Commit 2905bc6eb94f1210196150bd1179e8f2f9c5b827
Committed by
Leandro Santos
1 parent
65ff2c7a
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Check if add tag has an error and show a msg in task list
Showing
3 changed files
with
32 additions
and
3 deletions
Show diff stats
app/controllers/my_profile/tasks_controller.rb
@@ -93,7 +93,8 @@ class TasksController < MyProfileController | @@ -93,7 +93,8 @@ class TasksController < MyProfileController | ||
93 | 93 | ||
94 | if request.post? && params[:tag_list] | 94 | if request.post? && params[:tag_list] |
95 | result = { | 95 | result = { |
96 | - success: false | 96 | + success: false, |
97 | + message: _('Error to save tags. Please, contact the system admin') | ||
97 | } | 98 | } |
98 | 99 | ||
99 | ActsAsTaggableOn.remove_unused_tags = true | 100 | ActsAsTaggableOn.remove_unused_tags = true |
app/views/tasks/index.html.erb
@@ -78,8 +78,35 @@ | @@ -78,8 +78,35 @@ | ||
78 | activateFinalResult: true, | 78 | activateFinalResult: true, |
79 | submitTags: { | 79 | submitTags: { |
80 | url: <%= "'/myprofile/#{profile.identifier}/tasks/save_tags'" %>, | 80 | url: <%= "'/myprofile/#{profile.identifier}/tasks/save_tags'" %>, |
81 | + beforeSend: function(){ | ||
82 | + this.element.parents('.task_box') | ||
83 | + .prev('.fg-state-error') | ||
84 | + .remove(); | ||
85 | + }, | ||
81 | success: function(response){ | 86 | success: function(response){ |
82 | - console.dir(response); | 87 | + |
88 | + this.element.parents('.task_box') | ||
89 | + .prev('.fg-state-error') | ||
90 | + .remove(); | ||
91 | + | ||
92 | + if(!response.success){ | ||
93 | + | ||
94 | + var errorIcon = $('<span/>',{ | ||
95 | + 'class':'ui-icon ui-icon-alert', | ||
96 | + style:'float: left; margin-right: .3em;' | ||
97 | + }); | ||
98 | + | ||
99 | + var content = $('<p/>',{ | ||
100 | + html:'<strong>'+response.message+'</strong>' | ||
101 | + }).prepend(errorIcon); | ||
102 | + | ||
103 | + var div = $('<div/>',{ | ||
104 | + 'class':'alert fg-state-error ui-state-error' | ||
105 | + }).append(content); | ||
106 | + | ||
107 | + this.element.parents('.task_box').before(div); | ||
108 | + } | ||
109 | + | ||
83 | } | 110 | } |
84 | } | 111 | } |
85 | }) | 112 | }) |
public/javascripts/inputosaurus.js
@@ -537,7 +537,8 @@ | @@ -537,7 +537,8 @@ | ||
537 | url: requestTags.url, | 537 | url: requestTags.url, |
538 | dataType: 'json', | 538 | dataType: 'json', |
539 | data:{}, | 539 | data:{}, |
540 | - type:'POST' | 540 | + type:'POST', |
541 | + context:this | ||
541 | },requestTags); | 542 | },requestTags); |
542 | 543 | ||
543 | var extraValues = this.element.data('submit-values'); | 544 | var extraValues = this.element.data('submit-values'); |