@mattisvensson/strapi-plugin-webatlas 0.8.0 → 0.8.2
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/dist/_chunks/FullLoader-Cmsf8xS6.js +12 -0
- package/dist/_chunks/FullLoader-Cmsf8xS6.js.map +1 -0
- package/dist/_chunks/FullLoader-CrPED_dY.mjs +1 -0
- package/dist/_chunks/FullLoader-CrPED_dY.mjs.map +1 -0
- package/dist/_chunks/SettingTitle-BaaQ_99D.mjs +69 -0
- package/dist/_chunks/SettingTitle-BaaQ_99D.mjs.map +1 -0
- package/dist/_chunks/SettingTitle-D5oNwpzC.js +67 -0
- package/dist/_chunks/SettingTitle-DDZxIqee.js +68 -0
- package/dist/_chunks/SettingTitle-DDZxIqee.js.map +1 -0
- package/dist/_chunks/SettingTitle-IwvX4Kb5.mjs +68 -0
- package/dist/_chunks/{de-C1QgkRoj.mjs → de-B9pq-AJZ.mjs} +11 -2
- package/dist/_chunks/de-B9pq-AJZ.mjs.map +1 -0
- package/dist/_chunks/de-DlQxM8Tg.js +131 -0
- package/dist/_chunks/de-DlQxM8Tg.js.map +1 -0
- package/dist/_chunks/{en--8p5hbLP.mjs → en-Dmbcf7gp.mjs} +11 -2
- package/dist/_chunks/en-Dmbcf7gp.mjs.map +1 -0
- package/dist/_chunks/en-DrhxIwOr.js +131 -0
- package/dist/_chunks/en-DrhxIwOr.js.map +1 -0
- package/dist/_chunks/index--XAogZgv.js +247 -0
- package/dist/_chunks/index--XAogZgv.js.map +1 -0
- package/dist/_chunks/index-2lVgPz4a.js +128 -0
- package/dist/_chunks/index-B1dEY-gs.js +246 -0
- package/dist/_chunks/index-B1mbYb2_.js +293 -0
- package/dist/_chunks/index-B2tjc_lG.mjs +247 -0
- package/dist/_chunks/index-B2tjc_lG.mjs.map +1 -0
- package/dist/_chunks/index-BFuwbmZy.js +12241 -0
- package/dist/_chunks/{index-DSPh-fHL.mjs → index-D2Meknib.mjs} +11 -9
- package/dist/_chunks/index-D2SIGcj3.mjs +12242 -0
- package/dist/_chunks/index-D2SIGcj3.mjs.map +1 -0
- package/dist/_chunks/index-DH0mFrgH.js +129 -0
- package/dist/_chunks/index-DH0mFrgH.js.map +1 -0
- package/dist/_chunks/index-DKtlnMlv.js +12242 -0
- package/dist/_chunks/index-DKtlnMlv.js.map +1 -0
- package/dist/_chunks/index-DOMrViWi.js +4207 -0
- package/dist/_chunks/index-DOMrViWi.js.map +1 -0
- package/dist/_chunks/index-DXRtXlZW.mjs +129 -0
- package/dist/_chunks/index-DXRtXlZW.mjs.map +1 -0
- package/dist/_chunks/index-Df365kgY.js +294 -0
- package/dist/_chunks/index-Df365kgY.js.map +1 -0
- package/dist/_chunks/{index-VcxUbdMO.mjs → index-Dm_GIRd4.mjs} +35 -30
- package/dist/_chunks/index-Dt-mlR1F.mjs +4191 -0
- package/dist/_chunks/index-Dt-mlR1F.mjs.map +1 -0
- package/dist/_chunks/index-QFbHwlyj.mjs +294 -0
- package/dist/_chunks/index-QFbHwlyj.mjs.map +1 -0
- package/dist/_chunks/{index-7rox7tGX.mjs → index-QU9SZ_H9.mjs} +93 -52
- package/dist/_chunks/{index-Z3qq1ab8.mjs → index-_49Fvwqq.mjs} +47 -36
- package/dist/_chunks/{index-DGSjLYNl.mjs → index-aAKsnALd.mjs} +1 -1
- package/dist/_chunks/index-g8wz2qoC.js +4206 -0
- package/dist/admin/index.js +5 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/admin/index.mjs +2 -1
- package/dist/admin/index.mjs.map +1 -0
- package/dist/admin/src/components/modals/NavEdit.d.ts +1 -1
- package/dist/admin/src/pages/Navigation/RouteItem.d.ts +1 -0
- package/dist/admin/src/pages/Settings/ContentBox.d.ts +5 -0
- package/dist/admin/src/pages/Settings/PageWrapper.d.ts +2 -1
- package/dist/admin/src/pages/Settings/SettingTitle.d.ts +4 -0
- package/dist/admin/src/pages/Settings/index.d.ts +4 -0
- package/dist/pluginId.d.ts +2 -1
- package/dist/server/index.js +63 -45
- package/dist/server/index.js.map +1 -0
- package/dist/server/index.mjs +63 -45
- package/dist/server/index.mjs.map +1 -0
- package/dist/server/src/utils/index.d.ts +6 -0
- package/dist/server/src/utils/navItemHandler.d.ts +1 -1
- package/dist/server/src/utils/reduceDepthOfOrphanedItems.d.ts +2 -0
- package/package.json +1 -1
- package/dist/_chunks/PageWrapper-B6nLPFak.mjs +0 -55
- package/dist/_chunks/PageWrapper-BMzPDWn4.js +0 -0
- package/dist/_chunks/PageWrapper-BMzPDWn4.js.map +0 -0
- package/dist/_chunks/de-DYxCPOdb.js +0 -0
- package/dist/_chunks/de-DYxCPOdb.js.map +0 -0
- package/dist/_chunks/en-Be-athEA.js +0 -0
- package/dist/_chunks/en-Be-athEA.js.map +0 -0
- package/dist/_chunks/index-Bu-uQ9jA.js +0 -0
- package/dist/_chunks/index-Bu-uQ9jA.js.map +0 -0
- package/dist/_chunks/index-C53yDU_z.js +0 -0
- package/dist/_chunks/index-C53yDU_z.js.map +0 -0
- package/dist/_chunks/index-CAz59RSr.js +0 -0
- package/dist/_chunks/index-CAz59RSr.js.map +0 -0
- package/dist/_chunks/index-DKfUSLPc.js +0 -0
- package/dist/_chunks/index-DKfUSLPc.js.map +0 -0
- package/dist/_chunks/index-DPMhcaxW.js +0 -0
- package/dist/_chunks/index-DPMhcaxW.js.map +0 -0
package/dist/admin/index.js
CHANGED
package/dist/admin/index.js.map
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/dist/admin/index.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NestedNavigation } from '../../../../types';
|
|
2
2
|
type NavEditProps = {
|
|
3
3
|
item: NestedNavigation;
|
|
4
|
-
onEdit: () => void;
|
|
4
|
+
onEdit: (editedNavigation: NestedNavigation) => void;
|
|
5
5
|
};
|
|
6
6
|
export default function NavEdit({ item, onEdit }: NavEditProps): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -7,6 +7,7 @@ export interface RouteItemProps {
|
|
|
7
7
|
setNavigationItems: React.Dispatch<React.SetStateAction<NestedNavItem[] | undefined>>;
|
|
8
8
|
ghost?: boolean;
|
|
9
9
|
depth?: number;
|
|
10
|
+
maxDepth: number;
|
|
10
11
|
style?: React.CSSProperties;
|
|
11
12
|
wrapperRef?(node: HTMLLIElement): void;
|
|
12
13
|
handleProps?: any;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export default function PageWrapper({ save, isSaving, disabledCondition, children }: {
|
|
2
|
+
export default function PageWrapper({ save, isSaving, disabledCondition, subtitle, children }: {
|
|
3
3
|
save?: () => void;
|
|
4
4
|
isSaving: boolean;
|
|
5
5
|
disabledCondition: boolean;
|
|
6
|
+
subtitle: string;
|
|
6
7
|
children: React.ReactNode;
|
|
7
8
|
}): import("react/jsx-runtime").JSX.Element;
|
package/dist/pluginId.d.ts
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -20,7 +20,7 @@ function transformToUrl(input) {
|
|
|
20
20
|
input = input.replace(/-+/g, "-");
|
|
21
21
|
return input;
|
|
22
22
|
}
|
|
23
|
-
const version = "0.
|
|
23
|
+
const version = "0.8.2";
|
|
24
24
|
const keywords = [];
|
|
25
25
|
const type = "commonjs";
|
|
26
26
|
const exports$1 = {
|
|
@@ -5496,7 +5496,8 @@ async function createNavItem(data) {
|
|
|
5496
5496
|
data: {
|
|
5497
5497
|
navigation: data.navigation,
|
|
5498
5498
|
route: data.route || null,
|
|
5499
|
-
parent: data.parent || null
|
|
5499
|
+
parent: data.parent || null,
|
|
5500
|
+
order: data.order || 0
|
|
5500
5501
|
}
|
|
5501
5502
|
});
|
|
5502
5503
|
return entity;
|
|
@@ -5507,8 +5508,6 @@ async function createNavItem(data) {
|
|
|
5507
5508
|
async function updateNavItem(documentId, data) {
|
|
5508
5509
|
try {
|
|
5509
5510
|
const updateData = {};
|
|
5510
|
-
if (data.navigation !== void 0 && data.navigation !== null && data.navigation !== "") updateData.navigation = data.navigation;
|
|
5511
|
-
if (data.route !== void 0 && data.route !== null && data.route !== "") updateData.route = data.route;
|
|
5512
5511
|
if (data.parent !== void 0) updateData.parent = data.parent;
|
|
5513
5512
|
if (data.order !== void 0 && typeof data.order === "number") updateData.order = data.order;
|
|
5514
5513
|
return await strapi.documents(waNavItem).update({
|
|
@@ -5529,6 +5528,24 @@ async function deleteNavItem(documentId) {
|
|
|
5529
5528
|
console.log(e);
|
|
5530
5529
|
}
|
|
5531
5530
|
}
|
|
5531
|
+
function reduceDepthOfOrphanedItems(navigationItems, itemId) {
|
|
5532
|
+
const navigationItemsCopy = JSON.parse(JSON.stringify(navigationItems));
|
|
5533
|
+
const startItemIndex = navigationItemsCopy.findIndex((item) => item.documentId === itemId);
|
|
5534
|
+
if (startItemIndex === -1) return;
|
|
5535
|
+
const startItem = navigationItemsCopy[startItemIndex];
|
|
5536
|
+
for (let i = startItemIndex + 1; i < navigationItemsCopy.length; i++) {
|
|
5537
|
+
const currentItem = navigationItemsCopy[i];
|
|
5538
|
+
if (!currentItem) continue;
|
|
5539
|
+
if (currentItem.depth === 0) break;
|
|
5540
|
+
if (currentItem.depth > startItem.depth) {
|
|
5541
|
+
currentItem.depth = Math.max(0, currentItem.depth - 1);
|
|
5542
|
+
} else {
|
|
5543
|
+
break;
|
|
5544
|
+
}
|
|
5545
|
+
}
|
|
5546
|
+
navigationItemsCopy.splice(startItemIndex, 1);
|
|
5547
|
+
return navigationItemsCopy;
|
|
5548
|
+
}
|
|
5532
5549
|
async function createExternalRoute(data) {
|
|
5533
5550
|
try {
|
|
5534
5551
|
return await strapi.documents(waRoute).create({
|
|
@@ -5561,19 +5578,6 @@ const admin = ({ strapi: strapi2 }) => ({
|
|
|
5561
5578
|
console.log(err);
|
|
5562
5579
|
return "Error. Couldn't update config";
|
|
5563
5580
|
}
|
|
5564
|
-
if (newConfigMerged.selectedContentTypes) {
|
|
5565
|
-
try {
|
|
5566
|
-
const routes2 = await strapi2.documents(waRoute).findMany();
|
|
5567
|
-
const invalidRoutes = routes2.filter(
|
|
5568
|
-
(route2) => !newConfigMerged.selectedContentTypes.find((type2) => type2.uid === route2.relatedContentType)
|
|
5569
|
-
);
|
|
5570
|
-
for (const route2 of invalidRoutes) {
|
|
5571
|
-
await strapi2.documents(waRoute).delete({ documentId: route2.documentId });
|
|
5572
|
-
}
|
|
5573
|
-
} catch (err) {
|
|
5574
|
-
console.log(err);
|
|
5575
|
-
}
|
|
5576
|
-
}
|
|
5577
5581
|
return newConfigMerged;
|
|
5578
5582
|
},
|
|
5579
5583
|
async getConfig() {
|
|
@@ -5670,14 +5674,13 @@ const admin = ({ strapi: strapi2 }) => ({
|
|
|
5670
5674
|
},
|
|
5671
5675
|
async createNavigation(data) {
|
|
5672
5676
|
try {
|
|
5673
|
-
|
|
5677
|
+
return await strapi2.documents(waNavigation).create({
|
|
5674
5678
|
data: {
|
|
5675
5679
|
name: data.name,
|
|
5676
5680
|
slug: transformToUrl(data.name),
|
|
5677
5681
|
visible: data.isActive
|
|
5678
5682
|
}
|
|
5679
5683
|
});
|
|
5680
|
-
return navigation2;
|
|
5681
5684
|
} catch (e) {
|
|
5682
5685
|
console.log(e);
|
|
5683
5686
|
}
|
|
@@ -5718,22 +5721,28 @@ const admin = ({ strapi: strapi2 }) => ({
|
|
|
5718
5721
|
async updateNavigationItemStructure(navigationId, navigationItems) {
|
|
5719
5722
|
if (!navigationId || !navigationItems) return;
|
|
5720
5723
|
let error = false;
|
|
5721
|
-
let groupIndices = [];
|
|
5722
|
-
let parentIds = [];
|
|
5723
5724
|
const newNavItemsMap = /* @__PURE__ */ new Map();
|
|
5724
5725
|
for (const [index2, item] of navigationItems.entries()) {
|
|
5725
5726
|
if (item.deleted) {
|
|
5726
5727
|
try {
|
|
5727
5728
|
item.documentId && await deleteNavItem(item.documentId);
|
|
5729
|
+
const newItems = reduceDepthOfOrphanedItems(navigationItems, item.documentId);
|
|
5730
|
+
if (!newItems) throw new Error("Failed to reduce depth of orphaned items");
|
|
5731
|
+
navigationItems = newItems;
|
|
5728
5732
|
} catch (error2) {
|
|
5729
5733
|
error2 = true;
|
|
5730
5734
|
console.error("Error deleting navigation item ", error2);
|
|
5731
5735
|
}
|
|
5732
5736
|
continue;
|
|
5733
5737
|
}
|
|
5734
|
-
if (item.
|
|
5735
|
-
|
|
5736
|
-
|
|
5738
|
+
if (!item.route && item.documentId) {
|
|
5739
|
+
try {
|
|
5740
|
+
console.warn("Navigation item without route found. Deleting it. ", item);
|
|
5741
|
+
await deleteNavItem(item.documentId);
|
|
5742
|
+
} catch (error2) {
|
|
5743
|
+
console.error("Error deleting navigation item without route ", error2);
|
|
5744
|
+
}
|
|
5745
|
+
continue;
|
|
5737
5746
|
}
|
|
5738
5747
|
if (item.update && !item.isNew) {
|
|
5739
5748
|
try {
|
|
@@ -5748,9 +5757,12 @@ const admin = ({ strapi: strapi2 }) => ({
|
|
|
5748
5757
|
console.error("Error updating route ", error2);
|
|
5749
5758
|
}
|
|
5750
5759
|
}
|
|
5751
|
-
|
|
5760
|
+
}
|
|
5761
|
+
let parentIds = [];
|
|
5762
|
+
let groupIndices = [];
|
|
5763
|
+
for (const [index2, item] of navigationItems.entries()) {
|
|
5752
5764
|
if (typeof item.depth !== "number") {
|
|
5753
|
-
|
|
5765
|
+
continue;
|
|
5754
5766
|
}
|
|
5755
5767
|
if (item.depth === 0) {
|
|
5756
5768
|
if (groupIndices[0] !== void 0) {
|
|
@@ -5759,25 +5771,34 @@ const admin = ({ strapi: strapi2 }) => ({
|
|
|
5759
5771
|
groupIndices[0] = 0;
|
|
5760
5772
|
}
|
|
5761
5773
|
parentIds = [];
|
|
5762
|
-
} else
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5774
|
+
} else {
|
|
5775
|
+
const previousItem = navigationItems[index2 - 1];
|
|
5776
|
+
if (previousItem && typeof previousItem.depth === "number") {
|
|
5777
|
+
if (item.depth === previousItem.depth + 1) {
|
|
5778
|
+
parentIds.push(previousItem.documentId.startsWith("temp-") ? newNavItemsMap.get(previousItem.documentId)?.documentId || previousItem.documentId : previousItem.documentId);
|
|
5779
|
+
groupIndices[item.depth] = 0;
|
|
5780
|
+
} else if (item.depth <= previousItem.depth) {
|
|
5781
|
+
const diff = previousItem.depth - item.depth;
|
|
5782
|
+
for (let i = 0; i < diff; i++) {
|
|
5783
|
+
parentIds.pop();
|
|
5784
|
+
groupIndices.pop();
|
|
5785
|
+
}
|
|
5786
|
+
groupIndices[item.depth] = (groupIndices[item.depth] || 0) + 1;
|
|
5787
|
+
} else {
|
|
5788
|
+
groupIndices[item.depth] = (groupIndices[item.depth] || 0) + 1;
|
|
5789
|
+
}
|
|
5770
5790
|
}
|
|
5771
|
-
groupIndices[item.depth] = (groupIndices[item.depth] || 0) + 1;
|
|
5772
5791
|
}
|
|
5792
|
+
const calculatedParent = parentIds.at(-1) || null;
|
|
5793
|
+
const calculatedOrder = groupIndices[item.depth] || 0;
|
|
5773
5794
|
try {
|
|
5774
5795
|
if (item.isNew) {
|
|
5775
5796
|
if (item.isNew.route) {
|
|
5776
5797
|
await createNavItem({
|
|
5777
5798
|
route: item.isNew.route,
|
|
5778
|
-
parent:
|
|
5799
|
+
parent: calculatedParent,
|
|
5779
5800
|
navigation: item.isNew.navigation,
|
|
5780
|
-
order:
|
|
5801
|
+
order: calculatedOrder
|
|
5781
5802
|
});
|
|
5782
5803
|
} else {
|
|
5783
5804
|
const newRoute = await createExternalRoute({
|
|
@@ -5786,23 +5807,19 @@ const admin = ({ strapi: strapi2 }) => ({
|
|
|
5786
5807
|
fullPath: item.route.fullPath,
|
|
5787
5808
|
wrapper: item.route.wrapper,
|
|
5788
5809
|
internal: item.route.internal
|
|
5789
|
-
// isOverride: item.route.isOverride,
|
|
5790
|
-
// active: item.route.active,
|
|
5791
5810
|
});
|
|
5792
5811
|
const newNavItem = await createNavItem({
|
|
5793
5812
|
route: newRoute.documentId,
|
|
5794
5813
|
navigation: navigationId,
|
|
5795
|
-
parent:
|
|
5796
|
-
order:
|
|
5814
|
+
parent: calculatedParent,
|
|
5815
|
+
order: calculatedOrder
|
|
5797
5816
|
});
|
|
5798
5817
|
if (newNavItem) newNavItemsMap.set(item.documentId, newNavItem);
|
|
5799
5818
|
}
|
|
5800
5819
|
} else {
|
|
5801
5820
|
await updateNavItem(item.documentId, {
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
order: groupIndices[item.depth] || 0,
|
|
5805
|
-
parent: parentIds.at(-1) || null
|
|
5821
|
+
order: calculatedOrder,
|
|
5822
|
+
parent: calculatedParent
|
|
5806
5823
|
});
|
|
5807
5824
|
}
|
|
5808
5825
|
} catch (errorMsg) {
|
|
@@ -5926,3 +5943,4 @@ const index = {
|
|
|
5926
5943
|
middlewares
|
|
5927
5944
|
};
|
|
5928
5945
|
module.exports = index;
|
|
5946
|
+
//# sourceMappingURL=index.js.map
|