2 # Copyright (C) 2008 Georgia Public Library Service / Equinox Software, Inc
3 # Mike Rylander <miker@esilibrary.com>
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 <html xmlns="http://www.w3.org/1999/xhtml">
17 <title>Confiy :: Global :: Config :: Copy Status</title>
19 <style type="text/css">
20 @import url("/js/dojo/dojox/grid/_grid/tundraGrid.css");
21 @import url("/js/dojo/dojo/resources/dojo.css");
22 @import url("/js/dojo/dijit/themes/tundra/tundra.css");
23 @import url("/js/dojo/dojox/widget/Toaster/Toaster.css");
30 margin: 0px 0px 0px 0px;
31 padding: 0px 0px 0px 0px;
47 <!-- The OpenSRF API writ JS -->
48 <script language='javascript' src='/opac/common/js/utils.js' type='text/javascript'></script>
49 <script language='javascript' src='/opac/common/js/Cookies.js' type='text/javascript'></script>
50 <script language='javascript' src='/opac/common/js/CGI.js' type='text/javascript'></script>
51 <script language='javascript' src='/opac/common/js/JSON_v1.js' type='text/javascript'></script>
53 <!-- Fieldmapper objects -->
54 <script language='javascript' src='/opac/common/js/fmall.js' type='text/javascript'></script>
56 <!-- Dojo goodness -->
57 <script type="text/javascript" src="/js/dojo/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
58 <script type="text/javascript" src="/js/dojo/dijit/dijit.js"></script>
60 <script type="text/javascript" src="copy_status.js"></script>
64 <body class="tundra" id='pagebody'>
66 <div dojoType="dijit.layout.LayoutContainer" id="grid_container" jsId="grid_container" orientation="vertical">
67 <script type="dojo/method">
68 window.highlighter= {};
69 window.highlighter.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'grid_container', duration : 500 } );
70 window.highlighter.red = dojox.fx.highlight( { color : '#FF2018', node : 'grid_container', duration : 500 } );
72 window.dirtyStore = [];
75 method : 'open-ils.permacrud.search.ccs.atomic',
77 params : [ ses, { id : { "!=" : null } }, { order_by : { ccs : 'name' } } ],
78 onerror : function (r) { status_update('Problem fetching statuses') },
79 oncomplete : function (r) {
81 window._status_list = r.recv().content();
82 window._status_data = ccs.toStoreData( window._status_list, 'name' );
83 window.status_store = new dojo.data.ItemFileWriteStore({ data : window._status_data });
85 window.status_store.onSet = function (item, attr, o, n) {
86 if (attr == 'ischanged') return;
88 this.setValue( item, 'ischanged', 1);
90 if (attr == 'holdable' && typeof n != 'string')
91 this.setValue(item, 'holdable', n ? 't' : 'f');
95 dojo.addOnUnload( function (event) {
98 query : { ischanged : 1 },
99 onItem : function (item, req) { try { if (this.isItem( item )) window.dirtyStore.push( item ); } catch (e) { /* meh */ } },
103 if (dirtyStore.length > 0) {
104 var confirmation = confirm(
105 'There are unsaved modified Statuses! '+
106 'OK to save these changes, Cancel to abandon them.'
110 for (var i in window.dirtyStore) {
111 window.current_status = window.dirtyStore[i];
123 <div dojoType="dijit.layout.LayoutContainer" orientation="horizontal" style="margin-top: 5px;" layoutAlign="top">
124 <span>New Status:</span>
125 <div dojoType="dijit.form.TextBox" id="new_status_code" jsId="new_status_name" label="New Status Name"></div>
126 <button dojoType="dijit.form.Button" id="save_new_status_code" jsId="save_new_status_name" label="Add">
127 <script type="dojo/connect" event="onClick">
129 var new_name = new_status_name.getValue();
130 if (!new_name) return;
132 var new_fm_obj = new ccs().fromHash({
139 method : 'open-ils.permacrud.create.ccs',
141 params : [ ses, new_fm_obj ],
142 onerror : function (r) {
143 highlighter.red.play();
144 status_update( 'Problem calling method to create new Status' );
147 oncomplete : function (r) {
149 if ( res && res.content() ) {
150 var new_item_hash = res.content().toHash();
151 status_store.newItem( new_item_hash );
152 status_update( 'New ' + new_item_hash.name + ' status created' );
153 status_grid.model.sort(-2);
154 highlighter.green.play();
156 highlighter.red.play();
157 status_update( 'Problem creating new Status' );
167 <div dojoType="dijit.layout.ContentPane" style="width:100%; height:100%;" layoutAlign="client">
168 <div dojoType="dojox.grid.data.DojoData" id="status_data_model"jsId="status_data_model" store="status_store" query="{ 'id' : '*' }"></div>
169 <div id="status_grid" dojoType="dojox.Grid" jsId="status_grid">
170 <script type="dojo/connect" event="startup">
172 var status_grid_layout = [
181 editor : dojox.grid.editors.Dijit
185 editor : dojox.grid.editors.bool,
186 get : function (row) {
187 var r = window.status_data_model.getRow(row);
190 if (h == 't' || h === true) return true;
200 this.setStructure(status_grid_layout);
201 this.setModel(window.status_data_model);
206 <div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 5px;" layoutAlign="bottom">
208 <button jsId="save_ccs_button" dojoType="dijit.form.Button" label="Save Changes" onClick="save_them_all()"></button>
210 <button jsId="delete_ccs_button" dojoType="dijit.form.Button" label="Delete Selected">
211 <script type="dojo/connect" event="onClick">
213 var selected_rows = status_grid.selection.getSelected();
215 var selected_items = [];
216 for (var i in selected_rows) {
218 status_grid.model.getRow( selected_rows[i] ).__dojo_data_item
222 status_grid.selection.clear();
224 for (var i in selected_items) {
225 current_status = selected_items[i];
227 if ( confirm('Are you sure you want to delete ' + status_store.getValue( current_status, 'name' ) + '?')) {
229 status_store.setValue( current_status, 'isdeleted', 1 );
231 var modified_ccs = new ccs().fromStoreItem( current_status );
232 modified_ccs.isdeleted( 1 );
235 method : 'open-ils.permacrud.delete.ccs',
237 params : [ ses, modified_ccs ],
238 onerror : function (r) {
239 highlighter.red.play();
240 status_update( 'Problem deleting ' + status_store.getValue( current_status, 'name' ) );
242 oncomplete : function (r) {
244 if ( res && res.content() ) {
246 var old_name = status_store.getValue( current_status, 'name' );
249 query : { id : status_store.getValue( current_status, 'id' ) },
250 onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
254 current_status = null;
256 highlighter.green.play();
257 status_update( old_name + ' deleted' );
259 highlighter.red.play();
260 status_update( 'Problem deleting ' + old_name );