redmineup 1.0.2 → 1.1.13

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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.gitlab-ci.yml +33 -0
  4. data/README.md +74 -153
  5. data/app/assets/images/icons.svg +8 -0
  6. data/app/assets/javascripts/chart.min.js +13 -0
  7. data/app/assets/javascripts/consumer.js +53 -0
  8. data/app/assets/javascripts/consumer_worker.js +219 -0
  9. data/app/assets/javascripts/jquery.colorPicker.min.js +26 -0
  10. data/{vendor → app}/assets/javascripts/select2_helpers.js +11 -1
  11. data/app/assets/stylesheets/calendars.css +15 -0
  12. data/{vendor → app}/assets/stylesheets/money.css +1 -2
  13. data/app/assets/stylesheets/redmineup.css +509 -0
  14. data/{vendor → app}/assets/stylesheets/select2.css +1 -1
  15. data/app/views/redmineup/_additional_assets.html.erb +1 -0
  16. data/config/locales/en.yml +1 -0
  17. data/config/locales/ru.yml +1 -0
  18. data/config/routes.rb +4 -0
  19. data/doc/CHANGELOG +116 -7
  20. data/doc/active-record-mixins.md +156 -0
  21. data/doc/assets-money-and-utilities.md +71 -0
  22. data/doc/tagging-and-select2.md +108 -0
  23. data/lib/action_cable/connection/rup_connection.rb +17 -0
  24. data/lib/action_cable/server/rup_configuration.rb +17 -0
  25. data/lib/action_cable/server/rup_server.rb +17 -0
  26. data/lib/application_record.rb +3 -0
  27. data/lib/redmineup/acts_as_taggable/tag.rb +26 -2
  28. data/lib/redmineup/acts_as_taggable/up_acts_as_taggable.rb +42 -2
  29. data/lib/redmineup/acts_as_viewed/up_acts_as_viewed.rb +1 -1
  30. data/lib/redmineup/acts_as_votable/votable.rb +2 -5
  31. data/lib/redmineup/assets_manager.rb +12 -1
  32. data/lib/redmineup/currency.rb +3 -1
  33. data/lib/redmineup/engine.rb +12 -2
  34. data/lib/redmineup/helpers/calendars_helper.rb +22 -0
  35. data/lib/redmineup/helpers/datetime_helper.rb +23 -0
  36. data/lib/redmineup/helpers/external_assets_helper.rb +15 -7
  37. data/lib/redmineup/helpers/form_tag_helper.rb +43 -0
  38. data/lib/redmineup/helpers/tags_helper.rb +41 -0
  39. data/lib/redmineup/helpers/test_helper.rb +12 -0
  40. data/lib/redmineup/hooks/views_layouts_hook.rb +1 -3
  41. data/lib/redmineup/liquid/drops/attachment_drop.rb +8 -0
  42. data/lib/redmineup/liquid/drops/custom_field_enumeration_drop.rb +11 -0
  43. data/lib/redmineup/liquid/drops/issues_drop.rb +11 -19
  44. data/lib/redmineup/liquid/drops/users_drop.rb +2 -3
  45. data/lib/redmineup/liquid/drops/version_drop.rb +38 -0
  46. data/lib/redmineup/liquid/filters/additional.rb +31 -0
  47. data/lib/redmineup/liquid/filters/base.rb +16 -1
  48. data/lib/redmineup/money_helper.rb +10 -2
  49. data/lib/redmineup/patches/action_cable_base_patch.rb +25 -0
  50. data/lib/redmineup/patches/action_cable_patch.rb +19 -0
  51. data/lib/redmineup/patches/auto_completes_controller_patch.rb +17 -0
  52. data/lib/redmineup/patches/compatibility/routing_mapper_patch.rb +16 -0
  53. data/lib/redmineup/patches/compatibility/sprite_patch.rb +13 -0
  54. data/lib/redmineup/patches/compatibility_patch.rb +4 -0
  55. data/lib/redmineup/patches/liquid_patch.rb +13 -22
  56. data/lib/redmineup/version.rb +1 -1
  57. data/lib/redmineup.rb +66 -40
  58. data/test/acts_as_taggable/rup_acts_as_taggable_test.rb +1 -1
  59. data/test/acts_as_taggable/tag_test.rb +16 -0
  60. data/test/acts_as_votable/votable_test.rb +9 -9
  61. data/test/acts_as_votable/voter_test.rb +4 -4
  62. data/test/database.yml +3 -3
  63. data/test/fixtures/tags.yml +2 -0
  64. data/test/liquid/drops/issues_drop_test.rb +5 -0
  65. data/test/liquid/filters/additional_filter_test.rb +35 -0
  66. data/test/liquid/filters/arrays_filter_test.rb +6 -3
  67. data/test/liquid/liquid_helper.rb +1 -1
  68. data/test/models/attachment.rb +5 -0
  69. data/test/models/issue.rb +5 -0
  70. data/test/models/journal.rb +6 -0
  71. data/test/schema.rb +65 -53
  72. data/test/tags_helper_view_test.rb +41 -0
  73. data/test/test_helper.rb +13 -12
  74. metadata +43 -14
  75. data/app/views/redmine_crm/redmineup_calendar/_calendar.html.erb +0 -34
  76. data/bitbucket-pipelines.yml +0 -50
  77. data/lib/redmineup/compatibility/application_controller_patch.rb +0 -33
  78. data/lib/redmineup/compatibility/routing_mapper_patch.rb +0 -25
  79. data/lib/redmineup/helpers/rup_calendar_helper.rb +0 -146
  80. /data/{vendor → app}/assets/images/money.png +0 -0
  81. /data/{vendor → app}/assets/images/vcard.png +0 -0
  82. /data/{vendor/assets/javascripts/Chart.bundle.min.js → app/assets/javascripts/Chart.bundle.min.js.bak} +0 -0
  83. /data/{vendor → app}/assets/javascripts/select2.js +0 -0
