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.PoiDataPanel = Ext.extend(Ext.Window, { 19 /** 20 * The Servlet name used to get Poi Term-Category information 21 * @type String 22 */ 23 poiTermCatServeltName: 'POIManagingServlet', 24 id: 'IDPoiDataPanel', 25 layout: 'fit', 26 width: 500, 27 height: 400, 28 title: 'Punto di interesse', 29 closable: false, 30 resizable: true, 31 plain: true, 32 border: false, 33 x: 20, 34 y: 40, 35 initCat: 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[urlCatasto] 44 * 45 * url for wfs catasto service 46 * @public 47 * @type String 48 */ 49 urlWFS: '/geoserver/ows?', 50 /** api: config[serviceType] 51 * 52 * Service type for catasto service (query string parameter) 53 * Default WFS 54 * @public 55 * @type String 56 */ 57 serviceType: 'WFS', 58 /** api: config[version] 59 * 60 * Version for WFS service (query string parameter) 61 * Default 1.0.0 62 * @public 63 * @type String 64 */ 65 version: '1.0.0', 66 /** api: config[GetFeature] 67 * 68 * Request type for WFS service (query string parameter) 69 * Default GetFeature 70 * @public 71 * @type String 72 */ 73 requestType: 'GetFeature', 74 /** api: config[typeName] 75 * 76 * typeName for WFS service (query string parameter) 77 * @public 78 * @type String 79 */ 80 81 typeName: 'dbu:limitiamministrcomunali', // dbu:LIMITIAMMINISTRCOMUNALI 82 nameGeometry: 'geom', // POLIGONO 83 properties_nome: 'nome', // NOME 84 properties_istat: 'codiceist1', //CODICEISTATCOMUNALE 85 /** api: config[infoFormat] 86 * 87 * maxFeatures for WFS service (query string parameter) 88 * Default 50 89 * @public 90 * @type String 91 */ 92 maxFeatures: 5, 93 /** api: config[geometryFields] 94 * 95 * fields from service answer to be transformed on OpenLayers.Bounds 96 * @public 97 * @type Array of String 98 */ 99 geometryFields: null, 100 srs: 'EPSG:300', 101 poiFeature: null, 102 poiFeatureNew: null, 103 /** 104 * paht for images marker, 105 * default value is "theme/app/img/". 106 * @public 107 * @type String 108 */ 109 markersImgPath: 'theme/app/img/', 110 click: null, 111 checkControlClick: false, 112 userAuthDS: null, 113 114 termsDefaultValue: null, 115 categoryDefaultValue: null, 116 117 destroy: function() { 118 framework.widgets.PoiDataPanel.superclass.destroy.apply(this, arguments); 119 }, 120 initComponent: function() { 121 122 OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { 123 defaultHandlerOptions: { 124 'single': true, 125 'double': false, 126 'pixelTolerance': 0, 127 'stopSingle': false, 128 'stopDouble': false 129 }, 130 initialize: function(options) { 131 this.handlerOptions = OpenLayers.Util.extend( 132 {}, this.defaultHandlerOptions 133 ); 134 OpenLayers.Control.prototype.initialize.apply( 135 this, arguments 136 ); 137 this.handler = new OpenLayers.Handler.Click( 138 this, { 139 'click': this.trigger 140 }, this.handlerOptions 141 ); 142 }, 143 trigger: function(e) { 144 Ext.getCmp('categoryFormID').fireEvent('modPositionPOI', e); 145 } 146 147 }); 148 149 this.click = new OpenLayers.Control.Click(); 150 151 152 this.termsDs = new Ext.data.Store({ 153 url: this.poiTermCatServeltName, 154 baseParams: {method: 'getTerms'}, 155 reader: new Ext.data.JsonReader({ 156 root: 'terms', 157 totalProperty: 'totalCount', 158 id: 'myId' 159 }, [ 160 {name: 'myid', mapping: 'myid'}, 161 {name: 'term', mapping: 'term'}, 162 {name: 'termIt', mapping: 'termIt'} 163 ]), 164 listeners: { 165 load: function() { 166 }, 167 scope: this 168 } 169 }); 170 this.termsDs.on( 171 'load', function(store) { // store is equivalent to this.termsDs 172 var i = 0; 173 var itemFound = false; 174 while ((i < store.data.items.length) && (!itemFound)) { 175 if (store.data.items[i++].data.term === this.termsDefaultValue) { 176 this._categoryform.items.items[4].setValue(this.termsDefaultValue); 177 itemFound = true; 178 } 179 } 180 if (itemFound) { 181 this.categoryByTermDs.baseParams['term'] = store.data.items[i-1].data.term; 182 this.categoryByTermDs.reload(); 183 this.initCat = this.categoryDefaultValue; 184 } 185 }, this); 186 187 //POIManagingServlet?method=getRUserCat&user=C86A1DE0B51D45B2A4B5ADFC27CD51ED 188 189 this.categoryByTermDs = new Ext.data.Store({ 190 url: this.poiTermCatServeltName, 191 baseParams: {method: 'getCategoriesByTerm'}, 192 reader: new Ext.data.JsonReader({ 193 root: 'categories', 194 totalProperty: 'totalCount', 195 id: 'id' 196 }, [ 197 {name: 'id', mapping: 'id'}, 198 {name: 'term', mapping: 'term'}, 199 {name: 'category', mapping: 'category'}, 200 {name: 'termIt', mapping: 'termIt'}, 201 {name: 'categoryIt', mapping: 'categoryIt'}, 202 {name: 'valid', mapping: 'valid'} 203 ]), 204 listeners: { 205 load: function() { 206 if (this.initCat) { 207 var idCat = this.categoryByTermDs.find("category", this.initCat); 208 if(idCat == -1) 209 idCat = this.categoryByTermDs.find("categoryIt", this.initCat); 210 if(idCat > -1) 211 this._categoryform.getForm().items.items[5].setValue(this.categoryByTermDs.getAt(idCat).data.category); 212 this.initCat = null; 213 } 214 }, 215 scope: this 216 } 217 }); 218 // this.categoryByTermDs.on( 219 // 'load', function(store) { // store is equivalent to this.termsDs 220 // var i = 0; 221 // var itemFound = false; 222 // while ((i < store.data.items.length) && (!itemFound)) { 223 // if (store.data.items[i++].data.category === this.categoryDefaultValue) { 224 // this._categoryform.items.items[5].setValue(this.categoryDefaultValue); 225 // itemFound = true; 226 // } 227 // } 228 // }, this); 229 230 this.categoryByUserDs = new Ext.data.Store({ 231 url: this.poiTermCatServeltName, 232 baseParams: {method: 'getCat4User'}, 233 reader: new Ext.data.JsonReader({ 234 root: 'categories', 235 totalProperty: 'totalCount', 236 id: 'id' 237 }, [ 238 {name: 'id', mapping: 'id'}, 239 {name: 'term', mapping: 'term'}, 240 {name: 'category', mapping: 'category'}, 241 {name: 'termIt', mapping: 'termIt'}, 242 {name: 'categoryIt', mapping: 'categoryIt'}, 243 {name: 'valid', mapping: 'valid'} 244 ]), 245 listeners: { 246 load: function() { 247 this.checkPermission(); 248 }, 249 scope: this 250 } 251 }); 252 253 254 var _self = this; 255 256 this._categoryform = new Ext.FormPanel({ 257 labelWidth: 100, 258 frame: true, 259 defaultType: 'textfield', 260 id: 'categoryFormID', 261 // monitorValid: true, 262 standardSubmit: false, 263 layout: 'form', 264 listeners: { 265 modPositionPOI: function(e) { 266 267 this.fireEvent('modPositionPOI', e); 268 269 var lonlat = e.object.getLonLatFromPixel(e.xy); 270 this.updateCoord(lonlat); 271 this.updateISTAT(lonlat); 272 }, 273 scope: this 274 }, 275 items: [{ 276 id: 'poiName', 277 fieldLabel: 'Nome', 278 name: 'label', 279 width: 350, 280 blankText : _self.blankText, 281 allowBlank: false 282 }, { 283 id: 'poiUpdate', 284 xtype: 'displayfield', 285 // fieldLabel: 'update', 286 name: 'update', 287 width: 350 288 }, { 289 xtype: 'radiogroup', 290 // fieldLabel: 'Auto Layout', 291 name: 'public', 292 id: 'public', 293 width: 350, 294 // height: 18, 295 // columns: [170, 170], 296 items: [ 297 {boxLabel: 'Online', name: 'rb-auto', inputValue: 1}, 298 {boxLabel: 'Offline', name: 'rb-auto', inputValue: 2, checked: true} 299 ] 300 }, { 301 id: 'poiDescr', 302 xtype: 'textarea', 303 fieldLabel: 'Descrizione', 304 name: 'descriptions', 305 width: 350, 306 allowBlank: true 307 }, { 308 id: 'poiTerm', 309 xtype: 'combo', 310 name: 'term', 311 mode: 'local', 312 editable: false, 313 store: this.termsDs, 314 valueField: 'term', 315 displayField: 'termIt', 316 width: 350, 317 blankText : _self.blankText, 318 emptyText: 'Seleziona una tipologia...', 319 fieldLabel: 'Tipologia', 320 hiddenName: 'term', 321 triggerAction: 'all', 322 allowBlank: false, 323 listeners: { 324 select: function(combo, record, index) { 325 var term = record.data.term; 326 Ext.getCmp('poiCategory').setValue(undefined);//sbianco la combo delle categorie 327 _self.categoryByTermDs.baseParams = _self.categoryByTermDs.baseParams || {}; 328 _self.categoryByTermDs.baseParams['term'] = term; 329 _self.categoryByTermDs.reload(); 330 } 331 } 332 }, { 333 id: 'poiCategory', 334 xtype: 'combo', 335 name: 'category', 336 mode: 'local', 337 editable: false, 338 store: this.categoryByTermDs, 339 valueField: 'category', 340 displayField: 'categoryIt', 341 width: 350, 342 blankText : _self.blankText, 343 emptyText: 'Seleziona una categoria...', 344 fieldLabel: 'Categoria', 345 hiddenName: 'category', 346 triggerAction: 'all', 347 allowBlank: false, 348 lastQuery: '', 349 listeners: { 350 select: function(combo, record, index) { 351 _self.checkPermission(); 352 } 353 } 354 355 }, { 356 id: 'poiAddress', 357 fieldLabel: 'Indirizzo/Località', 358 name: 'address', 359 width: 350, 360 allowBlank: true 361 }, { 362 id: 'poiComune', 363 xtype: 'displayfield', 364 fieldLabel: 'Comune', 365 name: 'comune', 366 width: 350, 367 allowBlank: false 368 }, { 369 id: 'poiISTAT', 370 hidden: true, 371 fieldLabel: 'ISTAT', 372 name: 'istat', 373 width: 350, 374 allowBlank: false 375 }, {id: 'longitude', xtype: 'hidden', name: 'x'}, {id: 'latitude', xtype: 'hidden', name: 'y'}, { 376 id: 'poiCoord', 377 xtype: 'displayfield', 378 fieldLabel: 'Coordinate', 379 name: 'coordinates', 380 width: 350, 381 allowBlank: false 382 }, 383 { 384 id: 'poiRes', 385 xtype: 'framework_multipleinputfield', 386 fieldLabel: 'Risorse esterne', 387 groupName: 'poiRes', 388 name: 'link', 389 width: 350, 390 allowBlank: true 391 }], 392 buttons: [{ 393 text: 'Annulla', 394 handler: function() { 395 // _self.hide(); 396 if (_self.poiFeatureNew) { 397 _self.poiFeatureNew.style.display = false; // hide 398 if (_self.poiFeatureNew.layer && !_self.poiFeatureNew.isPoisExternal) 399 _self.poiFeatureNew.layer.removeAllFeatures(); 400 } 401 if (_self.poiFeature) { 402 _self.poiFeature.style.display = true; // show 403 _self.poiFeature.layer.redraw(); 404 _self.poiFeature.layer.map.moveTo(_self.poiFeature.geometry.bounds.getCenterLonLat(), 12); 405 } 406 _self.hide(); 407 _self.click.deactivate(); 408 // _self.destroy(); 409 } 410 }, { 411 text: 'Salva', 412 id: 'btnSavePOI', 413 disabled: true, 414 handler: function() { 415 416 var xy = _self._categoryform.getForm().findField('coordinates').getValue(); 417 var x = _self._categoryform.getForm().findField('longitude').getValue(); 418 var y = _self._categoryform.getForm().findField('latitude').getValue(); 419 var lbl = this.text = _self._categoryform.getForm().findField('label').getValue(); 420 /// 421 var term = this.term = _self._categoryform.getForm().findField('term').getValue(); 422 var termIdx = _self.termsDs.find('term', term); 423 var termIT = (termIdx < 0) ? "" : _self.termsDs.getAt(termIdx).data.termIt; 424 // 425 var cat = _self._categoryform.getForm().findField('category').getValue(); 426 427 var catIdx,catIT; 428 if (cat) { 429 catIdx = _self.categoryByTermDs.find('category', cat); 430 catIT = (termIdx < 0) ? "" : _self.categoryByTermDs.getAt(catIdx).data.categoryIt; 431 } 432 else 433 catIT = null; 434 435 // var catEng = (catIdx < 0) ? "" : _self.categoryByTermDs.getAt(catIdx).data.category; 436 // 437 var descr = _self._categoryform.getForm().findField('descriptions').getValue(); 438 var address = _self._categoryform.getForm().findField('address').getValue(); 439 var comune = _self._categoryform.getForm().findField('comune').getValue(); 440 var istat = _self._categoryform.getForm().findField('istat').getValue(); 441 442 var external = _self._categoryform.getForm().findField('poiRes').getValue(); 443 var publicPoiObj = _self._categoryform.getForm().findField('public').getValue(); 444 var publicPoi = this.publicPoi = (publicPoiObj.inputValue === 1) ? 1 : 0; 445 var author = _self.userAuthDS.myid; 446 447 var i = 0; 448 var extLink = (external) ? external : ''; 449 450 while (_self._categoryform.getForm().findField('poiRes_' + i)) { 451 external = _self._categoryform.getForm().findField('poiRes_' + i).getValue(); 452 if (external) 453 extLink += '>' + external; 454 i++; 455 } 456 if (_self.poiFeature) 457 var myid = _self.poiFeature.poiUUID; 458 else 459 var myid = null; 460 461 if (lbl && termIT && catIT) { 462 463 if (!this.busyMask) { 464 try{ 465 _self.busyMask = new Ext.LoadMask( 466 _self.poiFeatureNew.layer.map.div, { 467 msg: 'Operazione in corso ...' 468 } 469 ); 470 }catch(error){} 471 }; 472 473 if(_self.busyMask) 474 _self.busyMask.show(); 475 476 Ext.Ajax.request({ 477 url: 'POIManagingServlet', 478 headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, 479 method: 'POST', 480 params: { 481 method: 'savePoi', 482 myid: myid, 483 term: term, 484 termIt: termIT, 485 cat: cat, 486 catIt: catIT, 487 descr: descr, 488 comune: comune, 489 istat: istat, 490 addr: address, 491 ext: extLink, 492 xy: xy, 493 x: x, 494 y: y, 495 author: author, 496 publicPoi: publicPoi, 497 label: lbl 498 }, 499 success: function(data) { 500 if(_self.busyMask) 501 _self.busyMask.hide(); 502 var resp = Ext.util.JSON.decode(data.responseText); 503 if (resp.success) { 504 Ext.Msg.alert('Info', resp.msg); 505 506 var x = _self._categoryform.getForm().findField('longitude').getValue(); 507 var y = _self._categoryform.getForm().findField('latitude').getValue(); 508 var pos = new OpenLayers.LonLat(x, y) 509 510 if (_self.poiFeatureNew) { 511 512 if (this.publicPoi) 513 var icon = "poi/icon_poi_" + this.term + ".png"; 514 else 515 var icon = "poi/icon_poi_nopublic.png"; 516 _self.poiFeatureNew.style.externalGraphic = _self.markersImgPath + icon; 517 _self.poiFeatureNew.style.graphicWidth = 25; 518 _self.poiFeatureNew.style.graphicHeight = 25; 519 _self.poiFeatureNew.style.graphicYOffset = 0; 520 _self.poiFeatureNew.style.graphicZIndex = 1000; 521 _self.poiFeatureNew.text = this.text; 522 523 _self.poiFeatureNew.layer.redraw(); 524 } 525 526 if (_self.poiFeature) { 527 _self.poiFeature.style.display = true; // show 528 _self.poiFeature.move(pos); 529 _self.poiFeature.layer.redraw(); 530 _self.poiFeature.layer.map.moveTo(_self.poiFeature.geometry.bounds.getCenterLonLat(), 12); 531 } 532 533 _self.hide(); 534 // _self.destroy(); 535 } else { 536 Ext.Msg.alert('Attenzione', resp.msg); 537 } 538 539 }, 540 failure: function(form, action) { 541 if(_self.busyMask) 542 _self.busyMask.hide(); 543 Ext.Msg.alert("Load failed", action.result.errorMessage); 544 }, 545 scope: this 546 }); 547 548 } 549 else 550 Ext.Msg.alert('Attenzione', "Compilare tutti i campi obbligatori"); 551 552 } 553 }, { 554 text: 'Elimina', 555 id: 'btnDeletePOI', 556 cls: 'btnDeletePOI', 557 disabled: true, 558 handler: function() { 559 Ext.MessageBox.show({ 560 title : 'Attenzione!', 561 msg : 'Sei sicuro di voler eliminare questo Punto di Interesse? Questa operazione è irreversibile.', 562 width : 300, 563 buttons: Ext.MessageBox.YESNO, 564 buttonText:{ 565 yes: "Si", 566 no: "No" 567 }, 568 fn : myCallback 569 // icon : Ext.MessageBox.QUESTION 570 }); 571 572 function myCallback(btn) { 573 if (btn == "yes") { 574 _self.delPoi(); 575 _self.hide(); 576 } 577 } 578 579 } 580 }] 581 }); 582 583 this.items = [this._categoryform]; 584 585 this.openEditPoiForm = function(poiFeature) { 586 587 this.title = 'Modifica punto di interesse'; 588 589 var _self = this; 590 _self.poiFeature = poiFeature; 591 _self.poiFeatureNew = null; 592 this.termsDs.load({params: {method: 'getTerms'}}); 593 _self.poiUUID = (poiFeature) ? poiFeature.poiUUID : null; 594 595 if (!this.checkControlClick) { 596 _self.poiFeature.layer.map.addControl(_self.click); 597 this.checkControlClick = true; 598 } 599 600 _self.click.activate(); 601 602 Ext.Ajax.request({ 603 url: this.poiTermCatServeltName, 604 method: 'POST', 605 params: { 606 method: 'loadPoi', 607 poiID: _self.poiUUID 608 }, 609 success: function(data) { 610 611 var resp = Ext.util.JSON.decode(data.responseText); 612 613 this._categoryform.getForm().findField('label').setValue(resp.labels[0].value); 614 615 if (resp.enabled) 616 _self._categoryform.getForm().findField('public').items.items[0].setValue(true); 617 else 618 _self._categoryform.getForm().findField('public').items.items[1].setValue(true); 619 620 621 if (resp.descriptions.length) { 622 this._categoryform.getForm().findField('descriptions').setValue(resp.descriptions[0].value); 623 } 624 else 625 this._categoryform.getForm().findField('descriptions').setValue(""); 626 627 var idTerm = this.termsDs.find("term", resp.categories[0].term); 628 this._categoryform.getForm().items.items[4].setValue(this.termsDs.getAt(idTerm).data.term); 629 630 this.categoryByTermDs.baseParams['term'] = resp.categories[0].term; 631 this.categoryByTermDs.reload(); 632 this.initCat = resp.categories[0].value; 633 634 if (resp.address) { 635 this._categoryform.getForm().findField('address').setValue(resp.address); 636 } 637 else 638 this._categoryform.getForm().findField('address').setValue(""); 639 640 this._categoryform.getForm().findField('update').setValue("<small>data ultimo aggiornamento: " + resp.updated + "<small>"); 641 642 643 644 if (resp.links.length) { 645 var externalResField = _self._categoryform.getComponent('poiRes'); 646 for (var i = 0; i < resp.links.length; i++) { 647 if (i > 0) { 648 externalResField.onTrigger2Click(); 649 externalResField = _self._categoryform.getComponent('poiRes_' + (i - 1)); 650 } 651 externalResField.setValue(resp.links[i].href); 652 } 653 } 654 655 var coord = new OpenLayers.LonLat(resp.location.points[0].coordinates[0], resp.location.points[0].coordinates[1]); 656 this.updateCoord(coord); 657 this.updateISTAT(coord); 658 659 if (this.userAuthDS.usertype.description == "Amministratore" 660 || this.userAuthDS.usertype.description == "Gestore") 661 Ext.getCmp('btnDeletePOI').enable(); 662 663 664 }, 665 failure: function(form, action) { 666 Ext.Msg.alert("Load failed", action.result.errorMessage); 667 }, 668 scope: this 669 }); 670 671 672 }; 673 674 675 this.openEditNewPoiForm = function(poiFeature, position) { 676 677 this.title = 'Nuovo punto di interesse'; 678 var _self = this; 679 _self.poiFeatureNew = poiFeature; 680 _self.poiFeature = null; 681 682 this.termsDs.load({params: {method: 'getTerms'}}); 683 684 if (!this.checkControlClick) { 685 _self.poiFeatureNew.layer.map.addControl(_self.click); 686 this.checkControlClick = true; 687 } 688 _self.click.activate(); 689 690 this._categoryform.getForm().reset(); 691 692 this.updateCoord(position); 693 this.updateISTAT(position); 694 695 Ext.getCmp('btnDeletePOI').disable(); 696 697 }; 698 699 700 framework.widgets.PoiDataPanel.superclass.initComponent.call(this); 701 702 this.on("show", function() { 703 var tabPanel = Ext.getCmp('tabPanelID'); 704 if(tabPanel){ 705 tabPanel.disable(); 706 } 707 }); 708 this.on("hide", function() { 709 var tabPanel = Ext.getCmp('tabPanelID'); 710 if(tabPanel){ 711 tabPanel.enable(); 712 } 713 }) 714 }, 715 /** 716 * Create query string for wfs catasto service 717 * @private 718 */ 719 getParameters: function(coord) { 720 var parameters = {service: this.serviceType, version: this.version, request: this.requestType, 721 typeName: this.typeName, maxFeatures: this.maxFeatures, outputFormat: 'application/json', 722 FILTER: '<Filter xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">' + 723 '<Intersects><PropertyName>'+this.nameGeometry+'</PropertyName>' + 724 '<gml:Point srsName="' + this.srs + '">' + 725 '<gml:coordinates>' + coord.lon + ',' + coord.lat + '</gml:coordinates>' + 726 '</gml:Point></Intersects></Filter>'}; 727 return parameters; 728 }, 729 /** 730 * Create query string for wfs catasto service 731 * @private 732 */ 733 updateCoord: function(coord) { 734 this._categoryform.getForm().findField('longitude').setValue(coord.lon); 735 this._categoryform.getForm().findField('latitude').setValue(coord.lat); 736 this._categoryform.getForm().findField('coordinates').setValue(coord.lon + ',' + coord.lat); 737 738 }, 739 updateISTAT: function(coord) { 740 741 Ext.Ajax.request({ 742 method: 'POST', 743 url: this.urlProxy + this.urlWFS, 744 params: this.getParameters(coord), 745 success: function(result, request) { 746 try { 747 var obj = Ext.decode(result.responseText); 748 if (obj && obj.features) { 749 if (obj.features.length == 0) 750 alert('Nessun comune presente in questa zona'); 751 else if (obj.features.length == 1) { 752 753 var nome_comune = obj.features[0].properties[this.properties_nome]; 754 this.istat = obj.features[0].properties[this.properties_istat]; 755 756 this._categoryform.getForm().findField('comune').setValue(nome_comune); 757 this._categoryform.getForm().findField('istat').setValue(this.istat); 758 this.checkPermission(); 759 } 760 else if (obj.features.length > 1) 761 alert('Trovati più risultati!\n Affinare la ricerca per stabilire un extent.'); 762 } else 763 alert('Il servizio non risponde'); 764 } catch (ex) { 765 Ext.MessageBox.alert('Error', 'Il servizio è andato in errore!'); 766 } 767 768 }, 769 failure: function(result, request) { 770 if (self.busyMask) 771 self.busyMask.hide(); 772 //Ext.MessageBox.alert('Error', result.responseText); 773 }, 774 scope: this 775 }); 776 }, 777 updateUserAuth: function(userAuthDS) { 778 this.userAuthDS = userAuthDS; 779 if (this.userAuthDS.usertype.description === "Amministratore" || this.userAuthDS.usertype.description === "Gestore") 780 this._categoryform.getForm().findField('public').enable(); 781 else 782 this._categoryform.getForm().findField('public').disable(); 783 784 this.categoryByUserDs.load({ 785 params: { 786 method: 'getCat4User', 787 ursId: this.userAuthDS.myid 788 }}); 789 }, 790 checkPermission: function() { 791 792 var enableISTAT = false; 793 var enableType = false; 794 795 var provinciaInteresse = this.userAuthDS.provinciaInteresse; 796 var comuneInteresse = this.userAuthDS.comuneInteresse; 797 798 if (provinciaInteresse === "Tutte" || provinciaInteresse === "") { 799 enableISTAT = true; 800 } 801 else if (this.istat.search(provinciaInteresse) === 0) { 802 if (comuneInteresse === "Tutti" || comuneInteresse === "") 803 enableISTAT = true; 804 else if (comuneInteresse === this.istat) 805 enableISTAT = true; 806 } 807 808 var cat = this._categoryform.getForm().findField('category').getValue(); 809 if (this.categoryByUserDs.find('category', cat) !== -1) 810 enableType = true; 811 // else 812 // alert('Utente non abilitato alla categoria selezionata'); 813 814 if (enableISTAT && enableType) 815 Ext.getCmp('btnSavePOI').enable(); 816 else 817 Ext.getCmp('btnSavePOI').disable(); 818 } 819 , 820 delPoi: function() { 821 822 var _self = this; 823 824 if (_self.poiUUID) { 825 var myid = _self.poiUUID; 826 827 Ext.Ajax.request({ 828 url: _self.poiTermCatServeltName, 829 headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, 830 method: 'POST', 831 params: { 832 method: 'deletePoi', 833 poiID: myid 834 }, 835 success: function(data) { 836 if(_self.busyMask) 837 _self.busyMask.hide(); 838 var resp = Ext.util.JSON.decode(data.responseText); 839 if (resp.success) { 840 Ext.Msg.alert('Info', resp.msg); 841 842 _self.hide(); 843 844 //Aggiorna lista toponimi offLine 845 if(!_self.poiVerifyBox){ 846 _self.poiVerifyBox = Ext.getCmp('idPoiVerifyManagement'); 847 } 848 _self.poiVerifyBox.pagingBar.doRefresh(); 849 // _self.destroy(); 850 } else { 851 Ext.Msg.alert('Attenzione', resp.msg); 852 } 853 854 }, 855 failure: function(form, action) { 856 if(_self.busyMask) 857 _self.busyMask.hide(); 858 Ext.Msg.alert("Load failed", action.result.errorMessage); 859 }, 860 scope: this 861 }); 862 } 863 else { 864 Ext.Msg.alert('Attenzione', "Punto di interesse non inserito in banca dati"); 865 } 866 867 } 868 869 870 }); 871 872 /** api: xtype = framework_panelpoidata */ 873 Ext.reg("framework_panelpoidata", framework.widgets.PoiDataPanel);