lp1396764 - Hourse of Operation Note Field
authorKyle Huckins <khuckins@catalyte.io>
Mon, 4 Apr 2022 09:13:57 +0000 (09:13 +0000)
committerMichele Morgan <mmorgan@noblenet.org>
Thu, 27 Oct 2022 13:39:57 +0000 (09:39 -0400)
- Add a note field to each day of the week for the Hours of Operation object
- Display any existing notes note in the OPAC after their specified day

Signed-off-by: Kyle Huckins <khuckins@catalyte.io>
Signed-off-by: Michele Morgan <mmorgan@noblenet.org>

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.html
Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.ts
Open-ILS/src/sql/Pg/005.schema.actors.sql
Open-ILS/src/sql/Pg/upgrade/xxxx.schema.lp1396764-hours-of-operation-note.sql [new file with mode: 0644]
Open-ILS/src/templates-bootstrap/opac/parts/library/hours.tt2

index 35eaebc..86e8fc0 100644 (file)
@@ -3747,18 +3747,25 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                <fields oils_persist:primary="id">
                        <field name="dow_0_close" />
                        <field name="dow_0_open" />
+                       <field name="dow_0_note"  reporter:datatype="text" />
                        <field name="dow_1_close" />
                        <field name="dow_1_open" />
+                       <field name="dow_1_note"  reporter:datatype="text" />
                        <field name="dow_2_close" />
                        <field name="dow_2_open" />
+                       <field name="dow_2_note"  reporter:datatype="text" />
                        <field name="dow_3_close" />
                        <field name="dow_3_open" />
+                       <field name="dow_3_note"  reporter:datatype="text" />
                        <field name="dow_4_close" />
                        <field name="dow_4_open" />
+                       <field name="dow_4_note"  reporter:datatype="text" />
                        <field name="dow_5_close" />
                        <field name="dow_5_open" />
+                       <field name="dow_5_note"  reporter:datatype="text" />
                        <field name="dow_6_close" />
                        <field name="dow_6_open" />
+                       <field name="dow_6_note"  reporter:datatype="text" />
                        <field name="id" reporter:datatype="id" />
                        <field name="org_unit" oils_persist:virtual="true" reporter:datatype="org_unit"/>
                </fields>
index 0955e98..19b803a 100644 (file)
@@ -67,6 +67,7 @@
             <div class="row font-weight-bold mb-2">
               <div class="col-lg-3 offset-lg-2" i18n>Open Time</div>
               <div class="col-lg-3" i18n>Close Time</div>
+              <div class="col-lg-2 offset-lg-2" i18n>Edit Note Field?</div>
             </div>
             <div class="row mb-2" *ngFor="let dow of [0,1,2,3,4,5,6]">
               <div class="col-lg-2" [ngSwitch]="dow">
                 <button class="btn btn-outline-dark" (click)="closedOn(dow)" 
                   [disabled]="isClosed(dow)" i18n>Closed</button>
               </div>
+              <div class="col-lg-2">
+                 <input type="checkbox" [(ngModel)]="editNote"/>
+              </div>
+              <div class="col-lg-6 offset-lg-6" *ngIf="editNote">
+                <div class="row">
+                  <div class="col-lg-12">
+                    <div class="input-group">
+                      <div class="input-group-prepend">
+                        <div class="input-group-text" i18n>Note: </div>
+                      </div>
+                      <input class="form-control" type='text'
+                        [ngModel]="getNote(dow)" 
+                        (ngModelChange)="setNote(dow, $event)"
+                        placeholder="e.g. 'Closed for lunch from Noon to 1PM'" i18n-placeholder />
+                    </div>
+                  </div>
+                </div>
+              </div>
             </div>
             <div class="row d-flex justify-content-end">
               <div class="alert alert-warning mr-2 p-1" 
index 160e972..7b34df0 100644 (file)
@@ -138,7 +138,7 @@ 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' | 'note', value?: string, hoo?: IdlObject): string {
         if (!hoo && !this.selected) { return null; }
 
         const hours = hoo || this.selected.callerData.orgUnit.hours_of_operation();
@@ -157,6 +157,40 @@ export class OrgUnitComponent implements OnInit {
             this.hours(dow, 'close') === '00:00:00'
         );
     }
