redmine_crm 0.0.40 → 0.0.41

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cec54924c890caa40b9affa944a8cf4186e4ca7c
4
- data.tar.gz: 1b0b5395bc2f1e5f2c03ee4504725a6cbb153b57
3
+ metadata.gz: 937d5d243e43f7d09a1d11db2a8fb5b7201484dc
4
+ data.tar.gz: fc0ed270797f455ebaddbc14f6ea74d1d56eb43f
5
5
  SHA512:
6
- metadata.gz: 2cbb08c06c06fa75356b93d25a23483f776b1c96a9f505f1ace7a54ae6123057dc1972145a93dd0632cf3ac8c8260c88513ec9d333f5912d4c39653d5a1c7406
7
- data.tar.gz: 29c51f79b3d048c7d4ad59ff48be8f2757c85230fb1b5aa082fa4d07033d867142f3331d804363c10567d0f7aadfca404f273570f0056eb6ae440d7cb6291e60
6
+ metadata.gz: 77fc48be16fbba575c32f035af43aa4d0ec3e595f29b30364b62c3565dc4c600f5d809b839c62a779a5cb2cfa577f496205ebb2bb3d49bbc4ee06f4b72dd6c45
7
+ data.tar.gz: f45297ba257bd057cb6ad5073998fcd58bf3f99048a364b6d78967846d03c9d04d47af85407209b3df976168c706dc20fa2b8bd8c6146e679dfaf82154a54b62
@@ -19,10 +19,12 @@ require 'redmine_crm/acts_as_draftable/draft'
19
19
  require 'redmine_crm/currency'
20
20
  require 'redmine_crm/helpers/tags_helper'
21
21
  require 'redmine_crm/money_helper'
22
+ require 'redmine_crm/colors_helper'
22
23
 
23
24
  require 'liquid'
24
25
  require 'redmine_crm/liquid/filters/base'
25
26
  require 'redmine_crm/liquid/filters/arrays'
27
+ require 'redmine_crm/liquid/filters/colors'
26
28
  require 'redmine_crm/liquid/drops/issues_drop'
27
29
  require 'redmine_crm/liquid/drops/news_drop'
28
30
  require 'redmine_crm/liquid/drops/projects_drop'
