DB layout for recording custom toolbars
authorMike Rylander <mrylander@gmail.com>
Mon, 19 Mar 2012 19:58:51 +0000 (15:58 -0400)
committerThomas Berezansky <tsbere@mvlc.org>
Wed, 28 Mar 2012 19:32:33 +0000 (15:32 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/005.schema.actors.sql

index 21236c3..28f8ee3 100644 (file)
@@ -1095,10 +1095,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Workstation ID" name="id" reporter:datatype="id"/>
                        <field reporter:label="Workstation Name" name="name" reporter:datatype="text"/>
                        <field reporter:label="Owning Library" name="owning_lib"  reporter:datatype="org_unit"/>
                        <field reporter:label="Workstation ID" name="id" reporter:datatype="id"/>
                        <field reporter:label="Workstation Name" name="name" reporter:datatype="text"/>
                        <field reporter:label="Owning Library" name="owning_lib"  reporter:datatype="org_unit"/>
+                       <field reporter:label="Toolbars" name="toolbars" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Circulations" name="circulations" oils_persist:virtual="true" reporter:datatype="link"/>
                </fields>
                <links>
                        <link field="owning_lib" reltype="has_a" key="id" map="" class="aou"/>
                        <field reporter:label="Circulations" name="circulations" oils_persist:virtual="true" reporter:datatype="link"/>
                </fields>
                <links>
                        <link field="owning_lib" reltype="has_a" key="id" map="" class="aou"/>
+                       <link field="toolbars" reltype="has_many" key="ws" map="" class="atb"/>
                        <link field="circulations" reltype="has_many" key="workstation" map="" class="circ"/>
                </links>
        </class>
                        <link field="circulations" reltype="has_many" key="workstation" map="" class="circ"/>
                </links>
        </class>
@@ -2777,6 +2779,41 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        </actions>
                </permacrud>
        </class>
                        </actions>
                </permacrud>
        </class>
+       <class id="atb" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="actor::toolbar" oils_persist:tablename="actor.toolbar" reporter:label="Custom Toolbar">
+               <fields oils_persist:primary="id" oils_persist:sequence="actor.toolbar_id_seq">
+                       <field name="id" reporter:label="ID" reporter:datatype="id" />
+                       <field name="usr" reporter:label="Owning User" reporter:datatype="link" />
+                       <field name="org" reporter:label="Owning Org Unit" reporter:datatype="link" />
+                       <field name="ws" reporter:label="Owning Workstation" reporter:datatype="link" />
+                       <field name="label" reporter:label="Label" reporter:datatype="text" oils_persist:i18n="true" />
+                       <field name="layout" reporter:label="Layout" reporter:datatype="text" />
+        </fields>
+        <links>
+                       <link field="usr" reltype="might_have" key="id" map="" class="au"/>
+                       <link field="org" reltype="might_have" key="id" map="" class="aou"/>
+                       <link field="ws" reltype="might_have" key="id" map="" class="aws"/>
+               </links>
+               <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+                       <actions>
+                               <retrieve permission="ADMIN_TOOLBAR VIEW_TOOLBAR" context_field="org">
+                                       <context link="usr" field="home_ou" />
+                                       <context link="ws" field="owning_lib" />
+                               </retrieve>
+                               <create permission="ADMIN_TOOLBAR" context_field="org">
+                                       <context link="usr" field="home_ou" />
+                                       <context link="ws" field="owning_lib" />
+                               </create>
+                               <update permission="ADMIN_TOOLBAR" context_field="org">
+                                       <context link="usr" field="home_ou" />
+                                       <context link="ws" field="owning_lib" />
+                               </update>
+                               <delete permission="ADMIN_TOOLBAR" context_field="org">
+                                       <context link="usr" field="home_ou" />
+                                       <context link="ws" field="owning_lib" />
+                               </delete>
+                       </actions>
+               </permacrud>
+       </class>
        <class id="csg" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::settings_group" oils_persist:tablename="config.settings_group" reporter:label="Settings Group">
                <fields oils_persist:primary="name">
                        <field name="name" reporter:datatype="text"/>
        <class id="csg" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::settings_group" oils_persist:tablename="config.settings_group" reporter:label="Settings Group">
                <fields oils_persist:primary="name">
                        <field name="name" reporter:datatype="text"/>
index 9c219e0..4fead81 100644 (file)
@@ -630,4 +630,22 @@ CREATE TABLE actor.usr_activity (
     event_time  TIMESTAMPTZ NOT NULL DEFAULT NOW()
 );
 
     event_time  TIMESTAMPTZ NOT NULL DEFAULT NOW()
 );
 
+CREATE TABLE actor.toolbar (
+    id          BIGSERIAL   PRIMARY KEY,
+    ws          INT         REFERENCES actor.workstation (id) ON DELETE CASCADE,
+    org         INT         REFERENCES actor.org_unit (id) ON DELETE CASCADE,
+    usr         INT         REFERENCES actor.usr (id) ON DELETE CASCADE,
+    label       TEXT        NOT NULL,
+    layout      TEXT        NOT NULL,
+       CONSTRAINT label_once_per_ws UNIQUE (ws, label) WHERE ws IS NOT NULL,
+       CONSTRAINT label_once_per_org UNIQUE (org, label) WHERE org IS NOT NULL,
+       CONSTRAINT label_once_per_usr UNIQUE (usr, label) WHERE usr IS NOT NULL,
+    CONSTRAINT only_one_type CHECK (
+        (ws IS NOT NULL AND COALESCE(org,usr) IS NULL) OR
+        (org IS NOT NULL AND COALESCE(ws,usr) IS NULL) OR
+        (usr IS NOT NULL AND COALESCE(org,ws) IS NULL)
+    ),
+    CONSTRAINT layout_must_be_json CHECK ( is_json(layout) )
+);
+
 COMMIT;
 COMMIT;