Admin UIs for ACQ fiscal calendar & fiscal year
authorBill Erickson <berick@esilibrary.com>
Wed, 21 Sep 2011 15:02:55 +0000 (11:02 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 21 Sep 2011 15:02:55 +0000 (11:02 -0400)
These function solely to create and manage the data.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/templates/conify/global/acq/fiscal_calendar.tt2 [new file with mode: 0644]
Open-ILS/src/templates/conify/global/acq/fiscal_year.tt2 [new file with mode: 0644]

index 54a352c..92e50b9 100644 (file)
@@ -6224,7 +6224,7 @@ SELECT  usr,
                </permacrud>
        </class>
 
-       <class id="acqfc" controller="open-ils.cstore" oils_obj:fieldmapper="acq::fiscal_calendar" oils_persist:tablename="acq.fiscal_calendar" reporter:label="Fiscal Calendar">
+       <class id="acqfc" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::fiscal_calendar" oils_persist:tablename="acq.fiscal_calendar" reporter:label="Fiscal Calendar">
                <fields oils_persist:primary="id" oils_persist:sequence="acq.fiscal_calendar_id_seq">
                        <field reporter:label="Fiscal Calendar ID" name="id" reporter:datatype="id" reporter:selector='name'/>
                        <field reporter:label="Fiscal Calendar Name" name="name" reporter:datatype="text"/>
@@ -6233,10 +6233,6 @@ SELECT  usr,
                <links>
             <link field="years" reltype="has_many" map="" key="calendar" class="acqfy"/>
                </links>
-               <!--
-                       For now, we don't have pcrud as one of the controllers, so the permacrud section is moot.
-                       But here's what it should look like if we ever do use pcrud.
-               -->
                <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
                        <actions>
                                <create permission="ADMIN_ACQ_FISCAL_YEAR" global_required="true"/>
@@ -6247,7 +6243,7 @@ SELECT  usr,
                </permacrud>
        </class>
 
-       <class id="acqfy" controller="open-ils.cstore" oils_obj:fieldmapper="acq::fiscal_year" oils_persist:tablename="acq.fiscal_year" reporter:label="Fiscal Year">
+       <class id="acqfy" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::fiscal_year" oils_persist:tablename="acq.fiscal_year" reporter:label="Fiscal Year">
                <fields oils_persist:primary="id" oils_persist:sequence="acq.fiscal_year_id_seq">
                        <field reporter:label="Fiscal Year ID" name="id" reporter:datatype="id" reporter:selector='year'/>
                        <field reporter:label="Calendar" name="calendar" reporter:datatype="link"/>
@@ -6258,10 +6254,6 @@ SELECT  usr,
                <links>
                        <link field="calendar" reltype="has_a" key="id" map="" class="acqfc"/>
                </links>
-               <!--
-                       For now, we don't have pcrud as one of the controllers, so the permacrud section is moot.
-                       But here's what it should look like if we ever do use pcrud.
-               -->
                <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
                        <actions>
                                <create permission="ADMIN_ACQ_FISCAL_YEAR" global_required="true"/>
diff --git a/Open-ILS/src/templates/conify/global/acq/fiscal_calendar.tt2 b/Open-ILS/src/templates/conify/global/acq/fiscal_calendar.tt2
new file mode 100644 (file)
index 0000000..b1880d2
--- /dev/null
@@ -0,0 +1,42 @@
+[% WRAPPER base.tt2 %]
+[% ctx.page_title = l('Fiscal Calendar') %]
+<div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+        <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+            <div>[% l('Fiscal Calendar') %]</div>
+            <div>
+                <button dojoType='dijit.form.Button' onClick='acqfcGrid.showCreateDialog()'>[% l('New Calendar') %]</button>
+                <button dojoType='dijit.form.Button' onClick='acqfcGrid.deleteSelected()'>[% l('Delete Selected') %]</button>
+            </div>
+        </div>
+        <table  jsId="acqfcGrid"
+                dojoType="openils.widget.AutoGrid"
+                fieldOrder="['id', 'name']"
+                query="{id: '*'}"
+                defaultCellWidth='"auto"'
+                fmClass='acqfc'
+                showPaginator='true'
+                editOnEnter='true'>
+                <thead>
+                    <tr><th field='name' get='getName' formatter='formatName'/></tr>
+                </thead>
+        </table>
+    </div>
+</div>
+<script>
+    dojo.require('openils.widget.AutoGrid');
+    function getName(rowIdx, item) {
+        if(!item) return '';
+        var id = this.grid.store.getValue(item, 'id');
+        var name = this.grid.store.getValue(item, 'name');
+        return id + ':' + name;
+    }
+    function formatName(nameId) {
+        var chunks = nameId.split(':');
+        if(!chunks && chunks[0]) return ''
+        return "<a href='fiscal_year/" + chunks[0] + "'>" + chunks[1] + "</a>";
+    }
+    dojo.addOnLoad(function() { acqfcGrid.loadAll(); });
+</script>
+[% END %]
+
+
diff --git a/Open-ILS/src/templates/conify/global/acq/fiscal_year.tt2 b/Open-ILS/src/templates/conify/global/acq/fiscal_year.tt2
new file mode 100644 (file)
index 0000000..ea45acf
--- /dev/null
@@ -0,0 +1,44 @@
+[% WRAPPER base.tt2 %]
+[% ctx.page_title = l('Fiscal Year') %]
+<div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+        <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+            <div>[% l('Fiscal Year') %]</div>
+            <div>
+                <button dojoType='dijit.form.Button' onClick='acqfyGrid.showCreateDialog()'>[% l('New Fiscal Year') %]</button>
+                <button dojoType='dijit.form.Button' onClick='acqfyGrid.deleteSelected()'>[% l('Delete Selected') %]</button>
+            </div>
+        </div>
+        <h2><i id='calendar-name'></i></h2>
+        <table  jsId="acqfyGrid"
+                dojoType="openils.widget.AutoGrid"
+                fieldOrder="['id', 'calendar', 'year', 'year_begin', 'year_end']"
+                suppressEditFields="['id']"
+                query="{id: '*'}"
+                defaultCellWidth='"auto"'
+                fmClass='acqfy'
+                showPaginator='true'
+                editOnEnter='true'>
+        </table>
+    </div>
+</div>
+<script>
+    dojo.require('openils.widget.AutoGrid');
+    dojo.require('openils.widget.AutoFieldWidget');
+    dojo.require('openils.PermaCrud');
+    dojo.addOnLoad(function() { 
+        var calendarId = '[% ctx.page_args.0 %]';
+        if (calendarId) {
+            var calendar = new openils.PermaCrud().retrieve('acqfc', calendarId);
+            dojo.byId('calendar-name').innerHTML = calendar.name();
+            acqfyGrid.overrideEditWidgets.calendar = 
+                new dijit.form.TextBox({disabled : true, value : calendarId});
+        }
+        acqfyGrid.loadAll(
+            {order_by : {acqfy : 'year DESC'}}, 
+            {calendar : calendarId}
+        ); 
+    });
+</script>
+[% END %]
+
+