Project

General

Profile

Download (4.42 KB) Statistics
| Branch: | Revision:

git_sitools_idoc / szcluster-db / workspace / client-public / js / forms / components / PlanckType.js @ 2830ca05

1
/***************************************
2
 * Copyright 2011 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
//Ext.ns('sitools.component.users.SubSelectionParameters.SingleSelection');
21
Ext.ns('sitools.common.forms.components')
22

    
23
//sitools.component.users.SubSelectionParameters.SingleSelection.PlanckType = Ext.extend(Ext.Container, {
24

    
25
sitools.common.forms.components.PlanckType = Ext.extend(Ext.Container, {
26

    
27
        initComponent : function () {
28
                var defaultValue = "", value, items=[];
29
                items.push(['', '']);
30
                /*items.push(['20', 'Known clusters (type = 20)']);
31
                items.push(['10', 'New confirmed (type = 10)']);
32
                items.push(['1', 'New candidates-classe 1 (type = 1)']);
33
                items.push(['2', 'New candidates-classe 2 (type = 2)']);
34
                items.push(['3', 'New candidates-classe 3 (type = 3)']);*/
35
                items.push(['20', 'Known clusters']);
36
                items.push(['10', 'New confirmed']);
37
                items.push(['1', 'New candidates']);
38

    
39

    
40
                var store;
41
                store = new Ext.data.ArrayStore({
42
                        fields : [ 'id', 'value' ],
43
                        data : items
44
                });
45

    
46
                this.combo = new Ext.form.ComboBox ({
47
                        store : store,
48
                        parameterId : this.parameterId, 
49
                        sParentParam : this.parentParam, 
50
                        valueField : 'id',
51
                        displayField : 'value',
52
                        typeAhead : true,
53
                        mode : 'local',
54
                        triggerAction : 'all',
55
                        selectOnFocus : true,
56
                        allowBlank : true,
57
                        editable : false,
58
                        autoSelect : false,
59
                        flex : 1, 
60
                        height : this.height,
61
                        value : defaultValue,
62
                        tpl : '<tpl for="."><div class="x-combo-list-item comboItem">{value}</div></tpl>', 
63
                        stype : "sitoolsFormItem", 
64
                        /**
65
                         * The Parent Window.
66
                         */
67
                        parent : "panelResultForm" + this.formId, 
68

    
69
                        /**
70
                         * The code of the parameter to notify changed event.
71
                         */
72
                        code : this.code,
73
                        anchor : '90%', 
74
                        listeners : {
75
                                scope : this, 
76
                                'select' : function () {
77
                                        var parentPanel = this.ownerCt.ownerCt;
78
                                        parentPanel.fireEvent('componentChanged', parentPanel, this);
79
                                }
80
                        }
81
                });
82
                
83
                Ext.apply(this, {
84
                        stype : "sitoolsFormContainer",
85
                        layout : "hbox",
86
                        items : [new Ext.Container({
87
                                border : false,
88
                                html : this.label,
89
                                width : 50
90
                        }), this.combo, new Ext.Container({border : false,
91
                                html : '&nbsp;'}), new Ext.Container({
92
                                border : false,
93
                                html : '&nbsp;',
94
                                width : 5
95
                        })]
96
                });
97
                //sitools.component.users.SubSelectionParameters.SingleSelection.PlanckType.superclass.initComponent.apply(this,
98
                sitools.common.forms.components.PlanckType.superclass.initComponent.apply(this,
99
                                arguments);
100
        },
101

    
102
        notifyValueSelected : function () {
103
                this.parent.notifyValueChanged(this.code);
104
        },
105

    
106
        isValueDefined : function () {
107
                if (this.combo.getValue() && this.combo.getValue() !== "") {
108
                        return true;
109
                } else {
110
                        return false;
111
                }
112
        },
113
        getSelectedValue : function () {
114
                if (this.combo.getValue() && this.combo.getValue() !== "") {
115
                        return this.combo.getValue();
116
                } else {
117
                        return null;
118
                }
119
        },
120
        setSelectedValue : function (value) {
121
                this.combo.setValue(value);
122
        },
123
        getParameterValue : function () {
124
                var value = this.getSelectedValue();
125
                if (Ext.isEmpty(value)) {
126
                        return null;
127
                }
128
                
129
//                alert( this.type + "|" + value);
130
//                return this.type + "|" + this.code + "|" + value + "|" + probaval;
131
                //return this.type + "|" + value;
132
                if (value == "1") {
133
                        return {
134
                                    type : this.type, 
135
                                    code : "validation", 
136
                                value : '2'+"|"+'1'+"|"+'3'
137
                        }
138
                } 
139
                return {
140
                        type : this.type,
141
                        code : "validation",
142
                               value : value
143
                }
144
        },
145

    
146
//  *** Reset function for RESET button ***//
147
    resetToDefault : function () {
148
        this.combo.reset();
149
    }
150
//  ***************************************//
151

    
152

    
153
});