From 1f4d0d0f0d765e0e72b6755e3805151044021b1e Mon Sep 17 00:00:00 2001 From: Sarah Lafer Date: Wed, 12 Oct 2022 13:28:32 +0200 Subject: [PATCH 1/4] Add documentation for time field --- src/2.0/fields.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/2.0/fields.md b/src/2.0/fields.md index b5a491c..0253b31 100644 --- a/src/2.0/fields.md +++ b/src/2.0/fields.md @@ -120,7 +120,18 @@ By default, flatpickr is [disabled on mobile](https://flatpickr.js.org/mobile-su The `DateTime` field is similar to the Date field with two new attributes. `time_24hr` tells flatpickr to use 24 hours format and `timezone` to tell it in what timezone to display the time. By default it uses your browser's timezone. ```ruby -filed :created_at, as: :date_time, name: 'User joined', picker_format: 'Y-m-d H:i', format: :db, time_24hr: true, timezone: 'PST' +field :created_at, as: :date_time, name: 'User joined', picker_format: 'Y-m-d H:i', format: :db, time_24hr: true, timezone: 'PST' +``` + +## Time + + +DateTime field + +The `Time` field is similar to the DateTime field and uses the time picker of flatpickr (without the calendar). `time_24hr` tells flatpickr to use 24 hours format. Unlike in the `DateTime` field, the time always stays the same and doesn't change depending on your browser's timezone. + +```ruby +field :starting_at, as: :time, picker_format: 'H:i', format: "HH:mm", time_24hr: true ``` ## External image From b0c61779fe244636aa3c2dddbb8e5cd6005cf8bf Mon Sep 17 00:00:00 2001 From: Sarah Lafer Date: Wed, 12 Oct 2022 13:39:56 +0200 Subject: [PATCH 2/4] Update wording --- src/2.0/fields.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/2.0/fields.md b/src/2.0/fields.md index 0253b31..9435d61 100644 --- a/src/2.0/fields.md +++ b/src/2.0/fields.md @@ -128,7 +128,7 @@ field :created_at, as: :date_time, name: 'User joined', picker_format: 'Y-m-d H: DateTime field -The `Time` field is similar to the DateTime field and uses the time picker of flatpickr (without the calendar). `time_24hr` tells flatpickr to use 24 hours format. Unlike in the `DateTime` field, the time always stays the same and doesn't change depending on your browser's timezone. +The `Time` field is similar to the DateTime field and uses the time picker of flatpickr (without the calendar). You can use the `time_24hr` option for flatpickr to use the 24-hour format. Unlike in the `DateTime` field, the time stays static and is independent of your browser's timezone. ```ruby field :starting_at, as: :time, picker_format: 'H:i', format: "HH:mm", time_24hr: true From 46a36123aae62672fa50140b961a0bad3984c3b4 Mon Sep 17 00:00:00 2001 From: Sarah Lafer Date: Wed, 12 Oct 2022 13:45:07 +0200 Subject: [PATCH 3/4] Move field down to stay in alphabetical order --- src/2.0/fields.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/2.0/fields.md b/src/2.0/fields.md index 9435d61..c45d48b 100644 --- a/src/2.0/fields.md +++ b/src/2.0/fields.md @@ -123,17 +123,6 @@ The `DateTime` field is similar to the Date field with two new attributes. `time field :created_at, as: :date_time, name: 'User joined', picker_format: 'Y-m-d H:i', format: :db, time_24hr: true, timezone: 'PST' ``` -## Time - - -DateTime field - -The `Time` field is similar to the DateTime field and uses the time picker of flatpickr (without the calendar). You can use the `time_24hr` option for flatpickr to use the 24-hour format. Unlike in the `DateTime` field, the time stays static and is independent of your browser's timezone. - -```ruby -field :starting_at, as: :time, picker_format: 'H:i', format: "HH:mm", time_24hr: true -``` - ## External image You may have a field in the database that holds the url to an image and you want to display that in Avo. This is where the `ExternalImage` field comes in to help. @@ -692,6 +681,17 @@ The `Textarea` field renders a `textarea` element and has the `rows` option that field :body, as: :textarea, rows: 5 ``` +## Time + + +DateTime field + +The `Time` field is similar to the DateTime field and uses the time picker of flatpickr (without the calendar). You can use the `time_24hr` option for flatpickr to use the 24-hour format. Unlike in the `DateTime` field, the time stays static and is independent of your browser's timezone. + +```ruby +field :starting_at, as: :time, picker_format: 'H:i', format: "HH:mm", time_24hr: true +``` + ## Trix Trix field From ba205592bc91a18ba17839a937d3dadbe1e49281 Mon Sep 17 00:00:00 2001 From: Sarah Lafer Date: Wed, 19 Oct 2022 13:01:34 +0200 Subject: [PATCH 4/4] Update text regarding relative option --- src/2.0/fields.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/2.0/fields.md b/src/2.0/fields.md index c45d48b..fdcf81e 100644 --- a/src/2.0/fields.md +++ b/src/2.0/fields.md @@ -686,7 +686,7 @@ field :body, as: :textarea, rows: 5 DateTime field -The `Time` field is similar to the DateTime field and uses the time picker of flatpickr (without the calendar). You can use the `time_24hr` option for flatpickr to use the 24-hour format. Unlike in the `DateTime` field, the time stays static and is independent of your browser's timezone. +The `Time` field is similar to the DateTime field and uses the time picker of flatpickr (without the calendar). You can use the `time_24hr` option for flatpickr to use the 24-hour format. Add the option `relative: false` if you want the time to stay absolute and not change based on the browser's timezone. ```ruby field :starting_at, as: :time, picker_format: 'H:i', format: "HH:mm", time_24hr: true