From d1ec4b59aa22b8477f8d672ee994aff43cb82385 Mon Sep 17 00:00:00 2001 From: gilles orsini Date: Wed, 21 Nov 2018 22:42:25 +0100 Subject: [PATCH 01/14] initial context based --- README.rdoc | 2 +- TODO | 23 ----- app/controllers/ctrl_controller.rb | 5 ++ app/controllers/plan_controller.rb | 30 ------- app/helpers/ctrl_helper.rb | 2 + app/helpers/issue_plan_helper.rb | 2 - app/helpers/plan_helper.rb | 2 - app/views/ctrl/index.html.erb | 2 + app/views/plan/index.html.erb | 2 - app/views/plan/show.html.erb | 89 ------------------- assets/javascripts/plan.js | 1 - assets/stylesheets/plan.css | 43 --------- config/routes.rb | 5 +- init.rb | 15 +--- lib/issue_patch.rb.temp | 18 ---- lib/taskplan_hook_listener.rb | 15 ++++ ...roller_test.rb => ctrl_controller_test.rb} | 2 +- test/functional/issue_plan_controller_test.rb | 8 -- 18 files changed, 30 insertions(+), 236 deletions(-) delete mode 100644 TODO create mode 100644 app/controllers/ctrl_controller.rb delete mode 100644 app/controllers/plan_controller.rb create mode 100644 app/helpers/ctrl_helper.rb delete mode 100644 app/helpers/issue_plan_helper.rb delete mode 100644 app/helpers/plan_helper.rb create mode 100644 app/views/ctrl/index.html.erb delete mode 100644 app/views/plan/index.html.erb delete mode 100644 app/views/plan/show.html.erb delete mode 100644 assets/javascripts/plan.js delete mode 100644 assets/stylesheets/plan.css delete mode 100644 lib/issue_patch.rb.temp create mode 100644 lib/taskplan_hook_listener.rb rename test/functional/{plan_controller_test.rb => ctrl_controller_test.rb} (72%) delete mode 100644 test/functional/issue_plan_controller_test.rb diff --git a/README.rdoc b/README.rdoc index 4042c0d..0fc3059 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,3 +1,3 @@ -= plan += taskplan_redmine_plugin Description goes here diff --git a/TODO b/TODO deleted file mode 100644 index 66424ae..0000000 --- a/TODO +++ /dev/null @@ -1,23 +0,0 @@ -todo - -ameliorer ui -feature : notes, gerer mode saisie et mode rendu -feature : notes, avoir la derniere, la prochaine, et un moyen de les afficher toutes en consultation. -feature : rajouter edition précédente notes -indentation des taches pour montrer le niveau -bug : quand on choisit assigner à nobody -bug : on ne devrait pas pouvoir changer l'état et l'échéance d'une tache qui a une fille -bug : si pas connecté, le statut n’apparaît pas -bug : notes d'une nouvelle tache ne se sauvegarde pas -pouvoir rajouter une sous-tache sous un sous-tache -bug : gérer les erreurs lors de la sauvegarde (retour en mode grid) -retirer les boutons submit quand on rajoute une sous-tache -feature : pouvoir ordonner les taches -filtrer les taches par niveau - -test -modification -changer tous les champs -création -création à différent niveau -vérifier retour à la vue plan après modification ou création diff --git a/app/controllers/ctrl_controller.rb b/app/controllers/ctrl_controller.rb new file mode 100644 index 0000000..8ed6cdd --- /dev/null +++ b/app/controllers/ctrl_controller.rb @@ -0,0 +1,5 @@ +class CtrlController < ApplicationController + def index + @toto = "22" + end +end diff --git a/app/controllers/plan_controller.rb b/app/controllers/plan_controller.rb deleted file mode 100644 index 1e5ac3e..0000000 --- a/app/controllers/plan_controller.rb +++ /dev/null @@ -1,30 +0,0 @@ -class PlanController < IssuesController - - #before_action :find_issue, :only => [:show, :subtask] - skip_before_action :authorize, :only => [:subtask, :show] - - helper :issues - - def index - end - - def show - #byebug - @issuePlan = @issue.descendants.visible.preload(:status, :priority, :tracker, :assigned_to) - @backUrl = request.original_url - end - - def subtask - #byebug - build_new_issue_from_params - issue_to_add = @issue - issue_to_add.parent_id = params[:id] - find_issue - issue_to_edit = @issue - @issuePlan = @issue.descendants.visible.preload(:status, :priority, :tracker, :assigned_to) - @issuePlan << issue_to_add - logger.debug "goi:subtask #{edit_plan_path}" - @backUrl = edit_plan_path - render "show" - end -end diff --git a/app/helpers/ctrl_helper.rb b/app/helpers/ctrl_helper.rb new file mode 100644 index 0000000..b3b1668 --- /dev/null +++ b/app/helpers/ctrl_helper.rb @@ -0,0 +1,2 @@ +module CtrlHelper +end diff --git a/app/helpers/issue_plan_helper.rb b/app/helpers/issue_plan_helper.rb deleted file mode 100644 index d9f0516..0000000 --- a/app/helpers/issue_plan_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module IssuePlanHelper -end diff --git a/app/helpers/plan_helper.rb b/app/helpers/plan_helper.rb deleted file mode 100644 index 08c1767..0000000 --- a/app/helpers/plan_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module PlanHelper -end diff --git a/app/views/ctrl/index.html.erb b/app/views/ctrl/index.html.erb new file mode 100644 index 0000000..d5023bf --- /dev/null +++ b/app/views/ctrl/index.html.erb @@ -0,0 +1,2 @@ +

