description template update
This commit is contained in:
parent
ab010026a7
commit
5523ca2fe1
|
@ -262,8 +262,8 @@ public class DescriptionServiceImpl implements DescriptionService {
|
|||
throw new MyValidationException("New version not found");
|
||||
if (latestVersionDescriptionTemplates.size() > 1)
|
||||
throw new MyValidationException("Multiple template found");
|
||||
if (!latestVersionDescriptionTemplates.getFirst().getVersion().equals(oldDescriptionTemplateEntity.getVersion()))
|
||||
throw new MyValidationException(this.errors.getDescriptionTemplateNewVersionConflict().getCode(), this.errors.getDescriptionTemplateNewVersionConflict().getMessage());
|
||||
if (latestVersionDescriptionTemplates.getFirst().getVersion().equals(oldDescriptionTemplateEntity.getVersion()))
|
||||
throw new MyValidationException("Description already upgraded");
|
||||
|
||||
data.setDescriptionTemplateId(latestVersionDescriptionTemplates.getFirst().getId());
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import { DescriptionTemplateType } from "../description-template-type/descriptio
|
|||
import { ReferenceType } from "../reference-type/reference-type";
|
||||
import { User } from "../user/user";
|
||||
import { Reference } from "../reference/reference";
|
||||
import { DescriptionTemplateVersionStatus } from "@app/core/common/enum/description-template-version-status";
|
||||
|
||||
|
||||
export interface DescriptionTemplate extends BaseEntity {
|
||||
|
@ -21,6 +22,7 @@ export interface DescriptionTemplate extends BaseEntity {
|
|||
status?: DescriptionTemplateStatus;
|
||||
definition?: DescriptionTemplateDefinition;
|
||||
users?: UserDescriptionTemplate[];
|
||||
versionStatus?: DescriptionTemplateVersionStatus;
|
||||
}
|
||||
|
||||
export interface UserDescriptionTemplate extends BaseEntity {
|
||||
|
|
|
@ -12,6 +12,8 @@ import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.servic
|
|||
import { BaseComponent } from '@common/base/base.component';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { DeprecatedDescriptionTemplateDialog } from './dialog-description-template/deprecated-description-template-dialog.component';
|
||||
import { DescriptionTemplateVersionStatus } from '@app/core/common/enum/description-template-version-status';
|
||||
import { DescriptionStatus } from '@app/core/common/enum/description-status';
|
||||
|
||||
@Component({
|
||||
selector: 'app-description-base-fields-editor-component',
|
||||
|
@ -41,17 +43,22 @@ export class DescriptionBaseFieldsEditorComponent extends BaseComponent {
|
|||
}
|
||||
|
||||
private loadDescriptionTemplates(): void {
|
||||
const dmpDescriptionTemplates: DmpDescriptionTemplate[] = this.description.dmp.dmpDescriptionTemplates.filter(x => x.sectionId == this.description.dmpDescriptionTemplate.sectionId && x.isActive == IsActive.Active);
|
||||
const currentVersionsOfDescriptionTemplates = dmpDescriptionTemplates.map(x => x.currentDescriptionTemplate);
|
||||
//Check if the used tempalte in included in the current list. If not add it.
|
||||
if (this.description.descriptionTemplate && currentVersionsOfDescriptionTemplates.find(x => x.id == this.description?.descriptionTemplate?.id) == null) {
|
||||
if (this.description.status === 0) {
|
||||
const isPreviousVersion: boolean = this.description.descriptionTemplate.versionStatus === DescriptionTemplateVersionStatus.Previous;
|
||||
if (isPreviousVersion === true) {
|
||||
if (this.description.status === DescriptionStatus.Draft) {
|
||||
this.openDeprecatedDescriptionTemplateDialog();
|
||||
} else {
|
||||
this.availableDescriptionTemplates.push(this.description.descriptionTemplate);
|
||||
}
|
||||
} else {
|
||||
this.availableDescriptionTemplates.push(this.description.descriptionTemplate);
|
||||
}
|
||||
this.availableDescriptionTemplates.push(...currentVersionsOfDescriptionTemplates);
|
||||
|
||||
|
||||
// const dmpDescriptionTemplates: DmpDescriptionTemplate[] = this.description.dmp.dmpDescriptionTemplates.filter(x => x.sectionId == this.description.dmpDescriptionTemplate.sectionId && x.isActive == IsActive.Active);
|
||||
// // const currentVersionsOfDescriptionTemplates = dmpDescriptionTemplates.map(x => x.currentDescriptionTemplate);
|
||||
// //Check if the used tempalte in included in the current list. If not add it.
|
||||
// this.availableDescriptionTemplates.push(...currentVersionsOfDescriptionTemplates);
|
||||
}
|
||||
|
||||
private openDeprecatedDescriptionTemplateDialog(): void {
|
||||
|
|
|
@ -95,6 +95,7 @@ export class DescriptionEditorResolver extends BaseEditorResolver {
|
|||
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.id)].join('.'),
|
||||
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.label)].join('.'),
|
||||
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.version)].join('.'),
|
||||
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.versionStatus)].join('.'),
|
||||
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.groupId)].join('.'),
|
||||
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.isActive)].join('.'),
|
||||
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.id)].join('.'),
|
||||
|
|
Loading…
Reference in New Issue