Add time input to contribution form #146

Merged
raucao merged 4 commits from feauture/141-time_picker into master 2019-08-12 12:52:08 +00:00
raucao commented 2019-07-31 12:19:43 +00:00 (Migrated from github.com)

After adding it as a separate field, I figured out that we should use the same picker, because otherwise we'd have to keep the date in sync depending on the time zone. Zones are too messy in that regard, and the date is already normalized to UTC before creating the contribution record.

Edit: I forgot to split out the commit that adds proper labels to the same form, instead of relying on placeholders only (which is bad for accessibility as well as usability).

closes #141

After adding it as a separate field, I figured out that we should use the same picker, because otherwise we'd have to keep the date in sync depending on the time zone. Zones are too messy in that regard, and the date is already normalized to UTC before creating the contribution record. Edit: I forgot to split out the commit that adds proper labels to the same form, instead of relying on placeholders only (which is bad for accessibility as well as usability). closes #141
raucao (Migrated from github.com) reviewed 2019-07-31 12:25:16 +00:00
raucao (Migrated from github.com) commented 2019-07-31 12:25:16 +00:00

Someone has an idea for how to do this in the most simple and efficient way? /cc @galfert @fsmanuel

Someone has an idea for how to do this in the most simple and efficient way? /cc @galfert @fsmanuel
galfert (Migrated from github.com) reviewed 2019-07-31 14:19:04 +00:00
galfert (Migrated from github.com) commented 2019-07-31 14:19:04 +00:00

I think it works like this:

    const defaultDate = new Date();
    defaultDate.setHours(0, 0, 0, 0);
    this.set('defaultDate', defaultDate);

Unfortunately you can't just concatenate it (new Date().setHours(0, 0, 0, 0)), because setHours returns a timestamp.

I think it works like this: ```suggestion const defaultDate = new Date(); defaultDate.setHours(0, 0, 0, 0); this.set('defaultDate', defaultDate); ``` Unfortunately you can't just concatenate it (`new Date().setHours(0, 0, 0, 0)`), because `setHours` returns a timestamp.
galfert (Migrated from github.com) reviewed 2019-07-31 14:26:35 +00:00
galfert (Migrated from github.com) commented 2019-07-31 14:26:34 +00:00

Scrap my previous comment, I misread you wanted it to be the beginning of the day, not the current hour.

Since we already have moment in the project, I think the easiest way would be

    this.set('defaultDate', moment().startOf('hour').toDate());
Scrap my previous comment, I misread you wanted it to be the beginning of the day, not the current hour. Since we already have moment in the project, I think the easiest way would be ```suggestion this.set('defaultDate', moment().startOf('hour').toDate()); ```
raucao (Migrated from github.com) reviewed 2019-07-31 16:26:28 +00:00
raucao (Migrated from github.com) commented 2019-07-31 16:26:28 +00:00

Awesome, will try that. Thanks!

Awesome, will try that. Thanks!
raucao commented 2019-08-02 15:00:21 +00:00 (Migrated from github.com)

Added the missing import and fixed another issue. All ready to merge afaics.

Added the missing import and fixed another issue. All ready to merge afaics.
Sign in to join this conversation.