Browse Source

fix(client): make tag as optional to cover tag creation use case

pull/6893/head
KenTandrian 1 week ago
parent
commit
6a79070c02
  1. 13
      apps/client/src/app/components/admin-tag/admin-tag.component.ts
  2. 4
      apps/client/src/app/components/admin-tag/create-or-update-tag-dialog/create-or-update-tag-dialog.component.ts
  3. 2
      apps/client/src/app/components/admin-tag/create-or-update-tag-dialog/create-or-update-tag-dialog.html
  4. 2
      apps/client/src/app/components/admin-tag/create-or-update-tag-dialog/interfaces/interfaces.ts

13
apps/client/src/app/components/admin-tag/admin-tag.component.ts

@ -83,7 +83,9 @@ export class GfAdminTagComponent implements OnInit {
return id === params['tagId'];
});
this.openUpdateTagDialog(tag);
if (tag) {
this.openUpdateTagDialog(tag);
}
} else {
this.router.navigate(['.'], { relativeTo: this.route });
}
@ -153,12 +155,7 @@ export class GfAdminTagComponent implements OnInit {
GfCreateOrUpdateTagDialogComponent,
CreateOrUpdateTagDialogParams
>(GfCreateOrUpdateTagDialogComponent, {
data: {
tag: {
id: null,
name: null
}
},
data: {} satisfies CreateOrUpdateTagDialogParams,
height: this.deviceType === 'mobile' ? '98vh' : undefined,
width: this.deviceType === 'mobile' ? '100vw' : '50rem'
});
@ -197,7 +194,7 @@ export class GfAdminTagComponent implements OnInit {
id,
name
}
},
} satisfies CreateOrUpdateTagDialogParams,
height: this.deviceType === 'mobile' ? '98vh' : undefined,
width: this.deviceType === 'mobile' ? '100vw' : '50rem'
});

4
apps/client/src/app/components/admin-tag/create-or-update-tag-dialog/create-or-update-tag-dialog.component.ts

@ -43,7 +43,7 @@ export class GfCreateOrUpdateTagDialogComponent {
private formBuilder: FormBuilder
) {
this.tagForm = this.formBuilder.group({
name: [this.data.tag.name]
name: [this.data.tag?.name]
});
}
@ -57,7 +57,7 @@ export class GfCreateOrUpdateTagDialogComponent {
name: this.tagForm.get('name')?.value
};
if (this.data.tag.id) {
if (this.data.tag?.id) {
(tag as UpdateTagDto).id = this.data.tag.id;
await validateObjectForForm({
classDto: UpdateTagDto,

2
apps/client/src/app/components/admin-tag/create-or-update-tag-dialog/create-or-update-tag-dialog.html

@ -4,7 +4,7 @@
(keyup.enter)="tagForm.valid && onSubmit()"
(ngSubmit)="onSubmit()"
>
@if (data.tag.id) {
@if (data.tag?.id) {
<h1 i18n mat-dialog-title>Update tag</h1>
} @else {
<h1 i18n mat-dialog-title>Add tag</h1>

2
apps/client/src/app/components/admin-tag/create-or-update-tag-dialog/interfaces/interfaces.ts

@ -1,5 +1,5 @@
import { Tag } from '@prisma/client';
export interface CreateOrUpdateTagDialogParams {
tag: Pick<Tag, 'id' | 'name'>;
tag?: Pick<Tag, 'id' | 'name'>;
}

Loading…
Cancel
Save