Fixes Visibility Criteria on DMP listing.
This commit is contained in:
parent
caa6be46d8
commit
c0a780086c
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.Organisation;
|
||||
import eu.eudat.data.entities.Project;
|
||||
|
||||
import java.util.Date;
|
||||
|
@ -10,39 +11,14 @@ import java.util.UUID;
|
|||
public class DataManagementPlanCriteria extends Criteria<DMP> {
|
||||
private Date periodStart;
|
||||
private Date periodEnd;
|
||||
private List<eu.eudat.data.entities.Project> projects;
|
||||
private boolean allVersions;
|
||||
private List<UUID> groupIds;
|
||||
|
||||
private List<eu.eudat.data.entities.Project> projects;
|
||||
|
||||
public boolean getAllVersions() {
|
||||
return allVersions;
|
||||
}
|
||||
|
||||
public void setAllVersions(boolean allVersions) {
|
||||
this.allVersions = allVersions;
|
||||
}
|
||||
|
||||
public List<UUID> getGroupIds() {
|
||||
return groupIds;
|
||||
}
|
||||
|
||||
public void setGroupIds(List<UUID> groupIds) {
|
||||
this.groupIds = groupIds;
|
||||
}
|
||||
private Integer status;
|
||||
|
||||
public Date getPeriodStart() {
|
||||
return periodStart;
|
||||
}
|
||||
|
||||
public List<Project> getProjects() {
|
||||
return projects;
|
||||
}
|
||||
|
||||
public void setProjects(List<Project> projects) {
|
||||
this.projects = projects;
|
||||
}
|
||||
|
||||
public void setPeriodStart(Date periodStart) {
|
||||
this.periodStart = periodStart;
|
||||
}
|
||||
|
@ -50,9 +26,35 @@ public class DataManagementPlanCriteria extends Criteria<DMP> {
|
|||
public Date getPeriodEnd() {
|
||||
return periodEnd;
|
||||
}
|
||||
|
||||
public void setPeriodEnd(Date periodEnd) {
|
||||
this.periodEnd = periodEnd;
|
||||
}
|
||||
|
||||
public List<Project> getProjects() {
|
||||
return projects;
|
||||
}
|
||||
public void setProjects(List<Project> projects) {
|
||||
this.projects = projects;
|
||||
}
|
||||
|
||||
public boolean getAllVersions() {
|
||||
return allVersions;
|
||||
}
|
||||
public void setAllVersions(boolean allVersions) {
|
||||
this.allVersions = allVersions;
|
||||
}
|
||||
|
||||
public List<UUID> getGroupIds() {
|
||||
return groupIds;
|
||||
}
|
||||
public void setGroupIds(List<UUID> groupIds) {
|
||||
this.groupIds = groupIds;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,14 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
|||
nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
|
||||
if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
|
||||
query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds()));
|
||||
if (criteria.getStatus() != null) {
|
||||
if (criteria.getStatus() == DMP.DMPStatus.FINALISED.getValue()){
|
||||
query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.FINALISED.getValue()));
|
||||
}
|
||||
else if (criteria.getStatus() == DMP.DMPStatus.ACTIVE.getValue()){
|
||||
query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.ACTIVE.getValue()));
|
||||
}
|
||||
}
|
||||
query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()));
|
||||
return query;
|
||||
}
|
||||
|
|
|
@ -5,4 +5,5 @@ export class DmpCriteria extends BaseCriteria {
|
|||
public projects: ProjectListingModel[] = [];
|
||||
public groupIds: string[];
|
||||
public allVersions: boolean;
|
||||
public status?: number;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
<div class="row" style="justify-content: center;">
|
||||
<!-- Search Filter-->
|
||||
<mat-form-field class="col-11 search">
|
||||
<input matInput placeholder="{{ 'CRITERIA.PROJECTS.LIKE'| translate }}" name="projectCriteriaLike"
|
||||
[formControl]="formGroup.get('like')" (ngModelChange)="controlModified()">
|
||||
<input matInput placeholder="{{'CRITERIA.DMP.LIKE'| translate}}" name="likeCriteria"
|
||||
[formControl]="formGroup.get('like')">
|
||||
<mat-error *ngIf="formGroup.get('like').hasError('backendError')">
|
||||
{{formGroup.get('like').getError('backendError').message}}</mat-error>
|
||||
<mat-icon matSuffix class="style-icon">search</mat-icon>
|
||||
|
@ -15,10 +15,10 @@
|
|||
<!-- Visibility Filter-->
|
||||
<div *ngIf="showProject" class="col-10 filter-category">
|
||||
<h6 class="category-title">{{ 'TYPES.DMP-VISIBILITY.VISIBILITY' | translate }}</h6>
|
||||
<mat-radio-group aria-label="Select an option">
|
||||
<mat-list-item><mat-radio-button value="1">{{ 'TYPES.DMP-VISIBILITY.ANY' | translate }}</mat-radio-button></mat-list-item>
|
||||
<mat-list-item><mat-radio-button value="2">{{ 'TYPES.DMP-VISIBILITY.PUBLIC' | translate }}</mat-radio-button></mat-list-item>
|
||||
<mat-list-item><mat-radio-button value="3">{{ 'TYPES.DMP-VISIBILITY.PRIVATE' | translate }}</mat-radio-button></mat-list-item>
|
||||
<mat-radio-group aria-label="Select an option" [formControl]="formGroup.get('status')">
|
||||
<mat-list-item><mat-radio-button value="null">{{ 'TYPES.DMP-VISIBILITY.ANY' | translate }}</mat-radio-button></mat-list-item>
|
||||
<mat-list-item><mat-radio-button value="1">{{ 'TYPES.DMP-VISIBILITY.PUBLIC' | translate }}</mat-radio-button></mat-list-item>
|
||||
<mat-list-item><mat-radio-button value="0">{{ 'TYPES.DMP-VISIBILITY.PRIVATE' | translate }}</mat-radio-button></mat-list-item>
|
||||
</mat-radio-group>
|
||||
</div>
|
||||
<!-- End of Visibility Filter-->
|
||||
|
@ -65,11 +65,10 @@
|
|||
<div *ngIf="showProject" class="col-10 filter-category">
|
||||
<h6 class="category-title">{{ 'DMP-RELATED-ORGANIZATION.RELATED-ORGANIZATION' | translate }}</h6>
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="{{ 'DMP-RELATED-ORGANIZATION.SELECT-ORGANIZATIONS' | translate }}">
|
||||
<!-- <app-multiple-auto-complete [formControl]="formGroup.get('projects')"
|
||||
placeholder="Select Organizations"
|
||||
[configuration]="projectAutoCompleteConfiguration">
|
||||
</app-multiple-auto-complete> -->
|
||||
<app-multiple-auto-complete [formControl]="formGroup.get('organisations')"
|
||||
placeholder="{{'DMP-RELATED-ORGANIZATION.SELECT-ORGANIZATIONS' | translate}}"
|
||||
[configuration]="organisationAutoCompleteConfiguration">
|
||||
</app-multiple-auto-complete>
|
||||
<mat-icon matSuffix class="style-icon">arrow_drop_down</mat-icon>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
|
|
@ -14,6 +14,9 @@ import { DataTableRequest } from '../../../../core/model/data-table/data-table-r
|
|||
import { DmpService } from '../../../../core/services/dmp/dmp.service';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { DmpUploadDialogue } from './upload-dialogue/dmp-upload-dialogue.component';
|
||||
import { Observable } from 'rxjs';
|
||||
import { ExternalSourceItemModel } from '../../../../core/model/external-sources/external-source-item';
|
||||
import { ExternalSourcesService } from '../../../../core/services/external-sources/external-sources.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dmp-criteria-component',
|
||||
|
@ -26,14 +29,17 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
|||
filteringProjectsAsync = false;
|
||||
sizeError = false;
|
||||
maxFileSize: number = 1048576;
|
||||
|
||||
options: FormGroup;
|
||||
filteringOrganisationsAsync = false;
|
||||
filteredOrganisations: ExternalSourceItemModel[];
|
||||
|
||||
filteredProjects: ProjectListingModel[];
|
||||
public formGroup = new FormBuilder().group({
|
||||
like: new FormControl(),
|
||||
projects: new FormControl()
|
||||
projects: new FormControl(),
|
||||
status: new FormControl(),
|
||||
organisations: new FormControl()
|
||||
});
|
||||
|
||||
projectAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
||||
filterFn: this.filterProject.bind(this),
|
||||
initialItems: (excludedItems: any[]) => this.filterProject('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
|
||||
|
@ -41,12 +47,20 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
|||
titleFn: (item) => item['label']
|
||||
};
|
||||
|
||||
organisationAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
||||
filterFn: this.filterOrganisations.bind(this),
|
||||
initialItems: (excludedItems: any[]) => this.filterOrganisations('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
|
||||
displayFn: (item) => item['name'],
|
||||
titleFn: (item) => item['name']
|
||||
}
|
||||
|
||||
constructor(
|
||||
public language: TranslateService,
|
||||
public projectService: ProjectService,
|
||||
private dmpService: DmpService,
|
||||
public formBuilder: FormBuilder,
|
||||
private dialog: MatDialog
|
||||
private dialog: MatDialog,
|
||||
private externalSourcesService: ExternalSourcesService
|
||||
) {
|
||||
super(new ValidationErrorModel());
|
||||
}
|
||||
|
@ -54,6 +68,12 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
|||
ngOnInit() {
|
||||
super.ngOnInit();
|
||||
|
||||
this.formGroup.get('organisations').valueChanges
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(x => this.controlModified());
|
||||
this.formGroup.get('status').valueChanges
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(x => this.controlModified());
|
||||
this.formGroup.get('projects').valueChanges
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(x => this.controlModified());
|
||||
|
@ -66,6 +86,7 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
|||
setCriteria(criteria: DmpCriteria): void {
|
||||
this.formGroup.get('like').patchValue(criteria.like);
|
||||
this.formGroup.get('projects').patchValue(criteria.projects);
|
||||
this.formGroup.get('status').patchValue(criteria.status);
|
||||
}
|
||||
|
||||
onCallbackError(error: any) {
|
||||
|
@ -77,7 +98,7 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
|||
if (this.refreshCallback != null &&
|
||||
(this.formGroup.get('like').value == null || this.formGroup.get('like').value.length === 0 || this.formGroup.get('like').value.length > 2)
|
||||
) {
|
||||
this.refreshCallback();
|
||||
setTimeout(() => this.refreshCallback());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,6 +111,13 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
|||
return this.projectService.getPaged(projectRequestItem, "autocomplete").map(x => x.data);
|
||||
}
|
||||
|
||||
filterOrganisations(value: string): Observable<ExternalSourceItemModel[]> {
|
||||
this.filteredOrganisations = undefined;
|
||||
this.filteringOrganisationsAsync = true;
|
||||
|
||||
return this.externalSourcesService.searchDMPOrganizations(value);
|
||||
}
|
||||
|
||||
fileSave(event) {
|
||||
const dialogRef = this.dialog.open(DmpUploadDialogue, {
|
||||
data: {
|
||||
|
@ -101,8 +129,8 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
|||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||
if (result && result.success) {
|
||||
this.dmpService.uploadXml(result.fileList, result.dmpTitle)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe();
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue