Skip to content

Commit

Permalink
Fix template picker bugs for certificates (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
sei-bstein authored Jan 6, 2025
1 parent 15bd384 commit 0189a81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div class="input-group">
<select id="feedbackTemplate" class="form-control" [ngModel]="selectedTemplate"
(ngModelChange)="handleTemplateSelect()">
(ngModelChange)="handleTemplateSelect($event)">
<option [ngValue]="undefined">{{ defaultOptionText }}</option>
<option *ngFor="let template of templates" [ngValue]="template">
{{ template.name }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CertificateTemplateView } from '@/certificates/certificates.models';
import { fa } from "@/services/font-awesome.service";
import { CertificatesService } from '@/api/certificates.service';
import { ModalConfirmService } from '@/services/modal-confirm.service';
import { ToastService } from '@/utility/services/toast.service';

@Component({
selector: 'app-certificate-template-picker',
Expand All @@ -29,6 +30,7 @@ export class CertificateTemplatePickerComponent implements OnInit, OnChanges {
private formBuilder = inject(FormBuilder);
private initialLoad = false;
private modalService = inject(ModalConfirmService);
private toastsService = inject(ToastService);

protected fa = fa;
protected createEditForm = this.formBuilder.group({
Expand Down Expand Up @@ -101,8 +103,10 @@ export class CertificateTemplatePickerComponent implements OnInit, OnChanges {
};
if (!this.createEditForm.value.id) {
await this.certificatesService.templateCreate(request);
this.toastsService.showMessage(`Created certificate template **${request.name}**`);
} else {
await this.certificatesService.templateUpdate(request);
this.toastsService.showMessage(`Updated certificate template **${request.name}**`);
}

await this.load();
Expand All @@ -128,8 +132,9 @@ export class CertificateTemplatePickerComponent implements OnInit, OnChanges {
await this.load();
}

protected handleTemplateSelect() {
this.selected.emit(this.selectedTemplate);
protected handleTemplateSelect(template: CertificateTemplateView) {
this.selectedTemplate = template;
this.selected.emit(template);
}

private async load() {
Expand Down

0 comments on commit 0189a81

Please sign in to comment.