+    
+    getNote(dow: number, hoo?: IdlObject) {
+        if (!hoo && !this.selected) { return null; }
+
+        const hours = hoo || this.selected.callerData.orgUnit.hours_of_operation();
+
+        return hours['dow_' + dow + '_note']();
+    }
+    
+    setNote(dow: number, value?: string, hoo?: IdlObject) {
+        console.log(value);
+        if (!hoo && !this.selected) { return null; }
+
+        const hours = hoo || this.selected.callerData.orgUnit.hours_of_operation();
+
+        hours['dow_' + dow + '_note'](value);
+        hours.ischanged(true);
+
+        return hours['dow_' + dow + '_note']();
+    }
+
+    note(dow: number, which: 'note', value?: string, hoo?: IdlObject) {
+         if (!hoo && !this.selected) { return null; }
+
+        const hours = hoo || this.selected.callerData.orgUnit.hours_of_operation();
+        if (!value) {
+            hours[`dow_${dow}_${which}`]("");
+            hours.ischanged(true);
+        } else if (value != hours[`dow_${dow}_${which}`]()) {
+            hours[`dow_${dow}_${which}`](value);
+            hours.ischanged(true);
+        }
+        return hours[`dow_${dow}_${which}`]();
+    }
 
     closedOn(dow: number) {
         this.hours(dow, 'open', '00:00:00');
index b18a33c..1c6fb9d 100644 (file)
@@ -455,18 +455,25 @@ CREATE TABLE actor.hours_of_operation (
        id              INT     PRIMARY KEY REFERENCES actor.org_unit (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
        dow_0_open      TIME    NOT NULL DEFAULT '09:00',
        dow_0_close     TIME    NOT NULL DEFAULT '17:00',
+    dow_0_note  TEXT,
        dow_1_open      TIME    NOT NULL DEFAULT '09:00',
        dow_1_close     TIME    NOT NULL DEFAULT '17:00',
+    dow_1_note  TEXT,
        dow_2_open      TIME    NOT NULL DEFAULT '09:00',
        dow_2_close     TIME    NOT NULL DEFAULT '17:00',
+    dow_2_note  TEXT,
        dow_3_open      TIME    NOT NULL DEFAULT '09:00',
        dow_3_close     TIME    NOT NULL DEFAULT '17:00',
+    dow_3_note  TEXT,
        dow_4_open      TIME    NOT NULL DEFAULT '09:00',
        dow_4_close     TIME    NOT NULL DEFAULT '17:00',
+    dow_4_note  TEXT,
        dow_5_open      TIME    NOT NULL DEFAULT '09:00',
        dow_5_close     TIME    NOT NULL DEFAULT '17:00',
+    dow_5_note  TEXT,
        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_6_note  TEXT
 );
 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.schema.lp1396764-hours-of-operation-note.sql b/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.lp1396764-hours-of-operation-note.sql
new file mode 100644 (file)
index 0000000..c8555d9
--- /dev/null
@@ -0,0 +1,13 @@
+BEGIN;\r
+\r
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);\r
+\r
+ALTER TABLE actor.hours_of_operation\r
+    ADD COLUMN dow_0_note TEXT,\r
+    ADD COLUMN dow_1_note TEXT,\r
+    ADD COLUMN dow_2_note TEXT,\r
+    ADD COLUMN dow_3_note TEXT,\r
+    ADD COLUMN dow_4_note TEXT,\r
+    ADD COLUMN dow_5_note TEXT,\r
+    ADD COLUMN dow_6_note TEXT;\r
+COMMIT;
\ No newline at end of file
index 9ff96dd..382eddf 100755 (executable)
 [%-
     open = today _ ctx.hours.dow_0_open;
     close = today _ ctx.hours.dow_0_close;
+    note = ctx.hours.dow_0_note;
     IF open == close;
 %]
 <div class="opening-hours">[% l('Monday: closed') %]</div>
 [%- ELSE %]
 <div class="opening-hours" property="openingHoursSpecification" typeof="OpeningHoursSpecification"><link property="dayOfWeek" href="http://purl.org/goodrelations/v1#Monday" />[%
     l('Monday: [_1] - [_2]', '<time property="opens" content="' _ date.format(open, format => '%H:%M:%S') _ '">' _ date.format(open) _ '</time>',
-     '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>') -%]
+     '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>')
+-%]
+[% IF ctx.hours.dow_0_note %]
+    <span>[%l('(' _ note _ ')')%]</span>
+[% END -%]
 </div>
 [%- END %]
 
 [%-
     open = today _ ctx.hours.dow_1_open;
     close = today _ ctx.hours.dow_1_close;
+    note = ctx.hours.dow_1_note;
     IF open == close;
 %]
 <div class="opening-hours">[% l('Tuesday: closed') %]</div>
 [%- ELSE %]
 <div class="opening-hours" property="openingHoursSpecification" typeof="OpeningHoursSpecification"><link property="dayOfWeek" href="http://purl.org/goodrelations/v1#Tuesday" />[%
     l('Tuesday: [_1] - [_2]', '<time property="opens" content="' _ date.format(open, format => '%H:%M:%S') _ '">' _ date.format(open) _ '</time>',
-     '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>') -%]
+     '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>')
+-%]
+[% IF ctx.hours.dow_1_note %]
+    <span>[%l('(' _ note _ ')')%]</span>
+[% END -%]
 </div>
 [%- END %]
 
 [%-
     open = today _ ctx.hours.dow_2_open;
     close = today _ ctx.hours.dow_2_close;
+    note = ctx.hours.dow_2_note;
     IF open == close;
 %]
 <div class="opening-hours">[% l('Wednesday: closed') %]</div>
 [%- ELSE %]
 <div class="opening-hours" property="openingHoursSpecification" typeof="OpeningHoursSpecification"><link property="dayOfWeek" href="http://purl.org/goodrelations/v1#Wednesday" />[%
     l('Wednesday: [_1] - [_2]', '<time property="opens" content="' _ date.format(open, format => '%H:%M:%S') _ '">' _ date.format(open) _ '</time>',
-     '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>') -%]
+     '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>')
+-%]
+[% IF ctx.hours.dow_2_note %]
+    <span>[%l('(' _ note _ ')')%]</span>
+[% END -%]
 </div>
 [%- END %]
 
 [%-
     open = today _ ctx.hours.dow_3_open;
     close = today _ ctx.hours.dow_3_close;
+    note = ctx.hours.dow_3_note;
     IF open == close;
 %]
 <div class="opening-hours">[% l('Thursday: closed') %]</div>
 [%- ELSE %]
 <div class="opening-hours" property="openingHoursSpecification" typeof="OpeningHoursSpecification"><link property="dayOfWeek" href="http://purl.org/goodrelations/v1#Thursday" />[%
     l('Thursday: [_1] - [_2]', '<time property="opens" content="' _ date.format(open, format => '%H:%M:%S') _ '">' _ date.format(open) _ '</time>',
-     '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>') -%]
+     '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>')
+-%]
+[% IF ctx.hours.dow_3_note %]
+    <span>[%l('(' _ note _ ')')%]</span>
+[% END -%]
 </div>
 [%- END %]
 
 [%-
     open = today _ ctx.hours.dow_4_open;
     close = today _ ctx.hours.dow_4_close;
+    note = ctx.hours.dow_4_note;
     IF open == close;
 %]
 <div class="opening-hours">[% l('Friday: closed') %]</div>
 [%- ELSE %]
 <div class="opening-hours" property="openingHoursSpecification" typeof="OpeningHoursSpecification"><link property="dayOfWeek" href="http://purl.org/goodrelations/v1#Friday" />[%
     l('Friday: [_1] - [_2]', '<time property="opens" content="' _ date.format(open, format => '%H:%M:%S') _ '">' _ date.format(open) _ '</time>',
-     '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>') -%]
+     '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>')
+-%]
+[% IF ctx.hours.dow_4_note %]
+    <span>[%l('(' _ note _ ')')%]</span>
+[% END -%]
 </div>
 [%- END %]
 
 [%-
     open = today _ ctx.hours.dow_5_open;
     close = today _ ctx.hours.dow_5_close;
+    note = ctx.hours.dow_5_note;
     IF open == close;
 %]
 <div class="opening-hours">[% l('Saturday: closed') %]</div>
 [%- ELSE %]
 <div class="opening-hours" property="openingHoursSpecification" typeof="OpeningHoursSpecification"><link property="dayOfWeek" href="http://purl.org/goodrelations/v1#Saturday" />[%
     l('Saturday: [_1] - [_2]', '<time property="opens" content="' _ date.format(open, format => '%H:%M:%S') _ '">' _ date.format(open) _ '</time>',
-     '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>') -%]
+     '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>')
+-%]
+[% IF ctx.hours.dow_5_note %]
+    <span>[%l('(' _ note _ ')')%]</span>
+[% END -%]
 </div>
 [%- END %]
 
 [%-
     open = today _ ctx.hours.dow_6_open;
     close = today _ ctx.hours.dow_6_close;
+    note = ctx.hours.dow_6_note;
     IF open == close;
 %]
 <div class="opening-hours">[% l('Sunday: closed') %]</div>
 [%- ELSE %]
 <div class="opening-hours" property="openingHoursSpecification" typeof="OpeningHoursSpecification"><link property="dayOfWeek" href="http://purl.org/goodrelations/v1#Sunday" />[%
     l('Sunday: [_1] - [_2]', '<time property="opens" content="' _ date.format(open, format => '%H:%M:%S') _ '">' _ date.format(open) _ '</time>',
-     '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>') -%]
+     '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>')
+-%]
+[% IF ctx.hours.dow_6_note %]
+    <span>[%l('(' _ note _ ')')%]</span>
+[% END -%]
 </div>
 [%- END %]
 </div>
\ No newline at end of file