description multiplicity ui changes

This commit is contained in:
amentis 2024-04-05 09:44:26 +03:00
parent b4f54bc330
commit 0ded82e5cb
4 changed files with 21 additions and 16 deletions

View File

@ -594,7 +594,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
const commonDescriptions = descriptions.filter(x => x.dmpDescriptionTemplate.descriptionTemplateGroupId == sectionDescriptionTemplate.descriptionTemplateGroupId); const commonDescriptions = descriptions.filter(x => x.dmpDescriptionTemplate.descriptionTemplateGroupId == sectionDescriptionTemplate.descriptionTemplateGroupId);
if (commonDescriptions && commonDescriptions.length >= sectionDescriptionTemplate.maxMultiplicity) { if (commonDescriptions && commonDescriptions.length >= sectionDescriptionTemplate.maxMultiplicity) {
rejectedDmpDescriptionTemplates = commonDescriptions.map(x => x.dmpDescriptionTemplate); rejectedDmpDescriptionTemplates.push.apply(rejectedDmpDescriptionTemplates, commonDescriptions.map(x => x.dmpDescriptionTemplate));
} }
} }
}) })

View File

@ -96,17 +96,11 @@
</li> </li>
</ol> </ol>
<ul *ngIf="item.id && section.hasTemplates && canEditSection(section.id) && !formGroup.disabled" class="add-description-option"> <ul *ngIf="item.id && section.hasTemplates && canEditSection(section.id) && !formGroup.disabled" class="add-description-option">
<li *ngIf="canAddDescription(section)"> <li>
<a class="add-description-action" [routerLink]="['/descriptions/edit/' + item.id + '/' + section.id]"> <a class="add-description-action" [ngClass]="{'drag-handle-disabled': !canAddDescription(section)}" [routerLink]="canAddDescription(section) ? ['/descriptions/edit/' + item.id + '/' + section.id] : null">
<mat-icon>add</mat-icon>{{'DMP-EDITOR.ACTIONS.ADD-DESCRIPTION-IN-SECTION' | translate}} <mat-icon [matTooltipDisabled]="canAddDescription(section)" [matTooltip]="'DMP-EDITOR.DESCRIPTION-TEMPLATES-MAX-MULTIPLICITY' | translate">add</mat-icon>{{'DMP-EDITOR.ACTIONS.ADD-DESCRIPTION-IN-SECTION' | translate}}
</a> </a>
</li> </li>
<li *ngIf="!canAddDescription(section)">
<a [ngClass]="{'drag-handle-disabled': true}" class="add-description-action">
<mat-icon>add</mat-icon>{{'DMP-EDITOR.ACTIONS.ADD-DESCRIPTION-IN-SECTION' | translate}}
</a>
<small class="text-danger">{{'DMP-EDITOR.DESCRIPTION-TEMPLATES-MAX-MULTIPLICITY'| translate}}</small>
</li>
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -172,12 +172,18 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
prepareForm(data: Dmp) { prepareForm(data: Dmp) {
try { try {
this.editorModel = data ? new DmpEditorModel().fromModel(data) : new DmpEditorModel(); this.editorModel = data ? new DmpEditorModel().fromModel(data) : new DmpEditorModel();
if (data && data.descriptions) { if (data) {
if (data.status == DmpStatus.Finalized) { if(data.descriptions){
data.descriptions = data.descriptions.filter(x => x.isActive === IsActive.Active && x.status === DescriptionStatus.Finalized); if (data.status == DmpStatus.Finalized) {
} else { data.descriptions = data.descriptions.filter(x => x.isActive === IsActive.Active && x.status === DescriptionStatus.Finalized);
data.descriptions = data.descriptions.filter(x => x.isActive === IsActive.Active && x.status !== DescriptionStatus.Canceled); } else {
data.descriptions = data.descriptions.filter(x => x.isActive === IsActive.Active && x.status !== DescriptionStatus.Canceled);
}
} }
if(data.dmpDescriptionTemplates){
data.dmpDescriptionTemplates = data.dmpDescriptionTemplates.filter(x => x.isActive === IsActive.Active);
}
} }
this.item = data; this.item = data;
@ -416,7 +422,7 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
// //
// //
public descriptionsInSection(sectionId: Guid) { public descriptionsInSection(sectionId: Guid) {
return this.item?.descriptions?.filter(x => x?.dmpDescriptionTemplate?.sectionId === sectionId) || []; return this.item?.descriptions?.filter(x => x.isActive == IsActive.Active && x?.dmpDescriptionTemplate?.sectionId === sectionId && x.dmpDescriptionTemplate.isActive == IsActive.Active) || [];
} }
editDescription(id: string, isNew: boolean) { editDescription(id: string, isNew: boolean) {
@ -459,6 +465,10 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
if (section.descriptionTemplates?.length > 0){ if (section.descriptionTemplates?.length > 0){
const descriptions = this.descriptionsInSection(section.id) const descriptions = this.descriptionsInSection(section.id)
if (this.item.dmpDescriptionTemplates.filter(x => x.sectionId == section.id).length > descriptions.map(x => x.dmpDescriptionTemplate).length){
return true;
}
let multiplicityValidResults :boolean[] = []; let multiplicityValidResults :boolean[] = [];
section.descriptionTemplates.forEach(sectionDescriptionTemplate => { section.descriptionTemplates.forEach(sectionDescriptionTemplate => {
if (sectionDescriptionTemplate.maxMultiplicity != null){ if (sectionDescriptionTemplate.maxMultiplicity != null){

View File

@ -62,6 +62,7 @@ export class DmpEditorResolver extends BaseEditorResolver {
[nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.id)].join('.'), [nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.id)].join('.'),
[nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'), [nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'),
[nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.descriptionTemplateGroupId)].join('.'), [nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.descriptionTemplateGroupId)].join('.'),
[nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.isActive)].join('.'),
[nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.id)].join('.'), [nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.id)].join('.'),
[nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.user.id)].join('.'), [nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.user.id)].join('.'),