From f4154b4bfddbe35f4e5cff9627c9815ffb31666a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrej=20Rama=C5=A1euski?= <andrej@x2.cz> Date: Fri, 19 Apr 2024 12:02:50 +0200 Subject: [PATCH] Aktualizace pluginu --- .gitlab-ci.yml | 2 +- plugins/redmine_checklists/Gemfile | 2 +- plugins/redmine_checklists/init.rb | 2 +- plugins/redmineup_tags/.drone.jsonnet | 19 +++--- plugins/redmineup_tags/Gemfile | 2 +- .../app/controllers/issue_tags_controller.rb | 6 +- .../app/controllers/tags_controller.rb | 18 ++--- .../app/helpers/issues_tags_helper.rb | 2 +- .../redmineup_tags/app/helpers/tags_helper.rb | 4 +- .../views/auto_completes/_redmine_tags.erb | 6 -- .../views/auto_completes/_tag_list.html.erb | 4 -- .../views/auto_completes/_tag_list.json.erb | 4 -- .../app/views/issue_tags/_edit_modal.html.erb | 3 +- .../app/views/issues/_tags_form.html.erb | 2 +- .../app/views/tags/_manage_tags.html.erb | 65 +++++++++---------- .../_select2_transformation_rules.html.erb | 2 +- .../app/views/tags/edit.html.erb | 2 +- plugins/redmineup_tags/config/locales/ro.yml | 36 ++++++++++ plugins/redmineup_tags/config/routes.rb | 4 +- .../db/migrate/001_add_tags_and_taggings.rb | 4 +- .../db/migrate/002_create_tags.rb | 4 +- plugins/redmineup_tags/doc/CHANGELOG | 26 ++++++-- plugins/redmineup_tags/init.rb | 17 +++-- .../redmineup_tags/lib/query_tags_column.rb | 2 +- plugins/redmineup_tags/lib/redmineup_tags.rb | 50 +++++++------- .../redmineup_tags/hooks/model_issue_hook.rb | 2 +- .../hooks/views_context_menus_hook.rb | 4 +- .../redmineup_tags/hooks/views_issues_hook.rb | 2 +- .../hooks/views_layouts_hook.rb | 2 +- .../hooks/views_reports_hook.rb | 2 +- .../patches/action_controller_patch.rb | 49 -------------- .../add_helpers_for_issue_tags_patch.rb | 4 +- .../patches/agile_query_patch.rb | 6 +- .../patches/agile_versions_query_patch.rb | 3 +- .../auto_completes_controller_patch.rb | 15 ++++- .../lib/redmineup_tags/patches/issue_patch.rb | 33 ++++------ .../patches/issue_query_patch.rb | 12 ++-- .../patches/queries_helper_patch.rb | 3 +- .../patches/reports_controller_patch.rb | 2 +- .../patches/time_entry_patch.rb | 2 +- .../patches/time_entry_query_patch.rb | 6 +- .../patches/time_report_patch.rb | 18 ++--- .../agile_boards_controller_test.rb | 2 +- .../agile_versions_controller_test.rb | 2 +- .../auto_completes_controller_test.rb | 4 +- .../functional/issue_tags_controller_test.rb | 2 +- .../test/functional/issues_controller_test.rb | 26 +++++++- .../functional/reports_controller_test.rb | 2 +- .../test/functional/tags_controller_test.rb | 16 ++--- .../functional/timelog_controller_test.rb | 2 +- plugins/redmineup_tags/test/test_helper.rb | 12 ++-- .../redmineup_tags/test/unit/issue_test.rb | 2 +- 52 files changed, 256 insertions(+), 267 deletions(-) delete mode 100644 plugins/redmineup_tags/app/views/auto_completes/_redmine_tags.erb delete mode 100644 plugins/redmineup_tags/app/views/auto_completes/_tag_list.html.erb delete mode 100644 plugins/redmineup_tags/app/views/auto_completes/_tag_list.json.erb create mode 100644 plugins/redmineup_tags/config/locales/ro.yml mode change 100644 => 100755 plugins/redmineup_tags/doc/CHANGELOG delete mode 100644 plugins/redmineup_tags/lib/redmineup_tags/patches/action_controller_patch.rb diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 422d2fe..d8ede32 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ image: docker:stable variables: DOCKER_TLS_CERTDIR: "/certs" - IMAGE_VER: 4.2.10-passenger-2 + IMAGE_VER: 4.2.10-passenger-3 services: - docker:dind diff --git a/plugins/redmine_checklists/Gemfile b/plugins/redmine_checklists/Gemfile index c6b5df6..ffc40a3 100644 --- a/plugins/redmine_checklists/Gemfile +++ b/plugins/redmine_checklists/Gemfile @@ -1 +1 @@ -gem 'redmine_crm' +gem 'redmineup' diff --git a/plugins/redmine_checklists/init.rb b/plugins/redmine_checklists/init.rb index 5c8731b..dea2522 100644 --- a/plugins/redmine_checklists/init.rb +++ b/plugins/redmine_checklists/init.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>. -#requires_redmineup version_or_higher: '1.0.5' rescue raise "\n\033[31mRedmine requires newer redmineup gem version.\nPlease update with 'bundle update redmineup'.\033[0m" +requires_redmineup version_or_higher: '1.0.5' rescue raise "\n\033[31mRedmine requires newer redmineup gem version.\nPlease update with 'bundle update redmineup'.\033[0m" CHECKLISTS_VERSION_NUMBER = '3.1.23'.freeze CHECKLISTS_VERSION_TYPE = "Light version" diff --git a/plugins/redmineup_tags/.drone.jsonnet b/plugins/redmineup_tags/.drone.jsonnet index 309ddec..94601f9 100644 --- a/plugins/redmineup_tags/.drone.jsonnet +++ b/plugins/redmineup_tags/.drone.jsonnet @@ -16,15 +16,12 @@ local Pipeline(rubyVer, db, license, redmine, dependents) = { }; [ - Pipeline("2.7.3", "mysql", "pro", "trunk", "redmine_agile+pro"), - Pipeline("2.7.3", "mysql", "light", "trunk", "redmine_agile+light"), - Pipeline("2.7.3", "pg", "pro", "trunk", ""), - Pipeline("2.2.6", "mysql", "pro", "3.4", ""), - Pipeline("2.2.6", "mysql", "pro", "3.3", ""), - Pipeline("2.2.6", "mysql", "light", "3.3", ""), - Pipeline("2.2.6", "pg", "pro","3.3", ""), - Pipeline("2.2.6", "pg", "light", "3.3", ""), - Pipeline("2.4.1", "mysql", "light", "3.4", ""), - Pipeline("2.4.1", "pg", "pro", "3.4", "redmine_contacts+pro"), - Pipeline("2.2.6", "mysql", "pro", "3.0", "") + Pipeline("3.2.2", "mysql", "pro", "trunk", "redmine_agile+pro"), + Pipeline("3.2.2", "pg", "pro", "5.1", ""), + Pipeline("3.0.6", "mysql", "pro", "5.0", "redmine_agile+light"), + Pipeline("2.7.8", "mysql", "light", "4.2", ""), + Pipeline("2.7.8", "pg", "pro", "4.2", "redmine_contacts+pro"), + Pipeline("2.3.8", "mysql", "pro", "4.0", ""), + Pipeline("2.3.8", "mysql", "light", "4.0", ""), + Pipeline("2.3.8", "pg", "pro", "4.0", "") ] diff --git a/plugins/redmineup_tags/Gemfile b/plugins/redmineup_tags/Gemfile index c6b5df6..ffc40a3 100644 --- a/plugins/redmineup_tags/Gemfile +++ b/plugins/redmineup_tags/Gemfile @@ -1 +1 @@ -gem 'redmine_crm' +gem 'redmineup' diff --git a/plugins/redmineup_tags/app/controllers/issue_tags_controller.rb b/plugins/redmineup_tags/app/controllers/issue_tags_controller.rb index 34bf00c..d2911a1 100644 --- a/plugins/redmineup_tags/app/controllers/issue_tags_controller.rb +++ b/plugins/redmineup_tags/app/controllers/issue_tags_controller.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -18,8 +18,6 @@ # along with redmine_tags. If not, see <http://www.gnu.org/licenses/>. class IssueTagsController < ApplicationController - unloadable - before_action :find_issues, only: [:edit, :update] def edit @@ -56,7 +54,7 @@ class IssueTagsController < ApplicationController private def update_tags(issues, tags) - if tags.present? && issues.size > 1 + if (tags.present? && issues.size > 1) || params[:add_only] add_issues_tags(issues, tags) else update_issues_tags(issues, tags) diff --git a/plugins/redmineup_tags/app/controllers/tags_controller.rb b/plugins/redmineup_tags/app/controllers/tags_controller.rb index 9472886..b32a1e6 100644 --- a/plugins/redmineup_tags/app/controllers/tags_controller.rb +++ b/plugins/redmineup_tags/app/controllers/tags_controller.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -18,7 +18,6 @@ # along with redmine_tags. If not, see <http://www.gnu.org/licenses/>. class TagsController < ApplicationController - unloadable before_action :require_admin before_action :find_tag, only: [:edit, :update] before_action :bulk_find_tags, only: [:context_menu, :merge, :destroy] @@ -62,9 +61,10 @@ class TagsController < ApplicationController def merge if request.post? && params[:tag] && params[:tag][:name] - RedmineCrm::Tagging.transaction do - tag = RedmineCrm::Tag.find_by_name(params[:tag][:name]) || RedmineCrm::Tag.create(params[:tag]) - RedmineCrm::Tagging.where(tag_id: @tags.map(&:id)).update_all(tag_id: tag.id) + params_hash = params[:tag].respond_to?(:to_unsafe_hash) ? params[:tag].to_unsafe_hash : params + Redmineup::Tagging.transaction do + tag = Redmineup::Tag.find_by_name(params_hash['name']) || Redmineup::Tag.create(params_hash) + Redmineup::Tagging.where(tag_id: @tags.map(&:id)).update_all(tag_id: tag.id) @tags.select { |t| t.id != tag.id }.each{ |t| t.destroy } redirect_to controller: 'settings', action: 'plugin', id: 'redmineup_tags', tab: 'manage_tags' end @@ -74,15 +74,15 @@ class TagsController < ApplicationController private def bulk_find_tags - @tags = RedmineCrm::Tag.joins("JOIN #{RedmineCrm::Tagging.table_name} ON #{RedmineCrm::Tagging.table_name}.tag_id = #{RedmineCrm::Tag.table_name}.id "). - select("#{RedmineCrm::Tag.table_name}.*, COUNT(DISTINCT #{RedmineCrm::Tagging.table_name}.taggable_id) AS count"). + @tags = Redmineup::Tag.joins("JOIN #{Redmineup::Tagging.table_name} ON #{Redmineup::Tagging.table_name}.tag_id = #{Redmineup::Tag.table_name}.id "). + select("#{Redmineup::Tag.table_name}.*, COUNT(DISTINCT #{Redmineup::Tagging.table_name}.taggable_id) AS count"). where(id: params[:id] ? [params[:id]] : params[:ids]). - group("#{RedmineCrm::Tag.table_name}.id, #{RedmineCrm::Tag.table_name}.name") + group("#{Redmineup::Tag.table_name}.id, #{Redmineup::Tag.table_name}.name") raise ActiveRecord::RecordNotFound if @tags.empty? end def find_tag - @tag = RedmineCrm::Tag.find(params[:id]) + @tag = Redmineup::Tag.find(params[:id]) rescue ActiveRecord::RecordNotFound render_404 end diff --git a/plugins/redmineup_tags/app/helpers/issues_tags_helper.rb b/plugins/redmineup_tags/app/helpers/issues_tags_helper.rb index ddf543d..41f6a19 100644 --- a/plugins/redmineup_tags/app/helpers/issues_tags_helper.rb +++ b/plugins/redmineup_tags/app/helpers/issues_tags_helper.rb @@ -3,7 +3,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify diff --git a/plugins/redmineup_tags/app/helpers/tags_helper.rb b/plugins/redmineup_tags/app/helpers/tags_helper.rb index c5d1b84..3b3908d 100644 --- a/plugins/redmineup_tags/app/helpers/tags_helper.rb +++ b/plugins/redmineup_tags/app/helpers/tags_helper.rb @@ -3,7 +3,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -22,7 +22,7 @@ require 'digest/md5' module TagsHelper - include RedmineCrm::TagsHelper + include Redmineup::TagsHelper def render_issue_tag_link(tag, options = {}) filters = [[:issue_tags, '=', tag.name]] diff --git a/plugins/redmineup_tags/app/views/auto_completes/_redmine_tags.erb b/plugins/redmineup_tags/app/views/auto_completes/_redmine_tags.erb deleted file mode 100644 index 6de3634..0000000 --- a/plugins/redmineup_tags/app/views/auto_completes/_redmine_tags.erb +++ /dev/null @@ -1,6 +0,0 @@ -<%= raw @redmine_tags.map { |redmine_tag| { - 'id' => redmine_tag.name, - 'text' => redmine_tag.name - } - }.to_json -%> diff --git a/plugins/redmineup_tags/app/views/auto_completes/_tag_list.html.erb b/plugins/redmineup_tags/app/views/auto_completes/_tag_list.html.erb deleted file mode 100644 index 262cb2f..0000000 --- a/plugins/redmineup_tags/app/views/auto_completes/_tag_list.html.erb +++ /dev/null @@ -1,4 +0,0 @@ -<%= raw @tags.collect {|tag| - tag.name - }.to_json -%> diff --git a/plugins/redmineup_tags/app/views/auto_completes/_tag_list.json.erb b/plugins/redmineup_tags/app/views/auto_completes/_tag_list.json.erb deleted file mode 100644 index 262cb2f..0000000 --- a/plugins/redmineup_tags/app/views/auto_completes/_tag_list.json.erb +++ /dev/null @@ -1,4 +0,0 @@ -<%= raw @tags.collect {|tag| - tag.name - }.to_json -%> diff --git a/plugins/redmineup_tags/app/views/issue_tags/_edit_modal.html.erb b/plugins/redmineup_tags/app/views/issue_tags/_edit_modal.html.erb index 121a3cc..6063025 100644 --- a/plugins/redmineup_tags/app/views/issue_tags/_edit_modal.html.erb +++ b/plugins/redmineup_tags/app/views/issue_tags/_edit_modal.html.erb @@ -16,6 +16,7 @@ :method => :post, :id => 'edit-issue-tags-form') do %> + <%= hidden_field_tag :add_only, 1 %> <fieldset class="box"> <legend><%= l(:tags) %></legend> <div id="issue_tags"> @@ -23,7 +24,7 @@ [], width: '100%', multiple: true, - url: auto_complete_redmine_tags_url, + url: auto_complete_redmine_tags_path, placeholder: @is_bulk_editing ? t(:label_no_change_option) : '+ add tag', tags: User.current.allowed_to?(:create_tags, @project) %> </div> diff --git a/plugins/redmineup_tags/app/views/issues/_tags_form.html.erb b/plugins/redmineup_tags/app/views/issues/_tags_form.html.erb index 865cbb2..ffa254c 100644 --- a/plugins/redmineup_tags/app/views/issues/_tags_form.html.erb +++ b/plugins/redmineup_tags/app/views/issues/_tags_form.html.erb @@ -10,7 +10,7 @@ :multiple => true, :include_hidden => (params[:action] != 'bulk_edit'), :style => 'width: 100%;', - :url => auto_complete_redmine_tags_url, + :url => auto_complete_redmine_tags_path, :placeholder => params[:action] == 'bulk_edit' ? t(:label_no_change_option) : '+ add tag', :tags => User.current.allowed_to?(:create_tags, @projects || @project) %> diff --git a/plugins/redmineup_tags/app/views/tags/_manage_tags.html.erb b/plugins/redmineup_tags/app/views/tags/_manage_tags.html.erb index d6d84ec..64cbf45 100644 --- a/plugins/redmineup_tags/app/views/tags/_manage_tags.html.erb +++ b/plugins/redmineup_tags/app/views/tags/_manage_tags.html.erb @@ -1,41 +1,35 @@ <% tags = Issue.all_tag_counts(:order => :name) %> - <% unless tags.to_a.empty? %> -<table class = "list issues"> - <thead> - <tr> - <th class="checkbox hide-when-print"> - <%= link_to image_tag('toggle_check.png'), {}, - :onclick => 'toggleIssuesSelection(this); return false;', - :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %> - </th> - <th><%= l(:field_name) %></th> - <th align="center" style="width:10%;"> </th> - </tr> - </thead> - <tbody> - <% tags.each do |tag| %> - <tr id="<%= tag.id %>" class="<%= cycle("odd", "even") %> hascontextmenu "> - <td class="checkbox hide-when-print"><%= check_box_tag("ids[]", tag.id, false, :id => nil) %></td> - <td><%= render_issue_tag_link(tag) %></td> - <td class="buttons"> - <%= link_to l(:button_edit), edit_tag_path(tag), - :class => 'icon icon-edit' %> - - <%= link_to l(:button_delete), tags_path(:ids => tag), - :method => :delete, - :confirm => l(:text_are_you_sure), - :class => 'icon icon-del' %> - </td> - + <table class = "list issues"> + <thead> + <tr> + <th class="checkbox hide-when-print"> + <%= link_to image_tag('toggle_check.png'), {}, + :onclick => 'toggleIssuesSelection(this); return false;', + :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %> + </th> + <th><%= l(:field_name) %></th> + <th align="center" style="width:10%;"> </th> </tr> + </thead> + <tbody> + <% tags.each do |tag| %> + <tr id="<%= tag.id %>" class="<%= cycle("odd", "even") %> hascontextmenu "> + <td class="checkbox hide-when-print"><%= check_box_tag("ids[]", tag.id, false, :id => nil) %></td> + <td><%= render_issue_tag_link(tag) %></td> + <td class="buttons"> + <%= link_to l(:button_edit), edit_tag_path(tag), + :class => 'icon icon-edit' %> + <%= link_to l(:button_delete), tags_path(:ids => tag), + :method => :delete, + :confirm => l(:text_are_you_sure), + :class => 'icon icon-del' %> + </td> + </tr> + <% end %> + </tbody> + </table> - <% end %> - </tbody> -</table> -<% if Redmine::VERSION.to_s < '3.4' && Redmine::VERSION::BRANCH == 'stable' %> - <%= context_menu tags_context_menu_path %> -<% else %> <% content_for :header_tags do javascript_include_tag('context_menu') + stylesheet_link_tag('context_menu') end %> @@ -45,9 +39,8 @@ $('#settings form').data('cmUrl', '<%= tags_context_menu_path %>') }) <% end %> -<% end %> <% else %> -<p class="nodata"><%= l(:label_no_data) %></p> + <p class="nodata"><%= l(:label_no_data) %></p> <% end %> diff --git a/plugins/redmineup_tags/app/views/tags/_select2_transformation_rules.html.erb b/plugins/redmineup_tags/app/views/tags/_select2_transformation_rules.html.erb index 0c83768..58b491d 100644 --- a/plugins/redmineup_tags/app/views/tags/_select2_transformation_rules.html.erb +++ b/plugins/redmineup_tags/app/views/tags/_select2_transformation_rules.html.erb @@ -1 +1 @@ -<%= transform_to_select2('issue_tags', url: auto_complete_redmine_tags_url) %> +<%= transform_to_select2('issue_tags', url: auto_complete_redmine_tags_path) %> diff --git a/plugins/redmineup_tags/app/views/tags/edit.html.erb b/plugins/redmineup_tags/app/views/tags/edit.html.erb index a2e9745..601e764 100644 --- a/plugins/redmineup_tags/app/views/tags/edit.html.erb +++ b/plugins/redmineup_tags/app/views/tags/edit.html.erb @@ -1,4 +1,4 @@ -<h2><%= link_to l(:setting_issue_tags), :controller => 'settings', :action => 'plugin', :id => 'redmine_tags', :tab => 'manage_tags' %> » <%=h (l(:issue_tags_tag) + ": " + @tag.name) %></h2> +<h2><%= link_to l(:setting_issue_tags), controller: 'settings', action: 'plugin', id: 'redmineup_tags', tab: 'manage_tags' %> » <%=h (l(:issue_tags_tag) + ": " + @tag.name) %></h2> <%= form_tag(tag_path(@tag, :tab => 'tags'), :class => "tabular", :method => :put) do %> <%= error_messages_for 'tag' %> diff --git a/plugins/redmineup_tags/config/locales/ro.yml b/plugins/redmineup_tags/config/locales/ro.yml new file mode 100644 index 0000000..df86462 --- /dev/null +++ b/plugins/redmineup_tags/config/locales/ro.yml @@ -0,0 +1,36 @@ +ro: + tags: Etichete + field_tags: Etichete + field_tag_list: Etichete + label_add_tags: Adaugă etichete + notice_tags_added: Etichetele au fost adăugate + notice_failed_to_add_tags: Etichetele nu s-au putut adăuga + setting_issue_tags: Etichete de sarcini + issues_sidebar: Mod de afișare etichete în sidebar + issues_show_count: Afișează numărul de sarcini + issues_open_only: Afișează doar pentru sarcinile deschise + issues_sort_by: Sortează etichetele după + issues_use_colors: Folosește culori + + issue_tags_sidebar_none: Deloc + issue_tags_sidebar_list: Listă + issue_tags_sidebar_cloud: Nor + issue_tags_sidebar_simple_cloud: Nor simplu + + issues_sort_by_name: Denumire + issues_sort_by_count: Număr de sarcini + issues_sort_order_asc: Crescător + issues_sort_order_desc: Descrescător + + auto_complete_new_tag: "Adaugă..." + + issue_tags_label_add_tag: "+ adaugă etichetă" + issue_tags_manage_tags: Administrare etichete + issue_tags_tag: Etichetă + issue_tags_button_merge: Unește + issue_tags_label_merge: Unește etichetele selectate + + tags_suggestion_order: Sugerează în ordine, pornind de la + tags_order_by_name: Denumire alfabetic + tags_order_by_last_created: Ultima creată + tags_order_by_most_used: Cea mai folosită diff --git a/plugins/redmineup_tags/config/routes.rb b/plugins/redmineup_tags/config/routes.rb index 9a4d198..0d0cd43 100644 --- a/plugins/redmineup_tags/config/routes.rb +++ b/plugins/redmineup_tags/config/routes.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -18,8 +18,6 @@ # along with redmine_tags. If not, see <http://www.gnu.org/licenses/>. RedmineApp::Application.routes.draw do - match '/issue_tags/auto_complete/:project_id', to: 'auto_completes#issue_tags', via: :get, as: 'auto_complete_issue_tags' - match '/wiki_tags/auto_complete/:project_id', to: 'auto_completes#wiki_tags', via: :get, as: 'auto_complete_wiki_tags' match 'auto_completes/redmine_tags' => 'auto_completes#redmine_tags', via: :get, as: 'auto_complete_redmine_tags' match '/tags/context_menu', to: 'tags#context_menu', as: 'tags_context_menu', via: [:get, :post] match '/tags', controller: 'tags', action: 'destroy', via: :delete diff --git a/plugins/redmineup_tags/db/migrate/001_add_tags_and_taggings.rb b/plugins/redmineup_tags/db/migrate/001_add_tags_and_taggings.rb index 1b6540a..478cc9b 100644 --- a/plugins/redmineup_tags/db/migrate/001_add_tags_and_taggings.rb +++ b/plugins/redmineup_tags/db/migrate/001_add_tags_and_taggings.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with redmine_tags. If not, see <http://www.gnu.org/licenses/>. -class AddTagsAndTaggings < (Rails.version < '5.1') ? ActiveRecord::Migration : ActiveRecord::Migration[4.2] +class AddTagsAndTaggings < ActiveRecord::Migration[4.2] def up end diff --git a/plugins/redmineup_tags/db/migrate/002_create_tags.rb b/plugins/redmineup_tags/db/migrate/002_create_tags.rb index 900be33..8912b7e 100644 --- a/plugins/redmineup_tags/db/migrate/002_create_tags.rb +++ b/plugins/redmineup_tags/db/migrate/002_create_tags.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with redmine_tags. If not, see <http://www.gnu.org/licenses/>. -class CreateTags < (Rails.version < '5.1') ? ActiveRecord::Migration : ActiveRecord::Migration[4.2] +class CreateTags < ActiveRecord::Migration[4.2] def self.up ActiveRecord::Base.create_taggable_table diff --git a/plugins/redmineup_tags/doc/CHANGELOG b/plugins/redmineup_tags/doc/CHANGELOG old mode 100644 new mode 100755 index ffea186..9ec94a3 --- a/plugins/redmineup_tags/doc/CHANGELOG +++ b/plugins/redmineup_tags/doc/CHANGELOG @@ -1,9 +1,26 @@ == Redmine Tags plugin changelog Redmine Tags plugin - Tags board plugin for redmine -Copyright (C) 2011-2021 RedmineUP +Copyright (C) 2011-2024 Kirill Bezrukov (RedmineUP) http://www.redmineup.com/ +== 2024-02-15 v2.0.14 + +* Dropped Redmine 3 support +* Fixed insecure XMLHttpRequest +* Fixed select2 bug + +== 2023-01-27 v2.0.13 + +* Romanian locale updated (MarianV) +* Fixed "is not" tags filter condition + +== 2022-04-11 v2.0.12 + +* Fixed broken link +* Fixed wrong proto error +* Redmine 5.0 compatibility + == 2021-06-14 v2.0.11 * Fixed global issue list bug @@ -37,7 +54,7 @@ http://www.redmineup.com/ == 2019-05-16 v2.0.6 * Added tags to Time entries report -* Added tags to Agile Versions board +* Added tags to Agile Versions board * Updated german translation (Werner Maier) * Fixed Agile plugin compatibility bug * Fixed adding tags context menu permissions @@ -47,7 +64,7 @@ http://www.redmineup.com/ * Changed tags filter by condition AND * Fixed tags field on issues bulk edit form - + == 2018-09-25 v2.0.4 * Fixed bug with Agile board view @@ -76,4 +93,5 @@ http://www.redmineup.com/ * redmine_crm gem for tags * Admin settings link * Alphabet sorting view for list -* Merging tags fixes \ No newline at end of file +* Merging tags fixes +erging tags fixes diff --git a/plugins/redmineup_tags/init.rb b/plugins/redmineup_tags/init.rb index 6f7810d..8d286bb 100644 --- a/plugins/redmineup_tags/init.rb +++ b/plugins/redmineup_tags/init.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -17,11 +17,11 @@ # You should have received a copy of the GNU General Public License # along with redmine_tags. If not, see <http://www.gnu.org/licenses/>. -requires_redmine_crm version_or_higher: '0.0.55' rescue raise "\n\033[31mRedmine requires newer redmine_crm gem version.\nPlease update with 'bundle update redmine_crm'.\033[0m" +requires_redmineup version_or_higher: '1.0.5' rescue raise "\n\033[31mRedmine requires newer redmineup gem version.\nPlease update with 'bundle update redmineup'.\033[0m" require 'redmine' -TAGS_VERSION_NUMBER = '2.0.11' +TAGS_VERSION_NUMBER = '2.0.14' TAGS_VERSION_TYPE = 'Light version' Redmine::Plugin.register :redmineup_tags do @@ -32,7 +32,7 @@ Redmine::Plugin.register :redmineup_tags do url 'https://www.redmineup.com/pages/plugins/tags/' author_url 'mailto:support@redmineup.com' - requires_redmine version_or_higher: '3.0' + requires_redmine version_or_higher: '4.0' settings default: { issues_sidebar: 'none', issues_show_count: 0, @@ -50,4 +50,11 @@ Redmine::Plugin.register :redmineup_tags do end end -require 'redmineup_tags' +if Rails.configuration.respond_to?(:autoloader) && Rails.configuration.autoloader == :zeitwerk + Rails.autoloaders.each { |loader| loader.ignore(File.dirname(__FILE__) + '/lib') } +end +require File.dirname(__FILE__) + '/lib/redmineup_tags' + +ActiveSupport.on_load(:action_view) do + include TagsHelper +end diff --git a/plugins/redmineup_tags/lib/query_tags_column.rb b/plugins/redmineup_tags/lib/query_tags_column.rb index 23b4544..4238c09 100644 --- a/plugins/redmineup_tags/lib/query_tags_column.rb +++ b/plugins/redmineup_tags/lib/query_tags_column.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify diff --git a/plugins/redmineup_tags/lib/redmineup_tags.rb b/plugins/redmineup_tags/lib/redmineup_tags.rb index 4831432..3584d06 100644 --- a/plugins/redmineup_tags/lib/redmineup_tags.rb +++ b/plugins/redmineup_tags/lib/redmineup_tags.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -17,31 +17,33 @@ # You should have received a copy of the GNU General Public License # along with redmine_tags. If not, see <http://www.gnu.org/licenses/>. -require 'redmineup_tags/hooks/model_issue_hook' -require 'redmineup_tags/hooks/views_context_menus_hook' -require 'redmineup_tags/hooks/views_issues_hook' -require 'redmineup_tags/hooks/views_layouts_hook' +module RedmineupTags + def self.settings() Setting[:plugin_redmineup_tags].stringify_keys end +end -require 'redmineup_tags/patches/action_controller_patch' -require 'redmineup_tags/patches/add_helpers_for_issue_tags_patch' -require 'redmineup_tags/patches/auto_completes_controller_patch' -require 'redmineup_tags/patches/issue_patch' -require 'redmineup_tags/patches/issue_query_patch' -require 'redmineup_tags/patches/queries_helper_patch' -require 'redmineup_tags/patches/time_entry_query_patch' -require 'redmineup_tags/patches/time_report_patch' -require 'redmineup_tags/patches/time_entry_patch' +REDMINEUP_TAGS_REQUIRED_FILES = [ + 'redmineup_tags/hooks/model_issue_hook', + 'redmineup_tags/hooks/views_context_menus_hook', + 'redmineup_tags/hooks/views_issues_hook', + 'redmineup_tags/hooks/views_layouts_hook', + 'redmineup_tags/patches/add_helpers_for_issue_tags_patch', + 'redmineup_tags/patches/auto_completes_controller_patch', + 'redmineup_tags/patches/issue_patch', + 'redmineup_tags/patches/issue_query_patch', + 'redmineup_tags/patches/queries_helper_patch', + 'redmineup_tags/patches/time_entry_query_patch', + 'redmineup_tags/patches/time_report_patch', + 'redmineup_tags/patches/time_entry_patch', + 'query_tags_column', + 'redmineup_tags/patches/reports_controller_patch', + 'redmineup_tags/hooks/views_reports_hook', +] if Redmine::Plugin.installed?(:redmine_agile) && - Gem::Version.new(Redmine::Plugin.find(:redmine_agile).version) >= Gem::Version.new('1.4.3') && AGILE_VERSION_TYPE == 'PRO version' - require 'redmineup_tags/patches/agile_query_patch' - require 'redmineup_tags/patches/agile_versions_query_patch' + Gem::Version.new(Redmine::Plugin.find(:redmine_agile).version) >= Gem::Version.new('1.4.3') && AGILE_VERSION_TYPE == 'PRO version' + REDMINEUP_TAGS_REQUIRED_FILES << 'redmineup_tags/patches/agile_query_patch' + REDMINEUP_TAGS_REQUIRED_FILES << 'redmineup_tags/patches/agile_versions_query_patch' end -require 'query_tags_column' -require 'redmineup_tags/patches/reports_controller_patch' -require 'redmineup_tags/hooks/views_reports_hook' - -module RedmineupTags - def self.settings() Setting[:plugin_redmineup_tags].stringify_keys end -end +base_url = File.dirname(__FILE__) +REDMINEUP_TAGS_REQUIRED_FILES.each { |file| require(base_url + '/' + file) } diff --git a/plugins/redmineup_tags/lib/redmineup_tags/hooks/model_issue_hook.rb b/plugins/redmineup_tags/lib/redmineup_tags/hooks/model_issue_hook.rb index 060e9b9..b837989 100644 --- a/plugins/redmineup_tags/lib/redmineup_tags/hooks/model_issue_hook.rb +++ b/plugins/redmineup_tags/lib/redmineup_tags/hooks/model_issue_hook.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify diff --git a/plugins/redmineup_tags/lib/redmineup_tags/hooks/views_context_menus_hook.rb b/plugins/redmineup_tags/lib/redmineup_tags/hooks/views_context_menus_hook.rb index 745360f..3953b88 100644 --- a/plugins/redmineup_tags/lib/redmineup_tags/hooks/views_context_menus_hook.rb +++ b/plugins/redmineup_tags/lib/redmineup_tags/hooks/views_context_menus_hook.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -19,7 +19,7 @@ module RedmineupTags module Hooks - class ViewsContextMenuesHook < Redmine::Hook::ViewListener + class ViewsContextMenusHook < Redmine::Hook::ViewListener render_on :view_issues_context_menu_end, partial: 'context_menus/issues_tags' end end diff --git a/plugins/redmineup_tags/lib/redmineup_tags/hooks/views_issues_hook.rb b/plugins/redmineup_tags/lib/redmineup_tags/hooks/views_issues_hook.rb index e03878b..b02ead5 100644 --- a/plugins/redmineup_tags/lib/redmineup_tags/hooks/views_issues_hook.rb +++ b/plugins/redmineup_tags/lib/redmineup_tags/hooks/views_issues_hook.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify diff --git a/plugins/redmineup_tags/lib/redmineup_tags/hooks/views_layouts_hook.rb b/plugins/redmineup_tags/lib/redmineup_tags/hooks/views_layouts_hook.rb index 39848e5..91c7856 100644 --- a/plugins/redmineup_tags/lib/redmineup_tags/hooks/views_layouts_hook.rb +++ b/plugins/redmineup_tags/lib/redmineup_tags/hooks/views_layouts_hook.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify diff --git a/plugins/redmineup_tags/lib/redmineup_tags/hooks/views_reports_hook.rb b/plugins/redmineup_tags/lib/redmineup_tags/hooks/views_reports_hook.rb index 0eaf667..4eada6b 100644 --- a/plugins/redmineup_tags/lib/redmineup_tags/hooks/views_reports_hook.rb +++ b/plugins/redmineup_tags/lib/redmineup_tags/hooks/views_reports_hook.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify diff --git a/plugins/redmineup_tags/lib/redmineup_tags/patches/action_controller_patch.rb b/plugins/redmineup_tags/lib/redmineup_tags/patches/action_controller_patch.rb deleted file mode 100644 index 7780059..0000000 --- a/plugins/redmineup_tags/lib/redmineup_tags/patches/action_controller_patch.rb +++ /dev/null @@ -1,49 +0,0 @@ -# This file is a part of Redmine Tags (redmine_tags) plugin, -# customer relationship management plugin for Redmine -# -# Copyright (C) 2011-2021 RedmineUP -# http://www.redmineup.com/ -# -# redmine_tags 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 3 of the License, or -# (at your option) any later version. -# -# redmine_tags 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 redmine_tags. If not, see <http://www.gnu.org/licenses/>. - -module RedmineupTags - module Patches - module ActionControllerPatch - def self.included(base) - base.extend(ClassMethods) if Rails::VERSION::MAJOR < 4 - - base.class_eval do - end - end - - module ClassMethods - def before_action(*filters, &block) - before_filter(*filters, &block) - end - - def after_action(*filters, &block) - after_filter(*filters, &block) - end - - def skip_before_action(*filters) - skip_before_filter(*filters) - end - end - end - end -end - -unless ActionController::Base.included_modules.include?(RedmineupTags::Patches::ActionControllerPatch) - ActionController::Base.send(:include, RedmineupTags::Patches::ActionControllerPatch) -end diff --git a/plugins/redmineup_tags/lib/redmineup_tags/patches/add_helpers_for_issue_tags_patch.rb b/plugins/redmineup_tags/lib/redmineup_tags/patches/add_helpers_for_issue_tags_patch.rb index ecaa276..ac60fd2 100644 --- a/plugins/redmineup_tags/lib/redmineup_tags/patches/add_helpers_for_issue_tags_patch.rb +++ b/plugins/redmineup_tags/lib/redmineup_tags/patches/add_helpers_for_issue_tags_patch.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -38,4 +38,4 @@ end unless ImportsController.included_modules.include?(RedmineupTags::Patches::AddHelpersForIssueTagsPatch) ImportsController.send(:include, RedmineupTags::Patches::AddHelpersForIssueTagsPatch) -end if Redmine::VERSION.to_s > '3.2' +end diff --git a/plugins/redmineup_tags/lib/redmineup_tags/patches/agile_query_patch.rb b/plugins/redmineup_tags/lib/redmineup_tags/patches/agile_query_patch.rb index 79b8b8a..be81dec 100644 --- a/plugins/redmineup_tags/lib/redmineup_tags/patches/agile_query_patch.rb +++ b/plugins/redmineup_tags/lib/redmineup_tags/patches/agile_query_patch.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -26,8 +26,6 @@ if Redmine::Plugin.installed?(:redmine_agile) && def self.included(base) base.send(:include, InstanceMethods) base.class_eval do - unloadable - alias_method :available_filters_without_redmine_tags, :available_filters alias_method :available_filters, :available_filters_with_redmine_tags @@ -43,7 +41,7 @@ if Redmine::Plugin.installed?(:redmine_agile) && when '!*' issues = Issue.joins(:tags).uniq else - issues = Issue.tagged_with(RedmineCrm::Tag.all.map(&:to_s), any: true) + issues = Issue.tagged_with(Redmineup::Tag.all.map(&:to_s), any: true) end compare = operator.include?('!') ? 'NOT IN' : 'IN' diff --git a/plugins/redmineup_tags/lib/redmineup_tags/patches/agile_versions_query_patch.rb b/plugins/redmineup_tags/lib/redmineup_tags/patches/agile_versions_query_patch.rb index 3b34033..8c99912 100644 --- a/plugins/redmineup_tags/lib/redmineup_tags/patches/agile_versions_query_patch.rb +++ b/plugins/redmineup_tags/lib/redmineup_tags/patches/agile_versions_query_patch.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -29,7 +29,6 @@ if Redmine::Plugin.installed?(:redmine_agile) && def self.included(base) base.send(:include, InstanceMethods) base.class_eval do - unloadable add_available_column QueryTagsColumn.new(:tags_relations, caption: :tags) end end diff --git a/plugins/redmineup_tags/lib/redmineup_tags/patches/auto_completes_controller_patch.rb b/plugins/redmineup_tags/lib/redmineup_tags/patches/auto_completes_controller_patch.rb index e0b4ca6..abc327c 100644 --- a/plugins/redmineup_tags/lib/redmineup_tags/patches/auto_completes_controller_patch.rb +++ b/plugins/redmineup_tags/lib/redmineup_tags/patches/auto_completes_controller_patch.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -42,7 +42,18 @@ module RedmineupTags order: (suggestion_order == 'name' ? 'ASC' : 'DESC') } @redmine_tags = Issue.all_tags(options).limit(params[:limit] || 10) - render layout: false, partial: 'redmine_tags' + render json: format_redmine_tags_json(@redmine_tags) + end + + private + + def format_redmine_tags_json(redmine_tags) + redmine_tags.map do |redmine_tag| + { + id: redmine_tag.name, + text: redmine_tag.name + } + end end end end diff --git a/plugins/redmineup_tags/lib/redmineup_tags/patches/issue_patch.rb b/plugins/redmineup_tags/lib/redmineup_tags/patches/issue_patch.rb index 985eb67..502f41b 100644 --- a/plugins/redmineup_tags/lib/redmineup_tags/patches/issue_patch.rb +++ b/plugins/redmineup_tags/lib/redmineup_tags/patches/issue_patch.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -28,9 +28,7 @@ module RedmineupTags base.class_eval do include InstanceMethods - - unloadable - rcrm_acts_as_taggable + up_acts_as_taggable alias_method :safe_attributes_without_safe_tags=, :safe_attributes= alias_method :safe_attributes=, :safe_attributes_with_safe_tags= @@ -38,11 +36,6 @@ module RedmineupTags class << self alias_method :available_tags_without_redmine_tags, :available_tags alias_method :available_tags, :available_tags_with_redmine_tags - - if Redmine::VERSION.to_s <= '2.7' - alias_method :count_and_group_by_without_redmine_tags, :count_and_group_by - alias_method :count_and_group_by, :count_and_group_by_with_redmine_tags - end end alias_method :copy_from_without_redmine_tags, :copy_from @@ -71,27 +64,27 @@ module RedmineupTags end def all_tags(options = {}) - scope = RedmineCrm::Tag.where({}) - scope = scope.where("LOWER(#{RedmineCrm::Tag.table_name}.name) LIKE LOWER(?)", "%#{options[:name_like]}%") if options[:name_like] + scope = Redmineup::Tag.where({}) + scope = scope.where("LOWER(#{Redmineup::Tag.table_name}.name) LIKE LOWER(?)", "%#{options[:name_like]}%") if options[:name_like] join = [] - join << "JOIN #{RedmineCrm::Tagging.table_name} ON #{RedmineCrm::Tagging.table_name}.tag_id = #{RedmineCrm::Tag.table_name}.id " - join << "JOIN #{Issue.table_name} ON #{Issue.table_name}.id = #{RedmineCrm::Tagging.table_name}.taggable_id - AND #{RedmineCrm::Tagging.table_name}.taggable_type = '#{Issue.name}' " + join << "JOIN #{Redmineup::Tagging.table_name} ON #{Redmineup::Tagging.table_name}.tag_id = #{Redmineup::Tag.table_name}.id " + join << "JOIN #{Issue.table_name} ON #{Issue.table_name}.id = #{Redmineup::Tagging.table_name}.taggable_id + AND #{Redmineup::Tagging.table_name}.taggable_type = '#{Issue.name}' " scope = scope.joins(join.join(' ')) columns = [ - "#{RedmineCrm::Tag.table_name}.*", - "COUNT(DISTINCT #{RedmineCrm::Tagging.table_name}.taggable_id) AS count" + "#{Redmineup::Tag.table_name}.*", + "COUNT(DISTINCT #{Redmineup::Tagging.table_name}.taggable_id) AS count" ] if options[:sort_by] == 'created_at' - columns << "MIN(#{RedmineCrm::Tagging.table_name}.created_at) AS created_at" + columns << "MIN(#{Redmineup::Tagging.table_name}.created_at) AS created_at" end scope = scope.select(columns.join(', ')) - scope = scope.group("#{RedmineCrm::Tag.table_name}.id, #{RedmineCrm::Tag.table_name}.name ") + scope = scope.group("#{Redmineup::Tag.table_name}.id, #{Redmineup::Tag.table_name}.name ") scope = scope.having('COUNT(*) > 0') - column = options[:sort_by] || "#{RedmineCrm::Tag.table_name}.name" + column = options[:sort_by] || "#{Redmineup::Tag.table_name}.name" order = options[:order] || 'ASC' scope.order("#{column} #{order}") end @@ -106,7 +99,7 @@ module RedmineupTags end def by_tags(project, with_subprojects=false) - count_and_group_by(project: project, association: :tags, with_subprojects: with_subprojects) + count_and_group_by_with_redmine_tags(project: project, association: :tags, with_subprojects: with_subprojects) end def count_and_group_by_with_redmine_tags(options) diff --git a/plugins/redmineup_tags/lib/redmineup_tags/patches/issue_query_patch.rb b/plugins/redmineup_tags/lib/redmineup_tags/patches/issue_query_patch.rb index 1fb3fb1..01b2c16 100644 --- a/plugins/redmineup_tags/lib/redmineup_tags/patches/issue_query_patch.rb +++ b/plugins/redmineup_tags/lib/redmineup_tags/patches/issue_query_patch.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -24,8 +24,6 @@ module RedmineupTags base.send(:include, InstanceMethods) base.class_eval do - unloadable - alias_method :statement_without_redmine_tags, :statement alias_method :statement, :statement_with_redmine_tags @@ -52,11 +50,11 @@ module RedmineupTags op = operator_for('issue_tags') case op when '=', '!' - issues = issues.tagged_with(values_for('issue_tags').clone, match_all: true) + issues = issues.tagged_with(values_for('issue_tags').clone, any: true) when '!*' issues = issues.joins(:tags).uniq else - issues = issues.tagged_with(RedmineCrm::Tag.all.map(&:to_s), any: true) + issues = issues.tagged_with(Redmineup::Tag.all.map(&:to_s), any: true) end compare = op.include?('!') ? 'NOT IN' : 'IN' @@ -80,9 +78,9 @@ module RedmineupTags end def build_from_params_with_redmine_tags(params, defaults = {}) - Redmine::VERSION.to_s > '4' ? build_from_params_without_redmine_tags(params, defaults) : build_from_params_without_redmine_tags(params) + build_from_params_without_redmine_tags(params, defaults) - add_filter('issue_tags', '=', [RedmineCrm::Tag.find_by(id: params[:tag_id]).try(:name)]) if params[:tag_id].present? + add_filter('issue_tags', '=', [Redmineup::Tag.find_by(id: params[:tag_id]).try(:name)]) if params[:tag_id].present? end end end diff --git a/plugins/redmineup_tags/lib/redmineup_tags/patches/queries_helper_patch.rb b/plugins/redmineup_tags/lib/redmineup_tags/patches/queries_helper_patch.rb index 797d7b7..df8685c 100644 --- a/plugins/redmineup_tags/lib/redmineup_tags/patches/queries_helper_patch.rb +++ b/plugins/redmineup_tags/lib/redmineup_tags/patches/queries_helper_patch.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -27,7 +27,6 @@ module RedmineupTags base.send(:include, InstanceMethods) base.class_eval do - unloadable alias_method :column_value_without_tags, :column_value alias_method :column_value, :column_value_with_tags end diff --git a/plugins/redmineup_tags/lib/redmineup_tags/patches/reports_controller_patch.rb b/plugins/redmineup_tags/lib/redmineup_tags/patches/reports_controller_patch.rb index b21b1b5..775040f 100644 --- a/plugins/redmineup_tags/lib/redmineup_tags/patches/reports_controller_patch.rb +++ b/plugins/redmineup_tags/lib/redmineup_tags/patches/reports_controller_patch.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify diff --git a/plugins/redmineup_tags/lib/redmineup_tags/patches/time_entry_patch.rb b/plugins/redmineup_tags/lib/redmineup_tags/patches/time_entry_patch.rb index 168833f..1e1a859 100644 --- a/plugins/redmineup_tags/lib/redmineup_tags/patches/time_entry_patch.rb +++ b/plugins/redmineup_tags/lib/redmineup_tags/patches/time_entry_patch.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify diff --git a/plugins/redmineup_tags/lib/redmineup_tags/patches/time_entry_query_patch.rb b/plugins/redmineup_tags/lib/redmineup_tags/patches/time_entry_query_patch.rb index bb7fe20..3808165 100644 --- a/plugins/redmineup_tags/lib/redmineup_tags/patches/time_entry_query_patch.rb +++ b/plugins/redmineup_tags/lib/redmineup_tags/patches/time_entry_query_patch.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -24,8 +24,6 @@ module RedmineupTags base.send(:include, InstanceMethods) base.class_eval do - unloadable - alias_method :statement_without_redmine_tags, :statement alias_method :statement, :statement_with_redmine_tags @@ -53,7 +51,7 @@ module RedmineupTags when '!*' issues = issues.joins(:tags).uniq else - issues = issues.tagged_with(RedmineCrm::Tag.all.map(&:to_s), any: true) + issues = issues.tagged_with(Redmineup::Tag.all.map(&:to_s), any: true) end compare = op.include?('!') ? 'NOT IN' : 'IN' diff --git a/plugins/redmineup_tags/lib/redmineup_tags/patches/time_report_patch.rb b/plugins/redmineup_tags/lib/redmineup_tags/patches/time_report_patch.rb index 2704271..a83a752 100644 --- a/plugins/redmineup_tags/lib/redmineup_tags/patches/time_report_patch.rb +++ b/plugins/redmineup_tags/lib/redmineup_tags/patches/time_report_patch.rb @@ -1,7 +1,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -25,8 +25,6 @@ module RedmineupTags def self.included(base) base.send(:include, InstanceMethods) base.class_eval do - unloadable - alias_method :load_available_criteria_without_redmine_tags, :load_available_criteria alias_method :load_available_criteria, :load_available_criteria_with_redmine_tags end @@ -37,8 +35,8 @@ module RedmineupTags def load_available_criteria_with_redmine_tags return @load_available_criteria_with_redmine_tags if @load_available_criteria_with_redmine_tags @load_available_criteria_with_redmine_tags = load_available_criteria_without_redmine_tags - @load_available_criteria_with_redmine_tags['tags'] = { sql: "#{RedmineCrm::Tag.table_name}.id", - klass: RedmineCrm::Tag, + @load_available_criteria_with_redmine_tags['tags'] = { sql: "#{Redmineup::Tag.table_name}.id", + klass: Redmineup::Tag, joins: redmine_tags_join, label: :tags } @load_available_criteria_with_redmine_tags @@ -47,15 +45,7 @@ module RedmineupTags private def redmine_tags_join - return { issue: :tags } if [Redmine::VERSION::MAJOR, Redmine::VERSION::MINOR] != [3, 4] - time_entry_table = Arel::Table.new(TimeEntry.table_name) - issues_table = Arel::Table.new(Issue.table_name, as: :issues_time_entries) - taggings_table = Arel::Table.new(:taggings) - tags_table = Arel::Table.new(RedmineCrm::Tag.table_name) - jn = time_entry_table.join(issues_table).on(issues_table[:id].eq(time_entry_table[:issue_id])) - .join(taggings_table).on(taggings_table[:taggable_id].eq(issues_table[:id]).and(taggings_table[:taggable_type].eq('Issue'))) - .join(tags_table).on(tags_table[:id].eq(taggings_table[:tag_id])) - .join_sources + { issue: :tags } end end end diff --git a/plugins/redmineup_tags/test/functional/agile_boards_controller_test.rb b/plugins/redmineup_tags/test/functional/agile_boards_controller_test.rb index 07c5bb0..671967e 100644 --- a/plugins/redmineup_tags/test/functional/agile_boards_controller_test.rb +++ b/plugins/redmineup_tags/test/functional/agile_boards_controller_test.rb @@ -3,7 +3,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify diff --git a/plugins/redmineup_tags/test/functional/agile_versions_controller_test.rb b/plugins/redmineup_tags/test/functional/agile_versions_controller_test.rb index 18b9198..40887a1 100644 --- a/plugins/redmineup_tags/test/functional/agile_versions_controller_test.rb +++ b/plugins/redmineup_tags/test/functional/agile_versions_controller_test.rb @@ -3,7 +3,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify diff --git a/plugins/redmineup_tags/test/functional/auto_completes_controller_test.rb b/plugins/redmineup_tags/test/functional/auto_completes_controller_test.rb index dd9046f..4535455 100644 --- a/plugins/redmineup_tags/test/functional/auto_completes_controller_test.rb +++ b/plugins/redmineup_tags/test/functional/auto_completes_controller_test.rb @@ -3,7 +3,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -43,7 +43,7 @@ class AutoCompletesControllerTest < ActionController::TestCase :custom_fields_trackers def setup - @tag = RedmineCrm::Tag.create(name: 'Test_tag') + @tag = Redmineup::Tag.create(name: 'Test_tag') @request.session[:user_id] = 1 end diff --git a/plugins/redmineup_tags/test/functional/issue_tags_controller_test.rb b/plugins/redmineup_tags/test/functional/issue_tags_controller_test.rb index cd517d8..556a5ff 100644 --- a/plugins/redmineup_tags/test/functional/issue_tags_controller_test.rb +++ b/plugins/redmineup_tags/test/functional/issue_tags_controller_test.rb @@ -3,7 +3,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify diff --git a/plugins/redmineup_tags/test/functional/issues_controller_test.rb b/plugins/redmineup_tags/test/functional/issues_controller_test.rb index b2cd970..547a107 100644 --- a/plugins/redmineup_tags/test/functional/issues_controller_test.rb +++ b/plugins/redmineup_tags/test/functional/issues_controller_test.rb @@ -3,7 +3,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -43,8 +43,8 @@ class IssuesControllerTest < ActionController::TestCase :custom_fields_trackers def setup - @tag = RedmineCrm::Tag.create(name: 'test_tag') - @last_tag = RedmineCrm::Tag.create(name: 'last_tag') + @tag = Redmineup::Tag.create(name: 'test_tag') + @last_tag = Redmineup::Tag.create(name: 'last_tag') @request.session[:user_id] = 1 end @@ -68,6 +68,26 @@ class IssuesControllerTest < ActionController::TestCase issue.tags = [] end + def test_get_index_without_selected_tags + issue1, issue2 = Issue.find(1), Issue.find(2) + issue1.tags << @tag + issue2.tags << @last_tag + compatible_request( + :get, + :index, + f: ['issue_tags'], + op: { issue_tags: '!' }, + v: { issue_tags: ['test_tag', 'last_tag'] }, + c: ['status', 'priority', 'subject', 'tags_relations'] + ) + assert_response :success + assert_select 'table.list.issues tr.issue', (Issue.count - 2) + assert_select 'table.list.issues tr.issue td.subject', text: issue2.subject, count: 0 + assert_select 'table.list.issues tr.issue td.tags a', text: 'test_tag', count: 0 + ensure + issue1.tags, issue2.tags = [], [] + end + def test_get_index_with_sidebar_tags_in_list_by_count issue1 = Issue.find(1) issue1.tags << @tag diff --git a/plugins/redmineup_tags/test/functional/reports_controller_test.rb b/plugins/redmineup_tags/test/functional/reports_controller_test.rb index b511918..a0f1b84 100644 --- a/plugins/redmineup_tags/test/functional/reports_controller_test.rb +++ b/plugins/redmineup_tags/test/functional/reports_controller_test.rb @@ -3,7 +3,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify diff --git a/plugins/redmineup_tags/test/functional/tags_controller_test.rb b/plugins/redmineup_tags/test/functional/tags_controller_test.rb index 7143c80..9e11430 100644 --- a/plugins/redmineup_tags/test/functional/tags_controller_test.rb +++ b/plugins/redmineup_tags/test/functional/tags_controller_test.rb @@ -3,7 +3,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -57,14 +57,14 @@ class TagsControllerTest < ActionController::TestCase end def test_should_get_edit - tag = RedmineCrm::Tag.find_by_name('a1') + tag = Redmineup::Tag.find_by_name('a1') compatible_request :get, :edit, id: tag.id assert_response :success assert_select "input#tag_name[value='#{tag.name}']", 1 end def test_should_put_update - tag1 = RedmineCrm::Tag.find_by_name('a1') + tag1 = Redmineup::Tag.find_by_name('a1') new_name = 'updated main' compatible_request :put, :update, id: tag1.id, tag: { name: new_name } assert_redirected_to controller: 'settings', action: 'plugin', id: 'redmineup_tags', tab: 'manage_tags' @@ -73,17 +73,17 @@ class TagsControllerTest < ActionController::TestCase end test 'should delete destroy' do - tag1 = RedmineCrm::Tag.find_by_name('a1') - assert_difference 'RedmineCrm::Tag.count', -1 do + tag1 = Redmineup::Tag.find_by_name('a1') + assert_difference 'Redmineup::Tag.count', -1 do compatible_request :post, :destroy, ids: tag1.id assert_response 302 end end test 'should post merge' do - tag1 = RedmineCrm::Tag.find_by_name('a1') - tag2 = RedmineCrm::Tag.find_by_name('b8') - assert_difference 'RedmineCrm::Tag.count', -1 do + tag1 = Redmineup::Tag.find_by_name('a1') + tag2 = Redmineup::Tag.find_by_name('b8') + assert_difference 'Redmineup::Tag.count', -1 do compatible_request :post, :merge, ids: [tag1.id, tag2.id], tag: { name: 'a1' } assert_redirected_to controller: 'settings', action: 'plugin', id: 'redmineup_tags', tab: 'manage_tags' end diff --git a/plugins/redmineup_tags/test/functional/timelog_controller_test.rb b/plugins/redmineup_tags/test/functional/timelog_controller_test.rb index 9dcbb91..2953325 100644 --- a/plugins/redmineup_tags/test/functional/timelog_controller_test.rb +++ b/plugins/redmineup_tags/test/functional/timelog_controller_test.rb @@ -3,7 +3,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify diff --git a/plugins/redmineup_tags/test/test_helper.rb b/plugins/redmineup_tags/test/test_helper.rb index a89955b..3068ca4 100644 --- a/plugins/redmineup_tags/test/test_helper.rb +++ b/plugins/redmineup_tags/test/test_helper.rb @@ -3,7 +3,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify @@ -36,21 +36,17 @@ def plugin_fixtures(*fixtures) end def create_fixtures(fixtures_directory, table_names, class_names = {}) - if ActiveRecord::VERSION::MAJOR >= 4 - ActiveRecord::FixtureSet.create_fixtures(fixtures_directory, table_names, class_names) - else - ActiveRecord::Fixtures.create_fixtures(fixtures_directory, table_names, class_names) - end + ActiveRecord::FixtureSet.create_fixtures(fixtures_directory, table_names, class_names) end plugin_fixtures :all def compatible_request(type, action, parameters = {}) - Rails.version < '5.1' ? send(type, action, parameters) : send(type, action, params: parameters) + send(type, action, params: parameters) end def compatible_xhr_request(type, action, parameters = {}) - Rails.version < '5.1' ? xhr(type, action, parameters) : send(type, action, params: parameters, xhr: true) + send(type, action, params: parameters, xhr: true) end # Returns the issues that are displayed in the list in the same order diff --git a/plugins/redmineup_tags/test/unit/issue_test.rb b/plugins/redmineup_tags/test/unit/issue_test.rb index f1b6e50..a28a09d 100644 --- a/plugins/redmineup_tags/test/unit/issue_test.rb +++ b/plugins/redmineup_tags/test/unit/issue_test.rb @@ -3,7 +3,7 @@ # This file is a part of Redmine Tags (redmine_tags) plugin, # customer relationship management plugin for Redmine # -# Copyright (C) 2011-2021 RedmineUP +# Copyright (C) 2011-2024 RedmineUP # http://www.redmineup.com/ # # redmine_tags is free software: you can redistribute it and/or modify -- GitLab