From 9fbd2d944ef8d75d0b3b11db9c6379e01e3663fc Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 26 Nov 2024 16:31:45 +0100 Subject: [PATCH] Add shortcut to create a new issue related to the current one --- README.md | 2 + app/overrides/issues/_action_menu.rb | 17 ++++- ...ine_plugin_tiny_features_settings.html.erb | 75 +++++++++++-------- config/locales/en.yml | 3 + config/locales/fr.yml | 3 + init.rb | 2 + 6 files changed, 70 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 4a2c03e..160db2d 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ Here is a complete list of the features: * Issues filter: **sort group-by options alphabetically** * PDF exports: add **links to attached files in generated PDF**" * Projects overview: add an option to **hide members section** +* **Hide status select box** in new issue form if only one status is available +* Add a link to quickly **create a new issue related to the current one** ## Test status diff --git a/app/overrides/issues/_action_menu.rb b/app/overrides/issues/_action_menu.rb index f2a6552..2af1974 100644 --- a/app/overrides/issues/_action_menu.rb +++ b/app/overrides/issues/_action_menu.rb @@ -2,5 +2,18 @@ :name => 'hide-copy-issue-if-tracker-prevents-it', :insert_bottom => 'erb[loud]:contains("link_to l(:button_copy)")', :text => <<-HIDE_LINK - && !@issue.tracker.prevent_issue_copy -HIDE_LINK + && !@issue.tracker.prevent_issue_copy + HIDE_LINK + +Deface::Override.new :virtual_path => 'issues/_action_menu', + :name => 'add-link-issue-button-to-issue-actions', + :insert_before => 'erb[loud]:contains("link_to l(:button_edit)")', + :text => <<~RELATEDISSUE + <% if Setting["plugin_redmine_tiny_features"]["create_related_issue_shortcut"].present? %> + <%= link_to l(:label_create_related_issue_shortcut), + new_project_issue_path(project_id: Setting["plugin_redmine_tiny_features"]["create_related_issue_shortcut_project_id"] || @project.id, + 'issue[description]' => @issue.description, + related_to: @issue,), + class: "icon icon-link-break" %> + <% end %> + RELATEDISSUE diff --git a/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb b/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb index 054e0fe..3629b18 100644 --- a/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb +++ b/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb @@ -35,20 +35,20 @@
<% if Redmine::Plugin.installed?(:redmine_base_select2) %> -

- <%= label_tag '', { style: 'width: auto;' } do %> - <%= check_box_tag "settings[use_select2]", '1', Setting["plugin_redmine_tiny_features"]["use_select2"], :onclick=>"hidePagination()" %> - <%= l("setting_use_select2") %> - <% end %> -

- - -

- <%= label_tag '', { style: 'width: auto;' } do %> - <%= check_box_tag "settings[paginate_issue_filters_values]", '1', Setting["plugin_redmine_tiny_features"]["paginate_issue_filters_values"] %> - <%= l("setting_paginate_issue_filters_values") %> - <% end %> -

+

+ <%= label_tag '', { style: 'width: auto;' } do %> + <%= check_box_tag "settings[use_select2]", '1', Setting["plugin_redmine_tiny_features"]["use_select2"], :onclick => "hidePagination()" %> + <%= l("setting_use_select2") %> + <% end %> +

+ + +

+ <%= label_tag '', { style: 'width: auto;' } do %> + <%= check_box_tag "settings[paginate_issue_filters_values]", '1', Setting["plugin_redmine_tiny_features"]["paginate_issue_filters_values"] %> + <%= l("setting_paginate_issue_filters_values") %> + <% end %> +

<% end %> @@ -83,28 +83,43 @@ <%= javascript_tag do %> $(function() { - if ((typeof $().select2) === 'function') { - $('#settings_default_project').select2(); - } + if ((typeof $().select2) === 'function') { + $('#settings_default_project').select2(); + } }); // Avoid to activate pagination if select2 is not active function hidePagination(){ - paginationObject = $('#paginate_issue_filters_values input')[0] - paginationLabel = $('#paginate_issue_filters_values label')[0] - select2Checked = $('#settings_use_select2')[0].checked - - if(!select2Checked){ - paginationObject.checked = false - paginationObject.disabled = true - paginationLabel.classList.add("disabled-settings-redmine-tiny-features") - - } else { - paginationObject.disabled = false - paginationLabel.classList.remove("disabled-settings-redmine-tiny-features") - } + paginationObject = $('#paginate_issue_filters_values input')[0] + paginationLabel = $('#paginate_issue_filters_values label')[0] + select2Checked = $('#settings_use_select2')[0].checked + + if(!select2Checked){ + paginationObject.checked = false + paginationObject.disabled = true + paginationLabel.classList.add("disabled-settings-redmine-tiny-features") + + } else { + paginationObject.disabled = false + paginationLabel.classList.remove("disabled-settings-redmine-tiny-features") + } } // Add to disabled option pagination when select2 option is not checked when the page is launched hidePagination() <% end %> + + +
+

+ <%= label_tag '', { style: 'width: auto;' } do %> + <%= check_box_tag "settings[create_related_issue_shortcut]", '1', Setting["plugin_redmine_tiny_features"]["create_related_issue_shortcut"] %> + <%= l("setting_create_related_issue_shortcut") %> + <% end %> +

+

+ <%= label_tag l("setting_create_related_issue_shortcut_project_id") %> + <%= select_tag "settings[create_related_issue_shortcut_project_id]", + project_tree_options_for_select(Project.all_public.active.sorted, + selected: Project.where(id: Setting["plugin_redmine_tiny_features"]["create_related_issue_shortcut_project_id"]).first) %> +

diff --git a/config/locales/en.yml b/config/locales/en.yml index bd407f3..541398c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -41,3 +41,6 @@ en: label_issue_display_by_status: "Colorization According to status" field_show_pagination_at_top_results: "Show pagination links at the top of issues results" hide_members_on_project_overview: "Hide members section on project overview page" + label_create_related_issue_shortcut: "Create a related issue" + setting_create_related_issue_shortcut: "Display a shortcut to create a related issue" + setting_create_related_issue_shortcut_project_id: "Project where to create related issues" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index ad3df4b..656d711 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -41,3 +41,6 @@ fr: label_issue_display_by_status: "Colorisation par statut" field_show_pagination_at_top_results: "Afficher les liens de pagination en haut des résultats des demandes" hide_members_on_project_overview: "Masquer la section des membres sur la page d'aperçu des projets" + label_create_related_issue_shortcut: "Créer une demande liée" + setting_create_related_issue_shortcut: "Afficher un raccourci pour créer une demande liée" + setting_create_related_issue_shortcut_project_id: "Projet où créer les demandes liées" diff --git a/init.rb b/init.rb index da90623..412da87 100644 --- a/init.rb +++ b/init.rb @@ -24,5 +24,7 @@ 'use_select2': Rails.env.test? || !(Redmine::Plugin.installed?(:redmine_base_select2)) ? '0' : '1', 'load_issue_edit_form_asynchronously': Rails.env.test? ? '0' : '1', 'disable_email_hiding': '', + 'create_related_issue_shortcut': '', + 'create_related_issue_shortcut_project_id': '' } end