redmineup 1.1.1 → 1.1.18

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 (115) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.gitlab-ci.yml +7 -18
  4. data/README.md +74 -153
  5. data/Rakefile +1 -1
  6. data/app/assets/images/icons.svg +9 -0
  7. data/app/assets/javascripts/consumer.js +37 -50
  8. data/app/assets/javascripts/consumer_worker.js +219 -0
  9. data/app/assets/javascripts/jquery.colorPicker.min.js +26 -0
  10. data/app/assets/javascripts/select2_helpers.js +12 -0
  11. data/app/assets/stylesheets/calendars.css +0 -3
  12. data/app/assets/stylesheets/redmineup.css +520 -0
  13. data/app/assets/stylesheets/select2.css +2 -2
  14. data/app/views/redmineup/_additional_assets.html.erb +1 -0
  15. data/app/views/redmineup/journals/_history.html.erb +33 -0
  16. data/config/locales/ar.yml +13 -0
  17. data/config/locales/az.yml +13 -0
  18. data/config/locales/bg.yml +13 -0
  19. data/config/locales/bs.yml +13 -0
  20. data/config/locales/ca.yml +13 -0
  21. data/config/locales/cs.yml +1 -0
  22. data/config/locales/da.yml +13 -0
  23. data/config/locales/de.yml +1 -0
  24. data/config/locales/el.yml +13 -0
  25. data/config/locales/en-GB.yml +14 -0
  26. data/config/locales/en.yml +1 -0
  27. data/config/locales/es-PA.yml +14 -0
  28. data/config/locales/es.yml +1 -0
  29. data/config/locales/et.yml +13 -0
  30. data/config/locales/eu.yml +13 -0
  31. data/config/locales/fa.yml +13 -0
  32. data/config/locales/fi.yml +13 -0
  33. data/config/locales/fr.yml +13 -0
  34. data/config/locales/gl.yml +13 -0
  35. data/config/locales/he.yml +13 -0
  36. data/config/locales/hr.yml +13 -0
  37. data/config/locales/hu.yml +13 -0
  38. data/config/locales/id.yml +13 -0
  39. data/config/locales/it.yml +13 -0
  40. data/config/locales/ja.yml +13 -0
  41. data/config/locales/ko.yml +13 -0
  42. data/config/locales/lt.yml +13 -0
  43. data/config/locales/lv.yml +13 -0
  44. data/config/locales/mk.yml +13 -0
  45. data/config/locales/mn.yml +13 -0
  46. data/config/locales/nl.yml +13 -0
  47. data/config/locales/no.yml +13 -0
  48. data/config/locales/pl.yml +13 -0
  49. data/config/locales/pt-BR.yml +13 -0
  50. data/config/locales/pt.yml +13 -0
  51. data/config/locales/ro.yml +13 -0
  52. data/config/locales/ru.yml +2 -1
  53. data/config/locales/sk.yml +13 -0
  54. data/config/locales/sl.yml +13 -0
  55. data/config/locales/sq.yml +13 -0
  56. data/config/locales/sr-YU.yml +13 -0
  57. data/config/locales/sr.yml +13 -0
  58. data/config/locales/sv.yml +13 -0
  59. data/config/locales/ta-IN.yml +13 -0
  60. data/config/locales/th.yml +13 -0
  61. data/config/locales/tr.yml +13 -0
  62. data/config/locales/uk.yml +13 -0
  63. data/config/locales/vi.yml +13 -0
  64. data/config/locales/zh-TW.yml +13 -0
  65. data/config/locales/zh.yml +13 -0
  66. data/config/routes.rb +4 -0
  67. data/doc/CHANGELOG +119 -24
  68. data/doc/active-record-mixins.md +156 -0
  69. data/doc/assets-money-and-utilities.md +71 -0
  70. data/doc/tagging-and-select2.md +115 -0
  71. data/lib/action_cable/connection/rup_connection.rb +17 -0
  72. data/lib/action_cable/server/rup_configuration.rb +1 -9
  73. data/lib/action_cable/server/rup_server.rb +8 -0
  74. data/lib/redmineup/acts_as_journalized/hook.rb +16 -0
  75. data/lib/redmineup/acts_as_journalized/journal_event.rb +30 -0
  76. data/lib/redmineup/acts_as_journalized/journal_patch.rb +87 -0
  77. data/lib/redmineup/acts_as_journalized/up_acts_as_journalized.rb +118 -0
  78. data/lib/redmineup/acts_as_taggable/tag.rb +13 -3
  79. data/lib/redmineup/acts_as_taggable/up_acts_as_taggable.rb +36 -28
  80. data/lib/redmineup/acts_as_viewed/up_acts_as_viewed.rb +8 -3
  81. data/lib/redmineup/currency/formatting.rb +1 -0
  82. data/lib/redmineup/engine.rb +14 -2
  83. data/lib/redmineup/helpers/datetime_helper.rb +23 -0
  84. data/lib/redmineup/helpers/external_assets_helper.rb +14 -6
  85. data/lib/redmineup/helpers/form_tag_helper.rb +44 -0
  86. data/lib/redmineup/helpers/journals_helper.rb +53 -0
  87. data/lib/redmineup/helpers/tags_helper.rb +108 -0
  88. data/lib/redmineup/helpers/test_helper.rb +12 -0
  89. data/lib/redmineup/hooks/views_layouts_hook.rb +1 -5
  90. data/lib/redmineup/money_helper.rb +10 -2
  91. data/lib/redmineup/patches/action_cable_base_patch.rb +13 -8
  92. data/lib/redmineup/patches/action_cable_patch.rb +3 -7
  93. data/lib/redmineup/patches/auto_completes_controller_patch.rb +17 -0
  94. data/lib/redmineup/patches/compatibility/routing_mapper_patch.rb +5 -18
  95. data/lib/redmineup/patches/compatibility/sprite_patch.rb +3 -9
  96. data/lib/redmineup/patches/compatibility_patch.rb +0 -6
  97. data/lib/redmineup/patches/liquid_patch.rb +13 -22
  98. data/lib/redmineup/version.rb +1 -1
  99. data/lib/redmineup.rb +38 -41
  100. data/redmineup.gemspec +1 -1
  101. data/test/acts_as_journalized/up_acts_as_journalized_test.rb +106 -0
  102. data/test/acts_as_taggable/tag_test.rb +12 -9
  103. data/test/acts_as_viewed/rup_acts_as_viewed_test.rb +12 -0
  104. data/test/currency_test.rb +7 -0
  105. data/test/locales_test.rb +12 -0
  106. data/test/models/journal.rb +38 -0
  107. data/test/models/journalized_thing.rb +5 -0
  108. data/test/redmine/acts_as_journalized/journalized_redmine_test.rb +264 -0
  109. data/test/schema.rb +18 -1
  110. data/test/tags_helper_view_test.rb +111 -0
  111. data/test/test_helper.rb +13 -12
  112. metadata +74 -5
  113. data/app/assets/stylesheets/money.css +0 -95
  114. data/lib/redmineup/patches/compatibility/application_controller_patch.rb +0 -32
  115. data/lib/redmineup/patches/compatibility/user_patch.rb +0 -21
