summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/models/ui-models/constraint-object-ui.ts
blob: 48cf2abdc6197ddce72ca23efddc7eb02953634e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import {FilterConstraint} from "../filter-constraint";

export class ConstraintObjectUI extends FilterConstraint {
    isValidValue: boolean;

    constructor(input?: any) {
        super(input);
        if (input) {
            this.isValidValue = input.isValidValue ? input.isValidValue : input.value !== '';
        }
    }

    public updateValidity(isValidValue: boolean) {
        this.isValidValue = isValidValue;
    }

    public isValidRule() {
        const isValidValue = this.isStatic() ? this.isValidValue : true;
        return this.servicePropertyName != null && this.servicePropertyName !== ''
            && this.value != null && this.value !== '' && isValidValue;
    }

    private isStatic() {
        return this.sourceName === 'static';
    }
}