raimund@548: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz raimund@548: * Software engineering by Intevation GmbH raimund@548: * raimund@548: * This file is Free Software under the GNU GPL (v>=3) raimund@548: * and comes with ABSOLUTELY NO WARRANTY! Check out raimund@548: * the documentation coming with IMIS-Labordaten-Application for details. raimund@548: */ raimund@548: raimund@548: /** raimund@548: * Datetimepicker with german date format. raimund@548: */ raimund@548: Ext.define('Lada.view.widget.base.Datetime', { raimund@548: extend: 'Ext.panel.Panel', raimund@548: alias: 'widget.datetime', raimund@548: requires: [ raimund@548: 'Ext.ux.form.DateTimeField' raimund@548: ], raimund@548: raimund@548: layout: 'hbox', raimund@548: raimund@548: border: 0, raimund@548: raimund@548: initComponent: function() { raimund@548: this.margin = this.fieldMargin; raimund@548: var dateField = Ext.create('Ext.ux.form.DateTimeField', { raimund@548: format: 'd.m.Y', raimund@548: emptyText: 'Wählen Sie einen Zeitpunkt', raimund@548: fieldLabel: this.fieldLabel, raimund@548: labelWidth: this.labelWidth, raimund@548: flex: 1, raimund@548: name: this.name, raimund@548: msgTarget: 'none', raimund@548: listeners: this.listeners raimund@548: }); raimund@548: this.items = [dateField, { raimund@548: xtype: 'image', raimund@548: name: 'warnImg', raimund@632: src: 'resources/img/dialog-warning.png', raimund@632: width: 14, raimund@632: height: 14, raimund@548: hidden: true raimund@548: }, { raimund@548: xtype: 'image', raimund@548: name: 'errorImg', raimund@632: src: 'resources/img/emblem-important.png', raimund@632: width: 14, raimund@632: height: 14, raimund@548: hidden: true raimund@548: }]; raimund@548: this.callParent(arguments); raimund@548: }, raimund@548: raimund@548: showWarnings: function(warnings) { raimund@548: var img = this.down('image[name=warnImg]'); raimund@548: Ext.create('Ext.tip.ToolTip', { raimund@548: target: img.getEl(), raimund@548: html: warnings raimund@548: }); raimund@548: this.down('datetimefield').invalidCls = 'x-lada-warning'; raimund@548: this.down('datetimefield').markInvalid(''); raimund@548: img.show(); raimund@548: var fieldset = this.up('fieldset[collapsible=true]'); raimund@548: if (fieldset) { raimund@634: var i18n = Lada.getApplication().bundle; raimund@634: var warningText = i18n.getMsg(this.name) + ': ' + warnings; raimund@634: fieldset.showWarningOrError(true, warningText); raimund@548: } raimund@548: }, raimund@548: raimund@548: showErrors: function(errors) { raimund@548: var img = this.down('image[name=errorImg]'); raimund@548: var warnImg = this.down('image[name=warnImg]'); raimund@548: warnImg.hide(); raimund@548: Ext.create('Ext.tip.ToolTip', { raimund@548: target: img.getEl(), raimund@548: html: errors raimund@548: }); raimund@548: this.down('datetimefield').invalidCls = 'x-lada-error'; raimund@548: this.down('datetimefield').markInvalid(''); raimund@548: img.show(); raimund@548: var fieldset = this.up('fieldset[collapsible=true]'); raimund@548: if (fieldset) { raimund@634: var i18n = Lada.getApplication().bundle; raimund@634: var errorText = i18n.getMsg(this.name) + ': ' + errors; raimund@634: fieldset.showWarningOrError(false, '', true, errorText); raimund@548: } raimund@548: }, raimund@548: raimund@548: clearWarningOrError: function() { raimund@548: this.down('image[name=errorImg]').hide(); raimund@548: this.down('image[name=warnImg]').hide(); raimund@548: }, raimund@548: raimund@548: setReadOnly: function(value) { raimund@548: this.down('datetimefield').setReadOnly(value); raimund@548: } raimund@548: });