added Command+S quick save alias and fixed relations draft restore
This commit is contained in:
parent
818857dea2
commit
01f4765c09
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { fade } from "svelte/transition";
|
import { fade, slide } from "svelte/transition";
|
||||||
import { flip } from "svelte/animate";
|
import { flip } from "svelte/animate";
|
||||||
import { toasts, removeToast } from "@/stores/toasts";
|
import { toasts, removeToast } from "@/stores/toasts";
|
||||||
</script>
|
</script>
|
||||||
|
@ -12,7 +12,8 @@
|
||||||
class:alert-success={toast.type == "success"}
|
class:alert-success={toast.type == "success"}
|
||||||
class:alert-danger={toast.type == "error"}
|
class:alert-danger={toast.type == "error"}
|
||||||
class:alert-warning={toast.type == "warning"}
|
class:alert-warning={toast.type == "warning"}
|
||||||
transition:fade={{ duration: 150 }}
|
in:slide={{ duration: 150 }}
|
||||||
|
out:fade={{ duration: 150 }}
|
||||||
animate:flip={{ duration: 150 }}
|
animate:flip={{ duration: 150 }}
|
||||||
>
|
>
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
|
|
|
@ -101,7 +101,8 @@
|
||||||
isLoaded = true;
|
isLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceOriginal(newOriginal) {
|
async function replaceOriginal(newOriginal) {
|
||||||
|
setErrors({}); // reset errors
|
||||||
original = newOriginal || new Record();
|
original = newOriginal || new Record();
|
||||||
uploadedFilesMap = {};
|
uploadedFilesMap = {};
|
||||||
deletedFileIndexesMap = {};
|
deletedFileIndexesMap = {};
|
||||||
|
@ -115,6 +116,9 @@
|
||||||
record[k] = newOriginal[k];
|
record[k] = newOriginal[k];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// wait to populate the fields to get the normalized values
|
||||||
|
await tick();
|
||||||
|
|
||||||
originalSerializedData = JSON.stringify(record);
|
originalSerializedData = JSON.stringify(record);
|
||||||
|
|
||||||
deleteDraft();
|
deleteDraft();
|
||||||
|
@ -353,7 +357,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleFormKeydown(e) {
|
function handleFormKeydown(e) {
|
||||||
if (e.ctrlKey && e.code == "KeyS") {
|
if ((e.ctrlKey || e.metaKey) && e.code == "KeyS") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
save(false);
|
save(false);
|
||||||
|
|
|
@ -310,7 +310,7 @@
|
||||||
<span class="txt">Cancel</span>
|
<span class="txt">Cancel</span>
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="btn" on:click={() => save()}>
|
<button type="button" class="btn" on:click={() => save()}>
|
||||||
<span class="txt">Save selection</span>
|
<span class="txt">Set selection</span>
|
||||||
</button>
|
</button>
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</OverlayPanel>
|
</OverlayPanel>
|
||||||
|
|
|
@ -23,13 +23,28 @@
|
||||||
fieldRef?.changed();
|
fieldRef?.changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
load();
|
$: if (needLoad(list, value)) {
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
function needLoad() {
|
||||||
|
if (isLoading) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ids = CommonHelper.toArray(value);
|
||||||
|
|
||||||
|
list = list.filter((item) => ids.includes(item.id));
|
||||||
|
|
||||||
|
return ids.length != list.length;
|
||||||
|
}
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
const ids = CommonHelper.toArray(value);
|
const ids = CommonHelper.toArray(value);
|
||||||
|
|
||||||
|
list = []; // reset
|
||||||
|
|
||||||
if (!field?.options?.collectionId || !ids.length) {
|
if (!field?.options?.collectionId || !ids.length) {
|
||||||
list = [];
|
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +115,7 @@
|
||||||
|
|
||||||
<div class="list">
|
<div class="list">
|
||||||
<div class="relations-list">
|
<div class="relations-list">
|
||||||
{#each list as record}
|
{#each list as record (record.id)}
|
||||||
<div class="list-item">
|
<div class="list-item">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<RecordInfo {record} displayFields={field.options?.displayFields} />
|
<RecordInfo {record} displayFields={field.options?.displayFields} />
|
||||||
|
|
|
@ -1327,7 +1327,7 @@ export default class CommonHelper {
|
||||||
setup: (editor) => {
|
setup: (editor) => {
|
||||||
editor.on('keydown', (e) => {
|
editor.on('keydown', (e) => {
|
||||||
// propagate save shortcut to the parent
|
// propagate save shortcut to the parent
|
||||||
if (e.ctrlKey && e.code == "KeyS" && editor.formElement) {
|
if ((e.ctrlKey || e.metaKey) && e.code == "KeyS" && editor.formElement) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
editor.formElement.dispatchEvent(new KeyboardEvent("keydown", e));
|
editor.formElement.dispatchEvent(new KeyboardEvent("keydown", e));
|
||||||
|
|
Loading…
Reference in New Issue