From 0c9f58d083cc884ed42df9af41acf181519eb99b Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Mon, 14 Mar 2022 14:12:36 +0100 Subject: [PATCH 01/41] Remove dubugging code for production --- app/views/issues/_edit_closed.html.erb | 2 -- lib/redmine_tiny_features/hooks.rb | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/views/issues/_edit_closed.html.erb b/app/views/issues/_edit_closed.html.erb index 4530e23..3e7c631 100644 --- a/app/views/issues/_edit_closed.html.erb +++ b/app/views/issues/_edit_closed.html.erb @@ -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() } diff --git a/lib/redmine_tiny_features/hooks.rb b/lib/redmine_tiny_features/hooks.rb index 47b498c..d1126c5 100644 --- a/lib/redmine_tiny_features/hooks.rb +++ b/lib/redmine_tiny_features/hooks.rb @@ -2,12 +2,12 @@ module RedmineTinyFeatures class Hooks < Redmine::Hook::ViewListener #adds our css on each page def view_layouts_base_html_head(context) - stylesheet_link_tag("tiny_features", :plugin => "redmine_tiny_features")+ - javascript_include_tag('redmine_tiny_features.js', plugin: 'redmine_tiny_features') + stylesheet_link_tag("tiny_features", :plugin => "redmine_tiny_features") + + javascript_include_tag('redmine_tiny_features.js', plugin: 'redmine_tiny_features') end - def controller_journals_edit_post(context={}) - if Setting["plugin_redmine_tiny_features"]["journalize_note_deletion"].present? + def controller_journals_edit_post(context = {}) + if Setting["plugin_redmine_tiny_features"]["journalize_note_deletion"].present? journal = context[:journal] if context[:journal].notes.blank? journal.issue.init_journal(User.current).note_removed(journal) From d2888c1cc5487cfc10736f92a54dcdfce44af0a8 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Mon, 14 Mar 2022 15:54:43 +0100 Subject: [PATCH 02/41] Update reminders rake task: add max_delay --- README.md | 1 + init.rb | 1 + lib/redmine_tiny_features/mailer_patch.rb | 59 +++++++++++++++++++++++ spec/models/mailer_patch_spec.rb | 42 ++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 lib/redmine_tiny_features/mailer_patch.rb create mode 100644 spec/models/mailer_patch_spec.rb diff --git a/README.md b/README.md index 524e97b..d465f38 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Here is a complete list of the features: * Improve load time of **users filters** when there are thousands entries * 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 ## Test status diff --git a/init.rb b/init.rb index 35088fc..e2fbda6 100644 --- a/init.rb +++ b/init.rb @@ -15,6 +15,7 @@ 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/mailer_patch' end Redmine::Plugin.register :redmine_tiny_features do diff --git a/lib/redmine_tiny_features/mailer_patch.rb b/lib/redmine_tiny_features/mailer_patch.rb new file mode 100644 index 0000000..d17630b --- /dev/null +++ b/lib/redmine_tiny_features/mailer_patch.rb @@ -0,0 +1,59 @@ +require_dependency 'mailer' + +class Mailer < ActionMailer::Base + + # Sends reminders to issue assignees + # Available options: + # * :days => how many days in the future to remind about (defaults to 7) + # * :tracker => id of tracker for filtering issues (defaults to all trackers) + # * :project => id or identifier of project to process (defaults to all projects) + # * :users => array of user/group ids who should be reminded + # * :version => name of target version for filtering issues (defaults to none) + ####### ADDED BY TINY FEATURES PLUGIN 1/3 ####### + # * :max_delay => ignore older issues: how many days after due date to stop sending reminders (defaults to none) + def self.reminders(options = {}) + days = options[:days] || 7 + ####### ADDED BY TINY FEATURES PLUGIN 2/3 ####### + max_delay = options[:max_delay] || nil + project = options[:project] ? Project.find(options[:project]) : nil + tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil + target_version_id = options[:version] ? Version.named(options[:version]).pluck(:id) : nil + if options[:version] && target_version_id.blank? + raise ActiveRecord::RecordNotFound.new("Couldn't find Version named #{options[:version]}") + end + + user_ids = options[:users] + + scope = + Issue.open.where( + "#{Issue.table_name}.assigned_to_id IS NOT NULL" \ + " AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" \ + " AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date + ) + scope = scope.where(:assigned_to_id => user_ids) if user_ids.present? + scope = scope.where(:project_id => project.id) if project + scope = scope.where(:fixed_version_id => target_version_id) if target_version_id.present? + scope = scope.where(:tracker_id => tracker.id) if tracker + ####### ADDED BY TINY FEATURES PLUGIN 3/3 ####### + scope = scope.where("#{Issue.table_name}.due_date > ?", max_delay.day.ago.to_date) if max_delay + issues_by_assignee = scope.includes(:status, :assigned_to, :project, :tracker). + group_by(&:assigned_to) + issues_by_assignee.keys.each do |assignee| + if assignee.is_a?(Group) + assignee.users.each do |user| + issues_by_assignee[user] ||= [] + issues_by_assignee[user] += issues_by_assignee[assignee] + end + end + end + + issues_by_assignee.each do |assignee, issues| + if assignee.is_a?(User) && assignee.active? && issues.present? + visible_issues = issues.select { |i| i.visible?(assignee) } + visible_issues.sort! { |a, b| (a.due_date <=> b.due_date).nonzero? || (a.id <=> b.id) } + reminder(assignee, visible_issues, days).deliver_later if visible_issues.present? + end + end + end + +end diff --git a/spec/models/mailer_patch_spec.rb b/spec/models/mailer_patch_spec.rb new file mode 100644 index 0000000..9bbf974 --- /dev/null +++ b/spec/models/mailer_patch_spec.rb @@ -0,0 +1,42 @@ +require "spec_helper" +require "rails_helper" + +describe "Mailer" do + + include ActiveSupport::Testing::Assertions + + fixtures :users, :email_addresses, :user_preferences, + :roles, :members, :member_roles, + :issues, :issue_statuses, :issue_relations, + :versions, :trackers, :projects_trackers, + :issue_categories, :enabled_modules, :enumerations + + it "does not send reminders for older issues when using max_delay option" do + + user = User.find(2) + user.pref.update_attribute :time_zone, 'UTC' + + Issue.generate!(:assigned_to => user, :due_date => 20.days.from_now, :subject => 'quux') + Issue.generate!(:assigned_to => user, :due_date => 0.days.from_now, :subject => 'baz') + Issue.generate!(:assigned_to => user, :due_date => 1.days.from_now, :subject => 'qux') + Issue.generate!(:assigned_to => user, :due_date => 10.days.ago, :subject => 'foo') + Issue.generate!(:assigned_to => user, :due_date => 100.days.ago, :subject => 'bar') + ActionMailer::Base.deliveries.clear + + Mailer.reminders(:days => 7, :users => [user.id], :max_delay => 30) + + assert_equal 1, ActionMailer::Base.deliveries.size + + email = ActionMailer::Base.deliveries.last + expect(email).to_not be_nil + + mail_boy = email.parts.first.body.encoded + + expect(mail_boy).to_not match(/quux/) + expect(mail_boy).to match(/foo \(10 days late\)/) + expect(mail_boy).to match(/baz \(Due in 0 days\)/) + expect(mail_boy).to match(/qux \(Due in 1 day\)/) + expect(mail_boy).to_not match(/bar/) + + end +end From 1ce562aa860284bd539465a6d770938b2ca1894b Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Mon, 14 Mar 2022 15:59:56 +0100 Subject: [PATCH 03/41] Update reminder rake task --- lib/tasks/reminder.rake | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 lib/tasks/reminder.rake diff --git a/lib/tasks/reminder.rake b/lib/tasks/reminder.rake new file mode 100644 index 0000000..874cf9c --- /dev/null +++ b/lib/tasks/reminder.rake @@ -0,0 +1,47 @@ +# Redmine - project management software +# Copyright (C) 2006-2021 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +desc <<-END_DESC +Send reminders about issues due in the next days. + +Available options: + * days => number of days to remind about (defaults to 7) + * tracker => id of tracker (defaults to all trackers) + * project => id or identifier of project (defaults to all projects) + * users => comma separated list of user/group ids who should be reminded + * version => name of target version for filtering issues (defaults to none) + * max_delay => ignore older issues: how many days after due date to stop sending reminders (defaults to none) + +Example: + rails redmine_tiny_features:send_reminders days=7 users="1,23, 56" max_delay=100 RAILS_ENV="production" +END_DESC + +namespace :redmine_tiny_features do + task :send_reminders => :environment do + options = {} + options[:days] = ENV['days'].presence&.to_i + options[:project] = ENV['project'].presence + options[:tracker] = ENV['tracker'].presence&.to_i + options[:users] = ENV['users'].presence.to_s.split(',').each(&:strip!) + options[:version] = ENV['version'].presence + options[:max_delay] = ENV['max_delay'].presence&.to_i + + Mailer.with_synched_deliveries do + Mailer.reminders(options) + end + end +end From bc2799df1bb7d5a92bb255bd259bffd31432b7ca Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Tue, 29 Mar 2022 11:25:19 +0200 Subject: [PATCH 04/41] Improve comments --- lib/redmine_tiny_features/mailer_patch.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/redmine_tiny_features/mailer_patch.rb b/lib/redmine_tiny_features/mailer_patch.rb index d17630b..a9dd415 100644 --- a/lib/redmine_tiny_features/mailer_patch.rb +++ b/lib/redmine_tiny_features/mailer_patch.rb @@ -7,7 +7,7 @@ class Mailer < ActionMailer::Base # * :days => how many days in the future to remind about (defaults to 7) # * :tracker => id of tracker for filtering issues (defaults to all trackers) # * :project => id or identifier of project to process (defaults to all projects) - # * :users => array of user/group ids who should be reminded + # * :users => array of assigned user/group ids who should be reminded # * :version => name of target version for filtering issues (defaults to none) ####### ADDED BY TINY FEATURES PLUGIN 1/3 ####### # * :max_delay => ignore older issues: how many days after due date to stop sending reminders (defaults to none) From c651a17a09641c0ce2d8f975fb3f5702233595ff Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Tue, 29 Mar 2022 11:36:39 +0200 Subject: [PATCH 05/41] Update CI config: add latest Redmine releases --- .github/workflows/{4_1_6.yml => 4_1_7.yml} | 4 ++-- .github/workflows/{4_2_4.yml => 4_2_5.yml} | 4 ++-- README.md | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) rename .github/workflows/{4_1_6.yml => 4_1_7.yml} (99%) rename .github/workflows/{4_2_4.yml => 4_2_5.yml} (99%) diff --git a/.github/workflows/4_1_6.yml b/.github/workflows/4_1_7.yml similarity index 99% rename from .github/workflows/4_1_6.yml rename to .github/workflows/4_1_7.yml index 940cb20..e04974a 100644 --- a/.github/workflows/4_1_6.yml +++ b/.github/workflows/4_1_7.yml @@ -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: diff --git a/.github/workflows/4_2_4.yml b/.github/workflows/4_2_5.yml similarity index 99% rename from .github/workflows/4_2_4.yml rename to .github/workflows/4_2_5.yml index b16d641..4e9e929 100644 --- a/.github/workflows/4_2_4.yml +++ b/.github/workflows/4_2_5.yml @@ -1,8 +1,8 @@ -name: Tests 4.2.4 +name: Tests 4.2.5 env: PLUGIN_NAME: redmine_tiny_features - REDMINE_VERSION: 4.2.4 + REDMINE_VERSION: 4.2.5 RAILS_ENV: test on: diff --git a/README.md b/README.md index d465f38..a601648 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,11 @@ Here is a complete list of the features: |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.5 | [![4.2.5][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_5.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 From a5766ec5d81c80067530245d6b22efed319bbc89 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Tue, 31 May 2022 15:55:32 +0200 Subject: [PATCH 06/41] Add new 'Range' custom-field format --- README.md | 1 + .../custom_fields/formats/_range.html.erb | 14 ++++++ config/locales/en.yml | 5 ++- config/locales/fr.yml | 3 ++ db/migrate/002_add_step_to_custom_fields.rb | 7 +++ .../field_format_patch.rb | 44 +++++++++++++++++++ spec/controllers/issues_controller_spec.rb | 28 ++++++++++++ spec/controllers/queries_controller_spec.rb | 1 - spec/models/custom_field_spec.rb | 44 +++++++++++++++++++ 9 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 app/views/custom_fields/formats/_range.html.erb create mode 100644 db/migrate/002_add_step_to_custom_fields.rb create mode 100644 spec/controllers/issues_controller_spec.rb create mode 100644 spec/models/custom_field_spec.rb diff --git a/README.md b/README.md index a601648..8dd68ba 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Here is a complete list of the features: * 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 ## Test status diff --git a/app/views/custom_fields/formats/_range.html.erb b/app/views/custom_fields/formats/_range.html.erb new file mode 100644 index 0000000..69c8277 --- /dev/null +++ b/app/views/custom_fields/formats/_range.html.erb @@ -0,0 +1,14 @@ +

+ + <%= f.text_field :min_value, :size => 5, :no_label => true %> - + <%= f.text_field :max_value, :size => 5, :no_label => true %> +

+ +

+ + <%= f.text_field :steps, :size => 5, :no_label => true %> +

+

+ + <%= f.text_field :default_value, :size => 5, :no_label => true %> +

