mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-07-18 05:30:18 -04:00
fix: prevent empty bulk add from clearing import URLs (#7820)
Co-authored-by: zhangjian45 <zhangjian45@lenovo.com>
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
:title="$t('new-recipe.bulk-add')"
|
:title="$t('new-recipe.bulk-add')"
|
||||||
:icon="$globals.icons.createAlt"
|
:icon="$globals.icons.createAlt"
|
||||||
:submit-text="$t('general.add')"
|
:submit-text="$t('general.add')"
|
||||||
|
:submit-disabled="!canSave"
|
||||||
:disable-submit-on-enter="true"
|
:disable-submit-on-enter="true"
|
||||||
can-submit
|
can-submit
|
||||||
@submit="save"
|
@submit="save"
|
||||||
@@ -74,9 +75,11 @@ const dialog = ref(false);
|
|||||||
const inputText = ref(props.inputTextProp);
|
const inputText = ref(props.inputTextProp);
|
||||||
|
|
||||||
function splitText() {
|
function splitText() {
|
||||||
return inputText.value.split("\n").filter(line => !(line === "\n" || !line));
|
return inputText.value.split("\n").filter(line => line.trim().length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const canSave = computed(() => splitText().length > 0);
|
||||||
|
|
||||||
function removeFirstCharacter() {
|
function removeFirstCharacter() {
|
||||||
inputText.value = splitText()
|
inputText.value = splitText()
|
||||||
.map(line => line.substring(1))
|
.map(line => line.substring(1))
|
||||||
@@ -106,6 +109,10 @@ function trimAllLines() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
|
if (!canSave.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
emit("bulk-data", splitText());
|
emit("bulk-data", splitText());
|
||||||
dialog.value = false;
|
dialog.value = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,6 +223,10 @@ async function deleteReport(id: string) {
|
|||||||
fetchReports();
|
fetchReports();
|
||||||
|
|
||||||
function assignUrls(urls: string[]) {
|
function assignUrls(urls: string[]) {
|
||||||
|
if (urls.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bulkUrls.value = urls.map(url => ({ url, categories: [], tags: [] }));
|
bulkUrls.value = urls.map(url => ({ url, categories: [], tags: [] }));
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user