Mercurial > lada > lada-client
view app/view/widget/base/TextField.js @ 821:4194f77e7bb1
added an errortext
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Fri, 29 May 2015 11:00:49 +0200 |
parents | 40834912929e |
children | 777bf66dbb11 |
line wrap: on
line source
/* 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.widget.base.TextField', { extend: 'Ext.panel.Panel', alias: 'widget.tfield', layout: 'hbox', border: 0, margin: '0, 0, 5, 0', initComponent: function() { this.items = [{ xtype: 'textfield', flex: 1, name: this.name, msgTarget: 'none', maxLength: this.maxLength || 1000, enforceMaxLength: this.enforceMaxLength || true, fieldLabel: this.fieldLabel, labelWidth: this.labelWidth, listeners: this.listeners }, { xtype: 'image', name: 'warnImg', src: 'resources/img/dialog-warning.png', width: 14, height: 14, hidden: true }, { xtype: 'image', name: 'errorImg', src: 'resources/img/emblem-important.png', width: 14, height: 14, hidden: true }]; this.callParent(arguments); }, showWarnings: function(warnings) { var img = this.down('image[name=warnImg]'); Ext.create('Ext.tip.ToolTip', { target: img.getEl(), html: warnings }); img.show(); this.down('textfield').invalidCls = 'x-lada-warning'; this.down('textfield').markInvalid(''); var fieldset = this.up('fieldset[collapsible=true]'); if (fieldset) { var i18n = Lada.getApplication().bundle; var warningText = i18n.getMsg(this.name) + ': ' + warnings; fieldset.showWarningOrError(true, warningText); } }, showErrors: function(errors) { var img = this.down('image[name=errorImg]'); var warnImg = this.down('image[name=warnImg]'); warnImg.hide(); Ext.create('Ext.tip.ToolTip', { target: img.getEl(), html: errors }); this.down('textfield').invalidCls = 'x-lada-error'; this.down('textfield').markInvalid(''); img.show(); var fieldset = this.up('fieldset[collapsible=true]'); if (fieldset) { var i18n = Lada.getApplication().bundle; var errorText = i18n.getMsg(this.name) + ': ' + errors; fieldset.showWarningOrError(false, '', true, errorText); } }, clearWarningOrError: function() { this.down('image[name=errorImg]').hide(); this.down('image[name=warnImg]').hide(); }, setReadOnly: function(value) { this.down('textfield').setReadOnly(value); } });