additional_tags 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/linters.yml +2 -2
  3. data/.github/workflows/tests.yml +2 -9
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +16 -10
  6. data/README.md +4 -4
  7. data/additional_tags.gemspec +2 -2
  8. data/app/controllers/additional_tags_controller.rb +26 -3
  9. data/app/helpers/additional_tags_helper.rb +1 -1
  10. data/app/helpers/additional_tags_wiki_helper.rb +11 -6
  11. data/app/jobs/additional_tags_remove_unused_tag_job.rb +11 -6
  12. data/app/views/additional_tags/_tag_list.html.slim +3 -3
  13. data/app/views/additional_tags/context_menu.html.slim +1 -4
  14. data/app/views/additional_tags/index.api.rsb +5 -0
  15. data/app/views/additional_tags/settings/_manage_tags.html.slim +1 -2
  16. data/app/views/dashboards/blocks/_issue_tags.html.slim +6 -6
  17. data/app/views/issue_tags/edit.js.erb +1 -1
  18. data/app/views/issues/_tags.html.slim +7 -7
  19. data/app/views/issues/_tags_form_details.html.slim +1 -2
  20. data/app/views/issues/_tags_sidebar.html.slim +4 -1
  21. data/app/views/wiki/_tags_form_bottom.html.slim +1 -2
  22. data/app/views/wiki/_tags_show.html.slim +7 -7
  23. data/app/views/wiki/tag_index.html.slim +2 -2
  24. data/config/initializers/zeitwerk.rb +2 -4
  25. data/config/routes.rb +1 -1
  26. data/init.rb +1 -2
  27. data/lib/additional_tags/hooks/model_hook.rb +0 -2
  28. data/lib/additional_tags/hooks/view_hook.rb +3 -1
  29. data/lib/additional_tags/patches/issue_patch.rb +16 -16
  30. data/lib/additional_tags/patches/query_patch.rb +1 -1
  31. data/lib/additional_tags/patches/wiki_page_patch.rb +3 -2
  32. data/lib/additional_tags/plugin_version.rb +1 -1
  33. data/lib/additional_tags/tags.rb +3 -3
  34. data/lib/additional_tags.rb +5 -8
  35. metadata +7 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d10d32f78d464486a2921a86274972ec068f3aad16c988f9037e89a433ac4efa
4
- data.tar.gz: 50833ac552b8b3de0cba5eb5d9710cdbafdf17b3c2d53e742031ed22a52c9e86
3
+ metadata.gz: 05656ef90d3c7c796b1bd3d510f6a349fc77c8b1adbf43ca6135af8e48ca705e
4
+ data.tar.gz: a22552cd9d096d6963dd9349c207da4755b1e3ba1d8dec560d404b3207ee1458
5
5
  SHA512:
6
- metadata.gz: 837feb0dba819a2191dbd5151f523a3f65aac23918faaa2f93277a0b51c33e4483353c43dd7ae69ae98b43886099fe7f3005b33daafe9d05d4b593ce1866e657
7
- data.tar.gz: 2d54a07615b231470a074e42ec5f4d275af5b5838338a360e8d7401fa742deeba0b500a1ca94069a3b37240e23947e9110c6b2f6f785ec3517ae1cfc63a66351
6
+ metadata.gz: 2eb18bdccf79be5d1f1b4327c11c3c838e434c8737edcfa096d62d61925170e53be4a6ae45fb486e0c5b3a008933dc30e3bd2c36de9db929fe1fb1e71225adf2
7
+ data.tar.gz: 97fd974a51bcdf337c0246cd95c0313639d43aa73f19ac9a81f0f9efa87da0e3c02736970b5c8148566ded5bb3e670a2fb332a03f99d85f59caed219d12410be
@@ -8,7 +8,7 @@ jobs:
8
8
  runs-on: ubuntu-latest
9
9
 
10
10
  steps:
11
- - uses: actions/checkout@v1
11
+ - uses: actions/checkout@v2
12
12
 
13
13
  - name: Install package dependencies
14
14
  run: >
@@ -22,7 +22,7 @@ jobs:
22
22
  - name: Setup Ruby
23
23
  uses: ruby/setup-ruby@v1
24
24
  with:
25
- ruby-version: 2.6
25
+ ruby-version: 3.1
26
26
  bundler-cache: true
27
27
 
28
28
  - name: Setup gems
@@ -10,16 +10,9 @@ jobs:
10
10
 
