[open-ils-commits] r9602 - in branches/acq-experiment/Open-ILS/web:
js/dojo/openils/acq oilsweb/oilsweb/controllers/acq
oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/picklist
oilsweb/oilsweb/templates/oils/default/acq/picklist
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed May 14 13:01:49 EDT 2008
Author: erickson
Date: 2008-05-14 13:01:47 -0400 (Wed, 14 May 2008)
New Revision: 9602
Added:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/picklist/view_list.js
Removed:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view_listall.html
Modified:
branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Picklist.js
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view_list.html
Log:
moved picklist list displays to dojo
added a picklist create and deleteList static methods
need to work out a bug in the delete code.
Modified: branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Picklist.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Picklist.js 2008-05-14 16:58:12 UTC (rev 9601)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Picklist.js 2008-05-14 17:01:47 UTC (rev 9602)
@@ -96,5 +96,48 @@
},
});
+/** Creates a new picklist. fields.name is required */
+openils.acq.Picklist.create = function(fields, oncomplete) {
+ var picklist = new acqpl();
+ picklist.owner(fields.owner || new openils.User().user.id());
+ picklist.name(fields.name);
+
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.picklist.create'],
+ { async: true,
+ params: [openils.User.authtoken, picklist],
+ oncomplete: function(r) {
+ // XXX event/error handling
+ oncomplete(r.recv().content());
+ }
+ }
+ );
}
+/** Deletes a list of picklists
+ * @param list Array of picklist IDs
+ */
+openils.acq.Picklist.deleteList = function(list, onComplete) {
+ openils.acq.Picklist._deleteList(list, 0, onComplete);
+}
+
+/* iterate through the list of IDs deleting asynchronously as we go... */
+openils.acq.Picklist._deleteList = function(list, idx, onComplete) {
+ if(idx >= list.length)
+ return onComplete();
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.picklist.delete'],
+ { async: true,
+ params: [openils.User.authtoken, list[idx]],
+ oncomplete: function(r) {
+ msg = r.recv()
+ stat = msg.content();
+ /* XXX CHECH FOR EVENT */
+ openils.acq.Picklist._deleteList(list, ++idx, onComplete);
+ }
+ }
+ );
+}
+
+}
+
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py 2008-05-14 16:58:12 UTC (rev 9601)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py 2008-05-14 17:01:47 UTC (rev 9602)
@@ -86,15 +86,11 @@
def list(self):
r = RequestMgr()
- pl_manager = oilsweb.lib.acq.picklist.PicklistMgr(r)
- r.ctx.acq.picklist_list.value = pl_manager.retrieve_list()
return r.render('acq/picklist/view_list.html')
def listall(self):
r = RequestMgr()
- pl_manager = oilsweb.lib.acq.picklist.PicklistMgr(r)
- r.ctx.acq.picklist_list.value = pl_manager.retrieve_list(all=True)
- return r.render('acq/picklist/view_listall.html')
+ return r.render('acq/picklist/view_list.html')
def bib_search(self):
r = RequestMgr()
Added: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/picklist/view_list.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/picklist/view_list.js (rev 0)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/picklist/view_list.js 2008-05-14 17:01:47 UTC (rev 9602)
@@ -0,0 +1,86 @@
+dojo.require('dojox.grid.Grid');
+dojo.require('dijit.Dialog');
+dojo.require('dijit.form.Button');
+dojo.require('dijit.form.TextBox');
+dojo.require('dijit.form.Button');
+dojo.require('openils.acq.Picklist');
+
+var plList = [];
+var listAll = false;
+
+function makeGridFromList() {
+ var store = new dojo.data.ItemFileReadStore({data:acqpl.toStoreData(plList)});
+ var model = new dojox.grid.data.DojoData(null, store,
+ {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
+ plListGrid.setModel(model);
+ plListGrid.update();
+}
+
+
+function loadGrid() {
+
+ function handleResponse(r) {
+ plList.push(r.recv().content());
+ }
+
+ var method = 'open-ils.acq.picklist.user.retrieve';
+ if(listAll)
+ method = method.replace(/user/, 'user.all');
+
+ fieldmapper.standardRequest(
+ ['open-ils.acq', method],
+ { async: true,
+ params: [openils.User.authtoken,
+ {flesh_lineitem_count:1, flesh_username:1}],
+ onresponse: handleResponse,
+ oncomplete: makeGridFromList
+ }
+ );
+}
+
+function createPL(fields) {
+ if(fields.name == '') return;
+ openils.acq.Picklist.create(fields,
+ function(plId) {
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.picklist.retrieve'],
+ { async: true,
+ params: [openils.User.authtoken, plId,
+ {flesh_lineitem_count:1, flesh_username:1}],
+ oncomplete: function(r) {
+ var pl = r.recv().content();
+ plList.push(pl);
+ makeGridFromList();
+ }
+ }
+ );
+ }
+ );
+}
+
+function deleteFromGrid() {
+ var list = []
+ var selected = plListGrid.selection.getSelected();
+ alert('selected = ' + selected);
+ for(var rowIdx in selected) {
+ var id = plListGrid.model.getRow(rowIdx).id;
+ for(var i = 0; i < plList.length; i++) {
+ var pl = plList[i];
+ if(pl.id() == id && pl.owner() == new openils.User().user.usrname()) {
+ list.push(id);
+ plList = (plList.slice(0, i) || []).concat(plList.slice(i+1, plList.length) || []);
+ }
+ }
+ }
+ alert('deleting: ' + list);
+ var names = [];
+ for(var i = 0; i < plList.length; i++)
+ names.push(plList[i].name());
+ alert('keeping ' + names);
+ return;
+ openils.acq.Picklist.deleteList(list, function() { makeGridFromList(); });
+}
+
+dojo.addOnLoad(loadGrid);
+
+
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view_list.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view_list.html 2008-05-14 16:58:12 UTC (rev 9601)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view_list.html 2008-05-14 17:01:47 UTC (rev 9602)
@@ -4,34 +4,75 @@
<%def name="block_content()">
<div id='oils-acq-list-header' class='container'>
- <div id='oils-acq-list-header-label'>${_('My Picklists')}</div>
- <div id='oils-acq-list-header-actions'>
- <a href="${c.oils.acq.prefix.value}/picklist/listall">${_('View All Picklists')}</a>
- <a href='${c.oils.acq.prefix.value}/picklist/create'>${_('New Picklist')}</a>
+ <div id='oils-acq-picklist-my-list-header'>
+ <div id='oils-acq-list-header-label'>${_('My Picklists')}</div>
+ <div id='oils-acq-list-header-actions'>
+ <a id='oils-acq-picklist-view-all' href="${c.oils.acq.prefix.value}/picklist/listall">${_('View All Picklists')}</a>
+ </div>
</div>
+ <div id='oils-acq-picklist-all-list-header'>
+ <div id='oils-acq-list-header-label'>${_('All Picklists')}</div>
+ <div id='oils-acq-list-header-actions'>
+ <a id='oils-acq-picklist-view-mine' href="${c.oils.acq.prefix.value}/picklist/list">${_('View My Picklists')}</a>
+ </div>
+ </div>
</div>
-<table id='oils-acq-picklist-list-table'>
- <thead>
- <tr>
- <td>${_('Name')}</td>
- <td>${_('Selector')}</td>
- <td>${_('Edit Date')}</td>
- <td>${_('Number of Entries')}</td>
- <td/>
- <td/>
- </tr>
- </thead>
- <tbody>
- % for picklist in c.oils.acq.picklist_list.value:
- <tr>
- <td><a href='${c.oils.acq.prefix.value}/picklist/view/${picklist.id()}'>${picklist.name()}</a></td>
- <td>${picklist.owner()}</td>
- <td>${picklist.edit_time()}</td>
- <td>${picklist.entry_count()}</td>
- <td><a href='${c.oils.acq.prefix.value}/picklist/delete/${picklist.id()}'>${_('Delete')}</a></td>
- </tr>
- % endfor
- </tbody>
-</table>
+<script src='${c.oils.core.media_prefix.value}/ui_js/oils/default/acq/picklist/view_list.js'> </script>
+
+<script>
+ if(location.href.match(/listall$/)) {
+ listAll = true;
+ dojo.style('oils-acq-picklist-my-list-header', 'visibility', 'hidden');
+ dojo.style('oils-acq-picklist-my-list-header', 'display', 'none');
+ } else {
+ dojo.style('oils-acq-picklist-all-list-header', 'visibility', 'hidden');
+ dojo.style('oils-acq-picklist-all-list-header', 'display', 'none');
+ }
+</script>
+
+
+<div class='oils-acq-actions-div'>
+ <div dojoType="dijit.form.DropDownButton">
+ <span>${('New Picklist')}</span>
+ <div dojoType="dijit.TooltipDialog" execute="createPL(arguments[0]);">
+ <table class='dijitTooltipTable'>
+ <tr>
+ <td><label for="name">${_('Name:')} </label></td>
+ <td><input dojoType="dijit.form.TextBox" name="name"></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="deleteFromGrid();">
+ ${_('Delete Selected')}
+ </button>
+</div>
+
+
+<script>
+ function getName(rowIndex) {
+ data = plListGrid.model.getRow(rowIndex);
+ if(!data) return;
+ return '<a href="${c.oils.acq.prefix.value}/picklist/view/'+data.id+'">'+data.name+'</a>';
+ }
+
+ var plListGridStructure = [{
+ cells : [[
+ {name: '${_("ID")}', field: 'id'},
+ {name: '${_("Name")}', width:'auto', get:getName},
+ {name: '${_("Selector")}', field:'owner'},
+ {name: '${_("Create Time")}', field: 'create_time'},
+ {name: '${_("Edit Time")}', field: 'edit_time'},
+ {name: '${_("Entry Count")}', field: 'entry_count'},
+ ]]
+ }];
+</script>
+<div jsId='plListGrid' dojoType="dojox.Grid" structure='plListGridStructure'></div>
+
</%def>
Deleted: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view_listall.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view_listall.html 2008-05-14 16:58:12 UTC (rev 9601)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view_listall.html 2008-05-14 17:01:47 UTC (rev 9602)
@@ -1,39 +0,0 @@
-# -*- coding: utf-8 -*-
-<%inherit file='../base.html'/>
-<%def name="page_title()">${_('Evergreen All Picklists')}</%def>
-<%def name="block_content()">
-
-<div id='oils-acq-list-header' class='container'>
- <div id='oils-acq-list-header-label'>${_('All Picklists')}</div>
- <div id='oils-acq-list-header-actions'>
- <a href="${c.oils.acq.prefix.value}/picklist/list">${_('View My Picklists')}</a>
- <a href='${c.oils.acq.prefix.value}/picklist/create'>${_('New Picklist')}</a>
- </div>
-</div>
-
-<table id='oils-acq-picklist-list-table'>
- <thead>
- <tr>
- <td>${_('Name')}</td>
- <td>${_('Owner')}</td>
- <td>${_('Creation Date')}</td>
- <td>${_('Edit Date')}</td>
- <td>${_('Number of Entries')}</td>
- <td/>
- <td/>
- </tr>
- </thead>
- <tbody>
- % for picklist in c.oils.acq.picklist_list.value:
- <tr>
- <td><a href='${c.oils.acq.prefix.value}/picklist/view/${picklist.id()}'>${picklist.name()}</a></td>
- <td>${picklist.owner()}</td>
- <td>${picklist.create_time()}</td>
- <td>${picklist.edit_time()}</td>
- <td>${picklist.entry_count()}</td>
- <td><a href='${c.oils.acq.prefix.value}/picklist/delete/${picklist.id()}'>${_('Delete')}</a></td>
- </tr>
- % endfor
- </tbody>
-</table>
-</%def>
More information about the open-ils-commits
mailing list