This commit is contained in:
Diamantis Tziotzios 2017-12-21 11:23:55 +02:00
commit 2af51a18d2
5 changed files with 51 additions and 10 deletions

View File

@ -21,12 +21,12 @@
<td-chips color="accent" [items]="filteredProfiles" formControlName="profiles" placeholder="{{'DMP-EDITOR.FIELDS.PROFILES' | translate}}" <td-chips color="accent" [items]="filteredProfiles" formControlName="profiles" placeholder="{{'DMP-EDITOR.FIELDS.PROFILES' | translate}}"
(inputChange)="filterProfiles($event)" requireMatch> (inputChange)="filterProfiles($event)" requireMatch>
<ng-template td-chip let-chip="chip"> <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> <div class="tc-grey-100 bgc-teal-700" td-chip-avatar>{{chip.label.substring(0, 1).toUpperCase()}}</div>
{{chip.name}} {{chip.label}}
</ng-template> </ng-template>
<ng-template td-autocomplete-option let-option="option"> <ng-template td-autocomplete-option let-option="option">
<div layout="row" layout-align="start center"> <div layout="row" layout-align="start center">
{{option.name}} {{option.label}}
</div> </div>
</ng-template> </ng-template>
<mat-progress-bar [style.height.px]="2" *ngIf="filteredProfilesAsync" mode="indeterminate"></mat-progress-bar> <mat-progress-bar [style.height.px]="2" *ngIf="filteredProfilesAsync" mode="indeterminate"></mat-progress-bar>

View File

@ -12,6 +12,10 @@ import { DataManagementPlanService } from "../../services/data-management-plan/d
import { DataManagementPlanModel } from "../../models/data-managemnt-plans/DataManagementPlanModel"; import { DataManagementPlanModel } from "../../models/data-managemnt-plans/DataManagementPlanModel";
import { ExternalSourcesService } from "../../services/external-sources/external-sources.service"; import { ExternalSourcesService } from "../../services/external-sources/external-sources.service";
import { ExternalSourcesItemModel } from "../../models/external-sources/ExternalSourcesItemModel"; import { ExternalSourcesItemModel } from "../../models/external-sources/ExternalSourcesItemModel";
import { RequestItem } from "../../models/criteria/RequestItem";
import { DatasetProfileCriteria } from "../../models/criteria/dataset/DatasetProfileCriteria";
import { DataManagementPlanCriteriaComponent } from "../../shared/components/criteria/data-management-plan/dmp-criteria.component";
import { DatasetProfileModel } from "../../models/datasets/DatasetProfileModel";
@ -24,6 +28,7 @@ import { ExternalSourcesItemModel } from "../../models/external-sources/External
}) })
export class DataManagementPlanEditorComponent implements AfterViewInit { export class DataManagementPlanEditorComponent implements AfterViewInit {
isNew = true; isNew = true;
dataManagementPlan: DataManagementPlanModel; dataManagementPlan: DataManagementPlanModel;
formGroup: FormGroup = null; formGroup: FormGroup = null;
@ -33,7 +38,7 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
filteredProfilesAsync: boolean = false; filteredProfilesAsync: boolean = false;
filteredOrganisations: ExternalSourcesItemModel[]; filteredOrganisations: ExternalSourcesItemModel[];
filteredResearchers: ExternalSourcesItemModel[]; filteredResearchers: ExternalSourcesItemModel[];
filteredProfiles: ExternalSourcesItemModel[]; filteredProfiles: DatasetProfileModel[];
constructor( constructor(
private dataManagementPlanService: DataManagementPlanService, private dataManagementPlanService: DataManagementPlanService,
@ -42,6 +47,7 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
public snackBar: MatSnackBar, public snackBar: MatSnackBar,
public router: Router, public router: Router,
public language: TranslateService, public language: TranslateService,
private _service: DataManagementPlanService
) { ) {
} }
@ -122,6 +128,7 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
// }); // });
}); });
} }
} }
@ -149,14 +156,23 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
if (value) { if (value) {
this.filteredProfilesAsync = true; this.filteredProfilesAsync = true;
this.externalSourcesService.searchDMPProfiles(value).subscribe(items => { // 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;
// // });
// });
const request = new RequestItem<DatasetProfileCriteria>();
let criteria = new DatasetProfileCriteria();
criteria.like = value;
request.criteria = criteria;
this._service.searchDMPProfiles(request).subscribe(items => {
this.filteredProfiles = items; this.filteredProfiles = items;
this.filteredProfilesAsync = false; this.filteredProfilesAsync = false;
// this.filteredOrganisations = items.filter((filteredObj: any) => {
// return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
// });
}); });
} }
} }

View File

@ -0,0 +1,5 @@
import { BaseCriteria } from "../BaseCriteria";
export class DatasetProfileCriteria extends BaseCriteria {
}

View File

@ -0,0 +1,13 @@
import { Serializable } from "../Serializable";
export class DatasetProfileModel {
public id : String;
public label: String;
// fromJSONObject(item:any): DatasetProfileModel{
// this.id = item.id;
// this.label = item.label;
// return this;
// }
}

View File

@ -9,6 +9,9 @@ import { DataTableData } from '../../models/data-table/DataTableData';
import { DataManagementPlanModel } from '../../models/data-managemnt-plans/DataManagementPlanModel'; import { DataManagementPlanModel } from '../../models/data-managemnt-plans/DataManagementPlanModel';
import { DataManagementPlanListingModel } from '../../models/data-managemnt-plans/DataManagementPlanListingModel'; import { DataManagementPlanListingModel } from '../../models/data-managemnt-plans/DataManagementPlanListingModel';
import { DataManagementPlanCriteria } from '../../models/criteria/data-management-plan/DataManagementPlanCriteria'; import { DataManagementPlanCriteria } from '../../models/criteria/data-management-plan/DataManagementPlanCriteria';
import { DatasetProfileCriteria } from '../../models/criteria/dataset/DatasetProfileCriteria';
import { RequestItem } from '../../models/criteria/RequestItem';
import { DatasetProfileModel } from '../../models/datasets/DatasetProfileModel';
@Injectable() @Injectable()
@ -41,4 +44,8 @@ export class DataManagementPlanService {
inactivate(id: String): Observable<DataManagementPlanModel> { inactivate(id: String): Observable<DataManagementPlanModel> {
return this.http.delete<DataManagementPlanModel>(this.actionUrl + 'inactivate/' + id, { headers: this.headers }); return this.http.delete<DataManagementPlanModel>(this.actionUrl + 'inactivate/' + id, { headers: this.headers });
} }
searchDMPProfiles(dataSetProfileRequest: RequestItem<DatasetProfileCriteria>): Observable<DatasetProfileModel[]> {
return this.http.post<DatasetProfileModel[]>(this.actionUrl + "datasetprofiles/get", dataSetProfileRequest, { headers: this.headers });
}
} }