[#1656] added duplicate collection and record dropdown option

This commit is contained in:
Gani Georgiev
2023-01-24 22:30:42 +02:00
parent b3fa1f0fea
commit 39df263a03
33 changed files with 202 additions and 118 deletions
@@ -221,6 +221,40 @@
});
});
}
function duplicateConfirm() {
if (hasChanges) {
confirm("You have unsaved changes. Do you really want to discard them?", () => {
duplicate();
});
} else {
duplicate();
}
}
async function duplicate() {
const clone = original?.clone();
if (clone) {
clone.id = "";
clone.created = "";
clone.updated = "";
// reset file fields
const fields = collection?.schema || [];
for (const field of fields) {
if (field.type === "file") {
delete clone[field.name];
}
}
}
show(clone);
await tick();
initialFormHash = "";
}
</script>
<OverlayPanel
@@ -276,6 +310,14 @@
<span class="txt">Send password reset email</span>
</button>
{/if}
<button
type="button"
class="dropdown-item closable"
on:click={() => duplicateConfirm()}
>
<i class="ri-file-copy-line" />
<span class="txt">Duplicate</span>
</button>
<button
type="button"
class="dropdown-item txt-danger closable"
@@ -81,7 +81,7 @@
</label>
<div bind:this={filesListElem} class="list">
{#each valueAsArray as filename, i (filename)}
{#each valueAsArray as filename, i (filename + record.id)}
{@const isDeleted = deletedFileIndexes.includes(i)}
<div class="list-item">
<div class:fade={deletedFileIndexes.includes(i)}>