From 9df17649ffd7bc3969b599f8382af761d5d94ecd Mon Sep 17 00:00:00 2001 From: Christian Feitl Date: Fri, 3 Feb 2023 13:11:55 +0100 Subject: [PATCH] fix(Crm): add multilang renderer fot product name --- tine20/Crm/js/LeadEditDialog.js | 16 ++++- tine20/Crm/js/Product.js | 59 ++++++++++--------- .../js/widgets/grid/RendererManager.js | 3 + 3 files changed, 49 insertions(+), 29 deletions(-) diff --git a/tine20/Crm/js/LeadEditDialog.js b/tine20/Crm/js/LeadEditDialog.js index 7f33ca0c0dc..b50b7bd77e3 100644 --- a/tine20/Crm/js/LeadEditDialog.js +++ b/tine20/Crm/js/LeadEditDialog.js @@ -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'); /** @@ -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); }, diff --git a/tine20/Crm/js/Product.js b/tine20/Crm/js/Product.js index 5385cfa09cb..01608fbafe0 100644 --- a/tine20/Crm/js/Product.js +++ b/tine20/Crm/js/Product.js @@ -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"), @@ -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 ] }); } diff --git a/tine20/Tinebase/js/widgets/grid/RendererManager.js b/tine20/Tinebase/js/widgets/grid/RendererManager.js index 2c57e2a387f..3f8aa5a71f2 100644 --- a/tine20/Tinebase/js/widgets/grid/RendererManager.js +++ b/tine20/Tinebase/js/widgets/grid/RendererManager.js @@ -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':