@@ -0,0 +1,13 @@
1
+ zh-TW:
2
+ label_redmineup_settings: 貨幣設定
3
+ label_redmineup_money: 貨幣
4
+ label_redmineup_disable_taxes: 停用稅金
5
+ label_redmineup_default_tax: 預設稅額
6
+ label_redmineup_tax_type: 稅金類型
7
+ label_redmineup_tax_type_exclusive: 未含稅
8
+ label_redmineup_tax_type_inclusive: 含稅
9
+ label_redmineup_default_currency: 預設貨幣
10
+ label_redmineup_major_currencies: 主要貨幣
11
+ label_redmineup_thousands_delimiter: 千位分隔符
12
+ label_redmineup_decimal_separator: 小數分隔符
13
+ lable_redmineup_add_tag: 新增標籤
@@ -0,0 +1,13 @@
1
+ zh:
2
+ label_redmineup_settings: 货币设置
3
+ label_redmineup_money: 货币
4
+ label_redmineup_disable_taxes: 禁用税费
5
+ label_redmineup_default_tax: 默认税额
6
+ label_redmineup_tax_type: 税费类型
7
+ label_redmineup_tax_type_exclusive: 不含税
8
+ label_redmineup_tax_type_inclusive: 含税
9
+ label_redmineup_default_currency: 默认货币
10
+ label_redmineup_major_currencies: 主要货币
11
+ label_redmineup_thousands_delimiter: 千位分隔符
12
+ label_redmineup_decimal_separator: 小数分隔符
13
+ lable_redmineup_add_tag: 添加标签
data/config/routes.rb CHANGED
@@ -2,4 +2,8 @@
2
2
 
