mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
CST-11045 Dropdown behavior improved, working on multiple dropdowns
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
<div>
|
<div>
|
||||||
<ng-container *ngIf="patternsLoaded">
|
<ng-container>
|
||||||
<div *ngFor="let pattern of patterns; let i = index" class="col mt-3">
|
<div *ngFor="let pattern of patterns; let i = index" class="col mt-3">
|
||||||
<label class="mt-2 row">Request {{ pattern }} at the following service</label>
|
<label class="mt-2 row">Request {{ pattern }} at the following service</label>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<select [(ngModel)]="selectedServices[pattern]" class="form-control col">
|
<select [(ngModel)]="selectedServicesByPattern[pattern]" [compareWith]="compareById" class="form-control col">
|
||||||
<option *ngFor="let service of filterServices(pattern)" [ngValue]="service">
|
<option [ngValue]="null" selected>Select a service</option>
|
||||||
|
<option *ngFor="let service of (filterServices(pattern) | async)" [ngValue]="service">
|
||||||
{{ service.name }}
|
{{ service.name }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
@@ -14,9 +15,9 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<small class="row">Select a service for {{ pattern }} of this item</small>
|
<small class="row" *ngIf="!selectedServicesByPattern[pattern]">Select a service for {{ pattern }} of this item</small>
|
||||||
<div class="row">
|
<div class="row mt-1">
|
||||||
<div *ngIf="selectedServices[pattern]" class="alert alert-success col">
|
<div *ngIf="selectedServicesByPattern[pattern]" class="alert alert-success col">
|
||||||
<div class="row ml-2 mt-2 mb-1">
|
<div class="row ml-2 mt-2 mb-1">
|
||||||
<img alt="Coar-Notify-Pattern" class="coar-img-submission "
|
<img alt="Coar-Notify-Pattern" class="coar-img-submission "
|
||||||
src="../../../../assets/images/notify_logo.png">
|
src="../../../../assets/images/notify_logo.png">
|
||||||
@@ -27,7 +28,7 @@
|
|||||||
<img alt="Coar-Notify-Pattern" class="coar-img-submission invisible"
|
<img alt="Coar-Notify-Pattern" class="coar-img-submission invisible"
|
||||||
src="../../../../assets/images/notify_logo.png">
|
src="../../../../assets/images/notify_logo.png">
|
||||||
<i class="fa-solid fa-circle-check icon-check ml-2 invisible"></i>
|
<i class="fa-solid fa-circle-check icon-check ml-2 invisible"></i>
|
||||||
<div class="mt-1 ml-4" >{{ selectedServices[pattern].name }}: {{ selectedServices[pattern].description }}</div>
|
<div class="mt-1 ml-4" >{{ selectedServicesByPattern[pattern].name }}: {{ selectedServicesByPattern[pattern].description }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-1 invisible">
|
<div class="col-sm-1 invisible">
|
||||||
|
@@ -30,7 +30,7 @@ import { SubmissionCoarNotifyConfig } from './submission-coar-notify.config';
|
|||||||
import { FormFieldPreviousValueObject } from '../../../shared/form/builder/models/form-field-previous-value-object';
|
import { FormFieldPreviousValueObject } from '../../../shared/form/builder/models/form-field-previous-value-object';
|
||||||
import { UntypedFormGroup } from '@angular/forms';
|
import { UntypedFormGroup } from '@angular/forms';
|
||||||
import { AlertType } from '../../../shared/alert/aletr-type';
|
import { AlertType } from '../../../shared/alert/aletr-type';
|
||||||
import { filter, map, take } from "rxjs/operators";
|
import { filter, map } from 'rxjs/operators';
|
||||||
|
|
||||||
export interface CoarNotifyDropdownSelector {
|
export interface CoarNotifyDropdownSelector {
|
||||||
ldnService: LdnService;
|
ldnService: LdnService;
|
||||||
@@ -58,7 +58,7 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent
|
|||||||
|
|
||||||
|
|
||||||
patterns: string[] = [];
|
patterns: string[] = [];
|
||||||
selectedServices: { [key: string]: LdnService } = {};
|
selectedServicesByPattern: { [key: string]: LdnService } = {};
|
||||||
patternServices: { [key: string]: LdnService } = {};
|
patternServices: { [key: string]: LdnService } = {};
|
||||||
|
|
||||||
patternsLoaded = false;
|
patternsLoaded = false;
|
||||||
@@ -159,13 +159,8 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent
|
|||||||
this.formModel = this.formBuilderService.fromJSON(SECTION_COAR_FORM_MODEL);
|
this.formModel = this.formBuilderService.fromJSON(SECTION_COAR_FORM_MODEL);
|
||||||
this.setCoarNotifyConfig();
|
this.setCoarNotifyConfig();
|
||||||
this.fetchLdnServices();
|
this.fetchLdnServices();
|
||||||
this.coarNotifyConfigRD$.subscribe(data => {
|
|
||||||
console.log(data);
|
|
||||||
});
|
|
||||||
this.ldnServicesRD$.subscribe(data => {
|
|
||||||
console.log(data);
|
|
||||||
});
|
|
||||||
this.pathCombiner = new JsonPatchOperationPathCombiner('sections', this.sectionData.id);
|
this.pathCombiner = new JsonPatchOperationPathCombiner('sections', this.sectionData.id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -185,6 +180,9 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compareById(service1, service2){
|
||||||
|
return service1 && service2 && service1.id === service2.id;
|
||||||
|
}
|
||||||
|
|
||||||
addService() {
|
addService() {
|
||||||
this.patterns.push('');
|
this.patterns.push('');
|
||||||
@@ -302,6 +300,8 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsubscribe from all subscriptions
|
* Unsubscribe from all subscriptions
|
||||||
*/
|
*/
|
||||||
@@ -313,7 +313,7 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called when section is initialized
|
* Method called when section is initialized
|
||||||
* Retriev available NotifyConfigs
|
* Retriev available LdnServices
|
||||||
*/
|
*/
|
||||||
fetchLdnServices() {
|
fetchLdnServices() {
|
||||||
if (!this.ldnServicesRD$) {
|
if (!this.ldnServicesRD$) {
|
||||||
@@ -321,47 +321,24 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent
|
|||||||
getFirstCompletedRemoteData()
|
getFirstCompletedRemoteData()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ldnServicesRD$.subscribe((data) => {
|
|
||||||
if (this.patternsLoaded) {
|
|
||||||
this.patterns.forEach((pattern) => {
|
|
||||||
const servicesWithPattern = this.getServicesWithPattern(pattern, data?.payload?.page);
|
|
||||||
|
|
||||||
if (servicesWithPattern.length > 0) {
|
|
||||||
this.selectedServices[pattern] = servicesWithPattern[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Pattern:', pattern);
|
/**
|
||||||
console.log('Service:', this.selectedServices[pattern]);
|
* Method called when dropdowns for the section are initialized
|
||||||
|
* Retrieve services with corresponding patterns to the dropdowns.
|
||||||
|
*/
|
||||||
|
filterServices(pattern: string) {
|
||||||
|
|
||||||
if (this.selectedServices[pattern]) {
|
return this.ldnServicesRD$.pipe(
|
||||||
console.log('Name:', this.selectedServices[pattern].name);
|
|
||||||
console.log('Description:', this.selectedServices[pattern].description);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getServicesWithPattern(pattern: string, services: LdnService[] | null): LdnService[] {
|
|
||||||
if (services) {
|
|
||||||
return services.filter((service) => this.hasInboundPattern(service, pattern));
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
filterServices(pattern: string): LdnService[] {
|
|
||||||
let ldnServices: LdnService[] = [];
|
|
||||||
|
|
||||||
this.ldnServicesRD$.pipe(
|
|
||||||
filter((rd) => rd.hasSucceeded),
|
filter((rd) => rd.hasSucceeded),
|
||||||
map((rd) => rd.payload.page)
|
map((rd) => rd.payload.page.filter((service) =>
|
||||||
).subscribe((services) => {
|
this.hasInboundPattern(service, pattern)))
|
||||||
ldnServices = services.filter((service) => this.hasInboundPattern(service, pattern));
|
);
|
||||||
});
|
//.subscribe((services) => {
|
||||||
|
//ldnServices = services.filter((service) => this.hasInboundPattern(service, pattern));
|
||||||
|
//});
|
||||||
|
|
||||||
return ldnServices;
|
//return ldnServices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -369,16 +346,10 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent
|
|||||||
|
|
||||||
|
|
||||||
hasInboundPattern(service: any, patternType: string): boolean {
|
hasInboundPattern(service: any, patternType: string): boolean {
|
||||||
console.log('Pattern Type:', patternType);
|
|
||||||
console.log('Inbound Patterns in Service:', service.notifyServiceInboundPatterns);
|
|
||||||
|
|
||||||
const hasPattern = service.notifyServiceInboundPatterns.some((pattern: { pattern: string; }) => {
|
return service.notifyServiceInboundPatterns.some((pattern: { pattern: string; }) => {
|
||||||
console.log('Checking Pattern:', pattern.pattern);
|
|
||||||
return pattern.pattern === patternType;
|
return pattern.pattern === patternType;
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Has Inbound Pattern:', hasPattern);
|
|
||||||
return hasPattern;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getSectionStatus(): Observable<boolean> {
|
protected getSectionStatus(): Observable<boolean> {
|
||||||
|
Reference in New Issue
Block a user