/**
 * @fileoverview added by tsickle
 * Generated from: lib/dashboard/sidebar-iconlist/portlet-type-new/portlet-type-new.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { Component, Output, EventEmitter, ChangeDetectorRef, ChangeDetectionStrategy, Input, } from "@angular/core";
import { DashboardService } from "../../dashboard.service";
import { getTranslation } from "../../../utils/utils";
export class PortletTypeNewComponent {
    /**
     * @param {?} DashboardService
     * @param {?} ref
     */
    constructor(DashboardService, ref) {
        this.DashboardService = DashboardService;
        this.ref = ref;
        this.dataMartCode = "";
        this.portletType = new EventEmitter();
        this.subscriptions = [];
        this.portletList = [
            {
                portletName: "Table",
                portletCode: "table",
            },
            {
                portletName: "Transpose",
                portletCode: "transpose",
            },
            {
                portletName: "Pivot",
                portletCode: "pivot",
            },
            {
                portletName: "Pie",
                portletCode: "pie",
            },
            {
                portletName: "Bar",
                portletCode: "bar",
            },
            {
                portletName: "Column",
                portletCode: "column",
            },
            {
                portletName: "Line",
                portletCode: "line",
            },
            {
                portletName: "Area",
                portletCode: "area",
            },
            {
                portletName: "Radar",
                portletCode: "radar",
            },
        ];
        this.portletList = this.portletList.concat([
            {
                portletName: "NewChart",
                portletCode: "newchart",
            },
            {
                portletName: "NewColumn",
                portletCode: "newcolumn",
            },
            {
                portletName: "NewLine",
                portletCode: "newline",
            },
            {
                portletName: "NewColumnLine",
                portletCode: "newcolumnline",
            },
            // SMP2-17578/17654，仅 fund/company historical IRR 可选择
            // TODO: 需要确定 fund/company historical IRR code
            {
                portletName: "HistoricalIRR",
                portletCode: "historicalIRR",
            },
        ]);
        /** @type {?} */
        const excludeList = ["Pie", "Bar", "Column", "Line", "Area", "Radar"];
        this.portletList =
            this.portletList.filter((/**
             * @param {?} item
             * @return {?}
             */
            (item) => !excludeList.includes(item.portletName))) || [];
    }
    /**
     * @return {?}
     */
    ngOnInit() {
        this.getInfo();
        if (this.portlet && this.portlet.figureCode) {
            /** @type {?} */
            const configStr = this.portlet.config;
            if (!configStr) {
                return;
            }
            /** @type {?} */
            const config = JSON.parse(configStr);
            this.type = config.portletType;
        }
        this.datamart = JSON.parse(this.dashboard.config).datamartViewCode;
    }
    /**
     * @return {?}
     */
    ngAfterViewInit() {
        this.subscriptions.push(this.DashboardService.getportletEdit().subscribe((/**
         * @param {?} status
         * @return {?}
         */
        (status) => {
            if (status && this.portlet) {
                /** @type {?} */
                const configStr = this.portlet.config;
                if (!configStr) {
                    return;
                }
                /** @type {?} */
                const config = JSON.parse(configStr);
                this.type = config.portletType;
                // this.portletType.emit(this.type);
                this.datamart = config.datamartViewCode;
                this.ref.markForCheck();
                this.ref.detectChanges();
            }
        })));
        //Michael 20200526 clear options data
        this.subscriptions.push(this.DashboardService.getResetbtn().subscribe((/**
         * @param {?} status
         * @return {?}
         */
        (status) => {
            if (status) {
                this.type = "";
                this.portletType.emit(this.type);
                this.ref.detectChanges();
            }
        })));
        this.subscriptions.push(this.DashboardService.getPushbtn().subscribe((/**
         * @param {?} id
         * @return {?}
         */
        (id) => {
            if (this.dashboard && this.dashboard.id === id) {
                this.type = "";
                this.portletType.emit(this.type);
            }
        })));
    }
    /**
     * @param {?} changes
     * @return {?}
     */
    ngOnChanges(changes) {
        if (changes.dataMartCode) {
            if (this.disabledHistoricalIRR && this.type === "historicalIRR") {
                this.selectPortletType(null);
            }
        }
    }
    /**
     * @return {?}
     */
    ngOnDestroy() {
        this.subscriptions.forEach((/**
         * @param {?} sub
         * @return {?}
         */
        (sub) => sub.unsubscribe()));
    }
    /**
     * @return {?}
     */
    get disabledHistoricalIRR() {
        return ![
            "FundHistoricalCashflowIRR",
            "FundHistoricalGrossIRR",
        ].includes(this.dataMartCode);
    }
    /**
     * @param {?} item
     * @return {?}
     */
    setTooltip(item) {
        if (!item)
            return "";
        switch (item.portletName) {
            case "Table":
                return this.translation.TABLE || ".TABLE";
            case "Transpose":
                return `${this.translation.TRANSPOSE || ".TRANSPOSE"} ${this.translation.TABLE || ".TABLE"}`;
            case "Pivot":
                return `${this.translation.PIVOT || ".PIVOT"} ${this.translation.TABLE || ".TABLE"}`;
            case "NewChart":
                return `${this.translation.PIVOT || ".PIVOT"} ${this.translation.COMPANY_CHART || ".COMPANY_CHART"}`;
            case "NewColumn":
                return `${this.translation.CLUSTERED_COLUMN || ".CLUSTERED_COLUMN"} ${this.translation.COMPANY_CHART || ".COMPANY_CHART"}`;
            case "NewLine":
                return `${this.translation.LINE || ".LINE"} ${this.translation.COMPANY_CHART || ".COMPANY_CHART"}`;
            case "NewColumnLine":
                return `${this.translation.LINE || ".LINE"} ${this.translation.AND || ".AND"} ${this.translation.CLUSTERED_COLUMN || ".CLUSTERED_COLUMN"} ${this.translation.COMPANY_CHART || ".COMPANY_CHART"}`;
            case "HistoricalIRR":
                return `${this.translation.HISTORICAL} ${this.translation.IRR}`;
            default:
                return "";
        }
    }
    /**
     * @param {?} portletCode
     * @return {?}
     */
    selectPortletType(portletCode) {
        this.type = portletCode;
        this.portletType.emit(portletCode);
    }
    /**
     * @private
     * @return {?}
     */
    getInfo() {
        this.translation = getTranslation();
        this.userInfo = JSON.parse(localStorage.getItem("userInfo"));
    }
    /**
     * @return {?}
     */
    getFinancialType() {
        if (this.datamart) {
            return this.datamart.toLocaleLowerCase().indexOf("financial") > -1
                ? true
                : false;
        }
    }
    /**
     * @param {?} code
     * @return {?}
     */
    getFPPType(code) {
        /** @type {?} */
        let type_ = [
            "table",
            "pivot",
            "pie",
            "bar",
            "column",
            "line",
            "area",
            "multiSeries",
            "geo",
            "radar",
        ];
        return type_.indexOf(code) > -1 ? true : false;
    }
}
PortletTypeNewComponent.decorators = [
    { type: Component, args: [{
                selector: "rs-portlet-type-new",
                template: "<div class=\"portlet-row row\">\r\n\t<ng-container *ngFor=\"let item of portletList\">\r\n\t\t<div\r\n\t\t\tclass=\"portlet-wrapper\"\r\n\t\t\t*ngIf=\"\r\n\t\t\t\titem.portletCode == 'financialTable' ? getFinancialType() : true\r\n\t\t\t\"\r\n\t\t>\r\n\t\t\t<div\r\n\t\t\t\tclass=\"portlet\"\r\n\t\t\t\t[class]=\"item.portletCode + '-type'\"\r\n\t\t\t\tmatTooltip=\"{{ setTooltip(item) }}\"\r\n\t\t\t\t[ngClass]=\"{\r\n\t\t\t\t\tenabled: item.portletCode !== type,\r\n\t\t\t\t\tselected: item.portletCode === type,\r\n\t\t\t\t\tdisabled:\r\n\t\t\t\t\t\tdisabledHistoricalIRR &&\r\n\t\t\t\t\t\titem.portletCode === 'historicalIRR'\r\n\t\t\t\t}\"\r\n\t\t\t\t(click)=\"selectPortletType(item.portletCode)\"\r\n\t\t\t></div>\r\n\t\t\t<div\r\n\t\t\t\t*ngIf=\"item.portletCode === 'newchart'\"\r\n\t\t\t\tstyle=\"position: relative; top: -4px\"\r\n\t\t\t\tclass=\"portlet-label\"\r\n\t\t\t></div>\r\n\t\t</div>\r\n\t</ng-container>\r\n</div>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                styles: [".portlet-row{display:flex;margin-bottom:10px;justify-content:left;padding:0 16px}.portlet-row .portlet-wrapper{width:20%;display:flex;flex-direction:column;align-items:center;cursor:pointer;margin-bottom:10px;margin-top:5px}.portlet-row .portlet-wrapper .portlet{width:32px;height:32px;background-color:#44566c}.portlet-row .portlet-wrapper .portlet.enabled{background-color:#fff}.portlet-row .portlet-wrapper .portlet.disabled{background-color:#fff;opacity:.4;pointer-events:none}.portlet-row .portlet-wrapper .portlet.selected{background-color:#5867dd;border:5px solid rgba(80,102,181,.5);border-radius:2px}.portlet-row .portlet-wrapper .portlet.selected.table-type{background-image:url(../../assets/img/dashboard_icon/table-3-white.svg);background-repeat:no-repeat;background-position:center;background-size:100% 100%}.portlet-row .portlet-wrapper .portlet.selected.transpose-type{background-image:url(../../assets/img/dashboard_icon/transpose-white.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet.selected.pivot-type{background-image:url(../../assets/img/dashboard_icon/pivot-white.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet.selected.newchart-type{background-image:url(../../assets/img/dashboard_icon/pivot-chart-active.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet.selected.geo-type{background-image:url(../../assets/img/dashboard_icon/geo-white.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet.selected.pie-type{background-image:url(../../assets/img/dashboard_icon/pie-white.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet.selected.bar-type{background-image:url(../../assets/img/dashboard_icon/bar-white.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet.selected.column-type{background-image:url(../../assets/img/dashboard_icon/pivot_column_active.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet.selected.newcolumn-type{background-image:url(../../assets/img/dashboard_icon/column-white.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet.selected.line-type{background-image:url(../../assets/img/dashboard_icon/pivot_line_active.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet.selected.newline-type{background-image:url(../../assets/img/dashboard_icon/trade-up-white.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet.selected.area-type{background-image:url(../../assets/img/dashboard_icon/area-white.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet.selected.multiSeries-type{background-image:url(../../assets/img/dashboard_icon/multi-series-white.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet.selected.radar-type{background-image:url(../../assets/img/dashboard_icon/radar-white.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet.selected.financialTable-type{background-image:url(../../assets/img/dashboard_icon/ftable-white.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet.selected.newcolumnline-type{background-image:url(../../assets/img/dashboard_icon/chart-combined-active.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet.selected.historicalIRR-type{background-image:url(../../assets/img/dashboard_icon/historic-IRR-white.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet.table-type{background-image:url(../../assets/img/dashboard_icon/table-3.svg);background-repeat:no-repeat;background-position:center;background-size:100% 100%}.portlet-row .portlet-wrapper .portlet.transpose-type{background-image:url(../../assets/img/dashboard_icon/transpose.svg);background-repeat:no-repeat;background-position:center;background-size:100% 100%}.portlet-row .portlet-wrapper .portlet.pivot-type{background-image:url(../../assets/img/dashboard_icon/pivot.svg);background-repeat:no-repeat;background-position:center;background-size:100% 100%;width:32px!important;height:32px!important;position:relative}.portlet-row .portlet-wrapper .portlet.newchart-type{background-image:url(../../assets/img/dashboard_icon/pivot-chart.svg);background-repeat:no-repeat;background-position:center;background-size:100% 100%;width:32px!important;height:32px!important;position:relative}.portlet-row .portlet-wrapper .portlet.geo-type{background-image:url(../../assets/img/dashboard_icon/geo.svg);background-repeat:no-repeat;background-position:center;background-size:100% 100%}.portlet-row .portlet-wrapper .portlet.pie-type{background-image:url(../../assets/img/dashboard_icon/pie.svg);background-repeat:no-repeat;background-position:center;background-size:100% 100%}.portlet-row .portlet-wrapper .portlet.bar-type{background-image:url(../../assets/img/dashboard_icon/bar.svg);background-repeat:no-repeat;background-position:center;background-size:100% 100%}.portlet-row .portlet-wrapper .portlet.column-type{background-image:url(../../assets/img/dashboard_icon/pivot_column.svg);background-repeat:no-repeat;background-position:center;background-size:100% 100%;width:28px!important;height:28px!important;position:relative;top:1px}.portlet-row .portlet-wrapper .portlet.newcolumn-type{background-image:url(../../assets/img/dashboard_icon/column.svg);background-repeat:no-repeat;background-position:center;background-size:100% 100%}.portlet-row .portlet-wrapper .portlet.line-type{background-image:url(../../assets/img/dashboard_icon/pivot_line.svg);background-repeat:no-repeat;background-position:center;background-size:100% 100%;width:28px!important;height:28px!important;position:relative;top:1px}.portlet-row .portlet-wrapper .portlet.newline-type{background-image:url(../../assets/img/dashboard_icon/trade-up.svg);background-repeat:no-repeat;background-position:center;background-size:100% 100%}.portlet-row .portlet-wrapper .portlet.area-type{background-image:url(../../assets/img/dashboard_icon/area.svg);background-repeat:no-repeat;background-position:center;background-size:100% 100%}.portlet-row .portlet-wrapper .portlet.multiSeries-type{background-image:url(../../assets/img/dashboard_icon/multi-series.svg);background-repeat:no-repeat;background-position:center;background-size:100% 100%}.portlet-row .portlet-wrapper .portlet.radar-type{background-image:url(../../assets/img/dashboard_icon/radar.svg);background-repeat:no-repeat;background-position:center;background-size:100% 100%}.portlet-row .portlet-wrapper .portlet.financialTable-type{background-image:url(../../assets/img/dashboard_icon/ftable.svg);background-repeat:no-repeat;background-position:center;background-size:100% 100%}.portlet-row .portlet-wrapper .portlet.newcolumnline-type{background-image:url(../../assets/img/dashboard_icon/chart-combined.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet.historicalIRR-type{background-image:url(../../assets/img/dashboard_icon/historic-IRR.svg);background-repeat:no-repeat;background-position:center}.portlet-row .portlet-wrapper .portlet-label{width:100%;text-align:center;font-weight:500;color:#44566c;font-size:12px}"]
            }] }
];
/** @nocollapse */
PortletTypeNewComponent.ctorParameters = () => [
    { type: DashboardService },
    { type: ChangeDetectorRef }
];
PortletTypeNewComponent.propDecorators = {
    dataMartCode: [{ type: Input, args: ["dataMartCode",] }],
    portlet: [{ type: Input }],
    dashboard: [{ type: Input }],
    portletType: [{ type: Output }]
};
if (false) {
    /** @type {?} */
    PortletTypeNewComponent.prototype.dataMartCode;
    /** @type {?} */
    PortletTypeNewComponent.prototype.portlet;
    /** @type {?} */
    PortletTypeNewComponent.prototype.dashboard;
    /** @type {?} */
    PortletTypeNewComponent.prototype.portletType;
    /**
     * @type {?}
     * @private
     */
    PortletTypeNewComponent.prototype.datamart;
    /** @type {?} */
    PortletTypeNewComponent.prototype.translation;
    /**
     * @type {?}
     * @private
     */
    PortletTypeNewComponent.prototype.userInfo;
    /** @type {?} */
    PortletTypeNewComponent.prototype.portletList;
    /** @type {?} */
    PortletTypeNewComponent.prototype.type;
    /**
     * @type {?}
     * @private
     */
    PortletTypeNewComponent.prototype.subscriptions;
    /**
     * @type {?}
     * @private
     */
    PortletTypeNewComponent.prototype.DashboardService;
    /**
     * @type {?}
     * @private
     */
    PortletTypeNewComponent.prototype.ref;
}
//# sourceMappingURL=data:application/json;base64, 