/**
 * @fileoverview added by tsickle
 * Generated from: lib/fhir/organization/table/organization-table.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { Router } from '@angular/router';
import { Component, Input, ViewChild, Output, EventEmitter } from '@angular/core';
import { MatPaginator, MatSort, MatTableDataSource } from '@angular/material';
import { merge } from 'rxjs';
var OrganizationTableComponent = /** @class */ (function () {
    function OrganizationTableComponent(router) {
        this.router = router;
        this.contactPArray = [];
        this.headOfInstArray = [];
        /* @Output() modifyOrgStatus = new EventEmitter<any>(); */
        this.callSortSizeChanged = new EventEmitter();
        this.displayedColumns = ['nameText', 'headOfInstitution', 'contactPName', 'status', 'more'];
        this.dataSource = new MatTableDataSource();
        this.dataLength = 6;
    }
    /**
     * @param {?} changes
     * @return {?}
     */
    OrganizationTableComponent.prototype.ngOnChanges = /**
     * @param {?} changes
     * @return {?}
     */
    function (changes) {
        if (changes.organizationList) {
            this.paginator.pageIndex = this.actPage;
            if (this.paginator.pageIndex === 0) {
                this.paginator.length = this.pageSize;
            }
            if (changes.organizationList.currentValue.length > this.pageSize) {
                this.dataSource.data = changes.organizationList.currentValue.slice(0, changes.organizationList.currentValue.length - 1);
                this.paginator.length += this.pageSize;
            }
            else {
                this.dataSource.data = changes.organizationList.currentValue;
            }
        }
    };
    /**
     * @return {?}
     */
    OrganizationTableComponent.prototype.ngAfterViewInit = /**
     * @return {?}
     */
    function () {
        var _this = this;
        this.sort.sortChange.subscribe((/**
         * @return {?}
         */
        function () { return _this.paginator.pageIndex = 0; }));
        merge(this.sort.sortChange, this.paginator.page).subscribe((/**
         * @param {?} data
         * @return {?}
         */
        function (data) {
            if (data && data.pageSize) {
                _this.callSortSizeChanged.emit({
                    pageSize: data.pageSize,
                    sort: { active: _this.sort.active, direction: _this.sort.direction },
                    pageIndex: data.pageIndex
                });
            }
            if (data && data.active) {
                _this.callSortSizeChanged.emit({
                    pageSize: _this.paginator.pageSize,
                    sort: { active: data.active, direction: data.direction },
                    pageIndex: data.pageIndex
                });
            }
        }));
    };
    /**
     * @param {?} event
     * @return {?}
     */
    OrganizationTableComponent.prototype.stopProp = /**
     * @param {?} event
     * @return {?}
     */
    function (event) {
        event.stopPropagation();
    };
    /**
     * @param {?} url
     * @param {?} organization
     * @return {?}
     */
    OrganizationTableComponent.prototype.navigateTo = /**
     * @param {?} url
     * @param {?} organization
     * @return {?}
     */
    function (url, organization) {
        localStorage.removeItem('org');
        this.router.navigateByUrl(url, { state: { parameter: organization } });
    };
    OrganizationTableComponent.decorators = [
        { type: Component, args: [{
                    selector: 'inc-organization-table',
                    template: "<div class=\"org-table mat-elevation-z8\" [hidden]=\"!organizationList\">\r\n  <div class=\"loading-shade\" *ngIf=\"organizationList && organizationList.length===0 && filtered\">\r\n    <ion-text color=\"danger\">\r\n      <h4>{{'NO_RESULT' | translate}}</h4>\r\n    </ion-text>\r\n  </div>\r\n  <mat-table [dataSource]=\"dataSource\" multiTemplateDataRows matSort>\r\n    <ng-container matColumnDef=\"nameText\">\r\n      <mat-header-cell *matHeaderCellDef mat-sort-header id=\"organization-name-header\"> {{'NAME' | translate}}\r\n      </mat-header-cell>\r\n      <mat-cell *matCellDef=\"let org\" id=\"organization-name-row\"> {{org?.name}} </mat-cell>\r\n    </ng-container>\r\n\r\n    <ng-container matColumnDef=\"headOfInstitution\">\r\n      <mat-header-cell *matHeaderCellDef> {{'HEAD_OF_INSTITUTION' | translate}} </mat-header-cell>\r\n      <mat-cell *matCellDef=\"let i = renderIndex\">\r\n        {{headOfInstArray[i]?.name[0]}}<br>{{headOfInstArray[i]?.telecom[0]?.value}}</mat-cell>\r\n    </ng-container>\r\n\r\n    <ng-container matColumnDef=\"contactPName\">\r\n      <mat-header-cell *matHeaderCellDef> {{'CONTACT_P_INFO' | translate}} </mat-header-cell>\r\n      <mat-cell *matCellDef=\"let i = renderIndex\">\r\n        {{contactPArray[i]?.name[0]}}<br>{{contactPArray[i]?.telecom[0]?.value}}</mat-cell>\r\n    </ng-container>\r\n\r\n    <ng-container matColumnDef=\"status\">\r\n      <mat-header-cell *matHeaderCellDef> {{'STATUS' | translate}} </mat-header-cell>\r\n      <mat-cell *matCellDef=\"let org\" id=\"organization-status-row\">\r\n        {{(org?.active ? \"ACTIVE\" : \"INACTIVE\") | translate}}</mat-cell>\r\n    </ng-container>\r\n\r\n    <!-- <ng-container matColumnDef=\"more\">\r\n      <mat-header-cell *matHeaderCellDef></mat-header-cell>\r\n      <mat-cell *matCellDef=\"let org\">\r\n        <ion-buttons>\r\n          <button mat-button [matMenuTriggerFor]=\"menu\" (click)=\"stopProp($event)\" id=\"organization-menu-button\">\r\n            <ion-icon slot=\"icon-only\" name=\"more\"></ion-icon>\r\n          </button>\r\n        </ion-buttons>\r\n        <mat-menu id=\"organization-menu\" #menu=\"matMenu\" xPosition=\"before\">\r\n          <button class=\"menuItem\" mat-menu-item (click)=\"navigateTo('/organization-add', org)\"\r\n            id=\"organization-menu-edit-button\">{{'EDIT' |\r\n              translate}}</button>\r\n          <button class=\"menuItem\"  mat-menu-item (click)=\"modifyStatus(org)\" id=\"organization-menu-status-modify-button\">{{(org.active ? 'INACTIVATE' :\r\n              'ACTIVATE') |\r\n              translate}}</button>\r\n          <button class=\"menuItem\" mat-menu-item (click)=\"navigateTo('/main/careTeam-list', org)\"\r\n            id=\"organization-menu-group-button\">{{'CARETEAMS' |\r\n              translate}}</button>\r\n        </mat-menu>\r\n      </mat-cell>\r\n    </ng-container> -->\r\n\r\n    <mat-header-row *matHeaderRowDef=\"displayedColumns; sticky: true\"></mat-header-row>\r\n    <mat-row *matRowDef=\"let element; columns: displayedColumns;\" class=\"org-row\"\r\n      (click)=\"navigateTo('/organization-details', element)\"></mat-row>\r\n  </mat-table>\r\n  <mat-paginator showFirstLastButtons=\"true\" class=\"mat-paginator-sticky\" [pageSizeOptions]=\"[10, 25, 100]\">\r\n  </mat-paginator>\r\n</div>",
                    styles: [".mat-column-status{flex:.5}.org-row{cursor:pointer}.mat-paginator-sticky{bottom:0;position:-webkit-sticky;position:sticky;z-index:10}.org-table{position:relative}.mat-table{min-height:250px}.loading-shade{left:0;right:0;background:rgba(0,0,0,.15);display:flex;align-items:center;justify-content:center;position:absolute;top:56px;bottom:56px;z-index:1}.v-center{display:flex;align-items:center}"]
                }] }
    ];
    /** @nocollapse */
    OrganizationTableComponent.ctorParameters = function () { return [
        { type: Router }
    ]; };
    OrganizationTableComponent.propDecorators = {
        organizationList: [{ type: Input }],
        contactPArray: [{ type: Input }],
        headOfInstArray: [{ type: Input }],
        filtered: [{ type: Input }],
        actPage: [{ type: Input }],
        pageSize: [{ type: Input }],
        callSortSizeChanged: [{ type: Output }],
        paginator: [{ type: ViewChild, args: [MatPaginator,] }],
        sort: [{ type: ViewChild, args: [MatSort,] }],
        displayedColumns: [{ type: Input }]
    };
    return OrganizationTableComponent;
}());
export { OrganizationTableComponent };
if (false) {
    /** @type {?} */
    OrganizationTableComponent.prototype.organizationList;
    /** @type {?} */
    OrganizationTableComponent.prototype.contactPArray;
    /** @type {?} */
    OrganizationTableComponent.prototype.headOfInstArray;
    /** @type {?} */
    OrganizationTableComponent.prototype.filtered;
    /** @type {?} */
    OrganizationTableComponent.prototype.actPage;
    /** @type {?} */
    OrganizationTableComponent.prototype.pageSize;
    /** @type {?} */
    OrganizationTableComponent.prototype.callSortSizeChanged;
    /** @type {?} */
    OrganizationTableComponent.prototype.paginator;
    /** @type {?} */
    OrganizationTableComponent.prototype.sort;
    /** @type {?} */
    OrganizationTableComponent.prototype.displayedColumns;
    /** @type {?} */
    OrganizationTableComponent.prototype.dataSource;
    /** @type {?} */
    OrganizationTableComponent.prototype.dataLength;
    /**
     * @type {?}
     * @private
     */
    OrganizationTableComponent.prototype.router;
}
//# sourceMappingURL=data:application/json;base64, 