no message

This commit is contained in:
Diamantis Tziotzios 2017-12-19 11:53:52 +02:00
parent b64af052c9
commit 72ab2d9513
11 changed files with 70 additions and 16 deletions

View File

@ -95,7 +95,7 @@ export class DatasetDataSource extends DataSource<DatasetListingModel> {
this.isLoadingResults = true; this.isLoadingResults = true;
}); });
const startIndex = this._paginator.pageIndex * this._paginator.pageSize; const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
const request = new DataTableRequest(startIndex, this._paginator.pageSize); const request = new DataTableRequest<DatasetCriteria>(startIndex, this._paginator.pageSize);
request.criteria = this._criteria.criteria; request.criteria = this._criteria.criteria;
return this._service.getPaged(request); return this._service.getPaged(request);
}) })

View File

@ -10,13 +10,13 @@
<!-- Column Definition: Name --> <!-- Column Definition: Name -->
<ng-container cdkColumnDef="name"> <ng-container cdkColumnDef="name">
<mat-header-cell *matHeaderCellDef>{{'DMP-LISTING.COLUMNS.NAME' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef>{{'DMP-LISTING.COLUMNS.NAME' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.name}}</mat-cell> <mat-cell *matCellDef="let row">{{row.label}}</mat-cell>
</ng-container> </ng-container>
<!-- Column Definition: Project --> <!-- Column Definition: Project -->
<ng-container cdkColumnDef="project"> <ng-container cdkColumnDef="project">
<mat-header-cell *matHeaderCellDef>{{'DMP-LISTING.COLUMNS.PROJECT' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef>{{'DMP-LISTING.COLUMNS.PROJECT' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.abbreviation}} </mat-cell> <mat-cell *matCellDef="let row"> {{row.project?.label}} </mat-cell>
</ng-container> </ng-container>
<!-- Column Definition: Creation Time --> <!-- Column Definition: Creation Time -->

View File

@ -95,7 +95,7 @@ export class DataManagementPlanDataSource extends DataSource<DataManagementPlanL
this.isLoadingResults = true; this.isLoadingResults = true;
}); });
const startIndex = this._paginator.pageIndex * this._paginator.pageSize; const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
const request = new DataTableRequest(startIndex, this._paginator.pageSize); const request = new DataTableRequest<DataManagementPlanCriteria>(startIndex, this._paginator.pageSize);
request.criteria = this._criteria.criteria; request.criteria = this._criteria.criteria;
return this._service.getPaged(request); return this._service.getPaged(request);
}) })

View File

@ -0,0 +1,6 @@
import { FormGenerator } from "../../utilities/forms/FormGenerator";
import { BaseCriteriaErrorModel } from "./BaseCriteriaErrorModel";
export class RequestItem<T> {
public criteria: T;
}

View File

@ -1,11 +1,12 @@
import { BaseCriteria } from "../criteria/BaseCriteria"; import { BaseCriteria } from "../criteria/BaseCriteria";
import { RequestItem } from "../criteria/RequestItem";
export class DataTableRequest { export class DataTableRequest<T> extends RequestItem<T> {
offset = 0; offset = 0;
length = 0; length = 0;
criteria: BaseCriteria;
constructor(offset: number, length: number) { constructor(offset: number, length: number) {
super();
this.length = length; this.length = length;
this.offset = offset; this.offset = offset;
} }

View File

@ -96,7 +96,7 @@ export class ProjectDataSource extends DataSource<ProjectListingModel> {
this.isLoadingResults = true; this.isLoadingResults = true;
}); });
const startIndex = this._paginator.pageIndex * this._paginator.pageSize; const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
const request = new DataTableRequest(startIndex, this._paginator.pageSize); const request = new DataTableRequest<ProjectCriteria>(startIndex, this._paginator.pageSize);
request.criteria = this._criteria.criteria; request.criteria = this._criteria.criteria;
return this._service.getPaged(request); return this._service.getPaged(request);
}) })

