[Lada-commits] [PATCH 1 of 3] Added a Checkbox Widget
Wald Commits
scm-commit at wald.intevation.org
Fri Mar 13 15:00:47 CET 2015
# HG changeset patch
# User Dustin Demuth <dustin at intevation.de>
# Date 1426249249 -3600
# Node ID f240fe19ff5dc84da52c13c94643f2829ea9b4dc
# Parent 80077aeaa9ed553508ddbcf6d18da2926f6ae8eb
Added a Checkbox Widget
diff -r 80077aeaa9ed -r f240fe19ff5d app/view/widget/base/CheckBox.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/widget/base/CheckBox.js Fri Mar 13 13:20:49 2015 +0100
@@ -0,0 +1,96 @@
+/* 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.CheckBox', {
+ extend: 'Ext.form.Panel',
+ alias: 'widget.chkbox',
+
+ layout: 'hbox',
+
+ border: 0,
+
+ margin: '0, 0, 5, 0',
+
+ initComponent: function() {
+ this.items = [{
+ xtype: 'checkbox',
+ flex: 1,
+ name: this.name,
+ fieldLabel: this.fieldLabel,
+ labelWidth: this.labelWidth,
+ listeners: this.listeners,
+ triggerAction: this.triggerAction,
+ msgTarget: 'none',
+ tpl: this.tpl
+ }, {
+ xtype: 'image',
+ name: 'warnImg',
+ src: 'resources/img/icon-warning.gif',
+ width: 12,
+ height: 12,
+ hidden: true
+ }, {
+ xtype: 'image',
+ name: 'errorImg',
+ src: 'resources/img/icon-error.gif',
+ width: 12,
+ height: 12,
+ 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
+ });
+ this.down('checkbox').invalidCls = 'x-lada-warning';
+ this.down('checkbox').markInvalid('');
+ img.show();
+ var fieldset = this.up('fieldset[collapsible=true]');
+ if (fieldset) {
+ fieldset.showWarnings(warnings);
+ }
+ },
+
+ 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('checkbox').invalidCls = 'x-lada-error';
+ this.down('checkbox').markInvalid('');
+ img.show();
+ var fieldset = this.up('fieldset[collapsible=true]');
+ if (fieldset) {
+ fieldset.showErrors();
+ }
+ },
+
+ clearWarningOrError: function() {
+ this.down('image[name=errorImg]').hide();
+ this.down('image[name=warnImg]').hide();
+ },
+
+ getValue: function() {
+ return this.down('checkbox').getValue();
+ },
+
+ getName: function() {
+ return this.name;
+ },
+
+ setReadOnly: function(value) {
+ this.down('checkbox').setReadOnly(value);
+ }
+});
More information about the Lada-commits
mailing list