import { Component } from '@angular/core';
import { TenantStatus } from '@c8y/client';
import { FilteringFormRendererContext } from '@c8y/ngx-components';
import * as i0 from "@angular/core";
import * as i1 from "@c8y/ngx-components";
import * as i2 from "@angular/forms";
export class StatusFilteringFormRendererComponent {
    constructor(context) {
        this.context = context;
        this.model = (this.context.property.externalFilterQuery || {}).model || {};
    }
    applyFilter() {
        this.context.applyFilter({
            externalFilterQuery: {
                model: this.model
            },
            filterPredicate: (tenant) => Boolean((!this.model.active && !this.model.suspended) ||
                (this.model.active && tenant.status === TenantStatus.ACTIVE) ||
                (this.model.suspended && tenant.status === TenantStatus.SUSPENDED))
        });
    }
    resetFilter() {
        this.context.resetFilter();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: StatusFilteringFormRendererComponent, deps: [{ token: i1.FilteringFormRendererContext }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: StatusFilteringFormRendererComponent, selector: "c8y-status-filtering-form-renderer", ngImport: i0, template: "<form #filterForm=\"ngForm\">\n  <div class=\"m-b-8 p-t-8\">\n    <label>{{ 'Filter by status' | translate }}</label>\n    <c8y-form-group class=\"m-b-0\">\n      <label class=\"c8y-checkbox\">\n        <input type=\"checkbox\" name=\"active\" [(ngModel)]=\"model.active\" />\n        <span></span>\n        <span>{{ 'Active`tenant`' | translate }}</span>\n      </label>\n    </c8y-form-group>\n    <c8y-form-group class=\"m-b-0\">\n      <label class=\"c8y-checkbox\">\n        <input type=\"checkbox\" name=\"suspended\" [(ngModel)]=\"model.suspended\" />\n        <span></span>\n        <span>{{ 'Suspended`tenant`' | translate }}</span>\n      </label>\n    </c8y-form-group>\n  </div>\n</form>\n\n<div class=\"data-grid__dropdown__footer d-flex separator-top\">\n  <button\n    class=\"btn btn-default btn-sm m-r-8 flex-grow\"\n    (click)=\"resetFilter()\"\n    title=\"{{ 'Reset' | translate }}\"\n  >\n    {{ 'Reset' | translate }}\n  </button>\n  <button\n    class=\"btn btn-primary btn-sm flex-grow\"\n    [disabled]=\"filterForm.invalid\"\n    (click)=\"applyFilter()\"\n    title=\"{{ 'Apply' | translate }}\"\n  >\n    {{ 'Apply' | translate }}\n  </button>\n</div>\n", dependencies: [{ kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i2.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i1.FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "pipe", type: i1.C8yTranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: StatusFilteringFormRendererComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-status-filtering-form-renderer', template: "<form #filterForm=\"ngForm\">\n  <div class=\"m-b-8 p-t-8\">\n    <label>{{ 'Filter by status' | translate }}</label>\n    <c8y-form-group class=\"m-b-0\">\n      <label class=\"c8y-checkbox\">\n        <input type=\"checkbox\" name=\"active\" [(ngModel)]=\"model.active\" />\n        <span></span>\n        <span>{{ 'Active`tenant`' | translate }}</span>\n      </label>\n    </c8y-form-group>\n    <c8y-form-group class=\"m-b-0\">\n      <label class=\"c8y-checkbox\">\n        <input type=\"checkbox\" name=\"suspended\" [(ngModel)]=\"model.suspended\" />\n        <span></span>\n        <span>{{ 'Suspended`tenant`' | translate }}</span>\n      </label>\n    </c8y-form-group>\n  </div>\n</form>\n\n<div class=\"data-grid__dropdown__footer d-flex separator-top\">\n  <button\n    class=\"btn btn-default btn-sm m-r-8 flex-grow\"\n    (click)=\"resetFilter()\"\n    title=\"{{ 'Reset' | translate }}\"\n  >\n    {{ 'Reset' | translate }}\n  </button>\n  <button\n    class=\"btn btn-primary btn-sm flex-grow\"\n    [disabled]=\"filterForm.invalid\"\n    (click)=\"applyFilter()\"\n    title=\"{{ 'Apply' | translate }}\"\n  >\n    {{ 'Apply' | translate }}\n  </button>\n</div>\n" }]
        }], ctorParameters: () => [{ type: i1.FilteringFormRendererContext }] });
//# sourceMappingURL=data:application/json;base64, 