Claims: fixes for my claims page: new inputs, fix issues with selected types in 1st load, rename entities with OpenaireEntites

This commit is contained in:
argirok 2022-05-10 17:28:50 +03:00
parent 10c70ad1da
commit 0067239cb6
2 changed files with 18 additions and 9 deletions

View File

@ -18,13 +18,13 @@
</div>
<div class=" uk-grid uk-flex-middle">
<div class="">Filter by: </div>
<div class="uk-width-medium uk-padding-remove uk-margin-small-left" dashboard-input
<div class="uk-width-medium uk-padding-remove uk-margin-small-left" input
[formInput]="filterForm.get('entities')"
placeholder="Search by entities"
type="chips" [options]="allOptions" chipLabel="label">
</div>
<div class="">Sort by: </div>
<div class="uk-width-medium uk-padding-remove uk-margin-small-left" dashboard-input
<div class="uk-width-medium uk-padding-remove uk-margin-small-left" input
[formInput]="filterForm.get('sort')"
type="select"
[options]="sortOptions">

View File

@ -17,9 +17,10 @@ import {HelperService} from '../../../utils/helper/helper.service';
import {Meta, Title} from '@angular/platform-browser';
import {PiwikService} from '../../../utils/piwik/piwik.service';
import {properties} from '../../../../../environments/environment';
import {FormArray, FormBuilder, FormGroup} from '@angular/forms';
import {FormArray, FormBuilder, FormControl, FormGroup} from '@angular/forms';
import {Option} from '../../../sharedComponents/input/input.component';
import {SearchInputComponent} from '../../../sharedComponents/search-input/search-input.component';
import {OpenaireEntities} from "../../../utils/properties/searchFields";
declare var UIkit;
@Component({
@ -62,9 +63,8 @@ export class DisplayClaimsComponent {
public filterForm: FormGroup;
public entitiesCtrl: FormArray;
allOptions: Option[] = [{label: "Projects", value: {id:"project", label: "Projects"}},{label: "Publications", value:{id:"publication", label: "Publications"}},{label: "Research data", value: {id:"dataset", label: "Research data"}},
{label: "Software", value: {id:"software", label: "Software"}},{label: "Other reserch products", value: {id:"other", label: "Other reserch products"}},{label: "Communities", value: {id:"context", label: "Communities"}}];
allOptions: Option[] = [{label: OpenaireEntities.PROJECTS, value: "project"},{label: OpenaireEntities.PUBLICATIONS, value:"publication"},{label: OpenaireEntities.DATASETS, value: "dataset"},
{label: OpenaireEntities.SOFTWARE, value: "software"},{label: OpenaireEntities.OTHER, value: "other"},{label: OpenaireEntities.COMMUNITIES, value: "context"}];
sortOptions: Option[] = [
{label:"Date (recent) ", value:{ sort: "date", descending: true }}, {label:"Date (oldest) ", value:{ sort: "date",descending:false }},
// {label:"User (desc) ", value:{ sort: "user",descending: true }}, {label:"User (asc) ", value:{ sort: "user",descending:false }},
@ -148,7 +148,7 @@ export class DisplayClaimsComponent {
this.page = (page <= 0) ? 1 : page;
this.size = (size <= 0) ? this.defaultSize : size;
this.entityTypes = [];//(params['types']?params['types']:[]);
// this.setTypes(params['types']); // check the appropriate checkboxes
this.setTypes(params['types']); // check the appropriate checkboxes
this.setSortby(params['sort']);
this.getClaims();
this.subscriptions.push(this.searchTermStream
@ -196,7 +196,7 @@ export class DisplayClaimsComponent {
this.showErrorMessage = false;
this.showForbiddenMessage = false;
for (let type of this.entitiesCtrl.getRawValue()) {
types += (this.entitiesCtrl.getRawValue().length > 0 ? '&' : '') + "types=" + type.id;
types += (types.length > 0 ? '&' : '') + "types=" + type;
}
this.pageLoading = true;
if(this.subResults){
@ -305,7 +305,7 @@ export class DisplayClaimsComponent {
params += (this.size == 10 ? "" : (params.length > 0 ? '&' : '') + "size=" + this.size);
let types = "";
for (let type of this.entitiesCtrl.getRawValue()) {
types += (this.entitiesCtrl.getRawValue().length > 0 ? ',' : '') + type.id;
types += (types.length > 0 ? ',' : '') + type;
}
params += (this.entitiesCtrl.getRawValue().length > 0) ? (params.length > 0 ? '&' : '') + "types=" + types : "";
if (this.isAdmin) {
@ -332,6 +332,15 @@ export class DisplayClaimsComponent {
this.filterForm.get("sort").setValue(option?option.value:this.sortOptions[0].value);
}
setTypes(typesParam: string) {
for(let type of typesParam?typesParam.split(','):[]){
this.entitiesCtrl.push(new FormControl(type));
}
let types = typesParam?typesParam.split(','):[]
console.log(types);
}
changekeyword() {
if (this.filterForm.get("keyword").value.length >= 3 || this.filterForm.get("keyword").value.length == 0) {