View File

@ -8,6 +8,7 @@ import { DataTableRequest } from '../../models/data-table/DataTableRequest';
import { DataTableData } from '../../models/data-table/DataTableData'; 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';
@Injectable() @Injectable()
@ -25,7 +26,7 @@ export class DataManagementPlanService {
this.headers = this.headers.set('Accept', 'application/json'); this.headers = this.headers.set('Accept', 'application/json');
} }
getPaged(dataTableRequest: DataTableRequest): Observable<DataTableData<DataManagementPlanListingModel>> { getPaged(dataTableRequest: DataTableRequest<DataManagementPlanCriteria>): Observable<DataTableData<DataManagementPlanListingModel>> {
return this.http.post<DataTableData<DataManagementPlanListingModel>>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers }); return this.http.post<DataTableData<DataManagementPlanListingModel>>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers });
} }

View File

@ -8,6 +8,7 @@ import { DataTableRequest } from '../../models/data-table/DataTableRequest';
import { DataTableData } from '../../models/data-table/DataTableData'; import { DataTableData } from '../../models/data-table/DataTableData';
import { DatasetListingModel } from '../../models/datasets/DatasetListingModel'; import { DatasetListingModel } from '../../models/datasets/DatasetListingModel';
import { DatasetModel } from '../../models/datasets/DatasetModel'; import { DatasetModel } from '../../models/datasets/DatasetModel';
import { DatasetCriteria } from '../../models/criteria/dataset/DatasetCriteria';
@Injectable() @Injectable()
@ -25,7 +26,7 @@ export class DatasetService {
this.headers = this.headers.set('Accept', 'application/json'); this.headers = this.headers.set('Accept', 'application/json');
} }
getPaged(dataTableRequest: DataTableRequest): Observable<DataTableData<DatasetListingModel>> { getPaged(dataTableRequest: DataTableRequest<DatasetCriteria>): Observable<DataTableData<DatasetListingModel>> {
return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers }); return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers });
} }

View File

@ -9,6 +9,8 @@ import { DataTableData } from '../../models/data-table/DataTableData';
import { ProjectListingModel } from '../../models/projects/ProjectListingModel'; import { ProjectListingModel } from '../../models/projects/ProjectListingModel';
import { ProjectModel } from '../../models/projects/ProjectModel'; import { ProjectModel } from '../../models/projects/ProjectModel';
import { BaseHttpResponseModel } from '../../models/http/BaseHttpResponseModel'; import { BaseHttpResponseModel } from '../../models/http/BaseHttpResponseModel';
import { ProjectCriteria } from '../../models/criteria/project/ProjectCriteria';
import { RequestItem } from '../../models/criteria/RequestItem';
@Injectable() @Injectable()
@ -26,10 +28,14 @@ export class ProjectService {
this.headers = this.headers.set('Accept', 'application/json'); this.headers = this.headers.set('Accept', 'application/json');
} }
getPaged(dataTableRequest: DataTableRequest): Observable<DataTableData<ProjectListingModel>> { getPaged(dataTableRequest: DataTableRequest<ProjectCriteria>): Observable<DataTableData<ProjectListingModel>> {
return this.http.post<DataTableData<ProjectListingModel>>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers }); return this.http.post<DataTableData<ProjectListingModel>>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers });
} }
get(requestItem: RequestItem<ProjectCriteria>): Observable<ProjectModel[]> {
return this.http.post<ProjectModel[]>(this.actionUrl + 'get', requestItem, { headers: this.headers });
}
getSingle(id: string): Observable<ProjectModel> { getSingle(id: string): Observable<ProjectModel> {
return this.http.get<ProjectModel>(this.actionUrl + 'getSingle/' + id, { headers: this.headers }); return this.http.get<ProjectModel>(this.actionUrl + 'getSingle/' + id, { headers: this.headers });
} }

View File

