Index: . =================================================================== --- . (revision 23) +++ . (working copy) Property changes on: . ___________________________________________________________________ Added: svn:mergeinfo ## -0,0 +0,1 ## Merged /branches/close_action:r21-23 Index: app/controllers/sprints_controller.rb =================================================================== --- app/controllers/sprints_controller.rb (revision 23) +++ app/controllers/sprints_controller.rb (working copy) @@ -18,7 +18,7 @@ :stats, :sort] before_filter :find_project_by_project_id, :only => [:index, :new, :create, :change_task_status, :burndown_index, - :stats_index] + :stats_index, :update_pbi_status] before_filter :find_pbis, :only => [:sort] before_filter :authorize @@ -111,11 +111,28 @@ @issue.due_date = Date.today end @issue.save! + + if @issue.is_pbi_task_closed? and + !(Scrum::Setting.action_when_all_task_closed.nil?) and + Scrum::Setting.action_when_all_task_closed.to_i == ActionCloseTask.actions[:ask_user] + @askuser = true + end + respond_to do |format| format.js { render 'scrum/update_task' } end end + def update_pbi_status + @pbi = Issue.find(params[:pbi].match(/^pbi_(\d+)$/)[1].to_i) + @pbi.status = IssueStatus.find(params[:status].to_i) + raise 'New status is not allowed' unless @pbi.new_statuses_allowed_to.include?(@pbi.status) + @pbi.save! + respond_to do |format| + format.js { render 'scrum/update_pbi' } + end + end + def edit_effort end Index: app/models/action_close_task.rb =================================================================== --- app/models/action_close_task.rb (nonexistent) +++ app/models/action_close_task.rb (working copy) @@ -0,0 +1,5 @@ +class ActionCloseTask < ActiveRecord::Base + + enum action: [ :ask_user, :close_pbi ] + +end \ No newline at end of file Index: app/views/scrum/_ask_user_modal.html.erb =================================================================== --- app/views/scrum/_ask_user_modal.html.erb (nonexistent) +++ app/views/scrum/_ask_user_modal.html.erb (working copy) @@ -0,0 +1,11 @@ +

<%= l(:label_ask_user_modal_title) %>

+ +
+ +

All the task are closed.

+

Do you want to close the parent pbi ?

+ +

+ <%= submit_tag l(:label_button_yes), :name => "Yes", :onclick => "UpdatePbiAndClose(this);", :type => "button" %> + <%= submit_tag l(:label_button_no), :name => nil, :onclick => "hideModal(this);", :type => "button" %> +

