ecm_calendar_helper 0.0.2 → 0.0.3

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: 32b2ca56a2f9dd321f2db78da04aa1547c2e6c32
4
- data.tar.gz: b972dacdaab4c40d6485982cbebf7a536e7deb64
3
+ metadata.gz: f3e5f21214725193d52d1c15380ed1c03c04b8e6
4
+ data.tar.gz: 15278f09109d889796d8c3f91eddf1628230c0b9
5
5
  SHA512:
6
- metadata.gz: b094c8b15e9894c6a5a7bfa73cd04a05ce118614459a0da91aad936acdc5941e2cb130998d711ae41e54040c2c4f749975914851ac7c00d4d4221fb10eff7d66
7
- data.tar.gz: 569aae1a432c72e0a8da7dac2ff51e9e314e72b059c6e2272061894093488c59cfe2d2e67bdf5c0a540405b211ac7ccdb02e1437f9eb702b9abd0634624b8a69
6
+ metadata.gz: 8a05e3299d4059ab13376b008a7b8f1745cb7406c541ef4ceec4f4012c3eec063a22e90a07f2844ab90d82329bed3e645df8bd239a84346bc9c6a39f0f7fe659
7
+ data.tar.gz: ac222cd53b256fea99960dc1562aa81e9b1797824dacafdeb7c695474aeae3da6b60e4c4cd0a1bbd5ee7bbcc286ec8dbd38d565d9d3bcffa5630a8f1972fea5e
@@ -31,29 +31,15 @@ module Ecm
31
31
  end
32
32
 
33
33
  days_by_week = {}
34
- days_in_week = {}
35
- week = beginning_of_month.cweek
36
- (beginning_of_month..end_of_month).each_with_index do |day, index|
37
- days_in_week[day] = elements.find_all { |e| e.send(options[:date_method]).to_date == day.to_date } || {}
38
-
39
- if day.wday == last_day_of_week
40
- (7 - days_in_week.size).times do |i|
41
- days_in_week[0 - i] = {}
42
- end
43
- week = (day + 1.day).cweek
44
- end
34
+ first_day = beginning_of_month.beginning_of_week
35
+ last_day = end_of_month.end_of_week
45
36
 
46
- if day.wday == last_day_of_week || index == end_of_month.day - 1
47
- days_by_week[week] = days_in_week
48
- days_in_week = {}
49
- end
50
-
51
- if index == end_of_month.day - 1
52
- (7 - days_in_week.size).times do |i|
53
- days_in_week[days_in_week.size - i] = {}
54
- end
55
- end
37
+ days = (first_day..last_day).each_with_object({}).with_index do |(day, memo), index|
38
+ memo[day.to_date] = elements.find_all { |e| e.send(options[:date_method]).to_date == day.to_date } || {}
56
39
  end
40
+
41
+ days_by_week = days.each_with_object({}) { |(k, v), m| (m[k.cweek] ||= {})[k] = v }
42
+
57
43
  render partial: 'ecm/calendar_helper/month_calendar', locals: { localized_day_names: localized_day_names, days_by_week: days_by_week, display_method: display_method, link_elements: link_elements }
58
44
  end
59
45
 
@@ -3,27 +3,23 @@
3
3
  - localized_day_names.each do |day|
4
4
  .column.calendar-weekday-name
5
5
  %h1= day
6
+
6
7
  - days_by_week.each do |week, days|
7
- .flex-row
8
+ .flex-row{ class: "week-#{week}" }
8
9
  - days_count = 0
9
- - days.sort.each do |day, elements|
10
- - days_count += 1
11
- - if day < 1
12
- .column
13
- - else
14
- - td_classes = ['calendar-day']
15
- - td_classes << 'active today' if day == Time.zone.now.to_date
16
- - td_classes << 'with-elements' if elements.any?
17
- .column{ class: td_classes.join(" ") }
18
- .calendar-day-container
19
- %h1.calendar-day-title= day.day
20
- %div.calendar-entries
21
- - elements.each do |element|
22
- %div.calendar-day-content
23
- %span.calendar-item.calendar-item-default
24
- - if link_elements
25
- = link_to(element.send(display_method), element)
26
- - else
27
- = element.send(display_method)
28
- - (7 - days_count).times do
29
- .column
10
+ - days.each do |day, elements|
11
+ - td_classes = ['calendar-day']
12
+ - td_classes << 'active today' if day == Time.zone.now.to_date
13
+ - td_classes << 'with-elements' if elements.any?
14
+ - td_classes << 'not-actual-month' if day.month != Time.zone.now.month
15
+ .column{ class: td_classes.join(" ") }
16
+ .calendar-day-container
17
+ %h1.calendar-day-title= day.day
18
+ %div.calendar-entries
19
+ - elements.each do |element|
20
+ %div.calendar-day-content
21
+ %span.calendar-item.calendar-item-default
22
+ - if link_elements
23
+ = link_to(element.send(display_method), element)
24
+ - else
25
+ = element.send(display_method)
@@ -1,5 +1,5 @@
1
1
  module Ecm
2
2
  module CalendarHelper
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecm_calendar_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-09 00:00:00.000000000 Z
11
+ date: 2017-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  requirements: []
84
84
  rubyforge_project:
85
- rubygems_version: 2.4.8
85
+ rubygems_version: 2.6.11
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: Rails calendar helper.