five-two-nw-olivander 0.2.0.30 → 0.2.0.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/components/olivander/components/resource_form_component.html.haml +1 -1
- data/app/components/olivander/components/resource_form_component.rb +11 -0
- data/app/controllers/concerns/olivander/resources/crud_controller.rb +4 -2
- data/app/helpers/olivander/application_helper.rb +1 -1
- data/app/inputs/date_time_input.rb +15 -5
- data/lib/olivander/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1527b1808409e4c9fd29465a1c0744806daa5084e78117072eef5df8948526c
|
4
|
+
data.tar.gz: 768af4436b656b56a64c1e614d8eaf8b2107d5a12af485c5101e05b64b62e8a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c8682757f8441cf012c6204b32f7168b93bcbddf890c3f79793235cf8b3038dfd0c68c67b62536a0af12fcc66eeb50b759294682a7592f796deaa3998d7c5cb
|
7
|
+
data.tar.gz: 895aa1992d3e2583d7380f145fa02f6c89fc9b700d9f378f95f85ab3cb7a3830f4b1b22b12923295da4145dc84ff7b478b804232d4c32ed289a08584308c7ba7
|
@@ -14,4 +14,4 @@
|
|
14
14
|
- elsif boolean?(field)
|
15
15
|
= @f.input field.sym, disabled: !field.editable, as: field.type.to_sym, input_html: { data: input_data_hash_for(field) }
|
16
16
|
- else
|
17
|
-
= @f.input field.sym, disabled: !field.editable, as: field.type.to_sym, input_html: { rows: 10, data: input_data_hash_for(field) }
|
17
|
+
= @f.input field.sym, disabled: !field.editable, as: field.type.to_sym, picker_options: input_picker_options_for(field), input_html: { rows: 10, data: input_data_hash_for(field) }
|
@@ -28,6 +28,17 @@ class Olivander::Components::ResourceFormComponent < ViewComponent::Base
|
|
28
28
|
}
|
29
29
|
end
|
30
30
|
|
31
|
+
def input_picker_options_for(field)
|
32
|
+
case field.type
|
33
|
+
when :datetime
|
34
|
+
{ icons: { time: 'far fa-clock' } }
|
35
|
+
when :date
|
36
|
+
{ 'format': 'MM/DD/YYYY' }
|
37
|
+
else
|
38
|
+
{}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
31
42
|
def taggable?(field)
|
32
43
|
method_key = "#{field.sym}_taggable?"
|
33
44
|
return false unless @resource.class.respond_to?(method_key)
|
@@ -195,8 +195,10 @@ module Olivander
|
|
195
195
|
def rearrange_date_param(value)
|
196
196
|
return nil if value.blank?
|
197
197
|
|
198
|
-
|
199
|
-
|
198
|
+
datetime_parts = value.split(' ')
|
199
|
+
date_parts = datetime_parts.first.split('/')
|
200
|
+
datetime_parts[0] = "#{date_parts[2]}-#{date_parts[0]}-#{date_parts[1]}"
|
201
|
+
datetime_parts.join(' ')
|
200
202
|
end
|
201
203
|
end
|
202
204
|
end
|
@@ -1,12 +1,10 @@
|
|
1
1
|
class DateTimeInput < SimpleForm::Inputs::Base
|
2
2
|
def input(wrapper_options)
|
3
|
-
|
4
|
-
raw_value = object.public_send(attribute_name)
|
5
|
-
raw_value = raw_value.strftime(date_format) if raw_value.present?
|
3
|
+
raw_value = parse_value(object.public_send(attribute_name), options[:date_format])
|
6
4
|
|
7
5
|
disabled = options[:disabled] || false
|
8
6
|
|
9
|
-
hash = { id: "#{attribute_name}_datetimepicker", class: 'form-control', value: raw_value, disabled: disabled, 'data-toggle': 'datetimepicker', 'data-target': "##{attribute_name}_datetimepicker" }
|
7
|
+
hash = { id: "#{attribute_name}_datetimepicker", class: 'form-control datetimepicker-input', value: raw_value, disabled: disabled, 'data-toggle': 'datetimepicker', 'data-target': "##{attribute_name}_datetimepicker" }
|
10
8
|
data = options[:data] || {}
|
11
9
|
data.keys.each do |d|
|
12
10
|
hash["data-#{d.to_s.dasherize}".to_sym] = data[d]
|
@@ -26,7 +24,7 @@ class DateTimeInput < SimpleForm::Inputs::Base
|
|
26
24
|
|
27
25
|
script = "".html_safe
|
28
26
|
unless disabled then
|
29
|
-
picker_options = options[:picker_options] || { "format"
|
27
|
+
picker_options = options[:picker_options] || { "format": "MM/DD/YYYY" }
|
30
28
|
|
31
29
|
script = """
|
32
30
|
<script>
|
@@ -41,4 +39,16 @@ class DateTimeInput < SimpleForm::Inputs::Base
|
|
41
39
|
|
42
40
|
all + script
|
43
41
|
end
|
42
|
+
|
43
|
+
def parse_value(raw_value, format)
|
44
|
+
return nil unless raw_value.present?
|
45
|
+
|
46
|
+
format ||= case raw_value.class.name
|
47
|
+
when 'Time', 'ActiveSupport::TimeWithZone'
|
48
|
+
'%m/%d/%Y %H:%M %p'
|
49
|
+
else
|
50
|
+
'%m/%d/%Y'
|
51
|
+
end
|
52
|
+
raw_value.strftime(format)
|
53
|
+
end
|
44
54
|
end
|
data/lib/olivander/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: five-two-nw-olivander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.
|
4
|
+
version: 0.2.0.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Dennis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chartkick
|