From: Joseph Lewis Date: Wed, 11 Jul 2012 17:17:45 +0000 (-0600) Subject: Midterm GSoC stuff. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=bc61cc1bc28aab6e414c2212d19862e2bc602737;p=evergreen%2Fjoelewis.git Midterm GSoC stuff. Signed-off-by: Joseph Lewis --- diff --git a/Open-ILS/web/conify/global/config/copy_status.html b/Open-ILS/web/conify/global/config/copy_status.html index 644ad0e0b8..50157c288e 100644 --- a/Open-ILS/web/conify/global/config/copy_status.html +++ b/Open-ILS/web/conify/global/config/copy_status.html @@ -88,3 +88,4 @@ + diff --git a/Open-ILS/web/conify/global/config/copy_status.js b/Open-ILS/web/conify/global/config/copy_status.js index 9c29bcb810..e92bcc3e0b 100644 --- a/Open-ILS/web/conify/global/config/copy_status.js +++ b/Open-ILS/web/conify/global/config/copy_status.js @@ -26,13 +26,15 @@ dojo.require('dojo.cookie'); dojo.require('dijit.form.TextBox'); dojo.require('dijit.form.ValidationTextBox'); dojo.require('dijit.form.Textarea'); +dojo.require('dijit.form.CheckBox'); dojo.require('dijit.layout.ContentPane'); dojo.require('dijit.layout.LayoutContainer'); dojo.require('dijit.layout.BorderContainer'); +dojo.require('dijit.Toolbar'); +dojo.require('dijit.ToolbarSeparator'); dojo.require('dojox.widget.Toaster'); dojo.require('dojox.fx'); dojo.require('dojox.grid.cells.dijit'); -dojo.require('dojo.data.ItemFileWriteStore'); dojo.require('dojox.grid.DataGrid'); dojo.requireLocalization("openils.conify", "conify"); @@ -60,12 +62,12 @@ function save_status () { pCRUD.update(modified_ccs, { onerror : function (r) { highlighter.red.play(); - status_update( dojo.string.substitute(ccs_strings.ERROR_SAVING_STATUS, [status_store.getValue( current_status, 'name' )]) ); + status_update( dojo.string.substitute(ccs_strings.ERROR_SAVING_STATUS, [current_status.name])); }, oncomplete : function (r) { status_store.setValue( current_status, 'ischanged', 0 ); highlighter.green.play(); - status_update( dojo.string.substitute(ccs_strings.SUCCESS_SAVE, [status_store.getValue( current_status, 'name' )]) ); + status_update( dojo.string.substitute(ccs_strings.SUCCESS_SAVE, [current_status.name] )); } }); } @@ -178,7 +180,7 @@ function newCopyStatus() var new_item_hash = list[0].toHash(); status_store.newItem( new_item_hash ); status_update( dojo.string.substitute(ccs_strings.SUCCESS_CREATING_STATUS, [new_item_hash.name]) ); - status_grid.model.sort(-2); + status_grid.sort(-2); highlighter.green.play(); } }); @@ -188,22 +190,15 @@ function newCopyStatus() function delete_them() { var selected_rows = status_grid.selection.getSelected(); + + status_grid.removeSelectedRows(); - var selected_items = []; for (var i in selected_rows) { - selected_items.push( - status_grid.getItem( selected_rows[i] ).__dojo_data_item - ); - } + const current_status = selected_rows[i]; - status_grid.selection.clear(); + if ( confirm(dojo.string.substitute(ccs_strings.CONFIRM_DELETE, [current_status['name']]))) { - for (var i in selected_items) { - current_status = selected_items[i]; - - if ( confirm(dojo.string.substitute(ccs_strings.CONFIRM_DELETE, [status_store.getValue( current_status, 'name' )]))) { - - status_store.setValue( current_status, 'isdeleted', 1 ); + current_status['isdeleted'] = 1; var modified_ccs = new ccs().fromStoreItem( current_status ); modified_ccs.isdeleted( 1 ); @@ -211,21 +206,11 @@ function delete_them() pCRUD.eliminate(modified_ccs, { onerror : function (r) { highlighter.red.play(); - status_update( dojo.string.substitute( ccs_strings.ERROR_DELETING, [status_store.getValue( current_status, 'name' )] ) ); + status_update( dojo.string.substitute( ccs_strings.ERROR_DELETING, [current_status['name']] ) ); + onsole.log("pcrud couldn't delete: ", current_status['name']); }, oncomplete : function (r) { - var old_name = status_store.getValue( current_status, 'name' ); - - status_store.fetch({ - query : { id : status_store.getValue( current_status, 'id' ) }, - onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } }, - scope : status_store - }); - - current_status = null; - highlighter.green.play(); - status_update( dojo.string.substitute(ccs_strings.STATUS_DELETED, [old_name]) ); } }); @@ -233,90 +218,49 @@ function delete_them() } } - -var status_grid_layout = [ -{ cells : [ - [ - { name : ccs_strings.ID, - field : "id", - }, - { name : ccs_strings.NAME, - field : "name", - width : "auto", - //editor : dojox.grid.editors.Dijit - editable: true - }, - { name : ccs_strings.TRANSLATION, - width : "10em", - height : "2em", - formatter: function (row) { - return ''; - }, - get : function (row) { - if (!window.status_rows) window.status_rows = []; - var r = grid_container.getItem(row); - if (r) { - window.status_rows[row] = new ccs().fromHash(grid_container.getItem(row)); - setTimeout( - 'dojo.query(".status_grid_trans_cell_' + row + '").'+ - 'instantiate(openils.widget.TranslatorPopup,{field:"name",'+ - 'targetObject:"window.status_rows['+row+']"});'+ - 'status_grid.rowHeightChanged('+row+')', - 0 - ); - return row; - } - return ''; - } - }, - { name : ccs_strings.HOLDABLE, - field : "holdable", - editable: true, - //editor : dojox.grid.editors.bool, - get : function (row) { - var r = grid_container.getItem(row); - if (r) { - var h = r.holdable; - if (h == 't' || h === true) return true; - return false; - } - } - }, - { name : ccs_strings.OPAC_VISIBLE, - field : "opac_visible", - editable: true, - //editor : dojox.grid.editors.bool, - get : function (row) { - var r = grid_container.getItem(row); - if (r) { - var h = r.opac_visible; - if (h == 't' || h === true) return true; - return false; - } - } - }, - { name : ccs_strings.COPY_ACTIVE, - field : "copy_active", - //editor : dojox.grid.editors.bool, - editable: true, - get : function (row) { - var r = grid_container.getItem(row); - if (r) { - var h = r.copy_active; - if (h == 't' || h === true) return true; - return false; - } - } - } - ] - ] +/** + * Creates a function that looks at the row properties for a given row + * and turns the 't' or 'f' returned from the CRUD interface for true or + * false in to a literal true or false, so widgets for the field can be + * auto-created by dojo. + * + * @param propName - The name of the property to fetch for the given row + * @return A function that outputs true or false for the given property. + **/ +function getBoolRow(propName){ + return function boolRow(rowNum, rowVal) { + if(rowVal === null) + return false; + + var h = rowVal[propName]; + return (h == 't' || h === true); + }; } -]; +function getTranslationFormat(r, row, grid) +{ + if (!window.status_rows) window.status_rows = []; + if (r) { + window.status_rows[row] = new ccs().fromHash(r); + + var tp = new openils.widget.TranslatorPopup({field:"name", targetObject:"window.status_rows["+row+"]"}); + tp._destroyOnRemove=true; + return tp; + } +} + +var status_grid_layout = [[ + {name: ccs_strings.ID, field:'id'}, + {name: ccs_strings.NAME, field: 'name', width: 'auto', editable: true}, + {name: ccs_strings.TRANSLATION, width: "10em", height: "2em", field:"_item", formatter: getTranslationFormat, editable: true}, + {name: ccs_strings.HOLDABLE, field: "holdable", editable: true, cellType:dojox.grid.cells.Bool, get:getBoolRow('holdable')}, + {name: ccs_strings.OPAC_VISIBLE, field : "opac_visible", editable: true, cellType:dojox.grid.cells.Bool, get:getBoolRow('opac_visible')}, +]]; dojo.addOnLoad(function() { - highlighter.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'grid_container', duration : 500 } ); - highlighter.red = dojox.fx.highlight( { color : '#FF2018', node : 'grid_container', duration : 500 } ); + highlighter.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'pagebody', duration : 500 } ); + highlighter.red = dojox.fx.highlight( { color : '#FF2018', node : 'pagebody', duration : 500 } ); }); + diff --git a/Open-ILS/web/conify/global/config/marc_code_maps.html b/Open-ILS/web/conify/global/config/marc_code_maps.html index 9a8bbb0ad8..a83c2e3aef 100644 --- a/Open-ILS/web/conify/global/config/marc_code_maps.html +++ b/Open-ILS/web/conify/global/config/marc_code_maps.html @@ -447,3 +447,4 @@ + diff --git a/Open-ILS/web/conify/global/permission/grp_tree.html b/Open-ILS/web/conify/global/permission/grp_tree.html index 4567900b97..6f9ad6d970 100644 --- a/Open-ILS/web/conify/global/permission/grp_tree.html +++ b/Open-ILS/web/conify/global/permission/grp_tree.html @@ -269,3 +269,4 @@ + diff --git a/Open-ILS/web/conify/global/permission/grp_tree.js b/Open-ILS/web/conify/global/permission/grp_tree.js index 67367e67ec..7d7cafd87a 100644 --- a/Open-ILS/web/conify/global/permission/grp_tree.js +++ b/Open-ILS/web/conify/global/permission/grp_tree.js @@ -487,6 +487,43 @@ dojo.addOnLoad(function() { //perm_grid.refresh(); }); + /** + * Huge important function. + */ + function get_item_part(model_field, item_search_field, item_part, model, store, datum, row) { + return datum; + var formatter = true; + + if (!row && row != '0') { + row = datum; + formatter = false; + } + + if (!model.getItem(row)) + return null; + var value = null; + + if (!formatter) {//this.editor && (this.editor.alwaysOn || (this.grid.edit.info.rowIndex==row && this.grid.edit.info.cell==this))) { + return model.getItem(row)[model_field]; + } + + return datum; + + var value; + var q = {}; + q[item_search_field] = model.getItem(row)[model_field]; + console.log(q); + + store.fetch({ + query : q, + onItem : function(item) { + value = store.getValue(item, item_part) + } + }); + console.log(value); + + return value; + } perm_grid = new dojox.grid.DataGrid({ query: {perm: '*'}, store: perm_map_store, @@ -516,6 +553,7 @@ dojo.addOnLoad(function() { console.log(perm_store.getValue(item)); }}); return ""; + //dojo.partial(get_item_part, "perm", "id", "code", this, perm_store), }, width : "auto" }, { @@ -608,6 +646,14 @@ dojo.addOnLoad(function() { dojo.connect(delete_pgpm_button, "onClick", delete_pgpm_button, function() { var selected_items = perm_grid.selection.getSelected(); +/** + var selected_items = []; + for (var i in selected_rows) { + selected_items.push(perm_grid.getItem(selected_rows[i]).__dojo_data_item); + } + perm_grid.selection.clear(); + * **/ + for (var i in selected_items) { window.current_perm_map = selected_items[i]; @@ -647,3 +693,4 @@ dojo.addOnLoad(function() { } }); }); + diff --git a/Open-ILS/web/js/dojo/openils/acq/Picklist.js b/Open-ILS/web/js/dojo/openils/acq/Picklist.js index 1245b820fa..391d319d63 100644 --- a/Open-ILS/web/js/dojo/openils/acq/Picklist.js +++ b/Open-ILS/web/js/dojo/openils/acq/Picklist.js @@ -19,8 +19,8 @@ dojo._hasResource['openils.acq.Picklist'] = true; dojo.provide('openils.acq.Picklist'); dojo.require('dojo.data.ItemFileWriteStore'); -//dojo.require('dojox.grid.Grid'); // Apparently not used here. -//dojo.require('dojox.grid.compat._data.model'); // Apparently not used here. +//dojo.require('dojox.grid.Grid'); +//dojo.require('dojox.grid.compat._data.model'); dojo.require('fieldmapper.Fieldmapper'); dojo.require('fieldmapper.dojoData'); dojo.require('openils.Event'); @@ -166,4 +166,3 @@ openils.acq.Picklist._deleteList = function(list, idx, onComplete) { } } - diff --git a/Open-ILS/web/js/ui/default/acq/common/jubgrid.js b/Open-ILS/web/js/ui/default/acq/common/jubgrid.js index 2edc3870f3..55db0028ac 100644 --- a/Open-ILS/web/js/ui/default/acq/common/jubgrid.js +++ b/Open-ILS/web/js/ui/default/acq/common/jubgrid.js @@ -116,12 +116,12 @@ var JUBGrid = { for (var i in lineitems) { JUBGrid.lineitems[lineitems[i].id()] = lineitems[i]; } -//FIXME JUBGrid.jubGrid = gridWidget; - JUBGrid.jubGrid.setModel(model); + JUBGrid.jubGrid = gridWidget; + //JUBGrid.jubGrid.setModel(model); if(JUBGrid.showDetails) { dojo.connect(gridWidget, "onRowClick", function(evt) { - var jub = model.getRow(evt.rowIndex); + var jub = JubGrid.jubGrid.getItem(evt.rowIndex); var grid; JUBGrid.jubDetailGrid.lineitemID = jub.id; @@ -139,7 +139,7 @@ var JUBGrid = { ); } // capture changes to lineitems - dojo.connect(model.store, "onSet", JUBGrid.onJUBSet); + dojo.connect(JUBGrid.jubGrid.store, "onSet", JUBGrid.onJUBSet); gridWidget.update(); }, @@ -223,10 +223,7 @@ var JUBGrid = { JUBGrid.lineitems = keepMe; deleteList(deleteMe, 0, function(){ - JUBGrid.jubGrid.model.store = - new dojo.data.ItemFileReadStore({data:jub.toStoreData(keepMe)}); - JUBGrid.jubGrid.model.refresh(); - JUBGrid.jubGrid.update(); + JUBGrid.jubGrid.store = new dojo.data.ItemFileReadStore({data:jub.toStoreData(keepMe)}); }); }, @@ -243,20 +240,18 @@ var JUBGrid = { alert("Error: "+evt.desc); } else { var deleteItem = function(item, rq) { - JUBGrid.jubDetailGrid.model.store.deleteItem(item); + JUBGrid.jubDetailGrid.store.deleteItem(item); }; var updateCount = function(item) { - var newval = JUBGrid.jubGrid.model.store.getValue(item, "item_count"); - JUBGrid.jubGrid.model.store.setValue(item, "item_count", newval-1); - JUBGrid.jubGrid.update(); + var newval = JUBGrid.jubGrid.store.getValue(item, "item_count"); + JUBGrid.jubGrid.store.setValue(item, "item_count", newval-1); }; - JUBGrid.jubDetailGrid.model.store.fetch({query:{id:lid.id}, + JUBGrid.jubDetailGrid.store.fetch({query:{id:lid.id}, onItem: deleteItem}); - JUBGrid.jubGrid.model.store.fetch({query:{id:JUBGrid.jubDetailGrid.lineitemID}, + JUBGrid.jubGrid.store.fetch({query:{id:JUBGrid.jubDetailGrid.lineitemID}, onItem: updateCount}); } - JUBGrid.jubDetailGrid.update(); }; openils.acq.Lineitem.deleteLID(lid.id, deleteFromStore); @@ -264,13 +259,18 @@ var JUBGrid = { }, createLID: function(fields) { + console.log(fields); fields['lineitem'] = JUBGrid.jubDetailGrid.lineitemID; + console.log(fields); + JUBGrid.jubDetailGrid.store.newItem(acqlid.toStoreData([lid]).items[0]); var addToStore = function (lid) { - JUBGrid.jubDetailGrid.model.store.newItem(acqlid.toStoreData([lid]).items[0]); - JUBGrid.jubDetailGrid.refresh(); - JUBGrid.jubGrid.update(); - JUBGrid.jubGrid.refresh(); + JUBGrid.jubDetailGrid.store.newItem(acqlid.toStoreData([lid]).items[0]); + //JUBGrid.jubDetailGrid.refresh(); + //JUBGrid.jubGrid.update(); + //JUBGrid.jubGrid.refresh(); } + console.log("added to store"); + console.log(addToStore()); openils.acq.Lineitem.createLID(fields, addToStore); }, @@ -314,6 +314,7 @@ var JUBGrid = { // called when a lineitem is edited onJUBSet: function (griditem, attr, oldVal,newVal) { + console.log("onJUBSet called"); var item; var updateDone = function(r) { @@ -382,3 +383,4 @@ var JUBGrid = { }, }; +