Adds Dmp search filter on Dataset Listing. (Ticket #63)
This commit is contained in:
parent
30c84de19a
commit
92b027280d
|
@ -6,18 +6,27 @@
|
||||||
</mat-card-title>
|
</mat-card-title>
|
||||||
</mat-card-header>
|
</mat-card-header>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<mat-form-field class="col-md-4">
|
<mat-form-field class="col-md-3">
|
||||||
<input matInput placeholder=" {{'CRITERIA.PROJECTS.LIKE'| translate}}" name="datasetCriteriaName" [(ngModel)]="criteria.like" (ngModelChange)="controlModified()">
|
<input matInput placeholder=" {{'CRITERIA.DATA-SETS.LIKE'| translate}}" name="datasetCriteriaName" [(ngModel)]="criteria.like"
|
||||||
|
(ngModelChange)="controlModified()">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field class="col-md-4">
|
|
||||||
<mat-select placeholder=" {{'CRITERIA.DATA-SETS.STATUS'| translate}}" name="datasetCriteriastatus" [(ngModel)]="criteria.status" (ngModelChange)="controlModified()">
|
<mat-form-field class="col-md-3">
|
||||||
|
<app-multiple-auto-complete placeholder="{{'CRITERIA.DMP.LIKE'| translate}}" name="dmpCriteriaName" [(ngModel)]="criteria.dmpIds"
|
||||||
|
(ngModelChange)="controlModified()" [configuration]="dmpAutoCompleteConfiguration" [disabled]="!dmpSearchEnabled"></app-multiple-auto-complete>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field class="col-md-3">
|
||||||
|
<mat-select placeholder=" {{'CRITERIA.DATA-SETS.STATUS'| translate}}" name="datasetCriteriastatus" [(ngModel)]="criteria.status"
|
||||||
|
(ngModelChange)="controlModified()">
|
||||||
<mat-option [value]="null">{{'CRITERIA.DATA-SETS.NONE'| translate}}</mat-option>
|
<mat-option [value]="null">{{'CRITERIA.DATA-SETS.NONE'| translate}}</mat-option>
|
||||||
<mat-option [value]="statuses.Draft">{{enumUtils.toDatasetStatusString(statuses.Draft)}}</mat-option>
|
<mat-option [value]="statuses.Draft">{{enumUtils.toDatasetStatusString(statuses.Draft)}}</mat-option>
|
||||||
<mat-option [value]="statuses.Finalized">{{enumUtils.toDatasetStatusString(statuses.Finalized)}}</mat-option>
|
<mat-option [value]="statuses.Finalized">{{enumUtils.toDatasetStatusString(statuses.Finalized)}}</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field class="col-md-4">
|
<mat-form-field class="col-md-3">
|
||||||
<app-multiple-auto-complete name="datasetCriteriaTags" [(ngModel)]="criteria.tags" (ngModelChange)="controlModified()" placeholder="{{'CRITERIA.DATA-SETS.TAGS' | translate}}" [configuration]="tagsAutoCompleteConfiguration"></app-multiple-auto-complete>
|
<app-multiple-auto-complete name="datasetCriteriaTags" [(ngModel)]="criteria.tags" (ngModelChange)="controlModified()" placeholder="{{'CRITERIA.DATA-SETS.TAGS' | translate}}"
|
||||||
|
[configuration]="tagsAutoCompleteConfiguration"></app-multiple-auto-complete>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
|
|
@ -9,6 +9,12 @@ import { ExternalSourcesService } from '../../../../core/services/external-sourc
|
||||||
import { EnumUtils } from '../../../../core/services/utilities/enum-utils.service';
|
import { EnumUtils } from '../../../../core/services/utilities/enum-utils.service';
|
||||||
import { RequestItem } from '../../../../core/query/request-item';
|
import { RequestItem } from '../../../../core/query/request-item';
|
||||||
import { BaseCriteriaComponent } from '../../../misc/criteria/base-criteria.component';
|
import { BaseCriteriaComponent } from '../../../misc/criteria/base-criteria.component';
|
||||||
|
import { DmpCriteria } from '../../../../core/query/dmp/dmp-criteria';
|
||||||
|
import { DmpService } from '../../../../core/services/dmp/dmp.service';
|
||||||
|
import { DataTableRequest } from '../../../../core/model/data-table/data-table-request';
|
||||||
|
import { DataTableData } from '../../../../core/model/data-table/data-table-data';
|
||||||
|
import { DmpListingModel } from '../../../../core/model/dmp/dmp-listing';
|
||||||
|
import { Input } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dataset-criteria-component',
|
selector: 'app-dataset-criteria-component',
|
||||||
|
@ -17,10 +23,10 @@ import { BaseCriteriaComponent } from '../../../misc/criteria/base-criteria.comp
|
||||||
})
|
})
|
||||||
export class DatasetCriteriaComponent extends BaseCriteriaComponent implements OnInit {
|
export class DatasetCriteriaComponent extends BaseCriteriaComponent implements OnInit {
|
||||||
|
|
||||||
|
@Input() dmpSearchEnabled;
|
||||||
public criteria: any;
|
public criteria: any;
|
||||||
public filteringTagsAsync = false;
|
public filteringTagsAsync = false;
|
||||||
public filteredTags: ExternalSourceItemModel[];
|
public filteredTags: ExternalSourceItemModel[];
|
||||||
|
|
||||||
statuses = DatasetStatus;
|
statuses = DatasetStatus;
|
||||||
|
|
||||||
tagsAutoCompleteConfiguration = {
|
tagsAutoCompleteConfiguration = {
|
||||||
|
@ -30,9 +36,17 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
|
||||||
titleFn: (item) => item['name']
|
titleFn: (item) => item['name']
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dmpAutoCompleteConfiguration = {
|
||||||
|
filterFn: (x, excluded) => this.filterDmps(x).map(x => x.data),
|
||||||
|
initialItems: (extraData) => this.filterDmps('').map(x => x.data),
|
||||||
|
displayFn: (item) => item['label'],
|
||||||
|
titleFn: (item) => item['label']
|
||||||
|
};
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private externalSourcesService: ExternalSourcesService,
|
private externalSourcesService: ExternalSourcesService,
|
||||||
public enumUtils: EnumUtils
|
public enumUtils: EnumUtils,
|
||||||
|
public dmpService: DmpService
|
||||||
) {
|
) {
|
||||||
super(new ValidationErrorModel());
|
super(new ValidationErrorModel());
|
||||||
}
|
}
|
||||||
|
@ -60,7 +74,6 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
|
||||||
}
|
}
|
||||||
|
|
||||||
filterTags(value: string): Observable<ExternalSourceItemModel[]> {
|
filterTags(value: string): Observable<ExternalSourceItemModel[]> {
|
||||||
|
|
||||||
this.filteredTags = undefined;
|
this.filteredTags = undefined;
|
||||||
this.filteringTagsAsync = true;
|
this.filteringTagsAsync = true;
|
||||||
|
|
||||||
|
@ -69,6 +82,14 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
|
||||||
criteria.like = value;
|
criteria.like = value;
|
||||||
requestItem.criteria = criteria;
|
requestItem.criteria = criteria;
|
||||||
return this.externalSourcesService.searchDatasetTags(requestItem);
|
return this.externalSourcesService.searchDatasetTags(requestItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
filterDmps(value: string): Observable<DataTableData<DmpListingModel>> {
|
||||||
|
const fields: Array<string> = new Array<string>();
|
||||||
|
fields.push('asc');
|
||||||
|
const dmpDataTableRequest: DataTableRequest<DmpCriteria> = new DataTableRequest(0, null, { fields: fields });
|
||||||
|
dmpDataTableRequest.criteria = new DmpCriteria();
|
||||||
|
dmpDataTableRequest.criteria.like = value;
|
||||||
|
return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div>
|
<div>
|
||||||
<h3>{{'DATASET-LISTING.TITLE' | translate}} {{titlePrefix}}</h3>
|
<h3>{{'DATASET-LISTING.TITLE' | translate}} {{titlePrefix}}</h3>
|
||||||
|
|
||||||
<app-dataset-criteria-component></app-dataset-criteria-component>
|
<app-dataset-criteria-component [dmpSearchEnabled]="dmpSearchEnabled"></app-dataset-criteria-component>
|
||||||
<mat-card class="mat-card">
|
<mat-card class="mat-card">
|
||||||
<mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()">
|
<mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()">
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB
|
||||||
pageEvent: PageEvent;
|
pageEvent: PageEvent;
|
||||||
titlePrefix: String;
|
titlePrefix: String;
|
||||||
dmpId: string;
|
dmpId: string;
|
||||||
|
dmpSearchEnabled = true;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private datasetService: DatasetService,
|
private datasetService: DatasetService,
|
||||||
|
@ -47,23 +48,24 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
this.route.params
|
this.route.params
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(async (params: Params) => {
|
.subscribe(async (params: Params) => {
|
||||||
this.dmpId = params['dmpId'];
|
this.dmpId = params['dmpId'];
|
||||||
this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId));
|
|
||||||
this.refresh();
|
|
||||||
this.criteria.setRefreshCallback(() => this.refresh());
|
this.criteria.setRefreshCallback(() => this.refresh());
|
||||||
if (this.dmpId != null) {
|
if (this.dmpId != null) {
|
||||||
|
this.dmpSearchEnabled = false;
|
||||||
const dmp = await this.dmpService.getSingle(this.dmpId).toPromise();
|
const dmp = await this.dmpService.getSingle(this.dmpId).toPromise();
|
||||||
|
this.criteria.setCriteria(this.getDefaultCriteria(dmp));
|
||||||
|
this.refresh();
|
||||||
this.breadCrumbs = Observable.of([{ parentComponentName: 'DmpEditorComponent', label: dmp.label, url: 'plans/edit/' + this.dmpId }]);
|
this.breadCrumbs = Observable.of([{ parentComponentName: 'DmpEditorComponent', label: dmp.label, url: 'plans/edit/' + this.dmpId }]);
|
||||||
if (params['dmpLabel'] !== undefined) {
|
if (params['dmpLabel'] !== undefined) {
|
||||||
this.titlePrefix = 'for ' + params['dmpLabel'];
|
this.titlePrefix = 'for ' + params['dmpLabel'];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
this.criteria.setCriteria(this.getDefaultCriteria());
|
||||||
|
this.refresh();
|
||||||
this.breadCrumbs = Observable.of([]);
|
this.breadCrumbs = Observable.of([]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -77,7 +79,7 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB
|
||||||
this.router.navigate(['/datasets/edit/' + rowId]);
|
this.router.navigate(['/datasets/edit/' + rowId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultCriteria(dmpId: String): DatasetCriteria {
|
getDefaultCriteria(dmpId: any = null): DatasetCriteria {
|
||||||
const defaultCriteria = new DatasetCriteria();
|
const defaultCriteria = new DatasetCriteria();
|
||||||
if (dmpId != null) {
|
if (dmpId != null) {
|
||||||
defaultCriteria.dmpIds.push(dmpId);
|
defaultCriteria.dmpIds.push(dmpId);
|
||||||
|
@ -90,7 +92,6 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe();
|
.subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DatasetDataSource extends DataSource<DatasetListingModel> {
|
export class DatasetDataSource extends DataSource<DatasetListingModel> {
|
||||||
|
@ -106,7 +107,6 @@ export class DatasetDataSource extends DataSource<DatasetListingModel> {
|
||||||
private dmpId: String
|
private dmpId: String
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(): Observable<DatasetListingModel[]> {
|
connect(): Observable<DatasetListingModel[]> {
|
||||||
|
@ -115,7 +115,6 @@ export class DatasetDataSource extends DataSource<DatasetListingModel> {
|
||||||
//this._sort.matSortChange
|
//this._sort.matSortChange
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
return Observable.merge(...displayDataChanges)
|
return Observable.merge(...displayDataChanges)
|
||||||
.startWith(null)
|
.startWith(null)
|
||||||
.switchMap(() => {
|
.switchMap(() => {
|
||||||
|
@ -123,7 +122,13 @@ export class DatasetDataSource extends DataSource<DatasetListingModel> {
|
||||||
let fields: Array<string> = new Array();
|
let fields: Array<string> = new Array();
|
||||||
if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; }
|
if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; }
|
||||||
const request = new DataTableRequest<DatasetCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
|
const request = new DataTableRequest<DatasetCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
|
||||||
request.criteria = this._criteria.criteria;
|
request.criteria = {
|
||||||
|
like: this._criteria.criteria.like,
|
||||||
|
status: this._criteria.criteria.status,
|
||||||
|
dmpIds: this._criteria.criteria.dmpIds ? this._criteria.criteria.dmpIds.map(x => x.id) : null,
|
||||||
|
tags: this._criteria.criteria.tags,
|
||||||
|
allVersions: this._criteria.criteria.allVersions
|
||||||
|
}
|
||||||
if (this.dmpId) { request.criteria.allVersions = true; }
|
if (this.dmpId) { request.criteria.allVersions = true; }
|
||||||
return this._service.getPaged(request);
|
return this._service.getPaged(request);
|
||||||
})
|
})
|
||||||
|
|
|
@ -270,7 +270,9 @@
|
||||||
"DMP-SEARCH": {
|
"DMP-SEARCH": {
|
||||||
"PLACEHOLDER": "Search DMP"
|
"PLACEHOLDER": "Search DMP"
|
||||||
},
|
},
|
||||||
"ERROR-MESSAGE": "This DMP does not contain this Dataset Profile"
|
"COPY": "Copy",
|
||||||
|
"CANCEL": "Cancel",
|
||||||
|
"ERROR-MESSAGE": "Selected DMP does not contain this Dataset Profile"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"DATASET-LISTING": {
|
"DATASET-LISTING": {
|
||||||
|
@ -419,7 +421,7 @@
|
||||||
"CRITERIA": {
|
"CRITERIA": {
|
||||||
"FILTERS": "Filters",
|
"FILTERS": "Filters",
|
||||||
"PROJECTS": {
|
"PROJECTS": {
|
||||||
"LIKE": "Search",
|
"LIKE": "Search Projects",
|
||||||
"PERIOD-FROM": "Project Start",
|
"PERIOD-FROM": "Project Start",
|
||||||
"PERIOD-TO": "Project End",
|
"PERIOD-TO": "Project End",
|
||||||
"PROJECT-STATE-TYPE": "Project Status",
|
"PROJECT-STATE-TYPE": "Project Status",
|
||||||
|
@ -437,10 +439,11 @@
|
||||||
"PERIOD-TO": "End",
|
"PERIOD-TO": "End",
|
||||||
"STATUS": "Status",
|
"STATUS": "Status",
|
||||||
"NONE": "-",
|
"NONE": "-",
|
||||||
"TAGS": "Tags"
|
"TAGS": "Tags",
|
||||||
|
"LIKE": "Search Datasets"
|
||||||
},
|
},
|
||||||
"DMP": {
|
"DMP": {
|
||||||
"LIKE": "Search",
|
"LIKE": "Search DMPs",
|
||||||
"PROJECTS": "Projects"
|
"PROJECTS": "Projects"
|
||||||
},
|
},
|
||||||
"USERS": {
|
"USERS": {
|
||||||
|
|
Loading…
Reference in New Issue