From: erickson Date: Wed, 23 Apr 2008 02:06:38 +0000 (+0000) Subject: Merged revisions 9425,9428,9430-9435 via svnmerge from X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9ab807fe3101461c7adb62730cfb877140e53f9c;p=Evergreen.git Merged revisions 9425,9428,9430-9435 via svnmerge from svn://svn.open-ils.org/ILS/trunk ........ r9425 | erickson | 2008-04-22 10:36:27 -0400 (Tue, 22 Apr 2008) | 1 line default estimated hit count to 0 to protect against null counts in the case of a search timeout/failure ........ r9428 | erickson | 2008-04-22 14:01:05 -0400 (Tue, 22 Apr 2008) | 1 line added support for defining pivot data and label columns ........ r9430 | erickson | 2008-04-22 14:32:12 -0400 (Tue, 22 Apr 2008) | 1 line added support for taking pivot info from the report def ........ r9431 | miker | 2008-04-22 21:41:36 -0400 (Tue, 22 Apr 2008) | 1 line move the translation widget out to openils.widget ........ r9432 | miker | 2008-04-22 21:42:25 -0400 (Tue, 22 Apr 2008) | 1 line move the translation widget out to openils.widget ........ r9433 | miker | 2008-04-22 21:42:49 -0400 (Tue, 22 Apr 2008) | 1 line OO-ify openils.User ........ r9434 | miker | 2008-04-22 21:45:21 -0400 (Tue, 22 Apr 2008) | 1 line typo in name ........ r9435 | miker | 2008-04-22 22:03:48 -0400 (Tue, 22 Apr 2008) | 1 line back-compat global population ........ git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9436 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm index d28f5cc26f..e6640c4984 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm @@ -773,7 +773,7 @@ sub staged_search { # fulfill the user-specified limit and offset my $all_results = []; my $page; # current superpage - my $est_hit_count; + my $est_hit_count = 0; for($page = 0; $page < $SEARCH_PAGES; $page++) { diff --git a/Open-ILS/src/reporter/clark-kent.pl b/Open-ILS/src/reporter/clark-kent.pl index 0be667691f..d7c3410d64 100755 --- a/Open-ILS/src/reporter/clark-kent.pl +++ b/Open-ILS/src/reporter/clark-kent.pl @@ -14,7 +14,7 @@ use Spreadsheet::WriteExcel::Big; use OpenSRF::EX qw/:try/; use OpenSRF::Utils qw/:daemon/; use OpenSRF::Utils::JSON; -#use OpenSRF::Utils::Logger qw/:level/; +use OpenSRF::Utils::Logger qw/$logger/; use OpenSRF::System; use OpenSRF::AppSession; use OpenSRF::Utils::SettingsClient; @@ -133,9 +133,13 @@ while (my $r = $sth->fetchrow_hashref) { $r->{report} = $s3; my $b = OpenILS::Reporter::SQLBuilder->new; - $b->register_params( OpenSRF::Utils::JSON->JSON2perl( $r->{report}->{data} ) ); + my $report_data = OpenSRF::Utils::JSON->JSON2perl( $r->{report}->{data} ); + $b->register_params( $report_data ); $r->{resultset} = $b->parse_report( OpenSRF::Utils::JSON->JSON2perl( $r->{report}->{template}->{data} ) ); + $r->{resultset}->set_pivot_data($report_data->{__pivot_data}) if $report_data->{__pivot_data}; + $r->{resultset}->set_pivot_label($report_data->{__pivot_label}) if $report_data->{__pivot_label}; + $r->{resultset}->set_pivot_default($report_data->{__pivot_default}) if $report_data->{__pivot_default}; $r->{resultset}->relative_time($r->{run_time}); push @reports, $r; } @@ -161,6 +165,7 @@ for my $r ( @reports ) { WHERE id = ?; SQL + $logger->debug('Report SQL: ' . $r->{resultset}->toSQL); $sth = $dbh->prepare($r->{resultset}->toSQL); $sth->execute; diff --git a/Open-ILS/web/conify/global/actor/org_unit.html b/Open-ILS/web/conify/global/actor/org_unit.html index 7077479dc9..200c35934a 100644 --- a/Open-ILS/web/conify/global/actor/org_unit.html +++ b/Open-ILS/web/conify/global/actor/org_unit.html @@ -222,7 +222,7 @@ if (current_ou) ou_list_store.setValue( current_ou, "name", this.getValue() ); - + diff --git a/Open-ILS/web/conify/global/actor/org_unit.js b/Open-ILS/web/conify/global/actor/org_unit.js index ad00205e8b..3d418efe8d 100644 --- a/Open-ILS/web/conify/global/actor/org_unit.js +++ b/Open-ILS/web/conify/global/actor/org_unit.js @@ -16,7 +16,7 @@ */ dojo.require('fieldmapper.dojoData'); -dojo.require('openils.I18N'); +dojo.require('openils.widget.TranslatorPopup'); dojo.require('dojo.parser'); dojo.require('dojo.data.ItemFileWriteStore'); dojo.require('dojo.date.stamp'); diff --git a/Open-ILS/web/conify/global/actor/org_unit_type.html b/Open-ILS/web/conify/global/actor/org_unit_type.html index b9b111d694..534c169523 100644 --- a/Open-ILS/web/conify/global/actor/org_unit_type.html +++ b/Open-ILS/web/conify/global/actor/org_unit_type.html @@ -190,7 +190,7 @@ } - + @@ -203,7 +203,7 @@ } - + diff --git a/Open-ILS/web/conify/global/actor/org_unit_type.js b/Open-ILS/web/conify/global/actor/org_unit_type.js index dcb7d7d969..d9cd7cb73f 100644 --- a/Open-ILS/web/conify/global/actor/org_unit_type.js +++ b/Open-ILS/web/conify/global/actor/org_unit_type.js @@ -16,7 +16,7 @@ */ dojo.require('fieldmapper.dojoData'); -dojo.require('openils.I18N'); +dojo.require('openils.widget.TranslatorPopup'); dojo.require('dojo.parser'); dojo.require('dojo.data.ItemFileWriteStore'); dojo.require('dojo.date.stamp'); diff --git a/Open-ILS/web/conify/global/config/copy_status.html b/Open-ILS/web/conify/global/config/copy_status.html index 3efa3c2105..9b25ff36b0 100644 --- a/Open-ILS/web/conify/global/config/copy_status.html +++ b/Open-ILS/web/conify/global/config/copy_status.html @@ -188,7 +188,7 @@ window.status_rows[row] = new ccs().fromHash(window.status_data_model.getRow(row)); setTimeout( 'dojo.query(".status_grid_trans_cell_' + row + '").'+ - 'instantiate(openils.I18N.translationWidget,{field:"name",'+ + 'instantiate(openils.widget.TranslatorPopup,{field:"name",'+ 'targetObject:"window.status_rows['+row+']",unique:"' + row + '"});'+ 'status_grid.rowHeightChanged('+row+')', 0 diff --git a/Open-ILS/web/conify/global/config/copy_status.js b/Open-ILS/web/conify/global/config/copy_status.js index bfa91742da..ae869a70c1 100644 --- a/Open-ILS/web/conify/global/config/copy_status.js +++ b/Open-ILS/web/conify/global/config/copy_status.js @@ -16,7 +16,7 @@ */ dojo.require('fieldmapper.dojoData'); -dojo.require('openils.I18N'); +dojo.require('openils.widget.TranslatorPopup'); dojo.require('dojo.parser'); dojo.require('dojo.string'); dojo.require('dojo.data.ItemFileWriteStore'); diff --git a/Open-ILS/web/conify/global/permission/grp_tree.html b/Open-ILS/web/conify/global/permission/grp_tree.html index 31800c37bd..bb585df05d 100644 --- a/Open-ILS/web/conify/global/permission/grp_tree.html +++ b/Open-ILS/web/conify/global/permission/grp_tree.html @@ -266,7 +266,7 @@ } - + @@ -280,7 +280,7 @@ onChange="if (current_group) group_store.setValue( current_group, "description", this.getValue() );" > - + diff --git a/Open-ILS/web/conify/global/permission/grp_tree.js b/Open-ILS/web/conify/global/permission/grp_tree.js index 151a3431ff..aa604076df 100644 --- a/Open-ILS/web/conify/global/permission/grp_tree.js +++ b/Open-ILS/web/conify/global/permission/grp_tree.js @@ -16,7 +16,7 @@ */ dojo.require('fieldmapper.dojoData'); -dojo.require('openils.I18N'); +dojo.require('openils.widget.TranslatorPopup'); dojo.require('dojo.parser'); dojo.require('dojo.data.ItemFileWriteStore'); dojo.require('dojo.date.stamp'); diff --git a/Open-ILS/web/js/dojo/openils/I18N.js b/Open-ILS/web/js/dojo/openils/I18N.js index a99fa41692..029ea78b3c 100644 --- a/Open-ILS/web/js/dojo/openils/I18N.js +++ b/Open-ILS/web/js/dojo/openils/I18N.js @@ -66,195 +66,6 @@ if(!dojo._hasResource["openils.I18N"]) { return obj_list; } -//---------------------------------------------------------------- - - dojo.declare( - 'openils.I18N.translationWidget', - [dijit._Widget, dijit._Templated], - { - - templateString : "
Translate
", - - widgetsInTemplate: true, - field : "", - targetObject : "", - unique : "" - } - ); - - openils.I18N.translationWidget.renderTranslationPopup = function (obj, field, num) { - var node = dojo.byId(field + '_translation_' + num); - - var trans_list = openils.I18N.getTranslations( obj, field ); - - var trans_template = dojo.query('.translation_tbody_template', node)[0]; - var trans_tbody = dojo.query('.translation_tbody', node)[0]; - - // Empty it - while (trans_tbody.lastChild) trans_tbody.removeChild( trans_tbody.lastChild ); - - for (var i in trans_list) { - if (!trans_list[i]) continue; - - var trans_obj = trans_list[i]; - var trans_id = trans_obj.id(); - - var trans_row = dojo.query('tr',trans_template)[0].cloneNode(true); - trans_row.id = 'translation_row_' + trans_id; - - var old_dijit = dijit.byId('locale_' + trans_id); - if (old_dijit) old_dijit.destroy(); - - old_dijit = dijit.byId('translation_' + trans_id); - if (old_dijit) old_dijit.destroy(); - - dojo.query('.locale_combobox',trans_row).instantiate( - dijit.form.ComboBox, - { store:openils.I18N.localeStore, - searchAttr:'locale', - lowercase:true, - required:true, - id:'locale_' + trans_id, - value: trans_obj.translation(), - invalidMessage:'Specify locale as {languageCode}_{countryCode}, like en_us', - regExp:'[a-z_]+' - } - ); - - dojo.query('.translation_textbox',trans_row).instantiate( - dijit.form.TextBox, - { required : true, - id:'translation_' + trans_id, - value: trans_obj.string() - } - ); - - dojo.query('.update_button',trans_row).style({ visibility : 'visible', display : 'inline'}).instantiate( - dijit.form.Button, - { onClick : - (function (trans_id, obj, field) { - return function () { openils.I18N.translationWidget.updateTranslation(trans_id, obj, field, num) } - })(trans_id, obj, field) - } - ); - - dojo.query('.delete_button',trans_row).style({ visibility : 'visible', display : 'inline'}).instantiate( - dijit.form.Button, - { onClick : - (function (trans_id, obj, field) { - return function () { openils.I18N.translationWidget.removeTranslation(trans_id, obj, field, num) } - })(trans_id, obj, field) - } - ); - - trans_tbody.appendChild( trans_row ); - } - - old_dijit = dijit.byId('i18n_new_locale_' + obj.classname + '.' + field + num); - if (old_dijit) old_dijit.destroy(); - - old_dijit = dijit.byId('i18n_new_translation_' + obj.classname + '.' + field + num); - if (old_dijit) old_dijit.destroy(); - - trans_row = dojo.query('tr',trans_template)[0].cloneNode(true); - - dojo.query('.locale_combobox',trans_row).instantiate( - dijit.form.ComboBox, - { store:openils.I18N.localeStore, - searchAttr:'locale', - id:'i18n_new_locale_' + obj.classname + '.' + field + num, - lowercase:true, - required:true, - invalidMessage:'Specify locale as {languageCode}_{countryCode}, like en_us', - regExp:'[a-z_]+' - } - ); - - dojo.query('.translation_textbox',trans_row).addClass('new_translation').instantiate( - dijit.form.TextBox, - { required : true, - id:'i18n_new_translation_' + obj.classname + '.' + field + num - } - ); - - dojo.query('.create_button',trans_row).style({ visibility : 'visible', display : 'inline'}).instantiate( - dijit.form.Button, - { onClick : function () { openils.I18N.translationWidget.createTranslation( obj, field, num) } } - ); - - trans_tbody.appendChild( trans_row ); - } - - openils.I18N.translationWidget.updateTranslation = function (trans_id, obj, field, num) { - return openils.I18N.translationWidget.changeTranslation('update', trans_id, obj, field, num); - } - - openils.I18N.translationWidget.removeTranslation = function (trans_id, obj, field, num) { - return openils.I18N.translationWidget.changeTranslation('delete', trans_id, obj, field, num); - } - - openils.I18N.translationWidget.changeTranslation = function (method, trans_id, obj, field, num) { - - var trans_obj = new i18n().fromHash({ - ischanged : method == 'update' ? 1 : 0, - isdeleted : method == 'delete' ? 1 : 0, - id : trans_id, - fq_field : obj.classname + '.' + field, - identity_value : obj.id(), - translation : dijit.byId('locale_' + trans_id).getValue(), - string : dijit.byId('translation_' + trans_id).getValue() - }); - - openils.I18N.translationWidget.writeTranslation(method, trans_obj, obj, field, num); - } - - openils.I18N.translationWidget.createTranslation = function (obj, field, num) { - var node = dojo.byId(field + '_translation_' + num); - - var trans_obj = new i18n().fromHash({ - isnew : 1, - fq_field : obj.classname + '.' + field, - identity_value : obj.id(), - translation : dijit.byId('i18n_new_locale_' + obj.classname + '.' + field + num).getValue(), - string : dijit.byId('i18n_new_translation_' + obj.classname + '.' + field + num).getValue() - }); - - openils.I18N.translationWidget.writeTranslation('create', trans_obj, obj, field, num); - } - - openils.I18N.translationWidget.writeTranslation = function (method, trans_obj, obj, field, num) { - - OpenSRF.CachedClientSession('open-ils.permacrud').request({ - method : 'open-ils.permacrud.' + method + '.i18n', - timeout: 10, - params : [ ses, trans_obj ], - onerror: function (r) { - //highlighter.editor_pane.red.play(); - if (status_update) status_update( 'Problem saving translation for ' + obj[field]() ); - }, - oncomplete : function (r) { - var res = r.recv(); - if ( res && res.content() ) { - //highlighter.editor_pane.green.play(); - if (status_update) status_update( 'Saved changes to translation for ' + obj[field]() ); - - if (method == 'delete') { - dojo.NodeList(dojo.byId('translation_row_' + trans_obj.id())).orphan(); - } else if (method == 'create') { - var node = dojo.byId(field + '_translation_' + num); - dijit.byId('i18n_new_locale_' + obj.classname + '.' + field + num).setValue(null); - dijit.byId('i18n_new_translation_' + obj.classname + '.' + field + num).setValue(null); - openils.I18N.translationWidget.renderTranslationPopup(obj, field, num); - } - - } else { - //highlighter.editor_pane.red.play(); - if (status_update) status_update( 'Problem saving translation for ' + obj[field]() ); - } - }, - }).send(); - } - } diff --git a/Open-ILS/web/js/dojo/openils/User.js b/Open-ILS/web/js/dojo/openils/User.js index 2cd8e93802..6039dc0fe3 100644 --- a/Open-ILS/web/js/dojo/openils/User.js +++ b/Open-ILS/web/js/dojo/openils/User.js @@ -18,156 +18,196 @@ if(!dojo._hasResource["openils.User"]) { dojo._hasResource["openils.User"] = true; dojo.provide("openils.User"); + dojo.require("DojoSRF"); dojo.require('openils.Event'); dojo.require('fieldmapper.Fieldmapper'); - dojo.declare('openils.User', null, {}); - - openils.User.user = null; - openils.User.authtoken = null; - openils.User.authtime = null; - - var ses = new OpenSRF.ClientSession('open-ils.auth'); - - openils.User.getBySession = function(onComplete) { - var req = ses.request('open-ils.auth.session.retrieve', openils.User.authtoken); - if(onComplete) { - req.oncomplete = function(r) { - var user = r.recv().content(); - openils.User.user = user; - if(onComplete) + dojo.declare('openils.User', null, { + + user : null, + username : null, + passwd : null, + login_type : 'opac', + location : null, + authtoken : null, + authtime : null, + + constructor : function ( kwargs ) { + this.id = kwargs.id; + this.user = kwargs.user; + this.passwd = kwargs.passwd; + this.authtoken = kwargs.authtoken || openils.User.authtoken; + this.authtime = kwargs.authtime || openils.User.authtime; + this.login_type = kwargs.login_type; + this.location = kwargs.location; + + if (this.authtoken) this.getBySession(); + else if (this.id && this.authtoken) this.user = this.getById( this.id ); + else if (kwargs.login) this.login(); + + }, + + getBySession : function(onComplete) { + var _u = this; + var req = OpenSRF.CachedClientSession('open-ils.auth').request('open-ils.auth.session.retrieve', _u.authtoken); + if(onComplete) { + req.oncomplete = function(r) { + var user = r.recv().content(); + _u.user = user; + if (!openils.User.user) !openils.User.user = _u.user; + if(onComplete) + onComplete(user); + } + req.send(); + } else { + req.timeout = 10; + req.send(); + return _u.user = req.recv().content(); + } + }, + + getById : function(id, onComplete) { + var req = OpenSRF.CachedClientSession('open-ils.actor').request('open-ils.actor.user.retrieve', this.authtoken, id); + if(onComplete) { + req.oncomplete = function(r) { + var user = r.recv().content(); onComplete(user); + } + req.send(); + } else { + req.timeout = 10; + req.send(); + return req.recv().content(); } - req.send(); - } else { - req.timeout = 10; - req.send(); - return openils.User.user = req.recv().content(); - } - } - - openils.User.getById = function(id, onComplete) { - var ases = new OpenSRF.ClientSession('open-ils.actor'); - var req = ases.request('open-ils.actor.user.retrieve', openils.User.authtoken, id); - if(onComplete) { + }, + + + /** + * Logs in, sets the authtoken/authtime vars, and fetches the logged in user + */ + login : function(args, onComplete) { + var _u = this; + + if (!args) args = {}; + if (!args.username) args.username = _u.username; + if (!args.passwd) args.passwd = _u.passwd; + if (!args.type) args.type = _u.login_type; + if (!args.location) args.location = _u.location; + + var initReq = OpenSRF.CachedClientSession('open-ils.auth').request('open-ils.auth.authenticate.init', args.username); + + initReq.oncomplete = function(r) { + var seed = r.recv().content(); + alert(seed); + var loginInfo = { + password : hex_md5(seed + hex_md5(args.passwd)), + type : args.type, + org : args.location, + }; + + var authReq = OpenSRF.CachedClientSession('open-ils.auth').request('open-ils.auth.authenticate.complete', loginInfo); + authReq.oncomplete = function(rr) { + var data = rr.recv().content(); + _u.authtoken = data.payload.authtoken; + if (!openils.User.authtoken) !openils.User.authtoken = _u.authtoken; + _u.authtime = data.payload.authtime; + if (!openils.User.authtime) !openils.User.authtime = _u.authtime; + _u.getBySession(onComplete); + } + authReq.send(); + } + + initReq.send(); + }, + + /** + * Returns a list of the "highest" org units where the user + * has the given permission. + */ + getPermOrgList : function(perm, onload) { + + var req = OpenSRF.CachedClientSession('open-ils.actor').request( + 'open-ils.actor.user.work_perm.highest_org_set', + this.authtoken, perm); + req.oncomplete = function(r) { - var user = r.recv().content(); - onComplete(user); + org_list = r.recv().content(); + onload(org_list); } + req.send(); - } else { - req.timeout = 10; - req.send(); - return req.recv().content(); - } - } - - - /** - * Logs in, sets the authtoken/authtime vars, and fetches the logged in user - */ - openils.User.login = function(args, onComplete) { - var initReq = ses.request('open-ils.auth.authenticate.init', args.username); - - initReq.oncomplete = function(r) { - var seed = r.recv().content(); - alert(seed); - var loginInfo = { - password : hex_md5(seed + hex_md5(args.passwd)), - type : args.type || 'opac', - org : args.location, - }; - - var authReq = ses.request('open-ils.auth.authenticate.complete', loginInfo); - authReq.oncomplete = function(rr) { - var data = rr.recv().content(); - openils.User.authtoken = data.payload.authtoken; - openils.User.authtime = data.payload.authtime; - openils.User.getBySession(onComplete); + }, + + /** + * Builds a dijit.Tree using the orgs where the user has the requested permission + * @param perm The permission to check + * @param domId The DOM node where the tree widget should live + * @param onClick If defined, this will be connected to the tree widget for + * onClick events + */ + buildPermOrgTreePicker : function(perm, domId, onClick) { + + dojo.require('dojo.data.ItemFileReadStore'); + dojo.require('dijit.Tree'); + function buildTreePicker(r) { + var orgList = r.recv().content(); + var store = new dojo.data.ItemFileReadStore({data:aou.toStoreData(orgList)}); + var model = new dijit.tree.ForestStoreModel({ + store: store, + query: {_top:'true'}, + childrenAttrs: ["children"], + rootLabel : "Location" /* XXX i18n */ + }); + + var tree = new dijit.Tree({model : model}, dojo.byId(domId)); + if(onClick) + dojo.connect(tree, 'onClick', onClick); + tree.startup() } - authReq.send(); - } - - initReq.send(); - } - - /** - * Returns a list of the "highest" org units where the user - * has the given permission. - */ - openils.User.getPermOrgList = function(perm, onload) { - - var ases = new OpenSRF.ClientSession('open-ils.actor'); - var req = ases.request( - 'open-ils.actor.user.work_perm.highest_org_set', - openils.User.authtoken, perm); - - req.oncomplete = function(r) { - org_list = r.recv().content(); - onload(org_list); + + fieldmapper.standardRequest( + ['open-ils.actor', 'open-ils.actor.user.work_perm.org_unit_list'], + { params: [this.authtoken, perm], + oncomplete: buildTreePicker, + async: true + } + ) + }, + + /** + * Sets the store for an existing openils.widget.OrgUnitFilteringSelect + * using the orgs where the user has the requested permission. + * @param perm The permission to check + * @param selector The pre-created dijit.form.FilteringSelect object. + */ + buildPermOrgSelector : function(perm, selector) { + var _u = this; + + dojo.require('dojo.data.ItemFileReadStore'); + + function buildTreePicker(r) { + var orgList = r.recv().content(); + var store = new dojo.data.ItemFileReadStore({data:aou.toStoreData(orgList)}); + selector.store = store; + selector.startup(); + selector.setValue(_u.user.ws_ou()); + } + + fieldmapper.standardRequest( + ['open-ils.actor', 'open-ils.actor.user.work_perm.org_unit_list'], + { params: [this.authtoken, perm], + oncomplete: buildTreePicker, + async: true + } + ) } - req.send(); - } - - /** - * Builds a dijit.Tree using the orgs where the user has the requested permission - * @param perm The permission to check - * @param domId The DOM node where the tree widget should live - * @param onClick If defined, this will be connected to the tree widget for - * onClick events - */ - openils.User.buildPermOrgTreePicker = function(perm, domId, onClick) { - - function buildTreePicker(r) { - var orgList = r.recv().content(); - var store = new dojo.data.ItemFileReadStore({data:aou.toStoreData(orgList)}); - var model = new dijit.tree.ForestStoreModel({ - store: store, - query: {_top:'true'}, - childrenAttrs: ["children"], - rootLabel : "Location" /* XXX i18n */ - }); - - var tree = new dijit.Tree({model : model}, dojo.byId(domId)); - if(onClick) - dojo.connect(tree, 'onClick', onClick); - tree.startup() - } + }); - fieldmapper.standardRequest( - ['open-ils.actor', 'open-ils.actor.user.work_perm.org_unit_list'], - { params: [openils.User.authtoken, perm], - oncomplete: buildTreePicker, - async: true - } - ) - } - - /** - * Sets the store for an existing openils.widget.OrgUnitFilteringSelect - * using the orgs where the user has the requested permission. - * @param perm The permission to check - * @param selector The pre-created dijit.form.FilteringSelect object. - */ - openils.User.buildPermOrgSelector = function(perm, selector) { - - function buildTreePicker(r) { - var orgList = r.recv().content(); - var store = new dojo.data.ItemFileReadStore({data:aou.toStoreData(orgList)}); - selector.store = store; - selector.startup(); - selector.setValue(openils.User.user.ws_ou()); - } + openils.User.user = null; + openils.User.authtoken = null; + openils.User.authtime = null; - fieldmapper.standardRequest( - ['open-ils.actor', 'open-ils.actor.user.work_perm.org_unit_list'], - { params: [openils.User.authtoken, perm], - oncomplete: buildTreePicker, - async: true - } - ) - } } diff --git a/Open-ILS/web/js/dojo/openils/widget/TranslatorPopup.js b/Open-ILS/web/js/dojo/openils/widget/TranslatorPopup.js new file mode 100644 index 0000000000..4a5f04488b --- /dev/null +++ b/Open-ILS/web/js/dojo/openils/widget/TranslatorPopup.js @@ -0,0 +1,224 @@ +/* --------------------------------------------------------------------------- + * Copyright (C) 2008 Georgia Public Library Service + * Copyright (C) 2008 Equinox Software, Inc + * Mike Rylander + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * --------------------------------------------------------------------------- + */ + +if(!dojo._hasResource["openils.widget.TranslatorPopup"]) { + + dojo._hasResource["openils.widget.TranslatorPopup"] = true; + dojo.provide("openils.widget.TranslatorPopup"); + dojo.require("openils.I18N"); + dojo.require("fieldmapper.dojoData"); + dojo.require("DojoSRF"); + dojo.require("dojo.data.ItemFileWriteStore"); + dojo.require("dijit._Widget"); + dojo.require("dijit._Templated"); + dojo.require("dijit.layout.ContentPane"); + dojo.require("dijit.Dialog"); + dojo.require("dijit.form.Button"); + dojo.require("dijit.form.TextBox"); + dojo.require("dijit.form.ComboBox"); + + + dojo.declare( + 'openils.widget.TranslatorPopup', + [dijit._Widget, dijit._Templated], + { + + templateString : "
Translate
", + + widgetsInTemplate: true, + field : "", + targetObject : "", + unique : "" + } + ); + + openils.widget.TranslatorPopup.renderTranslationPopup = function (obj, field, num) { + var node = dojo.byId(field + '_translation_' + num); + + var trans_list = openils.I18N.getTranslations( obj, field ); + + var trans_template = dojo.query('.translation_tbody_template', node)[0]; + var trans_tbody = dojo.query('.translation_tbody', node)[0]; + + // Empty it + while (trans_tbody.lastChild) trans_tbody.removeChild( trans_tbody.lastChild ); + + for (var i in trans_list) { + if (!trans_list[i]) continue; + + var trans_obj = trans_list[i]; + var trans_id = trans_obj.id(); + + var trans_row = dojo.query('tr',trans_template)[0].cloneNode(true); + trans_row.id = 'translation_row_' + trans_id; + + var old_dijit = dijit.byId('locale_' + trans_id); + if (old_dijit) old_dijit.destroy(); + + old_dijit = dijit.byId('translation_' + trans_id); + if (old_dijit) old_dijit.destroy(); + + dojo.query('.locale_combobox',trans_row).instantiate( + dijit.form.ComboBox, + { store:openils.I18N.localeStore, + searchAttr:'locale', + lowercase:true, + required:true, + id:'locale_' + trans_id, + value: trans_obj.translation(), + invalidMessage:'Specify locale as {languageCode}_{countryCode}, like en_us', + regExp:'[a-z_]+' + } + ); + + dojo.query('.translation_textbox',trans_row).instantiate( + dijit.form.TextBox, + { required : true, + id:'translation_' + trans_id, + value: trans_obj.string() + } + ); + + dojo.query('.update_button',trans_row).style({ visibility : 'visible', display : 'inline'}).instantiate( + dijit.form.Button, + { onClick : + (function (trans_id, obj, field) { + return function () { openils.widget.TranslatorPopup.updateTranslation(trans_id, obj, field, num) } + })(trans_id, obj, field) + } + ); + + dojo.query('.delete_button',trans_row).style({ visibility : 'visible', display : 'inline'}).instantiate( + dijit.form.Button, + { onClick : + (function (trans_id, obj, field) { + return function () { openils.widget.TranslatorPopup.removeTranslation(trans_id, obj, field, num) } + })(trans_id, obj, field) + } + ); + + trans_tbody.appendChild( trans_row ); + } + + old_dijit = dijit.byId('i18n_new_locale_' + obj.classname + '.' + field + num); + if (old_dijit) old_dijit.destroy(); + + old_dijit = dijit.byId('i18n_new_translation_' + obj.classname + '.' + field + num); + if (old_dijit) old_dijit.destroy(); + + trans_row = dojo.query('tr',trans_template)[0].cloneNode(true); + + dojo.query('.locale_combobox',trans_row).instantiate( + dijit.form.ComboBox, + { store:openils.I18N.localeStore, + searchAttr:'locale', + id:'i18n_new_locale_' + obj.classname + '.' + field + num, + lowercase:true, + required:true, + invalidMessage:'Specify locale as {languageCode}_{countryCode}, like en_us', + regExp:'[a-z_]+' + } + ); + + dojo.query('.translation_textbox',trans_row).addClass('new_translation').instantiate( + dijit.form.TextBox, + { required : true, + id:'i18n_new_translation_' + obj.classname + '.' + field + num + } + ); + + dojo.query('.create_button',trans_row).style({ visibility : 'visible', display : 'inline'}).instantiate( + dijit.form.Button, + { onClick : function () { openils.widget.TranslatorPopup.createTranslation( obj, field, num) } } + ); + + trans_tbody.appendChild( trans_row ); + } + + openils.widget.TranslatorPopup.updateTranslation = function (trans_id, obj, field, num) { + return openils.widget.TranslatorPopup.changeTranslation('update', trans_id, obj, field, num); + } + + openils.widget.TranslatorPopup.removeTranslation = function (trans_id, obj, field, num) { + return openils.widget.TranslatorPopup.changeTranslation('delete', trans_id, obj, field, num); + } + + openils.widget.TranslatorPopup.changeTranslation = function (method, trans_id, obj, field, num) { + + var trans_obj = new i18n().fromHash({ + ischanged : method == 'update' ? 1 : 0, + isdeleted : method == 'delete' ? 1 : 0, + id : trans_id, + fq_field : obj.classname + '.' + field, + identity_value : obj.id(), + translation : dijit.byId('locale_' + trans_id).getValue(), + string : dijit.byId('translation_' + trans_id).getValue() + }); + + openils.widget.TranslatorPopup.writeTranslation(method, trans_obj, obj, field, num); + } + + openils.widget.TranslatorPopup.createTranslation = function (obj, field, num) { + var node = dojo.byId(field + '_translation_' + num); + + var trans_obj = new i18n().fromHash({ + isnew : 1, + fq_field : obj.classname + '.' + field, + identity_value : obj.id(), + translation : dijit.byId('i18n_new_locale_' + obj.classname + '.' + field + num).getValue(), + string : dijit.byId('i18n_new_translation_' + obj.classname + '.' + field + num).getValue() + }); + + openils.widget.TranslatorPopup.writeTranslation('create', trans_obj, obj, field, num); + } + + openils.widget.TranslatorPopup.writeTranslation = function (method, trans_obj, obj, field, num) { + + OpenSRF.CachedClientSession('open-ils.permacrud').request({ + method : 'open-ils.permacrud.' + method + '.i18n', + timeout: 10, + params : [ ses, trans_obj ], + onerror: function (r) { + //highlighter.editor_pane.red.play(); + if (status_update) status_update( 'Problem saving translation for ' + obj[field]() ); + }, + oncomplete : function (r) { + var res = r.recv(); + if ( res && res.content() ) { + //highlighter.editor_pane.green.play(); + if (status_update) status_update( 'Saved changes to translation for ' + obj[field]() ); + + if (method == 'delete') { + dojo.NodeList(dojo.byId('translation_row_' + trans_obj.id())).orphan(); + } else if (method == 'create') { + var node = dojo.byId(field + '_translation_' + num); + dijit.byId('i18n_new_locale_' + obj.classname + '.' + field + num).setValue(null); + dijit.byId('i18n_new_translation_' + obj.classname + '.' + field + num).setValue(null); + openils.widget.TranslatorPopup.renderTranslationPopup(obj, field, num); + } + + } else { + //highlighter.editor_pane.red.play(); + if (status_update) status_update( 'Problem saving translation for ' + obj[field]() ); + } + }, + }).send(); + } + +} + + diff --git a/Open-ILS/web/reports/oils_rpt_editor.xhtml b/Open-ILS/web/reports/oils_rpt_editor.xhtml index 7d06d777ed..007ced5782 100644 --- a/Open-ILS/web/reports/oils_rpt_editor.xhtml +++ b/Open-ILS/web/reports/oils_rpt_editor.xhtml @@ -34,8 +34,24 @@ Report Columns: - + + + Pivot Label Column: + + + + + + Pivot Data Column: + + + + + diff --git a/Open-ILS/web/reports/oils_rpt_report_editor.js b/Open-ILS/web/reports/oils_rpt_report_editor.js index 778078a9d0..8f3001862f 100644 --- a/Open-ILS/web/reports/oils_rpt_report_editor.js +++ b/Open-ILS/web/reports/oils_rpt_report_editor.js @@ -21,6 +21,43 @@ function oilsRptReportEditor(rptObject, folderWindow) { } ); +/* +oils_rpt_editor_pivot_label +oils_rpt_editor_pivot_data +*/ + + var hasAgg = false; + iterate(rptObject.def.select, + function(i) { + if(OILS_RPT_TRANSFORMS[i.column.transform].aggregate) + hasAgg = true; + } + ); + + while(DOM.oils_rpt_editor_pivot_label.getElementsByTagName('option').length > 1) + DOM.oils_rpt_editor_pivot_label.removeChild(DOM.oils_rpt_editor_pivot_label.lastChild); + + while(DOM.oils_rpt_editor_pivot_data.lastChild) + DOM.oils_rpt_editor_pivot_data.removeChild(DOM.oils_rpt_editor_pivot_data.lastChild); + + if(hasAgg) { + unHideMe(DOM.oils_rpt_editor_pivot_label_row); + unHideMe(DOM.oils_rpt_editor_pivot_data_row); + + for(var i in rptObject.def.select) { + var col = rptObject.def.select[i]; + if(OILS_RPT_TRANSFORMS[col.column.transform].aggregate) + insertSelectorVal(DOM.oils_rpt_editor_pivot_data, -1, col.alias, parseInt(i)+1); + else + insertSelectorVal(DOM.oils_rpt_editor_pivot_label, -1, col.alias, parseInt(i)+1); + } + + } else { + hideMe(DOM.oils_rpt_editor_pivot_label_row); + hideMe(DOM.oils_rpt_editor_pivot_data_row); + } + + if( rpt ) { DOM.oils_rpt_report_editor_name.value = rpt.name(); DOM.oils_rpt_report_editor_description.value = rpt.description(); @@ -102,6 +139,12 @@ oilsRptReportEditor.prototype.save = function() { data[par.key] = val; } + if(getSelectorVal(DOM.oils_rpt_editor_pivot_data)) { + data.__pivot_label = getSelectorVal(DOM.oils_rpt_editor_pivot_label); + data.__pivot_data = getSelectorVal(DOM.oils_rpt_editor_pivot_data); + } + + data = js2JSON(data); _debug("complete report data = "+data); report.data(data);