simple_calendar-timeslot 0.4.0 → 0.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7522e42ad4d981ea9307e4ec7af21b95bbf1c330d321e73fd8e265d73955346e
4
- data.tar.gz: d6562afe5db9a28979553bc1a089fa2ad0454af8dae55f120bcefd8b3d617f36
3
+ metadata.gz: b981b7c9ef328bf21adf9ced3ea7f53cdacdbd70ee70006f66e01fd676634d14
4
+ data.tar.gz: d9b6a5bcc147cd5155766a42e647654013c6c81c6bfdcdf1b1e4f3360659a0d5
5
5
  SHA512:
6
- metadata.gz: 6557f1572ef373f53325412e0e8f47eb9acaa01f639cfce83b128a1a1e31a4657eb9ff841a01e3dec96d7fd69970675c33237e3fa5e6e8b60303a53a1e15e62d
7
- data.tar.gz: ddafaefd0434bf85d5f29b01d31c9bb279028123ffd957a8332710d25bcf125d51d475f70f4133c652869ce21c40d6aff24ec29938dca2ae51e639bacf0f99f6
6
+ metadata.gz: 87c70e2c3cca879480f6ed87e7ce5d1adbcd2095e17aad0e30fdf3b1dea00a1b1461d676c81c2108010af619c488b9bbb067ab53f43678a63a584fbfb4220546
7
+ data.tar.gz: fe7d528e2b333e7ecbae96626aeb74ca4e0d58c857c5fdb1ec1101535dc0a6f54d7cb3c9d37ecc825d130266bbc8bd35ac49d4bb631cf7ebd85a9d34556b6a8e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.7.0] - 2021-11-15
4
+ ### Added
5
+ - new option to display a current time indicator line (based on Time.zone.now), that is invisible unless styled, the css-class is
6
+ `current_time_indicator`
7
+ ### Fixed
8
+ - minor z-index inconsistencies for event rendering
9
+
10
+ ## [0.6.0] - 2021-11-15
11
+ ### Added
12
+ - Added option horizontal_scroll_split to view helper, which defaults to false. This option affects
13
+ horizontal orientation only. If set to false, the
14
+ different days of the calendar scroll together horizontally, which is more consistent with the
15
+ behaviour of the vertical layout. If set to true, the days scroll independently.
16
+
17
+ ## [0.5.1] - 2021-11-15
18
+ ### Fixed
19
+ - Fixed reliance of calendar on legacy function to
20
+ calculate event height
21
+
22
+ ## [0.5.0] - 2021-11-14
23
+ - Removed images for the README from the gem, sry :(
24
+
25
+ ## [0.4.0] - 2021-11-14
26
+ ### Added
27
+ - Added compatibilty with the attribute and end_attribute options in the view helper
28
+ - Added documentation to README
29
+
3
30
  ## [0.3.0] - 2021-11-14
4
31
  ### Fixed
5
32
  - Fix issue with css styles when including style of this gem and simple_calendar
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_calendar-timeslot (0.4.0)
4
+ simple_calendar-timeslot (0.7.0)
5
5
  simple_calendar (~> 2.0)
6
6
 
7
7
  GEM
@@ -90,6 +90,8 @@ GEM
90
90
  nokogiri (1.12.5)
91
91
  mini_portile2 (~> 2.6.1)
92
92
  racc (~> 1.4)
93
+ nokogiri (1.12.5-x86_64-darwin)
94
+ racc (~> 1.4)
93
95
  parallel (1.21.0)
94
96
  parser (3.0.2.0)
95
97
  ast (~> 2.4.1)
@@ -157,7 +159,7 @@ GEM
157
159
  sprockets (4.0.2)
158
160
  concurrent-ruby (~> 1.0)
159
161
  rack (> 1, < 3)
160
- sprockets-rails (3.3.0)
162
+ sprockets-rails (3.4.0)
161
163
  actionpack (>= 5.2)
162
164
  activesupport (>= 5.2)
163
165
  sprockets (>= 3.0.0)
data/README.md CHANGED
@@ -9,10 +9,10 @@ This helps to visually grasps the length of events and the time between them. In
9
9
  Horizontal and vertical layout is selectable via options, just like many other ones.
10
10
 
11
11
  Horizontal example
12
- ![Horizontal Calendar](img/simple_calendar-timeslot_horizontal.png)
12
+ ![Horizontal Calendar](https://github.com/1klap/simple_calendar-timeslot/blob/96475bf7c354b7e0318a9421e155588d96517fc3/img/simple_calendar-timeslot_horizontal.png?raw=true)
13
13
 
14
14
  Vertical example
15
- ![Vertical Calendar](img/simple_calendar-timeslot_vertical.png)
15
+ ![Vertical Calendar](https://github.com/1klap/simple_calendar-timeslot/blob/96475bf7c354b7e0318a9421e155588d96517fc3/img/simple_calendar-timeslot_vertical.png?raw=true)
16
16
 
17
17
 
18
18
  ## Installation
@@ -34,7 +34,7 @@ Or install it yourself as:
34
34
 
35
35
  **Important** Then include the stylesheet in your rails app.
36
36
 
37
- If you an `application.css` file, include the following:
37
+ If you have an `application.css` file, include the following:
38
38
  ```ruby
39
39
  *= require simple_calendar-timeslot
40
40
  ```
@@ -47,12 +47,17 @@ If you use an SCSS file (`application.scss`), add the following line instead:
47
47
 
48
48
  TODO: Write usage instructions here
49
49
 
50
+ Your model must implement a `start_time` and `end_time` function,
51
+ or you can specify alternatives as options to the call below
52
+ as `attribute: :my_start_time` and `end_attribute: :my_end_time`.
53
+
50
54
  ```erb
51
55
  <%= timeslot_calendar(events: @events,
52
56
  number_of_days: 2,
53
57
  px_per_minute: 1.5,
54
58
  orientation: :horizontal,
55
59
  horizontal_height_px: 250,
60
+ # attribute: :my_start_time,
56
61
  # display_grid: false,
57
62
  # display_bucket_title: :event_type,
58
63
  # bucket_title_size: 30,
@@ -67,14 +72,16 @@ TODO: Write usage instructions here
67
72
  ```
68
73
 
69
74
  Shortversion in the meantime:
70
- - orientation (:vertical, :horizontal, default: :vertical)
71
- - horizontal_height_px default: 300
72
- - split_by_type (model function to call in case of bucketung f.ex.`:event_type`, default: false)
73
- - px_per_minute default: 0.65
74
- - display_bucket_title (model function to call in case of bucketung f.ex.`:event_type_name`, default: false)
75
- - bucket_title_size default: 20
76
- - grid_width default: 20px
77
- - display_grid default: true
75
+ - `orientation` (`:vertical`, `:horizontal`, default: :vertical)
76
+ - `px_per_minute` (defines size of calendar, default: 0.65)
77
+ - `horizontal_height_px` default: 300
78
+ - `horizonzal_scroll_split` (scroll days separately or together, default: false)
79
+ - `split_by_type` (model function to call in case of bucketing f.ex.`:event_type`, default: false)
80
+ - `display_bucket_title` (model function to call in case of bucketing f.ex.`:event_type_name`, default: false)
81
+ - `bucket_title_size` default: 20
82
+ - `grid_width` default: 20px
83
+ - `display_grid` default: true
84
+ - `current_time_indicator` (display a stylable div across the timeline that display the current time, css-class: `current_time_indicator`, default: false)
78
85
 
79
86
  ## Development
80
87
 
@@ -9,6 +9,10 @@
9
9
  display: flex;
10
10
  flex-direction: column;
11
11
  }
12
+ .timeslot-calendar .days-wrapper-horizontal.scroll-link {
13
+ overflow-x: auto;
14
+ overflow-y: hidden;
15
+ }
12
16
  .timeslot-calendar .day-wrapper {
13
17
  flex: 1 1 0;
14
18
  }
@@ -21,13 +25,14 @@
21
25
  display: flex;
22
26
  flex-direction: column;
23
27
  position: relative;
28
+ }
29
+ .timeslot-calendar .day-content-horizontal.scroll-split {
24
30
  overflow-x: auto;
25
31
  overflow-y: hidden;
26
32
  }
27
33
  .timeslot-calendar .day-content-horizontal-inner {
28
34
  position: relative;
29
35
  }
30
-
31
36
  .timeslot-calendar .hour-indicator-col-vertical {
32
37
  display: flex;
33
38
  flex: 1 1 0;
@@ -87,6 +92,9 @@
87
92
  z-index: 1;
88
93
  box-sizing: border-box;
89
94
  }
95
+ .timeslot-calendar .current_time_indicator {
96
+ position: absolute;
97
+ }
90
98
  /*--- Event example style ----*/
91
99
  .timeslot-event {
92
100
  width: 100%;
@@ -31,6 +31,9 @@
31
31
  <% end %>
32
32
  </div>
33
33
  <% end %>
34
+ <% if calendar.display_current_time_indicator %>
35
+ <div class="current_time_indicator" style="top:<%=calendar.current_time_offset %>px;left:0;right:0;height:0;"></div>
36
+ <% end %>
34
37
  <% events = sorted_events.fetch(day, []) %>
35
38
  <% buckets = calendar.split_into_buckets(events) %>
36
39
  <div class="buckets-wrapper" style="left:<%=calendar.grid_width%>;right:0">
@@ -46,7 +49,7 @@
46
49
  <div class="events-wrapper">
47
50
  <% events_size = calendar.slot_events(bucket, day) %>
48
51
  <% bucket.each do |event| %>
49
- <div class="event-wrapper" style="z-index:20;width:<%=events_size[event][0]%>%;top:<%=events_size[event][3]%>px;left:<%=events_size[event][1]%>%;height:<%=events_size[event][2]%>px">
52
+ <div class="event-wrapper" style="width:<%=events_size[event][0]%>%;top:<%=events_size[event][3]%>px;left:<%=events_size[event][1]%>%;height:<%=events_size[event][2]%>px">
50
53
  <% if defined?(Haml) && respond_to?(:block_is_haml?) && block_is_haml?(passed_block) %>
51
54
  <% capture_haml(event, &passed_block) %>
52
55
  <% else %>
@@ -66,7 +69,7 @@
66
69
  <% end %>
67
70
  </div>
68
71
  <% elsif calendar.orientation == :horizontal %>
69
- <div class="days-wrapper-horizontal">
72
+ <div class="days-wrapper-horizontal <%= calendar.horizontal_scroll_split ? "" : "scroll-link" %>">
70
73
  <% date_range.slice(0, 7).each do |day| %>
71
74
  <div class="day-wrapper">
72
75
  <div class="day-title-row">
@@ -78,7 +81,7 @@
78
81
  </span>
79
82
  </div>
80
83
  <%= content_tag :div, class: calendar.td_classes_for(day) do %>
81
- <div class="day-content-horizontal">
84
+ <div class="day-content-horizontal <%= calendar.horizontal_scroll_split ? "scroll-split" : "" %>">
82
85
  <div class="day-content-horizontal-inner" style="width:<%=calendar.height%>px;height:<%=calendar.horizontal_height_px%>px">
83
86
  <% if calendar.display_grid %>
84
87
  <div class="hour-indicator-col-horizontal" style="z-index:-10;">
@@ -94,6 +97,9 @@
94
97
  <% end %>
95
98
  </div>
96
99
  <% end %>
100
+ <% if calendar.display_current_time_indicator && !calendar.horizontal_scroll_split %>
101
+ <div class="current_time_indicator" style="left:<%=calendar.current_time_offset %>px;top:0;bottom:0;width:0;"></div>
102
+ <% end %>
97
103
  <% events = sorted_events.fetch(day, []) %>
98
104
  <% buckets = calendar.split_into_buckets(events) %>
99
105
  <div class="buckets-wrapper" style="top:<%=calendar.grid_width%>;bottom:0">
@@ -50,6 +50,14 @@ module SimpleCalendar
50
50
  @options.fetch(:display_grid, true)
51
51
  end
52
52
 
53
+ def horizontal_scroll_split
54
+ @options.fetch(:horizontal_scroll_split, false)
55
+ end
56
+
57
+ def display_current_time_indicator
58
+ @options.fetch(:display_current_time_indicator, false)
59
+ end
60
+
53
61
  def height
54
62
  #h = (24 - TimeslotCalendar::FIRST_HOUR_SLOT) * 60 * px_per_minute
55
63
  h = 24 * 60 * px_per_minute
@@ -63,9 +71,9 @@ module SimpleCalendar
63
71
  elsif event.send(attribute).to_date < event.send(end_attribute).to_date
64
72
  (event.send(end_attribute).midnight - 60 - event.send(attribute))/60
65
73
  else
66
- event.duration
74
+ (event.send(end_attribute) - event.send(attribute))/60
67
75
  end
68
- minutes * px_per_minute
76
+ minutes * px_per_minute
69
77
  end
70
78
 
71
79
  def event_top_distance(event, day)
@@ -119,6 +127,13 @@ module SimpleCalendar
119
127
  r
120
128
  end
121
129
 
130
+ def current_time_offset
131
+ now = Time.zone.now
132
+ offset = (now.hour * 60 + now.min) * px_per_minute
133
+ offset = offset + bucket_title_size if display_bucket_title
134
+ offset
135
+ end
136
+
122
137
  private
123
138
 
124
139
  def pack_events(r, columns)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SimpleCalendar
4
4
  module Timeslot
5
- VERSION = "0.4.0"
5
+ VERSION = "0.7.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_calendar-timeslot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kim Laplume
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-14 00:00:00.000000000 Z
11
+ date: 2021-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simple_calendar
@@ -88,8 +88,6 @@ files:
88
88
  - app/views/simple_calendar/timeslot/_timeslot_calendar.html.erb
89
89
  - bin/console
90
90
  - bin/setup
91
- - img/simple_calendar-timeslot_horizontal.png
92
- - img/simple_calendar-timeslot_vertical.png
93
91
  - lib/simple_calendar/timeslot.rb
94
92
  - lib/simple_calendar/timeslot/railtie.rb
95
93
  - lib/simple_calendar/timeslot/timeslot_calendar.rb