diff --git a/config/locales/en.yml b/config/locales/en.yml index 06b170d..c4d32ba 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -20,4 +20,7 @@ en: label_note: 'Note ' setting_journalize_note_deletion: Journalize the note deletion label_of: 'of ' - text_note_deleted: "%{label} (#%{old}) deleted" \ No newline at end of file + text_note_deleted: "%{label} (#%{old}) deleted" + label_range: "Range" + label_min_max_range: "Min / Max values" + label_steps: "Step" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index f3c9d88..b0b874a 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -21,3 +21,6 @@ fr: setting_journalize_note_deletion: Traçabilité des effacements de note label_of: 'de ' text_note_deleted: "%{label} (#%{old}) supprimée" + label_range: "Intervalle" + label_min_max_range: "Valeurs minimale et maximale" + label_steps: "Incrément" diff --git a/db/migrate/002_add_step_to_custom_fields.rb b/db/migrate/002_add_step_to_custom_fields.rb new file mode 100644 index 0000000..4487b15 --- /dev/null +++ b/db/migrate/002_add_step_to_custom_fields.rb @@ -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 diff --git a/lib/redmine_tiny_features/field_format_patch.rb b/lib/redmine_tiny_features/field_format_patch.rb index a7838d4..45d5862 100644 --- a/lib/redmine_tiny_features/field_format_patch.rb +++ b/lib/redmine_tiny_features/field_format_patch.rb @@ -14,5 +14,49 @@ def possible_values_records(custom_field, object = nil) end end + class RangeFormat < Numeric + add 'range' + + self.form_partial = 'custom_fields/formats/range' + + def label + "label_range" + end + + field_attributes :steps, :min_value, :max_value + + def edit_tag(view, tag_id, tag_name, custom_value, options = {}) + edit_tag = view.range_field_tag(tag_name, + custom_value.value || custom_value.custom_field.default_value, + options.merge(id: tag_id, + min: custom_value.custom_field.min_value, + max: custom_value.custom_field.max_value, + step: custom_value.custom_field.steps)) + edit_tag + end + + def cast_single_value(custom_field, value, customized = nil) + value.to_i + end + + def validate_single_value(custom_field, value, customized = nil) + errs = super + errs << ::I18n.t('activerecord.errors.messages.not_a_number') unless /^[+-]?\d+$/.match?(value.to_s.strip) + errs + end + + def query_filter_options(custom_field, query) + { :type => :integer } + end + + def group_statement(custom_field) + order_statement(custom_field) + end + end + end end + +class CustomField < ActiveRecord::Base + safe_attributes("steps", "min_value", "max_value") +end diff --git a/spec/controllers/issues_controller_spec.rb b/spec/controllers/issues_controller_spec.rb new file mode 100644 index 0000000..5a8a355 --- /dev/null +++ b/spec/controllers/issues_controller_spec.rb @@ -0,0 +1,28 @@ +require "spec_helper" + +describe IssuesController, type: :controller do + render_views + + fixtures :projects, :users, :members, :member_roles, :roles, + :issues, :journals, :journal_details, :enabled_modules, + :trackers, :issue_statuses, :enumerations, :custom_fields, + :custom_values, :custom_fields_projects, :projects_trackers + + before do + User.current = User.find(1) + @request.session[:user_id] = 1 # admin + end + + describe "range custom-field format" do + it "can sum several range fields" do + field = IssueCustomField.generate!(:field_format => 'range', :is_for_all => true) + CustomValue.create!(:customized => Issue.find(1), :custom_field => field, :value => '20') + CustomValue.create!(:customized => Issue.find(2), :custom_field => field, :value => '30') + get(:index, :params => { :t => ["cf_#{field.id}"] }) + assert_response :success + assert_select '.query-totals' + assert_select ".total-for-cf-#{field.id} span.value", :text => '50' + end + end + +end diff --git a/spec/controllers/queries_controller_spec.rb b/spec/controllers/queries_controller_spec.rb index 8200e54..0185e44 100644 --- a/spec/controllers/queries_controller_spec.rb +++ b/spec/controllers/queries_controller_spec.rb @@ -5,7 +5,6 @@ describe QueriesController, type: :controller do - fixtures :users, :projects, :members, :roles before do diff --git a/spec/models/custom_field_spec.rb b/spec/models/custom_field_spec.rb new file mode 100644 index 0000000..9d0dab1 --- /dev/null +++ b/spec/models/custom_field_spec.rb @@ -0,0 +1,44 @@ +require "spec_helper" + +describe "CustomField" do + describe "Range custom-field format" do + + it "validates Range custom-field before saving" do + field = CustomField.new(:name => 'test_before_validation', :field_format => 'range') + field.min_value = 0 + field.max_value = 20 + field.steps = 2 + field.searchable = true + expect(field.save).to be_truthy + + field.reload + + expect(field.steps).to eq 2 + expect(field.max_value).to eq 20 + expect(field.searchable).to be_falsey # Integer values are not searchable + end + + it "validates the default_value" do + field = CustomField.new(:name => 'Test', :field_format => 'range') + field.default_value = 'abc' + expect(field.valid?).to be_falsey + field.default_value = '6' + expect(field.valid?).to be_truthy + end + + it "validates possible values" do + f = CustomField.new(:field_format => 'range') + + assert f.valid_field_value?(nil) + assert f.valid_field_value?('') + assert !f.valid_field_value?(' ') + assert f.valid_field_value?('123') + assert f.valid_field_value?(' 123 ') + assert f.valid_field_value?('+123') + assert f.valid_field_value?('-123') + assert !f.valid_field_value?('9abc') + assert f.valid_field_value?(123) + end + + end +end From f216365de04fd817ecfa6fc7f57cc1134c9e3162 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Tue, 31 May 2022 19:44:30 +0200 Subject: [PATCH 07/41] Range input field: display selected value --- assets/stylesheets/tiny_features.css | 7 +++++++ lib/redmine_tiny_features/field_format_patch.rb | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/assets/stylesheets/tiny_features.css b/assets/stylesheets/tiny_features.css index 78e3454..bb80d96 100644 --- a/assets/stylesheets/tiny_features.css +++ b/assets/stylesheets/tiny_features.css @@ -13,3 +13,10 @@ 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;} + +.range_selected_value { + color: #505050; + line-height: 1.5em; + word-wrap: break-word; + padding-left: 8px; +} diff --git a/lib/redmine_tiny_features/field_format_patch.rb b/lib/redmine_tiny_features/field_format_patch.rb index 45d5862..e8ea546 100644 --- a/lib/redmine_tiny_features/field_format_patch.rb +++ b/lib/redmine_tiny_features/field_format_patch.rb @@ -32,6 +32,15 @@ def edit_tag(view, tag_id, tag_name, custom_value, options = {}) min: custom_value.custom_field.min_value, max: custom_value.custom_field.max_value, step: custom_value.custom_field.steps)) + edit_tag << view.content_tag(:span, custom_value.value, class: "range_selected_value") + edit_tag << view.javascript_tag( + <<~JAVASCRIPT + $(document).on("input change", "##{tag_id}", function(e) { + var value = $(this).val(); + $(this).next('.range_selected_value').html(value); + }) + JAVASCRIPT + ) edit_tag end From 2b88d89182e5944315b64288f6831ddfb96c87cf Mon Sep 17 00:00:00 2001 From: jtilatti <104084083+jtilatti@users.noreply.github.com> Date: Thu, 2 Jun 2022 09:47:54 +0200 Subject: [PATCH 08/41] Add option to activate Select2 on core select filters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Déplacement des méthodes de redmine_datetime_custom_field dans redmine_tiny_features * Supppresion de l'option de pagination quand le plugin redmine_base_select2 n'est pas installé * Modification de la fonction AddFilter pour prendre en compte la présence ou non du plugin redmine_datetime_custom_field * Modification du test suite au masquage de l'option pagination quand le plugin redmine_base_select2 n'est pas installé * Ajout de l'option sur le select2 (avec tests à corriger) * Correction des tests pour l'option sur select2 * Complétion du Readme * Changement du nom de la classe css disabled Co-authored-by: julie Co-authored-by: Julie TILATTI Co-authored-by: Vincent Robert --- README.md | 3 +- app/overrides/queries/_filters.rb | 13 +++-- ...ine_plugin_tiny_features_settings.html.erb | 40 +++++++++++++-- assets/javascripts/redmine_tiny_features.js | 50 ++++++++++++------- assets/stylesheets/tiny_features.css | 4 ++ config/locales/en.yml | 1 + config/locales/fr.yml | 1 + init.rb | 5 +- .../issue_query_patch.rb | 2 +- .../time_entry_query_patch.rb | 2 +- spec/controllers/journals_controller_spec.rb | 1 + spec/models/issue_query_patch_spec.rb | 35 ++++++++++++- spec/models/time_entry_query_patch_spec.rb | 3 +- .../settings_redmine_tiny_features_spec.rb | 16 +++--- 14 files changed, 136 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 8dd68ba..6e5a1b2 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ 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 diff --git a/app/overrides/queries/_filters.rb b/app/overrides/queries/_filters.rb index 9677e53..451b9a4 100644 --- a/app/overrides/queries/_filters.rb +++ b/app/overrides/queries/_filters.rb @@ -3,11 +3,17 @@ :insert_after => "div.add-filter", :text => < + // 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 %>'); @@ -27,6 +33,5 @@ } } } - SELECT2 \ No newline at end of file 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 c4842ca..7f28a7c 100644 --- a/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb +++ b/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb @@ -34,13 +34,22 @@


- +<% 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 %>

+<% end %>

