[open-ils-commits] SPAM: r9436 - in branches/acq-experiment: .
Open-ILS/src/perlmods/OpenILS/Application/Search
Open-ILS/src/reporter Open-ILS/web/conify/global/actor
Open-ILS/web/conify/global/config
Open-ILS/web/conify/global/permission Open-ILS/web/js/dojo/openils
Open-ILS/web/js/dojo/openils/widget Open-ILS/web/reports
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Apr 22 22:45:48 EDT 2008
Author: erickson
Date: 2008-04-22 22:06:38 -0400 (Tue, 22 Apr 2008)
New Revision: 9436
Added:
branches/acq-experiment/Open-ILS/web/js/dojo/openils/widget/TranslatorPopup.js
Modified:
branches/acq-experiment/
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
branches/acq-experiment/Open-ILS/src/reporter/clark-kent.pl
branches/acq-experiment/Open-ILS/web/conify/global/actor/org_unit.html
branches/acq-experiment/Open-ILS/web/conify/global/actor/org_unit.js
branches/acq-experiment/Open-ILS/web/conify/global/actor/org_unit_type.html
branches/acq-experiment/Open-ILS/web/conify/global/actor/org_unit_type.js
branches/acq-experiment/Open-ILS/web/conify/global/config/copy_status.html
branches/acq-experiment/Open-ILS/web/conify/global/config/copy_status.js
branches/acq-experiment/Open-ILS/web/conify/global/permission/grp_tree.html
branches/acq-experiment/Open-ILS/web/conify/global/permission/grp_tree.js
branches/acq-experiment/Open-ILS/web/js/dojo/openils/I18N.js
branches/acq-experiment/Open-ILS/web/js/dojo/openils/User.js
branches/acq-experiment/Open-ILS/web/reports/oils_rpt_editor.xhtml
branches/acq-experiment/Open-ILS/web/reports/oils_rpt_report_editor.js
Log:
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
........
Property changes on: branches/acq-experiment
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-9414
+ /trunk:1-9435
Modified: branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
===================================================================
--- branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm 2008-04-23 02:03:48 UTC (rev 9435)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm 2008-04-23 02:06:38 UTC (rev 9436)
@@ -773,7 +773,7 @@
# 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++) {
Modified: branches/acq-experiment/Open-ILS/src/reporter/clark-kent.pl
===================================================================
--- branches/acq-experiment/Open-ILS/src/reporter/clark-kent.pl 2008-04-23 02:03:48 UTC (rev 9435)
+++ branches/acq-experiment/Open-ILS/src/reporter/clark-kent.pl 2008-04-23 02:06:38 UTC (rev 9436)
@@ -14,7 +14,7 @@
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 @@
$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 @@
WHERE id = ?;
SQL
+ $logger->debug('Report SQL: ' . $r->{resultset}->toSQL);
$sth = $dbh->prepare($r->{resultset}->toSQL);
$sth->execute;
Modified: branches/acq-experiment/Open-ILS/web/conify/global/actor/org_unit.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/conify/global/actor/org_unit.html 2008-04-23 02:03:48 UTC (rev 9435)
+++ branches/acq-experiment/Open-ILS/web/conify/global/actor/org_unit.html 2008-04-23 02:06:38 UTC (rev 9436)
@@ -222,7 +222,7 @@
if (current_ou) ou_list_store.setValue( current_ou, "name", this.getValue() );
</script>
</span>
- <span dojoType="openils.I18N.translationWidget" targetObject="current_fm_ou" field="name"></span>
+ <span dojoType="openils.widget.TranslatorPopup" targetObject="current_fm_ou" field="name"></span>
</td>
</tr>
<tr>
Modified: branches/acq-experiment/Open-ILS/web/conify/global/actor/org_unit.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/conify/global/actor/org_unit.js 2008-04-23 02:03:48 UTC (rev 9435)
+++ branches/acq-experiment/Open-ILS/web/conify/global/actor/org_unit.js 2008-04-23 02:06:38 UTC (rev 9436)
@@ -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');
Modified: branches/acq-experiment/Open-ILS/web/conify/global/actor/org_unit_type.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/conify/global/actor/org_unit_type.html 2008-04-23 02:03:48 UTC (rev 9435)
+++ branches/acq-experiment/Open-ILS/web/conify/global/actor/org_unit_type.html 2008-04-23 02:06:38 UTC (rev 9436)
@@ -190,7 +190,7 @@
}
</script>
</span>
- <span dojoType="openils.I18N.translationWidget" targetObject="current_fm_type" field="name"></span>
+ <span dojoType="openils.widget.TranslatorPopup" targetObject="current_fm_type" field="name"></span>
</td>
</tr>
<tr>
@@ -203,7 +203,7 @@
}
</script>
</span>
- <span dojoType="openils.I18N.translationWidget" targetObject="current_fm_type" field="opac_label"></span>
+ <span dojoType="openils.widget.TranslatorPopup" targetObject="current_fm_type" field="opac_label"></span>
</td>
</tr>
<tr>
Modified: branches/acq-experiment/Open-ILS/web/conify/global/actor/org_unit_type.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/conify/global/actor/org_unit_type.js 2008-04-23 02:03:48 UTC (rev 9435)
+++ branches/acq-experiment/Open-ILS/web/conify/global/actor/org_unit_type.js 2008-04-23 02:06:38 UTC (rev 9436)
@@ -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');
Modified: branches/acq-experiment/Open-ILS/web/conify/global/config/copy_status.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/conify/global/config/copy_status.html 2008-04-23 02:03:48 UTC (rev 9435)
+++ branches/acq-experiment/Open-ILS/web/conify/global/config/copy_status.html 2008-04-23 02:06:38 UTC (rev 9436)
@@ -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
Modified: branches/acq-experiment/Open-ILS/web/conify/global/config/copy_status.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/conify/global/config/copy_status.js 2008-04-23 02:03:48 UTC (rev 9435)
+++ branches/acq-experiment/Open-ILS/web/conify/global/config/copy_status.js 2008-04-23 02:06:38 UTC (rev 9436)
@@ -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');
Modified: branches/acq-experiment/Open-ILS/web/conify/global/permission/grp_tree.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/conify/global/permission/grp_tree.html 2008-04-23 02:03:48 UTC (rev 9435)
+++ branches/acq-experiment/Open-ILS/web/conify/global/permission/grp_tree.html 2008-04-23 02:06:38 UTC (rev 9436)
@@ -266,7 +266,7 @@
}
</script>
</span>
- <span dojoType="openils.I18N.translationWidget" targetObject="current_fm_group" field="name"></span>
+ <span dojoType="openils.widget.TranslatorPopup" targetObject="current_fm_group" field="name"></span>
</td>
</tr>
<tr>
@@ -280,7 +280,7 @@
onChange="if (current_group) group_store.setValue( current_group, "description", this.getValue() );"
></textarea>
</span>
- <span dojoType="openils.I18N.translationWidget" targetObject="current_fm_group" field="description"></span>
+ <span dojoType="openils.widget.TranslatorPopup" targetObject="current_fm_group" field="description"></span>
</td>
</tr>
<tr>
Modified: branches/acq-experiment/Open-ILS/web/conify/global/permission/grp_tree.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/conify/global/permission/grp_tree.js 2008-04-23 02:03:48 UTC (rev 9435)
+++ branches/acq-experiment/Open-ILS/web/conify/global/permission/grp_tree.js 2008-04-23 02:06:38 UTC (rev 9436)
@@ -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');
Modified: branches/acq-experiment/Open-ILS/web/js/dojo/openils/I18N.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/js/dojo/openils/I18N.js 2008-04-23 02:03:48 UTC (rev 9435)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/I18N.js 2008-04-23 02:06:38 UTC (rev 9436)
@@ -66,195 +66,6 @@
return obj_list;
}
-//----------------------------------------------------------------
-
- dojo.declare(
- 'openils.I18N.translationWidget',
- [dijit._Widget, dijit._Templated],
- {
-
- templateString : "<span dojoAttachPoint='node'><div dojoType='dijit.form.DropDownButton'><span>Translate</span><div id='${field}_translation_${unique}' dojoType='dijit.TooltipDialog' onOpen='openils.I18N.translationWidget.renderTranslationPopup(${targetObject}, \"${field}\", \"${unique}\")' ><div dojoType='dijit.layout.ContentPane'><table><tbody class='translation_tbody_template' style='display:none; visiblity:hidden;'><tr><th>Locale</th><td class='locale'><div class='locale_combobox'></div></td><th>Translation</th><td class='translation'><div class='translation_textbox'></div></td><td><button class='create_button' style='display:none; visiblity:hidden;'>Create</button><button class='update_button' style='display:none; visiblity:hidden;'>Update</button><button class='delete_button' style='display:none; visiblity:hidden;'>Remove</button></td></tr></tbody><tbody class='translation_tbody'></tbody></table></div></div></div></span>",
-
- 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();
- }
-
}
Modified: branches/acq-experiment/Open-ILS/web/js/dojo/openils/User.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/js/dojo/openils/User.js 2008-04-23 02:03:48 UTC (rev 9435)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/User.js 2008-04-23 02:06:38 UTC (rev 9436)
@@ -18,156 +18,196 @@
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, {});
+ dojo.declare('openils.User', null, {
- openils.User.user = null;
- openils.User.authtoken = null;
- openils.User.authtime = 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;
- var ses = new OpenSRF.ClientSession('open-ils.auth');
+ if (this.authtoken) this.getBySession();
+ else if (this.id && this.authtoken) this.user = this.getById( this.id );
+ else if (kwargs.login) this.login();
- 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)
+ },
+
+ 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();
- }
- }
+ },
+
+
+ /**
+ * Logs in, sets the authtoken/authtime vars, and fetches the logged in user
+ */
+ login : function(args, onComplete) {
+ var _u = this;
- 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) {
+ 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();
- }
- }
+ },
+
+ /**
+ * 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()
+ }
+
+ 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');
- /**
- * 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);
+ 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());
}
- authReq.send();
+
+ fieldmapper.standardRequest(
+ ['open-ils.actor', 'open-ils.actor.user.work_perm.org_unit_list'],
+ { params: [this.authtoken, perm],
+ oncomplete: buildTreePicker,
+ async: true
+ }
+ )
}
- initReq.send();
- }
+ });
- /**
- * Returns a list of the "highest" org units where the user
- * has the given permission.
- */
- openils.User.getPermOrgList = function(perm, onload) {
+ openils.User.user = null;
+ openils.User.authtoken = null;
+ openils.User.authtime = null;
- 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);
- }
-
- 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());
- }
-
- fieldmapper.standardRequest(
- ['open-ils.actor', 'open-ils.actor.user.work_perm.org_unit_list'],
- { params: [openils.User.authtoken, perm],
- oncomplete: buildTreePicker,
- async: true
- }
- )
- }
}
Copied: branches/acq-experiment/Open-ILS/web/js/dojo/openils/widget/TranslatorPopup.js (from rev 9435, trunk/Open-ILS/web/js/dojo/openils/widget/TranslatorPopup.js)
===================================================================
--- branches/acq-experiment/Open-ILS/web/js/dojo/openils/widget/TranslatorPopup.js (rev 0)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/widget/TranslatorPopup.js 2008-04-23 02:06:38 UTC (rev 9436)
@@ -0,0 +1,224 @@
+/* ---------------------------------------------------------------------------
+ * Copyright (C) 2008 Georgia Public Library Service
+ * Copyright (C) 2008 Equinox Software, Inc
+ * Mike Rylander <miker at esilibrary.com>
+ *
+ * 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 : "<span dojoAttachPoint='node'><div dojoType='dijit.form.DropDownButton'><span>Translate</span><div id='${field}_translation_${unique}' dojoType='dijit.TooltipDialog' onOpen='openils.widget.TranslatorPopup.renderTranslationPopup(${targetObject}, \"${field}\", \"${unique}\")' ><div dojoType='dijit.layout.ContentPane'><table><tbody class='translation_tbody_template' style='display:none; visiblity:hidden;'><tr><th>Locale</th><td class='locale'><div class='locale_combobox'></div></td><th>Translation</th><td class='translation'><div class='translation_textbox'></div></td><td><button class='create_button' style='display:none; visiblity:hidden;'>Create</button><button class='update_button' style='display:none; visiblity:hidden;'>Update</button><button class='delete_button' style='display:none; visiblity:hidden;'>Remove</button></td></tr></tbody><tbody class='translation_tbody'></tbody></table></div></div></div></span>",
+
+ 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();
+ }
+
+}
+
+
Modified: branches/acq-experiment/Open-ILS/web/reports/oils_rpt_editor.xhtml
===================================================================
--- branches/acq-experiment/Open-ILS/web/reports/oils_rpt_editor.xhtml 2008-04-23 02:03:48 UTC (rev 9435)
+++ branches/acq-experiment/Open-ILS/web/reports/oils_rpt_editor.xhtml 2008-04-23 02:06:38 UTC (rev 9436)
@@ -34,8 +34,24 @@
</tr>
<tr>
<th>Report Columns:</th>
- <td><b id='oils_rpt_report_editor_cols'/></td>
+ <td nowrap='nowrap'><b id='oils_rpt_report_editor_cols'/></td>
</tr>
+ <tr class='hide_me' id='oils_rpt_editor_pivot_label_row'>
+ <th>Pivot Label Column:</th>
+ <td>
+ <select id='oils_rpt_editor_pivot_label'>
+ <option selected='selected' value=''> -- Select One (optional) -- </option>
+ </select>
+ </td>
+ </tr>
+ <tr class='hide_me' id='oils_rpt_editor_pivot_data_row'>
+ <th>Pivot Data Column:</th>
+ <td>
+ <select id='oils_rpt_editor_pivot_data'>
+ </select>
+ </td>
+ </tr>
+
<!--
<tr><td colspan='2'><hr/></td></tr>
-->
Modified: branches/acq-experiment/Open-ILS/web/reports/oils_rpt_report_editor.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/reports/oils_rpt_report_editor.js 2008-04-23 02:03:48 UTC (rev 9435)
+++ branches/acq-experiment/Open-ILS/web/reports/oils_rpt_report_editor.js 2008-04-23 02:06:38 UTC (rev 9436)
@@ -21,6 +21,43 @@
}
);
+/*
+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 @@
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);
More information about the open-ils-commits
mailing list