Skip to content

Commit

Permalink
Add shortcut to create a new issue related to the current one
Browse files Browse the repository at this point in the history
  • Loading branch information
nanego committed Nov 26, 2024
1 parent 4009f6c commit 9fbd2d9
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 32 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 15 additions & 2 deletions app/overrides/issues/_action_menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
&& [email protected]_issue_copy
HIDE_LINK
&& [email protected]_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
75 changes: 45 additions & 30 deletions app/views/settings/_redmine_plugin_tiny_features_settings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@

<hr>
<% if Redmine::Plugin.installed?(:redmine_base_select2) %>
<p>
<%= 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 %>
</p>

<!-- Add this parameter, because there are tests for available_filters in redmine core -->
<p id="paginate_issue_filters_values">
<%= 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 %>
</p>
<p>
<%= 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 %>
</p>

<!-- Add this parameter, because there are tests for available_filters in redmine core -->
<p id="paginate_issue_filters_values">
<%= 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 %>
</p>
<% end %>

<!-- Added this parameter in order to disable note deletion journalization and do not break core test (JournalsControllerTest#test_update_xhr_with_empty_notes_should_delete_the_journal in redmine core) -->
Expand Down Expand Up @@ -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 %>

<!-- Create Related Shortcut options -->
<hr>
<p>
<%= 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 %>
</p>
<p>
<%= 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) %>
</p>
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 3 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9fbd2d9

Please sign in to comment.