additional_tags 1.0.4 → 1.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d10d32f78d464486a2921a86274972ec068f3aad16c988f9037e89a433ac4efa
4
- data.tar.gz: 50833ac552b8b3de0cba5eb5d9710cdbafdf17b3c2d53e742031ed22a52c9e86
3
+ metadata.gz: 74f23c86bdd928603d2740edb89fbecf6061fa559bbd1a030b3221929c81ec70
4
+ data.tar.gz: fb2c25b2a00e1ee5530cf677fcd3474280075c0c60d028209240ec933631f71b
5
5
  SHA512:
6
- metadata.gz: 837feb0dba819a2191dbd5151f523a3f65aac23918faaa2f93277a0b51c33e4483353c43dd7ae69ae98b43886099fe7f3005b33daafe9d05d4b593ce1866e657
7
- data.tar.gz: 2d54a07615b231470a074e42ec5f4d275af5b5838338a360e8d7401fa742deeba0b500a1ca94069a3b37240e23947e9110c6b2f6f785ec3517ae1cfc63a66351
6
+ metadata.gz: 8a86b18dbebc7599d1afcb2b63edbea742e32825de1693254c5f066c7a12067aee4dec0649d5c5768480b13e830102e380784e0025f91b4a1da690f085b1b3fe
7
+ data.tar.gz: 2ccee9443f19a4a5b193cb63dc1a2d0ae6f965a2f2c11c937e3c2066149baa56272329b8ffa087f5f55d1446440da85a3c9e3d5b69b03ea6b5c99c78d72a3885
@@ -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.0
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/.rubocop.yml CHANGED
@@ -1,14 +1,22 @@
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
4
10
 
5
11
  Rails:
6
12
  Enabled: true
7
13
 
8
- AllCops:
9
- TargetRubyVersion: 2.6
10
- TargetRailsVersion: 5.2
11
- NewCops: enable
14
+ Minitest/MultipleAssertions:
15
+ Max: 15
16
+ Enabled: true
17
+
18
+ Minitest/AssertPredicate:
19
+ Enabled: false
12
20
 
13
21
  Metrics/AbcSize:
14
22
  Enabled: false
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
@@ -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,6 +7,29 @@ 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
 
@@ -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,7 +18,7 @@
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
23
  = render partial: defined?(tags_form) ? tags_form : 'tags_form',
24
24
  locals: { css_id: defined?(css_id) ? css_id : nil }
@@ -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
 
@@ -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,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
 
@@ -49,7 +49,7 @@ module AdditionalTags
49
49
 
50
50
  tags = Array tag
51
51
  tags.map!(&:strip)
52
- tags.reject!(&:blank?)
52
+ tags.compact_blank!
53
53
  return [] if tags.count.zero?
54
54
 
55
55
  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.5' 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,8 @@ 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.left_outer_joins(:taggings)
53
+ .where(taggings: { id: nil })
53
54
  .each(&:destroy)
54
55
  end
55
56
 
@@ -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.5
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-06-25 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