Skip to content

Commit

Permalink
feat(date-time picker): ability to remove now button (#2848)
Browse files Browse the repository at this point in the history
  • Loading branch information
evtkhvch committed Nov 8, 2021
1 parent 1c02e15 commit a2c9d10
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
@import '../../../../styles/core/mixins';

:host {
display: flex;
justify-content: space-between;

.apply-text-button {
@include nb-ltr(margin-left, auto);
@include nb-rtl(margin-right, auto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from
selector: 'nb-calendar-actions',
template: `
<button
*ngIf="showCurrentTimeButton"
nbButton
ghost
status="primary"
size="small"
(click)="setCurrentTime.emit()">
{{ currentTimeText }}</button>
<button
class="apply-text-button"
nbButton
status="primary"
size="small"
Expand Down Expand Up @@ -41,6 +43,8 @@ export class NbCalendarActionsComponent {
};
_currentTimeButtonText = 'now';

@Input() showCurrentTimeButton: boolean;

@Output() setCurrentTime: EventEmitter<void> = new EventEmitter();
@Output() saveValue: EventEmitter<void> = new EventEmitter();
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import { NbTimePickerComponent } from '../timepicker/timepicker.component';
<nb-calendar-actions
[applyButtonText]="applyButtonText"
[currentTimeButtonText]="currentTimeButtonText"
[showCurrentTimeButton]="showCurrentTimeButton"
(setCurrentTime)="saveCurrentTime()"
(saveValue)="saveValue()"
></nb-calendar-actions>
Expand Down Expand Up @@ -109,6 +110,8 @@ export class NbCalendarWithTimeComponent<D> extends NbCalendarComponent<D> imple

@Input() currentTimeButtonText: string;

@Input() showCurrentTimeButton: boolean;

@ViewChild(NbPortalOutletDirective) portalOutlet: NbPortalOutletDirective;
@ViewChild(NbTimePickerComponent) timepicker: NbTimePickerComponent<D>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export class NbDateTimePickerComponent<D> extends NbBasePickerComponent<D, D, Nb
@Input() title: string;
@Input() applyButtonText: string;
@Input() currentTimeButtonText: string;
@Input() showCurrentTimeButton = true;

/**
* Defines 12 hours format like '07:00 PM'.
Expand Down Expand Up @@ -134,6 +135,7 @@ export class NbDateTimePickerComponent<D> extends NbBasePickerComponent<D, D, Nb
this.picker.title = this.title;
this.picker.applyButtonText = this.applyButtonText;
this.picker.currentTimeButtonText = this.currentTimeButtonText;
this.picker.showCurrentTimeButton = this.showCurrentTimeButton;

if (this.twelveHoursFormat) {
this.picker.timeFormat = this.dateService.getTwelveHoursFormat();
Expand Down

0 comments on commit a2c9d10

Please sign in to comment.