[open-ils-commits] r12888 - in trunk/Open-ILS/web: js/ui/default/conify/global/permission templates/default/conify/global/permission (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Apr 16 10:45:21 EDT 2009
Author: erickson
Date: 2009-04-16 10:45:18 -0400 (Thu, 16 Apr 2009)
New Revision: 12888
Modified:
trunk/Open-ILS/web/js/ui/default/conify/global/permission/grp_penalty_threshold.js
trunk/Open-ILS/web/templates/default/conify/global/permission/grp_penalty_threshold.tt2
Log:
move to autogrid
Modified: trunk/Open-ILS/web/js/ui/default/conify/global/permission/grp_penalty_threshold.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/conify/global/permission/grp_penalty_threshold.js 2009-04-16 14:11:47 UTC (rev 12887)
+++ trunk/Open-ILS/web/js/ui/default/conify/global/permission/grp_penalty_threshold.js 2009-04-16 14:45:18 UTC (rev 12888)
@@ -1,146 +1,31 @@
-dojo.require('dojox.grid.DataGrid');
-dojo.require('dojo.data.ItemFileWriteStore');
-dojo.require('dijit.form.NumberTextBox');
dojo.require('dijit.form.FilteringSelect');
-dojo.require('openils.PermGrp');
+dojo.require('openils.widget.AutoGrid');
dojo.require('openils.widget.OrgUnitFilteringSelect');
dojo.require('openils.widget.PermGrpFilteringSelect');
-dojo.require('fieldmapper.OrgUtils');
-var GPT = {
- buildGrid : function () {
- var store = new dojo.data.ItemFileWriteStore({data:pgpt.initStoreData()});
- gptGrid.setStore(store);
- gptGrid.render();
+function buildGrid(org_id) {
+ var org_id = openils.User.user.ws_ou();
+ var list = fieldmapper.aou.findOrgUnit(org_id).orgNodeTrail().map( function (i) {
+ return i.id() } );
+
+ gptGrid.loadAll({order_by:{pgpt : 'grp'}},{org_unit:list});
- fieldmapper.standardRequest(
- ['open-ils.actor', 'open-ils.actor.grp_penalty_threshold.ranged.retrieve'],
- { async: true,
- params: [openils.User.authtoken, GPT.contextOrg],
- onresponse: function (r) {
- if(obj = openils.Util.readResponse(r, false, true)) {
- store.newItem(pgpt.toStoreItem(obj));
- }
- }
- }
- );
- },
+ new openils.User().buildPermOrgSelector('VIEW_GROUP_PENALTY_THRESHOLD', contextOrgSelector, null, function() {
+ dojo.connect(contextOrgSelector, 'onChange', filterGrid);});
+}
- init : function() {
- GPT.contextOrg = openils.User.user.ws_ou();
+function filterGrid() {
+ gptGrid.resetStore();
+ var unit = contextOrgSelector.getValue();
+ var list = fieldmapper.aou.findOrgUnit(unit).orgNodeTrail().map( function (i) {
+ return i.id() } );
- var connect = function() {
- dojo.connect(GPT.contextOrgSelector, 'onChange',
- function() {
- GPT.contextOrg = this.getValue();
- GPT.buildGrid();
- }
- );
- };
- new openils.User().buildPermOrgSelector('VIEW_GROUP_PENALTY_THRESHOLD', GPT.contextOrgSelector, null, connect);
+ if(unit)
+ gptGrid.loadAll({order_by:{pgpt: 'grp'}}, {org_unit:list});
+ else
+ gptGrid.loadAll({order_by:{pgpt : 'grp'}});
+
+}
- GPT.loadCsp(
- function() {
- openils.PermGrp.fetchGroupTree(
- function() { openils.PermGrp.flatten(); GPT.buildGrid(); }
- );
- }
- );
- },
-
-
- _onCreateComplete : function(r) {
- if(threshold = openils.Util.readResponse(r)) {
- gptGrid.store.newItem(pgpt.toStoreItem(threshold));
- }
- },
-
- create : function(args) {
- if(!(args.grp && args.org_unit && args.penalty && args.threshold))
- return;
-
- var thresh = new pgpt();
- thresh.grp(args.grp);
- thresh.org_unit(args.org_unit);
- thresh.penalty(args.penalty);
- thresh.threshold(args.threshold);
-
- fieldmapper.standardRequest(
- ['open-ils.permacrud', 'open-ils.permacrud.create.pgpt'],
- { async: true,
- params: [openils.User.authtoken, thresh],
- oncomplete:GPT._onCreateComplete
- }
- );
- },
-
- getGroupName : function(rowIdx, item) {
- if(!item) return '';
- var grpId = this.grid.store.getValue(item, this.field);
- return openils.PermGrp.groupIdMap[grpId].name();
- },
-
- drawCspSelector : function() {
- GPT.penaltySelector.store =
- new dojo.data.ItemFileReadStore({data:csp.toStoreData(GPT.standingPenalties)});
- GPT.penaltySelector.startup();
- },
-
- loadCsp : function(onload) {
- GPT.penaltyMap = {};
- fieldmapper.standardRequest(
- ['open-ils.pcrud', 'open-ils.pcrud.search.csp.atomic'],
- { async: true,
- params: [openils.User.authtoken, {id:{'<':100}}, {order_by:{csp:'id'}}],
- oncomplete: function(r) {
- if(list = openils.Util.readResponse(r, false, true)) {
- for(var idx in list)
- GPT.penaltyMap[list[idx].id()] = list[idx];
- GPT.standingPenalties = list;
- if(onload) onload(list);
- }
- }
- }
- );
- },
-
- getOrgInfo : function(rowIndex, item) {
- if(item) {
- var orgId = this.grid.store.getValue(item, this.field);
- return fieldmapper.aou.findOrgUnit(orgId).shortname();
- }
- },
-
- getPenaltyInfo : function(rowIndex, item) {
- if(item) {
- var pId = this.grid.store.getValue(item, this.field);
- return GPT.penaltyMap[pId].name();
- }
- },
-
- deleteFromGrid : function() {
- GPT._deleteFromGrid(gptGrid.selection.getSelected(), 0);
- },
-
- _deleteFromGrid : function(list, idx) {
- if(idx >= list.length) // we've made it through the list
- return;
-
- var item = list[idx];
- var id = gptGrid.store.getValue(item, 'id');
- fieldmapper.standardRequest(
- ['open-ils.permacrud', 'open-ils.permacrud.delete.pgpt'],
- { async: true,
- params: [openils.User.authtoken, id],
- oncomplete: function(r) {
- if(obj = openils.Util.readResponse(r)) {
- gptGrid.store.deleteItem(item);
- }
- GPT._deleteFromGrid(list, ++idx);
- }
- }
- );
- },
- };
-openils.Util.addOnLoad(GPT.init);
+openils.Util.addOnLoad(buildGrid);
Modified: trunk/Open-ILS/web/templates/default/conify/global/permission/grp_penalty_threshold.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/conify/global/permission/grp_penalty_threshold.tt2 2009-04-16 14:11:47 UTC (rev 12887)
+++ trunk/Open-ILS/web/templates/default/conify/global/permission/grp_penalty_threshold.tt2 2009-04-16 14:45:18 UTC (rev 12888)
@@ -1,71 +1,41 @@
[% WRAPPER default/base.tt2 %]
-<script src='[% ctx.media_prefix %]/js/ui/default/conify/global/permission/grp_penalty_threshold.js'> </script>
-<h1>Group Penalty Thresholds</h1><br/>
+<script src='[% ctx.media_prefix %]/js/ui/default/conify/global/permission/grp_penalty_threshold.js'> </script>
-<!-- grp, penalty, org_unit, threshold -->
-
-<div dojoType="dijit.form.DropDownButton">
- <span>New Group Penalty Threshold</span>
- <div dojoType="dijit.TooltipDialog" execute="GPT.create(arguments[0]);">
- <script type='dojo/connect' event='onOpen'>
- new openils.User().buildPermOrgSelector('ADMIN_GROUP_PENALTY_THRESHOLD', gptOwningOrg);
- GPT.drawCspSelector();
- GPT.grpSelector.drawGroups();
- </script>
- <table class='dijitTooltipTable'>
- <tr>
- <td><label for="grp">Group: </label></td>
- <td>
- <select dojoType="openils.widget.PermGrpFilteringSelect" name="grp" jsId='GPT.grpSelector'/>
- </td>
- </tr>
- <tr>
- <td><label for="org_unit">Context Org Unit: </label></td>
- <td>
- <select dojoType="openils.widget.OrgUnitFilteringSelect" name="org_unit"
- jsId='gptOwningOrg' searchAttr='shortname' labelAttr='shortname'/>
- </td>
- </tr>
- <tr>
- <td><label for="penalty">Penalty: </label></td>
- <td>
- <select dojoType="dijit.form.FilteringSelect" jsId='GPT.penaltySelector' name="penalty"/>
- </td>
- </tr>
- <tr>
- <td><label for="threshold">Threshold: </label></td>
- <td><input dojoType="dijit.form.NumberTextBox" name="threshold"/></td>
- </tr>
- <tr>
- <td colspan='2' align='center'>
- <button dojoType='dijit.form.Button' type="submit">Create</button>
- </td>
- </tr>
- </table>
+<div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+ <div>Penalty Threshold</div>
+ <div>
+ <button dojoType='dijit.form.Button' onClick='gptGrid.showCreateDialog()'>New Penalty Threshold</button>
+ <button dojoType='dijit.form.Button' onClick='gptGrid.deleteSelected()'>Delete Selected</button>
</div>
</div>
-
-<button dojoType='dijit.form.Button' onClick="GPT.deleteFromGrid">Delete Selected</button>
-
<span>Context Org Unit</span>
-<select dojoType="openils.widget.OrgUnitFilteringSelect" jsId='GPT.contextOrgSelector'
- searchAttr='shortname' labelAttr='shortname'> </select>
+<select dojoType="openils.widget.OrgUnitFilteringSelect"
+ jsId='contextOrgSelector'
+ searchAttr='shortname'
+ labelAttr='shortname'>
+</select>
+
<div dojoType="dijit.layout.ContentPane" layoutAlign="top">
<div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:600px;'>
- <table jsId="gptGrid" dojoType="dojox.grid.DataGrid" query="{id: '*'}" rowSelector='20px'>
- <thead>
- <tr>
- <th field="id">ID</th>
- <th field="grp" width='auto' get='GPT.getGroupName'>Group</th>
- <th field="org_unit" width='auto' get='GPT.getOrgInfo'>Context Org Unit</th>
- <th field="penalty" width='auto' get='GPT.getPenaltyInfo'>Penalty</th>
- <th field="threshold" width='auto'>threshold</th>
- </tr>
- </thead>
+ <table jsId="gptGrid"
+ dojoType="openils.widget.AutoGrid"
+ fieldOrder="['id', 'grp', 'org_unit', 'penalty', 'threshold']"
+ defaultCellWidth='15'
+ query="{id: '*'}"
+ fmClass='pgpt'
+ editOnEnter='true'>
</table>
</div>
</div>
-
+
+<script type='javascript/text'>
+ var org_id = openils.User.user.ws_ou();
+ console.log(org_id);
+ var list = fieldmapper.aou.findOrgUnit(org_id).orgNodeTrail().map( function (i) {
+ return i.id() } );
+ console.log(list);
+
+</script>
[% END %]
More information about the open-ils-commits
mailing list