3
3
  Rails.application.routes.draw do
4
4
  match 'redmineup/settings/:id', to: 'redmineup#settings', as: 'redmineup_settings', via: [:get, :post]
5
+ match 'auto_completes/taggable_tags' => 'auto_completes#taggable_tags',
6
+ via: :get, as: 'auto_complete_taggable_tags'
7
+
8
+ mount ActionCable.rup_server => '/rup_cable', as: 'rup_cable' if Redmineup.cable_available?
5
9
  end
data/doc/CHANGELOG CHANGED
@@ -1,58 +1,153 @@
1
1
  == RedmineUP gem changelog
2
2
 
3
3
  Redmine UP gem - general functions for plugins (tags, vote, viewing, currency)
4
- Copyright (C) 2011-2025 Kirill Bezrukov (RedmineUP)
4
+ Copyright (C) 2011-2026 Kirill Bezrukov (RedmineUP)
5
5
  https://www.redmineup.com/
6
6
 
7
- == 2025-10-24 v1.1.1
7
+ == 2026-10-28 v1.1.18
8
8
 
9
- * Fixed activation for sprite_icon patch
9
+ * Added up_acts_as_journalized: change history for any model
10
+ * Added open_only option to Issue available_tags
11
+ * Updated tags: no commas between chips
12
+ * Fixed tags text color and wrapping in tables
13
+
14
+ == 2026-10-24 v1.1.17
15
+
16
+ * Fixed gem breaking Redmine 5.0-6.0 on start (Norwegian locale)
17
+
18
+ == 2026-10-24 v1.1.16
19
+
20
+ * Added shared styles for tag chips: colored, gray, link
21
+ * Added tag_label, tag_label_link(s), tag_sidebar_cloud helpers
22
+ * Added tag and tag-merge icons
23
+ * Added translations for all languages supported by Redmine
24
+ * Fixed websocket reconnection every minute behind nginx
25
+ * Fixed error on deleting a person when the viewed model loads later
26
+ * Fixed trailing ".0" in amounts of currencies without a fractional unit
27
+
28
+ == 2026-10-11 v1.1.15
29
+
30
+ * Speeded up the tags list query (available_tags) on pages with a lot of tagged records
31
+
32
+ == 2026-10-09 v1.1.14
33
+
34
+ * Fixed missing calendar icons and extra padding in Redmine 6/7
35
+ * Fixed tag field width in forms
36
+
37
+ == 2026-08-25 v1.1.13
38
+
39
+ * Updated patches from include to prepend
40
+
41
+ == 2026-07-23 v1.1.12
42
+
43
+ * Fixed race condition and added exponential backoff to shared worker websocket reconnect logic
44
+ * Added `Redmineup::TestHelper#load_plugin_fixtures` for loading plugin test fixtures
45
+
46
+ == 2026-06-26 v1.1.11
47
+
48
+ * Added shared workers for websocket connection
49
+
50
+ == 2026-06-04 v1.1.10
51
+
52
+ * Added colorpicker JS component to shared gem assets, loaded globally via `redmineup_assets`
53
+ * Fixed viewings table ip column limit to 45 characters for IPv6 address support
54
+
55
+ == 2026-05-30 v1.1.9
56
+
57
+ * Added `prices_formatted_collection` to `MoneyHelper` — returns plain text price strings from currency hash, used by query totals
58
+
59
+ == 2026-05-01 v1.1.8
60
+
61
+ * Added `on_select` callback and `select_icon` options for `select2tag` helper
62
+ * Updated `requires_redmineup` version guard to reduce boilerplate in plugin init
63
+ * Fixed `link_to` display compatibility issue in Redmine 5
64
+
65
+ == 2026-04-18 v1.1.7
66
+
67
+ * hot fix for atom/rss compatibility for redmine < 5
68
+
69
+ == 2026-04-17 v1.1.6
70
+
71
+ * Added helpers for timezone conversions
72
+
73
+ == 2026-04-17 v1.1.5
74
+
75
+ * Added tag cloud links helper with URL convention by key
76
+ * Added shared tag list fields for views and FormBuilder
77
+ * Added shared tag autocomplete route for taggable models
78
+ * Updated layout hook to load shared gem assets globally
79
+ * Updated tag helpers registration in ActionView context
80
+ * Fixed tag color fallback for backward compatibility
81
+ * Fixed helper behavior for Ruby 2.3 compatibility
82
+
83
+ == 2026-04-10 v1.1.4
84
+
85
+ * Fixed tag queries for MSSQL adapter
86
+
87
+ == 2026-03-10 v1.1.3
88
+
89
+ * Added send method for ActionCable
90
+ * Fixed ActionCable compatibility with cable.yaml apply
91
+
92
+ == 2025-11-07 v1.1.2
93
+
94
+ * Fixed shared assets loading error
95
+
96
+ == 2025-10-01 v1.1.1
97
+
98
+ * Updated sprite_icon patch activation logic
10
99
 