@@ -0,0 +1,192 @@
1
+ module RedmineCrm
2
+ class ColorsHelper
3
+ NAMED_COLORS = {
4
+ 'aliceblue' => 'f0f8ff',
5
+ 'antiquewhite' => 'faebd7',
6
+ 'aqua' => '00ffff',
7
+ 'aquamarine' => '7fffd4',
8
+ 'azure' => 'f0ffff',
9
+ 'beige' => 'f5f5dc',
10
+ 'bisque' => 'ffe4c4',
11
+ 'black' => '000',
12
+ 'blanchedalmond' => 'ffebcd',
13
+ 'blue' => '0000ff',
14
+ 'blueviolet' => '8a2be2',
15
+ 'brown' => 'a52a2a',
16
+ 'burlywood' => 'deb887',
17
+ 'burntsienna' => 'ea7e5d',
18
+ 'cadetblue' => '5f9ea0',
19
+ 'chartreuse' => '7fff00',
20
+ 'chocolate' => 'd2691e',
21
+ 'coral' => 'ff7f50',
22
+ 'cornflowerblue' => '6495ed',
23
+ 'cornsilk' => 'fff8dc',
24
+ 'crimson' => 'dc143c',
25
+ 'cyan' => '00ffff',
26
+ 'darkblue' => '00008b',
27
+ 'darkcyan' => '008b8b',
28
+ 'darkgoldenrod' => 'b8860b',
29
+ 'darkgray' => 'a9a9a9',
30
+ 'darkgreen' => '006400',
31
+ 'darkgrey' => 'a9a9a9',
32
+ 'darkkhaki' => 'bdb76b',
33
+ 'darkmagenta' => '8b008b',
34
+ 'darkolivegreen' => '556b2f',
35
+ 'darkorange' => 'ff8c00',
36
+ 'darkorchid' => '9932cc',
37
+ 'darkred' => '8b0000',
38
+ 'darksalmon' => 'e9967a',
39
+ 'darkseagreen' => '8fbc8f',
40
+ 'darkslateblue' => '483d8b',
41
+ 'darkslategray' => '2f4f4f',
42
+ 'darkslategrey' => '2f4f4f',
43
+ 'darkturquoise' => '00ced1',
44
+ 'darkviolet' => '9400d3',
45
+ 'deeppink' => 'ff1493',
46
+ 'deepskyblue' => '00bfff',
47
+ 'dimgray' => '696969',
48
+ 'dimgrey' => '696969',
49
+ 'dodgerblue' => '1e90ff',
50
+ 'firebrick' => 'b22222',
51
+ 'floralwhite' => 'fffaf0',
52
+ 'forestgreen' => '228b22',
53
+ 'fuchsia' => 'ff00ff',
54
+ 'gainsboro' => 'dcdcdc',
55
+ 'ghostwhite' => 'f8f8ff',
56
+ 'gold' => 'ffd700',
57
+ 'goldenrod' => 'daa520',
58
+ 'gray' => '808080',
59
+ 'green' => '008000',
60
+ 'greenyellow' => 'adff2f',
61
+ 'grey' => '808080',
62
+ 'honeydew' => 'f0fff0',
63
+ 'hotpink' => 'ff69b4',
64
+ 'indianred' => 'cd5c5c',
65
+ 'indigo' => '4b0082',
66
+ 'ivory' => 'fffff0',
67
+ 'khaki' => 'f0e68c',
68
+ 'lavender' => 'e6e6fa',
69
+ 'lavenderblush' => 'fff0f5',
70
+ 'lawngreen' => '7cfc00',
71
+ 'lemonchiffon' => 'fffacd',
72
+ 'lightblue' => 'add8e6',
73
+ 'lightcoral' => 'f08080',
74
+ 'lightcyan' => 'e0ffff',
75
+ 'lightgoldenrodyellow' => 'fafad2',
76
+ 'lightgray' => 'd3d3d3',
77
+ 'lightgreen' => '90ee90',
78
+ 'lightgrey' => 'd3d3d3',
79
+ 'lightpink' => 'ffb6c1',
80
+ 'lightsalmon' => 'ffa07a',
81
+ 'lightseagreen' => '20b2aa',
82
+ 'lightskyblue' => '87cefa',
83
+ 'lightslategray' => '789',
84
+ 'lightslategrey' => '789',
85
+ 'lightsteelblue' => 'b0c4de',
86
+ 'lightyellow' => 'ffffe0',
87
+ 'lime' => '00ff00',
88
+ 'limegreen' => '32cd32',
89
+ 'linen' => 'faf0e6',
90
+ 'magenta' => 'ff00ff',
91
+ 'maroon' => '800000',
92
+ 'mediumaquamarine' => '66cdaa',
93
+ 'mediumblue' => '0000cd',
94
+ 'mediumorchid' => 'ba55d3',
95
+ 'mediumpurple' => '9370db',
96
+ 'mediumseagreen' => '3cb371',
97
+ 'mediumslateblue' => '7b68ee',
98
+ 'mediumspringgreen' => '00fa9a',
99
+ 'mediumturquoise' => '48d1cc',
100
+ 'mediumvioletred' => 'c71585',
101
+ 'midnightblue' => '191970',
102
+ 'mintcream' => 'f5fffa',
103
+ 'mistyrose' => 'ffe4e1',
104
+ 'moccasin' => 'ffe4b5',
105
+ 'navajowhite' => 'ffdead',
106
+ 'navy' => '000080',
107
+ 'oldlace' => 'fdf5e6',
108
+ 'olive' => '808000',
109
+ 'olivedrab' => '6b8e23',
110
+ 'orange' => 'ffa500',
111
+ 'orangered' => 'ff4500',
112
+ 'orchid' => 'da70d6',
113
+ 'palegoldenrod' => 'eee8aa',
114
+ 'palegreen' => '98fb98',
115
+ 'paleturquoise' => 'afeeee',
116
+ 'palevioletred' => 'db7093',
117
+ 'papayawhip' => 'ffefd5',
118
+ 'peachpuff' => 'ffdab9',
119
+ 'peru' => 'cd853f',
120
+ 'pink' => 'ffc0cb',
121
+ 'plum' => 'dda0dd',
122
+ 'powderblue' => 'b0e0e6',
123
+ 'purple' => '800080',
124
+ 'rebeccapurple' => '663399',
125
+ 'red' => 'ff0000',
126
+ 'rosybrown' => 'bc8f8f',
127
+ 'royalblue' => '4169e1',
128
+ 'saddlebrown' => '8b4513',
129
+ 'salmon' => 'fa8072',
130
+ 'sandybrown' => 'f4a460',
131
+ 'seagreen' => '2e8b57',
132
+ 'seashell' => 'fff5ee',
133
+ 'sienna' => 'a0522d',
134
+ 'silver' => 'c0c0c0',
135
+ 'skyblue' => '87ceeb',
136
+ 'slateblue' => '6a5acd',
137
+ 'slategray' => '708090',
138
+ 'slategrey' => '708090',
139
+ 'snow' => 'fffafa',
140
+ 'springgreen' => '00ff7f',
141
+ 'steelblue' => '4682b4',
142
+ 'tan' => 'd2b48c',
143
+ 'teal' => '008080',
144
+ 'thistle' => 'd8bfd8',
145
+ 'tomato' => 'ff6347',
146
+ 'turquoise' => '40e0d0',
147
+ 'violet' => 'ee82ee',
148
+ 'wheat' => 'f5deb3',
149
+ 'white' => 'fff',
150
+ 'whitesmoke' => 'f5f5f5',
151
+ 'yellow' => 'ffff00',
152
+ 'yellowgreen' => '9acd32'
153
+ }
154
+
155
+ class << self
156
+ # Amount should be a decimal between 0 and 1. Lower means darker
157
+
158
+ def darken_color(input_color, amount=0.4)
159
+ hex_color = hex_color(input_color).gsub('#','')
160
+ rgb = hex_color.scan(/../).map {|color| color.hex}
161
+ rgb[0] = (rgb[0].to_i * amount).round
162
+ rgb[1] = (rgb[1].to_i * amount).round
163
+ rgb[2] = (rgb[2].to_i * amount).round
164
+ "#%02x%02x%02x" % rgb
165
+ end
166
+
167
+ # Amount should be a decimal between 0 and 1. Higher lightgreen lighter
168
+ def lighten_color(input_color, amount=0.6)
169
+ hex_color = hex_color(input_color).gsub('#','')
170
+ rgb = hex_color.scan(/../).map {|color| color.hex}
171
+ rgb[0] = [(rgb[0].to_i + 255 * amount).round, 255].min
172
+ rgb[1] = [(rgb[1].to_i + 255 * amount).round, 255].min
173
+ rgb[2] = [(rgb[2].to_i + 255 * amount).round, 255].min
174
+ "#%02x%02x%02x" % rgb
175
+ end
176
+
177
+ def contrasting_text_color(input_color)
178
+ color = hex_color(input_color).gsub('#','')
179
+ convert_to_brightness_value(color) > 382.5 ? darken_color(color) : lighten_color(color)
180
+ end
181
+
182
+ def hex_color(input_color)
183
+ "##{NAMED_COLORS[input_color] || input_color}"
184
+ end
185
+
186
+ def convert_to_brightness_value(input_color)
187
+ (hex_color(input_color).scan(/../).map {|color| color.hex}).sum
188
+ end
189
+
190
+ end
191
+ end
192
+ end
@@ -115,6 +115,26 @@ module RedmineCrm
115
115
  @journals ||= JournalsDrop.new @issue.journals.where("#{Journal.table_name}.notes IS NOT ?", nil)
116
116
  end
117
117
 
118
+ def tags
119
+ @issue.respond_to?(:tag_list) && @issue.tag_list
120
+ end
121
+
122
+ def story_points
123
+ @issue.respond_to?(:story_points) && @issue.story_points
124
+ end
125
+
126
+ def color
127
+ @issue.respond_to?(:color) && @issue.color
128
+ end
129
+
130
+ def day_in_state
131
+ @issue.respond_to?(:day_in_state) && @issue.day_in_state
132
+ end
133
+
134
+ def checklists
135
+ @issue.respond_to?(:checklists) && @issue.checklists.map{|item| {"id_done": item.is_done, "subject": item.subject}}
136
+ end
137
+
118
138
  def custom_field_values
119
139
  @issue.custom_field_values
120
140
  end
@@ -150,7 +170,8 @@ module RedmineCrm
150
170
  :notes,
151
171
  :created_on,
152
172
  :private_notes,
153
- :to => :@journal
173
+ :to => :@journal,
174
+ allow_nil: true
154
175
 
155
176
  def initialize(journal)
156
177
  @journal = journal
@@ -37,7 +37,8 @@ module RedmineCrm
37
37
  :visible?,
38
38
  :updated_on,
39
39
  :created_on,
40
- :to => :@time_entry
40
+ :to => :@time_entry,
41
+ allow_nil: true
41
42
 
42
43
  def initialize(time_entry)
43
44
  @time_entry = time_entry
@@ -35,7 +35,7 @@ module RedmineCrm
35
35
  end
36
36
 
37
37
  class UserDrop < ::Liquid::Drop
38
- delegate :id, :name, :firstname, :lastname, :mail, :active?, :admin?, :logged?, :language, :to => :@user
38
+ delegate :id, :name, :firstname, :lastname, :mail, :active?, :admin?, :logged?, :language, :to => :@user, allow_nil: true
39
39
 
