From 77aa949cd110b814b327e183a1b757b61e489b63 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 13 Aug 2019 12:56:52 -0400 Subject: [PATCH] LP1840050 org unit admin UI WIP Signed-off-by: Bill Erickson --- .../app/staff/admin/server/org-unit.component.html | 22 ++++++---- .../app/staff/admin/server/org-unit.component.ts | 47 +++++++++++++++------- 2 files changed, 47 insertions(+), 22 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.html b/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.html index 22ae883593..798538ce84 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.html @@ -42,20 +42,28 @@
Open Time
Close Time
-
-
Monday
+
+
+ Monday + Tuesday + Wednesday + Thursday + Friday + Saturday + Sunday +
+ [ngModel]="hours(dow, 'open')" min="00:00:00" max="23:59:59" + (ngModelChange)="hours(dow, 'open', $event)"/>
+ [ngModel]="hours(dow, 'close')" min="00:00:00" max="23:59:59" + (ngModelChange)="hours(dow, 'close', $event)"/>
-
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.ts index 0446ecf62f..83abd090f9 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.ts @@ -56,14 +56,7 @@ export class OrgUnitComponent implements OnInit { if (!orgNode) { return; } if (!orgNode.hours_of_operation()) { - const hours = this.idl.create('aouhoo'); - hours.org_unit(orgNode.id()); - hours.isnew(true); - [0, 1, 2, 3, 4, 5, 6].forEach(dow => { - hours[`dow_${dow}_open`]('09:00:00'); - hours[`dow_${dow}_close`]('17:00:00'); - }); - orgNode.hours_of_operation(hours); + this.generateHours(orgNode); } // TODO addresses @@ -89,14 +82,38 @@ export class OrgUnitComponent implements OnInit { this.selected = $event; } - hours(): IdlObject { - if (this.selected) { - console.log('we have org ', this.selected.callerData.orgUnit); - console.log('we have hours ', this.selected.callerData.orgUnit.hours_of_operation()); - return this.selected.callerData.orgUnit.hours_of_operation(); + generateHours(org: IdlObject) { + const hours = this.idl.create('aouhoo'); + hours.org_unit(org.id()); + hours.isnew(true); + + [0, 1, 2, 3, 4, 5, 6].forEach(dow => { + this.hours(dow, 'open', '09:00:00', hours); + this.hours(dow, 'close', '17:00:00', hours); + }); + + org.hours_of_operation(hours); + } + + // if a 'value' is passed, it will be applied to the optional + // hours-of-operation object, otherwise the hours on the currently + // selected org unit. + hours(dow: number, which: 'open' | 'close', value?: string, hoo?: IdlObject): IdlObject { + if (!hoo && !this.selected) { return null; } + + const hours = hoo || this.selected.callerData.orgUnit.hours_of_operation(); + + if (value) { + hours[`dow_${dow}_${which}`](value); + hours.ischanged(true); } - return this.selected ? - this.selected.callerData.orgUnit.hours_of_operation() : null; + + return hours[`dow_${dow}_${which}`](); + } + + closedOn(dow: number) { + this.hours(dow, 'open', '00:00:00'); + this.hours(dow, 'close', '00:00:00'); } postUpdate(message: StringComponent) { -- 2.11.0