Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
fix(Crm): add multilang renderer fot product name
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Feitl committed Feb 3, 2023
1 parent 9bff0dd commit 9df1764
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 29 deletions.
16 changes: 15 additions & 1 deletion tine20/Crm/js/LeadEditDialog.js
Expand Up @@ -7,7 +7,9 @@
* @copyright Copyright (c) 2007-2011 Metaways Infosystems GmbH (http://www.metaways.de)
*
*/


import {getLocalizedLangPicker} from "../../Tinebase/js/widgets/form/LocalizedLangPicker";

Ext.namespace('Tine.Crm');

/**
Expand Down Expand Up @@ -77,6 +79,18 @@ Tine.Crm.LeadEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
enableToggle: true,
pressed: !!+this.record.get('mute'),
}))];
this.localizedLangPicker = getLocalizedLangPicker(Tine.Sales.Model.Product);
if (this.localizedLangPicker) {
this.tbarItems = this.tbarItems || [];
if (this.tbarItems.indexOf('->') <= 0) {
this.tbarItems.push('->');
}
this.tbarItems.push(this.localizedLangPicker);
}
this.localizedLangPicker.on('change', (picker, lang) => {
this.productsGrid.store.localizedLang = lang
this.productsGrid.getView().refresh()
})
Tine.Crm.LeadEditDialog.superclass.initComponent.call(this);
this.on('recordUpdate', this.onAfterRecordUpdate, this);
},
Expand Down
59 changes: 31 additions & 28 deletions tine20/Crm/js/Product.js
Expand Up @@ -134,6 +134,7 @@ Tine.Crm.Product.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
header: this.app.i18n._("Product"),
id: 'name',
dataIndex: 'name',
renderer: Tine.widgets.grid.RendererManager.get('Sales','Product','name'),
width: 150
}, {
header: this.app.i18n._("Description"),
Expand Down Expand Up @@ -213,37 +214,39 @@ Tine.Crm.Product.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
}]
});

this.ProductPickerCombo = new Tine.Crm.ProductPickerCombo({
anchor: '90%',
emptyText: this.app.i18n._('Search for Products to add ...'),
productsStore: this.store,
blurOnSelect: true,
recordClass: Tine.Sales.Model.Product,
getValue: function() {
return this.selectedRecord ? this.selectedRecord.data : null;
},
onSelect: function(record){
// check if already in?
if (! this.productsStore.getById(record.id)) {
var newRecord = new Ext.data.Record({
salesprice: record.data.salesprice,
remark_price: record.data.salesprice,
remark_quantity: 1,
name: record.data.name,
relation_type: 'product',
related_id: record.id,
id: record.id
}, record.id);
this.productsStore.insert(0, newRecord);
}

this.collapse();
this.clearValue();
}
})

this.tbar = new Ext.Panel({
layout: 'fit',
items: [
new Tine.Crm.ProductPickerCombo({
anchor: '90%',
emptyText: this.app.i18n._('Search for Products to add ...'),
productsStore: this.store,
blurOnSelect: true,
recordClass: Tine.Sales.Model.Product,
getValue: function() {
return this.selectedRecord ? this.selectedRecord.data : null;
},
onSelect: function(record){
// check if already in?
if (! this.productsStore.getById(record.id)) {
var newRecord = new Ext.data.Record({
salesprice: record.data.salesprice,
remark_price: record.data.salesprice,
remark_quantity: 1,
name: record.getTitle(),
relation_type: 'product',
related_id: record.id,
id: record.id
}, record.id);
this.productsStore.insert(0, newRecord);
}

this.collapse();
this.clearValue();
}
})
this.ProductPickerCombo
]
});
}
Expand Down
3 changes: 3 additions & 0 deletions tine20/Tinebase/js/widgets/grid/RendererManager.js
Expand Up @@ -88,6 +88,9 @@ Tine.widgets.grid.RendererManager = function() {
field = recordClass ? recordClass.getField(fieldName) : null,
fieldDefinition = Object.assign({}, field, _.get(field, 'fieldDefinition', {}), _.get(field, 'fieldDefinition.conifg', {}), _.get(field, 'fieldDefinition.uiconfig', {})),
fieldType = _.get(fieldDefinition, 'fieldDefinition.type', _.get(fieldDefinition, 'type', 'auto'));
if (_.get(fieldDefinition, 'config.specialType') === 'localizedString') {
fieldType = 'localizedString';
}
}
switch (fieldType) {
case 'record':
Expand Down

0 comments on commit 9df1764

Please sign in to comment.