Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 7 commits
  • 8 files changed
  • 0 comments
  • 1 contributor
7 core/src/script/CGXP/loader.js
@@ -69,6 +69,13 @@
69 69 "../../../../geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/tree/WMSBrowserTreePanel.js",
70 70 "../../../../geoext.ux/ux/WMSBrowser/resources/lang/fr.js",
71 71 // </wmsbrowser dependencies>
  72 + // <addkmlfile dependecies>
  73 + "../../../../ext/Ext/examples/ux/fileuploadfield/FileUploadField.js",
  74 + // </addkmlfile dependecies>
  75 + // <fulltextsearch dependencies>
  76 + "../../../../ext.ux/TwinTriggerComboBox/Ext/ux/form/TwinTriggerComboBox.js",
  77 + "data/FeatureReader.js",
  78 + // </fulltextsearch dependencies>
72 79 "locale/en.js",
73 80 "locale/fr.js",
74 81 "locale/de.js",
2  core/src/script/CGXP/plugins/AddKMLFile.js
@@ -30,7 +30,7 @@
30 30 Ext.namespace("cgxp.plugins");
31 31
32 32 /** api: example
33   - * Sample code showing how to add an AddKMLFile plugin to a
  33 + * Sample code showing how to add an AddKMLFile plugin to a
34 34 * `gxp.Viewer` is available in the `GoogleEarthView plugin <GoogleEarthView.html>`_.
35 35 */
36 36
2  core/src/script/CGXP/plugins/ContextualData.js
@@ -501,7 +501,7 @@ cgxp.plugins.ContextualData.Tooltip = OpenLayers.Class(cgxp.plugins.ContextualDa
501 501 showLocationTooltip: function(ev) {
502 502 if (this.showLocationInMapRequestOngoing) {
503 503 return;
504   - };
  504 + }
505 505
506 506 this.lonLat = this.map.getLonLatFromPixel(ev.xy);
507 507
487 core/src/script/CGXP/plugins/FeatureGrid.js
@@ -75,7 +75,7 @@ Ext.namespace("cgxp.plugins");
75 75 * :class:`cgxp.plugins.WMSGetFeatureInfo`, and
76 76 * :class:`cgxp.plugins.QueryBuilder`.
77 77 *
78   - */
  78 + */
79 79 cgxp.plugins.FeatureGrid = Ext.extend(gxp.plugins.Tool, {
80 80
81 81 /** api: ptype = cgxp_featuregrid */
@@ -140,9 +140,9 @@ cgxp.plugins.FeatureGrid = Ext.extend(gxp.plugins.Tool, {
140 140 events: null,
141 141
142 142 /** api: config[globalSelection]
143   - * ``Boolean`` If true, selection state are remembered across all result
  143 + * ``Boolean`` If true, selection state are remembered across all result
144 144 * tabs when switching tab.
145   - * Also the "select all", "select none" and "toggle" buttons act on all tabs
  145 + * Also the "select all", "select none" and "toggle" buttons act on all tabs
146 146 * and not only the active tab.
147 147 * This also enable global result in export pdf. Default is false.
148 148 */
@@ -271,7 +271,7 @@ cgxp.plugins.FeatureGrid = Ext.extend(gxp.plugins.Tool, {
271 271
272 272 if (this.tabpan.activeTab && this.currentGrid) {
273 273 // list the grids to use
274   - if (!this.globalSelection &&
  274 + if (!this.globalSelection &&
275 275 this.currentGrid.getSelectionModel().getSelections().length > 0) {
276 276 grids.push(this.currentGrid);
277 277 } else {
@@ -280,7 +280,7 @@ cgxp.plugins.FeatureGrid = Ext.extend(gxp.plugins.Tool, {
280 280 if (this.gridByType.hasOwnProperty(grid)) {
281 281 grids.push(this.gridByType[grid]);
282 282 }
283   - }
  283 + }
284 284 } else {
285 285 grids.push(this.currentGrid);
286 286 }
@@ -303,14 +303,14 @@ cgxp.plugins.FeatureGrid = Ext.extend(gxp.plugins.Tool, {
303 303
304 304 Ext.each(records, function(r) {
305 305 var attributes = r.getFeature().attributes;
306   -
  306 +
307 307 var raw = {};
308 308 var index = 0;
309 309 // group records by type (layer)
310 310 if (!groupedRecords[grid.title]) {
311 311 var results = {
312 312 table: {
313   - data: [],
  313 + data: [],
314 314 columns: []
315 315 },
316 316 _newGroup: true
@@ -339,7 +339,7 @@ cgxp.plugins.FeatureGrid = Ext.extend(gxp.plugins.Tool, {
339 339 }
340 340 return groupedRecords;
341 341 },
342   -
  342 +
343 343 /** private: method[getCount]
344 344 * Gets the result count.
345 345 */
@@ -405,211 +405,23 @@ cgxp.plugins.FeatureGrid = Ext.extend(gxp.plugins.Tool, {
405 405 // a ResultsPanel object has its own vector layer, which
406 406 // is added to the map once for good
407 407 this.vectorLayer = new OpenLayers.Layer.Vector(
408   - OpenLayers.Util.createUniqueID("c2cgeoportal"), {
  408 + OpenLayers.Util.createUniqueID("cgxp"), {
409 409 displayInLayerSwitcher: false,
410 410 alwaysInRange: true
411 411 });
412 412
413 413 this.events.on('queryopen', function() {
414 414 }, this);
415   -
  415 +
416 416 this.events.on('queryclose', function() {
417 417 this.control && this.control.deactivate();
418 418 }, this);
419 419
420   - this.events.on('queryresults', function(features, selectAll) {
421   -
422   - // if no feature do nothing
423   - if (!features || features.length === 0) {
424   - return;
425   - }
426   -
427   - if (this.currentGrid) {
428   - this.currentGrid.getSelectionModel().clearSelections();
429   - }
430   - this.currentGrid = null;
431   - this.vectorLayer.destroyFeatures();
432   -
433   - var grid;
434   -
435   - /* this is important, if the grid are not cleared and created anew,
436   - the event viewready is not triggered and we fall on an ext bug
437   - when we try to act on the grid before it is ready to be modified */
438   - for (var gridName in this.gridByType) {
439   - if (this.gridByType.hasOwnProperty(gridName)) {
440   - grid = this.gridByType[gridName];
441   - grid.getSelectionModel().unbind();
442   - grid.destroy();
443   - }
444   - }
445   - this.gridByType = {};
446   -
447   - if (this.tabpan) {
448   - this.tabpan.items.each(function (item) {
449   - this.tabpan.hideTabStripItem(item);
450   - }.createDelegate(this));
451   - this.tabpan.doLayout();
452   - }
453   -
454   - var currentType = {}, feature;
455   - for (var i = 0, len = features.length ; i < len ; i++) {
456   - feature = features[i];
457   - var hasAttributes = false;
458   - var attribute;
459   - for (attribute in feature.attributes) {
460   - if (feature.attributes.hasOwnProperty(attribute)) {
461   - hasAttributes = true;
462   - break;
463   - }
464   - }
465   - // don't use feature without attributes
466   - if (!hasAttributes) {
467   - continue;
468   - }
469   -
470   - if (!feature.geometry && feature.bounds) {
471   - feature.geometry = feature.bounds.toGeometry();
472   - }
473   -
474   - feature.style = {display: 'none'};
475   - currentType[feature.type] = true;
476   -
477   - if (!this.control) {
478   - this.control = new OpenLayers.Control.SelectFeature(this.vectorLayer, {
479   - toggle: true,
480   - multiple: true,
481   - multipleKey: (Ext.isMac ? "metaKey" : "ctrlKey")
482   - });
483   - map.addControl(this.control);
484   - this.control.handlers.feature.stopDown = false;
485   - } else {
486   - this.control.activate();
487   - }
488   -
489   - if (this.gridByType[feature.type] === undefined) {
490   - var fields = [];
491   - var columns = [];
492   - for (attribute in feature.attributes) {
493   - if (feature.attributes.hasOwnProperty(attribute)) {
494   - fields.push({name: attribute, type: 'string'});
495   - columns.push({header: OpenLayers.i18n(attribute), dataIndex: attribute});
496   - }
497   - }
498   -
499   - var store = new GeoExt.data.FeatureStore({
500   - layer: this.vectorLayer,
501   - fields: fields
502   - });
503   -
504   - grid = new Ext.grid.GridPanel({
505   - store: store,
506   - viewConfig: {
507   - // we add an horizontal scroll bar in case
508   - // there are too many attributes to display:
509   - forceFit: (columns.length < 9)
510   - },
511   - colModel: new Ext.grid.ColumnModel({
512   - defaults: {
513   - sortable: true
514   - },
515   - columns: columns
516   - }),
517   - sm: new GeoExt.grid.FeatureSelectionModel({
518   - selectControl: this.control,
519   - singleSelect: false
520   - }),
521   - title: OpenLayers.i18n(feature.type),
522   - ready: false
523   - });
524   - grid.getSelectionModel().on({
525   - 'rowdeselect': function (model, index, record) {
526   - this.hideFeature(record);
527   - if (this.globalSelection) {
528   - // store change
529   - model.grid.selection = model.getSelections();
530   - }
531   - },
532   - 'rowselect': function (model, index, record) {
533   - this.showFeature(record);
534   - if (this.globalSelection) {
535   - // store change
536   - model.grid.selection = model.getSelections();
537   - }
538   - },
539   - scope: this
540   - });
541   - grid.on({
542   - 'rowdblclick': function(gclickGrid, index) {
543   - var feature = store.getAt(index).getFeature();
544   - var center;
545   - if (feature.bounds) {
546   - center = feature.bounds.getCenterLonLat();
547   - } else if (feature.geometry) {
548   - var centroid = feature.geometry.getCentroid();
549   - center = new OpenLayers.LonLat(centroid.x, centroid.y);
550   - }
551   - feature.layer.map.setCenter(center);
552   - },
553   - 'render': function(renderGrid) {
554   - this.currentGrid = renderGrid;
555   - },
556   - 'viewready': function(renderGrid) {
557   - var sm = this.currentGrid.getSelectionModel();
558   -
559   - // set grid as ready
560   - sm.grid.ready = true;
561   -
562   - if (!this.globalSelection) {
563   - sm.clearSelections();
564   - }
565   - if (selectAll) {
566   - sm.selectAll();
567   - } else if (this.globalSelection && sm.grid.selection) {
568   - sm.selectRecords(sm.grid.selection);
569   - } else if (this.autoSelectFirst) {
570   - sm.selectFirstRow();
571   - }
572   - },
573   - scope: this
574   - });
575   - this.gridByType[feature.type] = grid;
576   - this.tabpan.add(grid);
577   - } else {
578   - grid = this.gridByType[feature.type];
579   - // reset grid selection
580   - grid.selection = null;
581   - this.tabpan.unhideTabStripItem(grid);
582   - }
583   - this.vectorLayer.addFeatures(feature);
584   - }
585   - var type;
586   - for (type in currentType) {
587   - if (currentType.hasOwnProperty(type)) {
588   - this.gridByType[type].getStore().filterBy(function(record) {
589   - return record.getFeature().type === type && record.getFeature().layer;
590   - });
591   - }
592   - }
593   - var firstType;
594   - for (type in this.gridByType) {
595   - if (this.gridByType.hasOwnProperty(type)) {
596   - if (currentType[type]) {
597   - firstType = type;
598   - continue;
599   - }
600   - }
601   - }
602   - this.currentGrid = this.gridByType[firstType];
603   - this.tabpan.setActiveTab(this.currentGrid.id);
604   - this.textItem.setText(this.getCount());
605   - this.tabpan.ownerCt.setVisible(true);
606   - this.tabpan.ownerCt.expand();
607   - this.tabpan.ownerCt.ownerCt.doLayout();
608   - }, this);
  420 + this.events.on('queryresults', this.onResults, this);
609 421
610 422 this.textItem = new Ext.Toolbar.TextItem({
611 423 text: ''
612   - });
  424 + });
613 425
614 426 config = {
615 427 xtype: 'tabpanel',
@@ -620,10 +432,10 @@ cgxp.plugins.FeatureGrid = Ext.extend(gxp.plugins.Tool, {
620 432 this.currentGrid = tab;
621 433 if (this.currentGrid && this.currentGrid.ready) {
622 434 /* this must be done here because the grid has alerady been
623   - initialized and the event "viewready" is not triggered
  435 + initialized and the event "viewready" is not triggered
624 436 anymore.
625   - this is not done the first time the grid is initialized,
626   - condition set by the custom ready property, see the
  437 + this is not done the first time the grid is initialized,
  438 + condition set by the custom ready property, see the
627 439 code of the "viewready" stage */
628 440 if (this.globalSelection && this.currentGrid.selection) {
629 441 // restore selection
@@ -654,38 +466,16 @@ cgxp.plugins.FeatureGrid = Ext.extend(gxp.plugins.Tool, {
654 466 bbar: [
655 467 new Ext.SplitButton({
656 468 text: this.selectText,
657   - handler: function() {
658   - if (this.globalSelection) {
659   - // update selection list for all grids
660   - for (var gridName in this.gridByType) {
661   - if (this.gridByType.hasOwnProperty(gridName)) {
662   - var grid = this.gridByType[gridName];
663   - grid.selection = grid.getStore().getRange();
664   - this.showFeatures(grid.selection);
665   - }
666   - }
667   - }
668   - var sm = this.currentGrid.getSelectionModel();
669   - sm.selectAll();
670   - }, // handle a click on the button itself
  469 + handler: this.selectAll, // handle a click on the button itself
  470 + scope: this,
671 471 menu: new Ext.menu.Menu({
672   - items: [
673   - {text: this.selectAllText, handler: function() {
674   - if (this.globalSelection) {
675   - // update selection list for all grids
676   - for (var gridName in this.gridByType) {
677   - if (this.gridByType.hasOwnProperty(gridName)) {
678   - var grid = this.gridByType[gridName];
679   - grid.selection = grid.getStore().getRange();
680   - this.showFeatures(grid.selection);
681   - }
682   - }
683   - }
684   - var sm = this.currentGrid.getSelectionModel();
685   - sm.selectAll();
686   - },
687   - scope: this},
688   - {text: this.selectNoneText, handler: function() {
  472 + items: [{
  473 + text: this.selectAllText,
  474 + handler: this.selectAll,
  475 + scope: this
  476 + }, {
  477 + text: this.selectNoneText,
  478 + handler: function() {
689 479 if (this.globalSelection) {
690 480 // update selection list for all grids
691 481 for (var gridName in this.gridByType) {
@@ -699,8 +489,10 @@ cgxp.plugins.FeatureGrid = Ext.extend(gxp.plugins.Tool, {
699 489 var sm = this.currentGrid.getSelectionModel();
700 490 sm.clearSelections();
701 491 },
702   - scope: this},
703   - {text: this.selectToggleText, handler: function() {
  492 + scope: this
  493 + }, {
  494 + text: this.selectToggleText,
  495 + handler: function() {
704 496 if (this.globalSelection) {
705 497 // update selection list for all grids
706 498 for (var gridName in this.gridByType) {
@@ -732,10 +524,10 @@ cgxp.plugins.FeatureGrid = Ext.extend(gxp.plugins.Tool, {
732 524 });
733 525 sm.clearSelections();
734 526 sm.selectRecords(recordsToSelect);
735   - },
736   - scope: this}
737   - ]
738   - }),
  527 + },
  528 + scope: this
  529 + }]
  530 + }),
739 531 scope: this
740 532 }),
741 533 {
@@ -745,7 +537,7 @@ cgxp.plugins.FeatureGrid = Ext.extend(gxp.plugins.Tool, {
745 537 xtype: 'menu',
746 538 plain: true,
747 539 items: [{
748   - text: this.zoomToSelectionText,
  540 + text: this.zoomToSelectionText,
749 541 handler: function() {
750 542 var sm = this.currentGrid.getSelectionModel();
751 543 var bbox = new OpenLayers.Bounds();
@@ -758,7 +550,7 @@ cgxp.plugins.FeatureGrid = Ext.extend(gxp.plugins.Tool, {
758 550 },
759 551 scope: this
760 552 }, {
761   - text: this.csvSelectionExportText,
  553 + text: this.csvSelectionExportText,
762 554 handler: this.csvExport,
763 555 target: this,
764 556 scope: this
@@ -785,6 +577,217 @@ cgxp.plugins.FeatureGrid = Ext.extend(gxp.plugins.Tool, {
785 577 this.vectorLayer.setVisibility(false);
786 578 }, this);
787 579 return this.tabpan;
  580 + },
  581 +
  582 + /** private: method[onResults]
  583 + * :arg features: ``Array(OpenLayers.Feature.Vector``
  584 + * :arg selectAll: ``Boolean``
  585 + */
  586 + onResults: function(features, selectAll) {
  587 +
  588 + // if no feature do nothing
  589 + if (!features || features.length === 0) {
  590 + return;
  591 + }
  592 +
  593 + if (this.currentGrid) {
  594 + this.currentGrid.getSelectionModel().clearSelections();
  595 + }
  596 + this.currentGrid = null;
  597 + this.vectorLayer.destroyFeatures();
  598 +
  599 + var grid;
  600 +
  601 + /* this is important, if the grid are not cleared and created anew,
  602 + the event viewready is not triggered and we fall on an ext bug
  603 + when we try to act on the grid before it is ready to be modified */
  604 + for (var gridName in this.gridByType) {
  605 + if (this.gridByType.hasOwnProperty(gridName)) {
  606 + grid = this.gridByType[gridName];
  607 + grid.getSelectionModel().unbind();
  608 + grid.destroy();
  609 + }
  610 + }
  611 + this.gridByType = {};
  612 +
  613 + if (this.tabpan) {
  614 + this.tabpan.items.each(function (item) {
  615 + this.tabpan.hideTabStripItem(item);
  616 + }.createDelegate(this));
  617 + this.tabpan.doLayout();
  618 + }
  619 +
  620 + var currentType = {}, feature;
  621 + for (var i = 0, len = features.length ; i < len ; i++) {
  622 + feature = features[i];
  623 + var hasAttributes = false;
  624 + var attribute;
  625 + for (attribute in feature.attributes) {
  626 + if (feature.attributes.hasOwnProperty(attribute)) {
  627 + hasAttributes = true;
  628 + break;
  629 + }
  630 + }
  631 + // don't use feature without attributes
  632 + if (!hasAttributes) {
  633 + continue;
  634 + }
  635 +
  636 + if (!feature.geometry && feature.bounds) {
  637 + feature.geometry = feature.bounds.toGeometry();
  638 + }
  639 +
  640 + feature.style = {display: 'none'};
  641 + currentType[feature.type] = true;
  642 +
  643 + if (!this.control) {
  644 + this.control = new OpenLayers.Control.SelectFeature(this.vectorLayer, {
  645 + toggle: true,
  646 + multiple: true,
  647 + multipleKey: (Ext.isMac ? "metaKey" : "ctrlKey")
  648 + });
  649 + map.addControl(this.control);
  650 + this.control.handlers.feature.stopDown = false;
  651 + } else {
  652 + this.control.activate();
  653 + }
  654 +
  655 + if (this.gridByType[feature.type] === undefined) {
  656 + var fields = [];
  657 + var columns = [];
  658 + for (attribute in feature.attributes) {
  659 + if (feature.attributes.hasOwnProperty(attribute)) {
  660 + fields.push({name: attribute, type: 'string'});
  661 + columns.push({header: OpenLayers.i18n(attribute), dataIndex: attribute});
  662 + }
  663 + }
  664 +
  665 + var store = new GeoExt.data.FeatureStore({
  666 + layer: this.vectorLayer,
  667 + fields: fields
  668 + });
  669 +
  670 + grid = new Ext.grid.GridPanel({
  671 + store: store,
  672 + viewConfig: {
  673 + // we add an horizontal scroll bar in case
  674 + // there are too many attributes to display:
  675 + forceFit: (columns.length < 9)
  676 + },
  677 + colModel: new Ext.grid.ColumnModel({
  678 + defaults: {
  679 + sortable: true
  680 + },
  681 + columns: columns
  682 + }),
  683 + sm: new GeoExt.grid.FeatureSelectionModel({
  684 + selectControl: this.control,
  685 + singleSelect: false
  686 + }),
  687 + title: OpenLayers.i18n(feature.type),
  688 + ready: false
  689 + });
  690 + grid.getSelectionModel().on({
  691 + 'rowdeselect': function (model, index, record) {
  692 + this.hideFeature(record);
  693 + if (this.globalSelection) {
  694 + // store change
  695 + model.grid.selection = model.getSelections();
  696 + }
  697 + },
  698 + 'rowselect': function (model, index, record) {
  699 + this.showFeature(record);
  700 + if (this.globalSelection) {
  701 + // store change
  702 + model.grid.selection = model.getSelections();
  703 + }
  704 + },
  705 + scope: this
  706 + });
  707 + grid.on({
  708 + 'rowdblclick': function(gclickGrid, index) {
  709 + var feature = store.getAt(index).getFeature();
  710 + var center;
  711 + if (feature.bounds) {
  712 + center = feature.bounds.getCenterLonLat();
  713 + } else if (feature.geometry) {
  714 + var centroid = feature.geometry.getCentroid();
  715 + center = new OpenLayers.LonLat(centroid.x, centroid.y);
  716 + }
  717 + feature.layer.map.setCenter(center);
  718 + },
  719 + 'render': function(renderGrid) {
  720 + this.currentGrid = renderGrid;
  721 + },
  722 + 'viewready': function(renderGrid) {
  723 + var sm = this.currentGrid.getSelectionModel();
  724 +
  725 + // set grid as ready
  726 + sm.grid.ready = true;
  727 +
  728 + if (!this.globalSelection) {
  729 + sm.clearSelections();
  730 + }
  731 + if (selectAll) {
  732 + sm.selectAll();
  733 + } else if (this.globalSelection && sm.grid.selection) {
  734 + sm.selectRecords(sm.grid.selection);
  735 + } else if (this.autoSelectFirst) {
  736 + sm.selectFirstRow();
  737 + }
  738 + },
  739 + scope: this
  740 + });
  741 + this.gridByType[feature.type] = grid;
  742 + this.tabpan.add(grid);
  743 + } else {
  744 + grid = this.gridByType[feature.type];
  745 + // reset grid selection
  746 + grid.selection = null;
  747 + this.tabpan.unhideTabStripItem(grid);
  748 + }
  749 + this.vectorLayer.addFeatures(feature);
  750 + }
  751 + var type;
  752 + for (type in currentType) {
  753 + if (currentType.hasOwnProperty(type)) {
  754 + this.gridByType[type].getStore().filterBy(function(record) {
  755 + return record.getFeature().type === type && record.getFeature().layer;
  756 + });
  757 + }
  758 + }
  759 + var firstType;
  760 + for (type in this.gridByType) {
  761 + if (this.gridByType.hasOwnProperty(type)) {
  762 + if (currentType[type]) {
  763 + firstType = type;
  764 + continue;
  765 + }
  766 + }
  767 + }
  768 + this.currentGrid = this.gridByType[firstType];
  769 + this.tabpan.setActiveTab(this.currentGrid.id);
  770 + this.textItem.setText(this.getCount());
  771 + this.tabpan.ownerCt.setVisible(true);
  772 + this.tabpan.ownerCt.expand();
  773 + this.tabpan.ownerCt.ownerCt.doLayout();
  774 + },
  775 +
  776 + /** private: method[selectAll]
  777 + */
  778 + selectAll: function() {
  779 + if (this.globalSelection) {
  780 + // update selection list for all grids
  781 + for (var gridName in this.gridByType) {
  782 + if (this.gridByType.hasOwnProperty(gridName)) {
  783 + var grid = this.gridByType[gridName];
  784 + grid.selection = grid.getStore().getRange();
  785 + this.showFeatures(grid.selection);
  786 + }
  787 + }
  788 + }
  789 + var sm = this.currentGrid.getSelectionModel();
  790 + sm.selectAll();
788 791 }
789 792 });
790 793
14 core/src/script/CGXP/plugins/FeaturesWindow.js
@@ -64,7 +64,7 @@ Ext.namespace("cgxp.plugins");
64 64 * This is to read the "identifier attribute" from the layer
65 65 * spec.
66 66 *
67   - */
  67 + */
68 68 cgxp.plugins.FeaturesWindow = Ext.extend(gxp.plugins.Tool, {
69 69
70 70 /** api: ptype = cgxp_featureswindow*/
@@ -231,7 +231,7 @@ cgxp.plugins.FeaturesWindow = Ext.extend(gxp.plugins.Tool, {
231 231 }
232 232 detail.push('</table>');
233 233 feature.attributes[this.formatedAttributesId] = detail.join('');
234   - feature.attributes.type = OpenLayers.i18n(feature.type);
  234 + feature.attributes.type = OpenLayers.i18n(feature.type);
235 235
236 236 if (feature.type != previousLayer) {
237 237 previousLayer = feature.type;
@@ -269,7 +269,7 @@ cgxp.plugins.FeaturesWindow = Ext.extend(gxp.plugins.Tool, {
269 269 groupField: 'type',
270 270 fields: [
271 271 'id',
272   - 'type', // the layer
  272 + 'type', // the layer
273 273 this.formatedAttributesId
274 274 ]
275 275 });
@@ -372,16 +372,16 @@ cgxp.plugins.FeaturesWindow = Ext.extend(gxp.plugins.Tool, {
372 372 return groupedRecords;
373 373 }
374 374
375   - Ext.each(records, function(r) {
  375 + Ext.each(records, function(r) {
376 376 var attributes = r.getFeature().attributes;
377   -
  377 +
378 378 var raw = {};
379 379 var index = 0;
380 380 // group records by type (layer)
381 381 if (!groupedRecords[attributes.type]) {
382 382 var results = {
383 383 table: {
384   - data: [],
  384 + data: [],
385 385 columns: []
386 386 },
387 387 _newGroup: true
@@ -389,7 +389,7 @@ cgxp.plugins.FeaturesWindow = Ext.extend(gxp.plugins.Tool, {
389 389 groupedRecords[attributes.type] = results;
390 390 }
391 391 for (prop in attributes) {
392   - if (attributes.hasOwnProperty(prop) &&
  392 + if (attributes.hasOwnProperty(prop) &&
393 393 prop != this.formatedAttributesId &&
394 394 prop != this.originalIdRef) {
395 395
20 core/tests/spec/script/CGXP/plugins/AddKMLFile.js
@@ -11,5 +11,25 @@ describe('plugins.AddKMLFile', function() {
11 11 expect(p).toBeInstanceOf(cgxp.plugins.AddKMLFile);
12 12 });
13 13 });
  14 + describe('when calling addActions', function() {
  15 + var actions;
  16 + beforeEach(function() {
  17 + p = new cgxp.plugins.AddKMLFile();
  18 + // some mocking
  19 + p.actionTarget = [null];
  20 + p.target = {
  21 + mapPanel: {
  22 + map: {}
  23 + }
  24 + };
  25 + actions = p.addActions();
  26 + });
  27 + it('creates an array of length 1', function() {
  28 + expect(actions.length).toEqual(1);
  29 + });
  30 + it('creates a fileupload form', function() {
  31 + expect(actions[0]).toBeInstanceOf(Ext.form.FormPanel);
  32 + });
  33 + });
14 34 });
15 35
53 core/tests/spec/script/CGXP/plugins/FeatureGrid.js
... ... @@ -1,9 +1,25 @@
1 1 describe('plugins.FeatureGrid', function() {
2   - var p;
3   - describe('when calling constructor', function() {
4   - beforeEach(function() {
5   - p = new cgxp.plugins.FeatureGrid();
  2 + var p,
  3 + events;
  4 + beforeEach(function() {
  5 + events = new Ext.util.Observable();
  6 + p = new cgxp.plugins.FeatureGrid({
  7 + events: events
6 8 });
  9 + });
  10 + afterEach(function() {
  11 + // clean up the DOM, which must be Ext-free
  12 + // after each run
  13 + var cmp = p && p.output && p.output[0];
  14 + while(cmp && cmp.ownerCt) {
  15 + cmp = cmp.ownerCt;
  16 + }
  17 + if(cmp) {
  18 + cmp.destroy();
  19 + }
  20 + p = null;
  21 + });
  22 + describe('when calling constructor', function() {
7 23 it('creates a gxp tool', function() {
8 24 expect(p).toBeInstanceOf(gxp.plugins.Tool);
9 25 });
@@ -11,4 +27,33 @@ describe('plugins.FeatureGrid', function() {
11 27 expect(p).toBeInstanceOf(cgxp.plugins.FeatureGrid);
12 28 });
13 29 });
  30 + describe('when calling addOutput', function() {
  31 + var output;
  32 + beforeEach(function() {
  33 + var target = new Ext.Panel({
  34 + tools: {},
  35 + on: function() {},
  36 + mapPanel: {
  37 + map: new OpenLayers.Map('map')
  38 + }
  39 + });
  40 + p.init(target);
  41 + output = p.addOutput();
  42 + });
  43 + it('creates a tabpanel', function() {
  44 + expect(output).toBeInstanceOf(Ext.TabPanel);
  45 + });
  46 + describe('when expanded', function() {
  47 + it('shows the vector layer', function() {
  48 + output.ownerCt.fireEvent('expand');
  49 + expect(p.vectorLayer.visibility).toBeTruthy();
  50 + });
  51 + });
  52 + describe('when collapsed', function() {
  53 + it('hides the vector layer', function() {
  54 + output.ownerCt.fireEvent('collapse');
  55 + expect(p.vectorLayer.visibility).toBeFalsy();
  56 + });
  57 + });
  58 + });
14 59 });
52 core/tests/spec/script/CGXP/plugins/FullTextSearch.js
@@ -11,4 +11,56 @@ describe('plugins.FullTextSearch', function() {
11 11 expect(p).toBeInstanceOf(cgxp.plugins.FullTextSearch);
12 12 });
13 13 });
  14 + describe('when calling init', function() {
  15 + beforeEach(function() {
  16 + p = new cgxp.plugins.FullTextSearch({});
  17 + p.init({
  18 + tools: {},
  19 + on: function(){}
  20 + });
  21 + });
  22 + it('creates a vector layer', function() {
  23 + expect(p.vectorLayer).toBeInstanceOf(OpenLayers.Layer.Vector);
  24 + });
  25 + });
  26 + describe('when calling viewerReady', function() {
  27 + var map;
  28 + beforeEach(function() {
  29 + p = new cgxp.plugins.FullTextSearch({});
  30 + map = new OpenLayers.Map();
  31 + p.init({
  32 + tools: {},
  33 + on: function(){}
  34 + });
  35 + p.target = {
  36 + mapPanel: {
  37 + map: map
  38 + }
  39 + };
  40 + p.viewerReady();
  41 + });
  42 + it('adds the vector layer to the map', function() {
  43 + expect(map.layers.indexOf(p.vectorLayer) != -1).toBeTruthy();
  44 + });
  45 + });
  46 + describe('when calling addActions', function() {
  47 + var actions;
  48 + beforeEach(function() {
  49 + p = new cgxp.plugins.FullTextSearch();
  50 + // some mocking
  51 + p.actionTarget = [null];
  52 + p.target = {
  53 + mapPanel: {
  54 + map: {}
  55 + }
  56 + };
  57 + actions = p.addActions();
  58 + });
  59 + it('creates an array of length 1', function() {
  60 + expect(actions.length).toEqual(1);
  61 + });
  62 + it('creates a twin trigger combo', function() {
  63 + expect(actions[0]).toBeInstanceOf(Ext.ux.form.TwinTriggerComboBox);
  64 + });
  65 + });
14 66 });

No commit comments for this range

Something went wrong with that request. Please try again.