LP#1850547: add views for PO and LI state labels
authorGalen Charlton <gmc@equinoxinitiative.org>
Tue, 11 Feb 2020 19:18:49 +0000 (14:18 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 3 Sep 2020 15:52:19 +0000 (11:52 -0400)
This patch adds two new views, acq.po_state_label and
acq.li_state_label, to map from the state codes to human-friendly
labels in a way that allows the labels to be retrieved and
translated.

This patch also changes the fieldmapper label of the PO
and LI state column from "State" to "Status".

This patch includes contributions by Mike Rylander.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Tiffany Little <tlittle@georgialibraries.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/200.schema.acq.sql
Open-ILS/src/sql/Pg/upgrade/ZZZZ.schema.acq_state_views.sql [new file with mode: 0644]

index f7bfcf7..44455db 100644 (file)
@@ -9627,7 +9627,7 @@ SELECT  usr,
                        <field reporter:label="Creation Time" name="create_time" reporter:datatype="timestamp" />
                        <field reporter:label="Edit Time" name="edit_time" reporter:datatype="timestamp" />
                        <field reporter:label="Provider" name="provider" reporter:datatype="link" />
-                       <field reporter:label="State" name="state" reporter:datatype="text" />
+                       <field reporter:label="Status" name="state" reporter:datatype="link" />
                        <field reporter:label="Ordering Agency" name="ordering_agency" reporter:datatype="org_unit" />
                        <field reporter:label="Creator" name="creator" reporter:datatype="link" />
                        <field reporter:label="Editor" name="editor" reporter:datatype="link" />
@@ -9644,6 +9644,7 @@ SELECT  usr,
                        <field reporter:label="PO Items" name="po_items" oils_persist:virtual="true" reporter:datatype="link" />
                </fields>
                <links>
+                       <link field="state" reltype="has_a" key="id" map="" class="acqpostlbl"/>
                        <link field="owner" reltype="has_a" key="id" map="" class="au"/>
                        <link field="creator" reltype="has_a" key="id" map="" class="au"/>
                        <link field="editor" reltype="has_a" key="id" map="" class="au"/>
@@ -9678,7 +9679,7 @@ SELECT  usr,
                        <field reporter:label="Create Time" name="create_time" reporter:datatype="timestamp"/>
                        <field reporter:label="Edit Time" name="edit_time" reporter:datatype="timestamp"/>
                        <field reporter:label="Provider" name="provider" reporter:datatype="link"/>
-                       <field reporter:label="State" name="state" reporter:datatype="text"/>
+                       <field reporter:label="Status" name="state" reporter:datatype="text"/>
                        <field reporter:label="Order Date" name="order_date" reporter:datatype="timestamp"/>
                        <field reporter:label="Name" name="name" reporter:datatype="text"/>
                        <field reporter:label="Cancel Reason" name="cancel_reason" reporter:datatype="link"/>
@@ -9784,7 +9785,7 @@ SELECT  usr,
                        <field reporter:label="Evergreen Bib ID" name="eg_bib_id" reporter:datatype="link" />
                        <field reporter:label="Source Label" name="source_label" reporter:datatype="text" />
                        <field reporter:label="Expected Receive Date" name="expected_recv_time" reporter:datatype="timestamp" />
-                       <field reporter:label="State" name="state" reporter:datatype="text" />
+                       <field reporter:label="Status" name="state" reporter:datatype="link" />
                        <field reporter:label="Creator" name="creator" reporter:datatype="link" />
                        <field reporter:label="Editor" name="editor" reporter:datatype="link" />
                        <field reporter:label="Claim Policy" name="claim_policy" reporter:datatype="link" />
@@ -9800,6 +9801,7 @@ SELECT  usr,
                        <field reporter:label="Order Summary" name="order_summary" oils_persist:virtual="true" reporter:datatype="link" />
                </fields>
                <links>
+                       <link field="state" reltype="has_a" key="id" map="" class="jubstlbl"/>
                        <link field="selector" reltype="has_a" key="id" map="" class="au"/>
                        <link field="editor" reltype="has_a" key="id" map="" class="au"/>
                        <link field="creator" reltype="has_a" key="id" map="" class="au"/>
@@ -9845,7 +9847,7 @@ SELECT  usr,
                        <field reporter:label="MARC" name="marc" reporter:datatype="text"/>
                        <field reporter:label="Evergreen Bib ID" name="eg_bib_id" reporter:datatype="link"/>
                        <field reporter:label="Source Label" name="source_label" reporter:datatype="text"/>
-                       <field reporter:label="State" name="state" reporter:datatype="text"/>
+                       <field reporter:label="Status" name="state" reporter:datatype="text"/>
                        <field reporter:label="Claim Policy" name="claim_policy" reporter:datatype="link"/>
                        <field reporter:label="Cancel Reason" name="cancel_reason" reporter:datatype="link"/>
                        <field reporter:label="Estimated Unit Price" name="estimated_unit_price" reporter:datatype="money" />
@@ -11874,6 +11876,33 @@ SELECT  usr,
                </permacrud>
        </class>
 
+       <class id="jubstlbl" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::li_state_label" oils_persist:tablename="acq.li_state_label" oils_persist:readonly="true" reporter:label="Line Item State Labels" oils_persist:field_safe="true">
+               <fields oils_persist:primary="id">
+                       <field reporter:label="State ID" reporter:selector="label" name="id" reporter:datatype="text"/>
+                       <field reporter:label="State Label" name="label" oils_persist:i18n="true" reporter:datatype="text"/>
+               </fields>
+               <links/>
+               <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+                       <actions>
+                               <retrieve/>
+                       </actions>
+               </permacrud>
+       </class>
+
+       <class id="acqpostlbl" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::po_state_label" oils_persist:tablename="acq.po_state_label" oils_persist:readonly="true" reporter:label="PO State Labels">
+               <fields oils_persist:primary="id">
+                       <field reporter:label="State ID" reporter:selector="label" name="id" reporter:datatype="text"/>
+                       <field reporter:label="State Label" name="label" oils_persist:i18n="true" reporter:datatype="text"/>
+               </fields>
+               <links/>
+               <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+                       <actions>
+                               <retrieve/>
+                       </actions>
+               </permacrud>
+       </class>
+
+
        <class id="rhcrpb" controller="open-ils.cstore open-ils.pcrud open-ils.reporter-store" oils_obj:fieldmapper="reporter::hold_copy_ratio_per_bib" oils_persist:readonly="true" reporter:core="true" reporter:label="Hold/Copy Ratio per Bib">
                <oils_persist:source_definition><![CDATA[
 
index 717f620..ce23237 100644 (file)
@@ -2585,4 +2585,28 @@ CREATE OR REPLACE VIEW acq.lineitem_summary AS
 
         FROM acq.lineitem AS li;
 
+
+CREATE VIEW acq.li_state_label AS
+  SELECT *
+  FROM (VALUES
+          ('new', oils_i18n_gettext('new', 'New', 'jubstlbl', 'label')),
+          ('selector-ready', oils_i18n_gettext('selector-ready', 'Selector-Ready', 'jubstlbl', 'label')),
+          ('order-ready', oils_i18n_gettext('order-ready', 'Order-Ready', 'jubstlbl', 'label')),
+          ('approved', oils_i18n_gettext('approved', 'Approved', 'jubstlbl', 'label')),
+          ('pending-order', oils_i18n_gettext('pending-order', 'Pending-Order', 'jubstlbl', 'label')),
+          ('on-order', oils_i18n_gettext('on-order', 'On-Order', 'jubstlbl', 'label')),
+          ('received', oils_i18n_gettext('received', 'Received', 'jubstlbl', 'label')),
+          ('cancelled', oils_i18n_gettext('cancelled', 'Cancelled', 'jubstlbl', 'label'))
+       ) AS t (id,label);
+
+CREATE VIEW acq.po_state_label AS
+  SELECT *
+  FROM (VALUES
+          ('new', oils_i18n_gettext('new', 'New', 'acqpostlbl', 'label')),
+          ('pending', oils_i18n_gettext('pending', 'Pending', 'acqpostlbl', 'label')),
+          ('on-order', oils_i18n_gettext('on-order', 'On-Order', 'acqpostlbl', 'label')),
+          ('received', oils_i18n_gettext('received', 'Received', 'acqpostlbl', 'label')),
+          ('cancelled', oils_i18n_gettext('cancelled', 'Cancelled', 'acqpostlbl', 'label'))
+       ) AS t (id,label);
+
 COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/ZZZZ.schema.acq_state_views.sql b/Open-ILS/src/sql/Pg/upgrade/ZZZZ.schema.acq_state_views.sql
new file mode 100644 (file)
index 0000000..2ed6c79
--- /dev/null
@@ -0,0 +1,28 @@
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE VIEW acq.li_state_label AS
+  SELECT *
+  FROM (VALUES
+          ('new', 'New'),
+          ('selector-ready', 'Selector-Ready'),
+          ('order-ready', 'Order-Ready'),
+          ('approved', 'Approved'),
+          ('pending-order', 'Pending-Order'),
+          ('on-order', 'On-Order'),
+          ('received', 'Received'),
+          ('cancelled', 'Cancelled')
+       ) AS t (id,label);
+
+CREATE VIEW acq.po_state_label AS
+  SELECT *
+  FROM (VALUES
+          ('new', 'New'),
+          ('pending', 'Pending'), 
+          ('on-order', 'On-Order'),
+          ('received', 'Received'),
+          ('cancelled', 'Cancelled')
+       ) AS t (id,label);
+
+COMMIT;