# HG changeset patch # User Raimund Renkert # Date 1418911431 -3600 # Node ID ce188e2fab06b0c4d81be337507befb034592e05 # Parent 0a948bb99b609fac7cf499678e0a76806a822abe Added custom textfield to shwo errors and warnings. diff -r 0a948bb99b60 -r ce188e2fab06 app/view/widgets/TextField.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/view/widgets/TextField.js Thu Dec 18 15:03:51 2014 +0100 @@ -0,0 +1,65 @@ +/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU GPL (v>=3) + * and comes with ABSOLUTELY NO WARRANTY! Check out + * the documentation coming with IMIS-Labordaten-Application for details. + */ + +Ext.define('Lada.view.widgets.TextField', { + extend: 'Ext.panel.Panel', + alias: 'widget.tfield', + + layout: 'hbox', + + border: 0, + + initComponent: function() { + this.items = [{ + xtype: 'image', + name: 'warnImg', + src: 'gfx/icon-warning.gif', + margin: '2, 5, 2, 5', + width: 16, + height: 16, + hidden: true + }, { + xtype: 'image', + name: 'errorImg', + src: 'gfx/icon-error.gif', + width: 16, + height: 16, + margin: '2, 5, 2, 5', + hidden: true + }, { + xtype: 'textfield', + flex: 1, + name: this.name, + maxLength: this.maxLength, + fieldLabel: this.fieldLabel, + labelWidth: this.labelWidth, + listeners: this.listeners + }]; + this.callParent(arguments); + }, + + showWarnings: function(warnings) { + var img = this.down('image[name=warnImg]'); + var field = this.down('textfield'); + Ext.create('Ext.tip.ToolTip', { + target: img.getEl(), + html: warnings + }); + field.setLabelWidth(field.labelWidth - 18); + img.show(); + }, + + showErrors: function(errors) { + var img = this.down('image[name=errorImg]'); + Ext.create('Ext.tip.ToolTip', { + target: img.getEl(), + html: errors + }); + img.show(); + } +});