correcting tranlation widget
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 14 Jul 2008 21:06:48 +0000 (21:06 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 14 Jul 2008 21:06:48 +0000 (21:06 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@10031 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/I18N.js
Open-ILS/web/js/dojo/openils/widget/TranslatorPopup.js

index 029ea78..215a530 100644 (file)
@@ -22,14 +22,6 @@ if(!dojo._hasResource["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.I18N', null, {});
 
@@ -53,7 +45,7 @@ if(!dojo._hasResource["openils.I18N"]) {
                var classname = obj.classname;
 
                // XXX need to derive identity field from IDL...
-               var ident_field = fieldmapper[classname].Identifier || 'id';
+               var ident_field = fieldmapper[classname].Identifier;
                var ident_value = obj[ident_field]();
 
                var fielder_args = { query : { fq_field : classname + '.' + field, identity_value : ident_value } };
index 9947425..8fac44a 100644 (file)
@@ -63,9 +63,13 @@ if(!dojo._hasResource["openils.widget.TranslatorPopup"]) {
                        },
 
                        renderTranslatorPopup : function () {
-               
+
                                this._targetObject = dojox.jsonPath.query(window, '$.' + this.targetObject, {evalType:"RESULT"});
 
+                               if (!this.unique && this._targetObject) {
+                                       this.unique = this._targetObject[this._targetObject.Identifier];
+                               }
+
                                var node = dojo.byId(this.field + '_translation_' + this.unique);
                
                                var trans_list = openils.I18N.getTranslations( this._targetObject, this.field );
@@ -114,12 +118,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( this, new Function('this.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( this, new Function('this.removeTranslation('+trans_id+')') ) }
                                        );
                
                                        trans_tbody.appendChild( trans_row );
@@ -167,7 +171,7 @@ if(!dojo._hasResource["openils.widget.TranslatorPopup"]) {
                        },
                        
                        removeTranslation : function (t) {
-                               return changeTranslation('delete',t);
+                               return this.changeTranslation('delete',t);
                        },
                        
                        changeTranslation : function (method, trans_id) {
@@ -201,32 +205,34 @@ if(!dojo._hasResource["openils.widget.TranslatorPopup"]) {
        
                        writeTranslation : function (method, trans_obj) {
                        
+                               var _trans_widget = 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_widget._targetObject[_trans_widget.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_widget._targetObject[_trans_widget.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_widget.field + '_translation_' + _trans_widget.unique);
+                                                               dijit.byId('i18n_new_locale_' + _trans_widget._targetObject.classname + '.' + _trans_widget.field + _trans_widget.unique).setValue(null);
+                                                               dijit.byId('i18n_new_translation_' + _trans_widget._targetObject.classname + '.' + _trans_widget.field + _trans_widget.unique).setValue(null);
+                                                               _trans_widget.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_widget._targetObject[_trans_widget.field]() );
                                                }
                                        },
                                }).send();