data/test/test_helper.rb CHANGED
@@ -1,25 +1,27 @@
1
1
  require 'rails/all'
2
2
  require 'redmineup'
3
3
  require 'minitest/autorun'
4
+ require 'minitest/mock'
4
5
 
5
6
  ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + '/debug.log')
6
7
  ActiveRecord::Base.configurations = YAML.load_file(File.dirname(__FILE__) + '/database.yml')
7
8
  ActiveRecord::Base.establish_connection(ENV['DB'].try(:to_sym) || :sqlite)
8
9
 
9
10
  load(File.dirname(__FILE__) + '/schema.rb')
10
- Dir.glob(File.expand_path('../models/*.rb', __FILE__)).each { |f| require f }
11
+ Dir.glob(File.expand_path('models/*.rb', __dir__)).each { |f| require f }
11
12
 
12
- class ActiveSupport::TestCase #:nodoc:
13
+ class ActiveSupport::TestCase # :nodoc:
13
14
  include ActiveRecord::TestFixtures
14
15
 
15
- self.fixture_path = File.dirname(__FILE__) + '/fixtures/'
16
+ gem_fixtures_path = File.dirname(__FILE__) + '/fixtures/'
17
+ respond_to?(:fixture_paths=) ? self.fixture_paths = [gem_fixtures_path] : self.fixture_path = gem_fixtures_path
16
18
 
17
19
  self.use_transactional_tests = true if RUBY_VERSION > '1.9.3'
18
20
  self.use_instantiated_fixtures = false
19
- set_fixture_class :tags => Redmineup::ActsAsTaggable::Tag
20
- set_fixture_class :taggings => Redmineup::ActsAsTaggable::Tagging
21
+ set_fixture_class tags: Redmineup::ActsAsTaggable::Tag
22
+ set_fixture_class taggings: Redmineup::ActsAsTaggable::Tagging
21
23
 
22
- set_fixture_class :votable_caches => VotableCache
24
+ set_fixture_class votable_caches: VotableCache
23
25
  fixtures :all
24
26
 
25
27
  def assert_equivalent(expected, actual, message = nil)
@@ -32,9 +34,8 @@ class ActiveSupport::TestCase #:nodoc:
32
34
 