@@ -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 %> + + + diff --git a/assets/javascripts/redmine_tiny_features.js b/assets/javascripts/redmine_tiny_features.js index 33ebf40..0c9f0fc 100644 --- a/assets/javascripts/redmine_tiny_features.js +++ b/assets/javascripts/redmine_tiny_features.js @@ -36,7 +36,6 @@ function redminePluginDatetimeCustomFieldInstalled() { } $(function() { - if (!redminePluginDatetimeCustomFieldInstalled()) { addFilter = function (field, operator, values) { var fieldId = field.replace('.', '_'); var tr = $('#tr_'+fieldId); @@ -55,42 +54,57 @@ $(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 { + buildFilterRow(field, operator, values); + } } $('#cb_'+fieldId).prop('checked', true); toggleFilter(field); - toggleMultiSelectIconInit(); + 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) { diff --git a/assets/stylesheets/tiny_features.css b/assets/stylesheets/tiny_features.css index bb80d96..a37619c 100644 --- a/assets/stylesheets/tiny_features.css +++ b/assets/stylesheets/tiny_features.css @@ -14,6 +14,10 @@ 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; diff --git a/config/locales/en.yml b/config/locales/en.yml index c4d32ba..9349757 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -21,6 +21,7 @@ en: setting_journalize_note_deletion: Journalize the note deletion label_of: 'of ' 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" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index b0b874a..f2aab5c 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -21,6 +21,7 @@ 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" diff --git a/init.rb b/init.rb index e2fbda6..6b2839c 100644 --- a/init.rb +++ b/init.rb @@ -34,7 +34,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 diff --git a/lib/redmine_tiny_features/issue_query_patch.rb b/lib/redmine_tiny_features/issue_query_patch.rb index 92d8d9d..8d6ff4b 100644 --- a/lib/redmine_tiny_features/issue_query_patch.rb +++ b/lib/redmine_tiny_features/issue_query_patch.rb @@ -14,7 +14,7 @@ module IssueQueryPatch def initialize_available_filters super # Add this condition,because of there are tests for available_filters in redmine core - if Setting["plugin_redmine_tiny_features"]["paginate_issue_filters_values"].present? + if Setting["plugin_redmine_tiny_features"]["use_select2"].present? && Setting["plugin_redmine_tiny_features"]["paginate_issue_filters_values"].present? add_available_filter( "author_id", :type => :list, :values => lambda { [] } diff --git a/lib/redmine_tiny_features/time_entry_query_patch.rb b/lib/redmine_tiny_features/time_entry_query_patch.rb index 3382a58..9b2ac51 100644 --- a/lib/redmine_tiny_features/time_entry_query_patch.rb +++ b/lib/redmine_tiny_features/time_entry_query_patch.rb @@ -17,7 +17,7 @@ module TimeEntryQueryPatch def initialize_available_filters super # Add this condition,because of there are tests for available_filters in redmine core - if Setting["plugin_redmine_tiny_features"]["paginate_issue_filters_values"].present? + if Setting["plugin_redmine_tiny_features"]["use_select2"].present? && Setting["plugin_redmine_tiny_features"]["paginate_issue_filters_values"].present? add_available_filter( "user_id", :type => :list_optional, :values => lambda { [] } diff --git a/spec/controllers/journals_controller_spec.rb b/spec/controllers/journals_controller_spec.rb index 25a7e28..fa53c7d 100644 --- a/spec/controllers/journals_controller_spec.rb +++ b/spec/controllers/journals_controller_spec.rb @@ -20,6 +20,7 @@ "warning_message_on_closed_issues"=>"1", "default_open_status"=>"2", "default_project"=>"1", + "use_select2"=>"1", "paginate_issue_filters_values"=>"1", "journalize_note_deletion"=>"1" } diff --git a/spec/models/issue_query_patch_spec.rb b/spec/models/issue_query_patch_spec.rb index 33aea92..3473734 100644 --- a/spec/models/issue_query_patch_spec.rb +++ b/spec/models/issue_query_patch_spec.rb @@ -13,10 +13,11 @@ it "should contain empty values for available_filter author_id, assigned_to_id, updated_by, last_updated_by" do - Setting.send "plugin_redmine_tiny_features=", { + Setting["plugin_redmine_tiny_features"] = { "warning_message_on_closed_issues"=>"1", "default_open_status"=>"2", "default_project"=>"1", + "use_select2"=>"1", "paginate_issue_filters_values"=>"1" } @@ -26,4 +27,36 @@ expect(issue_query.available_filters["updated_by"][:values]).to be_empty expect(issue_query.available_filters["last_updated_by"][:values]).to be_empty end + + it "should not contain empty values for available_filter author_id, assigned_to_id, updated_by, last_updated_by (use_select2 deactivated only)" do + + Setting["plugin_redmine_tiny_features"] = { + "warning_message_on_closed_issues"=>"1", + "default_open_status"=>"2", + "default_project"=>"1", + "paginate_issue_filters_values"=>"1" + } + + issue_query = IssueQuery.new + expect(issue_query.available_filters["author_id"][:values]).not_to be_empty + expect(issue_query.available_filters["assigned_to_id"][:values]).not_to be_empty + expect(issue_query.available_filters["updated_by"][:values]).not_to be_empty + expect(issue_query.available_filters["last_updated_by"][:values]).not_to be_empty + end + + it "should not contain empty values for available_filter author_id, assigned_to_id, updated_by, last_updated_by (use_select2 and paginate_issue_filters_values deactivated)" do + + Setting["plugin_redmine_tiny_features"] = { + "warning_message_on_closed_issues"=>"1", + "default_open_status"=>"2", + "default_project"=>"1", + } + + issue_query = IssueQuery.new + expect(issue_query.available_filters["author_id"][:values]).not_to be_empty + expect(issue_query.available_filters["assigned_to_id"][:values]).not_to be_empty + expect(issue_query.available_filters["updated_by"][:values]).not_to be_empty + expect(issue_query.available_filters["last_updated_by"][:values]).not_to be_empty + end + end diff --git a/spec/models/time_entry_query_patch_spec.rb b/spec/models/time_entry_query_patch_spec.rb index d8230dc..f99a630 100644 --- a/spec/models/time_entry_query_patch_spec.rb +++ b/spec/models/time_entry_query_patch_spec.rb @@ -12,10 +12,11 @@ end it "should contain empty values for available_filter author_id, user_id" do - Setting.send "plugin_redmine_tiny_features=", { + Setting["plugin_redmine_tiny_features"] = { "warning_message_on_closed_issues"=>"1", "default_open_status"=>"2", "default_project"=>"1", + "use_select2"=>"1", "paginate_issue_filters_values"=>"1" } diff --git a/spec/system/settings_redmine_tiny_features_spec.rb b/spec/system/settings_redmine_tiny_features_spec.rb index 9b703f6..3359707 100644 --- a/spec/system/settings_redmine_tiny_features_spec.rb +++ b/spec/system/settings_redmine_tiny_features_spec.rb @@ -4,13 +4,15 @@ fixtures :users it "Should active the option paginate_issue_filters_values" do + if Redmine::Plugin.installed?(:redmine_base_select2) + log_user('admin', 'admin') + visit 'settings/plugin/redmine_tiny_features' - log_user('admin', 'admin') - visit 'settings/plugin/redmine_tiny_features' - - find("input[name='settings[paginate_issue_filters_values]']").click - find("input[name='commit']").click - expect(Setting["plugin_redmine_tiny_features"]["paginate_issue_filters_values"]).to eq "1" - + find("input[name='settings[use_select2]']").click + find("input[name='settings[paginate_issue_filters_values]']").click + find("input[name='commit']").click + expect(Setting["plugin_redmine_tiny_features"]["use_select2"]).to eq '1' + expect(Setting["plugin_redmine_tiny_features"]["paginate_issue_filters_values"]).to eq "1" + end end end From 306a5ed174333f33a7d32c85900d416118f0440e Mon Sep 17 00:00:00 2001 From: Yazan Date: Wed, 8 Jun 2022 10:20:23 +0200 Subject: [PATCH 09/41] =?UTF-8?q?Mettre=20=C3=A0=20jour=20la=20table=20dis?= =?UTF-8?q?abled=5Fcustom=5Ffield=5Fenumerations=20en=20cas=20de=20suppres?= =?UTF-8?q?sion=20en=20cascade?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init.rb | 2 ++ .../custom_field_enumeration_patch.rb | 5 ++++ .../custom_field_patch.rb | 8 ++++++ lib/redmine_tiny_features/project_patch.rb | 2 +- spec/models/custom_field_spec.rb | 28 +++++++++++++++++++ 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 lib/redmine_tiny_features/custom_field_enumeration_patch.rb create mode 100644 lib/redmine_tiny_features/custom_field_patch.rb diff --git a/init.rb b/init.rb index 6b2839c..fc3b7e7 100644 --- a/init.rb +++ b/init.rb @@ -16,6 +16,8 @@ require_dependency 'redmine_tiny_features/issues_helper_patch' require_dependency 'redmine_tiny_features/journal_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' end Redmine::Plugin.register :redmine_tiny_features do diff --git a/lib/redmine_tiny_features/custom_field_enumeration_patch.rb b/lib/redmine_tiny_features/custom_field_enumeration_patch.rb new file mode 100644 index 0000000..5451669 --- /dev/null +++ b/lib/redmine_tiny_features/custom_field_enumeration_patch.rb @@ -0,0 +1,5 @@ +require_dependency 'custom_field_enumeration' + +class CustomFieldEnumeration < ActiveRecord::Base + has_many :disabled_custom_field_enumerations, :dependent => :delete_all +end \ No newline at end of file diff --git a/lib/redmine_tiny_features/custom_field_patch.rb b/lib/redmine_tiny_features/custom_field_patch.rb new file mode 100644 index 0000000..11789f7 --- /dev/null +++ b/lib/redmine_tiny_features/custom_field_patch.rb @@ -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 \ No newline at end of file diff --git a/lib/redmine_tiny_features/project_patch.rb b/lib/redmine_tiny_features/project_patch.rb index 00a05a5..85d3120 100644 --- a/lib/redmine_tiny_features/project_patch.rb +++ b/lib/redmine_tiny_features/project_patch.rb @@ -2,6 +2,6 @@ class Project < ActiveRecord::Base - has_many :disabled_custom_field_enumerations + has_many :disabled_custom_field_enumerations, :dependent => :delete_all end diff --git a/spec/models/custom_field_spec.rb b/spec/models/custom_field_spec.rb index 9d0dab1..fcf147e 100644 --- a/spec/models/custom_field_spec.rb +++ b/spec/models/custom_field_spec.rb @@ -40,5 +40,33 @@ assert f.valid_field_value?(123) end + describe "Update the table disabled_custom_field_enumerations in case of cascade deleting" do + let(:project) { Project.find(1) } + let(:field) { CustomField.create(:name => 'Test', :field_format => 'enumeration') } + let(:c_f_e1) { CustomFieldEnumeration.create(name: 'val1', position: 1, active: true, custom_field_id: field.id) } + let(:c_f_e2) { CustomFieldEnumeration.create(name: 'val2', position: 2, active: true, custom_field_id: field.id) } + + before do + CustomFieldEnumeration.create(name: 'val3', position: 3, active: true, custom_field_id: field.id) + DisabledCustomFieldEnumeration.create(project: project, custom_field_enumeration_id: c_f_e1.id) + DisabledCustomFieldEnumeration.create(project: project, custom_field_enumeration_id: c_f_e2.id) + expect(DisabledCustomFieldEnumeration.count).to eq(2) + end + + it "Should update the table disabled_custom_field_enumerations when deleting a project" do + project.destroy + expect(DisabledCustomFieldEnumeration.count).to eq(0) + end + + it "Should update the table disabled_custom_field_enumerations when deleting a customField" do + field.destroy + expect(DisabledCustomFieldEnumeration.count).to eq(0) + end + + it "Should update the table disabled_custom_field_enumerations when deleting a CustomFieldEnumeration" do + c_f_e1.destroy + expect(DisabledCustomFieldEnumeration.count).to eq(1) + end + end end end From f59c87422cb01502418fdd1f1f65041d08293477 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Mon, 13 Jun 2022 15:53:54 +0200 Subject: [PATCH 10/41] Apply default value when field is required but not set --- README.md | 1 + .../field_format_patch.rb | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/README.md b/README.md index 8dd68ba..8878124 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Here is a complete list of the features: * 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 ## Test status diff --git a/lib/redmine_tiny_features/field_format_patch.rb b/lib/redmine_tiny_features/field_format_patch.rb index e8ea546..c28e0d7 100644 --- a/lib/redmine_tiny_features/field_format_patch.rb +++ b/lib/redmine_tiny_features/field_format_patch.rb @@ -14,6 +14,40 @@ def possible_values_records(custom_field, object = nil) end end + class List < Base + # Renders the edit tag as check box or radio tags + def check_box_edit_tag(view, tag_id, tag_name, custom_value, options={}) + opts = [] + unless custom_value.custom_field.multiple? || custom_value.custom_field.is_required? + opts << ["(#{l(:label_none)})", ''] + end + opts += possible_custom_value_options(custom_value) + s = ''.html_safe + tag_method = custom_value.custom_field.multiple? ? :check_box_tag : :radio_button_tag + opts.each do |label, value| + value ||= label + checked = (custom_value.value.is_a?(Array) && custom_value.value.include?(value)) || + custom_value.value.to_s == value + + ################# + ##### START PATCH + if custom_value.value.blank? && custom_value.custom_field.is_required? && custom_value.custom_field.default_value.present? + checked = custom_value.custom_field.default_value == value + end + ## END PATCH + ################# + + tag = view.send(tag_method, tag_name, value, checked, :id => nil) + s << view.content_tag('label', tag + ' ' + label) + end + if custom_value.custom_field.multiple? + s << view.hidden_field_tag(tag_name, '', :id => nil) + end + css = "#{options[:class]} check_box_group" + view.content_tag('span', s, options.merge(:class => css)) + end + end + class RangeFormat < Numeric add 'range' From 28611d2020b0ab411ea44a420c6a5cb1f69b2d69 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Wed, 22 Jun 2022 12:01:35 +0200 Subject: [PATCH 11/41] Update CI config: add latest Redmine releases --- .github/workflows/{4_2_5.yml => 4_2_7.yml} | 4 ++-- README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename .github/workflows/{4_2_5.yml => 4_2_7.yml} (99%) diff --git a/.github/workflows/4_2_5.yml b/.github/workflows/4_2_7.yml similarity index 99% rename from .github/workflows/4_2_5.yml rename to .github/workflows/4_2_7.yml index 4e9e929..e15d0c8 100644 --- a/.github/workflows/4_2_5.yml +++ b/.github/workflows/4_2_7.yml @@ -1,8 +1,8 @@ -name: Tests 4.2.5 +name: Tests 4.2.7 env: PLUGIN_NAME: redmine_tiny_features - REDMINE_VERSION: 4.2.5 + REDMINE_VERSION: 4.2.7 RAILS_ENV: test on: diff --git a/README.md b/README.md index 4859448..15d7ed9 100644 --- a/README.md +++ b/README.md @@ -21,11 +21,11 @@ Here is a complete list of the features: |Plugin branch| Redmine Version | Test Status | |-------------|-------------------|------------------| -|master | 4.2.5 | [![4.2.5][1]][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_5.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 From 09447bccb4a5b46942b0ae3a09beea10fc438f6a Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Tue, 2 Aug 2022 16:32:11 +0200 Subject: [PATCH 12/41] Improve compatibility with RedmineLimitedVisibility plugin --- assets/javascripts/redmine_tiny_features.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/assets/javascripts/redmine_tiny_features.js b/assets/javascripts/redmine_tiny_features.js index 0c9f0fc..3a97704 100644 --- a/assets/javascripts/redmine_tiny_features.js +++ b/assets/javascripts/redmine_tiny_features.js @@ -35,6 +35,11 @@ function redminePluginDatetimeCustomFieldInstalled() { return !(typeof buildDateTimeFilterRow === "undefined") } +// check if plugin redmine_limited_visibility is installed +function redminePluginLimitedVisibilityIsInstalled() { + return !(typeof buildListVisibilityFilterRow === "undefined") +} + $(function() { addFilter = function (field, operator, values) { var fieldId = field.replace('.', '_'); @@ -54,14 +59,24 @@ $(function() { if (tr.length > 0) { tr.show(); } else { - if (redminePluginDatetimeCustomFieldInstalled() && (filterOptions['type'] == "date" || filterOptions['type'] == "date_past" )) { + if (redminePluginDatetimeCustomFieldInstalled() && (filterOptions['type'] == "date" || filterOptions['type'] == "date_past" )) { buildDateTimeFilterRow(field, operator, values); } else { - buildFilterRow(field, operator, values); + if (redminePluginLimitedVisibilityIsInstalled() && (filterOptions['type'] == "list_visibility")) { + buildListVisibilityFilterRow(field, operator, values); + } else { + buildFilterRow(field, operator, values); + } } } $('#cb_'+fieldId).prop('checked', true); - toggleFilter(field); + + if (redminePluginLimitedVisibilityIsInstalled() && ($("#operators_" + fieldId).val() == 'mine')) { + enableValues(field, []); + } else { + toggleFilter(field); + } + if(!redminePluginDatetimeCustomFieldInstalled()){ toggleMultiSelectIconInit(); } From d3c46836fe53a7a1fce69268d9694581a5e20722 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Tue, 9 Aug 2022 16:13:37 +0200 Subject: [PATCH 13/41] Fix performance issue when filtering by custom-values --- README.md | 1 + init.rb | 1 + .../issue_custom_field_patch.rb | 13 +++ lib/redmine_tiny_features/project_patch.rb | 79 ++++++++++++++++++- 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 lib/redmine_tiny_features/issue_custom_field_patch.rb diff --git a/README.md b/README.md index 15d7ed9..1b1bb3d 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Here is a complete list of the features: * **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) ## Test status diff --git a/init.rb b/init.rb index fc3b7e7..2371dd4 100644 --- a/init.rb +++ b/init.rb @@ -18,6 +18,7 @@ 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' end Redmine::Plugin.register :redmine_tiny_features do diff --git a/lib/redmine_tiny_features/issue_custom_field_patch.rb b/lib/redmine_tiny_features/issue_custom_field_patch.rb new file mode 100644 index 0000000..2fd38b0 --- /dev/null +++ b/lib/redmine_tiny_features/issue_custom_field_patch.rb @@ -0,0 +1,13 @@ +class IssueCustomField < CustomField + + def visibility_by_project_condition(project_key = nil, user = User.current, id_column = nil) + sql = super + id_column ||= id + tracker_condition = "#{Issue.table_name}.tracker_id IN (SELECT tracker_id FROM #{table_name_prefix}custom_fields_trackers#{table_name_suffix} WHERE custom_field_id = #{id_column})" + project_condition = "EXISTS (SELECT 1 FROM #{CustomField.table_name} ifa WHERE ifa.is_for_all = #{self.class.connection.quoted_true} AND ifa.id = #{id_column})" + + " OR #{Issue.table_name}.project_id IN (SELECT project_id FROM #{table_name_prefix}custom_fields_projects#{table_name_suffix} WHERE custom_field_id = #{id_column})" + + "((#{sql}) AND (#{tracker_condition}) AND (#{project_condition}) AND (#{Issue.visible_condition(user, { skip_pre_condition: true })}))" + end + +end diff --git a/lib/redmine_tiny_features/project_patch.rb b/lib/redmine_tiny_features/project_patch.rb index 85d3120..6e276d4 100644 --- a/lib/redmine_tiny_features/project_patch.rb +++ b/lib/redmine_tiny_features/project_patch.rb @@ -2,6 +2,83 @@ class Project < ActiveRecord::Base - has_many :disabled_custom_field_enumerations, :dependent => :delete_all + has_many :disabled_custom_field_enumerations, :dependent => :delete_all end + +module RedmineTinyFeatures + module ProjectPatch + + # Returns a SQL conditions string used to find all projects for which +user+ has the given +permission+ + # + # Valid options: + # * :skip_pre_condition => true don't check that the module is enabled (eg. when the condition is already set elsewhere in the query) + # * :project => project limit the condition to project + # * :with_subprojects => true limit the condition to project and its subprojects + # * :member => true limit the condition to the user projects + def allowed_to_condition(user, permission, options={}) + perm = Redmine::AccessControl.permission(permission) + if options[:skip_pre_condition] + base_statement = "1=1" + else + base_statement = if perm && perm.read? + "#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED}" + else + "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}" + end + if perm && perm.project_module + # If the permission belongs to a project module, make sure the module is enabled + base_statement += + " AND EXISTS (SELECT 1 AS one FROM #{EnabledModule.table_name} em" \ + " WHERE em.project_id = #{Project.table_name}.id" \ + " AND em.name='#{perm.project_module}')" + end + end + if project = options[:project] + project_statement = project.project_condition(options[:with_subprojects]) + base_statement = "(#{project_statement}) AND (#{base_statement})" + end + + if user.admin? + base_statement + else + statement_by_role = {} + unless options[:member] + role = user.builtin_role + if role.allowed_to?(permission) + s = "#{Project.table_name}.is_public = #{connection.quoted_true}" + if user.id + group = role.anonymous? ? Group.anonymous : Group.non_member + principal_ids = [user.id, group.id].compact + s = + "(#{s} AND #{Project.table_name}.id NOT IN " \ + "(SELECT project_id FROM #{Member.table_name} " \ + "WHERE user_id IN (#{principal_ids.join(',')})))" + end + statement_by_role[role] = s + end + end + user.project_ids_by_role.each do |role, project_ids| + if role.allowed_to?(permission) && project_ids.any? + statement_by_role[role] = "#{Project.table_name}.id IN (#{project_ids.join(',')})" + end + end + if statement_by_role.empty? + "1=0" + else + if block_given? + statement_by_role.each do |role, statement| + if s = yield(role, user) + statement_by_role[role] = "(#{statement} AND (#{s}))" + end + end + end + "((#{base_statement}) AND (#{statement_by_role.values.join(' OR ')}))" + end + end + end + + end +end + +Project.singleton_class.prepend RedmineTinyFeatures::ProjectPatch From f52597c7a5a080922e435c22372e304347726577 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Tue, 9 Aug 2022 17:32:53 +0200 Subject: [PATCH 14/41] Add missing dependency --- lib/redmine_tiny_features/issue_custom_field_patch.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/redmine_tiny_features/issue_custom_field_patch.rb b/lib/redmine_tiny_features/issue_custom_field_patch.rb index 2fd38b0..99d4ee8 100644 --- a/lib/redmine_tiny_features/issue_custom_field_patch.rb +++ b/lib/redmine_tiny_features/issue_custom_field_patch.rb @@ -1,3 +1,5 @@ +require 'issue_custom_field' + class IssueCustomField < CustomField def visibility_by_project_condition(project_key = nil, user = User.current, id_column = nil) From 641e53e58cb87af0570a50526e02dcd7a9cb24c9 Mon Sep 17 00:00:00 2001 From: Yazan ALAEDDIN Date: Fri, 9 Sep 2022 12:36:50 +0200 Subject: [PATCH 15/41] =?UTF-8?q?Pouvoir=20filtrer=20les=20projets=20par?= =?UTF-8?q?=20modules=20activ=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/en.yml | 1 + config/locales/fr.yml | 1 + init.rb | 1 + lib/redmine_tiny_features/project_patch.rb | 12 ++-- .../project_query_patch.rb | 38 ++++++++++++ spec/controllers/projects_controller_spec.rb | 61 +++++++++++++++++++ spec/models/project_query_spec.rb | 57 +++++++++++++++++ 7 files changed, 167 insertions(+), 4 deletions(-) create mode 100644 lib/redmine_tiny_features/project_query_patch.rb create mode 100644 spec/controllers/projects_controller_spec.rb create mode 100644 spec/models/project_query_spec.rb diff --git a/config/locales/en.yml b/config/locales/en.yml index 9349757..58ecc18 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -25,3 +25,4 @@ en: label_range: "Range" label_min_max_range: "Min / Max values" label_steps: "Step" + field_module_enabled: "Enabled modules" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index f2aab5c..d08ea96 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -25,3 +25,4 @@ fr: label_range: "Intervalle" label_min_max_range: "Valeurs minimale et maximale" label_steps: "Incrément" + field_module_enabled: "Modules activés" diff --git a/init.rb b/init.rb index 2371dd4..59969b4 100644 --- a/init.rb +++ b/init.rb @@ -19,6 +19,7 @@ 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 diff --git a/lib/redmine_tiny_features/project_patch.rb b/lib/redmine_tiny_features/project_patch.rb index 6e276d4..f294393 100644 --- a/lib/redmine_tiny_features/project_patch.rb +++ b/lib/redmine_tiny_features/project_patch.rb @@ -4,6 +4,10 @@ class Project < ActiveRecord::Base has_many :disabled_custom_field_enumerations, :dependent => :delete_all + def module_enabled + EnabledModule.where("project_id = ? ", self.id).map { |e_m| l("project_module_#{e_m.name}") } + end + end module RedmineTinyFeatures @@ -22,10 +26,10 @@ def allowed_to_condition(user, permission, options={}) base_statement = "1=1" else base_statement = if perm && perm.read? - "#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED}" - else - "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}" - end + "#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED}" + else + "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}" + end if perm && perm.project_module # If the permission belongs to a project module, make sure the module is enabled base_statement += diff --git a/lib/redmine_tiny_features/project_query_patch.rb b/lib/redmine_tiny_features/project_query_patch.rb new file mode 100644 index 0000000..41d2594 --- /dev/null +++ b/lib/redmine_tiny_features/project_query_patch.rb @@ -0,0 +1,38 @@ +require_dependency 'query' +require_dependency 'project_query' + +class ProjectQuery < Query + self.available_columns << QueryColumn.new(:module_enabled, :sortable => false, :default_order => 'asc') +end + +module PluginRedmineTinyFeatures + module ProjectQueryPatch + + def initialize_available_filters + super + + module_values = EnabledModule.all.collect { |s| [l("project_module_#{s.name}"), s.name] }.sort_by { |v| v.first }.uniq + add_available_filter("module_enabled", :type => :list_subprojects, :values => module_values) + end + + def sql_for_module_enabled_field(field, operator, value) + case operator + when "!*", "*" + module_enabled_table = EnabledModule.table_name + project_table = Project.table_name + #return only the projects for which a particular module or module group is activated + "#{project_table}.id #{ operator == '*' ? 'IN' : 'NOT IN' } (SELECT #{module_enabled_table}.project_id FROM #{module_enabled_table} " + + "JOIN #{project_table} ON #{module_enabled_table}.project_id = #{project_table}.id " + ') ' + when "=", "!" + module_enabled_table = EnabledModule.table_name + project_table = Project.table_name + #return only the projects for which a particular module or module group is activated + "#{project_table}.id #{ operator == '=' ? 'IN' : 'NOT IN' } (SELECT #{module_enabled_table}.project_id FROM #{module_enabled_table} " + + "JOIN #{project_table} ON #{module_enabled_table}.project_id = #{project_table}.id AND " + + sql_for_field('name', '=', value, module_enabled_table, 'name') + ') ' + end + end + end +end + +ProjectQuery.prepend PluginRedmineTinyFeatures::ProjectQueryPatch diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb new file mode 100644 index 0000000..b415625 --- /dev/null +++ b/spec/controllers/projects_controller_spec.rb @@ -0,0 +1,61 @@ +require "spec_helper" +require "active_support/testing/assertions" + +describe ProjectsController, type: :controller do + include ActiveSupport::Testing::Assertions + + render_views + + fixtures :users, :projects, :enabled_modules + + before do + @request.session[:user_id] = 1 #=> admin ; permissions are hard... + end + + context "Add a filter on the projects page: module activated" do + + it "should query use module_enabled when index with column module_enabled" do + columns = ['name', 'module_enabled'] + get :index, params: { :set_filter => 1, :c => columns } + expect(response).to be_successful + # query should use specified columns + query = assigns(:query) + + assert_kind_of ProjectQuery, query + expect(query.column_names.map(&:to_s)).to eq columns + end + + it "should ensure that the changes are compatible with the CSV" do + module_test = "issue_tracking" + columns = ['name', 'module_enabled'] + + get :index, params: { :set_filter => 1, + :f => ["module_enabled"], + :op => { "module_enabled" => "=" }, + :v => { "module_enabled" => [module_test] }, + :c => columns, + :format => 'csv' } + + expect(response).to be_successful + expect(response.media_type).to eq 'text/csv' + + lines = response.body.chomp.split("\n") + + expect(lines[0].split(',')[1]).to eq "Enabled modules" + + # projects for which the module Issue tracking is enabled + ids = EnabledModule.where(name: module_test).map{ |e_m| e_m.project_id } + # except the first line ( names of columns ) + expect(lines.count - 1).to eq(ids.count) + + project_csv = [] + + lines.count.times do |count| + project_csv.push( lines[count].split(',')[0]) if count > 0 + expect(lines[count].split(',').to_s).to include("Issue tracking") if count > 0 + end + + expect(project_csv.sort).to eq(Project.where(id: ids).map(&:name).sort) + end + end +end \ No newline at end of file diff --git a/spec/models/project_query_spec.rb b/spec/models/project_query_spec.rb new file mode 100644 index 0000000..5e92a51 --- /dev/null +++ b/spec/models/project_query_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' + +describe "ProjectQuery" do + fixtures :users, :projects, :enabled_modules + + before do + User.current = User.find(1) + end + + def find_projects_with_query(query) + Project.where( + query.statement + ).all + end + + it "should ProjectQuery have available_filters module_enabled" do + query = ProjectQuery.new + expect(query.available_filters).to include 'module_enabled' + end + + describe "should filter projects with module_enabled" do + let!(:module_test) { "wiki" } + + it "operator equal =" do + # projects for which the module wiki is enabled + ids = EnabledModule.where(name: module_test).map{|e_m| e_m.project_id } + query = ProjectQuery.new(:name => '_', :filters => { 'module_enabled' => { :operator => '=', :values => [module_test] } }) + result = find_projects_with_query(query) + + expect(result.count).to eq (ids.count) + expect(result.to_a).to eq(Project.where(id: ids)) + end + + it "operator not equal !" do + ids = EnabledModule.where(name: module_test).map{|e_m| e_m.project_id } + query = ProjectQuery.new(:name => '_', :filters => { 'module_enabled' => { :operator => '!', :values => [module_test] } }) + result = find_projects_with_query(query) + + expect(result.count).to eq ((Project.count - ids.count)) + expect(result.to_a).not_to eq(Project.where(id: ids)) + end + + it "operator all *" do + query = ProjectQuery.new(:name => '_', :filters => { 'module_enabled' => { :operator => '*', :values => [''] } }) + result = find_projects_with_query(query) + + expect(result.count).to eq (EnabledModule.all.map{ |e_m| e_m.project_id }.uniq.count) + end + + it "operator any !*" do + query = ProjectQuery.new(:name => '_', :filters => { 'module_enabled' => { :operator => '!*', :values => [''] } }) + result = find_projects_with_query(query) + + expect(result.count).to eq ((Project.all.map(&:id).uniq - EnabledModule.all.map{ |e_m| e_m.project_id }.uniq).count) + end + end +end From 3dd8805b7f41c407d006f5941f760fda51c01d0f Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Mon, 12 Sep 2022 16:22:49 +0200 Subject: [PATCH 16/41] Complete Readme and include new enabled-modules filter and column --- README.md | 1 + lib/redmine_tiny_features/project_patch.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b1bb3d..840c6a0 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Here is a complete list of the features: * 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 diff --git a/lib/redmine_tiny_features/project_patch.rb b/lib/redmine_tiny_features/project_patch.rb index f294393..81bf07d 100644 --- a/lib/redmine_tiny_features/project_patch.rb +++ b/lib/redmine_tiny_features/project_patch.rb @@ -5,7 +5,7 @@ class Project < ActiveRecord::Base has_many :disabled_custom_field_enumerations, :dependent => :delete_all def module_enabled - EnabledModule.where("project_id = ? ", self.id).map { |e_m| l("project_module_#{e_m.name}") } + EnabledModule.where("project_id = ? ", self.id).order(:name).map { |e_m| l("project_module_#{e_m.name}") } end end From 96a19ffed82765926ac044e086330de1da6a8729 Mon Sep 17 00:00:00 2001 From: Yalaeddin <89978016+Yalaeddin@users.noreply.github.com> Date: Wed, 5 Oct 2022 16:26:34 +0200 Subject: [PATCH 17/41] Forbid issue copy for specific trackers --- app/overrides/context_menus/issues.rb | 6 ++++ app/overrides/issues/_action_menu.rb | 6 ++++ app/overrides/trackers/_form.rb | 7 ++++ ...142452_add_trackers_prevent_copy_issues.rb | 5 +++ init.rb | 1 + lib/redmine_tiny_features/tracker_patch.rb | 3 ++ spec/models/tracker_query_spec.rb | 14 ++++++++ spec/system/issues_spec.rb | 32 +++++++++++++++++++ 8 files changed, 74 insertions(+) create mode 100644 app/overrides/context_menus/issues.rb create mode 100644 app/overrides/issues/_action_menu.rb create mode 100644 app/overrides/trackers/_form.rb create mode 100644 db/migrate/20221004142452_add_trackers_prevent_copy_issues.rb create mode 100644 lib/redmine_tiny_features/tracker_patch.rb create mode 100644 spec/models/tracker_query_spec.rb diff --git a/app/overrides/context_menus/issues.rb b/app/overrides/context_menus/issues.rb new file mode 100644 index 0000000..70904fd --- /dev/null +++ b/app/overrides/context_menus/issues.rb @@ -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 \ No newline at end of file diff --git a/app/overrides/issues/_action_menu.rb b/app/overrides/issues/_action_menu.rb new file mode 100644 index 0000000..e00b73a --- /dev/null +++ b/app/overrides/issues/_action_menu.rb @@ -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 \ No newline at end of file diff --git a/app/overrides/trackers/_form.rb b/app/overrides/trackers/_form.rb new file mode 100644 index 0000000..379f682 --- /dev/null +++ b/app/overrides/trackers/_form.rb @@ -0,0 +1,7 @@ +Deface::Override.new :virtual_path => "trackers/_form", + :name => "add-prevent-copy-issues", + :insert_after => "p:eq(2)", + :text => <<-EOS +

<%= f.check_box :prevent_copy_issues %>

+EOS + diff --git a/db/migrate/20221004142452_add_trackers_prevent_copy_issues.rb b/db/migrate/20221004142452_add_trackers_prevent_copy_issues.rb new file mode 100644 index 0000000..6ecde04 --- /dev/null +++ b/db/migrate/20221004142452_add_trackers_prevent_copy_issues.rb @@ -0,0 +1,5 @@ +class AddTrackersPreventCopyIssues < ActiveRecord::Migration[5.2] + def change + add_column :trackers, :prevent_copy_issues, :boolean, :default => false + end +end diff --git a/init.rb b/init.rb index 59969b4..9e18884 100644 --- a/init.rb +++ b/init.rb @@ -15,6 +15,7 @@ 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' diff --git a/lib/redmine_tiny_features/tracker_patch.rb b/lib/redmine_tiny_features/tracker_patch.rb new file mode 100644 index 0000000..a2db022 --- /dev/null +++ b/lib/redmine_tiny_features/tracker_patch.rb @@ -0,0 +1,3 @@ +class Tracker < ActiveRecord::Base + safe_attributes('prevent_copy_issues') +end \ No newline at end of file diff --git a/spec/models/tracker_query_spec.rb b/spec/models/tracker_query_spec.rb new file mode 100644 index 0000000..37a8afa --- /dev/null +++ b/spec/models/tracker_query_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe "TrackerPatch" do + fixtures :trackers + + it "should Tracker#prevent_copy_issues" do + tracker = Tracker.find(1) + tracker.safe_attributes=({ "prevent_copy_issues" => 1 }) + assert tracker.prevent_copy_issues + + tracker.safe_attributes=({ "prevent_copy_issues" => 0 }) + assert !tracker.prevent_copy_issues + end +end \ No newline at end of file diff --git a/spec/system/issues_spec.rb b/spec/system/issues_spec.rb index 9416000..3f49d05 100644 --- a/spec/system/issues_spec.rb +++ b/spec/system/issues_spec.rb @@ -115,5 +115,37 @@ def log_user(login, password) end end + describe "option prevent copy issues" do + it "Show link copy when its tracker allows copy issues page(issue/show)" do + visit 'issues/2' + expect(page).to have_selector('a' , class: 'icon-copy', text: 'Copy') + end + + it "Show link copy when its tracker allows copy issues page(issue/index)" do + visit 'issues/' + + find('tr#issue-2>td.buttons>a.icon-actions').click + expect(page).to have_selector('a.icon-copy') + end + + it "Hide link copy when its tracker prevents copy issues page(issue/show)" do + tracker_test = Tracker.find(2) + tracker_test.prevent_copy_issues = true + tracker_test.save + + visit 'issues/2' + expect(page).to_not have_selector('a', class: 'icon-copy', text: 'Copy') + end + + it "Hide link copy when its tracker prevents copy issues page(issue/index)" do + tracker_test = Tracker.find(2) + tracker_test.prevent_copy_issues = true + tracker_test.save + + visit 'issues/' + find('tr#issue-2>td.buttons>a.icon-actions').click + expect(page).to_not have_selector('a.icon-copy') + end + end end From 504e21fca15dca29bda380e672a7aa0a81ee7651 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Thu, 6 Oct 2022 15:29:24 +0200 Subject: [PATCH 18/41] Minor update in Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 840c6a0..4c59fcc 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Here is a complete list of the features: * Hide optional advanced fields in **version** form * 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 **roles synthesis** by adding missing data about issues permissions and trackers * 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 From 27a28b0f41c3049ad9827261aa27a06f0f8f0563 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Thu, 6 Oct 2022 15:41:37 +0200 Subject: [PATCH 19/41] Rename prevent-issue-copy attribute and complete Readme --- README.md | 1 + app/overrides/context_menus/issues.rb | 10 +++++----- app/overrides/issues/_action_menu.rb | 10 +++++----- app/overrides/trackers/_form.rb | 10 +++++----- config/locales/en.yml | 2 ++ config/locales/fr.yml | 1 + ...b => 003_add_trackers_prevent_copy_issues.rb} | 2 +- lib/redmine_tiny_features/tracker_patch.rb | 6 +++--- spec/models/tracker_query_spec.rb | 16 ++++++++-------- spec/system/issues_spec.rb | 10 +++++----- 10 files changed, 36 insertions(+), 32 deletions(-) rename db/migrate/{20221004142452_add_trackers_prevent_copy_issues.rb => 003_add_trackers_prevent_copy_issues.rb} (52%) diff --git a/README.md b/README.md index 4c59fcc..1150c8e 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Here is a complete list of the features: * 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 +* Add **prevent issue copy** attribute to trackers ## Test status diff --git a/app/overrides/context_menus/issues.rb b/app/overrides/context_menus/issues.rb index 70904fd..473f6f5 100644 --- a/app/overrides/context_menus/issues.rb +++ b/app/overrides/context_menus/issues.rb @@ -1,6 +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 \ No newline at end of file + :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_issue_copy +HIDE_LINK diff --git a/app/overrides/issues/_action_menu.rb b/app/overrides/issues/_action_menu.rb index e00b73a..f2a6552 100644 --- a/app/overrides/issues/_action_menu.rb +++ b/app/overrides/issues/_action_menu.rb @@ -1,6 +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 \ No newline at end of file + :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 diff --git a/app/overrides/trackers/_form.rb b/app/overrides/trackers/_form.rb index 379f682..5596f58 100644 --- a/app/overrides/trackers/_form.rb +++ b/app/overrides/trackers/_form.rb @@ -1,7 +1,7 @@ -Deface::Override.new :virtual_path => "trackers/_form", - :name => "add-prevent-copy-issues", - :insert_after => "p:eq(2)", - :text => <<-EOS -

<%= f.check_box :prevent_copy_issues %>

+Deface::Override.new :virtual_path => "trackers/_form", + :name => "add-prevent-copy-issues", + :insert_after => "p:eq(2)", + :text => <<-EOS +

<%= f.check_box :prevent_issue_copy %>

EOS diff --git a/config/locales/en.yml b/config/locales/en.yml index 58ecc18..7ef8287 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -26,3 +26,5 @@ en: label_min_max_range: "Min / Max values" label_steps: "Step" field_module_enabled: "Enabled modules" + field_prevent_issue_copy: "Prevent issue copy" + diff --git a/config/locales/fr.yml b/config/locales/fr.yml index d08ea96..e663bb3 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -26,3 +26,4 @@ fr: label_min_max_range: "Valeurs minimale et maximale" label_steps: "Incrément" field_module_enabled: "Modules activés" + field_prevent_issue_copy: "Empêcher la copie de demandes" diff --git a/db/migrate/20221004142452_add_trackers_prevent_copy_issues.rb b/db/migrate/003_add_trackers_prevent_copy_issues.rb similarity index 52% rename from db/migrate/20221004142452_add_trackers_prevent_copy_issues.rb rename to db/migrate/003_add_trackers_prevent_copy_issues.rb index 6ecde04..482bab4 100644 --- a/db/migrate/20221004142452_add_trackers_prevent_copy_issues.rb +++ b/db/migrate/003_add_trackers_prevent_copy_issues.rb @@ -1,5 +1,5 @@ class AddTrackersPreventCopyIssues < ActiveRecord::Migration[5.2] def change - add_column :trackers, :prevent_copy_issues, :boolean, :default => false + add_column :trackers, :prevent_issue_copy, :boolean, :default => false end end diff --git a/lib/redmine_tiny_features/tracker_patch.rb b/lib/redmine_tiny_features/tracker_patch.rb index a2db022..4877708 100644 --- a/lib/redmine_tiny_features/tracker_patch.rb +++ b/lib/redmine_tiny_features/tracker_patch.rb @@ -1,3 +1,3 @@ -class Tracker < ActiveRecord::Base - safe_attributes('prevent_copy_issues') -end \ No newline at end of file +class Tracker < ActiveRecord::Base + safe_attributes('prevent_issue_copy') +end diff --git a/spec/models/tracker_query_spec.rb b/spec/models/tracker_query_spec.rb index 37a8afa..2bcc8ab 100644 --- a/spec/models/tracker_query_spec.rb +++ b/spec/models/tracker_query_spec.rb @@ -2,13 +2,13 @@ describe "TrackerPatch" do fixtures :trackers - - it "should Tracker#prevent_copy_issues" do + + it "should Tracker#prevent_issue_copy" do tracker = Tracker.find(1) - tracker.safe_attributes=({ "prevent_copy_issues" => 1 }) - assert tracker.prevent_copy_issues - - tracker.safe_attributes=({ "prevent_copy_issues" => 0 }) - assert !tracker.prevent_copy_issues + tracker.safe_attributes = ({ "prevent_issue_copy" => 1 }) + assert tracker.prevent_issue_copy + + tracker.safe_attributes = ({ "prevent_issue_copy" => 0 }) + assert !tracker.prevent_issue_copy end -end \ No newline at end of file +end diff --git a/spec/system/issues_spec.rb b/spec/system/issues_spec.rb index 3f49d05..0e02dc9 100644 --- a/spec/system/issues_spec.rb +++ b/spec/system/issues_spec.rb @@ -118,19 +118,19 @@ def log_user(login, password) describe "option prevent copy issues" do it "Show link copy when its tracker allows copy issues page(issue/show)" do visit 'issues/2' - expect(page).to have_selector('a' , class: 'icon-copy', text: 'Copy') + expect(page).to have_selector('a', class: 'icon-copy', text: 'Copy') end it "Show link copy when its tracker allows copy issues page(issue/index)" do visit 'issues/' - + find('tr#issue-2>td.buttons>a.icon-actions').click expect(page).to have_selector('a.icon-copy') end it "Hide link copy when its tracker prevents copy issues page(issue/show)" do tracker_test = Tracker.find(2) - tracker_test.prevent_copy_issues = true + tracker_test.prevent_issue_copy = true tracker_test.save visit 'issues/2' @@ -139,10 +139,10 @@ def log_user(login, password) it "Hide link copy when its tracker prevents copy issues page(issue/index)" do tracker_test = Tracker.find(2) - tracker_test.prevent_copy_issues = true + tracker_test.prevent_issue_copy = true tracker_test.save - visit 'issues/' + visit 'issues/' find('tr#issue-2>td.buttons>a.icon-actions').click expect(page).to_not have_selector('a.icon-copy') end From 4f65d91254524223fe224145eb3e5e571261458b Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Mon, 24 Oct 2022 20:45:36 +0200 Subject: [PATCH 20/41] Puma 6 is breaking capybara test - Keep using Puma 5 for now in tests --- Gemfile | 1 + 1 file changed, 1 insertion(+) create mode 100644 Gemfile diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..ff1ed44 --- /dev/null +++ b/Gemfile @@ -0,0 +1 @@ +gem 'puma', '~> 5.6.5' if Rails.env.test? From 30ae7cba95cb08b2e4c669da50e150579fb7883a Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Mon, 24 Oct 2022 21:00:53 +0200 Subject: [PATCH 21/41] Revert previous patch - Perfs must have been fixed in Redmine 4.2.8 --- README.md | 1 - init.rb | 1 - .../issue_custom_field_patch.rb | 15 ---- lib/redmine_tiny_features/project_patch.rb | 77 ------------------- 4 files changed, 94 deletions(-) delete mode 100644 lib/redmine_tiny_features/issue_custom_field_patch.rb diff --git a/README.md b/README.md index 1150c8e..2c7a4a4 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,6 @@ Here is a complete list of the features: * **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 * Add **prevent issue copy** attribute to trackers diff --git a/init.rb b/init.rb index 9e18884..6b88e15 100644 --- a/init.rb +++ b/init.rb @@ -19,7 +19,6 @@ 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 diff --git a/lib/redmine_tiny_features/issue_custom_field_patch.rb b/lib/redmine_tiny_features/issue_custom_field_patch.rb deleted file mode 100644 index 99d4ee8..0000000 --- a/lib/redmine_tiny_features/issue_custom_field_patch.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'issue_custom_field' - -class IssueCustomField < CustomField - - def visibility_by_project_condition(project_key = nil, user = User.current, id_column = nil) - sql = super - id_column ||= id - tracker_condition = "#{Issue.table_name}.tracker_id IN (SELECT tracker_id FROM #{table_name_prefix}custom_fields_trackers#{table_name_suffix} WHERE custom_field_id = #{id_column})" - project_condition = "EXISTS (SELECT 1 FROM #{CustomField.table_name} ifa WHERE ifa.is_for_all = #{self.class.connection.quoted_true} AND ifa.id = #{id_column})" + - " OR #{Issue.table_name}.project_id IN (SELECT project_id FROM #{table_name_prefix}custom_fields_projects#{table_name_suffix} WHERE custom_field_id = #{id_column})" - - "((#{sql}) AND (#{tracker_condition}) AND (#{project_condition}) AND (#{Issue.visible_condition(user, { skip_pre_condition: true })}))" - end - -end diff --git a/lib/redmine_tiny_features/project_patch.rb b/lib/redmine_tiny_features/project_patch.rb index 81bf07d..2e7b9e8 100644 --- a/lib/redmine_tiny_features/project_patch.rb +++ b/lib/redmine_tiny_features/project_patch.rb @@ -9,80 +9,3 @@ def module_enabled end end - -module RedmineTinyFeatures - module ProjectPatch - - # Returns a SQL conditions string used to find all projects for which +user+ has the given +permission+ - # - # Valid options: - # * :skip_pre_condition => true don't check that the module is enabled (eg. when the condition is already set elsewhere in the query) - # * :project => project limit the condition to project - # * :with_subprojects => true limit the condition to project and its subprojects - # * :member => true limit the condition to the user projects - def allowed_to_condition(user, permission, options={}) - perm = Redmine::AccessControl.permission(permission) - if options[:skip_pre_condition] - base_statement = "1=1" - else - base_statement = if perm && perm.read? - "#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED}" - else - "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}" - end - if perm && perm.project_module - # If the permission belongs to a project module, make sure the module is enabled - base_statement += - " AND EXISTS (SELECT 1 AS one FROM #{EnabledModule.table_name} em" \ - " WHERE em.project_id = #{Project.table_name}.id" \ - " AND em.name='#{perm.project_module}')" - end - end - if project = options[:project] - project_statement = project.project_condition(options[:with_subprojects]) - base_statement = "(#{project_statement}) AND (#{base_statement})" - end - - if user.admin? - base_statement - else - statement_by_role = {} - unless options[:member] - role = user.builtin_role - if role.allowed_to?(permission) - s = "#{Project.table_name}.is_public = #{connection.quoted_true}" - if user.id - group = role.anonymous? ? Group.anonymous : Group.non_member - principal_ids = [user.id, group.id].compact - s = - "(#{s} AND #{Project.table_name}.id NOT IN " \ - "(SELECT project_id FROM #{Member.table_name} " \ - "WHERE user_id IN (#{principal_ids.join(',')})))" - end - statement_by_role[role] = s - end - end - user.project_ids_by_role.each do |role, project_ids| - if role.allowed_to?(permission) && project_ids.any? - statement_by_role[role] = "#{Project.table_name}.id IN (#{project_ids.join(',')})" - end - end - if statement_by_role.empty? - "1=0" - else - if block_given? - statement_by_role.each do |role, statement| - if s = yield(role, user) - statement_by_role[role] = "(#{statement} AND (#{s}))" - end - end - end - "((#{base_statement}) AND (#{statement_by_role.values.join(' OR ')}))" - end - end - end - - end -end - -Project.singleton_class.prepend RedmineTinyFeatures::ProjectPatch From 761883550e01a88adcdf3ccd961975347559b007 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Mon, 24 Oct 2022 21:10:29 +0200 Subject: [PATCH 22/41] Fix Gemfile --- Gemfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index ff1ed44..a14412f 100644 --- a/Gemfile +++ b/Gemfile @@ -1 +1,3 @@ -gem 'puma', '~> 5.6.5' if Rails.env.test? +group :test do + gem 'puma', '~> 5.6.5' +end From a377e7da4f29a79b959ebf4b8211aa880047bddf Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Mon, 24 Oct 2022 21:13:30 +0200 Subject: [PATCH 23/41] Remove Gemfile --- Gemfile | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 Gemfile diff --git a/Gemfile b/Gemfile deleted file mode 100644 index a14412f..0000000 --- a/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -group :test do - gem 'puma', '~> 5.6.5' -end From 3bf295262e5f9dbf624be4d9c7a3f6f0cace9f0a Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Tue, 25 Oct 2022 09:40:51 +0200 Subject: [PATCH 24/41] CI config: keep using Puma 5 for now - Capybara tests are broken with Puma 6 --- .github/workflows/4_2_7.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/4_2_7.yml b/.github/workflows/4_2_7.yml index e15d0c8..639dbb5 100644 --- a/.github/workflows/4_2_7.yml +++ b/.github/workflows/4_2_7.yml @@ -88,6 +88,7 @@ jobs: - name: Prepare Redmine source working-directory: redmine run: | + sed -i -e 's/.*puma.*/ gem "puma", "< 6"/' Gemfile sed -i '/rubocop/d' Gemfile rm -f .rubocop* cp plugins/redmine_base_rspec/spec/support/database-${{ matrix.db }}.yml config/database.yml From 9360c13e9bf03bf192efe6ac49fd8f95d348d86b Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Tue, 15 Nov 2022 16:25:55 +0100 Subject: [PATCH 25/41] Update CI config: use actions-checkout-v3 which depends on node 16 instead of node 12 --- .github/workflows/4_1_7.yml | 13 +++++++------ .github/workflows/4_2_7.yml | 13 +++++++------ .github/workflows/master.yml | 13 +++++++------ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.github/workflows/4_1_7.yml b/.github/workflows/4_1_7.yml index e04974a..643e3cb 100644 --- a/.github/workflows/4_1_7.yml +++ b/.github/workflows/4_1_7.yml @@ -37,7 +37,7 @@ jobs: steps: - name: Checkout Redmine - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: redmine/redmine ref: ${{ env.REDMINE_VERSION }} @@ -72,15 +72,16 @@ jobs: sudo mv policy.xml /etc/ImageMagick-6/policy.xml - name: Setup Ruby - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Setup Bundler run: gem install bundler -v '~> 1.0' - name: Checkout dependencies - Base RSpec plugin - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: jbbarth/redmine_base_rspec path: redmine/plugins/redmine_base_rspec @@ -113,19 +114,19 @@ jobs: bundle exec rails test:scm:setup:subversion - name: Checkout dependencies - Base Deface plugin - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: jbbarth/redmine_base_deface path: redmine/plugins/redmine_base_deface - name: Checkout dependencies - Base StimulusJS plugin - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: nanego/redmine_base_stimulusjs path: redmine/plugins/redmine_base_stimulusjs - name: Checkout plugin - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: redmine/plugins/${{ env.PLUGIN_NAME }} diff --git a/.github/workflows/4_2_7.yml b/.github/workflows/4_2_7.yml index 639dbb5..bb86ece 100644 --- a/.github/workflows/4_2_7.yml +++ b/.github/workflows/4_2_7.yml @@ -37,7 +37,7 @@ jobs: steps: - name: Checkout Redmine - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: redmine/redmine ref: ${{ env.REDMINE_VERSION }} @@ -72,15 +72,16 @@ jobs: sudo mv policy.xml /etc/ImageMagick-6/policy.xml - name: Setup Ruby - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Setup Bundler run: gem install bundler -v '~> 1.0' - name: Checkout dependencies - Base RSpec plugin - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: jbbarth/redmine_base_rspec path: redmine/plugins/redmine_base_rspec @@ -114,19 +115,19 @@ jobs: bundle exec rails test:scm:setup:subversion - name: Checkout dependencies - Base Deface plugin - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: jbbarth/redmine_base_deface path: redmine/plugins/redmine_base_deface - name: Checkout dependencies - Base StimulusJS plugin - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: nanego/redmine_base_stimulusjs path: redmine/plugins/redmine_base_stimulusjs - name: Checkout plugin - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: redmine/plugins/${{ env.PLUGIN_NAME }} diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index d555e3b..5a2fa00 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -37,7 +37,7 @@ jobs: steps: - name: Checkout Redmine - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: redmine/redmine ref: ${{ env.REDMINE_VERSION }} @@ -72,15 +72,16 @@ jobs: sudo mv policy.xml /etc/ImageMagick-6/policy.xml - name: Setup Ruby - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Setup Bundler run: gem install bundler -v '~> 1.0' - name: Checkout dependencies - Base RSpec plugin - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: jbbarth/redmine_base_rspec path: redmine/plugins/redmine_base_rspec @@ -113,19 +114,19 @@ jobs: bundle exec rails test:scm:setup:subversion - name: Checkout dependencies - Base Deface plugin - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: jbbarth/redmine_base_deface path: redmine/plugins/redmine_base_deface - name: Checkout dependencies - Base StimulusJS plugin - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: nanego/redmine_base_stimulusjs path: redmine/plugins/redmine_base_stimulusjs - name: Checkout plugin - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: redmine/plugins/${{ env.PLUGIN_NAME }} From 2f4f68428dc4929dcc7e10c333f902621f9a6c2a Mon Sep 17 00:00:00 2001 From: Yalaeddin <89978016+Yalaeddin@users.noreply.github.com> Date: Tue, 15 Nov 2022 16:25:09 +0100 Subject: [PATCH 26/41] Add ability to disable hidden-mails-addresses feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Pouvoir désactiver la fonction de masquage des emails * Masquer l'option "Cacher mon adresse mail" quand l'option "Désactiver la fonction de masquage des emails" est activé * Nouvelle permissions permettant de voir facilement toutes les adresses mails d'un utilisateur --- app/overrides/users/_preferences.rb | 8 +++ app/overrides/users/show.rb | 6 ++ ...ine_plugin_tiny_features_settings.html.erb | 8 +++ config/locales/en.yml | 3 + config/locales/fr.yml | 3 + init.rb | 8 ++- spec/controllers/users_controller_spec.rb | 59 +++++++++++++++++++ 7 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 app/overrides/users/_preferences.rb create mode 100644 app/overrides/users/show.rb create mode 100644 spec/controllers/users_controller_spec.rb diff --git a/app/overrides/users/_preferences.rb b/app/overrides/users/_preferences.rb new file mode 100644 index 0000000..cc4fc4f --- /dev/null +++ b/app/overrides/users/_preferences.rb @@ -0,0 +1,8 @@ +Deface::Override.new :virtual_path => "users/_preferences", + :name => "add-condition-disable_email_hiding_before_check_box_hide_mail", + :surround => 'p:contains("check_box :hide_mail")', + :text => < + <%= render_original %> +<% end %> +STRING_EMAIL \ No newline at end of file diff --git a/app/overrides/users/show.rb b/app/overrides/users/show.rb new file mode 100644 index 0000000..2ab2dbf --- /dev/null +++ b/app/overrides/users/show.rb @@ -0,0 +1,6 @@ +Deface::Override.new :virtual_path => "users/show", + :name => "add-condition-disable_email_hiding", + :replace => "erb[silent]:contains('unless @user.pref.hide_mail')", + :text => < true) %> +STRING_EMAIL 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 7f28a7c..8f33cb2 100644 --- a/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb +++ b/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb @@ -59,6 +59,14 @@ <% end %>

+ +

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

+ <%= javascript_tag do %> $(function() { if ((typeof $().select2) === 'function') { diff --git a/config/locales/en.yml b/config/locales/en.yml index 7ef8287..673ef71 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -27,4 +27,7 @@ en: label_steps: "Step" field_module_enabled: "Enabled modules" field_prevent_issue_copy: "Prevent issue copy" + setting_disable_email_hiding: "Disable the emails hiding function" + permission_always_see_user_email_addresses: "Always see user email addresses" + project_module_user_email: "User email addresses" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index e663bb3..5352344 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -27,3 +27,6 @@ fr: label_steps: "Incrément" field_module_enabled: "Modules activés" field_prevent_issue_copy: "Empêcher la copie de demandes" + setting_disable_email_hiding: "Désactiver la fonction de masquage des emails" + permission_always_see_user_email_addresses: "Toujours voir les adresses mail des utilisateurs" + project_module_user_email: "Adresses mail des utilisateurs" diff --git a/init.rb b/init.rb index 6b88e15..8b5d1d2 100644 --- a/init.rb +++ b/init.rb @@ -31,7 +31,10 @@ author_url 'https://github.com/nanego' requires_redmine_plugin :redmine_base_rspec, :version_or_higher => '0.0.4' if Rails.env.test? requires_redmine_plugin :redmine_base_deface, :version_or_higher => '0.0.1' - permission :manage_project_enumerations, {} + + project_module :user_email do + permission :always_see_user_email_addresses ,{} + end settings partial: 'settings/redmine_plugin_tiny_features_settings', default: { 'warning_message_on_closed_issues': '1', @@ -40,6 +43,7 @@ 'default_project': '', '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' + 'use_select2': Rails.env.test? || !(Redmine::Plugin.installed?(:redmine_base_select2)) ? '0' : '1', + 'disable_email_hiding': '', } end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb new file mode 100644 index 0000000..4662f5e --- /dev/null +++ b/spec/controllers/users_controller_spec.rb @@ -0,0 +1,59 @@ +require "spec_helper" +require "active_support/testing/assertions" + +describe UsersController, type: :controller do + include ActiveSupport::Testing::Assertions + + render_views + + fixtures :users, :email_addresses + + before do + @request.session[:user_id] = 1 #=> admin ; permissions are hard... + end + + context "Disable emails hiding function" do + + it "should show user's email when the option is selected, even if the user hides his email" do + Setting["plugin_redmine_tiny_features"]["disable_email_hiding"] = '1' + expect(User.find(2).pref.hide_mail).to eq true + get :show, params: { :id => 2 } + + expect(response.body).to include(User.find(2).mail) + end + + it "should hide user's email when the option is unselected, if the user hides his email" do + @request.session[:user_id] = 3 + Setting["plugin_redmine_tiny_features"]["disable_email_hiding"] = '' + expect(User.find(2).pref.hide_mail).to eq true + get :show, params: { :id => 2 } + + expect(response.body).to_not include(User.find(2).mail) + end + + it "should hide the option (Hide my email address) when the option is selected" do + Setting["plugin_redmine_tiny_features"]["disable_email_hiding"] = '1' + get :edit, params: { :id => 2 } + expect(response.body).to_not include("Hide my email address") + end + + it "should show the option (Hide my email address) when the option is unselected" do + Setting["plugin_redmine_tiny_features"]["disable_email_hiding"] = '' + get :edit, params: { :id => 2 } + expect(response.body).to include("Hide my email address") + end + + it "should show user's email when the current use has the permission always_see_user_email_addresses" do + User.current = User.find(1) + role_test = Role.find(1) + role_test.add_permission!(:always_see_user_email_addresses) + role_test.save + + expect(User.find(2).pref.hide_mail).to eq true + get :show, params: { :id => 2 } + + expect(response.body).to include(User.find(2).mail) + end + end + +end \ No newline at end of file From 48c9c34a21c88fe1f671b5f92349015405804303 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Wed, 7 Dec 2022 15:37:05 +0100 Subject: [PATCH 27/41] Update CI config: add latest Redmine releases --- .github/workflows/{4_2_7.yml => 4_2_9.yml} | 4 ++-- README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename .github/workflows/{4_2_7.yml => 4_2_9.yml} (99%) diff --git a/.github/workflows/4_2_7.yml b/.github/workflows/4_2_9.yml similarity index 99% rename from .github/workflows/4_2_7.yml rename to .github/workflows/4_2_9.yml index bb86ece..13560ff 100644 --- a/.github/workflows/4_2_7.yml +++ b/.github/workflows/4_2_9.yml @@ -1,8 +1,8 @@ -name: Tests 4.2.7 +name: Tests 4.2.9 env: PLUGIN_NAME: redmine_tiny_features - REDMINE_VERSION: 4.2.7 + REDMINE_VERSION: 4.2.9 RAILS_ENV: test on: diff --git a/README.md b/README.md index 2c7a4a4..3f31f88 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,11 @@ Here is a complete list of the features: |Plugin branch| Redmine Version | Test Status | |-------------|-------------------|------------------| -|master | 4.2.7 | [![4.2.7][1]][5] | +|master | 4.2.9 | [![4.2.9][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_7.yml/badge.svg +[1]: https://github.com/nanego/redmine_tiny_features/actions/workflows/4_2_9.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 From 9ed26e6a82d463d2ea8eb200c021b0c938785e96 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Tue, 17 Jan 2023 16:15:51 +0100 Subject: [PATCH 28/41] Update CI config: use Ruby 2.7 when testing Redmine 4.2 --- .github/workflows/4_1_7.yml | 2 +- .github/workflows/4_2_9.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/4_1_7.yml b/.github/workflows/4_1_7.yml index 643e3cb..622a054 100644 --- a/.github/workflows/4_1_7.yml +++ b/.github/workflows/4_1_7.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - ruby: ['2.6'] + ruby: ['2.7'] db: ['postgres'] fail-fast: false diff --git a/.github/workflows/4_2_9.yml b/.github/workflows/4_2_9.yml index 13560ff..20c4194 100644 --- a/.github/workflows/4_2_9.yml +++ b/.github/workflows/4_2_9.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - ruby: ['2.6'] + ruby: ['2.7'] db: ['postgres'] fail-fast: false From f74c00bf730bc59f625cff859cf59a3a2c7d262e Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Tue, 17 Jan 2023 16:47:06 +0100 Subject: [PATCH 29/41] CI config: keep using Ruby 2.6 with Redmine 4.1 --- .github/workflows/4_1_7.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/4_1_7.yml b/.github/workflows/4_1_7.yml index 622a054..643e3cb 100644 --- a/.github/workflows/4_1_7.yml +++ b/.github/workflows/4_1_7.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - ruby: ['2.7'] + ruby: ['2.6'] db: ['postgres'] fail-fast: false From 2bcfb52aa1fb55cba51377fc79e7afbe186b4a87 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Thu, 19 Jan 2023 16:17:31 +0100 Subject: [PATCH 30/41] Complete Readme with latest added feature --- README.md | 1 + app/overrides/users/_preferences.rb | 4 ++-- app/overrides/users/show.rb | 10 +++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3f31f88..8c4a00a 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Here is a complete list of the features: * Apply **default value** to existing-issues custom-fields if field is required and not set * Add **enabled modules** filter and column in projects list * Add **prevent issue copy** attribute to trackers +* Add new permission to always see **users's email addresses**, bypassing user email_hiding setting ## Test status diff --git a/app/overrides/users/_preferences.rb b/app/overrides/users/_preferences.rb index cc4fc4f..c6ef768 100644 --- a/app/overrides/users/_preferences.rb +++ b/app/overrides/users/_preferences.rb @@ -2,7 +2,7 @@ :name => "add-condition-disable_email_hiding_before_check_box_hide_mail", :surround => 'p:contains("check_box :hide_mail")', :text => < +<% if Setting["plugin_redmine_tiny_features"]["disable_email_hiding"].blank? %> <%= render_original %> <% end %> -STRING_EMAIL \ No newline at end of file +STRING_EMAIL diff --git a/app/overrides/users/show.rb b/app/overrides/users/show.rb index 2ab2dbf..05e4f64 100644 --- a/app/overrides/users/show.rb +++ b/app/overrides/users/show.rb @@ -1,6 +1,6 @@ -Deface::Override.new :virtual_path => "users/show", - :name => "add-condition-disable_email_hiding", - :replace => "erb[silent]:contains('unless @user.pref.hide_mail')", - :text => < true) %> +Deface::Override.new :virtual_path => "users/show", + :name => "add-condition-disable_email_hiding", + :replace => "erb[silent]:contains('unless @user.pref.hide_mail')", + :text => < true) %> STRING_EMAIL From cbb1f1be8b7798a3c81b92b6cda2727f62a210c1 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Thu, 19 Jan 2023 16:34:25 +0100 Subject: [PATCH 31/41] No need to create a new module to add this permission --- init.rb | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/init.rb b/init.rb index 8b5d1d2..18e304e 100644 --- a/init.rb +++ b/init.rb @@ -31,19 +31,18 @@ author_url 'https://github.com/nanego' requires_redmine_plugin :redmine_base_rspec, :version_or_higher => '0.0.4' if Rails.env.test? requires_redmine_plugin :redmine_base_deface, :version_or_higher => '0.0.1' - - project_module :user_email do - permission :always_see_user_email_addresses ,{} - end + + permission :always_see_user_email_addresses, {} + settings partial: 'settings/redmine_plugin_tiny_features_settings', default: { - 'warning_message_on_closed_issues': '1', - 'open_issue_when_editing_closed_issues': '', - 'simplified_version_form': '1', - 'default_project': '', - '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', - 'disable_email_hiding': '', + 'warning_message_on_closed_issues': '1', + 'open_issue_when_editing_closed_issues': '', + 'simplified_version_form': '1', + 'default_project': '', + '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', + 'disable_email_hiding': '', } end From 77e0e33a004b7b15b63d53a0e0d2a7e48ea480ff Mon Sep 17 00:00:00 2001 From: Yalaeddin Date: Fri, 6 Jan 2023 14:14:41 +0100 Subject: [PATCH 32/41] =?UTF-8?q?R=C3=A9duire=20le=20temps=20de=20chargeme?= =?UTF-8?q?nt=20de=20la=20page=20de=20visualisation=20d'une=20demande?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/overrides/issues/_action_menu.rb | 19 +++++++++++++++++++ app/overrides/issues/_action_menu_edit.rb | 3 +++ spec/system/issues_spec.rb | 7 +++++++ 3 files changed, 29 insertions(+) create mode 100644 app/overrides/issues/_action_menu_edit.rb diff --git a/app/overrides/issues/_action_menu.rb b/app/overrides/issues/_action_menu.rb index f2a6552..4143ba9 100644 --- a/app/overrides/issues/_action_menu.rb +++ b/app/overrides/issues/_action_menu.rb @@ -4,3 +4,22 @@ :text => <<-HIDE_LINK && !@issue.tracker.prevent_issue_copy HIDE_LINK +Deface::Override.new :virtual_path => 'issues/_action_menu', + :name => 'render-partial-edit-only-on-click-button-edit', + :replace => "erb[loud]:contains('l(:button_edit)')", + :text => <<-RENDER_PARTIAL +<%= link_to l(:button_edit), edit_issue_path(@issue), + :onclick => 'renderPartialEdit();showAndScrollTo("update", "issue_notes"); return false;', + :class => 'icon icon-edit', :accesskey => accesskey(:edit) if @issue.editable? %> + +RENDER_PARTIAL + diff --git a/app/overrides/issues/_action_menu_edit.rb b/app/overrides/issues/_action_menu_edit.rb new file mode 100644 index 0000000..60dc6dc --- /dev/null +++ b/app/overrides/issues/_action_menu_edit.rb @@ -0,0 +1,3 @@ +Deface::Override.new :virtual_path => 'issues/_action_menu_edit', + :name => 'prevents-render-edit-partial-render-it-only-on-click-button-edit', + :remove => "erb[loud]:contains(\"render :partial => 'edit'\")" \ No newline at end of file diff --git a/spec/system/issues_spec.rb b/spec/system/issues_spec.rb index 0e02dc9..5af346a 100644 --- a/spec/system/issues_spec.rb +++ b/spec/system/issues_spec.rb @@ -146,6 +146,13 @@ def log_user(login, password) find('tr#issue-2>td.buttons>a.icon-actions').click expect(page).to_not have_selector('a.icon-copy') end + + it "only on click button edit" do + visit 'issues/2' + expect(page).to_not have_selector('#issue-form', visible: :hidden) + find('.icon-edit', match: :first).click + expect(page).to have_selector('#issue-form') + end end end From 7be173e2ab3bbb511971209455992e0ed6829e6a Mon Sep 17 00:00:00 2001 From: Yalaeddin Date: Tue, 10 Jan 2023 09:41:35 +0100 Subject: [PATCH 33/41] Ajouer l'option load_issue_edit dans la configuration de ce plugin --- app/overrides/issues/_action_menu.rb | 25 ------------- app/overrides/issues/_action_menu_edit.rb | 35 +++++++++++++++++-- ...ine_plugin_tiny_features_settings.html.erb | 12 ++++--- config/locales/en.yml | 2 +- config/locales/fr.yml | 1 + init.rb | 22 ++++++------ spec/system/issues_spec.rb | 16 +++++++-- 7 files changed, 69 insertions(+), 44 deletions(-) delete mode 100644 app/overrides/issues/_action_menu.rb diff --git a/app/overrides/issues/_action_menu.rb b/app/overrides/issues/_action_menu.rb deleted file mode 100644 index 4143ba9..0000000 --- a/app/overrides/issues/_action_menu.rb +++ /dev/null @@ -1,25 +0,0 @@ -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_issue_copy -HIDE_LINK -Deface::Override.new :virtual_path => 'issues/_action_menu', - :name => 'render-partial-edit-only-on-click-button-edit', - :replace => "erb[loud]:contains('l(:button_edit)')", - :text => <<-RENDER_PARTIAL -<%= link_to l(:button_edit), edit_issue_path(@issue), - :onclick => 'renderPartialEdit();showAndScrollTo("update", "issue_notes"); return false;', - :class => 'icon icon-edit', :accesskey => accesskey(:edit) if @issue.editable? %> - -RENDER_PARTIAL - diff --git a/app/overrides/issues/_action_menu_edit.rb b/app/overrides/issues/_action_menu_edit.rb index 60dc6dc..334c6d5 100644 --- a/app/overrides/issues/_action_menu_edit.rb +++ b/app/overrides/issues/_action_menu_edit.rb @@ -1,3 +1,34 @@ Deface::Override.new :virtual_path => 'issues/_action_menu_edit', - :name => 'prevents-render-edit-partial-render-it-only-on-click-button-edit', - :remove => "erb[loud]:contains(\"render :partial => 'edit'\")" \ No newline at end of file + :name => 'prevents-render-edit-partial-render-it-only-on-click-button-edit', + :replace => "erb[loud]:contains(\"render :partial => 'edit'\")", + :text => <<-RENDER_PARTIAL +# Put the condition here, not at the beginning of the file, so that we can check the configuration each time we download the page, +# if we put the condition at the beginning of the file it does not execute only once, (start application) +<% if Setting.plugin_redmine_tiny_features.key?('load_issue_edit') %> + + +<% else %> + <%= render :partial => 'edit' %> +<% end %> +RENDER_PARTIAL 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 8f33cb2..69cb8a2 100644 --- a/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb +++ b/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb @@ -13,7 +13,7 @@

<%= label_tag l("default_open_status") %> <%= select_tag "settings[default_open_status]", options_for_select(IssueStatus.where(is_closed: false).sorted.map { |status| [status.name, status.id] }, - selected: Setting["plugin_redmine_tiny_features"]["default_open_status"]) %> + selected: Setting["plugin_redmine_tiny_features"]["default_open_status"]) %>


@@ -67,6 +67,13 @@ <% end %>

+

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

+ <%= javascript_tag do %> $(function() { if ((typeof $().select2) === 'function') { @@ -94,6 +101,3 @@ // Add to disabled option pagination when select2 option is not checked when the page is launched hidePagination() <% end %> - - - diff --git a/config/locales/en.yml b/config/locales/en.yml index 673ef71..0edc59c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -30,4 +30,4 @@ en: setting_disable_email_hiding: "Disable the emails hiding function" permission_always_see_user_email_addresses: "Always see user email addresses" project_module_user_email: "User email addresses" - + setting_load_issue_edit: "Load the issue's edit form only by clicking on the Edit link" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 5352344..4ee4901 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -30,3 +30,4 @@ fr: setting_disable_email_hiding: "Désactiver la fonction de masquage des emails" permission_always_see_user_email_addresses: "Toujours voir les adresses mail des utilisateurs" project_module_user_email: "Adresses mail des utilisateurs" + setting_load_issue_edit: "Charger le formulaire d'édition de la demande uniquement en cliquant sur le lien Modifier" diff --git a/init.rb b/init.rb index 18e304e..9fff74d 100644 --- a/init.rb +++ b/init.rb @@ -32,17 +32,19 @@ requires_redmine_plugin :redmine_base_rspec, :version_or_higher => '0.0.4' if Rails.env.test? requires_redmine_plugin :redmine_base_deface, :version_or_higher => '0.0.1' - permission :always_see_user_email_addresses, {} - + project_module :user_email do + permission :always_see_user_email_addresses ,{} + end settings partial: 'settings/redmine_plugin_tiny_features_settings', default: { - 'warning_message_on_closed_issues': '1', - 'open_issue_when_editing_closed_issues': '', - 'simplified_version_form': '1', - 'default_project': '', - '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', - 'disable_email_hiding': '', + 'warning_message_on_closed_issues': '1', + 'open_issue_when_editing_closed_issues': '', + 'simplified_version_form': '1', + 'default_project': '', + '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', + 'load_issue_edit': Rails.env.test? ? '0' : '1', + 'disable_email_hiding': '', } end diff --git a/spec/system/issues_spec.rb b/spec/system/issues_spec.rb index 5af346a..add2d37 100644 --- a/spec/system/issues_spec.rb +++ b/spec/system/issues_spec.rb @@ -146,8 +146,21 @@ def log_user(login, password) find('tr#issue-2>td.buttons>a.icon-actions').click expect(page).to_not have_selector('a.icon-copy') end + end - it "only on click button edit" do + describe "Load the issue's edit" do + it "Load the form when the option (load_issue_edit) is unselected" do + visit 'issues/2' + expect(page).to have_selector('#issue-form', visible: :hidden) + end + + it "only on click button edit and the option (load_issue_edit) is selected" do + Setting.send "plugin_redmine_tiny_features=", { + "warning_message_on_closed_issues" => "1", + "default_open_status" => "2", + "default_project" => "1", + "load_issue_edit" => "1", + } visit 'issues/2' expect(page).to_not have_selector('#issue-form', visible: :hidden) find('.icon-edit', match: :first).click @@ -155,4 +168,3 @@ def log_user(login, password) end end end - From c02d2f8378dd35b7a8a094f11a5448cd89cb604f Mon Sep 17 00:00:00 2001 From: Yalaeddin Date: Tue, 10 Jan 2023 10:00:18 +0100 Subject: [PATCH 34/41] Ajouter le test d'option load_issue_edit --- .../system/settings_redmine_tiny_features_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/system/settings_redmine_tiny_features_spec.rb b/spec/system/settings_redmine_tiny_features_spec.rb index 3359707..9dac0b0 100644 --- a/spec/system/settings_redmine_tiny_features_spec.rb +++ b/spec/system/settings_redmine_tiny_features_spec.rb @@ -15,4 +15,19 @@ expect(Setting["plugin_redmine_tiny_features"]["paginate_issue_filters_values"]).to eq "1" end end + + it "Should active the option load_issue_edit" do + log_user('admin', 'admin') + Setting.send "plugin_redmine_tiny_features=", { + "warning_message_on_closed_issues" => "1", + "default_open_status" => "2", + "default_project" => "1", + } + visit 'settings/plugin/redmine_tiny_features' + + find("input[name='settings[load_issue_edit]']").click + find("input[name='commit']").click + + expect(Setting["plugin_redmine_tiny_features"]["load_issue_edit"]).to eq '1' + end end From 8f3c3590475a8dce186ac86f35ff83d19b16a5a9 Mon Sep 17 00:00:00 2001 From: Yalaeddin Date: Tue, 10 Jan 2023 11:49:41 +0100 Subject: [PATCH 35/41] corriger la comentaire --- app/overrides/issues/_action_menu_edit.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/overrides/issues/_action_menu_edit.rb b/app/overrides/issues/_action_menu_edit.rb index 334c6d5..10a7976 100644 --- a/app/overrides/issues/_action_menu_edit.rb +++ b/app/overrides/issues/_action_menu_edit.rb @@ -2,8 +2,8 @@ :name => 'prevents-render-edit-partial-render-it-only-on-click-button-edit', :replace => "erb[loud]:contains(\"render :partial => 'edit'\")", :text => <<-RENDER_PARTIAL -# Put the condition here, not at the beginning of the file, so that we can check the configuration each time we download the page, -# if we put the condition at the beginning of the file it does not execute only once, (start application) +<% # Put the condition here, not at the beginning of the file, so that we can check the configuration each time we download the page, + # if we put the condition at the beginning of the file it does not execute only once, (start application) %> <% if Setting.plugin_redmine_tiny_features.key?('load_issue_edit') %> <% else %> diff --git a/config/routes.rb b/config/routes.rb index 18a99c2..c5d2787 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,6 @@ resources :projects do put :custom_field_enumerations, :controller => 'project_custom_field_enumerations', action: 'update', as: 'update_custom_field_enumerations' end +match 'issues/render_form_by_ajax/:id', :controller => 'issues', :action => 'render_form_by_ajax', :via => :get, :as => 'render_form_by_ajax' match 'queries/author_values_pagination', :controller => 'queries', :action => 'author_values_pagination' , :via => :get, :as => 'author_values_pagination' match 'queries/assigned_to_values_pagination', :controller => 'queries', :action => 'assigned_to_values_pagination' , :via => :get, :as => 'assigned_to_values_pagination' \ No newline at end of file diff --git a/lib/redmine_tiny_features/issues_controller_patch.rb b/lib/redmine_tiny_features/issues_controller_patch.rb index db5ebd9..40b250b 100644 --- a/lib/redmine_tiny_features/issues_controller_patch.rb +++ b/lib/redmine_tiny_features/issues_controller_patch.rb @@ -3,6 +3,17 @@ class IssuesController append_before_action :find_optional_project_for_new_issue, :only => [:new] + skip_before_action :authorize, :only => [:render_form_by_ajax] + + + def render_form_by_ajax + @issue = Issue.find(params[:id]) + + return unless update_issue_from_params + + render json: { html: render_to_string(partial: 'edit') } + + end private diff --git a/spec/system/issues_spec.rb b/spec/system/issues_spec.rb index add2d37..26708fd 100644 --- a/spec/system/issues_spec.rb +++ b/spec/system/issues_spec.rb @@ -164,6 +164,8 @@ def log_user(login, password) visit 'issues/2' expect(page).to_not have_selector('#issue-form', visible: :hidden) find('.icon-edit', match: :first).click + # wait for render form + sleep 10 expect(page).to have_selector('#issue-form') end end From a7e4e5aa522105498922174fbf03ec7575565b41 Mon Sep 17 00:00:00 2001 From: Yalaeddin Date: Tue, 24 Jan 2023 14:11:16 +0100 Subject: [PATCH 37/41] Ajouter _action_menu qui manque apres avoir fait rebaase --- app/overrides/issues/_action_menu.rb | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 app/overrides/issues/_action_menu.rb diff --git a/app/overrides/issues/_action_menu.rb b/app/overrides/issues/_action_menu.rb new file mode 100644 index 0000000..4ad4933 --- /dev/null +++ b/app/overrides/issues/_action_menu.rb @@ -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_issue_copy +HIDE_LINK \ No newline at end of file From 854270e9fc3bf310f2dd93d626a1752c965b3ce1 Mon Sep 17 00:00:00 2001 From: Yalaeddin Date: Wed, 25 Jan 2023 07:53:23 +0100 Subject: [PATCH 38/41] =?UTF-8?q?Remettre=20la=20valeur=20=C3=A0=200,=20?= =?UTF-8?q?=C3=A0=20la=20fin=20de=20m=C3=A9thode=20de=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/system/settings_redmine_tiny_features_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/system/settings_redmine_tiny_features_spec.rb b/spec/system/settings_redmine_tiny_features_spec.rb index 9dac0b0..8fdee22 100644 --- a/spec/system/settings_redmine_tiny_features_spec.rb +++ b/spec/system/settings_redmine_tiny_features_spec.rb @@ -29,5 +29,6 @@ find("input[name='commit']").click expect(Setting["plugin_redmine_tiny_features"]["load_issue_edit"]).to eq '1' + Setting["plugin_redmine_tiny_features"]["load_issue_edit"] = '0' end end From 44baefce3f0c3bae9e1183eebf03c2ac012d61e1 Mon Sep 17 00:00:00 2001 From: Yalaeddin Date: Wed, 25 Jan 2023 08:04:22 +0100 Subject: [PATCH 39/41] =?UTF-8?q?Remettre=20la=20valeur=20=C3=A0=200,=20av?= =?UTF-8?q?ant=20de=20m=C3=A9thode=20de=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/views/issues/show.html.erb_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/views/issues/show.html.erb_spec.rb b/spec/views/issues/show.html.erb_spec.rb index 70b40d9..8ef6ff6 100644 --- a/spec/views/issues/show.html.erb_spec.rb +++ b/spec/views/issues/show.html.erb_spec.rb @@ -33,7 +33,8 @@ it "contains a warning to prevent to re-open it if a new issue is more appropriate" do Setting["plugin_redmine_tiny_features"]["warning_message_on_closed_issues"] = '1' - + Setting["plugin_redmine_tiny_features"]["load_issue_edit"] = '0' + assign(:issue, issue) assign(:journals, issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").to_a) assign(:allowed_statuses, issue.new_statuses_allowed_to(User.current)) From a7a55250958f41ce75d2437bf0b35a4d057c3d7b Mon Sep 17 00:00:00 2001 From: Yalaeddin Date: Wed, 25 Jan 2023 09:21:49 +0100 Subject: [PATCH 40/41] Corriger les configuration de Setting --- spec/system/issues_spec.rb | 6 ++++++ spec/system/settings_redmine_tiny_features_spec.rb | 7 ++++++- spec/views/issues/show.html.erb_spec.rb | 1 - 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/spec/system/issues_spec.rb b/spec/system/issues_spec.rb index 26708fd..7400728 100644 --- a/spec/system/issues_spec.rb +++ b/spec/system/issues_spec.rb @@ -167,6 +167,12 @@ def log_user(login, password) # wait for render form sleep 10 expect(page).to have_selector('#issue-form') + Setting.send "plugin_redmine_tiny_features=", { + "warning_message_on_closed_issues" => "1", + "default_open_status" => "2", + "default_project" => "1", + "load_issue_edit" => "0", + } end end end diff --git a/spec/system/settings_redmine_tiny_features_spec.rb b/spec/system/settings_redmine_tiny_features_spec.rb index 8fdee22..aaa5eb2 100644 --- a/spec/system/settings_redmine_tiny_features_spec.rb +++ b/spec/system/settings_redmine_tiny_features_spec.rb @@ -29,6 +29,11 @@ find("input[name='commit']").click expect(Setting["plugin_redmine_tiny_features"]["load_issue_edit"]).to eq '1' - Setting["plugin_redmine_tiny_features"]["load_issue_edit"] = '0' + Setting.send "plugin_redmine_tiny_features=", { + "warning_message_on_closed_issues" => "1", + "default_open_status" => "2", + "default_project" => "1", + "load_issue_edit" => "0", + } end end diff --git a/spec/views/issues/show.html.erb_spec.rb b/spec/views/issues/show.html.erb_spec.rb index 8ef6ff6..be1ef47 100644 --- a/spec/views/issues/show.html.erb_spec.rb +++ b/spec/views/issues/show.html.erb_spec.rb @@ -33,7 +33,6 @@ it "contains a warning to prevent to re-open it if a new issue is more appropriate" do Setting["plugin_redmine_tiny_features"]["warning_message_on_closed_issues"] = '1' - Setting["plugin_redmine_tiny_features"]["load_issue_edit"] = '0' assign(:issue, issue) assign(:journals, issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").to_a) From 1b89de218fc65daac6d28a8bed46d4b26652cde4 Mon Sep 17 00:00:00 2001 From: Yalaeddin Date: Mon, 6 Feb 2023 14:31:45 +0100 Subject: [PATCH 41/41] =?UTF-8?q?=20renommer=20l'option=20+=20ajouter=20un?= =?UTF-8?q?e=20variable=20pour=20que=20la=20requ=C3=AAte=20Ajax=20ne=20soi?= =?UTF-8?q?t=20pas=20relanc=C3=A9e=20une=20seconde=20fois=20si=20le=20form?= =?UTF-8?q?ulaire=20a=20d=C3=A9j=C3=A0=20=C3=A9t=C3=A9=20charg=C3=A9=20et?= =?UTF-8?q?=20affich=C3=A9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/overrides/issues/_action_menu.rb | 43 ++++++++++++++++- app/overrides/issues/_action_menu_edit.rb | 47 ++----------------- ...ine_plugin_tiny_features_settings.html.erb | 4 +- config/locales/en.yml | 2 +- config/locales/fr.yml | 2 +- init.rb | 2 +- spec/system/issues_spec.rb | 8 ++-- .../settings_redmine_tiny_features_spec.rb | 8 ++-- 8 files changed, 59 insertions(+), 57 deletions(-) diff --git a/app/overrides/issues/_action_menu.rb b/app/overrides/issues/_action_menu.rb index 4ad4933..2869d79 100644 --- a/app/overrides/issues/_action_menu.rb +++ b/app/overrides/issues/_action_menu.rb @@ -3,4 +3,45 @@ :insert_bottom => 'erb[loud]:contains("link_to l(:button_copy)")', :text => <<-HIDE_LINK && !@issue.tracker.prevent_issue_copy -HIDE_LINK \ No newline at end of file +HIDE_LINK +Deface::Override.new :virtual_path => 'issues/_action_menu', + :name => 'call-renderPartialEdit-before-showAndScrollTo', + :replace => "erb[loud]:contains('l(:button_edit)')", + :text => <<-REPLACE_BUTTON + +<% # Put the condition here, not at the beginning of the file, so that we can check the configuration each time we download the page, + # if we put the condition at the beginning of the file it does not execute only once, (start application) %> +<% if Setting.plugin_redmine_tiny_features.key?('do_not_preload_issue_edit_form') %> + <%= link_to l(:button_edit), edit_issue_path(@issue), + :onclick => 'renderPartialEdit(); return false;', + :class => 'icon icon-edit', :accesskey => accesskey(:edit) if @issue.editable? %> + +<% else %> + <%= link_to l(:button_edit), edit_issue_path(@issue), + :onclick => 'showAndScrollTo("update", "issue_notes"); return false;', + :class => 'icon icon-edit', :accesskey => accesskey(:edit) if @issue.editable? %> +<% end %> +REPLACE_BUTTON diff --git a/app/overrides/issues/_action_menu_edit.rb b/app/overrides/issues/_action_menu_edit.rb index 943b51d..598313c 100644 --- a/app/overrides/issues/_action_menu_edit.rb +++ b/app/overrides/issues/_action_menu_edit.rb @@ -1,47 +1,8 @@ Deface::Override.new :virtual_path => 'issues/_action_menu_edit', - :name => 'prevents-render-edit-partial-render-it-only-on-click-button-edit', - :replace => "erb[loud]:contains(\"render :partial => 'edit'\")", - :text => <<-RENDER_PARTIAL -<% # Put the condition here, not at the beginning of the file, so that we can check the configuration each time we download the page, - # if we put the condition at the beginning of the file it does not execute only once, (start application) %> -<% if Setting.plugin_redmine_tiny_features.key?('load_issue_edit') %> - - -<% else %> + :name => 'prevents-render-edit-partial-render-it-only-on-edit-button-click', + :replace => "erb[loud]:contains(\"render :partial => 'edit'\")", + :text => <<-RENDER_PARTIAL +<% if !Setting.plugin_redmine_tiny_features.key?('do_not_preload_issue_edit_form') %> <%= render :partial => 'edit' %> <% end %> RENDER_PARTIAL 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 69cb8a2..f7d096d 100644 --- a/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb +++ b/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb @@ -69,8 +69,8 @@

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

diff --git a/config/locales/en.yml b/config/locales/en.yml index 0edc59c..a6a5108 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -30,4 +30,4 @@ en: setting_disable_email_hiding: "Disable the emails hiding function" permission_always_see_user_email_addresses: "Always see user email addresses" project_module_user_email: "User email addresses" - setting_load_issue_edit: "Load the issue's edit form only by clicking on the Edit link" + setting_do_not_preload_issue_edit_form: "Load the issue's edit form only by clicking on the Edit link" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 4ee4901..461c49e 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -30,4 +30,4 @@ fr: setting_disable_email_hiding: "Désactiver la fonction de masquage des emails" permission_always_see_user_email_addresses: "Toujours voir les adresses mail des utilisateurs" project_module_user_email: "Adresses mail des utilisateurs" - setting_load_issue_edit: "Charger le formulaire d'édition de la demande uniquement en cliquant sur le lien Modifier" + setting_do_not_preload_issue_edit_form: "Charger le formulaire d'édition de la demande uniquement en cliquant sur le lien Modifier" diff --git a/init.rb b/init.rb index 9fff74d..9819f2d 100644 --- a/init.rb +++ b/init.rb @@ -44,7 +44,7 @@ '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', - 'load_issue_edit': Rails.env.test? ? '0' : '1', + 'do_not_preload_issue_edit_form': Rails.env.test? ? '0' : '1', 'disable_email_hiding': '', } end diff --git a/spec/system/issues_spec.rb b/spec/system/issues_spec.rb index 7400728..8c0d95d 100644 --- a/spec/system/issues_spec.rb +++ b/spec/system/issues_spec.rb @@ -149,17 +149,17 @@ def log_user(login, password) end describe "Load the issue's edit" do - it "Load the form when the option (load_issue_edit) is unselected" do + it "Load the form when the option (do_not_preload_issue_edit_form) is unselected" do visit 'issues/2' expect(page).to have_selector('#issue-form', visible: :hidden) end - it "only on click button edit and the option (load_issue_edit) is selected" do + it "only on click button edit and the option (do_not_preload_issue_edit_form) is selected" do Setting.send "plugin_redmine_tiny_features=", { "warning_message_on_closed_issues" => "1", "default_open_status" => "2", "default_project" => "1", - "load_issue_edit" => "1", + "do_not_preload_issue_edit_form" => "1", } visit 'issues/2' expect(page).to_not have_selector('#issue-form', visible: :hidden) @@ -171,7 +171,7 @@ def log_user(login, password) "warning_message_on_closed_issues" => "1", "default_open_status" => "2", "default_project" => "1", - "load_issue_edit" => "0", + "do_not_preload_issue_edit_form" => "0", } end end diff --git a/spec/system/settings_redmine_tiny_features_spec.rb b/spec/system/settings_redmine_tiny_features_spec.rb index aaa5eb2..6d19fb4 100644 --- a/spec/system/settings_redmine_tiny_features_spec.rb +++ b/spec/system/settings_redmine_tiny_features_spec.rb @@ -16,7 +16,7 @@ end end - it "Should active the option load_issue_edit" do + it "Should active the option do_not_preload_issue_edit_form" do log_user('admin', 'admin') Setting.send "plugin_redmine_tiny_features=", { "warning_message_on_closed_issues" => "1", @@ -25,15 +25,15 @@ } visit 'settings/plugin/redmine_tiny_features' - find("input[name='settings[load_issue_edit]']").click + find("input[name='settings[do_not_preload_issue_edit_form]']").click find("input[name='commit']").click - expect(Setting["plugin_redmine_tiny_features"]["load_issue_edit"]).to eq '1' + expect(Setting["plugin_redmine_tiny_features"]["do_not_preload_issue_edit_form"]).to eq '1' Setting.send "plugin_redmine_tiny_features=", { "warning_message_on_closed_issues" => "1", "default_open_status" => "2", "default_project" => "1", - "load_issue_edit" => "0", + "do_not_preload_issue_edit_form" => "0", } end end