fix on create/copy description dialog

This commit is contained in:
Sofia Papacharalampous 2024-07-09 18:04:11 +03:00
parent 57a3c265ad
commit 4753952ea0
2 changed files with 35 additions and 1 deletions

View File

@ -18,6 +18,9 @@ import { nameof } from 'ts-simple-nameof';
import { FilterService } from '@common/modules/text-filter/filter-service';
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import { DescriptionTemplatesInSection, PlanBlueprint, PlanBlueprintDefinition, PlanBlueprintDefinitionSection } from '@app/core/model/plan-blueprint/plan-blueprint';
import { TenantLookup } from '@app/core/query/tenant.lookup';
import { Tenant } from '@app/core/model/tenant/tenant';
import { AuthService } from '@app/core/services/auth/auth.service';
@Component({
selector: 'description-copy-dialog-component',
@ -64,6 +67,19 @@ export class DescriptionCopyDialogComponent {
]
};
if (this.authService.selectedTenant() != 'default') {
lookup.tenantSubQuery = new TenantLookup();
lookup.tenantSubQuery.metadata = { countAll: true };
lookup.tenantSubQuery.isActive = [IsActive.Active];
lookup.tenantSubQuery.project = {
fields: [
nameof<Tenant>(x => x.code),
]
};
lookup.tenantSubQuery.codes = [this.authService.selectedTenant()];
}
if (planDescriptionTemplateSubQuery != null) lookup.planDescriptionTemplateSubQuery = planDescriptionTemplateSubQuery;
lookup.order = { items: [nameof<Plan>(x => x.label)] };
if (like) { lookup.like = this.filterService.transformLike(like); }
@ -76,6 +92,7 @@ export class DescriptionCopyDialogComponent {
public descriptionService: DescriptionService,
public language: TranslateService,
private filterService: FilterService,
private authService: AuthService,
@Inject(MAT_DIALOG_DATA) public data: any
) { }

View File

@ -16,6 +16,9 @@ import { Guid } from '@common/types/guid';
import { TranslateService } from '@ngx-translate/core';
import { map } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
import { AuthService } from '@app/core/services/auth/auth.service';
import { TenantLookup } from '@app/core/query/tenant.lookup';
import { Tenant } from '@app/core/model/tenant/tenant';
@Component({
selector: 'app-start-new-description-dialog',
@ -52,6 +55,19 @@ export class StartNewDescriptionDialogComponent extends BaseComponent {
nameof<Plan>(x => x.createdAt),
]
};
if (this.authService.selectedTenant() != 'default') {
lookup.tenantSubQuery = new TenantLookup();
lookup.tenantSubQuery.metadata = { countAll: true };
lookup.tenantSubQuery.isActive = [IsActive.Active];
lookup.tenantSubQuery.project = {
fields: [
nameof<Tenant>(x => x.code),
]
};
lookup.tenantSubQuery.codes = [this.authService.selectedTenant()];
}
if (planDescriptionTemplateSubQuery != null) lookup.planDescriptionTemplateSubQuery = planDescriptionTemplateSubQuery;
lookup.order = { items: [nameof<Plan>(x => x.label)] };
if (like) { lookup.like = this.filterService.transformLike(like); }
@ -65,7 +81,8 @@ export class StartNewDescriptionDialogComponent extends BaseComponent {
private language: TranslateService,
private planService: PlanService,
private filterService: FilterService,
private dateTimeFormatPipe: DateTimeFormatPipe
private dateTimeFormatPipe: DateTimeFormatPipe,
private authService: AuthService,
) {
super();
this.formGroup = data.formGroup;