33
35
  def assert_tag_counts(tags, expected_values)
34
36
  # Map the tag fixture names to real tag names
35
- expected_values = expected_values.inject({}) do |hash, (tag, count)|
37
+ expected_values = expected_values.each_with_object({}) do |(tag, count), hash|
36
38
  hash[tags(tag).name] = count
37
- hash
38
39
  end
39
40
 
40
41
  tags.each do |tag|
@@ -44,14 +45,14 @@ class ActiveSupport::TestCase #:nodoc:
44
45
  assert_equal value, tag.count, "Expected value of #{value} for #{tag.name}, but was #{tag.count}"
45
46
  end
46
47
 
47
- unless expected_values.empty?
48
- assert false, "The following tag counts were not present: #{expected_values.inspect}"
49
- end
48
+ return if expected_values.empty?
49
+
50
+ assert false, "The following tag counts were not present: #{expected_values.inspect}"
50
51
  end
51
52
 
52
53
  # From Rails trunk
53
54
  def assert_difference(expressions, difference = 1, message = nil, &block)
54
- expression_evaluations = [expressions].flatten.collect{ |expression| lambda { eval(expression, block.binding) } }
55
+ expression_evaluations = [expressions].flatten.collect { |expression| -> { eval(expression, block.binding) } }
55
56
 
56
57
  original_values = expression_evaluations.inject([]) { |memo, expression| memo << expression.call }
57
58
  yield
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmineup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - RedmineUP
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-18 00:00:00.000000000 Z
11
+ date: 2026-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -109,14 +109,28 @@ extensions: []
109
109
  extra_rdoc_files: []
110
110
  files:
111
111
  - ".gitignore"
112
+ - ".gitlab-ci.yml"
112
113
  - Gemfile
113
114
  - README.md
114
115
  - Rakefile
116
+ - app/assets/images/icons.svg
117
+ - app/assets/images/money.png
118
+ - app/assets/images/vcard.png
119
+ - app/assets/javascripts/Chart.bundle.min.js.bak
120
+ - app/assets/javascripts/chart.min.js
121
+ - app/assets/javascripts/consumer.js
122
+ - app/assets/javascripts/consumer_worker.js
123
+ - app/assets/javascripts/jquery.colorPicker.min.js
124
+ - app/assets/javascripts/select2.js
125
+ - app/assets/javascripts/select2_helpers.js
126
+ - app/assets/stylesheets/calendars.css
127
+ - app/assets/stylesheets/money.css
128
+ - app/assets/stylesheets/redmineup.css
129
+ - app/assets/stylesheets/select2.css
115
130
  - app/controllers/redmineup_controller.rb
116
- - app/views/redmine_crm/redmineup_calendar/_calendar.html.erb
131
+ - app/views/redmineup/_additional_assets.html.erb
117
132
  - app/views/redmineup/_money.html.erb
118
133
  - app/views/redmineup/settings.html.erb
119
- - bitbucket-pipelines.yml
120
134
  - config/currency_iso.json
121
135
  - config/locales/cs.yml
122
136
  - config/locales/de.yml
@@ -126,6 +140,13 @@ files:
126
140
  - config/routes.rb
127
141
  - doc/CHANGELOG
128
142
  - doc/LICENSE.txt
143
+ - doc/active-record-mixins.md
144
+ - doc/assets-money-and-utilities.md
145
+ - doc/tagging-and-select2.md
146
+ - lib/action_cable/connection/rup_connection.rb
147
+ - lib/action_cable/server/rup_configuration.rb
148
+ - lib/action_cable/server/rup_server.rb
149
+ - lib/application_record.rb
129
150
  - lib/redmineup.rb
130
151
  - lib/redmineup/acts_as_draftable/draft.rb
131
152
  - lib/redmineup/acts_as_draftable/up_acts_as_draftable.rb
@@ -143,30 +164,39 @@ files:
143
164
  - lib/redmineup/acts_as_votable/voter.rb
144
165
  - lib/redmineup/assets_manager.rb
145
166
  - lib/redmineup/colors_helper.rb
