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.
16 "-//W3C//DTD XHTML 1.0 Transitional//EN"
17 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [
18 <!--#include virtual="/opac/locale/${locale}/conify.dtd"-->
20 <html xmlns="http://www.w3.org/1999/xhtml">
22 <title>&conify.copy_status.title;</title>
24 <style type="text/css">
25 @import url('/js/dojo/dojox/grid/_grid/tundraGrid.css');
26 @import url('/js/dojo/dojo/resources/dojo.css');
27 @import url('/js/dojo/dijit/themes/tundra/tundra.css');
28 @import url('/js/dojo/dojox/widget/Toaster/Toaster.css');
35 margin: 0px 0px 0px 0px;
36 padding: 0px 0px 0px 0px;
52 <!-- The OpenSRF API writ JS -->
53 <script language='javascript' src='/opac/common/js/utils.js' type='text/javascript'></script>
54 <script language='javascript' src='/opac/common/js/Cookies.js' type='text/javascript'></script>
55 <script language='javascript' src='/opac/common/js/CGI.js' type='text/javascript'></script>
56 <script language='javascript' src='/opac/common/js/JSON_v1.js' type='text/javascript'></script>
58 <!-- Dojo goodness -->
59 <script type="text/javascript" src="../admin.js"></script>
60 <script type="text/javascript" src="/js/dojo/dojo/dojo.js"></script>
61 <script type="text/javascript" src="/js/dojo/dojo/openils_dojo.js"></script>
62 <script type="text/javascript" src="/js/dojo/dijit/dijit.js"></script>
64 <script type="text/javascript" src="copy_status.js"></script>
66 <script type="text/javascript">
69 highlighter.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'grid_container', duration : 500 } );
70 highlighter.red = dojox.fx.highlight( { color : '#FF2018', node : 'grid_container', duration : 500 } );
74 var _status_list = pCRUD.retrieveAll('ccs', { order_by : { ccs : 'name' } });
75 var _status_data = ccs.toStoreData( _status_list, 'name' );
76 var status_store = new dojo.data.ItemFileWriteStore({ data : _status_data });
78 status_store.onSet = function (item, attr, o, n) {
79 if (attr == 'ischanged') return;
81 this.setValue( item, 'ischanged', 1);
83 if (attr == 'holdable' && typeof n != 'string')
84 this.setValue(item, 'holdable', n ? 't' : 'f');
86 if (attr == 'opac_visible' && typeof n != 'string')
87 this.setValue(item, 'opac_visible', n ? 't' : 'f');
91 dojo.addOnUnload( function (event) {
94 query : { ischanged : 1 },
95 onItem : function (item, req) { try { if (this.isItem( item )) dirtyStore.push( item ); } catch (e) { /* meh */ } },
99 if (dirtyStore.length > 0) {
100 var confirmation = confirm(
101 ccs_strings.CONFIRM_EXIT_CCS
105 for (var i in window.dirtyStore) {
106 current_status = dirtyStore[i];
118 <body class="tundra" id='pagebody'>
120 <div dojoType="dijit.layout.LayoutContainer" id="grid_container" jsId="grid_container" orientation="vertical">
122 <div dojoType="dijit.layout.LayoutContainer" orientation="horizontal" style="margin-top: 5px;" layoutAlign="top">
123 <span>&conify.copy_status.new_status.label;</span>
124 <div dojoType="dijit.form.TextBox" id="new_status_code" jsId="new_status_name" label="&conify.copy_status.new_status.name;"></div>
125 <button dojoType="dijit.form.Button" id="save_new_status_code" jsId="save_new_status_name" label="&conify.copy_status.new_status.save;">
126 <script type="dojo/connect" event="onClick">
128 var new_name = new_status_name.getValue();
129 if (!new_name) return;
131 var new_fm_obj = new ccs().fromHash({
137 pCRUD.create(new_fm_obj, {
138 onerror : function (r) {
139 highlighter.red.play();
140 status_update( ccs_strings.ERROR_CALLING_METHOD_CCS );
143 oncomplete : function (r, list) {
144 var new_item_hash = list[0].toHash();
145 status_store.newItem( new_item_hash );
146 status_update( dojo.string.substitute(ccs_strings.SUCCESS_CREATING_STATUS, [new_item_hash.name]) );
147 status_grid.model.sort(-2);
148 highlighter.green.play();
156 <div dojoType="dijit.layout.ContentPane" style="width:100%; height:100%;" layoutAlign="client">
157 <div dojoType="dojox.grid.data.DojoData" id="status_data_model" jsId="status_data_model" store="status_store" query="{ 'id' : '*' }"></div>
158 <div id="status_grid" dojoType="dojox.Grid" jsId="status_grid">
159 <script type="dojo/connect" event="startup">
162 var status_grid_layout = [
165 { name : ccs_strings.ID,
168 { name : ccs_strings.NAME,
171 editor : dojox.grid.editors.Dijit
173 { name : ccs_strings.TRANSLATION,
176 get : function (row) {
177 if (!window.status_rows) window.status_rows = [];
178 var r = window.status_data_model.getRow(row);
180 window.status_rows[row] = new ccs().fromHash(window.status_data_model.getRow(row));
182 'dojo.query(".status_grid_trans_cell_' + row + '").'+
183 'instantiate(openils.widget.TranslatorPopup,{field:"name",'+
184 'targetObject:"window.status_rows['+row+']"});'+
185 'status_grid.rowHeightChanged('+row+')',
188 return '<span class="status_grid_trans_cell_'+row+'"></span>';
193 { name : ccs_strings.HOLDABLE,
195 editor : dojox.grid.editors.bool,
196 get : function (row) {
197 var r = window.status_data_model.getRow(row);
200 if (h == 't' || h === true) return true;
205 { name : ccs_strings.OPAC_VISIBLE,
206 field : "opac_visible",
207 editor : dojox.grid.editors.bool,
208 get : function (row) {
209 var r = window.status_data_model.getRow(row);
211 var h = r.opac_visible;
212 if (h == 't' || h === true) return true;
222 this.setStructure(status_grid_layout);
223 this.setModel(window.status_data_model);
229 <div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 5px;" layoutAlign="bottom">
231 <button jsId="save_ccs_button" dojoType="dijit.form.Button" label="&conify.copy_status.save_changes;" onClick="save_them_all()"></button>
233 <button jsId="delete_ccs_button" dojoType="dijit.form.Button" label="&conify.copy_status.delete_selected;">
234 <script type="dojo/connect" event="onClick">
236 var selected_rows = status_grid.selection.getSelected();
238 var selected_items = [];
239 for (var i in selected_rows) {
241 status_grid.model.getRow( selected_rows[i] ).__dojo_data_item
245 status_grid.selection.clear();
247 for (var i in selected_items) {
248 current_status = selected_items[i];
250 if ( confirm(dojo.string.substitute(ccs_strings.CONFIRM_DELETE, [status_store.getValue( current_status, 'name' )]))) {
252 status_store.setValue( current_status, 'isdeleted', 1 );
254 var modified_ccs = new ccs().fromStoreItem( current_status );
255 modified_ccs.isdeleted( 1 );
257 pCRUD.eliminate(modified_ccs, {
258 onerror : function (r) {
259 highlighter.red.play();
260 status_update( dojo.string.substitute( ccs_strings.ERROR_DELETING, [status_store.getValue( current_status, 'name' )] ) );
262 oncomplete : function (r) {
263 var old_name = status_store.getValue( current_status, 'name' );
266 query : { id : status_store.getValue( current_status, 'id' ) },
267 onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
271 current_status = null;
273 highlighter.green.play();
274 status_update( dojo.string.substitute(ccs_strings.STATUS_DELETED, [old_name]) );