dmp editor profile autocomplete field
This commit is contained in:
parent
b1e4787a92
commit
f530a2b862
|
@ -11,7 +11,7 @@ import { DataTableRequest } from "../models/data-table/DataTableRequest";
|
|||
import { SnackBarNotificationComponent } from "../shared/components/notificaiton/snack-bar-notification.component";
|
||||
import { DatasetService } from "../services/dataset/dataset.service";
|
||||
import { DatasetListingModel } from "../models/datasets/DatasetListingModel";
|
||||
|
||||
import {PageEvent} from '@angular/material';
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -28,6 +28,7 @@ export class DatasetListingComponent implements OnInit {
|
|||
|
||||
dataSource: DatasetDataSource | null;
|
||||
displayedColumns: String[] = ['label','dmp' ,'profile' , 'dataRepositories', 'registries','services', 'status', 'description', 'created', 'actions'];
|
||||
pageEvent: PageEvent;
|
||||
|
||||
statuses = [
|
||||
{value: '0', viewValue: 'Active'},
|
||||
|
@ -43,6 +44,7 @@ export class DatasetListingComponent implements OnInit {
|
|||
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.criteria.setCriteria(this.getDefaultCriteria());
|
||||
this.refresh();
|
||||
|
|
|
@ -18,6 +18,20 @@
|
|||
<mat-error *ngIf="formGroup.get('description').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<td-chips color="accent" [items]="filteredProfiles" formControlName="profiles" placeholder="{{'DMP-EDITOR.FIELDS.PROFILES' | translate}}"
|
||||
(inputChange)="filterProfiles($event)" requireMatch>
|
||||
<ng-template td-chip let-chip="chip">
|
||||
<div class="tc-grey-100 bgc-teal-700" td-chip-avatar>{{chip.name.substring(0, 1).toUpperCase()}}</div>
|
||||
{{chip.name}}
|
||||
</ng-template>
|
||||
<ng-template td-autocomplete-option let-option="option">
|
||||
<div layout="row" layout-align="start center">
|
||||
{{option.name}}
|
||||
</div>
|
||||
</ng-template>
|
||||
<mat-progress-bar [style.height.px]="2" *ngIf="filteredProfilesAsync" mode="indeterminate"></mat-progress-bar>
|
||||
</td-chips>
|
||||
|
||||
<td-chips color="accent" [items]="filteredOrganisations" formControlName="organisations" placeholder="{{'DMP-EDITOR.FIELDS.ORGANISATIONS' | translate}}"
|
||||
(inputChange)="filterOrganisations($event)" requireMatch>
|
||||
<ng-template td-chip let-chip="chip">
|
||||
|
|
|
@ -30,8 +30,10 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
|
|||
|
||||
filteringOrganisationsAsync: boolean = false;
|
||||
filteringResearchersAsync: boolean = false;
|
||||
filteredProfilesAsync: boolean = false;
|
||||
filteredOrganisations: ExternalSourcesItemModel[];
|
||||
filteredResearchers: ExternalSourcesItemModel[];
|
||||
filteredProfiles: ExternalSourcesItemModel[];
|
||||
|
||||
constructor(
|
||||
private dataManagementPlanService: DataManagementPlanService,
|
||||
|
@ -140,4 +142,23 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
filterProfiles(value: string): void {
|
||||
|
||||
this.filteredProfiles = undefined;
|
||||
if (value) {
|
||||
this.filteredProfilesAsync = true;
|
||||
|
||||
this.externalSourcesService.searchDMPProfiles(value).subscribe(items => {
|
||||
this.filteredProfiles = items;
|
||||
this.filteredProfilesAsync = false;
|
||||
|
||||
// this.filteredOrganisations = items.filter((filteredObj: any) => {
|
||||
// return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
|
||||
// });
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -8,6 +8,7 @@ import { ProjectModel } from "../projects/ProjectModel";
|
|||
import { OrganisationModel } from "../organisation/OrganisationModel";
|
||||
import { ResearcherModel } from "../researcher/ResearcherModel";
|
||||
import { JsonSerializer } from "../../utilities/JsonSerializer";
|
||||
import { ProfileModel } from "../profile/ProfileModel";
|
||||
|
||||
export class DataManagementPlanModel implements Serializable<DataManagementPlanModel> {
|
||||
public id: String;
|
||||
|
@ -19,6 +20,7 @@ export class DataManagementPlanModel implements Serializable<DataManagementPlanM
|
|||
public project: ProjectModel;
|
||||
public organisations: OrganisationModel[] = [];
|
||||
public researchers: ResearcherModel[] = [];
|
||||
public profiles: ProfileModel[] = [];
|
||||
|
||||
public errorModel: BaseErrorModel = new BaseErrorModel();
|
||||
|
||||
|
@ -32,6 +34,7 @@ export class DataManagementPlanModel implements Serializable<DataManagementPlanM
|
|||
this.project = new JsonSerializer<ProjectModel>().fromJSONObject(item.project, ProjectModel);
|
||||
this.organisations = new JsonSerializer<OrganisationModel>().fromJSONArray(item.organisations, OrganisationModel);
|
||||
this.researchers = new JsonSerializer<ResearcherModel>().fromJSONArray(item.researchers, ResearcherModel);
|
||||
this.profiles = new JsonSerializer<ProfileModel>().fromJSONArray(item.profiles, ProfileModel);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@ -49,6 +52,7 @@ export class DataManagementPlanModel implements Serializable<DataManagementPlanM
|
|||
project: [{ value: this.project, disabled: disabled }, context.getValidation('project').validators],
|
||||
organisations: [{ value: this.organisations, disabled: disabled }, context.getValidation('organisations').validators],
|
||||
researchers: [{ value: this.researchers, disabled: disabled }, context.getValidation('researchers').validators],
|
||||
profiles: [{ value: this.profiles, disabled: disabled }, context.getValidation('profiles').validators]
|
||||
});
|
||||
|
||||
return formGroup;
|
||||
|
@ -65,6 +69,7 @@ export class DataManagementPlanModel implements Serializable<DataManagementPlanM
|
|||
baseContext.validation.push({ key: 'project', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'project')] });
|
||||
baseContext.validation.push({ key: 'organisations', validators: [BackendErrorValidator(this.errorModel, 'organisations')] });
|
||||
baseContext.validation.push({ key: 'researchers', validators: [BackendErrorValidator(this.errorModel, 'researchers')] });
|
||||
baseContext.validation.push({ key: 'profiles', validators: [BackendErrorValidator(this.errorModel, 'profiles')] });
|
||||
|
||||
return baseContext;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
import { Serializable } from "../Serializable";
|
||||
|
||||
|
||||
export class ProfileModel implements Serializable<ProfileModel> {
|
||||
public id: String;
|
||||
public name: String;
|
||||
public description: String;
|
||||
public reference: String;
|
||||
|
||||
fromJSONObject(item: any): ProfileModel {
|
||||
this.id = item.id;
|
||||
this.name = item.name;
|
||||
this.description = item.abbreviation;
|
||||
this.reference = item.reference;
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -41,4 +41,8 @@ export class ExternalSourcesService {
|
|||
public searchDMPOrganizations(like: string): Observable<ExternalSourcesItemModel[]> {
|
||||
return this.http.get<ExternalSourcesItemModel[]>(this.actionUrl + "organisations" + "?query=" + like, { headers: this.headers });
|
||||
}
|
||||
|
||||
public searchDMPProfiles(like: string): Observable<ExternalSourcesItemModel[]> {
|
||||
return this.http.get<ExternalSourcesItemModel[]>(this.actionUrl + "profiles/get" + "?query=" + like, { headers: this.headers });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,8 @@
|
|||
"NAME": "Name",
|
||||
"DESCRIPTION": "Description",
|
||||
"ORGANISATIONS": "Organisations",
|
||||
"RESEARCHERS": "Researchers"
|
||||
"RESEARCHERS": "Researchers",
|
||||
"PROFILES":"Profiles"
|
||||
},
|
||||
"ACTIONS": {
|
||||
"SAVE": "Save",
|
||||
|
|
Loading…
Reference in New Issue