146
- - lib/redmineup/compatibility/application_controller_patch.rb
147
- - lib/redmineup/compatibility/routing_mapper_patch.rb
148
167
  - lib/redmineup/currency.rb
149
168
  - lib/redmineup/currency/formatting.rb
150
169
  - lib/redmineup/currency/heuristics.rb
151
170
  - lib/redmineup/currency/loader.rb
152
171
  - lib/redmineup/engine.rb
172
+ - lib/redmineup/helpers/calendars_helper.rb
173
+ - lib/redmineup/helpers/datetime_helper.rb
153
174
  - lib/redmineup/helpers/external_assets_helper.rb
154
175
  - lib/redmineup/helpers/form_tag_helper.rb
155
- - lib/redmineup/helpers/rup_calendar_helper.rb
156
176
  - lib/redmineup/helpers/tags_helper.rb
177
+ - lib/redmineup/helpers/test_helper.rb
157
178
  - lib/redmineup/helpers/vote_helper.rb
158
179
  - lib/redmineup/hooks/views_layouts_hook.rb
159
180
  - lib/redmineup/liquid/drops/attachment_drop.rb
181
+ - lib/redmineup/liquid/drops/custom_field_enumeration_drop.rb
160
182
  - lib/redmineup/liquid/drops/issue_relations_drop.rb
161
183
  - lib/redmineup/liquid/drops/issues_drop.rb
162
184
  - lib/redmineup/liquid/drops/news_drop.rb
163
185
  - lib/redmineup/liquid/drops/projects_drop.rb
164
186
  - lib/redmineup/liquid/drops/time_entries_drop.rb
165
187
  - lib/redmineup/liquid/drops/users_drop.rb
188
+ - lib/redmineup/liquid/drops/version_drop.rb
189
+ - lib/redmineup/liquid/filters/additional.rb
166
190
  - lib/redmineup/liquid/filters/arrays.rb
167
191
  - lib/redmineup/liquid/filters/base.rb
168
192
  - lib/redmineup/liquid/filters/colors.rb
169
193
  - lib/redmineup/money_helper.rb
194
+ - lib/redmineup/patches/action_cable_base_patch.rb
195
+ - lib/redmineup/patches/action_cable_patch.rb
196
+ - lib/redmineup/patches/auto_completes_controller_patch.rb
197
+ - lib/redmineup/patches/compatibility/routing_mapper_patch.rb
198
+ - lib/redmineup/patches/compatibility/sprite_patch.rb
199
+ - lib/redmineup/patches/compatibility_patch.rb
170
200
  - lib/redmineup/patches/liquid_patch.rb
171
201
  - lib/redmineup/settings.rb
172
202
  - lib/redmineup/settings/money.rb
@@ -201,6 +231,7 @@ files:
201
231
  - test/liquid/drops/news_drop_test.rb
202
232
  - test/liquid/drops/projects_drop_test.rb
203
233
  - test/liquid/drops/uses_drop_test.rb
234
+ - test/liquid/filters/additional_filter_test.rb
204
235
  - test/liquid/filters/arrays_filter_test.rb
205
236
  - test/liquid/filters/base_filter_test.rb
206
237
  - test/liquid/filters/colors_filter_test.rb
@@ -208,6 +239,7 @@ files:
208
239
  - test/models/attachment.rb
209
240
  - test/models/issue.rb
210
241
  - test/models/issue_relation.rb
242
+ - test/models/journal.rb
211
243
  - test/models/news.rb
212
244
  - test/models/project.rb
213
245
  - test/models/user.rb
@@ -215,15 +247,9 @@ files:
215
247
  - test/money_helper_test.rb
216
248
  - test/schema.rb
217
249
  - test/tags_helper_test.rb
250
+ - test/tags_helper_view_test.rb
218
251
  - test/test_helper.rb
219
252
  - test/vote_helper_test.rb
220
- - vendor/assets/images/money.png
221
- - vendor/assets/images/vcard.png
222
- - vendor/assets/javascripts/Chart.bundle.min.js
223
- - vendor/assets/javascripts/select2.js
224
- - vendor/assets/javascripts/select2_helpers.js
225
- - vendor/assets/stylesheets/money.css
226
- - vendor/assets/stylesheets/select2.css
227
253
  homepage: https://www.redmineup.com
228
254
  licenses:
229
255
  - GPL-2.0
@@ -277,6 +303,7 @@ test_files:
277
303
  - test/liquid/drops/news_drop_test.rb
278
304
  - test/liquid/drops/projects_drop_test.rb
279
305
  - test/liquid/drops/uses_drop_test.rb
306
+ - test/liquid/filters/additional_filter_test.rb
280
307
  - test/liquid/filters/arrays_filter_test.rb
281
308
  - test/liquid/filters/base_filter_test.rb
282
309
  - test/liquid/filters/colors_filter_test.rb
@@ -284,6 +311,7 @@ test_files:
284
311
  - test/models/attachment.rb
285
312
  - test/models/issue.rb
286
313
  - test/models/issue_relation.rb
314
+ - test/models/journal.rb
287
315
  - test/models/news.rb
288
316
  - test/models/project.rb
289
317
  - test/models/user.rb
@@ -291,5 +319,6 @@ test_files:
291
319
  - test/money_helper_test.rb
292
320
  - test/schema.rb
293
321
  - test/tags_helper_test.rb
322
+ - test/tags_helper_view_test.rb
294
323
  - test/test_helper.rb
295
324
  - test/vote_helper_test.rb
@@ -1,34 +0,0 @@
1
- <ul class="cal">
2
- <li scope="col" title="<%= l(:label_week) %>" class="calhead week-number"></li>
3
- <% 7.times do |i| %>
4
- <li scope="col" class="calhead"><%= day_name((calendar.first_wday + i) % 7) %></li>
5
- <% end %>
6
- <% calendar.format_month.each_slice(7) do |week| %>
7
- <li class='week-number'>
8
- <span class="label-week"><%= l(:label_week) %></span> <%= calendar.week_number week.first %>
9
- </li>
10
- <% week.each do |day| %>
11
- <li class="<%= calendar.day_css_classes day %> calbody">
12
- <p class="day-num"><%= day.day %>
13
- <span class="abbr-day">(<%= abbr_day_name(day.cwday) %>)</span>
14
- </p>
15
- <% calendar.events_on(day).each do |i| %>
16
- <% if i.is_a? Issue %>
17
- <%= tag.div class: [ i.css_classes, 'tooltip hascontextmenu', starting: day == i.start_date, ending: day == i.due_date] do %>
18
- <%= "#{i.project} -" unless @project && @project == i.project %>
19
- <%= link_to_issue i, :truncate => 30 %>
20
- <span class="tip"><%= render_issue_tooltip i %></span>
21
- <%= check_box_tag 'ids[]', i.id, false, :style => 'display:none;', :id => nil %>
22
- <% end %>
23
- <% else %>
24
- <span class="icon icon-package">
25
- <%= "#{i.project} -" unless @project && @project == i.project %>
26
- <%= link_to_version i %>
27
- </span>
28
- <% end %>
29
- <% end %>
30
- </li>
31
- <% end %>
32
- <% end %>
33
- </ul>
34
- <%= context_menu %>
@@ -1,50 +0,0 @@
1
- # This is a sample build configuration for Ruby.
2
- # Check our guides at https://confluence.atlassian.com/x/8r-5Mw for more examples.
3
- # Only use spaces to indent your .yml configuration.
4
- # -----
5
- # You can specify a custom docker image from Docker Hub as your build environment.
6
-
7
- pipelines:
8
- default:
9
- - parallel:
10
- - step:
11
- name: 2.4.1 ruby
12
- image: ruby:2.4.1
13
- script:
14
- - sed -i "s/'sqlite3'/'sqlite3', '~> 1.3.6'/g" redmineup.gemspec
15
- - sed -i "s/'mysql2'/'mysql2', '~> 0.4.0'/g" redmineup.gemspec
16
- - sed -i "s/'rubyzip'/'rubyzip'\n spec.add_runtime_dependency 'loofah', '~>2.19.1'/g" redmineup.gemspec
17
- - bundle install
18
- - bundle exec rake test DB=sqlite
19
- - bundle exec rake test DB=postgresql
20
- - bundle exec rake test DB=mysql
21
- services:
22
- - mysql
23
- - postgres
24
- - step:
25
- name: 3.2.2 ruby
26
- image: ruby:3.2.2
27
- script:
28
- - sed -i "s/'sqlite3'/'sqlite3', '~> 1.4.4'/g" redmineup.gemspec
29
- - sed -i "s/'mysql2'/'mysql2', '~> 0.5.0'/g" redmineup.gemspec
30
- - sed -i "s/'rubyzip'/'rubyzip'\n spec.add_runtime_dependency 'loofah', '~>2.19.1'/g" redmineup.gemspec
31
- - bundle install
32
- - bundle exec rake test DB=sqlite
33
- - bundle exec rake test DB=postgresql
34
- - bundle exec rake test DB=mysql
35
- services:
36
- - mysql
37
- - postgres
38
-
39
- definitions:
40
- services:
41
- mysql:
42
- image: mysql:5.7
43
- environment:
44
- MYSQL_DATABASE: redmineup_test
45
- MYSQL_ROOT_PASSWORD: password
46
- postgres:
47
- image: postgres
48
- environment:
49
- POSTGRES_DB: redmineup_test
50
- POSTGRES_PASSWORD: password
@@ -1,33 +0,0 @@
1
- module Redmineup
2
- module Patches
3
- module ApplicationControllerPatch
4
- def self.included(base) # :nodoc:
5
- base.extend(ClassMethods)
6
- base.class_eval do
7
- unloadable # Send unloadable so it will not be unloaded in development
8
- end
9
- end
10
-
11
- module ClassMethods
12
- def before_action(*filters, &block)
13
- before_filter(*filters, &block)
14
- end
15
-
16
- def after_action(*filters, &block)
17
- after_filter(*filters, &block)
18
- end
19
-
20
- def skip_before_action(*filters, &block)
21
- skip_before_filter(*filters, &block)
22
- end
23
- end
24
- end
25
- end
26
- end
27
-
28
- unless ActionController::Base.methods.include?(:before_action)
29
- ActionController::Base.send(
30
- :include,
31
- Redmineup::Patches::ApplicationControllerPatch
32
- )
33
- end
@@ -1,25 +0,0 @@
1
- module Redmineup
2
- module Patches
3
- module RoutingMapperPatch
4
- def self.included(base)
5
- base.send(:include, InstanceMethods)
6
-
7
- base.class_eval do
8
- alias_method :constraints_without_redmineup, :constraints
9
- alias_method :constraints, :constraints_with_redmineup
10
- end
11
- end
12
-
13
- module InstanceMethods
14
- def constraints_with_redmineup(options = {}, &block)
15
- options[:object_type] = /.+/ if options[:object_type] && options[:object_type].is_a?(Regexp)
16
- constraints_without_redmineup(options, &block)
17
- end
18
- end
19
- end
20
- end
21
- end
22
-
23
- unless ActionDispatch::Routing::Mapper.included_modules.include?(Redmineup::Patches::RoutingMapperPatch)
24
- ActionDispatch::Routing::Mapper.send(:include, Redmineup::Patches::RoutingMapperPatch)
25
- end
@@ -1,146 +0,0 @@
1
- module RedmineUp
2
- module CalendarHelper
3
- # Simple class to compute the start and end dates of a calendar
4
- class Calendar
5
- attr_reader :startdt, :enddt
6
-
7
- def initialize(date, options={}, lang = current_language, period = :month)
8
- @date = date
9
- @events = []
10
- @ending_events_by_days = {}
11
- @starting_events_by_days = {}
12
- # ADDED FOR CONTACTS-DEALS
13
- @start_date_field = options[:start_date_field] || "start_date"
14
- @due_date_field = options[:due_date_field] || "due_date"
15
- # /ADDED FOR CONTACTS-DEALS
16
- set_language_if_valid lang
17
- case period
18
- when :month
19
- @startdt = Date.civil(date.year, date.month, 1)
20
- @enddt = (@startdt >> 1)-1
21
- # starts from the first day of the week
22
- @startdt = @startdt - (@startdt.cwday - first_wday)%7
23
- # ends on the last day of the week
24
- @enddt = @enddt + (last_wday - @enddt.cwday)%7
25
- when :week
26
- @startdt = date - (date.cwday - first_wday)%7
27
- @enddt = date + (last_wday - date.cwday)%7
28
- else
29
- raise 'Invalid period'
30
- end
31
- end
32
-
33
- def format_month
34
- (@startdt..@enddt).to_a
35
- end
36
-
37
- def week_number(day)
38
- (day + (11 - day.cwday) % 7).cweek
39
- end
40
-
41
- def day_css_classes(day)
42
- css = day.month==month ? +'even' : +'odd'
43
- css << " today" if User.current.today == day
44
- css << " nwday" if non_working_week_days.include?(day.cwday)
45
- css
46
- end
47
-
48
- # Sets calendar events
49
- def events=(events)
50
- @events = events
51
- # CHANGED FOR CONTACTS-DEALS
52
- @ending_events_by_days = @events.group_by {|event| event.send(@start_date_field) ? event.send(@start_date_field).to_date : event.due_date}
53
- @starting_events_by_days = @events.group_by {|event| event.send(@due_date_field) ? event.send(@due_date_field).to_date : event.start_date}
54
- # /CHANGED FOR CONTACTS-DEALS
55
- end
56
-
57
- # Returns events for the given day
58
- def events_on(day)
59
- ((@ending_events_by_days[day] || []) + (@starting_events_by_days[day] || [])).uniq
60
- end
61
-
62
- # Calendar current month
63
- def month
64
- @date.month
65
- end
66
-
67
- # Return the first day of week
68
- # 1 = Monday ... 7 = Sunday
69
- def first_wday
70
- case Setting.start_of_week.to_i
71
- when 1
72
- @first_dow ||= (1 - 1)%7 + 1
73
- when 6
74
- @first_dow ||= (6 - 1)%7 + 1
75
- when 7
76
- @first_dow ||= (7 - 1)%7 + 1
77
- else
78
- @first_dow ||= (l(:general_first_day_of_week).to_i - 1)%7 + 1
79
- end
80
- end
81
-
82
- def last_wday
83
- @last_dow ||= (first_wday + 5)%7 + 1
84
- end
85
-
86
- def abbr_day_name(day)
87
- ::I18n.t('date.abbr_day_names')[day % 7]
88
- end
89
-
90
- def current_language
91
- ::I18n.locale
92
- end
93
-
94
- def set_language_if_valid(lang)
95
- if l = find_language(lang)
96
- ::I18n.locale = l
97
- end
98
- end
99
-
100
- def find_language(lang)
101
- @@languages_lookup ||=
102
- valid_languages.inject({}) do |k, v|
103
- k[v.to_s.downcase] = v
104
- k
105
- end
106
- @@languages_lookup[lang.to_s.downcase]
107
- end
108
-
109
- def valid_languages
110
- ::I18n.available_locales
111
- end
112
-
113
- def l(*args)
114
- case args.size
115
- when 1
116
- ::I18n.t(*args)
117
- when 2
118
- if args.last.is_a?(Hash)
119
- ::I18n.t(*args.first, **args.last)
120
- elsif args.last.is_a?(String)
121
- ::I18n.t(args.first, :value => args.last)
122
- else
123
- ::I18n.t(args.first, :count => args.last)
124
- end
125
- else
126
- raise "Translation string with multiple values: #{args.first}"
127
- end
128
- end
129
-
130
- def non_working_week_days
131
- @non_working_week_days ||= begin
132
- days = Setting.non_working_week_days
133
- if days.is_a?(Array) && days.size < 7
134
- days.map(&:to_i)
135
- else
136
- []
137
- end
138
- end
139
- end
140
- end
141
- end
142
- end
143
-
144
- unless ActionView::Base.included_modules.include?(RedmineUp::CalendarHelper)
145
- ActionView::Base.send(:include, RedmineUp::CalendarHelper)
146
- end
File without changes
File without changes
File without changes