11
100
  == 2025-07-24 v1.1.0
12
101
 
13
- * Added ActionCable methods
14
- * Fixed Tags migration method
15
- * Fixed svg icons for context menu
102
+ * Added ActionCable methods for plugin integrations
103
+ * Added SVG icon support for context menu actions
104
+ * Fixed tag migration method for old Rails versions
16
105
 
17
106
  == 2025-07-09 v1.0.13
18
107
 
19
- * Added color to Tag
108
+ * Added tag color support in tag model behavior
109
+
110
+ == 2025-07-08 v1.0.12
20
111
 
21
- == 2025-02-04 v1.0.11
112
+ * Added tag color selection functionality
22
113
 
23
- * Fixed bug with Redmine language settings
114
+ == 2025-03-30 v1.0.11
115
+
116
+ * Fixed ApplicationRecord loading compatibility
117
+
118
+ == 2025-02-04 v1.0.10
119
+
120
+ * Fixed SVG icon compatibility for older Redmine code
24
121
 
25
122
  == 2025-02-04 v1.0.9
26
123
 
27
124
  * Added regex_replace Liquid filter
28
- * Added svg icons for Redmine 6
125
+ * Added SVG icons for Redmine 6
126
+ * Fixed Liquid internal error in filter execution
127
+ * Fixed parse_inline_attachments Liquid filter behavior
29
128
 
30
129
  == 2025-01-31 v1.0.8
31
130
 
32
- * Fixed compatibility patch for Redmine < 5
131
+ * Fixed compatibility patch for Redmine versions below 5
33
132
 
34
133
  == 2025-01-29 v1.0.7
35
134
 
36
- * Fixed parse_inline_attachments Liquid filter
37
- * Added compatibility patch for Redmine 6 sprite_icon
135
+ * Added sprite_icon compatibility patch for Redmine 6
136
+ * Fixed parse_inline_attachments Liquid filter behavior
38
137
 
39
138
  == 2024-05-07 v1.0.6
40
139
 
41
- * Updated Chart.js to v3.9.1
42
- * Fixed assets paths for Redmine 5.3+
43
140
  * Added attachments to IssueDrop and JournalDrop
44
- * Added filter parse_inline_attachments for replace image urls
141
+ * Added parse_inline_attachments filter for image URL fix
142
+ * Updated Chart.js library to version 3.9.1
143
+ * Fixed asset paths for Redmine 5.3 and newer
45
144
 
46
145
  == 2024-01-31 v1.0.5
47
146
 
48
- * Added plugin_installed? method
49
- * Compatibility patches for ApplicationRecord
147
+ * Added plugin_installed? helper for plugin checks
148
+ * Fixed ApplicationRecord compatibility patch behavior
50
149
 