goi2

+<%= @toto %> \ No newline at end of file diff --git a/app/views/plan/index.html.erb b/app/views/plan/index.html.erb deleted file mode 100644 index 2075eaf..0000000 --- a/app/views/plan/index.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

Liste des plans d'actions

-plan d'action 3 diff --git a/app/views/plan/show.html.erb b/app/views/plan/show.html.erb deleted file mode 100644 index cf87894..0000000 --- a/app/views/plan/show.html.erb +++ /dev/null @@ -1,89 +0,0 @@ -<% content_for :header_tags do %> - <%= stylesheet_link_tag 'plan.css', :plugin => 'plan' %> -<% end %> - -

Plan d'action en détail

- -
- <%= link_to_issue(@issue) %> - - <%= l(:label_updated_time, time_tag(@issue.updated_on)).html_safe %>. -
- - <% issue_list(@issuePlan) do |child, level| %> - - <%= form_for child do %> - - - - - - - - <% end %> - - <% end %> -
<%= link_to_issue(child, :project => (@issue.project_id != child.project_id), - :subject => false, :tracker => false) if child.id %><%= text_field_tag('issue[subject]', child.subject) %> - <%= select_tag('issue[status_id]', - options_from_collection_for_select(child.new_statuses_allowed_to(User.current), :id, :name, child.status_id), - :onchange => "") %> - - <%= select_tag('issue[assigned_to_id]', - content_tag('option', l(:label_nobody), :value => 'none') + - principals_options_for_select(child.assignable_users, child.assigned_to)) %> - - <%= select_tag('issue[priority_id]', - options_from_collection_for_select(IssuePriority.active, :id, :name, child.priority_id)) %> - - <%= date_field_tag 'issue[due_date]', '', :value => child.due_date, :size => 10 %><%= calendar_for('issue_due_date') %> - - <% notes = child.journals.where.not(notes: '').reorder(:id => :desc).to_a %> - <% lastNote = notes.shift %> -
- Nouveau commentaire - <%= text_area_tag 'issue[notes]' %> -
- <% if lastNote %> -
- <%= format_time(lastNote.created_on) if lastNote %> - <%= textilizable(lastNote.notes) if lastNote %> -
- <% end %> - <% if notes.any? %> - Notes plus anciennes - - <% end %> -
- <%= submit_tag l(:button_save) %> - <%= link_to l(:button_delete), issue_path(child, :back_url => @backUrl), - :data => {:confirm => issues_destroy_confirmation_message(child)}, - :method => :delete, :class => 'icon icon-del' if child.id and child.deletable? %> - <%= hidden_field_tag('back_url', @backUrl) %> - <%= hidden_field_tag('issue[project_id]', child.project_id) %> - <%= hidden_field_tag('issue[parent_issue_id]', child.parent_id) %> -
- - -<%= button_to :add_task, subtask_path, method: :get %> - - diff --git a/assets/javascripts/plan.js b/assets/javascripts/plan.js deleted file mode 100644 index 168cf73..0000000 --- a/assets/javascripts/plan.js +++ /dev/null @@ -1 +0,0 @@ -alert('goi2') diff --git a/assets/stylesheets/plan.css b/assets/stylesheets/plan.css deleted file mode 100644 index 15bdac6..0000000 --- a/assets/stylesheets/plan.css +++ /dev/null @@ -1,43 +0,0 @@ -table.plan { - width: 100%; - border-spacing: 0; -} - -table.plan td { - vertical-align: baseline; -} - -table.plan fieldset { - height: 100%; - border: solid 1px #628db6; -} - -table.plan td:nth-child(6) { - width: 30%; -} - -table.plan td:nth-child(8) { - vertical-align: top; - width: 40%; -} - -table.plan tr:nth-child(even) { - background: #dae1ef; -} - -table.plan tr:nth-child(odd) { - background: #f5f5f5; -} - -table.plan td.block_button select { - display: block; - width: 100%; -} - -table.plan textarea { - width: 99%; -} - -table.plan input#issue_subject { - width: 95% -} diff --git a/config/routes.rb b/config/routes.rb index e995611..d9b3d7f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,3 @@ # Plugin's routes # See: http://guides.rubyonrails.org/routing.html -get 'plan', to: 'plan#index' -get 'plan/:id/new', to: 'plan#new' -get 'issues/:id/plan', to: 'plan#show', as: 'edit_plan' -get 'issues/:id/plan/new', to: 'plan#subtask', as: 'subtask' +get 'taskplan', :to => 'ctrl#index' diff --git a/init.rb b/init.rb index 83fa70c..5cb861a 100644 --- a/init.rb +++ b/init.rb @@ -1,19 +1,10 @@ -#require_dependency 'issue_patch' +require_dependency 'taskplan_hook_listener' -Redmine::Plugin.register :plan do - name 'Plan plugin' +Redmine::Plugin.register :taskplan_redmine_plugin do + name 'Taskplan Redmine Plugin plugin' author 'Author name' description 'This is a plugin for Redmine' version '0.0.1' url 'http://example.com/path/to/plugin' author_url 'http://example.com/about' - - project_module :plan do - permission :add_subtask, :subtask => :new - end - - permission :plan, { :plan => [:index] }, :public => true - menu :project_menu, :plan, { :controller => 'plan', :action => 'index' }, :caption => 'Plan' end - -#logger.debug "goi:init.rb" diff --git a/lib/issue_patch.rb.temp b/lib/issue_patch.rb.temp deleted file mode 100644 index d541254..0000000 --- a/lib/issue_patch.rb.temp +++ /dev/null @@ -1,18 +0,0 @@ -require_dependency 'issues_controller' - -module IssuePatch - - def subtask - logger.debug("goi:subtask") - params[:action => "new"] - find_optional_project - logger.debug "goi:subtask #{@project}" - build_new_issue_from_params - render "plan/toto", layout: false - end - -end - -print "goi:issue_patch" - -IssuesController.send(:include, IssuePatch) diff --git a/lib/taskplan_hook_listener.rb b/lib/taskplan_hook_listener.rb new file mode 100644 index 0000000..97c4bae --- /dev/null +++ b/lib/taskplan_hook_listener.rb @@ -0,0 +1,15 @@ +require 'byebug' + +class TaskplanHookListener < Redmine::Hook::ViewListener + include IssuesHelper + def view_issues_context_menu_start(context = {}) + #byebug + issue = context[:issues][0] + attrs = { + :parent_issue_id => issue + } + attrs[:tracker_id] = issue.tracker unless issue.tracker.disabled_core_fields.include?('parent_issue_id') + l = link_to("new subtask", new_project_issue_path(issue.project, :issue => attrs, :back_url => issue_path(issue))) + return "
  • " + l + "
  • " + end + end \ No newline at end of file diff --git a/test/functional/plan_controller_test.rb b/test/functional/ctrl_controller_test.rb similarity index 72% rename from test/functional/plan_controller_test.rb rename to test/functional/ctrl_controller_test.rb index 89b424f..1b427fc 100644 --- a/test/functional/plan_controller_test.rb +++ b/test/functional/ctrl_controller_test.rb @@ -1,6 +1,6 @@ require File.expand_path('../../test_helper', __FILE__) -class PlanControllerTest < ActionController::TestCase +class CtrlControllerTest < ActionController::TestCase # Replace this with your real tests. def test_truth assert true diff --git a/test/functional/issue_plan_controller_test.rb b/test/functional/issue_plan_controller_test.rb deleted file mode 100644 index c344d01..0000000 --- a/test/functional/issue_plan_controller_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.expand_path('../../test_helper', __FILE__) - -class IssuePlanControllerTest < ActionController::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end From e4d5bd0d7a8acd39a62960a1f4ef7ceab0bcfe49 Mon Sep 17 00:00:00 2001 From: gilles orsini Date: Thu, 22 Nov 2018 22:45:18 +0100 Subject: [PATCH 02/14] back_url sur action new_task vers issues_list --- lib/taskplan_hook_listener.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/taskplan_hook_listener.rb b/lib/taskplan_hook_listener.rb index 97c4bae..3b85685 100644 --- a/lib/taskplan_hook_listener.rb +++ b/lib/taskplan_hook_listener.rb @@ -1,15 +1,12 @@ -require 'byebug' - class TaskplanHookListener < Redmine::Hook::ViewListener include IssuesHelper def view_issues_context_menu_start(context = {}) - #byebug issue = context[:issues][0] attrs = { :parent_issue_id => issue } attrs[:tracker_id] = issue.tracker unless issue.tracker.disabled_core_fields.include?('parent_issue_id') - l = link_to("new subtask", new_project_issue_path(issue.project, :issue => attrs, :back_url => issue_path(issue))) + l = link_to("new subtask", new_project_issue_path(issue.project, :issue => attrs, :back_url => project_issues_path(issue.project))) return "
  • " + l + "
  • " end end \ No newline at end of file From 463a5bf24b5dd8940b286c3c49625918b2bdb81e Mon Sep 17 00:00:00 2001 From: gilles orsini Date: Sun, 25 Nov 2018 18:22:26 +0100 Subject: [PATCH 03/14] rajout filtrage sous-tache et tache parente --- lib/taskplan_hook_listener.rb | 43 +++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/lib/taskplan_hook_listener.rb b/lib/taskplan_hook_listener.rb index 3b85685..bc1a460 100644 --- a/lib/taskplan_hook_listener.rb +++ b/lib/taskplan_hook_listener.rb @@ -1,12 +1,35 @@ +require 'byebug' + class TaskplanHookListener < Redmine::Hook::ViewListener include IssuesHelper - def view_issues_context_menu_start(context = {}) - issue = context[:issues][0] - attrs = { - :parent_issue_id => issue - } - attrs[:tracker_id] = issue.tracker unless issue.tracker.disabled_core_fields.include?('parent_issue_id') - l = link_to("new subtask", new_project_issue_path(issue.project, :issue => attrs, :back_url => project_issues_path(issue.project))) - return "
  • " + l + "
  • " - end - end \ No newline at end of file + include RoutesHelper + + def view_issues_context_menu_start(context = {}) + issue = context[:issues][0] + attrs = { + :parent_issue_id => issue + } + attrs[:tracker_id] = issue.tracker unless issue.tracker.disabled_core_fields.include?('parent_issue_id') + # create subtask + l1 = link_to("new subtask", new_project_issue_path(issue.project, :issue => attrs, :back_url => project_issues_path(issue.project))) + # byebug + # TODO maintenir columns, order + # filter subtasks + l2 = link_to("filter sustasks", _project_issues_path(@project, :set_filter => 1, + :f => ["parent_id", ""], + :op => {:parent_id => "~"}, + :v => {:parent_id => [issue.id]}, + :issue_id => ["1"])) + # filter parent task + # byebug + # TODO manage no grand_parent + direct_parent_id = issue.parent.parent_id + l3 = link_to("filter parent tasks", _project_issues_path(@project, :set_filter => 1, + :f => ["parent_id", ""], + :op => {:parent_id => "~"}, + :v => {:parent_id => [direct_parent_id]})) + return "
  • " + l1 + "
  • " + + "
  • " + l2 + "
  • " + + "
  • " + l3.to_s+ "
  • " + end +end \ No newline at end of file From e3c4b45e3605cda4f3fe987a8494cce2f2e22121 Mon Sep 17 00:00:00 2001 From: gilles orsini Date: Wed, 28 Nov 2018 09:59:12 +0100 Subject: [PATCH 04/14] rajout filter depth --- init.rb | 1 + lib/redmine_depth_issue_filter.rb | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 lib/redmine_depth_issue_filter.rb diff --git a/init.rb b/init.rb index 5cb861a..1aebd74 100644 --- a/init.rb +++ b/init.rb @@ -1,4 +1,5 @@ require_dependency 'taskplan_hook_listener' +require_dependency 'redmine_depth_issue_filter' Redmine::Plugin.register :taskplan_redmine_plugin do name 'Taskplan Redmine Plugin plugin' diff --git a/lib/redmine_depth_issue_filter.rb b/lib/redmine_depth_issue_filter.rb new file mode 100644 index 0000000..b49d825 --- /dev/null +++ b/lib/redmine_depth_issue_filter.rb @@ -0,0 +1,24 @@ +module RedmineDepthIssueFilter + module PrependInstanceMethods + def initialize_available_filters + super + add_available_filter "depth", :type => :integer, :label => "depth" + end + end + + module AddedInstanceMethods + # Wrapper around the +available_filters+ to add a new Deliverable filter + def sql_for_depth_field(field, operator, value) + # TODO manage operator 'entre', 'aucun' et 'tous' + "(select count(*) + 1 from issues as i2 where i2.lft < issues.lft and i2.rgt > issues.rgt) #{operator} #{value.first.to_i}" + end + + end + + def self.included(base) # :nodoc: + base.send(:include, AddedInstanceMethods) + IssueQuery.prepend(PrependInstanceMethods) + end +end + +IssueQuery.send(:include, RedmineDepthIssueFilter) From 1b1b030c47b533aeccbef905dd5aef42ff7cf256 Mon Sep 17 00:00:00 2001 From: gilles orsini Date: Wed, 28 Nov 2018 14:38:56 +0100 Subject: [PATCH 05/14] i18n de filtre depth --- config/locales/en.yml | 1 + config/locales/fr.yml | 4 ++++ lib/redmine_depth_issue_filter.rb | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 config/locales/fr.yml diff --git a/config/locales/en.yml b/config/locales/en.yml index 642b07f..40fc051 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,3 +1,4 @@ # English strings go here for Rails i18n en: # my_label: "My label" + depth_filter: "Depth" diff --git a/config/locales/fr.yml b/config/locales/fr.yml new file mode 100644 index 0000000..06b3b94 --- /dev/null +++ b/config/locales/fr.yml @@ -0,0 +1,4 @@ +# French strings go here for Rails i18n +fr: + # my_label: "My label" + depth_filter: "Profondeur" diff --git a/lib/redmine_depth_issue_filter.rb b/lib/redmine_depth_issue_filter.rb index b49d825..07a0e7a 100644 --- a/lib/redmine_depth_issue_filter.rb +++ b/lib/redmine_depth_issue_filter.rb @@ -2,7 +2,8 @@ module RedmineDepthIssueFilter module PrependInstanceMethods def initialize_available_filters super - add_available_filter "depth", :type => :integer, :label => "depth" + byebug + add_available_filter "depth", :type => :integer, :label => :depth_filter end end From 6e79124698b7bc95c24ded8d6c6f2d0bb30e63df Mon Sep 17 00:00:00 2001 From: gilles orsini Date: Wed, 28 Nov 2018 14:39:33 +0100 Subject: [PATCH 06/14] comment byebug --- lib/redmine_depth_issue_filter.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/redmine_depth_issue_filter.rb b/lib/redmine_depth_issue_filter.rb index 07a0e7a..0ed31a5 100644 --- a/lib/redmine_depth_issue_filter.rb +++ b/lib/redmine_depth_issue_filter.rb @@ -2,7 +2,6 @@ module RedmineDepthIssueFilter module PrependInstanceMethods def initialize_available_filters super - byebug add_available_filter "depth", :type => :integer, :label => :depth_filter end end From 358301cce0d3a0cae7dc1b3f8bb1b97ea1744fe7 Mon Sep 17 00:00:00 2001 From: gilles orsini Date: Sun, 2 Dec 2018 22:14:44 +0100 Subject: [PATCH 07/14] keep current filters --- lib/taskplan_hook_listener.rb | 41 +++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/lib/taskplan_hook_listener.rb b/lib/taskplan_hook_listener.rb index bc1a460..6830c72 100644 --- a/lib/taskplan_hook_listener.rb +++ b/lib/taskplan_hook_listener.rb @@ -13,23 +13,42 @@ def view_issues_context_menu_start(context = {}) # create subtask l1 = link_to("new subtask", new_project_issue_path(issue.project, :issue => attrs, :back_url => project_issues_path(issue.project))) # byebug - # TODO maintenir columns, order # filter subtasks + # TODO maintenir columns, order + # TODO manage saved query + current_filters = context[:request].session[:issue_query][:filters] + filters, operators, values = url_filters current_filters l2 = link_to("filter sustasks", _project_issues_path(@project, :set_filter => 1, - :f => ["parent_id", ""], - :op => {:parent_id => "~"}, - :v => {:parent_id => [issue.id]}, - :issue_id => ["1"])) + :f => filters << "parent_id", + :op => operators.merge({"parent_id" => "~"}), + :v => values.merge({"parent_id" => [issue.id.to_s]}))) # filter parent task - # byebug # TODO manage no grand_parent direct_parent_id = issue.parent.parent_id + # l3 = link_to("filter parent tasks", _project_issues_path(@project, :set_filter => 1, + # :f => ["parent_id", "status"], + # :op => [{:parent_id => "~"}, + # :v => {:parent_id => [direct_parent_id]} + # )) + # l3 = link_to("filter parent tasks", project_issues_path(issue.project)) l3 = link_to("filter parent tasks", _project_issues_path(@project, :set_filter => 1, - :f => ["parent_id", ""], - :op => {:parent_id => "~"}, - :v => {:parent_id => [direct_parent_id]})) + :f => filters << "parent_id", + :op => operators.merge({"parent_id" => "~"}), + :v => values.merge({"parent_id" => [direct_parent_id.to_s]}))) return "
  • " + l1 + "
  • " + "
  • " + l2 + "
  • " + - "
  • " + l3.to_s+ "
  • " - end + "
  • " + l3 + "
  • " + end + + def url_filters(filters_hash) + filters = [] + operators = {} + values = {} + filters_hash.each do |key, value| + filters << key + operators[key] = value[:operator] + values[key] = value[:values] + end + return filters, operators, values + end end \ No newline at end of file From 416f7b39ca4027c9d07fa7c4e817d73e2125c045 Mon Sep 17 00:00:00 2001 From: gilles orsini Date: Sun, 2 Dec 2018 22:15:44 +0100 Subject: [PATCH 08/14] comment --- lib/taskplan_hook_listener.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/taskplan_hook_listener.rb b/lib/taskplan_hook_listener.rb index 6830c72..f462fa0 100644 --- a/lib/taskplan_hook_listener.rb +++ b/lib/taskplan_hook_listener.rb @@ -25,12 +25,6 @@ def view_issues_context_menu_start(context = {}) # filter parent task # TODO manage no grand_parent direct_parent_id = issue.parent.parent_id - # l3 = link_to("filter parent tasks", _project_issues_path(@project, :set_filter => 1, - # :f => ["parent_id", "status"], - # :op => [{:parent_id => "~"}, - # :v => {:parent_id => [direct_parent_id]} - # )) - # l3 = link_to("filter parent tasks", project_issues_path(issue.project)) l3 = link_to("filter parent tasks", _project_issues_path(@project, :set_filter => 1, :f => filters << "parent_id", :op => operators.merge({"parent_id" => "~"}), From b2ed2205a59a1f56710a539ab967223c7654c61c Mon Sep 17 00:00:00 2001 From: gilles orsini Date: Sun, 2 Dec 2018 22:35:29 +0100 Subject: [PATCH 09/14] rajout conservation sort --- lib/taskplan_hook_listener.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/taskplan_hook_listener.rb b/lib/taskplan_hook_listener.rb index f462fa0..fad555a 100644 --- a/lib/taskplan_hook_listener.rb +++ b/lib/taskplan_hook_listener.rb @@ -21,14 +21,16 @@ def view_issues_context_menu_start(context = {}) l2 = link_to("filter sustasks", _project_issues_path(@project, :set_filter => 1, :f => filters << "parent_id", :op => operators.merge({"parent_id" => "~"}), - :v => values.merge({"parent_id" => [issue.id.to_s]}))) + :v => values.merge({"parent_id" => [issue.id.to_s]}), + :sort => context[:request].session[:issue_query][:sort])) # filter parent task # TODO manage no grand_parent direct_parent_id = issue.parent.parent_id l3 = link_to("filter parent tasks", _project_issues_path(@project, :set_filter => 1, :f => filters << "parent_id", :op => operators.merge({"parent_id" => "~"}), - :v => values.merge({"parent_id" => [direct_parent_id.to_s]}))) + :v => values.merge({"parent_id" => [direct_parent_id.to_s]}), + :sort => context[:request].session[:issue_query][:sort])) return "
  • " + l1 + "
  • " + "
  • " + l2 + "
  • " + "
  • " + l3 + "
  • " From 326e97cb97972b988fb2a7dff47754ef4b4d7a8d Mon Sep 17 00:00:00 2001 From: gilles orsini Date: Tue, 4 Dec 2018 22:13:30 +0100 Subject: [PATCH 10/14] comment --- lib/taskplan_hook_listener.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/taskplan_hook_listener.rb b/lib/taskplan_hook_listener.rb index fad555a..1005531 100644 --- a/lib/taskplan_hook_listener.rb +++ b/lib/taskplan_hook_listener.rb @@ -14,9 +14,10 @@ def view_issues_context_menu_start(context = {}) l1 = link_to("new subtask", new_project_issue_path(issue.project, :issue => attrs, :back_url => project_issues_path(issue.project))) # byebug # filter subtasks - # TODO maintenir columns, order + # TODO maintenir columns, group_by et autre # TODO manage saved query current_filters = context[:request].session[:issue_query][:filters] + byebug filters, operators, values = url_filters current_filters l2 = link_to("filter sustasks", _project_issues_path(@project, :set_filter => 1, :f => filters << "parent_id", From 9c75ebb945f926b862c13cc6ebedabcd83c8e4a4 Mon Sep 17 00:00:00 2001 From: gilles orsini Date: Tue, 4 Dec 2018 22:14:05 +0100 Subject: [PATCH 11/14] comment --- lib/taskplan_hook_listener.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/taskplan_hook_listener.rb b/lib/taskplan_hook_listener.rb index 1005531..370e1be 100644 --- a/lib/taskplan_hook_listener.rb +++ b/lib/taskplan_hook_listener.rb @@ -14,10 +14,9 @@ def view_issues_context_menu_start(context = {}) l1 = link_to("new subtask", new_project_issue_path(issue.project, :issue => attrs, :back_url => project_issues_path(issue.project))) # byebug # filter subtasks - # TODO maintenir columns, group_by et autre + # TODO maintenir columns, order, group_by et autre # TODO manage saved query current_filters = context[:request].session[:issue_query][:filters] - byebug filters, operators, values = url_filters current_filters l2 = link_to("filter sustasks", _project_issues_path(@project, :set_filter => 1, :f => filters << "parent_id", From a491ac0ad8c73981cb6893683855fddf2563f821 Mon Sep 17 00:00:00 2001 From: gilles orsini Date: Wed, 5 Dec 2018 22:08:46 +0100 Subject: [PATCH 12/14] rajout des params sort, column_names et group_by --- lib/taskplan_hook_listener.rb | 39 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/taskplan_hook_listener.rb b/lib/taskplan_hook_listener.rb index 370e1be..5d08a23 100644 --- a/lib/taskplan_hook_listener.rb +++ b/lib/taskplan_hook_listener.rb @@ -14,37 +14,38 @@ def view_issues_context_menu_start(context = {}) l1 = link_to("new subtask", new_project_issue_path(issue.project, :issue => attrs, :back_url => project_issues_path(issue.project))) # byebug # filter subtasks - # TODO maintenir columns, order, group_by et autre # TODO manage saved query current_filters = context[:request].session[:issue_query][:filters] - filters, operators, values = url_filters current_filters - l2 = link_to("filter sustasks", _project_issues_path(@project, :set_filter => 1, - :f => filters << "parent_id", - :op => operators.merge({"parent_id" => "~"}), - :v => values.merge({"parent_id" => [issue.id.to_s]}), - :sort => context[:request].session[:issue_query][:sort])) + query_params = url_filters current_filters + l2 = link_to("filter sustasks", _project_issues_path(@project, { :set_filter => 1, + :f => query_params[:filter] << "parent_id", + :op => query_params[:operator].merge({"parent_id" => "~"}), + :v => query_params[:value].merge({"parent_id" => [issue.id.to_s]}), + :sort => context[:request].session[:issue_query][:sort], + :c => context[:request].session[:issue_query][:column_names], + :group_by => context[:request].session[:issue_query][:group_by]})) # filter parent task # TODO manage no grand_parent direct_parent_id = issue.parent.parent_id - l3 = link_to("filter parent tasks", _project_issues_path(@project, :set_filter => 1, - :f => filters << "parent_id", - :op => operators.merge({"parent_id" => "~"}), - :v => values.merge({"parent_id" => [direct_parent_id.to_s]}), - :sort => context[:request].session[:issue_query][:sort])) + l3 = link_to("filter parent tasks", _project_issues_path(@project, { :set_filter => 1, + :f => query_params[:filter] << "parent_id", + :op => query_params[:operator].merge({"parent_id" => "~"}), + :v => query_params[:value].merge({"parent_id" => [direct_parent_id.to_s]}), + :sort => context[:request].session[:issue_query][:sort], + :c => context[:request].session[:issue_query][:column_names], + :group_by => context[:request].session[:issue_query][:group_by]})) return "
  • " + l1 + "
  • " + "
  • " + l2 + "
  • " + "
  • " + l3 + "
  • " end def url_filters(filters_hash) - filters = [] - operators = {} - values = {} + result = { :filter => [], :operator => {}, :value => {}} filters_hash.each do |key, value| - filters << key - operators[key] = value[:operator] - values[key] = value[:values] + result[:filter] << key + result[:operator].merge!({ key => value[:operator] }) + result[:value].merge!({ key => value[:values] }) end - return filters, operators, values + result end end \ No newline at end of file From 6fc72f80068eb33ab969bf38768de01fd3189e60 Mon Sep 17 00:00:00 2001 From: gilles orsini Date: Thu, 6 Dec 2018 23:21:04 +0100 Subject: [PATCH 13/14] remove parent filter when use parent filter on the top task --- lib/taskplan_hook_listener.rb | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/taskplan_hook_listener.rb b/lib/taskplan_hook_listener.rb index 5d08a23..037db6e 100644 --- a/lib/taskplan_hook_listener.rb +++ b/lib/taskplan_hook_listener.rb @@ -3,6 +3,7 @@ class TaskplanHookListener < Redmine::Hook::ViewListener include IssuesHelper include RoutesHelper + include ContextMenusHelper def view_issues_context_menu_start(context = {}) issue = context[:issues][0] @@ -17,7 +18,7 @@ def view_issues_context_menu_start(context = {}) # TODO manage saved query current_filters = context[:request].session[:issue_query][:filters] query_params = url_filters current_filters - l2 = link_to("filter sustasks", _project_issues_path(@project, { :set_filter => 1, + l2 = context_menu_link("filter sustasks", _project_issues_path(@project, { :set_filter => 1, :f => query_params[:filter] << "parent_id", :op => query_params[:operator].merge({"parent_id" => "~"}), :v => query_params[:value].merge({"parent_id" => [issue.id.to_s]}), @@ -26,14 +27,24 @@ def view_issues_context_menu_start(context = {}) :group_by => context[:request].session[:issue_query][:group_by]})) # filter parent task # TODO manage no grand_parent - direct_parent_id = issue.parent.parent_id - l3 = link_to("filter parent tasks", _project_issues_path(@project, { :set_filter => 1, - :f => query_params[:filter] << "parent_id", - :op => query_params[:operator].merge({"parent_id" => "~"}), - :v => query_params[:value].merge({"parent_id" => [direct_parent_id.to_s]}), - :sort => context[:request].session[:issue_query][:sort], - :c => context[:request].session[:issue_query][:column_names], - :group_by => context[:request].session[:issue_query][:group_by]})) + direct_parent_id = issue.parent&.parent_id + if direct_parent_id then + l3 = context_menu_link("filter parent tasks", _project_issues_path(@project, { :set_filter => 1, + :f => query_params[:filter] << "parent_id", + :op => query_params[:operator].merge({"parent_id" => "~"}), + :v => query_params[:value].merge({"parent_id" => [direct_parent_id.to_s]}), + :sort => context[:request].session[:issue_query][:sort], + :c => context[:request].session[:issue_query][:column_names], + :group_by => context[:request].session[:issue_query][:group_by]})) + else + l3 = context_menu_link("filter parent tasks", _project_issues_path(@project, { :set_filter => 1, + :f => query_params[:filter].without("parent_id"), + :op => query_params[:operator].without("parent_id"), + :v => query_params[:value].without("parent_id"), + :sort => context[:request].session[:issue_query][:sort], + :c => context[:request].session[:issue_query][:column_names], + :group_by => context[:request].session[:issue_query][:group_by]})) + end return "
  • " + l1 + "
  • " + "
  • " + l2 + "
  • " + "
  • " + l3 + "
  • " From 13642acc1d8f763e8ef0e86e4711152cabd4c431 Mon Sep 17 00:00:00 2001 From: gilles orsini Date: Thu, 6 Dec 2018 23:21:04 +0100 Subject: [PATCH 14/14] remove parent filter when use parent filter on the top task --- README.rdoc | 11 +++++-- config/routes.rb | 2 +- init.rb | 6 ++-- ...istener.rb => actionplan_hook_listener.rb} | 31 +++++++++++++------ 4 files changed, 34 insertions(+), 16 deletions(-) rename lib/{taskplan_hook_listener.rb => actionplan_hook_listener.rb} (54%) diff --git a/README.rdoc b/README.rdoc index 0fc3059..d8ad5f0 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,3 +1,10 @@ -= taskplan_redmine_plugin += Action plan redmine plugin -Description goes here +Redmine plugin to helps manage action plans[https://en.wikipedia.org/wiki/Action_plan]. + +Supposing you create hierarchy of tasks ussing subtasks, this plugin adds into issues list contextual menu commands that : +* add a subtask to the select task +* filter issues at selected subtasks +* filter issues at parent tasks. + +This plugin also add a filter 'Depth' that filter issues by depth relative to root hierarchy. diff --git a/config/routes.rb b/config/routes.rb index d9b3d7f..0b36057 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,3 @@ # Plugin's routes # See: http://guides.rubyonrails.org/routing.html -get 'taskplan', :to => 'ctrl#index' +get 'actionplan', :to => 'ctrl#index' diff --git a/init.rb b/init.rb index 1aebd74..69f55ac 100644 --- a/init.rb +++ b/init.rb @@ -1,8 +1,8 @@ -require_dependency 'taskplan_hook_listener' +require_dependency 'actionplan_hook_listener' require_dependency 'redmine_depth_issue_filter' -Redmine::Plugin.register :taskplan_redmine_plugin do - name 'Taskplan Redmine Plugin plugin' +Redmine::Plugin.register :actionplan_redmine_plugin do + name 'Actionplan Redmine Plugin' author 'Author name' description 'This is a plugin for Redmine' version '0.0.1' diff --git a/lib/taskplan_hook_listener.rb b/lib/actionplan_hook_listener.rb similarity index 54% rename from lib/taskplan_hook_listener.rb rename to lib/actionplan_hook_listener.rb index 5d08a23..a0b1547 100644 --- a/lib/taskplan_hook_listener.rb +++ b/lib/actionplan_hook_listener.rb @@ -1,8 +1,9 @@ require 'byebug' -class TaskplanHookListener < Redmine::Hook::ViewListener +class ActionplanHookListener < Redmine::Hook::ViewListener include IssuesHelper include RoutesHelper + include ContextMenusHelper def view_issues_context_menu_start(context = {}) issue = context[:issues][0] @@ -17,7 +18,7 @@ def view_issues_context_menu_start(context = {}) # TODO manage saved query current_filters = context[:request].session[:issue_query][:filters] query_params = url_filters current_filters - l2 = link_to("filter sustasks", _project_issues_path(@project, { :set_filter => 1, + l2 = context_menu_link("filter sustasks", _project_issues_path(@project, { :set_filter => 1, :f => query_params[:filter] << "parent_id", :op => query_params[:operator].merge({"parent_id" => "~"}), :v => query_params[:value].merge({"parent_id" => [issue.id.to_s]}), @@ -26,14 +27,24 @@ def view_issues_context_menu_start(context = {}) :group_by => context[:request].session[:issue_query][:group_by]})) # filter parent task # TODO manage no grand_parent - direct_parent_id = issue.parent.parent_id - l3 = link_to("filter parent tasks", _project_issues_path(@project, { :set_filter => 1, - :f => query_params[:filter] << "parent_id", - :op => query_params[:operator].merge({"parent_id" => "~"}), - :v => query_params[:value].merge({"parent_id" => [direct_parent_id.to_s]}), - :sort => context[:request].session[:issue_query][:sort], - :c => context[:request].session[:issue_query][:column_names], - :group_by => context[:request].session[:issue_query][:group_by]})) + direct_parent_id = issue.parent&.parent_id + if direct_parent_id then + l3 = context_menu_link("filter parent tasks", _project_issues_path(@project, { :set_filter => 1, + :f => query_params[:filter] << "parent_id", + :op => query_params[:operator].merge({"parent_id" => "~"}), + :v => query_params[:value].merge({"parent_id" => [direct_parent_id.to_s]}), + :sort => context[:request].session[:issue_query][:sort], + :c => context[:request].session[:issue_query][:column_names], + :group_by => context[:request].session[:issue_query][:group_by]})) + else + l3 = context_menu_link("filter parent tasks", _project_issues_path(@project, { :set_filter => 1, + :f => query_params[:filter].without("parent_id"), + :op => query_params[:operator].without("parent_id"), + :v => query_params[:value].without("parent_id"), + :sort => context[:request].session[:issue_query][:sort], + :c => context[:request].session[:issue_query][:column_names], + :group_by => context[:request].session[:issue_query][:group_by]})) + end return "
  • " + l1 + "
  • " + "
  • " + l2 + "
  • " + "
  • " + l3 + "
  • "