From dc6f4bc828d399a6466553e292bb5177b781426f Mon Sep 17 00:00:00 2001 From: Kyle Huckins Date: Wed, 19 Jan 2022 03:41:30 +0000 Subject: [PATCH] lp136764 Split Hours Of Operation - sql upgrade files - Introduce optional secondary set of hours for aouhoo object - Update Angular UI to cover split hours - Display secondary hours on OPAC Signed-off-by: Kyle Huckins --- Open-ILS/examples/fm_IDL.xml | 14 +++++ .../app/staff/admin/server/org-unit.component.html | 54 +++++++++++++---- .../app/staff/admin/server/org-unit.component.ts | 65 +++++++++++++++++---- .../lib/OpenILS/Application/Storage/CDBI/actor.pm | 4 +- Open-ILS/src/sql/Pg/005.schema.actors.sql | 17 +++++- .../XXXX-lp1396764-split-hours-of-operation.sql | 21 +++++++ .../opac/parts/library/hours.tt2 | 68 ++++++++++++++++++++++ 7 files changed, 218 insertions(+), 25 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX-lp1396764-split-hours-of-operation.sql diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 6d8199f011..1ad0e5e297 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -3701,6 +3701,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + + + + + + + + + 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 294d62c2bf..f169fb49e1 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 @@ -62,12 +62,18 @@ [disabled]="currentOrg().isnew()">
-
-
Open Time
-
Close Time
+
+
+
+ Split Hours? +
+
+
Open Time
+
Close Time
+
-
+
Monday Tuesday Wednesday @@ -76,20 +82,46 @@ Saturday Sunday
-
+
+
+ +
+
+
+ [ngModel]="hours(dow, 'open', false)" min="00:00:00" max="23:59:59" + (ngModelChange)="hours(dow, 'open', false, $event)"/>
-
+
+ [ngModel]="hours(dow, 'close', false)" min="00:00:00" max="23:59:59" + (ngModelChange)="hours(dow, 'close', false, $event)"/>
-
+
+ +
+ +
+
+ +
; @ViewChild('editString', { static: true }) editString: StringComponent; @ViewChild('errorString', { static: true }) errorString: StringComponent; @ViewChild('delConfirm', { static: true }) delConfirm: ConfirmDialogComponent; @@ -34,8 +35,16 @@ export class OrgUnitComponent implements OnInit { ngOnInit() { + this.dowArray = [this.dowObj(0), this.dowObj(1), this.dowObj(2), this.dowObj(3), this.dowObj(4), this.dowObj(5), this.dowObj(6)] this.loadAouTree(this.org.root().id()); } + + dowObj(dow) { + return { + id: dow, + isSplit: false + }; + } tabChanged(evt: NgbTabChangeEvent) { const tab = evt.nextId; @@ -121,9 +130,9 @@ export class OrgUnitComponent implements OnInit { hours.id(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); + this.dowArray.forEach(dow => { + this.hours(dow['id'], 'open', false, '09:00:00', hours); + this.hours(dow['id'], 'close', false, '17:00:00', hours); }); org.hours_of_operation(hours); @@ -132,29 +141,61 @@ export class OrgUnitComponent implements OnInit { // 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): string { + hours(dow: number, which: 'open' | 'close', isSecondary: boolean, value?: string, hoo?: IdlObject): string { 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); + if (isSecondary) { + if (value) { + hours[`dow_${dow}_${which}_2`](value); + hours.ischanged(true); + } + return hours[`dow_${dow}_${which}_2`](); + } else { + if (value) { + hours[`dow_${dow}_${which}`](value); + hours.ischanged(true); + } + return hours[`dow_${dow}_${which}`](); } + } + + addNote(dow: number, value?: string, hoo?: IdlObject): string { + if (!hoo && !this.selected) { return null; } - return hours[`dow_${dow}_${which}`](); + const hours = hoo || this.selected.callerData.orgUnit.hours_of_operation(); + console.log(hours); + //if (hours.note()) return hours.note()[dow]; } isClosed(dow: number): boolean { return ( - this.hours(dow, 'open') === '00:00:00' && - this.hours(dow, 'close') === '00:00:00' + this.hours(dow, 'open', false) === '00:00:00' && + this.hours(dow, 'close', false) === '00:00:00' ); } closedOn(dow: number) { - this.hours(dow, 'open', '00:00:00'); - this.hours(dow, 'close', '00:00:00'); + this.hours(dow, 'open', false, '00:00:00'); + this.hours(dow, 'close', false, '00:00:00'); + } + + hasSplitHours(dow: number) { + this.dowArray.forEach(dow => { + if (this.hours(dow['id'], 'open', true) !== '00:00:00') dow['isSplit'] = true; + if (this.hours(dow['id'], 'close', true) !== '00:00:00') dow['isSplit'] = true; + }); + } + + clearSplitHours(dow: number, ticked: boolean) { + if (!ticked) { + this.hours(this.dowArray[dow]['id'], 'open', true, '00:00:00'); + this.hours(this.dowArray[dow]['id'], 'close', true, '00:00:00'); + } else { + this.hours(this.dowArray[dow]['id'], 'open', true, '00:00:00'); + this.hours(this.dowArray[dow]['id'], 'close', true, '00:00:00'); + } } saveHours() { diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI/actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI/actor.pm index 6bf0481662..1089355a13 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI/actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI/actor.pm @@ -92,7 +92,9 @@ __PACKAGE__->table( 'actor_hours_of_operation' ); __PACKAGE__->columns( Primary => qw/id/); __PACKAGE__->columns( Essential => qw/dow_0_open dow_0_close dow_1_open dow_1_close dow_2_open dow_2_close dow_3_open dow_3_close dow_4_open dow_4_close dow_5_open dow_5_close - dow_6_open dow_6_close/); + dow_6_open dow_6_close dow_0_open_2 dow_0_close_2 dow_1_open_2 dow_1_close_2 dow_2_open_2 dow_2_close_2 + dow_3_open_2 dow_3_close_2 dow_4_open_2 dow_4_close_2 dow_5_open_2 dow_5_close_2 + dow_6_open_2 dow_6_close_2/); #------------------------------------------------------------------------------- package actor::org_unit::closed_date; diff --git a/Open-ILS/src/sql/Pg/005.schema.actors.sql b/Open-ILS/src/sql/Pg/005.schema.actors.sql index b4afa7f0f9..3a488f9fcc 100644 --- a/Open-ILS/src/sql/Pg/005.schema.actors.sql +++ b/Open-ILS/src/sql/Pg/005.schema.actors.sql @@ -465,7 +465,22 @@ CREATE TABLE actor.hours_of_operation ( dow_5_open TIME NOT NULL DEFAULT '09:00', dow_5_close TIME NOT NULL DEFAULT '17:00', dow_6_open TIME NOT NULL DEFAULT '09:00', - dow_6_close TIME NOT NULL DEFAULT '17:00' + dow_6_close TIME NOT NULL DEFAULT '17:00', + dow_0_close_2 TIME NOT NULL DEFAULT '00:00', + dow_0_open_2 TIME NOT NULL DEFAULT '00:00', + dow_1_close_2 TIME NOT NULL DEFAULT '00:00', + dow_1_open_2 TIME NOT NULL DEFAULT '00:00', + dow_2_close_2 TIME NOT NULL DEFAULT '00:00', + dow_2_open_2 TIME NOT NULL DEFAULT '00:00', + dow_3_close_2 TIME NOT NULL DEFAULT '00:00', + dow_3_open_2 TIME NOT NULL DEFAULT '00:00', + dow_4_close_2 TIME NOT NULL DEFAULT '00:00', + dow_4_open_2 TIME NOT NULL DEFAULT '00:00', + dow_5_close_2 TIME NOT NULL DEFAULT '00:00', + dow_5_open_2 TIME NOT NULL DEFAULT '00:00', + dow_6_close_2 TIME NOT NULL DEFAULT '00:00', + dow_6_open_2 TIME NOT NULL DEFAULT '00:00' + ); COMMENT ON TABLE actor.hours_of_operation IS $$ When does this org_unit usually open and close? (Variations diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX-lp1396764-split-hours-of-operation.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX-lp1396764-split-hours-of-operation.sql new file mode 100644 index 0000000000..1327b9a403 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX-lp1396764-split-hours-of-operation.sql @@ -0,0 +1,21 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +ALTER TABLE actor.hours_of_operation + ADD COLUMN dow_0_close_2 TIME NOT NULL DEFAULT '00:00', + ADD COLUMN dow_0_open_2 TIME NOT NULL DEFAULT '00:00', + ADD COLUMN dow_1_close_2 TIME NOT NULL DEFAULT '00:00', + ADD COLUMN dow_1_open_2 TIME NOT NULL DEFAULT '00:00', + ADD COLUMN dow_2_close_2 TIME NOT NULL DEFAULT '00:00', + ADD COLUMN dow_2_open_2 TIME NOT NULL DEFAULT '00:00', + ADD COLUMN dow_3_close_2 TIME NOT NULL DEFAULT '00:00', + ADD COLUMN dow_3_open_2 TIME NOT NULL DEFAULT '00:00', + ADD COLUMN dow_4_close_2 TIME NOT NULL DEFAULT '00:00', + ADD COLUMN dow_4_open_2 TIME NOT NULL DEFAULT '00:00', + ADD COLUMN dow_5_close_2 TIME DEFAULT '00:00', + ADD COLUMN dow_5_open_2 TIME DEFAULT '00:00', + ADD COLUMN dow_6_close_2 TIME DEFAULT '00:00', + ADD COLUMN dow_6_open_2 TIME DEFAULT '00:00' + +COMMIT; \ No newline at end of file diff --git a/Open-ILS/src/templates-bootstrap/opac/parts/library/hours.tt2 b/Open-ILS/src/templates-bootstrap/opac/parts/library/hours.tt2 index 9ff96dd9c3..23298596ba 100755 --- a/Open-ILS/src/templates-bootstrap/opac/parts/library/hours.tt2 +++ b/Open-ILS/src/templates-bootstrap/opac/parts/library/hours.tt2 @@ -22,7 +22,18 @@
[% l('Monday: [_1] - [_2]', '', '') -%] +[%- + open_2 = today _ ctx.hours.dow_0_open_2; + close_2 = today _ ctx.hours.dow_0_close_2; + IF open_2 != close_2; +%] +[% + l('; [_1] - [_2]', '', + '') -%] +[%- END %]
+ + [%- END %] [%- @@ -35,6 +46,17 @@
[% l('Tuesday: [_1] - [_2]', '', '') -%] + + +[%- + open_2 = today _ ctx.hours.dow_1_open_2; + close_2 = today _ ctx.hours.dow_1_close_2; + IF open_2 != close_2; +%] +[% + l('; [_1] - [_2]', '', + '') -%] +[%- END %]
[%- END %] @@ -48,6 +70,15 @@
[% l('Wednesday: [_1] - [_2]', '', '') -%] +[%- + open_2 = today _ ctx.hours.dow_2_open_2; + close_2 = today _ ctx.hours.dow_2_close_2; + IF open_2 != close_2; +%] +[% + l('; [_1] - [_2]', '', + '') -%] +[%- END %]
[%- END %] @@ -61,6 +92,15 @@
[% l('Thursday: [_1] - [_2]', '', '') -%] +[%- + open_2 = today _ ctx.hours.dow_3_open_2; + close_2 = today _ ctx.hours.dow_3_close_2; + IF open_2 != close_2; +%] +[% + l('; [_1] - [_2]', '', + '') -%] +[%- END %]
[%- END %] @@ -74,6 +114,15 @@
[% l('Friday: [_1] - [_2]', '', '') -%] +[%- + open_2 = today _ ctx.hours.dow_4_open_2; + close_2 = today _ ctx.hours.dow_4_close_2; + IF open_2 != close_2; +%] +[% + l('; [_1] - [_2]', '', + '') -%] +[%- END %]
[%- END %] @@ -87,6 +136,15 @@
[% l('Saturday: [_1] - [_2]', '', '') -%] +[%- + open_2 = today _ ctx.hours.dow_5_open_2; + close_2 = today _ ctx.hours.dow_5_close_2; + IF open_2 != close_2; +%] +[% + l('; [_1] - [_2]', '', + '') -%] +[%- END %]
[%- END %] @@ -100,6 +158,16 @@
[% l('Sunday: [_1] - [_2]', '', '') -%] + +[%- + open_2 = today _ ctx.hours.dow_6_open_2; + close_2 = today _ ctx.hours.dow_6_close_2; + IF open_2 != close_2; +%] +[% + l('; [_1] - [_2]', '', + '') -%] +[%- END %]
[%- END %]
\ No newline at end of file -- 2.11.0