Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0c9f58d
Remove dubugging code for production
nanego Mar 14, 2022
d2888c1
Update reminders rake task: add max_delay
nanego Mar 14, 2022
1ce562a
Update reminder rake task
nanego Mar 14, 2022
bc2799d
Improve comments
nanego Mar 29, 2022
c651a17
Update CI config: add latest Redmine releases
nanego Mar 29, 2022
a5766ec
Add new 'Range' custom-field format
nanego May 31, 2022
f216365
Range input field: display selected value
nanego May 31, 2022
2b88d89
Add option to activate Select2 on core select filters
jtilatti Jun 2, 2022
306a5ed
Mettre à jour la table disabled_custom_field_enumerations en cas de s…
Jun 8, 2022
85db6f9
Delete disabled_fields when destroying related project or custom_field
nanego Jun 13, 2022
f59c874
Apply default value when field is required but not set
nanego Jun 13, 2022
7abe019
Merge remote-tracking branch 'origin/preprod'
nanego Jun 13, 2022
28611d2
Update CI config: add latest Redmine releases
nanego Jun 22, 2022
09447bc
Improve compatibility with RedmineLimitedVisibility plugin
nanego Aug 2, 2022
d3c4683
Fix performance issue when filtering by custom-values
nanego Aug 9, 2022
f52597c
Add missing dependency
nanego Aug 9, 2022
641e53e
Pouvoir filtrer les projets par modules activés
Sep 9, 2022
3dd8805
Complete Readme and include new enabled-modules filter and column
nanego Sep 12, 2022
0522eac
Ajouter une option pour les trackers qui permet de bloquer la copie d…
Oct 5, 2022
eee5092
test l'absence de lien copy dans les pages issue/show + issues/index
Oct 5, 2022
c35d439
Ajouter la conditions @issue.present?
Oct 5, 2022
7e5277e
Préciser le sélecteur ,car il y a deux sélecteurs qui correspondent à…
Oct 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/4_1_6.yml → .github/workflows/4_1_7.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Tests 4.1.6
name: Tests 4.1.7

env:
PLUGIN_NAME: redmine_tiny_features
REDMINE_VERSION: 4.1.6
REDMINE_VERSION: 4.1.7
RAILS_ENV: test

on:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/4_2_4.yml → .github/workflows/4_2_7.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Tests 4.2.4
name: Tests 4.2.7

env:
PLUGIN_NAME: redmine_tiny_features
REDMINE_VERSION: 4.2.4
REDMINE_VERSION: 4.2.7
RAILS_ENV: test

