mirror of
https://github.com/Lissy93/dashy.git
synced 2025-07-27 07:34:43 +02:00
🐛 Fixes save item without title bug (#377)
Closes #377. This bg was caused by adding items without a title, meaning an ID could not be calculated. The solution was to add a validtion check to ensure that a title is specified befire saving
This commit is contained in:
parent
3cbf7949c3
commit
bf3ccc13d0
@ -224,6 +224,9 @@
|
|||||||
"save-stage-btn": "Save",
|
"save-stage-btn": "Save",
|
||||||
"cancel-stage-btn": "Cancel"
|
"cancel-stage-btn": "Cancel"
|
||||||
},
|
},
|
||||||
|
"edit-item": {
|
||||||
|
"missing-title-err": "An item title is required"
|
||||||
|
},
|
||||||
"edit-section": {
|
"edit-section": {
|
||||||
"edit-section-title": "Edit Section",
|
"edit-section-title": "Edit Section",
|
||||||
"add-section-title": "Add New Section",
|
"add-section-title": "Add New Section",
|
||||||
|
@ -198,6 +198,12 @@ export default {
|
|||||||
// Convert form data back into section.item data structure
|
// Convert form data back into section.item data structure
|
||||||
const structured = {};
|
const structured = {};
|
||||||
this.formData.forEach((row) => { structured[row.name] = row.value; });
|
this.formData.forEach((row) => { structured[row.name] = row.value; });
|
||||||
|
if (!structured.title) { // Missing title, show error and don't proceed
|
||||||
|
this.$toasted.show(
|
||||||
|
this.$t('interactive-editor.edit-item.missing-title-err'),
|
||||||
|
{ className: 'toast-error' },
|
||||||
|
);
|
||||||
|
} else {
|
||||||
// Some attributes need a little extra formatting
|
// Some attributes need a little extra formatting
|
||||||
const newItem = this.formatBeforeSave(structured);
|
const newItem = this.formatBeforeSave(structured);
|
||||||
if (this.isNew) { // Insert new item into data store
|
if (this.isNew) { // Insert new item into data store
|
||||||
@ -211,6 +217,7 @@ export default {
|
|||||||
this.$store.commit(StoreKeys.SET_EDIT_MODE, true);
|
this.$store.commit(StoreKeys.SET_EDIT_MODE, true);
|
||||||
// Close edit menu
|
// Close edit menu
|
||||||
this.$emit('closeEditMenu');
|
this.$emit('closeEditMenu');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/* Some fields require a bit of extra processing before they're saved */
|
/* Some fields require a bit of extra processing before they're saved */
|
||||||
formatBeforeSave(item) {
|
formatBeforeSave(item) {
|
||||||
@ -225,7 +232,7 @@ export default {
|
|||||||
if (str === undefined) return undefined;
|
if (str === undefined) return undefined;
|
||||||
return str === 'true';
|
return str === 'true';
|
||||||
};
|
};
|
||||||
if (newItem.tags) newItem.tags = strToTags(newItem.tags);
|
if (newItem.tags) newItem.tags = newItem.tags ? strToTags(newItem.tags) : [];
|
||||||
if (newItem.statusCheck) newItem.statusCheck = strToBool(newItem.statusCheck);
|
if (newItem.statusCheck) newItem.statusCheck = strToBool(newItem.statusCheck);
|
||||||
if (newItem.statusCheckAllowInsecure) {
|
if (newItem.statusCheckAllowInsecure) {
|
||||||
newItem.statusCheckAllowInsecure = strToBool(newItem.statusCheckAllowInsecure);
|
newItem.statusCheckAllowInsecure = strToBool(newItem.statusCheckAllowInsecure);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user