From 73bb53e1e5b8a7757a8f4d4a19e79e4afbf1a587 Mon Sep 17 00:00:00 2001 From: Carsten Otto Date: Sun, 12 Apr 2015 19:28:40 +0200 Subject: [PATCH 1/3] Still show action if it could not be added as predecessor If it is added as a predecessor, other code takes care to hide the action. For a very short time, barely noticeable, the action is shown moving back to its original position. See pull request #1777 --- app/assets/javascripts/tracks.js.erb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/assets/javascripts/tracks.js.erb b/app/assets/javascripts/tracks.js.erb index 1974af86..0163b8ce 100644 --- a/app/assets/javascripts/tracks.js.erb +++ b/app/assets/javascripts/tracks.js.erb @@ -301,7 +301,6 @@ var TodoItems = { /* Drag & Drop for successor/predecessor */ var dragged_todo = ui.draggable[0].id.split('_')[2]; var dropped_todo = this.id.split('_')[2]; - ui.draggable.remove(); $('.drop_target').hide(); // IE8 doesn't call stop() in this situation ajax_options = default_ajax_options_for_scripts('POST', relative_to_root('todos/add_predecessor'), $(this)); @@ -324,7 +323,7 @@ var TodoItems = { setup_drag_and_drop: function() { $('.item-show').draggable({ handle: '.grip', - revert: 'invalid', + revert: true, start: TodoItems.drag_todo, stop: function() { $('.drop_target').hide(); From fd8f4e2b32e5c238809768ad48705d5b15082cff Mon Sep 17 00:00:00 2001 From: Carsten Otto Date: Sun, 12 Apr 2015 19:56:58 +0200 Subject: [PATCH 2/3] Fix syntax --- app/controllers/todos_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index f54669f6..85839bcc 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -85,7 +85,7 @@ class TodosController < ApplicationController create_multiple else p = Todos::TodoCreateParamsHelper.new(params, current_user) - p.parse_dates() unless mobile? + p.parse_dates unless mobile? tag_list = p.tag_list @todo = current_user.todos.build @@ -1137,7 +1137,7 @@ end end def update_project - @project_changed = false; + @project_changed = false if params['todo']['project_id'].blank? && !params['project_name'].nil? if params['project_name'] == 'None' project = Project.null_object From bba13194fd7886c2cade971ccabd2cb6e5060dfc Mon Sep 17 00:00:00 2001 From: Carsten Otto Date: Mon, 13 Apr 2015 21:45:39 +0200 Subject: [PATCH 3/3] show dependency validation errors in action edit form --- app/controllers/todos_controller.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 85839bcc..fcc7805c 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -423,7 +423,16 @@ class TodosController < ApplicationController update_dependencies update_attributes_of_todo - @saved = @todo.save + begin + @saved = @todo.save! + rescue ActiveRecord::RecordInvalid => exception + record = exception.record + if record.is_a?(Dependency) + record.errors.each { |key,value| @todo.errors[key] << value } + end + @saved = false + end + # this is set after save and cleared after reload, so save it here @removed_predecessors = @todo.removed_predecessors