1 /** 2 * @require framework/widgets/form/MultipleInputField.js 3 */ 4 5 /** 6 * @namespace framework.widgets 7 */ 8 Ext.namespace("framework.widgets"), 9 /** 10 * Panel search engine container. 11 * This implementation manage different search engine. 12 * By default, place a comboBox to switch different search engine components located inside the panel. 13 * @name_ PanelSearch 14 * @class Panel search engine container. 15 * @constructor 16 * @extends <a target="_blank" href="http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.panel.Panel">Ext.Panel</a> 17 */ 18 framework.widgets.TopDizioniDataPanel = Ext.extend(Ext.Window, { 19 /** 20 * The Servlet name used to get Poi Term-Category information 21 * @type String 22 */ 23 topCatTipServeltName: 'toponimirequest', 24 id: 'IDTopDizioniDataPanel', 25 layout: 'fit', 26 width: 450, 27 height: 420, 28 title: 'Dizione', 29 closable: false, 30 resizable: true, 31 plain: true, 32 border: false, 33 x: 100, 34 y: 100, 35 initTipo: null, 36 /** api: config[urlService] 37 * 38 * url to proxy for authenticate http calls 39 * @public 40 * @type String 41 */ 42 urlProxy: '', 43 /** api: config[geometryFields] 44 * 45 * fields from service answer to be transformed on OpenLayers.Bounds 46 * @public 47 * @type Array of String 48 */ 49 geometryFields: null, 50 srs: 'EPSG:300', 51 topFeature: null, 52 topFeatureNew: null, 53 /** 54 * paht for images marker, 55 * default value is "theme/app/img/". 56 * @public 57 * @type String 58 */ 59 markersImgPath: 'theme/app/img/', 60 click: null, 61 checkControlClick: false, 62 userAuthDS: null, 63 64 destroy: function() { 65 framework.widgets.TopDizioniDataPanel.superclass.destroy.apply(this, arguments); 66 }, 67 initComponent: function() { 68 69 var langData = [ 70 ['ita','Italiano'], 71 ['Srd','Sardo'] 72 ]; 73 74 // create the data store 75 this.langDS = new Ext.data.ArrayStore({ 76 fields: [ 77 {name: 'lang', type: 'string'}, 78 {name: 'desc', type: 'string'} 79 ] 80 }); 81 this.langDS.loadData(langData); 82 83 this.fontiDS = new Ext.data.Store({ 84 url: this.topCatTipServeltName, 85 baseParams: {method: 'getFonti'}, 86 reader: new Ext.data.JsonReader({ 87 id: 'codice' 88 }, [ 89 {name: 'codice', mapping: 'codice'}, 90 {name: 'descrizione', mapping: 'descrizione'} 91 ]), 92 listeners: { 93 load: function() { 94 this.toFront(); 95 if (this.codice_fonte) { 96 this._dizioneform.getForm().findField('fonte').setValue(this.codice_fonte); 97 this.codice_fonte = null; 98 } 99 100 }, 101 scope: this 102 } 103 }); 104 105 106 this.scaleDS = new Ext.data.Store({ 107 url: this.topCatTipServeltName, 108 baseParams: {method: 'getScala'}, 109 reader: new Ext.data.JsonReader({ 110 id: 'id' 111 }, [ 112 {name: 'id', mapping: 'id'}, 113 {name: 'scalaVisualMin', mapping: 'scalaVisualMin'}, 114 {name: 'scalaVisualMax', mapping: 'scalaVisualMax'} 115 ]), 116 listeners: { 117 load: function() { 118 this.toFront(); 119 /* if (this.idscala) { 120 this._dizioneform.getForm().findField('scalavis').setValue(this.idscala); 121 this.idscala = null; 122 }*/ 123 124 125 }, 126 scope: this 127 } 128 }); 129 130 131 var _self = this; 132 133 this._dizioneform = new Ext.FormPanel({ 134 labelWidth: 100, 135 frame: true, 136 defaultType: 'textfield', 137 id: 'dizioneFormID', 138 // monitorValid: true, 139 standardSubmit: false, 140 layout: 'form', 141 items: [ 142 {id: 'idDizione', xtype: 'hidden', name: 'idDizione'}, 143 { 144 id: 'topDizLingua', 145 xtype: 'combo', 146 name: 'lang_name', 147 mode: 'local', 148 editable: false, 149 store: this.langDS, 150 valueField: 'lang', 151 displayField: 'desc', 152 width: 300, 153 blankText : this.blankText, 154 emptyText: 'Seleziona una lingua...', 155 fieldLabel: 'Lingua', 156 hiddenName: 'language', 157 triggerAction: 'all', 158 allowBlank: false, 159 lastQuery: '' 160 161 },{ 162 id: 'topDizFonte', 163 xtype: 'combo', 164 name: 'fonte_name', 165 mode: 'local', 166 editable: false, 167 store: this.fontiDS, 168 valueField: 'codice', 169 displayField: 'descrizione', 170 width: 300, 171 blankText : this.blankText, 172 emptyText: 'Seleziona una fonte...', 173 fieldLabel: 'Fonte', 174 hiddenName: 'fonte', 175 triggerAction: 'all', 176 allowBlank: false, 177 lastQuery: '' 178 179 }, { 180 id: 'topDizScalaVis', 181 xtype: 'combo', 182 name: 'scalavis_name', 183 mode: 'local', 184 editable: false, 185 store: this.scaleDS, 186 valueField: 'id', 187 tpl: '<tpl for="."><div class="x-combo-list-item" >da 1:{scalaVisualMin} a 1:{scalaVisualMax}</div></tpl>', 188 // displayField: 'id', 189 width: 300, 190 blankText : this.blankText, 191 emptyText: 'Seleziona una scala di visualizzazione...', 192 fieldLabel: 'Scala di visualizzazione', 193 hiddenName: 'scalavis', 194 triggerAction: 'all', 195 allowBlank: false, 196 lastQuery: '', 197 listeners: { 198 select: function(combo, record, index) { 199 _self.idscala = record.data.id; 200 combo.setValue("da 1:"+record.data.scalaVisualMin+" a 1:"+record.data.scalaVisualMax); 201 } 202 } 203 },{ 204 xtype: 'radiogroup', 205 // fieldLabel: 'Auto Layout', 206 name: 'publicDizTop', 207 id: 'publicDizTop', 208 width: 300, 209 // height: 18, 210 // columns: [170, 170], 211 items: [ 212 {boxLabel: 'Online', name: 'rb-auto', inputValue: 1}, 213 {boxLabel: 'Offline', name: 'rb-auto', inputValue: 2, checked: true} 214 ] 215 }, 216 {id: 'geometryDiz', xtype: 'hidden', name: 'geometryDiz'}, 217 { 218 xtype: "framework_topattributidizionimanagement", 219 id: "topAttributiDizioniManagement", 220 dizdatapanel: this, 221 collapsed: false, 222 title: 'Gestione attributi dizioni', 223 layout: 'fit', 224 width: 400, 225 height: 200, 226 autoScroll:true, 227 listeners: { 228 loadGeometryAttDiz: function(geom) { 229 this.fireEvent('loadGeometryAttDiz', geom); 230 }, 231 getGeometryAttrDiz: function() { 232 this.fireEvent('getGeometryAttrDiz'); 233 }, 234 openWinEditAttDizTOP: function(flag) { 235 this.fireEvent('openWinEditAttDizTOP', flag); 236 }, 237 saveAttrDiz: function(attributi){ 238 if (!_self.dizione) { 239 _self.dizione = {}; 240 } 241 _self.dizione.lineeBase = attributi; 242 this.fireEvent('saveAttrDiz', _self.dizione); 243 }, 244 scope:this 245 } 246 } 247 ], 248 buttons: [{ 249 text: 'Annulla', 250 handler: function() { 251 _self.hide(); 252 } 253 }, { 254 text: 'Salva', 255 id: 'btnSaveDizTOP', 256 handler: function() { 257 var lang = _self._dizioneform.getForm().findField('language').getValue(); 258 var fonte = _self._dizioneform.getForm().findField('fonte').getValue(); 259 var scalavis = _self._dizioneform.getForm().findField('scalavis').getValue(); 260 261 var publicDizTopObj = _self._dizioneform.getForm().findField('publicDizTop').getValue(); 262 var publicDizTop = this.publicDizTop = (publicDizTopObj.inputValue === 1) ? true : false; 263 264 var lineeBase = Ext.getCmp('topAttributiDizioniManagement').getAttrDizTop(); 265 266 var idxLingua = _self.langDS.find('lang', lang); 267 var lingua = _self.langDS.getAt(idxLingua); 268 269 var idxFonte = _self.fontiDS.find('codice', fonte); 270 var fonte = _self.fontiDS.getAt(idxFonte); 271 var idxScala = _self.scaleDS.find('id', _self.idscala); 272 var scala = _self.scaleDS.getAt(idxScala); 273 274 if (lingua && fonte && scala && lineeBase) { 275 276 function compare(a,b) { 277 if (a.idTesto < b.idTesto) 278 return -1; 279 if (a.idTesto > b.idTesto) 280 return 1; 281 return 0; 282 } 283 284 lineeBase.sort(compare); 285 286 var testo = ""; 287 lineeBase.forEach(function(linea) { 288 testo += linea.testo+" "; 289 }); 290 if (!_self.dizione) { 291 _self.dizione = {}; 292 } 293 294 _self.dizione.lingua = lingua.data.desc; 295 _self.dizione.codLingua = lingua.data.lang; 296 _self.dizione.fonte = fonte.data; 297 _self.dizione.scala = scala.data; 298 _self.dizione.enabled = publicDizTop; 299 _self.dizione.lineeBase = lineeBase; 300 _self.dizione.testo = testo; 301 302 _self.fireEvent('saveDiz', _self.dizione); 303 304 Ext.getCmp('topAttributiDizioniManagement').clearDataAttrDizTop(); 305 306 _self.hide(); 307 308 } 309 else 310 Ext.Msg.alert('Attenzione', "Compilare tutti i campi e aggiungere almeno un attributo dizione"); 311 312 } 313 }] 314 }); 315 316 this.items = [this._dizioneform]; 317 318 this.openEditDizTopForm = function(dizione) { 319 320 this.dizione = dizione; 321 322 var _self = this; 323 // _self.topFeature = topFeature; 324 // _self.topFeatureNew = null; 325 this.fontiDS.load({params: {method: 'getFonti'}}); 326 this.scaleDS.load({params: {method: 'getScala'}}); 327 328 if (dizione) { 329 this.title = 'Modifica dizione'; 330 331 332 this._dizioneform.getForm().findField('idDizione').setValue(dizione.idDizione); 333 334 this._dizioneform.getForm().findField('language').setValue(dizione.codLingua); 335 // this._dizioneform.getForm().findField('fonte').setValue(dizione.fonte.codice); 336 var scala = "da 1:"+dizione.scala.scalaVisualMin+" a 1:"+dizione.scala.scalaVisualMax; 337 this._dizioneform.getForm().findField('scalavis').setValue(scala); 338 339 340 this.codice_fonte = dizione.fonte.codice; 341 this.idscala = dizione.scala.id; 342 343 if (dizione.enabled) 344 _self._dizioneform.getForm().findField('publicDizTop').items.items[0].setValue(true); 345 else 346 _self._dizioneform.getForm().findField('publicDizTop').items.items[1].setValue(true); 347 348 function compare(a,b) { 349 if (a.idTesto < b.idTesto) 350 return -1; 351 if (a.idTesto > b.idTesto) 352 return 1; 353 return 0; 354 } 355 356 dizione.lineeBase.sort(compare); 357 358 Ext.getCmp('topAttributiDizioniManagement').upDateAttrDizTop(dizione.lineeBase); 359 360 } 361 else { 362 this.title = 'Nuova dizione'; 363 this._dizioneform.getForm().reset(); 364 this.idscala = null; 365 Ext.getCmp('topAttributiDizioniManagement').clearDataAttrDizTop(); 366 } 367 368 // var poiUUID = (topFeature) ? topFeature.poiUUID : null; 369 370 }; 371 372 373 framework.widgets.TopDizioniDataPanel.superclass.initComponent.call(this); 374 }, 375 updateUserAuth: function(userAuthDS) { 376 this.userAuthDS = userAuthDS; 377 if (this.userAuthDS.usertype.description === "Amministratore" || this.userAuthDS.usertype.description === "Gestore") 378 this._dizioneform.getForm().findField('publicTop').enable(); 379 else 380 this._dizioneform.getForm().findField('publicTop').disable(); 381 382 } 383 384 385 }); 386 387 /** api: xtype = framework_panelpoidata */ 388 Ext.reg("framework_topdizionidatapanel", framework.widgets.TopDizioniDataPanel);