display initial items in editor

This commit is contained in:
2023-07-19 15:31:16 +10:00
parent 8f6310b463
commit 816989d472
2 changed files with 21 additions and 0 deletions

View File

@@ -165,6 +165,7 @@ const handleAddToGallery = async () => {
let result = await openDialog(SMDialogMedia, {
allowUpload: true,
multiple: true,
initial: props.modelValue,
});
if (result) {

View File

@@ -478,6 +478,11 @@ const props = defineProps({
default: false,
required: false,
},
initial: {
type: [Array, Object],
default: () => [],
required: false,
},
});
/**
@@ -1135,6 +1140,20 @@ const forceUpdate = () => {
formLoading.value = false;
};
/**
* Load initial items
*/
const loadInitial = () => {
selected.value = Array.isArray(props.initial)
? props.initial
: [props.initial];
totalItems.value = selected.value.length;
if (selected.value.length > 0) {
mediaItems.value.push(...selected.value);
}
};
// Get max upload size
api.get({
url: "",
@@ -1152,6 +1171,7 @@ api.get({
/* empty */
});
loadInitial();
handleLoad();
</script>