Update library. Fix an expression error in advanced-criteria. Add message if there are no subjects in each category.

This commit is contained in:
Konstantinos Triantafyllou 2023-06-27 12:39:52 +03:00
parent 94fc9bda53
commit 500dd61f9b
4 changed files with 376 additions and 353 deletions

@ -1 +1 @@
Subproject commit 0face4b57f291ea0168fe0d8fe32b51ebb1850d8
Subproject commit 8d8eda416b4873c50f689db54444f135396db56d

View File

@ -48,7 +48,7 @@ import {CommunityInfo} from "../../openaireLibrary/connect/community/communityIn
</div>
</div>
<fs-modal #filtersModal (okEmitter)="saveCriteria()" (cancelEmitter)="criteria.reset()"
[okButtonDisabled]="criteria && criteria.disabled">
[okButtonDisabled]="!criteria || criteria.disabled">
<div *ngIf="selectionCriteria" class="uk-container uk-container-large">
<criteria #criteria [height]="filtersModal.bodyHeight" [entityType]="'criterion'"
[entityTypePlural]="'criteria'" [selectionCriteria]="selectionCriteria">

View File

@ -31,19 +31,19 @@
<li class="uk-active" *ngIf="displayedAllSubjects?.length" (click)="groupSubjects(displayedAllSubjects, 'all')">
<a>All ({{displayedAllSubjects.length}})</a>
</li>
<li *ngIf="displayedSubjects?.length" (click)="groupSubjects(displayedSubjects, 'freeText')">
<li (click)="groupSubjects(displayedSubjects, 'freeText')">
<a>Free Text ({{displayedSubjects.length}})</a>
</li>
<li *ngIf="displayedSdg?.length" (click)="groupSubjects(displayedSdg, 'sdg')">
<li (click)="groupSubjects(displayedSdg, 'sdg')">
<a>SDGs ({{displayedSdg.length}})</a>
</li>
<li *ngIf="displayedFos?.length" (click)="groupSubjects(displayedFos, 'fos')">
<li (click)="groupSubjects(displayedFos, 'fos')">
<a>Fields of Science ({{displayedFos.length}})</a>
</li>
</ul>
<ul class="uk-switcher">
<li *ngIf="displayedAllSubjects?.length">
<ng-container *ngIf="groupedAllSubjects?.length">
<li>
<ng-container *ngIf="displayedAllSubjects?.length">
<div>
<ul class="uk-nav uk-nav-default uk-flex uk-flex-wrap">
<li *ngFor="let item of groupedAllSubjects; let i = index;" class="uk-margin-right" [class.uk-margin-left]="i != 0"
@ -97,9 +97,14 @@
</div>
</div>
</ng-container>
<ng-container *ngIf="displayedAllSubjects?.length === 0">
<div class="uk-position-relative uk-height-medium">
<h6 class="uk-position-center uk-margin-remove">There are no subjects yet</h6>
</div>
</ng-container>
</li>
<li *ngIf="displayedSubjects?.length">
<ng-container *ngIf="groupedSubjects?.length">
<li>
<ng-container *ngIf="displayedSubjects?.length">
<div>
<ul class="uk-nav uk-nav-default uk-flex uk-flex-wrap">
<li *ngFor="let item of groupedSubjects; let i = index;" class="uk-margin-right" [class.uk-margin-left]="i != 0"
@ -153,9 +158,14 @@
</div>
</div>
</ng-container>
<ng-container *ngIf="displayedSubjects?.length === 0">
<div class="uk-position-relative uk-height-medium">
<h6 class="uk-position-center uk-margin-remove">There are no subjects yet</h6>
</div>
</ng-container>
</li>
<li *ngIf="displayedSdg?.length">
<ng-container *ngIf="groupedSdg?.length">
<li>
<ng-container *ngIf="displayedSdg?.length">
<div>
<ul class="uk-nav uk-nav-default uk-flex uk-flex-wrap">
<li *ngFor="let item of groupedSdg; let i = index;" class="uk-margin-right" [class.uk-margin-left]="i != 0"
@ -209,9 +219,14 @@
</div>
</div>
</ng-container>
<ng-container *ngIf="displayedSdg?.length === 0">
<div class="uk-position-relative uk-height-medium">
<h6 class="uk-position-center uk-margin-remove">There are no subjects yet</h6>
</div>
</ng-container>
</li>
<li *ngIf="displayedFos?.length">
<ng-container *ngIf="groupedFos?.length">
<li>
<ng-container *ngIf="displayedFos?.length">
<div>
<ul class="uk-nav uk-nav-default uk-flex uk-flex-wrap">
<li *ngFor="let item of groupedFos; let i = index;" class="uk-margin-right" [class.uk-margin-left]="i != 0"
@ -265,7 +280,13 @@
</div>
</div>
</ng-container>
<ng-container *ngIf="displayedFos?.length === 0">
<div class="uk-position-relative uk-height-medium">
<h6 class="uk-position-center uk-margin-remove">There are no subjects yet</h6>
</div>
</ng-container>
</li>
</ul>
</div>
</div>