on:
Expand Down
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,25 @@ Here is a complete list of the features:
* Define a **default project** selected when creating a new issue without being in a specific project
* Add **check-all / uncheck-all shortcuts** to roles filters
* Improve **roles synthesis** by adding missing informations about issues permissions and trackers
* Improve load time of **users filters** when there are thousands entries
* Use or not the select2 plugin
* Improve load time of **users filters** when there are thousands entries and when the select2 plugin is used
* Save **note deletion** in issue journal
* Fix **pasted images** when using Chrome (may be fixed in future Redmine versions according to this issue https://www.redmine.org/issues/36013)
* **Reminders rake task: add max-delay option** to define the maximum number of days after which reminders stop to be sent
* Add **range** custom-field format
* Apply **default value** to existing-issues custom-fields if field is required and not set
* Fix performance problem when filtering issues by custom-values (remove this patch when issue has been addressed in Redmine Core: https://www.redmine.org/issues/37565)
* Add **enabled modules** filter and column in projects list

## Test status

|Plugin branch| Redmine Version | Test Status |
|-------------|-------------------|------------------|
|master | 4.2.4 | [![4.2.4][1]][5] |
|master | 4.1.6 | [![4.1.6][2]][5] |
|master | 4.2.7 | [![4.2.7][1]][5] |
|master | 4.1.7 | [![4.1.7][2]][5] |
|master | master | [![master][3]][5]|

[1]: https://github.com/nanego/redmine_tiny_features/actions/workflows/4_2_4.yml/badge.svg
[2]: https://github.com/nanego/redmine_tiny_features/actions/workflows/4_1_6.yml/badge.svg
[1]: https://github.com/nanego/redmine_tiny_features/actions/workflows/4_2_7.yml/badge.svg
[2]: https://github.com/nanego/redmine_tiny_features/actions/workflows/4_1_7.yml/badge.svg
[3]: https://github.com/nanego/redmine_tiny_features/actions/workflows/master.yml/badge.svg
[5]: https://github.com/nanego/redmine_tiny_features/actions
6 changes: 6 additions & 0 deletions app/overrides/context_menus/issues.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Deface::Override.new :virtual_path => 'context_menus/issues',
:name => 'hide-copy-issue-if-tracker-prevents-it',
:insert_bottom=> 'erb[loud]:contains("context_menu_link l(:button_copy), project_copy_issue_path(@project, @issue)")',
:text => <<-HIDE_LINK
if !@issue.tracker.prevent_copy_issues
HIDE_LINK
6 changes: 6 additions & 0 deletions app/overrides/issues/_action_menu.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Deface::Override.new :virtual_path => 'issues/_action_menu',
:name => 'hide-copy-issue-if-tracker-prevents-it',
:insert_bottom=> 'erb[loud]:contains("link_to l(:button_copy)")',
:text => <<-HIDE_LINK
&& !@issue.tracker.prevent_copy_issues
HIDE_LINK
13 changes: 9 additions & 4 deletions app/overrides/queries/_filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
:insert_after => "div.add-filter",
:text => <<SELECT2
<script>
// declaration this functions here, in order to generate the path by rails

function useRedminePluginSelect2(){
return <%= Setting.plugin_redmine_tiny_features.key?('use_select2') %>
}

// declaration this function here, in order to generate the path by rails
function updateSelect2ForElements() {
var activePagination = '<%= Setting["plugin_redmine_tiny_features"]["paginate_issue_filters_values"].present?%>';
if (activePagination === 'true'){
var activeSelect2 = useRedminePluginSelect2()
var activePagination = '<%= Setting["plugin_redmine_tiny_features"]["paginate_issue_filters_values"].present? %>';

if (activeSelect2 && activePagination === 'true'){
// check if values_author_id_1 defined
if ($('#values_author_id_1').length > 0) {
setConfigurationForSelect2($('#values_author_id_1'), '<%= author_values_pagination_path %>');
Expand All @@ -27,6 +33,5 @@
}
}
}

</script>
SELECT2
7 changes: 7 additions & 0 deletions app/overrides/trackers/_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Deface::Override.new :virtual_path => "trackers/_form",
:name => "add-prevent-copy-issues",
:insert_after => "p:eq(2)",
:text => <<-EOS
<p><%= f.check_box :prevent_copy_issues %></p>
EOS

14 changes: 14 additions & 0 deletions app/views/custom_fields/formats/_range.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<p>
<label for="custom_field_min_range"><%=l(:label_min_max_range)%></label>
<%= f.text_field :min_value, :size => 5, :no_label => true %> -
<%= f.text_field :max_value, :size => 5, :no_label => true %>
</p>

<p>
<label for="custom_field_steps"><%=l(:label_steps)%></label>
<%= f.text_field :steps, :size => 5, :no_label => true %>
</p>
<p>
<label><%= l(:field_default_value) %></label>
<%= f.text_field :default_value, :size => 5, :no_label => true %>
</p>
2 changes: 0 additions & 2 deletions app/views/issues/_edit_closed.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
})
$("#issue-form").on("change", "#issue_status_id", function () {
var status_id = parseInt($(this).val())
console.log(status_id)
console.log($.inArray(status_id, <%= IssueStatus.where(:is_closed => true).pluck(:id).inspect %>))
if ($.inArray(status_id, <%= IssueStatus.where(:is_closed => true).pluck(:id).inspect %>) < 0) {
showIfIssueOpen()
}
Expand Down
40 changes: 36 additions & 4 deletions app/views/settings/_redmine_plugin_tiny_features_settings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,22 @@
</p>

<hr>
<!-- Add this parameter, because there are tests for available_filters in redmine core -->
<% 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>
<% 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) -->
<p>
Expand All @@ -52,8 +61,31 @@

<%= 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")
}
}

// Add to disabled option pagination when select2 option is not checked when the page is launched
hidePagination()
<% end %>



67 changes: 48 additions & 19 deletions assets/javascripts/redmine_tiny_features.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ function redminePluginDatetimeCustomFieldInstalled() {
return !(typeof buildDateTimeFilterRow === "undefined")
}

// check if plugin redmine_limited_visibility is installed
function redminePluginLimitedVisibilityIsInstalled() {
return !(typeof buildListVisibilityFilterRow === "undefined")
}

$(function() {
if (!redminePluginDatetimeCustomFieldInstalled()) {
addFilter = function (field, operator, values) {
var fieldId = field.replace('.', '_');
var tr = $('#tr_'+fieldId);
Expand All @@ -55,42 +59,67 @@ $(function() {
if (tr.length > 0) {
tr.show();
} else {
buildFilterRow(field, operator, values);
if (redminePluginDatetimeCustomFieldInstalled() && (filterOptions['type'] == "date" || filterOptions['type'] == "date_past" )) {
buildDateTimeFilterRow(field, operator, values);
} else {
if (redminePluginLimitedVisibilityIsInstalled() && (filterOptions['type'] == "list_visibility")) {
buildListVisibilityFilterRow(field, operator, values);
} else {
buildFilterRow(field, operator, values);
}
}
}
$('#cb_'+fieldId).prop('checked', true);
toggleFilter(field);
toggleMultiSelectIconInit();

if (redminePluginLimitedVisibilityIsInstalled() && ($("#operators_" + fieldId).val() == 'mine')) {
enableValues(field, []);
} else {
toggleFilter(field);
}

if(!redminePluginDatetimeCustomFieldInstalled()){
toggleMultiSelectIconInit();
}
$('#add_filter_select').val('').find('option').each(function() {
if ($(this).attr('value') == field) {
$(this).attr('disabled', true);
}
});

addSelect2ToSelectTagsForTinyFeatures();
}
}
});

function toggleMultiSelect(el) {
if (el.attr('multiple')) {
el.removeAttr('multiple');
el.attr('size', 1);
} else {
el.attr('multiple', true);
if (el.children().length > 10)
el.attr('size', 10);
else
el.attr('size', 4);
}
// Patch
addSelect2ToSelectTagsForTinyFeatures()
}

/*
Override for addSelect2ToSelectTags, because of addFilter takes time ,we should wait for it to finish.
We use this method of override by variable to ensure that it is executed even if the function addSelect2ToSelectTags of plugin
redmine_datetime_custom_field installed loaded after addSelect2ToSelectTags of this plugin
*/

addSelect2ToSelectTags = function(){
$(document).ready(function(){
addSelect2ToSelectTagsForTinyFeatures();
});
}

function addSelect2ToSelectTagsForTinyFeatures() {
if ((typeof $().select2) === 'function') {
$('#filters select.value').select2({
containerCss: {width: '300px', minwidth: '300px'},
width: 'style'
});
updateSelect2ForElements();
}
$(document).ready(function(){
if (((typeof $().select2) === 'function') && useRedminePluginSelect2() ) {
$('#filters select.value').select2({
containerCss: {width: '300px', minwidth: '300px'},
width: 'style'
});
updateSelect2ForElements();
}
})
}

function setConfigurationForSelect2(element, url) {
Expand Down
11 changes: 11 additions & 0 deletions assets/stylesheets/tiny_features.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,14 @@

table.trackers-permissions td.role {color:#999;font-size:90%;font-weight:normal !important;text-align:center;vertical-align:bottom;}
.permissions-header {padding-left: 16px;display: inline-block;}

.disabled-settings-redmine-tiny-features {
color : #aaa
}

.range_selected_value {
color: #505050;
line-height: 1.5em;
word-wrap: break-word;
padding-left: 8px;
}
7 changes: 6 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ en:
label_note: 'Note '
setting_journalize_note_deletion: Journalize the note deletion
label_of: 'of '
text_note_deleted: "%{label} (#%{old}) deleted"
text_note_deleted: "%{label} (#%{old}) deleted"
setting_use_select2: Apply select2 to filters fields
label_range: "Range"
label_min_max_range: "Min / Max values"
label_steps: "Step"
field_module_enabled: "Enabled modules"
5 changes: 5 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ fr:
setting_journalize_note_deletion: Traçabilité des effacements de note
label_of: 'de '
text_note_deleted: "%{label} (#%{old}) supprimée"
setting_use_select2: Activer Select2 pour faciliter l'utilisation des listes déroulantes
label_range: "Intervalle"
label_min_max_range: "Valeurs minimale et maximale"
label_steps: "Incrément"
field_module_enabled: "Modules activés"
7 changes: 7 additions & 0 deletions db/migrate/002_add_step_to_custom_fields.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddStepToCustomFields < ActiveRecord::Migration[5.2]
def change
add_column :custom_fields, :steps, :integer
add_column :custom_fields, :min_value, :integer
add_column :custom_fields, :max_value, :integer
end
end
5 changes: 5 additions & 0 deletions db/migrate/20221004142452_add_trackers_prevent_copy_issues.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddTrackersPreventCopyIssues < ActiveRecord::Migration[5.2]
def change
add_column :trackers, :prevent_copy_issues, :boolean, :default => false
end
end
11 changes: 9 additions & 2 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
require_dependency 'redmine_tiny_features/time_entry_query_patch'
require_dependency 'redmine_tiny_features/issues_helper_patch'
require_dependency 'redmine_tiny_features/journal_patch'
require_dependency 'redmine_tiny_features/tracker_patch'
require_dependency 'redmine_tiny_features/mailer_patch'
require_dependency 'redmine_tiny_features/custom_field_enumeration_patch'
require_dependency 'redmine_tiny_features/custom_field_patch'
require_dependency 'redmine_tiny_features/issue_custom_field_patch'
require_dependency 'redmine_tiny_features/project_query_patch'
end

Redmine::Plugin.register :redmine_tiny_features do
Expand All @@ -33,7 +39,8 @@
'open_issue_when_editing_closed_issues': '',
'simplified_version_form': '1',
'default_project': '',
'paginate_issue_filters_values': Rails.env.test? ? '0' : '1',
'journalize_note_deletion': Rails.env.test? ? '0' : '1'
'paginate_issue_filters_values': Rails.env.test? || !(Redmine::Plugin.installed?(:redmine_base_select2)) ? '0' : '1',
'journalize_note_deletion': Rails.env.test? ? '0' : '1',
'use_select2': Rails.env.test? || !(Redmine::Plugin.installed?(:redmine_base_select2)) ? '0' : '1'
}
end
5 changes: 5 additions & 0 deletions lib/redmine_tiny_features/custom_field_enumeration_patch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require_dependency 'custom_field_enumeration'

class CustomFieldEnumeration < ActiveRecord::Base
has_many :disabled_custom_field_enumerations, :dependent => :delete_all
end
8 changes: 8 additions & 0 deletions lib/redmine_tiny_features/custom_field_patch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require_dependency 'custom_field'

class CustomField < ActiveRecord::Base
##### PATCH ,to call the destroy method of (CustomFieldEnumeration has :dependent => :delete_all)
has_many :enumerations, lambda {order(:position)},
:class_name => 'CustomFieldEnumeration',
:dependent => :destroy
end
Loading