argos/dmp-frontend/src/app/ui/project/listing/criteria/project-criteria.component.ts

50 lines
1.6 KiB
TypeScript
Raw Normal View History

2017-12-14 14:10:56 +01:00
import { Component, OnInit } from '@angular/core';
2019-01-18 18:03:45 +01:00
import { FormBuilder } from '@angular/forms';
import { TranslateService } from '@ngx-translate/core';
import { ValidationErrorModel } from '../../../../common/forms/validation/error-model/validation-error-model';
import { ProjectStateType } from '../../../../core/common/enum/project-state-type';
import { ProjectCriteria } from '../../../../core/query/project/project-criteria';
2018-03-28 15:24:47 +02:00
import { LanguageResolverService } from '../../../../services/language-resolver/language-resolver.service';
2019-01-18 18:03:45 +01:00
import { BaseCriteriaComponent } from '../../../misc/criteria/base-criteria.component';
2017-12-14 14:10:56 +01:00
@Component({
2019-01-18 18:03:45 +01:00
selector: 'app-project-criteria-component',
templateUrl: './project-criteria.component.html',
styleUrls: ['./project-criteria.component.scss']
2017-12-14 14:10:56 +01:00
})
export class ProjectCriteriaComponent extends BaseCriteriaComponent implements OnInit {
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
) {
2019-01-18 18:03:45 +01:00
super(new ValidationErrorModel());
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 &&
2018-10-05 17:00:54 +02:00
(this.criteria.like == null || this.criteria.like.length === 0 || this.criteria.like.length > 2)
2017-12-18 14:45:36 +01:00
) {
this.refreshCallback();
}
2017-12-14 14:10:56 +01:00
}
}