From 2905bc6eb94f1210196150bd1179e8f2f9c5b827 Mon Sep 17 00:00:00 2001 From: Michel Felipe Date: Sun, 31 May 2015 15:20:27 -0300 Subject: [PATCH] Check if add tag has an error and show a msg in task list --- app/controllers/my_profile/tasks_controller.rb | 3 ++- app/views/tasks/index.html.erb | 29 ++++++++++++++++++++++++++++- public/javascripts/inputosaurus.js | 3 ++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/controllers/my_profile/tasks_controller.rb b/app/controllers/my_profile/tasks_controller.rb index 0473342..74ae666 100644 --- a/app/controllers/my_profile/tasks_controller.rb +++ b/app/controllers/my_profile/tasks_controller.rb @@ -93,7 +93,8 @@ class TasksController < MyProfileController if request.post? && params[:tag_list] result = { - success: false + success: false, + message: _('Error to save tags. Please, contact the system admin') } ActsAsTaggableOn.remove_unused_tags = true diff --git a/app/views/tasks/index.html.erb b/app/views/tasks/index.html.erb index 69a433f..e6ee5c4 100644 --- a/app/views/tasks/index.html.erb +++ b/app/views/tasks/index.html.erb @@ -78,8 +78,35 @@ activateFinalResult: true, submitTags: { url: <%= "'/myprofile/#{profile.identifier}/tasks/save_tags'" %>, + beforeSend: function(){ + this.element.parents('.task_box') + .prev('.fg-state-error') + .remove(); + }, success: function(response){ - console.dir(response); + + this.element.parents('.task_box') + .prev('.fg-state-error') + .remove(); + + if(!response.success){ + + var errorIcon = $('',{ + 'class':'ui-icon ui-icon-alert', + style:'float: left; margin-right: .3em;' + }); + + var content = $('

',{ + html:''+response.message+'' + }).prepend(errorIcon); + + var div = $('

',{ + 'class':'alert fg-state-error ui-state-error' + }).append(content); + + this.element.parents('.task_box').before(div); + } + } } }) diff --git a/public/javascripts/inputosaurus.js b/public/javascripts/inputosaurus.js index 174d9c9..c38c20e 100644 --- a/public/javascripts/inputosaurus.js +++ b/public/javascripts/inputosaurus.js @@ -537,7 +537,8 @@ url: requestTags.url, dataType: 'json', data:{}, - type:'POST' + type:'POST', + context:this },requestTags); var extraValues = this.element.data('submit-values'); -- libgit2 0.21.2