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

Feature/alcs 2325 Tag and category implementation #1939

Merged
merged 10 commits into from
Oct 29, 2024

Conversation

fbarreta
Copy link
Collaborator

@fbarreta fbarreta commented Oct 28, 2024

  • Backend module refactor (Created tag module)
  • Implementation of Tag and Tag Categories on ALCS Admin.

@fbarreta fbarreta self-assigned this Oct 28, 2024
@fbarreta fbarreta changed the title Feature/alcs 2325 create tags entity Feature/alcs 2325 Tag and category implementation Oct 29, 2024
this.showNameWarning = true;
this.name = '';
} else {
throw e;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you're catching the error and it's not meeting your condition you're throwing it again, where is it being handled in the upstream components?

}

private handleError(e: any) {
const res = e as HttpErrorResponse;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the error is a HttpErrorResponse, then shouldn't the handling be done at the service level? That's the responsibility of the services to deal with the networking.

if (res.error.statusCode === HttpStatusCode.Conflict && res.error.message.includes('update or delete on table')) {
this.toastService.showErrorToast('Category is associated with tags. Unable to delete.');
} else {
throw e;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

this.showNameWarning = true;
this.name = '';
} else {
throw e;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

if (res.error.statusCode === HttpStatusCode.Conflict && res.error.message.includes('update or delete on table')) {
this.toastService.showErrorToast('Tag is associated with files. Unable to delete.');
} else {
throw e;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

try {
return await firstValueFrom(this.http.delete<TagCategoryDto>(`${this.url}/${code}`));
} catch (e) {
throw e;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

"bracketSpacing": true,
"endOfLine": "auto"
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please explain about the changes here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endOfLine was just freaking me out on my VSCode and fixed my CR/CRLF warnings hope it won't cause any harm, and added some of the same bracketSpacing as our frontends.

export class TagController {
constructor(private service: TagService) {}

@Get('/:pageIndex/:itemsPerPage')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In pagination and filtering, query parameters would be used instead of URL parameters.

/?pageIndex=1&itemsPerPage=10

const msg = (e as QueryFailedError).message;
throw new HttpException(msg, HttpStatus.CONFLICT);
} else {
throw e;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen if we just throw the error here?

@@ -0,0 +1,10 @@
@use 'sass:math';

@function rem($pixels, $context: 16) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason that we did not put rem function in alcs-frontend was that alcs-frontend would be only used on desktop devices so rem would not be useful.

this.showNameWarning = false;
}

private handleError(e: any) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really not a fan of any. It can lead to so many issues. Could we try to resolve this type up front? It seems like you're already expecting it to be a HttpErrorResponse, could we use this as the param type?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few other cases of the exact same thing. If you figure out a good solution, please apply to other cases.

Copy link
Collaborator

@Abradat Abradat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@fbarreta fbarreta merged commit 6845307 into develop Oct 29, 2024
5 checks passed
@fbarreta fbarreta deleted the feature/ALCS-2325-create-tags-entity branch October 29, 2024 20:20
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.

3 participants