mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-07-17 21:20:15 -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')"
|
||||
:icon="$globals.icons.createAlt"
|
||||
:submit-text="$t('general.add')"
|
||||
:submit-disabled="!canSave"
|
||||
:disable-submit-on-enter="true"
|
||||
can-submit
|
||||
@submit="save"
|
||||
@@ -74,9 +75,11 @@ const dialog = ref(false);
|
||||
const inputText = ref(props.inputTextProp);
|
||||
|
||||
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() {
|
||||
inputText.value = splitText()
|
||||
.map(line => line.substring(1))
|
||||
@@ -106,6 +109,10 @@ function trimAllLines() {
|
||||
}
|
||||
|
||||
function save() {
|
||||
if (!canSave.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
emit("bulk-data", splitText());
|
||||
dialog.value = false;
|
||||
}
|
||||
|
||||
@@ -223,6 +223,10 @@ async function deleteReport(id: string) {
|
||||
fetchReports();
|
||||
|
||||
function assignUrls(urls: string[]) {
|
||||
if (urls.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
bulkUrls.value = urls.map(url => ({ url, categories: [], tags: [] }));
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user