Skip to content
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

Merged
merged 2 commits into from
Jun 4, 2022

Conversation

usu
Copy link
Member

@usu usu commented May 28, 2022

No description provided.

@usu usu requested review from BacLuc and manuelmeister May 28, 2022 09:13
@usu usu mentioned this pull request May 28, 2022
7 tasks
methods: {
deleteErrorHandler (e) {
if (e?.response?.status === 422 /* Validation Error */) {
return this.$tc('components.camp.campMaterialListsItem.deleteError')
Copy link
Member

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?

Copy link
Member

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

Copy link
Member Author

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.',
Copy link
Member

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?

Copy link
Member

@carlobeltrame carlobeltrame May 30, 2022

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.

methods: {
deleteErrorHandler (e) {
if (e?.response?.status === 422 /* Validation Error */) {
return this.$tc('components.camp.campMaterialListsItem.deleteError')
Copy link
Member

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.',
Copy link
Member

@carlobeltrame carlobeltrame May 30, 2022

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.

@pmattmann pmattmann merged commit 4df8017 into ecamp:devel Jun 4, 2022
@usu usu deleted the feat/delete-material-list branch November 6, 2022 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants