keystone_ui 0.50.1 → 0.51.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: 1dd732a6c6f357ad5faee4d6eaca18a520d52a4005806f0bd6b653d6eb802aa3
4
- data.tar.gz: c2f11d4b9ef0e3b47b1e558dc84ec1b605822fd5ba11cb1a0ba2e070d3bc2266
3
+ metadata.gz: 9019c6a86ac84b02bafebdd7accad68930d008d2cfc6a209049943357b8c3b09
4
+ data.tar.gz: 9798d91d98fe27f0a636e714bb0654497cf84d34426277bd967f41c5341cbaed
5
5
  SHA512:
6
- metadata.gz: 7bdf1f5074e92f8036456e4fd88d3615617225d4a75feb2e522b3396aa10daabffbb890f0b03272bb89ad1c39cb85068d6b731257961fe59d390e83d54a24f29
7
- data.tar.gz: fbdfd5f8b5e0ee67bfa0f954f8eb9d62b3eae0c0ef9152def74d7091a2709c72228d6c860adb1e5b9ead1a9c0c2ce0a04f9237d9ee57365b9efaf15b120e1520
6
+ metadata.gz: bbbfb7e25ce8ef96adcf7f1fa7c68b9e8f629684f20efeb4bbe94315aade2810a7dd2bf3472247ab6ac8aca669b8b823a136ffa621391f89ec4d591de7444093
7
+ data.tar.gz: 98676baf7a6028dc0e03f3f457c42856bd9690a0e8ec29c559bc247a02111d10ab2b84a8e840aca56571b2046fee2980bab5b71d62a6a1fe3ac23174d811d543
@@ -79,7 +79,7 @@ module Keystone
79
79
  options[:type] = Keystone::Ui::InputComponent::TYPE_MAP.fetch(@type)
80
80
  end
81
81
  options[:placeholder] = @placeholder unless @placeholder.nil?
82
- options[:value] = @value unless @value.nil?
82
+ options[:value] = Keystone::Ui::InputComponent.formatted_value(@type, @value) unless @value.nil?
83
83
  options[:min] = @min unless @min.nil?
84
84
  options[:max] = @max unless @max.nil?
85
85
  options[:step] = @step unless @step.nil?
@@ -12,9 +12,18 @@ module Keystone
12
12
  number: "number",
13
13
  email: "email",
14
14
  password: "password",
15
- date: "date"
15
+ date: "date",
16
+ datetime: "datetime-local"
16
17
  }.freeze
17
18
 
19
+ DATETIME_FORMAT = "%Y-%m-%dT%H:%M"
20
+
21
+ def self.formatted_value(type, value)
22
+ return value unless type == :datetime && value.respond_to?(:strftime)
23
+
24
+ value.strftime(DATETIME_FORMAT)
25
+ end
26
+
18
27
  def initialize(name:, type: :text, value: nil, placeholder: nil, disabled: false, min: nil, max: nil, step: nil)
19
28
  @name = name
20
29
  @type = type
@@ -42,7 +51,7 @@ module Keystone
42
51
  name: @name,
43
52
  class: classes
44
53
  }
45
- options[:value] = @value unless @value.nil?
54
+ options[:value] = self.class.formatted_value(@type, @value) unless @value.nil?
46
55
  options[:placeholder] = @placeholder unless @placeholder.nil?
47
56
  options[:disabled] = true if @disabled
48
57
  options[:min] = @min unless @min.nil?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.50.1"
4
+ VERSION = "0.51.0"
5
5
  end
@@ -268,7 +268,10 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
268
268
  expects. Set `multipart: true` when the form holds a file upload.
269
269
  - `ui_form_field(attribute:, label: nil, type: :text, required: false, hint: nil, placeholder: nil, min: nil, max: nil, step: nil, value: nil, options: [], errors: [], include_blank: nil, disabled: false, suggestions: [])`
270
270
  is the default way to render a field. `type:` is `:text` `:number`
271
- `:email` `:password` `:date` `:textarea` `:checkbox` `:select`.
271
+ `:email` `:password` `:date` `:datetime` `:textarea` `:checkbox` `:select`.
272
+ - A `:datetime` field is a `datetime-local` input for a date and a time of
273
+ day. A `Time` or `DateTime` given as `value:` is written as
274
+ `YYYY-MM-DDTHH:MM`, and a string is used as given.
272
275
  - `attribute:` is used as the input's `name` as given, so pass the full
273
276
  param name, such as `"quote[title]"`, and pass `label:` whenever it is a
274
277
  nested name. `label:` defaults to the attribute with underscores turned to
@@ -282,14 +285,14 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
282
285
  and `"1"` checked, and is checked when `value:` is `"1"`.
283
286
  - `suggestions:` is an array of strings the browser offers while typing, and
284
287
  the user can still type any value. It applies to `:text` `:number`
285
- `:email` `:password` `:date` and is ignored by the other types. Its list
288
+ `:email` `:password` `:date` `:datetime` and is ignored by the other types. Its list
286
289
  is identified by `attribute:`, so two fields with suggestions on one
287
290
  screen need different `attribute:` values.
288
291
  - A value that must be one of a fixed list is a `:select`, and a free value
289
292
  with common choices is a text field with `suggestions:`. Ask the developer
290
293
  which a field is and which values it offers.
291
294
  - `ui_input(name:, type: :text, value: nil, placeholder: nil, disabled: false, min: nil, max: nil, step: nil)`
292
- takes `:text` `:number` `:email` `:password` `:date`.
295
+ takes `:text` `:number` `:email` `:password` `:date` `:datetime`.
293
296
  `ui_textarea(name:, value: nil, rows: 3, placeholder: nil, disabled: false)`
294
297
  and `ui_select(name:, options: [], selected: nil, include_blank: nil, disabled: false)`
295
298
  are the bare forms of the other two. Use them only where a label does not
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keystone_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.50.1
4
+ version: 0.51.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider