import { Component, ViewContainerRef, ViewChild, Inject, forwardRef } from '@angular/core';
import { GainsightService } from '@c8y/ngx-components';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { BulkOperationsService } from '@c8y/ngx-components/operations/bulk-operations-service';
import { ACTIONS_OPERATIONS_BULK, BULK_OPERATION_DIALOG_STEPS, BULK_OPERATION_EVENT } from '@c8y/ngx-components/operations/product-experience';
import { BulkOperationModalsService } from '..';
import { Router } from '@angular/router';
import * as i0 from "@angular/core";
import * as i1 from "ngx-bootstrap/modal";
import * as i2 from "@angular/router";
import * as i3 from "@c8y/ngx-components";
import * as i4 from "@c8y/ngx-components/operations/bulk-operations-service";
import * as i5 from "@angular/common";
import * as i6 from "..";
export class BulkOperationsModalComponent {
    constructor(bsModalRef, router, gainsightService, bulkOperationsService, bulkOperationModalsService) {
        this.bsModalRef = bsModalRef;
        this.router = router;
        this.gainsightService = gainsightService;
        this.bulkOperationsService = bulkOperationsService;
        this.bulkOperationModalsService = bulkOperationModalsService;
        this.BULK_OPERATION_EVENT = BULK_OPERATION_EVENT;
        this.bulkActions = ACTIONS_OPERATIONS_BULK;
        this.pxSteps = BULK_OPERATION_DIALOG_STEPS;
        this.showComponent = false;
        this.bulkList = [];
    }
    ngOnInit() {
        this.bulkList = this.bulkOperationsService.getBulkTypes();
    }
    cancel() {
        this.bsModalRef.hide();
    }
    createComponent(item) {
        if (item && item.component) {
            this.showComponent = true;
            this.container.createComponent(item.component);
            this.gainsightService.triggerEvent(this.BULK_OPERATION_EVENT, {
                action: this.bulkActions.SELECT_BULK_OPERTION_TYPE,
                bulkOperationType: item.type
            });
        }
    }
    handleClick(item) {
        if (item.path) {
            this.bulkOperationModalsService.hideNewBulkOperationModal();
            this.router.navigateByUrl(item.path);
            this.gainsightService.triggerEvent(this.BULK_OPERATION_EVENT, {
                action: this.bulkActions.SELECT_BULK_OPERTION_TYPE,
                bulkOperationType: item.type
            });
        }
        else if (item.component) {
            this.createComponent(item);
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: BulkOperationsModalComponent, deps: [{ token: i1.BsModalRef }, { token: i2.Router }, { token: i3.GainsightService }, { token: i4.BulkOperationsService }, { token: forwardRef(() => BulkOperationModalsService) }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: BulkOperationsModalComponent, selector: "c8y-bulk-operations-modal", viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, read: ViewContainerRef }], ngImport: i0, template: "<div class=\"viewport-modal\">\n  <div class=\"modal-header dialog-header\">\n    <i c8yIcon=\"c8y-energy\"></i>\n    <h4\n      id=\"modal-title\"\n      translate\n    >\n      Add bulk operation\n    </h4>\n  </div>\n  <div\n    class=\"modal-inner-scroll\"\n    id=\"modal-body\"\n  >\n    <div\n      class=\"modal-body p-t-8 p-b-8 sticky-top separator-bottom text-center\"\n      [hidden]=\"showComponent\"\n    >\n      <p\n        class=\"text-medium\"\n        translate\n      >\n        Select one of the available options\n      </p>\n      <p c8y-guide-docs>\n        <small\n          translate\n          ngNonBindable\n        >\n          Check the\n          <a\n            c8y-guide-href=\"/docs/device-management-application/monitoring-and-controlling-devices/#to-add-a-bulk-operation-using-the-wizard\"\n          >\n            user documentation\n          </a>\n          for more details.\n        </small>\n      </p>\n    </div>\n\n    <div class=\"list-group list-group-links\">\n      <button\n        class=\"list-group-item flex-row\"\n        type=\"button\"\n        *ngFor=\"let item of bulkList\"\n        (click)=\"handleClick(item)\"\n      >\n        <div\n          class=\"list-item-icon\"\n          *ngIf=\"item.c8yIcon; else icon\"\n        >\n          <i [c8yIcon]=\"item.c8yIcon\"></i>\n        </div>\n        <ng-template #icon>\n          <div class=\"list-item-icon\">\n            <i c8yIcon=\"cogs\"></i>\n          </div>\n        </ng-template>\n        <div\n          class=\"list-item-body text-truncate\"\n          title=\"{{ item.name | translate }}\"\n        >\n          {{ item.name | translate }}\n        </div>\n      </button>\n    </div>\n    <template #container></template>\n  </div>\n  <div\n    class=\"modal-footer\"\n    [hidden]=\"showComponent\"\n  >\n    <button\n      class=\"btn btn-default\"\n      title=\"{{ 'Cancel' | translate }}\"\n      type=\"button\"\n      (click)=\"cancel()\"\n      c8yProductExperience\n      [actionName]=\"BULK_OPERATION_EVENT\"\n      [actionData]=\"{\n        action: bulkActions.CANCEL_ADD_BULK_OPERATION_DIALOG,\n        step: pxSteps.SELECT_OPERATION_TYPE\n      }\"\n    >\n      <span translate>Cancel</span>\n    </button>\n  </div>\n</div>\n", dependencies: [{ kind: "directive", type: i3.IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: i3.C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.GuideHrefDirective, selector: "[c8y-guide-href]", inputs: ["c8y-guide-href"] }, { kind: "component", type: i3.GuideDocsComponent, selector: "[c8y-guide-docs]" }, { kind: "directive", type: i3.ProductExperienceDirective, selector: "[c8yProductExperience]", inputs: ["actionName", "actionData", "inherit", "suppressDataOverriding"] }, { kind: "pipe", type: i3.C8yTranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: BulkOperationsModalComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-bulk-operations-modal', template: "<div class=\"viewport-modal\">\n  <div class=\"modal-header dialog-header\">\n    <i c8yIcon=\"c8y-energy\"></i>\n    <h4\n      id=\"modal-title\"\n      translate\n    >\n      Add bulk operation\n    </h4>\n  </div>\n  <div\n    class=\"modal-inner-scroll\"\n    id=\"modal-body\"\n  >\n    <div\n      class=\"modal-body p-t-8 p-b-8 sticky-top separator-bottom text-center\"\n      [hidden]=\"showComponent\"\n    >\n      <p\n        class=\"text-medium\"\n        translate\n      >\n        Select one of the available options\n      </p>\n      <p c8y-guide-docs>\n        <small\n          translate\n          ngNonBindable\n        >\n          Check the\n          <a\n            c8y-guide-href=\"/docs/device-management-application/monitoring-and-controlling-devices/#to-add-a-bulk-operation-using-the-wizard\"\n          >\n            user documentation\n          </a>\n          for more details.\n        </small>\n      </p>\n    </div>\n\n    <div class=\"list-group list-group-links\">\n      <button\n        class=\"list-group-item flex-row\"\n        type=\"button\"\n        *ngFor=\"let item of bulkList\"\n        (click)=\"handleClick(item)\"\n      >\n        <div\n          class=\"list-item-icon\"\n          *ngIf=\"item.c8yIcon; else icon\"\n        >\n          <i [c8yIcon]=\"item.c8yIcon\"></i>\n        </div>\n        <ng-template #icon>\n          <div class=\"list-item-icon\">\n            <i c8yIcon=\"cogs\"></i>\n          </div>\n        </ng-template>\n        <div\n          class=\"list-item-body text-truncate\"\n          title=\"{{ item.name | translate }}\"\n        >\n          {{ item.name | translate }}\n        </div>\n      </button>\n    </div>\n    <template #container></template>\n  </div>\n  <div\n    class=\"modal-footer\"\n    [hidden]=\"showComponent\"\n  >\n    <button\n      class=\"btn btn-default\"\n      title=\"{{ 'Cancel' | translate }}\"\n      type=\"button\"\n      (click)=\"cancel()\"\n      c8yProductExperience\n      [actionName]=\"BULK_OPERATION_EVENT\"\n      [actionData]=\"{\n        action: bulkActions.CANCEL_ADD_BULK_OPERATION_DIALOG,\n        step: pxSteps.SELECT_OPERATION_TYPE\n      }\"\n    >\n      <span translate>Cancel</span>\n    </button>\n  </div>\n</div>\n" }]
        }], ctorParameters: () => [{ type: i1.BsModalRef }, { type: i2.Router }, { type: i3.GainsightService }, { type: i4.BulkOperationsService }, { type: i6.BulkOperationModalsService, decorators: [{
                    type: Inject,
                    args: [forwardRef(() => BulkOperationModalsService)]
                }] }], propDecorators: { container: [{
                type: ViewChild,
                args: ['container', { static: false, read: ViewContainerRef }]
            }] } });
//# sourceMappingURL=data:application/json;base64, 