argos/dmp-frontend/src/app/shared/components/criteria/projects/projects-criteria.component.ts

56 lines
1.9 KiB
TypeScript
Raw Normal View History

2017-12-14 14:10:56 +01:00
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup, FormBuilder, Validators } from '@angular/forms';
import { BaseCriteriaComponent } from '../base/base-criteria.component';
import { ValidationContext, Validation } from '../../../../utilities/validators/ValidationContext';
import { BackendErrorValidator } from '../../../../utilities/validators/BackendErrorValidator';
import { ProjectCriteria } from '../../../../models/criteria/project/ProjectCriteria';
import { ProjectCriteriaErrorModel } from '../../../../models/criteria/project/ProjectCriteriaErrorModel';
2018-03-28 15:24:47 +02:00
import { LanguageResolverService } from '../../../../services/language-resolver/language-resolver.service';
2018-08-24 17:21:02 +02:00
import { ProjectStateType } from '../../../../models/projects/ProjectStateType';
2017-12-14 14:10:56 +01:00
@Component({
selector: 'app-projects-criteria-component',
templateUrl: './projects-criteria.component.html',
styleUrls: ['./projects-criteria.component.scss'],
providers: [
]
})
export class ProjectCriteriaComponent extends BaseCriteriaComponent implements OnInit {
// public form: ProjectType;
2018-08-24 17:21:02 +02:00
public ProjectStateType = ProjectStateType;
2017-12-14 14:10:56 +01:00
public criteria: ProjectCriteria = new ProjectCriteria();
constructor(
public language: TranslateService,
2018-03-28 15:24:47 +02:00
public formBuilder: FormBuilder,
public languageResolver: LanguageResolverService
2017-12-14 14:10:56 +01:00
) {
2017-12-14 18:13:28 +01:00
super(new ProjectCriteriaErrorModel());
2017-12-14 14:10:56 +01:00
}
ngOnInit() {
super.ngOnInit();
if (this.criteria == null) { this.criteria = new ProjectCriteria(); }
}
setCriteria(criteria: ProjectCriteria): void {
this.criteria = criteria;
}
2017-12-18 14:45:36 +01:00
onCallbackError(error: any) {
this.setErrorModel(error.error);
2017-12-14 14:10:56 +01:00
}
2017-12-18 14:45:36 +01:00
controlModified(): void {
this.clearErrorModel();
if (this.refreshCallback != null &&
(this.criteria.like == null || this.criteria.like.length == 0 || this.criteria.like.length > 2)
) {
this.refreshCallback();
}
2017-12-14 14:10:56 +01:00
}
}