Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(date-time picker): ability to remove now button #2848

Merged
merged 8 commits into from
Nov 8, 2021
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