2020-02-11 12:58:51 +01:00
|
|
|
import {Component, EventEmitter, Input, OnChanges, Output, SimpleChanges} from '@angular/core';
|
|
|
|
import {FormBuilder, FormGroup} from "@angular/forms";
|
|
|
|
import {Filter} from "./searchHelperClasses.class";
|
2020-02-13 15:44:51 +01:00
|
|
|
import {EnvProperties} from "../../utils/properties/env-properties";
|
|
|
|
import {ConfigurationService} from "../../utils/configuration/configuration.service";
|
2020-03-27 13:39:18 +01:00
|
|
|
import {Subject, Subscription} from "rxjs";
|
|
|
|
import {debounceTime} from "rxjs/operators";
|
2020-02-11 12:58:51 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'quick-selections',
|
|
|
|
template: `
|
2020-07-13 00:19:30 +02:00
|
|
|
<form *ngIf="!vertical && (resultTypes || quickFilter)" [formGroup]="control"
|
|
|
|
[class]="(isDisabled ? 'uk-disabled' : '') + ' uk-text-small uk-margin-small-bottom uk-grid uk-inline uk-flex uk-margin-small-left'">
|
2020-04-23 09:33:23 +02:00
|
|
|
<div *ngIf="quickFilter" class="uk-margin-small-top uk-padding-remove-left uk-margin-right ">
|
2020-02-13 15:44:51 +01:00
|
|
|
<span class="uk-text-bold">{{quickFilter.value}}</span>
|
|
|
|
<mat-slide-toggle
|
|
|
|
class="uk-margin-small-left" formControlName="QFselected" (change)="quickFilterChanged()">
|
2020-02-11 12:58:51 +01:00
|
|
|
</mat-slide-toggle>
|
|
|
|
</div>
|
2020-04-23 09:33:23 +02:00
|
|
|
<div *ngIf="resultTypes && showEntities" class="uk-margin-small-top uk-padding-remove-left">
|
2020-02-13 15:44:51 +01:00
|
|
|
<span class="uk-text-muted">Include: </span>
|
2020-04-23 09:33:23 +02:00
|
|
|
<span>
|
|
|
|
<span *ngIf="showPublications" class="uk-margin-small-left"> <input type="checkbox" id="publ" name="Publications" formControlName="publication" (change)="changed()"> Publications </span>
|
|
|
|
<span *ngIf="showDatasets" class="uk-margin-small-left"> <input type="checkbox" formControlName="dataset" (change)="changed()"> Research data </span>
|
|
|
|
<span *ngIf="showSoftware" class="uk-margin-small-left"> <input type="checkbox" formControlName="software" (change)="changed()"> Software </span>
|
|
|
|
<span *ngIf="showOrp" class="uk-margin-small-left"> <input type="checkbox" formControlName="other" (change)="changed()"> Other research products </span>
|
|
|
|
</span>
|
2020-02-13 15:44:51 +01:00
|
|
|
</div>
|
2020-02-11 12:58:51 +01:00
|
|
|
</form>
|
2020-07-13 00:19:30 +02:00
|
|
|
<form *ngIf="vertical && (resultTypes || quickFilter)" [formGroup]="control"
|
|
|
|
[class]="(isDisabled ? 'uk-disabled' : '') + ' uk-margin-small-bottom uk-list uk-list-divider'">
|
2020-06-29 13:10:32 +02:00
|
|
|
<!-- <li *ngIf="quickFilter" class="uk-margin-small-bottom ">
|
2020-06-01 11:02:16 +02:00
|
|
|
<div class="uk-margin-small-top uk-padding-remove-left uk-margin-right ">
|
|
|
|
<h5 class="">{{quickFilter.value}}</h5>
|
|
|
|
<mat-slide-toggle
|
|
|
|
class="uk-margin-small-left" formControlName="QFselected" (change)="quickFilterChanged()">
|
|
|
|
</mat-slide-toggle>
|
|
|
|
</div>
|
2020-06-29 13:10:32 +02:00
|
|
|
</li>-->
|
2020-07-13 00:19:30 +02:00
|
|
|
<!-- {{showEntities}} - {{showPublications}} - {{showDatasets}} - {{showSoftware}} -- {{showOrp}}-->
|
2020-06-01 11:02:16 +02:00
|
|
|
<li *ngIf="resultTypes && showEntities" class="uk-margin-small-bottom ng-star-inserted">
|
|
|
|
<div class="uk-margin-small-top uk-margin-bottom uk-grid uk-flex uk-flex-bottom">
|
|
|
|
<h5 class="uk-margin-bottom-remove" title="Community">Research Type ({{(this.showPublications + this.showDatasets + this.showSoftware + this.showOrp)}})</h5>
|
|
|
|
<a *ngIf="selectedTypesNum>0" (click)="clearTypes()" class="portal-link">
|
|
|
|
Clear
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<div *ngIf="showPublications" class="uk-animation-fade filterItem searchFilterItem uk-text-small ng-star-inserted">
|
|
|
|
<div title="Publications">
|
2020-07-13 11:52:52 +02:00
|
|
|
<label class="ng-star-inserted"><input class="uk-checkbox" type="checkbox" id="publ" name="Publications" formControlName="publication" (change)="changed()"> Publications</label>
|
2020-06-01 11:02:16 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div *ngIf="showDatasets" class="uk-animation-fade filterItem searchFilterItem uk-text-small ng-star-inserted">
|
|
|
|
<div title="Research data">
|
2020-07-13 11:52:52 +02:00
|
|
|
<label class="ng-star-inserted"><input class="uk-checkbox" type="checkbox" formControlName="dataset" (change)="changed()"> Research data </label>
|
2020-06-01 11:02:16 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div *ngIf="showSoftware" class="uk-animation-fade filterItem searchFilterItem uk-text-small ng-star-inserted">
|
|
|
|
<div title="Software">
|
2020-07-13 11:52:52 +02:00
|
|
|
<label class="ng-star-inserted"> <input class="uk-checkbox" type="checkbox" formControlName="software" (change)="changed()"> Software</label>
|
2020-06-01 11:02:16 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div *ngIf="showOrp" class="uk-animation-fade filterItem searchFilterItem uk-text-small ng-star-inserted">
|
|
|
|
<div title=" Other research products">
|
2020-07-13 11:52:52 +02:00
|
|
|
<label class="ng-star-inserted"><input class="uk-checkbox" type="checkbox" formControlName="other" (change)="changed()"> Other research products</label>
|
2020-06-01 11:02:16 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</form>
|
2020-02-11 12:58:51 +01:00
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class QuickSelectionsComponent implements OnChanges {
|
|
|
|
@Input() resultTypes;
|
|
|
|
@Output() typeChange = new EventEmitter();
|
|
|
|
@Input() isDisabled;
|
|
|
|
@Input() quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string };
|
|
|
|
@Input() QFselected: boolean;
|
|
|
|
control: FormGroup;
|
|
|
|
initialized = false;
|
2020-02-13 15:44:51 +01:00
|
|
|
@Input() properties: EnvProperties;
|
2020-06-01 11:02:16 +02:00
|
|
|
@Input() vertical: boolean=false;
|
2020-02-13 15:44:51 +01:00
|
|
|
showPublications:boolean= false;
|
|
|
|
showDatasets:boolean= false;
|
|
|
|
showSoftware: boolean = false;
|
|
|
|
showOrp: boolean = false;
|
|
|
|
showEntities = false;
|
2020-06-01 11:02:16 +02:00
|
|
|
selectedTypesNum = 0;
|
|
|
|
@Input() delayTime = 0;
|
2020-03-27 13:39:18 +01:00
|
|
|
private clicks = new Subject();
|
2020-07-13 00:19:30 +02:00
|
|
|
|
|
|
|
subs: Subscription[] = [];
|
|
|
|
|
2020-02-13 15:44:51 +01:00
|
|
|
constructor(private _fb: FormBuilder, private config: ConfigurationService) {
|
2020-02-11 12:58:51 +01:00
|
|
|
|
|
|
|
this.control = this._fb.group({
|
|
|
|
publication: true,
|
|
|
|
dataset: true,
|
|
|
|
software: true,
|
|
|
|
other: true,
|
|
|
|
QFselected: true
|
|
|
|
});
|
|
|
|
|
2020-02-13 15:44:51 +01:00
|
|
|
|
2020-02-11 12:58:51 +01:00
|
|
|
}
|
|
|
|
|
2020-03-27 13:39:18 +01:00
|
|
|
changed() {
|
2020-02-11 12:58:51 +01:00
|
|
|
if (!this.initialized && this.isDisabled) {
|
|
|
|
this.initialized = true;
|
|
|
|
return;
|
|
|
|
}
|
2020-03-27 13:39:18 +01:00
|
|
|
this.clicks.next();
|
|
|
|
}
|
|
|
|
actuallyChanged(){
|
|
|
|
|
2020-02-11 12:58:51 +01:00
|
|
|
let value = this.control.getRawValue();
|
|
|
|
this.resultTypes.publication = value.publication;
|
|
|
|
this.resultTypes.dataset = value.dataset;
|
|
|
|
this.resultTypes.software = value.software;
|
|
|
|
this.resultTypes.other = value.other;
|
2020-06-01 11:02:16 +02:00
|
|
|
if (this.resultTypes && !this.resultTypes.publication && !this.resultTypes.dataset && !this.resultTypes.software && !this.resultTypes.other && !this.vertical) {
|
2020-02-11 12:58:51 +01:00
|
|
|
this.resultTypes.publication = true;
|
|
|
|
this.resultTypes.dataset = true;
|
|
|
|
this.resultTypes.software = true;
|
|
|
|
this.resultTypes.other = true;
|
|
|
|
this.setFormValues();
|
|
|
|
}
|
|
|
|
this.typeChange.emit({});
|
|
|
|
}
|
|
|
|
|
|
|
|
quickFilterChanged() {
|
|
|
|
let value = this.control.getRawValue();
|
|
|
|
this.quickFilter.selected = value.QFselected;
|
2020-02-13 15:44:51 +01:00
|
|
|
if(this.quickFilter.filter) {
|
2020-03-27 13:39:18 +01:00
|
|
|
this.quickFilter.filter.countSelectedValues = 0;
|
2020-02-13 15:44:51 +01:00
|
|
|
if (value.QFselected) {
|
|
|
|
for (let filterValue of this.quickFilter.filter.values) {
|
2020-02-28 11:05:59 +01:00
|
|
|
if((filterValue.name == this.quickFilter.value)) {
|
|
|
|
filterValue.selected = true
|
|
|
|
this.quickFilter.filter.countSelectedValues = 1;
|
|
|
|
}else{
|
|
|
|
filterValue.selected = false;
|
|
|
|
}
|
2020-02-13 15:44:51 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (let filterValue of this.quickFilter.filter.values) {
|
|
|
|
filterValue.selected = false;
|
|
|
|
}
|
2020-02-11 12:58:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
this.typeChange.emit({});
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
if (this.resultTypes) {
|
|
|
|
this.setFormValues();
|
|
|
|
}
|
2020-02-13 15:44:51 +01:00
|
|
|
if(this.properties) {
|
2020-06-29 15:15:52 +02:00
|
|
|
if(this.properties.adminToolsCommunity !== "monitor") {
|
2020-07-13 00:19:30 +02:00
|
|
|
//this.subs.push(this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity).subscribe(data => {
|
|
|
|
this.subs.push(this.config.communityInformationState.subscribe(data => {
|
|
|
|
if(data) {
|
|
|
|
var showEntity = {};
|
|
|
|
for (var i = 0; i < data['entities'].length; i++) {
|
|
|
|
showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
|
|
|
|
}
|
|
|
|
this.showPublications = showEntity["publication"];
|
|
|
|
this.showDatasets = showEntity["dataset"];
|
|
|
|
this.showSoftware = showEntity["software"];
|
|
|
|
this.showOrp = showEntity["orp"];
|
|
|
|
this.showEntities = this.showPublications || this.showDatasets || this.showSoftware || this.showOrp;
|
2020-06-29 15:15:52 +02:00
|
|
|
}
|
|
|
|
}, error => {
|
|
|
|
this.showPublications = true;
|
|
|
|
this.showDatasets = true;
|
|
|
|
this.showSoftware = true;
|
|
|
|
this.showOrp = true;
|
|
|
|
this.showEntities = true;
|
2020-07-13 00:19:30 +02:00
|
|
|
}));
|
2020-06-29 15:15:52 +02:00
|
|
|
} else {
|
|
|
|
this.showPublications = true;
|
|
|
|
this.showDatasets = true;
|
|
|
|
this.showSoftware = true;
|
|
|
|
this.showOrp = true;
|
|
|
|
this.showEntities = true;
|
|
|
|
}
|
2020-02-13 15:44:51 +01:00
|
|
|
}
|
2020-07-13 00:19:30 +02:00
|
|
|
this.subs.push(this.clicks.pipe(
|
2020-06-01 11:02:16 +02:00
|
|
|
debounceTime(this.delayTime)
|
2020-07-13 00:19:30 +02:00
|
|
|
).subscribe(e =>{this.actuallyChanged()} ));
|
2020-03-27 13:39:18 +01:00
|
|
|
|
2020-02-11 12:58:51 +01:00
|
|
|
}
|
|
|
|
|
2020-07-13 00:19:30 +02:00
|
|
|
public ngOnDestroy() {
|
|
|
|
for (let sub of this.subs) {
|
|
|
|
sub.unsubscribe();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-11 12:58:51 +01:00
|
|
|
ngOnChanges(changes: SimpleChanges): void {
|
|
|
|
if (changes.isDisabled) {
|
|
|
|
if (changes.isDisabled.currentValue == true) {
|
|
|
|
this.control.disable();
|
|
|
|
} else if (changes.isDisabled.currentValue == false) {
|
|
|
|
this.control.enable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changes.QFselected) {
|
|
|
|
let value = this.control.getRawValue();
|
|
|
|
if (changes.QFselected.currentValue != value.QFselected) {
|
|
|
|
this.setFormValues();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-04-22 15:00:13 +02:00
|
|
|
if (changes.resultTypes) {
|
|
|
|
this.setFormValues();
|
|
|
|
}
|
2020-02-11 12:58:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
setFormValues() {
|
|
|
|
this.control.setValue({
|
2020-02-11 15:56:20 +01:00
|
|
|
publication: (this.resultTypes && this.resultTypes.publication)?this.resultTypes.publication:null,
|
|
|
|
dataset: (this.resultTypes && this.resultTypes.dataset)?this.resultTypes.dataset:null,
|
|
|
|
software: (this.resultTypes && this.resultTypes.software)?this.resultTypes.software:null,
|
|
|
|
other: (this.resultTypes && this.resultTypes.other)?this.resultTypes.other:null,
|
2020-02-11 12:58:51 +01:00
|
|
|
QFselected: this.QFselected
|
|
|
|
});
|
2020-06-01 11:02:16 +02:00
|
|
|
this.selectedTypesNum = (this.resultTypes && this.resultTypes.publication)?this.resultTypes.publication:0 + (this.resultTypes && this.resultTypes.dataset)?this.resultTypes.dataset:0+ (this.resultTypes && this.resultTypes.software)?this.resultTypes.software:0 + (this.resultTypes && this.resultTypes.other)?this.resultTypes.other:null;
|
2020-02-11 12:58:51 +01:00
|
|
|
}
|
|
|
|
|
2020-06-01 11:02:16 +02:00
|
|
|
clearTypes(){
|
|
|
|
this.resultTypes.publication = false;
|
|
|
|
this.resultTypes.dataset = false;
|
|
|
|
this.resultTypes.software = false;
|
|
|
|
this.resultTypes.other = false;
|
|
|
|
this.setFormValues();
|
|
|
|
this.changed()
|
|
|
|
}
|
2020-02-11 12:58:51 +01:00
|
|
|
|
|
|
|
}
|