Revision d45a7442
Added by Alessandro_N over 10 years ago
| szcluster-db/workspace/client-public/js/forms/components/BooleanCheckBox.js | ||
|---|---|---|
| 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 |
}); |
|
| szcluster-db/workspace/client-public/js/forms/components/CheckBox.js | ||
|---|---|---|
| 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.CheckBox |
|
| 28 |
* @extends Ext.Container |
|
| 29 |
*/ |
|
| 30 |
sitools.common.forms.components.CheckBox = Ext.extend(Ext.Container, {
|
|
| 31 |
//sitools.component.users.SubSelectionParameters.MultipleSelection.CheckBox = Ext.extend(Ext.Container, {
|
|
| 32 |
|
|
| 33 |
initComponent : function () {
|
|
| 34 |
this.context = new sitools.common.forms.ComponentFactory(this.context); |
|
| 35 |
var items = []; |
|
| 36 |
for (i = 0; i < this.values.length; i++) {
|
|
| 37 |
value = this.values[i]; |
|
| 38 |
items.push({
|
|
| 39 |
value : value.value, |
|
| 40 |
boxLabel : value.value, |
|
| 41 |
name : this.code, |
|
| 42 |
checked : value.defaultValue, |
|
| 43 |
height : 25 |
|
| 44 |
|
|
| 45 |
}); |
|
| 46 |
} |
|
| 47 |
this.cbGroup = new Ext.form.CheckboxGroup ({
|
|
| 48 |
allowBlank : true, |
|
| 49 |
columns : 3, |
|
| 50 |
flex : 1, |
|
| 51 |
items : items |
|
| 52 |
}); |
|
| 53 |
Ext.apply(this, {
|
|
| 54 |
height : this.height, |
|
| 55 |
width : this.width, |
|
| 56 |
overCls : 'fieldset-child', |
|
| 57 |
layout : "hbox", |
|
| 58 |
stype : "sitoolsFormContainer", |
|
| 59 |
items : [this.cbGroup] |
|
| 60 |
}); |
|
| 61 |
sitools.common.forms.components.CheckBox.superclass.initComponent.apply(this, arguments); |
|
| 62 |
|
|
| 63 |
if (!Ext.isEmpty(this.label)) {
|
|
| 64 |
this.items.insert(0, new Ext.Container({
|
|
| 65 |
border : false, |
|
| 66 |
html : this.label, |
|
| 67 |
width : 100 |
|
| 68 |
})); |
|
| 69 |
} |
|
| 70 |
}, |
|
| 71 |
|
|
| 72 |
getSelectedValue : function () {
|
|
| 73 |
var values = this.cbGroup.getValue(); |
|
| 74 |
if (values && values.length > 0) {
|
|
| 75 |
var selectedValues = []; |
|
| 76 |
for (var i = 0; i < values.length; i++) {
|
|
| 77 |
if (Ext.isString(values[i].value) && ! Ext.isNumber(parseFloat(values[i].value))){
|
|
| 78 |
values[i].value = values[i].value; |
|
| 79 |
} |
|
| 80 |
selectedValues.push(values[i].value); |
|
| 81 |
} |
|
| 82 |
return selectedValues; |
|
| 83 |
} else {
|
|
| 84 |
return null; |
|
| 85 |
} |
|
| 86 |
}, |
|
| 87 |
getParameterValue : function () {
|
|
| 88 |
var values = this.getSelectedValue(); |
|
| 89 |
if (!Ext.isArray(values)) {
|
|
| 90 |
return null; |
|
| 91 |
} |
|
| 92 |
values = values.join("|");
|
|
| 93 |
// return this.type + "|" + this.code + "|" + values; |
|
| 94 |
return {
|
|
| 95 |
type : this.type, |
|
| 96 |
code : this.code, |
|
| 97 |
value : values |
|
| 98 |
}; |
|
| 99 |
|
|
| 100 |
}, |
|
| 101 |
|
|
| 102 |
// *** Reset function for RESET button ***// |
|
| 103 |
resetToDefault : function () {
|
|
| 104 |
this.cbGroup.reset(); |
|
| 105 |
} |
|
| 106 |
// **************************************// |
|
| 107 |
|
|
| 108 |
}); |
|
| szcluster-db/workspace/client-public/js/forms/components/ConeSearch.js | ||
|---|---|---|
| 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 "../AbstractComponentsWithUnit.js" |
|
| 22 |
* @include "../ComponentFactory.js" |
|
| 23 |
*/ |
|
| 24 |
Ext.ns('sitools.common.forms.components');
|
|
| 25 |
|
|
| 26 |
/** |
|
| 27 |
* Abstract Class to build Container to display a Cone Search. |
|
| 28 |
* subclasses : |
|
| 29 |
* - sitools.common.forms.components.ConeSearchCartesien |
|
| 30 |
* - sitools.common.forms.components.ConeSearchPGSphere |
|
| 31 |
* @requires sitools.common.forms.ComponentFactory |
|
| 32 |
* @class sitools.common.forms.components.AbstractConeSearch |
|
| 33 |
* @extends sitools.common.forms.AbstractWithUnit |
|
| 34 |
*/ |
|
| 35 |
sitools.common.forms.components.AbstractConeSearch = Ext.extend(sitools.common.forms.AbstractWithUnit, {
|
|
| 36 |
initComponent : function () {
|
|
| 37 |
this.context = new sitools.common.forms.ComponentFactory(this.context); |
|
| 38 |
//formattage de extraParams : |
|
| 39 |
var extraParams = {};
|
|
| 40 |
Ext.each(this.extraParams, function (param) {
|
|
| 41 |
extraParams[param.name]= param.value; |
|
| 42 |
}, this); |
|
| 43 |
|
|
| 44 |
this.extraParams = extraParams; |
|
| 45 |
var unit; |
|
| 46 |
//the administrator defines a dimension for this component |
|
| 47 |
if (!Ext.isEmpty(this.dimensionId)) {
|
|
| 48 |
var unit = new Ext.Button({
|
|
| 49 |
scope : this, |
|
| 50 |
text : i18n.get('label.degree'),
|
|
| 51 |
width : 100, |
|
| 52 |
sitoolsType : 'unitbutton', |
|
| 53 |
handler : function (b, e) {
|
|
| 54 |
//inherited method |
|
| 55 |
this.loadUnits(b, e); |
|
| 56 |
} |
|
| 57 |
}); |
|
| 58 |
} |
|
| 59 |
else {
|
|
| 60 |
unit = new Ext.Container({
|
|
| 61 |
html : i18n.get('label.degree'),
|
|
| 62 |
width : 100 |
|
| 63 |
}); |
|
| 64 |
|
|
| 65 |
} |
|
| 66 |
|
|
| 67 |
//Build the defaults Values |
|
| 68 |
var defaultRa = null; |
|
| 69 |
var defaultDec = null; |
|
| 70 |
var defaultThirdValue = null; |
|
| 71 |
if (Ext.isArray(this.defaultValues) && this.defaultValues.length == 3) {
|
|
| 72 |
defaultRa = this.defaultValues[0]; |
|
| 73 |
defaultDec = this.defaultValues[1]; |
|
| 74 |
defaultThirdValue = this.defaultValues[2]; |
|
| 75 |
} |
|
| 76 |
|
|
| 77 |
this.raParam = new Ext.form.NumberField({
|
|
| 78 |
fieldLabel : "RA", |
|
| 79 |
allowBlank : true, |
|
| 80 |
decimalPrecision : 20, |
|
| 81 |
anchor : "98%", |
|
| 82 |
value : defaultRa, |
|
| 83 |
flex : 1, |
|
| 84 |
labelSeparator : "" |
|
| 85 |
|
|
| 86 |
}); |
|
| 87 |
this.decParam = new Ext.form.NumberField({
|
|
| 88 |
fieldLabel : "DEC", |
|
| 89 |
allowBlank : true, |
|
| 90 |
decimalPrecision : 20, |
|
| 91 |
anchor : "98%", |
|
| 92 |
value : defaultDec, |
|
| 93 |
flex : 1, |
|
| 94 |
labelSeparator : "" |
|
| 95 |
}); |
|
| 96 |
|
|
| 97 |
this.thirdParam = new Ext.form.NumberField({
|
|
| 98 |
fieldLabel : this.getLabelThirdParam(), |
|
| 99 |
allowBlank : true, |
|
| 100 |
decimalPrecision : 20, |
|
| 101 |
value : defaultThirdValue, |
|
| 102 |
flex : 1, |
|
| 103 |
labelSeparator : "" |
|
| 104 |
}); |
|
| 105 |
|
|
| 106 |
var thirdCont = new Ext.form.CompositeField({
|
|
| 107 |
labelWidth : 100, |
|
| 108 |
fieldLabel : this.getLabelThirdParam(), |
|
| 109 |
items : [this.thirdParam, unit], |
|
| 110 |
labelSeparator : "" |
|
| 111 |
}); |
|
| 112 |
|
|
| 113 |
//build the resolver Name |
|
| 114 |
this.targetName = new Ext.form.TextField({
|
|
| 115 |
flex : 1, |
|
| 116 |
fieldLabel : i18n.get("label.targetName"),
|
|
| 117 |
enableKeyEvents : true, |
|
| 118 |
listeners : {
|
|
| 119 |
scope : this, |
|
| 120 |
change : function (field, newValue, oldValue) {
|
|
| 121 |
this.nameResolverButton.setDisabled(Ext.isEmpty(newValue)); |
|
| 122 |
}, |
|
| 123 |
keyup : function () {
|
|
| 124 |
this.nameResolverButton.setDisabled(Ext.isEmpty(this.targetName.getValue())); |
|
| 125 |
} |
|
| 126 |
} |
|
| 127 |
}); |
|
| 128 |
|
|
| 129 |
|
|
| 130 |
this.nameResolverButton = new Ext.Button({
|
|
| 131 |
scope : this, |
|
| 132 |
id : 'resolveNameBtn', |
|
| 133 |
handler : this.resolveTargetName, |
|
| 134 |
text : i18n.get('label.resolveName'),
|
|
| 135 |
width : 100, |
|
| 136 |
disabled : true |
|
| 137 |
}); |
|
| 138 |
|
|
| 139 |
var targetCmp = new Ext.form.FieldSet({
|
|
| 140 |
title : i18n.get('label.resolverName'),
|
|
| 141 |
items : [ |
|
| 142 |
new Ext.form.CompositeField ({
|
|
| 143 |
items : [this.targetName, this.nameResolverButton] |
|
| 144 |
}) |
|
| 145 |
] |
|
| 146 |
}); |
|
| 147 |
|
|
| 148 |
//Load the 3 fields into a form layout in the main container items |
|
| 149 |
var items = [{
|
|
| 150 |
layout : "form", |
|
| 151 |
items : [ this.raParam, this.decParam, thirdCont], |
|
| 152 |
flex : 3 |
|
| 153 |
}]; |
|
| 154 |
|
|
| 155 |
//insert first the name Resolver if needed |
|
| 156 |
if (this.extraParams.showTargetName && this.extraParams.showTargetName != "false") {
|
|
| 157 |
items[0].items.unshift(targetCmp); |
|
| 158 |
} |
|
| 159 |
|
|
| 160 |
Ext.apply(this, {
|
|
| 161 |
autoEl: 'div', |
|
| 162 |
layout : 'hbox', |
|
| 163 |
defaults : {
|
|
| 164 |
xtype : 'container', |
|
| 165 |
autoEl : 'div' |
|
| 166 |
}, |
|
| 167 |
items : items, |
|
| 168 |
overCls : 'fieldset-child', |
|
| 169 |
stype : "sitoolsFormContainer" |
|
| 170 |
}); |
|
| 171 |
sitools.common.forms.components.AbstractConeSearch.superclass.initComponent.apply( |
|
| 172 |
this, arguments); |
|
| 173 |
if (!Ext.isEmpty(this.label)) {
|
|
| 174 |
this.items.insert(0, new Ext.Container({
|
|
| 175 |
border : false, |
|
| 176 |
html : this.label, |
|
| 177 |
width : 100 |
|
| 178 |
})); |
|
| 179 |
} |
|
| 180 |
|
|
| 181 |
}, |
|
| 182 |
/** |
|
| 183 |
* Return true if values are specified |
|
| 184 |
* @return {Boolean}
|
|
| 185 |
*/ |
|
| 186 |
isValueDefined : function () {
|
|
| 187 |
if (this.raParam.getValue() && this.decParam.getValue() && this.thirdParam.getValue()) {
|
|
| 188 |
return true; |
|
| 189 |
} else {
|
|
| 190 |
return false; |
|
| 191 |
} |
|
| 192 |
}, |
|
| 193 |
/** |
|
| 194 |
* Return the ConeSearch value |
|
| 195 |
* @return {}
|
|
| 196 |
*/ |
|
| 197 |
getSelectedValue : function () {
|
|
| 198 |
return {
|
|
| 199 |
raParam : this.raParam.getValue(), |
|
| 200 |
decParam : this.decParam.getValue(), |
|
| 201 |
thirdParam : this.thirdParam.getValue() |
|
| 202 |
}; |
|
| 203 |
}, |
|
| 204 |
|
|
| 205 |
/** |
|
| 206 |
* Method to be called by the form |
|
| 207 |
* returns an object with type, code& value attributes |
|
| 208 |
* @return {}
|
|
| 209 |
*/ |
|
| 210 |
getParameterValue : function () {
|
|
| 211 |
var value = this.getSelectedValue(); |
|
| 212 |
if (Ext.isEmpty(value) || Ext.isEmpty(value.raParam) || Ext.isEmpty(value.decParam) || Ext.isEmpty(value.thirdParam)) {
|
|
| 213 |
return null; |
|
| 214 |
} |
|
| 215 |
return {
|
|
| 216 |
type : this.type, |
|
| 217 |
code : this.code, |
|
| 218 |
value : value.raParam + "|" + value.decParam + "|" + value.thirdParam, |
|
| 219 |
userDimension : this.userDimension, |
|
| 220 |
userUnit : this.userUnit |
|
| 221 |
}; |
|
| 222 |
|
|
| 223 |
}, |
|
| 224 |
/** |
|
| 225 |
* Name Resolver action. |
|
| 226 |
* Send a query as defined by the admin. |
|
| 227 |
* @param type |
|
| 228 |
* the type |
|
| 229 |
*/ |
|
| 230 |
resolveTargetName : function () {
|
|
| 231 |
|
|
| 232 |
var baseUrl = this.extraParams.resolveNameUrl; |
|
| 233 |
var url = baseUrl + "/" + this.targetName.getValue() + "/" + this.extraParams.coordSystem; |
|
| 234 |
|
|
| 235 |
if (!Ext.isEmpty(this.extraParams.resolverName)){
|
|
| 236 |
url += "?nameResolver=" + this.extraParams.resolverName; |
|
| 237 |
} |
|
| 238 |
|
|
| 239 |
this.getEl().mask(); |
|
| 240 |
Ext.Ajax.request({
|
|
| 241 |
url : url, |
|
| 242 |
scope : this, |
|
| 243 |
method : "GET", |
|
| 244 |
success : function (ret) {
|
|
| 245 |
try {
|
|
| 246 |
var json = Ext.decode(ret.responseText); |
|
| 247 |
|
|
| 248 |
if (json.totalResults > 1){
|
|
| 249 |
this.choosePropertyType(json); |
|
| 250 |
} |
|
| 251 |
else {
|
|
| 252 |
this.fillUpRADEC(json.features[0].geometry.coordinates); |
|
| 253 |
} |
|
| 254 |
} |
|
| 255 |
catch(err) {
|
|
| 256 |
Ext.Msg.alert(i18n.get('label.error'), i18n.get("label.unableToParseRequest"));
|
|
| 257 |
return; |
|
| 258 |
} |
|
| 259 |
}, |
|
| 260 |
failure : alertFailure, |
|
| 261 |
callback : function () {
|
|
| 262 |
this.getEl().unmask(); |
|
| 263 |
} |
|
| 264 |
}) |
|
| 265 |
}, |
|
| 266 |
|
|
| 267 |
/** |
|
| 268 |
* Choose a property type. |
|
| 269 |
* Define a type to fill up RA/DEC |
|
| 270 |
*/ |
|
| 271 |
choosePropertyType : function (json) {
|
|
| 272 |
|
|
| 273 |
var position = Ext.getCmp('resolveNameBtn').getPosition();
|
|
| 274 |
|
|
| 275 |
var tabTypes = []; |
|
| 276 |
|
|
| 277 |
tabTypes.push({
|
|
| 278 |
xtype : 'label', |
|
| 279 |
text : 'Select a Type : ', |
|
| 280 |
style : 'padding:3px; margin:auto; font-style:italic;' |
|
| 281 |
}); |
|
| 282 |
|
|
| 283 |
|
|
| 284 |
Ext.each(json.features, function(feat, ind, all){
|
|
| 285 |
if(feat.properties.type){
|
|
| 286 |
tabTypes.push({
|
|
| 287 |
xtype : 'button', |
|
| 288 |
text : feat.properties.type, |
|
| 289 |
style : 'padding:3px; margin:auto;', |
|
| 290 |
scope : this, |
|
| 291 |
handler : function(b, e){
|
|
| 292 |
this.fillUpRADEC(feat.geometry.coordinates); |
|
| 293 |
Ext.getCmp('nameResolverTypeWin').close();
|
|
| 294 |
} |
|
| 295 |
}); |
|
| 296 |
} |
|
| 297 |
}, this); |
|
| 298 |
|
|
| 299 |
var popup = new Ext.Window({
|
|
| 300 |
id : 'nameResolverTypeWin', |
|
| 301 |
x : position[0] + 4, |
|
| 302 |
y : position[1] + 18, |
|
| 303 |
title : '', |
|
| 304 |
bodyStyle : 'background-color : #E4E8EC;', |
|
| 305 |
frame:false, |
|
| 306 |
closable : false, |
|
| 307 |
resizable : false, |
|
| 308 |
draggable : true, |
|
| 309 |
items : tabTypes, |
|
| 310 |
listeners : {
|
|
| 311 |
deactivate : function (t){
|
|
| 312 |
t.close(); |
|
| 313 |
} |
|
| 314 |
} |
|
| 315 |
}).show(); |
|
| 316 |
}, |
|
| 317 |
|
|
| 318 |
fillUpRADEC : function (coord){
|
|
| 319 |
this.raParam.setValue(coord[0]); |
|
| 320 |
this.decParam.setValue(coord[1]); |
|
| 321 |
}, |
|
| 322 |
|
|
| 323 |
isValid : function () {
|
|
| 324 |
if(!this.isEmpty(this.raParam) || !this.isEmpty(this.decParam) || !this.isEmpty(this.decParam)) {
|
|
| 325 |
var valid = true; |
|
| 326 |
valid &= this.checkTextFieldIsNotEmpty(this.raParam); |
|
| 327 |
valid &= this.checkTextFieldIsNotEmpty(this.decParam); |
|
| 328 |
valid &= this.checkTextFieldIsNotEmpty(this.thirdParam); |
|
| 329 |
return valid; |
|
| 330 |
} else {
|
|
| 331 |
return true; |
|
| 332 |
} |
|
| 333 |
}, |
|
| 334 |
|
|
| 335 |
//private |
|
| 336 |
checkTextFieldIsNotEmpty : function (field){
|
|
| 337 |
var valid = true; |
|
| 338 |
if(this.isEmpty(field)){
|
|
| 339 |
field.markInvalid(); |
|
| 340 |
valid = false; |
|
| 341 |
} |
|
| 342 |
return valid; |
|
| 343 |
}, |
|
| 344 |
|
|
| 345 |
isEmpty : function (field) {
|
|
| 346 |
return Ext.isEmpty(field.getValue()) |
|
| 347 |
}, |
|
| 348 |
|
|
| 349 |
// *** Reset function for RESET button ***// |
|
| 350 |
resetToDefault : function () {
|
|
| 351 |
this.raParam.reset(); |
|
| 352 |
this.decParam.reset(); |
|
| 353 |
this.thirdParam.reset(); |
|
| 354 |
this.targetName.reset(); |
|
| 355 |
} |
|
| 356 |
// **************************************// |
|
| 357 |
|
|
| 358 |
}); |
|
| 359 |
|
|
| 360 |
/** |
|
| 361 |
* Specification of sitools.common.forms.components.AbstractConeSearch |
|
| 362 |
* @class sitools.common.forms.components.ConeSearchCartesien |
|
| 363 |
* @extends sitools.common.forms.components.AbstractConeSearch |
|
| 364 |
*/ |
|
| 365 |
sitools.common.forms.components.ConeSearchCartesien = Ext.extend(sitools.common.forms.components.AbstractConeSearch, {
|
|
| 366 |
getLabelThirdParam : function () {
|
|
| 367 |
return "Search Radius"; |
|
| 368 |
} |
|
| 369 |
}); |
|
| 370 |
|
|
| 371 |
/** |
|
| 372 |
* Specification of sitools.common.forms.components.AbstractConeSearch |
|
| 373 |
* @class sitools.common.forms.components.ConeSearchPGSphere |
|
| 374 |
* @extends sitools.common.forms.components.AbstractConeSearch |
|
| 375 |
*/ |
|
| 376 |
sitools.common.forms.components.ConeSearchPGSphere = Ext.extend(sitools.common.forms.components.AbstractConeSearch, {
|
|
| 377 |
getLabelThirdParam : function () {
|
|
| 378 |
return "Radius"; |
|
| 379 |
} |
|
| 380 |
}); |
|
| szcluster-db/workspace/client-public/js/forms/components/DateBetween.js | ||
|---|---|---|
| 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.DateBetween |
|
| 28 |
* @extends Ext.Container |
|
| 29 |
*/ |
|
| 30 |
sitools.common.forms.components.DateBetween = Ext.extend(Ext.Container, {
|
|
| 31 |
//sitools.component.users.SubSelectionParameters.SingleSelection.DateBetween = Ext.extend(Ext.Container, {
|
|
| 32 |
regToday : new RegExp("^\{\\$TODAY\}"),
|
|
| 33 |
initComponent : function () {
|
|
| 34 |
this.context = new sitools.common.forms.ComponentFactory(this.context); |
|
| 35 |
//formattage de extraParams : |
|
| 36 |
var extraParams = {};
|
|
| 37 |
Ext.each(this.extraParams, function (param) {
|
|
| 38 |
extraParams[param.name]= param.value; |
|
| 39 |
}, this); |
|
| 40 |
|
|
| 41 |
|
|
| 42 |
this.showTime = extraParams.showTime; |
|
| 43 |
if (Ext.isString(this.showTime)) {
|
|
| 44 |
this.showTime = extraParams.showTime == "true"; |
|
| 45 |
} |
|
| 46 |
this.truncateDefaultValue = extraParams.truncateDefaultValue; |
|
| 47 |
if (Ext.isString(this.truncateDefaultValue)) {
|
|
| 48 |
this.truncateDefaultValue = extraParams.truncateDefaultValue == "true"; |
|
| 49 |
} |
|
| 50 |
this.format = extraParams.format; |
|
| 51 |
|
|
| 52 |
var dateFormat = this.format; |
|
| 53 |
|
|
| 54 |
var valueFrom = this.getDefaultValue(this.defaultValues[0]) ; |
|
| 55 |
var valueTo = this.getDefaultValue(this.defaultValues[1]) ; |
|
| 56 |
|
|
| 57 |
this.fieldFrom = new Ext.form.DateField({
|
|
| 58 |
allowBlank : true, |
|
| 59 |
format : dateFormat, |
|
| 60 |
flex : 1, |
|
| 61 |
//height : this.height, |
|
| 62 |
value : valueFrom, |
|
| 63 |
showTime : this.showTime, |
|
| 64 |
listeners : {
|
|
| 65 |
scope : this, |
|
| 66 |
change : function (field, newValue, oldValue) {
|
|
| 67 |
this.fieldTo.setMinValue(newValue); |
|
| 68 |
this.fieldTo.validate(); |
|
| 69 |
} |
|
| 70 |
} |
|
| 71 |
}); |
|
| 72 |
this.fieldTo = new Ext.form.DateField({
|
|
| 73 |
allowBlank : true, |
|
| 74 |
format : dateFormat, |
|
| 75 |
flex : 1, |
|
| 76 |
//height : this.height, |
|
| 77 |
value : valueTo, |
|
| 78 |
showTime : this.showTime, |
|
| 79 |
minValue : valueFrom |
|
| 80 |
}); |
|
| 81 |
Ext.apply(this, {
|
|
| 82 |
layout : 'hbox', |
|
| 83 |
overCls : 'fieldset-child', |
|
| 84 |
stype : "sitoolsFormContainer", |
|
| 85 |
|
|
| 86 |
items : [this.fieldFrom, this.fieldTo ] |
|
| 87 |
}); |
|
| 88 |
sitools.common.forms.components.DateBetween.superclass.initComponent.apply( |
|
| 89 |
this, arguments); |
|
| 90 |
if (!Ext.isEmpty(this.label)) {
|
|
| 91 |
var labels = this.label.split("|") || [];
|
|
| 92 |
switch (labels.length) {
|
|
| 93 |
case 0 : |
|
| 94 |
break; |
|
| 95 |
case 1 : |
|
| 96 |
this.items.insert(0, new Ext.Container({
|
|
| 97 |
border : false, |
|
| 98 |
html : labels[0], |
|
| 99 |
width : 100 |
|
| 100 |
})); |
|
| 101 |
break; |
|
| 102 |
case 2 : |
|
| 103 |
this.items.insert(0, new Ext.Container({
|
|
| 104 |
border : false, |
|
| 105 |
html : labels[0], |
|
| 106 |
width : 50 |
|
| 107 |
})); |
|
| 108 |
this.items.insert(2, new Ext.Container({
|
|
| 109 |
border : false, |
|
| 110 |
html : labels[1], |
|
| 111 |
width : 50, |
|
| 112 |
style : {
|
|
| 113 |
"padding-left" : "10px" |
|
| 114 |
} |
|
| 115 |
})); |
|
| 116 |
break; |
|
| 117 |
case 3 : |
|
| 118 |
this.items.insert(0, new Ext.Container({
|
|
| 119 |
border : false, |
|
| 120 |
html : labels[0], |
|
| 121 |
width : 50 |
|
| 122 |
})); |
|
| 123 |
this.items.insert(1, new Ext.Container({
|
|
| 124 |
border : false, |
|
| 125 |
html : labels[1], |
|
| 126 |
width : 50, |
|
| 127 |
style : {
|
|
| 128 |
"padding-left" : "10px" |
|
| 129 |
} |
|
| 130 |
})); |
|
| 131 |
this.items.insert(3, new Ext.Container({
|
|
| 132 |
border : false, |
|
| 133 |
html : labels[2], |
|
| 134 |
width : 50, |
|
| 135 |
style : {
|
|
| 136 |
"padding-left" : "10px" |
|
| 137 |
} |
|
| 138 |
})); |
|
| 139 |
break; |
|
| 140 |
} |
|
| 141 |
} |
|
| 142 |
|
|
| 143 |
}, |
|
| 144 |
|
|
| 145 |
/** |
|
| 146 |
* The code of the parameter to notify changed event. |
|
| 147 |
*/ |
|
| 148 |
code : null, |
|
| 149 |
|
|
| 150 |
/** |
|
| 151 |
* The left bound of the period. |
|
| 152 |
*/ |
|
| 153 |
fieldFrom : null, |
|
| 154 |
|
|
| 155 |
/** |
|
| 156 |
* The right bound of the period. |
|
| 157 |
*/ |
|
| 158 |
fieldTo : null, |
|
| 159 |
|
|
| 160 |
notifyValueSelected : function () {
|
|
| 161 |
this.parent.notifyValueChanged(this.code); |
|
| 162 |
}, |
|
| 163 |
|
|
| 164 |
isValueDefined : function () {
|
|
| 165 |
if (this.fieldFrom.getValue() && this.fieldTo.getValue()) {
|
|
| 166 |
return true; |
|
| 167 |
} else {
|
|
| 168 |
return false; |
|
| 169 |
} |
|
| 170 |
}, |
|
| 171 |
|
|
| 172 |
getSelectedValue : function () {
|
|
| 173 |
return {
|
|
| 174 |
from : this.fieldFrom.getValue(), |
|
| 175 |
to : this.fieldTo.getValue() |
|
| 176 |
}; |
|
| 177 |
}, |
|
| 178 |
|
|
| 179 |
getParameterValue : function () {
|
|
| 180 |
var value = this.getSelectedValue(); |
|
| 181 |
if (Ext.isEmpty(value) || Ext.isEmpty(value.from) || Ext.isEmpty(value.to)) {
|
|
| 182 |
return null; |
|
| 183 |
} |
|
| 184 |
var format = SITOOLS_DATE_FORMAT; |
|
| 185 |
return {
|
|
| 186 |
type : this.type, |
|
| 187 |
code : this.code, |
|
| 188 |
value : value.from.format(format) + "|" + value.to.format(format) |
|
| 189 |
}; |
|
| 190 |
|
|
| 191 |
// return this.type + "|" + this.code + "|" + value.from.format(format) + "|" + value.to.format(format) ; |
|
| 192 |
}, |
|
| 193 |
|
|
| 194 |
/** |
|
| 195 |
* return a date truncated or not depending on this.truncateDefaultValue |
|
| 196 |
* @param {String} val A string representing date a SITOOLS_DATE_FORMAT or containg {$TODAY}
|
|
| 197 |
* @return {Date} the date
|
|
| 198 |
*/ |
|
| 199 |
getDefaultValue : function (val) {
|
|
| 200 |
var result; |
|
| 201 |
if (Ext.isEmpty(val)) {
|
|
| 202 |
return null; |
|
| 203 |
} |
|
| 204 |
else {
|
|
| 205 |
if (Ext.isDate(Date.parseDate(val, SITOOLS_DATE_FORMAT))) {
|
|
| 206 |
result = Date.parseDate(val, SITOOLS_DATE_FORMAT); |
|
| 207 |
} |
|
| 208 |
else {
|
|
| 209 |
if (this.regToday.test(val)) {
|
|
| 210 |
try {
|
|
| 211 |
result = sitools.common.utils.Date.stringWithTodayToDate(val); |
|
| 212 |
} |
|
| 213 |
catch (err) {
|
|
| 214 |
return null; |
|
| 215 |
} |
|
| 216 |
|
|
| 217 |
} |
|
| 218 |
} |
|
| 219 |
} |
|
| 220 |
|
|
| 221 |
if (this.truncateDefaultValue) {
|
|
| 222 |
return result.clearTime(); |
|
| 223 |
} |
|
| 224 |
else {
|
|
| 225 |
return result; |
|
| 226 |
} |
|
| 227 |
}, |
|
| 228 |
|
|
| 229 |
isValid : function () {
|
|
| 230 |
return (this.fieldFrom.isValid() && this.fieldTo.isValid()); |
|
| 231 |
}, |
|
| 232 |
|
|
| 233 |
// *** Reset function for RESET button ***// |
|
| 234 |
resetToDefault : function () {
|
|
| 235 |
this.fieldFrom.reset(); |
|
| 236 |
this.fieldTo.reset(); |
|
| 237 |
} |
|
| 238 |
// **************************************// |
|
| 239 |
|
|
| 240 |
}); |
|
| 241 |
|
|
| szcluster-db/workspace/client-public/js/forms/components/ListBoxMultiple.js | ||
|---|---|---|
| 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.ListBoxMultiple |
|
| 28 |
* @extends Ext.Container |
|
| 29 |
*/ |
|
| 30 |
sitools.common.forms.components.ListBoxMultiple = Ext.extend(Ext.Container, {
|
|
| 31 |
//sitools.component.users.SubSelectionParameters.MultipleSelection.ListBox = Ext.extend(Ext.Container, {
|
|
| 32 |
|
|
| 33 |
initComponent : function () {
|
|
| 34 |
this.context = new sitools.common.forms.ComponentFactory(this.context); |
|
| 35 |
var items = []; |
|
| 36 |
this.defaultValues = []; |
|
| 37 |
for (i = 0; i < this.values.length; i++) {
|
|
| 38 |
value = this.values[i]; |
|
| 39 |
items.push([ value.value, value.value ]); |
|
| 40 |
if (value.defaultValue) {
|
|
| 41 |
this.defaultValues.push(value.value); |
|
| 42 |
} |
|
| 43 |
} |
|
| 44 |
|
|
| 45 |
var store; |
|
| 46 |
if (this.valueSelection == 'S') {
|
|
| 47 |
store = new Ext.data.ArrayStore({
|
|
| 48 |
fields : ['value','text'], |
|
| 49 |
data : items, |
|
| 50 |
valueField : 'value', |
|
| 51 |
displayField : 'text' |
|
| 52 |
}); |
|
| 53 |
} else {
|
|
| 54 |
var params = {
|
|
| 55 |
colModel : [ this.code ], |
|
| 56 |
distinct : true |
|
| 57 |
}; |
|
| 58 |
store = new Ext.data.JsonStore({
|
|
| 59 |
fields : [ {
|
|
| 60 |
name : 'value', |
|
| 61 |
mapping : this.code |
|
| 62 |
}, {
|
|
| 63 |
name : 'text', |
|
| 64 |
mapping : this.code |
|
| 65 |
} ], |
|
| 66 |
autoLoad : !Ext.isEmpty(this.dataUrl) ? true : false, |
|
| 67 |
root : 'data', |
|
| 68 |
restful : true, |
|
| 69 |
url : this.dataUrl + "/records", |
|
| 70 |
baseParams : params, |
|
| 71 |
valueField : 'value', |
|
| 72 |
displayField : 'text' |
|
| 73 |
}); |
|
| 74 |
} |
|
| 75 |
this.multiSelect = new Ext.ux.form.MultiSelect ({
|
|
| 76 |
store : store, |
|
| 77 |
width : this.width, |
|
| 78 |
height : this.height - 10, |
|
| 79 |
flex : 1, |
|
| 80 |
delimiter : '|', |
|
| 81 |
stype : "sitoolsFormItem", |
|
| 82 |
listeners : {
|
|
| 83 |
scope : this, |
|
| 84 |
'click' : function () {
|
|
| 85 |
this.form.fireEvent('componentChanged', this.form, this);
|
|
| 86 |
}, |
|
| 87 |
'afterRender' : function () {
|
|
| 88 |
this.setSelectedValue(this.defaultValues); |
|
| 89 |
} |
|
| 90 |
} |
|
| 91 |
}); |
|
| 92 |
Ext.apply(this, {
|
|
| 93 |
height : this.height, |
|
| 94 |
width : this.width, |
|
| 95 |
layout : "hbox", |
|
| 96 |
overCls : 'fieldset-child', |
|
| 97 |
stype : "sitoolsFormContainer", |
|
| 98 |
items : [this.multiSelect] |
|
| 99 |
}); |
|
| 100 |
sitools.common.forms.components.ListBoxMultiple.superclass.initComponent.apply(this, |
|
| 101 |
arguments); |
|
| 102 |
if (!Ext.isEmpty(this.label)) {
|
|
| 103 |
this.items.insert(0, new Ext.Container({
|
|
| 104 |
border : false, |
|
| 105 |
html : this.label, |
|
| 106 |
width : 100 |
|
| 107 |
})); |
|
| 108 |
} |
|
| 109 |
|
|
| 110 |
}, |
|
| 111 |
|
|
| 112 |
/** |
|
| 113 |
* The code of the parameter to notify changed event. |
|
| 114 |
*/ |
|
| 115 |
code : null, |
|
| 116 |
|
|
| 117 |
isValueDefined : function () {
|
|
| 118 |
if (this.multiSelect.getValue() && this.multiSelect.getValue() !== "") {
|
|
| 119 |
return true; |
|
| 120 |
} else {
|
|
| 121 |
return false; |
|
| 122 |
} |
|
| 123 |
}, |
|
| 124 |
|
|
| 125 |
getSelectedValue : function () {
|
|
| 126 |
if (this.multiSelect.getValue()) {
|
|
| 127 |
return this.multiSelect.getValue(); |
|
| 128 |
} else {
|
|
| 129 |
return null; |
|
| 130 |
} |
|
| 131 |
}, |
|
| 132 |
|
|
| 133 |
|
|
| 134 |
setSelectedValue : function (values) {
|
|
| 135 |
this.multiSelect.setValue(values); |
|
| 136 |
}, |
|
| 137 |
|
|
| 138 |
getParameterValue : function () {
|
|
| 139 |
var value = this.getSelectedValue(); |
|
| 140 |
if (Ext.isEmpty(value)) {
|
|
| 141 |
return null; |
|
| 142 |
} |
|
| 143 |
// return this.type + "|" + this.code + "|" + value; |
|
| 144 |
return {
|
|
| 145 |
type : this.type, |
|
| 146 |
code : this.code, |
|
| 147 |
value : value |
|
| 148 |
}; |
|
| 149 |
|
|
| 150 |
}, |
|
| 151 |
|
|
| 152 |
// *** Reset function for RESET button ***// |
|
| 153 |
resetToDefault : function () {
|
|
| 154 |
this.multiSelect.reset(); |
|
| 155 |
} |
|
| 156 |
// ***************************************// |
|
| 157 |
}); |
|
| szcluster-db/workspace/client-public/js/forms/components/Listbox.js | ||
|---|---|---|
| 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.ListBox |
|
| 28 |
* @extends Ext.Container |
|
| 29 |
*/ |
|
| 30 |
sitools.common.forms.components.ListBox = Ext.extend(Ext.Container, {
|
|
| 31 |
//sitools.component.users.SubSelectionParameters.MultipleSelection.ListBox = Ext.extend(Ext.Container, {
|
|
| 32 |
|
|
| 33 |
initComponent : function () {
|
|
| 34 |
this.context = new sitools.common.forms.ComponentFactory(this.context); |
|
| 35 |
var items = []; |
|
| 36 |
this.defaultValues = []; |
|
| 37 |
for (i = 0; i < this.values.length; i++) {
|
|
| 38 |
value = this.values[i]; |
|
| 39 |
items.push([ value.value, value.value ]); |
|
| 40 |
if (value.defaultValue) {
|
|
| 41 |
this.defaultValues.push(value.value); |
|
| 42 |
} |
|
| 43 |
} |
|
| 44 |
|
|
| 45 |
var store; |
|
| 46 |
if (this.valueSelection == 'S') {
|
|
| 47 |
store = new Ext.data.ArrayStore({
|
|
| 48 |
fields : ['value','text'], |
|
| 49 |
data : items, |
|
| 50 |
valueField : 'value', |
|
| 51 |
displayField : 'text' |
|
| 52 |
}); |
|
| 53 |
} else {
|
|
| 54 |
var params = {
|
|
| 55 |
colModel : [ this.code ], |
|
| 56 |
distinct : true |
|
| 57 |
}; |
|
| 58 |
store = new Ext.data.JsonStore({
|
|
| 59 |
fields : [ {
|
|
| 60 |
name : 'value', |
|
| 61 |
mapping : this.code |
|
| 62 |
}, {
|
|
| 63 |
name : 'text', |
|
| 64 |
mapping : this.code |
|
| 65 |
} ], |
|
| 66 |
autoLoad : !Ext.isEmpty(this.dataUrl) ? true : false, |
|
| 67 |
root : 'data', |
|
| 68 |
restful : true, |
|
| 69 |
url : this.dataUrl + "/records", |
|
| 70 |
baseParams : params, |
|
| 71 |
valueField : 'value', |
|
| 72 |
displayField : 'text' |
|
| 73 |
}); |
|
| 74 |
} |
|
| 75 |
this.multiSelect = new Ext.ux.form.MultiSelect ({
|
|
| 76 |
store : store, |
|
| 77 |
width : this.width, |
|
| 78 |
height : this.height - 10, |
|
| 79 |
flex : 1, |
|
| 80 |
delimiter : '|', |
|
| 81 |
stype : "sitoolsFormItem", |
|
| 82 |
listeners : {
|
|
| 83 |
scope : this, |
|
| 84 |
'click' : function () {
|
|
| 85 |
this.form.fireEvent('componentChanged', this.form, this);
|
|
| 86 |
}, |
|
| 87 |
'afterRender' : function () {
|
|
| 88 |
this.setSelectedValue(this.defaultValues); |
|
| 89 |
} |
|
| 90 |
} |
|
| 91 |
}); |
|
| 92 |
Ext.apply(this, {
|
|
| 93 |
height : this.height, |
|
| 94 |
width : this.width, |
|
| 95 |
overCls : 'fieldset-child', |
|
| 96 |
layout : "hbox", |
|
| 97 |
stype : "sitoolsFormContainer", |
|
| 98 |
items : [this.multiSelect] |
|
| 99 |
}); |
|
| 100 |
sitools.common.forms.components.ListBox.superclass.initComponent.apply(this, |
|
| 101 |
arguments); |
|
| 102 |
if (!Ext.isEmpty(this.label)) {
|
|
| 103 |
this.items.insert(0, new Ext.Container({
|
|
| 104 |
border : false, |
|
| 105 |
html : this.label, |
|
| 106 |
width : 100 |
|
| 107 |
})); |
|
| 108 |
} |
|
| 109 |
|
|
| 110 |
}, |
|
| 111 |
|
|
| 112 |
/** |
|
| 113 |
* The code of the parameter to notify changed event. |
|
| 114 |
*/ |
|
| 115 |
code : null, |
|
| 116 |
|
|
| 117 |
isValueDefined : function () {
|
|
| 118 |
if (this.multiSelect.getValue() && this.multiSelect.getValue() !== "") {
|
|
| 119 |
return true; |
|
| 120 |
} else {
|
|
| 121 |
return false; |
|
| 122 |
} |
|
| 123 |
}, |
|
| 124 |
|
|
| 125 |
getSelectedValue : function () {
|
|
| 126 |
if (this.multiSelect.getValue()) {
|
|
| 127 |
return this.multiSelect.getValue(); |
|
| 128 |
} else {
|
|
| 129 |
return null; |
|
| 130 |
} |
|
| 131 |
}, |
|
| 132 |
|
|
| 133 |
|
|
| 134 |
setSelectedValue : function (values) {
|
|
| 135 |
this.multiSelect.setValue(values); |
|
| 136 |
}, |
|
| 137 |
|
|
| 138 |
getParameterValue : function () {
|
|
| 139 |
var value = this.getSelectedValue(); |
|
| 140 |
if (Ext.isEmpty(value)) {
|
|
| 141 |
return null; |
|
| 142 |
} |
|
| 143 |
// return this.type + "|" + this.code + "|" + value; |
|
| 144 |
return {
|
|
| 145 |
type : this.type, |
|
| 146 |
code : this.code, |
|
| 147 |
value : value |
|
| 148 |
}; |
|
| 149 |
|
|
| 150 |
}, |
|
| 151 |
|
|
| 152 |
// *** Reset function for RESET button ***// |
|
| 153 |
resetToDefault : function () {
|
|
| 154 |
this.multiSelect.reset(); |
|
| 155 |
} |
|
| 156 |
// **************************************// |
|
| 157 |
|
|
| 158 |
}); |
|
| szcluster-db/workspace/client-public/js/forms/components/NumberBetween.js | ||
|---|---|---|
| 22 | 22 |
* @include "../ComponentFactory.js" |
| 23 | 23 |
*/ |
| 24 | 24 |
Ext.ns('sitools.common.forms.components');
|
| 25 |
|
|
| 25 | 26 |
/** |
| 26 | 27 |
* A number between form component. |
| 27 | 28 |
* @cfg {string} parameterId Id of the future component.
|
| ... | ... | |
| 71 | 72 |
flex : 1, |
| 72 | 73 |
//height : this.height, |
| 73 | 74 |
|
| 75 |
/* Comment here and uncomment line 95 for the 2nd option */ |
|
| 76 |
/*value : this.defaultValues[0], |
|
| 77 |
fieldClass : "defaultGray", |
|
| 78 |
focusClass : "textblack",*/ |
|
| 79 |
/****/ |
|
| 80 |
|
|
| 74 | 81 |
validator : function (value) {
|
| 75 | 82 |
if (Ext.isEmpty(this.ownerCt.fieldTo.getValue())) {
|
| 76 | 83 |
return true; |
| ... | ... | |
| 95 | 102 |
flex : 1, |
| 96 | 103 |
//height : this.height, |
| 97 | 104 |
|
| 105 |
/* Comment here and uncomment line 124 for the 2nd option */ |
|
| 106 |
/*value : this.defaultValues[1], |
|
| 107 |
fieldClass : "defaultGray", |
|
| 108 |
focusClass : "textblack",*/ |
|
| 109 |
/****/ |
|
| 110 |
|
|
| 98 | 111 |
validator : function (value) {
|
| 99 | 112 |
if (value < this.ownerCt.fieldFrom.getValue()) {
|
| 100 | 113 |
return "invalid Value"; |
| szcluster-db/workspace/client-public/js/forms/components/NumberFieldUser.js | ||
|---|---|---|
| 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 "../AbstractComponentsWithUnit.js" |
|
| 22 |
* @include "../ComponentFactory.js" |
|
| 23 |
*/ |
|
| 24 |
Ext.ns('sitools.common.forms.components');
|
|
| 25 |
|
|
| 26 |
/** |
|
| 27 |
* A number Field form component. |
|
| 28 |
* @cfg {string} parameterId Id of the future component.
|
|
| 29 |
* @cfg {Array} code Array of string representing columns alias attached to this component
|
|
| 30 |
* @cfg {string} type Defines wich unique type of component it is.
|
|
| 31 |
* @cfg {string} label The label of the form component.
|
|
| 32 |
* @cfg {numeric} height height of the future component.
|
|
| 33 |
* @cfg {numeric} widthBox width of the future component.
|
|
| 34 |
* @cfg {string} valueSelection "S" for specific Selection, "D" for data selection.
|
|
| 35 |
* @cfg {string} dataUrl the url to request the data in case of valueSelection == "D".
|
|
| 36 |
* @cfg {boolean} autoComplete for TEXTFIELD, autoComplete configuration of future Ext.form.Textfield.
|
|
| 37 |
* @cfg {string} formId The form id that contains this component.
|
|
| 38 |
* @cfg {string} dimensionId The sitools units dimension id.
|
|
| 39 |
* @cfg {string} css An optional css to add to this component.
|
|
| 40 |
* @cfg {Array} defaultValues Array of default values.
|
|
| 41 |
* @cfg {} datasetCm the dataset ColumnModel object
|
|
| 42 |
* @requires sitools.common.forms.ComponentFactory |
|
| 43 |
* @class sitools.common.forms.components.NumberField |
|
| 44 |
* @extends sitools.common.forms.AbstractWithUnit |
|
| 45 |
*/ |
|
| 46 |
sitools.common.forms.components.NumberField = Ext.extend(sitools.common.forms.AbstractWithUnit, {
|
|
| 47 |
//sitools.component.users.SubSelectionParameters.SingleSelection.NumberFieldUser = Ext.extend(sitools.common.forms.AbstractWithUnit, {
|
|
| 48 |
|
|
| 49 |
/** |
|
| 50 |
* The numeric field |
|
| 51 |
*/ |
|
| 52 |
field : null, |
|
| 53 |
|
|
| 54 |
initComponent : function () {
|
|
| 55 |
this.context = new sitools.common.forms.ComponentFactory(this.context); |
|
| 56 |
|
|
| 57 |
|
|
| 58 |
var extraParams = {};
|
|
| 59 |
Ext.each(this.extraParams, function (param) {
|
|
| 60 |
extraParams[param.name]= param.value; |
|
| 61 |
}, this); |
|
| 62 |
|
|
| 63 |
this.extraParams = extraParams; |
|
| 64 |
|
|
| 65 |
var unit = this.getUnitComponent(); |
|
| 66 |
|
|
| 67 |
this.field = new Ext.form.NumberField({
|
|
| 68 |
allowBlank : true, |
|
| 69 |
flex : 1, |
|
| 70 |
//height : this.height, |
|
| 71 |
value : this.defaultValues[0], |
|
| 72 |
decimalPrecision : 20 |
|
| 73 |
}); |
|
| 74 |
var items = [this.field]; |
|
| 75 |
|
|
| 76 |
if (!Ext.isEmpty(unit)) {
|
|
| 77 |
items.push(unit); |
|
| 78 |
} |
|
| 79 |
|
|
| 80 |
Ext.apply(this, {
|
|
| 81 |
layout : 'hbox', |
|
| 82 |
stype : "sitoolsFormContainer", |
|
| 83 |
overCls : 'fieldset-child', |
|
| 84 |
defaults : {
|
|
| 85 |
xtype : 'container', |
|
| 86 |
autoEl : 'div' |
|
| 87 |
}, |
|
| 88 |
items : items |
|
| 89 |
}); |
|
| 90 |
sitools.common.forms.components.NumberField.superclass.initComponent.apply( |
|
| 91 |
this, arguments); |
|
| 92 |
if (!Ext.isEmpty(this.label)) {
|
|
| 93 |
this.items.insert(0, new Ext.Container({
|
|
| 94 |
border : false, |
|
| 95 |
html : this.label, |
|
| 96 |
width : 100 |
|
| 97 |
})); |
|
| 98 |
} |
|
| 99 |
|
|
| 100 |
}, |
|
| 101 |
|
|
| 102 |
/** |
|
| 103 |
* Notify the parent of any change |
|
| 104 |
* @method |
|
| 105 |
*/ |
|
| 106 |
notifyValueSelected : function () {
|
|
| 107 |
this.parent.notifyValueChanged(this.code); |
|
| 108 |
}, |
|
| 109 |
|
|
| 110 |
/** |
|
| 111 |
* Return if the value is defined. |
|
| 112 |
* @method |
|
| 113 |
* @return {Boolean}
|
|
| 114 |
*/ |
|
| 115 |
isValueDefined : function () {
|
|
| 116 |
if (this.fieldFrom.getValue()) {
|
|
| 117 |
return true; |
|
| 118 |
} else {
|
|
| 119 |
return false; |
|
| 120 |
} |
|
| 121 |
}, |
|
| 122 |
|
|
| 123 |
/** |
|
| 124 |
* Get the selected Value |
|
| 125 |
* @return {Numeric} the selected Value
|
|
| 126 |
*/ |
|
| 127 |
getSelectedValue : function () {
|
|
| 128 |
return this.field.getValue(); |
|
| 129 |
}, |
|
| 130 |
|
|
| 131 |
/** |
|
| 132 |
* Returns the value to request corresponding to the Filter API. |
|
| 133 |
* @return {String} parameter filter value
|
|
| 134 |
*/ |
|
| 135 |
getParameterValue : function () {
|
|
| 136 |
var value = this.getSelectedValue(); |
|
| 137 |
if (Ext.isEmpty(value) || Ext.isEmpty(value)) {
|
|
| 138 |
return null; |
|
| 139 |
} |
|
| 140 |
var result = this.type + "|" + this.code + "|" + value; |
|
| 141 |
if (!Ext.isEmpty(this.userDimension) && !Ext.isEmpty(this.userUnit)){
|
|
| 142 |
result += "|" + this.userDimension + "|" + this.userUnit; |
|
| 143 |
} |
|
| 144 |
return {
|
|
| 145 |
type : this.type, |
|
| 146 |
code : this.code, |
|
| 147 |
value : value, |
|
| 148 |
userDimension : this.userDimension, |
|
| 149 |
userUnit : this.userUnit |
|
| 150 |
}; |
|
| 151 |
}, |
|
| 152 |
|
|
| 153 |
// *** Reset function for RESET button ***// |
|
| 154 |
resetToDefault : function () {
|
|
| 155 |
this.field.reset(); |
|
| 156 |
}, |
|
| 157 |
// |
|
| 158 |
|
|
| 159 |
}); |
|
| szcluster-db/workspace/client-public/js/forms/components/OneOrBetween.js | ||
|---|---|---|
| 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, i18n*/ |
|
| 20 |
/* |
|
| 21 |
* @include "../AbstractComponentsWithUnit.js" |
|
| 22 |
* @include "../ComponentFactory.js" |
|
| 23 |
*/ |
|
| 24 |
Ext.ns('sitools.common.forms.components');
|
|
| 25 |
|
|
| 26 |
/** |
|
| 27 |
* A number between form component. |
|
| 28 |
* @cfg {string} parameterId Id of the future component.
|
|
| 29 |
* @cfg {Array} code Array of string representing columns alias attached to this component
|
|
| 30 |
* @cfg {string} type Defines wich unique type of component it is.
|
|
| 31 |
* @cfg {string} label The label of the form component.
|
|
| 32 |
* @cfg {numeric} height height of the future component.
|
|
| 33 |
* @cfg {numeric} widthBox width of the future component.
|
|
| 34 |
* @cfg {string} valueSelection "S" for specific Selection, "D" for data selection.
|
|
| 35 |
* @cfg {string} dataUrl the url to request the data in case of valueSelection == "D".
|
|
| 36 |
* @cfg {boolean} autoComplete for TEXTFIELD, autoComplete configuration of future Ext.form.Textfield.
|
|
| 37 |
* @cfg {string} formId The form id that contains this component.
|
|
| 38 |
* @cfg {string} dimensionId The sitools units dimension id.
|
|
| 39 |
* @cfg {string} css An optional css to add to this component.
|
|
| 40 |
* @cfg {Array} defaultValues Array of default values.
|
|
| 41 |
* @cfg {} datasetCm the dataset ColumnModel object
|
|
| 42 |
* @requires sitools.common.forms.ComponentFactory |
|
| 43 |
* @class sitools.common.forms.components.OneOrBetween |
|
| 44 |
* @extends sitools.common.forms.AbstractWithUnit |
|
| 45 |
*/ |
|
| 46 |
sitools.common.forms.components.OneOrBetween = Ext.extend(sitools.common.forms.AbstractWithUnit, {
|
|
| 47 |
//sitools.component.users.SubSelectionParameters.SingleSelection.OneOrBetween = Ext.extend(sitools.common.forms.AbstractWithUnit, {
|
|
| 48 |
/** |
|
| 49 |
* the first value. |
|
| 50 |
*/ |
|
| 51 |
fieldOne : null, |
|
| 52 |
|
|
| 53 |
/** |
|
| 54 |
* The left bound of the period. |
|
| 55 |
*/ |
|
| 56 |
fieldFrom : null, |
|
| 57 |
|
|
| 58 |
/** |
|
| 59 |
* The right bound of the period. |
|
| 60 |
*/ |
|
| 61 |
fieldTo : null, |
|
| 62 |
|
|
| 63 |
|
|
| 64 |
initComponent : function () {
|
|
| 65 |
this.context = new sitools.common.forms.ComponentFactory(this.context); |
|
| 66 |
|
|
| 67 |
//formattage de extraParams : |
|
| 68 |
var unit = this.getUnitComponent(); |
|
| 69 |
|
|
| 70 |
this.fieldOne = new Ext.form.NumberField({
|
|
| 71 |
allowBlank : true, |
|
| 72 |
//height : this.height, |
|
| 73 |
value : this.defaultValues[0], |
|
| 74 |
flex : 2, |
|
| 75 |
listeners : |
|
| 76 |
{
|
|
| 77 |
scope : this, |
|
| 78 |
change : function () {
|
|
| 79 |
this.fieldTo.setValue("");
|
|
| 80 |
this.fieldFrom.setValue("");
|
|
| 81 |
} |
|
| 82 |
}, |
|
| 83 |
decimalPrecision : 20 |
|
| 84 |
}); |
|
| 85 |
|
|
| 86 |
this.fieldFrom = new Ext.form.NumberField({
|
|
| 87 |
allowBlank : true, |
|
| 88 |
//height : this.height, |
|
| 89 |
flex : 2, |
|
| 90 |
validator : function (value) {
|
|
| 91 |
if (Ext.isEmpty(this.ownerCt.fieldTo.getValue())) {
|
|
| 92 |
return true; |
|
| 93 |
} |
|
| 94 |
if (value > this.ownerCt.fieldTo.getValue()) {
|
|
| 95 |
return "invalid Value"; |
|
| 96 |
} else {
|
|
| 97 |
return true; |
|
| 98 |
} |
|
| 99 |
}, |
|
| 100 |
listeners : {
|
|
| 101 |
change : function () {
|
|
| 102 |
this.ownerCt.fieldOne.setValue("");
|
|
| 103 |
} |
|
| 104 |
}, |
|
| 105 |
decimalPrecision : 20 |
|
| 106 |
}); |
|
| 107 |
this.fieldTo = new Ext.form.NumberField({
|
|
| 108 |
allowBlank : true, |
|
| 109 |
//height : this.height, |
|
| 110 |
flex : 2, |
|
| 111 |
validator : function (value) {
|
|
| 112 |
if (value < this.ownerCt.fieldFrom.getValue()) {
|
|
| 113 |
return "invalid Value"; |
|
| 114 |
} else {
|
|
| 115 |
return true; |
|
| 116 |
} |
|
| 117 |
}, |
|
| 118 |
listeners : {
|
|
| 119 |
change : function () {
|
|
Also available in: Unified diff
Updated code to create a 'Reset Form' button