fix Test errors, hide COAR requests with no LDN associable

This commit is contained in:
frabacche
2024-02-26 15:30:26 +01:00
parent fbd5dd41ed
commit 14976e0e06
2 changed files with 122 additions and 114 deletions

View File

@@ -3,22 +3,28 @@ import { TestBed } from '@angular/core/testing';
import { NotifyInfoService } from './notify-info.service'; import { NotifyInfoService } from './notify-info.service';
import { ConfigurationDataService } from '../../data/configuration-data.service'; import { ConfigurationDataService } from '../../data/configuration-data.service';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { AuthorizationDataService } from '../../data/feature-authorization/authorization-data.service';
describe('NotifyInfoService', () => { describe('NotifyInfoService', () => {
let service: NotifyInfoService; let service: NotifyInfoService;
let configurationDataService: any; let configurationDataService: any;
let authorizationDataService: any;
beforeEach(() => { beforeEach(() => {
configurationDataService = { authorizationDataService = {
findByPropertyName: jasmine.createSpy('findByPropertyName').and.returnValue(of({})), isAuthorized: jasmine.createSpy('isAuthorized').and.returnValue(of(true)),
}; };
configurationDataService = {
findByPropertyName: jasmine.createSpy('findByPropertyName').and.returnValue(of({})),
};
TestBed.configureTestingModule({ TestBed.configureTestingModule({
providers: [ providers: [
NotifyInfoService, NotifyInfoService,
{ provide: ConfigurationDataService, useValue: configurationDataService }, { provide: ConfigurationDataService, useValue: configurationDataService },
{ provide: AuthorizationDataService, useValue: authorizationDataService }
] ]
}); });
service = TestBed.inject(NotifyInfoService); service = TestBed.inject(NotifyInfoService);
authorizationDataService = TestBed.inject(AuthorizationDataService);
configurationDataService = TestBed.inject(ConfigurationDataService); configurationDataService = TestBed.inject(ConfigurationDataService);
}); });

View File

@@ -1,138 +1,140 @@
<div class="container-fluid"> <div class="container-fluid">
<ng-container *ngIf="patterns?.length > 0"> <ng-container *ngIf="patterns?.length > 0 ">
<div *ngFor="let ldnPattern of patterns; let i = index" class="col"> <div *ngFor="let ldnPattern of patterns; let i = index" class="col">
<label class="row col-form-label" <div *ngIf="(filterServices(ldnPattern.pattern ) | async)?.length > 0">
<label class="row col-form-label"
> >
{{'submission.section.section-coar-notify.control.' + ldnPattern.pattern + '.label' | translate }} {{'submission.section.section-coar-notify.control.' + ldnPattern.pattern + '.label' | translate }}
</label </label
> >
<div *ngIf="ldnServiceByPattern[ldnPattern.pattern]?.services.length"> <div *ngIf="ldnServiceByPattern[ldnPattern.pattern]?.services.length">
<div <div
*ngFor=" *ngFor="
let service of ldnServiceByPattern[ldnPattern.pattern].services; let service of ldnServiceByPattern[ldnPattern.pattern].services;
let serviceIndex = index let serviceIndex = index
" "
> >
<div class="row"> <div class="row">
<div ngbDropdown #myDropdown="ngbDropdown" [class.mt-2]="serviceIndex > 0" class="flex-grow-1"> <div ngbDropdown #myDropdown="ngbDropdown" [class.mt-2]="serviceIndex > 0" class="flex-grow-1">
<div class="position-relative right-addon" role="combobox"> <div class="position-relative right-addon" role="combobox">
<i ngbDropdownToggle class="position-absolute scrollable-dropdown-toggle" <i ngbDropdownToggle class="position-absolute scrollable-dropdown-toggle"
aria-hidden="true"></i> aria-hidden="true"></i>
<input <input
type="text" type="text"
[readonly]="true" [readonly]="true"
ngbDropdownAnchor ngbDropdownAnchor
[ngClass]="{'border-danger': (getShownSectionErrors$(ldnPattern.pattern, serviceIndex) | async)?.length > 0}" [ngClass]="{'border-danger': (getShownSectionErrors$(ldnPattern.pattern, serviceIndex) | async)?.length > 0}"
class="form-control w-100 scrollable-dropdown-input" class="form-control w-100 scrollable-dropdown-input"
[value]="ldnServiceByPattern[ldnPattern.pattern].services[serviceIndex]?.name" [value]="ldnServiceByPattern[ldnPattern.pattern].services[serviceIndex]?.name"
(click)="myDropdown.open()" (click)="myDropdown.open()"
/> />
</div> </div>
<div
ngbDropdownMenu
class="dropdown-menu scrollable-dropdown-menu w-100"
aria-haspopup="true"
aria-expanded="false"
>
<div <div
class="scrollable-menu" ngbDropdownMenu
role="listbox" class="dropdown-menu scrollable-dropdown-menu w-100"
infiniteScroll aria-haspopup="true"
[infiniteScrollDistance]="2" aria-expanded="false"
[infiniteScrollThrottle]="50"
[scrollWindow]="false"
> >
<button <div
*ngIf="(filterServices(ldnPattern.pattern) | async)?.length == 0" class="scrollable-menu"
class="dropdown-item collection-item text-truncate w-100" role="listbox"
infiniteScroll
[infiniteScrollDistance]="2"
[infiniteScrollThrottle]="50"
[scrollWindow]="false"
> >
{{'submission.section.section-coar-notify.dropdown.no-data' | translate}} <button
</button> *ngIf="(filterServices(ldnPattern.pattern) | async)?.length == 0"
<button class="dropdown-item collection-item text-truncate w-100"
*ngIf="(filterServices(ldnPattern.pattern ) | async)?.length > 0" >
class="dropdown-item collection-item text-truncate w-100" {{'submission.section.section-coar-notify.dropdown.no-data' | translate}}
(click)="onChange(ldnPattern.pattern, serviceIndex, null)" </button>
> <button
{{'submission.section.section-coar-notify.dropdown.select-none' | translate}} *ngIf="(filterServices(ldnPattern.pattern ) | async)?.length > 0"
</button> class="dropdown-item collection-item text-truncate w-100"
<button (click)="onChange(ldnPattern.pattern, serviceIndex, null)"
*ngFor="let serviceOption of filterServices(ldnPattern.pattern ) | async" >
[ngClass]="{'bg-light': ldnServiceByPattern[ldnPattern.pattern ].services[serviceIndex]?.id == serviceOption.id}" {{'submission.section.section-coar-notify.dropdown.select-none' | translate}}
class="dropdown-item collection-item text-truncate w-100" </button>
(click)="onChange(ldnPattern.pattern, serviceIndex, serviceOption)" <button
> *ngFor="let serviceOption of filterServices(ldnPattern.pattern ) | async"
<b> [ngClass]="{'bg-light': ldnServiceByPattern[ldnPattern.pattern ].services[serviceIndex]?.id == serviceOption.id}"
{{ serviceOption.name }} class="dropdown-item collection-item text-truncate w-100"
</b> (click)="onChange(ldnPattern.pattern, serviceIndex, serviceOption)"
<br /> >
{{ serviceOption.description }} <b>
</button> {{ serviceOption.name }}
</b>
<br />
{{ serviceOption.description }}
</button>
</div>
</div> </div>
</div> </div>
<button *ngIf="ldnServiceByPattern[ldnPattern.pattern].services.length > 1"
type="button" [class.mt-2]="serviceIndex > 0"
class="btn btn-secondary ml-2"
role="button"
title="{{'form.remove' | translate}}"
[attr.aria-label]="'form.remove' | translate"
(click)="removeService(ldnPattern, serviceIndex)"
>
<span><i class="fas fa-trash" aria-hidden="true"></i></span>
</button>
</div> </div>
<button *ngIf="ldnServiceByPattern[ldnPattern.pattern].services.length > 1"
type="button" [class.mt-2]="serviceIndex > 0"
class="btn btn-secondary ml-2"
role="button"
title="{{'form.remove' | translate}}"
[attr.aria-label]="'form.remove' | translate"
(click)="removeService(ldnPattern, serviceIndex)"
>
<span><i class="fas fa-trash" aria-hidden="true"></i></span>
</button>
</div>
<small <small
class="row text-muted" class="row text-muted"
*ngIf="!ldnServiceByPattern[ldnPattern.pattern].services[serviceIndex] && *ngIf="!ldnServiceByPattern[ldnPattern.pattern].services[serviceIndex] &&
serviceIndex === ldnServiceByPattern[ldnPattern.pattern].services.length -1" serviceIndex === ldnServiceByPattern[ldnPattern.pattern].services.length -1"
>
{{'submission.section.section-coar-notify.small.notification' | translate : {pattern : ldnPattern.pattern} }}
</small>
<ng-container *ngIf="(getShownSectionErrors$(ldnPattern.pattern , serviceIndex) | async)?.length > 0">
<small class="row text-danger" *ngFor="let error of (getShownSectionErrors$(ldnPattern.pattern , serviceIndex) | async)">
{{ error.message | translate}}
</small>
</ng-container>
<div
class="row mt-1"
*ngIf="ldnServiceByPattern[ldnPattern.pattern].services[serviceIndex]"
>
<div
class="alert alert-info w-100 d-flex align-items-center flex-row"
> >
<i class="fa-solid fa-circle-info fa-xl ml-2"></i> {{'submission.section.section-coar-notify.small.notification' | translate : {pattern : ldnPattern.pattern} }}
<div class="ml-4"> </small>
<div>{{ 'submission.section.section-coar-notify.selection.description' | translate }}</div> <ng-container *ngIf="(getShownSectionErrors$(ldnPattern.pattern , serviceIndex) | async)?.length > 0">
<div *ngIf="ldnServiceByPattern[ldnPattern.pattern].services[serviceIndex]?.description; else noDesc"> <small class="row text-danger" *ngFor="let error of (getShownSectionErrors$(ldnPattern.pattern , serviceIndex) | async)">
{{ ldnServiceByPattern[ldnPattern.pattern].services[serviceIndex].description }} {{ error.message | translate}}
</div> </small>
<ng-template #noDesc> </ng-container>
<div
class="row mt-1"
*ngIf="ldnServiceByPattern[ldnPattern.pattern].services[serviceIndex]"
>
<div
class="alert alert-info w-100 d-flex align-items-center flex-row"
>
<i class="fa-solid fa-circle-info fa-xl ml-2"></i>
<div class="ml-4">
<div>{{ 'submission.section.section-coar-notify.selection.description' | translate }}</div>
<div *ngIf="ldnServiceByPattern[ldnPattern.pattern].services[serviceIndex]?.description; else noDesc">
{{ ldnServiceByPattern[ldnPattern.pattern].services[serviceIndex].description }}
</div>
<ng-template #noDesc>
<span class="text-muted"> <span class="text-muted">
{{ 'submission.section.section-coar-notify.selection.no-description' | translate }} {{ 'submission.section.section-coar-notify.selection.no-description' | translate }}
</span> </span>
</ng-template> </ng-template>
</div>
</div> </div>
</div> </div>
</div> <div class="row" *ngIf="(getShownSectionErrors$(ldnPattern.pattern, serviceIndex) | async)?.length > 0">
<div class="row" *ngIf="(getShownSectionErrors$(ldnPattern.pattern, serviceIndex) | async)?.length > 0"> <div
<div class="alert alert-danger w-100 d-flex align-items-center flex-row"
class="alert alert-danger w-100 d-flex align-items-center flex-row" >
> <div class="ml-4">
<div class="ml-4">
<span> <span>
{{ 'submission.section.section-coar-notify.notification.error' | translate }} {{ 'submission.section.section-coar-notify.notification.error' | translate }}
</span> </span>
</div>
</div> </div>
</div> </div>
</div> <div class="row">
<div class="row"> <div *ngIf="ldnPattern.multipleRequest && (serviceIndex === ldnServiceByPattern[ldnPattern.pattern].services.length - 1)"
<div *ngIf="ldnPattern.multipleRequest && (serviceIndex === ldnServiceByPattern[ldnPattern.pattern].services.length - 1)" (click)="addNewService(ldnPattern)"
(click)="addNewService(ldnPattern)" class="btn btn-link mt-2 pl-0"
class="btn btn-link mt-2 pl-0" >
> <i class="fas fa-plus"></i>
<i class="fas fa-plus"></i> {{ 'submission.sections.general.add-more' | translate }}
{{ 'submission.sections.general.add-more' | translate }} </div>
</div> </div>
</div> </div>
</div> </div>