\ No newline at end of file Index: app/views/scrum/update_task.js.erb =================================================================== --- app/views/scrum/update_task.js.erb (revision 23) +++ app/views/scrum/update_task.js.erb (working copy) @@ -22,4 +22,29 @@ task.detach(); task.appendTo($("#<%= "pbi_#{@issue.parent_id}_status_#{@issue.status.id}" %>")); <%- end -%> +<%- end -%> +<%- if defined?(@askuser) -%> + $("#ajax-modal").html("<%= escape_javascript(render :partial => "scrum/ask_user_modal") %>"); + function UpdatePbiAndClose(modal){ + hideModal(modal); + if ($.isFunction($.fn.setupAjaxIndicator)) { + setupAjaxIndicator(); + } + $.ajax({ + url: "<%= project_sprints_update_pbi_status_path(@project) %>", + type: "POST", + data: {pbi: encodeURIComponent("pbi_<%= @issue.parent_id %>"), + status: encodeURIComponent("<%= @issue.status.id %>")}, + error: function() { + alert("<%= l(:error_changing_pbi_status) %>"); + location.reload(true); + }, + complete: function() { + if ($.isFunction($.fn.hideOnLoad)) { + hideOnLoad(); + } + } + }); + } + showModal("ajax-modal", "300px"); <%- end -%> \ No newline at end of file Index: app/views/settings/_scrum_settings.html.erb =================================================================== --- app/views/settings/_scrum_settings.html.erb (revision 23) +++ app/views/settings/_scrum_settings.html.erb (working copy) @@ -67,6 +67,12 @@ <%- options = options_for_select(statuses, Scrum::Setting.status_id_set_enddate) -%> <%= select_tag 'settings[status_id_set_enddate]', options, :include_blank => true %>

+

+ + <%- actions = ActionCloseTask.actions.map{|s| [l('label_setting_actions_' + s[0]), s[1]]} -%> + <%- options = options_for_select(actions, Scrum::Setting.action_when_all_task_closed) -%> + <%= select_tag 'settings[action_when_all_task_closed]', options, :include_blank => true %> +

Index: config/locales/en.yml =================================================================== --- config/locales/en.yml (revision 23) +++ config/locales/en.yml (working copy) @@ -19,6 +19,7 @@ error_no_sprints: "There are none Sprints defined yet, please ask this project administrator to create them in settings tab." error_updating_pbi: "Error updating the PBI (%{message})" error_updating_task: "Error updating the task (%{message})" + error_changing_pbi_status: "Failed to update the pbi status. The page will be reloaded" field_end_date: "End date" field_pending_effort: "Pending effort" field_position: "Position" @@ -99,6 +100,9 @@ label_setting_verification_activities: "Verification activities" label_setting_status_set_startdate: "Status that set the start date of the task" label_setting_status_set_enddate: "Status that set the end date of the task" + label_setting_action_when_all_task_closed: "Action to do when all task are closed" + label_setting_actions_ask_user: "Ask user" + label_setting_actions_close_pbi: "Close parent pbi" label_scrum: "Scrum" label_sprint: "Sprint" label_sprint_board: "Sprint board" @@ -152,6 +156,9 @@ label_velocity_custom: "Custom value:" label_velocity_only_scheduled_pbis: "Only scheduled ones" label_velocity_only_scheduled_pbis_hint: "This excludes from calculus any PBI created once the Sprint has started" + label_ask_user_modal_title: "Ask user about action" + label_button_yes: "Yes" + label_button_no: "No" notice_pbi_created: "The product backlog item was successfully created" notice_sprint_has_issues: "The Sprint has issues" notice_task_created: "The task was successfully created" @@ -169,7 +176,7 @@ permission_view_sprint_board: "View Sprint board" permission_view_sprint_burndown: "View Sprint burndown" permission_view_sprint_stats: "View Sprint stats" - permission_view_sprint_stats_by_member: "View Sprint stats by member" + permission_view_sprint_stats_by_member: "View Sprint stats by member" date: formats: scrum_day: "%a" Index: config/locales/fr.yml =================================================================== --- config/locales/fr.yml (revision 23) +++ config/locales/fr.yml (working copy) @@ -19,6 +19,7 @@ error_no_sprints: "Il n'y a aucun Sprint de défini pour le moment, merci de solliciter un administrateur du projet pour en créer dans l'onglet configuration." error_updating_pbi: "Erreur à la mise à jour du PBI (%{message})" error_updating_task: "Erreur à la mise à jour de la tâche (%{message})" + error_changing_pbi_status: "Impossible de mettre à jour le status du PBI. La page va être rechargée." field_end_date: "Fin" field_pending_effort: "Reste à faire" field_position: "Partagé" @@ -89,6 +90,9 @@ label_setting_verification_activities: "Vérification des activités" label_setting_status_set_startdate: "Statut qui ecrit la date de debut" label_setting_status_set_enddate: "Statut qui ecrit la date de fin" + label_setting_action_when_all_task_closed: "Action a effectuer lorsque toutes les taches sont fermées" + label_setting_actions_ask_user: "Demander a l'utilisateur" + label_setting_actions_close_pbi: "Fermer le PBI" label_scrum: "Scrum" label_sprint: "Sprint" label_sprint_board: "Tableau de bord du Sprint" Index: config/routes.rb =================================================================== --- config/routes.rb (revision 23) +++ config/routes.rb (working copy) @@ -26,6 +26,9 @@ post "sprints/change_task_status", :controller => :sprints, :action => :change_task_status, :as => :sprints_change_task_status + post "sprints/update_pbi_status", + :controller => :sprints, :action => :update_pbi_status, + :as => :sprints_update_pbi_status resources :product_backlog, :shallow => true do member do Index: init.rb =================================================================== --- init.rb (revision 23) +++ init.rb (working copy) @@ -45,7 +45,7 @@ permission :view_sprint_board, {:sprints => [:index, :show]} permission :edit_sprint_board, - {:sprints => [:change_task_status, :sort], + {:sprints => [:change_task_status, :update_pbi_status, :sort], :scrum => [:change_story_points, :change_pending_effort, :change_assigned_to, :new_pbi, :create_pbi, :edit_pbi, :update_pbi, :new_task, :create_task, :edit_task, :update_task]}, @@ -110,6 +110,7 @@ :high_speed => 140, :render_plugin_tips => '1', :status_id_set_startdate => nil, - :status_id_set_enddate => nil}, + :status_id_set_enddate => nil, + :action_when_all_task_closed => nil}, :partial => 'settings/scrum_settings' end Index: lib/scrum/issue_patch.rb =================================================================== --- lib/scrum/issue_patch.rb (revision 23) +++ lib/scrum/issue_patch.rb (working copy) @@ -323,6 +323,31 @@ end end + def is_pbi_task_new? + new_status = IssueStatus.task_statuses.first + pbi = self.parent + all_tasks_new = (self.status == new_status) + pbi.children.each do |task| + if task.is_task? + task = self if task.id == self.id + all_tasks_new = false if task.status != new_status + end + end + return all_tasks_new + end + + def is_pbi_task_closed? + pbi = self.parent + all_tasks_closed = (self.status.is_closed) + pbi.children.each do |task| + if task.is_task? + task = self if task.id == self.id + all_tasks_closed = false if !(task.status.is_closed) + end + end + return all_tasks_closed + end + protected def copy_attribute(source_issue, attribute) @@ -378,13 +403,9 @@ if new_status && in_progress_status pbi = self.parent if pbi and pbi.is_pbi? - all_tasks_new = (self.status == new_status) - pbi.children.each do |task| - if task.is_task? - task = self if task.id == self.id - all_tasks_new = false if task.status != new_status - end - end + all_tasks_new = self.is_pbi_task_new? + all_tasks_closed = self.is_pbi_task_closed? + if pbi.status == new_status and !all_tasks_new pbi.status = in_progress_status pbi.save! @@ -391,6 +412,15 @@ elsif pbi.status != new_status and all_tasks_new pbi.status = new_status pbi.save! + elsif pbi.status != new_status and all_tasks_closed + if !(Scrum::Setting.action_when_all_task_closed.nil?) and + Scrum::Setting.action_when_all_task_closed != "" + case Scrum::Setting.action_when_all_task_closed.to_i + when ActionCloseTask.actions[:close_pbi] + pbi.status = self.status + pbi.save! + end + end end end end Index: lib/scrum/setting.rb =================================================================== --- lib/scrum/setting.rb (revision 23) +++ lib/scrum/setting.rb (working copy) @@ -65,7 +65,8 @@ end %w(status_id_set_startdate - status_id_set_enddate).each do |setting| + status_id_set_enddate + action_when_all_task_closed).each do |setting| src = <<-END_SRC def self.#{setting} ::Setting.plugin_scrum[:#{setting}]