UNPKG

@pepperi/lib

Version:

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.0.1.

726 lines (725 loc) 220 kB
import { Component, Input, Output, EventEmitter, ViewChild } from '@angular/core'; import { delay } from 'rxjs/operators'; import { LAYOUT_TYPE, FIELD_TYPE, SCREEN_SIZE } from '@pepperi/lib'; import { VirtualScrollComponent } from './virtual-scroll.component'; import disableScroll from 'disable-scroll'; // import { ApplicationState } from '../application-state/application-state'; import * as $ from 'jquery'; import * as i0 from "@angular/core"; import * as i1 from "@pepperi/lib"; import * as i2 from "@angular/common"; import * as i3 from "@angular/material/checkbox"; import * as i4 from "@angular/material/icon"; import * as i5 from "@pepperi/lib/icon"; import * as i6 from "./virtual-scroll.component"; import * as i7 from "@pepperi/lib/form"; import * as i8 from "@angular/material/radio"; import * as i9 from "@ngx-translate/core"; const _c0 = ["noVirtualScrollCont"]; const _c1 = ["tableHeader"]; const _c2 = ["selectAllCB"]; function PepperiListComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementContainerStart(0); i0.ɵɵelementStart(1, "div", 3); i0.ɵɵtext(2); i0.ɵɵelementEnd(); i0.ɵɵelementContainerEnd(); } if (rf & 2) { const ctx_r0 = i0.ɵɵnextContext(); i0.ɵɵadvance(2); i0.ɵɵtextInterpolate(ctx_r0.noDataFoundMsg); } } const _c3 = function (a0) { return { visibility: a0 }; }; function PepperiListComponent_ng_container_1_div_1_mat_checkbox_3_Template(rf, ctx) { if (rf & 1) { const _r15 = i0.ɵɵgetCurrentView(); i0.ɵɵelementStart(0, "mat-checkbox", 13, 14); i0.ɵɵlistener("change", function PepperiListComponent_ng_container_1_div_1_mat_checkbox_3_Template_mat_checkbox_change_0_listener($event) { i0.ɵɵrestoreView(_r15); const ctx_r14 = i0.ɵɵnextContext(3); return ctx_r14.selectAllItemsForActions($event); }); i0.ɵɵelementEnd(); } if (rf & 2) { const ctx_r11 = i0.ɵɵnextContext(3); i0.ɵɵproperty("ngStyle", i0.ɵɵpureFunction1(4, _c3, ctx_r11.selectionTypeForActions == ctx_r11.SELECTION_TYPE_FOR_ACTIONS.Single || ctx_r11.selectionTypeForActions == ctx_r11.SELECTION_TYPE_FOR_ACTIONS.Multi && ctx_r11.hideAllSelectionInMulti ? "hidden" : "visible"))("indeterminate", ctx_r11.isAllSelected ? ctx_r11.unSelectedItems.size > 0 && ctx_r11.unSelectedItems.size < ctx_r11.totalRows : ctx_r11.selectedItems.size > 0 && !ctx_r11.getIsAllSelectedForActions())("disabled", ctx_r11.disabled || ctx_r11.selectionTypeForActions === ctx_r11.SELECTION_TYPE_FOR_ACTIONS.Single)("checked", ctx_r11.getIsAllSelectedForActions()); } } function PepperiListComponent_ng_container_1_div_1_div_5_label_1_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "label", 20); i0.ɵɵtext(1); i0.ɵɵelementEnd(); } if (rf & 2) { const field_r16 = i0.ɵɵnextContext().$implicit; i0.ɵɵclassMapInterpolate1("header-label body-sm pull-left flip text-align-", field_r16.Layout.XAlignment, ""); i0.ɵɵpropertyInterpolate("id", field_r16.ApiName); i0.ɵɵpropertyInterpolate("title", field_r16.Title); i0.ɵɵadvance(1); i0.ɵɵtextInterpolate1(" ", field_r16.Title, " "); } } function PepperiListComponent_ng_container_1_div_1_div_5_label_2_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "label", 21); i0.ɵɵtext(1, "\u00A0"); i0.ɵɵelementEnd(); } if (rf & 2) { const field_r16 = i0.ɵɵnextContext().$implicit; i0.ɵɵpropertyInterpolate("id", field_r16.ApiName); } } function PepperiListComponent_ng_container_1_div_1_div_5_div_3_Template(rf, ctx) { if (rf & 1) { const _r25 = i0.ɵɵgetCurrentView(); i0.ɵɵelementStart(0, "div", 22); i0.ɵɵlistener("mousedown", function PepperiListComponent_ng_container_1_div_1_div_5_div_3_Template_div_mousedown_0_listener($event) { i0.ɵɵrestoreView(_r25); const field_r16 = i0.ɵɵnextContext().$implicit; const ctx_r24 = i0.ɵɵnextContext(3); return ctx_r24.onListResizeStart($event, field_r16.ApiName); }); i0.ɵɵelementStart(1, "mat-icon"); i0.ɵɵelement(2, "pep-icon", 23); i0.ɵɵelementEnd(); i0.ɵɵelementEnd(); } } function PepperiListComponent_ng_container_1_div_1_div_5_div_4_mat_icon_1_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "mat-icon"); i0.ɵɵelement(1, "pep-icon", 26); i0.ɵɵelementEnd(); } } const _c4 = function (a0) { return { "sort-by": a0 }; }; function PepperiListComponent_ng_container_1_div_1_div_5_div_4_mat_icon_2_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "mat-icon", 27); i0.ɵɵpipe(1, "translate"); i0.ɵɵelement(2, "pep-icon", 28); i0.ɵɵelementEnd(); } if (rf & 2) { const field_r16 = i0.ɵɵnextContext(2).$implicit; const ctx_r28 = i0.ɵɵnextContext(3); i0.ɵɵpropertyInterpolate("title", i0.ɵɵpipeBind1(1, 2, "Asc")); i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(4, _c4, field_r16.ApiName === ctx_r28.sortBy && ctx_r28.isAsc)); } } function PepperiListComponent_ng_container_1_div_1_div_5_div_4_mat_icon_3_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "mat-icon", 27); i0.ɵɵpipe(1, "translate"); i0.ɵɵelement(2, "pep-icon", 29); i0.ɵɵelementEnd(); } if (rf & 2) { const field_r16 = i0.ɵɵnextContext(2).$implicit; const ctx_r29 = i0.ɵɵnextContext(3); i0.ɵɵpropertyInterpolate("title", i0.ɵɵpipeBind1(1, 2, "Desc")); i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(4, _c4, field_r16.ApiName === ctx_r29.sortBy && !ctx_r29.isAsc)); } } const _c5 = function (a0) { return { "has-sorting": a0 }; }; function PepperiListComponent_ng_container_1_div_1_div_5_div_4_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "div", 24); i0.ɵɵtemplate(1, PepperiListComponent_ng_container_1_div_1_div_5_div_4_mat_icon_1_Template, 2, 0, "mat-icon", 0); i0.ɵɵtemplate(2, PepperiListComponent_ng_container_1_div_1_div_5_div_4_mat_icon_2_Template, 3, 6, "mat-icon", 25); i0.ɵɵtemplate(3, PepperiListComponent_ng_container_1_div_1_div_5_div_4_mat_icon_3_Template, 3, 6, "mat-icon", 25); i0.ɵɵelementEnd(); } if (rf & 2) { const field_r16 = i0.ɵɵnextContext().$implicit; const ctx_r21 = i0.ɵɵnextContext(3); i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(4, _c5, field_r16.ApiName === ctx_r21.sortBy)); i0.ɵɵadvance(1); i0.ɵɵproperty("ngIf", field_r16.ApiName !== ctx_r21.sortBy); i0.ɵɵadvance(1); i0.ɵɵproperty("ngIf", field_r16.ApiName === ctx_r21.sortBy && !ctx_r21.isAsc); i0.ɵɵadvance(1); i0.ɵɵproperty("ngIf", field_r16.ApiName === ctx_r21.sortBy && ctx_r21.isAsc); } } const _c6 = function (a0) { return { width: a0 }; }; const _c7 = function (a0, a1, a2, a3, a4) { return { "support-sorting": a0, "has-sorting": a1, "is-resizing": a2, "is-first": a3, "is-last": a4 }; }; function PepperiListComponent_ng_container_1_div_1_div_5_Template(rf, ctx) { if (rf & 1) { const _r34 = i0.ɵɵgetCurrentView(); i0.ɵɵelementStart(0, "div", 15); i0.ɵɵlistener("click", function PepperiListComponent_ng_container_1_div_1_div_5_Template_div_click_0_listener($event) { i0.ɵɵrestoreView(_r34); const field_r16 = ctx.$implicit; const ctx_r33 = i0.ɵɵnextContext(3); return ctx_r33.supportSorting ? ctx_r33.onListSortingChange(field_r16.ApiName, ctx_r33.sortBy !== null && ctx_r33.sortBy != field_r16.ApiName ? true : !ctx_r33.isAsc, $event) : false; }); i0.ɵɵtemplate(1, PepperiListComponent_ng_container_1_div_1_div_5_label_1_Template, 2, 6, "label", 16); i0.ɵɵtemplate(2, PepperiListComponent_ng_container_1_div_1_div_5_label_2_Template, 2, 1, "label", 17); i0.ɵɵtemplate(3, PepperiListComponent_ng_container_1_div_1_div_5_div_3_Template, 3, 0, "div", 18); i0.ɵɵtemplate(4, PepperiListComponent_ng_container_1_div_1_div_5_div_4_Template, 4, 6, "div", 19); i0.ɵɵelementEnd(); } if (rf & 2) { const field_r16 = ctx.$implicit; const j_r17 = ctx.index; const ctx_r12 = i0.ɵɵnextContext(3); i0.ɵɵproperty("ngStyle", i0.ɵɵpureFunction1(6, _c6, field_r16.calcTitleColumnWidthString))("ngClass", i0.ɵɵpureFunction5(8, _c7, ctx_r12.supportSorting, field_r16.ApiName === ctx_r12.sortBy, field_r16.ApiName === ctx_r12.pressedColumn, j_r17 === 0 && ctx_r12.selectionTypeForActions !== ctx_r12.SELECTION_TYPE_FOR_ACTIONS.Multi, j_r17 === (ctx_r12.uiControl == null ? null : ctx_r12.uiControl.ControlFields == null ? null : ctx_r12.uiControl.ControlFields.length) - 1)); i0.ɵɵadvance(1); i0.ɵɵproperty("ngIf", field_r16.Title != ""); i0.ɵɵadvance(1); i0.ɵɵproperty("ngIf", field_r16.Title == ""); i0.ɵɵadvance(1); i0.ɵɵproperty("ngIf", ctx_r12.supportResizing); i0.ɵɵadvance(1); i0.ɵɵproperty("ngIf", ctx_r12.supportSorting); } } const _c8 = function (a0) { return { "below-header-and-top-bar": a0 }; }; function PepperiListComponent_ng_container_1_div_1_Template(rf, ctx) { if (rf & 1) { const _r36 = i0.ɵɵgetCurrentView(); i0.ɵɵelementStart(0, "div", 8, 9); i0.ɵɵlistener("mouseup", function PepperiListComponent_ng_container_1_div_1_Template_div_mouseup_0_listener($event) { i0.ɵɵrestoreView(_r36); const ctx_r35 = i0.ɵɵnextContext(2); return ctx_r35.onListResizeEnd($event); })("mouseenter", function PepperiListComponent_ng_container_1_div_1_Template_div_mouseenter_0_listener($event) { i0.ɵɵrestoreView(_r36); const ctx_r37 = i0.ɵɵnextContext(2); return ctx_r37.onListHeaderMouseEnter($event); })("mouseleave", function PepperiListComponent_ng_container_1_div_1_Template_div_mouseleave_0_listener($event) { i0.ɵɵrestoreView(_r36); const ctx_r38 = i0.ɵɵnextContext(2); return ctx_r38.onListHeaderMouseLeave($event); })("mousemove", function PepperiListComponent_ng_container_1_div_1_Template_div_mousemove_0_listener($event) { i0.ɵɵrestoreView(_r36); const ctx_r39 = i0.ɵɵnextContext(2); return ctx_r39.onListResize($event); }); i0.ɵɵelementStart(2, "fieldset", 10); i0.ɵɵtemplate(3, PepperiListComponent_ng_container_1_div_1_mat_checkbox_3_Template, 2, 6, "mat-checkbox", 11); i0.ɵɵelementStart(4, "fieldset"); i0.ɵɵtemplate(5, PepperiListComponent_ng_container_1_div_1_div_5_Template, 5, 14, "div", 12); i0.ɵɵelementEnd(); i0.ɵɵelementEnd(); i0.ɵɵelementEnd(); } if (rf & 2) { const ctx_r6 = i0.ɵɵnextContext(2); i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(3, _c8, ctx_r6.parentScroll == null)); i0.ɵɵadvance(3); i0.ɵɵproperty("ngIf", ctx_r6.selectionTypeForActions !== ctx_r6.SELECTION_TYPE_FOR_ACTIONS.None); i0.ɵɵadvance(2); i0.ɵɵproperty("ngForOf", ctx_r6.uiControl == null ? null : ctx_r6.uiControl.ControlFields); } } function PepperiListComponent_ng_container_1_virtual_scroll_2_ng_container_1_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementContainer(0); } } const _c9 = function (a0, a1) { return { "table-body": a0, "cards-body": a1 }; }; function PepperiListComponent_ng_container_1_virtual_scroll_2_Template(rf, ctx) { if (rf & 1) { const _r42 = i0.ɵɵgetCurrentView(); i0.ɵɵelementStart(0, "virtual-scroll", 30); i0.ɵɵlistener("load", function PepperiListComponent_ng_container_1_virtual_scroll_2_Template_virtual_scroll_load_0_listener($event) { i0.ɵɵrestoreView(_r42); const ctx_r41 = i0.ɵɵnextContext(2); return ctx_r41.onListLoad($event); })("change", function PepperiListComponent_ng_container_1_virtual_scroll_2_Template_virtual_scroll_change_0_listener($event) { i0.ɵɵrestoreView(_r42); const ctx_r43 = i0.ɵɵnextContext(2); return ctx_r43.onListChange($event); }); i0.ɵɵtemplate(1, PepperiListComponent_ng_container_1_virtual_scroll_2_ng_container_1_Template, 1, 0, "ng-container", 7); i0.ɵɵelementEnd(); } if (rf & 2) { const ctx_r7 = i0.ɵɵnextContext(2); const _r2 = i0.ɵɵreference(3); i0.ɵɵproperty("totalRows", ctx_r7.totalRows)("isTable", ctx_r7.isTable)("parentScroll", ctx_r7.parentScroll ? ctx_r7.parentScroll : ctx_r7.nativeWindow)("bufferAmount", ctx_r7.isReport ? ctx_r7.isTable ? 20 : 3 : ctx_r7.isTable ? 15 : 3)("ngClass", i0.ɵɵpureFunction2(6, _c9, ctx_r7.isTable, !ctx_r7.isTable)); i0.ɵɵadvance(1); i0.ɵɵproperty("ngTemplateOutlet", _r2); } } function PepperiListComponent_ng_container_1_div_3_ng_container_2_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementContainer(0); } } function PepperiListComponent_ng_container_1_div_3_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "div", 31, 32); i0.ɵɵtemplate(2, PepperiListComponent_ng_container_1_div_3_ng_container_2_Template, 1, 0, "ng-container", 7); i0.ɵɵelementEnd(); } if (rf & 2) { const ctx_r8 = i0.ɵɵnextContext(2); const _r2 = i0.ɵɵreference(3); i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction2(2, _c9, ctx_r8.isTable, !ctx_r8.isTable)); i0.ɵɵadvance(2); i0.ɵɵproperty("ngTemplateOutlet", _r2); } } function PepperiListComponent_ng_container_1_ng_container_4_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementContainer(0); } } function PepperiListComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementContainerStart(0); i0.ɵɵtemplate(1, PepperiListComponent_ng_container_1_div_1_Template, 6, 5, "div", 4); i0.ɵɵtemplate(2, PepperiListComponent_ng_container_1_virtual_scroll_2_Template, 2, 9, "virtual-scroll", 5); i0.ɵɵtemplate(3, PepperiListComponent_ng_container_1_div_3_Template, 3, 5, "div", 6); i0.ɵɵtemplate(4, PepperiListComponent_ng_container_1_ng_container_4_Template, 1, 0, "ng-container", 7); i0.ɵɵelementContainerEnd(); } if (rf & 2) { const ctx_r1 = i0.ɵɵnextContext(); const _r4 = i0.ɵɵreference(5); i0.ɵɵadvance(1); i0.ɵɵproperty("ngIf", ctx_r1.isTable); i0.ɵɵadvance(1); i0.ɵɵproperty("ngIf", ctx_r1.useVirtualScroll); i0.ɵɵadvance(1); i0.ɵɵproperty("ngIf", !ctx_r1.useVirtualScroll); i0.ɵɵadvance(1); i0.ɵɵproperty("ngTemplateOutlet", _r4); } } function PepperiListComponent_ng_template_2_ng_container_0_ng_container_1_mat_checkbox_3_Template(rf, ctx) { if (rf & 1) { const _r55 = i0.ɵɵgetCurrentView(); i0.ɵɵelementStart(0, "mat-checkbox", 39); i0.ɵɵlistener("change", function PepperiListComponent_ng_template_2_ng_container_0_ng_container_1_mat_checkbox_3_Template_mat_checkbox_change_0_listener($event) { i0.ɵɵrestoreView(_r55); const pepperiObjectInput_r47 = i0.ɵɵnextContext(2).$implicit; const ctx_r54 = i0.ɵɵnextContext(2); return ctx_r54.selectItemForActions($event, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.IsSelectableForActions, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type); }); i0.ɵɵelementEnd(); } if (rf & 2) { const pepperiObjectInput_r47 = i0.ɵɵnextContext(2).$implicit; const ctx_r52 = i0.ɵɵnextContext(2); i0.ɵɵproperty("disabled", ctx_r52.getIsDisabled(pepperiObjectInput_r47))("ngStyle", i0.ɵɵpureFunction1(3, _c3, ctx_r52.isTouchDevice || (pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID) + ctx_r52.SEPARATOR + (pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type) === ctx_r52.hoveredItemId || ctx_r52.isAllSelected || ctx_r52.selectedItems.size > 0 ? "visible" : "hidden"))("checked", ctx_r52.getIsSelectedForActions(pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.IsSelectableForActions, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type)); } } function PepperiListComponent_ng_template_2_ng_container_0_ng_container_1_mat_radio_button_4_Template(rf, ctx) { if (rf & 1) { const _r59 = i0.ɵɵgetCurrentView(); i0.ɵɵelementStart(0, "mat-radio-button", 40); i0.ɵɵlistener("change", function PepperiListComponent_ng_template_2_ng_container_0_ng_container_1_mat_radio_button_4_Template_mat_radio_button_change_0_listener($event) { i0.ɵɵrestoreView(_r59); const pepperiObjectInput_r47 = i0.ɵɵnextContext(2).$implicit; const ctx_r58 = i0.ɵɵnextContext(2); return ctx_r58.selectItemForActions($event, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.IsSelectableForActions, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type); }); i0.ɵɵelementEnd(); } if (rf & 2) { const pepperiObjectInput_r47 = i0.ɵɵnextContext(2).$implicit; const ctx_r53 = i0.ɵɵnextContext(2); i0.ɵɵproperty("disabled", ctx_r53.getIsDisabled(pepperiObjectInput_r47))("checked", ctx_r53.getIsSelectedForActions(pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.IsSelectableForActions, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type)); } } const _c10 = function (a0, a1) { return { selected: a0, highlighted: a1 }; }; const _c11 = function (a0, a1) { return { height: a0, visibility: a1 }; }; const _c12 = function (a0) { return { "background-color": a0 }; }; function PepperiListComponent_ng_template_2_ng_container_0_ng_container_1_Template(rf, ctx) { if (rf & 1) { const _r63 = i0.ɵɵgetCurrentView(); i0.ɵɵelementContainerStart(0); i0.ɵɵelementStart(1, "div", 34); i0.ɵɵlistener("mouseenter", function PepperiListComponent_ng_template_2_ng_container_0_ng_container_1_Template_div_mouseenter_1_listener($event) { i0.ɵɵrestoreView(_r63); const pepperiObjectInput_r47 = i0.ɵɵnextContext().$implicit; const ctx_r62 = i0.ɵɵnextContext(2); return ctx_r62.onTableRowMouseEnter($event, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type); })("mouseleave", function PepperiListComponent_ng_template_2_ng_container_0_ng_container_1_Template_div_mouseleave_1_listener($event) { i0.ɵɵrestoreView(_r63); const pepperiObjectInput_r47 = i0.ɵɵnextContext().$implicit; const ctx_r65 = i0.ɵɵnextContext(2); return ctx_r65.onTableRowMouseLeave($event, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type); }); i0.ɵɵelementStart(2, "fieldset", 35); i0.ɵɵtemplate(3, PepperiListComponent_ng_template_2_ng_container_0_ng_container_1_mat_checkbox_3_Template, 1, 5, "mat-checkbox", 36); i0.ɵɵtemplate(4, PepperiListComponent_ng_template_2_ng_container_0_ng_container_1_mat_radio_button_4_Template, 1, 2, "mat-radio-button", 37); i0.ɵɵelementStart(5, "pep-form", 38); i0.ɵɵlistener("notifyValueChanged", function PepperiListComponent_ng_template_2_ng_container_0_ng_container_1_Template_pep_form_notifyValueChanged_5_listener($event) { i0.ɵɵrestoreView(_r63); const ctx_r67 = i0.ɵɵnextContext(3); return ctx_r67.onValueChanged($event); })("notifyFieldClicked", function PepperiListComponent_ng_template_2_ng_container_0_ng_container_1_Template_pep_form_notifyFieldClicked_5_listener($event) { i0.ɵɵrestoreView(_r63); const ctx_r68 = i0.ɵɵnextContext(3); return ctx_r68.onCustomizeFieldClick($event); })("notifyMenuItemClicked", function PepperiListComponent_ng_template_2_ng_container_0_ng_container_1_Template_pep_form_notifyMenuItemClicked_5_listener($event) { i0.ɵɵrestoreView(_r63); const ctx_r69 = i0.ɵɵnextContext(3); return ctx_r69.onCustomizeFieldMenuClicked($event); })("click", function PepperiListComponent_ng_template_2_ng_container_0_ng_container_1_Template_pep_form_click_5_listener($event) { i0.ɵɵrestoreView(_r63); const pepperiObjectInput_r47 = i0.ɵɵnextContext().$implicit; const ctx_r70 = i0.ɵɵnextContext(2); return ctx_r70.itemClicked($event, pepperiObjectInput_r47); }); i0.ɵɵelementEnd(); i0.ɵɵelementEnd(); i0.ɵɵelementEnd(); i0.ɵɵelementContainerEnd(); } if (rf & 2) { const pepperiObjectInput_r47 = i0.ɵɵnextContext().$implicit; const ctx_r50 = i0.ɵɵnextContext(2); i0.ɵɵadvance(1); i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction2(19, _c10, ctx_r50.isItemSelected(pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type), (pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID) + ctx_r50.SEPARATOR + (pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type) === ctx_r50.selectedItemId))("ngStyle", i0.ɵɵpureFunction2(22, _c11, ctx_r50.calculatedObjectHeight, ctx_r50.showItems || pepperiObjectInput_r47 ? "visible" : "hidden")); i0.ɵɵadvance(1); i0.ɵɵproperty("ngStyle", i0.ɵɵpureFunction1(25, _c12, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.BackgroundColor)); i0.ɵɵadvance(1); i0.ɵɵproperty("ngIf", ctx_r50.selectionTypeForActions == ctx_r50.SELECTION_TYPE_FOR_ACTIONS.Multi || ctx_r50.selectionTypeForActions == ctx_r50.SELECTION_TYPE_FOR_ACTIONS.SingleAction); i0.ɵɵadvance(1); i0.ɵɵproperty("ngIf", ctx_r50.selectionTypeForActions == ctx_r50.SELECTION_TYPE_FOR_ACTIONS.Single); i0.ɵɵadvance(1); i0.ɵɵproperty("checkForChanges", ctx_r50.checkForChanges)("uiControlHeader", ctx_r50.uiControl)("firstFieldAsLink", ctx_r50.firstFieldAsLink)("pepperiObjectInput", pepperiObjectInput_r47)("canEditObject", !ctx_r50.disabled && (pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.IsEditable))("objectId", ctx_r50.objectId)("parentId", ctx_r50.parentId)("searchCode", ctx_r50.searchCode)("lockEvents", ctx_r50.disableSelectionItems)("isReport", ctx_r50.isReport)("layoutType", ctx_r50.LAYOUT_TYPE.PepperiTable)("listType", ctx_r50.listType)("isActive", ((pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID) + ctx_r50.SEPARATOR + (pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type) === ctx_r50.selectedItemId || (pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID) + ctx_r50.SEPARATOR + (pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type) === ctx_r50.hoveredItemId) && !ctx_r50.isTouchDevice)("pageType", ctx_r50.pageType); } } function PepperiListComponent_ng_template_2_ng_container_0_ng_container_2_mat_checkbox_2_Template(rf, ctx) { if (rf & 1) { const _r75 = i0.ɵɵgetCurrentView(); i0.ɵɵelementStart(0, "mat-checkbox", 44); i0.ɵɵlistener("change", function PepperiListComponent_ng_template_2_ng_container_0_ng_container_2_mat_checkbox_2_Template_mat_checkbox_change_0_listener($event) { i0.ɵɵrestoreView(_r75); const pepperiObjectInput_r47 = i0.ɵɵnextContext(2).$implicit; const ctx_r74 = i0.ɵɵnextContext(2); return ctx_r74.selectItemForActions($event, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.IsSelectableForActions, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type); }); i0.ɵɵelementEnd(); } if (rf & 2) { const pepperiObjectInput_r47 = i0.ɵɵnextContext(2).$implicit; const ctx_r73 = i0.ɵɵnextContext(2); i0.ɵɵproperty("disabled", ctx_r73.getIsDisabled(pepperiObjectInput_r47))("checked", ctx_r73.getIsSelectedForActions(pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.IsSelectableForActions, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type)); } } const _c13 = function (a0, a1, a2) { return { selected: a0, highlighted: a1, cardView: a2 }; }; function PepperiListComponent_ng_template_2_ng_container_0_ng_container_2_Template(rf, ctx) { if (rf & 1) { const _r79 = i0.ɵɵgetCurrentView(); i0.ɵɵelementContainerStart(0); i0.ɵɵelementStart(1, "div", 41); i0.ɵɵlistener("mouseenter", function PepperiListComponent_ng_template_2_ng_container_0_ng_container_2_Template_div_mouseenter_1_listener($event) { i0.ɵɵrestoreView(_r79); const pepperiObjectInput_r47 = i0.ɵɵnextContext().$implicit; const ctx_r78 = i0.ɵɵnextContext(2); return ctx_r78.onCardMouseEnter($event, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type); })("mouseleave", function PepperiListComponent_ng_template_2_ng_container_0_ng_container_2_Template_div_mouseleave_1_listener($event) { i0.ɵɵrestoreView(_r79); const pepperiObjectInput_r47 = i0.ɵɵnextContext().$implicit; const ctx_r81 = i0.ɵɵnextContext(2); return ctx_r81.onCardMouseLeave($event, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type); }); i0.ɵɵtemplate(2, PepperiListComponent_ng_template_2_ng_container_0_ng_container_2_mat_checkbox_2_Template, 1, 2, "mat-checkbox", 42); i0.ɵɵelementStart(3, "pep-form", 43); i0.ɵɵlistener("notifyValueChanged", function PepperiListComponent_ng_template_2_ng_container_0_ng_container_2_Template_pep_form_notifyValueChanged_3_listener($event) { i0.ɵɵrestoreView(_r79); const ctx_r83 = i0.ɵɵnextContext(3); return ctx_r83.onValueChanged($event); })("notifyFieldClicked", function PepperiListComponent_ng_template_2_ng_container_0_ng_container_2_Template_pep_form_notifyFieldClicked_3_listener($event) { i0.ɵɵrestoreView(_r79); const ctx_r84 = i0.ɵɵnextContext(3); return ctx_r84.onCustomizeFieldClick($event); })("notifyMenuItemClicked", function PepperiListComponent_ng_template_2_ng_container_0_ng_container_2_Template_pep_form_notifyMenuItemClicked_3_listener($event) { i0.ɵɵrestoreView(_r79); const ctx_r85 = i0.ɵɵnextContext(3); return ctx_r85.onCustomizeFieldMenuClicked($event); })("click", function PepperiListComponent_ng_template_2_ng_container_0_ng_container_2_Template_pep_form_click_3_listener($event) { i0.ɵɵrestoreView(_r79); const pepperiObjectInput_r47 = i0.ɵɵnextContext().$implicit; const ctx_r86 = i0.ɵɵnextContext(2); return ctx_r86.itemClicked($event, pepperiObjectInput_r47); }); i0.ɵɵelementEnd(); i0.ɵɵelementEnd(); i0.ɵɵelementContainerEnd(); } if (rf & 2) { const pepperiObjectInput_r47 = i0.ɵɵnextContext().$implicit; const ctx_r51 = i0.ɵɵnextContext(2); i0.ɵɵadvance(1); i0.ɵɵclassMap(ctx_r51.itemClass); i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction3(19, _c13, ctx_r51.isItemSelected(pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID, pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type), (pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID) + ctx_r51.SEPARATOR + (pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type) === ctx_r51.selectedItemId, ctx_r51.isCardView))("ngStyle", i0.ɵɵpureFunction2(23, _c11, ctx_r51.calculatedObjectHeight, ctx_r51.showItems || pepperiObjectInput_r47 ? "visible" : "hidden")); i0.ɵɵadvance(1); i0.ɵɵproperty("ngIf", ctx_r51.showSelection); i0.ɵɵadvance(1); i0.ɵɵproperty("firstFieldAsLink", ctx_r51.isCardView ? ctx_r51.firstFieldAsLink : false)("checkForChanges", ctx_r51.checkForChanges)("uiControlHeader", ctx_r51.uiControl)("pepperiObjectInput", pepperiObjectInput_r47)("isCardView", ctx_r51.isCardView)("canEditObject", !ctx_r51.disabled && (pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.IsEditable))("objectId", ctx_r51.objectId)("parentId", ctx_r51.parentId)("searchCode", ctx_r51.searchCode)("lockEvents", ctx_r51.disableSelectionItems)("layoutType", ctx_r51.getThumbnailsLayout())("listType", ctx_r51.listType)("isActive", ((pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID) + ctx_r51.SEPARATOR + (pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type) === ctx_r51.selectedItemId || (pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.UID) + ctx_r51.SEPARATOR + (pepperiObjectInput_r47 == null ? null : pepperiObjectInput_r47.Data == null ? null : pepperiObjectInput_r47.Data.Type) === ctx_r51.hoveredItemId) && !ctx_r51.isTouchDevice)("pageType", ctx_r51.pageType); } } function PepperiListComponent_ng_template_2_ng_container_0_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementContainerStart(0); i0.ɵɵtemplate(1, PepperiListComponent_ng_template_2_ng_container_0_ng_container_1_Template, 6, 27, "ng-container", 0); i0.ɵɵtemplate(2, PepperiListComponent_ng_template_2_ng_container_0_ng_container_2_Template, 4, 26, "ng-container", 0); i0.ɵɵelementContainerEnd(); } if (rf & 2) { const ctx_r46 = i0.ɵɵnextContext(2); i0.ɵɵadvance(1); i0.ɵɵproperty("ngIf", ctx_r46.isTable); i0.ɵɵadvance(1); i0.ɵɵproperty("ngIf", !ctx_r46.isTable); } } function PepperiListComponent_ng_template_2_Template(rf, ctx) { if (rf & 1) { i0.ɵɵtemplate(0, PepperiListComponent_ng_template_2_ng_container_0_Template, 3, 2, "ng-container", 33); } if (rf & 2) { const ctx_r3 = i0.ɵɵnextContext(); i0.ɵɵproperty("ngForOf", ctx_r3.scrollItems)("ngForTrackBy", ctx_r3.trackByFunc); } } function PepperiListComponent_ng_template_4_div_0_div_2_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "div", 48); i0.ɵɵelementStart(1, "label"); i0.ɵɵtext(2); i0.ɵɵelementEnd(); i0.ɵɵelementEnd(); } if (rf & 2) { const field_r91 = ctx.$implicit; const j_r92 = ctx.index; const ctx_r90 = i0.ɵɵnextContext(3); i0.ɵɵproperty("ngStyle", i0.ɵɵpureFunction1(5, _c6, field_r91.calcTitleColumnWidthString)); i0.ɵɵadvance(1); i0.ɵɵclassMapInterpolate1("total-label body-sm text-align-", field_r91.Layout.XAlignment, ""); i0.ɵɵadvance(1); i0.ɵɵtextInterpolate1(" ", ctx_r90.totalsRow[j_r92], " "); } } function PepperiListComponent_ng_template_4_div_0_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "div", 46); i0.ɵɵelementStart(1, "fieldset", 10); i0.ɵɵtemplate(2, PepperiListComponent_ng_template_4_div_0_div_2_Template, 3, 7, "div", 47); i0.ɵɵelementEnd(); i0.ɵɵelementEnd(); } if (rf & 2) { const ctx_r89 = i0.ɵɵnextContext(2); i0.ɵɵadvance(2); i0.ɵɵproperty("ngForOf", ctx_r89.uiControl == null ? null : ctx_r89.uiControl.ControlFields); } } function PepperiListComponent_ng_template_4_Template(rf, ctx) { if (rf & 1) { i0.ɵɵtemplate(0, PepperiListComponent_ng_template_4_div_0_Template, 3, 1, "div", 45); } if (rf & 2) { const ctx_r5 = i0.ɵɵnextContext(); i0.ɵɵproperty("ngIf", (ctx_r5.totalsRow == null ? null : ctx_r5.totalsRow.length) > 0 && ctx_r5.totalsRow.length <= (ctx_r5.uiControl == null ? null : ctx_r5.uiControl.ControlFields.length)); } } export var SELECTION_TYPE_FOR_ACTIONS; (function (SELECTION_TYPE_FOR_ACTIONS) { SELECTION_TYPE_FOR_ACTIONS[SELECTION_TYPE_FOR_ACTIONS["None"] = 0] = "None"; SELECTION_TYPE_FOR_ACTIONS[SELECTION_TYPE_FOR_ACTIONS["Single"] = 1] = "Single"; SELECTION_TYPE_FOR_ACTIONS[SELECTION_TYPE_FOR_ACTIONS["Multi"] = 2] = "Multi"; SELECTION_TYPE_FOR_ACTIONS[SELECTION_TYPE_FOR_ACTIONS["SingleAction"] = 3] = "SingleAction"; })(SELECTION_TYPE_FOR_ACTIONS || (SELECTION_TYPE_FOR_ACTIONS = {})); export var VIEW_TYPE; (function (VIEW_TYPE) { VIEW_TYPE[VIEW_TYPE["None"] = 0] = "None"; VIEW_TYPE[VIEW_TYPE["Card"] = 1] = "Card"; VIEW_TYPE[VIEW_TYPE["Line"] = 2] = "Line"; VIEW_TYPE[VIEW_TYPE["Table"] = 3] = "Table"; VIEW_TYPE[VIEW_TYPE["Map"] = 4] = "Map"; })(VIEW_TYPE || (VIEW_TYPE = {})); export class SelectionData { } export class PepperiListComponent { constructor(element, layoutService, cd, renderer) { this.element = element; this.layoutService = layoutService; this.cd = cd; this.renderer = renderer; this.currentListTypeTranslation = ''; this.noDataFoundMsg = 'Items not found'; this.selectionTypeForActions = SELECTION_TYPE_FOR_ACTIONS.Multi; this.hideAllSelectionInMulti = false; this.top = -1; this.listType = ''; this.objectId = '0'; this.parentId = '0'; this.searchCode = '0'; // @Input() showTopBorder = false; this.firstFieldAsLink = false; this.supportSorting = true; this.supportResizing = true; this.parentScroll = null; this.disabled = false; this.isPrinting = false; this.disableSelectionItems = false; this.isReport = false; this.layoutType = null; this.pageType = ''; this.totalsRow = []; this.isTouchDevice = false; this.notifyThumbnailClicked = new EventEmitter(); this.notifyFieldClicked = new EventEmitter(); this.notifyMenuItemClicked = new EventEmitter(); this.notifyValueChanged = new EventEmitter(); this.notifyListChanged = new EventEmitter(); this.notifySortingChanged = new EventEmitter(); this.notifySelectedItemsChanged = new EventEmitter(); this.notifySelectAllSingleActionClicked = new EventEmitter(); this.notifySingleActionClicked = new EventEmitter(); this.notifyListLoad = new EventEmitter(); this.LAYOUT_TYPE = LAYOUT_TYPE; this.SELECTION_TYPE_FOR_ACTIONS = SELECTION_TYPE_FOR_ACTIONS; this.uiControl = null; this.totalRows = -1; this.isTable = false; this.hasColumnWidthOfTypePercentage = true; this.items = null; this.showSelection = false; this.isCardView = false; this.itemsCounter = 0; this.showItems = true; this.SEPARATOR = ','; this.isAllSelected = false; this.selectedItems = new Map(); this.unSelectedItems = new Map(); // public tableHeaderWidth: string; this.nativeWindow = null; this.selectedItemId = ''; this.hoveredItemId = ''; this.lockEvents = false; this.containerWidth = 0; // headerIsInFocus = false; // For resize this.pressedColumn = ''; this.startX = 0; this.startWidth = 0; this.tableStartWidth = 0; // For sorting this.isAsc = true; this.sortBy = ''; this.isUserSelected = false; this.checkForChanges = null; this.useVirtualScroll = true; this.layoutService.onResize$ .pipe(delay(0)) .subscribe(size => { this.screenSize = size; }); // this.checkForChanges = new Date().getTime(); // this.state.stateKey = location.href; this.nativeWindow = window; } ngOnInit() { this.containerWidth = 0; } ngOnChanges(changes) { if (this.containerWidth <= 0) { this.setContainerWidth(); } } ngOnDestroy() { if (this.notifyValueChanged) { this.notifyValueChanged.unsubscribe(); } if (this.notifyListChanged) { this.notifyListChanged.unsubscribe(); } if (this.notifySortingChanged) { this.notifySortingChanged.unsubscribe(); } if (this.notifyFieldClicked) { this.notifyFieldClicked.unsubscribe(); } if (this.notifyMenuItemClicked) { this.notifyMenuItemClicked.unsubscribe(); } if (this.notifyThumbnailClicked) { this.notifyThumbnailClicked.unsubscribe(); } this.saveSortingToSession(); } setContainerWidth() { const selectionCheckBoxWidth = this.selectionTypeForActions === SELECTION_TYPE_FOR_ACTIONS.Multi ? 44 : 0; const rowHeight = 40; // the table row height (2.5rem * 16font-size). const style = window.getComputedStyle(this.element.nativeElement.parentElement); // The container-fluid class padding left + right + border const containerFluidSpacing = parseInt(style.paddingLeft, 10) + parseInt(style.paddingRight, 10); const parentContainer = this.element.nativeElement.parentElement.parentElement > 0 ? this.element.nativeElement.parentElement.parentElement : this.element.nativeElement.parentElement; // Calculate if vertical scroll should appear, if so set the scroll width. (this.totalRows + 1) + 1 is for the header row. const scrollWidth = parentContainer.clientHeight < rowHeight * (this.totalRows + 1) ? 18 : 0; // 18 is the default scroll width. // The selectionCheckBoxWidth width + containerFluidSpacing + scrollWidth. const rowHeaderWidthToSub = containerFluidSpacing + selectionCheckBoxWidth + scrollWidth; this.containerWidth = parentContainer.offsetWidth - rowHeaderWidthToSub; } saveSortingToSession() { // this.state.setItemInState(PepperiListComponent.SORT_BY_STATE_KEY, this.sortBy); // this.state.setItemInState(PepperiListComponent.ASCENDING_STATE_KEY, this.isAsc); // this.state.writeToSession(); } onMouseDown(event) { const self = this; // if (!this.element.nativeElement.contains(event.target) || event.target.className === 'scrollable-content') { // setTimeout(() => { // if (self.selectionTypeForActions === SELECTION_TYPE_FOR_ACTIONS.Multi || self.selectionTypeForActions === SELECTION_TYPE_FOR_ACTIONS.SingleAction) { // } // // self.selectedItemId = ''; // //self.hoveredItemId = ''; // }, 500); // } } removeTable() { this.cleanItems(); this.uiControl = null; } getTopItems() { return this.isTable ? PepperiListComponent.TOP_ITEMS_TABLE : PepperiListComponent.TOP_ITEMS_THUMBNAILS; } toggleItems(isVisible) { this.showItems = isVisible; this.lockEvents = !isVisible; if (this.useVirtualScroll) { if (isVisible) { disableScroll.off(); } else { disableScroll.on(); } } } updateScrollItems(startIndex, endIndex, loadInChunks = true) { this.scrollItems = this.items.slice(startIndex, endIndex); // if (!loadInChunks) { // this.scrollItems = this.items.slice(startIndex, endIndex).map((item) => item).filter((item) => item != null); // } else { // // this.scrollItems = this.items.slice(startIndex, endIndex); // const ITEMS_RENDERED_AT_ONCE = 15;//this.isTable ? 1 : 7; // const INTERVAL_IN_MS = 10; // let currentIndex = 0; // const tmp = this.items.slice(startIndex, endIndex); // // this.scrollItems = []; // const interval = setInterval(() => { // const nextIndex = currentIndex + ITEMS_RENDERED_AT_ONCE; // for (let i = currentIndex; i < nextIndex; i++) { // // if (currentIndex === 0) { // // this.scrollItems = []; // // } // if (i >= tmp.length) { // clearInterval(interval); // break; // } // if (this.scrollItems[i]) { // this.scrollItems[i] = tmp[i]; // } else { // this.scrollItems.push(tmp[i]); // } // } // currentIndex += ITEMS_RENDERED_AT_ONCE; // }, INTERVAL_IN_MS); // } } setSelectionItems(itemId, uniqItemId, isChecked) { // Set selected item checkbox if (this.isAllSelected) { if (isChecked) { this.unSelectedItems.delete(itemId); this.selectedItems.set(itemId, uniqItemId); } else { this.selectedItems.delete(itemId); this.unSelectedItems.set(itemId, uniqItemId); } } else { if (isChecked) { this.unSelectedItems.delete(itemId); this.selectedItems.set(itemId, uniqItemId); } else { this.selectedItems.delete(itemId); this.unSelectedItems.set(itemId, uniqItemId); } } } getUniqItemId(itemId, itemType = '') { return itemId + this.SEPARATOR + itemType; } isItemSelected(itemId, itemType = '') { let isSelected = false; if (this.selectionTypeForActions === SELECTION_TYPE_FOR_ACTIONS.SingleAction || this.selectionTypeForActions === SELECTION_TYPE_FOR_ACTIONS.Multi) { isSelected = this.selectedItems.has(itemId) || this.isAllSelected && !this.unSelectedItems.has(itemId); } else if (this.selectionTypeForActions === SELECTION_TYPE_FOR_ACTIONS.Single) { const uniqItemId = this.getUniqItemId(itemId, itemType); isSelected = uniqItemId === this.selectedItemId; } return isSelected; } setLayout() { const self = this; if (this.totalRows === 0 || !this.uiControl || !this.uiControl.ControlFields || this.uiControl.ControlFields.length === 0) { return; } this.uiControl.ControlFields.forEach((cf) => { if (cf.ColumnWidth === 0) { cf.ColumnWidth = 10; } if (self.isTable && (cf.FieldType === FIELD_TYPE.Image || // cf.FieldType === FIELD_TYPE.Indicators || ??? cf.FieldType === FIELD_TYPE.Signature || cf.FieldType === FIELD_TYPE.NumberIntegerQuantitySelector || cf.FieldType === FIELD_TYPE.NumberRealQuantitySelector || cf.FieldType === FIELD_TYPE.NumberIntegerForMatrix || cf.FieldType === FIELD_TYPE.NumberRealForMatrix || cf.FieldType === FIELD_TYPE.Package || cf.ApiName === 'UnitsQuantity' || cf.ApiName === 'QuantitySelector')) { cf.Layout.XAlignment = 3; } }); if (!this.cd['destroyed']) { this.cd.detectChanges(); } // Set the columns width. if (this.containerWidth <= 0) { this.setContainerWidth(); } this.calcColumnsWidth(); this.checkForChanges = new Date().getTime(); } calcColumnsWidth() { const fixedMultiple = 3.78; // for converting em to pixel. const length = this.uiControl.ControlFields.length; const selectionCheckBoxWidth = this.selectionTypeForActions === SELECTION_TYPE_FOR_ACTIONS.Multi ? 44 : 0; // Is table AND there is at least one column of width type of percentage. if (this.isTable) { if (this.uiControl && this.uiControl.ControlFields) { this.hasColumnWidthOfTypePercentage = this.uiControl.ControlFields.filter(cf => cf.ColumnWidthType === 1).length === 0; } } // If the columns size is fixed and the total is small then the container change it to percentage. if (!this.hasColumnWidthOfTypePercentage) { const totalFixedColsWidth = this.uiControl.ControlFields .map(cf => cf.ColumnWidth * fixedMultiple) .reduce((sum, current) => sum + current); if (window.innerWidth > totalFixedColsWidth) { this.hasColumnWidthOfTypePercentage = true; } } let totalCalcColsWidth = 0; // Calc by percentage if (this.hasColumnWidthOfTypePercentage) { const totalColsWidth = this.uiControl.ControlFields.map(cf => cf.ColumnWidth).reduce((sum, current) => sum + current); for (let index = 0; index < length; index++) { const uiControlField = this.uiControl.ControlFields[index]; const calcColumnWidthPercentage = (100 / totalColsWidth) * uiControlField.ColumnWidth; uiControlField.calcColumnWidth = Math.floor((this.containerWidth * calcColumnWidthPercentage) / 100); if (index === length - 1) { uiControlField.calcTitleColumnWidthString = uiControlField.calcColumnWidthString = 'calc(100% - ' + totalCalcColsWidth + 'px)'; // For 100% } else { uiControlField.calcTitleColumnWidthString = uiControlField.calcColumnWidthString = uiControlField.calcColumnWidth + 'px'; totalCalcColsWidth += uiControlField.calcColumnWidth; } } this.renderer.setStyle(this.element.nativeElement, 'width', 'inherit'); } else { for (let index = 0; index < length; index++) { const uiControlField = this.uiControl.ControlFields[index]; const currentFixedWidth = Math.floor(uiControlField.ColumnWidth * fixedMultiple); if (index === length - 1) { uiControlField.calcTitleColumnWidthString = currentFixedWidth + 'px'; uiControlField.calcColumnWidthString = currentFixedWidth - 4 + 'px'; // -4 for the row padding. } else { uiControlField.calcTitleColumnWidthString = uiControlField.calcColumnWidthString = currentFixedWidth + 'px'; } totalCalcColsWidth += currentFixedWidth; } this.renderer.setStyle(this.element.nativeElement, 'width', totalCalcColsWidth + selectionCheckBoxWidth + 'px'); } } initResizeData() { this.startX = 0; this.startWidth = 0; this.tableStartWidth = 0; this.pressedColumn = ''; } onListResizeStart(event, apiName) { this.pressedColumn = apiName; this.startX = event.x; this.startWidth = event.target.closest('.header-column').offsetWidth; if (this.useVirtualScroll) { this.tableStartWidth = this.virtualScroll.contentElementRef.nativeElement.offsetWidth; } else { // Set the tableStartWidth to the container offsetWidth this.tableStartWidth = this.noVirtualScrollCont.nativeElement.offsetWidth; } } onListResize(event) { if (this.pressedColumn.length > 0) { const widthToAdd = this.layoutService.isRtl() ? this.startX - event.x : event.x - this.startX; // Set the width of the column and the container of the whole columns. if (this.startWidth + widthToAdd >= PepperiListComponent.MINIMUM_COLUMN_WIDTH || widthToAdd > 0) { const length = this.uiControl.ControlFields.length; let totalCalcColsWidth = 0; for (let index = 0; index < length; index++) { const uiControlField = this.uiControl.ControlFields[index]; if (index === length - 1) { // Calc the last column only in percentage type. if (this.hasColumnWidthOfTypePercentage) { uiControlField.calcTitleColumnWidthString = uiControlField.calcColumnWidthString = 'calc(100% - ' + totalCalcColsWidth + 'px)'; // For 100% } else { if (uiControlField.ApiName === this.pressedColumn) { uiControlField.calcColumnWidth = this.startWidth + widthToAdd; uiControlField.calcTitleColumnWidthString = uiControlField.calcColumnWidth + 'px'; uiControlField.calcColumnWidthString = uiControlField.calcColumnWidth - 4 + 'px'; } }