40
40
  def initialize(user)
41
41
  @user = user
@@ -45,10 +45,6 @@ module RedmineCrm
45
45
  ApplicationController.helpers.avatar(@user)
46
46
  end
47
47
 
48
- def name
49
- @user.name
50
- end
51
-
52
48
  def permissions
53
49
  roles = @user.memberships.collect { |m| m.roles }.flatten.uniq
54
50
  roles << (@user.logged? ? Role.non_member : Role.anonymous)
@@ -65,16 +65,26 @@ module RedmineCrm
65
65
  end || []
66
66
  elsif operator == '>'
67
67
  input.select do |object|
68
- item_property(object, property) > value
68
+ item_property_value = item_property(object, property)
69
+ item_property_value && item_property_value > value
69
70
  end || []
70
71
  elsif operator == '<'
71
72
  input.select do |object|
72
- item_property(object, property) < value
73
+ item_property_value = item_property(object, property)
74
+ item_property_value && item_property_value < value
73
75
  end || []
74
76
  elsif operator == 'match'
75
77
  input.select do |object|
76
78
  Array(item_property(object, property)).map(&:to_s).any?{|i| i.match(value.to_s)}
77
79
  end || []
80
+ elsif operator == 'any'
81
+ input.select do |object|
82
+ item_property(object, property).present?
83
+ end || []
84
+ elsif operator == 'none'
85
+ input.select do |object|
86
+ item_property(object, property).blank?
87
+ end || []
78
88
  else
79
89
  []
80
90
  end
@@ -172,7 +172,9 @@ module RedmineCrm
172
172
 
173
173
  def item_property(item, property)
174
174
  if item.respond_to?(:to_liquid)
175
- item.to_liquid[property.to_s]
175
+ property.to_s.split(".").reduce(item.to_liquid) do |subvalue, attribute|
176
+ subvalue[attribute]
177
+ end
176
178
  elsif item.respond_to?(:data)
177
179
  item.data[property.to_s]
178
180
  else
@@ -0,0 +1,31 @@
1
+ require 'liquid'
2
+
3
+ module RedmineCrm
4
+ module Liquid
5
+ module Filters
6
+ module Colors
7
+ def darken_color(input, value=0.4)
8
+ RedmineCrm::ColorsHelper.darken_color(input, value.to_f)
9
+ end
10
+
11
+ def lighten_color(input, value=0.6)
12
+ RedmineCrm::ColorsHelper.lighten_color(input, value.to_f)
13
+ end
14
+
15
+ def contrasting_text_color(input)
16
+ RedmineCrm::ColorsHelper.contrasting_text_color(input)
17
+ end
18
+
19
+ def hex_color(input)
20
+ RedmineCrm::ColorsHelper.hex_color(input)
21
+ end
22
+
23
+ def convert_to_brightness_value(input)
24
+ RedmineCrm::ColorsHelper.convert_to_brightness_value(input)
25
+ end
26
+
27
+ end
28
+ ::Liquid::Template.register_filter(RedmineCrm::Liquid::Filters::Colors)
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module RedmineCrm
2
- VERSION = '0.0.40'
2
+ VERSION = '0.0.41'
3
3
  end
@@ -14,7 +14,7 @@ third_issue:
14
14
  subject: Issue 3 subject
15
15
  description: Third issue
16
16
  user: sam
17
- author: sam
17
+ author: homer
18
18
  project: second_project
19
19
  fourth_issue:
20
20
  subject: Issue 4 subject
@@ -4,3 +4,6 @@ jonathan:
4
4
  sam:
5
5
  name: Sam
6
6
  language: 'RU'
7
+ homer:
8
+ name: Homer
9
+ language: 'CH'
@@ -21,7 +21,7 @@ module RedmineCrm
21
21
  end
22
22
 
23
23
  def test_users_size
24
- assert_equal '2', @liquid_render.render('{{ users.size }}')
24
+ assert_equal '3', @liquid_render.render('{{ users.size }}')
25
25
  end
26
26
 
27
27
  def test_user_name
@@ -18,6 +18,13 @@ module RedmineCrm
18
18
 
19
19
  def test_where_filter
20
20
  assert_match '{"name"=>"two", "value"=>5}', @liquid_render.render("{{ objects_arr | where: 'name', 'two' }}")
