mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-28 21:08:48 +01:00
make project settings editable from the project page
We're using the edit form instead of several separate fields to edit settings
This commit is contained in:
parent
66833829a0
commit
b990f8a015
14 changed files with 150 additions and 169 deletions
|
|
@ -9,14 +9,15 @@ class ProjectsController < ApplicationController
|
|||
session :off, :only => :index, :if => Proc.new { |req| ['rss','atom','txt'].include?(req.parameters[:format]) }
|
||||
|
||||
def index
|
||||
@projects = current_user.projects(true)
|
||||
@source_view = params['_source_view'] || 'project_list'
|
||||
@projects = current_user.projects
|
||||
if params[:projects_and_actions]
|
||||
projects_and_actions
|
||||
else
|
||||
@contexts = current_user.contexts(true)
|
||||
@contexts = current_user.contexts
|
||||
init_not_done_counts(['project'])
|
||||
if params[:only_active_with_no_next_actions]
|
||||
@projects = @projects.select { |p| p.active? && count_undone_todos(p) == 0 }
|
||||
@projects = current_user.projects.active.select { |p| count_undone_todos(p) == 0 }
|
||||
end
|
||||
init_project_hidden_todo_counts(['project'])
|
||||
respond_to do |format|
|
||||
|
|
@ -31,7 +32,7 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def projects_and_actions
|
||||
@projects = @projects.active
|
||||
@projects = current_user.projects.active
|
||||
respond_to do |format|
|
||||
format.text {
|
||||
render :action => 'index_text_projects_and_actions', :layout => false, :content_type => Mime::TEXT
|
||||
|
|
@ -40,24 +41,19 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@contexts = current_user.contexts(true)
|
||||
init_data_for_sidebar unless mobile?
|
||||
@projects = current_user.projects
|
||||
@contexts = current_user.contexts
|
||||
@page_title = "TRACKS::Project: #{@project.name}"
|
||||
@project.todos.send :with_scope, :find => { :include => [:context] } do
|
||||
@not_done = @project.not_done_todos(:include_project_hidden_todos => true)
|
||||
@deferred = @project.deferred_todos.sort_by { |todo| todo.show_from }
|
||||
@done = @project.done_todos
|
||||
end
|
||||
|
||||
@max_completed = current_user.prefs.show_number_completed
|
||||
init_data_for_sidebar unless mobile?
|
||||
@page_title = "TRACKS::Project: #{@project.name}"
|
||||
|
||||
@not_done = @project.not_done_todos_including_hidden
|
||||
@deferred = @project.deferred_todos
|
||||
@done = @project.todos.find_in_state(:all, :completed, :order => "todos.completed_at DESC", :limit => current_user.prefs.show_number_completed, :include => [:context])
|
||||
|
||||
@count = @not_done.size
|
||||
@down_count = @count + @deferred.size
|
||||
@next_project = current_user.projects.next_from(@project)
|
||||
@previous_project = current_user.projects.previous_from(@project)
|
||||
@default_project_context_name_map = build_default_project_context_name_map(@projects).to_json
|
||||
@default_project_context_name_map = build_default_project_context_name_map(current_user.projects).to_json
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.m &render_project_mobile
|
||||
|
|
@ -70,7 +66,7 @@ class ProjectsController < ApplicationController
|
|||
# -u username:password
|
||||
# -d '<request><project><name>new project_name</name></project></request>'
|
||||
# http://our.tracks.host/projects
|
||||
#
|
||||
#
|
||||
def create
|
||||
if params[:format] == 'application/xml' && params['exception']
|
||||
render_failure "Expected post format is valid xml like so: <request><project><name>project name</name></project></request>."
|
||||
|
|
@ -102,7 +98,7 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
# Edit the details of the project
|
||||
#
|
||||
#
|
||||
def update
|
||||
params['project'] ||= {}
|
||||
if params['project']['state']
|
||||
|
|
@ -121,10 +117,10 @@ class ProjectsController < ApplicationController
|
|||
if boolean_param('wants_render')
|
||||
if (@project.hidden?)
|
||||
@project_project_hidden_todo_counts = Hash.new
|
||||
@project_project_hidden_todo_counts[@project.id] = @project.reload().not_done_todo_count(:include_project_hidden_todos => true)
|
||||
@project_project_hidden_todo_counts[@project.id] = @project.reload().not_done_todos_including_hidden.count
|
||||
else
|
||||
@project_not_done_counts = Hash.new
|
||||
@project_not_done_counts[@project.id] = @project.reload().not_done_todo_count(:include_project_hidden_todos => true)
|
||||
@project_not_done_counts[@project.id] = @project.reload().not_done_todos_including_hidden.count
|
||||
end
|
||||
@contexts = current_user.contexts
|
||||
@active_projects_count = current_user.projects.active.count
|
||||
|
|
@ -159,7 +155,6 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def edit
|
||||
@contexts = current_user.contexts
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
|
@ -205,11 +200,11 @@ class ProjectsController < ApplicationController
|
|||
lambda do
|
||||
@page_title = "TRACKS::List Projects"
|
||||
@count = current_user.projects.size
|
||||
@active_projects = @projects.active
|
||||
@hidden_projects = @projects.hidden
|
||||
@completed_projects = @projects.completed
|
||||
@no_projects = @projects.empty?
|
||||
@projects.cache_note_counts
|
||||
@active_projects = current_user.projects.active
|
||||
@hidden_projects = current_user.projects.hidden
|
||||
@completed_projects = current_user.projects.completed
|
||||
@no_projects = current_user.projects.empty?
|
||||
current_user.projects.cache_note_counts
|
||||
@new_project = current_user.projects.build
|
||||
render
|
||||
end
|
||||
|
|
@ -297,4 +292,4 @@ class ProjectsController < ApplicationController
|
|||
project_description
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue