Changeset 1225

Show
Ignore:
Timestamp:
10/16/08 16:01:29 (3 months ago)
Author:
ochriste
Message:

codding standart formating / natural doc headers
templating for combobox values

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/camptocamp/MapFishAeai/client/mfbase/mapfish/widgets/recenter/Ws.js

    r1187 r1225  
    2727/** 
    2828 * Class: mapfish.widgets.WsRecenter 
    29  * Display a list of elements corresponding to the user input and recenters (and zooms if asked) on the selected element. 
     29 * Display a list of elements corresponding to the user input and recenters (and 
     30 * zooms if asked) on the selected element. 
    3031 * 
    3132 * config example: 
     
    3637 * map: projectid.map.map, 
    3738 * wsRecenterServices: [ 
    38  *     {id: 'swissnames', label: 'Swissnames', url: projectid.config.wsRecenterSwissnamesUrl, urlSuffixGeo: 'features', paramIdGeo: 'ids', urlSuffixList: 'properties', paramList: 'return=id,name', listFields: ['id', 'name'], isDefault: true}, 
    39  *     {id: 'communes', label: 'Communes', url: projectid.config.wsRecenterCommunesUrl, urlSuffixGeo: 'features', paramIdGeo: 'ids', urlSuffixList: 'properties', paramList: 'return=id,name', listFields: ['id', 'name']} 
     39 *     {id: 'swissnames',  
     40 *      label: 'Swissnames',  
     41 *      url: projectid.config.wsRecenterSwissnamesUrl,  
     42 *      urlSuffixGeo: 'features',  
     43 *      paramIdGeo: 'ids',  
     44 *      urlSuffixList: 'properties',  
     45 *      paramList: 'return=id,name',  
     46 *      listFields: ['id', 'name'],  
     47 *      isDefault: true}, 
     48 *     {id: 'communes',  
     49 *      label: 'Communes',  
     50 *      url: projectid.config.wsRecenterCommunesUrl,  
     51 *      urlSuffixGeo: 'features',  
     52 *      paramIdGeo: 'ids',  
     53 *      urlSuffixList: 'properties',  
     54 *      paramList: 'return=id,name',  
     55 *      listFields: ['id', 'name']} 
    4056 * ] 
    4157 *  
     
    4460 * id : id of the search service 
    4561 * label : label displayed over the service combobox 
    46  * url : main url of the target webservice. If the webservice is on another domain, simply set it as a local url and use an Apache's proxy redirection (rewrite.conf) 
    47  * urlSuffixGeo : suffix appended to the url to obtain the geojson (x,y at the moment) to do the final recentering 
    48  * paramIdGeo : id of the parameter to obtain the geojson. The value is automaticaly recovered from the user choice in the combobox values list 
    49  * urlSuffixList : suffix appended to the url to obtain the list of elements which will be proposed to the user 
    50  * paramList : whole list of parameter=value needed to obtain the list of elements which will be proposed to the user 
    51  * listFields : array of id of the elements returned by the webservice, used to initialize the store object which will feed the list of elements which will be proposed to the user. May be the same as the paramList elements. 
     62 * url : main url of the target webservice. If the webservice is on another  
     63 *  domain, simply set it as a local url and use an Apache's proxy redirection  
     64 *  (rewrite.conf) 
     65 * urlSuffixGeo : suffix appended to the url to obtain the geojson (x,y at the  
     66 *  moment) to do the final recentering 
     67 * paramIdGeo : id of the parameter to obtain the geojson. The value is  
     68 *  automaticaly recovered from the user choice in the combobox values list 
     69 * urlSuffixList : suffix appended to the url to obtain the list of elements  
     70 *  which will be proposed to the user 
     71 * paramList : whole list of parameter=value needed to obtain the list of elements  
     72 *  which will be proposed to the user 
     73 * listFields : array of id of the elements returned by the webservice, used to  
     74 *  initialize the store object which will feed the list of elements which will  
     75 *  be proposed to the user. May be the same as the paramList elements. 
    5276 *  
    53  * if more that one webservice is defined, a combobox is displayed to allow the user the switch between the services 
     77 * if more that one webservice is defined, a combobox is displayed to allow the  
     78 * user the switch between the services 
    5479 * 
    5580 * for the "swissnames" webservice examples above, the full url would be : 
     
    6287 
    6388/** 
    64  * Constructor: mapfish.widgets.Ws 
     89 * Constructor: mapfish.widgets.recenter.Ws 
    6590 * 
    6691 * Parameters: 
     
    6994 * {<mapfish.widgets.recenter.Ws>} 
    7095 */ 
    71  
    7296mapfish.widgets.recenter.Ws = function(config) { 
    7397    Ext.apply(this, config); 
     
    77101Ext.extend(mapfish.widgets.recenter.Ws, mapfish.widgets.recenter.Base, { 
    78102 
     103    /** 
     104     * Property: wsRecenterstore 
     105     * {Ext.data.JsonStore} - JsonStore for filling recenter combobox 
     106     */ 
    79107    wsRecenterstore: null, 
     108 
     109    /** 
     110     * Property: wsRecenterServicestore 
     111     * {Ext.data.SimpleStore} - SimpleStore for filling service combobox 
     112     */ 
    80113    wsRecenterServicestore: null, 
    81114 
     115    /** 
     116     * Property: wsRecenterServicestore 
     117     * {Object} Service config object 
     118     */ 
    82119    wsRecenterCurrentService: null, 
    83120 
     121    /** 
     122     * Property: errorMsg 
     123     * {String} Error message in case webservice is not accessible 
     124     */ 
    84125    errorMsg: OpenLayers.i18n('mf.recenter.ws.error'), 
    85126 
    86127    /** 
    87128     * Method: fillComponent 
    88      * 
    89      * Called by initComponent to create the component's sub-elements. 
     129     *      Called by initComponent to create the component's sub-elements. 
    90130     */ 
    91131    fillComponent: function() { 
     
    94134        this.initWsRecenterServicestore(); 
    95135        this.initWsRecenterstore(); 
    96  
    97         /* init combobox */ 
    98136 
    99137        /** 
     
    130168 
    131169        /** 
    132          * init main recentering combobox 
     170         * Property: resultTpl 
     171         * {Ext.XTemplate} template for combobox values 
     172         */ 
     173        var resultTpl = new Ext.XTemplate( 
     174                '<tpl for=".">', 
     175                '<div class="x-combo-list-item">', 
     176                    '<h3><span>{name}</span></h3>', 
     177                '</div>', 
     178                '</tpl>' 
     179        ); 
     180 
     181        /** 
     182         * Property: wsRecenterCombo 
     183         * {Ext.form.ComboBox} template for combobox values 
     184         *      init main recentering combobox 
    133185         */ 
    134186        var wsRecenterCombo = new Ext.form.ComboBox({ 
     
    136188                  name: 'wsRecenter', 
    137189                  value: '', 
     190                  tpl: this.wsRecenterCurrentService.tpl || resultTpl, 
    138191                  displayField: 'name', 
    139192                  mode: 'remote', 
     
    163216        this.add(wsRecenterCombo); 
    164217 
    165         /* handle scales selection for recentering*/ 
     218        /* handle scales selection for recentering */ 
    166219        if (this.scales) { 
    167220            this.addScaleCombo('Ws'); 
     
    171224 
    172225    /** 
    173      * change current webservice based on user selection 
    174      * @param object combo Ext.form.ComboBox 
     226     * Method: onWsRecenterServicesSelect 
     227     *      change current webservice based on user selection 
     228     * 
     229     * Parameters: 
     230     * {Ext.form.ComboBox} combo - combobox reference 
    175231     */ 
    176232    onWsRecenterServicesSelect: function(combo) { 
     
    180236 
    181237    /** 
    182      * recenter on geometry after the user has selected an option in the combobox 
    183      * @param object combo Ext.form.ComboBox 
     238     * Method: onWsRecenterSelect 
     239     *      recenter on geometry after the user has selected an option in the  
     240     *      combobox 
     241     * 
     242     * Parameters: 
     243     * {Ext.form.ComboBox} combo - combobox reference 
    184244     */ 
    185245    onWsRecenterSelect: function(combo) { 
     
    189249            // prevent action if user press enter only on first try 
    190250        } 
    191         var url = this.wsRecenterCurrentService.url + this.wsRecenterCurrentService.urlSuffixGeo + '?' + this.wsRecenterCurrentService.paramIdGeo + '=' + combo.value;  
     251        var url = this.wsRecenterCurrentService.url; 
     252        url += this.wsRecenterCurrentService.urlSuffixGeo + '?'; 
     253        url += this.wsRecenterCurrentService.paramIdGeo + '=' + combo.value; 
     254 
    192255        OpenLayers.Request.GET({ 
    193256            url: url, 
     
    209272                } 
    210273 
    211                 this.recenterOnCoords(feature.geometry.x, feature.geometry.y, zoom); 
     274                this.recenterOnCoords(feature.geometry.x,  
     275                                      feature.geometry.y, zoom); 
    212276 
    213277            }, 
    214278            failure: function(response) { 
    215                 var msg = this.errorMsg + "<br /><br />" + url + "<br /><br />" + response.status + "<br />" + response.statusText; 
     279                var msg = this.errorMsg + "<br /><br />" + url + "<br /><br />"; 
     280                msg += response.status + "<br />" + response.statusText; 
     281 
    216282                this.showError(msg); 
    217283            }, 
     
    221287    },  
    222288 
    223     /**  
    224      * Initializes recenter service: get default recenter service from config 
     289    /** 
     290     * Method: initWsRecenterService 
     291     *      Initializes recenter service: get default recenter service from config 
    225292     */ 
    226293    initWsRecenterService: function () { 
     
    233300    }, 
    234301 
    235     /**  
    236      * Changes recenter service 
    237      * @param string serviceId 
     302    /** 
     303     * Method: setWsRecenterService 
     304     *      Changes recenter service 
     305     * 
     306     * Parameters: 
     307     * {String} serviceId - service id 
    238308     */ 
    239309    setWsRecenterService: function (serviceId) { 
     
    243313            } 
    244314        } 
    245         //this.initWsRecenterstore(); 
    246         this.wsRecenterstore.proxy.conn.url = this.wsRecenterCurrentService.url + this.wsRecenterCurrentService.urlSuffixList + '?' + this.wsRecenterCurrentService.paramList; 
     315        var url = this.wsRecenterCurrentService.url; 
     316        url += this.wsRecenterCurrentService.urlSuffixList + '?'; 
     317        url += this.wsRecenterCurrentService.paramList; 
     318        this.wsRecenterstore.proxy.conn.url = url 
    247319        this.wsRecenterstore.load(); 
    248320    }, 
    249321 
    250     /**  
    251      * store for first webservice call, get options liste 
     322    /** 
     323     * Method: initWsRecenterstore 
     324     *      store for first webservice call, get options liste 
    252325     */ 
    253326    initWsRecenterstore: function () { 
     
    260333          loadexception: function(proxy, options, response) { 
    261334            if (response.status < 200 || response.status >= 300) { 
    262                 var msg = this.errorMsg + "<br /><br />" + this.wsRecenterstore.proxy.conn.url + "<br /><br />" + response.status + "<br />" + response.statusText; 
     335                var msg = this.errorMsg + "<br /><br />"; 
     336                msg += this.wsRecenterstore.proxy.conn.url + "<br /><br />" 
     337                msg += response.status + "<br />" + response.statusText; 
    263338                this.showError(msg); 
    264339            } 
     
    269344 
    270345    /** 
    271      * init store for services selector 
     346     * Method: initWsRecenterServicestore 
     347     *      init store for services selector 
    272348     */ 
    273349    initWsRecenterServicestore: function () { 
    274350        var myData = []; 
    275351        for (var i = 0; i < this.wsRecenterServices.length; i++) { 
    276             myData[i] = [this.wsRecenterServices[i].id, this.wsRecenterServices[i].label]; 
     352            myData[i] = [this.wsRecenterServices[i].id,  
     353                         this.wsRecenterServices[i].label]; 
    277354        } 
    278355 
     
    284361 
    285362    /** 
    286      * return domain from wsRecenterUrl  
    287      * @return string domain d 
     363     * Method: wsDomain 
     364     *      return domain from wsRecenterUrl  
     365     * 
     366     * Returns: 
     367     * {String} domain d 
    288368     */ 
    289369    wsDomain: function() {