|
@ -67,7 +67,7 @@ openerp.web_translate_dialog = function (instance) { |
|
|
}, |
|
|
}, |
|
|
start: function() { |
|
|
start: function() { |
|
|
var self = this; |
|
|
var self = this; |
|
|
this.$el.find('.oe_trad_field').change(function() { |
|
|
|
|
|
|
|
|
this.$el.find('.oe_translation_field').change(function() { |
|
|
$(this).toggleClass('touched', ($(this).val() != $(this).attr('data-value'))); |
|
|
$(this).toggleClass('touched', ($(this).val() != $(this).attr('data-value'))); |
|
|
}); |
|
|
}); |
|
|
this.$buttons.html(QWeb.render("TranslateDialog.buttons")); |
|
|
this.$buttons.html(QWeb.render("TranslateDialog.buttons")); |
|
@ -133,7 +133,7 @@ openerp.web_translate_dialog = function (instance) { |
|
|
var self = this, |
|
|
var self = this, |
|
|
deferred = []; |
|
|
deferred = []; |
|
|
|
|
|
|
|
|
this.$el.find('.oe_trad_field').val('').removeClass('touched'); |
|
|
|
|
|
|
|
|
this.$el.find('.oe_translation_field').val('').removeClass('touched'); |
|
|
_.each(self.languages, function(lg) { |
|
|
_.each(self.languages, function(lg) { |
|
|
var deff = $.Deferred(); |
|
|
var deff = $.Deferred(); |
|
|
deferred.push(deff); |
|
|
deferred.push(deff); |
|
@ -147,16 +147,16 @@ openerp.web_translate_dialog = function (instance) { |
|
|
'lang': lg.code |
|
|
'lang': lg.code |
|
|
})]).done(function (values) { |
|
|
})]).done(function (values) { |
|
|
_.each(self.translatable_fields_keys, function(f) { |
|
|
_.each(self.translatable_fields_keys, function(f) { |
|
|
self.$el.find('.oe_trad_field[name="' + lg.code + '-' + f + '"]') |
|
|
|
|
|
|
|
|
self.$el.find('.oe_translation_field[name="' + lg.code + '-' + f + '"]') |
|
|
.val(values[0][f] || '') |
|
|
.val(values[0][f] || '') |
|
|
.attr('data-value', values[0][f] || ''); |
|
|
.attr('data-value', values[0][f] || ''); |
|
|
|
|
|
|
|
|
var $tarea = self.$el.find('.oe_form_field_html .oe_trad_field[name="' + lg.code + '-' + f + '"]'); |
|
|
|
|
|
|
|
|
var $tarea = self.$el.find('.oe_form_field_html .oe_translation_field[name="' + lg.code + '-' + f + '"]'); |
|
|
if ($tarea.length) { |
|
|
if ($tarea.length) { |
|
|
$tarea.cleditor()[0].updateFrame(); |
|
|
$tarea.cleditor()[0].updateFrame(); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
var $textarea = self.$el.find('textarea.oe_trad_field'); |
|
|
|
|
|
|
|
|
var $textarea = self.$el.find('textarea.oe_translation_field'); |
|
|
$textarea.css({minHeight:'100px'}); |
|
|
$textarea.css({minHeight:'100px'}); |
|
|
$textarea.autosize(); |
|
|
$textarea.autosize(); |
|
|
$(window).resize(); // triggers the autosize
|
|
|
$(window).resize(); // triggers the autosize
|
|
@ -166,17 +166,17 @@ openerp.web_translate_dialog = function (instance) { |
|
|
return deferred; |
|
|
return deferred; |
|
|
}, |
|
|
}, |
|
|
on_button_save: function() { |
|
|
on_button_save: function() { |
|
|
var trads = {}, |
|
|
|
|
|
|
|
|
var translations = {}, |
|
|
self = this, |
|
|
self = this, |
|
|
trads_mutex = new $.Mutex(); |
|
|
|
|
|
self.$el.find('.oe_trad_field.touched').each(function() { |
|
|
|
|
|
|
|
|
translation_mutex = new $.Mutex(); |
|
|
|
|
|
self.$el.find('.oe_translation_field.touched').each(function() { |
|
|
var field = $(this).attr('name').split('-'); |
|
|
var field = $(this).attr('name').split('-'); |
|
|
if (!trads[field[0]]) { |
|
|
|
|
|
trads[field[0]] = {}; |
|
|
|
|
|
|
|
|
if (!translations[field[0]]) { |
|
|
|
|
|
translations[field[0]] = {}; |
|
|
} |
|
|
} |
|
|
trads[field[0]][field[1]] = $(this).val(); |
|
|
|
|
|
|
|
|
translations[field[0]][field[1]] = $(this).val(); |
|
|
}); |
|
|
}); |
|
|
_.each(trads, function(data, code) { |
|
|
|
|
|
|
|
|
_.each(translations, function(data, code) { |
|
|
if (code === self.view_language) { |
|
|
if (code === self.view_language) { |
|
|
_.each(data, function(value, field) { |
|
|
_.each(data, function(value, field) { |
|
|
var view_field = self.view.fields[field]; |
|
|
var view_field = self.view.fields[field]; |
|
@ -190,7 +190,7 @@ openerp.web_translate_dialog = function (instance) { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
trads_mutex.exec(function() { |
|
|
|
|
|
|
|
|
translation_mutex.exec(function() { |
|
|
return new instance.web.DataSet(self, self.view.dataset.model, self.view.dataset.get_context()).write(self.view.datarecord.id, data, { context : { 'lang': code }}); |
|
|
return new instance.web.DataSet(self, self.view.dataset.model, self.view.dataset.get_context()).write(self.view.datarecord.id, data, { context : { 'lang': code }}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|