@vcmap/ui 5.0.0-rc.24 → 5.0.0-rc.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/build.js +132 -14
- package/build/buildHelpers.js +196 -92
- package/build/bundle.js +56 -0
- package/build/commonViteConfig.js +2 -2
- package/config/base.config.json +29 -2
- package/config/dev.config.json +29 -1
- package/config/www.config.json +81 -39
- package/dist/assets/@mdi/font/LICENSE +20 -0
- package/dist/assets/@mdi/font/css/materialdesignicons.css.map +16 -0
- package/dist/assets/@mdi/font/css/materialdesignicons.min.e3f476.css +3 -0
- package/dist/assets/@mdi/font/fonts/materialdesignicons-webfont.woff2 +0 -0
- package/dist/assets/cesium/Workers/{AxisAlignedBoundingBox-85d9e53a.js → AxisAlignedBoundingBox-4140c51f.js} +1 -1
- package/dist/assets/cesium/Workers/{BoundingRectangle-1ee7eb47.js → BoundingRectangle-c714b156.js} +1 -1
- package/dist/assets/cesium/Workers/{BoxGeometry-3b2be784.js → BoxGeometry-6f3da43d.js} +1 -1
- package/dist/assets/cesium/Workers/{Color-f107c84d.js → Color-8a565ff2.js} +5 -5
- package/dist/assets/cesium/Workers/{CoplanarPolygonGeometryLibrary-78d71993.js → CoplanarPolygonGeometryLibrary-4b4d4096.js} +1 -1
- package/dist/assets/cesium/Workers/{CorridorGeometryLibrary-50d99b33.js → CorridorGeometryLibrary-7b94502b.js} +1 -1
- package/dist/assets/cesium/Workers/{CylinderGeometry-51b0d9bf.js → CylinderGeometry-ca070b87.js} +1 -1
- package/dist/assets/cesium/Workers/{EllipseGeometry-bcfb5d87.js → EllipseGeometry-122e51fa.js} +1 -1
- package/dist/assets/cesium/Workers/{EllipseGeometryLibrary-e94f8472.js → EllipseGeometryLibrary-4d326efc.js} +1 -1
- package/dist/assets/cesium/Workers/{EllipseOutlineGeometry-28e3a1bb.js → EllipseOutlineGeometry-16cc2bd7.js} +1 -1
- package/dist/assets/cesium/Workers/{EllipsoidGeometry-b222fa63.js → EllipsoidGeometry-cb148ca2.js} +1 -1
- package/dist/assets/cesium/Workers/{EllipsoidOutlineGeometry-38a3fb5b.js → EllipsoidOutlineGeometry-0fa10c79.js} +1 -1
- package/dist/assets/cesium/Workers/{EllipsoidTangentPlane-8c89f28c.js → EllipsoidTangentPlane-6dd1b7af.js} +1 -1
- package/dist/assets/cesium/Workers/{FrustumGeometry-bdd3a04d.js → FrustumGeometry-ee73037c.js} +1 -1
- package/dist/assets/cesium/Workers/{GeometryAttribute-153115c5.js → GeometryAttribute-ff5b4fb1.js} +1 -1
- package/dist/assets/cesium/Workers/{GeometryPipeline-acb2399c.js → GeometryPipeline-1f8fbf05.js} +1 -1
- package/dist/assets/cesium/Workers/{IntersectionTests-271e513e.js → IntersectionTests-70d39ba9.js} +1 -1
- package/dist/assets/cesium/Workers/{OrientedBoundingBox-5e04e31f.js → OrientedBoundingBox-159cf1d6.js} +1 -1
- package/dist/assets/cesium/Workers/{PolygonGeometryLibrary-6762b65b.js → PolygonGeometryLibrary-076a5d25.js} +1 -1
- package/dist/assets/cesium/Workers/{PolygonPipeline-7dc7a431.js → PolygonPipeline-b9f2810a.js} +1 -1
- package/dist/assets/cesium/Workers/{PolylinePipeline-15fde655.js → PolylinePipeline-639192e0.js} +1 -1
- package/dist/assets/cesium/Workers/{PolylineVolumeGeometryLibrary-ba7dfed5.js → PolylineVolumeGeometryLibrary-b73549fb.js} +1 -1
- package/dist/assets/cesium/Workers/{PrimitivePipeline-68f0b9a2.js → PrimitivePipeline-10ede1b6.js} +1 -1
- package/dist/assets/cesium/Workers/{RectangleGeometryLibrary-8eaf23da.js → RectangleGeometryLibrary-c35a7356.js} +1 -1
- package/dist/assets/cesium/Workers/{TerrainEncoding-eb8a645a.js → TerrainEncoding-668d242f.js} +1 -1
- package/dist/assets/cesium/Workers/{Transforms-f6451f99.js → Transforms-a2a85221.js} +14 -0
- package/dist/assets/cesium/Workers/{WallGeometryLibrary-feef3109.js → WallGeometryLibrary-1938bf0d.js} +1 -1
- package/dist/assets/cesium/Workers/cesiumWorkerBootstrapper.js +1 -1
- package/dist/assets/cesium/Workers/combineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createBoxGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createBoxOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createCircleGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createCircleOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createCoplanarPolygonGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createCoplanarPolygonOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createCorridorGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createCorridorOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createCylinderGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createCylinderOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createEllipseGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createEllipseOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createEllipsoidGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createEllipsoidOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createFrustumGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createFrustumOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createGroundPolylineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createPlaneGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createPlaneOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createPolygonGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createPolygonOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createPolylineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createPolylineVolumeGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createPolylineVolumeOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createRectangleGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createRectangleOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createSimplePolylineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createSphereGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createSphereOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createVectorTileGeometries.js +1 -1
- package/dist/assets/cesium/Workers/createVectorTilePolygons.js +1 -1
- package/dist/assets/cesium/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +1 -1
- package/dist/assets/cesium/Workers/createVerticesFromHeightmap.js +1 -1
- package/dist/assets/cesium/Workers/createVerticesFromQuantizedTerrainMesh.js +1 -1
- package/dist/assets/cesium/Workers/createWallGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createWallOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/package.js +1 -1
- package/dist/assets/cesium/Workers/transferTypedArrayTest.js +1 -1
- package/dist/assets/cesium/Workers/upsampleQuantizedTerrainMesh.js +1 -1
- package/dist/assets/{cesium.253914.js → cesium.305b7c.js} +58656 -33170
- package/dist/assets/cesium.js +1 -1
- package/dist/assets/core.f3d6d4.js +19060 -0
- package/dist/assets/core.js +1 -1
- package/dist/assets/index-f94d5be3.js +1 -0
- package/dist/assets/{ol.1c946a.js → ol.39cc05.js} +27344 -12118
- package/dist/assets/ol.js +1 -1
- package/dist/assets/ui.74022f.css +5 -0
- package/dist/assets/ui.74022f.js +13466 -0
- package/dist/assets/ui.js +1 -1
- package/dist/assets/{vue.c1ece7.js → vue.9b8c6e.js} +834 -598
- package/dist/assets/vue.js +2 -2
- package/dist/assets/{vuetify.6efa21.css → vuetify.30486f.css} +1 -1
- package/dist/assets/{vuetify.6efa21.js → vuetify.30486f.js} +343 -103
- package/dist/assets/vuetify.js +2 -2
- package/dist/index.html +7 -6
- package/index.html +14 -6
- package/index.js +19 -2
- package/lib/olLib.js +19 -16
- package/package.json +15 -14
- package/plugins/@vcmap/create-link/fallbackCreateLink.vue +0 -2
- package/plugins/@vcmap/simple-graph/index.js +1 -1
- package/plugins/@vcmap-show-case/README.md +2 -1
- package/plugins/@vcmap-show-case/buttons-example/ButtonsExample.vue +55 -79
- package/plugins/@vcmap-show-case/category-tester/CategoriesExample.vue +135 -0
- package/plugins/@vcmap-show-case/category-tester/CollectionComponentOptions.vue +209 -0
- package/plugins/@vcmap-show-case/category-tester/index.js +19 -1
- package/plugins/@vcmap-show-case/collection-manager-example/CollectionManagerExample.vue +182 -0
- package/plugins/@vcmap-show-case/collection-manager-example/README.md +3 -0
- package/plugins/@vcmap-show-case/collection-manager-example/index.js +74 -0
- package/plugins/@vcmap-show-case/collection-manager-example/package.json +5 -0
- package/plugins/@vcmap-show-case/form-inputs-example/FormInputsExample.vue +20 -3
- package/plugins/@vcmap-show-case/switch-map-callback-example/README.md +21 -0
- package/plugins/@vcmap-show-case/switch-map-callback-example/SwitchMapCallback.js +47 -0
- package/plugins/@vcmap-show-case/switch-map-callback-example/config.json +3 -0
- package/plugins/@vcmap-show-case/switch-map-callback-example/index.js +34 -0
- package/plugins/@vcmap-show-case/switch-map-callback-example/package.json +5 -0
- package/plugins/@vcmap-show-case/table-example/DataTableExample.vue +0 -1
- package/plugins/package.json +3 -1
- package/public/assets/@mdi/font/LICENSE +20 -0
- package/public/assets/@mdi/font/css/materialdesignicons.css.map +16 -0
- package/public/assets/@mdi/font/css/materialdesignicons.min.css +3 -0
- package/public/assets/@mdi/font/fonts/materialdesignicons-webfont.woff2 +0 -0
- package/public/assets/favicon-128.png +0 -0
- package/public/assets/favicon-180.png +0 -0
- package/public/assets/favicon-192.png +0 -0
- package/public/assets/favicon-32.png +0 -0
- package/src/application/VcsApp.vue +38 -8
- package/src/application/VcsAttributions.vue +20 -5
- package/src/application/VcsAttributionsFooter.vue +0 -1
- package/src/application/VcsNavbar.vue +29 -22
- package/src/callback/activateLayersCallback.js +54 -0
- package/src/callback/applyLayerStyleCallback.js +63 -0
- package/src/callback/deactivateLayersCallback.js +54 -0
- package/src/callback/goToViewpointCallback.js +54 -0
- package/src/callback/vcsCallback.js +66 -0
- package/src/components/buttons/VcsActionButtonList.vue +28 -10
- package/src/components/buttons/VcsButton.vue +38 -100
- package/src/components/buttons/VcsFormButton.vue +6 -4
- package/src/components/buttons/VcsToolButton.vue +161 -0
- package/src/components/form-inputs-controls/VcsDatePicker.vue +19 -5
- package/src/components/form-inputs-controls/VcsFormSection.vue +0 -1
- package/src/components/form-inputs-controls/VcsSelect.vue +16 -2
- package/src/components/form-inputs-controls/VcsSlider.vue +72 -0
- package/src/components/form-inputs-controls/VcsTextField.vue +24 -13
- package/src/components/form-inputs-controls/VcsWizard.vue +13 -14
- package/src/components/form-inputs-controls/VcsWizardStep.vue +0 -1
- package/src/components/lists/VcsList.vue +3 -2
- package/src/components/lists/VcsTreeviewLeaf.vue +0 -1
- package/src/components/tables/VcsDataTable.vue +5 -5
- package/src/components/tables/VcsTable.vue +1 -1
- package/src/contentTree/LayerTree.vue +15 -9
- package/src/contentTree/contentTreeCollection.js +1 -1
- package/src/contentTree/contentTreeItem.js +22 -3
- package/src/contentTree/groupContentTreeItem.js +1 -0
- package/src/contentTree/layerContentTreeItem.js +4 -14
- package/src/contentTree/layerGroupContentTreeItem.js +4 -14
- package/src/contentTree/obliqueCollectionContentTreeItem.js +4 -0
- package/src/contentTree/viewpointContentTreeItem.js +1 -0
- package/src/featureInfo/BalloonComponent.vue +0 -1
- package/src/featureInfo/abstractFeatureInfoView.js +16 -1
- package/src/featureInfo/featureInfo.js +45 -56
- package/src/i18n/de.js +5 -2
- package/src/i18n/en.js +5 -2
- package/src/i18n/i18nCollection.js +1 -2
- package/src/init.js +1 -4
- package/src/legend/vcsLegend.vue +1 -1
- package/src/manager/buttonManager.js +15 -0
- package/src/manager/{categoryManager/CategoryComponent.vue → collectionManager/CollectionComponent.vue} +57 -66
- package/src/manager/collectionManager/CollectionComponentList.vue +62 -0
- package/src/manager/collectionManager/CollectionComponentProvider.vue +38 -0
- package/src/manager/collectionManager/CollectionManager.vue +43 -0
- package/src/manager/collectionManager/categoryManager.js +83 -0
- package/src/manager/collectionManager/collectionComponent.js +453 -0
- package/src/manager/collectionManager/collectionManager.js +432 -0
- package/src/manager/navbarManager.js +5 -4
- package/src/manager/toolbox/GroupToolboxComponent.vue +5 -7
- package/src/manager/toolbox/SelectToolboxComponent.vue +6 -9
- package/src/manager/toolbox/ToolboxManager.vue +4 -5
- package/src/manager/window/WindowComponentHeader.vue +0 -4
- package/src/manager/window/WindowManager.vue +22 -5
- package/src/navigation/mapNavigation.vue +34 -8
- package/src/navigation/overviewMap.js +7 -1
- package/src/notifier/notifierComponent.vue +0 -1
- package/src/pluginHelper.js +5 -0
- package/src/search/resultItem.vue +0 -1
- package/src/search/searchComponent.vue +7 -9
- package/src/styles/_theming.scss +0 -16
- package/src/styles/_typography.scss +2 -2
- package/src/styles/main.scss +8 -0
- package/src/styles/vcsFont.scss +1 -22
- package/src/vcsUiApp.js +76 -12
- package/src/vuePlugins/i18n.js +18 -19
- package/src/vuePlugins/vuetify.js +0 -1
- package/dist/assets/core.3a8205.js +0 -18426
- package/dist/assets/index.91ae2d55.js +0 -1
- package/dist/assets/ui.0025be.css +0 -5
- package/dist/assets/ui.0025be.js +0 -18534
- package/plugins/@vcmap-show-case/category-tester/Categories.vue +0 -291
- package/plugins/@vcmap-show-case/category-tester/Category.vue +0 -164
- package/src/manager/categoryManager/CategoryComponentList.vue +0 -82
- package/src/manager/categoryManager/CategoryManager.vue +0 -47
- package/src/manager/categoryManager/categoryManager.js +0 -633
- package/start.js +0 -9
- /package/{src/assets/favicon-128.png → dist/assets/favicon-128.4c4ce5.png} +0 -0
- /package/{src/assets/favicon-180.png → dist/assets/favicon-180.5b99c0.png} +0 -0
- /package/{src/assets/favicon-192.png → dist/assets/favicon-192.0e205e.png} +0 -0
- /package/{src/assets/favicon-32.png → dist/assets/favicon-32.6b9add.png} +0 -0
- /package/dist/assets/{favicon.decf54cc.svg → favicon.d5ec97.svg} +0 -0
- /package/dist/assets/font/{TitilliumWeb-Regular.woff2 → TitilliumWeb-Regular.9ca076.woff2} +0 -0
- /package/{src → public}/assets/favicon.svg +0 -0
- /package/{src → public}/assets/font/OFL.txt +0 -0
- /package/{src → public}/assets/font/TitilliumWeb-Regular.woff2 +0 -0
- /package/src/{assets/logo-mobile.svg → logo-mobile.svg} +0 -0
- /package/src/{assets/logo.svg → logo.svg} +0 -0
@@ -0,0 +1,83 @@
|
|
1
|
+
import { moduleIdSymbol } from '@vcmap/core';
|
2
|
+
import { vcsAppSymbol } from '../../pluginHelper.js';
|
3
|
+
import CollectionManager from './collectionManager.js';
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Manages all requested category collections.
|
7
|
+
* Provides an API to add/remove collectionsComponents.
|
8
|
+
* @implements {VcsComponentManager<CollectionComponent, CollectionComponentOptions>}
|
9
|
+
* @extends CollectionManager
|
10
|
+
*/
|
11
|
+
class CategoryManager extends CollectionManager {
|
12
|
+
/**
|
13
|
+
* @param {import("@vcmap/ui").VcsUiApp} app
|
14
|
+
*/
|
15
|
+
/**
|
16
|
+
* @param {import("@vcmap/ui").VcsUiApp} app
|
17
|
+
*/
|
18
|
+
constructor(app) {
|
19
|
+
super();
|
20
|
+
|
21
|
+
/**
|
22
|
+
* @type {import("@vcmap/ui").VcsUiApp}
|
23
|
+
* @private
|
24
|
+
*/
|
25
|
+
this._app = app;
|
26
|
+
/**
|
27
|
+
* @type {string}
|
28
|
+
* @private
|
29
|
+
*/
|
30
|
+
this._dynamicModuleId = this._app.dynamicModuleId;
|
31
|
+
|
32
|
+
this._dynamicModuleIdFilter = (item) =>
|
33
|
+
item[moduleIdSymbol] === this._dynamicModuleId;
|
34
|
+
|
35
|
+
this.addFilterFunction(this._dynamicModuleIdFilter, vcsAppSymbol);
|
36
|
+
|
37
|
+
this._categoryListeners = [
|
38
|
+
this._app.dynamicModuleIdChanged.addEventListener((id) => {
|
39
|
+
this._dynamicModuleId = id;
|
40
|
+
this.reset();
|
41
|
+
}),
|
42
|
+
this._app.categories.removed.addEventListener((category) => {
|
43
|
+
const collectionComponents = this.getCollection(category.collection);
|
44
|
+
collectionComponents.forEach(({ id }) => this.remove(id));
|
45
|
+
}),
|
46
|
+
];
|
47
|
+
}
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Requests a new or existing category and adds its collection to this manager.
|
51
|
+
* The collectionComponent's id is always the category's name.
|
52
|
+
* Returns requested category and its corresponding collectionComponent.
|
53
|
+
* @param {import("@vcmap/core").CategoryOptions} options
|
54
|
+
* @param {string|symbol} owner
|
55
|
+
* @param {CollectionComponentUiOptions} collectionComponentOptions
|
56
|
+
* @return {{ collectionComponent:CollectionComponent,category:import("@vcmap/core").Category }}
|
57
|
+
*/
|
58
|
+
async requestCategory(options, owner, collectionComponentOptions = {}) {
|
59
|
+
const category = await this._app.categories.requestCategory(options);
|
60
|
+
const id = category.name;
|
61
|
+
if (this.has(id)) {
|
62
|
+
const collectionComponent = this.get(id);
|
63
|
+
return { collectionComponent, category };
|
64
|
+
}
|
65
|
+
const collectionComponent = this.add(
|
66
|
+
{
|
67
|
+
...collectionComponentOptions,
|
68
|
+
id,
|
69
|
+
title: collectionComponentOptions.title ?? category.title ?? id,
|
70
|
+
collection: category.collection,
|
71
|
+
},
|
72
|
+
owner,
|
73
|
+
);
|
74
|
+
return { collectionComponent, category };
|
75
|
+
}
|
76
|
+
|
77
|
+
destroy() {
|
78
|
+
super.destroy();
|
79
|
+
this._categoryListeners.forEach((cb) => cb());
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
export default CategoryManager;
|
@@ -0,0 +1,453 @@
|
|
1
|
+
import { IndexedCollection, isOverrideCollection } from '@vcmap/core';
|
2
|
+
import { getLogger } from '@vcsuite/logger';
|
3
|
+
import { v4 as uuidv4 } from 'uuid';
|
4
|
+
import { computed, ref } from 'vue';
|
5
|
+
import { validateAction } from '../../components/lists/VcsActionList.vue';
|
6
|
+
import { sortByWeight } from '../buttonManager.js';
|
7
|
+
|
8
|
+
/**
|
9
|
+
* @typedef {Object} CollectionComponentUiOptions
|
10
|
+
* @property {string} [id]
|
11
|
+
* @property {string} [title]
|
12
|
+
* @property {boolean} [draggable] - only supported for IndexedCollections
|
13
|
+
* @property {boolean} [selectable]
|
14
|
+
* @property {boolean} [singleSelect]
|
15
|
+
*/
|
16
|
+
|
17
|
+
/**
|
18
|
+
* @typedef {CollectionComponentUiOptions} CollectionComponentOptions
|
19
|
+
* @property {import("@vcmap/core").Collection<T>} collection
|
20
|
+
* @template {Object} T
|
21
|
+
*/
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Manages one collection and creates a mirrored items array with ListItems.
|
25
|
+
* Listens to all collection events and synchronizes changes to the items array.
|
26
|
+
* The Collection Items will be transformed and filtered with the given itemMappings and itemFilter functions
|
27
|
+
* @class
|
28
|
+
* @template {Object|VcsObject} T
|
29
|
+
*/
|
30
|
+
class CollectionComponent {
|
31
|
+
/**
|
32
|
+
* @param {CollectionComponentOptions} options
|
33
|
+
* @param {string|vcsAppSymbol} owner
|
34
|
+
*/
|
35
|
+
constructor(options, owner) {
|
36
|
+
if (!options?.collection?.uniqueKey) {
|
37
|
+
throw new Error(
|
38
|
+
'CollectionComponentOptions requires a collection with mandatory key!',
|
39
|
+
);
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* @type {Collection<T>}
|
44
|
+
* @private
|
45
|
+
*/
|
46
|
+
this._collection = options.collection;
|
47
|
+
/**
|
48
|
+
* @type {string}
|
49
|
+
* @private
|
50
|
+
*/
|
51
|
+
this._id = options.id || uuidv4();
|
52
|
+
/**
|
53
|
+
* @type {import("vue").Ref<string>}
|
54
|
+
*/
|
55
|
+
this.title = ref(options.title);
|
56
|
+
/**
|
57
|
+
* @type {import("vue").Ref<boolean>}
|
58
|
+
* @private
|
59
|
+
*/
|
60
|
+
this._draggable = ref(
|
61
|
+
options.draggable && this._collection instanceof IndexedCollection,
|
62
|
+
);
|
63
|
+
/**
|
64
|
+
* @type {import("vue").Ref<boolean>}
|
65
|
+
*/
|
66
|
+
this.selectable = ref(options.selectable);
|
67
|
+
/**
|
68
|
+
* @type {import("vue").Ref<boolean>}
|
69
|
+
*/
|
70
|
+
this.singleSelect = ref(options.singleSelect);
|
71
|
+
/**
|
72
|
+
* @type {string|vcsAppSymbol}
|
73
|
+
* @private
|
74
|
+
*/
|
75
|
+
this._owner = owner;
|
76
|
+
|
77
|
+
/**
|
78
|
+
* @type {import("vue").Ref<Array<OwnedAction>>}
|
79
|
+
*/
|
80
|
+
this._actions = ref([]);
|
81
|
+
/**
|
82
|
+
* @type {Array<ItemMapping<*>>}
|
83
|
+
* @private
|
84
|
+
*/
|
85
|
+
this._itemMappings = [];
|
86
|
+
/**
|
87
|
+
* @type {Array<ItemFilter<*>>}
|
88
|
+
* @private
|
89
|
+
*/
|
90
|
+
this._itemFilters = [];
|
91
|
+
/**
|
92
|
+
* @type {import("vue").Ref<Array<import("@vcmap/ui").VcsListItem & { destroy: (function():void)|undefined }>>}
|
93
|
+
* @private
|
94
|
+
*/
|
95
|
+
this._listItems = ref([]);
|
96
|
+
/**
|
97
|
+
* @type {import("vue").Ref<Array<import("@vcmap/ui").VcsListItem & { destroy: (function():void)|undefined }>>}
|
98
|
+
*/
|
99
|
+
this.selection = ref([]);
|
100
|
+
|
101
|
+
this._listeners = [
|
102
|
+
this._collection.added.addEventListener(this._handleItemAdded.bind(this)),
|
103
|
+
this._collection.removed.addEventListener(
|
104
|
+
this._handleItemRemoved.bind(this),
|
105
|
+
),
|
106
|
+
];
|
107
|
+
|
108
|
+
if (this._collection[isOverrideCollection]) {
|
109
|
+
this._listeners.push(
|
110
|
+
this._collection.replaced.addEventListener((replacedEvent) => {
|
111
|
+
this._handleItemRemoved(replacedEvent.old);
|
112
|
+
}),
|
113
|
+
);
|
114
|
+
}
|
115
|
+
|
116
|
+
if (this._collection instanceof IndexedCollection) {
|
117
|
+
this._listeners.push(
|
118
|
+
this._collection.moved.addEventListener(
|
119
|
+
this._handleItemMoved.bind(this),
|
120
|
+
),
|
121
|
+
);
|
122
|
+
}
|
123
|
+
|
124
|
+
this.reset();
|
125
|
+
}
|
126
|
+
|
127
|
+
/**
|
128
|
+
* @type {string}
|
129
|
+
* @readonly
|
130
|
+
*/
|
131
|
+
get id() {
|
132
|
+
return this._id;
|
133
|
+
}
|
134
|
+
|
135
|
+
/**
|
136
|
+
* @type {Collection<*>}
|
137
|
+
* @readonly
|
138
|
+
*/
|
139
|
+
get collection() {
|
140
|
+
return this._collection;
|
141
|
+
}
|
142
|
+
|
143
|
+
/**
|
144
|
+
* @type {import("vue").Ref<Array<import("@vcmap/ui").VcsListItem & { destroy: (function():void)|undefined }>>}
|
145
|
+
* @readonly
|
146
|
+
*/
|
147
|
+
get items() {
|
148
|
+
return this._listItems;
|
149
|
+
}
|
150
|
+
|
151
|
+
/**
|
152
|
+
* @type {import("vue").Ref<boolean>}
|
153
|
+
* @readonly
|
154
|
+
*/
|
155
|
+
get draggable() {
|
156
|
+
return this._draggable;
|
157
|
+
}
|
158
|
+
|
159
|
+
/**
|
160
|
+
* @param {boolean} value
|
161
|
+
*/
|
162
|
+
set draggable(value) {
|
163
|
+
if (this._collection instanceof IndexedCollection) {
|
164
|
+
getLogger('CollectionComponent').warn(
|
165
|
+
'draggable can only be set to IndexedCollections!',
|
166
|
+
);
|
167
|
+
return;
|
168
|
+
}
|
169
|
+
this._draggable.value = value;
|
170
|
+
}
|
171
|
+
|
172
|
+
/**
|
173
|
+
* @type {string|vcsAppSymbol}
|
174
|
+
* @readonly
|
175
|
+
*/
|
176
|
+
get owner() {
|
177
|
+
return this._owner;
|
178
|
+
}
|
179
|
+
|
180
|
+
/**
|
181
|
+
* @returns {import("vue").ComputedRef<VcsAction[]>}
|
182
|
+
*/
|
183
|
+
getActions() {
|
184
|
+
return computed(() => this._actions.value.map(({ action }) => action));
|
185
|
+
}
|
186
|
+
|
187
|
+
/**
|
188
|
+
* uses the itemMappings to transform the given Item to an VcsListItem usable in the VcsList
|
189
|
+
* @param {T} item
|
190
|
+
* @returns {import("@vcmap/ui").VcsListItem & { destroy: (function():void)|undefined }}
|
191
|
+
* @template T
|
192
|
+
* @private
|
193
|
+
*/
|
194
|
+
_transformItem(item) {
|
195
|
+
const keyProperty = this._collection.uniqueKey;
|
196
|
+
const listItem = {
|
197
|
+
get name() {
|
198
|
+
return item[keyProperty];
|
199
|
+
},
|
200
|
+
title: item?.properties?.title || item[keyProperty],
|
201
|
+
visible: item?.properties?.visible,
|
202
|
+
disabled: item?.properties?.disabled,
|
203
|
+
tooltip: item?.properties?.tooltip,
|
204
|
+
icon: item?.properties?.icon,
|
205
|
+
hasUpdate: item?.properties?.hasUpdate,
|
206
|
+
actions: [],
|
207
|
+
};
|
208
|
+
this._itemMappings.forEach((itemMapping) => {
|
209
|
+
if (
|
210
|
+
itemMapping.predicate === undefined ||
|
211
|
+
itemMapping.predicate(item, this)
|
212
|
+
) {
|
213
|
+
itemMapping.mappingFunction(item, this, listItem);
|
214
|
+
}
|
215
|
+
});
|
216
|
+
listItem.actions = listItem.actions.filter((action) => {
|
217
|
+
return validateAction(action);
|
218
|
+
});
|
219
|
+
return listItem;
|
220
|
+
}
|
221
|
+
|
222
|
+
/**
|
223
|
+
* Inserts the listItem into the list items array at the correct relative position in respect to the position of the listItem
|
224
|
+
* in the collection
|
225
|
+
* @param {import("@vcmap/ui").VcsListItem} listItem
|
226
|
+
* @private
|
227
|
+
*/
|
228
|
+
_insertListItem(listItem) {
|
229
|
+
if (!this._listItems.value.includes(listItem)) {
|
230
|
+
if (this._collection instanceof IndexedCollection) {
|
231
|
+
const newItemIndex = this._collection.indexOfKey(listItem.name);
|
232
|
+
if (newItemIndex === this._collection.size - 1) {
|
233
|
+
this._listItems.value.push(listItem);
|
234
|
+
} else {
|
235
|
+
const positionInChildren = this._listItems.value.findIndex((elem) => {
|
236
|
+
const treeViewItemIndex = this._collection.indexOfKey(elem.name);
|
237
|
+
return newItemIndex < treeViewItemIndex;
|
238
|
+
});
|
239
|
+
if (positionInChildren >= 0) {
|
240
|
+
this._listItems.value.splice(positionInChildren, 0, listItem);
|
241
|
+
} else {
|
242
|
+
this._listItems.value.push(listItem);
|
243
|
+
}
|
244
|
+
}
|
245
|
+
} else {
|
246
|
+
this._listItems.value.push(listItem);
|
247
|
+
}
|
248
|
+
}
|
249
|
+
}
|
250
|
+
|
251
|
+
/**
|
252
|
+
* synchronizes the category items with the internal items list.
|
253
|
+
* @param {T} item
|
254
|
+
* @template T
|
255
|
+
* @private
|
256
|
+
*/
|
257
|
+
_handleItemAdded(item) {
|
258
|
+
if (
|
259
|
+
this._itemFilters.every(({ filterFunction }) =>
|
260
|
+
filterFunction(item, this),
|
261
|
+
)
|
262
|
+
) {
|
263
|
+
const listItem = this._transformItem(item);
|
264
|
+
this._insertListItem(listItem);
|
265
|
+
}
|
266
|
+
}
|
267
|
+
|
268
|
+
/**
|
269
|
+
* synchronizes the order of the list items with respect to the order of the items in the collection.
|
270
|
+
* removes and reinserts the moved item.
|
271
|
+
* @param {T} item
|
272
|
+
* @template T
|
273
|
+
* @private
|
274
|
+
*/
|
275
|
+
_handleItemMoved(item) {
|
276
|
+
if (
|
277
|
+
this._itemFilters.every(({ filterFunction }) =>
|
278
|
+
filterFunction(item, this),
|
279
|
+
)
|
280
|
+
) {
|
281
|
+
const index = this._listItems.value.findIndex((elem) => {
|
282
|
+
return elem.name === item[this._collection.uniqueKey];
|
283
|
+
});
|
284
|
+
if (index > -1) {
|
285
|
+
const listItem = this._listItems.value[index];
|
286
|
+
this._listItems.value.splice(index, 1);
|
287
|
+
this._insertListItem(listItem);
|
288
|
+
}
|
289
|
+
}
|
290
|
+
}
|
291
|
+
|
292
|
+
/**
|
293
|
+
* synchronizes the collection items with the internal list items.
|
294
|
+
* @param {T} item
|
295
|
+
* @template T
|
296
|
+
* @private
|
297
|
+
*/
|
298
|
+
_handleItemRemoved(item) {
|
299
|
+
const index = this._listItems.value.findIndex((elem) => {
|
300
|
+
return elem.name === item[this._collection.uniqueKey];
|
301
|
+
});
|
302
|
+
if (index > -1) {
|
303
|
+
const listItem = this._listItems.value[index];
|
304
|
+
if (listItem.destroy) {
|
305
|
+
listItem.destroy();
|
306
|
+
}
|
307
|
+
this._listItems.value.splice(index, 1);
|
308
|
+
}
|
309
|
+
}
|
310
|
+
|
311
|
+
/**
|
312
|
+
* recreates the items array with the new Mapping Function
|
313
|
+
* @param {ItemMapping} itemMapping
|
314
|
+
*/
|
315
|
+
addItemMapping(itemMapping) {
|
316
|
+
if (
|
317
|
+
!this._itemMappings.find(({ mappingFunction, owner }) => {
|
318
|
+
return (
|
319
|
+
itemMapping.mappingFunction === mappingFunction &&
|
320
|
+
itemMapping.owner === owner
|
321
|
+
);
|
322
|
+
})
|
323
|
+
) {
|
324
|
+
this._itemMappings.push(itemMapping);
|
325
|
+
this.reset();
|
326
|
+
}
|
327
|
+
}
|
328
|
+
|
329
|
+
/**
|
330
|
+
* recreates the items array with the new Mapping Function
|
331
|
+
* @param {ItemMapping} itemMapping
|
332
|
+
*/
|
333
|
+
removeItemMapping(itemMapping) {
|
334
|
+
const index = this._itemMappings.findIndex(({ mappingFunction, owner }) => {
|
335
|
+
return (
|
336
|
+
itemMapping.mappingFunction === mappingFunction &&
|
337
|
+
itemMapping.owner === owner
|
338
|
+
);
|
339
|
+
});
|
340
|
+
if (index > -1) {
|
341
|
+
this._itemMappings.splice(index, 1);
|
342
|
+
this.reset();
|
343
|
+
}
|
344
|
+
}
|
345
|
+
|
346
|
+
/**
|
347
|
+
* recreates the items array with the new Filter Function
|
348
|
+
* @param {ItemFilter} itemFilter
|
349
|
+
*/
|
350
|
+
addItemFilter(itemFilter) {
|
351
|
+
if (
|
352
|
+
!this._itemFilters.find(({ filterFunction, owner }) => {
|
353
|
+
return (
|
354
|
+
itemFilter.filterFunction === filterFunction &&
|
355
|
+
itemFilter.owner === owner
|
356
|
+
);
|
357
|
+
})
|
358
|
+
) {
|
359
|
+
this._itemFilters.push(itemFilter);
|
360
|
+
this.reset();
|
361
|
+
}
|
362
|
+
}
|
363
|
+
|
364
|
+
/**
|
365
|
+
* recreates the items array with the new Filter Function
|
366
|
+
* @param {ItemFilter} itemFilter
|
367
|
+
*/
|
368
|
+
removeItemFilter(itemFilter) {
|
369
|
+
const index = this._itemFilters.findIndex(({ filterFunction, owner }) => {
|
370
|
+
return (
|
371
|
+
itemFilter.filterFunction === filterFunction &&
|
372
|
+
itemFilter.owner === owner
|
373
|
+
);
|
374
|
+
});
|
375
|
+
if (index > -1) {
|
376
|
+
this._itemFilters.splice(index, 1);
|
377
|
+
this.reset();
|
378
|
+
}
|
379
|
+
}
|
380
|
+
|
381
|
+
/**
|
382
|
+
* @param {Array<OwnedAction>} ownedActions
|
383
|
+
*/
|
384
|
+
addActions(ownedActions) {
|
385
|
+
const actions = [...this._actions.value, ...ownedActions];
|
386
|
+
this._actions.value = actions
|
387
|
+
.filter((item, pos, self) => {
|
388
|
+
return self.indexOf(item) === pos;
|
389
|
+
})
|
390
|
+
.sort(sortByWeight);
|
391
|
+
}
|
392
|
+
|
393
|
+
/**
|
394
|
+
* @param {Array<OwnedAction>} ownedActions
|
395
|
+
*/
|
396
|
+
removeActions(ownedActions) {
|
397
|
+
this._actions.value = this._actions.value.filter((ownedAction) => {
|
398
|
+
return !ownedActions.includes(ownedAction);
|
399
|
+
});
|
400
|
+
}
|
401
|
+
|
402
|
+
/**
|
403
|
+
* removes itemMapping, itemFilter and actions of provided owner and resets all list items
|
404
|
+
* @param {string | symbol} owner
|
405
|
+
*/
|
406
|
+
removeOwner(owner) {
|
407
|
+
const itemMappings = this._itemMappings.filter((itemMapping) => {
|
408
|
+
return itemMapping.owner !== owner;
|
409
|
+
});
|
410
|
+
const itemFilters = this._itemFilters.filter((itemFilter) => {
|
411
|
+
return itemFilter.owner !== owner;
|
412
|
+
});
|
413
|
+
const actions = this._actions.value.filter(
|
414
|
+
(ownedAction) => ownedAction.owner !== owner,
|
415
|
+
);
|
416
|
+
if (
|
417
|
+
itemMappings.length < this._itemMappings.length ||
|
418
|
+
itemFilters.length < this._itemFilters.length
|
419
|
+
) {
|
420
|
+
this.reset();
|
421
|
+
}
|
422
|
+
this._itemMappings = itemMappings;
|
423
|
+
this._itemFilters = itemFilters;
|
424
|
+
this._actions.value = actions;
|
425
|
+
}
|
426
|
+
|
427
|
+
/**
|
428
|
+
* resets this collection component by destroying all list items and
|
429
|
+
* re-adding them from the collection applying current filter and mapping functions
|
430
|
+
*/
|
431
|
+
reset() {
|
432
|
+
this._listItems.value.forEach((i) => i.destroy?.());
|
433
|
+
this._listItems.value = [];
|
434
|
+
this.selection.value = [];
|
435
|
+
[...this._collection]
|
436
|
+
.filter((item) =>
|
437
|
+
this._itemFilters.every(({ filterFunction }) =>
|
438
|
+
filterFunction(item, this),
|
439
|
+
),
|
440
|
+
)
|
441
|
+
.map((item) => this._transformItem(item))
|
442
|
+
.forEach((listItem) => this._listItems.value.push(listItem));
|
443
|
+
}
|
444
|
+
|
445
|
+
destroy() {
|
446
|
+
this._listeners.forEach((cb) => cb());
|
447
|
+
this._listItems.value.forEach((i) => i.destroy?.());
|
448
|
+
this._listItems.value = [];
|
449
|
+
this.selection.value = [];
|
450
|
+
}
|
451
|
+
}
|
452
|
+
|
453
|
+
export default CollectionComponent;
|