Commit 2905bc6eb94f1210196150bd1179e8f2f9c5b827

Authored by Michel Felipe
Committed by Leandro Santos
1 parent 65ff2c7a

Check if add tag has an error and show a msg in task list

app/controllers/my_profile/tasks_controller.rb
... ... @@ -93,7 +93,8 @@ class TasksController < MyProfileController
93 93  
94 94 if request.post? && params[:tag_list]
95 95 result = {
96   - success: false
  96 + success: false,
  97 + message: _('Error to save tags. Please, contact the system admin')
97 98 }
98 99  
99 100 ActsAsTaggableOn.remove_unused_tags = true
... ...
app/views/tasks/index.html.erb
... ... @@ -78,8 +78,35 @@
78 78 activateFinalResult: true,
79 79 submitTags: {
80 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 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 537 url: requestTags.url,
538 538 dataType: 'json',
539 539 data:{},
540   - type:'POST'
  540 + type:'POST',
  541 + context:this
541 542 },requestTags);
542 543  
543 544 var extraValues = this.element.data('submit-values');
... ...