51
150
  == 2023-10-12 v1.0.1
52
151
 
53
- * RedmineUp module renamed to Redmineup
54
-
55
- == 2023-09-27 v1.0.0
56
-
57
- * Initial release
58
- * Mirgated from redmineup gem
152
+ * Added initial public release
153
+ * Updated module name from RedmineUp to Redmineup
@@ -0,0 +1,156 @@
1
+ # ActiveRecord mixins
2
+
3
+ This page documents the model mixins provided by `redmineup`.
4
+
5
+ ## `up_acts_as_taggable`
6
+
7
+ Adds polymorphic tagging support.
8
+
9
+ ### Migration
10
+
11
+ ```ruby
12
+ class CreateTags < ActiveRecord::Migration[6.1]
13
+ def change
14
+ ActiveRecord::Base.create_taggable_table
15
+ end
16
+ end
17
+ ```
18
+
19
+ Useful migration helpers:
20
+
21
+ - `ActiveRecord::Base.create_taggable_table`
22
+ - `ActiveRecord::Base.drop_taggable_table`
23
+ - `ActiveRecord::Base.add_tags_column(:tags, name: :color, type: :integer, default: nil)`
24
+ - `ActiveRecord::Base.remove_tags_columns(:tags, :color)`
25
+
26
+ ### Model
27
+
28
+ ```ruby
29
+ class Product < ApplicationRecord
30
+ up_acts_as_taggable
31
+ end
32
+ ```
33
+
34
+ ### Runtime API
35
+
36
+ - `record.tag_list` / `record.tag_list = 'a, b'`
37
+ - `record.save_tags` (called via callbacks)
38
+ - `Model.available_tags(project: @project, limit: 30)`
39
+ - `Model.tagged_with(['tag1', 'tag2'])`
40
+ - `Model.find_related_tags('tag1')`
41
+
42
+ ## `up_acts_as_draftable`
43
+
44
+ Adds draft save/restore workflow for unsaved or changed records.
45
+
46
+ ### Migration
47
+
48
+ ```ruby
49
+ class CreateDrafts < ActiveRecord::Migration[6.1]
50
+ def change
51
+ ActiveRecord::Base.create_drafts_table
52
+ end
53
+ end
54
+ ```
55
+
56
+ Helpers:
57
+
58
+ - `ActiveRecord::Base.create_drafts_table`
59
+ - `ActiveRecord::Base.drop_drafts_table`
60
+
61
+ ### Model
62
+
63
+ ```ruby
64
+ class WikiPage < ApplicationRecord
65
+ up_acts_as_draftable parent: :wiki
66
+ end
67
+ ```
68
+
69
+ ### Runtime API
70
+
71
+ - `record.save_draft`
72
+ - `record.update_draft(attrs)`
73
+ - `Model.drafts(User.current)`
74
+ - `Model.from_draft(draft_or_id)`
75
+
76
+ ## `up_acts_as_viewed`
77
+
78
+ Tracks unique views by user (or IP) and total views.
79
+
80
+ ### Migration
81
+
82
+ ```ruby
83
+ class CreateViewings < ActiveRecord::Migration[6.1]
84
+ def change
85
+ ActiveRecord::Base.create_viewings_table
86
+ end
87
+ end
88
+ ```
89
+
90
+ Optional helpers for models with embedded counters:
91
+
92
+ - `ActiveRecord::Base.generate_viewings_columns(table)`
93
+ - `Model.add_viewings_columns`
94
+ - `Model.remove_viewings_columns`
95
+ - `ActiveRecord::Base.drop_viewings_table`
96
+
97
+ ### Model
98
+
99
+ ```ruby
100
+ class Question < ApplicationRecord
101
+ up_acts_as_viewed
102
+ end
103
+ ```
104
+
105
+ ### Runtime API
106
+
107
+ - `record.view(request.remote_ip, User.current)`
108
+ - `record.viewed?`
109
+ - `record.view_count`
110
+ - `record.viewed_by?(request.remote_ip, User.current)`
111
+
112
+ ## `up_acts_as_votable` and `up_acts_as_voter`
113
+
114
+ Adds voting capabilities for content and users.
115
+
116
+ ### Migration
117
+
118
+ ```ruby
119
+ class CreateVotes < ActiveRecord::Migration[6.1]
120
+ def change
121
+ ActiveRecord::Base.create_votable_table
122
+ end
123
+ end
124
+ ```
125
+
126
+ Helpers:
127
+
128
+ - `ActiveRecord::Base.create_votable_table`
129
+ - `ActiveRecord::Base.drop_votable_table`
130
+
131
+ ### Models
132
+
133
+ ```ruby
134
+ class Question < ApplicationRecord
135
+ up_acts_as_votable
136
+ end
137
+
138
+ class User < ApplicationRecord
139
+ up_acts_as_voter
140
+ end
141
+ ```
142
+
143
+ ## `up_acts_as_priceable`
144
+
145
+ Generates currency-aware `*_to_s` methods for price fields.
146
+
147
+ ### Model
148
+
149
+ ```ruby
150
+ class Deal < ApplicationRecord
151
+ up_acts_as_priceable :amount, :tax_amount, :subtotal, :total
152
+ end
153
+ ```
154
+
155
+ This creates methods like `amount_to_s`, `tax_amount_to_s`, etc., backed by
156
+ `Redmineup::MoneyHelper#object_price`.
@@ -0,0 +1,71 @@
1
+ # Assets, money, and shared utilities
2
+
3
+ ## Asset helpers
4
+
5
+ Provided by `Redmineup::ExternalAssetsHelper`:
6
+
7
+ - `redmineup_assets`
8
+ - `select2_assets` (alias for `redmineup_assets`)
9
+ - `chartjs_assets`
10
+
11
+ `redmineup_assets` includes:
12
+
13
+ - `consumer.js`
14
+ - `select2.js`
15
+ - `select2_helpers.js`
16
+ - `redmineup.css`
17
+
18
+ The gem also hooks `view_layouts_base_html_head` and renders
19
+ `redmineup/_additional_assets`, so shared assets can be included globally.
20
+ Helpers are idempotent and safe to call from plugin views.
21
+
22
+ ## Money and currency
23
+
24
+ ### Settings API
25
+
26
+ `Redmineup::Settings::Money` provides access to plugin-level money settings:
27
+
28
+ - `default_currency`
29
+ - `major_currencies`
30
+ - `default_tax`
31
+ - `tax_type`, `tax_exclusive?`
32
+ - `thousands_delimiter`
33
+ - `decimal_separator`
34
+ - `disable_taxes?`
35
+
36
+ ### Formatting helpers
37
+
38
+ `Redmineup::MoneyHelper` provides:
39
+
40
+ - `price_to_currency(price, currency, options = {})`
41
+ - `object_price(record, :price)`
42
+ - `prices_collection_by_currency(hash, hide_zeros: true)`
43
+ - `collection_for_currencies_select`
44
+ - `all_currencies`
45
+
46
+ `up_acts_as_priceable` uses these helpers to generate `*_to_s` methods on
47
+ models.
48
+
49
+ ### Admin UI
50
+
51
+ `Redmineup::Currency.add_admin_money_menu` registers a Redmine admin menu item
52
+ that points to:
53
+
54
+ - `redmineup_settings_path(:money)`
55
+
56
+ ## Misc shared helpers and patches
57
+
58
+ - `Redmineup::CalendarsHelper#calendar_day_css_classes`
59
+ - Liquid patch for numeric conversion in `Liquid::StandardFilters`
60
+ - Liquid filters/drops under `lib/redmineup/liquid/**`
61
+ - Compatibility and ActionCable patches loaded at gem boot
62
+
63
+ ## Version requirements in plugins
64
+
65
+ Plugins typically guard compatibility in `init.rb`:
66
+
67
+ ```ruby
68
+ requires_redmineup version_or_higher: '1.1.5'
69
+ ```
70
+
71
+ Use this to fail fast when a plugin depends on newer helper or API behavior.
@@ -0,0 +1,115 @@
1
+ # Tagging and Select2 helpers
2
+
3
+ This page covers view helpers used by RedmineUP plugins for tag rendering,
4
+ tag editing, and select2-backed filters.
5
+
6
+ ## Tag rendering helpers
7
+
8
+ Provided by `Redmineup::TagsHelper`:
9
+
10
+ - `tag_link(url, tag_name, options = {})`
11
+ - `tag_links(tag_list, options = {}) { |tag| url }`
12
+ - `tag_cloud(tags, classes) { |tag, css_class| ... }`
13
+ - `tag_cloud_links(tags, key, options = {})`
14
+
15
+ Since 1.1.16 (the display mode, sidebar style, counts and order come from the Tags plugin when it is installed; without it tags are colored chips in a cloud):
16
+
17
+ - `tag_display_mode` returns `color`, `plain` or `link`
18
+ - `tag_label(inner, color)` wraps markup in a chip (`span.tag-label.tag-label-color` / `.tag-label-plain`) or `span.tag-link`
19
+ - `tag_label_link(url, tag_name, options = {})`, `tag_label_links(tag_list, options = {}) { |tag| url }`, `tag_label_separator`
20
+ - `tag_sidebar_cloud(tags, key)` renders the sidebar tags (list, cloud or simple cloud) and resolves links through `{key}_tag_url`
21
+ - `tag_separator`
22
+
23
+ ### Recommended pattern
24
+
25
+ Define `*_tag_url` per plugin context:
26
+
27
+ ```ruby
28
+ def contact_tag_url(tag_name, options = {})
29
+ {
30
+ controller: 'contacts',
31
+ action: 'index',
32
+ set_filter: 1,
33
+ fields: [:tags],
34
+ values: { tags: [tag_name] },
35
+ operators: { tags: '=' }
36
+ }.merge(options)
37
+ end
38
+ ```
39
+
40
+ Then render the cloud via convention:
41
+
42
+ ```erb
43
+ <%= tag_cloud_links(Contact.available_tags(project: @project), :contact) %>
44
+ ```
45
+
46
+ `tag_cloud_links(tags, :contact)` expects `contact_tag_url(name)` to be defined
47
+ in the current view context.
48
+
49
+ ## Tag editors with Select2
50
+
51
+ Provided by `Redmineup::FormTagHelper`:
52
+
53
+ - `select2_tag(name, option_tags = nil, options = {})`
54
+ - `select2(...)` (alias)
55
+ - `tag_list_field_tag(name, value = [], options = {})`
56
+ - `transform_to_select2(type, options = {})`
57
+
58
+ `ActionView::Helpers::FormBuilder` is extended with:
59
+
60
+ - `f.tag_list_field(:tag_list, **options)`
61
+
62
+ ### Example: form object API
63
+
64
+ ```erb
65
+ <%= f.tag_list_field :tag_list, width: '95%' %>
66
+ ```
67
+
68
+ ### Example: standalone field API
69
+
70
+ ```erb
71
+ <%= tag_list_field_tag 'product[tag_list]', @product.tag_list, taggable_type: 'Product' %>
72
+ ```
73
+
74
+ ### Example: query/filter select2 transform
75
+
76
+ ```erb
77
+ <%= transform_to_select2 'product_tags',
78
+ url: auto_complete_taggable_tags_path(project_id: @project, taggable_type: 'Product') %>
79
+ ```
80
+
81
+ ## Tag autocomplete endpoint
82
+
83
+ `redmineup` adds a shared route:
84
+
85
+ - `GET /auto_completes/taggable_tags`
86
+
87
+ Named route:
88
+
89
+ - `auto_complete_taggable_tags_path`
90
+
91
+ Typical params used by plugins:
92
+
93
+ - `taggable_type`: model class name (`Contact`, `Person`, `Product`, `Issue`, `DriveEntry`)
94
+ - `project_id`: optional project scope
95
+ - `limit`: optional result size limit
96
+
97
+ Response format:
98
+
99
+ ```json
100
+ [
101
+ { "id": "important", "text": "important" },
102
+ { "id": "vip", "text": "vip" }
103
+ ]
104
+ ```
105
+
106
+ ## Real plugin usage
107
+
108
+ Patterns above are used by:
109
+
110
+ - `redmine_contacts` (`contact_tag_url`, `contact_tag_links`, `f.tag_list_field`)
111
+ - `redmine_people` (`people_tag_url`, `tag_cloud_links`, bulk edit tag forms)
112
+ - `redmine_products` (`product_tag_url`, `tag_list_field_tag`, select2 filters)
113
+ - `redmine_questions` (`question_tag_url`, `tag_cloud_links`)
114
+ - `redmine_drive` (`drive_entry_tag_url`, select2 tag filters)
115
+ - `redmineup_tags` (issue tag forms with `tag_list_field_tag`)
@@ -0,0 +1,17 @@
1
+ module ActionCable
2
+ module Connection
3
+ class RupConnection < ActionCable::Connection::Base
4
+ identified_by :current_user
5
+
6
+ def connect
7
+ self.current_user = find_verified_user
8
+ end
9
+
10
+ private
11
+
12
+ def find_verified_user
13
+ User.find_by(id: @request.session[:user_id]) || User.anonymous
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,8 +1,6 @@
1
-
2
1
  module ActionCable
