Skip to content

Commit

Permalink
Merge 1f30ab3 into 656ed0f
Browse files Browse the repository at this point in the history
  • Loading branch information
unumtresocto committed Apr 20, 2021
2 parents 656ed0f + 1f30ab3 commit f17efc2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Component,
ComponentFactoryResolver,
Inject,
Injector,
Input,
OnInit,
Optional,
Expand Down Expand Up @@ -88,10 +89,11 @@ export class NbDateTimePickerComponent<D> extends NbBasePickerComponent<D, D, Nb
triggerStrategyBuilder: NbTriggerStrategyBuilderService,
overlay: NbOverlayService,
cfr: ComponentFactoryResolver,
injector: Injector,
dateService: NbDateService<D>,
@Optional() @Inject(NB_DATE_SERVICE_OPTIONS) dateServiceOptions,
protected calendarWithTimeModelService: NbCalendarTimeModelService<D>) {
super(document, positionBuilder, triggerStrategyBuilder, overlay, cfr, dateService, dateServiceOptions);
super(document, positionBuilder, triggerStrategyBuilder, overlay, cfr, injector, dateService, dateServiceOptions);
}

ngOnInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
OnInit,
SimpleChanges,
Optional,
Injector,
} from '@angular/core';
import { takeUntil } from 'rxjs/operators';
import { Observable, ReplaySubject, Subject } from 'rxjs';
Expand Down Expand Up @@ -193,6 +194,7 @@ export abstract class NbBasePicker<D, T, P> extends NbDatepicker<T> {
protected positionBuilder: NbPositionBuilderService,
protected triggerStrategyBuilder: NbTriggerStrategyBuilderService,
protected cfr: ComponentFactoryResolver,
protected injector: Injector,
protected dateService: NbDateService<D>,
protected dateServiceOptions,
) {
Expand Down Expand Up @@ -281,7 +283,9 @@ export abstract class NbBasePicker<D, T, P> extends NbDatepicker<T> {
}

protected openDatepicker() {
this.container = this.ref.attach(new NbComponentPortal(NbDatepickerContainerComponent, null, null, this.cfr));
this.container = this.ref.attach(
new NbComponentPortal(NbDatepickerContainerComponent, null, this.injector, this.cfr),
);
this.instantiatePicker();
this.subscribeOnValueChange();
this.writeQueue();
Expand Down Expand Up @@ -471,10 +475,11 @@ export class NbBasePickerComponent<D, T, P> extends NbBasePicker<D, T, P>
triggerStrategyBuilder: NbTriggerStrategyBuilderService,
overlay: NbOverlayService,
cfr: ComponentFactoryResolver,
injector: Injector,
dateService: NbDateService<D>,
@Optional() @Inject(NB_DATE_SERVICE_OPTIONS) dateServiceOptions,
) {
super(overlay, positionBuilder, triggerStrategyBuilder, cfr, dateService, dateServiceOptions);
super(overlay, positionBuilder, triggerStrategyBuilder, cfr, injector, dateService, dateServiceOptions);
}

ngOnInit() {
Expand Down
16 changes: 16 additions & 0 deletions src/framework/theme/components/timepicker/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ import { InjectionToken } from '@angular/core';

export const NB_TIME_PICKER_CONFIG = new InjectionToken('NB_TIME_PICKER_CONFIG');

export const NB_TIME_PICKER_LOCALIZATION = new InjectionToken<NbTimepickerLocalization>('NB_TIME_PICKER_LOCALIZATION', {
providedIn: 'root',
factory: () => {
return {
hoursText: 'Hr', minutesText: 'Min', secondsText: 'Sec', ampmText: 'Am/Pm',
}
},
});

export interface NbTimePickerConfig {
twelveHoursFormat?: boolean,
format?: string,
Expand All @@ -21,3 +30,10 @@ export interface NbSelectedTimePayload<D> {
time: D,
save?: boolean,
}

export interface NbTimepickerLocalization {
hoursText: string,
minutesText: string,
secondsText: string,
ampmText: string,
}
19 changes: 12 additions & 7 deletions src/framework/theme/components/timepicker/timepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
EventEmitter,
Inject,
Input,
LOCALE_ID,
OnChanges,
OnInit,
Output,
Expand All @@ -21,7 +20,13 @@ import { NbPlatform } from '../cdk/platform/platform-service';
import { NbDateService, NbDayPeriod } from '../calendar-kit/services/date.service';
import { range, rangeFromTo } from '../calendar-kit/helpers';
import { NbCalendarTimeModelService } from '../calendar-kit/services/calendar-time-model.service';
import { NB_TIME_PICKER_CONFIG, NbSelectedTimePayload, NbTimePickerConfig } from './model';
import {
NB_TIME_PICKER_CONFIG,
NB_TIME_PICKER_LOCALIZATION,
NbSelectedTimePayload,
NbTimePickerConfig,
NbTimepickerLocalization,
} from './model';

interface NbTimePartOption {
value: number,
Expand Down Expand Up @@ -146,10 +151,10 @@ export class NbTimePickerComponent<D> implements OnChanges, OnInit {
*/
@Input() showFooter: boolean = true;
@Input() applyButtonText: string;
@Input() hoursText = 'Hr';
@Input() minutesText = 'Min';
@Input() secondsText = 'Sec';
@Input() ampmText = 'Am/Pm';
@Input() hoursText = this.tokens.hoursText;
@Input() minutesText = this.tokens.minutesText;
@Input() secondsText = this.tokens.secondsText;
@Input() ampmText = this.tokens.ampmText;
@Input() currentTimeButtonText: string;

/**
Expand All @@ -159,8 +164,8 @@ export class NbTimePickerComponent<D> implements OnChanges, OnInit {
@ViewChild(NbPortalDirective, {static: true}) portal: NbPortalDirective;

constructor(@Inject(NB_TIME_PICKER_CONFIG) protected config: NbTimePickerConfig,
@Inject(NB_TIME_PICKER_LOCALIZATION) protected tokens: NbTimepickerLocalization,
protected platformService: NbPlatform,
@Inject(LOCALE_ID) locale: string,
public cd: ChangeDetectorRef,
protected calendarTimeModelService: NbCalendarTimeModelService<D>,
protected dateService: NbDateService<D>) {
Expand Down

0 comments on commit f17efc2

Please sign in to comment.