11
11
  strategy:
12
12
  matrix:
13
- ruby: ['2.7', '2.6', '3.0']
14
- redmine: ['4.1-stable', '4.2-stable', 'master']
13
+ ruby: ['2.7', '3.0', '3.1']
14
+ redmine: ['5.0-stable', 'master']
15
15
  db: ['postgres', 'mysql']
16
- exclude:
17
- - ruby: '2.7'
18
- redmine: 4.1-stable
19
- - ruby: '3.0'
20
- redmine: 4.1-stable
21
- - ruby: '3.0'
22
- redmine: 4.2-stable
23
16
  fail-fast: false
24
17
 
25
18
  services:
data/.gitignore CHANGED
@@ -8,3 +8,4 @@ Gemfile.lock
8
8
  .enable_*
9
9
  ._*
10
10
  *.gem
11
+ rails_best_practices_output.html
data/.rubocop.yml CHANGED
@@ -1,14 +1,23 @@
1
1
  require:
2
2
  - rubocop-performance
3
3
  - rubocop-rails
4
+ - rubocop-minitest
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 2.7
8
+ TargetRailsVersion: 6.1
9
+ NewCops: enable
10
+ ActiveSupportExtensionsEnabled: true
4
11
 
5
12
  Rails:
6
13
  Enabled: true
7
14
 
8
- AllCops:
9
- TargetRubyVersion: 2.6
10
- TargetRailsVersion: 5.2
11
- NewCops: enable
15
+ Minitest/MultipleAssertions:
16
+ Max: 15
17
+ Enabled: true
18
+
19
+ Minitest/AssertPredicate:
20
+ Enabled: false
12
21
 
13
22
  Metrics/AbcSize:
14
23
  Enabled: false
@@ -110,17 +119,14 @@ Style/MethodCallWithArgsParentheses:
110
119
  AllowParenthesesInChaining: true
111
120
  EnforcedStyle: omit_parentheses
112
121
 
113
- Style/HashTransformKeys:
114
- Enabled: false
115
-
116
- Style/HashTransformValues:
117
- Enabled: false
118
-
119
122
  Naming/VariableNumber:
120
123
  Enabled: true
121
124
  Exclude:
122
125
  - 'test/**/*'
123
126
 
127
+ Layout/LineContinuationLeadingSpace:
128
+ Enabled: false
129
+
124
130
  # see https://github.com/rubocop/rubocop-rails/issues/578
125
131
  # redmine does not use load_defaults: https://rails.rubystyle.guide/#config-defaults
126
132
  Rails/RedundantPresenceValidationOnBelongsTo:
data/README.md CHANGED
@@ -38,8 +38,8 @@ Start using it, too. The example image shows the centralized tag management in t
38
38
 
39
39
  ## Requirements
40
40
 