View File

@ -10,7 +10,9 @@ import {AlertModal} from '../../../openaireLibrary/utils/modal/alert';
import {SearchInputComponent} from '../../../openaireLibrary/sharedComponents/search-input/search-input.component';
import {forkJoin, Subscription} from 'rxjs';
import {CommunityInfo} from '../../../openaireLibrary/connect/community/communityInfo';
import {FullScreenModalComponent} from 'src/app/openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.component';
import {
FullScreenModalComponent
} from 'src/app/openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.component';
import {HelperFunctions} from 'src/app/openaireLibrary/utils/HelperFunctions.class';
import {NotificationHandler} from "../../../openaireLibrary/utils/notification-handler";
import {ClearCacheService} from "../../../openaireLibrary/services/clear-cache.service";
@ -91,13 +93,13 @@ export class SubjectsEditFormComponent implements OnInit {
this.displayedFos = this.originalFos.filter(subject => {
return !value || subject.toLowerCase().indexOf(value.toLowerCase()) != -1
});
if(this.activeTab === 'all') {
if (this.activeTab === 'all') {
this.groupSubjects(this.displayedAllSubjects, 'all');
} else if(this.activeTab === 'freeText') {
} else if (this.activeTab === 'freeText') {
this.groupSubjects(this.displayedSubjects, 'freeText');
} else if(this.activeTab === 'sdg') {
} else if (this.activeTab === 'sdg') {
this.groupSubjects(this.displayedSdg, 'sdg');
} else if(this.activeTab === 'fos') {
} else if (this.activeTab === 'fos') {
this.groupSubjects(this.displayedFos, 'fos');
}
}));
@ -113,7 +115,7 @@ export class SubjectsEditFormComponent implements OnInit {
community: encodeURIComponent(
'"' + community.queryId + '"')
};
this.community.subjects.sort((n1,n2)=> {
this.community.subjects.sort((n1, n2) => {
if (n1.toLowerCase() > n2.toLowerCase()) {
return 1;
}
@ -148,79 +150,79 @@ export class SubjectsEditFormComponent implements OnInit {
}
public groupSubjects(subjects: string[], type: string) {
if(subjects.length === 0) {
if (subjects.length === 0) {
return [];
}
subjects.sort((a, b) => a.localeCompare(b));
if(type === 'all') {
if (type === 'all') {
this.indexAll = 0;
this.activeTab = 'all';
this.groupedAllSubjects = Object.values(
subjects.reduce((acc, subject) => {
let firstLetter = subject[0].toLocaleUpperCase();
if(!acc[firstLetter]) {
if (!acc[firstLetter]) {
acc[firstLetter] = {group: firstLetter, data: [subject]};
} else {
acc[firstLetter].data.push(subject);
}
return acc;
},{})
}, {})
)
if(subjects.length > 1) {
if (subjects.length > 1) {
this.groupedAllSubjects.unshift({group: 'All', data: subjects});
}
}
if(type === 'freeText') {
if (type === 'freeText') {
this.indexSubjects = 0;
this.activeTab = 'freeText';
this.groupedSubjects = Object.values(
subjects.reduce((acc, subject) => {
let firstLetter = subject[0].toLocaleUpperCase();
if(!acc[firstLetter]) {
if (!acc[firstLetter]) {
acc[firstLetter] = {group: firstLetter, data: [subject]};
} else {
acc[firstLetter].data.push(subject);
}
return acc;
},{})
}, {})
)
if(subjects.length > 1) {
if (subjects.length > 1) {
this.groupedSubjects.unshift({group: 'All', data: subjects});
}
}
if(type === 'sdg') {
if (type === 'sdg') {
this.indexSdg = 0;
this.activeTab = 'sdg';
this.groupedSdg = Object.values(
subjects.reduce((acc, subject) => {
let firstLetter = subject[0].toLocaleUpperCase();
if(!acc[firstLetter]) {
if (!acc[firstLetter]) {
acc[firstLetter] = {group: firstLetter, data: [subject]};
} else {
acc[firstLetter].data.push(subject);
}
return acc;
},{})
}, {})
)
if(subjects.length > 1) {
if (subjects.length > 1) {
this.groupedSdg.unshift({group: 'All', data: subjects});
}
}
if(type === 'fos') {
if (type === 'fos') {
this.indexFos = 0;
this.activeTab = 'fos';
this.groupedFos = Object.values(
subjects.reduce((acc, subject) => {
let key = subject.substring(0,2).toLocaleUpperCase();
if(!acc[key]) {
let key = subject.substring(0, 2).toLocaleUpperCase();
if (!acc[key]) {
acc[key] = {group: key, data: [subject]};
} else {
acc[key].data.push(subject);
}
return acc;
},{})
}, {})
)
if(subjects.length > 1) {
if (subjects.length > 1) {
this.groupedFos.unshift({group: 'All', data: subjects});
}
}
@ -228,23 +230,23 @@ export class SubjectsEditFormComponent implements OnInit {
public changeDisplayedSubjects(i, group) {
this.subjectsColumns = [];
if(this.activeTab === 'all') {
if (this.activeTab === 'all') {
this.indexAll = i;
} else if(this.activeTab === 'freeText') {
} else if (this.activeTab === 'freeText') {
this.indexSubjects = i;
} else if(this.activeTab === 'sdg') {
} else if (this.activeTab === 'sdg') {
this.indexSdg = i;
} else if(this.activeTab === 'fos') {
} else if (this.activeTab === 'fos') {
this.indexFos = i;
}
if(group.data.length > this.subjectsLimit && group.group != 'All') {
if (group.data.length > this.subjectsLimit && group.group != 'All') {
this.divideSubjects(group);
}
}
public divideSubjects(group) {
let columns = [];
for(let i = 0; i < (group.data.length / this.subjectsLimit); i++) {
for (let i = 0; i < (group.data.length / this.subjectsLimit); i++) {
columns.push(group.data.slice(i * this.subjectsLimit, ((i + 1) * this.subjectsLimit)));
}
this.subjectsColumns = columns;
@ -275,7 +277,7 @@ export class SubjectsEditFormComponent implements OnInit {
}
public addSubjectsIntoList() {
if(this.addSubjectsInput.searchControl.getRawValue()) {
if (this.addSubjectsInput.searchControl.getRawValue()) {
this.addSubjectsInput.add(null, true);
}
this.subjectsForm.getRawValue().forEach(element => {
@ -324,7 +326,7 @@ export class SubjectsEditFormComponent implements OnInit {
}
handleUpdateError(message: string, error = null) {
if(error) {
if (error) {
console.error(error)
}
NotificationHandler.rise(message, 'danger');
@ -342,7 +344,7 @@ export class SubjectsEditFormComponent implements OnInit {
}
});
this._communityService.updateSubjects(this.community.subjects, this.community.fos, this.community.sdg);
this._clearCacheService.purgeBrowserCache("Subjects "+message, this.communityId);
this._clearCacheService.purgeBrowserCache("Subjects " + message, this.communityId);
NotificationHandler.rise('Subjects successfully ' + message + '!')
this.loading = false;
}