git_sitools_idoc / szcluster-db / workspace / client-public / js / forms / components / BooleanCheckBox.js @ 2830ca05
1 |
/***************************************
|
---|---|
2 |
* Copyright 2010-2014 CNES - CENTRE NATIONAL d'ETUDES SPATIALES
|
3 |
*
|
4 |
* This file is part of SITools2.
|
5 |
*
|
6 |
* SITools2 is free software: you can redistribute it and/or modify
|
7 |
* it under the terms of the GNU General Public License as published by
|
8 |
* the Free Software Foundation, either version 3 of the License, or
|
9 |
* (at your option) any later version.
|
10 |
*
|
11 |
* SITools2 is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with SITools2. If not, see <http://www.gnu.org/licenses/>.
|
18 |
***************************************/
|
19 |
/*global Ext, sitools*/
|
20 |
/*
|
21 |
* @include "../ComponentFactory.js"
|
22 |
*/
|
23 |
Ext.ns('sitools.common.forms.components');
|
24 |
|
25 |
/**
|
26 |
* @requires sitools.common.forms.ComponentFactory
|
27 |
* @class sitools.common.forms.components.BooleanCheckbox
|
28 |
* @extends Ext.Container
|
29 |
*/
|
30 |
sitools.common.forms.components.BooleanCheckbox = Ext.extend(Ext.Container, { |
31 |
//sitools.component.users.SubSelectionParameters.SingleSelection.BooleanCheckbox = Ext.extend(Ext.Container, {
|
32 |
|
33 |
initComponent : function () { |
34 |
this.context = new sitools.common.forms.ComponentFactory(this.context); |
35 |
this.cbGroup = new Ext.form.CheckboxGroup ({ |
36 |
allowBlank : true, |
37 |
flex : 1, |
38 |
items : [ {
|
39 |
xtype : "checkbox", |
40 |
checked : eval(this.defaultValues[0]), |
41 |
value : true |
42 |
} ] |
43 |
}); |
44 |
Ext.apply(this, {
|
45 |
layout : "hbox", |
46 |
stype : "sitoolsFormContainer", |
47 |
overCls : 'fieldset-child', |
48 |
items : [this.cbGroup] |
49 |
}); |
50 |
sitools.common.forms.components.BooleanCheckbox.superclass.initComponent.apply( |
51 |
this, arguments); |
52 |
|
53 |
if (!Ext.isEmpty(this.label)) { |
54 |
this.items.insert(0, new Ext.Container({ |
55 |
border : false, |
56 |
html : this.label, |
57 |
width : 100 |
58 |
})); |
59 |
} |
60 |
|
61 |
}, |
62 |
|
63 |
getSelectedValue : function () { |
64 |
if (this.cbGroup.getValue() && this.cbGroup.getValue().length > 0) { |
65 |
return "true"; |
66 |
} else {
|
67 |
return "false"; |
68 |
} |
69 |
|
70 |
}, |
71 |
getParameterValue : function () { |
72 |
var value = this.getSelectedValue(); |
73 |
return {
|
74 |
type : this.type, |
75 |
code : this.code, |
76 |
value : value
|
77 |
}; |
78 |
}, |
79 |
|
80 |
// *** Reset function for RESET button ***//
|
81 |
resetToDefault : function () { |
82 |
this.cbGroup.reset();
|
83 |
} |
84 |
// **************************************//
|
85 |
|
86 |
|
87 |
}); |