add new feature: selection criteria by FoS and SDGs

This commit is contained in:
Alex Martzios 2023-03-15 11:56:28 +02:00
parent 88be699fd2
commit 070f9d369d
2 changed files with 369 additions and 567 deletions

View File

@ -1,395 +1,316 @@
<div page-content>
<div actions class="uk-margin-top">
<div class="uk-section-xsmall">
<div class="uk-flex uk-flex-right@m uk-flex-center uk-flex-middle uk-grid uk-margin-top" uk-grid>
<div [disabled]="showLoading" search-input class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"
[searchControl]="filterForm" [expandable]="true" placeholder="Search Subjects" searchInputClass="outer">
</div>
<div>
<button class="uk-button uk-button-default uk-flex uk-flex-middle"
[disabled]="showLoading" [class.uk-disabled]="showLoading"
(click)="editAllSubjects()"
uk-tooltip="title:<div><div class='uk-margin-small-bottom uk-text-bold'>Add or edit subjects</div> All the research results associated to the subjects specified here will be automatically linked to the community dashboard in the next run of OpenAIRE workflows.</div>">
<span>Add/Edit Subjects</span>
</button>
</div>
</div>
</div>
</div>
<div actions class="uk-margin-top">
<div class="uk-section-xsmall">
<div class="uk-flex uk-flex-right@m uk-flex-center uk-flex-middle uk-grid uk-margin-top" uk-grid>
<div [disabled]="showLoading" search-input class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"
[searchControl]="filterForm" [expandable]="true" placeholder="Search Subjects" searchInputClass="outer">
</div>
<div>
<button class="uk-button uk-button-default uk-flex uk-flex-middle"
[disabled]="showLoading" [class.uk-disabled]="showLoading"
(click)="editAllSubjects()"
uk-tooltip="title:<div><div class='uk-margin-small-bottom uk-text-bold'>Add or edit subjects</div> All the research results associated to the subjects specified here will be automatically linked to the community dashboard in the next run of OpenAIRE workflows.</div>">
<span>Add/Edit Subjects</span>
</button>
</div>
</div>
</div>
</div>
<div inner>
<div class="uk-section uk-section-small uk-position-relative" style="min-height: 60vh">
<div *ngIf="showLoading" class="uk-position-center">
<div class="uk-section uk-section-small uk-position-relative" style="min-height: 60vh">
<div *ngIf="showLoading" class="uk-position-center">
<loading></loading>
</div>
<div *ngIf="!showLoading">
<!-- TODO: Alter following if statement to match new functionality -->
<div *ngIf="community.subjects.length == 0"
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<div>No subjects
<span *ngIf="originalSubjects.length == 0; else: notFound">for {{community.shortTitle}}</span>
<ng-template #notFound>found</ng-template>
</div>
</div>
<div *ngIf="community.subjects.length > 0">
<ul uk-tab class="uk-tab uk-margin-bottom uk-flex uk-flex-center uk-flex-left@m">
<li class="uk-active" *ngIf="displayedAllSubjects?.length">
<a>All ({{displayedAllSubjects.length}})</a>
</li>
<li *ngIf="displayedSubjects?.length" (click)="groupSubjects(displayedSubjects, 'freeText')">
<a>Free Text ({{displayedSubjects.length}})</a>
</li>
<li *ngIf="displayedSdg?.length" (click)="groupSubjects(displayedSdg, 'sdg')">
<a>SDGs ({{displayedSdg.length}})</a>
</li>
<li *ngIf="displayedFos?.length" (click)="groupSubjects(displayedFos, 'fos')">
<a>Fields of Science ({{displayedFos.length}})</a>
</li>
</ul>
<ul class="uk-switcher">
<li>
<ng-container *ngIf="groupedAllSubjects?.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"
[class]="index == i ? 'uk-active':''" (click)="changeDisplayedSubjects(i, item)">
<a class="uk-padding-remove">{{item.group}}</a>
</li>
</ul>
</div>
<!-- View for 'All' -->
<div *ngIf="index == 0 && groupedAllSubjects.length > 1" class="uk-margin-large-top uk-grid uk-child-width-1-4@m" uk-grid>
<div *ngFor="let item of groupedAllSubjects.slice(1); let i = index;">
<div>
<h6>{{item.group}}</h6>
<div *ngFor="let subItem of item.data.slice(0, subjectsLimit)" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
<div *ngIf="item.data.length > subjectsLimit">
<a (click)="changeDisplayedSubjects(i+1, item)" class="view-more-less-link">
View all
</a>
</div>
</div>
</div>
</div>
<!-- View for a single group -->
<div *ngIf="index != 0 || groupedAllSubjects.length == 1" class="uk-margin-large-top">
<div>
<div>
<h6>{{groupedAllSubjects[index].group}}</h6>
<ng-container *ngIf="subjectsColumns?.length == 0; else elseBlock">
<div *ngFor="let subItem of groupedAllSubjects[index].data" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
</ng-container>
<ng-template #elseBlock>
<div class="uk-grid uk-child-width-1-4@m" uk-grid>
<div *ngFor="let group of subjectsColumns">
<div *ngFor="let subItem of group" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
</div>
</div>
</ng-template>
</div>
</div>
</div>
</ng-container>
</li>
<li>
<ng-container *ngIf="groupedSubjects?.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"
[class]="index == i ? 'uk-active':''" (click)="changeDisplayedSubjects(i, item)">
<a class="uk-padding-remove">{{item.group}}</a>
</li>
</ul>
</div>
<!-- View for 'All' -->
<div *ngIf="index == 0 && groupedSubjects.length > 1" class="uk-margin-large-top uk-grid uk-child-width-1-4@m" uk-grid>
<div *ngFor="let item of groupedSubjects.slice(1); let i = index;">
<div>
<h6>{{item.group}}</h6>
<div *ngFor="let subItem of item.data.slice(0, subjectsLimit)" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
<div *ngIf="item.data.length > subjectsLimit">
<a (click)="changeDisplayedSubjects(i+1, item)" class="view-more-less-link">
View all
</a>
</div>
</div>
</div>
</div>
<!-- View for a single group -->
<div *ngIf="index != 0 || groupedSubjects.length == 1" class="uk-margin-large-top">
<div>
<div>
<h6>{{groupedSubjects[index].group}}</h6>
<ng-container *ngIf="subjectsColumns?.length == 0; else elseBlock">
<div *ngFor="let subItem of groupedSubjects[index].data" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
</ng-container>
<ng-template #elseBlock>
<div class="uk-grid uk-child-width-1-4@m" uk-grid>
<div *ngFor="let group of subjectsColumns">
<div *ngFor="let subItem of group" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
</div>
</div>
</ng-template>
</div>
</div>
</div>
</ng-container>
</li>
<li>
<ng-container *ngIf="groupedSdg?.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"
[class]="index == i ? 'uk-active':''" (click)="changeDisplayedSubjects(i, item)">
<a class="uk-padding-remove">{{item.group}}</a>
</li>
</ul>
</div>
<!-- View for 'All' -->
<div *ngIf="index == 0 && groupedSdg.length > 1" class="uk-margin-large-top uk-grid uk-child-width-1-4@m" uk-grid>
<div *ngFor="let item of groupedSdg.slice(1); let i = index;">
<div>
<h6>{{item.group}}</h6>
<div *ngFor="let subItem of item.data.slice(0, subjectsLimit)" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
<div *ngIf="item.data.length > subjectsLimit">
<a (click)="changeDisplayedSubjects(i+1, item)" class="view-more-less-link">
View all
</a>
</div>
</div>
</div>
</div>
<!-- View for a single group -->
<div *ngIf="index != 0 || groupedSdg.length == 1" class="uk-margin-large-top">
<div>
<div>
<h6>{{groupedSdg[index].group}}</h6>
<ng-container *ngIf="subjectsColumns?.length == 0; else elseBlock">
<div *ngFor="let subItem of groupedSdg[index].data" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
</ng-container>
<ng-template #elseBlock>
<div class="uk-grid uk-child-width-1-4@m" uk-grid>
<div *ngFor="let group of subjectsColumns">
<div *ngFor="let subItem of group" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
</div>
</div>
</ng-template>
</div>
</div>
</div>
</ng-container>
</li>
<li>
<ng-container *ngIf="groupedFos?.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"
[class]="index == i ? 'uk-active':''" (click)="changeDisplayedSubjects(i, item)">
<a class="uk-padding-remove">{{item.group}}</a>
</li>
</ul>
</div>
<!-- View for 'All' -->
<div *ngIf="index == 0 && groupedFos.length > 1" class="uk-margin-large-top uk-grid uk-child-width-1-4@m" uk-grid>
<div *ngFor="let item of groupedFos.slice(1); let i = index;">
<div>
<h6>{{item.group}}</h6>
<div *ngFor="let subItem of item.data.slice(0, subjectsLimit)" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
<div *ngIf="item.data.length > subjectsLimit">
<a (click)="changeDisplayedSubjects(i+1, item)" class="view-more-less-link">
View all
</a>
</div>
</div>
</div>
</div>
<!-- View for a single group -->
<div *ngIf="index != 0 || groupedFos.length == 1" class="uk-margin-large-top">
<div>
<div>
<h6>{{groupedFos[index].group}}</h6>
<ng-container *ngIf="subjectsColumns?.length == 0; else elseBlock">
<div *ngFor="let subItem of groupedFos[index].data" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
</ng-container>
<ng-template #elseBlock>
<div class="uk-grid uk-child-width-1-4@m" uk-grid>
<div *ngFor="let group of subjectsColumns">
<div *ngFor="let subItem of group" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
</div>
</div>
</ng-template>
</div>
</div>
</div>
</ng-container>
</li>
</ul>
</div>
<!-- <div *ngIf="community.subjects.length > 0">
<no-load-paging *ngIf="community.subjects.length > 0" [type]="'Subjects'"
[page]="page" [pageSize]="size" (pageChange)="updatePage($event)"
[totalResults]="community.subjects.length">
</no-load-paging>
<div class="uk-grid uk-grid-large uk-grid-match uk-child-width-1-1 uk-child-width-1-2@m uk-margin-top uk-margin-bottom" uk-grid>
<div *ngFor='let subject of currentPage; let i = index;'>
<div class="uk-card uk-card-default">
<div class="uk-card-body">
<h6 uk-tooltip="title:All the research results associated to this subjects will be automatically linked to the community dashboard."
class="uk-display-inline-block">
{{subject}}
</h6>
</div>
<div class="uk-card-footer uk-padding-remove-vertical">
<div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
<div *ngIf="!showLoading">
<div *ngIf="displayedSubjects?.length == 0 && displayedSdg?.length == 0 && displayedFos?.length == 0"
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<div>No subjects</div>
</div>
<div *ngIf="displayedSubjects?.length > 0 || displayedSdg?.length > 0 || displayedFos?.length > 0">
<ul uk-tab class="uk-tab uk-margin-bottom uk-flex uk-flex-center uk-flex-left@m">
<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')">
<a>Free Text ({{displayedSubjects.length}})</a>
</li>
<li *ngIf="displayedSdg?.length" (click)="groupSubjects(displayedSdg, 'sdg')">
<a>SDGs ({{displayedSdg.length}})</a>
</li>
<li *ngIf="displayedFos?.length" (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">
<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"
[class]="indexAll == i ? 'uk-active':''" (click)="changeDisplayedSubjects(i, item)">
<a class="uk-padding-remove">{{item.group}}</a>
</li>
</ul>
</div>
<!-- View for 'All' -->
<div *ngIf="indexAll == 0 && groupedAllSubjects.length > 1" class="uk-margin-large-top uk-grid uk-child-width-1-4@m" uk-grid>
<div *ngFor="let item of groupedAllSubjects.slice(1); let i = index;">
<div>
<div class="uk-padding-small uk-padding-remove-horizontal">
<a (click)="editSubject(subject)"
class="uk-button uk-button-link uk-flex uk-flex-middle">
<icon name="edit" [flex]="true"></icon>
<span class="uk-margin-xsmall-left">Edit</span>
<h6>{{item.group}}</h6>
<div *ngFor="let subItem of item.data.slice(0, subjectsLimit)" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
<div *ngIf="item.data.length > subjectsLimit">
<a (click)="changeDisplayedSubjects(i+1, item)" class="view-more-less-link">
View all
</a>
</div>
</div>
</div>
</div>
<!-- View for a single group -->
<div *ngIf="indexAll != 0 || groupedAllSubjects.length == 1" class="uk-margin-large-top">
<div>
<div>
<div class="uk-padding-small uk-padding-remove-horizontal">
<button class="uk-button uk-button-link uk-flex uk-flex-middle"
(click)="removeModalOpen(subject, i)">
<icon name="delete" [flex]="true"></icon>
<span class="uk-margin-xsmall-left">Delete</span>
</button>
<h6>{{groupedAllSubjects[indexAll].group}}</h6>
<ng-container *ngIf="subjectsColumns?.length == 0; else elseBlock">
<div *ngFor="let subItem of groupedAllSubjects[indexAll].data" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
</ng-container>
<ng-template #elseBlock>
<div class="uk-grid uk-child-width-1-4@m" uk-grid>
<div *ngFor="let group of subjectsColumns">
<div *ngFor="let subItem of group" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
</div>
</div>
</ng-template>
</div>
</div>
</div>
</ng-container>
</li>
<li *ngIf="displayedSubjects?.length">
<ng-container *ngIf="groupedSubjects?.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"
[class]="indexSubjects == i ? 'uk-active':''" (click)="changeDisplayedSubjects(i, item)">
<a class="uk-padding-remove">{{item.group}}</a>
</li>
</ul>
</div>
<!-- View for 'All' -->
<div *ngIf="indexSubjects == 0 && groupedSubjects.length > 1" class="uk-margin-large-top uk-grid uk-child-width-1-4@m" uk-grid>
<div *ngFor="let item of groupedSubjects.slice(1); let i = index;">
<div>
<h6>{{item.group}}</h6>
<div *ngFor="let subItem of item.data.slice(0, subjectsLimit)" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
<div *ngIf="item.data.length > subjectsLimit">
<a (click)="changeDisplayedSubjects(i+1, item)" class="view-more-less-link">
View all
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="uk-margin-small-top">
<paging-no-load [currentPage]="page" [totalResults]="community.subjects.length" [size]="size"
(pageChange)="updatePage($event)" customClasses="uk-flex-right@m uk-flex-center">
</paging-no-load>
</div>
</div> -->
</div>
</div>
</div>
<!-- View for a single group -->
<div *ngIf="indexSubjects != 0 || groupedSubjects.length == 1" class="uk-margin-large-top">
<div>
<div>
<h6>{{groupedSubjects[indexSubjects]?.group}}</h6>
<ng-container *ngIf="subjectsColumns?.length == 0; else elseBlock">
<div *ngFor="let subItem of groupedSubjects[indexSubjects]?.data" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
</ng-container>
<ng-template #elseBlock>
<div class="uk-grid uk-child-width-1-4@m" uk-grid>
<div *ngFor="let group of subjectsColumns">
<div *ngFor="let subItem of group" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
</div>
</div>
</ng-template>
</div>
</div>
</div>
</ng-container>
</li>
<li *ngIf="displayedSdg?.length">
<ng-container *ngIf="groupedSdg?.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"
[class]="indexSdg == i ? 'uk-active':''" (click)="changeDisplayedSubjects(i, item)">
<a class="uk-padding-remove">{{item.group}}</a>
</li>
</ul>
</div>
<!-- View for 'All' -->
<div *ngIf="indexSdg == 0 && groupedSdg.length > 1" class="uk-margin-large-top uk-grid uk-child-width-1-4@m" uk-grid>
<div *ngFor="let item of groupedSdg.slice(1); let i = index;">
<div>
<h6>{{item.group}}</h6>
<div *ngFor="let subItem of item.data.slice(0, subjectsLimit)" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
<div *ngIf="item.data.length > subjectsLimit">
<a (click)="changeDisplayedSubjects(i+1, item)" class="view-more-less-link">
View all
</a>
</div>
</div>
</div>
</div>
<!-- View for a single group -->
<div *ngIf="indexSdg != 0 || groupedSdg.length == 1" class="uk-margin-large-top">
<div>
<div>
<h6>{{groupedSdg[indexSdg].group}}</h6>
<ng-container *ngIf="subjectsColumns?.length == 0; else elseBlock">
<div *ngFor="let subItem of groupedSdg[indexSdg].data" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
</ng-container>
<ng-template #elseBlock>
<div class="uk-grid uk-child-width-1-4@m" uk-grid>
<div *ngFor="let group of subjectsColumns">
<div *ngFor="let subItem of group" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
</div>
</div>
</ng-template>
</div>
</div>
</div>
</ng-container>
</li>
<li *ngIf="displayedFos?.length">
<ng-container *ngIf="groupedFos?.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"
[class]="indexFos == i ? 'uk-active':''" (click)="changeDisplayedSubjects(i, item)">
<a class="uk-padding-remove">{{item.group}}</a>
</li>
</ul>
</div>
<!-- View for 'All' -->
<div *ngIf="indexFos == 0 && groupedFos.length > 1" class="uk-margin-large-top uk-grid uk-child-width-1-4@m" uk-grid>
<div *ngFor="let item of groupedFos.slice(1); let i = index;">
<div>
<h6>{{item.group}}</h6>
<div *ngFor="let subItem of item.data.slice(0, subjectsLimit)" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
<div *ngIf="item.data.length > subjectsLimit">
<a (click)="changeDisplayedSubjects(i+1, item)" class="view-more-less-link">
View all
</a>
</div>
</div>
</div>
</div>
<!-- View for a single group -->
<div *ngIf="indexFos != 0 || groupedFos.length == 1" class="uk-margin-large-top">
<div>
<div>
<h6>{{groupedFos[indexFos].group}}</h6>
<ng-container *ngIf="subjectsColumns?.length == 0; else elseBlock">
<div *ngFor="let subItem of groupedFos[indexFos].data" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
</ng-container>
<ng-template #elseBlock>
<div class="uk-grid uk-child-width-1-4@m" uk-grid>
<div *ngFor="let group of subjectsColumns">
<div *ngFor="let subItem of group" class="uk-margin-small-bottom">
<span [attr.uk-tooltip]="subItem.length > maxCharacters ? 'cls: uk-active' : 'cls: uk-invisible'" [title]="subItem">
{{subItem.length > maxCharacters ? subItem.substring(0,maxCharacters)+'...' : subItem}}
</span>
</div>
</div>
</div>
</ng-template>
</div>
</div>
</div>
</ng-container>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- <modal-alert #deleteModal (alertOutput)="saveSubjects()" [overflowBody]="false" classTitle="uk-background-primary uk-light"></modal-alert> -->
<fs-modal #fsModal classBody="uk-container-large" (okEmitter)="saveAllSubjects()" [okButtonDisabled]="!hasChanges && !sdgSelection.hasChanges && !fosSelection.hasChanges">
<div>
<ul uk-tab #modalTabs class="uk-tab uk-margin-top uk-margin-large-bottom uk-flex uk-flex-center uk-flex-left@m">
<li class="uk-active">
<a>Free Text ({{displayedSubjects.length}})</a>
</li>
<li>
<a>SDGs ({{sdgSelection.getSelectedSubjects().length}})</a>
</li>
<li>
<a>Fields of Science ({{fosSelection.getSelectedSubjects().length}})</a>
</li>
</ul>
<ul class="uk-switcher">
<li *ngIf="subjectsForm">
<div input [type]="'chips'" [formInput]="subjectsForm" [inputClass]="'flat small'" [extendEnter]="onEnter"
[separators]="[',', 'enter']" [visibleChips]="3" class="uk-width-1-1 uk-width-xlarge@m"
[placeholder]="{static: true, label: 'Type subjects as free text keywords'}">
<div tools class="uk-flex uk-flex-right">
<button (click)="addSubjectsIntoList()" class="uk-button uk-button-link uk-margin-xsmall-left uk-margin-right">add</button>
</div>
<div note class="uk-text-xsmall">Separate subjects with commas</div>
</div>
<!-- <form *ngIf="myForm">
<div class="uk-margin-top uk-flex-center uk-flex uk-margin-medium-bottom">
<a *ngIf="!isEditModal" (click)="addSubjectInForm()">
<button class="uk-button uk-button-primary uk-flex uk-flex-middle">
<icon name="add" [flex]="true"></icon>
<span class="uk-margin-xsmall-left">Add Subject</span>
</button>
</a>
</div>
<div class="uk-grid uk-child-width-1-1" uk-grid>
<div *ngFor=" let control of myForm.controls; index as i" class="uk-flex uk-flex-middle">
<div input [formInput]="myForm.controls[i]" type="text"
placeholder="Type subjects as free text keywords" class="uk-width-expand"></div>
<div *ngIf="!isEditModal" class="uk-width-auto uk-flex uk-flex-center uk-margin-left">
<button class="uk-close uk-icon" [class.uk-invisible]="myForm.length === 1"
(click)="removeSubjectInForm(i)">
<icon name="close" [flex]="true" [ratio]="1.5"></icon>
</button>
</div>
</div>
</div>
</form> -->
<div class="uk-margin-large-top">
<span *ngFor="let subject of displayedSubjects; let i = index;"
class="uk-label uk-label-primary uk-flex-inline uk-flex-middle uk-margin-right uk-margin-bottom">
<span class="uk-margin-small-right uk-text-truncate">{{subject}}</span>
<button (click)="removeSubjectFromList(i)" class="uk-close uk-icon">
<icon name="close" flex="true" ratio="0.7"></icon>
</button>
</span>
</div>
</li>
<li>
<sdg-selection #sdgSelection [subjects]="displayedSdg" [isFeedback]="false"></sdg-selection>
</li>
<li>
<fos-selection #fosSelection [subjects]="displayedFos" [inModal]="true"></fos-selection>
</li>
</ul>
</div>
</fs-modal>
<!--<modal-alert #enablePageModal (alertOutput)="enablePage()">
<div class="uk-padding uk-padding-remove-horizontal">
This information will be visible in <span class="uk-text-bold">Subjects page</span> of Research Community
Dashboard, which is <span class="uk-text-bold">disabled</span>.
Do you want to <span class="uk-text-bold">enable</span> it now?
<div>
<ul uk-tab #modalTabs class="uk-tab uk-margin-top uk-margin-large-bottom uk-flex uk-flex-center uk-flex-left@m">
<li class="uk-active" *ngIf="displayedSubjects?.length">
<a>Free Text ({{displayedSubjects.length}})<span *ngIf="hasChanges">*</span></a>
</li>
<li *ngIf="displayedSdg?.length">
<a>SDGs ({{sdgSelection.getSelectedSubjects().length}})<span *ngIf="sdgSelection.hasChanges">*</span></a>
</li>
<li *ngIf="displayedFos?.length">
<a>Fields of Science ({{fosSelection.getSelectedSubjects().length}})<span *ngIf="fosSelection.hasChanges">*</span></a>
</li>
</ul>
<ul class="uk-switcher">
<li *ngIf="subjectsForm">
<div input [type]="'chips'" [formInput]="subjectsForm" [inputClass]="'flat small'" [extendEnter]="onEnter"
[separators]="[',', 'enter']" [visibleChips]="3" class="uk-width-1-1 uk-width-xlarge@m"
[placeholder]="{static: true, label: 'Type subjects as free text keywords'}">
<div tools class="uk-flex uk-flex-right">
<button (click)="addSubjectsIntoList()" class="uk-button uk-button-link uk-margin-xsmall-left uk-margin-right">add</button>
</div>
<div note class="uk-text-xsmall">Separate subjects with commas</div>
</div>
<div class="uk-margin-large-top">
<span *ngFor="let subject of displayedSubjects; let i = index;"
class="uk-label uk-label-primary uk-flex-inline uk-flex-middle uk-margin-right uk-margin-bottom">
<span class="uk-margin-small-right uk-text-truncate">{{subject}}</span>
<button (click)="removeSubjectFromList(i)" class="uk-close uk-icon">
<icon name="close" flex="true" ratio="0.7"></icon>
</button>
</span>
</div>
</li>
<li>
<sdg-selection #sdgSelection [subjects]="displayedSdg" [isFeedback]="false"></sdg-selection>
</li>
<li>
<fos-selection #fosSelection [subjects]="displayedFos" [inModal]="true"></fos-selection>
</li>
</ul>
</div>
</modal-alert>-->
</fs-modal>

View File

@ -1,6 +1,6 @@
import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {UntypedFormArray, UntypedFormBuilder, UntypedFormControl} from '@angular/forms';
import {ActivatedRoute, Router} from '@angular/router';
import {ActivatedRoute} from '@angular/router';
import {CommunityService} from '../../../openaireLibrary/connect/community/community.service';
import {SubjectsService} from '../subjects.service';
import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties';
@ -24,72 +24,81 @@ declare var UIkit: any;
templateUrl: './subjects-edit-form.component.html',
})
export class SubjectsEditFormComponent implements OnInit {
properties: EnvProperties = properties;
communityId: string = null;
community: CommunityInfo = null;
showLoading = true;
params: any;
private subscriptions: any[] = [];
filterForm: UntypedFormControl;
subjectsForm = new UntypedFormArray([]);
hasChanges: boolean = false;
originalAllSubjects = [];
originalSubjects = [];
originalSdg = [];
originalFos = [];
displayedAllSubjects = [];
displayedSubjects = [];
displayedSdg = [];
displayedFos = [];
groupedAllSubjects = [];
groupedSubjects = [];
groupedSdg = [];
groupedFos = [];
subjectsColumns = [];
index: number = 0;
subjectsLimit: number = 6;
public maxCharacters: number = 25;
displayedAllSubjects = [];
displayedSubjects = [];
displayedSdg = [];
displayedFos = [];
hasChanges: boolean = false;
maxCharacters: number = 25;
activeTab: 'all' | 'freeText' | 'sdg' | 'fos' = 'all';
indexAll: number = 0;
indexSubjects: number = 0;
indexSdg: number = 0;
indexFos: number = 0;
myForm = new UntypedFormArray([]);
public showLoading = true;
public res = [];
params: any;
public communityId: string = null;
public community: CommunityInfo = null;
public properties: EnvProperties = properties;
public edit = null;
public originalSubjects = [];
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
@ViewChild('editModal') editModal: AlertModal;
@ViewChild('deleteModal') deleteModal: AlertModal;
@ViewChild('fsModal', {static: true}) fullscreen: FullScreenModalComponent;
@ViewChild('modalTabs') modalTabs: ElementRef;
page = 1;
size = 10;
selectedSubjects = [];
isEditModal: boolean = false;
public selectedKeyword: string;
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
public filterForm: UntypedFormControl;
private subscriptions: any[] = [];
@ViewChild('sdgSelection') sdgSelection: SdgSelectionComponent;
@ViewChild('fosSelection') fosSelection: FosSelectionComponent;
/*//Check again functionality to enable page
subjectsPage;
@ViewChild('enablePageModal') enablePageModal: AlertModal;*/
onEnter: () => void = () => {
this.addSubjectsIntoList();
}
constructor(private element: ElementRef,
private route: ActivatedRoute,
private _router: Router,
constructor(private route: ActivatedRoute,
public _fb: UntypedFormBuilder,
private title: Title,
// private _helpContentService: HelpContentService,
private _communityService: CommunityService,
private _subjectsService: SubjectsService,
private _clearCacheService: ClearCacheService
) {
}
private _clearCacheService: ClearCacheService) {
}
ngOnInit() {
this.filterForm = this._fb.control('');
this.subscriptions.push(this.filterForm.valueChanges.subscribe(value => {
this.community.subjects = this.originalSubjects.filter(subject => {
this.displayedAllSubjects = this.originalAllSubjects.filter(subject => {
return !value || subject.toLowerCase().indexOf(value.toLowerCase()) != -1
});
this.displayedSubjects = this.originalSubjects.filter(subject => {
return !value || subject.toLowerCase().indexOf(value.toLowerCase()) != -1
});
this.displayedSdg = this.originalSdg.filter(subject => {
return !value || subject.toLowerCase().indexOf(value.toLowerCase()) != -1
});
this.displayedFos = this.originalFos.filter(subject => {
return !value || subject.toLowerCase().indexOf(value.toLowerCase()) != -1
});
if(this.activeTab === 'all') {
this.groupSubjects(this.displayedAllSubjects, 'all');
} else if(this.activeTab === 'freeText') {
this.groupSubjects(this.displayedSubjects, 'freeText');
} else if(this.activeTab === 'sdg') {
this.groupSubjects(this.displayedSdg, 'sdg');
} else if(this.activeTab === 'fos') {
this.groupSubjects(this.displayedFos, 'fos');
}
}));
this.subscriptions.push(this.route.params.subscribe(
params => {
@ -112,21 +121,15 @@ export class SubjectsEditFormComponent implements OnInit {
}
return 0;
});
// assigning values
this.displayedSubjects = HelperFunctions.copy(this.community.subjects);
this.displayedSdg = this.community.sdg;
this.displayedFos = this.community.fos;
this.displayedAllSubjects = [...this.displayedSubjects, ...this.displayedSdg, ...this.displayedFos];
// grouping eveything for 'All' view
this.groupSubjects(this.displayedAllSubjects, 'all');
this.originalSubjects = [];
for (let i = 0; i < this.community.subjects.length; i++) {
this.originalSubjects.push(this.community.subjects[i]);
}
if (this.community.subjects.length === 0) {
this.community.subjects.push('');
}
this.originalAllSubjects = HelperFunctions.copy(this.displayedAllSubjects);
this.originalSubjects = HelperFunctions.copy(this.displayedSubjects);
this.originalSdg = HelperFunctions.copy(this.displayedSdg);
this.originalFos = HelperFunctions.copy(this.displayedFos);
this.showLoading = false;
},
error => this.handleUpdateError('System error retrieving community profile', error)
@ -149,6 +152,8 @@ export class SubjectsEditFormComponent implements OnInit {
}
subjects.sort((a, b) => a.localeCompare(b));
if(type === 'all') {
this.indexAll = 0;
this.activeTab = 'all';
this.groupedAllSubjects = Object.values(
subjects.reduce((acc, subject) => {
let firstLetter = subject[0].toLocaleUpperCase();
@ -165,6 +170,8 @@ export class SubjectsEditFormComponent implements OnInit {
}
}
if(type === 'freeText') {
this.indexSubjects = 0;
this.activeTab = 'freeText';
this.groupedSubjects = Object.values(
subjects.reduce((acc, subject) => {
let firstLetter = subject[0].toLocaleUpperCase();
@ -181,6 +188,8 @@ export class SubjectsEditFormComponent implements OnInit {
}
}
if(type === 'sdg') {
this.indexSdg = 0;
this.activeTab = 'sdg';
this.groupedSdg = Object.values(
subjects.reduce((acc, subject) => {
let firstLetter = subject[0].toLocaleUpperCase();
@ -197,6 +206,8 @@ export class SubjectsEditFormComponent implements OnInit {
}
}
if(type === 'fos') {
this.indexFos = 0;
this.activeTab = 'fos';
this.groupedFos = Object.values(
subjects.reduce((acc, subject) => {
let key = subject.substring(0,2).toLocaleUpperCase();
@ -216,7 +227,15 @@ export class SubjectsEditFormComponent implements OnInit {
public changeDisplayedSubjects(i, group) {
this.subjectsColumns = [];
this.index = i;
if(this.activeTab === 'all') {
this.indexAll = i;
} else if(this.activeTab === 'freeText') {
this.indexSubjects = i;
} else if(this.activeTab === 'sdg') {
this.indexSdg = i;
} else if(this.activeTab === 'fos') {
this.indexFos = i;
}
if(group.data.length > this.subjectsLimit && group.group != 'All') {
this.divideSubjects(group);
}
@ -230,19 +249,6 @@ export class SubjectsEditFormComponent implements OnInit {
this.subjectsColumns = columns;
}
private removeModalOpen(subject: string, i: any) {
this.selectedSubjects = [subject];
this.reset(['']);
this.deleteModal.cancelButton = true;
this.deleteModal.okButton = true;
this.deleteModal.alertTitle = 'Delete Subject';
this.deleteModal.message = 'Are you sure you want to delete this subject?';
this.deleteModal.okButtonText = 'Yes';
this.deleteModal.cancelButtonText = 'No';
this.deleteModal.open();
}
public getSubjectsExistOnlyInFirst(firstArray: string[], secondArray: string[]): string[] {
const difference = [];
for (let i = 0; i < firstArray.length; i++) {
@ -333,24 +339,7 @@ export class SubjectsEditFormComponent implements OnInit {
}
});
this._communityService.updateSubjects(this.community.subjects, this.community.fos, this.community.sdg);
// this.originalSubjects = [];
// for (let i = 0; i < this.community.subjects.length; i++) {
// this.originalSubjects.push(this.community.subjects[i]);
// }
// this.originalSubjects.sort((n1,n2)=> {
// if (n1.toLowerCase() > n2.toLowerCase()) {
// return 1;
// }
// if (n1.toLowerCase() < n2.toLowerCase()) {
// return -1;
// }
// return 0;
// });
// this.community.subjects = this.originalSubjects.filter(subject => {
// return !this.filterForm.value || subject.toLowerCase().indexOf(this.filterForm.value.toLowerCase()) != -1
// }).sort();
// this._clearCacheService.purgeBrowserCache("Subjects "+message, this.communityId);
this._clearCacheService.purgeBrowserCache("Subjects "+message, this.communityId);
NotificationHandler.rise('Subjects successfully ' + message + '!')
this.showLoading = false;
}
@ -386,112 +375,4 @@ export class SubjectsEditFormComponent implements OnInit {
return false;
}
}
public addSubjectInForm() {
this.myForm.push(new UntypedFormControl(''));
}
public removeSubjectInForm(i: number) {
this.myForm.removeAt(i);
}
public reset(subjects: string[]) {
this.myForm = new UntypedFormArray([]);
for (let subject in subjects) {
this.myForm.push(new UntypedFormControl(''));
}
this.myForm.patchValue(subjects);
}
newSubject() {
this.isEditModal = false;
this.selectedSubjects = [];
this.reset([]);
this.fullscreen.title = "Add/Edit Subjects";
this.fullscreen.okButtonText = "Save";
this.fullscreen.back = true;
this.fullscreen.okButton = true;
this.fullscreen.open();
}
get currentPage() {
if(this.community.subjects) {
return this.community.subjects.slice((this.page - 1) * this.size, this.page * this.size);
} else {
return [];
}
}
public updatePage(event) {
this.page = event.value;
HelperFunctions.scroll();
}
public editSubject(subject: string) {
this.isEditModal = true;
this.selectedSubjects = [subject];
this.reset([subject]);
this.fullscreen.title = "Edit Subject";
this.fullscreen.okButtonText = "Save";
this.fullscreen.back = true;
this.fullscreen.okButton = true;
this.fullscreen.open();
}
private formModalOpen(title: string, yesBtn: string) {
this.editModal.okButtonLeft = false;
this.editModal.cancelButton = true;
this.editModal.okButton = true;
this.editModal.alertTitle = title;
this.editModal.okButtonText = yesBtn;
this.editModal.open();
}
public onSearchClose() {
this.selectedKeyword = this.filterForm.value;
}
public resetInput() {
this.selectedKeyword = null;
this.searchInputComponent.reset()
}
/*
//Check again functionality to enable page
private getSubjectsPageStatus() {
this._helpContentService.getCommunityPagesByRoute(this.communityId, '/subjects', this.properties.adminToolsAPIURL).subscribe((page) => {
this.subjectsPage = page;
});
}
public get subjectsEnabled(): boolean {
return !this.subjectsPage || this.subjectsPage.isEnabled;
}
enablePage() {
this._helpContentService.togglePages(this.communityId, [this.subjectsPage._id], true, this.properties.adminToolsAPIURL).subscribe(() => {
this.subjectsPage.isEnabled = true;
UIkit.notification('Curators Page has been <b>enabled successfully</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},error => {
this.subjectsPage.isEnabled = false;
UIkit.notification('An error occured', {
status: 'danger',
timeout: 6000,
pos: 'bottom-right'
});
});
}
private curatorsEnabledOpen() {
this.enablePageModal.okButtonLeft = false;
this.enablePageModal.alertTitle = 'Enable Subjects Page';
this.enablePageModal.okButtonText = 'Yes';
this.enablePageModal.cancelButtonText = 'No';
this.enablePageModal.open();
}*/
}