Changeset 3369
- Timestamp:
- 02/16/10 14:42:18 (2 years ago)
- Location:
- sandbox/gislars/sipv/MapFish/client/mfbase/styler/lib/Styler/widgets
- Files:
-
- 4 modified
-
BaseFilterPanel.js (modified) (2 diffs)
-
FilterBuilder.js (modified) (17 diffs)
-
FilterPanel.js (modified) (12 diffs)
-
SpatialFilterPanel.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sandbox/gislars/sipv/MapFish/client/mfbase/styler/lib/Styler/widgets/BaseFilterPanel.js
r3354 r3369 14 14 filter: null, 15 15 16 /**17 * Property: deactivable18 * {Boolean}19 */20 deactivable: false,21 22 /**23 * Property: checkbox24 * {Ext.form.CheckBox}25 */26 checkbox: null,27 28 16 initComponent: function() { 29 17 30 18 var defConfig = { 31 19 plain: true, 20 layout: 'fit', 32 21 border: false 33 22 }; … … 72 61 return []; 73 62 }, 74 75 /**76 * Method: createFilterCheckbox77 * Creates a checkbox to temporarily deactivate filter78 */79 createFilterCheckbox: function() {80 var items = [];81 if (this.deactivable) {82 checkbox = new Ext.form.Checkbox({83 checked: true84 });85 checkbox.on('check', function(cb, checked){86 this.filter.removed = !checked;87 this.fireEvent("change", this.filter);88 }, this);89 items.push({90 width: 20,91 border: false,92 bodyStyle: 'vertical-align: top',93 items: [ checkbox ]94 });95 }96 return items;97 },98 63 99 64 /** -
sandbox/gislars/sipv/MapFish/client/mfbase/styler/lib/Styler/widgets/FilterBuilder.js
r3354 r3369 77 77 */ 78 78 map: null, 79 80 /** 81 * Property: cookieProvider 82 * {Ext.state.CookieProvider} The cookie provider 83 * Used for storing filters or geometries (if available) ... 84 */ 85 cookieProvider: null, 79 86 80 87 /** … … 87 94 var defConfig = { 88 95 plain: true, 96 layout: 'column', 97 defaults: { 98 columnWidth: 1 99 }, 89 100 defaultBuilderType: Styler.FilterBuilder.ANY_OF 90 101 }; … … 100 111 { 101 112 xtype: "panel", 113 height: 35, 114 layout: 'fit', 102 115 border: false, 103 116 items: [{ … … 134 147 * <getFilter> to get the updated filter. 135 148 */ 136 "change" 149 "change", 150 /** 151 * Event: loading 152 * Fires when loading data from server 153 */ 154 "loading", 155 /** 156 * Event: loaded 157 * Fires when finished loading data from server 158 */ 159 "loaded" 137 160 ); 138 161 … … 227 250 group: "querier", 228 251 text: "sur la base d'un point", 229 iconCls: " drawpoint"252 iconCls: "point" 230 253 }))); 231 254 } … … 236 259 group: "querier", 237 260 text: "sur la base d'une ligne", 238 iconCls: " drawline"261 iconCls: "linestring" 239 262 }))); 240 263 } … … 245 268 group: "querier", 246 269 text: "sur la base d'un polygone", 247 iconCls: " drawpolygon"270 iconCls: "polygon" 248 271 }))); 249 272 } 250 251 return new Ext.menu.Menu({ items: items }); 273 if (this.cookieProvider) { 274 var item = new Ext.menu.CheckItem({ 275 text: "sur la base d'une géométrie stockée", 276 disabled: !this.cookieProvider.get('geometry', false), 277 handler: function() { 278 var wkt = this.cookieProvider.decodeValue( 279 this.cookieProvider.get('geometry') 280 ); 281 this.vectorLayer.addFeatures([ 282 new OpenLayers.Format.WKT().read(wkt) 283 ]); 284 }, 285 scope: this, 286 iconCls: "database" 287 }); 288 this.cookieProvider.on('statechange', function(cp, key, value){ 289 if (key == 'geometry') { 290 if (value.length) { 291 item.enable(); 292 } else { 293 item.disable(); 294 } 295 } 296 }, this); 297 items.push(item); 298 } 299 return new Ext.menu.Menu({items: items}); 252 300 }, 253 301 … … 265 313 var filter; 266 314 if(this.filter) { 267 filter = this.removeUnchecked(this. filter.clone());315 filter = this.removeUnchecked(this.cloneFilter(this.filter)); 268 316 if(filter instanceof OpenLayers.Filter.Logical) { 269 317 filter = this.cleanFilter(filter); … … 274 322 275 323 /** 324 * Method: cloneFilter 325 * A special cloning method which takes care of the "removed" property 326 * 327 * Parameters: 328 * f - {OpenLayers.Filter} A filter. 329 * 330 * Returns: 331 * {OpenLayers.Filter} A filter 332 */ 333 cloneFilter: function(f) { 334 var filter; 335 if(f instanceof OpenLayers.Filter.Logical) { 336 var filters = []; 337 for(var i=0, len=f.filters.length; i<len; ++i) { 338 filters.push(this.cloneFilter(f.filters[i])); 339 } 340 filter = new OpenLayers.Filter.Logical({ 341 type: f.type, 342 filters: filters 343 }); 344 if (f.removed === true) { 345 filter.removed = true; 346 } 347 } else { 348 filter = f.clone(); 349 } 350 return filter; 351 }, 352 353 /** 276 354 * Method: removeUnchecked 277 355 * Returns a filter containing only those which have been checked 356 * 357 * Parameters: 358 * filter - {OpenLayers.Filter} A filter. 278 359 * 279 360 * Returns: … … 283 364 if(filter instanceof OpenLayers.Filter.Logical) { 284 365 var toDelete = []; 285 for (var i = 0, l = filter.filters.length; i<l; i++) { 286 if(filter.filters[i] instanceof OpenLayers.Filter.Logical) { 287 filter.filters[i] = this.removeUnchecked(filter.filters[i]); 366 var filters = filter.filters; 367 for (var i = 0, l = filters.length; i<l; i++) { 368 if (filters[i].removed === true) { 369 toDelete.push(filters[i]); 288 370 } else { 289 if (filter.filters[i].removed === true) { 290 toDelete.push(filter.filters[i]); 291 } 371 filters[i] = this.removeUnchecked(filters[i]); 292 372 } 293 373 } 294 374 for (var j = 0, ll = toDelete.length; j<ll; j++) { 295 OpenLayers.Util.removeItem(filter .filters, toDelete[j]);375 OpenLayers.Util.removeItem(filters, toDelete[j]); 296 376 } 297 377 } … … 501 581 customizeFilterOnInit: (conditionType == "group") && false, 502 582 listeners: { 503 change: function() {583 "change": function() { 504 584 this.fireEvent("change", this); 585 }, 586 "loaded": function() { 587 this.fireEvent("loaded"); 588 }, 589 "loading": function() { 590 this.fireEvent("loading"); 505 591 }, 506 592 scope: this … … 524 610 xtype: "gx_spatialfilterpanel", 525 611 filter: filter, 526 deactivable: this.deactivable,612 cookieProvider: this.cookieProvider, 527 613 feature: feature, 528 614 toggleGroup: "querier", … … 536 622 filter: filter, 537 623 attributes: this.attributes, 538 deactivable: this.deactivable,539 624 filterPanelOptions: Ext.apply({}, this.filterPanelOptions) 540 625 }); … … 592 677 scope: this 593 678 }, 594 width: 60// TODO: move to css679 width: 85 // TODO: move to css 595 680 }; 596 681 }, … … 641 726 this.childFiltersPanel = new Ext.Panel({ 642 727 border: false, 643 defaults: {border: false} 728 layout: 'column', 729 bufferResize: true, 730 defaults: { 731 border: false, 732 columnWidth: 1 733 } 644 734 }); 645 735 var grandchildren = this.filter.filters[0].filters; … … 655 745 filterPanelOptions: Ext.apply({}, this.filterPanelOptions), 656 746 listeners: { 657 change: function() {747 "change": function() { 658 748 this.fireEvent("change", this); 749 }, 750 "loading": function() { 751 this.fireEvent("loading"); 752 }, 753 "loaded": function() { 754 this.fireEvent("loaded"); 659 755 }, 660 756 scope: this … … 675 771 */ 676 772 newRow: function(filterPanel) { 677 var panel = new Ext.Panel({ 773 var panel; 774 var firstItems = [{ 775 border: false, 776 bodyStyle: "padding-left: 0.25em;", 777 items: [{ 778 xtype: "button", 779 tooltip: "Supprimer cette condition", 780 cls: 'x-btn-icon', 781 iconCls: "delete", 782 handler: function() { 783 this.removeCondition(panel, filterPanel.filter); 784 }, 785 scope: this 786 }] 787 }]; 788 789 if (this.deactivable) { 790 var checkbox = new Ext.form.Checkbox({ 791 checked: true 792 }); 793 checkbox.on('check', function(cb, checked){ 794 filterPanel.filter.removed = !checked; 795 this.fireEvent("change", filterPanel.filter); 796 }, this); 797 firstItems.push({ 798 bodyStyle: "padding: 0 5px;", 799 border: false, 800 items: [ checkbox ] 801 }); 802 } 803 804 panel = new Ext.Panel({ 678 805 layout: "column", 679 806 defaults: {border: false}, 680 style: "padding: 0.5em 0.25em;", 807 listeners: { 808 'resize': function() { 809 this.doLayout(); 810 } 811 }, 812 //style: "padding: 0.25em 0.5em;", // nice look in FF but not in IE 813 style: "padding: 0.25em 0;", 681 814 items: [{ 682 815 border: false, 683 columnWidth: 0.1, 684 items: [{ 685 xtype: "button", 686 tooltip: "Supprimer cette condition", 687 cls: 'x-btn-icon', 688 iconCls: "delete", 689 handler: function() { 690 this.removeCondition(panel, filterPanel.filter); 691 }, 692 scope: this 693 }] 816 width: 60, 817 layout: 'column', 818 defaults: { 819 columnWidth: 0.5 820 }, 821 items: firstItems 694 822 }, { 695 823 items: [filterPanel], 696 824 border: false, 697 columnWidth: 0.9825 columnWidth: 1 698 826 }] 699 827 }); 828 700 829 return panel; 701 830 }, -
sandbox/gislars/sipv/MapFish/client/mfbase/styler/lib/Styler/widgets/FilterPanel.js
r3354 r3369 62 62 }, 63 63 scope: this 64 }, 65 width: 120 64 } 66 65 }; 67 66 this.storeUriProperty = this.filterPanelOptions.values.storeUriProperty; 68 this.deactivable = this.filterPanelOptions.deactivable;69 67 this.storeOptions = Ext.apply({}, this.filterPanelOptions.values.storeOptions); 70 68 this.comboOptions = Ext.apply({}, this.filterPanelOptions.values.comboOptions); … … 72 70 this.attributesComboConfig = Ext.apply({}, this.filterPanelOptions.attributesComboConfig); 73 71 Ext.applyIf(this.attributesComboConfig, defAttributesComboConfig); 74 72 73 this.addEvents( 74 /** 75 * Event: loading 76 * Fires when loading data from server 77 */ 78 "loading", 79 /** 80 * Event: loaded 81 * Fires when finished loading data from server 82 */ 83 "loaded" 84 ); 85 75 86 Styler.FilterPanel.superclass.initComponent.call(this); 76 87 }, … … 95 106 /** 96 107 * Method: adaptValueField 97 * filter comparison box according to attribute's type108 * 98 109 * 99 110 * Parameters: … … 101 112 */ 102 113 adaptValueField: function(record) { 114 var previousCmp = this.valueContainer.items.items[0]; 115 var newCmpWidth = (previousCmp instanceof(Ext.form.ComboBox)) ? 116 previousCmp.getSize().width+17 : // 17 = trigger size 117 previousCmp.getSize().width; 118 119 var recordIsDate = (record.get('type')=='dateTime' || 120 record.get('type')=='date'); 121 103 122 if (this.storeUriProperty && record.get(this.storeUriProperty)) { 104 123 this.setEqualComparison(); 105 124 var store = new Ext.data.JsonStore(Ext.apply({ 106 url: record.get(this.storeUriProperty) 125 url: record.get(this.storeUriProperty), 126 listeners: { 127 "beforeload": function(store, options) { 128 this.fireEvent("loading"); 129 }, 130 "loadexception": function() { 131 this.fireEvent("loaded"); 132 }, 133 scope: this 134 } 107 135 }, this.storeOptions)); 108 136 … … 110 138 store: store, 111 139 mode: 'local', 112 width: 120,140 width: newCmpWidth, 113 141 triggerAction: 'all' 114 142 }, this.comboOptions)); 115 143 116 144 store.on('load', function(store, records){ 117 145 field.setValue(records[0].get(this.comboOptions.valueField)); 146 this.fireEvent("loaded"); 118 147 field.fireEvent('change', field, field.getValue()); 119 148 }, this); 149 120 150 store.load(); 121 } else if (record.get('type')=='dateTime') { 151 152 } else if (recordIsDate) { 122 153 var field = new Ext.form.DateField({ 123 width: 120,154 width: newCmpWidth, 124 155 value: '', 125 156 format: 'd/m/Y', … … 129 160 } else { 130 161 var field = new Ext.form.TextField({ 131 width: 120,162 width: newCmpWidth, 132 163 value: '', 133 164 allowBlank: false, … … 136 167 } 137 168 field.on('change', function(el, value) { 138 if (record .get('type')=='dateTime') {169 if (recordIsDate) { 139 170 var dt = new Date(value); 140 171 value = dt.format('c'); … … 144 175 }, this); 145 176 146 this.valueContainer.remove( this.valueContainer.items.items[0]);177 this.valueContainer.remove(previousCmp); 147 178 this.valueContainer.add(field); 148 179 this.valueContainer.doLayout(); … … 213 244 createFilterItems: function() { 214 245 this.valueContainer = new Ext.Panel({ 246 columnWidth: 0.5, 215 247 items: [{ 216 248 xtype: "textfield", 217 width: 120,218 249 value: this.filter.value, 219 250 allowBlank: false, … … 226 257 scope: this 227 258 } 228 }] 259 }], 260 listeners: { 261 'resize': function(p, newWidth) { 262 p.findByType("textfield")[0].setWidth(newWidth); 263 } 264 } 229 265 }); 230 266 231 267 this.comparisonCombo = new Styler.form.ComparisonComboBox({ 232 268 value: this.filter.type, 269 width: 50, 233 270 blankText: "Ce champ est nécessaire", 234 271 listeners: { … … 240 277 } 241 278 }); 242 243 var items = this.createFilterCheckbox();244 items.push({245 width: this.attributesComboConfig.width,246 items: [this.attributesComboConfig]247 }, {248 items: [ this.comparisonCombo ]249 },250 this.valueContainer251 );252 279 253 280 return [{ … … 255 282 border: false, 256 283 defaults: {border: false}, 257 items: items 284 items: [{ 285 items: [this.attributesComboConfig], 286 columnWidth: 0.5, 287 listeners: { 288 'resize': function(p, newWidth) { 289 p.findByType("combo")[0].setWidth(newWidth); 290 } 291 } 292 }, { 293 width: 56, 294 style: "padding: 0 3px;", 295 items: [this.comparisonCombo] 296 }, this.valueContainer] 258 297 }]; 259 298 } 260 261 299 }); 262 300 -
sandbox/gislars/sipv/MapFish/client/mfbase/styler/lib/Styler/widgets/SpatialFilterPanel.js
r3354 r3369 34 34 35 35 /** 36 * Property: cookieProvider 37 * {Ext.state.CookieProvider} The cookie provider 38 * Used for storing a geometry (if available) ... 39 */ 40 cookieProvider: null, 41 42 /** 36 43 * Property: toggleGroup 37 44 * {String} the toggleGroup for the modify feature button … … 117 124 var className = this.feature.geometry.CLASS_NAME; 118 125 var cls = className.substr(className.lastIndexOf('.')+1).toLowerCase(); 119 var items = this.createFilterCheckbox();120 126 var width = this.comboConfig.width; 121 127 if (this.deactivable) { … … 123 129 } 124 130 125 items.push({ 126 width: this.comboConfig.width, 127 border: false, 128 items: [this.comboConfig] 129 }); 131 var buttonPanels = [{ 132 items: [{ 133 xtype: "button", 134 iconCls: cls, 135 tooltip: "Modifier la géométrie", 136 enableToggle: true, 137 toggleGroup: this.toggleGroup, 138 listeners: { 139 "toggle": function(btn, pressed) { 140 var feature = this.feature; 141 if (pressed) { 142 var geometry = feature.geometry; 143 if (geometry.CLASS_NAME == "OpenLayers.Geometry.Point") { 144 this.map.setCenter( 145 geometry.getBounds().getCenterLonLat() 146 ); 147 } else { 148 this.map.zoomToExtent( 149 geometry.getBounds().scale(1.05) 150 ); 151 } 152 // zindex hack (might need a rework of the handler feature 's 153 // moveLayerToTop and moveLayerBack methods to manage this) 154 zindex = feature.layer.getZIndex(); 155 this.mfControl.activate(); 156 this.mfControl.selectFeature(feature); 157 feature.layer.setZIndex(this.map.Z_INDEX_BASE['Feature']+1); 158 } else { 159 this.mfControl.unselectFeature(feature); 160 this.mfControl.deactivate(); 161 feature.layer.setZIndex(zindex); 162 } 163 }, 164 scope: this 165 } 166 }] 167 }]; 168 169 if (this.cookieProvider) { 170 buttonPanels.push({ 171 items: [{ 172 xtype: "button", 173 iconCls: "savegeometry", 174 tooltip: "Enregistrer cette géométrie", 175 handler: function() { 176 if (this.feature && this.feature.geometry) { 177 this.cookieProvider.set('geometry', 178 this.cookieProvider.encodeValue(this.feature.geometry.toString()) 179 ); 180 alert('Géométrie enregistrée pour 30 jours sur ce navigateur.'); 181 } 182 }, 183 scope: this 184 }] 185 }); 186 } 187 130 188 return [{ 131 189 layout: "column", 132 190 border: false, 133 defaults: {border: false}, 134 items: [ { 135 width: this.comboConfig.width+20, 191 defaults: { 192 border: false 193 }, 194 items: [{ 195 width: this.comboConfig.width, 136 196 layout: 'column', 137 items: items 197 items: [{ 198 width: this.comboConfig.width, 199 border: false, 200 items: [this.comboConfig] 201 }] 138 202 }, { 139 items: [{ 140 xtype: "button", 141 iconCls: cls, 142 tooltip: "Modifier la géométrie", 143 enableToggle: true, 144 toggleGroup: this.toggleGroup, 145 listeners: { 146 "toggle": function(btn, pressed) { 147 var feature = this.feature; 148 if (pressed) { 149 var geometry = feature.geometry; 150 if (geometry.CLASS_NAME == "OpenLayers.Geometry.Point") { 151 this.map.setCenter( 152 geometry.getBounds().getCenterLonLat() 153 ); 154 } else { 155 this.map.zoomToExtent( 156 geometry.getBounds().scale(1.05) 157 ); 158 } 159 // zindex hack (might need a rework of the handler feature 's 160 // moveLayerToTop and moveLayerBack methods to manage this) 161 zindex = feature.layer.getZIndex(); 162 this.mfControl.activate(); 163 this.mfControl.selectFeature(feature); 164 feature.layer.setZIndex(this.map.Z_INDEX_BASE['Feature']+1); 165 } else { 166 this.mfControl.unselectFeature(feature); 167 this.mfControl.deactivate(); 168 feature.layer.setZIndex(zindex); 169 } 170 }, 171 scope: this 172 } 173 }] 203 width: 70, 204 layout: 'column', 205 defaults: { 206 border: false, 207 bodyStyle: 'padding-left:1em;' 208 }, 209 items: buttonPanels 174 210 }] 175 211 }];
