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.
17 "-//W3C//DTD XHTML 1.0 Transitional//EN"
18 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [
19 <!--#include virtual="/opac/locale/${locale}/conify.dtd"-->
22 <html xmlns="http://www.w3.org/1999/xhtml">
24 <title>&conify.org_unit_type.title;</title>
26 <style type="text/css">
27 @import url('/js/dojo/dojo/resources/dojo.css');
28 @import url('/js/dojo/dijit/themes/tundra/tundra.css');
29 @import url('/js/dojo/dojox/widget/Toaster/Toaster.css');
32 <style type="text/css">
37 margin: 0px 0px 0px 0px;
38 padding: 0px 0px 0px 0px;
51 <!-- The OpenSRF API writ JS -->
52 <script language='javascript' src='/IDL2js' type='text/javascript'></script>
53 <script language='javascript' src='/opac/common/js/utils.js' type='text/javascript'></script>
54 <script language='javascript' src='/opac/common/js/CGI.js' type='text/javascript'></script>
55 <script language='javascript' src='/opac/common/js/JSON_v1.js' type='text/javascript'></script>
57 <!-- Dojo goodness -->
58 <script type="text/javascript" src="../admin.js"></script>
59 <script type="text/javascript" src="/js/dojo/dojo/dojo.js"></script>
60 <script type="text/javascript" src="/js/dojo/dojo/openils_dojo.js"></script>
61 <script type="text/javascript" src="/js/dojo/dijit/dijit.js"></script>
63 <script type="text/javascript" src="org_unit_type.js"></script>
65 <script type="text/javascript">
69 var _out_type_list = pCRUD.retrieveAll('aout', { order_by : { aout : 'name' } });
71 var ou_type_store = new dojo.data.ItemFileWriteStore({ data : aout.toStoreData( _out_type_list ) });
73 ou_type_store.onSet = function (item, attr, o, n) {
74 if (attr == 'ischanged') return;
76 this.setValue( item, 'ischanged', 1);
79 dojo.addOnUnload( function (event) {
82 query : { ischanged : 1 },
83 queryOptions : { deep : true },
84 onItem : function (item, req) { try { if (this.isItem( item )) dirtyStore.push( item ); } catch (e) { /* meh */ } },
88 if (dirtyStore.length > 0) {
89 var confirmation = confirm(
90 aout_strings.CONFIRM_UNSAVED_CHANGES
94 for (var i in dirtyStore) {
95 current_type = dirtyStore[i];
107 <body class="tundra" id='pagebody'>
109 <div dojoType="dijit.layout.SplitContainer" orientation="horizontal" style="height: 100%">
111 <div dojoType="dijit.layout.ContentPane" sizeShare="100">
114 label="&conify.org_unit_type.type_tree.label;"
115 query="{'_top':'true'}"
116 dojoType="dijit.Tree"
117 store="ou_type_store"
122 <script type="dojo/method" event="onClick" args="item,node">
124 right_pane_toggler.show();
126 current_fm_type = new aout().fromStoreItem(item);
128 highlighter.editor_pane.green.play();
129 status_update( dojo.string.substitute( aout_strings.STATUS_EDITING, [this.store.getValue( item, 'name' )] ) );
131 new_kid_button.disabled = false;
132 save_out_button.disabled = false;
133 delete_out_button.disabled = false;
135 var main_settings_fields = [ 'name', 'opac_label'];
136 for ( var i in main_settings_fields ) {
137 var field = main_settings_fields[i];
138 var value = this.store.getValue( current_type, field );
141 window["editor_pane_" + field].setValue( '' ); // unset the value
142 window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
143 } else window["editor_pane_" + field].setValue( value );
146 if ( this.store.getValue( current_type, '_trueRoot' ) == 'true' ) {
147 editor_pane_parent.disabled = true;
148 editor_pane_parent.setValue(null);
149 editor_pane_parent.setDisplayedValue('');
150 editor_pane_parent.validate(false);
152 editor_pane_parent.disabled = false;
153 editor_pane_parent.validate(true);
154 editor_pane_parent.setValue( this.store.getValue( current_type, 'parent' ) );
157 editor_pane_can_have_vols.setChecked( this.store.getValue( current_type, 'can_have_vols' ) == 't' ? true : false );
158 editor_pane_can_have_users.setChecked( this.store.getValue( current_type, 'can_have_users' ) == 't' ? true : false );
162 <script type="dojo/method" event="getLabel" args="item,pI">
163 var label = this.store.getValue(item,'name');
164 if (this.store.getValue(item,'ischanged') == 1) label = '* ' + label;
171 <div id="right_pane" dojoType="dijit.layout.ContentPane" sizeShare="200">
172 <script type="dojo/method">
173 window.right_pane_toggler = new dojo.fx.Toggler({ node: 'right_pane'});
174 window.right_pane_toggler.hide();
177 <div id="editor_pane" dojoType="dijit.layout.ContentPane">
178 <script type="dojo/method">
179 highlighter.type_tree = {};
180 highlighter.editor_pane = {};
181 highlighter.type_tree.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'type_tree', duration : 500 } );
182 highlighter.type_tree.red = dojox.fx.highlight( { color : '#FF2018', node : 'type_tree', duration : 500 } );
183 highlighter.editor_pane.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'editor_pane', duration : 500 } );
184 highlighter.editor_pane.red = dojox.fx.highlight( { color : '#FF2018', node : 'editor_pane', duration : 500 } );
187 <table class="tundra" style="margin:10px;">
189 <th>&conify.org_unit_type.type_name;</th>
191 <span id="editor_pane_name" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_name" regExp=".+" required="true">
192 <script type="dojo/connect" event="onChange">
194 ou_type_store.setValue( current_type, "name", this.getValue() );
198 <span dojoType="openils.widget.TranslatorPopup" targetObject="current_fm_type" field="name"></span>
202 <th>&conify.org_unit_type.opac_label;</th>
204 <span id="editor_pane_opac_label" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_opac_label" regExp=".+" required="true">
205 <script type="dojo/connect" event="onChange">
207 ou_type_store.setValue( current_type, "opac_label", this.getValue() );
211 <span dojoType="openils.widget.TranslatorPopup" targetObject="current_fm_type" field="opac_label"></span>
215 <th>&conify.org_unit_type.parent_type;</th>
218 id="editor_pane_parent"
219 dojoType="dijit.form.FilteringSelect"
220 jsId="editor_pane_parent"
221 store="ou_type_store"
226 <script type="dojo/method" event="onChange">
228 if (current_type && this.getValue()) {
229 if ( this.store.getValue( current_type, 'parent' ) == this.getValue() ) return;
231 this.store.setValue( current_type, "parent", this.getValue() );
233 query : { "parent" : this.getValue() },
234 onItem: function (parent_item) {
235 this.setValue( current_type, 'depth', 1 + parseInt(this.getValue( parent_item, 'depth' ) ));
237 scope : ou_type_store
246 <th>&conify.org_unit_type.can_have_volumes;</th>
249 id="editor_pane_can_have_vols"
250 jsId="editor_pane_can_have_vols"
252 dojoType="dijit.form.CheckBox"
253 onChange="if (current_type) ou_type_store.setValue( current_type, 'can_have_vols', this.checked ? 't' : 'f' );"
258 <th>&conify.org_unit_type.can_have_users;</th>
261 id="editor_pane_can_have_users"
262 jsId="editor_pane_can_have_users"
264 dojoType="dijit.form.CheckBox"
265 onChange="if (current_type) ou_type_store.setValue( current_type, 'can_have_users', this.checked ? 't' : 'f' );"
271 <div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 20px;">
273 <button jsId="save_out_button" dojoType="dijit.form.Button" label="&conify.save_button.label;" onClick="save_type()">
274 <script type="dojo/connect" event="startup">
275 this.disabled = true;
279 <button jsId="delete_out_button" dojoType="dijit.form.Button" label="&conify.delete_button.label;">
280 <script type="dojo/connect" event="startup">
281 this.disabled = true;
283 <script type="dojo/connect" event="onClick">
286 if (ou_type_store.getValue( current_type, '_trueRoot' ) == 'true') {
287 highlighter.editor_pane.red.play();
288 status_update( dojo.string.substitute( aout_strings.ERROR_DELETING_LAST_AOUT, [ou_type_store.getValue( current_type, 'name' )] ) );
292 if ( current_type.children ) {
293 var kids = current_type.children;
294 if (!dojo.isArray(kids)) kids = [kids];
296 var existing_kids = dojo.filter(
298 function(kid){ return kid.isdeleted[0] != 1 }
300 if ( existing_kids.length > 0) {
301 highlighter.editor_pane.red.play();
302 status_update( dojo.string.substitute( aout_strings.ERROR_ORPHANS, [ou_type_store.getValue( current_type, 'name' ), existing_kids.length] ) );
307 if ( confirm( dojo.string.substitute ( aout_strings.CONFIRM_DELETE, [current_type.name] ))) {
308 ou_type_store.setValue( current_type, 'isdeleted', 1 );
310 var modified_aout = new aout().fromStoreItem( current_type );
311 modified_aout.isdeleted( 1 );
313 pCRUD.eliminate(modified_aout, {
314 onerror : function (r) {
315 highlighter.editor_pane.red.play();
316 status_update( dojo.string.substitute ( aout_strings.ERROR_DELETING, [ou_type_store.getValue( current_type, 'name' )] ) );
318 oncomplete : function (r) {
320 var old_name = ou_type_store.getValue( current_type, 'name' );
322 ou_type_store.fetch({
323 query : { id : ou_type_store.getValue( current_type, 'id' ) },
324 queryOptions : { deep : true },
325 onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
326 scope : ou_type_store
331 new_kid_button.disabled = true;
332 save_out_button.disabled = true;
333 delete_out_button.disabled = true;
335 var main_settings_fields = [ 'name', 'opac_label' ];
336 for ( var i in main_settings_fields ) {
337 var field = main_settings_fields[i];
338 window["editor_pane_" + field].setValue( '' ); // unset the value
339 window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
342 window["editor_pane_can_have_vols"].setChecked( false ); // unset the value
343 window["editor_pane_can_have_users"].setChecked( false ); // unset the value
345 highlighter.editor_pane.green.play();
346 status_update( dojo.string.substitute( aout_strings.STATUS_DELETED, [old_name] ) );
357 <button jsId="new_kid_button" dojoType="dijit.form.Button" label="&conify.new_kid_button.label;">
358 <script type="dojo/connect" event="startup">
359 this.disabled = true;
361 <script type="dojo/connect" event="onClick">
363 var new_fm_obj = new aout().fromHash({
365 name : aout_strings.LABEL_NEW_TYPE,
367 can_have_users : 'f',
368 depth : 1 + parseInt(ou_type_store.getValue( current_type, 'depth' )),
369 opac_label : ou_type_store.getValue( current_type, 'opac_label' ) + ' child' + virgin_out_id--,
370 parent : ou_type_store.getValue( current_type, 'id' )
373 pCRUD.create(new_fm_obj, {
374 onerror : function (r) {
375 highlighter.editor_pane.red.play();
376 status_update( aout_strings.ERROR_CALLING_METHOD_AOUT );
379 oncomplete : function (r, list) {
380 ou_type_store.newItem(
382 { parent : current_type, attribute : 'children' }
388 highlighter.editor_pane.green.play();
389 highlighter.type_tree.green.play();
390 status_update( dojo.string.substitute( aout_strings.SUCCESS_CREATING_CHILD_AOUT, [ou_type_store.getValue( current_type, 'name' )] ) );