Merge branch 'master' of code-repo.d4science.org:MaDgIK/connect-admin
This commit is contained in:
commit
3c46fb9459
|
@ -126,7 +126,7 @@ export class AppComponent implements OnInit {
|
||||||
this.subscriptions.push(this.data.subscribe(data => {
|
this.subscriptions.push(this.data.subscribe(data => {
|
||||||
if(data && data.portal) {
|
if(data && data.portal) {
|
||||||
this.setProperties(data.portal);
|
this.setProperties(data.portal);
|
||||||
this.configurationService.initCommunityInformation(this.properties, this.properties.adminToolsCommunity);
|
this.configurationService.initPortal(this.properties, this.properties.adminToolsCommunity);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||||
|
@ -172,7 +172,7 @@ export class AppComponent implements OnInit {
|
||||||
} else {
|
} else {
|
||||||
ConnectHelper.setPortalTypeFromPid(id);
|
ConnectHelper.setPortalTypeFromPid(id);
|
||||||
}
|
}
|
||||||
this.configurationService.initCommunityInformation(this.properties, this.properties.adminToolsCommunity);
|
this.configurationService.initPortal(this.properties, this.properties.adminToolsCommunity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get open() {
|
public get open() {
|
||||||
|
|
|
@ -48,7 +48,7 @@ import {CommunityInfo} from "../../openaireLibrary/connect/community/communityIn
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<fs-modal #filtersModal (okEmitter)="saveCriteria()" (cancelEmitter)="criteria.reset()"
|
<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">
|
<div *ngIf="selectionCriteria" class="uk-container uk-container-large">
|
||||||
<criteria #criteria [height]="filtersModal.bodyHeight" [entityType]="'criterion'"
|
<criteria #criteria [height]="filtersModal.bodyHeight" [entityType]="'criterion'"
|
||||||
[entityTypePlural]="'criteria'" [selectionCriteria]="selectionCriteria">
|
[entityTypePlural]="'criteria'" [selectionCriteria]="selectionCriteria">
|
||||||
|
|
|
@ -49,7 +49,6 @@ export class CriteriaComponent implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.reset();
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.subscriptions.push(this.vocabulariesService.getVocabularyByType('fos', null, properties).subscribe((fos: any[]) => {
|
this.subscriptions.push(this.vocabulariesService.getVocabularyByType('fos', null, properties).subscribe((fos: any[]) => {
|
||||||
this.fos = fos.map(element => element.id);
|
this.fos = fos.map(element => element.id);
|
||||||
|
@ -60,6 +59,9 @@ export class CriteriaComponent implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
|
if(changes.selectionCriteria){
|
||||||
|
this.reset();
|
||||||
|
}
|
||||||
this.calculateMaxHeight();
|
this.calculateMaxHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,10 +88,11 @@ export class CriteriaComponent implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
if (this.selectionCriteria?.criteria) {
|
|
||||||
this.selectionCriteriaForm = this.fb.group({
|
this.selectionCriteriaForm = this.fb.group({
|
||||||
criteria: this.fb.array([])
|
criteria: this.fb.array([])
|
||||||
});
|
});
|
||||||
|
if (this.selectionCriteria?.criteria) {
|
||||||
|
|
||||||
this.selectionCriteria.criteria.forEach(criterion => {
|
this.selectionCriteria.criteria.forEach(criterion => {
|
||||||
let constraintArray: UntypedFormArray = this.fb.array([]);
|
let constraintArray: UntypedFormArray = this.fb.array([]);
|
||||||
criterion.constraint.forEach(constraint => {
|
criterion.constraint.forEach(constraint => {
|
||||||
|
@ -158,7 +161,7 @@ export class CriteriaComponent implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||||
}
|
}
|
||||||
|
|
||||||
get dirty() {
|
get dirty() {
|
||||||
if (!this.selectionCriteria || !this.criteria) {
|
if (!this.selectionCriteria && !this.criteria) {
|
||||||
return false;
|
return false;
|
||||||
} else if (this.criteria.length !== this.criteriaArray.length) {
|
} else if (this.criteria.length !== this.criteriaArray.length) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -26,6 +26,7 @@ declare var UIkit;
|
||||||
class="uk-float-right uk-border-rounded uk-margin-top uk-margin-right uk-background-muted uk-button uk-button-link">
|
class="uk-float-right uk-border-rounded uk-margin-top uk-margin-right uk-background-muted uk-button uk-button-link">
|
||||||
<icon name="delete" [defaultSize]="true" [flex]="true"></icon>
|
<icon name="delete" [defaultSize]="true" [flex]="true"></icon>
|
||||||
</a>
|
</a>
|
||||||
|
<div class="uk-text-small uk-margin-large-top uk-text-center" [class.uk-light]="!light">Lorem ipsum dolor sit amet...</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="background.imageFile" class="uk-margin-top">
|
<div *ngIf="background.imageFile" class="uk-margin-top">
|
||||||
|
@ -51,7 +52,7 @@ export class BackgroundUploadComponent implements OnInit {
|
||||||
@Input() oldBackground;
|
@Input() oldBackground;
|
||||||
// @Input() light:boolean;
|
// @Input() light:boolean;
|
||||||
@Input() communityId: string = "";
|
@Input() communityId: string = "";
|
||||||
|
@Input() light:boolean; //fonts mode
|
||||||
public file: File;
|
public file: File;
|
||||||
// public photo: string | ArrayBuffer;
|
// public photo: string | ArrayBuffer;
|
||||||
private maxsize: number = 2000 * 1024;
|
private maxsize: number = 2000 * 1024;
|
||||||
|
|
|
@ -17,7 +17,7 @@ import {CustomizationOptions} from '../../openaireLibrary/connect/community/Cust
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="uk-text-warning uk-text-xsmall uk-margin-small-left" *ngIf="warningForContrast(color)">Contrast ratio may be too low.</div>
|
<div class="uk-text-warning uk-text-xsmall uk-margin-small-left" [class.uk-invisible]="!warningForContrast(color)">Contrast ratio may be too low.</div>
|
||||||
`,
|
`,
|
||||||
styles:[
|
styles:[
|
||||||
`
|
`
|
||||||
|
|
|
@ -207,11 +207,35 @@
|
||||||
<background label="Light" [background]="draftCustomizationOptions.backgrounds.light"
|
<background label="Light" [background]="draftCustomizationOptions.backgrounds.light"
|
||||||
[light]="true"></background>
|
[light]="true"></background>
|
||||||
<background label="Hero section" [background]="draftCustomizationOptions.backgrounds.form"
|
<background label="Hero section" [background]="draftCustomizationOptions.backgrounds.form"
|
||||||
[light]="true"
|
[light]="draftCustomizationOptions.backgrounds.form.fontsDarkMode"
|
||||||
[oldBackground]="publishedCustomizationOptions.backgrounds.form"
|
[oldBackground]="publishedCustomizationOptions.backgrounds.form"
|
||||||
[communityId]="communityId" description="The area under menu"></background>
|
[communityId]="communityId" description="The area under menu"></background>
|
||||||
<div class="uk-margin-xsmall-bottom uk-text-uppercase uk-text-meta uk-text-bold uk-margin-large-top uk-flex uk-flex-middle">
|
<div class="uk-margin-xsmall-bottom uk-text-uppercase uk-text-meta uk-text-bold uk-margin-large-top uk-flex uk-flex-middle uk-heading-divider">
|
||||||
Hero section image
|
Hero section
|
||||||
|
</div>
|
||||||
|
<div class="uk-margin-xsmall-bottom uk-text-uppercase uk-text-meta uk-text-bold uk-margin-medium-top uk-flex uk-flex-middle">
|
||||||
|
Fonts
|
||||||
|
<a *ngIf="( publishedCustomizationOptions.backgrounds.form.fontsDarkMode != draftCustomizationOptions.backgrounds.form.fontsDarkMode )
|
||||||
|
&& draftCustomizationOptions.backgroundsIsCustom"
|
||||||
|
(click)="draftCustomizationOptions.backgrounds.form.fontsDarkMode=publishedCustomizationOptions.backgrounds.form.fontsDarkMode;" class="uk-margin-small-left uk-button-link"
|
||||||
|
uk-tooltip="title:<div class='uk-width-large'>Reset to previously saved options</div>">
|
||||||
|
<icon name="settings_backup_restore" flex="true"></icon>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="uk-margin-small-top">
|
||||||
|
<span>Dark mode </span>
|
||||||
|
<span>
|
||||||
|
<mat-slide-toggle class="uk-margin-large-left"
|
||||||
|
[checked]="draftCustomizationOptions.backgrounds.form.fontsDarkMode"
|
||||||
|
(change)="draftCustomizationOptions.backgrounds.form.fontsDarkMode=!draftCustomizationOptions.backgrounds.form.fontsDarkMode;"
|
||||||
|
[attr.uk-tooltip]="'title:<div class=\'uk-width-large\'>' +
|
||||||
|
(draftCustomizationOptions.backgrounds.form.fontsDarkMode?'Change to light color mode if the hero section background is dark':'Change to dark mode if the hero section background is light')+'</div>'"
|
||||||
|
>
|
||||||
|
</mat-slide-toggle>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="uk-margin-xsmall-bottom uk-text-uppercase uk-text-meta uk-text-bold uk-margin-medium-top uk-flex uk-flex-middle">
|
||||||
|
Image
|
||||||
<a *ngIf="(formHasChanges(publishedCustomizationOptions, draftCustomizationOptions) )
|
<a *ngIf="(formHasChanges(publishedCustomizationOptions, draftCustomizationOptions) )
|
||||||
&& draftCustomizationOptions.backgroundsIsCustom"
|
&& draftCustomizationOptions.backgroundsIsCustom"
|
||||||
(click)="resetImageTo(publishedCustomizationOptions.backgrounds);" class="uk-margin-small-left uk-button-link"
|
(click)="resetImageTo(publishedCustomizationOptions.backgrounds);" class="uk-margin-small-left uk-button-link"
|
||||||
|
@ -222,7 +246,7 @@
|
||||||
<div class="uk-margin-medium-bottom">
|
<div class="uk-margin-medium-bottom">
|
||||||
<background-upload label="Form" [background]="draftCustomizationOptions.backgrounds.form"
|
<background-upload label="Form" [background]="draftCustomizationOptions.backgrounds.form"
|
||||||
[oldBackground]="publishedCustomizationOptions.backgrounds.form"
|
[oldBackground]="publishedCustomizationOptions.backgrounds.form"
|
||||||
[communityId]="communityId"></background-upload>
|
[communityId]="communityId" [light]="draftCustomizationOptions.backgrounds.form.fontsDarkMode" ></background-upload>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -133,7 +133,7 @@ export class StatsComponent implements OnInit {
|
||||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||||
} else {
|
} else {
|
||||||
//console.log(`calling ${this.properties.adminToolsAPIURL}/communityFull/${this.communityId}`);
|
//console.log(`calling ${this.properties.adminToolsAPIURL}/communityFull/${this.communityId}`);
|
||||||
this.configService.communityInformationState.subscribe(
|
this.configService.portalAsObservable.subscribe(
|
||||||
res => {
|
res => {
|
||||||
console.debug(res);
|
console.debug(res);
|
||||||
if(res) {
|
if(res) {
|
||||||
|
|
|
@ -31,19 +31,19 @@
|
||||||
<li class="uk-active" *ngIf="displayedAllSubjects?.length" (click)="groupSubjects(displayedAllSubjects, 'all')">
|
<li class="uk-active" *ngIf="displayedAllSubjects?.length" (click)="groupSubjects(displayedAllSubjects, 'all')">
|
||||||
<a>All ({{displayedAllSubjects.length}})</a>
|
<a>All ({{displayedAllSubjects.length}})</a>
|
||||||
</li>
|
</li>
|
||||||
<li *ngIf="displayedSubjects?.length" (click)="groupSubjects(displayedSubjects, 'freeText')">
|
<li (click)="groupSubjects(displayedSubjects, 'freeText')">
|
||||||
<a>Free Text ({{displayedSubjects.length}})</a>
|
<a>Free Text ({{displayedSubjects.length}})</a>
|
||||||
</li>
|
</li>
|
||||||
<li *ngIf="displayedSdg?.length" (click)="groupSubjects(displayedSdg, 'sdg')">
|
<li (click)="groupSubjects(displayedSdg, 'sdg')">
|
||||||
<a>SDGs ({{displayedSdg.length}})</a>
|
<a>SDGs ({{displayedSdg.length}})</a>
|
||||||
</li>
|
</li>
|
||||||
<li *ngIf="displayedFos?.length" (click)="groupSubjects(displayedFos, 'fos')">
|
<li (click)="groupSubjects(displayedFos, 'fos')">
|
||||||
<a>Fields of Science ({{displayedFos.length}})</a>
|
<a>Fields of Science ({{displayedFos.length}})</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="uk-switcher">
|
<ul class="uk-switcher">
|
||||||
<li *ngIf="displayedAllSubjects?.length">
|
<li>
|
||||||
<ng-container *ngIf="groupedAllSubjects?.length">
|
<ng-container *ngIf="displayedAllSubjects?.length">
|
||||||
<div>
|
<div>
|
||||||
<ul class="uk-nav uk-nav-default uk-flex uk-flex-wrap">
|
<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"
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</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>
|
||||||
<li *ngIf="displayedSubjects?.length">
|
<li>
|
||||||
<ng-container *ngIf="groupedSubjects?.length">
|
<ng-container *ngIf="displayedSubjects?.length">
|
||||||
<div>
|
<div>
|
||||||
<ul class="uk-nav uk-nav-default uk-flex uk-flex-wrap">
|
<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"
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</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>
|
||||||
<li *ngIf="displayedSdg?.length">
|
<li>
|
||||||
<ng-container *ngIf="groupedSdg?.length">
|
<ng-container *ngIf="displayedSdg?.length">
|
||||||
<div>
|
<div>
|
||||||
<ul class="uk-nav uk-nav-default uk-flex uk-flex-wrap">
|
<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"
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</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>
|
||||||
<li *ngIf="displayedFos?.length">
|
<li>
|
||||||
<ng-container *ngIf="groupedFos?.length">
|
<ng-container *ngIf="displayedFos?.length">
|
||||||
<div>
|
<div>
|
||||||
<ul class="uk-nav uk-nav-default uk-flex uk-flex-wrap">
|
<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"
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</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>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,7 +10,9 @@ import {AlertModal} from '../../../openaireLibrary/utils/modal/alert';
|
||||||
import {SearchInputComponent} from '../../../openaireLibrary/sharedComponents/search-input/search-input.component';
|
import {SearchInputComponent} from '../../../openaireLibrary/sharedComponents/search-input/search-input.component';
|
||||||
import {forkJoin, Subscription} from 'rxjs';
|
import {forkJoin, Subscription} from 'rxjs';
|
||||||
import {CommunityInfo} from '../../../openaireLibrary/connect/community/communityInfo';
|
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 {HelperFunctions} from 'src/app/openaireLibrary/utils/HelperFunctions.class';
|
||||||
import {NotificationHandler} from "../../../openaireLibrary/utils/notification-handler";
|
import {NotificationHandler} from "../../../openaireLibrary/utils/notification-handler";
|
||||||
import {ClearCacheService} from "../../../openaireLibrary/services/clear-cache.service";
|
import {ClearCacheService} from "../../../openaireLibrary/services/clear-cache.service";
|
||||||
|
@ -91,13 +93,13 @@ export class SubjectsEditFormComponent implements OnInit {
|
||||||
this.displayedFos = this.originalFos.filter(subject => {
|
this.displayedFos = this.originalFos.filter(subject => {
|
||||||
return !value || subject.toLowerCase().indexOf(value.toLowerCase()) != -1
|
return !value || subject.toLowerCase().indexOf(value.toLowerCase()) != -1
|
||||||
});
|
});
|
||||||
if(this.activeTab === 'all') {
|
if (this.activeTab === 'all') {
|
||||||
this.groupSubjects(this.displayedAllSubjects, 'all');
|
this.groupSubjects(this.displayedAllSubjects, 'all');
|
||||||
} else if(this.activeTab === 'freeText') {
|
} else if (this.activeTab === 'freeText') {
|
||||||
this.groupSubjects(this.displayedSubjects, 'freeText');
|
this.groupSubjects(this.displayedSubjects, 'freeText');
|
||||||
} else if(this.activeTab === 'sdg') {
|
} else if (this.activeTab === 'sdg') {
|
||||||
this.groupSubjects(this.displayedSdg, 'sdg');
|
this.groupSubjects(this.displayedSdg, 'sdg');
|
||||||
} else if(this.activeTab === 'fos') {
|
} else if (this.activeTab === 'fos') {
|
||||||
this.groupSubjects(this.displayedFos, 'fos');
|
this.groupSubjects(this.displayedFos, 'fos');
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
@ -113,7 +115,7 @@ export class SubjectsEditFormComponent implements OnInit {
|
||||||
community: encodeURIComponent(
|
community: encodeURIComponent(
|
||||||
'"' + community.queryId + '"')
|
'"' + community.queryId + '"')
|
||||||
};
|
};
|
||||||
this.community.subjects.sort((n1,n2)=> {
|
this.community.subjects.sort((n1, n2) => {
|
||||||
if (n1.toLowerCase() > n2.toLowerCase()) {
|
if (n1.toLowerCase() > n2.toLowerCase()) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -148,79 +150,79 @@ export class SubjectsEditFormComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public groupSubjects(subjects: string[], type: string) {
|
public groupSubjects(subjects: string[], type: string) {
|
||||||
if(subjects.length === 0) {
|
if (subjects.length === 0) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
subjects.sort((a, b) => a.localeCompare(b));
|
subjects.sort((a, b) => a.localeCompare(b));
|
||||||
if(type === 'all') {
|
if (type === 'all') {
|
||||||
this.indexAll = 0;
|
this.indexAll = 0;
|
||||||
this.activeTab = 'all';
|
this.activeTab = 'all';
|
||||||
this.groupedAllSubjects = Object.values(
|
this.groupedAllSubjects = Object.values(
|
||||||
subjects.reduce((acc, subject) => {
|
subjects.reduce((acc, subject) => {
|
||||||
let firstLetter = subject[0].toLocaleUpperCase();
|
let firstLetter = subject[0].toLocaleUpperCase();
|
||||||
if(!acc[firstLetter]) {
|
if (!acc[firstLetter]) {
|
||||||
acc[firstLetter] = {group: firstLetter, data: [subject]};
|
acc[firstLetter] = {group: firstLetter, data: [subject]};
|
||||||
} else {
|
} else {
|
||||||
acc[firstLetter].data.push(subject);
|
acc[firstLetter].data.push(subject);
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
},{})
|
}, {})
|
||||||
)
|
)
|
||||||
if(subjects.length > 1) {
|
if (subjects.length > 1) {
|
||||||
this.groupedAllSubjects.unshift({group: 'All', data: subjects});
|
this.groupedAllSubjects.unshift({group: 'All', data: subjects});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(type === 'freeText') {
|
if (type === 'freeText') {
|
||||||
this.indexSubjects = 0;
|
this.indexSubjects = 0;
|
||||||
this.activeTab = 'freeText';
|
this.activeTab = 'freeText';
|
||||||
this.groupedSubjects = Object.values(
|
this.groupedSubjects = Object.values(
|
||||||
subjects.reduce((acc, subject) => {
|
subjects.reduce((acc, subject) => {
|
||||||
let firstLetter = subject[0].toLocaleUpperCase();
|
let firstLetter = subject[0].toLocaleUpperCase();
|
||||||
if(!acc[firstLetter]) {
|
if (!acc[firstLetter]) {
|
||||||
acc[firstLetter] = {group: firstLetter, data: [subject]};
|
acc[firstLetter] = {group: firstLetter, data: [subject]};
|
||||||
} else {
|
} else {
|
||||||
acc[firstLetter].data.push(subject);
|
acc[firstLetter].data.push(subject);
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
},{})
|
}, {})
|
||||||
)
|
)
|
||||||
if(subjects.length > 1) {
|
if (subjects.length > 1) {
|
||||||
this.groupedSubjects.unshift({group: 'All', data: subjects});
|
this.groupedSubjects.unshift({group: 'All', data: subjects});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(type === 'sdg') {
|
if (type === 'sdg') {
|
||||||
this.indexSdg = 0;
|
this.indexSdg = 0;
|
||||||
this.activeTab = 'sdg';
|
this.activeTab = 'sdg';
|
||||||
this.groupedSdg = Object.values(
|
this.groupedSdg = Object.values(
|
||||||
subjects.reduce((acc, subject) => {
|
subjects.reduce((acc, subject) => {
|
||||||
let firstLetter = subject[0].toLocaleUpperCase();
|
let firstLetter = subject[0].toLocaleUpperCase();
|
||||||
if(!acc[firstLetter]) {
|
if (!acc[firstLetter]) {
|
||||||
acc[firstLetter] = {group: firstLetter, data: [subject]};
|
acc[firstLetter] = {group: firstLetter, data: [subject]};
|
||||||
} else {
|
} else {
|
||||||
acc[firstLetter].data.push(subject);
|
acc[firstLetter].data.push(subject);
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
},{})
|
}, {})
|
||||||
)
|
)
|
||||||
if(subjects.length > 1) {
|
if (subjects.length > 1) {
|
||||||
this.groupedSdg.unshift({group: 'All', data: subjects});
|
this.groupedSdg.unshift({group: 'All', data: subjects});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(type === 'fos') {
|
if (type === 'fos') {
|
||||||
this.indexFos = 0;
|
this.indexFos = 0;
|
||||||
this.activeTab = 'fos';
|
this.activeTab = 'fos';
|
||||||
this.groupedFos = Object.values(
|
this.groupedFos = Object.values(
|
||||||
subjects.reduce((acc, subject) => {
|
subjects.reduce((acc, subject) => {
|
||||||
let key = subject.substring(0,2).toLocaleUpperCase();
|
let key = subject.substring(0, 2).toLocaleUpperCase();
|
||||||
if(!acc[key]) {
|
if (!acc[key]) {
|
||||||
acc[key] = {group: key, data: [subject]};
|
acc[key] = {group: key, data: [subject]};
|
||||||
} else {
|
} else {
|
||||||
acc[key].data.push(subject);
|
acc[key].data.push(subject);
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
},{})
|
}, {})
|
||||||
)
|
)
|
||||||
if(subjects.length > 1) {
|
if (subjects.length > 1) {
|
||||||
this.groupedFos.unshift({group: 'All', data: subjects});
|
this.groupedFos.unshift({group: 'All', data: subjects});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,23 +230,23 @@ export class SubjectsEditFormComponent implements OnInit {
|
||||||
|
|
||||||
public changeDisplayedSubjects(i, group) {
|
public changeDisplayedSubjects(i, group) {
|
||||||
this.subjectsColumns = [];
|
this.subjectsColumns = [];
|
||||||
if(this.activeTab === 'all') {
|
if (this.activeTab === 'all') {
|
||||||
this.indexAll = i;
|
this.indexAll = i;
|
||||||
} else if(this.activeTab === 'freeText') {
|
} else if (this.activeTab === 'freeText') {
|
||||||
this.indexSubjects = i;
|
this.indexSubjects = i;
|
||||||
} else if(this.activeTab === 'sdg') {
|
} else if (this.activeTab === 'sdg') {
|
||||||
this.indexSdg = i;
|
this.indexSdg = i;
|
||||||
} else if(this.activeTab === 'fos') {
|
} else if (this.activeTab === 'fos') {
|
||||||
this.indexFos = i;
|
this.indexFos = i;
|
||||||
}
|
}
|
||||||
if(group.data.length > this.subjectsLimit && group.group != 'All') {
|
if (group.data.length > this.subjectsLimit && group.group != 'All') {
|
||||||
this.divideSubjects(group);
|
this.divideSubjects(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public divideSubjects(group) {
|
public divideSubjects(group) {
|
||||||
let columns = [];
|
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)));
|
columns.push(group.data.slice(i * this.subjectsLimit, ((i + 1) * this.subjectsLimit)));
|
||||||
}
|
}
|
||||||
this.subjectsColumns = columns;
|
this.subjectsColumns = columns;
|
||||||
|
@ -275,7 +277,7 @@ export class SubjectsEditFormComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public addSubjectsIntoList() {
|
public addSubjectsIntoList() {
|
||||||
if(this.addSubjectsInput.searchControl.getRawValue()) {
|
if (this.addSubjectsInput.searchControl.getRawValue()) {
|
||||||
this.addSubjectsInput.add(null, true);
|
this.addSubjectsInput.add(null, true);
|
||||||
}
|
}
|
||||||
this.subjectsForm.getRawValue().forEach(element => {
|
this.subjectsForm.getRawValue().forEach(element => {
|
||||||
|
@ -324,7 +326,7 @@ export class SubjectsEditFormComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleUpdateError(message: string, error = null) {
|
handleUpdateError(message: string, error = null) {
|
||||||
if(error) {
|
if (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
NotificationHandler.rise(message, 'danger');
|
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._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 + '!')
|
NotificationHandler.rise('Subjects successfully ' + message + '!')
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue