-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: validate material list to be empty before deletion #2765
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
<v-card> | ||
<v-item-group> | ||
<v-list-item-action> | ||
<dialog-entity-delete :entity="materialList"> | ||
<dialog-entity-delete :entity="materialList" :error-handler="deleteErrorHandler"> | ||
<template #activator="{ on }"> | ||
<button-delete v-on="on" /> | ||
</template> | ||
|
@@ -54,6 +54,15 @@ export default { | |
props: { | ||
materialList: { type: Object, required: true }, | ||
disabled: { type: Boolean, default: false } | ||
}, | ||
methods: { | ||
deleteErrorHandler (e) { | ||
if (e?.response?.status === 422 /* Validation Error */) { | ||
return this.$tc('components.camp.campMaterialListsItem.deleteError') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't we say, what the reason is, instead of just a generic message? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume it's because it currently doesn't work, see #2764 which he opened around the same time as this PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main motivation was, because the backend error comes without translation. So I kind of assume that all 422 errors are due to fact that the list was not empty (there's no other deletion validation at the moment). Would certainly be cleaner to implement proper translation codes. |
||
} | ||
|
||
return null | ||
} | ||
} | ||
} | ||
</script> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we already have a concept for api error messaging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have #2365 which works towards displaying the validation messages from the backend.
We also have the more general epic issue #1277, which should include translation of error messages.