From 1cb21e81b2f4a70eeddb94e8169dc3219818c154 Mon Sep 17 00:00:00 2001 From: bertramhillmann <43250699+bertramhillmann@users.noreply.github.com> Date: Wed, 30 Nov 2022 17:29:54 +0100 Subject: [PATCH 1/4] merge dev again --- .../components/SelectionManager.vue | 102 ++++++++++++++++-- .../locales/de/additional.json | 2 + 2 files changed, 93 insertions(+), 11 deletions(-) diff --git a/cosi/SelectionManager/components/SelectionManager.vue b/cosi/SelectionManager/components/SelectionManager.vue index aa734d48f..dbbcf4511 100644 --- a/cosi/SelectionManager/components/SelectionManager.vue +++ b/cosi/SelectionManager/components/SelectionManager.vue @@ -8,7 +8,7 @@ import VectorSource from "ol/source/Vector.js"; import getBoundingGeometry from "../../utils/getBoundingGeometry.js"; import setBBoxToGeom from "../../utils/setBBoxToGeom.js"; import ToolInfo from "../../components/ToolInfo.vue"; -import {getModelByAttributes} from "../../utils/radioBridge.js"; +import {addModelsByAttribute, getModelByAttributes} from "../../utils/radioBridge.js"; import Feature from "ol/Feature"; import Polygon from "ol/geom/Polygon"; import {default as turfCenterOfMass} from "@turf/center-of-mass"; @@ -256,6 +256,9 @@ export default { if (model) { model.set("isSelected", true); } + else { + addModelsByAttribute({name: layerName}); + } }); }, /** @@ -278,18 +281,19 @@ export default { allSelections () { const flatArray = this.selections.map(selection => selection.selection).flat(); - this.addNewSelection({selection: flatArray, source: this.$t("additional:modules.tools.cosi.selectionManager.title"), id: this.$t("additional:modules.tools.cosi.selectionManager.allSelections") + " (" + flatArray.length + ")"}); + this.addNewSelection({selection: flatArray, source: this.$t("additional:modules.tools.cosi.selectionManager.title"), id: this.$t("additional:modules.tools.cosi.selectionManager.allSelections") + " (" + this.selections.length + ")"}); this.highlightSelection(this.selections.length - 1); this.allSelectionsPossible = false; }, /** * @description Calculates the center of each feature and draws a polygon along these points. + * @param {Array} selectionArray - Array of selections that i supposed to be connected * @returns {void} */ - connectSelections () { + connectSelections (selectionArray) { const format = new GeoJSON(), newPolygonCoords = [], - selectionsCopy = this.selections.map(selection => selection.selection); + selectionsCopy = selectionArray.map(selection => selection.selection); selectionsCopy.forEach(selection => { if (Array.isArray(selection)) { @@ -349,6 +353,11 @@ export default { this.rerenderSelection(index); } }, + /** + * @description Creates a new selection from the buffered value. + * @param {Integer} index - Index of the chosen selection in this.selections + * @returns {void} + */ addBufferAsSelection (index) { this.addNewSelection({selection: this.selections[index].bufferedSelection, source: this.$t("additional:modules.tools.cosi.selectionManager.title"), id: this.$t("additional:modules.tools.cosi.selectionManager.buffer") + " " + this.selections[index].id}); this.selections[index].settings.buffer = 0; @@ -389,8 +398,7 @@ export default { * @param {Integer} index - Index of the chosen selection in this.selections * @returns {void} */ - addMergedSelection (index) { - this.selectionsToMerge.push(index); + addMergedSelection () { const flatSelections = this.selections.filter((selection, i) => this.selectionsToMerge.includes(i)).map(selection => selection.selection), flatArray = flatSelections.flat(); @@ -457,8 +465,8 @@ export default { @@ -470,6 +478,52 @@ export default { mdi-close-box-multiple +
+
+

{{ $t('additional:modules.tools.cosi.selectionManager.cache') }}

+
+ + + +
+
+ +
+ +

{{ $t('additional:modules.tools.cosi.selectionManager.dataLoaded') }}

+ +
diff --git a/cosi/SelectionManager/locales/de/additional.json b/cosi/SelectionManager/locales/de/additional.json index ef14bd126..4201e2de7 100644 --- a/cosi/SelectionManager/locales/de/additional.json +++ b/cosi/SelectionManager/locales/de/additional.json @@ -11,6 +11,7 @@ "connectedSelections": "Auswahl verbunden", "buffer": "Veränderte Auswahl", "cache": "Zwischenspeicher", + "dataLoaded": "Die gewünschten Themendaten wurden erfolgreich geladen", "title_view": "Auswahl ein/aus", "title_add": "Auswahl zum Zwischenspeicher hinzufügen", "title_merge": "Zwischenauswahl zusammenführen", diff --git a/cosi/SelectionManager/store/actionsSelectionManager.js b/cosi/SelectionManager/store/actionsSelectionManager.js index 8243bd1fa..172fdc41f 100644 --- a/cosi/SelectionManager/store/actionsSelectionManager.js +++ b/cosi/SelectionManager/store/actionsSelectionManager.js @@ -26,8 +26,8 @@ const actions = { } }, mergedPolygons = []; - - + + console.log("what is da problem", selection); for (let i = 0; i < selection.length; i++) { // turns feature into geojson readable for turf diff --git a/cosi/SelectionManager/store/gettersSelectionManager.js b/cosi/SelectionManager/store/gettersSelectionManager.js index 5c2473c32..5acb13b30 100644 --- a/cosi/SelectionManager/store/gettersSelectionManager.js +++ b/cosi/SelectionManager/store/gettersSelectionManager.js @@ -1,4 +1,5 @@ +import GeoJSON from "ol/format/GeoJSON"; import {generateSimpleGetters} from "../../../../src/app-store/utils/generators"; import selectionManagerState from "./stateSelectionManager"; @@ -24,12 +25,19 @@ const getters = { // pick currently active data layers from FeatureList activeVectorLayerList = rootGetters["Tools/FeaturesList/activeVectorLayerList"], // store the names only - activeLayerList = activeVectorLayerList.map(layer => layer.getProperties().name); // as in activeLayers() computed prop. better duplicate this line than put the whole logic in store + activeLayerList = activeVectorLayerList.map(layer => layer.getProperties().name), // as in activeLayers() computed prop. better duplicate this line than put the whole logic in store + format = new GeoJSON(), + selectionHelper = { + selection: state.selections[index].selection.map(selection => format.writeFeatureObject(selection)), + storedLayers: activeLayerList, + settings: state.selections[index].settings, + id: state.selections[index].id, + bufferedSelection: state.selections[index].bufferedSelection, + source: state.selections[index].source + }; - // update the selection in selectionManager - state.selections[index].storedLayers = activeLayerList; // return the selection settings - return state.selections[index]; + return selectionHelper; } }; diff --git a/cosi/package-lock.json b/cosi/package-lock.json index bc0ce1ac6..f2775933a 100644 --- a/cosi/package-lock.json +++ b/cosi/package-lock.json @@ -13,6 +13,7 @@ "@turf/buffer": "^6.5.0", "@turf/center-of-mass": "^6.5.0", "@turf/circle": "^6.5.0", + "@turf/concave": "^6.5.0", "@turf/helpers": "^6.5.0", "@turf/intersect": "^6.5.0", "@turf/simplify": "^6.5.0", @@ -27,6 +28,7 @@ "object-hash": "^2.1.1", "pdfmake": "^0.2.6", "tableify": "^1.1.1", + "turf-featurecollection": "^1.0.1", "vue-chartjs": "^3.5.1", "vue-inline-svg": "^2.1.0", "vue-json-excel": "^0.3.0", @@ -183,6 +185,24 @@ "url": "https://opencollective.com/turf" } }, + "node_modules/@turf/concave": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@turf/concave/-/concave-6.5.0.tgz", + "integrity": "sha512-I/sUmUC8TC5h/E2vPwxVht+nRt+TnXIPRoztDFvS8/Y0+cBDple9inLSo9nnPXMXidrBlGXZ9vQx/BjZUJgsRQ==", + "dependencies": { + "@turf/clone": "^6.5.0", + "@turf/distance": "^6.5.0", + "@turf/helpers": "^6.5.0", + "@turf/invariant": "^6.5.0", + "@turf/meta": "^6.5.0", + "@turf/tin": "^6.5.0", + "topojson-client": "3.x", + "topojson-server": "3.x" + }, + "funding": { + "url": "https://opencollective.com/turf" + } + }, "node_modules/@turf/convex": { "version": "6.5.0", "license": "MIT", @@ -206,6 +226,18 @@ "url": "https://opencollective.com/turf" } }, + "node_modules/@turf/distance": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@turf/distance/-/distance-6.5.0.tgz", + "integrity": "sha512-xzykSLfoURec5qvQJcfifw/1mJa+5UwByZZ5TZ8iaqjGYN0vomhV9aiSLeYdUGtYRESZ+DYC/OzY+4RclZYgMg==", + "dependencies": { + "@turf/helpers": "^6.5.0", + "@turf/invariant": "^6.5.0" + }, + "funding": { + "url": "https://opencollective.com/turf" + } + }, "node_modules/@turf/helpers": { "version": "6.5.0", "license": "MIT", @@ -270,6 +302,17 @@ "url": "https://opencollective.com/turf" } }, + "node_modules/@turf/tin": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@turf/tin/-/tin-6.5.0.tgz", + "integrity": "sha512-YLYikRzKisfwj7+F+Tmyy/LE3d2H7D4kajajIfc9mlik2+esG7IolsX/+oUz1biguDYsG0DUA8kVYXDkobukfg==", + "dependencies": { + "@turf/helpers": "^6.5.0" + }, + "funding": { + "url": "https://opencollective.com/turf" + } + }, "node_modules/@turf/union": { "version": "6.5.0", "license": "MIT", @@ -530,6 +573,11 @@ "version": "1.1.4", "license": "MIT" }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, "node_modules/concat-stream": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", @@ -1707,6 +1755,30 @@ "version": "2.0.3", "license": "ISC" }, + "node_modules/topojson-client": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/topojson-client/-/topojson-client-3.1.0.tgz", + "integrity": "sha512-605uxS6bcYxGXw9qi62XyrV6Q3xwbndjachmNxu8HWTtVPxZfEJN9fd/SZS1Q54Sn2y0TMyMxFj/cJINqGHrKw==", + "dependencies": { + "commander": "2" + }, + "bin": { + "topo2geo": "bin/topo2geo", + "topomerge": "bin/topomerge", + "topoquantize": "bin/topoquantize" + } + }, + "node_modules/topojson-server": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/topojson-server/-/topojson-server-3.0.1.tgz", + "integrity": "sha512-/VS9j/ffKr2XAOjlZ9CgyyeLmgJ9dMwq6Y0YEON8O7p/tGGk+dCWnrE03zEdu7i4L7YsFZLEPZPzCvcB7lEEXw==", + "dependencies": { + "commander": "2" + }, + "bin": { + "geo2topo": "bin/geo2topo" + } + }, "node_modules/tr46": { "version": "2.1.0", "license": "MIT", @@ -1717,6 +1789,11 @@ "node": ">=8" } }, + "node_modules/turf-featurecollection": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/turf-featurecollection/-/turf-featurecollection-1.0.1.tgz", + "integrity": "sha512-VLoAXhEVd/KavMrs98x/bQccDd2R9gSPWkNLiwHwC8Cl/0S5Mid6AkCqGpc556V9DAz+6wcQvW6h+oZZQ+Sitg==" + }, "node_modules/turf-jsts": { "version": "1.2.3", "license": "(EDL-1.0 OR EPL-1.0)" @@ -2071,6 +2148,21 @@ "@turf/helpers": "^6.5.0" } }, + "@turf/concave": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@turf/concave/-/concave-6.5.0.tgz", + "integrity": "sha512-I/sUmUC8TC5h/E2vPwxVht+nRt+TnXIPRoztDFvS8/Y0+cBDple9inLSo9nnPXMXidrBlGXZ9vQx/BjZUJgsRQ==", + "requires": { + "@turf/clone": "^6.5.0", + "@turf/distance": "^6.5.0", + "@turf/helpers": "^6.5.0", + "@turf/invariant": "^6.5.0", + "@turf/meta": "^6.5.0", + "@turf/tin": "^6.5.0", + "topojson-client": "3.x", + "topojson-server": "3.x" + } + }, "@turf/convex": { "version": "6.5.0", "requires": { @@ -2086,6 +2178,15 @@ "@turf/invariant": "^6.5.0" } }, + "@turf/distance": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@turf/distance/-/distance-6.5.0.tgz", + "integrity": "sha512-xzykSLfoURec5qvQJcfifw/1mJa+5UwByZZ5TZ8iaqjGYN0vomhV9aiSLeYdUGtYRESZ+DYC/OzY+4RclZYgMg==", + "requires": { + "@turf/helpers": "^6.5.0", + "@turf/invariant": "^6.5.0" + } + }, "@turf/helpers": { "version": "6.5.0" }, @@ -2126,6 +2227,14 @@ "@turf/meta": "^6.5.0" } }, + "@turf/tin": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@turf/tin/-/tin-6.5.0.tgz", + "integrity": "sha512-YLYikRzKisfwj7+F+Tmyy/LE3d2H7D4kajajIfc9mlik2+esG7IolsX/+oUz1biguDYsG0DUA8kVYXDkobukfg==", + "requires": { + "@turf/helpers": "^6.5.0" + } + }, "@turf/union": { "version": "6.5.0", "requires": { @@ -2315,6 +2424,11 @@ "color-name": { "version": "1.1.4" }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, "concat-stream": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", @@ -3172,12 +3286,33 @@ "tinyqueue": { "version": "2.0.3" }, + "topojson-client": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/topojson-client/-/topojson-client-3.1.0.tgz", + "integrity": "sha512-605uxS6bcYxGXw9qi62XyrV6Q3xwbndjachmNxu8HWTtVPxZfEJN9fd/SZS1Q54Sn2y0TMyMxFj/cJINqGHrKw==", + "requires": { + "commander": "2" + } + }, + "topojson-server": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/topojson-server/-/topojson-server-3.0.1.tgz", + "integrity": "sha512-/VS9j/ffKr2XAOjlZ9CgyyeLmgJ9dMwq6Y0YEON8O7p/tGGk+dCWnrE03zEdu7i4L7YsFZLEPZPzCvcB7lEEXw==", + "requires": { + "commander": "2" + } + }, "tr46": { "version": "2.1.0", "requires": { "punycode": "^2.1.1" } }, + "turf-featurecollection": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/turf-featurecollection/-/turf-featurecollection-1.0.1.tgz", + "integrity": "sha512-VLoAXhEVd/KavMrs98x/bQccDd2R9gSPWkNLiwHwC8Cl/0S5Mid6AkCqGpc556V9DAz+6wcQvW6h+oZZQ+Sitg==" + }, "turf-jsts": { "version": "1.2.3" }, diff --git a/cosi/package.json b/cosi/package.json index c7625a3ce..7c39cc500 100644 --- a/cosi/package.json +++ b/cosi/package.json @@ -14,6 +14,7 @@ "@turf/buffer": "^6.5.0", "@turf/center-of-mass": "^6.5.0", "@turf/circle": "^6.5.0", + "@turf/concave": "^6.5.0", "@turf/helpers": "^6.5.0", "@turf/intersect": "^6.5.0", "@turf/simplify": "^6.5.0", @@ -28,6 +29,7 @@ "object-hash": "^2.1.1", "pdfmake": "^0.2.6", "tableify": "^1.1.1", + "turf-featurecollection": "^1.0.1", "vue-chartjs": "^3.5.1", "vue-inline-svg": "^2.1.0", "vue-json-excel": "^0.3.0", From f4a9a4eae2e6df182e6d77475b7e33c6bfc59ae9 Mon Sep 17 00:00:00 2001 From: bertramhillmann <43250699+bertramhillmann@users.noreply.github.com> Date: Mon, 19 Dec 2022 15:35:35 +0100 Subject: [PATCH 3/4] merged dev --- .../components/AccessibilityAnalysis.vue | 2 +- cosi/AreaSelector/components/AreaSelector.vue | 2 +- .../components/SelectionManager.vue | 140 +++++++++++------- .../locales/de/additional.json | 1 + .../store/actionsSelectionManager.js | 4 +- 5 files changed, 89 insertions(+), 60 deletions(-) diff --git a/cosi/AccessibilityAnalysis/components/AccessibilityAnalysis.vue b/cosi/AccessibilityAnalysis/components/AccessibilityAnalysis.vue index f1f630fdf..62272aebe 100644 --- a/cosi/AccessibilityAnalysis/components/AccessibilityAnalysis.vue +++ b/cosi/AccessibilityAnalysis/components/AccessibilityAnalysis.vue @@ -494,7 +494,7 @@ export default { } this.dataSets[this.activeSet].geojson = this.exportAsGeoJson(this.mapLayer); - this.addNewSelection({selection: analysisSet.results, source: this.$t("additional:modules.tools.cosi.accessibilityAnalysis.title"), id: this._mode + ", " + this._transportType + ", [...]"}); + this.addNewSelection({selection: analysisSet.results, source: this.$t("additional:modules.tools.cosi.accessibilityAnalysis.title"), id: this.$t("additional:modules.tools.cosi.accessibilityAnalysis.transportTypes." + this._transportType) + ", " + this.$t("additional:modules.tools.cosi.accessibilityAnalysis.scaleUnits." + this._scaleUnit) + ", [...]"}); }, exportAsGeoJson, // pagination features diff --git a/cosi/AreaSelector/components/AreaSelector.vue b/cosi/AreaSelector/components/AreaSelector.vue index 4a5826811..86559af53 100644 --- a/cosi/AreaSelector/components/AreaSelector.vue +++ b/cosi/AreaSelector/components/AreaSelector.vue @@ -69,7 +69,7 @@ export default { this.drawingLayer.getSource().addFeature(this.feature); } - this.addNewSelection({selection: [new Feature(geom)], source: this.$t("additional:modules.tools.cosi.areaSelector.title"), id: "areaselector-index"}); + this.addNewSelection({selection: [new Feature(geom)], source: this.$t("additional:modules.tools.cosi.areaSelector.title"), id: this.$t("additional:modules.tools.cosi.areaSelector.title") + " #" + new Feature(geom).ol_uid}); setBBoxToGeom.call(this, geom || this.boundingGeometry); } }, diff --git a/cosi/SelectionManager/components/SelectionManager.vue b/cosi/SelectionManager/components/SelectionManager.vue index 2ac97f3c4..186f799db 100644 --- a/cosi/SelectionManager/components/SelectionManager.vue +++ b/cosi/SelectionManager/components/SelectionManager.vue @@ -9,7 +9,6 @@ import getBoundingGeometry from "../../utils/getBoundingGeometry.js"; import setBBoxToGeom from "../../utils/setBBoxToGeom.js"; import ToolInfo from "../../components/ToolInfo.vue"; import {addModelsByAttributes, getModelByAttributes} from "../../utils/radioBridge.js"; -import Modal from "../../../../src/share-components/modals/components/ModalItem.vue"; import Feature from "ol/Feature"; import Polygon from "ol/geom/Polygon"; import {default as turfCenterOfMass} from "@turf/center-of-mass"; @@ -22,8 +21,7 @@ import LoaderOverlay from "../../../../src/utils/loaderOverlay.js"; export default { name: "SelectionManager", components: { - ToolInfo, - Modal + ToolInfo }, data () { return { @@ -76,13 +74,7 @@ export default { selection.selection = selection.selection.map(sel => format.readFeature(sel)); this.addSelection(selection); - if (dataToLoad) { - console.log("testMeHere", dataToLoad); - this.dataLoaded = true; - } - else { - this.highlightSelection(this.selections.length - 1); - } + this.highlightSelection(this.selections.length - 1); } }, // watcher on activeSet so that the active selection can be changed via the setActiveSelection mutation from outside of the component @@ -243,23 +235,25 @@ export default { * @returns {void} */ hoverSelection (index) { - this.map.getLayers().getArray().filter(layer => layer.get("name") === "selection_manager_hover_layer").forEach(layer => this.map.removeLayer(layer)); + if(this.activeSelection != index) { + this.map.getLayers().getArray().filter(layer => layer.get("name") === "selection_manager_hover_layer").forEach(layer => this.map.removeLayer(layer)); - const vectorSource = new VectorSource({ - features: this.selections[index].selection - }), - layer = new VectorLayer({ - name: "selection_manager_hover_layer", - source: vectorSource, - style: new Style({ - fill: new Fill({ - color: "rgba(214, 96, 93, 0.2)" + const vectorSource = new VectorSource({ + features: this.selections[index].selection + }), + layer = new VectorLayer({ + name: "selection_manager_hover_layer", + source: vectorSource, + style: new Style({ + fill: new Fill({ + color: "rgba(214, 96, 93, 0.2)" + }) }) - }) - }); + }); - layer.setZIndex(9999); - this.map.addLayer(layer); + layer.setZIndex(9999); + this.map.addLayer(layer); + } }, /** * @description Removes the hover selection layer. @@ -287,6 +281,8 @@ export default { * @returns {void} */ setStoredLayersActive (storedLayers) { + LoaderOverlay.show(); + // hide all active layers this.activeVectorLayerList.forEach(layer => { const layerId = layer.getProperties().id, @@ -299,16 +295,15 @@ export default { // show all layers stored in the current selection storedLayers.forEach(async layerName => { - + await this.$nextTick(); const model = getModelByAttributes({type: "layer", name: layerName}); if (model) { model.set("isSelected", true); - await this.$nextTick(); - LoaderOverlay.hide(); } }); - + + LoaderOverlay.hide(); }, /** * @description Adds index of selection to extendedOptions to extend to option menu in the frontend. @@ -512,7 +507,11 @@ export default { :locale="currentLocale" /> -
+
+
-
-
-

{{ $t('additional:modules.tools.cosi.selectionManager.cache') }}

+
+
+ @@ -572,7 +574,7 @@ export default { :key="i" class="cache_selection" > - {{ selection }} + {{ selections[selection].abv }}
- -

{{ $t('additional:modules.tools.cosi.selectionManager.dataLoaded') }}

- -
@@ -782,11 +771,11 @@ export default { } } - .all_function_buttons { - width:90px; + .all_function_buttons, .cache_buttons { + width:auto; height:30px; margin:0px 5px 0px auto; - border-bottom: 1px solid #aaa; + // border-bottom: 1px solid #aaa; display:flex; flex-flow:row wrap; justify-content:flex-end; @@ -835,10 +824,15 @@ export default { } .cache { - margin:5px; + margin:3px 0px; + border-top:1px solid #ccc; + border-bottom:1px solid #ccc; + background:whitesmoke; ul { justify-content:flex-end; + padding:5px; + box-sizing:border-box; li { flex:0 0 auto; @@ -851,6 +845,11 @@ export default { button { margin-left:10px; + &.disabled { + pointer-events:none; + opacity:0.6; + } + .v-icon { font-size:10px; color:#444; @@ -860,6 +859,15 @@ export default { } } + .function_grp { + .menu_title { + color:#aaa; + font-size:90%; + line-height:30px; + margin-right:5px; + } + } + ul.groups { .group_header { width:100%; @@ -882,7 +890,7 @@ export default { background:whitesmoke; border-bottom:1px solid #ccc; height:30px; - padding-left:20px; + padding-left:10px; text-align:left; box-sizing:border-box; overflow:hidden; @@ -954,8 +962,22 @@ export default { } } + span.hint { + display:inline; + font-size:75%; + padding:0px 3px; + box-sizing:border-box; + color:#888; + height:20px; + width:38px; + text-align:center; + line-height:20px; + margin:5px 6px 5px 0px; + border:1px solid #888; + } + p { - flex-basis:calc(100% - 140px); + // flex-basis:calc(100% - 170px); line-height:30px; } @@ -1062,6 +1084,10 @@ export default { } } } + + &:hover { + cursor:pointer; + } } } } diff --git a/cosi/SelectionManager/locales/de/additional.json b/cosi/SelectionManager/locales/de/additional.json index 4201e2de7..d379e1f4e 100644 --- a/cosi/SelectionManager/locales/de/additional.json +++ b/cosi/SelectionManager/locales/de/additional.json @@ -8,6 +8,7 @@ "noData": "Keine Daten vorhanden", "mergedSelections": "Kombinierte Auswahl", "allSelections": "Alle aktiven ausgewählt", + "allSelectionsMenu": "Alle Auswahlen", "connectedSelections": "Auswahl verbunden", "buffer": "Veränderte Auswahl", "cache": "Zwischenspeicher", diff --git a/cosi/SelectionManager/store/actionsSelectionManager.js b/cosi/SelectionManager/store/actionsSelectionManager.js index 172fdc41f..37171652f 100644 --- a/cosi/SelectionManager/store/actionsSelectionManager.js +++ b/cosi/SelectionManager/store/actionsSelectionManager.js @@ -10,7 +10,7 @@ import GeoJSON from "ol/format/GeoJSON"; * @returns {void} */ const actions = { - addNewSelection ({commit}, {selection, source, id}) { + addNewSelection ({state, commit}, {selection, source, id}) { let collection; const format = new GeoJSON(), selectionObject = { @@ -18,6 +18,7 @@ const actions = { bufferedSelection: Array, source: String, id: String, + abv: String, storedLayers: [], filterSettings: [], settings: { @@ -53,6 +54,7 @@ const actions = { selectionObject.selection = mergedPolygons; selectionObject.source = source; selectionObject.id = id; + selectionObject.abv = state.selections.filter(selection => selection.abv === id.match(/\b([A-Z0-9])/g).join('')).length > 0 ? id.match(/\b([A-Z0-9])/g).join('') + "-" + state.selections.filter(selection => selection.abv === id.match(/\b([A-Z0-9])/g).join('')).length : id.match(/\b([A-Z0-9])/g).join(''); commit("addSelection", selectionObject); } From dbcc29447c91ae43296ecfc6464dd15d25edd189 Mon Sep 17 00:00:00 2001 From: bertramhillmann <43250699+bertramhillmann@users.noreply.github.com> Date: Thu, 22 Dec 2022 10:43:13 +0100 Subject: [PATCH 4/4] push fuer pr --- .../components/AccessibilityAnalysis.vue | 3 +- .../components/SelectionManager.vue | 149 ++++++++++-------- .../store/actionsSelectionManager.js | 5 +- .../store/mutationsSelectionManager.js | 9 +- 4 files changed, 95 insertions(+), 71 deletions(-) diff --git a/cosi/AccessibilityAnalysis/components/AccessibilityAnalysis.vue b/cosi/AccessibilityAnalysis/components/AccessibilityAnalysis.vue index 62272aebe..96b66e2fb 100644 --- a/cosi/AccessibilityAnalysis/components/AccessibilityAnalysis.vue +++ b/cosi/AccessibilityAnalysis/components/AccessibilityAnalysis.vue @@ -108,6 +108,7 @@ export default { ...mapGetters("Tools/DistrictSelector", ["boundingGeometry"]), ...mapGetters("Tools/FeaturesList", ["activeVectorLayerList", "isFeatureActive"]), ...mapGetters("Tools/AreaSelector", {areaSelectorGeom: "geometry"}), + ...mapGetters("Tools/SelectionManager", ["activeSelection"]), ...mapGetters("Tools/ScenarioBuilder", ["scenarioUpdated"]), ...mapGetters("Tools/Routing/Directions", ["directionsRouteSource", "directionsRouteLayer", "routingDirections"]), ...mapGetters("Tools/Routing", {routingActive: "active", activeRoutingToolOption: "activeRoutingToolOption"}), @@ -255,7 +256,7 @@ export default { mode () { this.setSetByFeature(false); - if (this.mode === "region") { + if (this.mode === "region" && this.activeSelection === null) { this.resetIsochroneBBox(); } diff --git a/cosi/SelectionManager/components/SelectionManager.vue b/cosi/SelectionManager/components/SelectionManager.vue index 186f799db..19af67460 100644 --- a/cosi/SelectionManager/components/SelectionManager.vue +++ b/cosi/SelectionManager/components/SelectionManager.vue @@ -16,7 +16,6 @@ import {default as turfConcave} from "@turf/concave"; import {featureCollection as turfFeatureCollection} from "@turf/helpers"; import GeoJSON from "ol/format/GeoJSON"; import {Fill, Stroke, Style} from "ol/style.js"; -import LoaderOverlay from "../../../../src/utils/loaderOverlay.js"; export default { name: "SelectionManager", @@ -52,6 +51,9 @@ export default { }, activeLayerList () { return this.activeVectorLayerList.map(layer => layer.getProperties().name); + }, + selectionsLength () { + return this.selections.length; } }, watch: { @@ -59,32 +61,28 @@ export default { // that pattern allows us to use data from external tools and apply internal methods to it. acceptSelection (selection) { if (selection) { - let dataToLoad = false; - // check for stored vector layers to load selection.storedLayers.forEach(layerName => { if (!getModelByAttributes({type: "layer", name: layerName})) { addModelsByAttributes({name: layerName}); - dataToLoad = true; } }); const format = new GeoJSON(); selection.selection = selection.selection.map(sel => format.readFeature(sel)); - + selection.abv = this.selections.filter(sel => sel.abv === selection.id.match(/\b([A-Z0-9])/g).join("")).length > 0 ? selection.id.match(/\b([A-Z0-9])/g).join("") + "-" + this.selections.filter(sel => sel.abv === selection.id.match(/\b([A-Z0-9])/g).join("")).length : selection.id.match(/\b([A-Z0-9])/g).join(""); this.addSelection(selection); this.highlightSelection(this.selections.length - 1); } }, - // watcher on activeSet so that the active selection can be changed via the setActiveSelection mutation from outside of the component - activeSet (oldValue, newValue) { - if (oldValue === newValue) { - this.removeLayer(); - this.setActiveSelection(null); + // watcher on activeSet so that the active selection can be changed via the inputActiveSelection mutation from outside of the component + activeSelection (value) { + if (value !== null) { + this.activateSelection(value); } else { - this.toggleSelection(newValue); + this.removeLayer(); } }, /** @@ -122,11 +120,15 @@ export default { } } }, - /** - * @description Sets the all selections button active again if the this.selections array changes. - * @returns {void} - */ - selections () { + // Sets the all selections button active again if the this.selections array changes and updates the selection index + selectionsLength (newValue, oldValue) { + if ((oldValue && newValue && oldValue < newValue) || (!oldValue && newValue)) { + this.inputActiveSelection(newValue - 1); + } + else if (newValue && newValue < this.activeSelection + 1) { + this.inputActiveSelection(0); + } + this.allSelectionsPossible = true; } }, @@ -138,24 +140,16 @@ export default { ...mapActions("Tools/SelectionManager", Object.keys(actions)), ...mapMutations("Maps", ["setLayerVisibility", "addLayerToMap", "removeLayerFromMap"]), /** - * @description Toggles the active selection on click in frontend - * @param {*} index - Index of the chosen selection in this.selections - * @returns {void} - */ - toggleSelection (index) { - if (this.activeSelection !== index) { - this.setActiveSelection(index); - - if (this.selections[index].settings.bufferActive) { - this.rerenderSelection(index); - } - else { - this.highlightSelection(index); - } + * @description Highlights activeSelection + * @param {Integer} index - Index of the active selection in this.selections + * @returns {void} + */ + activateSelection (index) { + if (this.selections[index].settings.bufferActive) { + this.rerenderSelection(index); } else { - this.removeLayer(); - this.setActiveSelection(null); + this.highlightSelection(index); } }, /** @@ -232,10 +226,11 @@ export default { /** * @description Creates VectorLayer for the chosen selection on hover in the selection menu. * @param {Integer} index - Index of the chosen selection in this.selections + * @param {Integer} color - RGB String of color that the hover shall have * @returns {void} */ - hoverSelection (index) { - if(this.activeSelection != index) { + hoverSelection (index, color) { + if (this.activeSelection !== index) { this.map.getLayers().getArray().filter(layer => layer.get("name") === "selection_manager_hover_layer").forEach(layer => this.map.removeLayer(layer)); const vectorSource = new VectorSource({ @@ -246,7 +241,7 @@ export default { source: vectorSource, style: new Style({ fill: new Fill({ - color: "rgba(214, 96, 93, 0.2)" + color: color }) }) }); @@ -280,9 +275,8 @@ export default { * @param {Array} storedLayers - The names of the stored layers inside the saved selection * @returns {void} */ - setStoredLayersActive (storedLayers) { - LoaderOverlay.show(); - + async setStoredLayersActive (storedLayers) { + // hide all active layers this.activeVectorLayerList.forEach(layer => { const layerId = layer.getProperties().id, @@ -295,15 +289,23 @@ export default { // show all layers stored in the current selection storedLayers.forEach(async layerName => { - await this.$nextTick(); const model = getModelByAttributes({type: "layer", name: layerName}); if (model) { model.set("isSelected", true); } }); - - LoaderOverlay.hide(); + + // a bug in the loaderOverlay.hide() is not working, even if it's fired with a timeOut + // so here's a very! uncanny workaround to make it work in this case + await this.$nextTick(); + + // setTimout because something triggers LoaderOverlay.show() after the last $nextTick() and I can't figure out what + setTimeout(()=> { + // remove the classes manually + document.getElementById("loader").classList.remove("loader-is-loading"); + document.getElementById("masterportal-container").classList.remove("blurry"); + }, 1500); }, /** * @description Adds index of selection to extendedOptions to extend to option menu in the frontend. @@ -373,7 +375,6 @@ export default { if (this.selections[index].settings.bufferActive) { this.selections[index].settings.bufferActive = false; if (this.activeSelection === index) { - this.setActiveSelection(null); this.highlightSelection(index); } } @@ -419,7 +420,6 @@ export default { * @returns {void} */ removeLayer () { - this.setActiveSelection(null); this.map.getLayers().getArray().filter(layer => layer.get("name") === "selection_manager").forEach(layer => this.map.removeLayer(layer)); }, /** @@ -430,13 +430,21 @@ export default { removeSelection (index) { this.selections.splice(index, 1); + // if no selections are left => remove the ol layer if (this.selections.length === 0) { + this.inputActiveSelection(null); this.removeLayer(); } + // if selection was in cache => remove it there as well if (this.selectionsToMerge.includes(index)) { this.selectionsToMerge.splice(this.selectionsToMerge.indexOf(index), 1); } + + // if selection was active selection => reset active selection + if (this.selections.length > 0 && index === this.activeSelection) { + this.inputActiveSelection(0); + } }, /** * @description Resets the whole this.selections array @@ -445,7 +453,7 @@ export default { removeAllSelections () { this.clearAllSelections(); this.removeLayer(); - this.setActiveSelection(null); + this.inputActiveSelection(null); }, /** * @description Merges selections from selectionToMerge array into a single selection. @@ -507,11 +515,13 @@ export default { :locale="currentLocale" />
-
- +
-
- + @@ -635,14 +654,6 @@ export default { > mdi-plus -