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/dijit/dijit.js"></script>
62 <script type="text/javascript" src="org_unit_type.js"></script>
64 <script type="text/javascript">
68 var _out_type_list = pCRUD.retrieveAll('aout', { order_by : { aout : 'name' } });
70 var ou_type_store = new dojo.data.ItemFileWriteStore({ data : aout.toStoreData( _out_type_list ) });
72 ou_type_store.onSet = function (item, attr, o, n) {
73 if (attr == 'ischanged') return;
75 this.setValue( item, 'ischanged', 1);
78 dojo.addOnUnload( function (event) {
81 query : { ischanged : 1 },
82 queryOptions : { deep : true },
83 onItem : function (item, req) { try { if (this.isItem( item )) dirtyStore.push( item ); } catch (e) { /* meh */ } },
87 if (dirtyStore.length > 0) {
88 var confirmation = confirm(
89 aout_strings.CONFIRM_UNSAVED_CHANGES
93 for (var i in dirtyStore) {
94 current_type = dirtyStore[i];
106 <body class="tundra" id='pagebody'>
108 <div dojoType="dijit.layout.SplitContainer" orientation="horizontal" style="height: 100%">
110 <div dojoType="dijit.layout.ContentPane" sizeShare="100">
113 label="&conify.org_unit_type.type_tree.label;"
114 query="{'_top':'true'}"
115 dojoType="dijit.Tree"
116 store="ou_type_store"
121 <script type="dojo/method" event="onClick" args="item,node">
123 right_pane_toggler.show();
125 current_fm_type = new aout().fromStoreItem(item);
127 highlighter.editor_pane.green.play();
128 status_update( dojo.string.substitute( aout_strings.STATUS_EDITING, [this.store.getValue( item, 'name' )] ) );
130 new_kid_button.disabled = false;
131 save_out_button.disabled = false;
132 delete_out_button.disabled = false;
134 var main_settings_fields = [ 'name', 'opac_label'];
135 for ( var i in main_settings_fields ) {
136 var field = main_settings_fields[i];
137 var value = this.store.getValue( current_type, field );
140 window["editor_pane_" + field].setValue( '' ); // unset the value
141 window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
142 } else window["editor_pane_" + field].setValue( value );
145 if ( this.store.getValue( current_type, '_trueRoot' ) == 'true' ) {
146 editor_pane_parent.disabled = true;
147 editor_pane_parent.setValue(null);
148 editor_pane_parent.setDisplayedValue('');
149 editor_pane_parent.validate(false);
151 editor_pane_parent.disabled = false;
152 editor_pane_parent.validate(true);
153 editor_pane_parent.setValue( this.store.getValue( current_type, 'parent' ) );
156 editor_pane_can_have_vols.setChecked( this.store.getValue( current_type, 'can_have_vols' ) == 't' ? true : false );
157 editor_pane_can_have_users.setChecked( this.store.getValue( current_type, 'can_have_users' ) == 't' ? true : false );
161 <script type="dojo/method" event="getLabel" args="item,pI">
162 var label = this.store.getValue(item,'name');
163 if (this.store.getValue(item,'ischanged') == 1) label = '* ' + label;
170 <div id="right_pane" dojoType="dijit.layout.ContentPane" sizeShare="200">
171 <script type="dojo/method">
172 window.right_pane_toggler = new dojo.fx.Toggler({ node: 'right_pane'});
173 window.right_pane_toggler.hide();
176 <div id="editor_pane" dojoType="dijit.layout.ContentPane">
177 <script type="dojo/method">
178 highlighter.type_tree = {};
179 highlighter.editor_pane = {};
180 highlighter.type_tree.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'type_tree', duration : 500 } );
181 highlighter.type_tree.red = dojox.fx.highlight( { color : '#FF2018', node : 'type_tree', duration : 500 } );
182 highlighter.editor_pane.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'editor_pane', duration : 500 } );
183 highlighter.editor_pane.red = dojox.fx.highlight( { color : '#FF2018', node : 'editor_pane', duration : 500 } );
186 <table class="tundra" style="margin:10px;">
188 <th>&conify.org_unit_type.type_name;</th>
190 <span id="editor_pane_name" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_name" regExp=".+" required="true">
191 <script type="dojo/connect" event="onChange">
193 ou_type_store.setValue( current_type, "name", this.getValue() );
197 <span dojoType="openils.widget.TranslatorPopup" targetObject="current_fm_type" field="name"></span>
201 <th>&conify.org_unit_type.opac_label;</th>
203 <span id="editor_pane_opac_label" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_opac_label" regExp=".+" required="true">
204 <script type="dojo/connect" event="onChange">
206 ou_type_store.setValue( current_type, "opac_label", this.getValue() );
210 <span dojoType="openils.widget.TranslatorPopup" targetObject="current_fm_type" field="opac_label"></span>
214 <th>&conify.org_unit_type.parent_type;</th>
217 id="editor_pane_parent"
218 dojoType="dijit.form.FilteringSelect"
219 jsId="editor_pane_parent"
220 store="ou_type_store"
225 <script type="dojo/method" event="onChange">
227 if (current_type && this.getValue()) {
228 if ( this.store.getValue( current_type, 'parent' ) == this.getValue() ) return;
230 this.store.setValue( current_type, "parent", this.getValue() );
232 query : { "parent" : this.getValue() },
233 onItem: function (parent_item) {
234 this.setValue( current_type, 'depth', 1 + parseInt(this.getValue( parent_item, 'depth' ) ));
236 scope : ou_type_store
245 <th>&conify.org_unit_type.can_have_volumes;</th>
248 id="editor_pane_can_have_vols"
249 jsId="editor_pane_can_have_vols"
251 dojoType="dijit.form.CheckBox"
252 onChange="if (current_type) ou_type_store.setValue( current_type, 'can_have_vols', this.checked ? 't' : 'f' );"
257 <th>&conify.org_unit_type.can_have_users;</th>
260 id="editor_pane_can_have_users"
261 jsId="editor_pane_can_have_users"
263 dojoType="dijit.form.CheckBox"
264 onChange="if (current_type) ou_type_store.setValue( current_type, 'can_have_users', this.checked ? 't' : 'f' );"
270 <div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 20px;">
272 <button jsId="save_out_button" dojoType="dijit.form.Button" label="&conify.save_button.label;" onClick="save_type()">
273 <script type="dojo/connect" event="startup">
274 this.disabled = true;
278 <button jsId="delete_out_button" dojoType="dijit.form.Button" label="&conify.delete_button.label;">
279 <script type="dojo/connect" event="startup">
280 this.disabled = true;
282 <script type="dojo/connect" event="onClick">
285 if (ou_type_store.getValue( current_type, '_trueRoot' ) == 'true') {
286 highlighter.editor_pane.red.play();
287 status_update( dojo.string.substitute( aout_strings.ERROR_DELETING_LAST_AOUT, [ou_type_store.getValue( current_type, 'name' )] ) );
291 if ( current_type.children ) {
292 var kids = current_type.children;
293 if (!dojo.isArray(kids)) kids = [kids];
295 var existing_kids = dojo.filter(
297 function(kid){ return kid.isdeleted[0] != 1 }
299 if ( existing_kids.length > 0) {
300 highlighter.editor_pane.red.play();
301 status_update( dojo.string.substitute( aout_strings.ERROR_ORPHANS, [ou_type_store.getValue( current_type, 'name' ), existing_kids.length] ) );
306 if ( confirm( dojo.string.substitute ( aout_strings.CONFIRM_DELETE, [current_type.name] ))) {
307 ou_type_store.setValue( current_type, 'isdeleted', 1 );
309 var modified_aout = new aout().fromStoreItem( current_type );
310 modified_aout.isdeleted( 1 );
312 pCRUD.eliminate(modified_aout, {
313 onerror : function (r) {
314 highlighter.editor_pane.red.play();
315 status_update( dojo.string.substitute ( aout_strings.ERROR_DELETING, [ou_type_store.getValue( current_type, 'name' )] ) );
317 oncomplete : function (r) {
319 var old_name = ou_type_store.getValue( current_type, 'name' );
321 ou_type_store.fetch({
322 query : { id : ou_type_store.getValue( current_type, 'id' ) },
323 queryOptions : { deep : true },
324 onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
325 scope : ou_type_store
330 new_kid_button.disabled = true;
331 save_out_button.disabled = true;
332 delete_out_button.disabled = true;
334 var main_settings_fields = [ 'name', 'opac_label' ];
335 for ( var i in main_settings_fields ) {
336 var field = main_settings_fields[i];
337 window["editor_pane_" + field].setValue( '' ); // unset the value
338 window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
341 window["editor_pane_can_have_vols"].setChecked( false ); // unset the value
342 window["editor_pane_can_have_users"].setChecked( false ); // unset the value
344 highlighter.editor_pane.green.play();
345 status_update( dojo.string.substitute( aout_strings.STATUS_DELETED, [old_name] ) );
356 <button jsId="new_kid_button" dojoType="dijit.form.Button" label="&conify.new_kid_button.label;">
357 <script type="dojo/connect" event="startup">
358 this.disabled = true;
360 <script type="dojo/connect" event="onClick">
362 var new_fm_obj = new aout().fromHash({
364 name : aout_strings.LABEL_NEW_TYPE,
366 can_have_users : 'f',
367 depth : 1 + parseInt(ou_type_store.getValue( current_type, 'depth' )),
368 opac_label : ou_type_store.getValue( current_type, 'opac_label' ) + ' child' + virgin_out_id--,
369 parent : ou_type_store.getValue( current_type, 'id' )
372 pCRUD.create(new_fm_obj, {
373 onerror : function (r) {
374 highlighter.editor_pane.red.play();
375 status_update( aout_strings.ERROR_CALLING_METHOD_AOUT );
378 oncomplete : function (r, list) {
379 ou_type_store.newItem(
381 { parent : current_type, attribute : 'children' }
387 highlighter.editor_pane.green.play();
388 highlighter.type_tree.green.play();
389 status_update( dojo.string.substitute( aout_strings.SUCCESS_CREATING_CHILD_AOUT, [ou_type_store.getValue( current_type, 'name' )] ) );