[open-ils-commits] r9709 - in branches/acq-experiment/Open-ILS/web:
js/dojo/openils js/dojo/openils/acq js/dojo/openils/widget
oilsweb/oilsweb/public/oils/media/ui_js/oils/default/common
oilsweb/oilsweb/templates/oils/default/common
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon May 26 21:41:39 EDT 2008
Author: djfiander
Date: 2008-05-26 21:41:37 -0400 (Mon, 26 May 2008)
New Revision: 9709
Added:
branches/acq-experiment/Open-ILS/web/js/dojo/openils/editors.js
Modified:
branches/acq-experiment/Open-ILS/web/js/dojo/openils/User.js
branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Lineitems.js
branches/acq-experiment/Open-ILS/web/js/dojo/openils/widget/FundSelector.js
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/common/jubgrid.js
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/jubgrid.html
Log:
Create new acqlids and edit existing ones.
todo: update display.
Modified: branches/acq-experiment/Open-ILS/web/js/dojo/openils/User.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/js/dojo/openils/User.js 2008-05-26 19:52:40 UTC (rev 9708)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/User.js 2008-05-27 01:41:37 UTC (rev 9709)
@@ -43,7 +43,7 @@
this.location = kwargs.location;
this.authcookie = kwargs.authcookie || openils.User.authcookie;
this.orgCache = {perm: null, store: null};
- this.fundStore = null;
+ this.fundCache = [];
if (this.id && this.authtoken) this.user = this.getById( this.id );
else if (this.authtoken) this.getBySession();
@@ -256,8 +256,52 @@
}
)
}
- }
+ },
+ /**
+ * Sets the store for an existing openils.widget.FundFilteringSelect
+ * using the funds where the user has the requested permission.
+ * @param perm The permission to check
+ * @param selector The pre-created dijit.form.FilteringSelect object.
+ */
+ buildPermFundSelector : function(perm, selector) {
+ var _u = this;
+
+ dojo.require('dojo.data.ItemFileReadStore');
+
+ function hookupStore(store) {
+ selector.store = store;
+ selector.startup();
+ }
+
+ function buildPicker(r) {
+ var msg;
+ var fundList = [];
+ while (msg = r.recv()) {
+ var fund = msg.content();
+ fundList.push(fund);
+ }
+
+ var store = new dojo.data.ItemFileReadStore({data:acqf.toStoreData(fundList)});
+
+ hookupStore(store);
+ _u.fundCache[perm] = store;
+ }
+
+ if (this.fundCache[perm]) {
+ hookupStore(this.fundCache[perm]);
+ } else {
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.fund.org.retrieve'],
+ { params: [this.authtoken, null, {flesh_summary:1, limit_perm:perm}],
+ oncomplete: buildPicker,
+ async: true
+ }
+ )
+ }
+ }
+
+
});
openils.User.user = null;
Modified: branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Lineitems.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Lineitems.js 2008-05-26 19:52:40 UTC (rev 9708)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Lineitems.js 2008-05-27 01:41:37 UTC (rev 9709)
@@ -125,6 +125,25 @@
});
};
+openils.acq.Lineitems.createLID = function(fields, onCreateComplete) {
+ var lid = new acqlid()
+ for (var field in fields) {
+ lid[field](fields[field]);
+ }
+
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.lineitem_detail.create'],
+ { async: true,
+ params: [openils.User.authtoken, lid],
+ oncomplete: function(r) {
+ var msg = r.recv();
+ if (onCreateComplete) {
+ onCreateComplete(lid);
+ }
+ }
+ });
+};
+
openils.acq.Lineitems.loadGrid = function(domNode, id, layout) {
if (!openils.acq.Lineitems.ModelCache[id]) {
openils.acq.Lineitems.createStore(id,
Added: branches/acq-experiment/Open-ILS/web/js/dojo/openils/editors.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/js/dojo/openils/editors.js (rev 0)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/editors.js 2008-05-27 01:41:37 UTC (rev 9709)
@@ -0,0 +1,38 @@
+if(!dojo._hasResource["openils.editors"]){
+dojo._hasResource["openils.editors"] = true;
+dojo.provide("openils.editors");
+
+dojo.require("dojox.grid._data.dijitEditors");
+dojo.require("dojox.grid._data.editors");
+dojo.require("dijit.form.NumberSpinner");
+dojo.require('dijit.form.FilteringSelect');
+
+dojo.declare("openils.editors.NumberSpinner", dojox.grid.editors.Dijit, {
+ editorClass: "dijit.form.NumberSpinner",
+
+ getvalue: function() {
+ var e = this.editor;
+ // make sure to apply the displayed value
+ e.setDisplayedValue(e.getDisplayedValue());
+ return e.getValue();
+ },
+
+ getEditorProps: function(inDatum){
+ return dojo.mixin({}, this.cell.editorProps||{}, {
+ constraints: dojo.mixin({}, this.cell.constraints) || {},
+ value: inDatum
+ });
+ },
+});
+
+dojo.declare('openils.editors.FundSelectEditor', dojox.grid.editors.Dijit, {
+ editorClass: "openils.widget.FundSelector",
+ createEditor: function(inNode, inDatum, inRowIndex) {
+ var editor = new this.editorClass(this.getEditorProps(inDatum), inNode);
+ globalUser.buildPermFundSelector(this.cell.perm || this.perm,
+ editor);
+ return editor;
+ },
+});
+
+}
Modified: branches/acq-experiment/Open-ILS/web/js/dojo/openils/widget/FundSelector.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/js/dojo/openils/widget/FundSelector.js 2008-05-26 19:52:40 UTC (rev 9708)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/widget/FundSelector.js 2008-05-27 01:41:37 UTC (rev 9709)
@@ -2,8 +2,6 @@
dojo._hasResource["openils.widget.FundSelector"] = true;
dojo.provide("openils.widget.FundSelector");
- dojo.require("dojox.grid.editors");
-
dojo.require('openils.acq.Fund');
dojo.require('fieldmapper.Fieldmapper');
dojo.require('fieldmapper.dojoData');
@@ -13,23 +11,8 @@
* a fund.
*/
- dojo.declare("openils.widget.FundSelector", dojox.grid.editors.Select, {
-
- constructor: function(inCell) {
- this.options = openils.widget.FundSelector.fundNames;
- this.values = openils.widget.FundSelector.fundCodes;
- }
- });
-
- openils.widget.FundSelector.fundNames = [];
- openils.widget.FundSelector.fundCodes = [];
-
- dojo.addOnLoad(
- function() {
- openils.acq.Fund.nameMapping(
- function(ids, names) {
- openils.widget.FundSelector.fundCodes = ids;
- openils.widget.FundSelector.fundNames = names;
- });
+ dojo.declare(
+ "openils.widget.FundSelector", [dijit.form.FilteringSelect],
+ {
});
}
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/common/jubgrid.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/common/jubgrid.js 2008-05-26 19:52:40 UTC (rev 9708)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/common/jubgrid.js 2008-05-27 01:41:37 UTC (rev 9709)
@@ -1,12 +1,21 @@
dojo.require('dojo.data.ItemFileReadStore');
dojo.require('dijit.layout.SplitContainer');
+dojo.require('dijit.Dialog');
+dojo.require('dijit.form.FilteringSelect');
+dojo.require('dijit.form.Button');
dojo.require('dojox.grid.Grid');
+
+dojo.require("openils.User");
dojo.require("openils.acq.Fund");
dojo.require("openils.acq.Lineitems");
+dojo.require('openils.acq.Provider');
dojo.require("openils.widget.FundSelector");
+dojo.require('openils.editors');
+dojo.require("openils.widget.OrgUnitFilteringSelect");
dojo.require("fieldmapper.OrgUtils");
-dojo.require('openils.acq.Provider');
+var globalUser = new openils.User();
+
/* put all the accessors, etc. into a local object for namespacing */
var JUBGrid = {
jubGrid : null,
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/jubgrid.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/jubgrid.html 2008-05-26 19:52:40 UTC (rev 9708)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/jubgrid.html 2008-05-27 01:41:37 UTC (rev 9709)
@@ -62,11 +62,18 @@
{name:"ID", field:"id"},
{name:"Fund", field:"fund",
get:JUBGrid.getLIDFundName,
- editor: openils.widget.FundSelector,
+ editor: openils.editors.FundSelectEditor,
},
{name:"Location", field:"location", get:JUBGrid.getLIDLibName}
]]
}];
+
+ function createLID(fields) {
+ fields['lineitem'] = JUBGrid.jubDetailGrid.lineitemID;
+ openils.acq.Lineitems.createLID(fields,
+ function (lidId) {
+ });
+ }
</script>
<div id="${domprefix + '-container'}"
@@ -77,10 +84,43 @@
<div dojoType="dijit.layout.ContentPane" sizeMin="20" sizeShare="50">
<div jsid="lineItemButtonbar" dojoType="dijit.layout.ContentPane"
id=${domprefix+"-details-buttonbar"}>
- <button dojoType='dijit.form.Button'
- onclick='JUBGrid.createLID'>
- ${_('Add Copy')}
- </button>
+ <div dojoType="dijit.form.DropDownButton">
+ <span>${_('New Copy')}</span>
+ <div dojoType="dijit.TooltipDialog"
+ execute="createLID(arguments[0]);">
+ <script type='dojo/connect' event='onOpen'>
+ globalUser.buildPermOrgSelector('MANAGE_FUND', copyOwnerSelect);
+ globalUser.buildPermFundSelector('MANAGE_FUND', acqlidFund);
+ </script>
+ <table class="dijitTooltipTable">
+ <tr>
+ <td><label for="fund">${_('Fund:')} </label></td>
+ <td>
+ <input dojoType="openils.widget.FundSelector"
+ jsId="acqlidFund"
+ searchAttr="name" autocomplete="true"
+ name="fund"></input>
+ </td>
+ </tr>
+ <tr>
+ <td><label for="owning_lib">${_('Location:')} </label></td>
+ <td><input dojoType="openils.widget.OrgUnitFilteringSelect"
+ jsId="copyOwnerSelect"
+ searchAttr="shortname"
+ name="owning_lib" autocomplete="true"
+ labelAttr="shortname"></input>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" align="center">
+ <button dojotype="dijit.form.Button" type="submit">
+ ${_('Create')}
+ </button>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
<button dojotype='dijit.form.Button' onclick='JUBGrid.deleteLID'>
${_('Delete Selected Copy')}
</button>
More information about the open-ils-commits
mailing list