@colijnit/corecomponents_v12 258.1.9 → 258.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/colijnit-corecomponents_v12.umd.js +49 -2
- package/bundles/colijnit-corecomponents_v12.umd.js.map +1 -1
- package/colijnit-corecomponents_v12.metadata.json +1 -1
- package/esm2015/lib/components/simple-grid/simple-grid.component.js +212 -165
- package/fesm2015/colijnit-corecomponents_v12.js +211 -164
- package/fesm2015/colijnit-corecomponents_v12.js.map +1 -1
- package/lib/components/simple-grid/simple-grid.component.d.ts +1 -0
- package/package.json +1 -1
|
@@ -9894,13 +9894,60 @@ class SimpleGridComponent extends BaseSimpleGridComponent {
|
|
|
9894
9894
|
}
|
|
9895
9895
|
exportToExcel() {
|
|
9896
9896
|
this.isSettingsMenuOpen = false;
|
|
9897
|
+
const exportData = this._filterSelectedOrReturnAll(this.data);
|
|
9897
9898
|
const columns = this.headerColumnsCopy.map(column => {
|
|
9898
9899
|
return ({
|
|
9899
9900
|
key: column.field,
|
|
9900
9901
|
header: column.headerText
|
|
9901
9902
|
});
|
|
9902
9903
|
});
|
|
9903
|
-
|
|
9904
|
+
const headers = columns.map(col => col.header);
|
|
9905
|
+
const rows = exportData.map(row => columns.map(col => {
|
|
9906
|
+
const value = row[col.key];
|
|
9907
|
+
if (value instanceof Date) {
|
|
9908
|
+
const formattedDate = value.toISOString().split('T')[0];
|
|
9909
|
+
const [year, month, day] = formattedDate.split('-');
|
|
9910
|
+
return `${day}-${month}-${year}`;
|
|
9911
|
+
}
|
|
9912
|
+
else if (typeof value === 'number') {
|
|
9913
|
+
const hasDecimal = (num) => !Number.isInteger(num);
|
|
9914
|
+
return hasDecimal ? value.toFixed(2) : value.toFixed(0);
|
|
9915
|
+
}
|
|
9916
|
+
else if (Array.isArray(value)) {
|
|
9917
|
+
return value.join(', ');
|
|
9918
|
+
}
|
|
9919
|
+
else if (typeof value === 'object' && value !== null) {
|
|
9920
|
+
return JSON.stringify(value);
|
|
9921
|
+
}
|
|
9922
|
+
else {
|
|
9923
|
+
if (!value)
|
|
9924
|
+
return '';
|
|
9925
|
+
if (value.includes('T00:00:00')) {
|
|
9926
|
+
const [year, month, day] = value.replace('T00:00:00', '').split('-');
|
|
9927
|
+
return `${day}-${month}-${year}`;
|
|
9928
|
+
}
|
|
9929
|
+
return String(value);
|
|
9930
|
+
}
|
|
9931
|
+
}));
|
|
9932
|
+
const csvContent = [headers, ...rows].map(row => row.map(cell => `"${cell.replace(/"/g, '""')}"`).join(',')).join('\r\n');
|
|
9933
|
+
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
|
|
9934
|
+
const link = document.createElement('a');
|
|
9935
|
+
const url = URL.createObjectURL(blob);
|
|
9936
|
+
link.href = url;
|
|
9937
|
+
link.setAttribute('download', 'ExcelSheet');
|
|
9938
|
+
document.body.appendChild(link);
|
|
9939
|
+
link.click();
|
|
9940
|
+
document.body.removeChild(link);
|
|
9941
|
+
// this.excelExportService.exportToExcel(
|
|
9942
|
+
// this.data,
|
|
9943
|
+
// columns,
|
|
9944
|
+
// 'ExcelSheet',
|
|
9945
|
+
// 'Sheet1'
|
|
9946
|
+
// );
|
|
9947
|
+
}
|
|
9948
|
+
_filterSelectedOrReturnAll(items) {
|
|
9949
|
+
const hasSelectedTrue = items.some(item => item.selected === true);
|
|
9950
|
+
return hasSelectedTrue ? items.filter(item => item.selected === true) : items;
|
|
9904
9951
|
}
|
|
9905
9952
|
prepareDataRow(row, index) {
|
|
9906
9953
|
this.isRowDisabled(row, index);
|
|
@@ -10050,175 +10097,175 @@ SimpleGridComponent.decorators = [
|
|
|
10050
10097
|
{ type: Component, args: [{
|
|
10051
10098
|
selector: 'co-simple-grid',
|
|
10052
10099
|
template: `
|
|
10053
|
-
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
|
|
10058
|
-
|
|
10059
|
-
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
|
|
10064
|
-
|
|
10100
|
+
<co-grid-toolbar
|
|
10101
|
+
*ngIf="showToolbar" [class.right]="rightToolbar"
|
|
10102
|
+
[showEdit]="showEdit"
|
|
10103
|
+
[showAdd]="showAdd"
|
|
10104
|
+
[showDelete]="showDelete"
|
|
10105
|
+
[deleteEnabled]="selectedRowIndex > -1"
|
|
10106
|
+
(addClick)="addNewRow()"
|
|
10107
|
+
(editClick)="editRow($event)"
|
|
10108
|
+
(saveClick)="validateAndSave()"
|
|
10109
|
+
(cancelClick)="cancelEditRow()"
|
|
10110
|
+
(deleteClick)="removeRow()">
|
|
10111
|
+
</co-grid-toolbar>
|
|
10065
10112
|
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
|
|
10084
|
-
|
|
10085
|
-
|
|
10086
|
-
|
|
10087
|
-
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
-
|
|
10113
|
+
<table
|
|
10114
|
+
id="simple-grid-table"
|
|
10115
|
+
class="simple-grid-table"
|
|
10116
|
+
[clickOutside]="editing"
|
|
10117
|
+
(clickOutside)="handleClickOutsideRow()">
|
|
10118
|
+
<colgroup>
|
|
10119
|
+
<col
|
|
10120
|
+
*ngFor="let column of headerColumnsCopy; let index = index"
|
|
10121
|
+
[class.simple-grid-column-auto-fit]="column.autoFit"
|
|
10122
|
+
[style.width.px]="column.width"
|
|
10123
|
+
[style.min-width.px]="MIN_COLUMN_WIDTH">
|
|
10124
|
+
</colgroup>
|
|
10125
|
+
<thead>
|
|
10126
|
+
<tr>
|
|
10127
|
+
<th
|
|
10128
|
+
scope="col"
|
|
10129
|
+
#headerCell
|
|
10130
|
+
class="simple-grid-column-header"
|
|
10131
|
+
*ngFor="let column of headerColumnsCopy; let index = index">
|
|
10132
|
+
<div
|
|
10133
|
+
class="simple-grid-column-header-wrapper"
|
|
10134
|
+
[class.resizable]="resizable"
|
|
10135
|
+
[class.selected]="column.isSelected"
|
|
10136
|
+
[ngClass]="column.textAlign ? column.textAlign : defaultTextAlign">
|
|
10137
|
+
<ng-container *ngIf="column.headerTemplate; else noHeaderTemplate">
|
|
10138
|
+
<ng-container [ngTemplateOutlet]="column.headerTemplate"></ng-container>
|
|
10139
|
+
</ng-container>
|
|
10140
|
+
<ng-template #noHeaderTemplate>
|
|
10141
|
+
<div
|
|
10142
|
+
class="simple-grid-column-header-label"
|
|
10143
|
+
[ngClass]="column.textAlign ? column.textAlign : defaultTextAlign"
|
|
10144
|
+
[class.with-menu]="showGridSettings"
|
|
10145
|
+
[class.with-sort]="showColumnSort"
|
|
10146
|
+
[textContent]="column.headerText || ' '"
|
|
10147
|
+
(click)="showColumnSort ? sortColumn(column, column.field) : toggleColumnMenu(column)">
|
|
10148
|
+
</div>
|
|
10102
10149
|
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
|
|
10150
|
+
<div class="sort-column" *ngIf="showColumnSort">
|
|
10151
|
+
<co-button
|
|
10152
|
+
(click)="sortColumn(column, column?.field)"
|
|
10153
|
+
[iconData]="icons.getIcon(Icons.ArrowUpArrowDown)">
|
|
10154
|
+
</co-button>
|
|
10155
|
+
</div>
|
|
10109
10156
|
|
|
10110
|
-
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
|
|
10114
|
-
|
|
10115
|
-
|
|
10116
|
-
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
|
|
10157
|
+
<div class="column-menu" *ngIf="column.isSelected">
|
|
10158
|
+
<h3 [textContent]="'COLUMN_OPTIONS' | coreLocalize"></h3>
|
|
10159
|
+
<ul>
|
|
10160
|
+
<li (click)="hideColumn(column)">Hide Column</li>
|
|
10161
|
+
<li (click)="sortColumn(column, column.field)">Sort Column</li>
|
|
10162
|
+
</ul>
|
|
10163
|
+
</div>
|
|
10164
|
+
</ng-template>
|
|
10165
|
+
<div
|
|
10166
|
+
*ngIf="resizable && column.resizable"
|
|
10167
|
+
class="simple-grid-column-sizer"
|
|
10168
|
+
(mousedown)="handleSizerMouseDown($event, column)">
|
|
10169
|
+
</div>
|
|
10170
|
+
</div>
|
|
10171
|
+
</th>
|
|
10172
|
+
</tr>
|
|
10126
10173
|
|
|
10127
|
-
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
|
|
10131
|
-
|
|
10132
|
-
|
|
10174
|
+
<div *ngIf="showGridSettings" class="grid-settings">
|
|
10175
|
+
<co-button
|
|
10176
|
+
[class.selected]="isSettingsMenuOpen"
|
|
10177
|
+
[iconData]="icons.getIcon(Icons.CogWheels)"
|
|
10178
|
+
(click)="toggleSettingsMenu()">
|
|
10179
|
+
</co-button>
|
|
10133
10180
|
|
|
10134
|
-
|
|
10135
|
-
|
|
10136
|
-
|
|
10137
|
-
|
|
10138
|
-
|
|
10139
|
-
|
|
10140
|
-
|
|
10141
|
-
|
|
10142
|
-
</div>
|
|
10143
|
-
</div>
|
|
10144
|
-
</thead>
|
|
10145
|
-
<tbody
|
|
10146
|
-
#dropList cdkDropList cdkDropListOrientation="vertical"
|
|
10147
|
-
class="simple-grid-drag-drop-list"
|
|
10148
|
-
[cdkDropListDisabled]="!dragDropEnabled || editing"
|
|
10149
|
-
[cdkDropListData]="data"
|
|
10150
|
-
[cdkDropListEnterPredicate]="handleCanDragDrop"
|
|
10151
|
-
(cdkDropListDropped)="handleDrop($event)">
|
|
10152
|
-
<co-form class="simple-grid-row-form">
|
|
10153
|
-
<tr
|
|
10154
|
-
class="simple-grid-row"
|
|
10155
|
-
[class.selected]="rowIndex === selectedRowIndex && !editing" observeVisibility
|
|
10156
|
-
[class.disabled]="getIsRowDisabled(rowIndex)"
|
|
10157
|
-
[class.editing]="rowIndex === editRowIndex"
|
|
10158
|
-
*ngFor="let row of (!!rowsPerPage ? (data | paginate: {itemsPerPage: rowsPerPage, currentPage: currentPage}) : data); last as last; let rowIndex = index"
|
|
10159
|
-
cdkDrag
|
|
10160
|
-
(click)="handleClickRow($event, rowIndex, row)" (dblclick)="handleDblClickRow($event, rowIndex, row)"
|
|
10161
|
-
(visibilityChange)="rowVisible.next(row)"
|
|
10162
|
-
(mouseenter)="hoveredRowIndex = rowIndex"
|
|
10163
|
-
(mouseleave)="hoveredRowIndex = -1"
|
|
10164
|
-
>
|
|
10165
|
-
<ng-container *ngIf="isSingleColumnRow(row)">
|
|
10166
|
-
<td class="simple-grid-single-column-cell" [attr.colspan]="headerColumnsCopy.length">
|
|
10167
|
-
<co-simple-grid-cell
|
|
10168
|
-
[column]="columns[singleColumnIndex(row)]"
|
|
10169
|
-
[row]="row"
|
|
10170
|
-
[editMode]="false">
|
|
10171
|
-
</co-simple-grid-cell>
|
|
10172
|
-
</td>
|
|
10173
|
-
</ng-container>
|
|
10174
|
-
<ng-container *ngIf="!isSingleColumnRow(row)">
|
|
10175
|
-
<ng-container *ngFor="let column of headerColumnsCopy; let columnIndex = index">
|
|
10176
|
-
<td class="simple-grid-column-cell" *ngIf="columnIndex !== singleColumnIndex(row)">
|
|
10177
|
-
<co-simple-grid-cell
|
|
10178
|
-
[column]="column"
|
|
10179
|
-
[row]="row"
|
|
10180
|
-
[editMode]="inlineEdit && editing && rowIndex === editRowIndex"
|
|
10181
|
-
[fieldEditMode]="editCellIndex === columnIndex && rowIndex === editRowIndex"
|
|
10182
|
-
(cellClick)="handleCellClick($event, row, rowIndex, columnIndex)">
|
|
10183
|
-
</co-simple-grid-cell>
|
|
10184
|
-
<div *ngIf="column.resizable" class="simple-grid-column-sizer-placeholder"></div>
|
|
10185
|
-
</td>
|
|
10186
|
-
</ng-container>
|
|
10187
|
-
<ng-container *ngIf="inlineEdit">
|
|
10188
|
-
<div class="icons-container" *ngIf="!editing">
|
|
10189
|
-
<co-icon class="icon-item icon-edit"
|
|
10190
|
-
[iconData]="icons.getIcon(Icons.PenToSquareSolid)" *ngIf="hoveredRowIndex === rowIndex"
|
|
10191
|
-
(click)="editRow($event, true, rowIndex); $event.stopPropagation()"></co-icon>
|
|
10192
|
-
<co-icon class="icon-item icon-delete"
|
|
10193
|
-
[iconData]="icons.getIcon(Icons.TrashBin)" *ngIf="hoveredRowIndex === rowIndex"
|
|
10194
|
-
(click)="removeRow()"></co-icon>
|
|
10195
|
-
</div>
|
|
10196
|
-
<div class="icons-container">
|
|
10197
|
-
<co-button class="save-button"
|
|
10198
|
-
*ngIf="editing && (selectedRowIndex === rowIndex || (isNewRow && rowIndex === editRowIndex))"
|
|
10199
|
-
[iconData]="icons.getIcon(Icons.CheckDuotone)"
|
|
10200
|
-
(click)="validateAndSave(); $event.stopPropagation()"></co-button>
|
|
10201
|
-
<co-button class="close-button"
|
|
10202
|
-
*ngIf="editing && (selectedRowIndex === rowIndex || (isNewRow && rowIndex === editRowIndex))"
|
|
10203
|
-
[iconData]="icons.getIcon(Icons.CrossSkinny)"
|
|
10204
|
-
(click)="cancelEditRow(); $event.stopPropagation() "></co-button>
|
|
10181
|
+
<div class="settings-menu" *ngIf="isSettingsMenuOpen">
|
|
10182
|
+
<h3 [textContent]="'GRID_OPTIONS' | coreLocalize"></h3>
|
|
10183
|
+
<ul>
|
|
10184
|
+
<li (click)="exportToExcel()">Export to Excel</li>
|
|
10185
|
+
<li *ngIf="headerColumnsCopy.length !== headerColumns.length" (click)="showAllColumns()">
|
|
10186
|
+
Show All Columns
|
|
10187
|
+
</li>
|
|
10188
|
+
</ul>
|
|
10205
10189
|
</div>
|
|
10206
|
-
|
|
10207
|
-
</
|
|
10208
|
-
|
|
10209
|
-
|
|
10210
|
-
|
|
10211
|
-
|
|
10212
|
-
|
|
10213
|
-
|
|
10214
|
-
|
|
10215
|
-
|
|
10216
|
-
|
|
10217
|
-
|
|
10218
|
-
|
|
10219
|
-
|
|
10220
|
-
|
|
10221
|
-
|
|
10190
|
+
</div>
|
|
10191
|
+
</thead>
|
|
10192
|
+
<tbody
|
|
10193
|
+
#dropList cdkDropList cdkDropListOrientation="vertical"
|
|
10194
|
+
class="simple-grid-drag-drop-list"
|
|
10195
|
+
[cdkDropListDisabled]="!dragDropEnabled || editing"
|
|
10196
|
+
[cdkDropListData]="data"
|
|
10197
|
+
[cdkDropListEnterPredicate]="handleCanDragDrop"
|
|
10198
|
+
(cdkDropListDropped)="handleDrop($event)">
|
|
10199
|
+
<co-form class="simple-grid-row-form">
|
|
10200
|
+
<tr
|
|
10201
|
+
class="simple-grid-row"
|
|
10202
|
+
[class.selected]="rowIndex === selectedRowIndex && !editing" observeVisibility
|
|
10203
|
+
[class.disabled]="getIsRowDisabled(rowIndex)"
|
|
10204
|
+
[class.editing]="rowIndex === editRowIndex"
|
|
10205
|
+
*ngFor="let row of (!!rowsPerPage ? (data | paginate: {itemsPerPage: rowsPerPage, currentPage: currentPage}) : data); last as last; let rowIndex = index"
|
|
10206
|
+
cdkDrag
|
|
10207
|
+
(click)="handleClickRow($event, rowIndex, row)" (dblclick)="handleDblClickRow($event, rowIndex, row)"
|
|
10208
|
+
(visibilityChange)="rowVisible.next(row)"
|
|
10209
|
+
(mouseenter)="hoveredRowIndex = rowIndex"
|
|
10210
|
+
(mouseleave)="hoveredRowIndex = -1"
|
|
10211
|
+
>
|
|
10212
|
+
<ng-container *ngIf="isSingleColumnRow(row)">
|
|
10213
|
+
<td class="simple-grid-single-column-cell" [attr.colspan]="headerColumnsCopy.length">
|
|
10214
|
+
<co-simple-grid-cell
|
|
10215
|
+
[column]="columns[singleColumnIndex(row)]"
|
|
10216
|
+
[row]="row"
|
|
10217
|
+
[editMode]="false">
|
|
10218
|
+
</co-simple-grid-cell>
|
|
10219
|
+
</td>
|
|
10220
|
+
</ng-container>
|
|
10221
|
+
<ng-container *ngIf="!isSingleColumnRow(row)">
|
|
10222
|
+
<ng-container *ngFor="let column of headerColumnsCopy; let columnIndex = index">
|
|
10223
|
+
<td class="simple-grid-column-cell" *ngIf="columnIndex !== singleColumnIndex(row)">
|
|
10224
|
+
<co-simple-grid-cell
|
|
10225
|
+
[column]="column"
|
|
10226
|
+
[row]="row"
|
|
10227
|
+
[editMode]="inlineEdit && editing && rowIndex === editRowIndex"
|
|
10228
|
+
[fieldEditMode]="editCellIndex === columnIndex && rowIndex === editRowIndex"
|
|
10229
|
+
(cellClick)="handleCellClick($event, row, rowIndex, columnIndex)">
|
|
10230
|
+
</co-simple-grid-cell>
|
|
10231
|
+
<div *ngIf="column.resizable" class="simple-grid-column-sizer-placeholder"></div>
|
|
10232
|
+
</td>
|
|
10233
|
+
</ng-container>
|
|
10234
|
+
<ng-container *ngIf="inlineEdit">
|
|
10235
|
+
<div class="icons-container" *ngIf="!editing">
|
|
10236
|
+
<co-icon class="icon-item icon-edit"
|
|
10237
|
+
[iconData]="icons.getIcon(Icons.PenToSquareSolid)" *ngIf="hoveredRowIndex === rowIndex"
|
|
10238
|
+
(click)="editRow($event, true, rowIndex); $event.stopPropagation()"></co-icon>
|
|
10239
|
+
<co-icon class="icon-item icon-delete"
|
|
10240
|
+
[iconData]="icons.getIcon(Icons.TrashBin)" *ngIf="hoveredRowIndex === rowIndex"
|
|
10241
|
+
(click)="removeRow()"></co-icon>
|
|
10242
|
+
</div>
|
|
10243
|
+
<div class="icons-container">
|
|
10244
|
+
<co-button class="save-button"
|
|
10245
|
+
*ngIf="editing && (selectedRowIndex === rowIndex || (isNewRow && rowIndex === editRowIndex))"
|
|
10246
|
+
[iconData]="icons.getIcon(Icons.CheckDuotone)"
|
|
10247
|
+
(click)="validateAndSave(); $event.stopPropagation()"></co-button>
|
|
10248
|
+
<co-button class="close-button"
|
|
10249
|
+
*ngIf="editing && (selectedRowIndex === rowIndex || (isNewRow && rowIndex === editRowIndex))"
|
|
10250
|
+
[iconData]="icons.getIcon(Icons.CrossSkinny)"
|
|
10251
|
+
(click)="cancelEditRow(); $event.stopPropagation() "></co-button>
|
|
10252
|
+
</div>
|
|
10253
|
+
</ng-container>
|
|
10254
|
+
</ng-container>
|
|
10255
|
+
</tr>
|
|
10256
|
+
</co-form>
|
|
10257
|
+
</tbody>
|
|
10258
|
+
</table>
|
|
10259
|
+
<co-pagination-bar
|
|
10260
|
+
*ngIf="data?.length > rowsPerPage" class="pagination-bar"
|
|
10261
|
+
[itemsPerPage]="rowsPerPage"
|
|
10262
|
+
[currentPage]="currentPage"
|
|
10263
|
+
[totalItems]="data.length"
|
|
10264
|
+
[autoHide]="true"
|
|
10265
|
+
(previousClick)="goToPreviousPage()"
|
|
10266
|
+
(nextClick)="goToNextPage()"
|
|
10267
|
+
(pageClick)="setCurrentPage($event)">
|
|
10268
|
+
</co-pagination-bar>
|
|
10222
10269
|
`,
|
|
10223
10270
|
providers: [FormMasterService],
|
|
10224
10271
|
changeDetection: ChangeDetectionStrategy.OnPush,
|