bull-date-time-picker 0.0.0 → 0.0.1

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/datetime_ui.rb +22 -15
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e857e755f1827198d0553bdc26cea549e0c4b1f5
4
- data.tar.gz: 1691c94b6b28c379226185a9a66b55fdfdd18f63
3
+ metadata.gz: d0088f51ce3ae2cc14114257f46aa917a20db846
4
+ data.tar.gz: c4d2a61d1afb7c7d9df971abd1a480abe0291358
5
5
  SHA512:
6
- metadata.gz: ed1d368c9564d8dc59ccf63e7e2d7e02e62aa9b8216774c4930ceab11687e14f9e1cd456148e40974c7d7a9d541cdec41912dd83d3ef48d6525d60ed04ed169c
7
- data.tar.gz: 72a882546ba4e703771a0c0ad3a1e4ece5005f3a34c2c823727b593b9cd962fb2dc1b67b0555015a3f5a6932dafe461d1d800ea0a8c3279458c448db320b9503
6
+ metadata.gz: d83779e48070fd0fa432f7edfe24c415031d33c565fe07182d42541668974c382ee0a0f4238a8f0b6880c637210b1f4278dea402337adc1b6cd9af7a40198156
7
+ data.tar.gz: 5dff46519a637f63c46151e6060fb240e4be0279e6e09a1532c182b3891ba796855552f9235053446a28c86f77c06655ce33e5d42112f54f8254ce92159871d9
data/lib/datetime_ui.rb CHANGED
@@ -3,7 +3,8 @@ require 'time'
3
3
 
4
4
  def day_row week, date
5
5
  ret = []
6
- ini_month = Time.new(date.year, date.month, 1, date.hour, date.min)
6
+ #ini_month = Time.new(date.year, date.month, 1, date.hour, date.min)
7
+ ini_month = Time.new(date.year, date.month, 1)
7
8
  ini = ini_month - (ini_month.wday-1)*24*60*60
8
9
  ini = ini + 7*week*24*60*60
9
10
  end_ = ini + 7*24*60*60
@@ -26,11 +27,11 @@ end
26
27
 
27
28
  class Day < React::Component::Base
28
29
  param :data
29
- param :change_date#, type: Proc
30
+ param :on_change
30
31
 
31
32
  def render
32
33
  span(class: params.data['decoration']){params.data['value']}.on(:click) do |event|
33
- params.change_date.call params.data['date']
34
+ params.on_change.call params.data['date']
34
35
  end
35
36
  end
36
37
  end
@@ -38,19 +39,19 @@ end
38
39
  class Week < React::Component::Base
39
40
  param :week
40
41
  param :day
41
- param :change_date#, type: Proc
42
+ param :on_change
42
43
 
43
44
  def render
44
45
  div(class: 'xdatetime-week') do
45
46
  day_row(params.week, params.day).each do |d|
46
- Day(data: d, change_date: params.change_date) # key?
47
+ Day(data: d, on_change: params.on_change) # key?
47
48
  end
48
49
  end
49
50
  end
50
51
  end
51
52
 
52
53
  class DateTimeInput < React::Component::Base
53
- param :change_date #, type: Proc
54
+ param :on_change
54
55
  param :time
55
56
  param :value
56
57
  param :format, type: String
@@ -60,6 +61,13 @@ class DateTimeInput < React::Component::Base
60
61
  state.day! Time.now
61
62
  end
62
63
 
64
+ def on_change v
65
+ if !params.time
66
+ state.show! false
67
+ end
68
+ params.on_change.call v
69
+ end
70
+
63
71
  def render
64
72
  day = params.value || Time.now
65
73
  val = if params.value
@@ -67,25 +75,24 @@ class DateTimeInput < React::Component::Base
67
75
  else
68
76
  ''
69
77
  end
70
- div do
71
- #input(type: :text, value: day.strftime(params.format)).on(:click) {|event| state.show! !state.show}
72
- input(type: :text, value: val).on(:click) {|event| state.show! !state.show}
78
+ span(class: 'date-time-box') do
79
+ input(type: :text, value: val, disabled: 'disabled').on(:click) {|event| state.show! !state.show}
73
80
  div(class: 'xdatetime-popover') do
74
81
  div(class: 'xdatetime-header') do
75
- i(class: 'minus-month fa fa-minus').on(:click) {state.day! state.day - 30*24*60*60} #{params.change_date.call day - 30*24*60*60}
82
+ i(class: 'minus-month fa fa-minus').on(:click) {state.day! state.day - 30*24*60*60}
76
83
  span{state.day.strftime('%m')}
77
84
  i(class: 'plus-month fa fa-plus').on(:click) {state.day! state.day + 30*24*60*60}
78
85
  i(class: 'minus-year fa fa-minus').on(:click) {state.day! state.day - 365*24*60*60}
79
86
  span{state.day.strftime('%Y')}
80
87
  i(class: 'plus-year fa fa-plus').on(:click) {state.day! state.day + 365*24*60*60}
81
88
  end
82
- 6.times {|w| Week(week: w, day: state.day, change_date: params.change_date)}
89
+ 6.times {|w| Week(week: w, day: state.day, on_change: lambda{|v| on_change v})}
83
90
  div(class: 'xdatetime-bottom') do
84
- i(class: 'minus-hour fa fa-minus').on(:click) {params.change_date.call day - 60*60; state.day! state.day - 60*60}
85
- i(class: 'plus-hour fa fa-plus').on(:click) {params.change_date.call day + 60*60; state.day! state.day + 60*60}
91
+ i(class: 'minus-hour fa fa-minus').on(:click) {params.on_change.call day - 60*60; state.day! state.day - 60*60}
92
+ i(class: 'plus-hour fa fa-plus').on(:click) {params.on_change.call day + 60*60; state.day! state.day + 60*60}
86
93
  span{day.strftime('%H:%M')}
87
- i(class: 'minus-minute fa fa-minus').on(:click) {params.change_date.call day - 60; state.day! state.day - 60}
88
- i(class: 'plus-minute fa fa-plus').on(:click) {params.change_date.call day + 60; state.day! state.day + 60}
94
+ i(class: 'minus-minute fa fa-minus').on(:click) {params.on_change.call day - 60; state.day! state.day - 60}
95
+ i(class: 'plus-minute fa fa-plus').on(:click) {params.on_change.call day + 60; state.day! state.day + 60}
89
96
  end if params.time
90
97
  end if state.show
91
98
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bull-date-time-picker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Alarcos
@@ -10,7 +10,7 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-04-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Date time picker feature for Bull
13
+ description: Date time picker feature for Bull Framework
14
14
  email: miguel.alarcos@gmail.com
15
15
  executables: []
16
16
  extensions: []
@@ -18,7 +18,7 @@ extra_rdoc_files: []
18
18
  files:
19
19
  - lib/bull-date-time-picker.rb
20
20
  - lib/datetime_ui.rb
21
- homepage:
21
+ homepage: https://rubygems.org/gems/bull-date-time-picker
22
22
  licenses:
23
23
  - MIT
24
24
  metadata: {}