Skip to content

Commit

Permalink
[#49680] Today button missing when selecting "Between specific dates"…
Browse files Browse the repository at this point in the history
  • Loading branch information
dombesz authored and oliverguenther committed Aug 14, 2023
1 parent 3566735 commit daccef3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@
(input)="dateChange([$event.target.value, selectedDates[1] || ''])"
type="text"
class="op-baseline--date-input"/>
<button
slot="action"
type="button"
class="spot-link"
(click)="setToday('from')"
[textContent]="text.today">
</button>
</spot-form-field>

<spot-form-field
Expand All @@ -120,6 +127,13 @@
(input)="dateChange([selectedDates[0] || '', $event.target.value])"
type="text"
class="op-baseline--date-input"/>
<button
slot="action"
type="button"
class="spot-link"
(click)="setToday('to')"
[textContent]="text.today">
</button>
</spot-form-field>

<spot-form-field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export class OpBaselineComponent extends UntilDestroyedMixin implements OnInit {
to: this.I18n.t('js.baseline.to'),
date: this.I18n.t('js.label_date'),
time: this.I18n.t('js.baseline.time'),
today: this.I18n.t('js.label_today'),
moreInfoLink: enterpriseDocsUrl.website,
more_info_text: this.I18n.t('js.admin.enterprise.upsale.more_info'),
help_description: this.I18n.t('js.baseline.help_description'),
Expand Down Expand Up @@ -211,6 +212,17 @@ export class OpBaselineComponent extends UntilDestroyedMixin implements OnInit {
this.selectedOffsets = [this.userOffset, this.userOffset];
}

public setToday(key:string):void {
const today = moment().format('YYYY-MM-DD');
// When setting the "from" date to today, the "to" date must also be set to today,
// because we do not allow future dates, meaning "to" cannot be anything else but today.
if (key === 'from') {
this.selectedDates[0] = today;
}

this.selectedDates[1] = today;
}

public onSubmit(e:Event):void {
e.preventDefault();
this.onSave();
Expand Down

0 comments on commit daccef3

Please sign in to comment.