41
- - Redmine `>= 4.1.0`
42
- - Ruby `>= 2.6`
41
+ - Redmine `>= 5.0`
42
+ - Ruby `>= 2.7`
43
43
  - Redmine plugins: [additionals](https://www.redmine.org/plugins/additionals)
44
44
 
45
45
  ## Installing
@@ -71,14 +71,14 @@ git clone https://github.com/alphanodes/additionals.git plugins/additionals
71
71
  git clone https://github.com/alphanodes/additional_tags.git plugins/additional_tags
72
72
  ```
73
73
 
74
- ### 2. Install dependencies and migrate database.
74
+ ### 2. Install dependencies and migrate database
75
75
 
76
76
  ```shell
77
77
  bundle install
78
78
  bundle exec rake redmine:plugins:migrate RAILS_ENV=production
79
79
  ```
80
80
 
81
- ### 3. Restart your Redmine web server.
81
+ ### 3. Restart your Redmine web server
82
82
 
83
83
  ## Running tests
84
84
 
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
22
22
  spec.bindir = 'exe'
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename f }
24
24
  spec.require_paths = ['lib']
25
- spec.required_ruby_version = '>= 2.6'
25
+ spec.required_ruby_version = '>= 2.7'
26
26
 
27
- spec.add_runtime_dependency 'acts-as-taggable-on', '~> 7.0'
27
+ spec.add_runtime_dependency 'acts-as-taggable-on', '~> 9.0'
28
28
  spec.add_runtime_dependency 'redmine_plugin_kit'
29
29
 
30
30
  spec.add_development_dependency 'bundler'
@@ -7,13 +7,36 @@ class AdditionalTagsController < ApplicationController
7
7
  before_action :set_tag_list_path
8
8
 
9
9
  helper :additional_tags_issues
10
+ include AdditionalTagsHelper
11
+
12
+ accept_api_auth :index
13
+
14
+ # used by api calls
15
+ def index
16
+ raise 'type is not provided' if params[:type].blank?
17
+
18
+ type_info = manageable_tag_columns.detect { |m| m.first.to_s == params[:type] }
19
+ raise 'type is not supported' unless type_info
20
+
21
+ klass = type_info.first.to_s.camelize.constantize
22
+ raise "#{klass.name} does not support tags" unless klass.respond_to? :available_tags
23
+
24
+ @tags = klass.available_tags.to_a
25
+ @count = @tags.count
26
+ @tag_type = klass.name
27
+
28
+ respond_to do |format|
29
+ format.html { head :not_acceptable }
30
+ format.api
31
+ end
32
+ end
10
33
 
11
34
  def edit; end
12
35
 
13
36
  def destroy
14
37
  @tags.each do |tag|
15
- tag.reload.destroy
16
- rescue ::ActiveRecord::RecordNotFound
38
+ tag.reload.destroy!
39
+ rescue ::ActiveRecord::RecordNotFound, ::ActiveRecord::RecordNotDestroyed
17
40
  Rails.logger.warn "Tag #{tag} could not be deleted"
18
41
  end
19
42
  redirect_back_or_default @tag_list_path
@@ -31,7 +54,7 @@ class AdditionalTagsController < ApplicationController
31
54
  end
32
55
  else
33
56
  respond_to do |format|
34
- format.html { render action: 'edit' }
57
+ format.html { render :edit }
35
58
  end
36
59
  end
37
60
  end
@@ -168,7 +168,7 @@ module AdditionalTagsHelper
168
168
  def additional_tags_from_params(str)
169
169
  tags = str.is_a?(Array) ? str : str.to_s.split(',')
170
170
  tags.map!(&:strip)
171
- tags.reject(&:blank?)
171
+ tags.compact_blank
172
172
  end
173
173
 
174
174
  def additional_tag_links(tag_list, **options)
@@ -18,18 +18,23 @@ module AdditionalTagsWikiHelper
18
18
  render_tags_list sidebar_tags, **options
19
19
  end
20
20
 
21
- def render_wiki_index_title(project, tag = nil)
21
+ def render_wiki_index_title(project: nil, name: nil, tag: nil, title: :label_wiki)
22
22
  if tag.present?
23
- if project.nil?
24
- title = [link_to(l(:label_wiki), wiki_index_path)]
23
+ if project
24
+ t :label_wiki_index_for_tag_html, tag: tag
25
+ else
26
+ title = [link_to(l(title), wiki_index_path)]
25
27
  title << Additionals::LIST_SEPARATOR
26
28
  title << t(:label_wiki_index_for_tag_html, tag: tag)
27
29
  safe_join title, ' '
28
- else
29
- t :label_wiki_index_for_tag_html, tag: tag
30
30
  end
31
+ elsif name.present?
32
+ title = [link_to(l(title), wiki_index_path)]
33
+ title << Additionals::LIST_SEPARATOR
34
+ title << name
35
+ safe_join title, ' '
31
36
  else
32
- l :label_wiki
37
+ l title
33
38
  end
34
39
  end
35
40
  end
@@ -2,11 +2,16 @@
2
2
 
3
3
  class AdditionalTagsRemoveUnusedTagJob < AdditionalTagsJob
4
4
  def perform
5
- # only once a minute to reduce load
6
- cache_key = self.class.to_s
7
- return if Rails.cache.read(cache_key) && !Rails.env.test?
8
-
9
- Rails.cache.write cache_key, true, expires_in: 60
10
- AdditionalTags::Tags.remove_unused_tags
5
+ if Rails.env.test?
6
+ # no cache for testing
7
+ AdditionalTags::Tags.remove_unused_tags
8
+ else
9
+ # only once a minute to reduce load
10
+ cache = ActiveSupport::Cache::MemoryStore.new expires_in: 1.minute
11
+ cache.fetch self.class.to_s do
12
+ AdditionalTags::Tags.remove_unused_tags
13
+ true
14
+ end
15
+ end
11
16
  end
12
17
  end
@@ -18,10 +18,10 @@
18
18
  onclick: "$('#edit_tags_form').show(); $('#tags-data').hide(); return false;",
19
19
  id: 'edit_tags_link'
20
20
 
21
- #edit_tags_form style="display: none;"
21
+ #edit_tags_form.hidden
22
22
  = form_tag update_url, method: :put do
23
- = render partial: defined?(tags_form) ? tags_form : 'tags_form',
24
- locals: { css_id: defined?(css_id) ? css_id : nil }
23
+ = render defined?(tags_form) ? tags_form : 'tags_form',
24
+ css_id: defined?(css_id) ? css_id : nil
25
25
  '
26
26
  = submit_tag l(:button_save), class: 'button-small'
27
27
  '
@@ -10,7 +10,4 @@ ul
10
10
  merge_additional_tags_path(ids: @tags.collect(&:id)),
11
11
  class: 'icon icon-tags-merge'
12
12
  li
13
- = link_to l(:button_delete),
14
- additional_tags_path(ids: @tags.collect(&:id), back_url: @back),
15
- method: :delete, data: { confirm: l(:text_are_you_sure) },
16
- class: 'icon icon-del'
13
+ = delete_link additional_tags_path(ids: @tags.collect(&:id), back_url: @back)
@@ -0,0 +1,5 @@
1
+ api.array :tags, api_meta(total_count: @count, tag_type: @tag_type) do
2
+ @tags.each do |tag|
3
+ api.tag id: tag.id, name: tag.name, count: tag.count
4
+ end
5
+ end
@@ -23,8 +23,7 @@
23
23
  td.buttons
24
24
  = link_to l(:button_edit), edit_additional_tag_path(tag),
25
25
  class: 'icon icon-edit'
26
- = link_to l(:button_delete), additional_tags_path(ids: tag), method: :delete,
27
- data: { confirm: l(:text_are_you_sure) }, class: 'icon icon-del'
26
+ = delete_link additional_tags_path(ids: tag)
28
27
  - else
29
28
  p.nodata = l :label_no_data
30
29
 
@@ -7,12 +7,12 @@ h3 = block_definition[:label]
7
7
  statuses: { true => :closed, false => :open },
8
8
  group_id_is_bool: true
9
9
 
10
- = render partial: 'common/tag_summary_block',
11
- locals: { tags: tags,
12
- entities_label: l(:label_issue_plural),
13
- totals_link: link_to_issue_tags_totals(entries: counts,
14
- project: @project,
15
- open_issues_only: open_issues_only) }
10
+ = render 'common/tag_summary_block',
11
+ tags: tags,
12
+ entities_label: l(:label_issue_plural),
13
+ totals_link: link_to_issue_tags_totals(entries: counts,
14
+ project: @project,
15
+ open_issues_only: open_issues_only)
16
16
 
17
17
  - if RedminePluginKit.true? settings[:with_table_of_values]
18
18
  - if tags.present?
@@ -1,2 +1,2 @@
1
- $('#ajax-modal').html('<%= escape_javascript(render partial: 'issue_tags/edit_modal') %>');
1
+ $('#ajax-modal').html("<%= escape_javascript(render 'issue_tags/edit_modal') %>");
2
2
  showModal('ajax-modal', '600px');
@@ -1,8 +1,8 @@
1
1
  - if AdditionalTags.setting?(:active_issue_tags) && User.current.allowed_to?(:view_issue_tags, issue.project)
2
- = render partial: 'additional_tags/tag_list',
3
- locals: { entry: issue,
4
- show_always: true,
5
- editable: issue.editable?(User.current),
6
- css_id: 'issue_tag_list_show',
7
- update_url: issue_path(issue),
8
- use_colors: AdditionalTags.setting?(:use_colors) }
2
+ = render 'additional_tags/tag_list',
3
+ entry: issue,
4
+ show_always: true,
5
+ editable: issue.editable?(User.current),
6
+ css_id: 'issue_tag_list_show',
7
+ update_url: issue_path(issue),
8
+ use_colors: AdditionalTags.setting?(:use_colors)
@@ -3,5 +3,4 @@
3
3
  div
4
4
  p#issue_tags
5
5
  = label_tag l(:field_tag_list)
6
- = render partial: tags_form,
7
- locals: { project: project }
6
+ = render tags_form, project: project
@@ -1,5 +1,8 @@
1
1
  - if AdditionalTags.setting?(:active_issue_tags) && \
2
- User.current.allowed_to?(:view_issue_tags, @project, global: true) && sidebar_tags.present?
2
+ User.current.allowed_to?(:view_issue_tags, @project, global: true) && \
3
+ defined?(sidebar_tags) && \
4
+ sidebar_tags.present?
5
+
3
6
  .sidebar-tags
4
7
  h3 = l :field_tags
5
8
  = render_sidebar_tags
@@ -1,5 +1,4 @@
1
1
  - if AdditionalTags.setting?(:active_wiki_tags) && User.current.allowed_to?(:add_wiki_tags, @project)
2
2
  p#wiki_tags
3
3
  = label_tag l(:field_tag_list)
4
- = render partial: 'wiki/tags_form',
5
- locals: { project: project, page: page }
4
+ = render 'wiki/tags_form', project: project, page: page
@@ -1,9 +1,9 @@
1
1
  - if AdditionalTags.setting? :active_wiki_tags
2
2
  .wiki-attributes
3
- = render partial: 'additional_tags/tag_list',
4
- locals: { entry: page,
5
- show_always: true,
6
- link_wiki_tag: true,
7
- editable: User.current.allowed_to?(:add_wiki_tags, @project),
8
- update_url: update_tags_project_wiki_page_path(@project, page.title),
9
- use_colors: AdditionalTags.setting?(:use_colors) }
3
+ = render 'additional_tags/tag_list',
4
+ entry: page,
5
+ show_always: true,
6
+ link_wiki_tag: true,
7
+ editable: User.current.allowed_to?(:add_wiki_tags, @project),
8
+ update_url: update_tags_project_wiki_page_path(@project, page.title),
9
+ use_colors: AdditionalTags.setting?(:use_colors)
@@ -2,7 +2,7 @@
2
2
  - if User.current.allowed_to? :edit_wiki_pages, @project
3
3
  = link_to l(:label_wiki_page_new), new_project_wiki_page_path(@project), remote: true, class: 'icon icon-add'
4
4
 
5
- h2 = render_wiki_index_title @project, @tag
5
+ h2 = render_wiki_index_title project: @project, tag: @tag
6
6
 
7
7
  - if @pages.empty?
8
8
  p.nodata = l :label_no_data
@@ -18,4 +18,4 @@ h2 = render_wiki_index_title @project, @tag
18
18
  = link_to page.parent.pretty_title, project_wiki_page_path(@project, page.parent.title)
19
19
 
20
20
  - content_for :sidebar do
21
- = render partial: 'sidebar'
21
+ = render 'sidebar'
@@ -1,6 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- if Rails.version > '6.0'
4
- plugin_dir = RedminePluginKit::Loader.plugin_dir plugin_id: 'additional_tags'
5
- Rails.autoloaders.main.push_dir "#{plugin_dir}/lib"
6
- end
3
+ plugin_dir = RedminePluginKit::Loader.plugin_dir plugin_id: 'additional_tags'
4
+ Rails.autoloaders.main.push_dir "#{plugin_dir}/lib"
data/config/routes.rb CHANGED
@@ -9,7 +9,7 @@ Rails.application.routes.draw do
9
9
  end
10
10
  end
11
11
 
12
- resources :additional_tags, only: %i[edit update] do
12
+ resources :additional_tags, only: %i[index edit update] do
13
13
  collection do
14
14
  post :merge
15
15
  get :context_menu, :merge
data/init.rb CHANGED
@@ -13,7 +13,7 @@ Redmine::Plugin.register :additional_tags do
13
13
  author_url 'https://alphanodes.com/'
14
14
  directory __dir__
15
15
 
16
- requires_redmine version_or_higher: '4.1'
16
+ requires_redmine version_or_higher: '5.0'
17
17
 
18
18
  settings default: loader.default_settings,
19
19
  partial: 'additional_tags/settings/settings'
@@ -35,4 +35,3 @@ Redmine::Plugin.register :additional_tags do
35
35
  end
36
36
 
37
37
  RedminePluginKit::Loader.persisting { loader.load_model_hooks! }
38
- RedminePluginKit::Loader.to_prepare { AdditionalTags.setup!(loader) } if Rails.version < '6.0'
@@ -4,8 +4,6 @@ module AdditionalTags
4
4
  module Hooks
5
5
  class ModelHook < Redmine::Hook::Listener
6
6
  def after_plugins_loaded(_context = {})
7
- return if Rails.version < '6.0'
8
-
9
7
  AdditionalTags.setup!
10
8
  end
11
9
  end
@@ -54,13 +54,15 @@ module AdditionalTags
54
54
 
55
55
  pdf.ln
56
56
  pdf.SetFontStyle '', 8
57
- pdf.RDMCell 190, 5, page.tag_list.join(', ')
57
+ pdf.RDMCell 190, 5, page.tag_list.to_list
58
58
  pdf.ln
59
59
  end
60
60
 
61
61
  private
62
62
 
63
63
  def issues_bulk_tags_fix(issue, params)
64
+ return unless params && params[:issue]
65
+
64
66
  old_tags = issue.tags.map(&:name)
65
67
  new_tags = Array(params[:issue][:tag_list]).reject(&:empty?)
66
68
  issue.tag_list = (old_tags + new_tags).uniq
@@ -56,29 +56,29 @@ module AdditionalTags
56
56
  end
57
57
 
58
58
  def safe_attributes_with_tags=(attrs, user = User.current)
59
- if attrs && attrs[:tag_list]
60
- tags = attrs.delete :tag_list
61
- tags = Array(tags).reject(&:empty?)
62
-
63
- if user.allowed_to?(:create_issue_tags, project) ||
64
- user.allowed_to?(:edit_issue_tags, project) && Issue.allowed_tags?(tags)
65
- attrs[:tag_list] = tags
66
- self.tag_list = tags
67
- end
68
- end
59
+ send :safe_attributes_without_tags=, attrs, user # required to fire first to get loaded project
60
+ return unless attrs && attrs[:tag_list]
61
+
62
+ tags = attrs.delete :tag_list
63
+ tags = Array(tags).reject(&:empty?)
64
+
65
+ Additionals.debug "tags: #{tags.inspect} - project: #{project&.id} - access: #{user.allowed_to? :create_issue_tags, project}"
69
66
 
70
- send :safe_attributes_without_tags=, attrs, user
67
+ if user.allowed_to?(:create_issue_tags, project) ||
68
+ user.allowed_to?(:edit_issue_tags, project) && Issue.allowed_tags?(tags)
69
+ attrs[:tag_list] = tags # required fix for journal details
70
+ self.tag_list = tags # required fix for tags
71
+ end
71
72
  end
72
73
 
73
- # copy_from requires hash for Redmine - works with Ruby 3
74
- # rubocop: disable Style/OptionHash
75
- def copy_from_with_tags(arg, options = {})
76
- copy_from_without_tags arg, options
74
+ def copy_from_with_tags(arg, options = nil)
75
+ options ||= {} # works with Ruby 3
76
+
77
+ copy_from_without_tags arg, **options
77
78
  issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg)
78
79
  self.tag_list = issue.tag_list
79
80
  self
80
81
  end
81
- # rubocop: enable Style/OptionHash
82
82
 
83
83
  private
84
84
 
@@ -44,7 +44,7 @@ module AdditionalTags
44
44
  subsql = ActsAsTaggableOn::Tagging.joins("INNER JOIN #{quoted_joined_table}" \
45
45
  " ON additional_taggings.taggable_id = #{quoted_joined_table}.#{quoted_target_field}")
46
46
  .where(taggable_type: klass.name)
47
- .where("#{self.class.connection.quote_table_name queried_table_name}.#{quoted_source_field} ="\
47
+ .where("#{self.class.connection.quote_table_name queried_table_name}.#{quoted_source_field} =" \
48
48
  " #{quoted_joined_table}.#{quoted_joined_field}")
49
49
  .select(1)
50
50
 
@@ -41,15 +41,16 @@ module AdditionalTags
41
41
  scope
42
42
  end
43
43
 
44
- def with_tags(tag, project: nil, order: 'title_asc', max_entries: nil)
44
+ def with_tags(tag, project: nil, order: 'title_asc', max_entries: nil, exclude_page: nil)
45
45
  wiki = project&.wiki
46
46
 
47
47
  scope = with_tags_scope wiki: wiki, project: project
48
+ scope = scope.where.not id: exclude_page.id if exclude_page
48
49
  scope = scope.limit max_entries if max_entries
49
50
 
50
51
  tags = Array tag
51
52
  tags.map!(&:strip)
52
- tags.reject!(&:blank?)
53
+ tags.compact_blank!
53
54
  return [] if tags.count.zero?
54
55
 
55
56
  tags.map!(&:downcase)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module AdditionalTags
4
4
  module PluginVersion
5
- VERSION = '1.0.4' unless defined? VERSION
5
+ VERSION = '1.0.6' unless defined? VERSION
6
6
  end
7
7
  end
@@ -25,7 +25,7 @@ module AdditionalTags
25
25
 
26
26
  columns << "MIN(#{TAGGING_TABLE_NAME}.created_at) AS last_created" if options[:sort_by] == 'last_created'
27
27
 
28
- scope.select(columns.join(', '))
28
+ scope.select(columns.to_list)
29
29
  .joins(tag_for_joins(klass, **options.slice(:project_join, :project, :without_projects)))
30
30
  .group("#{TAG_TABLE_NAME}.id, #{TAG_TABLE_NAME}.name, #{TAG_TABLE_NAME}.taggings_count").having('COUNT(*) > 0')
31
31
  .order(build_order_sql(options[:sort_by], options[:order]))
@@ -35,7 +35,7 @@ module AdditionalTags
35
35
  ActsAsTaggableOn::Tag.all
36
36
  .joins(tag_for_joins(klass, without_projects: without_projects))
37
37
  .distinct
38
- .order("#{TAG_TABLE_NAME}.name")
38
+ .order(:name)
39
39
  end
40
40
 
41
41
  def tag_to_joins(klass)
@@ -49,7 +49,7 @@ module AdditionalTags
49
49
  end
50
50
 
51
51
  def remove_unused_tags
52
- ActsAsTaggableOn::Tag.where.not(id: ActsAsTaggableOn::Tagging.select(:tag_id).distinct)
52
+ ActsAsTaggableOn::Tag.where.missing(:taggings)
53
53
  .each(&:destroy)
54
54
  end
55
55
 
@@ -46,14 +46,11 @@ module AdditionalTags
46
46
  loader.add_patch({ target: Redmine::Helpers::TimeReport,
47
47
  patch: 'TimeReport' })
48
48
 
49
- # because of this bug: https://www.redmine.org/issues/33290
50
- if RedminePluginKit::Loader.redmine_database_ready? TAG_TABLE_NAME
51
- loader.add_patch %w[IssueQuery TimeEntryQuery]
52
-
53
- if Redmine::Plugin.installed? 'redmine_agile'
54
- loader.add_patch %w[AgileQuery AgileBoardsController]
55
- loader.add_patch %w[AgileVersionsController AgileVersionsQuery] if AGILE_VERSION_TYPE == 'PRO version'
56
- end
49
+ loader.add_patch %w[IssueQuery TimeEntryQuery]
50
+
51
+ if Redmine::Plugin.installed? 'redmine_agile'
52
+ loader.add_patch %w[AgileQuery AgileBoardsController]
53
+ loader.add_patch %w[AgileVersionsController AgileVersionsQuery] if AGILE_VERSION_TYPE == 'PRO version'
57
54
  end
58
55
 
59
56
  # Apply patches and helper
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: additional_tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - AlphaNodes
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-18 00:00:00.000000000 Z
11
+ date: 2022-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: acts-as-taggable-on
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '7.0'
19
+ version: '9.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '7.0'
26
+ version: '9.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: redmine_plugin_kit
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -100,6 +100,7 @@ files:
100
100
  - app/views/additional_tags/_tag_list.html.slim
101
101
  - app/views/additional_tags/context_menu.html.slim
102
102
  - app/views/additional_tags/edit.html.slim
103
+ - app/views/additional_tags/index.api.rsb
103
104
  - app/views/additional_tags/merge.html.slim
104
105
  - app/views/additional_tags/settings/_general.html.slim
105
106
  - app/views/additional_tags/settings/_manage_tags.html.slim
@@ -187,14 +188,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
187
188
  requirements:
188
189
  - - ">="
189
190
  - !ruby/object:Gem::Version
190
- version: '2.6'
191
+ version: '2.7'
191
192
  required_rubygems_version: !ruby/object:Gem::Requirement
192
193
  requirements:
193
194
  - - ">="
194
195
  - !ruby/object:Gem::Version
195
196
  version: '0'
196
197
  requirements: []
197
- rubygems_version: 3.1.6
198
+ rubygems_version: 3.3.7
198
199
  signing_key:
199
200
  specification_version: 4
200
201
  summary: Redmine plugin for adding tag functionality