Permalink
Browse files

[IMP]web: Pass alertFields as object so where key will be field name,…

… this will allow us to set name attribute on translation alert for specific field so when that field is clicked translation list is opened in that field's context
  • Loading branch information...
msh-odoo authored and tsh-odoo committed Sep 11, 2018
1 parent b3c8da2 commit a879cf98f1983439f493a6e881f4b12b11e91587
@@ -216,15 +216,15 @@ var FormController = BasicController.extend({
// are displayed with an alert
var fields = self.renderer.state.fields;
var data = self.renderer.state.data;
var alertFields = [];
var alertFields = {};
for (var k = 0; k < changedFields.length; k++) {
var field = fields[changedFields[k]];
var fieldData = data[changedFields[k]];
if (field.translate && fieldData) {
alertFields.push(field);
alertFields[changedFields[k]] = field;
}
}
if (alertFields.length) {
if (!_.isEmpty(alertFields)) {
self.renderer.updateAlertFields(alertFields);
}
}
@@ -108,10 +108,10 @@ var FormRenderer = BasicRenderer.extend({
/*
* Updates translation alert fields for the current state and display updated fields
*
* @param {Object[]} alertFields field list
* @param {Object} alertFields
*/
updateAlertFields: function (alertFields) {
this.alertFields[this.state.res_id] = _.uniq(_.union(this.alertFields[this.state.res_id] , alertFields), false, function(item){ return item.string; });
this.alertFields[this.state.res_id] = _.extend(this.alertFields[this.state.res_id] || {}, alertFields);
this.displayTranslationAlert();
},
/**
@@ -982,6 +982,12 @@ var FormRenderer = BasicRenderer.extend({
event.preventDefault();
this.trigger_up('translate', {fieldName: event.target.name, id: this.state.id});
},
/**
* remove alert fields of record from alertFields object
*
* @private
* @param {MouseEvent} ev
*/
_onTranslateNotificationClose: function(ev) {
delete this.alertFields[this.state.res_id];
},
@@ -1326,7 +1326,7 @@
<div>
Please update translations of :
<t t-foreach="fields" t-as="field">
<strong><a class="oe_field_translate" t-att-name="field.name" href="#"><t t-esc="field.string"/><t t-if="!field_last">, </t></a></strong>
<strong><a class="oe_field_translate" t-att-name="field" href="#"><t t-esc="field_value.string"/><t t-if="field_index &lt; _.size(fields)-1">, </t></a></strong>
</t>
</div>
</t>

0 comments on commit a879cf9

Please sign in to comment.