Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOUR-19918: Can not paste a multi column inside another multicolumn #1768

Merged
merged 6 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
title="Default"
:render-controls="displayBuilder"
@change="updateConfig"
:screen-type="displayType"
>
<default-loading-spinner />
</vue-form-builder>
Expand Down Expand Up @@ -448,6 +449,7 @@ export default {
},
showTemplatesPanel: false,
sharedTemplatesData: null,
displayType: 'form'
};
},
computed: {
Expand Down
25 changes: 20 additions & 5 deletions src/components/editor/loop.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<template>
<div class="column-draggable" :selector="config.customCssSelector">
<draggable style="min-height: 80px" :list="items" group="controls">
<draggable
style="min-height: 80px"
:list="items"
group="controls"
@change="onChange"
>
<div
v-for="(element, index) in items"
:key="index"
Expand Down Expand Up @@ -28,7 +33,7 @@
/>
{{ element.config.name || $t("Variable Name") }}
<b-badge
v-if="isInClipboard(items[index])"
v-if="isInClipboard(items[index]) && screenType === 'form'"
data-cy="copied-badge"
class="m-2 custom-badge"
pill
Expand All @@ -38,6 +43,7 @@
</b-badge>
<div class="ml-auto">
<clipboard-button
v-if="screenType === 'form'"
:index="index"
:config="element.config"
:isInClipboard="isInClipboard(items[index])"
Expand Down Expand Up @@ -83,6 +89,7 @@
:config="element.config"
@inspect="inspect"
@update-state="$emit('update-state')"
:screen-type="screenType"
/>
</div>
</div>
Expand All @@ -101,7 +108,7 @@
/>
{{ element.config.name || $t("Variable Name") }}
<b-badge
v-if="isInClipboard(items[index])"
v-if="isInClipboard(items[index]) && screenType === 'form'"
data-cy="copied-badge"
class="m-2 custom-badge"
pill
Expand All @@ -111,6 +118,7 @@
</b-badge>
<div class="ml-auto">
<clipboard-button
v-if="screenType === 'form'"
:index="index"
:config="element.config"
:isInClipboard="isInClipboard(items[index])"
Expand Down Expand Up @@ -146,6 +154,7 @@
]"
:tabindex="element.config.interactive ? 0 : -1"
:config="element.config"
:screen-type="screenType"
@input="
element.config.interactive
? (element.config.content = $event)
Expand Down Expand Up @@ -191,7 +200,7 @@ export default {
...renderer
},
mixins: [HasColorProperty, Clipboard],
props: ["value", "name", "config", "selected", "validationErrors"],
props: ["value", "name", "config", "selected", "validationErrors", "screenType"],
data() {
return {
items: [],
Expand Down Expand Up @@ -276,7 +285,13 @@ export default {
this.$set(item.config.aiConfig, "progress", progress);
}
});
}
},
/**
* Triggered when the draggable container is changed.
*/
onChange(e) {
this.$emit("update-state");
},
}
};
</script>
Expand Down
10 changes: 7 additions & 3 deletions src/components/editor/multi-column.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
/>
{{ element.config.name || $t("Variable Name") }}
<b-badge
v-if="isInClipboard(element)"
v-if="isInClipboard(element) && screenType === 'form'"
data-cy="copied-badge"
class="m-2 custom-badge"
pill
Expand All @@ -53,6 +53,7 @@
</b-badge>
<div class="ml-auto">
<clipboard-button
v-if="screenType === 'form'"
:index="index"
:config="element.config"
:isInClipboard="isInClipboard(element)"
Expand Down Expand Up @@ -95,6 +96,7 @@
:selected="selected"
:ai-element="element"
:config="element.config"
:screen-type="screenType"
@inspect="inspect"
@update-state="$emit('update-state')"
/>
Expand All @@ -118,7 +120,7 @@
/>
{{ element.config.name || $t("Variable Name") }}
<b-badge
v-if="isInClipboard(element)"
v-if="isInClipboard(element) && screenType === 'form'"
data-cy="copied-badge"
class="m-2 custom-badge"
pill
Expand All @@ -128,6 +130,7 @@
</b-badge>
<div class="ml-auto">
<clipboard-button
v-if="screenType === 'form'"
:index="index"
:config="element.config"
:isInClipboard="isInClipboard(element)"
Expand Down Expand Up @@ -163,6 +166,7 @@
]"
:tabindex="element.config.interactive ? 0 : -1"
:config="element.config"
:screen-type="screenType"
@input="
element.config.interactive
? (element.config.content = $event)
Expand Down Expand Up @@ -212,7 +216,7 @@ export default {
...renderer
},
mixins: [HasColorProperty, Clipboard],
props: ["value", "name", "config", "selected", "validationErrors"],
props: ["value", "name", "config", "selected", "validationErrors", "screenType"],
data() {
return {
items: [],
Expand Down
11 changes: 7 additions & 4 deletions src/components/vue-form-builder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
/>
{{ element.config.name || element.label || $t("Field Name") }}
<b-badge
v-if="!isClipboardPage(tabPage) && isInClipboard(extendedPages[tabPage].items[index])"
v-if="!isClipboardPage(tabPage) && isInClipboard(extendedPages[tabPage].items[index]) && screenType === 'form'"
data-cy="copied-badge"
class="m-2 custom-badge"
pill
Expand All @@ -213,7 +213,7 @@
</b-badge>
<div class="ml-auto">
<clipboard-button
v-if="!isClipboardPage(tabPage)"
v-if="!isClipboardPage(tabPage) && screenType === 'form'"
:index="index"
:config="element.config"
:isInClipboard="isInClipboard(extendedPages[tabPage].items[index])"
Expand Down Expand Up @@ -261,6 +261,7 @@
:selected="selected"
:config="element.config"
:ai-element="element"
:screen-type="screenType"
@inspect="inspect"
@update-state="updateState"
/>
Expand All @@ -279,7 +280,7 @@
/>
{{ element.config.name || $t("Variable Name") }}
<b-badge
v-if="!isClipboardPage(tabPage) && isInClipboard(extendedPages[tabPage].items[index])"
v-if="!isClipboardPage(tabPage) && isInClipboard(extendedPages[tabPage].items[index]) && screenType === 'form'"
data-cy="copied-badge"
class="m-2 custom-badge"
pill
Expand All @@ -289,7 +290,7 @@
</b-badge>
<div class="ml-auto">
<clipboard-button
v-if="!isClipboardPage(tabPage)"
v-if="!isClipboardPage(tabPage) && screenType === 'form'"
:index="index"
:config="element.config"
:isInClipboard="isInClipboard(extendedPages[tabPage].items[index])"
Expand Down Expand Up @@ -325,12 +326,14 @@
: elementCssClass(element),
{ 'prevent-interaction': !element.config.interactive }
]"
:screen-type="screenType"
@input="
element.config.interactive
? (element.config.content = $event)
: null
"
@focusout.native="updateState"

/>
</div>
</div>
Expand Down
55 changes: 39 additions & 16 deletions src/mixins/Clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,45 @@ export default {
}

const replaceInPage = (page) => {
page.items.forEach((item, index) => {
if (item.component === clipboardComponentName) {
// clone clipboard content to avoid modifying the original
const clipboardContent = _.cloneDeep(this.$store.getters["clipboardModule/clipboardItems"]);
// replace uuids in clipboard content
clipboardContent.forEach(this.updateUuids);
page.items.splice(index, 1, ...clipboardContent);
if (clipboardContent.length) {
window.ProcessMaker.alert(this.$t("Clipboard Pasted Succesfully"), "success");
}
}
if (item.items) {
replaceInPage(item);
}
});
}
const processItems = (items) => {
items.forEach((item, index) => {
// Recursively process nested arrays
if (Array.isArray(item)) {
return processItems(item);
}

// Replace clipboard component with clipboard content
if (item.component === clipboardComponentName) {
// Clone clipboard content to avoid modifying original data
const clipboardContent = _.cloneDeep(this.$store.getters["clipboardModule/clipboardItems"]);

// Update UUIDs in clipboard content to prevent duplicate IDs
clipboardContent.forEach(this.updateUuids);

// Replace the clipboard component with the clipboard content
items.splice(index, 1, ...clipboardContent);

// Show success message if clipboard content is present
if (clipboardContent.length > 0) {
window.ProcessMaker.alert(this.$t("Clipboard Pasted Successfully"), "success");
}
}

// Process nested items recursively
if (item.items) {
processItems(item.items);
}
});
};

// Initiate the processing of page items
if (page && Array.isArray(page.items)) {
processItems(page.items);
} else {
console.warn("Invalid page structure or no items to process.");
}
};

screenConfig.forEach((item) => replaceInPage(item));
},

Expand Down
1 change: 1 addition & 0 deletions tests/e2e/fixtures/displayScreenNext.json

Large diffs are not rendered by default.

Loading
Loading