LP#1269911: Teach the IDL about MVF- and CRA-related structures
authorMike Rylander <mrylander@gmail.com>
Wed, 15 Jan 2014 18:17:39 +0000 (13:17 -0500)
committerDan Wells <dbw2@calvin.edu>
Fri, 21 Feb 2014 20:38:52 +0000 (15:38 -0500)
IDL link from ccvm => ccraed via composite_def field

IDL selector attribute for ccvm class

ccraed gets CUD actions

In conify/global/config/coded_value_map, if the selected attr type is
composite=true, show a link from each coded value to manage the
composite definition.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/templates/conify/global/config/coded_value_map.tt2

index 3e82953..7c8201d 100644 (file)
@@ -784,8 +784,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Name" name="name" reporter:datatype="id" reporter:selector="label"  oils_obj:required="true"/>
                        <field reporter:label="Label" name="label" reporter:datatype="text"  oils_obj:required="true"/>
                        <field reporter:label="Description" name="description" reporter:datatype="text" />
+                       <field reporter:label="Multi-valued?" name="multi" reporter:datatype="bool"/>
                        <field reporter:label="Filter?" name="filter" reporter:datatype="bool"/>
                        <field reporter:label="Sorter?" name="sorter" reporter:datatype="bool"/>
+                       <field reporter:label="Composite attribute?" name="composite" reporter:datatype="bool"/>
                        <field reporter:label="MARC Tag" name="tag" reporter:datatype="text"/>
                        <field reporter:label="MARC Subfields" name="sf_list" reporter:datatype="text"/>
                        <field reporter:label="Joiner" name="joiner" reporter:datatype="text"/>
@@ -830,7 +832,77 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
         </permacrud>
        </class>
 
-       <class id="mra" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="metabib::record_attr" oils_persist:tablename="metabib.record_attr" reporter:label="SVF Record Attribute" oils_persist:field_safe="true">
+       <class id="ccraed" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::composite_attr_entry_definition" oils_persist:tablename="config.composite_attr_entry_definition" reporter:label="Composite Attribute Definitions" oils_persist:field_safe="true">
+               <fields oils_persist:primary="coded_value">
+                       <field reporter:label="Coded Value" name="coded_value" reporter:datatype="id" oils_obj:required="true"/>
+                       <field reporter:label="Defintion" name="definition" reporter:datatype="text"  oils_obj:required="true"/>
+               </fields>
+               <links>
+                       <link field="coded_value" reltype="has_a" key="id" map="" class="ccvm"/>
+               </links>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <create permission="ADMIN_CODED_VALUE" global_required="true"/>
+                <retrieve/>
+                <update permission="ADMIN_CODED_VALUE" global_required="true"/>
+                <delete permission="ADMIN_CODED_VALUE" global_required="true"/>
+            </actions>
+        </permacrud>
+       </class>
+
+       <class id="murav" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="metabib::uncontrolled_record_attr_value" oils_persist:tablename="metabib.uncontrolled_record_attr_value" reporter:label="Uncontrolled Record Attribute Values" oils_persist:field_safe="true">
+               <fields oils_persist:primary="id" oils_persist:sequence="metabib.uncontrolled_record_attr_value_id_seq">
+                       <field reporter:label="ID" name="id" reporter:datatype="id" oils_obj:required="true"/>
+                       <field reporter:label="Attribute" name="attr" reporter:datatype="text"  oils_obj:required="true"/>
+                       <field reporter:label="Value" name="value" reporter:datatype="text"  oils_obj:required="true"/>
+               </fields>
+               <links>
+                       <link field="attr" reltype="has_a" key="name" map="" class="crad"/>
+               </links>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <retrieve/>
+            </actions>
+        </permacrud>
+       </class>
+
+
+       <class id="mrs" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="metabib::record_sorter" oils_persist:tablename="metabib.record_sorter" reporter:label="Record Sort Values" oils_persist:field_safe="true">
+               <fields oils_persist:primary="id" oils_persist:sequence="metabib.record_sorter_id_seq">
+                       <field reporter:label="ID" name="id" reporter:datatype="id" oils_obj:required="true"/>
+                       <field reporter:label="Bib Record ID" name="source" reporter:datatype="int" oils_obj:required="true"/>
+                       <field reporter:label="Attribute" name="attr" reporter:datatype="text"  oils_obj:required="true"/>
+                       <field reporter:label="Value" name="value" reporter:datatype="text"  oils_obj:required="true"/>
+               </fields>
+               <links>
+                       <link field="source" reltype="has_a" key="id" map="" class="bre"/>
+                       <link field="attr" reltype="has_a" key="name" map="" class="crad"/>
+               </links>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <retrieve/>
+            </actions>
+        </permacrud>
+       </class>
+
+
+       <class id="mravl" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="metabib::record_attr_vector_list" oils_persist:tablename="metabib.record_attr_vector_list" reporter:label="MVF Record Attribute Vectors" oils_persist:field_safe="true">
+               <fields oils_persist:primary="source">
+                       <field reporter:label="Record ID" name="source" reporter:datatype="id" oils_obj:required="true"/>
+                       <field reporter:label="Vector" name="vlist" reporter:datatype="text"  oils_obj:required="true"/> <!-- Actually an int[], but this is the best we can do in fm_IDL.xml -->
+               </fields>
+               <links>
+                       <link field="source" reltype="has_a" key="id" map="" class="bre"/>
+               </links>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <retrieve/>
+            </actions>
+        </permacrud>
+       </class>
+
+
+       <class id="mra" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="metabib::record_attr" oils_persist:tablename="metabib.record_attr" reporter:label="SVF Record Attribute" oils_persist:field_safe="true" oils_persist:readonly="true">
                <fields oils_persist:primary="id">
                        <field reporter:label="Record ID" name="id" reporter:datatype="id" oils_obj:required="true"/>
                        <field reporter:label="Attributes" name="attrs" reporter:datatype="text"  oils_obj:required="true"/>
