qwc2 2025.10.9 → 2025.10.14
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/actions/display.js +30 -1
- package/actions/editing.js +22 -1
- package/actions/layerinfo.js +13 -1
- package/actions/layers.js +213 -3
- package/actions/localConfig.js +58 -1
- package/actions/locale.js +21 -1
- package/actions/locate.js +26 -1
- package/actions/logging.js +10 -1
- package/actions/map.js +105 -2
- package/actions/measurement.js +12 -1
- package/actions/processNotifications.js +37 -1
- package/actions/redlining.js +18 -1
- package/actions/redliningPick.js +12 -1
- package/actions/search.js +12 -1
- package/actions/serviceinfo.js +12 -1
- package/actions/task.js +55 -3
- package/actions/theme.js +339 -19
- package/actions/windows.js +164 -5
- package/components/AppMenu.js +435 -3
- package/components/AttributeForm.js +928 -32
- package/components/AttributeTableWidget.js +1105 -13
- package/components/AutoEditForm.js +189 -3
- package/components/CoordinateDisplayer.js +78 -2
- package/components/EditComboField.js +190 -6
- package/components/EditUploadField.js +315 -3
- package/components/ExportSelection.js +203 -2
- package/components/FullscreenSwitcher.js +90 -3
- package/components/Icon.js +81 -2
- package/components/IdentifyViewer.js +1161 -6
- package/components/ImportLayer.js +718 -20
- package/components/LayerInfoWindow.js +145 -2
- package/components/LinkFeatureForm.js +246 -5
- package/components/MapButton.js +88 -2
- package/components/MapSelection.js +287 -8
- package/components/MessageBar.js +68 -2
- package/components/NumericInputWindow.js +359 -2
- package/components/PickFeature.js +266 -2
- package/components/PluginsContainer.js +227 -8
- package/components/PrintSelection.js +620 -49
- package/components/ProcessNotifications.js +104 -2
- package/components/QtDesignerForm.js +1137 -18
- package/components/ResizeableWindow.js +591 -8
- package/components/SearchBox.js +1307 -20
- package/components/ServiceInfoWindow.js +107 -2
- package/components/SideBar.js +204 -4
- package/components/StandardApp.js +381 -20
- package/components/Swipeable.js +15 -1
- package/components/TaskBar.js +85 -2
- package/components/ThemeLayersListWindow.js +216 -4
- package/components/ThemeList.js +381 -7
- package/components/Toolbar.js +106 -2
- package/components/WindowManager.js +178 -2
- package/components/map/OlLayer.js +257 -6
- package/components/map/OlMap.js +405 -5
- package/components/map/layers/BingLayer.js +31 -2
- package/components/map/layers/GoogleLayer.js +222 -19
- package/components/map/layers/GraticuleLayer.js +21 -1
- package/components/map/layers/ImageLayer.js +15 -1
- package/components/map/layers/MVTLayer.js +52 -2
- package/components/map/layers/OSMLayer.js +24 -2
- package/components/map/layers/OverlayLayer.js +55 -3
- package/components/map/layers/VectorLayer.js +173 -8
- package/components/map/layers/WFSLayer.js +220 -6
- package/components/map/layers/WMSLayer.js +180 -6
- package/components/map/layers/WMTSLayer.js +67 -3
- package/components/map/layers/XYZLayer.js +24 -2
- package/components/map/layers/index.js +28 -1
- package/components/map3d/EditDataset3D.js +190 -3
- package/components/map3d/HeightProfile3D.js +402 -3
- package/components/map3d/ImportObjects3D.js +162 -2
- package/components/map3d/Map3D.js +1304 -38
- package/components/map3d/MapControls3D.js +392 -7
- package/components/map3d/SearchField3D.js +183 -11
- package/components/map3d/View3DSwitcher.js +98 -2
- package/components/map3d/drawtool/CreateTool3D.js +174 -4
- package/components/map3d/drawtool/EditTool3D.js +590 -6
- package/components/map3d/drawtool/NumericInput3D.js +336 -4
- package/components/map3d/layers/GeoTIFFLayer3D.js +15 -1
- package/components/map3d/layers/VectorLayer3D.js +53 -2
- package/components/map3d/layers/WFSLayer3D.js +109 -3
- package/components/map3d/layers/WMSLayer3D.js +70 -2
- package/components/map3d/layers/WMTSLayer3D.js +27 -3
- package/components/map3d/layers/index.js +14 -1
- package/components/map3d/utils/FirstPersonControls3D.js +423 -16
- package/components/map3d/utils/MiscUtils3D.js +221 -13
- package/components/map3d/utils/OrbitControls3D.js +176 -5
- package/components/map3d/utils/Tiles3DStyle.js +238 -9
- package/components/share/ShareLink.js +54 -2
- package/components/share/ShareQRCode.js +62 -2
- package/components/share/ShareSocials.js +125 -3
- package/components/timeline/FixedTimeline.js +236 -5
- package/components/timeline/InfiniteTimeline.js +347 -8
- package/components/timeline/TimelineFeaturesSlider.js +439 -5
- package/components/widgets/AccordeonWidget.js +96 -2
- package/components/widgets/ButtonBar.js +124 -2
- package/components/widgets/ColorButton.js +201 -3
- package/components/widgets/ComboBox.js +166 -2
- package/components/widgets/CopyButton.js +110 -2
- package/components/widgets/DateTimeInput.js +100 -3
- package/components/widgets/EditableSelect.js +230 -3
- package/components/widgets/FileSelector.js +128 -4
- package/components/widgets/Input.js +124 -2
- package/components/widgets/InputContainer.js +96 -2
- package/components/widgets/LayerCatalogWidget.js +219 -3
- package/components/widgets/MenuButton.js +157 -1
- package/components/widgets/ModalDialog.js +64 -2
- package/components/widgets/NavBar.js +119 -2
- package/components/widgets/NumberInput.js +226 -4
- package/components/widgets/PopupMenu.js +72 -1
- package/components/widgets/Primitives.js +6 -1
- package/components/widgets/ReCaptchaWidget.js +55 -1
- package/components/widgets/SearchWidget.js +255 -2
- package/components/widgets/Spinner.js +44 -2
- package/components/widgets/SuggestionInput.js +77 -2
- package/components/widgets/TextInput.js +308 -2
- package/components/widgets/ToggleSwitch.js +85 -2
- package/components/widgets/VectorLayerPicker.js +85 -3
- package/libs/openlayers.js +225 -5
- package/package.json +1 -1
- package/plugins/API.js +358 -15
- package/plugins/AttributeTable.js +109 -3
- package/plugins/Authentication.js +130 -5
- package/plugins/BackgroundSwitcher.js +218 -4
- package/plugins/Bookmark.js +289 -3
- package/plugins/BottomBar.js +298 -4
- package/plugins/CookiePopup.js +67 -3
- package/plugins/Cyclomedia.js +442 -5
- package/plugins/Editing.js +497 -9
- package/plugins/FeatureForm.js +366 -4
- package/plugins/FeatureSearch.js +458 -3
- package/plugins/GeometryDigitizer.js +664 -7
- package/plugins/HeightProfile.js +763 -15
- package/plugins/Help.js +102 -3
- package/plugins/HomeButton.js +80 -3
- package/plugins/Identify.js +543 -5
- package/plugins/LayerCatalog.js +215 -4
- package/plugins/LayerTree.js +1194 -6
- package/plugins/LocateButton.js +94 -3
- package/plugins/Map.js +320 -16
- package/plugins/MapCompare.js +94 -3
- package/plugins/MapCopyright.js +127 -5
- package/plugins/MapExport.js +613 -20
- package/plugins/MapFilter.js +868 -12
- package/plugins/MapInfoTooltip.js +277 -3
- package/plugins/MapLegend.js +253 -4
- package/plugins/MapTip.js +290 -4
- package/plugins/Measure.js +220 -4
- package/plugins/NewsPopup.js +137 -3
- package/plugins/OverviewMap.js +167 -7
- package/plugins/Panoramax.js +340 -2
- package/plugins/Portal.js +199 -4
- package/plugins/Print.js +1231 -15
- package/plugins/Redlining.js +750 -6
- package/plugins/Reports.js +332 -3
- package/plugins/Routing.js +1278 -15
- package/plugins/ScratchDrawing.js +173 -5
- package/plugins/Settings.js +241 -4
- package/plugins/Share.js +198 -3
- package/plugins/StartupMarker.js +84 -4
- package/plugins/TaskButton.js +88 -3
- package/plugins/ThemeSwitcher.js +164 -4
- package/plugins/TimeManager.js +971 -10
- package/plugins/TopBar.js +300 -7
- package/plugins/TourGuide.js +213 -2
- package/plugins/ValueTool.js +419 -4
- package/plugins/View3D.js +519 -14
- package/plugins/ZoomButtons.js +165 -3
- package/plugins/map/EditingSupport.js +199 -7
- package/plugins/map/LocateSupport.js +260 -4
- package/plugins/map/MeasurementSupport.js +216 -8
- package/plugins/map/RedliningPickSupport.js +201 -7
- package/plugins/map/RedliningSupport.js +726 -17
- package/plugins/map/SnapInteraction.js +101 -1
- package/plugins/map/SnapSupport.js +210 -2
- package/plugins/map/SnappingSupport.js +356 -17
- package/plugins/map3d/BackgroundSwitcher3D.js +44 -3
- package/plugins/map3d/BottomBar3D.js +118 -3
- package/plugins/map3d/Compare3D.js +422 -8
- package/plugins/map3d/Draw3D.js +353 -6
- package/plugins/map3d/ExportObjects3D.js +393 -18
- package/plugins/map3d/HideObjects3D.js +313 -12
- package/plugins/map3d/Identify3D.js +283 -12
- package/plugins/map3d/LayerTree3D.js +323 -3
- package/plugins/map3d/MapCopyright3D.js +128 -5
- package/plugins/map3d/MapExport3D.js +590 -10
- package/plugins/map3d/MapLight3D.js +553 -6
- package/plugins/map3d/Measure3D.js +571 -20
- package/plugins/map3d/OverviewMap3D.js +169 -3
- package/plugins/map3d/Settings3D.js +73 -3
- package/plugins/map3d/TopBar3D.js +207 -9
- package/plugins/redlining/RedliningBufferSupport.js +206 -3
- package/reducers/display.js +34 -2
- package/reducers/editing.js +68 -3
- package/reducers/index.js +9 -1
- package/reducers/layerinfo.js +26 -2
- package/reducers/layers.js +456 -9
- package/reducers/localConfig.js +122 -2
- package/reducers/locale.js +38 -2
- package/reducers/locate.js +40 -2
- package/reducers/map.js +176 -5
- package/reducers/measurement.js +42 -2
- package/reducers/processNotifications.js +49 -2
- package/reducers/redlining.js +50 -2
- package/reducers/redliningPick.js +27 -2
- package/reducers/search.js +20 -1
- package/reducers/serviceinfo.js +25 -2
- package/reducers/task.js +45 -2
- package/reducers/theme.js +51 -2
- package/reducers/windows.js +203 -2
- package/scripts/dist.sh +1 -1
- package/scripts/gen-plugin-docs.js +152 -2
- package/scripts/makeIconkit.js +85 -6
- package/scripts/themesConfig.js +742 -40
- package/scripts/updateTranslations.js +251 -10
- package/selectors/searchproviders.js +44 -2
- package/stores/StandardStore.js +42 -2
- package/utils/ConfigUtils.js +84 -3
- package/utils/CoordinatesUtils.js +234 -23
- package/utils/DxfUtils.js +237 -11
- package/utils/EditingInterface.js +421 -87
- package/utils/EditingUtils.js +357 -13
- package/utils/ElevationInterface.js +83 -22
- package/utils/FeatureStyles.js +429 -5
- package/utils/IdentifyUtils.js +443 -7
- package/utils/ImageEditor.js +79 -9
- package/utils/LayerUtils.js +1516 -50
- package/utils/LocaleUtils.js +117 -7
- package/utils/MapUtils.js +241 -59
- package/utils/MeasureUtils.js +323 -2
- package/utils/MiscUtils.js +189 -11
- package/utils/PermaLinkUtils.js +429 -6
- package/utils/PluginStore.js +27 -1
- package/utils/ResourceRegistry.js +15 -1
- package/utils/RoutingInterface.js +307 -7
- package/utils/SearchProviders.js +722 -19
- package/utils/ServiceLayerUtils.js +669 -14
- package/utils/Signal.js +32 -2
- package/utils/ThemeUtils.js +341 -7
- package/utils/VectorLayerUtils.js +589 -15
- package/utils/expr_grammar/grammar.js +2239 -2
- package/utils/expr_grammar/test.js +65 -3
package/reducers/layers.js
CHANGED
|
@@ -1,15 +1,462 @@
|
|
|
1
|
-
function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
5
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
6
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
7
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
8
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
13
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
+
/**
|
|
2
15
|
* Copyright 2015 GeoSolutions Sas
|
|
3
16
|
* Copyright 2016-2024 Sourcepole AG
|
|
4
17
|
* All rights reserved.
|
|
5
18
|
*
|
|
6
19
|
* This source code is licensed under the BSD-style license found in the
|
|
7
20
|
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import isEmpty from 'lodash.isempty';
|
|
24
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
25
|
+
import { LayerRole, SET_LAYER_LOADING, ADD_LAYER, ADD_LAYER_SEPARATOR, REMOVE_LAYER, REORDER_LAYER, CHANGE_LAYER_PROPERTY, SET_LAYER_DIMENSIONS, ADD_LAYER_FEATURES, REMOVE_LAYER_FEATURES, CLEAR_LAYER, ADD_THEME_SUBLAYER, REFRESH_LAYER, REMOVE_ALL_LAYERS, REPLACE_PLACEHOLDER_LAYER, SET_SWIPE, SET_FILTER, SET_THEME_LAYERS_VISIBILITY_PRESET } from '../actions/layers';
|
|
26
|
+
import LayerUtils from '../utils/LayerUtils';
|
|
27
|
+
import { UrlParams } from '../utils/PermaLinkUtils';
|
|
28
|
+
import VectorLayerUtils from '../utils/VectorLayerUtils';
|
|
29
|
+
var defaultState = {
|
|
30
|
+
flat: [],
|
|
31
|
+
loading: [],
|
|
32
|
+
swipe: null,
|
|
33
|
+
filter: {
|
|
34
|
+
filterParams: null,
|
|
35
|
+
filterGeom: null,
|
|
36
|
+
timeRange: null
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export default function layers() {
|
|
40
|
+
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
|
|
41
|
+
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
42
|
+
switch (action.type) {
|
|
43
|
+
case SET_LAYER_LOADING:
|
|
44
|
+
{
|
|
45
|
+
var loading = state.loading.filter(function (layerId) {
|
|
46
|
+
return layerId !== action.layerId;
|
|
47
|
+
});
|
|
48
|
+
if (action.loading) {
|
|
49
|
+
loading.push(action.layerId);
|
|
50
|
+
}
|
|
51
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
52
|
+
loading: loading
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
case CHANGE_LAYER_PROPERTY:
|
|
56
|
+
{
|
|
57
|
+
var targetLayer = state.flat.find(function (layer) {
|
|
58
|
+
return layer.id === action.layerId;
|
|
59
|
+
});
|
|
60
|
+
if (!targetLayer) {
|
|
61
|
+
return state;
|
|
62
|
+
}
|
|
63
|
+
var backgroundVisibilityChanged = targetLayer.role === LayerRole.BACKGROUND && action.property === "visibility";
|
|
64
|
+
var parent = targetLayer;
|
|
65
|
+
var parentPath = action.sublayerpath.slice(0, action.sublayerpath.length - 1);
|
|
66
|
+
parentPath.forEach(function (idx) {
|
|
67
|
+
parent = parent.sublayers[idx];
|
|
68
|
+
});
|
|
69
|
+
var mutexVisibilityChanged = parent.mutuallyExclusive && action.property === "visibility";
|
|
70
|
+
if (mutexVisibilityChanged && action.newvalue === false) {
|
|
71
|
+
// Don't allow explicitly hiding item in mutex group - need to toggle other item
|
|
72
|
+
return state;
|
|
73
|
+
}
|
|
74
|
+
var newLayers = (state.flat || []).map(function (layer) {
|
|
75
|
+
if (layer.id === action.layerId) {
|
|
76
|
+
var _LayerUtils$cloneLaye = LayerUtils.cloneLayer(layer, action.sublayerpath || []),
|
|
77
|
+
newlayer = _LayerUtils$cloneLaye.newlayer,
|
|
78
|
+
newsublayer = _LayerUtils$cloneLaye.newsublayer;
|
|
79
|
+
newsublayer[action.property] = action.newvalue;
|
|
80
|
+
var recurseDirection = action.recurseDirection;
|
|
81
|
+
|
|
82
|
+
// Handle mutually exclusive groups
|
|
83
|
+
if (mutexVisibilityChanged) {
|
|
84
|
+
var newParent = newlayer;
|
|
85
|
+
parentPath.forEach(function (index) {
|
|
86
|
+
newParent = newParent.sublayers[index];
|
|
87
|
+
});
|
|
88
|
+
var targetIdx = action.sublayerpath[action.sublayerpath.length - 1];
|
|
89
|
+
newParent.sublayers = newParent.sublayers.map(function (l, idx) {
|
|
90
|
+
return _objectSpread(_objectSpread({}, l), {}, {
|
|
91
|
+
visibility: idx === targetIdx
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (["children", "both"].includes(recurseDirection)) {
|
|
96
|
+
// recurse to children (except visibility to children in mutex case)
|
|
97
|
+
LayerUtils.propagateLayerProperty(newsublayer, action.property, action.newvalue);
|
|
98
|
+
}
|
|
99
|
+
if (["parents", "both"].includes(recurseDirection)) {
|
|
100
|
+
// recurse to parents
|
|
101
|
+
LayerUtils.propagateLayerProperty(newlayer, action.property, action.newvalue, action.sublayerpath);
|
|
102
|
+
}
|
|
103
|
+
if (newlayer.type === "wms") {
|
|
104
|
+
Object.assign(newlayer, LayerUtils.buildWMSLayerParams(newlayer, state.filter));
|
|
105
|
+
}
|
|
106
|
+
if (newlayer.role === LayerRole.BACKGROUND) {
|
|
107
|
+
UrlParams.updateParams({
|
|
108
|
+
bl: newlayer.visibility ? newlayer.name : ''
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return newlayer;
|
|
112
|
+
} else if (layer.role === LayerRole.BACKGROUND && backgroundVisibilityChanged) {
|
|
113
|
+
return _objectSpread(_objectSpread({}, layer), {}, {
|
|
114
|
+
visibility: false
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return layer;
|
|
118
|
+
});
|
|
119
|
+
UrlParams.updateParams({
|
|
120
|
+
l: LayerUtils.buildWMSLayerUrlParam(newLayers)
|
|
121
|
+
});
|
|
122
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
123
|
+
flat: newLayers
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
case SET_LAYER_DIMENSIONS:
|
|
127
|
+
{
|
|
128
|
+
var _state$flat$find;
|
|
129
|
+
// Set dimensions for all layers with the same URL (i.e. if a WMS is split)
|
|
130
|
+
var layerUrl = (_state$flat$find = state.flat.find(function (layer) {
|
|
131
|
+
return layer.id === action.layerId;
|
|
132
|
+
})) === null || _state$flat$find === void 0 ? void 0 : _state$flat$find.url;
|
|
133
|
+
if (!layerUrl) {
|
|
134
|
+
return "";
|
|
135
|
+
}
|
|
136
|
+
var _newLayers = (state.flat || []).map(function (layer) {
|
|
137
|
+
if (layer.url === layerUrl) {
|
|
138
|
+
var newLayer = _objectSpread(_objectSpread({}, layer), {}, {
|
|
139
|
+
dimensionValues: action.dimensions
|
|
140
|
+
});
|
|
141
|
+
Object.assign(newLayer, LayerUtils.buildWMSLayerParams(newLayer, state.filter));
|
|
142
|
+
return newLayer;
|
|
143
|
+
}
|
|
144
|
+
return layer;
|
|
145
|
+
});
|
|
146
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
147
|
+
flat: _newLayers
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
case ADD_LAYER:
|
|
151
|
+
{
|
|
152
|
+
var _action$layer$visibil, _action$layer$opacity, _action$options, _action$options2;
|
|
153
|
+
var _newLayers2 = (state.flat || []).concat();
|
|
154
|
+
var layerId = action.layer.id || uuidv4();
|
|
155
|
+
var newLayer = _objectSpread(_objectSpread({}, action.layer), {}, {
|
|
156
|
+
id: layerId,
|
|
157
|
+
name: action.layer.name || layerId,
|
|
158
|
+
role: action.layer.role || LayerRole.USERLAYER,
|
|
159
|
+
queryable: action.layer.queryable || false,
|
|
160
|
+
visibility: (_action$layer$visibil = action.layer.visibility) !== null && _action$layer$visibil !== void 0 ? _action$layer$visibil : true,
|
|
161
|
+
opacity: (_action$layer$opacity = action.layer.opacity) !== null && _action$layer$opacity !== void 0 ? _action$layer$opacity : 255,
|
|
162
|
+
layertreehidden: action.layer.layertreehidden || action.layer.role > LayerRole.USERLAYER
|
|
163
|
+
});
|
|
164
|
+
if ((_action$options = action.options) !== null && _action$options !== void 0 && _action$options.beforeLayerName || (_action$options2 = action.options) !== null && _action$options2 !== void 0 && _action$options2.afterLayerName) {
|
|
165
|
+
_newLayers2 = LayerUtils.insertLayer(_newLayers2, newLayer, "name", action.options.beforeLayerName || action.options.afterLayerName, action.options.afterLayerName ? true : false);
|
|
166
|
+
} else {
|
|
167
|
+
var inspos = 0;
|
|
168
|
+
if (action.pos === null) {
|
|
169
|
+
for (; inspos < _newLayers2.length && newLayer.role < _newLayers2[inspos].role; ++inspos);
|
|
170
|
+
} else {
|
|
171
|
+
inspos = action.pos;
|
|
172
|
+
}
|
|
173
|
+
_newLayers2.splice(inspos, 0, newLayer);
|
|
174
|
+
// Compress layers if possible
|
|
175
|
+
_newLayers2 = LayerUtils.implodeLayers(LayerUtils.explodeLayers(_newLayers2));
|
|
176
|
+
}
|
|
177
|
+
var _iterator = _createForOfIteratorHelper(_newLayers2),
|
|
178
|
+
_step;
|
|
179
|
+
try {
|
|
180
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
181
|
+
var lyr = _step.value;
|
|
182
|
+
if (lyr.type === "wms") {
|
|
183
|
+
Object.assign(lyr, LayerUtils.buildWMSLayerParams(lyr, state.filter));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
} catch (err) {
|
|
187
|
+
_iterator.e(err);
|
|
188
|
+
} finally {
|
|
189
|
+
_iterator.f();
|
|
190
|
+
}
|
|
191
|
+
UrlParams.updateParams({
|
|
192
|
+
l: LayerUtils.buildWMSLayerUrlParam(_newLayers2)
|
|
193
|
+
});
|
|
194
|
+
if (newLayer.role === LayerRole.BACKGROUND && newLayer.visibility) {
|
|
195
|
+
UrlParams.updateParams({
|
|
196
|
+
bl: newLayer.name
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
200
|
+
flat: _newLayers2
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
case ADD_LAYER_SEPARATOR:
|
|
204
|
+
{
|
|
205
|
+
var _newLayers3 = LayerUtils.insertSeparator(state.flat, action.title, action.afterLayerId, action.afterSublayerPath);
|
|
206
|
+
var _iterator2 = _createForOfIteratorHelper(_newLayers3),
|
|
207
|
+
_step2;
|
|
208
|
+
try {
|
|
209
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
210
|
+
var layer = _step2.value;
|
|
211
|
+
if (layer.type === "wms") {
|
|
212
|
+
Object.assign(layer, LayerUtils.buildWMSLayerParams(layer, state.filter));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
} catch (err) {
|
|
216
|
+
_iterator2.e(err);
|
|
217
|
+
} finally {
|
|
218
|
+
_iterator2.f();
|
|
219
|
+
}
|
|
220
|
+
UrlParams.updateParams({
|
|
221
|
+
l: LayerUtils.buildWMSLayerUrlParam(_newLayers3)
|
|
222
|
+
});
|
|
223
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
224
|
+
flat: _newLayers3
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
case REMOVE_LAYER:
|
|
228
|
+
{
|
|
229
|
+
var _layer = state.flat.find(function (l) {
|
|
230
|
+
return l.id === action.layerId;
|
|
231
|
+
});
|
|
232
|
+
if (!_layer) {
|
|
233
|
+
return state;
|
|
234
|
+
}
|
|
235
|
+
var _newLayers4 = state.flat;
|
|
236
|
+
if (_layer.role === LayerRole.BACKGROUND || isEmpty(action.sublayerpath)) {
|
|
237
|
+
var position = state.flat.findIndex(function (l) {
|
|
238
|
+
return l.id === action.layerId;
|
|
239
|
+
});
|
|
240
|
+
_newLayers4 = _toConsumableArray(_newLayers4);
|
|
241
|
+
_newLayers4.splice(position, 1);
|
|
242
|
+
if (position > 0 && position < _newLayers4.length && _newLayers4[position - 1].id === _newLayers4[position].id) {
|
|
243
|
+
// Compress layers
|
|
244
|
+
_newLayers4 = LayerUtils.implodeLayers(LayerUtils.explodeLayers(_newLayers4));
|
|
245
|
+
}
|
|
246
|
+
} else {
|
|
247
|
+
_newLayers4 = LayerUtils.removeLayer(state.flat, _layer, action.sublayerpath).map(function (l) {
|
|
248
|
+
if (l.type === "wms") {
|
|
249
|
+
return _objectSpread(_objectSpread({}, l), LayerUtils.buildWMSLayerParams(l, state.filter));
|
|
250
|
+
} else {
|
|
251
|
+
return l;
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
UrlParams.updateParams({
|
|
256
|
+
l: LayerUtils.buildWMSLayerUrlParam(_newLayers4)
|
|
257
|
+
});
|
|
258
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
259
|
+
flat: _newLayers4
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
case ADD_LAYER_FEATURES:
|
|
263
|
+
{
|
|
264
|
+
var _layerId = action.layer.id || uuidv4();
|
|
265
|
+
var _newLayers5 = (state.flat || []).concat();
|
|
266
|
+
var idx = _newLayers5.findIndex(function (layer) {
|
|
267
|
+
return layer.id === _layerId;
|
|
268
|
+
});
|
|
269
|
+
if (idx === -1) {
|
|
270
|
+
var newFeatures = action.features.map(function (f) {
|
|
271
|
+
return _objectSpread(_objectSpread({}, f), {}, {
|
|
272
|
+
id: f.id || (f.properties || {}).id || uuidv4()
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
var _newLayer = _objectSpread(_objectSpread({}, action.layer), {}, {
|
|
276
|
+
id: _layerId,
|
|
277
|
+
type: 'vector',
|
|
278
|
+
name: action.layer.name || _layerId,
|
|
279
|
+
features: newFeatures,
|
|
280
|
+
role: action.layer.role || LayerRole.USERLAYER,
|
|
281
|
+
queryable: action.layer.queryable || false,
|
|
282
|
+
visibility: action.layer.visibility || true,
|
|
283
|
+
opacity: action.layer.opacity || 255,
|
|
284
|
+
layertreehidden: action.layer.layertreehidden || action.layer.role > LayerRole.USERLAYER,
|
|
285
|
+
bbox: VectorLayerUtils.computeFeaturesBBox(action.features)
|
|
286
|
+
});
|
|
287
|
+
var _inspos = 0;
|
|
288
|
+
for (; _inspos < _newLayers5.length && _newLayer.role < _newLayers5[_inspos].role; ++_inspos);
|
|
289
|
+
_newLayers5.splice(_inspos, 0, _newLayer);
|
|
290
|
+
} else {
|
|
291
|
+
var addFeatures = action.features.map(function (f) {
|
|
292
|
+
return _objectSpread(_objectSpread({}, f), {}, {
|
|
293
|
+
id: f.id || (f.properties || {}).id || uuidv4()
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
var _newFeatures = action.clear ? addFeatures : [].concat(_toConsumableArray((_newLayers5[idx].features || []).filter(function (f) {
|
|
297
|
+
return !addFeatures.find(function (g) {
|
|
298
|
+
return g.id === f.id;
|
|
299
|
+
});
|
|
300
|
+
})), _toConsumableArray(addFeatures));
|
|
301
|
+
_newLayers5[idx] = _objectSpread(_objectSpread({}, _newLayers5[idx]), {}, {
|
|
302
|
+
features: _newFeatures,
|
|
303
|
+
bbox: VectorLayerUtils.computeFeaturesBBox(_newFeatures),
|
|
304
|
+
rev: action.layer.rev
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
308
|
+
flat: _newLayers5
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
case REMOVE_LAYER_FEATURES:
|
|
312
|
+
{
|
|
313
|
+
var changed = false;
|
|
314
|
+
var _newLayers6 = (state.flat || []).reduce(function (result, layer) {
|
|
315
|
+
if (layer.id === action.layerId) {
|
|
316
|
+
var _newFeatures2 = (layer.features || []).filter(function (f) {
|
|
317
|
+
return action.featureIds.includes(f.id) === false;
|
|
318
|
+
});
|
|
319
|
+
if (!isEmpty(_newFeatures2) || action.keepEmptyLayer) {
|
|
320
|
+
result.push(_objectSpread(_objectSpread({}, layer), {}, {
|
|
321
|
+
features: _newFeatures2,
|
|
322
|
+
bbox: VectorLayerUtils.computeFeaturesBBox(_newFeatures2)
|
|
323
|
+
}));
|
|
324
|
+
}
|
|
325
|
+
changed = true;
|
|
326
|
+
} else {
|
|
327
|
+
result.push(layer);
|
|
328
|
+
}
|
|
329
|
+
return result;
|
|
330
|
+
}, []);
|
|
331
|
+
if (changed) {
|
|
332
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
333
|
+
flat: _newLayers6
|
|
334
|
+
});
|
|
335
|
+
} else {
|
|
336
|
+
return state;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
case CLEAR_LAYER:
|
|
340
|
+
{
|
|
341
|
+
var _newLayers7 = (state.flat || []).map(function (layer) {
|
|
342
|
+
if (layer.id === action.layerId) {
|
|
343
|
+
return _objectSpread(_objectSpread({}, layer), {}, {
|
|
344
|
+
features: [],
|
|
345
|
+
bbox: null
|
|
346
|
+
});
|
|
347
|
+
} else {
|
|
348
|
+
return layer;
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
352
|
+
flat: _newLayers7
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
case ADD_THEME_SUBLAYER:
|
|
356
|
+
{
|
|
357
|
+
var themeLayerIdx = state.flat.findIndex(function (layer) {
|
|
358
|
+
return layer.role === LayerRole.THEME;
|
|
359
|
+
});
|
|
360
|
+
if (themeLayerIdx >= 0) {
|
|
361
|
+
var _newLayers8 = state.flat.slice(0);
|
|
362
|
+
_newLayers8[themeLayerIdx] = LayerUtils.mergeSubLayers(state.flat[themeLayerIdx], action.layer);
|
|
363
|
+
_newLayers8[themeLayerIdx].visibility = true;
|
|
364
|
+
Object.assign(_newLayers8[themeLayerIdx], LayerUtils.buildWMSLayerParams(_newLayers8[themeLayerIdx], state.filter));
|
|
365
|
+
UrlParams.updateParams({
|
|
366
|
+
l: LayerUtils.buildWMSLayerUrlParam(_newLayers8)
|
|
367
|
+
});
|
|
368
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
369
|
+
flat: _newLayers8
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
return state;
|
|
373
|
+
}
|
|
374
|
+
case REFRESH_LAYER:
|
|
375
|
+
{
|
|
376
|
+
var _newLayers9 = (state.flat || []).map(function (layer) {
|
|
377
|
+
if (action.filter(layer)) {
|
|
378
|
+
return _objectSpread(_objectSpread({}, layer), {}, {
|
|
379
|
+
rev: +new Date()
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
return layer;
|
|
383
|
+
});
|
|
384
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
385
|
+
flat: _newLayers9
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
case REMOVE_ALL_LAYERS:
|
|
389
|
+
{
|
|
390
|
+
return defaultState;
|
|
391
|
+
}
|
|
392
|
+
case REORDER_LAYER:
|
|
393
|
+
{
|
|
394
|
+
var _newLayers10 = LayerUtils.reorderLayer(state.flat, action.layer, action.sublayerpath, action.direction, action.preventSplittingGroups).map(function (layer) {
|
|
395
|
+
if (layer.type === "wms") {
|
|
396
|
+
return _objectSpread(_objectSpread({}, layer), LayerUtils.buildWMSLayerParams(layer, state.filter));
|
|
397
|
+
} else {
|
|
398
|
+
return layer;
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
UrlParams.updateParams({
|
|
402
|
+
l: LayerUtils.buildWMSLayerUrlParam(_newLayers10)
|
|
403
|
+
});
|
|
404
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
405
|
+
flat: _newLayers10
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
case REPLACE_PLACEHOLDER_LAYER:
|
|
409
|
+
{
|
|
410
|
+
var _newLayers11 = LayerUtils.replacePlaceholderLayer(state.flat, action.id, action.layer, state.filter);
|
|
411
|
+
UrlParams.updateParams({
|
|
412
|
+
l: LayerUtils.buildWMSLayerUrlParam(_newLayers11)
|
|
413
|
+
});
|
|
414
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
415
|
+
flat: _newLayers11
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
case SET_SWIPE:
|
|
419
|
+
{
|
|
420
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
421
|
+
swipe: action.swipe
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
case SET_FILTER:
|
|
425
|
+
{
|
|
426
|
+
var filter = {
|
|
427
|
+
filterParams: action.filter,
|
|
428
|
+
filterGeom: action.filterGeom,
|
|
429
|
+
timeRange: action.timeRange
|
|
430
|
+
};
|
|
431
|
+
var _newLayers12 = state.flat.map(function (layer) {
|
|
432
|
+
if (layer.type === "wms") {
|
|
433
|
+
return _objectSpread(_objectSpread({}, layer), LayerUtils.buildWMSLayerParams(layer, filter));
|
|
434
|
+
}
|
|
435
|
+
return layer;
|
|
436
|
+
});
|
|
437
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
438
|
+
flat: _newLayers12,
|
|
439
|
+
filter: filter
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
case SET_THEME_LAYERS_VISIBILITY_PRESET:
|
|
443
|
+
{
|
|
444
|
+
var _newLayers13 = state.flat.map(function (layer) {
|
|
445
|
+
if (layer.role === LayerRole.THEME) {
|
|
446
|
+
var _newLayer2 = LayerUtils.applyVisibilityPreset(layer, action.preset);
|
|
447
|
+
return _objectSpread(_objectSpread({}, _newLayer2), LayerUtils.buildWMSLayerParams(_newLayer2, state.filter));
|
|
448
|
+
} else {
|
|
449
|
+
return layer;
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
UrlParams.updateParams({
|
|
453
|
+
l: LayerUtils.buildWMSLayerUrlParam(_newLayers13)
|
|
454
|
+
});
|
|
455
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
456
|
+
flat: _newLayers13
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
default:
|
|
460
|
+
return state;
|
|
461
|
+
}
|
|
462
|
+
}
|
package/reducers/localConfig.js
CHANGED
|
@@ -1,8 +1,128 @@
|
|
|
1
|
-
function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
5
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
6
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
7
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
9
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
10
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
11
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
12
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
+
/**
|
|
2
18
|
* Copyright 2016 GeoSolutions Sas
|
|
3
19
|
* Copyright 2016-2024 Sourcepole AG
|
|
4
20
|
* All rights reserved.
|
|
5
21
|
*
|
|
6
22
|
* This source code is licensed under the BSD-style license found in the
|
|
7
23
|
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*/
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { LOCAL_CONFIG_LOADED, SET_STARTUP_PARAMETERS, SET_COLOR_SCHEME, SET_USER_INFO_FIELDS, SET_PERMALINK_PARAMETERS, REGISTER_CUSTOM_PLUGIN, UNREGISTER_CUSTOM_PLUGIN } from '../actions/localConfig';
|
|
27
|
+
import ConfigUtils from '../utils/ConfigUtils';
|
|
28
|
+
import { UrlParams } from '../utils/PermaLinkUtils';
|
|
29
|
+
var defaultState = _objectSpread(_objectSpread({}, ConfigUtils.getDefaults()), {}, {
|
|
30
|
+
customPlugins: [],
|
|
31
|
+
startupParams: {},
|
|
32
|
+
startupState: {},
|
|
33
|
+
permalinkParams: {},
|
|
34
|
+
colorScheme: 'default'
|
|
35
|
+
});
|
|
36
|
+
export default function localConfig() {
|
|
37
|
+
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
|
|
38
|
+
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
39
|
+
switch (action.type) {
|
|
40
|
+
case LOCAL_CONFIG_LOADED:
|
|
41
|
+
{
|
|
42
|
+
return _objectSpread(_objectSpread({}, state), action.config);
|
|
43
|
+
}
|
|
44
|
+
case SET_STARTUP_PARAMETERS:
|
|
45
|
+
{
|
|
46
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
47
|
+
startupParams: action.params,
|
|
48
|
+
startupState: action.state
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
case SET_COLOR_SCHEME:
|
|
52
|
+
{
|
|
53
|
+
var root = document.querySelector(':root');
|
|
54
|
+
if (state.colorScheme) {
|
|
55
|
+
root.classList.remove(state.colorScheme);
|
|
56
|
+
}
|
|
57
|
+
var newColorScheme = action.colorScheme || state.defaultColorScheme || "default";
|
|
58
|
+
if (newColorScheme) {
|
|
59
|
+
root.classList.add(newColorScheme);
|
|
60
|
+
}
|
|
61
|
+
if (UrlParams.getParam("style")) {
|
|
62
|
+
UrlParams.updateParams({
|
|
63
|
+
style: newColorScheme
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (action.storeInLocalStorage) {
|
|
67
|
+
localStorage.setItem('qwc2-color-scheme', newColorScheme);
|
|
68
|
+
}
|
|
69
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
70
|
+
colorScheme: newColorScheme
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
case SET_USER_INFO_FIELDS:
|
|
74
|
+
{
|
|
75
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
76
|
+
user_infos: _objectSpread(_objectSpread({}, state.user_infos), action.fields)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
case SET_PERMALINK_PARAMETERS:
|
|
80
|
+
{
|
|
81
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
82
|
+
permalinkParams: Object.entries(_objectSpread(_objectSpread({}, state.permalinkParams), action.params)).reduce(function (res, _ref) {
|
|
83
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
84
|
+
key = _ref2[0],
|
|
85
|
+
value = _ref2[1];
|
|
86
|
+
if (value !== undefined) {
|
|
87
|
+
res[key] = value;
|
|
88
|
+
}
|
|
89
|
+
return res;
|
|
90
|
+
}, {})
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
case REGISTER_CUSTOM_PLUGIN:
|
|
94
|
+
{
|
|
95
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
96
|
+
customPlugins: [].concat(_toConsumableArray(state.customPlugins), _toConsumableArray(action.name)),
|
|
97
|
+
plugins: {
|
|
98
|
+
desktop: state.plugins.desktop.map(function (entry) {
|
|
99
|
+
if (entry.name === action.name) {
|
|
100
|
+
return _objectSpread(_objectSpread({}, entry), {}, {
|
|
101
|
+
availableIn3D: action.availableIn3D
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return entry;
|
|
105
|
+
}),
|
|
106
|
+
mobile: state.plugins.mobile.map(function (entry) {
|
|
107
|
+
if (entry.name === action.name) {
|
|
108
|
+
return _objectSpread(_objectSpread({}, entry), {}, {
|
|
109
|
+
availableIn3D: action.availableIn3D
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return entry;
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
case UNREGISTER_CUSTOM_PLUGIN:
|
|
118
|
+
{
|
|
119
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
120
|
+
customPlugins: state.customPlugins.filter(function (el) {
|
|
121
|
+
return el !== action.name;
|
|
122
|
+
})
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
default:
|
|
126
|
+
return state;
|
|
127
|
+
}
|
|
128
|
+
}
|