@mattisvensson/strapi-plugin-webatlas 0.2.6 → 0.3.1

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.
@@ -19,7 +19,7 @@ function transformToUrl(input) {
19
19
  input = input.replace(/-+/g, "-");
20
20
  return input;
21
21
  }
22
- const version = "0.2.6";
22
+ const version = "0.3.1";
23
23
  const keywords = [];
24
24
  const type = "commonjs";
25
25
  const exports = {
@@ -238,9 +238,11 @@ const bootstrap = async ({ strapi: strapi2 }) => {
238
238
  });
239
239
  strapi2.db?.lifecycles.subscribe({
240
240
  models: config2.selectedContentTypes.map((type2) => type2.uid),
241
- async beforeCreate() {
241
+ async beforeCreate(event) {
242
242
  const validContentTypes = config2.selectedContentTypes.filter((type2) => strapi2.contentTypes[type2.uid]);
243
243
  await pluginStore.set({ key: "config", value: { selectedContentTypes: validContentTypes } });
244
+ if (!event.params.data.webatlas_path) return;
245
+ event.params.data.webatlas_path = transformToUrl(event.params.data.webatlas_path);
244
246
  },
245
247
  async afterCreate(event) {
246
248
  const ctSettings = config2.selectedContentTypes.find((type2) => type2.uid === event.model.uid);
@@ -1481,6 +1483,7 @@ const sortItems = (items) => {
1481
1483
  function extractRouteAndItems(items) {
1482
1484
  return items.map((item) => {
1483
1485
  const route2 = { ...item.route };
1486
+ if (!route2) return null;
1484
1487
  if (item.depth) {
1485
1488
  route2.depth = item.depth;
1486
1489
  }
@@ -5665,6 +5668,16 @@ const admin = ({ strapi: strapi2 }) => ({
5665
5668
  },
5666
5669
  async deleteNavigation(documentId) {
5667
5670
  try {
5671
+ const navigation2 = await strapi2.documents(waNavigation).findOne({
5672
+ documentId,
5673
+ populate: ["items"]
5674
+ });
5675
+ if (!navigation2) throw new Error("Navigation not found");
5676
+ for (const item of navigation2.items) {
5677
+ await strapi2.documents(waNavItem).delete({
5678
+ documentId: item.documentId
5679
+ });
5680
+ }
5668
5681
  return await strapi2.documents(waNavigation).delete({
5669
5682
  documentId
5670
5683
  });