[hourStep]="1"
[minuteStep]="minuteStep || 15" >
</ngb-timepicker>
- <span *ngIf="showTZ" class="badge badge-info">America/Los_Angeles</span>
+ <span *ngIf="showTZ" class="badge badge-info">{{ timezone || 'America/Los_Angeles'}}</span>
<button i18n class="btn btn-success" (click)="dtPicker.close()">Choose time</button>
</ng-template>
-
templateUrl: './datetime-select.component.html'
})
export class DateTimeSelectComponent implements OnInit {
- @Input() formModel: any; // External model bound back to parent
@Input() domId = '';
@Input() fieldName: string;
@Input() required: boolean;
@Input() minuteStep: number;
@Input() showTZ = true;
+ @Input() timezone: string;
@Input() initialIso: string;
- @Output() formModelChange = new EventEmitter();
+ @Output() onChangeAsIso = new EventEmitter();
dateTime: any; // Used internally on internal input
timeModel: NgbTimeStruct;
}
ngOnInit() {
- const start = this.formModel ? Moment(this.formModel) : Moment();
+ const start = this.initialIso ? Moment(this.initialIso) : Moment();
this.setDefaultDate(start);
this.setDefaultTime(start);
- if (this.formModel) {
+ if (this.initialIso) {
this.modelChanged(null);
}
}
// Set component view value
this.dateTime = Moment(newDate).format('MM/D/YYYY h:mm A');
// Update form passed in view value
- this.formModelChange.emit(Moment(newDate));
+ this.onChangeAsIso.emit(Moment(newDate).toISOString);
}
}
</eg-date-select>
</ng-container>
+ <ng-container *ngSwitchCase="'timestamp-timepicker'">
+ <eg-datetime-select
+ domId="{{idPrefix}}-{{field.name}}"
+ (onChangeAsIso)="record[field.name]($event)"
+ initialIso="{{record[field.name]()}}">
+ </eg-datetime-select>
+ </ng-container>
+
<ng-container *ngSwitchCase="'org_unit'">
<eg-org-select
placeholder="{{field.label}}..."
(click)="cancel()" i18n>Cancel</button>
</div>
</ng-template>
+
@Input() requiredFieldsList: string[] = [];
@Input() requiredFields: string; // comma-separated string version
+ // list of timezone fields that should display with a timepicker
+ @Input() datetimeFieldsList: string[] = [];
+ @Input() datetimeFields: string; // comma-separated string version
+
// list of org_unit fields where a default value may be applied by
// the org-select if no value is present.
@Input() orgDefaultAllowedList: string[] = [];
if (this.requiredFields) {
this.requiredFieldsList = this.requiredFields.split(/,/);
}
+ if (this.datetimeFields) {
+ this.datetimeFieldsList = this.requiredFields.split(/,/);
+ }
if (this.orgDefaultAllowed) {
this.orgDefaultAllowedList = this.orgDefaultAllowed.split(/,/);
}
promise = this.wireUpCombobox(field);
+ } else if (field.datatype === 'timestamp') {
+ field.datetime = this.datetimeFieldsList.includes(field.name);
} else if (field.datatype === 'org_unit') {
field.orgDefaultAllowed =
this.orgDefaultAllowedList.includes(field.name);
return 'template';
}
+ if ( field.datatype === 'timestamp' && field.datetime ) {
+ return 'timestamp-timepicker';
+ }
+
// Some widgets handle readOnly for us.
if ( field.datatype === 'timestamp'
|| field.datatype === 'org_unit'
return 'readonly-money';
}
- if ((field.datatype === 'link' || field.linkedValues) && field.class === 'au') {
+ if ((field.datatype === 'link' || field.linkedValues.length) && field.class === 'au') {
return 'readonly-au';
}
private router: Router,
private pcrud: PcrudService,
private patron: PatronService,
- private store: ServerStoreService,
+ private store: ServerStoreService,
private toast: ToastService
) {
}
<eg-fm-record-editor #editDialog
idlClass="bresv"
+ datetimeFields="start_time,end_time"
hiddenFields="xact_finish,cancel_time,booking_interval"
readonlyFields="usr,xact_start,request_time,capture_time,pickup_time,return_time,capture_staff,target_resource_type,current_resource,target_resource,unrecovered,request_library,pickup_library,fine_interval,fine_amount,max_fine">
</eg-fm-record-editor>
</eg-confirm-dialog>
<eg-no-timezone-set-dialog #noTimezoneSetDialog>
</eg-no-timezone-set-dialog>
+