@mattisvensson/strapi-plugin-webatlas 0.3.1 → 0.4.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/{EmptyBox-7D4LrvdH.mjs → EmptyBox-BM4IscSk.mjs} +2 -6
- package/dist/_chunks/{EmptyBox-DT6D5gcf.js → EmptyBox-T8t29l25.js} +1 -5
- package/dist/_chunks/FullLoader-Cmsf8xS6.js +11 -0
- package/dist/_chunks/FullLoader-CrPED_dY.mjs +12 -0
- package/dist/_chunks/{de-C8PE3n3B.mjs → de-Dn24NwJf.mjs} +11 -1
- package/dist/_chunks/{de-4tL_cJTC.js → de-RiCps8UH.js} +11 -1
- package/dist/_chunks/{en-CR1YZvJo.mjs → en-D9Lxaugc.mjs} +11 -1
- package/dist/_chunks/{en-Bg4z3fR7.js → en-JLW5S3ZC.js} +11 -1
- package/dist/_chunks/index-9db80XRS.mjs +126 -0
- package/dist/_chunks/{index-CwHhwtOU.mjs → index-B4pe6Yuh.mjs} +1375 -357
- package/dist/_chunks/{index-CKoxbSC0.js → index-CSYue_D0.js} +42 -60
- package/dist/_chunks/index-CVj7qbwh.mjs +281 -0
- package/dist/_chunks/index-CiY-8z8F.js +126 -0
- package/dist/_chunks/{index-BAqGJ3TM.js → index-Clikpy91.js} +1381 -363
- package/dist/_chunks/{index-BBL_eQ0G.mjs → index-CtJ_9-RB.mjs} +42 -60
- package/dist/_chunks/index-IHvD3566.js +281 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/UI/FullLoader.d.ts +3 -0
- package/dist/admin/src/components/UI/index.d.ts +2 -1
- package/dist/admin/src/components/modals/Delete.d.ts +3 -3
- package/dist/admin/src/components/modals/NavEdit.d.ts +2 -2
- package/dist/admin/src/components/modals/externalItem/index.d.ts +10 -4
- package/dist/admin/src/components/modals/internalItem/internalItemCreate.d.ts +1 -1
- package/dist/admin/src/components/modals/wrapperItem/index.d.ts +11 -5
- package/dist/admin/src/hooks/useApi.d.ts +6 -5
- package/dist/admin/src/hooks/useNavigations.d.ts +2 -0
- package/dist/admin/src/hooks/usePluginConfig.d.ts +3 -3
- package/dist/admin/src/pages/Navigation/PageWrapper.d.ts +7 -0
- package/dist/admin/src/pages/Navigation/index.d.ts +1 -1
- package/dist/admin/src/pages/Routes/PageWrapper.d.ts +4 -0
- package/dist/admin/src/pages/Routes/TableHeader.d.ts +1 -0
- package/dist/admin/src/pages/Routes/TableRow.d.ts +4 -0
- package/dist/admin/src/pages/Settings/ContentTypeAccordion.d.ts +7 -0
- package/dist/admin/src/pages/Settings/PageWrapper.d.ts +8 -0
- package/dist/admin/src/utils/createTempNavItemObject.d.ts +25 -0
- package/dist/admin/src/utils/index.d.ts +2 -1
- package/dist/server/index.js +225 -176
- package/dist/server/index.mjs +225 -176
- package/dist/server/src/controllers/admin.d.ts +1 -4
- package/dist/server/src/controllers/index.d.ts +1 -4
- package/dist/server/src/index.d.ts +2 -8
- package/dist/server/src/services/admin.d.ts +2 -5
- package/dist/server/src/services/index.d.ts +1 -4
- package/dist/server/src/utils/navItemHandler.d.ts +5 -0
- package/dist/server/src/utils/routeHandler.d.ts +3 -0
- package/package.json +1 -1
- package/dist/_chunks/_baseConvert-B84_vf8X.js +0 -864
- package/dist/_chunks/_baseConvert-C2SW1VHq.mjs +0 -865
- package/dist/_chunks/index-BOq-WidK.mjs +0 -17176
- package/dist/_chunks/index-C4ou6MTp.js +0 -17195
- package/dist/_chunks/index-DZmhgSeq.mjs +0 -92
- package/dist/_chunks/index-DsTyLL2l.js +0 -92
- package/dist/admin/src/pages/Navigation/Header.d.ts +0 -6
- package/dist/server/index.js.map +0 -1
- package/dist/server/index.mjs.map +0 -1
package/dist/server/index.mjs
CHANGED
|
@@ -19,7 +19,7 @@ function transformToUrl(input) {
|
|
|
19
19
|
input = input.replace(/-+/g, "-");
|
|
20
20
|
return input;
|
|
21
21
|
}
|
|
22
|
-
const version = "0.
|
|
22
|
+
const version = "0.4.1";
|
|
23
23
|
const keywords = [];
|
|
24
24
|
const type = "commonjs";
|
|
25
25
|
const exports = {
|
|
@@ -1127,16 +1127,6 @@ const admin$2 = () => ({
|
|
|
1127
1127
|
return ctx.throw(500, e);
|
|
1128
1128
|
}
|
|
1129
1129
|
},
|
|
1130
|
-
async createExternalRoute(ctx) {
|
|
1131
|
-
try {
|
|
1132
|
-
const { data } = ctx.request.body;
|
|
1133
|
-
return await getAdminService().createExternalRoute(
|
|
1134
|
-
data
|
|
1135
|
-
);
|
|
1136
|
-
} catch (e) {
|
|
1137
|
-
return ctx.throw(500, e);
|
|
1138
|
-
}
|
|
1139
|
-
},
|
|
1140
1130
|
async getRelatedRoute(ctx) {
|
|
1141
1131
|
try {
|
|
1142
1132
|
const { documentId } = ctx.query;
|
|
@@ -1172,38 +1162,20 @@ const admin$2 = () => ({
|
|
|
1172
1162
|
return ctx.throw(500, e);
|
|
1173
1163
|
}
|
|
1174
1164
|
},
|
|
1175
|
-
async
|
|
1165
|
+
async updateNavigationItemStructure(ctx) {
|
|
1176
1166
|
try {
|
|
1177
|
-
const {
|
|
1178
|
-
if (!
|
|
1179
|
-
return await getAdminService().
|
|
1167
|
+
const { navigationId, navigationItems } = ctx.request.body;
|
|
1168
|
+
if (!navigationId || !navigationItems) return ctx.throw(400, "NavigationId and Navigation items are required");
|
|
1169
|
+
return await getAdminService().updateNavigationItemStructure(navigationId, navigationItems);
|
|
1180
1170
|
} catch (e) {
|
|
1181
1171
|
return ctx.throw(500, e);
|
|
1182
1172
|
}
|
|
1183
1173
|
},
|
|
1184
|
-
async
|
|
1185
|
-
try {
|
|
1186
|
-
const { data } = ctx.request.body;
|
|
1187
|
-
return await getAdminService().createNavItem(data);
|
|
1188
|
-
} catch (e) {
|
|
1189
|
-
return ctx.throw(500, e);
|
|
1190
|
-
}
|
|
1191
|
-
},
|
|
1192
|
-
async updateNavItem(ctx) {
|
|
1193
|
-
try {
|
|
1194
|
-
const { documentId } = ctx.query;
|
|
1195
|
-
if (!documentId) return ctx.throw(400, "NavItem documentId is required");
|
|
1196
|
-
const { data } = ctx.request.body;
|
|
1197
|
-
return await getAdminService().updateNavItem(documentId, data);
|
|
1198
|
-
} catch (e) {
|
|
1199
|
-
return ctx.throw(500, e);
|
|
1200
|
-
}
|
|
1201
|
-
},
|
|
1202
|
-
async deleteNavItem(ctx) {
|
|
1174
|
+
async deleteNavigation(ctx) {
|
|
1203
1175
|
try {
|
|
1204
1176
|
const { documentId } = ctx.query;
|
|
1205
|
-
if (!documentId) return ctx.throw(400, "
|
|
1206
|
-
return await getAdminService().
|
|
1177
|
+
if (!documentId) return ctx.throw(400, "Navigation documentId is required");
|
|
1178
|
+
return await getAdminService().deleteNavigation(documentId);
|
|
1207
1179
|
} catch (e) {
|
|
1208
1180
|
return ctx.throw(500, e);
|
|
1209
1181
|
}
|
|
@@ -1287,15 +1259,6 @@ const admin$1 = {
|
|
|
1287
1259
|
auth: false
|
|
1288
1260
|
}
|
|
1289
1261
|
},
|
|
1290
|
-
{
|
|
1291
|
-
method: "POST",
|
|
1292
|
-
path: "/route/external",
|
|
1293
|
-
handler: "admin.createExternalRoute",
|
|
1294
|
-
config: {
|
|
1295
|
-
policies: [],
|
|
1296
|
-
auth: false
|
|
1297
|
-
}
|
|
1298
|
-
},
|
|
1299
1262
|
{
|
|
1300
1263
|
method: "GET",
|
|
1301
1264
|
path: "/route/related",
|
|
@@ -1332,28 +1295,10 @@ const admin$1 = {
|
|
|
1332
1295
|
auth: false
|
|
1333
1296
|
}
|
|
1334
1297
|
},
|
|
1335
|
-
{
|
|
1336
|
-
method: "DELETE",
|
|
1337
|
-
path: "/navigation",
|
|
1338
|
-
handler: "admin.deleteNavigation",
|
|
1339
|
-
config: {
|
|
1340
|
-
policies: [],
|
|
1341
|
-
auth: false
|
|
1342
|
-
}
|
|
1343
|
-
},
|
|
1344
|
-
{
|
|
1345
|
-
method: "POST",
|
|
1346
|
-
path: "/navitem",
|
|
1347
|
-
handler: "admin.createNavItem",
|
|
1348
|
-
config: {
|
|
1349
|
-
policies: [],
|
|
1350
|
-
auth: false
|
|
1351
|
-
}
|
|
1352
|
-
},
|
|
1353
1298
|
{
|
|
1354
1299
|
method: "PUT",
|
|
1355
|
-
path: "/
|
|
1356
|
-
handler: "admin.
|
|
1300
|
+
path: "/navigation/items",
|
|
1301
|
+
handler: "admin.updateNavigationItemStructure",
|
|
1357
1302
|
config: {
|
|
1358
1303
|
policies: [],
|
|
1359
1304
|
auth: false
|
|
@@ -1361,8 +1306,8 @@ const admin$1 = {
|
|
|
1361
1306
|
},
|
|
1362
1307
|
{
|
|
1363
1308
|
method: "DELETE",
|
|
1364
|
-
path: "/
|
|
1365
|
-
handler: "admin.
|
|
1309
|
+
path: "/navigation",
|
|
1310
|
+
handler: "admin.deleteNavigation",
|
|
1366
1311
|
config: {
|
|
1367
1312
|
policies: [],
|
|
1368
1313
|
auth: false
|
|
@@ -1415,49 +1360,54 @@ function buildStructuredNavigation(navigation2, variant = "nested") {
|
|
|
1415
1360
|
const rootItems = [];
|
|
1416
1361
|
if (!navigation2.items || navigation2.items?.length === 0) return navigation2;
|
|
1417
1362
|
navigation2.items.forEach((item) => {
|
|
1418
|
-
itemsById.set(item.
|
|
1363
|
+
itemsById.set(item.documentId, { ...item, items: [] });
|
|
1419
1364
|
});
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
if (item.parent) {
|
|
1425
|
-
const parentItem = itemsById.get(item.parent.id);
|
|
1426
|
-
parentItem && parentItem.items.push(newItem);
|
|
1427
|
-
} else {
|
|
1428
|
-
rootItems.push(newItem);
|
|
1429
|
-
}
|
|
1430
|
-
});
|
|
1431
|
-
sortItems(rootItems);
|
|
1432
|
-
return { ...navigation2, items: rootItems };
|
|
1433
|
-
} else if (variant === "flat") {
|
|
1434
|
-
let itemsToProcess = [...navigation2.items];
|
|
1435
|
-
let itemsProcessed = /* @__PURE__ */ new Set();
|
|
1436
|
-
while (itemsToProcess.length > 0) {
|
|
1437
|
-
const remainingItems = [];
|
|
1438
|
-
itemsToProcess.forEach((item) => {
|
|
1439
|
-
const newItem = itemsById.get(item.id);
|
|
1365
|
+
try {
|
|
1366
|
+
if (variant === "nested") {
|
|
1367
|
+
navigation2.items.forEach((item) => {
|
|
1368
|
+
const newItem = itemsById.get(item.documentId);
|
|
1440
1369
|
if (!newItem) return null;
|
|
1441
1370
|
if (item.parent) {
|
|
1442
|
-
const parentItem = itemsById.get(item.parent.
|
|
1443
|
-
|
|
1444
|
-
remainingItems.push(item);
|
|
1445
|
-
return;
|
|
1446
|
-
}
|
|
1447
|
-
newItem.depth = parentItem.depth !== void 0 ? parentItem.depth + 1 : 0;
|
|
1448
|
-
parentItem.items.push(newItem);
|
|
1371
|
+
const parentItem = itemsById.get(item.parent.documentId);
|
|
1372
|
+
parentItem && parentItem.items.push(newItem);
|
|
1449
1373
|
} else {
|
|
1450
|
-
newItem.depth = 0;
|
|
1451
1374
|
rootItems.push(newItem);
|
|
1452
1375
|
}
|
|
1453
|
-
itemsById.set(item.id, newItem);
|
|
1454
|
-
itemsProcessed.add(item.id);
|
|
1455
1376
|
});
|
|
1456
|
-
|
|
1377
|
+
sortItems(rootItems);
|
|
1378
|
+
return { ...navigation2, items: rootItems };
|
|
1379
|
+
} else if (variant === "flat") {
|
|
1380
|
+
let itemsToProcess = [...navigation2.items];
|
|
1381
|
+
let itemsProcessed = /* @__PURE__ */ new Set();
|
|
1382
|
+
while (itemsToProcess.length > 0) {
|
|
1383
|
+
const remainingItems = [];
|
|
1384
|
+
itemsToProcess.forEach((item) => {
|
|
1385
|
+
const newItem = itemsById.get(item.documentId);
|
|
1386
|
+
if (!newItem) return null;
|
|
1387
|
+
if (item.parent) {
|
|
1388
|
+
const parentItem = itemsById.get(item.parent.documentId);
|
|
1389
|
+
if (!parentItem || !itemsProcessed.has(item.parent.documentId)) {
|
|
1390
|
+
remainingItems.push(item);
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
newItem.depth = parentItem.depth !== void 0 ? parentItem.depth + 1 : 0;
|
|
1394
|
+
parentItem.items.push(newItem);
|
|
1395
|
+
} else {
|
|
1396
|
+
newItem.depth = 0;
|
|
1397
|
+
rootItems.push(newItem);
|
|
1398
|
+
}
|
|
1399
|
+
itemsById.set(item.documentId, newItem);
|
|
1400
|
+
itemsProcessed.add(item.documentId);
|
|
1401
|
+
});
|
|
1402
|
+
itemsToProcess = remainingItems;
|
|
1403
|
+
}
|
|
1404
|
+
const sortedItems = sortItems(rootItems);
|
|
1405
|
+
const flattenedItems = flattenItems(sortedItems);
|
|
1406
|
+
return { ...navigation2, items: flattenedItems };
|
|
1457
1407
|
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1408
|
+
} catch (error) {
|
|
1409
|
+
console.error(error);
|
|
1410
|
+
throw error;
|
|
1461
1411
|
}
|
|
1462
1412
|
}
|
|
1463
1413
|
const flattenItems = (items, result = []) => {
|
|
@@ -5523,6 +5473,80 @@ function removeWaFields(obj) {
|
|
|
5523
5473
|
delete obj["webatlas_override"];
|
|
5524
5474
|
return obj;
|
|
5525
5475
|
}
|
|
5476
|
+
async function createNavItem(data) {
|
|
5477
|
+
try {
|
|
5478
|
+
if (!data.route || !data.navigation) return null;
|
|
5479
|
+
const parent = data.parent ? await strapi.documents(waNavItem).findOne({
|
|
5480
|
+
documentId: data.parent,
|
|
5481
|
+
populate: ["route"]
|
|
5482
|
+
}) : null;
|
|
5483
|
+
const route2 = data.route ? await strapi.documents(waRoute).findOne({
|
|
5484
|
+
documentId: data.route
|
|
5485
|
+
}) : null;
|
|
5486
|
+
let fullPath = route2.slug;
|
|
5487
|
+
if (route2.internal && !route2.isOverride && parent?.route.internal) fullPath = getFullPath(parent?.route?.fullPath, route2.slug);
|
|
5488
|
+
await strapi.documents(waRoute).update({
|
|
5489
|
+
documentId: data.route,
|
|
5490
|
+
data: {
|
|
5491
|
+
fullPath
|
|
5492
|
+
}
|
|
5493
|
+
});
|
|
5494
|
+
const entity = await strapi.documents(waNavItem).create({
|
|
5495
|
+
data: {
|
|
5496
|
+
navigation: data.navigation,
|
|
5497
|
+
route: data.route || null,
|
|
5498
|
+
parent: data.parent || null
|
|
5499
|
+
}
|
|
5500
|
+
});
|
|
5501
|
+
return entity;
|
|
5502
|
+
} catch (e) {
|
|
5503
|
+
console.log(e);
|
|
5504
|
+
}
|
|
5505
|
+
}
|
|
5506
|
+
async function updateNavItem(documentId, data) {
|
|
5507
|
+
try {
|
|
5508
|
+
const updateData = {};
|
|
5509
|
+
if (data.navigation !== void 0 && data.navigation !== null && data.navigation !== "") updateData.navigation = data.navigation;
|
|
5510
|
+
if (data.route !== void 0 && data.route !== null && data.route !== "") updateData.route = data.route;
|
|
5511
|
+
if (data.parent !== void 0) updateData.parent = data.parent;
|
|
5512
|
+
if (data.order !== void 0 && typeof data.order === "number") updateData.order = data.order;
|
|
5513
|
+
return await strapi.documents(waNavItem).update({
|
|
5514
|
+
documentId,
|
|
5515
|
+
data: updateData
|
|
5516
|
+
});
|
|
5517
|
+
} catch (e) {
|
|
5518
|
+
console.log(e);
|
|
5519
|
+
}
|
|
5520
|
+
}
|
|
5521
|
+
async function deleteNavItem(documentId) {
|
|
5522
|
+
try {
|
|
5523
|
+
await strapi.documents(waNavItem).delete({
|
|
5524
|
+
documentId
|
|
5525
|
+
});
|
|
5526
|
+
return true;
|
|
5527
|
+
} catch (e) {
|
|
5528
|
+
console.log(e);
|
|
5529
|
+
}
|
|
5530
|
+
}
|
|
5531
|
+
async function createExternalRoute(data) {
|
|
5532
|
+
try {
|
|
5533
|
+
return await strapi.documents(waRoute).create({
|
|
5534
|
+
data: {
|
|
5535
|
+
title: data.title,
|
|
5536
|
+
slug: data.fullPath,
|
|
5537
|
+
fullPath: data.fullPath,
|
|
5538
|
+
relatedContentType: "",
|
|
5539
|
+
relatedId: 0,
|
|
5540
|
+
relatedDocumentId: "",
|
|
5541
|
+
uidPath: "",
|
|
5542
|
+
internal: false,
|
|
5543
|
+
wrapper: data.wrapper
|
|
5544
|
+
}
|
|
5545
|
+
});
|
|
5546
|
+
} catch (e) {
|
|
5547
|
+
console.log(e);
|
|
5548
|
+
}
|
|
5549
|
+
}
|
|
5526
5550
|
const admin = ({ strapi: strapi2 }) => ({
|
|
5527
5551
|
async updateConfig(newConfig) {
|
|
5528
5552
|
if (!newConfig || !newConfig.selectedContentTypes) return;
|
|
@@ -5586,25 +5610,6 @@ const admin = ({ strapi: strapi2 }) => ({
|
|
|
5586
5610
|
console.log(e);
|
|
5587
5611
|
}
|
|
5588
5612
|
},
|
|
5589
|
-
async createExternalRoute(data) {
|
|
5590
|
-
try {
|
|
5591
|
-
return await strapi2.documents(waRoute).create({
|
|
5592
|
-
data: {
|
|
5593
|
-
title: data.title,
|
|
5594
|
-
slug: data.fullPath,
|
|
5595
|
-
fullPath: data.fullPath,
|
|
5596
|
-
relatedContentType: "",
|
|
5597
|
-
relatedId: 0,
|
|
5598
|
-
relatedDocumentId: "",
|
|
5599
|
-
uidPath: "",
|
|
5600
|
-
internal: false,
|
|
5601
|
-
wrapper: data.wrapper
|
|
5602
|
-
}
|
|
5603
|
-
});
|
|
5604
|
-
} catch (e) {
|
|
5605
|
-
console.log(e);
|
|
5606
|
-
}
|
|
5607
|
-
},
|
|
5608
5613
|
async getRelatedRoute(documentId) {
|
|
5609
5614
|
try {
|
|
5610
5615
|
return await strapi2.db?.query(waRoute).findOne({
|
|
@@ -5624,14 +5629,17 @@ const admin = ({ strapi: strapi2 }) => ({
|
|
|
5624
5629
|
documentId,
|
|
5625
5630
|
populate: ["items", "items.route", "items.parent"]
|
|
5626
5631
|
});
|
|
5632
|
+
if (!navigation2) throw new Error("Navigation not found");
|
|
5633
|
+
if (variant)
|
|
5634
|
+
navigation2 = buildStructuredNavigation(navigation2, variant);
|
|
5627
5635
|
} else {
|
|
5628
5636
|
navigation2 = await strapi2.documents(waNavigation).findMany({
|
|
5629
5637
|
populate: ["items", "items.route", "items.parent"]
|
|
5630
5638
|
});
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5639
|
+
if (!navigation2) throw new Error("Navigation not found");
|
|
5640
|
+
if (variant) {
|
|
5641
|
+
navigation2 = navigation2.map((nav) => buildStructuredNavigation(nav, variant));
|
|
5642
|
+
}
|
|
5635
5643
|
}
|
|
5636
5644
|
return navigation2;
|
|
5637
5645
|
} catch (e) {
|
|
@@ -5685,60 +5693,102 @@ const admin = ({ strapi: strapi2 }) => ({
|
|
|
5685
5693
|
console.log(e);
|
|
5686
5694
|
}
|
|
5687
5695
|
},
|
|
5688
|
-
async
|
|
5689
|
-
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
documentId: data.route,
|
|
5702
|
-
data: {
|
|
5703
|
-
fullPath
|
|
5696
|
+
async updateNavigationItemStructure(navigationId, navigationItems) {
|
|
5697
|
+
if (!navigationId || !navigationItems) return;
|
|
5698
|
+
let error = false;
|
|
5699
|
+
let groupIndices = [];
|
|
5700
|
+
let parentIds = [];
|
|
5701
|
+
const newNavItemsMap = /* @__PURE__ */ new Map();
|
|
5702
|
+
for (const [index2, item] of navigationItems.entries()) {
|
|
5703
|
+
if (item.deleted) {
|
|
5704
|
+
try {
|
|
5705
|
+
item.documentId && await deleteNavItem(item.documentId);
|
|
5706
|
+
} catch (error2) {
|
|
5707
|
+
error2 = true;
|
|
5708
|
+
console.error("Error deleting navigation item ", error2);
|
|
5704
5709
|
}
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5710
|
+
continue;
|
|
5711
|
+
}
|
|
5712
|
+
if (item.parent?.documentId.startsWith("temp-")) {
|
|
5713
|
+
const newItem = newNavItemsMap.get(item.parent.documentId);
|
|
5714
|
+
item.isNew.parent = newItem?.documentId;
|
|
5715
|
+
}
|
|
5716
|
+
if (item.update && !item.isNew) {
|
|
5717
|
+
try {
|
|
5718
|
+
await this.updateRoute(item.route.documentId, {
|
|
5719
|
+
title: item.update.title || item.route.title,
|
|
5720
|
+
slug: item.update.slug || item.route.slug,
|
|
5721
|
+
fullPath: item.update.fullPath || item.route.fullPath,
|
|
5722
|
+
isOverride: item.update.isOverride !== void 0 ? item.update.isOverride : item.route.isOverride
|
|
5723
|
+
});
|
|
5724
|
+
} catch (error2) {
|
|
5725
|
+
error2 = true;
|
|
5726
|
+
console.error("Error updating route ", error2);
|
|
5711
5727
|
}
|
|
5712
|
-
}
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
data: {
|
|
5723
|
-
navigation: data.navigation || null,
|
|
5724
|
-
route: data.route || null,
|
|
5725
|
-
parent: data.parent || null,
|
|
5726
|
-
order: data.order || 0
|
|
5728
|
+
}
|
|
5729
|
+
const previousItem = navigationItems[index2 - 1];
|
|
5730
|
+
if (typeof item.depth !== "number") {
|
|
5731
|
+
return;
|
|
5732
|
+
}
|
|
5733
|
+
if (item.depth === 0) {
|
|
5734
|
+
if (groupIndices[0] !== void 0) {
|
|
5735
|
+
groupIndices[0] = groupIndices[0] + 1;
|
|
5736
|
+
} else {
|
|
5737
|
+
groupIndices[0] = 0;
|
|
5727
5738
|
}
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5739
|
+
parentIds = [];
|
|
5740
|
+
} else if (typeof previousItem.depth === "number" && item.depth === previousItem.depth + 1) {
|
|
5741
|
+
parentIds.push(previousItem.documentId);
|
|
5742
|
+
groupIndices[item.depth] = 0;
|
|
5743
|
+
} else if (typeof previousItem.depth === "number" && item.depth <= previousItem.depth) {
|
|
5744
|
+
const diff = previousItem.depth - item.depth;
|
|
5745
|
+
for (let i = 0; i < diff; i++) {
|
|
5746
|
+
parentIds.pop();
|
|
5747
|
+
groupIndices.pop();
|
|
5748
|
+
}
|
|
5749
|
+
groupIndices[item.depth] = (groupIndices[item.depth] || 0) + 1;
|
|
5750
|
+
}
|
|
5751
|
+
try {
|
|
5752
|
+
if (item.isNew) {
|
|
5753
|
+
if (item.isNew.route) {
|
|
5754
|
+
await createNavItem({
|
|
5755
|
+
route: item.isNew.route,
|
|
5756
|
+
parent: item.isNew.parent,
|
|
5757
|
+
navigation: item.isNew.navigation,
|
|
5758
|
+
order: groupIndices[item.depth]
|
|
5759
|
+
});
|
|
5760
|
+
} else {
|
|
5761
|
+
const newRoute = await createExternalRoute({
|
|
5762
|
+
title: item.route.title,
|
|
5763
|
+
slug: item.route.slug,
|
|
5764
|
+
fullPath: item.route.fullPath,
|
|
5765
|
+
wrapper: item.route.wrapper,
|
|
5766
|
+
internal: item.route.internal
|
|
5767
|
+
// isOverride: item.route.isOverride,
|
|
5768
|
+
// active: item.route.active,
|
|
5769
|
+
});
|
|
5770
|
+
const newNavItem = await createNavItem({
|
|
5771
|
+
route: newRoute.documentId,
|
|
5772
|
+
navigation: navigationId,
|
|
5773
|
+
parent: item.isNew.parent,
|
|
5774
|
+
order: groupIndices[item.depth]
|
|
5775
|
+
});
|
|
5776
|
+
if (newNavItem) newNavItemsMap.set(item.documentId, newNavItem);
|
|
5777
|
+
}
|
|
5778
|
+
} else {
|
|
5779
|
+
await updateNavItem(item.documentId, {
|
|
5780
|
+
navigation: void 0,
|
|
5781
|
+
route: void 0,
|
|
5782
|
+
order: groupIndices[item.depth] || 0,
|
|
5783
|
+
parent: parentIds.at(-1) || null
|
|
5784
|
+
});
|
|
5785
|
+
}
|
|
5786
|
+
} catch (errorMsg) {
|
|
5787
|
+
error = true;
|
|
5788
|
+
console.error("Error updating navigation item ", errorMsg);
|
|
5789
|
+
}
|
|
5741
5790
|
}
|
|
5791
|
+
return !error;
|
|
5742
5792
|
},
|
|
5743
5793
|
async checkUniquePath(initialPath, targetRouteDocumentId = null) {
|
|
5744
5794
|
try {
|
|
@@ -5856,4 +5906,3 @@ const index = {
|
|
|
5856
5906
|
export {
|
|
5857
5907
|
index as default
|
|
5858
5908
|
};
|
|
5859
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -3,15 +3,12 @@ declare const admin: () => {
|
|
|
3
3
|
getConfig(ctx: any): Promise<any>;
|
|
4
4
|
getRoutes(ctx: any): Promise<any>;
|
|
5
5
|
updateRoute(ctx: any): Promise<any>;
|
|
6
|
-
createExternalRoute(ctx: any): Promise<any>;
|
|
7
6
|
getRelatedRoute(ctx: any): Promise<any>;
|
|
8
7
|
getNavigation(ctx: any): Promise<any>;
|
|
9
8
|
createNavigation(ctx: any): Promise<any>;
|
|
10
9
|
updateNavigation(ctx: any): Promise<any>;
|
|
10
|
+
updateNavigationItemStructure(ctx: any): Promise<any>;
|
|
11
11
|
deleteNavigation(ctx: any): Promise<any>;
|
|
12
|
-
createNavItem(ctx: any): Promise<any>;
|
|
13
|
-
updateNavItem(ctx: any): Promise<any>;
|
|
14
|
-
deleteNavItem(ctx: any): Promise<any>;
|
|
15
12
|
checkUniquePath(ctx: any): Promise<any>;
|
|
16
13
|
};
|
|
17
14
|
export default admin;
|
|
@@ -4,15 +4,12 @@ declare const _default: {
|
|
|
4
4
|
getConfig(ctx: any): Promise<any>;
|
|
5
5
|
getRoutes(ctx: any): Promise<any>;
|
|
6
6
|
updateRoute(ctx: any): Promise<any>;
|
|
7
|
-
createExternalRoute(ctx: any): Promise<any>;
|
|
8
7
|
getRelatedRoute(ctx: any): Promise<any>;
|
|
9
8
|
getNavigation(ctx: any): Promise<any>;
|
|
10
9
|
createNavigation(ctx: any): Promise<any>;
|
|
11
10
|
updateNavigation(ctx: any): Promise<any>;
|
|
11
|
+
updateNavigationItemStructure(ctx: any): Promise<any>;
|
|
12
12
|
deleteNavigation(ctx: any): Promise<any>;
|
|
13
|
-
createNavItem(ctx: any): Promise<any>;
|
|
14
|
-
updateNavItem(ctx: any): Promise<any>;
|
|
15
|
-
deleteNavItem(ctx: any): Promise<any>;
|
|
16
13
|
checkUniquePath(ctx: any): Promise<any>;
|
|
17
14
|
};
|
|
18
15
|
client: ({ strapi }: {
|
|
@@ -18,15 +18,12 @@ declare const _default: {
|
|
|
18
18
|
getConfig(ctx: any): Promise<any>;
|
|
19
19
|
getRoutes(ctx: any): Promise<any>;
|
|
20
20
|
updateRoute(ctx: any): Promise<any>;
|
|
21
|
-
createExternalRoute(ctx: any): Promise<any>;
|
|
22
21
|
getRelatedRoute(ctx: any): Promise<any>;
|
|
23
22
|
getNavigation(ctx: any): Promise<any>;
|
|
24
23
|
createNavigation(ctx: any): Promise<any>;
|
|
25
24
|
updateNavigation(ctx: any): Promise<any>;
|
|
25
|
+
updateNavigationItemStructure(ctx: any): Promise<any>;
|
|
26
26
|
deleteNavigation(ctx: any): Promise<any>;
|
|
27
|
-
createNavItem(ctx: any): Promise<any>;
|
|
28
|
-
updateNavItem(ctx: any): Promise<any>;
|
|
29
|
-
deleteNavItem(ctx: any): Promise<any>;
|
|
30
27
|
checkUniquePath(ctx: any): Promise<any>;
|
|
31
28
|
};
|
|
32
29
|
client: ({ strapi }: {
|
|
@@ -69,15 +66,12 @@ declare const _default: {
|
|
|
69
66
|
getConfig(): Promise<any>;
|
|
70
67
|
getRoutes(): Promise<any>;
|
|
71
68
|
updateRoute(documentId: string, data: any): Promise<any>;
|
|
72
|
-
createExternalRoute(data: any): Promise<any>;
|
|
73
69
|
getRelatedRoute(documentId: string): Promise<any>;
|
|
74
70
|
getNavigation(documentId?: string, variant?: import("../../types").StructuredNavigationVariant): Promise<any>;
|
|
75
71
|
createNavigation(data: any): Promise<any>;
|
|
76
72
|
updateNavigation(documentId: string, data: import("../../types").NavigationInput): Promise<any>;
|
|
77
73
|
deleteNavigation(documentId: string): Promise<any>;
|
|
78
|
-
|
|
79
|
-
updateNavItem(documentId: string, data: import("../../types").NavItemSettings): Promise<any>;
|
|
80
|
-
deleteNavItem(documentId: string): Promise<boolean>;
|
|
74
|
+
updateNavigationItemStructure(navigationId: string, navigationItems: import("../../types").NestedNavItem[]): Promise<boolean>;
|
|
81
75
|
checkUniquePath(initialPath: string, targetRouteDocumentId?: string): Promise<string>;
|
|
82
76
|
};
|
|
83
77
|
client: ({ strapi }: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NavigationInput,
|
|
1
|
+
import type { NavigationInput, NestedNavItem, StructuredNavigationVariant } from "../../../types";
|
|
2
2
|
declare const _default: ({ strapi }: {
|
|
3
3
|
strapi: any;
|
|
4
4
|
}) => {
|
|
@@ -6,15 +6,12 @@ declare const _default: ({ strapi }: {
|
|
|
6
6
|
getConfig(): Promise<any>;
|
|
7
7
|
getRoutes(): Promise<any>;
|
|
8
8
|
updateRoute(documentId: string, data: any): Promise<any>;
|
|
9
|
-
createExternalRoute(data: any): Promise<any>;
|
|
10
9
|
getRelatedRoute(documentId: string): Promise<any>;
|
|
11
10
|
getNavigation(documentId?: string, variant?: StructuredNavigationVariant): Promise<any>;
|
|
12
11
|
createNavigation(data: any): Promise<any>;
|
|
13
12
|
updateNavigation(documentId: string, data: NavigationInput): Promise<any>;
|
|
14
13
|
deleteNavigation(documentId: string): Promise<any>;
|
|
15
|
-
|
|
16
|
-
updateNavItem(documentId: string, data: NavItemSettings): Promise<any>;
|
|
17
|
-
deleteNavItem(documentId: string): Promise<boolean>;
|
|
14
|
+
updateNavigationItemStructure(navigationId: string, navigationItems: NestedNavItem[]): Promise<boolean>;
|
|
18
15
|
checkUniquePath(initialPath: string, targetRouteDocumentId?: string | null): Promise<string>;
|
|
19
16
|
};
|
|
20
17
|
export default _default;
|
|
@@ -6,15 +6,12 @@ declare const _default: {
|
|
|
6
6
|
getConfig(): Promise<any>;
|
|
7
7
|
getRoutes(): Promise<any>;
|
|
8
8
|
updateRoute(documentId: string, data: any): Promise<any>;
|
|
9
|
-
createExternalRoute(data: any): Promise<any>;
|
|
10
9
|
getRelatedRoute(documentId: string): Promise<any>;
|
|
11
10
|
getNavigation(documentId?: string, variant?: import("../../../types").StructuredNavigationVariant): Promise<any>;
|
|
12
11
|
createNavigation(data: any): Promise<any>;
|
|
13
12
|
updateNavigation(documentId: string, data: import("../../../types").NavigationInput): Promise<any>;
|
|
14
13
|
deleteNavigation(documentId: string): Promise<any>;
|
|
15
|
-
|
|
16
|
-
updateNavItem(documentId: string, data: import("../../../types").NavItemSettings): Promise<any>;
|
|
17
|
-
deleteNavItem(documentId: string): Promise<boolean>;
|
|
14
|
+
updateNavigationItemStructure(navigationId: string, navigationItems: import("../../../types").NestedNavItem[]): Promise<boolean>;
|
|
18
15
|
checkUniquePath(initialPath: string, targetRouteDocumentId?: string): Promise<string>;
|
|
19
16
|
};
|
|
20
17
|
client: ({ strapi }: {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { NavItemSettings, NestedNavItem } from "../../../types";
|
|
2
|
+
declare function createNavItem(data: NavItemSettings): Promise<null | NestedNavItem>;
|
|
3
|
+
declare function updateNavItem(documentId: string, data: NavItemSettings): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
|
|
4
|
+
declare function deleteNavItem(documentId: string): Promise<boolean>;
|
|
5
|
+
export { createNavItem, updateNavItem, deleteNavItem };
|
package/package.json
CHANGED