-
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
Conversation
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 comment
The 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 comment
The 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 comment
The 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.
@@ -42,6 +42,11 @@ class MaterialList extends BaseEntity implements BelongsToCampInterface, CopyFro | |||
/** | |||
* The items that are part of this list. | |||
*/ | |||
#[Assert\Count( | |||
exactly: 0, | |||
exactMessage: 'It\'s not possible to delete a material list as long as it has items linked to it.', |
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.
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 comment
The 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
@@ -42,6 +42,11 @@ class MaterialList extends BaseEntity implements BelongsToCampInterface, CopyFro | |||
/** | |||
* The items that are part of this list. | |||
*/ | |||
#[Assert\Count( | |||
exactly: 0, | |||
exactMessage: 'It\'s not possible to delete a material list as long as it has items linked to it.', |
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.
No description provided.