21
+ assert_match '{"name"=>"one", "value"=>10}', @liquid_render.render("{{ objects_arr | where: 'value', 6, '>' }}")
22
+ assert_match '{"name"=>"one", "value"=>10}', @liquid_render.render("{{ objects_arr | where: 'name', 'on', 'match' }}")
23
+ assert_match '3', @liquid_render.render("{{ objects_arr | where: 'value', '', 'any' | size }}")
24
+ assert_match '1', @liquid_render.render("{{ objects_arr | where: 'value', '', 'none' | size }}")
25
+ assert_match '2', @liquid_render.render("{{ issues.all | where: 'author.name', 'Jonathan', '==' | size }}")
26
+ assert_match '1', @liquid_render.render("{{ issues.all | where: 'author.language', 'CH', '==' | size }}")
27
+ assert_match '0', @liquid_render.render("{{ issues.all | where: 'author.name', '', 'none' | size }}")
21
28
  end
22
29
 
23
30
  end
@@ -0,0 +1,33 @@
1
+ require File.dirname(__FILE__) + '/../liquid_helper'
2
+ include LiquidHelperMethods
3
+
4
+ module RedmineCrm
5
+ class ColorsFilterTest < ActiveSupport::TestCase
6
+
7
+ def setup
8
+ @liquid_render = LiquidRender.new
9
+ end
10
+
11
+ def test_hex_color
12
+ assert_match '#ff0000', @liquid_render.render("{{ 'red' | hex_color }}")
13
+ end
14
+
15
+ def test_darken_color
16
+ assert_match '#000066', @liquid_render.render("{{ 'blue' | darken_color }}")
17
+ end
18
+
19
+ def test_lighten_color
20
+ assert_match '#9999ff', @liquid_render.render("{{ 'blue' | lighten_color }}")
21
+ end
22
+
23
+ def test_contrasting_text_color
24
+ assert_match '#9999ff', @liquid_render.render("{{ 'blue' | contrasting_text_color }}")
25
+ end
26
+
27
+ def test_convert_to_brightness_value
28
+ assert_match '15', @liquid_render.render("{{ 'blue' | convert_to_brightness_value }}")
29
+ end
30
+
31
+
32
+ end
33
+ end
@@ -6,11 +6,13 @@ class LiquidRender
6
6
  @objects_hash = [
7
7
  {'name' => 'one', "value" => 10},
8
8
  {'name' => 'two', "value" => 5},
9
+ {'name' => 'blank', "value" => nil},
9
10
  {'name' => 'three', "value" => 6}
10
11
  ]
11
12
  @registers = {}
12
13
  @assigns = {}
13
14
  @assigns['objects_arr'] = @objects_hash
15
+ @assigns['issues'] = RedmineCrm::Liquid::IssuesDrop.new(Issue.all)
14
16
  @assigns['now'] = Time.now
15
17
  @assigns['today'] = Date.today.strftime(date_format)
16
18
  drops.each do |key, drop|
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.40
4
+ version: 0.0.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - RedmineUP
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-28 00:00:00.000000000 Z
11
+ date: 2018-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -111,6 +111,7 @@ files:
111
111
  - lib/redmine_crm/acts_as_votable/vote.rb
112
112
  - lib/redmine_crm/acts_as_votable/voter.rb
113
113
  - lib/redmine_crm/assets_manager.rb
114
+ - lib/redmine_crm/colors_helper.rb
114
115
  - lib/redmine_crm/compatibility/application_controller_patch.rb
115
116
  - lib/redmine_crm/currency.rb
116
117
  - lib/redmine_crm/currency/formatting.rb
@@ -127,6 +128,7 @@ files:
127
128
  - lib/redmine_crm/liquid/drops/users_drop.rb
128
129
  - lib/redmine_crm/liquid/filters/arrays.rb
129
130
  - lib/redmine_crm/liquid/filters/base.rb
131
+ - lib/redmine_crm/liquid/filters/colors.rb
130
132
  - lib/redmine_crm/money_helper.rb
131
133
  - lib/redmine_crm/version.rb
132
134
  - redmine_crm.gemspec
@@ -158,6 +160,7 @@ files:
158
160
  - test/liquid/drops/uses_drop_test.rb
159
161
  - test/liquid/filters/arrays_filter_test.rb
160
162
  - test/liquid/filters/base_filter_test.rb
163
+ - test/liquid/filters/colors_filter_test.rb
161
164
  - test/liquid/liquid_helper.rb
162
165
  - test/models/issue.rb
163
166
  - test/models/news.rb
@@ -227,6 +230,7 @@ test_files:
227
230
  - test/liquid/drops/uses_drop_test.rb
228
231
  - test/liquid/filters/arrays_filter_test.rb
229
232
  - test/liquid/filters/base_filter_test.rb
233
+ - test/liquid/filters/colors_filter_test.rb
230
234
  - test/liquid/liquid_helper.rb
231
235
  - test/models/issue.rb
232
236
  - test/models/news.rb