dustin@645: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz dustin@645: * Software engineering by Intevation GmbH dustin@645: * dustin@645: * This file is Free Software under the GNU GPL (v>=3) dustin@645: * and comes with ABSOLUTELY NO WARRANTY! Check out dustin@645: * the documentation coming with IMIS-Labordaten-Application for details. dustin@645: */ dustin@645: dustin@892: /** dustin@892: * This Widget extends a Panel in order to create a custom Datefield dustin@892: */ dustin@645: Ext.define('Lada.view.widget.base.DateField', { dustin@645: extend: 'Ext.form.Panel', dustin@645: alias: 'widget.datef', dustin@645: dustin@645: requires: [ dustin@645: 'Ext.form.field.Date' dustin@645: ], dustin@645: dustin@645: layout: 'hbox', dustin@645: dustin@645: border: 0, dustin@645: dustin@645: margin: '0, 0, 5, 0', dustin@645: dustin@645: initComponent: function() { dustin@645: this.items = [{ dustin@645: xtype: 'datefield', dustin@645: flex: 1, dustin@645: name: this.name, dustin@645: fieldLabel: this.fieldLabel, dustin@645: labelWidth: this.labelWidth, dustin@645: listeners: this.listeners, dustin@645: triggerAction: this.triggerAction, dustin@645: format: this.format, dustin@645: msgTarget: 'none', dustin@645: tpl: this.tpl dustin@645: }, { dustin@645: xtype: 'image', dustin@645: name: 'warnImg', dustin@645: src: 'resources/img/dialog-warning.png', dustin@645: width: 14, dustin@645: height: 14, dustin@645: hidden: true dustin@645: }, { dustin@645: xtype: 'image', dustin@645: name: 'errorImg', dustin@645: src: 'resources/img/emblem-important.png', dustin@645: width: 14, dustin@645: height: 14, dustin@645: hidden: true dustin@645: }]; dustin@645: this.callParent(arguments); dustin@645: }, dustin@645: dustin@645: showWarnings: function(warnings) { dustin@645: var img = this.down('image[name=warnImg]'); dustin@645: Ext.create('Ext.tip.ToolTip', { dustin@645: target: img.getEl(), dustin@645: html: warnings dustin@645: }); dustin@645: this.down('datefield').invalidCls = 'x-lada-warning'; dustin@645: this.down('datefield').markInvalid(''); dustin@645: img.show(); dustin@645: var fieldset = this.up('fieldset[collapsible=true]'); dustin@645: if (fieldset) { dustin@645: var i18n = Lada.getApplication().bundle; dustin@645: var warningText = i18n.getMsg(this.name) + ': ' + warnings; dustin@645: fieldset.showWarningOrError(true, warningText); dustin@645: } dustin@645: }, dustin@645: dustin@645: showErrors: function(errors) { dustin@645: var img = this.down('image[name=errorImg]'); dustin@645: var warnImg = this.down('image[name=warnImg]'); dustin@645: warnImg.hide(); dustin@645: Ext.create('Ext.tip.ToolTip', { dustin@645: target: img.getEl(), dustin@645: html: errors dustin@645: }); dustin@645: this.down('datefield').invalidCls = 'x-lada-error'; dustin@645: this.down('datefield').markInvalid(''); dustin@645: img.show(); dustin@645: var fieldset = this.up('fieldset[collapsible=true]'); dustin@645: if (fieldset) { dustin@645: var i18n = Lada.getApplication().bundle; dustin@645: var errorText = i18n.getMsg(this.name) + ': ' + errors; dustin@645: fieldset.showWarningOrError(false, '', true, errorText); dustin@645: } dustin@645: }, dustin@645: dustin@645: clearWarningOrError: function() { dustin@645: this.down('image[name=errorImg]').hide(); dustin@645: this.down('image[name=warnImg]').hide(); dustin@645: }, dustin@645: dustin@645: getValue: function() { dustin@645: return this.down('datefield').getValue(); dustin@645: }, dustin@645: raimund@1016: setValue: function(value) { raimund@1016: this.down('datefield').setValue(value); raimund@1016: }, raimund@1016: raimund@733: clearValue: function() { raimund@733: this.down('datefield').clearValue(); raimund@733: }, raimund@733: dustin@645: getName: function() { dustin@645: return this.name; dustin@645: }, dustin@645: dustin@645: setReadOnly: function(value) { dustin@645: this.down('datefield').setReadOnly(value); dustin@645: } dustin@645: });