decide.nolog.cz/app/templates/components/create-options-datetime.hbs

105 lines
3.4 KiB
Handlebars
Raw Normal View History

<div class="cr-form-wrapper box">
{{#if errorMessage}}
<BsAlert type="warning">
{{t errorMessage}}
</BsAlert>
{{/if}}
<BsForm
@onSubmit={{action "submit"}}
@formLayout="horizontal"
@model={{this}}
novalidate
as |form|
>
<div class="days">
{{#each dates as |date index|}}
2016-06-08 18:42:26 +02:00
{{!
show summarized validation state for all times in a day
2016-06-08 18:42:26 +02:00
}}
2018-12-29 20:35:04 +01:00
<div
class={{if
(get daysValidationState date.day)
(concat "label-has-" (get daysValidationState date.day))
"label-has-no-validation"
}}
data-test-day={{date.day}}
2018-12-29 20:35:04 +01:00
>
<form.element
@label={{date.dayFormatted}}
{{!
show label only if it differ from label before
Nested-helpers are called first and object-at requires a positive integer
but returns undefined if an element with the passed in index does not exist.
Therefore we pass in array length if index is null. Cause index starting
by zero there can't be any element with an index === array.length.
}}
@invisibleLabel={{eq date.dayFormatted (get (object-at (if index (sub index 1) dates.length) dates) "dayFormatted")}}
@model={{date}}
@property="time"
class="option"
as |el|
>
<div class="input-group">
<el.control
@autofocus={{unless index true false}}
@onChange={{action this.inputChanged date}}
@placeholder="00:00"
@type="time"
@value={{el.value}}
{{on "focusout" (action this.validateInput date)}}
id={{el.id}}
/>
<div class="input-group-append">
<BsButton
@onClick={{action "deleteOption" date}}
@type="link"
2018-12-29 20:35:04 +01:00
class="delete"
{{! disable delete button if there is only one option }}
disabled={{lte dates.length 1}}
>
<span class="oi oi-trash" title={{t "create.options.button.delete.label"}} aria-hidden="true"></span>
2018-12-29 20:35:04 +01:00
<span class="sr-only">{{t "create.options.button.delete.label"}}</span>
</BsButton>
</div>
</div>
<BsButton
@onClick={{action "addOption" date}}
@type="link"
@size="sm"
class="add cr-option-menu__button cr-option-menu__add-button float-left"
>
<span class="oi oi-plus" title={{t "create.options.button.add.label"}} aria-hidden="true"></span>
<span class="sr-only">{{t "create.options.button.add.label"}}</span>
</BsButton>
</form.element>
</div>
{{/each}}
</div>
2016-05-18 22:18:36 +02:00
{{#if (gt groupedDates.length 1)}}
<form.element>
<BsButton
@onClick={{action "adoptTimesOfFirstDay"}}
@size="sm"
2018-12-29 20:35:04 +01:00
class="adopt-times-of-first-day"
>
2018-12-29 20:35:04 +01:00
{{t "create.options-datetime.copy-first-line"}}
</BsButton>
</form.element>
{{/if}}
<div class="row cr-steps-bottom-nav">
<div class="col-6 col-md-4 text-right">
<BackButton @onClick={{action "previousPage"}} />
</div>
<div class="col-6 col-md-8">
<NextButton />
</div>
</div>
</BsForm>
</div>