redmineup 1.1.4 → 1.1.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +74 -153
- data/app/assets/stylesheets/redmineup.css +476 -0
- data/app/views/redmineup/_additional_assets.html.erb +1 -0
- data/config/locales/en.yml +1 -0
- data/config/locales/ru.yml +1 -0
- data/config/routes.rb +2 -0
- data/doc/CHANGELOG +46 -26
- data/doc/active-record-mixins.md +156 -0
- data/doc/assets-money-and-utilities.md +71 -0
- data/doc/tagging-and-select2.md +108 -0
- data/lib/redmineup/acts_as_taggable/tag.rb +12 -2
- data/lib/redmineup/acts_as_taggable/up_acts_as_taggable.rb +8 -6
- data/lib/redmineup/engine.rb +12 -2
- data/lib/redmineup/helpers/datetime_helper.rb +23 -0
- data/lib/redmineup/helpers/external_assets_helper.rb +11 -5
- data/lib/redmineup/helpers/form_tag_helper.rb +42 -0
- data/lib/redmineup/helpers/tags_helper.rb +39 -3
- data/lib/redmineup/hooks/views_layouts_hook.rb +1 -5
- data/lib/redmineup/patches/auto_completes_controller_patch.rb +19 -0
- data/lib/redmineup/version.rb +1 -1
- data/lib/redmineup.rb +1 -0
- data/test/acts_as_taggable/tag_test.rb +12 -9
- data/test/tags_helper_view_test.rb +41 -0
- data/test/test_helper.rb +2 -1
- metadata +11 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ffc6eee33542600145eba2fd7789b0b4166fc992752e1ae73123d2b92a290588
|
|
4
|
+
data.tar.gz: 2f1bb7682cea36f0bab2481fe3e13f67e54736bd0751442d4e90652144a73589
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 398413f2a14e103ab19db992c186d142fe7acfb31a9c90a26b56880cfa084662250dd807d362a533ede13fd2f0df00813eeefb05c9f1869a37e74158da2d4eb3
|
|
7
|
+
data.tar.gz: b344e60e5a6dc5f551da6cd17fa2a055445a3a1dbac62647a8677a07e1c06c092fe10fcce12c8e944ffb6b3b2136bac9c25a5c6416c1289af84de514d5e05afb
|
data/.gitignore
CHANGED
data/README.md
CHANGED
|
@@ -1,204 +1,125 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
# redmineup
|
|
2
|
+
|
|
3
|
+
`redmineup` is a shared gem used by RedmineUP plugins. It provides common
|
|
4
|
+
ActiveRecord mixins, view helpers, assets, settings, and compatibility patches
|
|
5
|
+
so plugin code stays focused on domain logic.
|
|
6
|
+
|
|
7
|
+
The gem is used in production plugins such as `redmine_contacts`,
|
|
8
|
+
`redmine_people`, `redmine_products`, `redmine_questions`, `redmine_drive`,
|
|
9
|
+
`redmineup_tags`, `redmine_agile`, and others.
|
|
10
|
+
|
|
11
|
+
## What is included
|
|
12
|
+
|
|
13
|
+
- ActiveRecord mixins: `up_acts_as_taggable`, `up_acts_as_draftable`,
|
|
14
|
+
`up_acts_as_viewed`, `up_acts_as_votable`, `up_acts_as_voter`,
|
|
15
|
+
`up_acts_as_priceable`
|
|
16
|
+
- Tag helpers and tag UI helpers: `tag_link`, `tag_links`, `tag_cloud_links`,
|
|
17
|
+
`tag_list_field_tag`, `FormBuilder#tag_list_field`
|
|
18
|
+
- Select2 and chart integration helpers: `select2_tag`, `transform_to_select2`,
|
|
19
|
+
`redmineup_assets`, `chartjs_assets`
|
|
20
|
+
- Shared endpoint for tag autocompletion:
|
|
21
|
+
`auto_complete_taggable_tags_path`
|
|
22
|
+
- Money and currency formatting (`Redmineup::MoneyHelper`,
|
|
23
|
+
`Redmineup::Currency`, `Redmineup::Settings::Money`)
|
|
24
|
+
- Liquid filters and drops used across RedmineUP plugins
|
|
14
25
|
|
|
15
26
|
## Installation
|
|
16
27
|
|
|
17
|
-
Add
|
|
28
|
+
Add to your Redmine or plugin `Gemfile`:
|
|
29
|
+
|
|
18
30
|
```ruby
|
|
19
31
|
gem 'redmineup'
|
|
20
32
|
```
|
|
21
33
|
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
$ bundle install
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
And now you can start using it.
|
|
28
|
-
|
|
34
|
+
Install dependencies:
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
This module allows saving and restoring drafts for different models. To be
|
|
33
|
-
saved as a draft, an instance does not need to pass the validations. Drafts
|
|
34
|
-
store not only model attributes, but also associations and virtual attributes.
|
|
35
|
-
A draft could be linked to a given user, so every user can manage his/her own
|
|
36
|
-
drafts independent of others. A draft might have a parent instance.
|
|
37
|
-
|
|
38
|
-
First of all, drafts need to be saved somewhere, so let's create a migration:
|
|
39
|
-
```ruby
|
|
40
|
-
class CreateDrafts < Rails.version > '5' ? ActiveRecord::Migration[5.0] : ActiveRecord::Migration
|
|
41
|
-
def change
|
|
42
|
-
ActiveRecord::Base.create_drafts_table
|
|
43
|
-
end
|
|
44
|
-
end
|
|
36
|
+
```bash
|
|
37
|
+
bundle install
|
|
45
38
|
```
|
|
46
39
|
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
$ rake redmine:plugins:migrate
|
|
50
|
-
```
|
|
40
|
+
In plugin `init.rb`, guard the minimum supported version:
|
|
51
41
|
|
|
52
|
-
Next, add `up_acts_as_draftable` to a model for which you want to save drafts:
|
|
53
42
|
```ruby
|
|
54
|
-
|
|
55
|
-
up_acts_as_draftable
|
|
56
|
-
end
|
|
43
|
+
requires_redmineup version_or_higher: '1.1.5'
|
|
57
44
|
```
|
|
58
45
|
|
|
59
|
-
|
|
60
|
-
```ruby
|
|
61
|
-
# You can save message as a draft.
|
|
62
|
-
Message.new(subject: 'foo').save_draft
|
|
63
|
-
|
|
64
|
-
# And later restore message from the draft.
|
|
65
|
-
draft = Message.drafts(nil).last
|
|
66
|
-
message = draft.restore
|
|
67
|
-
puts message.subject
|
|
68
|
-
# => foo
|
|
69
|
-
|
|
70
|
-
# Draft can be overwritten.
|
|
71
|
-
message.content = 'bar'
|
|
72
|
-
puts message.save_draft
|
|
73
|
-
# => true
|
|
74
|
-
|
|
75
|
-
# You can also save draft linked to a particular user.
|
|
76
|
-
Message.new(subject: 'baz').save_draft(user: current_user)
|
|
77
|
-
|
|
78
|
-
# And restore message from some user's draft.
|
|
79
|
-
user_draft = Message.drafts(current_user).last
|
|
80
|
-
user_message = user_draft.restore
|
|
81
|
-
puts user_message.subject
|
|
82
|
-
# => baz
|
|
83
|
-
|
|
84
|
-
# It's also possible to restore a bunch of messages at once.
|
|
85
|
-
messages = Message.drafts(current_user).restore_all
|
|
86
|
-
p messages.map(&:subject)
|
|
87
|
-
# => ["baz"]
|
|
88
|
-
|
|
89
|
-
# When a model instance is saved, corresponding draft is removed.
|
|
90
|
-
puts Message.drafts(current_user).count
|
|
91
|
-
# => 1
|
|
92
|
-
user_message.board_id = Board.first.id
|
|
93
|
-
user_message.save!
|
|
94
|
-
puts Message.drafts(current_user).count
|
|
95
|
-
# => 0
|
|
96
|
-
|
|
97
|
-
# Drafts will be saved only for new (not persisted) or changed instances.
|
|
98
|
-
puts Message.new.save_draft
|
|
99
|
-
# => true
|
|
100
|
-
persisted = Message.last
|
|
101
|
-
puts persisted.save_draft
|
|
102
|
-
# => false
|
|
103
|
-
persisted.subject = 'other subject'
|
|
104
|
-
puts persisted.save_draft
|
|
105
|
-
# => true
|
|
106
|
-
```
|
|
46
|
+
## Quick start
|
|
107
47
|
|
|
108
|
-
###
|
|
109
|
-
This module makes it possible to tag objects.
|
|
48
|
+
### 1) Add taggable behavior to a model
|
|
110
49
|
|
|
111
|
-
First, create a migration:
|
|
112
50
|
```ruby
|
|
113
|
-
|
|
51
|
+
# db/migrate/XXXXXXXXXXXX_create_tags.rb
|
|
52
|
+
class CreateTags < ActiveRecord::Migration[6.1]
|
|
114
53
|
def change
|
|
115
54
|
ActiveRecord::Base.create_taggable_table
|
|
116
55
|
end
|
|
117
56
|
end
|
|
118
57
|
```
|
|
119
58
|
|
|
120
|
-
Then in the Redmine directory run:
|
|
121
|
-
```
|
|
122
|
-
$ rake redmine:plugins:migrate
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
Next, add `up_acts_as_taggable` to a model for which you want to provide tags:
|
|
126
59
|
```ruby
|
|
127
|
-
class Contact <
|
|
60
|
+
class Contact < ApplicationRecord
|
|
128
61
|
up_acts_as_taggable
|
|
129
62
|
end
|
|
130
63
|
```
|
|
131
64
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
### Viewings
|
|
135
|
-
This module allows you to count views for some ActiveRecord model instances.
|
|
65
|
+
### 2) Render tags using shared helpers
|
|
136
66
|
|
|
137
|
-
To count views you'll need to create a migration:
|
|
138
67
|
```ruby
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
68
|
+
# helper
|
|
69
|
+
def contact_tag_url(tag_name, options = {})
|
|
70
|
+
{
|
|
71
|
+
controller: 'contacts',
|
|
72
|
+
action: 'index',
|
|
73
|
+
set_filter: 1,
|
|
74
|
+
fields: [:tags],
|
|
75
|
+
values: { tags: [tag_name] },
|
|
76
|
+
operators: { tags: '=' }
|
|
77
|
+
}.merge(options)
|
|
143
78
|
end
|
|
144
79
|
```
|
|
145
80
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
$ rake redmine:plugins:migrate
|
|
81
|
+
```erb
|
|
82
|
+
<%= tag_cloud_links(Contact.available_tags(project: @project), :contact) %>
|
|
149
83
|
```
|
|
150
84
|
|
|
151
|
-
|
|
152
|
-
```ruby
|
|
153
|
-
class Question < ActiveRecord::Base
|
|
154
|
-
up_acts_as_viewed
|
|
155
|
-
end
|
|
156
|
-
```
|
|
85
|
+
`tag_cloud_links(tags, :contact)` resolves links via `contact_tag_url(name)`.
|
|
157
86
|
|
|
158
|
-
|
|
87
|
+
### 3) Add Select2 tag editor to forms
|
|
159
88
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
As always, create a migration first:
|
|
164
|
-
```ruby
|
|
165
|
-
class CreateVotes < Rails.version > '5' ? ActiveRecord::Migration[5.0] : ActiveRecord::Migration
|
|
166
|
-
def change
|
|
167
|
-
ActiveRecord::Base.create_votable_table
|
|
168
|
-
end
|
|
169
|
-
end
|
|
89
|
+
```erb
|
|
90
|
+
<%= f.tag_list_field :tag_list, width: '95%' %>
|
|
170
91
|
```
|
|
171
92
|
|
|
172
|
-
|
|
173
|
-
```
|
|
174
|
-
$ rake redmine:plugins:migrate
|
|
175
|
-
```
|
|
93
|
+
or standalone:
|
|
176
94
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
class Question < ActiveRecord::Base
|
|
180
|
-
up_acts_as_votable
|
|
181
|
-
end
|
|
95
|
+
```erb
|
|
96
|
+
<%= tag_list_field_tag 'contact[tag_list]', @contact.tag_list, taggable_type: 'Contact' %>
|
|
182
97
|
```
|
|
183
98
|
|
|
184
|
-
|
|
99
|
+
## Documentation
|
|
185
100
|
|
|
101
|
+
- [ActiveRecord mixins](doc/active-record-mixins.md)
|
|
102
|
+
- [Tagging and Select2 helpers](doc/tagging-and-select2.md)
|
|
103
|
+
- [Assets, money, and shared utilities](doc/assets-money-and-utilities.md)
|
|
186
104
|
|
|
187
105
|
## Development
|
|
188
106
|
|
|
189
|
-
|
|
190
|
-
dependencies. To do this, execute the following command in the project's
|
|
191
|
-
directory:
|
|
192
|
-
```
|
|
193
|
-
$ bundle install
|
|
194
|
-
```
|
|
107
|
+
Install dependencies:
|
|
195
108
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
$ bundle exec rake test
|
|
109
|
+
```bash
|
|
110
|
+
bundle install
|
|
199
111
|
```
|
|
200
112
|
|
|
201
|
-
|
|
113
|
+
Run tests:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
bundle exec rake test
|
|
202
117
|
```
|
|
203
|
-
|
|
118
|
+
|
|
119
|
+
Run tests against another DB adapter:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
bundle exec rake test DB=postgresql
|
|
204
123
|
```
|
|
124
|
+
|
|
125
|
+
Available `DB` values: `sqlite`, `mysql`, `postgresql`.
|