From 586b46661acebc05a82c01be972d0408315847e4 Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Fri, 25 Sep 2009 20:15:34 -0400 Subject: [PATCH] Projects page completely working now --- app/controllers/projects_controller.rb | 4 +++- public/javascripts/application.js | 27 ++++++++++++-------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index a175d9eb..e6ead846 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -173,7 +173,7 @@ class ProjectsController < ApplicationController end def order - project_ids = params["list-active-projects"] || params["list-hidden-projects"] || params["list-completed-projects"] + project_ids = params["container_project"] @projects = current_user.projects.update_positions( project_ids ) render :nothing => true rescue @@ -186,6 +186,7 @@ class ProjectsController < ApplicationController @projects = current_user.projects.alphabetize(:state => @state) if @state @contexts = current_user.contexts init_not_done_counts(['project']) + init_project_hidden_todo_counts(['project']) if @state == 'hidden' end def actionize @@ -193,6 +194,7 @@ class ProjectsController < ApplicationController @projects = current_user.projects.actionize(current_user.id, :state => @state) if @state @contexts = current_user.contexts init_not_done_counts(['project']) + init_project_hidden_todo_counts(['project']) if @state == 'hidden' end protected diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 74bbec13..c39d475a 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -229,6 +229,15 @@ function askIfNewContextProvided() { return confirm('New context "' + givenContextName + '" will be also created. Are you sure?'); } +function update_project_order(event, ui){ + container = $(ui.item).parent(); + project_display = $(ui.item).children('.project'); + $.post('/projects/order', + container.sortable("serialize"), + function(){project_display.effect('highlight', {}, 1000)}, + 'script'); +} + /* Unobtrusive jQuery behavior */ $(document).ready(function() { @@ -361,19 +370,7 @@ $(document).ready(function() { $(this).parents('.edit-form').find('form').clearForm(); }); - $("#list-active-projects").sortable({handle: '.handle', - /* -"#list-active-projects": function(event) { -Sortable.create("list-active-projects", {handle:'handle', onUpdate:function(){new Ajax.Request('/projects/order', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Highlight("list-active-projects",{});}, parameters:Sortable.serialize("list-active-projects") + '&authenticity_token=' + encodeURIComponent('1e046f4f2a85aa09451c6e17f902bf9a254868c6')})}, tag:'div'}) -}, -"#list-hidden-projects": function(event) { -Sortable.create("list-hidden-projects", {handle:'handle', onUpdate:function(){new Ajax.Request('/projects/order', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Highlight("list-hidden-projects",{});}, parameters:Sortable.serialize("list-hidden-projects") + '&authenticity_token=' + encodeURIComponent('1e046f4f2a85aa09451c6e17f902bf9a254868c6')})}, tag:'div'}) -}, -"#list-completed-projects": function(event) { -Sortable.create("list-completed-projects", {handle:'handle', onUpdate:function(){new Ajax.Request('/projects/order', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Highlight("list-completed-projects",{});}, parameters:Sortable.serialize("list-completed-projects") + '&authenticity_token=' + encodeURIComponent('1e046f4f2a85aa09451c6e17f902bf9a254868c6')})}, tag:'div'}) -}, - */ - update: function(event, ui){ - console.log(ui); - }}); + $("#list-active-projects").sortable({handle: '.handle', update: update_project_order}); + $("#list-hidden-projects").sortable({handle: '.handle', update: update_project_order}); + $("#list-completed-projects").sortable({handle: '.handle', update: update_project_order}); });