4 * @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
5 * @author Cornelius Weiss <c.weiss@metaways.de>
6 * @copyright Copyright (c) 2016 Metaways Infosystems GmbH (http://www.metaways.de)
9 Ext.ns('Tine.widgets.display');
12 * @class Tine.widgets.display.RecordDisplayPanel
13 * @namespace Tine.widgets.display
14 * @extends Ext.ux.display.DisplayPanel
16 * @author Cornelius Weiss <c.weiss@metaways.de>
18 * Panel for displaying information of a singel record.
20 Tine.widgets.display.RecordDisplayPanel = Ext.extend(Ext.ux.display.DisplayPanel, {
23 * @cfg {Ext.data.Record} recordClass
24 * record definition class
37 * @property {Tine.Tinebase.Application}
46 * initializes the component, builds this.fields, calls parent
48 initComponent: function() {
49 this.appName = this.recordClass.getMeta('appName');
50 this.modelName = this.recordClass.getMeta('modelName');
52 this.app = Tine.Tinebase.appMgr.get(this.appName);
54 var containerProperty = this.recordClass.getMeta('containerProperty');
55 if (! this.containerRenderer && this.recordClass.hasField(containerProperty)) {
56 this.containerRenderer = Tine.widgets.grid.RendererManager.get(this.appName, this.modelName, containerProperty, Tine.widgets.grid.RendererManager.CATEGORY_DISPLAYPANEL);
70 style: 'padding-left: 5px; padding-right: 5px',
74 items: this.getHeadlineItems()
86 items: this.getBodyItems()
90 Tine.widgets.display.RecordDisplayPanel.superclass.initComponent.call(this);
93 getHeadlineItems: function() {
94 var headlineItems = [{
96 xtype: 'ux.displayfield',
97 name: this.recordClass.getMeta('titleProperty'),
98 style: 'padding-top: 2px',
99 cls: 'x-ux-display-header',
101 renderer: this.titleRenderer.createDelegate(this)
104 if (this.recordClass.getMeta('containerProperty')) {
107 xtype: 'ux.displayfield',
108 style: 'text-align: right;',
109 cls: 'x-ux-display-header',
110 name: this.recordClass.getMeta('containerProperty'),
112 renderer: this.containerRenderer
116 return headlineItems;
119 getBodyItems: function() {
120 var modelConfig = this.recordClass.getModelConfiguration(),
121 fieldsToExclude = ['tags', 'notes', 'attachments', 'relations', 'customfields',
122 this.recordClass.getMeta('idProperty'),
123 this.recordClass.getMeta('titleProperty'),
124 this.recordClass.getMeta('containerProperty')
126 fieldNames = this.recordClass.getFieldNames(),
130 Ext.each(Tine.Tinebase.Model.genericFields, function(field) {fieldsToExclude.push(field.name)});
132 Ext.each(fieldNames, function(fieldName) {
133 var fieldDefinition = modelConfig.fields[fieldName],
134 fieldType = fieldDefinition.type || 'textfield',
136 xtype: 'ux.displayfield',
137 name: fieldDefinition.fieldName,
138 fieldLabel: this.app.i18n._hidden(fieldDefinition.label || fieldDefinition.fieldName),
141 if (fieldsToExclude.indexOf(fieldDefinition.fieldName) < 0 && ! fieldDefinition.shy) {
142 if (fieldType == 'text') {
145 cls: 'x-ux-display-background-border',
146 xtype: 'ux.displaytextarea'
148 displayAreas.push(field);
150 var renderer = Tine.widgets.grid.RendererManager.get(this.appName, this.modelName, fieldDefinition.fieldName, Tine.widgets.grid.RendererManager.CATEGORY_DISPLAYPANEL);
152 field.renderer = renderer;
154 displayFields.push(field);
160 this.defaultHeight = 25 + displayFields.length * 18;
164 layout: 'ux.display',
170 items: [displayFields]
171 }].concat(displayAreas);
174 loadRecord: function(record) {
175 this.record = record;
177 this.supr().loadRecord.apply(this, arguments);
180 titleRenderer: function(title) {
181 return this.record ? Tine.Tinebase.EncodingHelper.encode(this.record.getTitle()) : Tine.Tinebase.EncodingHelper.encode(title);
185 Ext.reg('ux.displaypanel', Ext.ux.display.DisplayPanel);