@ -9,15 +9,15 @@
</mat-form-field> </mat-form-field>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<td-chips color="accent" [items]="filteredProjects" [(ngModel)]="criteria.projects" placeholder="{{'CRITERIA.DMP.PROJECTS' | translate}}" <td-chips color="accent" [items]="filteredProjects" [(ngModel)]="criteria.projects" (ngModelChange)="controlModified()" placeholder="{{'CRITERIA.DMP.PROJECTS' | translate}}"
(inputChange)="filterProjects($event)" requireMatch> (inputChange)="filterProjects($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="filteringProjectsAsync" mode="indeterminate"></mat-progress-bar> <mat-progress-bar [style.height.px]="2" *ngIf="filteringProjectsAsync" mode="indeterminate"></mat-progress-bar>

View File

@ -7,13 +7,16 @@ import { BackendErrorValidator } from '../../../../utilities/validators/BackendE
import { DataManagementPlanCriteria } from '../../../../models/criteria/data-management-plan/DataManagementPlanCriteria'; import { DataManagementPlanCriteria } from '../../../../models/criteria/data-management-plan/DataManagementPlanCriteria';
import { DataManagementPlanCriteriaErrorModel } from '../../../../models/criteria/data-management-plan/DataManagementPlanCriteriaErrorModel'; import { DataManagementPlanCriteriaErrorModel } from '../../../../models/criteria/data-management-plan/DataManagementPlanCriteriaErrorModel';
import { ProjectModel } from '../../../../models/projects/ProjectModel'; import { ProjectModel } from '../../../../models/projects/ProjectModel';
import { ProjectService } from '../../../../services/project/project.service';
import { ProjectCriteria } from '../../../../models/criteria/project/ProjectCriteria';
import { RequestItem } from '../../../../models/criteria/RequestItem';
import { create } from 'domain';
@Component({ @Component({
selector: 'app-dmp-criteria-component', selector: 'app-dmp-criteria-component',
templateUrl: './dmp-criteria.component.html', templateUrl: './dmp-criteria.component.html',
styleUrls: ['./dmp-criteria.component.scss'], styleUrls: ['./dmp-criteria.component.scss'],
providers: [ providers: [ProjectService]
]
}) })
export class DataManagementPlanCriteriaComponent extends BaseCriteriaComponent implements OnInit { export class DataManagementPlanCriteriaComponent extends BaseCriteriaComponent implements OnInit {
@ -24,6 +27,7 @@ export class DataManagementPlanCriteriaComponent extends BaseCriteriaComponent i
constructor( constructor(
public language: TranslateService, public language: TranslateService,
public projectService: ProjectService,
public formBuilder: FormBuilder public formBuilder: FormBuilder
) { ) {
super(new DataManagementPlanCriteriaErrorModel()); super(new DataManagementPlanCriteriaErrorModel());
@ -37,4 +41,39 @@ export class DataManagementPlanCriteriaComponent extends BaseCriteriaComponent i
setCriteria(criteria: DataManagementPlanCriteria): void { setCriteria(criteria: DataManagementPlanCriteria): void {
this.criteria = criteria; this.criteria = criteria;
} }
onCallbackError(error: any) {
this.setErrorModel(error.error);
}
controlModified(): void {
this.clearErrorModel();
if (this.refreshCallback != null &&
(this.criteria.like == null || this.criteria.like.length == 0 || this.criteria.like.length > 2)
) {
this.refreshCallback();
}
}
filterProjects(value: string): void {
this.filteredProjects = undefined;
if (value) {
this.filteringProjectsAsync = true;
let requestItem: RequestItem<ProjectCriteria> = new RequestItem();
let criteria: ProjectCriteria = new ProjectCriteria();
criteria.like = value;
requestItem.criteria = criteria;
this.projectService.get(requestItem).subscribe(items => {
this.filteredProjects = items;
this.filteringProjectsAsync = false;
// this.filteredProjects = items.filter((filteredObj: any) => {
// return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
// });
});
}
}
} }