Adding all versions listing and new version form for description templates

This commit is contained in:
Thomas Georgios Giannos 2024-02-08 16:48:50 +02:00
parent f255f61ee6
commit fbf5f65318
1 changed files with 17 additions and 7 deletions

View File

@ -14,7 +14,7 @@ import { IsActive } from '@app/core/common/enum/is-active.enum';
import { AppPermission } from '@app/core/common/enum/permission.enum'; import { AppPermission } from '@app/core/common/enum/permission.enum';
import { UserDescriptionTemplateRole } from '@app/core/common/enum/user-description-template-role'; import { UserDescriptionTemplateRole } from '@app/core/common/enum/user-description-template-role';
import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; import { DescriptionTemplate } from '@app/core/model/description-template/description-template';
import { DescriptionTemplatePersist } from '@app/core/model/description-template/description-template-persist'; import { DescriptionTemplatePersist, NewVersionDescriptionTemplatePersist } from '@app/core/model/description-template/description-template-persist';
import { LanguageInfo } from '@app/core/model/language-info'; import { LanguageInfo } from '@app/core/model/language-info';
import { User } from '@app/core/model/user/user'; import { User } from '@app/core/model/user/user';
import { AuthService } from '@app/core/services/auth/auth.service'; import { AuthService } from '@app/core/services/auth/auth.service';
@ -201,13 +201,23 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
} }
persistEntity(onSuccess?: (response) => void): void { persistEntity(onSuccess?: (response) => void): void {
const formData = this.formService.getValue(this.formGroup.value) as DescriptionTemplatePersist; if (this.isNew && !this.isClone && !this.isNewVersion){
const formData = this.formService.getValue(this.formGroup.value) as DescriptionTemplatePersist;
this.descriptionTemplateService.persist(formData) this.descriptionTemplateService.persist(formData)
.pipe(takeUntil(this._destroyed)).subscribe( .pipe(takeUntil(this._destroyed)).subscribe(
complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete), complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
error => this.onCallbackError(error) error => this.onCallbackError(error)
); );
} else if (this.isNewVersion && !this.isNew && !this.isClone) {
const formData = this.formService.getValue(this.formGroup.value) as NewVersionDescriptionTemplatePersist;
this.descriptionTemplateService.newVersion(formData)
.pipe(takeUntil(this._destroyed)).subscribe(
complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
error => this.onCallbackError(error)
);
}
} }
formSubmit(): void { formSubmit(): void {