adding datetime-select to fmeditor
authorJane Sandberg <sandbej@linnbenton.edu>
Wed, 27 Mar 2019 03:10:37 +0000 (20:10 -0700)
committerJane Sandberg <sandbej@linnbenton.edu>
Wed, 27 Mar 2019 03:14:10 +0000 (20:14 -0700)
Open-ILS/src/eg2/src/app/share/datetime-select/datetime-select.component.html
Open-ILS/src/eg2/src/app/share/datetime-select/datetime-select.component.ts
Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.html
Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts
Open-ILS/src/eg2/src/app/staff/booking/manage-reservations.component.ts
Open-ILS/src/eg2/src/app/staff/booking/reservations-grid.component.html

index 96b17e9..ee00660 100644 (file)
@@ -43,7 +43,6 @@
     [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>
-
index c11ecfa..aa8eb98 100644 (file)
@@ -10,16 +10,16 @@ import { NgbTimeStruct, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
     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;
@@ -29,11 +29,11 @@ export class DateTimeSelectComponent implements OnInit {
     }
 
     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);
         }
     }
@@ -70,7 +70,7 @@ export class DateTimeSelectComponent implements OnInit {
             // 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);
         }
     }
 
index 31a3cd7..cacd278 100644 (file)
               </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>
+
index c8933a7..007891a 100644 (file)
@@ -109,6 +109,10 @@ export class FmRecordEditorComponent
     @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[] = [];
@@ -192,6 +196,9 @@ export class FmRecordEditorComponent
         if (this.requiredFields) {
             this.requiredFieldsList = this.requiredFields.split(/,/);
         }
+        if (this.datetimeFields) {
+            this.datetimeFieldsList = this.requiredFields.split(/,/);
+        }
         if (this.orgDefaultAllowed) {
             this.orgDefaultAllowedList = this.orgDefaultAllowed.split(/,/);
         }
@@ -355,6 +362,8 @@ export class FmRecordEditorComponent
 
             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);
@@ -465,6 +474,10 @@ export class FmRecordEditorComponent
             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'
@@ -477,7 +490,7 @@ export class FmRecordEditorComponent
                 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';
             }
 
index 2f69592..6f771d0 100644 (file)
@@ -36,7 +36,7 @@ export class ManageReservationsComponent implements OnInit {
         private router: Router,
         private pcrud: PcrudService,
         private patron: PatronService,
-       private store: ServerStoreService,
+        private store: ServerStoreService,
         private toast: ToastService
     ) {
     }
index 1a26a73..7b48afa 100644 (file)
@@ -36,6 +36,7 @@
 
 <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>
@@ -46,3 +47,4 @@
 </eg-confirm-dialog>
 <eg-no-timezone-set-dialog #noTimezoneSetDialog>
 </eg-no-timezone-set-dialog>
+