this.navigate(constants.basePaths.login);
},
- noteDeletedToast: function () {
- this.$bvToast.toast("Note deleted ✓", {
- variant: "success",
+ showToast: function (variant, message, title = null) {
+ const options = {
+ variant: variant,
noCloseButton: true,
toaster: "b-toaster-bottom-right",
- });
+ };
+ if (title != null) {
+ options.title = title;
+ }
+ this.$bvToast.toast(message, options);
},
focusSearchInput: function () {
},
unhandledServerErrorToast: function () {
- this.$bvToast.toast(
+ this.showToast(
+ "danger",
"Unknown error communicating with the server. Please try again.",
- {
- title: "Unknown Error",
- variant: "danger",
- noCloseButton: true,
- toaster: "b-toaster-bottom-right",
- }
+ "Unknown Error"
);
},
this.constants = constants;
EventBus.$on("navigate", this.navigate);
- EventBus.$on("unhandledServerError", this.unhandledServerErrorToast);
+ EventBus.$on("showToast", this.showToast);
+ EventBus.$on("unhandledServerErrorToast", this.unhandledServerErrorToast);
EventBus.$on("updateNoteTitle", this.updateNoteTitle);
Mousetrap.bind("/", function () {
methods: {
badFilenameToast: function (invalidItem) {
- this.$bvToast.toast(
- `Invalid ${invalidItem}. Due to filename restrictions, the following characters are not allowed: <>:"/\\|?*`,
- {
- variant: "danger",
- noCloseButton: true,
- toaster: "b-toaster-bottom-right",
- }
+ EventBus.$emit(
+ "showToast",
+ "danger",
+ `Invalid ${invalidItem}. Due to filename restrictions, the following characters are not allowed: <>:"/\\|?*`
);
},
parent.noteLoadFailedMessage = "Note not found";
parent.noteLoadFailed = true;
} else {
- EventBus.$emit("unhandledServerError");
+ EventBus.$emit("unhandledServerErrorToast");
parent.noteLoadFailed = true;
}
});
},
existingTitleToast: function () {
- this.$bvToast.toast(
+ EventBus.$emit(
+ "showToast",
+ "danger",
"A note with this title already exists. Please try again with a new title.",
- {
- title: "Duplicate ✘",
- variant: "danger",
- noCloseButton: true,
- toaster: "b-toaster-bottom-right",
- }
+ "Duplicate ✘"
);
},
entityTooLargeToast: function (entityName) {
- this.$bvToast.toast(
+ EventBus.$emit(
+ "showToast",
+ "danger",
`This ${entityName.toLowerCase()} is too large. Please try again with a smaller ${entityName.toLowerCase()} or adjust your server configuration.`,
- {
- title: `${entityName} Too Large ✘`,
- variant: "danger",
- noCloseButton: true,
- toaster: "b-toaster-bottom-right",
- }
+ `${entityName} Too Large ✘`
);
},
this.titleInput = this.titleInput.trim();
}
if (!this.titleInput) {
- this.$bvToast.toast("Cannot save note without a title ✘", {
- variant: "danger",
- noCloseButton: true,
- toaster: "b-toaster-bottom-right",
- });
+ EventBus.$emit(
+ "showToast",
+ "danger",
+ "Cannot save note without a title ✘"
+ );
return;
}
} else if (error.response?.status == 413) {
this.entityTooLargeToast("Note");
} else {
- EventBus.$emit("unhandledServerError");
+ EventBus.$emit("unhandledServerErrorToast");
}
});
}
) {
parent.existingTitleToast();
} else {
- EventBus.$emit("unhandledServerError");
+ EventBus.$emit("unhandledServerErrorToast");
}
});
}
},
noteSavedToast: function () {
- this.$bvToast.toast("Note saved ✓", {
- variant: "success",
- noCloseButton: true,
- toaster: "b-toaster-bottom-right",
- });
+ EventBus.$emit("showToast", "success", "Note saved ✓");
},
cancelNote: function () {
})
.catch(function (error) {
if (!error.handled) {
- EventBus.$emit("unhandledServerError");
+ EventBus.$emit("unhandledServerErrorToast");
}
});
}
return false;
}
- this.$bvToast.toast("Uploading attachment...", {
- variant: "success",
- noCloseButton: true,
- toaster: "b-toaster-bottom-right",
- });
+ EventBus.$emit("showToast", "success", "Uploading attachment...");
const formData = new FormData();
formData.append("file", file);
},
})
.then(function () {
- parent.$bvToast.toast("Attachment uploaded ✓", {
- variant: "success",
- noCloseButton: true,
- toaster: "b-toaster-bottom-right",
- });
+ EventBus.$emit("showToast", "success", "Attachment uploaded ✓");
return true;
})
.catch(function (error) {
if (error.response?.status == 409) {
- parent.$bvToast.toast(
- "An attachment with this filename already exists ✘",
- {
- variant: "danger",
- noCloseButton: true,
- toaster: "b-toaster-bottom-right",
- }
+ EventBus.$emit(
+ "showToast",
+ "danger",
+ "An attachment with this filename already exists ✘"
);
} else if (error.response?.status == 413) {
this.entityTooLargeToast("Attachment");
} else {
- parent.$bvToast.toast("Failed to upload attachment ✘", {
- variant: "danger",
- noCloseButton: true,
- toaster: "b-toaster-bottom-right",
- });
+ EventBus.$emit(
+ "showToast",
+ "danger",
+ "Failed to upload attachment ✘"
+ );
}
return false;
});