From fc9e77b887f6f710ccdac09df1d05843bdb48ead Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Mon, 20 Feb 2023 20:54:26 +0200 Subject: [PATCH] [Library | explore-redesign]: Fixes on FoS and SDGs suggest modal (checked existing subjects, added loading) - In FoS fixed scrolling, search and final response of selected fields. 1. composer.ts & resultLanding.component.ts: Removed "and Technology" from "Fields of Science" typename. 2. resultLanding.component.html: Bind (suggestClicked) to instead of (feedbackClicked). 3. input.component.ts: [Bug fix] Added check in "filter()" method if option.label. 4. sdg-selection.component.ts: [Bug fix] Set this.loading = false; inside subscribe. 5. fos.component.ts: In title, updated FOS to FoS. 6. sdg-fos-suggest.module.ts: Imported LoadingModule. 7. sdg-fos-suggest.component.ts: Show loading when sending email | Do not initialize and before subjects have value (this way inputs of existing fos/sdgs are checked). 8. fos-selection.component.ts: a. Added @Input() inModal: boolean = false; to set activeSection, when inModal, instead of navigating with fragment. b. [Bug fix] Set this.loading = false; inside subscribe. c. Call this.setObserver(); both in ngOnInit and when keyword changes. d. Updated threshold of observer from 0.25 to 0.1 (large FoS categories were never triggered on scrolling, because less than 25% of their content was visible). e. Updated fosOptions to Map to track easily checked inputs and updated getSelectedSubjects() accordingly. 9. fos-selection.component.html: In search-input of keyword no options are needed | Updated ngModel of checkbox inputs. 10. cache-interceptor.service.ts: Added check if (!properties.useLongCache) to skip cache. --- cache-interceptor.service.ts | 5 +++ .../fos-selection.component.html | 12 +++--- fos/fos-selection/fos-selection.component.ts | 39 +++++++++++++------ .../entity-metadata.component.ts | 16 ++++---- landingPages/landing-utils/fos.component.ts | 2 +- .../sdg-fos-suggest.component.ts | 14 ++++--- .../sdg-fos-suggest/sdg-fos-suggest.module.ts | 3 +- .../result/resultLanding.component.html | 4 +- .../result/resultLanding.component.ts | 3 +- sdg/sdg-selection/sdg-selection.component.ts | 4 +- sharedComponents/input/input.component.ts | 2 +- utils/email/composer.ts | 2 +- 12 files changed, 65 insertions(+), 41 deletions(-) diff --git a/cache-interceptor.service.ts b/cache-interceptor.service.ts index 12f5c557..a3a67d32 100644 --- a/cache-interceptor.service.ts +++ b/cache-interceptor.service.ts @@ -49,6 +49,11 @@ export class CacheInterceptorService implements HttpInterceptor { } public checkForCachedRequests(url){ + // Do not call cache when it is not enabled at all. + // This property is not correctly used here. A new property should be introduced. For now it is ok. + if (!properties.useLongCache) { + return false; + } if(url.indexOf("refine=true") !== -1 || url.indexOf("/count?format=json") !== -1 || url.indexOf("relresulttype%3Dpublication") !== -1) { return this.cachingRequests.some(partUrl => (url.indexOf(partUrl) !== -1)); } diff --git a/fos/fos-selection/fos-selection.component.html b/fos/fos-selection/fos-selection.component.html index 1af39d33..eb877e23 100644 --- a/fos/fos-selection/fos-selection.component.html +++ b/fos/fos-selection/fos-selection.component.html @@ -4,7 +4,7 @@
-
@@ -30,7 +30,7 @@
-
@@ -77,7 +77,7 @@
@@ -110,10 +110,10 @@ -->
- - + {{project.funderShortname ? project.funderShortname : project.funderName}} @@ -183,25 +183,25 @@ import {Organization, Project} from "../../utils/result-preview/result-preview"; ({{project.code}}) , - ... + ... - + {{organization.name}} - , + , - ... + ... - + {{subject}} - {{(i < (subjects.slice(0, 10).length - 1)) ? "," : ""}} + , - ... + ... diff --git a/landingPages/landing-utils/fos.component.ts b/landingPages/landing-utils/fos.component.ts index 22734738..4b3236ec 100644 --- a/landingPages/landing-utils/fos.component.ts +++ b/landingPages/landing-utils/fos.component.ts @@ -38,7 +38,7 @@ import {StringUtils} from "../../utils/string-utils.class";
Beta
- Fields of Science (FOS) + Fields of Science (FoS)
diff --git a/landingPages/landing-utils/sdg-fos-suggest/sdg-fos-suggest.component.ts b/landingPages/landing-utils/sdg-fos-suggest/sdg-fos-suggest.component.ts index 3d012cb5..6c0d059a 100644 --- a/landingPages/landing-utils/sdg-fos-suggest/sdg-fos-suggest.component.ts +++ b/landingPages/landing-utils/sdg-fos-suggest/sdg-fos-suggest.component.ts @@ -15,10 +15,10 @@ import {StringUtils} from "../../../utils/string-utils.class"; template: ` - - +
@@ -29,8 +29,9 @@ import {StringUtils} from "../../../utils/string-utils.class"; (Optional)
- - + +
@@ -120,6 +121,7 @@ export class SdgFosSuggestComponent { this.selectionModal.alertTitle = "Please send your feedback on most relevant Fields of Science for this "+this.getEntityName(this.entityType)+"."; } } else { + this.sending = true; // email functionality this.form.get("subjects").setValue(this.selection.getSelectedSubjects().map(subject => subject.id)); this.subscriptions.push(this.emailService.contact(this.properties, @@ -142,7 +144,7 @@ export class SdgFosSuggestComponent { this.selectionModal.previousButton = false; this.selectionModal.stayOpen = false; } - // this.sending = false; + this.sending = false; }, error => { console.log(error); this.error = true; diff --git a/landingPages/landing-utils/sdg-fos-suggest/sdg-fos-suggest.module.ts b/landingPages/landing-utils/sdg-fos-suggest/sdg-fos-suggest.module.ts index 4d327c9e..13ddd8fc 100644 --- a/landingPages/landing-utils/sdg-fos-suggest/sdg-fos-suggest.module.ts +++ b/landingPages/landing-utils/sdg-fos-suggest/sdg-fos-suggest.module.ts @@ -8,10 +8,11 @@ import {InputModule} from "../../../sharedComponents/input/input.module"; import {SdgFosSuggestComponent} from "./sdg-fos-suggest.component"; import {AlertModalModule} from "../../../utils/modal/alertModal.module"; import {IconsModule} from "../../../utils/icons/icons.module"; +import {LoadingModule} from "../../../utils/loading/loading.module"; @NgModule({ imports: [ - CommonModule, FormsModule, InputModule, SdgSelectionModule, FosSelectionModule, RecaptchaModule, AlertModalModule, IconsModule + CommonModule, FormsModule, InputModule, SdgSelectionModule, FosSelectionModule, RecaptchaModule, AlertModalModule, IconsModule, LoadingModule ], declarations: [ SdgFosSuggestComponent diff --git a/landingPages/result/resultLanding.component.html b/landingPages/result/resultLanding.component.html index a2492f9e..19f43f81 100644 --- a/landingPages/result/resultLanding.component.html +++ b/landingPages/result/resultLanding.component.html @@ -719,7 +719,7 @@
-
@@ -871,7 +871,7 @@ - + diff --git a/landingPages/result/resultLanding.component.ts b/landingPages/result/resultLanding.component.ts index d2f24466..2ed5f2f1 100644 --- a/landingPages/result/resultLanding.component.ts +++ b/landingPages/result/resultLanding.component.ts @@ -116,7 +116,7 @@ export class ResultLandingComponent { 'Title', 'Authors', 'Access rights', 'Publisher information', 'Funding Information', 'Persistent identifiers', 'Sustainable Development Goals (SDGs)', - 'Fields of Science and Technology (FOS)', 'Other']; + 'Fields of Science (FoS)', 'Other']; public pidsArrayString: string = ""; public identifier: Identifier; @@ -993,6 +993,7 @@ export class ResultLandingComponent { this.sdgFosSuggest.subjects=this.resultLandingInfo.fos; this.sdgFosSuggest.subjectType="fos"; } + this.cdr.detectChanges(); this.sdgFosSuggest.openSelectionModal(); } diff --git a/sdg/sdg-selection/sdg-selection.component.ts b/sdg/sdg-selection/sdg-selection.component.ts index 2c42ff95..1a9101a2 100644 --- a/sdg/sdg-selection/sdg-selection.component.ts +++ b/sdg/sdg-selection/sdg-selection.component.ts @@ -28,8 +28,8 @@ export class SdgSelectionComponent { this.sdgs.push({code: element.code, id: element.id, label: element.label, html: element.html, checked: this.subjects?.includes(element.id)}); }); this.sdgs.push({code: '18', id: 'No SDGs are relevant for this ' + this.getEntityName(this.entityType), label: 'Not relevant', html: 'Not relevant', checked: false}); - }); - this.loading = false; + this.loading = false; + }); } public get firstColumn() { diff --git a/sharedComponents/input/input.component.ts b/sharedComponents/input/input.component.ts index d20bf6ff..8f7e50aa 100644 --- a/sharedComponents/input/input.component.ts +++ b/sharedComponents/input/input.component.ts @@ -476,7 +476,7 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang return (this.showOptionsOnEmpty) ? options : []; } const filterValue = value.toString().toLowerCase(); - options = options.filter(option => option.label.toLowerCase().indexOf(filterValue) != -1); + options = options.filter(option => (option.label && option.label.toLowerCase().indexOf(filterValue) != -1)); this.selectedIndex = options.findIndex(option => option.value === this.formControl.value); if (this.selectedIndex === -1) { this.selectedIndex = 0; diff --git a/utils/email/composer.ts b/utils/email/composer.ts index be93fefa..8e21bd62 100644 --- a/utils/email/composer.ts +++ b/utils/email/composer.ts @@ -142,7 +142,7 @@ export class Composer { if(subjectType == "sdg") { typeName = "Sustainable Development Goals (SDGs)"; } else { - typeName = "Fields of Science and Technology (FoS)"; + typeName = "Fields of Science (FoS)"; } let email: Email = new Email();