@vcmap/ui 5.0.0-rc.24 → 5.0.0-rc.25
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.1457fa.js} +58656 -33170
- package/dist/assets/cesium.js +1 -1
- package/dist/assets/core.47836f.js +19060 -0
- package/dist/assets/core.js +1 -1
- package/dist/assets/index-bb372634.js +1 -0
- package/dist/assets/{ol.1c946a.js → ol.9e4d23.js} +27344 -12118
- package/dist/assets/ol.js +1 -1
- package/dist/assets/ui.6ed89d.css +5 -0
- package/dist/assets/ui.6ed89d.js +13461 -0
- package/dist/assets/ui.js +1 -1
- package/dist/assets/{vue.c1ece7.js → vue.7327e4.js} +834 -598
- package/dist/assets/vue.js +2 -2
- package/dist/assets/{vuetify.6efa21.css → vuetify.d2131d.css} +1 -1
- package/dist/assets/{vuetify.6efa21.js → vuetify.d2131d.js} +343 -103
- package/dist/assets/vuetify.js +2 -2
- package/dist/index.html +7 -6
- package/index.html +14 -6
- package/index.js +17 -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/public/assets/logo-mobile.svg +9 -0
- package/public/assets/logo.svg +26 -0
- package/src/application/VcsApp.vue +34 -5
- package/src/application/VcsAttributions.vue +20 -5
- package/src/application/VcsAttributionsFooter.vue +0 -1
- package/src/application/VcsNavbar.vue +18 -13
- 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 +2 -4
- 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/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 +2 -2
- 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/assets/logo-mobile.svg → dist/assets/logo-mobile.2d10a6.svg} +0 -0
- /package/{src/assets/logo.svg → dist/assets/logo.27089a.svg} +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
@@ -1,633 +0,0 @@
|
|
1
|
-
import { reactive } from 'vue';
|
2
|
-
import { moduleIdSymbol, IndexedCollection, VcsEvent } from '@vcmap/core';
|
3
|
-
import { check } from '@vcsuite/check';
|
4
|
-
import { sortByOwner } from '../navbarManager.js';
|
5
|
-
import {
|
6
|
-
validateAction,
|
7
|
-
validateActions,
|
8
|
-
} from '../../components/lists/VcsActionList.vue';
|
9
|
-
|
10
|
-
/**
|
11
|
-
* @callback MappingFunction
|
12
|
-
* @param {T} item
|
13
|
-
* @param {import("@vcmap/core").Category<T>} category
|
14
|
-
* @param {import("@vcmap/ui").VcsListItem & { destroy: (function():void)|undefined }} listItem - you can add a destroy callback for cleanup
|
15
|
-
* @template {Object} T
|
16
|
-
*/
|
17
|
-
|
18
|
-
/**
|
19
|
-
* @callback PredicateFunction
|
20
|
-
* @param {T} item
|
21
|
-
* @param {import("@vcmap/core").Category<T>} category
|
22
|
-
* @returns {boolean}
|
23
|
-
* @template {Object} T
|
24
|
-
*/
|
25
|
-
|
26
|
-
/**
|
27
|
-
* @typedef {Object} ItemMapping
|
28
|
-
* @property {MappingFunction<T>} mappingFunction
|
29
|
-
* @property {PredicateFunction<T>} predicate
|
30
|
-
* @property {Array<string>} categoryNames
|
31
|
-
* @property {string | symbol} owner
|
32
|
-
* @template T
|
33
|
-
*/
|
34
|
-
|
35
|
-
/**
|
36
|
-
* @typedef {Object} ManagedCategory
|
37
|
-
* @property {string} categoryName
|
38
|
-
* @property {string} title
|
39
|
-
* @property {Array<VcsAction>} actions
|
40
|
-
* @property {Array<VcsListItem & { destroy: (function():void|undefined) }>} items
|
41
|
-
* @property {boolean} draggable
|
42
|
-
* @property {boolean} selectable
|
43
|
-
* @property {boolean} singleSelect
|
44
|
-
* @property {Array<VcsListItem>} selection
|
45
|
-
* @property {function():void} destroy - called when the item is destroyed. do not call yourself, remove the category from the manager
|
46
|
-
*/
|
47
|
-
|
48
|
-
/**
|
49
|
-
* @typedef {Object} ManagedCategoryOptions
|
50
|
-
* @property {string} categoryName
|
51
|
-
* @property {boolean} [draggable] - only allowed for categories with underlying IndexedCollections
|
52
|
-
* @property {boolean} [selectable]
|
53
|
-
* @property {boolean} [singleSelect]
|
54
|
-
* @property {Array<VcsAction>} [actions]
|
55
|
-
*/
|
56
|
-
|
57
|
-
/**
|
58
|
-
* uses the itemMappings to transform the given Item to an VcsListItem usable in the VcsList
|
59
|
-
* @param {T} item
|
60
|
-
* @param {import("@vcmap/core").Category<T>} category
|
61
|
-
* @param {Array<ItemMapping<T>>} itemMappings
|
62
|
-
* @returns {import("@vcmap/ui").VcsListItem & { destroy: (function():void)|undefined }}
|
63
|
-
* @template T
|
64
|
-
* @private
|
65
|
-
*/
|
66
|
-
function transformItem(item, category, itemMappings) {
|
67
|
-
const keyProperty = category.collection.uniqueKey;
|
68
|
-
const listItem = {
|
69
|
-
get id() {
|
70
|
-
return item[keyProperty];
|
71
|
-
},
|
72
|
-
title: item?.properties?.title || item[keyProperty],
|
73
|
-
actions: [],
|
74
|
-
};
|
75
|
-
itemMappings.forEach((itemMapping) => {
|
76
|
-
if (itemMapping.predicate(item, category)) {
|
77
|
-
itemMapping.mappingFunction(item, category, listItem);
|
78
|
-
}
|
79
|
-
});
|
80
|
-
listItem.actions = listItem.actions.filter((action) => {
|
81
|
-
return validateAction(action);
|
82
|
-
});
|
83
|
-
return listItem;
|
84
|
-
}
|
85
|
-
|
86
|
-
/**
|
87
|
-
* Inserts the item into the items array at the correct relative position in respect to the position of the item
|
88
|
-
* in the collection
|
89
|
-
* @param {import("@vcmap/ui").VcsListItem} item
|
90
|
-
* @param {import("@vcmap/core").Collection} collection
|
91
|
-
* @param {Array<import("@vcmap/ui").VcsListItem>} items
|
92
|
-
* @private
|
93
|
-
*/
|
94
|
-
function insertItem(item, collection, items) {
|
95
|
-
if (collection instanceof IndexedCollection) {
|
96
|
-
const newItemIndex = collection.indexOfKey(item.id);
|
97
|
-
if (newItemIndex === collection.size - 1) {
|
98
|
-
items.push(item);
|
99
|
-
} else {
|
100
|
-
const positionInChildren = items.findIndex((listItem) => {
|
101
|
-
const treeViewItemIndex = collection.indexOfKey(listItem.id);
|
102
|
-
return newItemIndex < treeViewItemIndex;
|
103
|
-
});
|
104
|
-
if (positionInChildren >= 0) {
|
105
|
-
items.splice(positionInChildren, 0, item);
|
106
|
-
} else {
|
107
|
-
items.push(item);
|
108
|
-
}
|
109
|
-
}
|
110
|
-
} else {
|
111
|
-
items.push(item);
|
112
|
-
}
|
113
|
-
}
|
114
|
-
|
115
|
-
/**
|
116
|
-
* @param {ManagedCategoryOptions} current
|
117
|
-
* @param {ManagedCategoryOptions} next
|
118
|
-
* @returns {ManagedCategoryOptions}
|
119
|
-
*/
|
120
|
-
function reduceCategoryOptions(current, next) {
|
121
|
-
if (next.actions?.length > 0) {
|
122
|
-
current.actions.push(...next.actions);
|
123
|
-
}
|
124
|
-
current.draggable = current.draggable ?? next.draggable;
|
125
|
-
current.selectable = current.selectable ?? next.selectable;
|
126
|
-
current.singleSelect = current.singleSelect ?? next.singleSelect;
|
127
|
-
return current;
|
128
|
-
}
|
129
|
-
|
130
|
-
/**
|
131
|
-
* a categoryManager manages categories, and synchronizes a tree of VcsTreeView Items.
|
132
|
-
* provides an API to add/remove Categories.
|
133
|
-
* @implements {VcsComponentManager<ManagedCategory, ManagedCategoryOptions>}
|
134
|
-
*/
|
135
|
-
class CategoryManager {
|
136
|
-
/**
|
137
|
-
* @param {import("@vcmap/ui").VcsUiApp} app
|
138
|
-
*/
|
139
|
-
constructor(app) {
|
140
|
-
/**
|
141
|
-
* @type {import("@vcmap/ui").VcsUiApp}
|
142
|
-
* @private
|
143
|
-
*/
|
144
|
-
this._app = app;
|
145
|
-
|
146
|
-
/**
|
147
|
-
* @type {Map<string, Map<string|symbol, ManagedCategoryOptions>>}
|
148
|
-
* @private
|
149
|
-
*/
|
150
|
-
this._managedCategoryOptions = new Map();
|
151
|
-
|
152
|
-
/**
|
153
|
-
* @type {function():void}
|
154
|
-
* @private
|
155
|
-
*/
|
156
|
-
this._dynamicModuleIdListener =
|
157
|
-
this._app.dynamicModuleIdChanged.addEventListener((id) => {
|
158
|
-
this._dynamicModuleId = id;
|
159
|
-
this._resetManagedCategories();
|
160
|
-
});
|
161
|
-
|
162
|
-
/**
|
163
|
-
* @type {function():void}
|
164
|
-
* @private
|
165
|
-
*/
|
166
|
-
this._appCategoriesRemovedListener =
|
167
|
-
this._app.categories.removed.addEventListener((category) => {
|
168
|
-
this._removeCategory(category.name);
|
169
|
-
});
|
170
|
-
|
171
|
-
/**
|
172
|
-
* @type {string}
|
173
|
-
* @private
|
174
|
-
*/
|
175
|
-
this._dynamicModuleId = this._app.dynamicModuleId;
|
176
|
-
|
177
|
-
/**
|
178
|
-
* @type {Array<ItemMapping<*>>}
|
179
|
-
* @private
|
180
|
-
*/
|
181
|
-
this._itemMappings = [];
|
182
|
-
/**
|
183
|
-
* @type {Map<string, ManagedCategory>}
|
184
|
-
* @private
|
185
|
-
*/
|
186
|
-
this._managedCategories = new Map();
|
187
|
-
/**
|
188
|
-
* @type {Array<string>}
|
189
|
-
*/
|
190
|
-
this.componentIds = [];
|
191
|
-
/**
|
192
|
-
* @type {VcsEvent<ManagedCategory>}
|
193
|
-
*/
|
194
|
-
this.added = new VcsEvent();
|
195
|
-
/**
|
196
|
-
* @type {VcsEvent<ManagedCategory>}
|
197
|
-
*/
|
198
|
-
this.removed = new VcsEvent();
|
199
|
-
}
|
200
|
-
|
201
|
-
/**
|
202
|
-
* synchronizes the category items with the internal items list.
|
203
|
-
* @param {T} item
|
204
|
-
* @param {import("@vcmap/core").Category<T>} category
|
205
|
-
* @template T
|
206
|
-
* @private
|
207
|
-
*/
|
208
|
-
_handleItemAdded(item, category) {
|
209
|
-
const itemMappings = this._itemMappings.filter((itemMapping) => {
|
210
|
-
return itemMapping.categoryNames.includes(category.name);
|
211
|
-
});
|
212
|
-
const listItem = transformItem(item, category, itemMappings);
|
213
|
-
const managedCategory = this.get(category.name);
|
214
|
-
if (managedCategory) {
|
215
|
-
insertItem(listItem, category.collection, managedCategory.items);
|
216
|
-
}
|
217
|
-
}
|
218
|
-
|
219
|
-
/**
|
220
|
-
* synchronizes the order of the treeViewItems with respect to the order of the items in the collection.
|
221
|
-
* removes and reinserts the moved item.
|
222
|
-
* @param {T} item
|
223
|
-
* @param {import("@vcmap/core").Category<T>} category
|
224
|
-
* @template T
|
225
|
-
* @private
|
226
|
-
*/
|
227
|
-
_handleItemMoved(item, category) {
|
228
|
-
const managedCategory = this.get(category.name);
|
229
|
-
if (managedCategory) {
|
230
|
-
const index = managedCategory.items.findIndex((elem) => {
|
231
|
-
return elem.id === item[category.collection.uniqueKey];
|
232
|
-
});
|
233
|
-
if (index > -1) {
|
234
|
-
const listItem = managedCategory.items[index];
|
235
|
-
managedCategory.items.splice(index, 1);
|
236
|
-
insertItem(listItem, category.collection, managedCategory.items);
|
237
|
-
}
|
238
|
-
}
|
239
|
-
}
|
240
|
-
|
241
|
-
/**
|
242
|
-
* synchronizes the category items with the internal items list.
|
243
|
-
* @param {T} item
|
244
|
-
* @param {import("@vcmap/core").Category<T>} category
|
245
|
-
* @template T
|
246
|
-
* @private
|
247
|
-
*/
|
248
|
-
_handleItemRemoved(item, category) {
|
249
|
-
const managedCategory = this.get(category.name);
|
250
|
-
if (managedCategory) {
|
251
|
-
const index = managedCategory.items.findIndex((elem) => {
|
252
|
-
return elem.id === item[category.collection.uniqueKey];
|
253
|
-
});
|
254
|
-
if (index > -1) {
|
255
|
-
const listItem = managedCategory.items[index];
|
256
|
-
if (listItem.destroy) {
|
257
|
-
listItem.destroy();
|
258
|
-
}
|
259
|
-
managedCategory.items.splice(index, 1);
|
260
|
-
}
|
261
|
-
}
|
262
|
-
}
|
263
|
-
|
264
|
-
/**
|
265
|
-
* removes all items from all categories and rebuilds the item tree depending on the ModuleId
|
266
|
-
* @private
|
267
|
-
*/
|
268
|
-
_resetManagedCategories() {
|
269
|
-
this._managedCategoryOptions.forEach((value, categoryName) => {
|
270
|
-
this._resetCategoryItems(categoryName);
|
271
|
-
});
|
272
|
-
}
|
273
|
-
|
274
|
-
/**
|
275
|
-
* @param {string} categoryName
|
276
|
-
* @private
|
277
|
-
*/
|
278
|
-
_resetCategoryItems(categoryName) {
|
279
|
-
const category = this._app.categories.getByKey(categoryName);
|
280
|
-
const managedCategory = this.get(categoryName);
|
281
|
-
|
282
|
-
if (category && managedCategory) {
|
283
|
-
const itemMappings = this._itemMappings.filter((itemMapping) => {
|
284
|
-
return itemMapping.categoryNames.includes(categoryName);
|
285
|
-
});
|
286
|
-
if (managedCategory.selection.length > 0) {
|
287
|
-
managedCategory.selection = [];
|
288
|
-
}
|
289
|
-
managedCategory.items.forEach((item) => {
|
290
|
-
if (item.destroy) {
|
291
|
-
item.destroy();
|
292
|
-
}
|
293
|
-
});
|
294
|
-
managedCategory.items = [...category.collection]
|
295
|
-
.filter((item) => {
|
296
|
-
return item[moduleIdSymbol] === this._dynamicModuleId;
|
297
|
-
})
|
298
|
-
.map((item) => {
|
299
|
-
return transformItem(item, category, itemMappings);
|
300
|
-
});
|
301
|
-
}
|
302
|
-
}
|
303
|
-
|
304
|
-
/**
|
305
|
-
* create the managed category
|
306
|
-
* @param {string} categoryName
|
307
|
-
* @returns {ManagedCategory}
|
308
|
-
* @private
|
309
|
-
*/
|
310
|
-
_createManagedCategory(categoryName) {
|
311
|
-
const category = this._app.categories.getByKey(categoryName);
|
312
|
-
if (!category) {
|
313
|
-
throw new Error(`Could not find Category: ${categoryName}`);
|
314
|
-
}
|
315
|
-
|
316
|
-
const options = [
|
317
|
-
...this._managedCategoryOptions.get(category.name).values(),
|
318
|
-
] // does not have to be sorted, since this is the first owner
|
319
|
-
.reduce(reduceCategoryOptions, { actions: [] });
|
320
|
-
|
321
|
-
const listeners = [
|
322
|
-
category.collection.added.addEventListener((item) => {
|
323
|
-
if (item[moduleIdSymbol] === this._dynamicModuleId) {
|
324
|
-
this._handleItemAdded(item, category);
|
325
|
-
}
|
326
|
-
}),
|
327
|
-
category.collection.removed.addEventListener((item) => {
|
328
|
-
if (item[moduleIdSymbol] === this._dynamicModuleId) {
|
329
|
-
this._handleItemRemoved(item, category);
|
330
|
-
}
|
331
|
-
}),
|
332
|
-
category.collection.replaced.addEventListener((replacedEvent) => {
|
333
|
-
if (replacedEvent.old[moduleIdSymbol] === this._dynamicModuleId) {
|
334
|
-
this._handleItemRemoved(replacedEvent.old, category);
|
335
|
-
}
|
336
|
-
}),
|
337
|
-
];
|
338
|
-
|
339
|
-
if (category.collection instanceof IndexedCollection) {
|
340
|
-
listeners.push(
|
341
|
-
category.collection.moved.addEventListener((item) => {
|
342
|
-
if (item[moduleIdSymbol] === this._dynamicModuleId) {
|
343
|
-
this._handleItemMoved(item, category);
|
344
|
-
}
|
345
|
-
}),
|
346
|
-
);
|
347
|
-
}
|
348
|
-
|
349
|
-
/** @type {ManagedCategory} */
|
350
|
-
const managedCategory = reactive({
|
351
|
-
...options,
|
352
|
-
get categoryName() {
|
353
|
-
return category.name;
|
354
|
-
},
|
355
|
-
selection: [],
|
356
|
-
title: category.title,
|
357
|
-
items: [],
|
358
|
-
destroy() {
|
359
|
-
listeners.forEach((cb) => {
|
360
|
-
cb();
|
361
|
-
});
|
362
|
-
this.items.forEach((item) => {
|
363
|
-
if (item.destroy) {
|
364
|
-
item.destroy();
|
365
|
-
}
|
366
|
-
});
|
367
|
-
this.items = [];
|
368
|
-
},
|
369
|
-
});
|
370
|
-
|
371
|
-
this._managedCategories.set(categoryName, managedCategory);
|
372
|
-
this._resetCategoryItems(categoryName);
|
373
|
-
this.componentIds.push(categoryName);
|
374
|
-
this.added.raiseEvent(managedCategory);
|
375
|
-
|
376
|
-
return managedCategory;
|
377
|
-
}
|
378
|
-
|
379
|
-
/**
|
380
|
-
* updates the managed categorys actions
|
381
|
-
* @param {string} categoryName
|
382
|
-
* @private
|
383
|
-
*/
|
384
|
-
_updateCategory(categoryName) {
|
385
|
-
if (this._managedCategoryOptions.has(categoryName)) {
|
386
|
-
const managedCategory = this.get(categoryName);
|
387
|
-
if (managedCategory) {
|
388
|
-
const pluginNames = [...this._app.plugins].map((p) => p.name);
|
389
|
-
const options = [
|
390
|
-
...this._managedCategoryOptions.get(categoryName).entries(),
|
391
|
-
]
|
392
|
-
.sort(([ownerA], [ownerB]) =>
|
393
|
-
sortByOwner(ownerA, ownerB, pluginNames),
|
394
|
-
)
|
395
|
-
.map(([, value]) => value)
|
396
|
-
.reduce(reduceCategoryOptions, { actions: [] });
|
397
|
-
Object.assign(managedCategory, options);
|
398
|
-
}
|
399
|
-
}
|
400
|
-
}
|
401
|
-
|
402
|
-
/**
|
403
|
-
* @param {string} categoryName
|
404
|
-
* @returns {ManagedCategory|undefined}
|
405
|
-
*/
|
406
|
-
get(categoryName) {
|
407
|
-
return this._managedCategories.get(categoryName);
|
408
|
-
}
|
409
|
-
|
410
|
-
/**
|
411
|
-
* @param {string} categoryName
|
412
|
-
* @returns {boolean}
|
413
|
-
*/
|
414
|
-
has(categoryName) {
|
415
|
-
return this._managedCategories.has(categoryName);
|
416
|
-
}
|
417
|
-
|
418
|
-
/**
|
419
|
-
* adds a category to this manager, the category will be shown in the components window.
|
420
|
-
* If a category has been added by several owners the actions will be merged and sorted by the order of the
|
421
|
-
* owner in the app.plugins collection.
|
422
|
-
* @param {ManagedCategoryOptions} managedCategoryOptions
|
423
|
-
* @param {string|symbol} owner
|
424
|
-
* @returns {ManagedCategory}
|
425
|
-
*/
|
426
|
-
add(managedCategoryOptions, owner) {
|
427
|
-
check(managedCategoryOptions, { categoryName: String });
|
428
|
-
check(owner, [String, Symbol]);
|
429
|
-
|
430
|
-
const { categoryName } = managedCategoryOptions;
|
431
|
-
if (
|
432
|
-
managedCategoryOptions.actions &&
|
433
|
-
!validateActions(managedCategoryOptions.actions)
|
434
|
-
) {
|
435
|
-
throw new Error('Invalid actions Array');
|
436
|
-
}
|
437
|
-
if (!this._app.categories.hasKey(categoryName)) {
|
438
|
-
throw new Error(`Could not find category: ${categoryName}`);
|
439
|
-
}
|
440
|
-
|
441
|
-
if (this._managedCategoryOptions.get(categoryName)?.has(owner)) {
|
442
|
-
throw new Error(
|
443
|
-
`Category has already been added by this owner: ${categoryName}, ${owner}`,
|
444
|
-
);
|
445
|
-
}
|
446
|
-
if (managedCategoryOptions.draggable) {
|
447
|
-
const { collection } = this._app.categories.getByKey(categoryName);
|
448
|
-
managedCategoryOptions.draggable =
|
449
|
-
collection instanceof IndexedCollection;
|
450
|
-
}
|
451
|
-
|
452
|
-
/** @type {ManagedCategoryOptions} */
|
453
|
-
const clonedOptions = {
|
454
|
-
categoryName,
|
455
|
-
actions: managedCategoryOptions.actions?.slice?.() ?? [],
|
456
|
-
draggable: managedCategoryOptions.draggable,
|
457
|
-
selectable: managedCategoryOptions.selectable,
|
458
|
-
singleSelect: managedCategoryOptions.singleSelect,
|
459
|
-
};
|
460
|
-
|
461
|
-
if (!this._managedCategoryOptions.has(categoryName)) {
|
462
|
-
const managedCategory = new Map();
|
463
|
-
managedCategory.set(owner, clonedOptions);
|
464
|
-
this._managedCategoryOptions.set(categoryName, managedCategory);
|
465
|
-
return this._createManagedCategory(categoryName);
|
466
|
-
} else {
|
467
|
-
this._managedCategoryOptions.get(categoryName).set(owner, clonedOptions);
|
468
|
-
this._updateCategory(categoryName);
|
469
|
-
return this.get(categoryName);
|
470
|
-
}
|
471
|
-
}
|
472
|
-
|
473
|
-
/**
|
474
|
-
* removes a category for a specific owner from this manager
|
475
|
-
* @param {string} categoryName
|
476
|
-
* @param {string|symbol} owner
|
477
|
-
*/
|
478
|
-
remove(categoryName, owner) {
|
479
|
-
check(categoryName, String);
|
480
|
-
check(owner, [String, Symbol]);
|
481
|
-
if (!this._managedCategoryOptions.has(categoryName)) {
|
482
|
-
return;
|
483
|
-
}
|
484
|
-
this._managedCategoryOptions.get(categoryName).delete(owner);
|
485
|
-
if (this._managedCategoryOptions.get(categoryName).size > 0) {
|
486
|
-
this._updateCategory(categoryName);
|
487
|
-
} else {
|
488
|
-
this._removeCategory(categoryName);
|
489
|
-
}
|
490
|
-
}
|
491
|
-
|
492
|
-
/**
|
493
|
-
* removes a Category from management, removes all Listeners, and updates the listItems
|
494
|
-
* @param {string} categoryName
|
495
|
-
* @private
|
496
|
-
*/
|
497
|
-
_removeCategory(categoryName) {
|
498
|
-
const managedCategory = this.get(categoryName);
|
499
|
-
this._managedCategoryOptions.delete(categoryName);
|
500
|
-
const index = this.componentIds.indexOf(categoryName);
|
501
|
-
if (index > -1) {
|
502
|
-
this.componentIds.splice(index, 1);
|
503
|
-
}
|
504
|
-
if (managedCategory) {
|
505
|
-
this._managedCategories.delete(categoryName);
|
506
|
-
managedCategory.destroy();
|
507
|
-
this.removed.raiseEvent(managedCategory);
|
508
|
-
}
|
509
|
-
}
|
510
|
-
|
511
|
-
/**
|
512
|
-
* adds MappingFunction to the categoryManager. For the given categoryNames each Item will be transformed by the
|
513
|
-
* mappingFunction if the predicate returns true.
|
514
|
-
* @param {PredicateFunction} predicate
|
515
|
-
* @param {MappingFunction} mappingFunction
|
516
|
-
* @param {Array<string>} categoryNames list of categories this mappingFunction should be used on
|
517
|
-
* @param {string | symbol} owner
|
518
|
-
*/
|
519
|
-
addMappingFunction(predicate, mappingFunction, categoryNames, owner) {
|
520
|
-
check(predicate, Function);
|
521
|
-
check(mappingFunction, Function);
|
522
|
-
check(categoryNames, [String]);
|
523
|
-
check(owner, [String, Symbol]);
|
524
|
-
if (categoryNames.length === 0) {
|
525
|
-
throw new Error('Provide at least one categoryName');
|
526
|
-
}
|
527
|
-
if (
|
528
|
-
this._itemMappings.find((itemMapping) => {
|
529
|
-
return (
|
530
|
-
itemMapping.mappingFunction === mappingFunction &&
|
531
|
-
itemMapping.owner === owner
|
532
|
-
);
|
533
|
-
})
|
534
|
-
) {
|
535
|
-
throw new Error(
|
536
|
-
'Could not add MappingFunction, the MappingFunction is already under management',
|
537
|
-
);
|
538
|
-
}
|
539
|
-
/** @type {ItemMapping} */
|
540
|
-
const itemMapping = {
|
541
|
-
predicate,
|
542
|
-
mappingFunction,
|
543
|
-
categoryNames: categoryNames.slice(),
|
544
|
-
owner,
|
545
|
-
};
|
546
|
-
this._itemMappings.push(itemMapping);
|
547
|
-
itemMapping.categoryNames.forEach((categoryName) => {
|
548
|
-
if (this._managedCategoryOptions.has(categoryName)) {
|
549
|
-
this._resetCategoryItems(categoryName);
|
550
|
-
}
|
551
|
-
});
|
552
|
-
}
|
553
|
-
|
554
|
-
/**
|
555
|
-
* removes the given mappingFunction
|
556
|
-
* @param {MappingFunction} mappingFunction
|
557
|
-
* @param {string | symbol} owner
|
558
|
-
*/
|
559
|
-
removeMappingFunction(mappingFunction, owner) {
|
560
|
-
check(mappingFunction, Function);
|
561
|
-
check(owner, [String, Symbol]);
|
562
|
-
const affectedCategories = [];
|
563
|
-
this._itemMappings = this._itemMappings.filter((itemMapping) => {
|
564
|
-
if (
|
565
|
-
itemMapping.mappingFunction === mappingFunction &&
|
566
|
-
itemMapping.owner === owner
|
567
|
-
) {
|
568
|
-
affectedCategories.push(...itemMapping.categoryNames);
|
569
|
-
return false;
|
570
|
-
}
|
571
|
-
return true;
|
572
|
-
});
|
573
|
-
new Set(affectedCategories).forEach((categoryName) => {
|
574
|
-
this._resetCategoryItems(categoryName);
|
575
|
-
});
|
576
|
-
}
|
577
|
-
|
578
|
-
/**
|
579
|
-
* removes managed categories and mappingFunctions belonging to the given owner.
|
580
|
-
* @param {string | symbol} owner
|
581
|
-
*/
|
582
|
-
removeOwner(owner) {
|
583
|
-
check(owner, [String, Symbol]);
|
584
|
-
const affectedCategories = [];
|
585
|
-
this._managedCategoryOptions.forEach((managedCategory, categoryName) => {
|
586
|
-
if (managedCategory.delete(owner)) {
|
587
|
-
affectedCategories.push(categoryName);
|
588
|
-
}
|
589
|
-
if (managedCategory.size === 0) {
|
590
|
-
this._managedCategoryOptions.delete(categoryName);
|
591
|
-
}
|
592
|
-
});
|
593
|
-
affectedCategories.forEach((categoryName) => {
|
594
|
-
if (this._managedCategoryOptions.has(categoryName)) {
|
595
|
-
this._updateCategory(categoryName);
|
596
|
-
} else {
|
597
|
-
this._removeCategory(categoryName);
|
598
|
-
}
|
599
|
-
});
|
600
|
-
this._itemMappings = this._itemMappings.filter((itemMapping) => {
|
601
|
-
return itemMapping.owner !== owner;
|
602
|
-
});
|
603
|
-
this._resetManagedCategories();
|
604
|
-
}
|
605
|
-
|
606
|
-
/**
|
607
|
-
* Clears the manager of all added categories and item mappings
|
608
|
-
*/
|
609
|
-
clear() {
|
610
|
-
[...this.componentIds].forEach((categoryName) => {
|
611
|
-
this._removeCategory(categoryName);
|
612
|
-
});
|
613
|
-
this._itemMappings = [];
|
614
|
-
}
|
615
|
-
|
616
|
-
/**
|
617
|
-
* destroys the categoryManager, removes all Listeners and clears all Managed Categories
|
618
|
-
*/
|
619
|
-
destroy() {
|
620
|
-
this._dynamicModuleIdListener();
|
621
|
-
this._appCategoriesRemovedListener();
|
622
|
-
this.componentIds = [];
|
623
|
-
this._managedCategories.forEach((item) => {
|
624
|
-
item.destroy();
|
625
|
-
});
|
626
|
-
this._managedCategories.clear();
|
627
|
-
this._managedCategoryOptions.clear();
|
628
|
-
this.added.destroy();
|
629
|
-
this.removed.destroy();
|
630
|
-
}
|
631
|
-
}
|
632
|
-
|
633
|
-
export default CategoryManager;
|
package/start.js
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
// to load a app.config.json containing a set of configs
|
2
|
-
import { initAppFromAppConfig } from '@vcmap/ui';
|
3
|
-
|
4
|
-
initAppFromAppConfig('#app', 'app.config.json');
|
5
|
-
|
6
|
-
// to load a single module (config)
|
7
|
-
// import { initAppFromModule } from '@vcmap/ui';
|
8
|
-
|
9
|
-
// initAppFromModule('#app', 'config/projects.config.json');
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|