redmine_crm 0.0.32 → 0.0.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bitbucket-pipelines.yml +1 -1
- data/config/currency_iso.json +12 -0
- data/doc/CHANGELOG +10 -0
- data/lib/redmine_crm.rb +3 -1
- data/lib/redmine_crm/acts_as_list/list.rb +282 -0
- data/lib/redmine_crm/acts_as_taggable/rcrm_acts_as_taggable.rb +5 -4
- data/lib/redmine_crm/acts_as_viewed/rcrm_acts_as_viewed.rb +2 -1
- data/lib/redmine_crm/acts_as_votable/votable.rb +1 -1
- data/lib/redmine_crm/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5242b016d5072c81150cb2008b3fc7633a96216f
|
4
|
+
data.tar.gz: b3f77eb78ff97c6c06ef28e57b8d17af8d7f8e34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef26d5b1ee5e367ef7240ca961cdeb3bbaaf75b0af6c2c68f779b988302998cd2ee2b69c7a21ac48b22ea18f6ffb141cfa42afb033ca1dc7c0389cd97b395aa4
|
7
|
+
data.tar.gz: f0779bd48b8225c24411e243b4dcb7a8b17b359e51dc57dd894c57f9388e3dcdc3316edd9ee67fb48b223828246025dc083b2034e157cb02d550c4d2c338dde1
|
data/bitbucket-pipelines.yml
CHANGED
data/config/currency_iso.json
CHANGED
@@ -2528,5 +2528,17 @@
|
|
2528
2528
|
"thousands_separator": ",",
|
2529
2529
|
"iso_numeric": "967",
|
2530
2530
|
"smallest_denomination": 5
|
2531
|
+
},
|
2532
|
+
"btc": {
|
2533
|
+
"priority": 100,
|
2534
|
+
"iso_code": "BTC",
|
2535
|
+
"name": "Bitcoin",
|
2536
|
+
"symbol": "฿",
|
2537
|
+
"subunit": "sat",
|
2538
|
+
"subunit_to_unit": 100000000,
|
2539
|
+
"symbol_first": false,
|
2540
|
+
"html_entity": "฿",
|
2541
|
+
"decimal_mark": ",",
|
2542
|
+
"thousands_separator": "."
|
2531
2543
|
}
|
2532
2544
|
}
|
data/doc/CHANGELOG
CHANGED
@@ -4,6 +4,16 @@ Redmine crm gem - general functions for plugins (tags, vote, viewing, currency)
|
|
4
4
|
Copyright (C) 2011-2017 RedmineUP
|
5
5
|
https://www.redmineup.com/
|
6
6
|
|
7
|
+
== 2017-12-18 v0.0.33
|
8
|
+
|
9
|
+
* Rails 5 support (Redmine 4)
|
10
|
+
* rcrm_acts_as_list (Redmine 4)
|
11
|
+
* Bitcoin currency support
|
12
|
+
|
13
|
+
== 2017-07-18 v0.0.32
|
14
|
+
|
15
|
+
* charjs added
|
16
|
+
|
7
17
|
== 2017-05-29 v0.0.31
|
8
18
|
|
9
19
|
* select2 controls for contacts and people
|
data/lib/redmine_crm.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'redmine_crm/version'
|
2
2
|
|
3
|
+
require 'redmine_crm/acts_as_list/list'
|
3
4
|
require 'redmine_crm/acts_as_taggable/tag'
|
4
5
|
require 'redmine_crm/acts_as_taggable/tag_list'
|
5
6
|
require 'redmine_crm/acts_as_taggable/tagging'
|
@@ -26,8 +27,9 @@ require 'redmine_crm/helpers/external_assets_helper'
|
|
26
27
|
require 'redmine_crm/assets_manager'
|
27
28
|
|
28
29
|
if defined?(ActiveRecord::Base)
|
29
|
-
ActiveRecord::Base.
|
30
|
+
ActiveRecord::Base.include(RedmineCrm::ActsAsList::List)
|
30
31
|
ActiveRecord::Base.extend(RedmineCrm::ActsAsVotable::Voter)
|
32
|
+
ActiveRecord::Base.extend(RedmineCrm::ActsAsVotable::Votable)
|
31
33
|
end
|
32
34
|
|
33
35
|
RedmineCrm::AssetsManager.install_assets
|
@@ -0,0 +1,282 @@
|
|
1
|
+
module RedmineCrm
|
2
|
+
module ActsAsList
|
3
|
+
module List
|
4
|
+
def self.included(base)
|
5
|
+
base.extend(ClassMethods)
|
6
|
+
end
|
7
|
+
|
8
|
+
# This +acts_as+ extension provides the capabilities for sorting and reordering a number of objects in a list.
|
9
|
+
# The class that has this specified needs to have a +position+ column defined as an integer on
|
10
|
+
# the mapped database table.
|
11
|
+
#
|
12
|
+
# Todo list example:
|
13
|
+
#
|
14
|
+
# class TodoList < ActiveRecord::Base
|
15
|
+
# has_many :todo_items, :order => "position"
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# class TodoItem < ActiveRecord::Base
|
19
|
+
# belongs_to :todo_list
|
20
|
+
# acts_as_list :scope => :todo_list
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# todo_list.first.move_to_bottom
|
24
|
+
# todo_list.last.move_higher
|
25
|
+
module ClassMethods
|
26
|
+
# Configuration options are:
|
27
|
+
#
|
28
|
+
# * +column+ - specifies the column name to use for keeping the position integer (default: +position+)
|
29
|
+
# * +scope+ - restricts what is to be considered a list. Given a symbol, it'll attach <tt>_id</tt>
|
30
|
+
# (if it hasn't already been added) and use that as the foreign key restriction. It's also possible
|
31
|
+
# to give it an entire string that is interpolated if you need a tighter scope than just a foreign key.
|
32
|
+
# Example: <tt>acts_as_list :scope => 'todo_list_id = #{todo_list_id} AND completed = 0'</tt>
|
33
|
+
def rcrm_acts_as_list(options = {})
|
34
|
+
|
35
|
+
configuration = { :column => "position", :scope => "1 = 1" }
|
36
|
+
configuration.update(options) if options.is_a?(Hash)
|
37
|
+
|
38
|
+
configuration[:scope] = "#{configuration[:scope]}_id".intern if configuration[:scope].is_a?(Symbol) && configuration[:scope].to_s !~ /_id$/
|
39
|
+
|
40
|
+
if configuration[:scope].is_a?(Symbol)
|
41
|
+
scope_condition_method = %(
|
42
|
+
def scope_condition
|
43
|
+
if #{configuration[:scope].to_s}.nil?
|
44
|
+
"#{configuration[:scope].to_s} IS NULL"
|
45
|
+
else
|
46
|
+
"#{configuration[:scope].to_s} = \#{#{configuration[:scope].to_s}}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
)
|
50
|
+
else
|
51
|
+
scope_condition_method = "def scope_condition() \"#{configuration[:scope]}\" end"
|
52
|
+
end
|
53
|
+
|
54
|
+
class_eval <<-EOV
|
55
|
+
include RedmineCrm::ActsAsList::List::InstanceMethods
|
56
|
+
|
57
|
+
def rcrm_acts_as_list_class
|
58
|
+
::#{self.name}
|
59
|
+
end
|
60
|
+
|
61
|
+
def position_column
|
62
|
+
'#{configuration[:column]}'
|
63
|
+
end
|
64
|
+
|
65
|
+
#{scope_condition_method}
|
66
|
+
|
67
|
+
before_destroy :remove_from_list
|
68
|
+
before_create :add_to_list_bottom
|
69
|
+
EOV
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# All the methods available to a record that has had <tt>acts_as_list</tt> specified. Each method works
|
74
|
+
# by assuming the object to be the item in the list, so <tt>chapter.move_lower</tt> would move that chapter
|
75
|
+
# lower in the list of all chapters. Likewise, <tt>chapter.first?</tt> would return +true+ if that chapter is
|
76
|
+
# the first in the list of all chapters.
|
77
|
+
module InstanceMethods
|
78
|
+
# Insert the item at the given position (defaults to the top position of 1).
|
79
|
+
def insert_at(position = 1)
|
80
|
+
insert_at_position(position)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Swap positions with the next lower item, if one exists.
|
84
|
+
def move_lower
|
85
|
+
return unless lower_item
|
86
|
+
|
87
|
+
rcrm_acts_as_list_class.transaction do
|
88
|
+
lower_item.decrement_position
|
89
|
+
increment_position
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# Swap positions with the next higher item, if one exists.
|
94
|
+
def move_higher
|
95
|
+
return unless higher_item
|
96
|
+
|
97
|
+
rcrm_acts_as_list_class.transaction do
|
98
|
+
higher_item.increment_position
|
99
|
+
decrement_position
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# Move to the bottom of the list. If the item is already in the list, the items below it have their
|
104
|
+
# position adjusted accordingly.
|
105
|
+
def move_to_bottom
|
106
|
+
return unless in_list?
|
107
|
+
rcrm_acts_as_list_class.transaction do
|
108
|
+
decrement_positions_on_lower_items
|
109
|
+
assume_bottom_position
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# Move to the top of the list. If the item is already in the list, the items above it have their
|
114
|
+
# position adjusted accordingly.
|
115
|
+
def move_to_top
|
116
|
+
return unless in_list?
|
117
|
+
rcrm_acts_as_list_class.transaction do
|
118
|
+
increment_positions_on_higher_items
|
119
|
+
assume_top_position
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
# Move to the given position
|
124
|
+
def move_to=(pos)
|
125
|
+
case pos.to_s
|
126
|
+
when 'highest'
|
127
|
+
move_to_top
|
128
|
+
when 'higher'
|
129
|
+
move_higher
|
130
|
+
when 'lower'
|
131
|
+
move_lower
|
132
|
+
when 'lowest'
|
133
|
+
move_to_bottom
|
134
|
+
end
|
135
|
+
reset_positions_in_list
|
136
|
+
end
|
137
|
+
|
138
|
+
def reset_positions_in_list
|
139
|
+
rcrm_acts_as_list_class.where(scope_condition).reorder("#{position_column} ASC, id ASC").each_with_index do |item, i|
|
140
|
+
unless item.send(position_column) == (i + 1)
|
141
|
+
rcrm_acts_as_list_class.where({:id => item.id}).
|
142
|
+
update_all({position_column => (i + 1)})
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# Removes the item from the list.
|
148
|
+
def remove_from_list
|
149
|
+
if in_list?
|
150
|
+
decrement_positions_on_lower_items
|
151
|
+
update_attribute position_column, nil
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# Increase the position of this item without adjusting the rest of the list.
|
156
|
+
def increment_position
|
157
|
+
return unless in_list?
|
158
|
+
update_attribute position_column, self.send(position_column).to_i + 1
|
159
|
+
end
|
160
|
+
|
161
|
+
# Decrease the position of this item without adjusting the rest of the list.
|
162
|
+
def decrement_position
|
163
|
+
return unless in_list?
|
164
|
+
update_attribute position_column, self.send(position_column).to_i - 1
|
165
|
+
end
|
166
|
+
|
167
|
+
# Return +true+ if this object is the first in the list.
|
168
|
+
def first?
|
169
|
+
return false unless in_list?
|
170
|
+
self.send(position_column) == 1
|
171
|
+
end
|
172
|
+
|
173
|
+
# Return +true+ if this object is the last in the list.
|
174
|
+
def last?
|
175
|
+
return false unless in_list?
|
176
|
+
self.send(position_column) == bottom_position_in_list
|
177
|
+
end
|
178
|
+
|
179
|
+
# Return the next higher item in the list.
|
180
|
+
def higher_item
|
181
|
+
return nil unless in_list?
|
182
|
+
rcrm_acts_as_list_class.where(
|
183
|
+
"#{scope_condition} AND #{position_column} = #{(send(position_column).to_i - 1).to_s}"
|
184
|
+
).first
|
185
|
+
end
|
186
|
+
|
187
|
+
# Return the next lower item in the list.
|
188
|
+
def lower_item
|
189
|
+
return nil unless in_list?
|
190
|
+
rcrm_acts_as_list_class.where(
|
191
|
+
"#{scope_condition} AND #{position_column} = #{(send(position_column).to_i + 1).to_s}"
|
192
|
+
).first
|
193
|
+
end
|
194
|
+
|
195
|
+
# Test if this record is in a list
|
196
|
+
def in_list?
|
197
|
+
!send(position_column).nil?
|
198
|
+
end
|
199
|
+
|
200
|
+
private
|
201
|
+
|
202
|
+
def add_to_list_top
|
203
|
+
increment_positions_on_all_items
|
204
|
+
end
|
205
|
+
|
206
|
+
def add_to_list_bottom
|
207
|
+
self[position_column] = bottom_position_in_list.to_i + 1
|
208
|
+
end
|
209
|
+
|
210
|
+
# Overwrite this method to define the scope of the list changes
|
211
|
+
def scope_condition() "1" end
|
212
|
+
|
213
|
+
# Returns the bottom position number in the list.
|
214
|
+
# bottom_position_in_list # => 2
|
215
|
+
def bottom_position_in_list(except = nil)
|
216
|
+
item = bottom_item(except)
|
217
|
+
item ? item.send(position_column) : 0
|
218
|
+
end
|
219
|
+
|
220
|
+
# Returns the bottom item
|
221
|
+
def bottom_item(except = nil)
|
222
|
+
conditions = scope_condition
|
223
|
+
conditions = "#{conditions} AND #{self.class.primary_key} != #{except.id}" if except
|
224
|
+
rcrm_acts_as_list_class.where(conditions).reorder("#{position_column} DESC").first
|
225
|
+
end
|
226
|
+
|
227
|
+
# Forces item to assume the bottom position in the list.
|
228
|
+
def assume_bottom_position
|
229
|
+
update_attribute(position_column, bottom_position_in_list(self).to_i + 1)
|
230
|
+
end
|
231
|
+
|
232
|
+
# Forces item to assume the top position in the list.
|
233
|
+
def assume_top_position
|
234
|
+
update_attribute(position_column, 1)
|
235
|
+
end
|
236
|
+
|
237
|
+
# This has the effect of moving all the higher items up one.
|
238
|
+
def decrement_positions_on_higher_items(position)
|
239
|
+
rcrm_acts_as_list_class.
|
240
|
+
where("#{scope_condition} AND #{position_column} <= #{position}").
|
241
|
+
update_all("#{position_column} = (#{position_column} - 1)")
|
242
|
+
end
|
243
|
+
|
244
|
+
# This has the effect of moving all the lower items up one.
|
245
|
+
def decrement_positions_on_lower_items
|
246
|
+
return unless in_list?
|
247
|
+
rcrm_acts_as_list_class.
|
248
|
+
where("#{scope_condition} AND #{position_column} > #{send(position_column).to_i}").
|
249
|
+
update_all("#{position_column} = (#{position_column} - 1)")
|
250
|
+
end
|
251
|
+
|
252
|
+
# This has the effect of moving all the higher items down one.
|
253
|
+
def increment_positions_on_higher_items
|
254
|
+
return unless in_list?
|
255
|
+
rcrm_acts_as_list_class.
|
256
|
+
where("#{scope_condition} AND #{position_column} < #{send(position_column).to_i}").
|
257
|
+
update_all("#{position_column} = (#{position_column} + 1)")
|
258
|
+
end
|
259
|
+
|
260
|
+
# This has the effect of moving all the lower items down one.
|
261
|
+
def increment_positions_on_lower_items(position)
|
262
|
+
rcrm_acts_as_list_class.
|
263
|
+
where("#{scope_condition} AND #{position_column} >= #{position}").
|
264
|
+
update_all("#{position_column} = (#{position_column} + 1)")
|
265
|
+
end
|
266
|
+
|
267
|
+
# Increments position (<tt>position_column</tt>) of all items in the list.
|
268
|
+
def increment_positions_on_all_items
|
269
|
+
rcrm_acts_as_list_class.
|
270
|
+
where("#{scope_condition}").
|
271
|
+
update_all("#{position_column} = (#{position_column} + 1)")
|
272
|
+
end
|
273
|
+
|
274
|
+
def insert_at_position(position)
|
275
|
+
remove_from_list
|
276
|
+
increment_positions_on_lower_items(position)
|
277
|
+
self.update_attribute(position_column, position)
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
@@ -24,7 +24,8 @@ module RedmineCrm
|
|
24
24
|
include RedmineCrm::ActsAsTaggable::Taggable::InstanceMethods
|
25
25
|
extend RedmineCrm::ActsAsTaggable::Taggable::SingletonMethods
|
26
26
|
|
27
|
-
|
27
|
+
alias_method :reload_without_tag_list, :reload
|
28
|
+
alias_method :reload, :reload_with_tag_list
|
28
29
|
|
29
30
|
class_eval do
|
30
31
|
def self.taggable?
|
@@ -230,8 +231,8 @@ module RedmineCrm
|
|
230
231
|
# scope(:find)
|
231
232
|
|
232
233
|
conditions = []
|
233
|
-
conditions << send(:
|
234
|
-
conditions << send(:
|
234
|
+
conditions << send(:sanitize_sql, options.delete(:conditions)) if options[:conditions]
|
235
|
+
conditions << send(:sanitize_sql, scope) if scope
|
235
236
|
conditions << "#{Tagging.table_name}.taggable_type = #{quote_string_value(base_class.name)}"
|
236
237
|
conditions << type_condition unless descends_from_active_record?
|
237
238
|
conditions.compact!
|
@@ -253,7 +254,7 @@ module RedmineCrm
|
|
253
254
|
|
254
255
|
private
|
255
256
|
def quote_string_value(object)
|
256
|
-
|
257
|
+
connection.quote(object)
|
257
258
|
end
|
258
259
|
|
259
260
|
def tags_condition(tags, table_name = Tag.table_name)
|
@@ -144,7 +144,8 @@ module RedmineCrm
|
|
144
144
|
target = self
|
145
145
|
target.views = ((target.views || 0) + 1) unless options[:only_total]
|
146
146
|
target.total_views = ((target.total_views || 0) + 1)
|
147
|
-
target.
|
147
|
+
target.record_timestamps = false
|
148
|
+
target.save(:validate => false, :touch => false)
|
148
149
|
# target.save_without_validation
|
149
150
|
end
|
150
151
|
end
|
@@ -235,7 +235,7 @@ module RedmineCrm
|
|
235
235
|
updates[scope_cache_field :cached_weighted_average, vote_scope] = weighted_average(true, vote_scope)
|
236
236
|
end
|
237
237
|
end
|
238
|
-
|
238
|
+
self.record_timestamps = false
|
239
239
|
if (::ActiveRecord::VERSION::MAJOR == 3) && (::ActiveRecord::VERSION::MINOR != 0)
|
240
240
|
self.update_attributes(updates, :without_protection => true) if !updates.empty?
|
241
241
|
else
|
data/lib/redmine_crm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redmine_crm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RedmineUP
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- doc/CHANGELOG
|
42
42
|
- doc/LICENSE.txt
|
43
43
|
- lib/redmine_crm.rb
|
44
|
+
- lib/redmine_crm/acts_as_list/list.rb
|
44
45
|
- lib/redmine_crm/acts_as_taggable/rcrm_acts_as_taggable.rb
|
45
46
|
- lib/redmine_crm/acts_as_taggable/tag.rb
|
46
47
|
- lib/redmine_crm/acts_as_taggable/tag_list.rb
|