staff portal: turn entry type list into a table
authorGalen Charlton <gmc@equinoxOLI.org>
Fri, 3 Sep 2021 15:12:10 +0000 (11:12 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 3 Sep 2021 15:12:10 +0000 (11:12 -0400)
Allows i18n of type label and field adding as a combobox in fm-editor

Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.portal_page_table.sql

index b498085..bb295d0 100644 (file)
@@ -13566,12 +13566,24 @@ SELECT  usr,
                </permacrud>
        </class>
 
+    <class id="cusppet" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::ui_staff_portal_page_entry_type" oils_persist:tablename="config.ui_staff_portal_page_entry_type" reporter:label="Portal Page Entry Type">
+        <fields oils_persist:primary="code">
+            <field name="code" reporter:label="Entry Type Code" reporter:datatype="text" reporter:selector="label" oils_obj:required="true"/>
+            <field name="label" reporter:label="Entry Type Label" reporter:datatype="text" oils_obj:required="true"/>
+        </fields>
+               <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+                       <actions>
+                               <retrieve/>
+                       </actions>
+               </permacrud>
+       </class>
+
     <class id="cusppe" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::ui_staff_portal_page_entry" oils_persist:tablename="config.ui_staff_portal_page_entry" reporter:label="Portal Page Entry">
         <fields oils_persist:primary="id" oils_persist:sequence="config.ui_staff_portal_page_entry_id_seq">
             <field name="id" reporter:label="ID" reporter:datatype="id" reporter:selector="label"/>
             <field name="page_col" reporter:label="Page Column" reporter:datatype="int" oils_obj:required="true"/>
             <field name="col_pos" reporter:label="Column Position" reporter:datatype="int" oils_obj:required="true"/>
-            <field name="entry_type" reporter:label="Entry Type" reporter:datatype="text" oils_obj:required="true"/>
+            <field name="entry_type" reporter:label="Entry Type" reporter:datatype="link" oils_obj:required="true"/>
             <field name="label" reporter:label="Entry Label" reporter:datatype="text"/>
             <field name="image_url" reporter:label="Entry Image URL" reporter:datatype="text"/>
             <field name="target_url" reporter:label="Entry Target URL" reporter:datatype="text"/>
@@ -13579,6 +13591,7 @@ SELECT  usr,
                        <field name="owner" reporter:label="Owner" reporter:datatype="link" oils_obj:required="true"/>
         </fields>
                <links>
+                       <link field="entry_type" reltype="has_a" key="code" map="" class="cusppet"/>
                        <link field="owner" reltype="has_a" key="id" map="" class="aou"/>
                </links>
         <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
index 585eae1..80ac803 100644 (file)
@@ -1,12 +1,24 @@
 BEGIN;
 
-CREATE TYPE config.ui_staff_portal_page_entry_type AS ENUM ('link', 'menuitem', 'text', 'header', 'catalogsearch');
+CREATE TABLE config.ui_staff_portal_page_entry_type(
+    code        TEXT PRIMARY KEY,
+    label       TEXT NOT NULL
+);
+
+INSERT INTO config.ui_staff_portal_page_entry_type (code, label)
+VALUES
+    ('link', oils_i18n_gettext('link', 'Link', 'cusppet', 'label')),
+    ('menuitem', oils_i18n_gettext('menuitem', 'Menu Item', 'cusppet', 'label')),
+    ('text', oils_i18n_gettext('text', 'Text and/or HTML', 'cusppet', 'label')),
+    ('header', oils_i18n_gettext('header', 'Header', 'cusppet', 'label')),
+    ('catalogsearch', oils_i18n_gettext('catalogsearch', 'Catalog Search Box', 'cusppet', 'label'));
+
 
 CREATE TABLE config.ui_staff_portal_page_entry (
-    id          SERIAL PRIMARY Key,
+    id          SERIAL PRIMARY KEY,
     page_col    INTEGER NOT NULL,
     col_pos     INTEGER NOT NULL,
-    entry_type  config.ui_staff_portal_page_entry_type NOT NULL,
+    entry_type  TEXT NOT NULL,
     label       TEXT,
     image_url   TEXT,
     target_url  TEXT,
@@ -14,6 +26,8 @@ CREATE TABLE config.ui_staff_portal_page_entry (
     owner       INT NOT NULL -- REFERENCES actor.org_unit (id)
 );
 
+ALTER TABLE config.ui_staff_portal_page_entry ADD CONSTRAINT cusppe_entry_type_fkey
+    FOREIGN KEY (entry_type) REFERENCES  config.ui_staff_portal_page_entry_type(code) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
 ALTER TABLE config.ui_staff_portal_page_entry ADD CONSTRAINT cusppe_owner_fkey
     FOREIGN KEY (owner) REFERENCES  actor.org_unit(id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;