@cwa/nuxt-edge 1.0.0-29140666.31bb7d4 → 1.0.0-29141013.85e8d7a

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.
@@ -131,7 +131,7 @@ export default class Fetcher {
131
131
  if (!type) {
132
132
  return;
133
133
  }
134
- const nestedIris = [];
134
+ let nestedIris = [];
135
135
  const nestedPropertiesToFetch = resourceTypeToNestedResourceProperties[type];
136
136
  for (const prop of nestedPropertiesToFetch) {
137
137
  let propIris = resource[prop];
@@ -148,7 +148,7 @@ export default class Fetcher {
148
148
  }
149
149
  }
150
150
  if (onlyIfNoExist) {
151
- nestedIris.filter((iri2) => !this.resourcesStore.current.currentIds.includes(iri2));
151
+ nestedIris = nestedIris.filter((iri2) => !this.resourcesStore.current.currentIds.includes(iri2));
152
152
  if (!nestedIris.length) {
153
153
  return;
154
154
  }
@@ -82,6 +82,7 @@ export const useCwaResourceModel = (iri, property, ops) => {
82
82
  },
83
83
  source
84
84
  });
85
+ isSubmitting.value = false;
85
86
  const newIriReturned = newResource?.["@id"] && newResource["@id"] !== submittingIri;
86
87
  if (newIriReturned) {
87
88
  localValueWithIri.value[newResource["@id"]] = localValueWithIri.value[submittingIri];
@@ -52,9 +52,22 @@ export default function(resourcesState, resourcesGetters) {
52
52
  if (!resource.data || event.noCascade) {
53
53
  break;
54
54
  }
55
- const hasAlternativeVersion = resourcesGetters.findAllPublishableIris.value(event.resource).length > 1;
56
- if (!hasAlternativeVersion) {
57
- const mappedPositions = [...resource.data.componentPositions || [], ...resourcesState.current.positionsByComponent[event.resource] || []];
55
+ const alternativeVersions = resourcesGetters.findAllPublishableIris.value(event.resource);
56
+ const hasAlternativeVersion = alternativeVersions.length > 1;
57
+ const mappedPositions = [...resource.data.componentPositions || [], ...resourcesState.current.positionsByComponent[event.resource] || []];
58
+ if (hasAlternativeVersion) {
59
+ const otherVersions = alternativeVersions.filter((altIri) => altIri !== event.resource);
60
+ if (otherVersions.length) {
61
+ const newPositionIri = otherVersions[0];
62
+ for (const positionIri of mappedPositions) {
63
+ const positionResource = resourcesState.current.byId[positionIri];
64
+ if (!positionResource?.data) {
65
+ continue;
66
+ }
67
+ positionResource.data.component = newPositionIri;
68
+ }
69
+ }
70
+ } else {
58
71
  for (const positionIri of mappedPositions) {
59
72
  const positionResource = resourcesState.current.byId[positionIri];
60
73
  if (!positionResource?.data) {
@@ -1,6 +1,7 @@
1
1
  <script setup>
2
2
  import { computed, onBeforeUnmount, onMounted, ref, toRef, useTemplateRef, watch } from "vue";
3
3
  import { useElementSize, useWindowSize } from "@vueuse/core";
4
+ import { v4 as uuidv4 } from "uuid";
4
5
  import { useCwa } from "#imports";
5
6
  import { getPublishedResourceState } from "#cwa/runtime/resources/resource-utils";
6
7
  const props = defineProps({
@@ -13,6 +14,7 @@ const iri = toRef(props, "iri");
13
14
  const canvas = useTemplateRef("canvas");
14
15
  const windowSize = useWindowSize();
15
16
  const elementSizeInstances = ref([]);
17
+ const reorderId = ref();
16
18
  watch(props.domElements, (newDomElements) => {
17
19
  for (const esInstance of elementSizeInstances.value) {
18
20
  esInstance.stop();
@@ -39,7 +41,6 @@ const resource = computed(() => {
39
41
  }
40
42
  return $cwa.resources.getResource(iri.value).value;
41
43
  });
42
- const resourceData = computed(() => resource.value?.data);
43
44
  const position = computed(() => {
44
45
  const clearCoords = {
45
46
  top: 999999999999,
@@ -50,7 +51,8 @@ const position = computed(() => {
50
51
  width: windowSize.width.value,
51
52
  height: windowSize.height.value
52
53
  },
53
- totalWidthAndHeight: totalWidthAndHeight.value
54
+ totalWidthAndHeight: totalWidthAndHeight.value,
55
+ reorderId: reorderId.value
54
56
  };
55
57
  for (const domElement of domElements.value) {
56
58
  if (domElement.nodeType !== 1) {
@@ -124,14 +126,18 @@ function drawRoundedRect(ctx, x, y, width, height, radius) {
124
126
  ctx.arcTo(x + width, y, x + width - radius, y, radius);
125
127
  ctx.arcTo(x, y, x, y + radius, radius);
126
128
  }
129
+ function assignReorderId() {
130
+ reorderId.value = uuidv4();
131
+ }
127
132
  onMounted(() => {
128
133
  $cwa.admin.eventBus.on("redrawFocus", redraw);
129
- watch(resourceData, $cwa.admin.emitRedraw, { deep: true, flush: "post" });
134
+ $cwa.admin.eventBus.on("reorder", assignReorderId);
135
+ watch([totalWidthAndHeight, position], $cwa.admin.emitRedraw);
130
136
  watch(canvas, (newCanvas) => newCanvas && redraw());
131
- watch(totalWidthAndHeight, $cwa.admin.emitRedraw);
132
137
  });
133
138
  onBeforeUnmount(() => {
134
139
  $cwa.admin.eventBus.off("redrawFocus", redraw);
140
+ $cwa.admin.eventBus.off("reorder", assignReorderId);
135
141
  });
136
142
  defineExpose({
137
143
  redraw
@@ -55,9 +55,6 @@ const buttonOptions = computed(() => {
55
55
  ]);
56
56
  }
57
57
  }
58
- if (resourceType.value === CwaResourceTypes.COMPONENT) {
59
- ops.push({ label: "Clone", value: "clone" });
60
- }
61
58
  return ops;
62
59
  });
63
60
  async function publishResource() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cwa/nuxt-edge",
3
- "version": "1.0.0-29140666.31bb7d4",
3
+ "version": "1.0.0-29141013.85e8d7a",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Components Web Apps Nuxt Module. UI for creating component-driven web apps with the API Components Bundle",