From 6bbf6aa6bd698aaa5eac9ec96dcaf08a37506de6 Mon Sep 17 00:00:00 2001 From: miker Date: Tue, 22 Jul 2008 02:34:35 +0000 Subject: [PATCH] more translator widget work git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@10086 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/conify/global/config/copy_status.html | 2 -- .../web/js/dojo/openils/widget/TranslatorPopup.js | 36 +++++++++++++--------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Open-ILS/web/conify/global/config/copy_status.html b/Open-ILS/web/conify/global/config/copy_status.html index 8b6f062888..f60920e754 100644 --- a/Open-ILS/web/conify/global/config/copy_status.html +++ b/Open-ILS/web/conify/global/config/copy_status.html @@ -196,8 +196,6 @@ 'status_grid.rowHeightChanged('+row+')', 0 ); - var oldnode = dojo.byId('name_translation_' + row); - if (oldnode) dijit.byNode(oldnode).destroyRecursive(); return ''; } return ''; diff --git a/Open-ILS/web/js/dojo/openils/widget/TranslatorPopup.js b/Open-ILS/web/js/dojo/openils/widget/TranslatorPopup.js index 9947425e6e..fe7f74d1ee 100644 --- a/Open-ILS/web/js/dojo/openils/widget/TranslatorPopup.js +++ b/Open-ILS/web/js/dojo/openils/widget/TranslatorPopup.js @@ -39,16 +39,20 @@ if(!dojo._hasResource["openils.widget.TranslatorPopup"]) { [dijit._Widget, dijit._Templated], { - templateString : "
Translate
", + templateString : "
Translate
", widgetsInTemplate: true, field : "", targetObject : "", unique : "", + postMixInProperties : function () { + if (!this.unique) this.unique = openils.widget.TranslatorPopup._unique++; + }, + postCreate : function () { - dojo.connect(this.tooltipDialog, 'onOpen', this, 'renderTranslatorPopup'); + dojo.connect(this.tooltipDialog, 'onFocus', this, 'renderTranslatorPopup'); this.nls = dojo.i18n.getLocalization("openils.widget", "TranslatorPopup"); @@ -64,9 +68,11 @@ if(!dojo._hasResource["openils.widget.TranslatorPopup"]) { renderTranslatorPopup : function () { + var _trans_dijit = this; + this._targetObject = dojox.jsonPath.query(window, '$.' + this.targetObject, {evalType:"RESULT"}); - var node = dojo.byId(this.field + '_translation_' + this.unique); + var node = dojo.byId(this.field + '_translation_tooltip_' + this.unique); var trans_list = openils.I18N.getTranslations( this._targetObject, this.field ); @@ -114,12 +120,12 @@ if(!dojo._hasResource["openils.widget.TranslatorPopup"]) { dojo.query('.update_button',trans_row).style({ visibility : 'visible', display : 'inline'}).instantiate( dijit.form.Button, - { onClick : dojo.hitch( this, 'updateTranslation') } + { onClick : dojo.hitch( _trans_dijit, 'updateTranslation', trans_id) } ); dojo.query('.delete_button',trans_row).style({ visibility : 'visible', display : 'inline'}).instantiate( dijit.form.Button, - { onClick : dojo.hitch( this, 'removeTranslation') } + { onClick : dojo.hitch( _trans_dijit, 'removeTranslation', trans_id) } ); trans_tbody.appendChild( trans_row ); @@ -155,7 +161,7 @@ if(!dojo._hasResource["openils.widget.TranslatorPopup"]) { dojo.query('.create_button',trans_row).style({ visibility : 'visible', display : 'inline'}).instantiate( dijit.form.Button, - { onClick : dojo.hitch( this, 'createTranslation') } + { onClick : dojo.hitch( _trans_dijit, 'createTranslation') } ); trans_tbody.appendChild( trans_row ); @@ -186,7 +192,7 @@ if(!dojo._hasResource["openils.widget.TranslatorPopup"]) { }, createTranslation : function () { - var node = dojo.byId(this.field + '_translation_' + this.unique); + var node = dojo.byId(this.field + '_translation_tooltip_' + this.unique); var trans_obj = new i18n().fromHash({ isnew : 1, @@ -201,32 +207,34 @@ if(!dojo._hasResource["openils.widget.TranslatorPopup"]) { writeTranslation : function (method, trans_obj) { + var _trans_dijit = this; + 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 ' + this._targetObject[this.field]() ); + if (status_update) status_update( 'Problem saving translation for ' + _trans_dijit._targetObject[_trans_dijit.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 ' + this._targetObject[this.field]() ); + if (status_update) status_update( 'Saved changes to translation for ' + _trans_dijit._targetObject[_trans_dijit.field]() ); if (method == 'delete') { dojo.NodeList(dojo.byId('translation_row_' + trans_obj.id())).orphan(); } else if (method == 'create') { - var node = dojo.byId(this.field + '_translation_' + this.unique); - dijit.byId('i18n_new_locale_' + this._targetObject.classname + '.' + this.field + this.unique).setValue(null); - dijit.byId('i18n_new_translation_' + this._targetObject.classname + '.' + this.field + this.unique).setValue(null); - this.renderTranslatorPopup(); + var node = dojo.byId(_trans_dijit.field + '_translation_tooltip_' + _trans_dijit.unique); + dijit.byId('i18n_new_locale_' + _trans_dijit._targetObject.classname + '.' + _trans_dijit.field + _trans_dijit.unique).setValue(null); + dijit.byId('i18n_new_translation_' + _trans_dijit._targetObject.classname + '.' + _trans_dijit.field + _trans_dijit.unique).setValue(null); + _trans_dijit.renderTranslatorPopup(); } } else { //highlighter.editor_pane.red.play(); - if (status_update) status_update( 'Problem saving translation for ' + this._targetObject[this.field]() ); + if (status_update) status_update( 'Problem saving translation for ' + _trans_dijit._targetObject[_trans_dijit.field]() ); } }, }).send(); -- 2.11.0