Fixes bug not filter out deleted items of DMP and Dataset. Refactors redirect when selecting Grant from Search bar. (Issue #215)

This commit is contained in:
gkolokythas 2019-12-16 12:18:49 +02:00
parent 72310d8ff1
commit 816ed4dd65
4 changed files with 27 additions and 17 deletions

View File

@ -144,6 +144,7 @@ public class DashBoardManager {
CompletableFuture<List<SearchBarItem>> dmps = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.asQueryable(), principal.getId(), roles)
.withHint("dmpRecentActivity")
.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + like.toUpperCase() + "%"))
.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()))
.orderBy((builder, root) -> builder.desc(root.get("modified")))
.selectAsync(item -> new SearchBarItem(item.getId().toString(), item.getLabel(), SearchBarItemType.DMP.getValue()))
.whenComplete((dmpItems, throwable) -> searchBarItems.addAll(dmpItems));
@ -151,6 +152,8 @@ public class DashBoardManager {
CompletableFuture<List<SearchBarItem>> datasets = datasetRepository.getAuthenticated(datasetRepository.asQueryable(), user)
.withHint("datasetRecentActivity")
.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + like.toUpperCase() + "%"))
.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.DELETED.getValue()))
.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.CANCELED.getValue()))
.orderBy((builder, root) -> builder.desc(root.get("modified")))
.selectAsync(item -> new SearchBarItem(item.getId().toString(), item.getLabel(), SearchBarItemType.DATASET.getValue()))
.whenComplete((dataSetItems, throwable) -> searchBarItems.addAll(dataSetItems));

View File

@ -23,13 +23,13 @@ const routes: Routes = [
},
},
// Uncomment to get dmp plans for grant with grantId
// {
// path: 'grant/:grantId',
// component: DmpListingComponent,
// data: {
// breadcrumb: true
// },
// },
{
path: 'grant/:grantId',
component: DmpListingComponent,
data: {
breadcrumb: true
},
},
{
path: 'edit/:id',
component: DmpEditorComponent,

View File

@ -18,6 +18,7 @@ import { BaseComponent } from '@common/base/base.component';
import { TranslateService } from '@ngx-translate/core';
import { Observable, of as observableOf } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { GrantService } from "@app/core/services/grant/grant.service";
@Component({
selector: 'app-dmp-listing-component',
@ -45,6 +46,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
private dialog: MatDialog,
public enumUtils: EnumUtils,
private language: TranslateService,
private grantService: GrantService
) {
super();
}
@ -56,15 +58,20 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
let grantLabel;
if (params['grantId']) {
this.grantId = params['grantId'];
this.showGrant = false;
const grant: GrantListingModel = {
id: this.grantId
}
this.showGrant = true;
this.grantService.getSingle(this.grantId)
.subscribe((grant: GrantListingModel) => {
// const grant: GrantListingModel = {
// id: this.grantId
// }
this.criteria.setCriteria({ like: null, grants: [grant], groupIds: null, allVersions: false });
this.refresh();
grantLabel = this.route.snapshot.queryParams.grantLabel;
// this.breadCrumbs = Observable.of([{ parentComponentName: 'GrantEditorComponent', label: grantLabel, url: '/grants/edit/' + this.grantId }]);
this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages));
})
} else {
this.itemId = params['groupId'];
this.showGrant = true;

View File

@ -41,7 +41,7 @@ export class SearchComponent implements OnInit {
this.searchControl.patchValue(null);
const selectedSearchBarItem = event.option.value;
if (selectedSearchBarItem.type === SearchBarType.Dataset) { this.router.navigate(['datasets/edit/' + selectedSearchBarItem.id]); }
if (selectedSearchBarItem.type === SearchBarType.Grant) { this.router.navigate(['grants/edit/' + selectedSearchBarItem.id]); }
if (selectedSearchBarItem.type === SearchBarType.Grant) { this.router.navigate(['plans/grant/' + selectedSearchBarItem.id]); }
if (selectedSearchBarItem.type === SearchBarType.Dmp) { this.router.navigate(['plans/edit/' + selectedSearchBarItem.id]); }
}