3
2
  module Server
4
3
  class RupConfiguration < ActionCable::Server::Configuration
5
-
6
4
  def initialize(connection_klass: 'ActionCable::Connection::Base')
7
5
  super()
8
6
 
@@ -12,13 +10,7 @@ module ActionCable
12
10
  end
13
11
 
14
12
  def cable
15
- @cable ||= { 'adapter' => detect_adapter_type }.with_indifferent_access
16
- end
17
-
18
- private
19
-
20
- def detect_adapter_type
21
- ActionCable.server.config.cable ? (ActionCable.server.config.cable.fetch('adapter') { 'async' }) : 'async'
13
+ @cable ||= ActionCable.server.config.cable || { 'adapter' => 'async' }.with_indifferent_access
22
14
  end
23
15
  end
24
16
  end
@@ -1,6 +1,8 @@
1
1
  module ActionCable
2
2
  module Server
3
3
  class RupServer < ActionCable::Server::Base
4
+ BEAT_INTERVAL = 10
5
+
4
6
  attr_reader :config
5
7
 
6
8
  def initialize(config: self.class.config)
@@ -8,6 +10,12 @@ module ActionCable
8
10
  @mutex = Monitor.new
9
11
  @remote_connections = @event_loop = @worker_pool = @pubsub = nil
10
12
  end
13
+
14
+ def setup_heartbeat_timer
15
+ @heartbeat_timer ||= event_loop.timer(BEAT_INTERVAL) do
16
+ event_loop.post { connections.each(&:beat) }
17
+ end
18
+ end
11
19
  end
12
20
  end
13
21
  end
@@ -0,0 +1,16 @@
1
+ module Redmineup
2
+ module ActsAsJournalized
3
+ class Hook < Redmine::Hook::Listener
4
+ def after_plugins_loaded(_context)
5
+ return unless Gem::Version.new(Redmine::VERSION.to_s) >= Gem::Version.new('5.0')
6
+
7
+ require File.expand_path('journal_patch', __dir__)
8
+ require File.expand_path('journal_event', __dir__)
9
+ ::Journal.prepend(JournalPatch) unless ::Journal.include?(JournalPatch)
10
+ Redmineup::ActsAsJournalized.journalized_classes.each do |klass|
11
+ Redmineup::ActsAsJournalized.register_activity(klass) if klass.up_journalized_options[:activity]
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,30 @@
1
+ module Redmineup
2
+ class JournalEvent < ::Journal
3
+ def self.visible(user = User.current, options = {})
4
+ visible_for(user, options)
5
+ end
6
+
7
+ def event_title
8
+ title = up_activity_options[:title]
9
+ title ? title.call(self) : journalized.to_s
10
+ end
11
+
12
+ def event_url(options = {})
13
+ up_activity_options[:url].call(self).merge(options)
14
+ end
15
+
16
+ def event_type
17
+ up_activity_options[:css_type] || "#{journalized_type.underscore.dasherize}-edit"
18
+ end
19
+
20
+ def event_group
21
+ journalized
22
+ end
23
+
24
+ private
25
+
26
+ def up_activity_options
27
+ journalized.up_journalized_options[:activity]
28
+ end
29
+ end
30
+ end