@@ -869,7 +941,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
        <class id="ccvm" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::coded_value_map" oils_persist:tablename="config.coded_value_map" reporter:label="SVF Record Attribute Coded Value Map" oils_persist:field_safe="true">
                <fields oils_persist:primary="id" oils_persist:sequence="config.coded_value_map_id_seq">
-                       <field reporter:label="ID" name="id" reporter:datatype="id"  oils_obj:required="true"/>
+                       <field reporter:label="ID" name="id" reporter:datatype="id"  oils_obj:required="true" reporter:selector="value"/>
                        <field reporter:label="SVF Attribute" name="ctype" reporter:datatype="link"  oils_obj:required="true"/>
                        <field reporter:label="Code" name="code" reporter:datatype="text"  oils_obj:required="true"/>
                        <field reporter:label="Value" name="value" reporter:datatype="text"  oils_obj:required="true" oils_persist:i18n="true"/>
@@ -877,9 +949,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="OPAC Visible" name="opac_visible" reporter:datatype="bool"/>
                        <field reporter:label="Search Label" name="search_label" reporter:datatype="text" oils_persist:i18n="true"/>
             <field reporter:label="Is Simple Selector" name="is_simple" reporter:datatype="bool"/>
+            <field reporter:label="Composite Definition" name="composite_def" oils_persist:virtual="true" reporter:datatype="link"/>
                </fields>
                <links>
                        <link field="ctype" reltype="has_a" key="name" map="" class="crad"/>
+                       <link field="composite_def" reltype="might_have" key="coded_value" map="" class="ccraed"/>
                </links>
         <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
             <actions>
index a31d2c8..3d30089 100644 (file)
     <table  jsId="ccvmGrid"
             autoHeight='true'
             dojoType="openils.widget.AutoGrid"
-            fieldOrder="['ctype', 'code', 'value', 'description', 'opac_visible', 'search_label']"
+            fieldOrder="['ctype', 'code', 'value', 'description', 'opac_visible', 'search_label', 'is_simple', 'composite_def']"
             query="{code: '*'}"
             defaultCellWidth='"25%"'
             fmClass='ccvm'
             showPaginator='true'
-            editOnEnter='true'/>
+            editOnEnter='true'>
+      <thead>
+        <tr><th field='composite_def' 
+                get='getCompositeDefLink' 
+                formatter='formatCompositeDefLink'>
+            [% l('Composite Definition') %]</th></tr>
+      </thead>
+    </table>
  </div>
 
 <script type ="text/javascript">
     dojo.require('openils.widget.AutoGrid');
     dojo.require('openils.widget.AutoFieldWidget');
 
+    function getCompositeDefLink(rowId, item) {
+      if (!item) return '';
+      return this.grid.store.getValue(item, 'id');
+    }
+
+    var isComposite = false;
+    function formatCompositeDefLink(id) {
+      if (id && isComposite) {
+        return "<a href='" + oilsBasePath +
+          "/conify/global/config/composite_attr_entry_definition/" 
+          + id + "'>Manage</a>";
+        } else {
+          return "";
+      }
+    }
+
     openils.Util.addOnLoad(
         function() {
 
                 function(w, ww) {
                     dojo.connect(w, 'onChange', 
                         function(newVal) {
+
+                            // see if this attr def supports composite entries
+                            w.store.fetch({
+                              onComplete : function(list) {
+                                if (!list.length) return;
+                                var comp = w.store.getValue(list[0], 'composite');
+                                if (comp == 't') {
+                                  isComposite = true;
+                                } else {
+                                  isComposite = false;
+                                }
+                              },
+                              query : {name : ''+newVal}
+                            });
+                            
                             ccvmGrid.resetStore();
                             ccvmGrid.loadAll({order_by : {ccvm : 'code'}}, {ctype : newVal});
                             ccvmGrid.overrideWidgetArgs.ctype = {dijitArgs : {value : newVal}};