[open-ils-commits] r14244 - in trunk/Open-ILS/xul/staff_client/chrome: content/admin locale/en-US (phasefx)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Oct 2 00:32:54 EDT 2009
Author: phasefx
Date: 2009-10-02 00:32:51 -0400 (Fri, 02 Oct 2009)
New Revision: 14244
Modified:
trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey.js
trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey_overlay.xul
trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties
Log:
Make the old survey wizard use work locations instead of home lib
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey.js 2009-10-02 03:07:34 UTC (rev 14243)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey.js 2009-10-02 04:32:51 UTC (rev 14244)
@@ -4,53 +4,64 @@
var last_answer;
var last_button;
-function populate_lib_list_with_branch(menulist,menupopup,defaultlib,branch,id_flag) {
- JSAN.use('util.fm_utils');
- var default_menuitem;
- if (typeof defaultlib == 'object') {
- defaultlib = defaultlib.id();
- }
- var popup = menupopup;
- if (typeof(popup)!='object') popup = document.getElementById(menupopup);
- if (popup) {
- //empty_widget(popup);
- var padding_flag = true;
- var flat_branch = util.fm_utils.flatten_ou_branch( branch );
- for (var i in flat_branch) {
- var menuitem = document.createElement('menuitem');
- var padding = '';
- var depth = g.OpenILS.data.hash.aout[ flat_branch[i].ou_type() ].depth();
- if (padding_flag) {
- for (var j = 0; j < depth; j++) {
- padding = padding + ' ';
- }
- }
- menuitem.setAttribute('label', padding + flat_branch[i].name() );
- menuitem.setAttribute('value', flat_branch[i].id() );
- if (id_flag) menuitem.setAttribute('id', 'libitem' + flat_branch[i].id() );
- if (defaultlib == flat_branch[i].id()) {
- default_menuitem = menuitem;
- }
- popup.appendChild(menuitem);
- }
- var list = menulist;
- if (typeof(list)!='object') { list = document.getElementById(menulist); }
- if (list && defaultlib && default_menuitem) {
- if (list) { list.selectedItem = default_menuitem; }
- }
- } else {
- var err = ('populate_lib_list_with_branch: Could not find ' + menupopup + '\n');
- dump(err);
- alert(err);
- }
+function render_lib_menu() {
+ try {
+ JSAN.use('util.functional'); JSAN.use('util.fm_utils'); JSAN.use('util.widgets');
+
+ var work_ous = g.network.simple_request(
+ 'PERM_RETRIEVE_WORK_OU',
+ [ ses(), 'CREATE_SURVEY']
+ );
+ if (work_ous.length == 0) {
+ alert(document.getElementById('offlineStrings').getString('menu.cmd_survey_wizard.inadequate_perm'));
+ window.close();
+ return;
+ }
+ var my_libs = [];
+ for (var i = 0; i < work_ous.length; i++ ) {
+ var perm_depth = g.OpenILS.data.hash.aout[ g.OpenILS.data.hash.aou[ work_ous[i] ].ou_type() ].depth();
+
+ var my_libs_tree = g.network.simple_request(
+ 'FM_AOU_DESCENDANTS_RETRIEVE',
+ [ work_ous[i], perm_depth ]
+ );
+ if (!instanceOf(my_libs_tree,aou)) { /* FIXME - workaround for weird descendants call result */
+ my_libs_tree = my_libs_tree[0];
+ }
+ my_libs = my_libs.concat( util.fm_utils.flatten_ou_branch( my_libs_tree ) );
+ }
+
+ var x = document.getElementById('placeholder');
+ util.widgets.remove_children( x );
+
+ var default_lib = my_libs[0].id();
+
+ var ml = util.widgets.make_menulist(
+ util.functional.map_list(
+ my_libs,
+ function(obj) {
+ return [
+ obj.shortname(),
+ obj.id(),
+ false,
+ ( g.OpenILS.data.hash.aout[ obj.ou_type() ].depth() )
+ ];
+ }
+ ),
+ default_lib
+ );
+ ml.setAttribute('id','lib_menulist');
+
+ x.appendChild( ml );
+ } catch(E) {
+ alert('Error in survey.js, render_lib_menu(): ' + E);
+ }
}
function survey_init() {
dump('survey_init()\n');
- var user_ou = g.OpenILS.data.list.au[0].home_ou();
- var user_branch = g.OpenILS.data.hash.aou[ user_ou ];
- populate_lib_list_with_branch('lib_menulist','lib_menupopup',user_ou,user_branch);
+ render_lib_menu();
SURVEY['asv'] = new asv(); SURVEY['asv'].isnew('1');
SURVEY['num_of_questions'] = 0;
document.getElementById('survey_name').focus();
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey_overlay.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey_overlay.xul 2009-10-02 03:07:34 UTC (rev 14243)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey_overlay.xul 2009-10-02 04:32:51 UTC (rev 14244)
@@ -21,9 +21,7 @@
<rows id="page1_grid1_rows">
<row id="page1_grid1_row1">
<label id="page1_row1_label1" value="&staff.admin.survey.available.label;" class="wizard_label"/>
- <menulist id="lib_menulist">
- <menupopup id="lib_menupopup"/>
- </menulist>
+ <hbox id="placeholder" />
</row>
<row id="page1_grid1_row2">
Modified: trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties 2009-10-02 03:07:34 UTC (rev 14243)
+++ trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties 2009-10-02 04:32:51 UTC (rev 14244)
@@ -204,6 +204,7 @@
list.actions.csv_to_file.accesskey=F
list.actions.save_column_configuration.label=Save Column Configuration
list.actions.save_column_configuration.accesskey=S
+menu.cmd_survey_wizard.inadequate_perm=You are lacking the CREATE_SURVEY permission and/or working locations.
menu.cmd_local_admin_fonts_and_sounds.tab=Global Font and Sound Settings
menu.cmd_local_admin_printer.tab=Printer Settings Editor
menu.cmd_local_admin_closed_dates.tab=Closed Dates Editor
More information about the open-ils-commits
mailing list