Commit 2e0b07f0b7684047ba8086e2e2158dfb0a92ba2d
1 parent
7b733153
Exists in
master
and in
9 other branches
added feature to allow confirm proposals individually
Showing
6 changed files
with
132 additions
and
67 deletions
Show diff stats
controllers/myprofile/proposals_discussion_plugin_confirm_tasks_controller.rb
0 → 100644
| @@ -0,0 +1,43 @@ | @@ -0,0 +1,43 @@ | ||
| 1 | +class ProposalsDiscussionPluginConfirmTasksController < MyProfileController | ||
| 2 | + protect :perform_task, :profile, :only => [:approve_proposal, :reprove_proposal] | ||
| 3 | + | ||
| 4 | + def approve_proposal | ||
| 5 | + result = {} | ||
| 6 | + if request.post? | ||
| 7 | + result = process_decision(params, :finish) | ||
| 8 | + end | ||
| 9 | + render json: result | ||
| 10 | + end | ||
| 11 | + | ||
| 12 | + def reprove_proposal | ||
| 13 | + result = {} | ||
| 14 | + if request.post? | ||
| 15 | + result = process_decision(params, :cancel) | ||
| 16 | + end | ||
| 17 | + render json: result | ||
| 18 | + end | ||
| 19 | + | ||
| 20 | +private | ||
| 21 | + | ||
| 22 | + def process_decision(params, decision) | ||
| 23 | + result = { | ||
| 24 | + success: false, | ||
| 25 | + message: _('Error flagging proposal. Please, contact the system admin') | ||
| 26 | + } | ||
| 27 | + if params[:task_id] and request.post? | ||
| 28 | + begin | ||
| 29 | + task = profile.find_in_all_tasks(params[:task_id]) | ||
| 30 | + task.tag_list = params[:tag_list] | ||
| 31 | + task.article_parent_id = params[:article_parent_id] | ||
| 32 | + task.email_template_id = params[:email_template_id] | ||
| 33 | + task.send(decision, current_person) | ||
| 34 | + result = {:success => true } | ||
| 35 | + rescue Exception => ex | ||
| 36 | + message = "#{task.title} (#{task.requestor ? task.requestor.name : task.author_name})" if task | ||
| 37 | + message = "#{message} #{ex.message}" | ||
| 38 | + result[:message] += ". #{message}" | ||
| 39 | + end | ||
| 40 | + return result | ||
| 41 | + end | ||
| 42 | + end | ||
| 43 | +end |
controllers/myprofile/proposals_discussion_plugin_evaluate_tasks_controller.rb
| 1 | class ProposalsDiscussionPluginEvaluateTasksController < MyProfileController | 1 | class ProposalsDiscussionPluginEvaluateTasksController < MyProfileController |
| 2 | + protect :view_tasks, :profile, :only => [:approve_proposal, :reprove_proposal] | ||
| 2 | 3 | ||
| 3 | - protect :view_tasks, :profile, :only => [:flag_approve_proposal, :flag_reject_proposal] | ||
| 4 | - | ||
| 5 | - def flag_approve_proposal | 4 | + def approve_proposal |
| 5 | + result = {} | ||
| 6 | if request.post? && params[:task_id] | 6 | if request.post? && params[:task_id] |
| 7 | result = { | 7 | result = { |
| 8 | success: false, | 8 | success: false, |
| 9 | message: _('Error flagging proposal. Please, contact the system admin') | 9 | message: _('Error flagging proposal. Please, contact the system admin') |
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | + | ||
| 12 | task = Task.to(profile).find_by_id params[:task_id] | 13 | task = Task.to(profile).find_by_id params[:task_id] |
| 13 | save = task.flag_accept_proposal(current_person) | 14 | save = task.flag_accept_proposal(current_person) |
| 14 | 15 | ||
| @@ -20,7 +21,8 @@ class ProposalsDiscussionPluginEvaluateTasksController < MyProfileController | @@ -20,7 +21,8 @@ class ProposalsDiscussionPluginEvaluateTasksController < MyProfileController | ||
| 20 | render json: result | 21 | render json: result |
| 21 | end | 22 | end |
| 22 | 23 | ||
| 23 | - def flag_reprove_proposal | 24 | + def reprove_proposal |
| 25 | + result = {} | ||
| 24 | if request.post? && params[:task_id] | 26 | if request.post? && params[:task_id] |
| 25 | result = { | 27 | result = { |
| 26 | success: false, | 28 | success: false, |
public/style.css
| @@ -326,6 +326,7 @@ form .proposals-discussion-plugin .body textarea { | @@ -326,6 +326,7 @@ form .proposals-discussion-plugin .body textarea { | ||
| 326 | width: auto; | 326 | width: auto; |
| 327 | float: left; | 327 | float: left; |
| 328 | padding: 5px; | 328 | padding: 5px; |
| 329 | + border: 1px solid #EEEEEE; | ||
| 329 | } | 330 | } |
| 330 | 331 | ||
| 331 | .evaluation_button img { | 332 | .evaluation_button img { |
| @@ -344,7 +345,8 @@ form .proposals-discussion-plugin .body textarea { | @@ -344,7 +345,8 @@ form .proposals-discussion-plugin .body textarea { | ||
| 344 | } | 345 | } |
| 345 | 346 | ||
| 346 | div.evaluation_button.checked { | 347 | div.evaluation_button.checked { |
| 347 | - border: 1px dotted black; | 348 | + border: 1px dashed black; |
| 349 | + background-color: white; | ||
| 348 | } | 350 | } |
| 349 | 351 | ||
| 350 | .evaluation_button.approval span { | 352 | .evaluation_button.approval span { |
| @@ -367,8 +369,9 @@ div.evaluation_button.checked { | @@ -367,8 +369,9 @@ div.evaluation_button.checked { | ||
| 367 | } | 369 | } |
| 368 | 370 | ||
| 369 | div.confirm_evaluation_button a { | 371 | div.confirm_evaluation_button a { |
| 370 | - text-decoration: none; | 372 | + text-decoration: underline; |
| 371 | color: #003366; | 373 | color: #003366; |
| 374 | + font-size: 28px; | ||
| 372 | } | 375 | } |
| 373 | 376 | ||
| 374 | div.confirm_evaluation_button a:hover { | 377 | div.confirm_evaluation_button a:hover { |
views/proposals_discussion_plugin_tasks/_task.html.erb
| @@ -19,28 +19,6 @@ | @@ -19,28 +19,6 @@ | ||
| 19 | </div> | 19 | </div> |
| 20 | <% end %> | 20 | <% end %> |
| 21 | 21 | ||
| 22 | - <div class="task_decisions"> | ||
| 23 | - <% unless @view_only %> | ||
| 24 | - <%= | ||
| 25 | - labelled_radio_button(_("Accept"), "tasks[#{task.id}][decision]", 'finish', task.flagged_for_approval? || task.default_decision == 'accept', | ||
| 26 | - :id => "decision-finish-#{task.id}", | ||
| 27 | - :class => 'task_accept_radio', | ||
| 28 | - :disabled => task.accept_disabled?, | ||
| 29 | - :task_id => "#{task.id}") + | ||
| 30 | - labelled_radio_button(_("Reject"), "tasks[#{task.id}][decision]", 'cancel', task.flagged_for_reproval? || task.default_decision == 'reject', | ||
| 31 | - :id => "decision-cancel-#{task.id}", | ||
| 32 | - :class => 'task_reject_radio', | ||
| 33 | - :disabled => task.reject_disabled?, | ||
| 34 | - :task_id => "#{task.id}") + | ||
| 35 | - labelled_radio_button(_("Skip"), "tasks[#{task.id}][decision]", 'skip', task.default_decision == 'skip' && task.unflagged?, | ||
| 36 | - :id => "decision-skip-#{task.id}", | ||
| 37 | - :class => 'task_skip_radio', | ||
| 38 | - :disabled => task.skip_disabled?, | ||
| 39 | - :task_id => "#{task.id}") | ||
| 40 | - %> | ||
| 41 | - <% end %> | ||
| 42 | - </div><!-- class="task_decisions" --> | ||
| 43 | - | ||
| 44 | <div class="task_date"><%= show_time(task.created_at) %></div> | 22 | <div class="task_date"><%= show_time(task.created_at) %></div> |
| 45 | 23 | ||
| 46 | <%= render :partial => 'task_title', :locals => {:task => task} %> | 24 | <%= render :partial => 'task_title', :locals => {:task => task} %> |
| @@ -49,59 +27,60 @@ | @@ -49,59 +27,60 @@ | ||
| 49 | <%= task_information(task) %> | 27 | <%= task_information(task) %> |
| 50 | </div> | 28 | </div> |
| 51 | 29 | ||
| 52 | - | ||
| 53 | - <%= fields_for "tasks[#{task.id}][task]", task do |f| %> | ||
| 54 | - <% if task.accept_details and !@view_only %> | ||
| 55 | - <div id="on-accept-information-<%=task.id%>" style="display: none"> | ||
| 56 | - <%= render :partial => partial_for_class(task.class, nil, :accept_details), :locals => {:task => task, :f => f} %> | ||
| 57 | - </div> | ||
| 58 | - <% end %> | ||
| 59 | - | ||
| 60 | - <% if task.reject_details and !@view_only %> | ||
| 61 | - <div id="on-reject-information-<%=task.id%>" style="display: none"> | ||
| 62 | - <%= render :partial => partial_for_class(task.class, nil, :reject_details), :locals => {:task => task, :f => f} %> | ||
| 63 | - </div> | ||
| 64 | - <% end %> | ||
| 65 | - | ||
| 66 | - <% if @view_only %> | ||
| 67 | - <div class="evaluation_toolbar"> | 30 | + <div class="evaluation_toolbar"> |
| 68 | <div class="evaluation_button approval" | 31 | <div class="evaluation_button approval" |
| 69 | data-url='<%="/myprofile/#{profile.identifier}/plugin/proposals_discussion/evaluate_tasks/flag_approve_proposal"%>' | 32 | data-url='<%="/myprofile/#{profile.identifier}/plugin/proposals_discussion/evaluate_tasks/flag_approve_proposal"%>' |
| 70 | data-task-id="<%= task.id %>" | 33 | data-task-id="<%= task.id %>" |
| 71 | - data-flag-action="flag_approve_proposal"> | 34 | + data-flag-action="approve_proposal"> |
| 72 | <img class="" src="/plugins/proposals_discussion/images/approval.png"> | 35 | <img class="" src="/plugins/proposals_discussion/images/approval.png"> |
| 73 | <span>Aprovar</span> | 36 | <span>Aprovar</span> |
| 74 | </div> | 37 | </div> |
| 75 | <div id="evaluation_button_#{task.id}" class="evaluation_button reproval" | 38 | <div id="evaluation_button_#{task.id}" class="evaluation_button reproval" |
| 76 | data-url='<%="/myprofile/#{profile.identifier}/plugin/proposals_discussion/evaluate_tasks/flag_reject_proposal"%>' | 39 | data-url='<%="/myprofile/#{profile.identifier}/plugin/proposals_discussion/evaluate_tasks/flag_reject_proposal"%>' |
| 77 | - data-task-id="<%= task.id %>" data-flag-action="flag_reprove_proposal"> | 40 | + data-task-id="<%= task.id %>" data-flag-action="reprove_proposal"> |
| 78 | <img class="" src="/plugins/proposals_discussion/images/reproval.png"> | 41 | <img class="" src="/plugins/proposals_discussion/images/reproval.png"> |
| 79 | <span>Reprovar</span> | 42 | <span>Reprovar</span> |
| 80 | </div> | 43 | </div> |
| 81 | </div> | 44 | </div> |
| 82 | - <% end %> | ||
| 83 | - <%#= select_tag "tasks[#{task.id}][setting][evaluation_flag]", | ||
| 84 | - options_for_select( | ||
| 85 | - [_('FLAGGED_FOR_APPROVAL'),_('FLAGGED_FOR_REPROVAL')],(task.flagged_status.present? ? task.flagged_status : nil) | ||
| 86 | - ), | ||
| 87 | - { | ||
| 88 | - :include_blank => true, | ||
| 89 | - :onchange => "change_flagged_status(this);", | ||
| 90 | - 'data-old-responsible' => task.flagged_status.present? ? task.flagged_status.id : nil, | ||
| 91 | - 'data-task' => task.id, 'data-url' => 'change_flagged_status_url' | ||
| 92 | - } %> | ||
| 93 | - | ||
| 94 | - | ||
| 95 | - <div class="formfieldline"> | ||
| 96 | - <div class="formfield tag-list-fields"> | ||
| 97 | - <%= labelled_text_field(_('Tags'),"tasks[#{task.id}][task][tag_list]", task.tags_from(nil).to_s, :size => 36, :class => 'tag-list','data-submit-values'=>"{'task_id':'#{task.id}'}") %> | 45 | + |
| 46 | + | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + <%= fields_for "tasks[#{task.id}][task]", task do |f| %> | ||
| 50 | + <% if task.accept_details %> | ||
| 51 | + <div id="on-accept-information-<%=task.id%>" style="display: none"> | ||
| 52 | + <%= render :partial => partial_for_class(task.class, nil, :accept_details), :locals => {:task => task, :f => f} %> | ||
| 53 | + </div> | ||
| 54 | + <% end %> | ||
| 55 | + | ||
| 56 | + <% if task.reject_details %> | ||
| 57 | + <div id="on-reject-information-<%=task.id%>" style="display: none"> | ||
| 58 | + <%= render :partial => partial_for_class(task.class, nil, :reject_details), :locals => {:task => task, :f => f} %> | ||
| 59 | + </div> | ||
| 60 | + <% end %> | ||
| 61 | + | ||
| 62 | + <div class="formfieldline"> | ||
| 63 | + <div class="formfield tag-list-fields"> | ||
| 64 | + <%= labelled_text_field(_('Tags'),"tasks[#{task.id}][task][tag_list]", task.tags_from(nil).to_s, :size => 36, :class => 'tag-list','data-submit-values'=>"{'task_id':'#{task.id}'}") %> | ||
| 65 | + </div> | ||
| 98 | </div> | 66 | </div> |
| 67 | + | ||
| 68 | + <% end %> | ||
| 69 | + | ||
| 70 | + <% unless @view_only #MODERATOR VIEW %> | ||
| 71 | + <div class="confirm_evaluation_toolbar"> | ||
| 72 | + <div class="confirm_evaluation_button"> | ||
| 73 | + <a data-task-id="<%= task.id %>" class="disabled" href="#task-<%= task.id %>" | ||
| 74 | + data-href='<%="/myprofile/#{profile.identifier}/plugin/proposals_discussion/confirm_tasks"%>'>Confirmar</span> | ||
| 99 | </div> | 75 | </div> |
| 76 | + </div> | ||
| 77 | + <% end %> | ||
| 100 | 78 | ||
| 79 | + <% if @view_only # EVALUATOR VIEW %> | ||
| 101 | <div class="confirm_evaluation_toolbar"> | 80 | <div class="confirm_evaluation_toolbar"> |
| 102 | <div class="confirm_evaluation_button"> | 81 | <div class="confirm_evaluation_button"> |
| 103 | <a data-task-id="<%= task.id %>" class="disabled" href="#task-<%= task.id %>" | 82 | <a data-task-id="<%= task.id %>" class="disabled" href="#task-<%= task.id %>" |
| 104 | - data-href='<%="/myprofile/#{profile.identifier}/plugin/proposals_discussion/evaluate_tasks/"%>'>Confirmar</span> | 83 | + data-href='<%="/myprofile/#{profile.identifier}/plugin/proposals_discussion/evaluate_tasks"%>'>Confirmar</span> |
| 105 | </div> | 84 | </div> |
| 106 | </div> | 85 | </div> |
| 107 | 86 |
views/proposals_discussion_plugin_tasks/_task_accept_details.html.erb
| @@ -0,0 +1,5 @@ | @@ -0,0 +1,5 @@ | ||
| 1 | +<% unless @view_only %> | ||
| 2 | + <%= f.fields_for 'article', OpenStruct.new(task.article) do |a| %> | ||
| 3 | + <%= select_profile_folder(_('Select the folder where the article must be published'), "tasks[#{task.id}][task][article_parent_id]", task.target, task.article[:parent_id]) %> | ||
| 4 | + <% end %> | ||
| 5 | +<% end %> |
views/proposals_discussion_plugin_tasks/index.html.erb
| @@ -128,9 +128,31 @@ | @@ -128,9 +128,31 @@ | ||
| 128 | 128 | ||
| 129 | taskElement.find('div.confirm_evaluation_button a').removeClass('disabled'); | 129 | taskElement.find('div.confirm_evaluation_button a').removeClass('disabled'); |
| 130 | 130 | ||
| 131 | - $(el).addClass("checked"); | 131 | + var checkedButton = $(el); |
| 132 | + checkedButton.addClass("checked"); | ||
| 133 | + | ||
| 134 | + var flag_action = checkedButton.data('flag-action'); | ||
| 135 | + var animation_options = {duration:'fast', queue: true}; | ||
| 136 | + if(flag_action == 'approve_proposal'){ | ||
| 137 | + $('#on-reject-information-' + task_id).hide(animation_options); | ||
| 138 | + $('#on-skip-information-' + task_id).hide(animation_options); | ||
| 139 | + $('#on-accept-information-' + task_id).show(animation_options); | ||
| 140 | + | ||
| 141 | + } else if(flag_action == 'reprove_proposal') { | ||
| 142 | + $('#on-skip-information-' + task_id).hide(animation_options); | ||
| 143 | + $('#on-accept-information-' + task_id) | ||
| 144 | + .hide( | ||
| 145 | + { | ||
| 146 | + duration:'fast', | ||
| 147 | + complete: function() { | ||
| 148 | + $('#on-reject-information-' + task_id).show('fast'); | ||
| 149 | + } | ||
| 150 | + }); | ||
| 151 | + | ||
| 152 | + } | ||
| 132 | } | 153 | } |
| 133 | 154 | ||
| 155 | + | ||
| 134 | function evaluate_task(el) { | 156 | function evaluate_task(el) { |
| 135 | 157 | ||
| 136 | if($(el).hasClass('disabled')) { | 158 | if($(el).hasClass('disabled')) { |
| @@ -147,10 +169,21 @@ | @@ -147,10 +169,21 @@ | ||
| 147 | 169 | ||
| 148 | var flag_action = checkedButton.data('flag-action'); | 170 | var flag_action = checkedButton.data('flag-action'); |
| 149 | 171 | ||
| 172 | + var form = $(el).closest("form"); | ||
| 173 | + | ||
| 174 | + var tag_list = form.find("input.tag-list[type='text']").val(); | ||
| 175 | + | ||
| 150 | var params = { | 176 | var params = { |
| 151 | - task_id: task_id | 177 | + task_id: task_id, |
| 178 | + tag_list: tag_list | ||
| 152 | }; | 179 | }; |
| 153 | 180 | ||
| 181 | + if(flag_action == 'approve_proposal'){ | ||
| 182 | + params['article_parent_id'] = form.find('#tasks_' + task_id + '_task_article_parent_id').val(); | ||
| 183 | + } else if(flag_action == 'reprove_proposal') { | ||
| 184 | + params['email_template_id'] = form.find('#tasks_' + task_id + '_task_email_template_id').val(); | ||
| 185 | + } | ||
| 186 | + | ||
| 154 | jQuery.post(url + "/" + flag_action, params , | 187 | jQuery.post(url + "/" + flag_action, params , |
| 155 | function(data) { | 188 | function(data) { |
| 156 | if (data.success) { | 189 | if (data.success) { |
| @@ -159,8 +192,8 @@ | @@ -159,8 +192,8 @@ | ||
| 159 | } else { | 192 | } else { |
| 160 | $(el).effect("highlight", {color: 'red'}); | 193 | $(el).effect("highlight", {color: 'red'}); |
| 161 | } | 194 | } |
| 162 | - if (data.notice) { | ||
| 163 | - display_notice(data.notice); | 195 | + if (data.message) { |
| 196 | + display_notice(data.message); | ||
| 164 | } | 197 | } |
| 165 | }); | 198 | }); |
| 166 | } | 199 | } |