@one-grid-core/angular 0.1.0-beta.5
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/README.md +168 -0
- package/esm2022/lib/components/one-grid/one-grid.component.mjs +388 -0
- package/esm2022/lib/components/one-grid-body/one-grid-body.component.mjs +570 -0
- package/esm2022/lib/components/one-grid-cell-currency/one-grid-cell-currency.component.mjs +90 -0
- package/esm2022/lib/components/one-grid-cell-group-renderer/one-grid-cell-group-renderer.component.mjs +31 -0
- package/esm2022/lib/components/one-grid-cell-option-menu/one-grid-cell-option-menu.component.mjs +67 -0
- package/esm2022/lib/components/one-grid-checkbox/one-grid-checkbox.component.mjs +47 -0
- package/esm2022/lib/components/one-grid-checkbox-header/one-grid-checkbox-header.component.mjs +62 -0
- package/esm2022/lib/components/one-grid-header/one-grid-header.component.mjs +140 -0
- package/esm2022/lib/components/one-grid-pagination/one-grid-pagination.component.mjs +76 -0
- package/esm2022/lib/components/one-grid-row-action/one-grid-row-action.component.mjs +193 -0
- package/esm2022/lib/components/one-grid-status/one-grid-status.component.mjs +35 -0
- package/esm2022/lib/core/directives/one-cell-input-validator.directive.mjs +71 -0
- package/esm2022/lib/core/directives/one-cell-renderer-component.directive.mjs +77 -0
- package/esm2022/lib/core/directives/one-cell-text-expand.directive.mjs +82 -0
- package/esm2022/lib/core/instants/one-grid-api.class.mjs +591 -0
- package/esm2022/lib/core/instants/one-row-node.class.mjs +90 -0
- package/esm2022/lib/core/models/constants/one-pagination.constant.mjs +2 -0
- package/esm2022/lib/core/models/one-column-def-types.model.mjs +2 -0
- package/esm2022/lib/core/models/one-event-types.model.mjs +2 -0
- package/esm2022/lib/core/models/one-filter.model.mjs +2 -0
- package/esm2022/lib/core/models/one-grid-types.model.mjs +2 -0
- package/esm2022/lib/core/models/one-master-detail.model.mjs +2 -0
- package/esm2022/lib/core/models/one-pagination-types.model.mjs +2 -0
- package/esm2022/lib/core/models/one-row.model.mjs +13 -0
- package/esm2022/lib/core/models/one-tree-data.model.mjs +2 -0
- package/esm2022/lib/core/models/one-validation.model.mjs +2 -0
- package/esm2022/lib/core/pipes/cell-action-button-enable.pipe.mjs +21 -0
- package/esm2022/lib/core/pipes/cell-action-button-visible.pipe.mjs +17 -0
- package/esm2022/lib/core/pipes/cell-disable-resolver.pipe.mjs +26 -0
- package/esm2022/lib/core/pipes/cell-editable.pipe.mjs +30 -0
- package/esm2022/lib/core/pipes/cell-field-value-empty.pipe.mjs +21 -0
- package/esm2022/lib/core/pipes/cell-field-value.pipe.mjs +25 -0
- package/esm2022/lib/core/pipes/cell-field.pipe.mjs +20 -0
- package/esm2022/lib/core/pipes/cell-invalid.pipe.mjs +21 -0
- package/esm2022/lib/core/pipes/cell-key.pipe.mjs +21 -0
- package/esm2022/lib/core/pipes/cell-level-padding.pipe.mjs +18 -0
- package/esm2022/lib/core/pipes/cell-number-value.pipe.mjs +19 -0
- package/esm2022/lib/core/pipes/cell-selected.pipe.mjs +20 -0
- package/esm2022/lib/core/pipes/cell-state-group-renderer.pipe.mjs +21 -0
- package/esm2022/lib/core/pipes/cell-state-renderer.pipe.mjs +24 -0
- package/esm2022/lib/core/pipes/cell-value-getter.pipe.mjs +23 -0
- package/esm2022/lib/core/pipes/column-sort-state.pipe.mjs +19 -0
- package/esm2022/lib/core/pipes/header-checkbox-checked.pipe.mjs +17 -0
- package/esm2022/lib/core/pipes/header-checkbox-disabled.pipe.mjs +17 -0
- package/esm2022/lib/core/pipes/header-checkbox-indeterminate.pipe.mjs +17 -0
- package/esm2022/lib/core/services/og-column.service.mjs +81 -0
- package/esm2022/lib/core/services/one-grid-cell.service.mjs +88 -0
- package/esm2022/lib/core/services/one-grid-event.service.mjs +42 -0
- package/esm2022/lib/core/services/one-grid-expansion.service.mjs +40 -0
- package/esm2022/lib/core/services/one-grid-row.service.mjs +29 -0
- package/esm2022/lib/core/services/one-grid-selection.service.mjs +54 -0
- package/esm2022/lib/core/services/one-grid-tree-data.service.mjs +59 -0
- package/esm2022/lib/helpers/one-cell.helper.mjs +42 -0
- package/esm2022/lib/helpers/one-column-def.helper.mjs +28 -0
- package/esm2022/lib/helpers/one-filter.helper.mjs +52 -0
- package/esm2022/lib/helpers/one-validation.helper.mjs +95 -0
- package/esm2022/lib/index.mjs +19 -0
- package/esm2022/lib/one-grid.module.mjs +142 -0
- package/esm2022/one-grid-core-angular.mjs +5 -0
- package/esm2022/public-api.mjs +5 -0
- package/fesm2022/one-grid-core-angular.mjs +3573 -0
- package/fesm2022/one-grid-core-angular.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/components/one-grid/one-grid.component.d.ts +139 -0
- package/lib/components/one-grid-body/one-grid-body.component.d.ts +176 -0
- package/lib/components/one-grid-cell-currency/one-grid-cell-currency.component.d.ts +27 -0
- package/lib/components/one-grid-cell-group-renderer/one-grid-cell-group-renderer.component.d.ts +16 -0
- package/lib/components/one-grid-cell-option-menu/one-grid-cell-option-menu.component.d.ts +21 -0
- package/lib/components/one-grid-checkbox/one-grid-checkbox.component.d.ts +19 -0
- package/lib/components/one-grid-checkbox-header/one-grid-checkbox-header.component.d.ts +24 -0
- package/lib/components/one-grid-header/one-grid-header.component.d.ts +41 -0
- package/lib/components/one-grid-pagination/one-grid-pagination.component.d.ts +21 -0
- package/lib/components/one-grid-row-action/one-grid-row-action.component.d.ts +59 -0
- package/lib/components/one-grid-status/one-grid-status.component.d.ts +15 -0
- package/lib/core/directives/one-cell-input-validator.directive.d.ts +15 -0
- package/lib/core/directives/one-cell-renderer-component.directive.d.ts +20 -0
- package/lib/core/directives/one-cell-text-expand.directive.d.ts +21 -0
- package/lib/core/instants/one-grid-api.class.d.ts +161 -0
- package/lib/core/instants/one-row-node.class.d.ts +49 -0
- package/lib/core/models/constants/one-pagination.constant.d.ts +1 -0
- package/lib/core/models/one-column-def-types.model.d.ts +139 -0
- package/lib/core/models/one-event-types.model.d.ts +78 -0
- package/lib/core/models/one-filter.model.d.ts +15 -0
- package/lib/core/models/one-grid-types.model.d.ts +48 -0
- package/lib/core/models/one-master-detail.model.d.ts +18 -0
- package/lib/core/models/one-pagination-types.model.d.ts +9 -0
- package/lib/core/models/one-row.model.d.ts +38 -0
- package/lib/core/models/one-tree-data.model.d.ts +9 -0
- package/lib/core/models/one-validation.model.d.ts +9 -0
- package/lib/core/pipes/cell-action-button-enable.pipe.d.ts +8 -0
- package/lib/core/pipes/cell-action-button-visible.pipe.d.ts +9 -0
- package/lib/core/pipes/cell-disable-resolver.pipe.d.ts +9 -0
- package/lib/core/pipes/cell-editable.pipe.d.ts +9 -0
- package/lib/core/pipes/cell-field-value-empty.pipe.d.ts +7 -0
- package/lib/core/pipes/cell-field-value.pipe.d.ts +7 -0
- package/lib/core/pipes/cell-field.pipe.d.ts +7 -0
- package/lib/core/pipes/cell-invalid.pipe.d.ts +9 -0
- package/lib/core/pipes/cell-key.pipe.d.ts +7 -0
- package/lib/core/pipes/cell-level-padding.pipe.d.ts +7 -0
- package/lib/core/pipes/cell-number-value.pipe.d.ts +7 -0
- package/lib/core/pipes/cell-selected.pipe.d.ts +7 -0
- package/lib/core/pipes/cell-state-group-renderer.pipe.d.ts +9 -0
- package/lib/core/pipes/cell-state-renderer.pipe.d.ts +8 -0
- package/lib/core/pipes/cell-value-getter.pipe.d.ts +9 -0
- package/lib/core/pipes/column-sort-state.pipe.d.ts +8 -0
- package/lib/core/pipes/header-checkbox-checked.pipe.d.ts +9 -0
- package/lib/core/pipes/header-checkbox-disabled.pipe.d.ts +9 -0
- package/lib/core/pipes/header-checkbox-indeterminate.pipe.d.ts +9 -0
- package/lib/core/services/og-column.service.d.ts +22 -0
- package/lib/core/services/one-grid-cell.service.d.ts +29 -0
- package/lib/core/services/one-grid-event.service.d.ts +17 -0
- package/lib/core/services/one-grid-expansion.service.d.ts +13 -0
- package/lib/core/services/one-grid-row.service.d.ts +15 -0
- package/lib/core/services/one-grid-selection.service.d.ts +17 -0
- package/lib/core/services/one-grid-tree-data.service.d.ts +10 -0
- package/lib/helpers/one-cell.helper.d.ts +26 -0
- package/lib/helpers/one-column-def.helper.d.ts +17 -0
- package/lib/helpers/one-filter.helper.d.ts +20 -0
- package/lib/helpers/one-validation.helper.d.ts +21 -0
- package/lib/index.d.ts +18 -0
- package/lib/one-grid.module.d.ts +45 -0
- package/package.json +48 -0
- package/public-api.d.ts +1 -0
- package/scss/_one-grid.scss +999 -0
|
@@ -0,0 +1,3573 @@
|
|
|
1
|
+
import { v4 } from 'uuid';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { Injectable, Pipe, Input, Component, EventEmitter, Output, HostListener, Directive, ViewChild, ChangeDetectionStrategy, NgModule } from '@angular/core';
|
|
4
|
+
import { BehaviorSubject, Subject, Subscription, fromEvent } from 'rxjs';
|
|
5
|
+
import _ from 'lodash';
|
|
6
|
+
import { filter, map } from 'rxjs/operators';
|
|
7
|
+
import * as i2 from '@angular/common';
|
|
8
|
+
import { CommonModule } from '@angular/common';
|
|
9
|
+
import * as i3 from 'lucide-angular';
|
|
10
|
+
import { LucideAngularModule, icons } from 'lucide-angular';
|
|
11
|
+
import * as i5 from '@angular/cdk/scrolling';
|
|
12
|
+
import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling';
|
|
13
|
+
import * as i3$1 from '@angular/forms';
|
|
14
|
+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
15
|
+
import { NgbTypeahead, NgbHighlight } from '@ng-bootstrap/ng-bootstrap';
|
|
16
|
+
import { CdkDragPlaceholder } from '@angular/cdk/drag-drop';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Apply Default Column Definitions
|
|
20
|
+
*/
|
|
21
|
+
function applyDefaultColumnDef(columnDefs, defaultColumnDef) {
|
|
22
|
+
return columnDefs.map(colDef => ({
|
|
23
|
+
...defaultColumnDef,
|
|
24
|
+
...colDef
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* One Column Params Resolver (Cell Renderer)
|
|
29
|
+
*/
|
|
30
|
+
function resolveOneCellRendererParams(prop, params) {
|
|
31
|
+
return typeof prop === 'function' ? prop(params) : !!prop;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* One Column Params Resolver (Generics)
|
|
35
|
+
*/
|
|
36
|
+
function resolveOneColumDefParams(prop, params) {
|
|
37
|
+
return typeof prop === 'function' ? prop(params) : prop;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* One Column Params Resolver (Value Getter)
|
|
41
|
+
*/
|
|
42
|
+
function resolveOneValueGetterParams(prop, params) {
|
|
43
|
+
return typeof prop === 'function' ? prop(params) : prop;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* One Grid Validators
|
|
48
|
+
*/
|
|
49
|
+
const Validators = {
|
|
50
|
+
required: (message = 'This field is required') => {
|
|
51
|
+
return (value) => {
|
|
52
|
+
if (value === null || value === undefined || value === '') {
|
|
53
|
+
return message;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
minLength: (min, message) => {
|
|
59
|
+
return (value) => {
|
|
60
|
+
if (value != null && value.length < min) {
|
|
61
|
+
return message || `Minimum length is ${min} digits`;
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
maxLength: (max, message) => {
|
|
67
|
+
return (value) => {
|
|
68
|
+
if (value != null && value.length > max) {
|
|
69
|
+
return message || `Maximum length is ${max} digits`;
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
pattern: (regex, message = 'Format is not valid') => {
|
|
75
|
+
return (value) => {
|
|
76
|
+
if (value != null && !regex.test(value)) {
|
|
77
|
+
return message;
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
custom: (fn) => fn,
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* One Grid Validation Rules
|
|
86
|
+
*/
|
|
87
|
+
const ValidationRules = {
|
|
88
|
+
required: [
|
|
89
|
+
Validators.required()
|
|
90
|
+
],
|
|
91
|
+
title: [
|
|
92
|
+
Validators.required('Title is required'),
|
|
93
|
+
Validators.minLength(1, 'Title must be at least 1 digit'),
|
|
94
|
+
Validators.maxLength(250, 'Code must be less than 36 digits'),
|
|
95
|
+
],
|
|
96
|
+
code: [
|
|
97
|
+
Validators.required("Code is required"),
|
|
98
|
+
Validators.minLength(1, 'Code must be at least 1 digit'),
|
|
99
|
+
Validators.maxLength(36, 'Code must be less than 36 digits'),
|
|
100
|
+
],
|
|
101
|
+
email: [
|
|
102
|
+
Validators.required(),
|
|
103
|
+
Validators.pattern(/^[^\s@]+@[^\s@]+\.[^\s@]+$/, 'Email format is invalid'),
|
|
104
|
+
],
|
|
105
|
+
phone: [
|
|
106
|
+
Validators.required('Phone number is required'),
|
|
107
|
+
Validators.pattern(/^0(10|11|12|13|14|15|16|17|18|19|20|23|24|25|26|27|28|29)\d{7}$/, 'Phone must be a valid pattern')
|
|
108
|
+
],
|
|
109
|
+
datetime: [
|
|
110
|
+
Validators.required('Datetime is required'),
|
|
111
|
+
]
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Helper fuction to return invalid cell on UI
|
|
115
|
+
*/
|
|
116
|
+
function getCellError(column, node, value, row) {
|
|
117
|
+
if (!column?.validationRules || column?.validationRules?.length === 0)
|
|
118
|
+
return null;
|
|
119
|
+
if (column?.autoGroupField) {
|
|
120
|
+
if (column.editableLevels.includes(node.level)) {
|
|
121
|
+
for (const ruleFn of column?.validationRules) {
|
|
122
|
+
const error = ruleFn(value, row);
|
|
123
|
+
if (error)
|
|
124
|
+
return error;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
if (!node.group) {
|
|
131
|
+
for (const ruleFn of column?.validationRules) {
|
|
132
|
+
const error = ruleFn(value, row);
|
|
133
|
+
if (error)
|
|
134
|
+
return error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
class OneRowNode {
|
|
142
|
+
constructor(rowId, data, rowIndex) {
|
|
143
|
+
this.rowId = null;
|
|
144
|
+
this.rowIndex = null;
|
|
145
|
+
this.data = null;
|
|
146
|
+
this.level = null;
|
|
147
|
+
this.leaf = false;
|
|
148
|
+
this.leafGroup = false;
|
|
149
|
+
this.visible = false;
|
|
150
|
+
this.selected = false;
|
|
151
|
+
this.expandable = false;
|
|
152
|
+
this.expanded = false;
|
|
153
|
+
this.group = false;
|
|
154
|
+
this.submitted = false;
|
|
155
|
+
this.parent = null;
|
|
156
|
+
this.children = null;
|
|
157
|
+
this.editing = {};
|
|
158
|
+
this.cellStates = {};
|
|
159
|
+
this.cellOptions = {};
|
|
160
|
+
this.detailRowData = null;
|
|
161
|
+
this.detailActive = false;
|
|
162
|
+
this.detailRowHeight = null;
|
|
163
|
+
this.listeners = new Map();
|
|
164
|
+
this.rowId = rowId;
|
|
165
|
+
this.data = data;
|
|
166
|
+
this.rowIndex = rowIndex;
|
|
167
|
+
}
|
|
168
|
+
setDataValue(field, value) {
|
|
169
|
+
this.data[field] = value;
|
|
170
|
+
}
|
|
171
|
+
setSelected(selected) {
|
|
172
|
+
this.selected = selected;
|
|
173
|
+
}
|
|
174
|
+
setRowIndex(index) {
|
|
175
|
+
this.rowIndex = index;
|
|
176
|
+
}
|
|
177
|
+
setCellStates(cellStates) {
|
|
178
|
+
this.cellStates = cellStates;
|
|
179
|
+
}
|
|
180
|
+
isSelected() {
|
|
181
|
+
return this.selected;
|
|
182
|
+
}
|
|
183
|
+
isExpanded() {
|
|
184
|
+
return this.expanded;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Event System
|
|
188
|
+
*/
|
|
189
|
+
on(event, listener) {
|
|
190
|
+
if (!this.listeners.has(event)) {
|
|
191
|
+
this.listeners.set(event, new Set());
|
|
192
|
+
}
|
|
193
|
+
this.listeners.get(event).add(listener);
|
|
194
|
+
// Return unsubscribe fn
|
|
195
|
+
return () => this.off(event, listener);
|
|
196
|
+
}
|
|
197
|
+
off(event, listener) {
|
|
198
|
+
this.listeners.get(event)?.delete(listener);
|
|
199
|
+
}
|
|
200
|
+
emit(event, payload) {
|
|
201
|
+
this.listeners.get(event)?.forEach(cb => cb(payload));
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Mutators that fire events
|
|
205
|
+
*/
|
|
206
|
+
setDetailRowData(detailRowData) {
|
|
207
|
+
const previousDetailRowData = this.detailRowData;
|
|
208
|
+
this.detailRowData = detailRowData;
|
|
209
|
+
this.emit('detailRowDataChanged', {
|
|
210
|
+
node: this,
|
|
211
|
+
detailRowData,
|
|
212
|
+
previousDetailRowData,
|
|
213
|
+
});
|
|
214
|
+
this.emit('childrenChanged', {
|
|
215
|
+
node: this,
|
|
216
|
+
children: this.children,
|
|
217
|
+
source: 'masterDetail',
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
setExpanded(expanded) {
|
|
221
|
+
if (this.expanded === expanded)
|
|
222
|
+
return; // skip if no change
|
|
223
|
+
this.expanded = expanded;
|
|
224
|
+
this.emit('expandedChanged', { node: this, expanded });
|
|
225
|
+
}
|
|
226
|
+
destroy() {
|
|
227
|
+
this.listeners.clear(); // prevent memory leaks
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Recursively filters a tree and updates each node's UI state.
|
|
233
|
+
*
|
|
234
|
+
* Rules:
|
|
235
|
+
* - A node is visible if it matches the filters or has a matching descendant.
|
|
236
|
+
* - A node is expanded if it has a matching descendant.
|
|
237
|
+
*
|
|
238
|
+
* @returns True if the current node or any descendant matches.
|
|
239
|
+
*/
|
|
240
|
+
function filterTreeNode(node, filters, quick) {
|
|
241
|
+
// Check whether the current node matches all active filters.
|
|
242
|
+
const selfMatch = matchesAdvancedFilters(node, filters) && matchesQuickFilter(node, quick);
|
|
243
|
+
// Recursively determine whether any child matches.
|
|
244
|
+
const childMatch = node.children?.some(child => filterTreeNode(child, filters, quick)) ?? false;
|
|
245
|
+
// Keep the node visible when it or any descendant matches.
|
|
246
|
+
node.visible = selfMatch || childMatch;
|
|
247
|
+
// Expand parents to reveal matching descendants.
|
|
248
|
+
node.expanded = childMatch;
|
|
249
|
+
return node.visible;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Apply advanced per-column filters
|
|
253
|
+
*/
|
|
254
|
+
function matchesAdvancedFilters(node, filters) {
|
|
255
|
+
if (!filters || filters.length === 0)
|
|
256
|
+
return true;
|
|
257
|
+
return filters.every(filter => {
|
|
258
|
+
const val = (node.data[filter.field] ?? '').toString().toLowerCase();
|
|
259
|
+
const results = filter.conditions.map(condition => {
|
|
260
|
+
const cmp = (condition.value ?? '').toString().toLowerCase();
|
|
261
|
+
switch (condition.operator) {
|
|
262
|
+
case 'equals': return val === cmp;
|
|
263
|
+
case 'contains': return val.includes(cmp);
|
|
264
|
+
case 'startsWith': return val.startsWith(cmp);
|
|
265
|
+
case 'endsWith': return val.endsWith(cmp);
|
|
266
|
+
case 'greaterThan': return +val > +cmp;
|
|
267
|
+
case 'lessThan': return +val < +cmp;
|
|
268
|
+
default: return true; // Unknown operator = ignore
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
return filter.logicOperator === 'AND' ? results.every(Boolean) : results.some(Boolean);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Apply quick filter across all fields
|
|
276
|
+
*/
|
|
277
|
+
function matchesQuickFilter(node, quick) {
|
|
278
|
+
if (!quick)
|
|
279
|
+
return true;
|
|
280
|
+
return Object.values(node.data).some(value => (value ?? '').toString().toLowerCase().includes(quick));
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Generate Cell Field
|
|
285
|
+
*/
|
|
286
|
+
function getCellField(rowIndex, field) {
|
|
287
|
+
return `${rowIndex}--${field}`;
|
|
288
|
+
}
|
|
289
|
+
function getCellKey(rowId, field) {
|
|
290
|
+
return `${rowId}--${field}`;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Get Value From Data Field
|
|
294
|
+
*/
|
|
295
|
+
function getFieldValue(data, field) {
|
|
296
|
+
return field?.split('.')?.reduce((obj, key) => obj?.[key], data);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Resolve cell style (handles both static and function-based)
|
|
300
|
+
* @param column
|
|
301
|
+
* @param row
|
|
302
|
+
* @returns
|
|
303
|
+
*/
|
|
304
|
+
function resolveCellStyle(column, row) {
|
|
305
|
+
if (!column.cellStyle)
|
|
306
|
+
return {};
|
|
307
|
+
return typeof column.cellStyle === 'function'
|
|
308
|
+
? column.cellStyle(row)
|
|
309
|
+
: column.cellStyle;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Resolve cell class (handles both static and function-based)
|
|
313
|
+
* @param column
|
|
314
|
+
* @param row
|
|
315
|
+
* @returns
|
|
316
|
+
*/
|
|
317
|
+
function resolveCellClass(column, row) {
|
|
318
|
+
if (!column.cellClass)
|
|
319
|
+
return '';
|
|
320
|
+
return typeof column.cellClass === 'function'
|
|
321
|
+
? column.cellClass(row)
|
|
322
|
+
: column.cellClass;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
class OgColumnService {
|
|
326
|
+
constructor() {
|
|
327
|
+
this.defaultColumnDef = null;
|
|
328
|
+
this.columnDefs$ = new BehaviorSubject([]);
|
|
329
|
+
this.groupColumnDefs$ = new BehaviorSubject([]);
|
|
330
|
+
}
|
|
331
|
+
initColumnDefs(defaultColumnDef, columnDefs, groupColumnDefs) {
|
|
332
|
+
this.defaultColumnDef = defaultColumnDef;
|
|
333
|
+
this.setGroupColumnDefs(groupColumnDefs);
|
|
334
|
+
this.setColumnDefs(columnDefs);
|
|
335
|
+
}
|
|
336
|
+
getColumnState() {
|
|
337
|
+
const columns = this.columnDefs$.getValue();
|
|
338
|
+
const groups = this.groupColumnDefs$.getValue();
|
|
339
|
+
return { columns, groups };
|
|
340
|
+
}
|
|
341
|
+
setGroupColumnDefs(groupColumnDefs) {
|
|
342
|
+
const groups = groupColumnDefs.map((group) => this.resolveGroupPresentation(group));
|
|
343
|
+
this.groupColumnDefs$.next(groups);
|
|
344
|
+
}
|
|
345
|
+
setColumnDefs(columnDefs) {
|
|
346
|
+
const columns = columnDefs.map((col) => {
|
|
347
|
+
const column = {
|
|
348
|
+
...this.defaultColumnDef,
|
|
349
|
+
...col,
|
|
350
|
+
id: col?.field ? col.field : _.uniqueId('col_'),
|
|
351
|
+
};
|
|
352
|
+
return this.resolveCellPresentation(column);
|
|
353
|
+
});
|
|
354
|
+
this.recalculateGroups(columns);
|
|
355
|
+
this.columnDefs$.next(columns);
|
|
356
|
+
}
|
|
357
|
+
// Update single column
|
|
358
|
+
updateColumnDef(id, changes) {
|
|
359
|
+
const columns = this.getColumnState().columns;
|
|
360
|
+
const updatedColumns = columns.map(col => col.id === id ? { ...col, ...changes } : col);
|
|
361
|
+
this.recalculateGroups(updatedColumns);
|
|
362
|
+
this.columnDefs$.next(updatedColumns);
|
|
363
|
+
}
|
|
364
|
+
// Reorder columns
|
|
365
|
+
reorderColumnDefs(fromIndex, toIndex) {
|
|
366
|
+
const columns = _.clone(this.getColumnState().columns);
|
|
367
|
+
const [moved] = columns.splice(fromIndex, 1);
|
|
368
|
+
columns.splice(toIndex, 0, moved);
|
|
369
|
+
this.columnDefs$.next(columns);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Group Header Columns
|
|
373
|
+
*/
|
|
374
|
+
recalculateGroups(columnDefs) {
|
|
375
|
+
if (this.groupColumnDefs$.getValue().length > 0) {
|
|
376
|
+
const groups = this.groupColumnDefs$.value.map(group => ({
|
|
377
|
+
...group,
|
|
378
|
+
width: columnDefs.filter(c => c.groupId === group.id).reduce((sum, col) => sum + (col.width ? col.width > col.maxWidth ? col.maxWidth : col.width < col.minWidth ? col.minWidth : col.width : col.minWidth), 0)
|
|
379
|
+
}));
|
|
380
|
+
this.groupColumnDefs$.next(groups);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
resolveGroupPresentation(col, params) {
|
|
384
|
+
col._resolvedGroupClass = typeof col.groupClass === 'function' ? col.groupClass(params) : col.groupClass;
|
|
385
|
+
col._resolvedGroupStyle = typeof col.groupStyle === 'function' ? col.groupStyle(params) : col.groupStyle;
|
|
386
|
+
return col;
|
|
387
|
+
}
|
|
388
|
+
resolveCellPresentation(col, params) {
|
|
389
|
+
col._resolvedHeaderClass = typeof col.headerClass === 'function' ? col.headerClass(params) : col.headerClass;
|
|
390
|
+
col._resolvedHeaderStyle = typeof col.headerStyle === 'function' ? col.headerStyle(params) : col.headerStyle;
|
|
391
|
+
col._resolvedCellClass = typeof col.cellClass === 'function' ? col.cellClass(params) : col.cellClass;
|
|
392
|
+
col._resolvedCellStyle = typeof col.cellStyle === 'function' ? col.cellStyle(params) : col.cellStyle;
|
|
393
|
+
return col;
|
|
394
|
+
}
|
|
395
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OgColumnService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
396
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OgColumnService }); }
|
|
397
|
+
}
|
|
398
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OgColumnService, decorators: [{
|
|
399
|
+
type: Injectable
|
|
400
|
+
}] });
|
|
401
|
+
|
|
402
|
+
class OneGridRowService {
|
|
403
|
+
constructor() {
|
|
404
|
+
this._getRowId = null;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Set Row Id Funciton
|
|
408
|
+
*/
|
|
409
|
+
setGetRowIdFn(getRowId) {
|
|
410
|
+
this._getRowId = getRowId;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Generate Unique Row ID
|
|
414
|
+
*/
|
|
415
|
+
generateRowId(data, rowIndex) {
|
|
416
|
+
if (this._getRowId) {
|
|
417
|
+
return this._getRowId({ data, rowIndex }) ?? v4();
|
|
418
|
+
}
|
|
419
|
+
return v4();
|
|
420
|
+
}
|
|
421
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridRowService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
422
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridRowService }); }
|
|
423
|
+
}
|
|
424
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridRowService, decorators: [{
|
|
425
|
+
type: Injectable
|
|
426
|
+
}] });
|
|
427
|
+
|
|
428
|
+
class CellFieldValueEmptyPipe {
|
|
429
|
+
transform(data, field) {
|
|
430
|
+
if (!data) {
|
|
431
|
+
return true;
|
|
432
|
+
}
|
|
433
|
+
const value = field.split('.').reduce((obj, key) => obj?.[key], data);
|
|
434
|
+
return value === null || value === undefined || value === '';
|
|
435
|
+
}
|
|
436
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellFieldValueEmptyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
437
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: CellFieldValueEmptyPipe, name: "cellFieldValueEmpty" }); }
|
|
438
|
+
}
|
|
439
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellFieldValueEmptyPipe, decorators: [{
|
|
440
|
+
type: Pipe,
|
|
441
|
+
args: [{
|
|
442
|
+
standalone: false,
|
|
443
|
+
name: 'cellFieldValueEmpty'
|
|
444
|
+
}]
|
|
445
|
+
}] });
|
|
446
|
+
|
|
447
|
+
class CellValueGetterPipe {
|
|
448
|
+
transform(data, node, column, context) {
|
|
449
|
+
return resolveOneValueGetterParams(column.valueGetter, {
|
|
450
|
+
data,
|
|
451
|
+
rowIndex: node.rowIndex,
|
|
452
|
+
node: node,
|
|
453
|
+
context: context
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellValueGetterPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
457
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: CellValueGetterPipe, name: "cellValueGetter" }); }
|
|
458
|
+
}
|
|
459
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellValueGetterPipe, decorators: [{
|
|
460
|
+
type: Pipe,
|
|
461
|
+
args: [{
|
|
462
|
+
standalone: false,
|
|
463
|
+
name: 'cellValueGetter'
|
|
464
|
+
}]
|
|
465
|
+
}] });
|
|
466
|
+
|
|
467
|
+
class CellFieldValuePipe {
|
|
468
|
+
transform(data, field) {
|
|
469
|
+
const value = getFieldValue(data, field);
|
|
470
|
+
if (value === null || value === undefined) {
|
|
471
|
+
return null;
|
|
472
|
+
}
|
|
473
|
+
if (typeof value === 'string' && value.trim() === '') {
|
|
474
|
+
return null;
|
|
475
|
+
}
|
|
476
|
+
return value;
|
|
477
|
+
}
|
|
478
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellFieldValuePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
479
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: CellFieldValuePipe, name: "cellFieldValue" }); }
|
|
480
|
+
}
|
|
481
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellFieldValuePipe, decorators: [{
|
|
482
|
+
type: Pipe,
|
|
483
|
+
args: [{
|
|
484
|
+
standalone: false,
|
|
485
|
+
name: 'cellFieldValue'
|
|
486
|
+
}]
|
|
487
|
+
}] });
|
|
488
|
+
|
|
489
|
+
class OneGridCellService {
|
|
490
|
+
constructor() {
|
|
491
|
+
this._cellFieldValueEmpty = new CellFieldValueEmptyPipe();
|
|
492
|
+
this._cellValueGetter = new CellValueGetterPipe();
|
|
493
|
+
this._cellFieldValue = new CellFieldValuePipe();
|
|
494
|
+
this._columnDefs = [];
|
|
495
|
+
/**
|
|
496
|
+
* One Column Def Params Resolver
|
|
497
|
+
*/
|
|
498
|
+
this.editableFn = (column, node) => resolveOneCellRendererParams(column.editable, { node, data: node.data, columnDef: column, rowIndex: node.rowIndex, context: this._context });
|
|
499
|
+
this.updatableFn = (column, node) => resolveOneCellRendererParams(column.updatable, { node, data: node.data, columnDef: column, rowIndex: node.rowIndex, context: this._context });
|
|
500
|
+
this.disableFn = (column, node) => resolveOneCellRendererParams(column.disable, { node, data: node.data, columnDef: column, rowIndex: node.rowIndex, context: this._context });
|
|
501
|
+
this.dragableFn = (column, node) => resolveOneCellRendererParams(column.dragable, { node, data: node.data, columnDef: column, rowIndex: node.rowIndex, context: this._context });
|
|
502
|
+
this.valueGetterFn = (column, node) => resolveOneValueGetterParams(column.valueGetter, { data: node.data, rowIndex: node.rowIndex, node: node, context: this._context });
|
|
503
|
+
}
|
|
504
|
+
applyColumnDefs(columnDefs, context) {
|
|
505
|
+
this._columnDefs = columnDefs;
|
|
506
|
+
this._context = context;
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Generate New Node States
|
|
510
|
+
*/
|
|
511
|
+
generateCellStates(node) {
|
|
512
|
+
if (!node)
|
|
513
|
+
return null;
|
|
514
|
+
const newStates = {};
|
|
515
|
+
for (const column of this._columnDefs) {
|
|
516
|
+
const field = column.field;
|
|
517
|
+
if (field !== '_oneRowNumber') {
|
|
518
|
+
newStates[field] = this.generateCellState(node, column) ?? node.cellStates[field] ?? { type: 'none', value: '' };
|
|
519
|
+
}
|
|
520
|
+
else {
|
|
521
|
+
newStates[field] = node.cellStates[column.field];
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
return newStates;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Generate New Node State Based on Column Field
|
|
528
|
+
*/
|
|
529
|
+
generateCellState(node, column) {
|
|
530
|
+
const isField = column.field !== undefined || column.field !== '' || column.field !== null;
|
|
531
|
+
const isEmpty = this._cellFieldValueEmpty.transform(node.data, column.field);
|
|
532
|
+
const isGroup = node.group || node.leafGroup;
|
|
533
|
+
const isAutoGroup = column?.autoGroupField;
|
|
534
|
+
if (column && column.cellRenderer && !isGroup) {
|
|
535
|
+
const value = column.cellRenderer({ node, columnDef: column });
|
|
536
|
+
return { type: 'html', value: value };
|
|
537
|
+
}
|
|
538
|
+
// 1. Cell Group Placeholder
|
|
539
|
+
if (isField && isEmpty && isGroup && isAutoGroup) {
|
|
540
|
+
return { type: 'placeholder', value: column?.cellRendererParams?.placeholder ?? this._cellValueGetter.transform(node.data, node, column, this._context) ?? '' };
|
|
541
|
+
}
|
|
542
|
+
// 2. Cell Group Text Value
|
|
543
|
+
if (isField && isGroup && isAutoGroup) {
|
|
544
|
+
const value = column?.valueGetter ? this._cellValueGetter.transform(node.data, node, column, this._context) : this._cellFieldValue.transform(node.data, column.field);
|
|
545
|
+
return { type: 'text', value: value ?? '' };
|
|
546
|
+
}
|
|
547
|
+
// 3. Cell Placeholder
|
|
548
|
+
if (isField && isEmpty && !isGroup && !isAutoGroup) {
|
|
549
|
+
const valueGetter = this._cellValueGetter.transform(node.data, node, column, this._context);
|
|
550
|
+
if (valueGetter) {
|
|
551
|
+
return { type: 'text', value: valueGetter };
|
|
552
|
+
}
|
|
553
|
+
const placeholder = column?.cellRendererParams?.placeholder ?? '';
|
|
554
|
+
return { type: 'placeholder', value: placeholder };
|
|
555
|
+
}
|
|
556
|
+
// 4. Cell Text Value
|
|
557
|
+
if (isField && !(isGroup || isAutoGroup)) {
|
|
558
|
+
const value = column?.valueGetter ? this._cellValueGetter.transform(node.data, node, column, this._context) : this._cellFieldValue.transform(node.data, column.field);
|
|
559
|
+
return { type: 'text', value: value ?? '' };
|
|
560
|
+
}
|
|
561
|
+
// 5. Default
|
|
562
|
+
return { type: 'none', value: '' };
|
|
563
|
+
}
|
|
564
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridCellService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
565
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridCellService }); }
|
|
566
|
+
}
|
|
567
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridCellService, decorators: [{
|
|
568
|
+
type: Injectable
|
|
569
|
+
}] });
|
|
570
|
+
|
|
571
|
+
class OneGridEventService {
|
|
572
|
+
constructor() {
|
|
573
|
+
this.events$ = new Subject();
|
|
574
|
+
this.subscriptions = [];
|
|
575
|
+
}
|
|
576
|
+
// Dispatch event
|
|
577
|
+
dispatchEvent(type, payload) {
|
|
578
|
+
this.events$.next({ type, payload });
|
|
579
|
+
}
|
|
580
|
+
// Subscribe to event
|
|
581
|
+
addEventListener(type, handler) {
|
|
582
|
+
const subscription = this.events$
|
|
583
|
+
.pipe(filter(e => e.type === type), map(e => e.payload))
|
|
584
|
+
.subscribe(handler);
|
|
585
|
+
// Track subscription for bulk cleanup
|
|
586
|
+
this.subscriptions.push(subscription);
|
|
587
|
+
// Return an unsubscribe function
|
|
588
|
+
return () => subscription.unsubscribe();
|
|
589
|
+
}
|
|
590
|
+
// RxJS API
|
|
591
|
+
eventStream(type) {
|
|
592
|
+
return this.events$.pipe(filter(e => e.type === type), map(e => e.payload));
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Clear All Subscriptions
|
|
596
|
+
*/
|
|
597
|
+
ngOnDestroy() {
|
|
598
|
+
this.subscriptions.forEach(sub => sub.unsubscribe());
|
|
599
|
+
this.subscriptions = [];
|
|
600
|
+
this.events$.complete();
|
|
601
|
+
}
|
|
602
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridEventService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
603
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridEventService }); }
|
|
604
|
+
}
|
|
605
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridEventService, decorators: [{
|
|
606
|
+
type: Injectable
|
|
607
|
+
}] });
|
|
608
|
+
|
|
609
|
+
class OneGridSelectionService {
|
|
610
|
+
constructor() {
|
|
611
|
+
this._selectedIds = new Set();
|
|
612
|
+
this._selectionMode = null;
|
|
613
|
+
}
|
|
614
|
+
getSelectedIds() {
|
|
615
|
+
return this._selectedIds;
|
|
616
|
+
}
|
|
617
|
+
setSelectedIds(rowIds) {
|
|
618
|
+
this._selectedIds = new Set(rowIds);
|
|
619
|
+
}
|
|
620
|
+
getSelectionMode() {
|
|
621
|
+
return this._selectionMode;
|
|
622
|
+
}
|
|
623
|
+
setSelectionMode(mode) {
|
|
624
|
+
this._selectionMode = mode;
|
|
625
|
+
if (mode === 'single' && this._selectedIds.size > 1) {
|
|
626
|
+
// keep only one if mode is single
|
|
627
|
+
const first = this._selectedIds.values().next().value;
|
|
628
|
+
this._selectedIds = new Set([first]);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
toggleSelection(rowId, selected) {
|
|
632
|
+
if (this._selectionMode === 'single') {
|
|
633
|
+
this._selectedIds.clear();
|
|
634
|
+
}
|
|
635
|
+
selected ? this._selectedIds.add(rowId) : this._selectedIds.delete(rowId);
|
|
636
|
+
}
|
|
637
|
+
toggleAllSelection(allIds, selected) {
|
|
638
|
+
selected ? this._selectedIds = new Set(allIds) : this._selectedIds.clear();
|
|
639
|
+
}
|
|
640
|
+
// Header Checkbox State
|
|
641
|
+
getSelectAllState(allIds) {
|
|
642
|
+
if (this._selectedIds.size === 0)
|
|
643
|
+
return 'unchecked';
|
|
644
|
+
if (this._selectedIds.size === allIds.length)
|
|
645
|
+
return 'checked';
|
|
646
|
+
return 'indeterminate';
|
|
647
|
+
}
|
|
648
|
+
selectAll(rowIds) {
|
|
649
|
+
this._selectedIds = new Set(rowIds);
|
|
650
|
+
}
|
|
651
|
+
deselectAll() {
|
|
652
|
+
this._selectedIds.clear();
|
|
653
|
+
}
|
|
654
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridSelectionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
655
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridSelectionService }); }
|
|
656
|
+
}
|
|
657
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridSelectionService, decorators: [{
|
|
658
|
+
type: Injectable
|
|
659
|
+
}] });
|
|
660
|
+
|
|
661
|
+
class OneGridExpansionService {
|
|
662
|
+
constructor() {
|
|
663
|
+
this._expandedIds = new Set();
|
|
664
|
+
this._collapsedIds = new Set();
|
|
665
|
+
}
|
|
666
|
+
getExpandedIds() {
|
|
667
|
+
return this._expandedIds;
|
|
668
|
+
}
|
|
669
|
+
getCollapsedIds() {
|
|
670
|
+
return this._collapsedIds;
|
|
671
|
+
}
|
|
672
|
+
toggleExpanded(rowId, expanded) {
|
|
673
|
+
if (expanded) {
|
|
674
|
+
this._expandedIds.add(rowId);
|
|
675
|
+
this._collapsedIds.delete(rowId);
|
|
676
|
+
}
|
|
677
|
+
else {
|
|
678
|
+
this._expandedIds.delete(rowId);
|
|
679
|
+
this._collapsedIds.add(rowId);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
isExpanded(rowId) {
|
|
683
|
+
return this._expandedIds.has(rowId);
|
|
684
|
+
}
|
|
685
|
+
isCollapsed(rowId) {
|
|
686
|
+
return this._collapsedIds.has(rowId);
|
|
687
|
+
}
|
|
688
|
+
clear() {
|
|
689
|
+
this._expandedIds.clear();
|
|
690
|
+
this._collapsedIds.clear();
|
|
691
|
+
}
|
|
692
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridExpansionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
693
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridExpansionService }); }
|
|
694
|
+
}
|
|
695
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridExpansionService, decorators: [{
|
|
696
|
+
type: Injectable
|
|
697
|
+
}] });
|
|
698
|
+
|
|
699
|
+
class OneGridApi {
|
|
700
|
+
constructor(columnService, rowService, cellService, eventService, selectionService, expansionService) {
|
|
701
|
+
this.columnService = columnService;
|
|
702
|
+
this.rowService = rowService;
|
|
703
|
+
this.cellService = cellService;
|
|
704
|
+
this.eventService = eventService;
|
|
705
|
+
this.selectionService = selectionService;
|
|
706
|
+
this.expansionService = expansionService;
|
|
707
|
+
this.context = null;
|
|
708
|
+
this.rowSelection = null;
|
|
709
|
+
this.apiType = null;
|
|
710
|
+
this.rowNodes = [];
|
|
711
|
+
this.sortModel = [];
|
|
712
|
+
this.rowHeight = 26;
|
|
713
|
+
this.headerRowHeight = 32;
|
|
714
|
+
this._currentIndex = 0;
|
|
715
|
+
this._quickFilterValue = null;
|
|
716
|
+
this._activeFilters = [];
|
|
717
|
+
this._visibleRowNodes = [];
|
|
718
|
+
this._originalRowNodes = new Map();
|
|
719
|
+
this._nodeCleanupMap = new Map(); // Cleanup registry (prevents memory leaks)
|
|
720
|
+
this._destroyed = false;
|
|
721
|
+
// Advanced Features
|
|
722
|
+
this.treeData = false;
|
|
723
|
+
this.treeDataChildrenField = null;
|
|
724
|
+
this.groupDefaultExpanded = 0;
|
|
725
|
+
this.masterDetail = false;
|
|
726
|
+
}
|
|
727
|
+
init(gridApiType, rowSelection, columnDefs, defaultColumnDef, context, masterDetail, detailCellRendererParams, detailRendererComponent, treeData, groupColumnDefs) {
|
|
728
|
+
this.id = v4();
|
|
729
|
+
this.apiType = gridApiType;
|
|
730
|
+
this.rowSelection = rowSelection;
|
|
731
|
+
this.context = context;
|
|
732
|
+
this.masterDetail = masterDetail;
|
|
733
|
+
this.detailCellRendererParams = detailCellRendererParams;
|
|
734
|
+
this.detailRendererComponent = detailRendererComponent;
|
|
735
|
+
this.treeData = treeData;
|
|
736
|
+
this.selectionService.setSelectionMode(this.rowSelection);
|
|
737
|
+
this.rowService.setGetRowIdFn(this.context?.componentParent?.getRowId ?? null);
|
|
738
|
+
this.cellService.applyColumnDefs(columnDefs, context);
|
|
739
|
+
this.columnService.initColumnDefs(defaultColumnDef, columnDefs, groupColumnDefs);
|
|
740
|
+
const columnState = this.columnService.getColumnState();
|
|
741
|
+
setTimeout(() => this.eventService.dispatchEvent('columnChanged', columnState));
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Create Row Node & Clear All State IDS
|
|
745
|
+
*/
|
|
746
|
+
setRowData(rowData) {
|
|
747
|
+
const validRowIds = new Set();
|
|
748
|
+
// Clear All State IDS
|
|
749
|
+
this.selectionService.deselectAll();
|
|
750
|
+
this.expansionService.clear();
|
|
751
|
+
// Build New Row Nodes
|
|
752
|
+
this.buildRowNodes(rowData, null, 0, validRowIds);
|
|
753
|
+
// Apply Filter
|
|
754
|
+
this.applyFilters();
|
|
755
|
+
// Remove invalid nodes from map
|
|
756
|
+
for (const rowId of this._originalRowNodes.keys()) {
|
|
757
|
+
if (!validRowIds.has(rowId)) {
|
|
758
|
+
this._originalRowNodes.delete(rowId);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Create Row Nodes & Not Clear State IDS
|
|
764
|
+
*/
|
|
765
|
+
updateRowData(rowData) {
|
|
766
|
+
const validRowIds = new Set();
|
|
767
|
+
// Build New Row Nodes
|
|
768
|
+
this.buildRowNodes(rowData, null, 0, validRowIds);
|
|
769
|
+
// Apply Filter
|
|
770
|
+
this.applyFilters();
|
|
771
|
+
// Remove invalid nodes from map
|
|
772
|
+
for (const rowId of this._originalRowNodes.keys()) {
|
|
773
|
+
if (!validRowIds.has(rowId)) {
|
|
774
|
+
this._originalRowNodes.delete(rowId);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Recursive Build Row Nodes (Optimized)
|
|
780
|
+
*/
|
|
781
|
+
buildRowNodes(rowData, parent = null, level = 0, validRowIds = new Set(), expandedIds = new Set(this.expansionService.getExpandedIds()), collapsedIds = new Set(this.expansionService.getCollapsedIds()), selectedIds = new Set(this.selectionService.getSelectedIds())) {
|
|
782
|
+
if (parent === null) {
|
|
783
|
+
this.rowNodes = [];
|
|
784
|
+
this._currentIndex = 0;
|
|
785
|
+
}
|
|
786
|
+
if (!rowData?.length)
|
|
787
|
+
return [];
|
|
788
|
+
const nodes = [];
|
|
789
|
+
for (const data of rowData) {
|
|
790
|
+
const rowId = this.rowService.generateRowId(data, this._currentIndex);
|
|
791
|
+
const children = data[this.treeDataChildrenField] || null;
|
|
792
|
+
let node = this._originalRowNodes.get(rowId);
|
|
793
|
+
validRowIds.add(rowId);
|
|
794
|
+
if (node) {
|
|
795
|
+
node.data = data;
|
|
796
|
+
node.setRowIndex(this._currentIndex);
|
|
797
|
+
}
|
|
798
|
+
else {
|
|
799
|
+
node = new OneRowNode(rowId, data, this._currentIndex);
|
|
800
|
+
node.level = level;
|
|
801
|
+
node.parent = parent;
|
|
802
|
+
node.detailRendererComponent = this.detailRendererComponent;
|
|
803
|
+
this._originalRowNodes.set(rowId, node);
|
|
804
|
+
if (this.masterDetail) {
|
|
805
|
+
this.subscribeToDetailChanges(node);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
const childrenExist = children && children.length >= 0;
|
|
809
|
+
node.group = this.masterDetail ? false : childrenExist;
|
|
810
|
+
node.leaf = this.masterDetail ? true : !node.group;
|
|
811
|
+
node.leafGroup = this.masterDetail ? false : (node.group && !childrenExist);
|
|
812
|
+
node.expandable = this.masterDetail ? true : (node.group && !node.leafGroup);
|
|
813
|
+
const defaultExpanded = node.expandable && (level < this.groupDefaultExpanded || this.groupDefaultExpanded === -1);
|
|
814
|
+
node.setExpanded(expandedIds.has(rowId) ? true : collapsedIds.has(rowId) ? false : defaultExpanded);
|
|
815
|
+
node.setSelected(selectedIds.has(rowId));
|
|
816
|
+
node.setCellStates(this.cellService.generateCellStates(node));
|
|
817
|
+
if (this.masterDetail && this.apiType === 'master') {
|
|
818
|
+
this.getDetailRowData({ data, node: node, successCallback: (detailRowData) => node.setDetailRowData(detailRowData) });
|
|
819
|
+
}
|
|
820
|
+
this._currentIndex++;
|
|
821
|
+
this.rowNodes.push(node);
|
|
822
|
+
nodes.push(node);
|
|
823
|
+
node.children = this.treeData && childrenExist ? this.buildRowNodes(children || [], node, level + 1, validRowIds, expandedIds, collapsedIds, selectedIds) : [];
|
|
824
|
+
}
|
|
825
|
+
return nodes;
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Filter Feature
|
|
829
|
+
*/
|
|
830
|
+
applyFilters() {
|
|
831
|
+
const filters = this._activeFilters;
|
|
832
|
+
const quick = this._quickFilterValue?.toLowerCase() ?? '';
|
|
833
|
+
this.rowNodes.forEach(node => filterTreeNode(node, filters, quick));
|
|
834
|
+
this.refreshVisibleNodes();
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* Update Row Nodes Display
|
|
838
|
+
*/
|
|
839
|
+
refreshVisibleNodes() {
|
|
840
|
+
if (this._destroyed)
|
|
841
|
+
return;
|
|
842
|
+
const visibleNodes = [];
|
|
843
|
+
let rowNumber = 1;
|
|
844
|
+
const visibilityCache = new Map();
|
|
845
|
+
for (const node of this.rowNodes) {
|
|
846
|
+
const parentVisible = node.parent ? visibilityCache.get(node.parent.rowId) : true;
|
|
847
|
+
const isVisible = node.visible && parentVisible && (!node.parent || node.parent.expanded);
|
|
848
|
+
visibilityCache.set(node.rowId, isVisible);
|
|
849
|
+
if (isVisible) {
|
|
850
|
+
node.cellStates['_oneRowNumber'] = { type: 'text', value: rowNumber++ };
|
|
851
|
+
node.cellStates = { ...node.cellStates };
|
|
852
|
+
visibleNodes.push(node);
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
node.cellStates['_oneRowNumber'] = { type: 'none', value: null };
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
this._visibleRowNodes = [...visibleNodes];
|
|
859
|
+
this.eventService.dispatchEvent('rowDataChanged', { nodes: visibleNodes });
|
|
860
|
+
}
|
|
861
|
+
getVisibleRowNodes() {
|
|
862
|
+
return this._visibleRowNodes;
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* Sorting Model Feature
|
|
866
|
+
*/
|
|
867
|
+
onSortChanged(sortModel) {
|
|
868
|
+
this.sortModel = sortModel;
|
|
869
|
+
this.applySorting();
|
|
870
|
+
this.eventService.dispatchEvent('sortChanged', { nodes: this.rowNodes });
|
|
871
|
+
}
|
|
872
|
+
applySorting() {
|
|
873
|
+
if (this.sortModel.length === 0) {
|
|
874
|
+
this.rowNodes = [...this._originalRowNodes.values()];
|
|
875
|
+
return;
|
|
876
|
+
}
|
|
877
|
+
this.rowNodes = [...this._originalRowNodes.values()].sort((a, b) => {
|
|
878
|
+
for (const sortItem of this.sortModel) {
|
|
879
|
+
const { colId, sort } = sortItem;
|
|
880
|
+
const valA = getFieldValue(a.data, colId);
|
|
881
|
+
const valB = getFieldValue(b.data, colId);
|
|
882
|
+
const comparisonResult = this.compareValues(valA, valB, sort);
|
|
883
|
+
if (comparisonResult !== 0) {
|
|
884
|
+
return comparisonResult;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
return 0;
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
compareValues(valA, valB, sortDirection) {
|
|
891
|
+
if (valA === null && valB === null)
|
|
892
|
+
return 0;
|
|
893
|
+
if (valA === null)
|
|
894
|
+
return sortDirection === 'asc' ? 1 : -1;
|
|
895
|
+
if (valB === null)
|
|
896
|
+
return sortDirection === 'asc' ? -1 : 1;
|
|
897
|
+
if (typeof valA === 'string' && typeof valB === 'string') {
|
|
898
|
+
const comparison = valA.localeCompare(valB, undefined, { numeric: true });
|
|
899
|
+
return sortDirection === 'asc' ? comparison : -comparison;
|
|
900
|
+
}
|
|
901
|
+
if (valA < valB)
|
|
902
|
+
return sortDirection === 'asc' ? -1 : 1;
|
|
903
|
+
if (valA > valB)
|
|
904
|
+
return sortDirection === 'asc' ? 1 : -1;
|
|
905
|
+
return 0;
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* Row Selection Feature (Optimized)
|
|
909
|
+
*/
|
|
910
|
+
selectAll() {
|
|
911
|
+
const rowIds = [];
|
|
912
|
+
this._originalRowNodes.forEach(node => {
|
|
913
|
+
node.setSelected(true);
|
|
914
|
+
node.cellStates = { ...node.cellStates };
|
|
915
|
+
rowIds.push(node.rowId);
|
|
916
|
+
});
|
|
917
|
+
this.selectionService.selectAll(rowIds);
|
|
918
|
+
this.eventService.dispatchEvent('selectionChanged', { allNodesNotSelected: false, allNodesSelected: true, selected: true, node: null });
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* Deselect all nodes (optimized)
|
|
922
|
+
*/
|
|
923
|
+
deselectAll() {
|
|
924
|
+
this._originalRowNodes.forEach(node => {
|
|
925
|
+
node.setSelected(false);
|
|
926
|
+
node.cellStates = { ...node.cellStates };
|
|
927
|
+
});
|
|
928
|
+
this.selectionService.deselectAll();
|
|
929
|
+
if (this.selectionService.getSelectionMode() === 'multiple') {
|
|
930
|
+
this.eventService.dispatchEvent('selectionChanged', {
|
|
931
|
+
allNodesNotSelected: true,
|
|
932
|
+
allNodesSelected: false,
|
|
933
|
+
selected: false,
|
|
934
|
+
node: null
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
toggleSelection(rowId, selected) {
|
|
939
|
+
const node = this.getRowNodeById(rowId);
|
|
940
|
+
if (node) {
|
|
941
|
+
node.setSelected(selected);
|
|
942
|
+
this.selectionService.toggleSelection(rowId, selected);
|
|
943
|
+
this.eventService.dispatchEvent('selectionChanged', { node, data: node.data, selected });
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
setSelectedById(rowId) {
|
|
947
|
+
const node = this.getRowNodeById(rowId);
|
|
948
|
+
if (node) {
|
|
949
|
+
if (this.selectionService.getSelectionMode() === 'single') {
|
|
950
|
+
this.rowNodes.forEach(rowNode => rowNode.setSelected(rowNode.rowId === node.rowId));
|
|
951
|
+
this._originalRowNodes.forEach(rowNode => rowNode.setSelected(rowNode.rowId === node.rowId));
|
|
952
|
+
}
|
|
953
|
+
else {
|
|
954
|
+
node.setSelected(true);
|
|
955
|
+
}
|
|
956
|
+
this.selectionService.toggleSelection(rowId, true);
|
|
957
|
+
this.eventService.dispatchEvent('selectionChanged', { node, selected: true });
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
setSelectedByIds(rowIds, selected = true) {
|
|
961
|
+
rowIds.forEach(rowId => {
|
|
962
|
+
const node = this._originalRowNodes.get(rowId);
|
|
963
|
+
if (node) {
|
|
964
|
+
node.setSelected(selected);
|
|
965
|
+
node.cellStates = { ...node.cellStates };
|
|
966
|
+
this.selectionService.toggleSelection(rowId, selected);
|
|
967
|
+
}
|
|
968
|
+
});
|
|
969
|
+
this.eventService.dispatchEvent('selectionChanged', { node: null });
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* Get & Set Functions
|
|
973
|
+
*/
|
|
974
|
+
getAllRowNodes() {
|
|
975
|
+
return this.rowNodes?.length > 0 ? [...this.rowNodes] : [];
|
|
976
|
+
}
|
|
977
|
+
getRowDataSelected() {
|
|
978
|
+
return this.rowNodes.filter(node => node.selected).map(node => ({ ...node.data }));
|
|
979
|
+
}
|
|
980
|
+
getSelectedRowNodes() {
|
|
981
|
+
const nodes = this.rowNodes.filter(node => node.selected);
|
|
982
|
+
return nodes && nodes.length > 0 ? [...nodes] : [];
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Column filters
|
|
986
|
+
*/
|
|
987
|
+
getFilterModel() {
|
|
988
|
+
return this._activeFilters;
|
|
989
|
+
}
|
|
990
|
+
setFilterModel(model) {
|
|
991
|
+
this._activeFilters = model;
|
|
992
|
+
this.applyFilters();
|
|
993
|
+
}
|
|
994
|
+
filterActive(field) {
|
|
995
|
+
return this._activeFilters.some(f => f.field === field && f.conditions.length > 0);
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Quick filter
|
|
999
|
+
*/
|
|
1000
|
+
setQuickFilter(value) {
|
|
1001
|
+
this._quickFilterValue = (value || '').toLowerCase();
|
|
1002
|
+
this.applyFilters();
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Validation Feature
|
|
1006
|
+
*/
|
|
1007
|
+
validateRow(row, columns) {
|
|
1008
|
+
const errors = {};
|
|
1009
|
+
columns.forEach(col => {
|
|
1010
|
+
// Only check columns with validationRule
|
|
1011
|
+
if (!col.validationRules || col.validationRules.length === 0)
|
|
1012
|
+
return;
|
|
1013
|
+
const rules = col.validationRules;
|
|
1014
|
+
for (const rule of rules) {
|
|
1015
|
+
const error = rule(row[col.field], row);
|
|
1016
|
+
if (error) {
|
|
1017
|
+
errors[col.field] = error;
|
|
1018
|
+
break; // stop at first error for this column
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
});
|
|
1022
|
+
return errors;
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Validate all rows and return both errors and a flag indicating if there are any errors
|
|
1026
|
+
*/
|
|
1027
|
+
validateAllRows(rowData, columns) {
|
|
1028
|
+
const allErrors = rowData.map(row => {
|
|
1029
|
+
const errors = {};
|
|
1030
|
+
columns.forEach(col => {
|
|
1031
|
+
if (!col.validationRules || col.validationRules.length === 0)
|
|
1032
|
+
return;
|
|
1033
|
+
for (const rule of col.validationRules) {
|
|
1034
|
+
const error = rule(row[col.field], row);
|
|
1035
|
+
if (error) {
|
|
1036
|
+
errors[col.field] = error;
|
|
1037
|
+
break;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
});
|
|
1041
|
+
return errors;
|
|
1042
|
+
});
|
|
1043
|
+
const hasErrors = allErrors.some(err => Object.keys(err).length > 0);
|
|
1044
|
+
return { errors: allErrors, valid: !hasErrors, invalid: hasErrors };
|
|
1045
|
+
}
|
|
1046
|
+
/** Traverse all nodes */
|
|
1047
|
+
forEachNode(callback) {
|
|
1048
|
+
const visit = (nodes) => {
|
|
1049
|
+
nodes.forEach((node, index) => {
|
|
1050
|
+
callback(node, index);
|
|
1051
|
+
if (node?.children?.length)
|
|
1052
|
+
visit(node.children);
|
|
1053
|
+
});
|
|
1054
|
+
};
|
|
1055
|
+
visit(this.rowNodes);
|
|
1056
|
+
}
|
|
1057
|
+
/** Traverse only leaf nodes */
|
|
1058
|
+
forEachLeafNode(callback) {
|
|
1059
|
+
let leafIndex = 0;
|
|
1060
|
+
const visit = (nodes) => {
|
|
1061
|
+
nodes.forEach(node => {
|
|
1062
|
+
if (node.leaf) {
|
|
1063
|
+
callback(node, leafIndex++);
|
|
1064
|
+
}
|
|
1065
|
+
else if (node.group && node?.children?.length) {
|
|
1066
|
+
visit(node.children);
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1069
|
+
};
|
|
1070
|
+
visit(this.rowNodes);
|
|
1071
|
+
}
|
|
1072
|
+
getRowNodeById(rowId) {
|
|
1073
|
+
return this._originalRowNodes.get(rowId);
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Expand/collapse a node
|
|
1077
|
+
*/
|
|
1078
|
+
setTreeDataChildrenField(field) {
|
|
1079
|
+
this.treeDataChildrenField = field;
|
|
1080
|
+
}
|
|
1081
|
+
setGroupDefaultExpanded(defaultExpanded) {
|
|
1082
|
+
this.groupDefaultExpanded = defaultExpanded;
|
|
1083
|
+
}
|
|
1084
|
+
toggleExpandAll(expanded) {
|
|
1085
|
+
this.forEachNode(node => {
|
|
1086
|
+
node.setExpanded(expanded);
|
|
1087
|
+
this.expansionService.toggleExpanded(node.rowId, expanded);
|
|
1088
|
+
});
|
|
1089
|
+
this.refreshVisibleNodes();
|
|
1090
|
+
}
|
|
1091
|
+
setExpandedById(rowId, expanded) {
|
|
1092
|
+
const node = this._originalRowNodes.get(rowId);
|
|
1093
|
+
if (node) {
|
|
1094
|
+
node.setExpanded(expanded);
|
|
1095
|
+
this.expansionService.toggleExpanded(rowId, expanded);
|
|
1096
|
+
}
|
|
1097
|
+
this.refreshVisibleNodes();
|
|
1098
|
+
}
|
|
1099
|
+
setExpandedByIds(rowIds, expanded) {
|
|
1100
|
+
if (rowIds && rowIds.length > 0) {
|
|
1101
|
+
for (let rowId of rowIds) {
|
|
1102
|
+
const node = this._originalRowNodes.get(rowId);
|
|
1103
|
+
if (node) {
|
|
1104
|
+
node.setExpanded(expanded);
|
|
1105
|
+
this.expansionService.toggleExpanded(rowId, expanded);
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
this.refreshVisibleNodes();
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
getExpandedByIds() {
|
|
1112
|
+
return Array.from(this.expansionService.getExpandedIds());
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Master Detail Feature
|
|
1116
|
+
*/
|
|
1117
|
+
setDetailRowData(node, detailData) {
|
|
1118
|
+
const rowNode = this.getRowNodeById(node.rowId);
|
|
1119
|
+
if (rowNode) {
|
|
1120
|
+
rowNode.setDetailRowData(detailData);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
setGetDetailRowData(getDetailRowData) {
|
|
1124
|
+
this.getDetailRowData = getDetailRowData;
|
|
1125
|
+
}
|
|
1126
|
+
/**
|
|
1127
|
+
* Columns State
|
|
1128
|
+
*/
|
|
1129
|
+
getColumnState() {
|
|
1130
|
+
return this.columnService.getColumnState();
|
|
1131
|
+
}
|
|
1132
|
+
setColumnDefs(columnDefs) {
|
|
1133
|
+
this.columnService.setColumnDefs(columnDefs);
|
|
1134
|
+
const columnState = this.columnService.getColumnState();
|
|
1135
|
+
this.cellService.applyColumnDefs(columnState.columns, this.context);
|
|
1136
|
+
this.eventService.dispatchEvent('columnChanged', columnState);
|
|
1137
|
+
}
|
|
1138
|
+
updateColumn(id, changes) {
|
|
1139
|
+
this.columnService.updateColumnDef(id, changes);
|
|
1140
|
+
const columnState = this.columnService.getColumnState();
|
|
1141
|
+
this.cellService.applyColumnDefs(columnState.columns, this.context);
|
|
1142
|
+
this.eventService.dispatchEvent('columnChanged', columnState);
|
|
1143
|
+
}
|
|
1144
|
+
reorderColumnDefs(fromIndex, toIndex) {
|
|
1145
|
+
this.columnService.reorderColumnDefs(fromIndex, toIndex);
|
|
1146
|
+
const columnState = this.columnService.getColumnState();
|
|
1147
|
+
this.eventService.dispatchEvent('columnChanged', columnState);
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* Update checkbox selection features
|
|
1151
|
+
*/
|
|
1152
|
+
setNodeAndChildrenSelected(node, selected) {
|
|
1153
|
+
const rowIds = new Set();
|
|
1154
|
+
const collect = (n) => {
|
|
1155
|
+
rowIds.add(n.rowId);
|
|
1156
|
+
if (n.children && n.children.length) {
|
|
1157
|
+
n.children.forEach(child => collect(child));
|
|
1158
|
+
}
|
|
1159
|
+
};
|
|
1160
|
+
collect(node);
|
|
1161
|
+
this.setSelectedByIds(Array.from(rowIds), selected);
|
|
1162
|
+
}
|
|
1163
|
+
updateNodeStates(node) {
|
|
1164
|
+
const rowNode = this.getRowNodeById(node.rowId);
|
|
1165
|
+
if (rowNode) {
|
|
1166
|
+
rowNode.cellStates = this.cellService.generateCellStates(rowNode);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
updateCellState(node, column) {
|
|
1170
|
+
const rowNode = this.getRowNodeById(node.rowId);
|
|
1171
|
+
if (rowNode) {
|
|
1172
|
+
rowNode.cellStates[column.field] = this.cellService.generateCellState(rowNode, column);
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
updateCellStates(node) {
|
|
1176
|
+
const rowNode = this.getRowNodeById(node.rowId);
|
|
1177
|
+
if (rowNode) {
|
|
1178
|
+
rowNode.cellStates = this.cellService.generateCellStates(rowNode);
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* Handler that Reacts to Detail Changes
|
|
1183
|
+
*/
|
|
1184
|
+
subscribeToDetailChanges(node) {
|
|
1185
|
+
const unsubRowData = node.on('rowDataChanged', ({ node, data, previousData }) => {
|
|
1186
|
+
});
|
|
1187
|
+
// When detail data arrives
|
|
1188
|
+
const unsubDetail = node.on('detailRowDataChanged', ({ node, detailRowData, previousDetailRowData }) => {
|
|
1189
|
+
if (this.apiType === 'master') {
|
|
1190
|
+
this._resolvedDetailRowHeight(node);
|
|
1191
|
+
}
|
|
1192
|
+
});
|
|
1193
|
+
// When row expands
|
|
1194
|
+
const unsubExpand = node.on('expandedChanged', ({ node, expanded }) => {
|
|
1195
|
+
// if (!expanded) return;
|
|
1196
|
+
// // Only fetch if detail data not already loaded
|
|
1197
|
+
// if (!node.detailRowData) {
|
|
1198
|
+
// this.getDetailRowData({ data: node.data, node, successCallback: (detailRowData) => node.setDetailRowData(detailRowData) });
|
|
1199
|
+
// }
|
|
1200
|
+
});
|
|
1201
|
+
// // Cleanup when node is removed from grid
|
|
1202
|
+
this.registerNodeCleanup(node.rowId, [unsubDetail, unsubExpand]);
|
|
1203
|
+
}
|
|
1204
|
+
registerNodeCleanup(rowId, unsubs) {
|
|
1205
|
+
// Merge with any existing cleanups for this rowId
|
|
1206
|
+
const existing = this._nodeCleanupMap.get(rowId) ?? [];
|
|
1207
|
+
this._nodeCleanupMap.set(rowId, [...existing, ...unsubs]);
|
|
1208
|
+
}
|
|
1209
|
+
cleanupNode(rowId) {
|
|
1210
|
+
const cleanups = this._nodeCleanupMap.get(rowId);
|
|
1211
|
+
cleanups?.forEach(fn => fn());
|
|
1212
|
+
this._nodeCleanupMap.delete(rowId);
|
|
1213
|
+
}
|
|
1214
|
+
// Call this when rows are removed
|
|
1215
|
+
pruneRemovedNodes(validRowIds) {
|
|
1216
|
+
for (const [rowId, node] of this._originalRowNodes) {
|
|
1217
|
+
if (!validRowIds.has(rowId)) {
|
|
1218
|
+
this.cleanupNode(rowId); // unsubscribe listeners
|
|
1219
|
+
node.destroy(); // clear node's own listener map
|
|
1220
|
+
this._originalRowNodes.delete(rowId);
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Resolve Detail Row Height
|
|
1226
|
+
*/
|
|
1227
|
+
_resolvedDetailRowHeight(node) {
|
|
1228
|
+
const minRows = this.detailCellRendererParams.detailGridOptions.detailRowHeightOptions.minRows;
|
|
1229
|
+
const maxRows = this.detailCellRendererParams.detailGridOptions.detailRowHeightOptions.maxRows;
|
|
1230
|
+
const minHeight = (this.rowHeight * minRows) + this.headerRowHeight;
|
|
1231
|
+
const maxHeight = (this.rowHeight * maxRows) + this.headerRowHeight;
|
|
1232
|
+
const rows = node.detailRowData && node.detailRowData.length ? node.detailRowData.length : 0;
|
|
1233
|
+
node.detailRowHeight = rows <= minRows ? minHeight : rows >= maxRows ? maxHeight : (this.rowHeight * rows) + this.headerRowHeight;
|
|
1234
|
+
}
|
|
1235
|
+
/**
|
|
1236
|
+
* On Destroy
|
|
1237
|
+
*/
|
|
1238
|
+
destroy() {
|
|
1239
|
+
if (this._destroyed)
|
|
1240
|
+
return;
|
|
1241
|
+
this._destroyed = true;
|
|
1242
|
+
this.rowNodes.forEach(node => {
|
|
1243
|
+
node.children = [];
|
|
1244
|
+
node.parent = null;
|
|
1245
|
+
});
|
|
1246
|
+
this.rowNodes = [];
|
|
1247
|
+
this._originalRowNodes.clear();
|
|
1248
|
+
this._currentIndex = null;
|
|
1249
|
+
// Clear services
|
|
1250
|
+
if (this.selectionService) {
|
|
1251
|
+
this.selectionService.deselectAll();
|
|
1252
|
+
}
|
|
1253
|
+
this.selectionService = null;
|
|
1254
|
+
if (this.expansionService) {
|
|
1255
|
+
this.expansionService.clear();
|
|
1256
|
+
}
|
|
1257
|
+
this.expansionService = null;
|
|
1258
|
+
this.eventService = null;
|
|
1259
|
+
this.rowService = null;
|
|
1260
|
+
this.cellService = null;
|
|
1261
|
+
// Clear filters, sorting, context
|
|
1262
|
+
this._activeFilters = [];
|
|
1263
|
+
this._quickFilterValue = null;
|
|
1264
|
+
this.sortModel = [];
|
|
1265
|
+
// Clear master/detail/treeData
|
|
1266
|
+
this.masterDetail = false;
|
|
1267
|
+
this.treeData = false;
|
|
1268
|
+
this.treeDataChildrenField = '';
|
|
1269
|
+
this.groupDefaultExpanded = 0;
|
|
1270
|
+
}
|
|
1271
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridApi, deps: [{ token: OgColumnService }, { token: OneGridRowService }, { token: OneGridCellService }, { token: OneGridEventService }, { token: OneGridSelectionService }, { token: OneGridExpansionService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1272
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridApi }); }
|
|
1273
|
+
}
|
|
1274
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridApi, decorators: [{
|
|
1275
|
+
type: Injectable
|
|
1276
|
+
}], ctorParameters: () => [{ type: OgColumnService }, { type: OneGridRowService }, { type: OneGridCellService }, { type: OneGridEventService }, { type: OneGridSelectionService }, { type: OneGridExpansionService }] });
|
|
1277
|
+
|
|
1278
|
+
class OneGridTreeDataService {
|
|
1279
|
+
create(tree, parentId, newNode) {
|
|
1280
|
+
if (!parentId) {
|
|
1281
|
+
return [newNode, ...tree];
|
|
1282
|
+
}
|
|
1283
|
+
return tree.map(node => {
|
|
1284
|
+
if (node.id === parentId) {
|
|
1285
|
+
return { ...node, children: [newNode, ...(node.children || [])] };
|
|
1286
|
+
}
|
|
1287
|
+
if (node.children) {
|
|
1288
|
+
return { ...node, children: this.create(node.children, parentId, newNode) };
|
|
1289
|
+
}
|
|
1290
|
+
return node;
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
update(tree, nodeId, updatedData) {
|
|
1294
|
+
return tree.map(node => {
|
|
1295
|
+
if (node.id === nodeId) {
|
|
1296
|
+
return { ...node, ...updatedData };
|
|
1297
|
+
}
|
|
1298
|
+
if (node.children) {
|
|
1299
|
+
return { ...node, children: this.update(node.children, nodeId, updatedData) };
|
|
1300
|
+
}
|
|
1301
|
+
return node;
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
delete(tree, nodeId) {
|
|
1305
|
+
return tree.map(node => {
|
|
1306
|
+
if (node.children && node.children.length > 0) {
|
|
1307
|
+
return { ...node, children: this.delete(node.children, nodeId) };
|
|
1308
|
+
}
|
|
1309
|
+
return node;
|
|
1310
|
+
}).filter(node => node.id !== nodeId);
|
|
1311
|
+
}
|
|
1312
|
+
find(treeData, nodeId) {
|
|
1313
|
+
for (const node of treeData) {
|
|
1314
|
+
if (node.id === nodeId) {
|
|
1315
|
+
return node;
|
|
1316
|
+
}
|
|
1317
|
+
if (node.children) {
|
|
1318
|
+
const found = this.find(node.children, nodeId);
|
|
1319
|
+
if (found)
|
|
1320
|
+
return found;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
return null;
|
|
1324
|
+
}
|
|
1325
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridTreeDataService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1326
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridTreeDataService, providedIn: 'root' }); }
|
|
1327
|
+
}
|
|
1328
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridTreeDataService, decorators: [{
|
|
1329
|
+
type: Injectable,
|
|
1330
|
+
args: [{
|
|
1331
|
+
providedIn: 'root'
|
|
1332
|
+
}]
|
|
1333
|
+
}] });
|
|
1334
|
+
|
|
1335
|
+
const OnePageSizeOption = [25, 50, 100, 250];
|
|
1336
|
+
|
|
1337
|
+
class HeaderCheckboxDisabledPipe {
|
|
1338
|
+
transform(rowNodes, selectionMode, allowedEdit) {
|
|
1339
|
+
return rowNodes?.length === 0 || selectionMode !== 'multiple' || !allowedEdit;
|
|
1340
|
+
}
|
|
1341
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: HeaderCheckboxDisabledPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1342
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: HeaderCheckboxDisabledPipe, name: "headerCheckboxDisabled" }); }
|
|
1343
|
+
}
|
|
1344
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: HeaderCheckboxDisabledPipe, decorators: [{
|
|
1345
|
+
type: Pipe,
|
|
1346
|
+
args: [{
|
|
1347
|
+
standalone: false,
|
|
1348
|
+
name: 'headerCheckboxDisabled'
|
|
1349
|
+
}]
|
|
1350
|
+
}] });
|
|
1351
|
+
|
|
1352
|
+
class HeaderCheckboxCheckedPipe {
|
|
1353
|
+
transform(rowNodes, selectionMode, state) {
|
|
1354
|
+
return rowNodes?.length > 0 && selectionMode === 'multiple' && state === 'checked';
|
|
1355
|
+
}
|
|
1356
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: HeaderCheckboxCheckedPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1357
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: HeaderCheckboxCheckedPipe, name: "headerCheckboxChecked" }); }
|
|
1358
|
+
}
|
|
1359
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: HeaderCheckboxCheckedPipe, decorators: [{
|
|
1360
|
+
type: Pipe,
|
|
1361
|
+
args: [{
|
|
1362
|
+
standalone: false,
|
|
1363
|
+
name: 'headerCheckboxChecked'
|
|
1364
|
+
}]
|
|
1365
|
+
}] });
|
|
1366
|
+
|
|
1367
|
+
class HeaderCheckboxIndeterminatePipe {
|
|
1368
|
+
transform(rowNodes, selectionMode, state) {
|
|
1369
|
+
return rowNodes?.length > 0 && selectionMode === 'multiple' && state === 'indeterminate';
|
|
1370
|
+
}
|
|
1371
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: HeaderCheckboxIndeterminatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1372
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: HeaderCheckboxIndeterminatePipe, name: "headerCheckboxIndeterminate" }); }
|
|
1373
|
+
}
|
|
1374
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: HeaderCheckboxIndeterminatePipe, decorators: [{
|
|
1375
|
+
type: Pipe,
|
|
1376
|
+
args: [{
|
|
1377
|
+
standalone: false,
|
|
1378
|
+
name: 'headerCheckboxIndeterminate'
|
|
1379
|
+
}]
|
|
1380
|
+
}] });
|
|
1381
|
+
|
|
1382
|
+
class OneGridCheckboxHeaderComponent {
|
|
1383
|
+
constructor(eventService, selectionService) {
|
|
1384
|
+
this.eventService = eventService;
|
|
1385
|
+
this.selectionService = selectionService;
|
|
1386
|
+
this.allowedEdit = false;
|
|
1387
|
+
this.state = 'unchecked';
|
|
1388
|
+
this.rowNodes = [];
|
|
1389
|
+
}
|
|
1390
|
+
ngOnInit() {
|
|
1391
|
+
this.selectionMode = this.api.rowSelection;
|
|
1392
|
+
/**
|
|
1393
|
+
* Listen Row Node Selection Changed Event
|
|
1394
|
+
*/
|
|
1395
|
+
this.eventService.addEventListener('selectionChanged', (payload) => {
|
|
1396
|
+
this.rowNodes = this.api.getAllRowNodes();
|
|
1397
|
+
const rowIds = this.rowNodes && this.rowNodes.length > 0 ? this.rowNodes.map((node) => node.rowId) : [];
|
|
1398
|
+
this.state = this.selectionService.getSelectAllState(rowIds);
|
|
1399
|
+
});
|
|
1400
|
+
/**
|
|
1401
|
+
* Listen Row Data Changed Event
|
|
1402
|
+
*/
|
|
1403
|
+
this.eventService.addEventListener('rowDataChanged', (payload) => {
|
|
1404
|
+
this.rowNodes = this.api.getAllRowNodes();
|
|
1405
|
+
const rowIds = this.rowNodes && this.rowNodes.length > 0 ? this.rowNodes.map((node) => node.rowId) : [];
|
|
1406
|
+
this.state = this.selectionService.getSelectAllState(rowIds);
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
/**
|
|
1410
|
+
* Toggle Selection Action
|
|
1411
|
+
*/
|
|
1412
|
+
toggleSelectionAll(event) {
|
|
1413
|
+
if (this.selectionMode === 'single')
|
|
1414
|
+
return;
|
|
1415
|
+
const checked = event.target.checked;
|
|
1416
|
+
if (this.rowNodes && this.rowNodes.length > 0) {
|
|
1417
|
+
if (checked) {
|
|
1418
|
+
this.api.selectAll();
|
|
1419
|
+
}
|
|
1420
|
+
else {
|
|
1421
|
+
this.api.deselectAll();
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridCheckboxHeaderComponent, deps: [{ token: OneGridEventService }, { token: OneGridSelectionService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1426
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: OneGridCheckboxHeaderComponent, selector: "one-grid-checkbox-header", inputs: { api: "api", allowedEdit: "allowedEdit" }, ngImport: i0, template: "<div class=\"one-grid-checkbox\">\n <input\n [id]=\"api.id\"\n [type]=\"'checkbox'\"\n [class.disabled]=\"rowNodes | headerCheckboxDisabled:selectionMode:allowedEdit\"\n [checked]=\"rowNodes | headerCheckboxChecked:selectionMode:state\"\n [indeterminate]=\"rowNodes | headerCheckboxIndeterminate:selectionMode:state\"\n (change)=\"toggleSelectionAll($event)\" />\n</div>", styles: [""], dependencies: [{ kind: "pipe", type: HeaderCheckboxDisabledPipe, name: "headerCheckboxDisabled" }, { kind: "pipe", type: HeaderCheckboxCheckedPipe, name: "headerCheckboxChecked" }, { kind: "pipe", type: HeaderCheckboxIndeterminatePipe, name: "headerCheckboxIndeterminate" }] }); }
|
|
1427
|
+
}
|
|
1428
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridCheckboxHeaderComponent, decorators: [{
|
|
1429
|
+
type: Component,
|
|
1430
|
+
args: [{ standalone: false, selector: 'one-grid-checkbox-header', template: "<div class=\"one-grid-checkbox\">\n <input\n [id]=\"api.id\"\n [type]=\"'checkbox'\"\n [class.disabled]=\"rowNodes | headerCheckboxDisabled:selectionMode:allowedEdit\"\n [checked]=\"rowNodes | headerCheckboxChecked:selectionMode:state\"\n [indeterminate]=\"rowNodes | headerCheckboxIndeterminate:selectionMode:state\"\n (change)=\"toggleSelectionAll($event)\" />\n</div>" }]
|
|
1431
|
+
}], ctorParameters: () => [{ type: OneGridEventService }, { type: OneGridSelectionService }], propDecorators: { api: [{
|
|
1432
|
+
type: Input
|
|
1433
|
+
}], allowedEdit: [{
|
|
1434
|
+
type: Input
|
|
1435
|
+
}] } });
|
|
1436
|
+
|
|
1437
|
+
class ColumnSortStatePipe {
|
|
1438
|
+
transform(field, sortModel) {
|
|
1439
|
+
if (!sortModel || !field)
|
|
1440
|
+
return null;
|
|
1441
|
+
return sortModel.find(s => s.colId === field)?.sort ?? null;
|
|
1442
|
+
}
|
|
1443
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ColumnSortStatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1444
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: ColumnSortStatePipe, name: "columnSortState" }); }
|
|
1445
|
+
}
|
|
1446
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ColumnSortStatePipe, decorators: [{
|
|
1447
|
+
type: Pipe,
|
|
1448
|
+
args: [{
|
|
1449
|
+
standalone: false,
|
|
1450
|
+
name: 'columnSortState'
|
|
1451
|
+
}]
|
|
1452
|
+
}] });
|
|
1453
|
+
|
|
1454
|
+
class OneGridHeaderComponent {
|
|
1455
|
+
constructor(eventService, cdr) {
|
|
1456
|
+
this.eventService = eventService;
|
|
1457
|
+
this.cdr = cdr;
|
|
1458
|
+
this.scrollLeft = 0;
|
|
1459
|
+
this.allowedEdit = false;
|
|
1460
|
+
this.enableGroupColumnDefs = false;
|
|
1461
|
+
this.groupColumnDefs = [];
|
|
1462
|
+
this.columnDefs = [];
|
|
1463
|
+
this.sortModel = [];
|
|
1464
|
+
this.destroy$ = new Subject();
|
|
1465
|
+
this.subscriptions = new Subscription();
|
|
1466
|
+
this.draggedIndex = null;
|
|
1467
|
+
// Track resize state
|
|
1468
|
+
this.resizing = false;
|
|
1469
|
+
this.resizeColumnIndex = null;
|
|
1470
|
+
this.startX = 0;
|
|
1471
|
+
this.startWidth = 0;
|
|
1472
|
+
// Arrow function to preserve 'this' context
|
|
1473
|
+
this.onResizeMove = (event) => {
|
|
1474
|
+
if (!this.resizing || this.resizeColumnIndex === null)
|
|
1475
|
+
return;
|
|
1476
|
+
// Calculate how far the mouse has moved
|
|
1477
|
+
const deltaX = event.clientX - this.startX;
|
|
1478
|
+
// Calculate new width (with minimum of 50px)
|
|
1479
|
+
const newWidth = Math.max(50, this.startWidth + deltaX);
|
|
1480
|
+
// Update the column width
|
|
1481
|
+
this.api.updateColumn(this.columnDefs[this.resizeColumnIndex].id, { width: newWidth });
|
|
1482
|
+
};
|
|
1483
|
+
this.onResizeEnd = () => {
|
|
1484
|
+
// Clean up
|
|
1485
|
+
this.resizing = false;
|
|
1486
|
+
this.resizeColumnIndex = null;
|
|
1487
|
+
document.body.style.cursor = '';
|
|
1488
|
+
// Remove document listeners
|
|
1489
|
+
document.removeEventListener('mousemove', this.onResizeMove);
|
|
1490
|
+
document.removeEventListener('mouseup', this.onResizeEnd);
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
ngOnInit() {
|
|
1494
|
+
// Listen Column Changed Event
|
|
1495
|
+
this.subscriptions.add(this.eventService.addEventListener('columnChanged', (payload) => {
|
|
1496
|
+
const { groups, columns } = payload;
|
|
1497
|
+
if (groups) {
|
|
1498
|
+
this.groupColumnDefs = groups;
|
|
1499
|
+
}
|
|
1500
|
+
if (columns) {
|
|
1501
|
+
this.columnDefs = columns;
|
|
1502
|
+
}
|
|
1503
|
+
// this.cdr.markForCheck();
|
|
1504
|
+
}));
|
|
1505
|
+
}
|
|
1506
|
+
onHeaderMenuOptionClick(columnDef) {
|
|
1507
|
+
}
|
|
1508
|
+
onHeaderMenuSortClick(colId) {
|
|
1509
|
+
const currentSort = this.sortModel.find(sort => sort.colId === colId)?.sort ?? null;
|
|
1510
|
+
const nextSort = this.cycleSort(currentSort);
|
|
1511
|
+
this.sortModel = nextSort ? [{ colId, sort: nextSort }] : [];
|
|
1512
|
+
this.api.onSortChanged(this.sortModel);
|
|
1513
|
+
}
|
|
1514
|
+
// Cycle Sorting Model
|
|
1515
|
+
cycleSort(current) {
|
|
1516
|
+
switch (current) {
|
|
1517
|
+
case null: return 'asc';
|
|
1518
|
+
case 'asc': return 'desc';
|
|
1519
|
+
case 'desc': return null;
|
|
1520
|
+
default: return null;
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
onResizeStart(event, columnIndex) {
|
|
1524
|
+
// Prevent text selection and default behavior
|
|
1525
|
+
event.preventDefault();
|
|
1526
|
+
event.stopPropagation();
|
|
1527
|
+
// Store initial values
|
|
1528
|
+
this.resizing = true;
|
|
1529
|
+
this.resizeColumnIndex = columnIndex;
|
|
1530
|
+
this.startX = event.clientX;
|
|
1531
|
+
this.startWidth = this.columnDefs[columnIndex].width;
|
|
1532
|
+
// Add document-level listeners for drag and release
|
|
1533
|
+
document.addEventListener('mousemove', this.onResizeMove);
|
|
1534
|
+
document.addEventListener('mouseup', this.onResizeEnd);
|
|
1535
|
+
// Add a class to body to maintain cursor during drag
|
|
1536
|
+
document.body.style.cursor = 'col-resize';
|
|
1537
|
+
}
|
|
1538
|
+
// Track the dragged column index
|
|
1539
|
+
onDragColumnStart(event, index) {
|
|
1540
|
+
this.draggedIndex = index;
|
|
1541
|
+
// Optional: Set drag image/effect
|
|
1542
|
+
if (event.dataTransfer) {
|
|
1543
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
onDragColumnOver(event, targetIndex) {
|
|
1547
|
+
event.preventDefault();
|
|
1548
|
+
// Skip if dragging over itself or no drag in progress
|
|
1549
|
+
if (this.draggedIndex === null || this.draggedIndex === targetIndex) {
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1552
|
+
// IMMEDIATELY reorder columns
|
|
1553
|
+
this.api.reorderColumnDefs(this.draggedIndex, targetIndex);
|
|
1554
|
+
// Update draggedIndex to the new position
|
|
1555
|
+
this.draggedIndex = targetIndex;
|
|
1556
|
+
}
|
|
1557
|
+
onDragColumnEnd(event) {
|
|
1558
|
+
this.draggedIndex = null;
|
|
1559
|
+
}
|
|
1560
|
+
onDropColumn(event) {
|
|
1561
|
+
event.preventDefault();
|
|
1562
|
+
this.draggedIndex = null;
|
|
1563
|
+
}
|
|
1564
|
+
/**
|
|
1565
|
+
* Clear All Subscriptions
|
|
1566
|
+
*/
|
|
1567
|
+
ngOnDestroy() {
|
|
1568
|
+
this.destroy$.complete();
|
|
1569
|
+
}
|
|
1570
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridHeaderComponent, deps: [{ token: OneGridEventService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1571
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.12", type: OneGridHeaderComponent, selector: "one-grid-header", inputs: { scrollLeft: "scrollLeft", allowedEdit: "allowedEdit", enableGroupColumnDefs: "enableGroupColumnDefs", api: "api" }, ngImport: i0, template: "<div class=\"one-grid-header\">\n @if (enableGroupColumnDefs) {\n <div class=\"one-group-header-row\" [style.transform]=\"'translateX(-' + scrollLeft + 'px)'\">\n <ng-container *ngTemplateOutlet=\"groupColumns; context: { groups: groupColumnDefs }\"></ng-container>\n </div>\n }\n <div class=\"one-grid-header-viewport\">\n <div class=\"one-header-row\" [style.transform]=\"'translateX(-' + scrollLeft + 'px)'\">\n <ng-container *ngTemplateOutlet=\"headerColumns; context: { columns: columnDefs }\"></ng-container>\n </div>\n </div>\n</div>\n\n<!-- Group Header Cell Template -->\n<ng-template #groupColumns let-groups=\"groups\">\n @for(group of groups; track group.id) {\n <div class=\"one-group-header-cell\"\n [style.width.px]=\"group.width\"\n [ngClass]=\"group._resolvedGroupClass\"\n [ngStyle]=\"group._resolvedGroupStyle\">\n <div class=\"one-group-header-cell-text\">\n {{ group.headerName }}\n </div>\n </div>\n }\n</ng-template>\n\n<!-- Header Cell Template -->\n<ng-template #headerColumns let-columns=\"columns\">\n @for (col of columns; let colIndex = $index; track col.id) {\n <div class=\"one-grid-header-column\"\n [attr.data-index]=\"colIndex\"\n [style.width.px]=\"col.width\"\n [style.min-width.px]=\"col.minWidth\"\n [style.max-width.px]=\"col.maxWidth\"\n [draggable]=\"col?.dragable\"\n (dragstart)=\"onDragColumnStart($event, colIndex)\"\n (dragover)=\"onDragColumnOver($event, colIndex)\"\n (dragend)=\"onDragColumnEnd($event)\"\n (drop)=\"onDropColumn($event)\">\n <div class=\"one-grid-header-cell\"\n [ngClass]=\"col._resolvedHeaderClass\"\n [ngStyle]=\"col._resolvedHeaderStyle\"\n >\n <span class=\"one-grid-header-cell-group\">\n @if (col?.headerCheckboxSelection) {\n <one-grid-checkbox-header\n [api]=\"api\"\n [allowedEdit]=\"allowedEdit\"\n />\n }\n\n {{ col?.headerName ?? '' }}\n </span>\n\n <!-- Og Resize Handler -->\n @if (col?.resizable) {\n <div class=\"og-resize-handle\" (mousedown)=\"onResizeStart($event, colIndex)\">\n <i class=\"bi bi-grip-vertical\"></i>\n </div>\n }\n\n <div class=\"one-grid-header-cell-group\">\n\n <!-- Sort Menu Button -->\n @if (col?.sortable) {\n <div class=\"one-grid-header-menu-button\" (click)=\"onHeaderMenuSortClick(col.field)\">\n\n @if ((col.field | columnSortState:api.sortModel) === 'asc') {\n <lucide-icon name=\"arrow-up-a-z\" [size]=\"16\" [strokeWidth]=\"2\"></lucide-icon>\n }\n @else if ((col.field | columnSortState:api.sortModel) === 'desc') {\n <lucide-icon name=\"arrow-down-z-a\" [size]=\"16\" [strokeWidth]=\"2\"></lucide-icon>\n }\n @else {\n <lucide-icon name=\"arrow-down-up\" [size]=\"16\" [strokeWidth]=\"2\"></lucide-icon>\n }\n </div>\n }\n\n <!-- Og Option Menu Button -->\n @if (col && !col.suppressHeaderMenuButton) {\n <div class=\"one-grid-header-menu-button\" (click)=\"onHeaderMenuOptionClick(col)\">\n <i class=\"bi bi-three-dots-vertical\"></i>\n </div>\n }\n </div>\n </div>\n </div>\n }\n</ng-template>\n", styles: [""], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: i3.LucideAngularComponent, selector: "lucide-angular, lucide-icon, i-lucide, span-lucide", inputs: ["class", "name", "img", "color", "absoluteStrokeWidth", "size", "strokeWidth"] }, { kind: "component", type: OneGridCheckboxHeaderComponent, selector: "one-grid-checkbox-header", inputs: ["api", "allowedEdit"] }, { kind: "pipe", type: ColumnSortStatePipe, name: "columnSortState" }] }); }
|
|
1572
|
+
}
|
|
1573
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridHeaderComponent, decorators: [{
|
|
1574
|
+
type: Component,
|
|
1575
|
+
args: [{ standalone: false, selector: 'one-grid-header', template: "<div class=\"one-grid-header\">\n @if (enableGroupColumnDefs) {\n <div class=\"one-group-header-row\" [style.transform]=\"'translateX(-' + scrollLeft + 'px)'\">\n <ng-container *ngTemplateOutlet=\"groupColumns; context: { groups: groupColumnDefs }\"></ng-container>\n </div>\n }\n <div class=\"one-grid-header-viewport\">\n <div class=\"one-header-row\" [style.transform]=\"'translateX(-' + scrollLeft + 'px)'\">\n <ng-container *ngTemplateOutlet=\"headerColumns; context: { columns: columnDefs }\"></ng-container>\n </div>\n </div>\n</div>\n\n<!-- Group Header Cell Template -->\n<ng-template #groupColumns let-groups=\"groups\">\n @for(group of groups; track group.id) {\n <div class=\"one-group-header-cell\"\n [style.width.px]=\"group.width\"\n [ngClass]=\"group._resolvedGroupClass\"\n [ngStyle]=\"group._resolvedGroupStyle\">\n <div class=\"one-group-header-cell-text\">\n {{ group.headerName }}\n </div>\n </div>\n }\n</ng-template>\n\n<!-- Header Cell Template -->\n<ng-template #headerColumns let-columns=\"columns\">\n @for (col of columns; let colIndex = $index; track col.id) {\n <div class=\"one-grid-header-column\"\n [attr.data-index]=\"colIndex\"\n [style.width.px]=\"col.width\"\n [style.min-width.px]=\"col.minWidth\"\n [style.max-width.px]=\"col.maxWidth\"\n [draggable]=\"col?.dragable\"\n (dragstart)=\"onDragColumnStart($event, colIndex)\"\n (dragover)=\"onDragColumnOver($event, colIndex)\"\n (dragend)=\"onDragColumnEnd($event)\"\n (drop)=\"onDropColumn($event)\">\n <div class=\"one-grid-header-cell\"\n [ngClass]=\"col._resolvedHeaderClass\"\n [ngStyle]=\"col._resolvedHeaderStyle\"\n >\n <span class=\"one-grid-header-cell-group\">\n @if (col?.headerCheckboxSelection) {\n <one-grid-checkbox-header\n [api]=\"api\"\n [allowedEdit]=\"allowedEdit\"\n />\n }\n\n {{ col?.headerName ?? '' }}\n </span>\n\n <!-- Og Resize Handler -->\n @if (col?.resizable) {\n <div class=\"og-resize-handle\" (mousedown)=\"onResizeStart($event, colIndex)\">\n <i class=\"bi bi-grip-vertical\"></i>\n </div>\n }\n\n <div class=\"one-grid-header-cell-group\">\n\n <!-- Sort Menu Button -->\n @if (col?.sortable) {\n <div class=\"one-grid-header-menu-button\" (click)=\"onHeaderMenuSortClick(col.field)\">\n\n @if ((col.field | columnSortState:api.sortModel) === 'asc') {\n <lucide-icon name=\"arrow-up-a-z\" [size]=\"16\" [strokeWidth]=\"2\"></lucide-icon>\n }\n @else if ((col.field | columnSortState:api.sortModel) === 'desc') {\n <lucide-icon name=\"arrow-down-z-a\" [size]=\"16\" [strokeWidth]=\"2\"></lucide-icon>\n }\n @else {\n <lucide-icon name=\"arrow-down-up\" [size]=\"16\" [strokeWidth]=\"2\"></lucide-icon>\n }\n </div>\n }\n\n <!-- Og Option Menu Button -->\n @if (col && !col.suppressHeaderMenuButton) {\n <div class=\"one-grid-header-menu-button\" (click)=\"onHeaderMenuOptionClick(col)\">\n <i class=\"bi bi-three-dots-vertical\"></i>\n </div>\n }\n </div>\n </div>\n </div>\n }\n</ng-template>\n" }]
|
|
1576
|
+
}], ctorParameters: () => [{ type: OneGridEventService }, { type: i0.ChangeDetectorRef }], propDecorators: { scrollLeft: [{
|
|
1577
|
+
type: Input
|
|
1578
|
+
}], allowedEdit: [{
|
|
1579
|
+
type: Input
|
|
1580
|
+
}], enableGroupColumnDefs: [{
|
|
1581
|
+
type: Input
|
|
1582
|
+
}], api: [{
|
|
1583
|
+
type: Input
|
|
1584
|
+
}] } });
|
|
1585
|
+
|
|
1586
|
+
class CellEditablePipe {
|
|
1587
|
+
transform(cellStates, column, node, editable, updatable, allowedEdit) {
|
|
1588
|
+
if (cellStates) {
|
|
1589
|
+
return (editable(column, node) &&
|
|
1590
|
+
updatable(column, node) &&
|
|
1591
|
+
allowedEdit &&
|
|
1592
|
+
!(column?.cellRendererParams?.validateSelectedRowOnly && !node?.selected) &&
|
|
1593
|
+
((node?.leaf &&
|
|
1594
|
+
!(node?.group && node?.leafGroup) &&
|
|
1595
|
+
!column?.autoGroupField) ||
|
|
1596
|
+
(!node?.leaf &&
|
|
1597
|
+
(node?.group || node?.leafGroup) &&
|
|
1598
|
+
column?.autoGroupField &&
|
|
1599
|
+
column?.editableLevels?.includes(node.level))));
|
|
1600
|
+
}
|
|
1601
|
+
return false;
|
|
1602
|
+
}
|
|
1603
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellEditablePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1604
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: CellEditablePipe, name: "cellEditable" }); }
|
|
1605
|
+
}
|
|
1606
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellEditablePipe, decorators: [{
|
|
1607
|
+
type: Pipe,
|
|
1608
|
+
args: [{
|
|
1609
|
+
name: 'cellEditable',
|
|
1610
|
+
standalone: false
|
|
1611
|
+
}]
|
|
1612
|
+
}] });
|
|
1613
|
+
|
|
1614
|
+
class OneGridCheckboxComponent {
|
|
1615
|
+
constructor(selectionService, eventService) {
|
|
1616
|
+
this.selectionService = selectionService;
|
|
1617
|
+
this.eventService = eventService;
|
|
1618
|
+
this.allowedEdit = false;
|
|
1619
|
+
this.onRowSelection = new EventEmitter();
|
|
1620
|
+
}
|
|
1621
|
+
onToggleSelection(event) {
|
|
1622
|
+
const isChecked = event.target.checked;
|
|
1623
|
+
const { rowId, rowIndex, data } = this.node;
|
|
1624
|
+
const selectionMode = this.selectionService.getSelectionMode();
|
|
1625
|
+
if (selectionMode === 'single') {
|
|
1626
|
+
this.api.deselectAll();
|
|
1627
|
+
if (isChecked) {
|
|
1628
|
+
this.node.setSelected(true);
|
|
1629
|
+
}
|
|
1630
|
+
this.api.toggleSelection(rowId, isChecked);
|
|
1631
|
+
}
|
|
1632
|
+
else {
|
|
1633
|
+
// Multi-select mode
|
|
1634
|
+
this.selectionService.toggleSelection(rowId, isChecked);
|
|
1635
|
+
this.node.setSelected(isChecked);
|
|
1636
|
+
}
|
|
1637
|
+
this.node.cellStates = { ...this.node.cellStates };
|
|
1638
|
+
this.eventService.dispatchEvent('selectionChanged', { rowIndex, selected: isChecked, data, node: this.node });
|
|
1639
|
+
this.onRowSelection.emit({ rowIndex, selected: isChecked, data, node: this.node });
|
|
1640
|
+
}
|
|
1641
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridCheckboxComponent, deps: [{ token: OneGridSelectionService }, { token: OneGridEventService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1642
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: OneGridCheckboxComponent, selector: "one-grid-checkbox", inputs: { node: "node", allowedEdit: "allowedEdit", api: "api" }, outputs: { onRowSelection: "onRowSelection" }, ngImport: i0, template: "\n<div class=\"one-grid-checkbox\">\n <input type=\"checkbox\"\n [name]=\"node.rowId\"\n [class.disabled]=\"!(allowedEdit)\"\n [checked]=\"node.selected\"\n (change)=\"onToggleSelection($event)\"/>\n</div>", styles: [""] }); }
|
|
1643
|
+
}
|
|
1644
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridCheckboxComponent, decorators: [{
|
|
1645
|
+
type: Component,
|
|
1646
|
+
args: [{ standalone: false, selector: 'one-grid-checkbox', template: "\n<div class=\"one-grid-checkbox\">\n <input type=\"checkbox\"\n [name]=\"node.rowId\"\n [class.disabled]=\"!(allowedEdit)\"\n [checked]=\"node.selected\"\n (change)=\"onToggleSelection($event)\"/>\n</div>" }]
|
|
1647
|
+
}], ctorParameters: () => [{ type: OneGridSelectionService }, { type: OneGridEventService }], propDecorators: { node: [{
|
|
1648
|
+
type: Input
|
|
1649
|
+
}], allowedEdit: [{
|
|
1650
|
+
type: Input
|
|
1651
|
+
}], api: [{
|
|
1652
|
+
type: Input
|
|
1653
|
+
}], onRowSelection: [{
|
|
1654
|
+
type: Output
|
|
1655
|
+
}] } });
|
|
1656
|
+
|
|
1657
|
+
class CellDisableResolverPipe {
|
|
1658
|
+
transform(node, column, context, allowedEdit) {
|
|
1659
|
+
if (!column || !node)
|
|
1660
|
+
return false;
|
|
1661
|
+
return resolveOneCellRendererParams(column.disable, {
|
|
1662
|
+
node,
|
|
1663
|
+
data: node.data,
|
|
1664
|
+
columnDef: column,
|
|
1665
|
+
rowIndex: node.rowIndex,
|
|
1666
|
+
context
|
|
1667
|
+
}) || !allowedEdit;
|
|
1668
|
+
}
|
|
1669
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellDisableResolverPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1670
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: CellDisableResolverPipe, name: "cellDisableResolver" }); }
|
|
1671
|
+
}
|
|
1672
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellDisableResolverPipe, decorators: [{
|
|
1673
|
+
type: Pipe,
|
|
1674
|
+
args: [{
|
|
1675
|
+
standalone: false,
|
|
1676
|
+
name: 'cellDisableResolver'
|
|
1677
|
+
}]
|
|
1678
|
+
}] });
|
|
1679
|
+
|
|
1680
|
+
class OneGridRowActionComponent {
|
|
1681
|
+
constructor() {
|
|
1682
|
+
this.allowedEdit = false;
|
|
1683
|
+
this.masterDetail = false;
|
|
1684
|
+
this.masterNode = null;
|
|
1685
|
+
this.gridType = null;
|
|
1686
|
+
this.context = null;
|
|
1687
|
+
/**
|
|
1688
|
+
* Bind Event to Parent Component
|
|
1689
|
+
*/
|
|
1690
|
+
this.onRowGotoDetail = new EventEmitter();
|
|
1691
|
+
this.onRowAddNew = new EventEmitter();
|
|
1692
|
+
this.onRowView = new EventEmitter();
|
|
1693
|
+
this.onRowLocation = new EventEmitter();
|
|
1694
|
+
this.onRowDocument = new EventEmitter();
|
|
1695
|
+
this.onRowCopy = new EventEmitter();
|
|
1696
|
+
this.onRowDelete = new EventEmitter();
|
|
1697
|
+
this.onRowGotoList = new EventEmitter();
|
|
1698
|
+
this.onRowEdit = new EventEmitter();
|
|
1699
|
+
this.onRowPrint = new EventEmitter();
|
|
1700
|
+
this.onRowHistory = new EventEmitter();
|
|
1701
|
+
this.onRowOption = new EventEmitter();
|
|
1702
|
+
this.onRowLanguage = new EventEmitter();
|
|
1703
|
+
this.onRowCellOption = new EventEmitter();
|
|
1704
|
+
}
|
|
1705
|
+
ngOnInit() {
|
|
1706
|
+
this.detailActiveExcludeLevels = new Set(this.column.cellRendererParams?.detailActiveExcludeLevels ?? []);
|
|
1707
|
+
this.gotoDetailExcludeLevels = new Set(this.column.cellRendererParams?.gotoDetailExcludeLevels ?? []);
|
|
1708
|
+
this.addNewExcludeLevels = new Set(this.column.cellRendererParams?.addNewExcludeLevels ?? []);
|
|
1709
|
+
}
|
|
1710
|
+
/**
|
|
1711
|
+
* Trigger Invoke Click Event
|
|
1712
|
+
*/
|
|
1713
|
+
invokeRowToggleDetailActiveExpand(node) {
|
|
1714
|
+
node.detailActive = !node.detailActive;
|
|
1715
|
+
}
|
|
1716
|
+
invokeRowActionGotoDetail(node, column) {
|
|
1717
|
+
let data = { node, column, data: node.data, rowIndex: node.rowIndex, gridType: null };
|
|
1718
|
+
if (this.masterDetail) {
|
|
1719
|
+
data = { ...data, gridType: this.gridType, masterNode: this.masterNode };
|
|
1720
|
+
}
|
|
1721
|
+
this.onRowGotoDetail.emit(data);
|
|
1722
|
+
}
|
|
1723
|
+
invokeRowActionAddNew(node, column) {
|
|
1724
|
+
let data = { node, column, data: node.data, rowIndex: node.rowIndex, gridType: null };
|
|
1725
|
+
if (this.masterDetail) {
|
|
1726
|
+
data = { ...data, gridType: this.gridType, masterNode: this.masterNode };
|
|
1727
|
+
}
|
|
1728
|
+
this.onRowAddNew.emit(data);
|
|
1729
|
+
}
|
|
1730
|
+
invokeRowActionView(node, column) {
|
|
1731
|
+
let data = { node, column, data: node.data, rowIndex: node.rowIndex, gridType: null };
|
|
1732
|
+
if (this.masterDetail) {
|
|
1733
|
+
data = { ...data, gridType: this.gridType, masterNode: this.masterNode };
|
|
1734
|
+
}
|
|
1735
|
+
this.onRowView.emit(data);
|
|
1736
|
+
}
|
|
1737
|
+
invokeRowActionLocation(node, column) {
|
|
1738
|
+
let data = { node, column, data: node.data, rowIndex: node.rowIndex, gridType: null };
|
|
1739
|
+
if (this.masterDetail) {
|
|
1740
|
+
data = { ...data, gridType: this.gridType, masterNode: this.masterNode };
|
|
1741
|
+
}
|
|
1742
|
+
this.onRowLocation.emit(data);
|
|
1743
|
+
}
|
|
1744
|
+
invokeRowActionDocument(node, column) {
|
|
1745
|
+
let data = { node, column, data: node.data, rowIndex: node.rowIndex, gridType: null };
|
|
1746
|
+
if (this.masterDetail) {
|
|
1747
|
+
data = { ...data, gridType: this.gridType, masterNode: this.masterNode };
|
|
1748
|
+
}
|
|
1749
|
+
this.onRowDocument.emit(data);
|
|
1750
|
+
}
|
|
1751
|
+
invokeRowActionCopy(node, column) {
|
|
1752
|
+
let data = { node, column, data: node.data, rowIndex: node.rowIndex, gridType: null };
|
|
1753
|
+
if (this.masterDetail) {
|
|
1754
|
+
data = { ...data, gridType: this.gridType, masterNode: this.masterNode };
|
|
1755
|
+
}
|
|
1756
|
+
this.onRowCopy.emit(data);
|
|
1757
|
+
}
|
|
1758
|
+
invokeRowActionDelete(node, column) {
|
|
1759
|
+
let data = { node, column, data: node.data, rowIndex: node.rowIndex, gridType: null };
|
|
1760
|
+
if (this.masterDetail) {
|
|
1761
|
+
data = { ...data, gridType: this.gridType, masterNode: this.masterNode };
|
|
1762
|
+
}
|
|
1763
|
+
this.onRowDelete.emit(data);
|
|
1764
|
+
}
|
|
1765
|
+
invokeRowActionGotoList(node, column) {
|
|
1766
|
+
let data = { node, column, data: node.data, rowIndex: node.rowIndex, gridType: null };
|
|
1767
|
+
if (this.masterDetail) {
|
|
1768
|
+
data = { ...data, gridType: this.gridType, masterNode: this.masterNode };
|
|
1769
|
+
}
|
|
1770
|
+
this.onRowGotoList.emit(data);
|
|
1771
|
+
}
|
|
1772
|
+
invokeRowActionEdit(node, column) {
|
|
1773
|
+
let data = { node, column, data: node.data, rowIndex: node.rowIndex, gridType: null };
|
|
1774
|
+
if (this.masterDetail) {
|
|
1775
|
+
data = { ...data, gridType: this.gridType, masterNode: this.masterNode };
|
|
1776
|
+
}
|
|
1777
|
+
this.onRowEdit.emit(data);
|
|
1778
|
+
}
|
|
1779
|
+
invokeRowActionPrint(node, column) {
|
|
1780
|
+
let data = { node, column, data: node.data, rowIndex: node.rowIndex, gridType: null };
|
|
1781
|
+
if (this.masterDetail) {
|
|
1782
|
+
data = { ...data, gridType: this.gridType, masterNode: this.masterNode };
|
|
1783
|
+
}
|
|
1784
|
+
this.onRowPrint.emit(data);
|
|
1785
|
+
}
|
|
1786
|
+
invokeRowActionHistory(node, column) {
|
|
1787
|
+
let data = { node, column, data: node.data, rowIndex: node.rowIndex, gridType: null };
|
|
1788
|
+
if (this.masterDetail) {
|
|
1789
|
+
data = { ...data, gridType: this.gridType, masterNode: this.masterNode };
|
|
1790
|
+
}
|
|
1791
|
+
this.onRowHistory.emit(data);
|
|
1792
|
+
}
|
|
1793
|
+
invokeRowActionOption(node, column) {
|
|
1794
|
+
let data = { node, column, data: node.data, rowIndex: node.rowIndex, gridType: null };
|
|
1795
|
+
if (this.masterDetail) {
|
|
1796
|
+
data = { ...data, gridType: this.gridType, masterNode: this.masterNode };
|
|
1797
|
+
}
|
|
1798
|
+
this.onRowOption.emit(data);
|
|
1799
|
+
}
|
|
1800
|
+
invokeRowActionLanguage(node, column) {
|
|
1801
|
+
let data = { node, column, data: node.data, rowIndex: node.rowIndex, gridType: null };
|
|
1802
|
+
if (this.masterDetail) {
|
|
1803
|
+
data = { ...data, gridType: this.gridType, masterNode: this.masterNode };
|
|
1804
|
+
}
|
|
1805
|
+
this.onRowLanguage.emit(data);
|
|
1806
|
+
}
|
|
1807
|
+
invokeRowActionCellOption(node, column) {
|
|
1808
|
+
let data = { node, column, data: node.data, rowIndex: node.rowIndex, gridType: null };
|
|
1809
|
+
if (this.masterDetail) {
|
|
1810
|
+
data = { ...data, gridType: this.gridType, masterNode: this.masterNode };
|
|
1811
|
+
}
|
|
1812
|
+
this.onRowCellOption.emit(data);
|
|
1813
|
+
}
|
|
1814
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridRowActionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1815
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.12", type: OneGridRowActionComponent, selector: "one-grid-row-action", inputs: { column: "column", node: "node", allowedEdit: "allowedEdit", masterDetail: "masterDetail", masterNode: "masterNode", cellRendererParams: "cellRendererParams", gridType: "gridType", context: "context" }, outputs: { onRowGotoDetail: "onRowGotoDetail", onRowAddNew: "onRowAddNew", onRowView: "onRowView", onRowLocation: "onRowLocation", onRowDocument: "onRowDocument", onRowCopy: "onRowCopy", onRowDelete: "onRowDelete", onRowGotoList: "onRowGotoList", onRowEdit: "onRowEdit", onRowPrint: "onRowPrint", onRowHistory: "onRowHistory", onRowOption: "onRowOption", onRowLanguage: "onRowLanguage", onRowCellOption: "onRowCellOption" }, ngImport: i0, template: "@if ((cellRendererParams && node?.leaf && !column?.autoGroupField && !(node.group && node.leafGroup)) || (column?.rowActionLevels?.includes(node.level) && column?.autoGroupField)) {\n <div class=\"btn-action-container\">\n\n <!-- Expansion Button Status -->\n @if ((cellRendererParams?.detailActiveButtonStatus == 1 && !(detailActiveExcludeLevels?.has(node.level)))) {\n <a\n class=\"me-2\"\n [attr.aria-label]=\"node.detailActive ? 'Collapse row' : 'Expand row'\"\n [title]=\"node.detailActive ? 'Collapse' : 'Expand'\"\n (click)=\"invokeRowToggleDetailActiveExpand(node)\">\n\n <i class=\"bi\" [ngClass]=\"{ 'bi-chevron-down': node.detailActive, 'bi-chevron-right': !node.detailActive }\"></i>\n </a>\n }\n\n <!-- Goto Detail Button Status -->\n @if ((cellRendererParams?.gotoDetailButtonStatus == 1 && !(gotoDetailExcludeLevels?.has(node.level))) && (!column?.hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n (click)=\"invokeRowActionGotoDetail(node, column)\">\n\n <i class=\"bi bi-list-task\"></i>\n </button>\n }\n\n <!-- Add New Button Status -->\n @if ((cellRendererParams?.addNewButtonStatus == 1 && !(addNewExcludeLevels?.has(node.level))) && (!column?.hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"!allowedEdit\"\n (click)=\"invokeRowActionAddNew(node, column)\">\n\n <i class=\"bi bi-plus\"></i>\n </button>\n }\n\n <!-- View Button Status -->\n @if (cellRendererParams?.viewButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n (click)=\"invokeRowActionView(node, column)\">\n\n <i class=\"bi bi-eye\"></i>\n </button>\n }\n @if (cellRendererParams?.locationButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n (click)=\"invokeRowActionLocation(node, column)\">\n\n <i class=\"bi bi-geo-alt\"></i>\n </button>\n }\n\n <!-- Document Button Status -->\n @if (cellRendererParams?.documentButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n (click)=\"invokeRowActionDocument(node, column)\">\n\n <i class=\"bi bi-file-earmark-text\"></i>\n </button>\n }\n\n <!-- Copy Button Status -->\n @if (cellRendererParams?.copyButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n (click)=\"invokeRowActionCopy(node, column)\">\n\n <i class=\"bi bi-files\"></i>\n </button>\n }\n\n\n <!-- Delete Button Status -->\n @if (cellRendererParams?.deleteButtonStatus == 1 && (!column?.hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-danger\"\n [class.disabled]=\"!allowedEdit\"\n (click)=\"invokeRowActionDelete(node, column)\">\n\n <i class=\"bi bi-trash3\"></i>\n </button>\n }\n\n <!-- Goto List Button Status -->\n @if (cellRendererParams?.gotoListButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-success\"\n (click)=\"invokeRowActionGotoList(node, column)\">\n\n <i class=\"bi bi-list-ul\"></i>\n </button>\n }\n\n <!-- Edit Button Status -->\n @if (cellRendererParams?.editButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"node | cellDisableResolver:column:context:allowedEdit\"\n (click)=\"invokeRowActionEdit(node, column)\">\n\n <i class=\"bi bi-pencil\"></i>\n </button>\n }\n\n <!-- Print Button Status -->\n @if (cellRendererParams?.printButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"node | cellDisableResolver:column:context:allowedEdit\"\n (click)=\"invokeRowActionPrint(node, column)\">\n\n <i class=\"bi bi-printer\"></i>\n </button>\n }\n\n <!-- History Button Status -->\n @if (cellRendererParams?.historyButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"node | cellDisableResolver:column:context:allowedEdit\"\n (click)=\"invokeRowActionHistory(node, column)\">\n\n <i class=\"bi bi-clock-history\"></i>\n </button>\n }\n\n <!-- Option Button Status -->\n @if (cellRendererParams?.optionButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"node | cellDisableResolver:column:context:allowedEdit\"\n (click)=\"invokeRowActionOption(node, column)\">\n\n <i class=\"bi bi-three-dots-vertical\"></i>\n </button>\n }\n\n <!-- Language Button Status -->\n @if (cellRendererParams?.languageButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"node | cellDisableResolver:column:context:allowedEdit\"\n (click)=\"invokeRowActionLanguage(node, column)\">\n\n <i class=\"bi bi-translate\"></i>\n </button>\n }\n\n <!-- Cell Optoion Button Status (Context Menu) -->\n @if (cellRendererParams?.cellOptionButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary border-0 text-body\"\n [style.background]=\"'transparent'\"\n [class.disabled]=\"node | cellDisableResolver:column:context:allowedEdit\"\n (click)=\"invokeRowActionCellOption(node, column)\">\n\n <i class=\"bi bi-three-dots-vertical\"></i>\n </button>\n }\n </div>\n}", styles: [""], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "pipe", type: CellDisableResolverPipe, name: "cellDisableResolver" }] }); }
|
|
1816
|
+
}
|
|
1817
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridRowActionComponent, decorators: [{
|
|
1818
|
+
type: Component,
|
|
1819
|
+
args: [{ standalone: false, selector: 'one-grid-row-action', template: "@if ((cellRendererParams && node?.leaf && !column?.autoGroupField && !(node.group && node.leafGroup)) || (column?.rowActionLevels?.includes(node.level) && column?.autoGroupField)) {\n <div class=\"btn-action-container\">\n\n <!-- Expansion Button Status -->\n @if ((cellRendererParams?.detailActiveButtonStatus == 1 && !(detailActiveExcludeLevels?.has(node.level)))) {\n <a\n class=\"me-2\"\n [attr.aria-label]=\"node.detailActive ? 'Collapse row' : 'Expand row'\"\n [title]=\"node.detailActive ? 'Collapse' : 'Expand'\"\n (click)=\"invokeRowToggleDetailActiveExpand(node)\">\n\n <i class=\"bi\" [ngClass]=\"{ 'bi-chevron-down': node.detailActive, 'bi-chevron-right': !node.detailActive }\"></i>\n </a>\n }\n\n <!-- Goto Detail Button Status -->\n @if ((cellRendererParams?.gotoDetailButtonStatus == 1 && !(gotoDetailExcludeLevels?.has(node.level))) && (!column?.hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n (click)=\"invokeRowActionGotoDetail(node, column)\">\n\n <i class=\"bi bi-list-task\"></i>\n </button>\n }\n\n <!-- Add New Button Status -->\n @if ((cellRendererParams?.addNewButtonStatus == 1 && !(addNewExcludeLevels?.has(node.level))) && (!column?.hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"!allowedEdit\"\n (click)=\"invokeRowActionAddNew(node, column)\">\n\n <i class=\"bi bi-plus\"></i>\n </button>\n }\n\n <!-- View Button Status -->\n @if (cellRendererParams?.viewButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n (click)=\"invokeRowActionView(node, column)\">\n\n <i class=\"bi bi-eye\"></i>\n </button>\n }\n @if (cellRendererParams?.locationButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n (click)=\"invokeRowActionLocation(node, column)\">\n\n <i class=\"bi bi-geo-alt\"></i>\n </button>\n }\n\n <!-- Document Button Status -->\n @if (cellRendererParams?.documentButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n (click)=\"invokeRowActionDocument(node, column)\">\n\n <i class=\"bi bi-file-earmark-text\"></i>\n </button>\n }\n\n <!-- Copy Button Status -->\n @if (cellRendererParams?.copyButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n (click)=\"invokeRowActionCopy(node, column)\">\n\n <i class=\"bi bi-files\"></i>\n </button>\n }\n\n\n <!-- Delete Button Status -->\n @if (cellRendererParams?.deleteButtonStatus == 1 && (!column?.hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-danger\"\n [class.disabled]=\"!allowedEdit\"\n (click)=\"invokeRowActionDelete(node, column)\">\n\n <i class=\"bi bi-trash3\"></i>\n </button>\n }\n\n <!-- Goto List Button Status -->\n @if (cellRendererParams?.gotoListButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-success\"\n (click)=\"invokeRowActionGotoList(node, column)\">\n\n <i class=\"bi bi-list-ul\"></i>\n </button>\n }\n\n <!-- Edit Button Status -->\n @if (cellRendererParams?.editButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"node | cellDisableResolver:column:context:allowedEdit\"\n (click)=\"invokeRowActionEdit(node, column)\">\n\n <i class=\"bi bi-pencil\"></i>\n </button>\n }\n\n <!-- Print Button Status -->\n @if (cellRendererParams?.printButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"node | cellDisableResolver:column:context:allowedEdit\"\n (click)=\"invokeRowActionPrint(node, column)\">\n\n <i class=\"bi bi-printer\"></i>\n </button>\n }\n\n <!-- History Button Status -->\n @if (cellRendererParams?.historyButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"node | cellDisableResolver:column:context:allowedEdit\"\n (click)=\"invokeRowActionHistory(node, column)\">\n\n <i class=\"bi bi-clock-history\"></i>\n </button>\n }\n\n <!-- Option Button Status -->\n @if (cellRendererParams?.optionButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"node | cellDisableResolver:column:context:allowedEdit\"\n (click)=\"invokeRowActionOption(node, column)\">\n\n <i class=\"bi bi-three-dots-vertical\"></i>\n </button>\n }\n\n <!-- Language Button Status -->\n @if (cellRendererParams?.languageButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"node | cellDisableResolver:column:context:allowedEdit\"\n (click)=\"invokeRowActionLanguage(node, column)\">\n\n <i class=\"bi bi-translate\"></i>\n </button>\n }\n\n <!-- Cell Optoion Button Status (Context Menu) -->\n @if (cellRendererParams?.cellOptionButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary border-0 text-body\"\n [style.background]=\"'transparent'\"\n [class.disabled]=\"node | cellDisableResolver:column:context:allowedEdit\"\n (click)=\"invokeRowActionCellOption(node, column)\">\n\n <i class=\"bi bi-three-dots-vertical\"></i>\n </button>\n }\n </div>\n}" }]
|
|
1820
|
+
}], propDecorators: { column: [{
|
|
1821
|
+
type: Input,
|
|
1822
|
+
args: [{ required: true }]
|
|
1823
|
+
}], node: [{
|
|
1824
|
+
type: Input,
|
|
1825
|
+
args: [{ required: true }]
|
|
1826
|
+
}], allowedEdit: [{
|
|
1827
|
+
type: Input,
|
|
1828
|
+
args: [{ required: true }]
|
|
1829
|
+
}], masterDetail: [{
|
|
1830
|
+
type: Input
|
|
1831
|
+
}], masterNode: [{
|
|
1832
|
+
type: Input
|
|
1833
|
+
}], cellRendererParams: [{
|
|
1834
|
+
type: Input
|
|
1835
|
+
}], gridType: [{
|
|
1836
|
+
type: Input
|
|
1837
|
+
}], context: [{
|
|
1838
|
+
type: Input
|
|
1839
|
+
}], onRowGotoDetail: [{
|
|
1840
|
+
type: Output
|
|
1841
|
+
}], onRowAddNew: [{
|
|
1842
|
+
type: Output
|
|
1843
|
+
}], onRowView: [{
|
|
1844
|
+
type: Output
|
|
1845
|
+
}], onRowLocation: [{
|
|
1846
|
+
type: Output
|
|
1847
|
+
}], onRowDocument: [{
|
|
1848
|
+
type: Output
|
|
1849
|
+
}], onRowCopy: [{
|
|
1850
|
+
type: Output
|
|
1851
|
+
}], onRowDelete: [{
|
|
1852
|
+
type: Output
|
|
1853
|
+
}], onRowGotoList: [{
|
|
1854
|
+
type: Output
|
|
1855
|
+
}], onRowEdit: [{
|
|
1856
|
+
type: Output
|
|
1857
|
+
}], onRowPrint: [{
|
|
1858
|
+
type: Output
|
|
1859
|
+
}], onRowHistory: [{
|
|
1860
|
+
type: Output
|
|
1861
|
+
}], onRowOption: [{
|
|
1862
|
+
type: Output
|
|
1863
|
+
}], onRowLanguage: [{
|
|
1864
|
+
type: Output
|
|
1865
|
+
}], onRowCellOption: [{
|
|
1866
|
+
type: Output
|
|
1867
|
+
}] } });
|
|
1868
|
+
|
|
1869
|
+
class OneGridCellGroupRendererComponent {
|
|
1870
|
+
constructor() {
|
|
1871
|
+
this.masterDetail = false;
|
|
1872
|
+
this.expansionChanged = new EventEmitter();
|
|
1873
|
+
}
|
|
1874
|
+
invokeChangedClick() {
|
|
1875
|
+
// if (this.masterDetail && !this.node.expanded) {
|
|
1876
|
+
// this.detailCellRendererParams.getDetailRowData({ data: this.node.data, node: this.node, successCallback: (rows) => { this.node.setDetailRowData(rows) }});
|
|
1877
|
+
// }
|
|
1878
|
+
this.expansionChanged.emit({ rowIndex: this.node.rowIndex, data: this.node.data, node: this.node });
|
|
1879
|
+
}
|
|
1880
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridCellGroupRendererComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1881
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.12", type: OneGridCellGroupRendererComponent, selector: "one-grid-cell-group-renderer", inputs: { node: "node", masterDetail: "masterDetail", detailCellRendererParams: "detailCellRendererParams", detailRendererComponent: "detailRendererComponent" }, outputs: { expansionChanged: "expansionChanged" }, ngImport: i0, template: "@if (node.expandable) {\n <span class=\"cell-group-renderer\" [style.padding-left.px]=\"6\" (click)=\"invokeChangedClick()\">\n @if (node.children?.length > 0 || masterDetail) {\n <i [class.node-expanded]=\"node.expanded\" class=\"bi bi-chevron-right expansion-icon\"></i>\n }\n </span>\n}\n", styles: [""] }); }
|
|
1882
|
+
}
|
|
1883
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridCellGroupRendererComponent, decorators: [{
|
|
1884
|
+
type: Component,
|
|
1885
|
+
args: [{ standalone: false, selector: 'one-grid-cell-group-renderer', template: "@if (node.expandable) {\n <span class=\"cell-group-renderer\" [style.padding-left.px]=\"6\" (click)=\"invokeChangedClick()\">\n @if (node.children?.length > 0 || masterDetail) {\n <i [class.node-expanded]=\"node.expanded\" class=\"bi bi-chevron-right expansion-icon\"></i>\n }\n </span>\n}\n" }]
|
|
1886
|
+
}], propDecorators: { node: [{
|
|
1887
|
+
type: Input
|
|
1888
|
+
}], masterDetail: [{
|
|
1889
|
+
type: Input
|
|
1890
|
+
}], detailCellRendererParams: [{
|
|
1891
|
+
type: Input
|
|
1892
|
+
}], detailRendererComponent: [{
|
|
1893
|
+
type: Input
|
|
1894
|
+
}], expansionChanged: [{
|
|
1895
|
+
type: Output
|
|
1896
|
+
}] } });
|
|
1897
|
+
|
|
1898
|
+
class OneCellInputValidatorDirective {
|
|
1899
|
+
constructor(el) {
|
|
1900
|
+
this.el = el;
|
|
1901
|
+
this.regex = '';
|
|
1902
|
+
this.MAX_CODE_LENGTH = 36;
|
|
1903
|
+
this.KHMER_CHARACTER_RANGE = /[\u1780-\u17FF]/;
|
|
1904
|
+
}
|
|
1905
|
+
onKeyPress(event) {
|
|
1906
|
+
let isValid = false;
|
|
1907
|
+
const char = event.key;
|
|
1908
|
+
const inputElement = this.el.nativeElement;
|
|
1909
|
+
switch (this.validationType) {
|
|
1910
|
+
case 'disabled':
|
|
1911
|
+
event.preventDefault();
|
|
1912
|
+
return;
|
|
1913
|
+
case 'integer':
|
|
1914
|
+
isValid = /^\d+$/.test(char);
|
|
1915
|
+
break;
|
|
1916
|
+
case 'code':
|
|
1917
|
+
isValid = /[a-zA-Z\d]/.test(char);
|
|
1918
|
+
if (isValid) {
|
|
1919
|
+
event.preventDefault();
|
|
1920
|
+
if (inputElement.value.length < this.MAX_CODE_LENGTH) {
|
|
1921
|
+
inputElement.value += char.toUpperCase();
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
return;
|
|
1925
|
+
case 'title':
|
|
1926
|
+
isValid = /^[a-zA-Z\s\d]+$/.test(char) || this.KHMER_CHARACTER_RANGE.test(char);
|
|
1927
|
+
break;
|
|
1928
|
+
case 'number':
|
|
1929
|
+
isValid = /^[0-9.]$/.test(char) && !(char === '.' && inputElement.value.includes('.'));
|
|
1930
|
+
break;
|
|
1931
|
+
case 'regex':
|
|
1932
|
+
isValid = this.regex ? new RegExp(this.regex).test(char) : false;
|
|
1933
|
+
break;
|
|
1934
|
+
default:
|
|
1935
|
+
isValid = true;
|
|
1936
|
+
}
|
|
1937
|
+
if (!isValid) {
|
|
1938
|
+
event.preventDefault();
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
onKeyDown(event) {
|
|
1942
|
+
if (this.validationType === 'disabled') {
|
|
1943
|
+
event.preventDefault();
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneCellInputValidatorDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1947
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.12", type: OneCellInputValidatorDirective, selector: "[oneCellInputValidator]", inputs: { validationType: "validationType", regex: "regex" }, host: { listeners: { "keypress": "onKeyPress($event)", "keydown": "onKeyDown($event)" } }, ngImport: i0 }); }
|
|
1948
|
+
}
|
|
1949
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneCellInputValidatorDirective, decorators: [{
|
|
1950
|
+
type: Directive,
|
|
1951
|
+
args: [{
|
|
1952
|
+
standalone: false,
|
|
1953
|
+
selector: '[oneCellInputValidator]'
|
|
1954
|
+
}]
|
|
1955
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { validationType: [{
|
|
1956
|
+
type: Input
|
|
1957
|
+
}], regex: [{
|
|
1958
|
+
type: Input
|
|
1959
|
+
}], onKeyPress: [{
|
|
1960
|
+
type: HostListener,
|
|
1961
|
+
args: ['keypress', ['$event']]
|
|
1962
|
+
}], onKeyDown: [{
|
|
1963
|
+
type: HostListener,
|
|
1964
|
+
args: ['keydown', ['$event']]
|
|
1965
|
+
}] } });
|
|
1966
|
+
|
|
1967
|
+
class OneCellRendererComponentDirective {
|
|
1968
|
+
constructor(vcr) {
|
|
1969
|
+
this.vcr = vcr;
|
|
1970
|
+
this.initialized = false;
|
|
1971
|
+
}
|
|
1972
|
+
ngOnInit() {
|
|
1973
|
+
this.initialized = true;
|
|
1974
|
+
this.createOrUpdateComponent(true);
|
|
1975
|
+
}
|
|
1976
|
+
ngOnChanges(changes) {
|
|
1977
|
+
if (!this.initialized)
|
|
1978
|
+
return;
|
|
1979
|
+
const componentChanged = changes['cellRendererComponent'];
|
|
1980
|
+
const paramsChanged = changes['params'];
|
|
1981
|
+
if (componentChanged) {
|
|
1982
|
+
this.destroyComponent();
|
|
1983
|
+
this.createOrUpdateComponent(true);
|
|
1984
|
+
}
|
|
1985
|
+
else if (paramsChanged) {
|
|
1986
|
+
this.updateComponentInputs();
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
createOrUpdateComponent(forceCreate = false) {
|
|
1990
|
+
if (!this.cellRendererComponent)
|
|
1991
|
+
return;
|
|
1992
|
+
if (forceCreate || !this.compRef) {
|
|
1993
|
+
this.vcr.clear();
|
|
1994
|
+
this.compRef = this.vcr.createComponent(this.cellRendererComponent);
|
|
1995
|
+
}
|
|
1996
|
+
this.updateComponentInputs();
|
|
1997
|
+
}
|
|
1998
|
+
updateComponentInputs() {
|
|
1999
|
+
if (!this.compRef?.instance)
|
|
2000
|
+
return;
|
|
2001
|
+
const instance = this.compRef.instance;
|
|
2002
|
+
if (typeof instance.oneInit === 'function') {
|
|
2003
|
+
const newParams = { ...this.params };
|
|
2004
|
+
newParams.value = getFieldValue(this.params.data, this.params?.columnDef?.field) ?? null;
|
|
2005
|
+
instance.oneInit(newParams);
|
|
2006
|
+
}
|
|
2007
|
+
else {
|
|
2008
|
+
Object.assign(instance, this.params);
|
|
2009
|
+
}
|
|
2010
|
+
// Optional: call change detector if needed
|
|
2011
|
+
// if (this.compRef.changeDetectorRef) {
|
|
2012
|
+
// this.compRef.changeDetectorRef.detectChanges();
|
|
2013
|
+
// }
|
|
2014
|
+
}
|
|
2015
|
+
destroyComponent() {
|
|
2016
|
+
if (this.compRef) {
|
|
2017
|
+
this.compRef.destroy();
|
|
2018
|
+
this.compRef = undefined;
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
ngOnDestroy() {
|
|
2022
|
+
this.destroyComponent();
|
|
2023
|
+
}
|
|
2024
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneCellRendererComponentDirective, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
2025
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.12", type: OneCellRendererComponentDirective, selector: "[oneCellRendererComponent]", inputs: { cellRendererComponent: "cellRendererComponent", params: "params" }, usesOnChanges: true, ngImport: i0 }); }
|
|
2026
|
+
}
|
|
2027
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneCellRendererComponentDirective, decorators: [{
|
|
2028
|
+
type: Directive,
|
|
2029
|
+
args: [{
|
|
2030
|
+
standalone: false,
|
|
2031
|
+
selector: '[oneCellRendererComponent]'
|
|
2032
|
+
}]
|
|
2033
|
+
}], ctorParameters: () => [{ type: i0.ViewContainerRef }], propDecorators: { cellRendererComponent: [{
|
|
2034
|
+
type: Input,
|
|
2035
|
+
args: [{ required: true }]
|
|
2036
|
+
}], params: [{
|
|
2037
|
+
type: Input,
|
|
2038
|
+
args: [{ required: true }]
|
|
2039
|
+
}] } });
|
|
2040
|
+
|
|
2041
|
+
class OneCellTextExpandDirective {
|
|
2042
|
+
constructor(cell, renderer) {
|
|
2043
|
+
this.cell = cell;
|
|
2044
|
+
this.renderer = renderer;
|
|
2045
|
+
this.overflowing = false;
|
|
2046
|
+
this.lastText = null;
|
|
2047
|
+
}
|
|
2048
|
+
ngAfterViewInit() {
|
|
2049
|
+
this.checkOverflow();
|
|
2050
|
+
this.lastText = this.cell.nativeElement.textContent;
|
|
2051
|
+
}
|
|
2052
|
+
ngAfterViewChecked() {
|
|
2053
|
+
const currentText = this.cell.nativeElement.textContent;
|
|
2054
|
+
if (this.lastText !== currentText) {
|
|
2055
|
+
this.lastText = currentText;
|
|
2056
|
+
this.checkOverflow();
|
|
2057
|
+
this.collapse();
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
ngOnDestroy() {
|
|
2061
|
+
clearTimeout(this.timer);
|
|
2062
|
+
this.collapse();
|
|
2063
|
+
}
|
|
2064
|
+
checkOverflow() {
|
|
2065
|
+
const cell = this.cell.nativeElement;
|
|
2066
|
+
this.overflowing = cell.scrollWidth > cell.clientWidth;
|
|
2067
|
+
}
|
|
2068
|
+
onResize() {
|
|
2069
|
+
this.checkOverflow();
|
|
2070
|
+
}
|
|
2071
|
+
onMouseEnter() {
|
|
2072
|
+
if (!this.overflowing)
|
|
2073
|
+
return;
|
|
2074
|
+
this.timer = setTimeout(() => this.expand(), 800);
|
|
2075
|
+
}
|
|
2076
|
+
onMouseLeave() {
|
|
2077
|
+
clearTimeout(this.timer);
|
|
2078
|
+
this.collapse();
|
|
2079
|
+
}
|
|
2080
|
+
expand() {
|
|
2081
|
+
const cell = this.cell.nativeElement;
|
|
2082
|
+
this.renderer.setStyle(cell, 'overflow', 'visible');
|
|
2083
|
+
this.renderer.setStyle(cell, 'text-overflow', 'unset');
|
|
2084
|
+
this.renderer.setStyle(cell, 'z-index', '1000');
|
|
2085
|
+
this.renderer.setStyle(cell, 'background', 'var(--ins-card-bg)');
|
|
2086
|
+
this.renderer.setStyle(cell, 'white-space', 'nowrap');
|
|
2087
|
+
this.renderer.setStyle(cell, 'transition', 'width 0.3s ease');
|
|
2088
|
+
this.renderer.setStyle(cell, 'padding', '4px 8px');
|
|
2089
|
+
this.renderer.setStyle(cell, 'border-radius', '4px');
|
|
2090
|
+
}
|
|
2091
|
+
collapse() {
|
|
2092
|
+
const cell = this.cell.nativeElement;
|
|
2093
|
+
this.renderer.setStyle(cell, 'white-space', 'nowrap');
|
|
2094
|
+
this.renderer.setStyle(cell, 'overflow', 'hidden');
|
|
2095
|
+
this.renderer.setStyle(cell, 'text-overflow', 'ellipsis');
|
|
2096
|
+
this.renderer.removeStyle(cell, 'z-index');
|
|
2097
|
+
this.renderer.removeStyle(cell, 'background');
|
|
2098
|
+
this.renderer.removeStyle(cell, 'padding');
|
|
2099
|
+
this.renderer.removeStyle(cell, 'border-radius');
|
|
2100
|
+
}
|
|
2101
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneCellTextExpandDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
2102
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.12", type: OneCellTextExpandDirective, selector: "[oneCellTextExpand]", host: { listeners: { "window:resize": "onResize()", "mouseenter": "onMouseEnter()", "mouseleave": "onMouseLeave()" } }, ngImport: i0 }); }
|
|
2103
|
+
}
|
|
2104
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneCellTextExpandDirective, decorators: [{
|
|
2105
|
+
type: Directive,
|
|
2106
|
+
args: [{
|
|
2107
|
+
standalone: false,
|
|
2108
|
+
selector: '[oneCellTextExpand]'
|
|
2109
|
+
}]
|
|
2110
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { onResize: [{
|
|
2111
|
+
type: HostListener,
|
|
2112
|
+
args: ['window:resize']
|
|
2113
|
+
}], onMouseEnter: [{
|
|
2114
|
+
type: HostListener,
|
|
2115
|
+
args: ['mouseenter']
|
|
2116
|
+
}], onMouseLeave: [{
|
|
2117
|
+
type: HostListener,
|
|
2118
|
+
args: ['mouseleave']
|
|
2119
|
+
}] } });
|
|
2120
|
+
|
|
2121
|
+
class OneGridCellOptionMenuComponent {
|
|
2122
|
+
constructor(elementRef) {
|
|
2123
|
+
this.elementRef = elementRef;
|
|
2124
|
+
this.column = null;
|
|
2125
|
+
this.node = null;
|
|
2126
|
+
this.options = [];
|
|
2127
|
+
this.cellOptionMenuSelect = new EventEmitter();
|
|
2128
|
+
this.cellOptionMenuClose = new EventEmitter();
|
|
2129
|
+
}
|
|
2130
|
+
// Click outside
|
|
2131
|
+
onDocumentClick(event) {
|
|
2132
|
+
const target = event.target;
|
|
2133
|
+
if (!this.elementRef.nativeElement.contains(target)) {
|
|
2134
|
+
this.close();
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
// Escape key
|
|
2138
|
+
onEscape() {
|
|
2139
|
+
this.close();
|
|
2140
|
+
}
|
|
2141
|
+
// Scroll closes menu (prevents misalignment)
|
|
2142
|
+
onScroll() {
|
|
2143
|
+
this.close();
|
|
2144
|
+
}
|
|
2145
|
+
// Option selected
|
|
2146
|
+
onOptionSelected(option) {
|
|
2147
|
+
this.cellOptionMenuSelect.emit({
|
|
2148
|
+
column: this.column,
|
|
2149
|
+
node: this.node,
|
|
2150
|
+
option: option
|
|
2151
|
+
});
|
|
2152
|
+
this.close();
|
|
2153
|
+
}
|
|
2154
|
+
// Single close method
|
|
2155
|
+
close() {
|
|
2156
|
+
this.node.cellOptions[this.column.field] = false;
|
|
2157
|
+
this.cellOptionMenuClose.emit();
|
|
2158
|
+
}
|
|
2159
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridCellOptionMenuComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2160
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.12", type: OneGridCellOptionMenuComponent, selector: "one-grid-cell-option-menu", inputs: { column: "column", node: "node", options: "options" }, outputs: { cellOptionMenuSelect: "cellOptionMenuSelect", cellOptionMenuClose: "cellOptionMenuClose" }, host: { listeners: { "document:click": "onDocumentClick($event)", "document:keydown.escape": "onEscape()", "document:scroll": "onScroll()" } }, ngImport: i0, template: "<div class=\"cell-option-menu\" #menuEl>\n @for (opt of options; track opt.value) {\n <div class=\"cell-option-menu-item\" (click)=\"onOptionSelected(opt)\">\n <!-- <span [style.padding-right.px]=\"8\"><lucide-icon name=\"check\" [size]=\"16\" [strokeWidth]=\"2\"></lucide-icon></span> -->\n <span>{{ opt.text }}</span> \n </div>\n }\n</div>", styles: [""] }); }
|
|
2161
|
+
}
|
|
2162
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridCellOptionMenuComponent, decorators: [{
|
|
2163
|
+
type: Component,
|
|
2164
|
+
args: [{ selector: 'one-grid-cell-option-menu', standalone: false, template: "<div class=\"cell-option-menu\" #menuEl>\n @for (opt of options; track opt.value) {\n <div class=\"cell-option-menu-item\" (click)=\"onOptionSelected(opt)\">\n <!-- <span [style.padding-right.px]=\"8\"><lucide-icon name=\"check\" [size]=\"16\" [strokeWidth]=\"2\"></lucide-icon></span> -->\n <span>{{ opt.text }}</span> \n </div>\n }\n</div>" }]
|
|
2165
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { column: [{
|
|
2166
|
+
type: Input
|
|
2167
|
+
}], node: [{
|
|
2168
|
+
type: Input
|
|
2169
|
+
}], options: [{
|
|
2170
|
+
type: Input
|
|
2171
|
+
}], cellOptionMenuSelect: [{
|
|
2172
|
+
type: Output
|
|
2173
|
+
}], cellOptionMenuClose: [{
|
|
2174
|
+
type: Output
|
|
2175
|
+
}], onDocumentClick: [{
|
|
2176
|
+
type: HostListener,
|
|
2177
|
+
args: ['document:click', ['$event']]
|
|
2178
|
+
}], onEscape: [{
|
|
2179
|
+
type: HostListener,
|
|
2180
|
+
args: ['document:keydown.escape']
|
|
2181
|
+
}], onScroll: [{
|
|
2182
|
+
type: HostListener,
|
|
2183
|
+
args: ['document:scroll']
|
|
2184
|
+
}] } });
|
|
2185
|
+
|
|
2186
|
+
class CellInvalidPipe {
|
|
2187
|
+
transform(cellStates, value, column, node, allowedEdit, submitted) {
|
|
2188
|
+
if (!column.validationRules?.length) {
|
|
2189
|
+
return false;
|
|
2190
|
+
}
|
|
2191
|
+
return getCellError(column, node, value, node.data) !== null && !(node.editing[column.field]) && !(column?.cellRendererParams?.validateSelectedRowOnly && !node?.selected) && allowedEdit && submitted;
|
|
2192
|
+
}
|
|
2193
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellInvalidPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2194
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: CellInvalidPipe, name: "cellInvalid" }); }
|
|
2195
|
+
}
|
|
2196
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellInvalidPipe, decorators: [{
|
|
2197
|
+
type: Pipe,
|
|
2198
|
+
args: [{
|
|
2199
|
+
standalone: false,
|
|
2200
|
+
name: 'cellInvalid'
|
|
2201
|
+
}]
|
|
2202
|
+
}] });
|
|
2203
|
+
|
|
2204
|
+
class CellSelectedPipe {
|
|
2205
|
+
transform(selectedCells, rowId, field) {
|
|
2206
|
+
if (!selectedCells)
|
|
2207
|
+
return false;
|
|
2208
|
+
return selectedCells.has(getCellKey(rowId, field));
|
|
2209
|
+
}
|
|
2210
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellSelectedPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2211
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: CellSelectedPipe, name: "cellSelected" }); }
|
|
2212
|
+
}
|
|
2213
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellSelectedPipe, decorators: [{
|
|
2214
|
+
type: Pipe,
|
|
2215
|
+
args: [{
|
|
2216
|
+
standalone: false,
|
|
2217
|
+
name: 'cellSelected'
|
|
2218
|
+
}]
|
|
2219
|
+
}] });
|
|
2220
|
+
|
|
2221
|
+
class CellActionButtonEnablePipe {
|
|
2222
|
+
transform(params) {
|
|
2223
|
+
if (!params) {
|
|
2224
|
+
return false;
|
|
2225
|
+
}
|
|
2226
|
+
const statusValues = Object.values(params);
|
|
2227
|
+
return statusValues.some(status => status === 1);
|
|
2228
|
+
}
|
|
2229
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellActionButtonEnablePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2230
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: CellActionButtonEnablePipe, name: "cellActionButtonEnable" }); }
|
|
2231
|
+
}
|
|
2232
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellActionButtonEnablePipe, decorators: [{
|
|
2233
|
+
type: Pipe,
|
|
2234
|
+
args: [{
|
|
2235
|
+
standalone: false,
|
|
2236
|
+
name: 'cellActionButtonEnable'
|
|
2237
|
+
}]
|
|
2238
|
+
}] });
|
|
2239
|
+
|
|
2240
|
+
class CellKeyPipe {
|
|
2241
|
+
transform(rowId, field) {
|
|
2242
|
+
if (!rowId || !field) {
|
|
2243
|
+
return '';
|
|
2244
|
+
}
|
|
2245
|
+
return getCellKey(rowId, field);
|
|
2246
|
+
}
|
|
2247
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellKeyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2248
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: CellKeyPipe, name: "cellKey" }); }
|
|
2249
|
+
}
|
|
2250
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellKeyPipe, decorators: [{
|
|
2251
|
+
type: Pipe,
|
|
2252
|
+
args: [{
|
|
2253
|
+
standalone: false,
|
|
2254
|
+
name: 'cellKey'
|
|
2255
|
+
}]
|
|
2256
|
+
}] });
|
|
2257
|
+
|
|
2258
|
+
class CellLevelPaddingPipe {
|
|
2259
|
+
transform(level, factor) {
|
|
2260
|
+
level += 1;
|
|
2261
|
+
return level * factor;
|
|
2262
|
+
}
|
|
2263
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellLevelPaddingPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2264
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: CellLevelPaddingPipe, name: "cellLevelPadding" }); }
|
|
2265
|
+
}
|
|
2266
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellLevelPaddingPipe, decorators: [{
|
|
2267
|
+
type: Pipe,
|
|
2268
|
+
args: [{
|
|
2269
|
+
standalone: false,
|
|
2270
|
+
name: 'cellLevelPadding'
|
|
2271
|
+
}]
|
|
2272
|
+
}] });
|
|
2273
|
+
|
|
2274
|
+
class CellStateRendererPipe {
|
|
2275
|
+
transform(cellStates, field) {
|
|
2276
|
+
const value = cellStates?.[field]?.value;
|
|
2277
|
+
if (value === null || value === undefined) {
|
|
2278
|
+
return null;
|
|
2279
|
+
}
|
|
2280
|
+
if (typeof value === 'string' && value.trim() === '') {
|
|
2281
|
+
return null;
|
|
2282
|
+
}
|
|
2283
|
+
return value;
|
|
2284
|
+
}
|
|
2285
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellStateRendererPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2286
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: CellStateRendererPipe, name: "cellStateRenderer" }); }
|
|
2287
|
+
}
|
|
2288
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellStateRendererPipe, decorators: [{
|
|
2289
|
+
type: Pipe,
|
|
2290
|
+
args: [{
|
|
2291
|
+
standalone: false,
|
|
2292
|
+
name: 'cellStateRenderer'
|
|
2293
|
+
}]
|
|
2294
|
+
}] });
|
|
2295
|
+
|
|
2296
|
+
class OneGridBodyComponent {
|
|
2297
|
+
constructor(colService, cellService, eventService, cdr) {
|
|
2298
|
+
this.colService = colService;
|
|
2299
|
+
this.cellService = cellService;
|
|
2300
|
+
this.eventService = eventService;
|
|
2301
|
+
this.cdr = cdr;
|
|
2302
|
+
this.rowData = [];
|
|
2303
|
+
this.pagination = false;
|
|
2304
|
+
this.allowedEdit = true;
|
|
2305
|
+
this.enableGroupColumnDefs = false;
|
|
2306
|
+
this.submitted = false;
|
|
2307
|
+
this.context = null;
|
|
2308
|
+
this.columnDefs = [];
|
|
2309
|
+
this.cellRenderer = false;
|
|
2310
|
+
/**
|
|
2311
|
+
* Master Detail Properties
|
|
2312
|
+
*/
|
|
2313
|
+
this.gridType = 'simple';
|
|
2314
|
+
this.masterDetail = false;
|
|
2315
|
+
this.masterNode = null;
|
|
2316
|
+
// @Input() detailRowHeight: number = null;
|
|
2317
|
+
// @Input() detailRowAutoHeight: boolean = false;
|
|
2318
|
+
this.detailRowMaxHeight = null;
|
|
2319
|
+
this.detailGridTemplate = null;
|
|
2320
|
+
/**
|
|
2321
|
+
* Tree Data Properties
|
|
2322
|
+
*/
|
|
2323
|
+
this.treeData = false;
|
|
2324
|
+
this.groupDefaultExpanded = -1; // It's work with master detail also
|
|
2325
|
+
/**
|
|
2326
|
+
* Passing Row Action Events to Parent
|
|
2327
|
+
*/
|
|
2328
|
+
this.onRowGotoDetail = new EventEmitter();
|
|
2329
|
+
this.onRowAddNew = new EventEmitter();
|
|
2330
|
+
this.onRowView = new EventEmitter();
|
|
2331
|
+
this.onRowCopy = new EventEmitter();
|
|
2332
|
+
this.onRowLocation = new EventEmitter();
|
|
2333
|
+
this.onRowDocument = new EventEmitter();
|
|
2334
|
+
this.onRowDelete = new EventEmitter();
|
|
2335
|
+
this.onRowGotoList = new EventEmitter();
|
|
2336
|
+
this.onRowEdit = new EventEmitter();
|
|
2337
|
+
this.onRowPrint = new EventEmitter();
|
|
2338
|
+
this.onRowHistory = new EventEmitter();
|
|
2339
|
+
this.onRowOption = new EventEmitter();
|
|
2340
|
+
this.onRowLanguage = new EventEmitter();
|
|
2341
|
+
this.onRowCellOption = new EventEmitter();
|
|
2342
|
+
this.onRowSelection = new EventEmitter();
|
|
2343
|
+
this.onShiftDoubleClick = new EventEmitter();
|
|
2344
|
+
this.rowCountChanged = new EventEmitter();
|
|
2345
|
+
this.expansionChanged = new EventEmitter();
|
|
2346
|
+
this.bodyScroll = new EventEmitter();
|
|
2347
|
+
this.cellOptionSelect = new EventEmitter();
|
|
2348
|
+
/**
|
|
2349
|
+
* Selection Range Variables
|
|
2350
|
+
*/
|
|
2351
|
+
this.rowWidth = 0;
|
|
2352
|
+
this.nodes = [];
|
|
2353
|
+
this.selectedCells = new Set();
|
|
2354
|
+
this.isMouseDown = false;
|
|
2355
|
+
this.startCell = null;
|
|
2356
|
+
this.lastScrollLeft = 0;
|
|
2357
|
+
this.cellEditablePipe = new CellEditablePipe();
|
|
2358
|
+
this.subscriptions = new Subscription();
|
|
2359
|
+
this.cellRendererParams = {
|
|
2360
|
+
gotoDetailButtonStatus: 1,
|
|
2361
|
+
addNewButtonStatus: 1,
|
|
2362
|
+
viewButtonStatus: 1,
|
|
2363
|
+
locationButtonStatus: 1,
|
|
2364
|
+
documentButtonStatus: 1,
|
|
2365
|
+
copyButtonStatus: 1,
|
|
2366
|
+
deleteButtonStatus: 1,
|
|
2367
|
+
gotoListButtonStatus: 1,
|
|
2368
|
+
optionButtonStatus: 1,
|
|
2369
|
+
languageButtonStatus: 1,
|
|
2370
|
+
editButtonStatus: 1,
|
|
2371
|
+
printButtonStatus: 1,
|
|
2372
|
+
historyButtonStatus: 1,
|
|
2373
|
+
};
|
|
2374
|
+
/**
|
|
2375
|
+
* Virtual Scroll Properties
|
|
2376
|
+
*/
|
|
2377
|
+
this.itemSize = 30;
|
|
2378
|
+
this.minBufferPx = 200;
|
|
2379
|
+
this.maxBufferPx = 400;
|
|
2380
|
+
}
|
|
2381
|
+
ngOnInit() {
|
|
2382
|
+
/**
|
|
2383
|
+
* Listen Grid Copy Event
|
|
2384
|
+
*/
|
|
2385
|
+
this.subscriptions.add(this.gridCopy$.subscribe((event) => {
|
|
2386
|
+
this.onGridCopy(event);
|
|
2387
|
+
}));
|
|
2388
|
+
/**
|
|
2389
|
+
* Listen Column Changed Event
|
|
2390
|
+
*/
|
|
2391
|
+
this.subscriptions.add(this.eventService.addEventListener('columnChanged', (payload) => {
|
|
2392
|
+
this.columnDefs = [...payload.columns];
|
|
2393
|
+
this.cellRenderer = this.columnDefs.some(col => col.cellRendererComponent);
|
|
2394
|
+
this.rowWidth = this.columnDefs.reduce((sum, col) => sum + (col.width ? col.width > col.maxWidth ? col.maxWidth : col.width < col.minWidth ? col.minWidth : col.width : col.minWidth), 0);
|
|
2395
|
+
this.cdr.markForCheck();
|
|
2396
|
+
}));
|
|
2397
|
+
/**
|
|
2398
|
+
* Listen Row Data Changed Event
|
|
2399
|
+
*/
|
|
2400
|
+
this.subscriptions.add(this.eventService.addEventListener('rowDataChanged', ({ nodes }) => {
|
|
2401
|
+
this.rowCountChanged.emit(nodes?.length ?? 0);
|
|
2402
|
+
setTimeout(() => {
|
|
2403
|
+
this.viewport?.checkViewportSize();
|
|
2404
|
+
this.setVirtualScroll(nodes?.length);
|
|
2405
|
+
if (this.masterDetail) {
|
|
2406
|
+
this.nodes = nodes.map((node) => {
|
|
2407
|
+
if (node.leaf && this.detailRendererComponent) {
|
|
2408
|
+
node.detailRendererComponent = this.detailRendererComponent;
|
|
2409
|
+
}
|
|
2410
|
+
if (node.expanded) {
|
|
2411
|
+
this.api.setDetailRowData(node, [...node.detailRowData]);
|
|
2412
|
+
}
|
|
2413
|
+
return node;
|
|
2414
|
+
});
|
|
2415
|
+
}
|
|
2416
|
+
else {
|
|
2417
|
+
this.nodes = nodes;
|
|
2418
|
+
}
|
|
2419
|
+
this.cdr.markForCheck();
|
|
2420
|
+
});
|
|
2421
|
+
}));
|
|
2422
|
+
/**
|
|
2423
|
+
* Listen Sort Changed Event
|
|
2424
|
+
*/
|
|
2425
|
+
this.subscriptions.add(this.eventService.addEventListener('sortChanged', ({ nodes }) => {
|
|
2426
|
+
this.nodes = nodes;
|
|
2427
|
+
this.cdr.markForCheck();
|
|
2428
|
+
}));
|
|
2429
|
+
/**
|
|
2430
|
+
* Listen Selection Changed Event
|
|
2431
|
+
*/
|
|
2432
|
+
this.subscriptions.add(this.eventService.addEventListener('selectionChanged', (payload) => {
|
|
2433
|
+
if (payload) {
|
|
2434
|
+
this.cdr.markForCheck();
|
|
2435
|
+
}
|
|
2436
|
+
}));
|
|
2437
|
+
}
|
|
2438
|
+
onGridReady(params) {
|
|
2439
|
+
params.api.setRowData(this.masterNode?.detailRowData ?? []);
|
|
2440
|
+
}
|
|
2441
|
+
onBodyScroll(event) {
|
|
2442
|
+
const scrollLeft = event.target.scrollLeft;
|
|
2443
|
+
if (scrollLeft !== this.lastScrollLeft) {
|
|
2444
|
+
this.lastScrollLeft = scrollLeft;
|
|
2445
|
+
this.bodyScroll.emit(scrollLeft);
|
|
2446
|
+
return;
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
/**
|
|
2450
|
+
* Track Rendering Row Node By Row ID
|
|
2451
|
+
*/
|
|
2452
|
+
trackByRowId(index, node) {
|
|
2453
|
+
return node.rowId;
|
|
2454
|
+
}
|
|
2455
|
+
/**
|
|
2456
|
+
* Cell Selection Range Feature
|
|
2457
|
+
*/
|
|
2458
|
+
startSelection(rowId, field) {
|
|
2459
|
+
this.isMouseDown = true;
|
|
2460
|
+
this.startCell = { rowId, field };
|
|
2461
|
+
this.selectedCells.clear();
|
|
2462
|
+
this.selectedCells = new Set(this.selectedCells).add(getCellKey(rowId, field));
|
|
2463
|
+
}
|
|
2464
|
+
extendSelection(rowId, field) {
|
|
2465
|
+
if (!this.isMouseDown || !this.startCell)
|
|
2466
|
+
return;
|
|
2467
|
+
const rows = this.nodes; // already sorted
|
|
2468
|
+
const startRowIndex = rows.findIndex(r => r.rowId === this.startCell.rowId);
|
|
2469
|
+
const endRowIndex = rows.findIndex(r => r.rowId === rowId);
|
|
2470
|
+
if (startRowIndex === -1 || endRowIndex === -1)
|
|
2471
|
+
return;
|
|
2472
|
+
const colStartIndex = this.columnDefs.findIndex(c => c.field === this.startCell.field);
|
|
2473
|
+
const colEndIndex = this.columnDefs.findIndex(c => c.field === field);
|
|
2474
|
+
if (colStartIndex === -1 || colEndIndex === -1)
|
|
2475
|
+
return;
|
|
2476
|
+
const rowStart = Math.min(startRowIndex, endRowIndex);
|
|
2477
|
+
const rowEnd = Math.max(startRowIndex, endRowIndex);
|
|
2478
|
+
const colStart = Math.min(colStartIndex, colEndIndex);
|
|
2479
|
+
const colEnd = Math.max(colStartIndex, colEndIndex);
|
|
2480
|
+
const next = new Set();
|
|
2481
|
+
for (let r = rowStart; r <= rowEnd; r++) {
|
|
2482
|
+
for (let c = colStart; c <= colEnd; c++) {
|
|
2483
|
+
next.add(getCellKey(rows[r].rowId, this.columnDefs[c].field));
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
this.selectedCells = next;
|
|
2487
|
+
}
|
|
2488
|
+
endSelection() {
|
|
2489
|
+
this.isMouseDown = false;
|
|
2490
|
+
this.startCell = null;
|
|
2491
|
+
}
|
|
2492
|
+
/**
|
|
2493
|
+
* Clear Cells Selected
|
|
2494
|
+
*/
|
|
2495
|
+
onDocumentClick(event) {
|
|
2496
|
+
if (this.bodyRef?.nativeElement) {
|
|
2497
|
+
const clickedInside = this.bodyRef.nativeElement.contains(event.target);
|
|
2498
|
+
if (!clickedInside) {
|
|
2499
|
+
this.selectedCells.clear();
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
/**
|
|
2504
|
+
* Selection Range Event Hold Mouse Click
|
|
2505
|
+
*/
|
|
2506
|
+
onGlobalMouseUp() {
|
|
2507
|
+
this.endSelection();
|
|
2508
|
+
}
|
|
2509
|
+
/**
|
|
2510
|
+
* Listen Copy Clipboard Event
|
|
2511
|
+
*/
|
|
2512
|
+
onGridCopy(event) {
|
|
2513
|
+
event.preventDefault();
|
|
2514
|
+
if (this.selectedCells.size > 0) {
|
|
2515
|
+
const text = this.buildClipboardText();
|
|
2516
|
+
event.clipboardData?.setData('text/plain', text);
|
|
2517
|
+
this.selectedCells.forEach(cellId => {
|
|
2518
|
+
const cellElement = document.querySelector(`[data-cell-id="${cellId}"]`);
|
|
2519
|
+
if (cellElement) {
|
|
2520
|
+
cellElement.classList.add('one-cell-copied');
|
|
2521
|
+
setTimeout(() => cellElement.classList.remove('one-cell-copied'), 400);
|
|
2522
|
+
}
|
|
2523
|
+
});
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
copyToClipboard(value) {
|
|
2527
|
+
if (navigator.clipboard?.writeText) {
|
|
2528
|
+
navigator.clipboard.writeText(value);
|
|
2529
|
+
}
|
|
2530
|
+
else {
|
|
2531
|
+
// Fallback (Safari / older browsers)
|
|
2532
|
+
const textarea = document.createElement('textarea');
|
|
2533
|
+
textarea.value = value;
|
|
2534
|
+
textarea.style.position = 'fixed';
|
|
2535
|
+
textarea.style.opacity = '0';
|
|
2536
|
+
document.body.appendChild(textarea);
|
|
2537
|
+
textarea.select();
|
|
2538
|
+
document.execCommand('copy');
|
|
2539
|
+
document.body.removeChild(textarea);
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
/**
|
|
2543
|
+
* Build Copy Cell Text to Clipboard
|
|
2544
|
+
*/
|
|
2545
|
+
buildClipboardText() {
|
|
2546
|
+
if (!this.selectedCells.size)
|
|
2547
|
+
return '';
|
|
2548
|
+
// Parse selected cells
|
|
2549
|
+
const selected = Array.from(this.selectedCells).map(key => {
|
|
2550
|
+
const [rowId, field] = key.split('--');
|
|
2551
|
+
return { rowId, field };
|
|
2552
|
+
});
|
|
2553
|
+
// Resolve visual row indexes from displayedRows
|
|
2554
|
+
const rowIndexes = selected
|
|
2555
|
+
.map(s => this.nodes.findIndex(r => r.rowId === s.rowId))
|
|
2556
|
+
.filter(i => i !== -1);
|
|
2557
|
+
const colIndexes = selected
|
|
2558
|
+
.map(s => this.columnDefs.findIndex(c => c.field === s.field))
|
|
2559
|
+
.filter(i => i !== -1);
|
|
2560
|
+
if (!rowIndexes.length || !colIndexes.length)
|
|
2561
|
+
return '';
|
|
2562
|
+
const rowStart = Math.min(...rowIndexes);
|
|
2563
|
+
const rowEnd = Math.max(...rowIndexes);
|
|
2564
|
+
const colStart = Math.min(...colIndexes);
|
|
2565
|
+
const colEnd = Math.max(...colIndexes);
|
|
2566
|
+
const selectedFields = this.columnDefs
|
|
2567
|
+
.slice(colStart, colEnd + 1)
|
|
2568
|
+
.map(c => c.field);
|
|
2569
|
+
const clipboardLines = [];
|
|
2570
|
+
for (let r = rowStart; r <= rowEnd; r++) {
|
|
2571
|
+
const row = this.nodes[r];
|
|
2572
|
+
const line = selectedFields
|
|
2573
|
+
.map(field => {
|
|
2574
|
+
const key = `${row.rowId}--${field}`;
|
|
2575
|
+
if (!this.selectedCells.has(key)) {
|
|
2576
|
+
return '';
|
|
2577
|
+
}
|
|
2578
|
+
const value = getFieldValue(row.data, field);
|
|
2579
|
+
return value ?? '';
|
|
2580
|
+
}).join('\t');
|
|
2581
|
+
clipboardLines.push(line);
|
|
2582
|
+
}
|
|
2583
|
+
return clipboardLines.join('\n');
|
|
2584
|
+
}
|
|
2585
|
+
/**
|
|
2586
|
+
* Binding Events Row Action to Parent
|
|
2587
|
+
*/
|
|
2588
|
+
invokeRowActionGotoDetail(event) {
|
|
2589
|
+
this.onRowGotoDetail.emit(event);
|
|
2590
|
+
}
|
|
2591
|
+
invokeRowActionAddNew(event) {
|
|
2592
|
+
this.onRowAddNew.emit(event);
|
|
2593
|
+
}
|
|
2594
|
+
invokeRowActionView(event) {
|
|
2595
|
+
this.onRowView.emit(event);
|
|
2596
|
+
}
|
|
2597
|
+
invokeRowActionLocation(event) {
|
|
2598
|
+
this.onRowLocation.emit(event);
|
|
2599
|
+
}
|
|
2600
|
+
invokeRowActionDocument(event) {
|
|
2601
|
+
this.onRowDocument.emit(event);
|
|
2602
|
+
}
|
|
2603
|
+
invokeRowActionCopy(event) {
|
|
2604
|
+
this.onRowCopy.emit(event);
|
|
2605
|
+
}
|
|
2606
|
+
invokeRowActionDelete(event) {
|
|
2607
|
+
this.onRowDelete.emit(event);
|
|
2608
|
+
}
|
|
2609
|
+
invokeRowActionGotoList(event) {
|
|
2610
|
+
this.onRowGotoList.emit(event);
|
|
2611
|
+
}
|
|
2612
|
+
invokeRowActionEdit(event) {
|
|
2613
|
+
this.onRowEdit.emit(event);
|
|
2614
|
+
}
|
|
2615
|
+
invokeRowActionPrint(event) {
|
|
2616
|
+
this.onRowPrint.emit(event);
|
|
2617
|
+
}
|
|
2618
|
+
invokeRowActionHistory(event) {
|
|
2619
|
+
this.onRowHistory.emit(event);
|
|
2620
|
+
}
|
|
2621
|
+
invokeRowActionOption(event) {
|
|
2622
|
+
this.onRowOption.emit(event);
|
|
2623
|
+
}
|
|
2624
|
+
invokeRowActionLanguage(event) {
|
|
2625
|
+
this.onRowLanguage.emit(event);
|
|
2626
|
+
}
|
|
2627
|
+
invokeRowActionCellOption(event) {
|
|
2628
|
+
this.onRowCellOption.emit(event);
|
|
2629
|
+
}
|
|
2630
|
+
invokeRowActionSelection(event) {
|
|
2631
|
+
this.onRowSelection.emit(event);
|
|
2632
|
+
}
|
|
2633
|
+
invokeExpansionChangedClick(event) {
|
|
2634
|
+
this.expansionChanged.emit(event);
|
|
2635
|
+
}
|
|
2636
|
+
cellOptionMenuSelected(event) {
|
|
2637
|
+
this.cellOptionSelect.emit(event);
|
|
2638
|
+
}
|
|
2639
|
+
/**
|
|
2640
|
+
* Special Events
|
|
2641
|
+
*/
|
|
2642
|
+
invokeShiftDoubleClick(node, column) {
|
|
2643
|
+
let event = { node, column, data: node.data, rowIndex: node.rowIndex, gridType: null };
|
|
2644
|
+
if (this.masterDetail) {
|
|
2645
|
+
event = { ...event, gridType: this.gridType, masterNode: this.masterNode };
|
|
2646
|
+
}
|
|
2647
|
+
this.onShiftDoubleClick.emit(event);
|
|
2648
|
+
}
|
|
2649
|
+
/**
|
|
2650
|
+
* Cell Edit Feature
|
|
2651
|
+
*/
|
|
2652
|
+
startEdit(event, node, column) {
|
|
2653
|
+
const target = event.target;
|
|
2654
|
+
if (target.tagName.toLowerCase() === 'i') {
|
|
2655
|
+
return;
|
|
2656
|
+
}
|
|
2657
|
+
if (event.shiftKey) {
|
|
2658
|
+
this.invokeShiftDoubleClick(node, column);
|
|
2659
|
+
return;
|
|
2660
|
+
}
|
|
2661
|
+
if (!this.cellEditablePipe.transform(node.cellStates, column, node, this.cellService.editableFn, this.cellService.updatableFn, this.allowedEdit)) {
|
|
2662
|
+
this.selectedCells.clear();
|
|
2663
|
+
const cellKey = getCellKey(node.rowId, column.field);
|
|
2664
|
+
this.selectedCells.add(cellKey);
|
|
2665
|
+
return;
|
|
2666
|
+
}
|
|
2667
|
+
let rowNode = this.api.getRowNodeById(node.rowId);
|
|
2668
|
+
if (rowNode) {
|
|
2669
|
+
rowNode.editing[column.field] = true;
|
|
2670
|
+
setTimeout(() => {
|
|
2671
|
+
const input = document.querySelector(`[data-cell-id="${getCellKey(node.rowId, column.field)}"] input`);
|
|
2672
|
+
if (input) {
|
|
2673
|
+
input.focus();
|
|
2674
|
+
const value = input.value;
|
|
2675
|
+
if (value && ["text"].includes(input.type)) {
|
|
2676
|
+
input.setSelectionRange(value.length, value.length);
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
}, 10);
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
/**
|
|
2683
|
+
* Save Cell Edit Mode
|
|
2684
|
+
*/
|
|
2685
|
+
stopEdit(node, column, event) {
|
|
2686
|
+
let rowNode = this.api.getRowNodeById(node.rowId);
|
|
2687
|
+
if (rowNode) {
|
|
2688
|
+
event.preventDefault();
|
|
2689
|
+
event.stopPropagation();
|
|
2690
|
+
const value = event.target.value ?? '';
|
|
2691
|
+
this.setCellValueByRowId(node.rowId, column, value);
|
|
2692
|
+
rowNode.cellStates = this.cellService.generateCellStates(rowNode);
|
|
2693
|
+
rowNode.editing[column.field] = false;
|
|
2694
|
+
this.eventService.dispatchEvent('cellStateChanged', {
|
|
2695
|
+
data: rowNode.data,
|
|
2696
|
+
node: rowNode,
|
|
2697
|
+
column: column
|
|
2698
|
+
});
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
/**
|
|
2702
|
+
* Cancel Cell Edit Mode
|
|
2703
|
+
*/
|
|
2704
|
+
cancelEdit(node, column) {
|
|
2705
|
+
let rowNode = this.api.getRowNodeById(node.rowId);
|
|
2706
|
+
if (rowNode) {
|
|
2707
|
+
rowNode.editing[column.field] = false;
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
/**
|
|
2711
|
+
* Set Cell Value
|
|
2712
|
+
*/
|
|
2713
|
+
setCellValueByRowId(rowId, column, value) {
|
|
2714
|
+
const node = this.api.getRowNodeById(rowId);
|
|
2715
|
+
if (node && column.field) {
|
|
2716
|
+
if (column?.cellRendererParams?.inputType !== 'number') {
|
|
2717
|
+
node.data[column.field] = value === '' ? null : value;
|
|
2718
|
+
}
|
|
2719
|
+
else {
|
|
2720
|
+
node.data[column.field] = value === '' ? null : Number(value);
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
/**
|
|
2725
|
+
* Virtual Scroll Properties
|
|
2726
|
+
*/
|
|
2727
|
+
setVirtualScroll(items = 0) {
|
|
2728
|
+
this.minBufferPx = this.itemSize * items * 1.5;
|
|
2729
|
+
this.maxBufferPx = this.minBufferPx * 2;
|
|
2730
|
+
}
|
|
2731
|
+
/**
|
|
2732
|
+
* Unsubscribe All Subscriptions
|
|
2733
|
+
*/
|
|
2734
|
+
ngOnDestroy() {
|
|
2735
|
+
this.subscriptions.unsubscribe();
|
|
2736
|
+
}
|
|
2737
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridBodyComponent, deps: [{ token: OgColumnService }, { token: OneGridCellService }, { token: OneGridEventService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2738
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.12", type: OneGridBodyComponent, selector: "one-grid-body", inputs: { rowData: "rowData", rowNumber: "rowNumber", api: "api", pagination: "pagination", allowedEdit: "allowedEdit", enableGroupColumnDefs: "enableGroupColumnDefs", submitted: "submitted", context: "context", getRowId: "getRowId", gridCopy$: "gridCopy$", gridType: "gridType", masterDetail: "masterDetail", masterNode: "masterNode", detailRowMaxHeight: "detailRowMaxHeight", detailCellRendererParams: "detailCellRendererParams", detailGridTemplate: "detailGridTemplate", detailRendererComponent: "detailRendererComponent", treeData: "treeData", treeDataChildrenField: "treeDataChildrenField", autoGroupColumnDef: "autoGroupColumnDef", groupDefaultExpanded: "groupDefaultExpanded" }, outputs: { onRowGotoDetail: "onRowGotoDetail", onRowAddNew: "onRowAddNew", onRowView: "onRowView", onRowCopy: "onRowCopy", onRowLocation: "onRowLocation", onRowDocument: "onRowDocument", onRowDelete: "onRowDelete", onRowGotoList: "onRowGotoList", onRowEdit: "onRowEdit", onRowPrint: "onRowPrint", onRowHistory: "onRowHistory", onRowOption: "onRowOption", onRowLanguage: "onRowLanguage", onRowCellOption: "onRowCellOption", onRowSelection: "onRowSelection", onShiftDoubleClick: "onShiftDoubleClick", rowCountChanged: "rowCountChanged", expansionChanged: "expansionChanged", bodyScroll: "bodyScroll", cellOptionSelect: "cellOptionSelect" }, host: { listeners: { "document:click": "onDocumentClick($event)", "document:mouseup": "onGlobalMouseUp()" } }, viewQueries: [{ propertyName: "bodyRef", first: true, predicate: ["bodyRef"], descendants: true, static: true }, { propertyName: "viewport", first: true, predicate: CdkVirtualScrollViewport, descendants: true }], ngImport: i0, template: "<div #bodyRef class=\"one-grid-body\">\n <cdk-virtual-scroll-viewport\n class=\"one-grid-body-viewport\"\n [itemSize]=\"itemSize\"\n [minBufferPx]=\"minBufferPx\"\n [maxBufferPx]=\"maxBufferPx\"\n (scroll)=\"onBodyScroll($event)\">\n\n <ng-container *cdkVirtualFor=\"let node of nodes; trackBy: trackByRowId;\">\n \n <div class=\"one-row\" [attr.data-row-id]=\"node.rowId\" [class.one-row-selected]=\"node.selected\">\n @for (col of columnDefs; track col.field;) {\n <ng-container [ngTemplateOutlet]=\"cellTemplate\" [ngTemplateOutletContext]=\"{ node, rowIndex: node.rowIndex, column: col }\"></ng-container>\n }\n </div>\n\n <!-- Custom Detail Component -->\n @if(node.leaf && node.detailActive && node?.detailRendererComponent) {\n <ng-container\n oneCellRendererComponent\n [cellRendererComponent]=\"node?.detailRendererComponent\"\n [params]=\"{ data: node.data, rowIndex: node.rowIndex, node: node, context: context }\">\n </ng-container>\n }\n\n <!-- Master Detail Grid (template provided by the parent one-grid to avoid a compile-time import cycle) -->\n @if (masterDetail && node.expanded && node?.detailRowData) {\n <div class=\"one-row-detail-container\" [attr.data-row-id]=\"node.rowId + '-detail'\">\n <ng-container\n [ngTemplateOutlet]=\"detailGridTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: node, node: node }\">\n </ng-container>\n </div>\n }\n </ng-container>\n @if (!nodes?.length) {\n <div style=\"width: max-content; border-top: 1px solid transparent;\">\n <div [style.width.px]=\"rowWidth\"></div>\n </div>\n }\n </cdk-virtual-scroll-viewport>\n @if (!nodes?.length) {\n <span class=\"one-grid-empty-message\" style=\"position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);\">No Rows to Show</span>\n }\n</div>\n\n<!-- Master Column Template -->\n<ng-template #cellTemplate let-node=\"node\" let-rowIndex=\"rowIndex\" let-column=\"column\">\n <div\n class=\"one-column\"\n [attr.data-cell-id]=\"node.rowId | cellKey:column.field\"\n [style.width.px]=\"column?.width\"\n [style.min-width.px]=\"column?.minWidth\"\n [style.max-width.px]=\"column?.maxWidth\"\n [class.one-column-border-top]=\"masterDetail && nodes?.length > 0 && nodes[node.rowIndex - 1]?.expanded\"\n [class.one-cell-selected]=\"selectedCells | cellSelected:node.rowId:column.field\"\n [class.one-cell-invalid]=\"node.cellStates | cellInvalid:node.data[column.field]:column:node:allowedEdit:submitted\"\n (dblclick)=\"startEdit($event, node, column)\"\n (mousedown)=\"startSelection(node.rowId, column.field)\"\n (mouseenter)=\"extendSelection(node.rowId, column.field)\"\n (mouseup)=\"endSelection()\">\n\n <!-- One Grid Cell Option -->\n @if (node.cellOptions[column.field]) {\n <one-grid-cell-option-menu\n #contextOptionMenuRef\n [node]=\"node\"\n [column]=\"column\"\n [options]=\"column.cellOptionMenu\"\n (cellOptionMenuSelect)=\"cellOptionMenuSelected($event)\"/>\n }\n\n <!-- Grid Cell Template -->\n @if(column?.cellRendererComponent) {\n <ng-container\n oneCellRendererComponent\n [cellRendererComponent]=\"column?.cellRendererComponent\"\n [params]=\"{ data: node.data, field: column.field, rowIndex: node.rowIndex, columnDef: column, node: node, context: context }\">\n </ng-container>\n }\n @else if (node.editing[column.field]) {\n <!-- Cell Editing Input -->\n <input class=\"one-cell-input\"\n name=\"{{ node.rowId + '' + column.field }}\"\n oneCellInputValidator\n [validationType]=\"column?.cellRendererParams?.inputType === 'number' ? 'number' : 'none'\"\n [placeholder]=\"column?.cellRendererParams?.placeholder\"\n [type]=\"column?.cellRendererParams?.inputType === 'number' ? 'text' : column?.cellRendererParams?.inputType\"\n [value]=\"node?.data[column?.field]\"\n [maxLength]=\"250\"\n (blur)=\"stopEdit(node, column, $event)\"\n (keydown.enter)=\"stopEdit(node, column, $event)\"\n (keydown.esc)=\"cancelEdit(node, column)\"\n />\n }\n @else if (column?.cellRenderer) {\n <div\n [ngStyle]=\"{ width: column.width + 'px' , position: 'relative' }\"\n [innerHTML]=\"node.cellStates | cellStateRenderer:column.field\"\n [class.editable-active]=\"node.cellStates | cellEditable:column:node:cellService.editableFn:cellService.updatableFn:allowedEdit\">\n </div>\n }\n @else {\n <div class=\"one-cell\"\n [class.align-content-left]=\"column?.alignContent === 'left'\"\n [class.align-content-center]=\"column?.alignContent === 'center'\"\n [class.align-content-right]=\"column?.alignContent === 'right'\"\n [ngClass]=\"colService.resolveCellPresentation(column, { node, data: node.data, columnDef: column })._resolvedCellClass\"\n [ngStyle]=\"colService.resolveCellPresentation(column, { node, data: node.data, columnDef: column })._resolvedCellStyle\"\n [style.padding-left.px]=\"column.autoGroupField && node.level | cellLevelPadding:24\"\n [class.one-cell-allowed-edit-active]=\"node.cellStates | cellEditable:column:node:cellService.editableFn:cellService.updatableFn:allowedEdit\">\n\n <!-- Cell Checkbox Selection -->\n @if (column?.checkboxSelection) {\n <one-grid-checkbox\n [node]=\"node\"\n [allowedEdit]=\"allowedEdit\"\n [api]=\"api\"\n (onRowSelection)=\"invokeRowActionSelection($event)\"\n />\n }\n\n <!-- Expand & Collapse Icon -->\n @if (((node?.group || detailRendererComponent) && column?.autoGroupField) || (masterDetail && node?.expandable && gridType === 'master' && column?.masterGroupField)) {\n <one-grid-cell-group-renderer\n [node]=\"node\"\n [masterDetail]=\"masterDetail\"\n [detailCellRendererParams]=\"detailCellRendererParams\"\n [detailRendererComponent]=\"detailRendererComponent\"\n (expansionChanged)=\"invokeExpansionChangedClick($event)\"\n />\n }\n\n @if(column?.cellRendererComponent) {\n <ng-container\n oneCellRendererComponent\n [cellRendererComponent]=\"column?.cellRendererComponent\"\n [params]=\"{ data: node.data, field: column.field, rowIndex: node.rowIndex, columnDef: column, node: node, context: context }\">\n </ng-container>\n }\n @else {\n <!-- Cell Value OR Placeholder -->\n <div oneCellTextExpand class=\"one-cell-text\" [class.one-cell-placeholder]=\"node.cellStates[column.field]?.type === 'placeholder'\">\n {{ (node.cellStates | cellStateRenderer:column.field) }}\n </div>\n }\n\n <!-- Cell Action Buttons -->\n @if (column.cellRendererParams | cellActionButtonEnable) {\n <one-grid-row-action\n [ngStyle]=\"{ marginLeft: 'auto' }\"\n [column]=\"column\"\n [node]=\"node\"\n [allowedEdit]=\"allowedEdit\"\n [masterNode]=\"masterNode\"\n [masterDetail]=\"masterDetail\"\n [gridType]=\"gridType\"\n [context]=\"context\"\n [cellRendererParams]=\"column?.cellRendererParams\"\n (onRowGotoDetail)=\"invokeRowActionGotoDetail($event)\"\n (onRowAddNew)=\"invokeRowActionAddNew($event)\"\n (onRowView)=\"invokeRowActionView($event)\"\n (onRowLocation)=\"invokeRowActionLocation($event)\"\n (onRowDocument)=\"invokeRowActionDocument($event)\"\n (onRowCopy)=\"invokeRowActionCopy($event)\"\n (onRowDelete)=\"invokeRowActionDelete($event)\"\n (onRowGotoList)=\"invokeRowActionGotoList($event)\"\n (onRowEdit)=\"invokeRowActionEdit($event)\"\n (onRowPrint)=\"invokeRowActionPrint($event)\"\n (onRowHistory)=\"invokeRowActionHistory($event)\"\n (onRowOption)=\"invokeRowActionOption($event)\"\n (onRowLanguage)=\"invokeRowActionLanguage($event)\"\n (onRowCellOption)=\"invokeRowActionCellOption($event)\"\n />\n }\n </div>\n }\n </div>\n</ng-template>\n", styles: [""], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i5.CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }, { kind: "directive", type: i5.CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }, { kind: "component", type: i5.CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }, { kind: "component", type: OneGridCheckboxComponent, selector: "one-grid-checkbox", inputs: ["node", "allowedEdit", "api"], outputs: ["onRowSelection"] }, { kind: "component", type: OneGridRowActionComponent, selector: "one-grid-row-action", inputs: ["column", "node", "allowedEdit", "masterDetail", "masterNode", "cellRendererParams", "gridType", "context"], outputs: ["onRowGotoDetail", "onRowAddNew", "onRowView", "onRowLocation", "onRowDocument", "onRowCopy", "onRowDelete", "onRowGotoList", "onRowEdit", "onRowPrint", "onRowHistory", "onRowOption", "onRowLanguage", "onRowCellOption"] }, { kind: "component", type: OneGridCellGroupRendererComponent, selector: "one-grid-cell-group-renderer", inputs: ["node", "masterDetail", "detailCellRendererParams", "detailRendererComponent"], outputs: ["expansionChanged"] }, { kind: "directive", type: OneCellInputValidatorDirective, selector: "[oneCellInputValidator]", inputs: ["validationType", "regex"] }, { kind: "directive", type: OneCellRendererComponentDirective, selector: "[oneCellRendererComponent]", inputs: ["cellRendererComponent", "params"] }, { kind: "directive", type: OneCellTextExpandDirective, selector: "[oneCellTextExpand]" }, { kind: "component", type: OneGridCellOptionMenuComponent, selector: "one-grid-cell-option-menu", inputs: ["column", "node", "options"], outputs: ["cellOptionMenuSelect", "cellOptionMenuClose"] }, { kind: "pipe", type: CellEditablePipe, name: "cellEditable" }, { kind: "pipe", type: CellInvalidPipe, name: "cellInvalid" }, { kind: "pipe", type: CellSelectedPipe, name: "cellSelected" }, { kind: "pipe", type: CellActionButtonEnablePipe, name: "cellActionButtonEnable" }, { kind: "pipe", type: CellKeyPipe, name: "cellKey" }, { kind: "pipe", type: CellLevelPaddingPipe, name: "cellLevelPadding" }, { kind: "pipe", type: CellStateRendererPipe, name: "cellStateRenderer" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2739
|
+
}
|
|
2740
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridBodyComponent, decorators: [{
|
|
2741
|
+
type: Component,
|
|
2742
|
+
args: [{ standalone: false, selector: 'one-grid-body', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div #bodyRef class=\"one-grid-body\">\n <cdk-virtual-scroll-viewport\n class=\"one-grid-body-viewport\"\n [itemSize]=\"itemSize\"\n [minBufferPx]=\"minBufferPx\"\n [maxBufferPx]=\"maxBufferPx\"\n (scroll)=\"onBodyScroll($event)\">\n\n <ng-container *cdkVirtualFor=\"let node of nodes; trackBy: trackByRowId;\">\n \n <div class=\"one-row\" [attr.data-row-id]=\"node.rowId\" [class.one-row-selected]=\"node.selected\">\n @for (col of columnDefs; track col.field;) {\n <ng-container [ngTemplateOutlet]=\"cellTemplate\" [ngTemplateOutletContext]=\"{ node, rowIndex: node.rowIndex, column: col }\"></ng-container>\n }\n </div>\n\n <!-- Custom Detail Component -->\n @if(node.leaf && node.detailActive && node?.detailRendererComponent) {\n <ng-container\n oneCellRendererComponent\n [cellRendererComponent]=\"node?.detailRendererComponent\"\n [params]=\"{ data: node.data, rowIndex: node.rowIndex, node: node, context: context }\">\n </ng-container>\n }\n\n <!-- Master Detail Grid (template provided by the parent one-grid to avoid a compile-time import cycle) -->\n @if (masterDetail && node.expanded && node?.detailRowData) {\n <div class=\"one-row-detail-container\" [attr.data-row-id]=\"node.rowId + '-detail'\">\n <ng-container\n [ngTemplateOutlet]=\"detailGridTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: node, node: node }\">\n </ng-container>\n </div>\n }\n </ng-container>\n @if (!nodes?.length) {\n <div style=\"width: max-content; border-top: 1px solid transparent;\">\n <div [style.width.px]=\"rowWidth\"></div>\n </div>\n }\n </cdk-virtual-scroll-viewport>\n @if (!nodes?.length) {\n <span class=\"one-grid-empty-message\" style=\"position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);\">No Rows to Show</span>\n }\n</div>\n\n<!-- Master Column Template -->\n<ng-template #cellTemplate let-node=\"node\" let-rowIndex=\"rowIndex\" let-column=\"column\">\n <div\n class=\"one-column\"\n [attr.data-cell-id]=\"node.rowId | cellKey:column.field\"\n [style.width.px]=\"column?.width\"\n [style.min-width.px]=\"column?.minWidth\"\n [style.max-width.px]=\"column?.maxWidth\"\n [class.one-column-border-top]=\"masterDetail && nodes?.length > 0 && nodes[node.rowIndex - 1]?.expanded\"\n [class.one-cell-selected]=\"selectedCells | cellSelected:node.rowId:column.field\"\n [class.one-cell-invalid]=\"node.cellStates | cellInvalid:node.data[column.field]:column:node:allowedEdit:submitted\"\n (dblclick)=\"startEdit($event, node, column)\"\n (mousedown)=\"startSelection(node.rowId, column.field)\"\n (mouseenter)=\"extendSelection(node.rowId, column.field)\"\n (mouseup)=\"endSelection()\">\n\n <!-- One Grid Cell Option -->\n @if (node.cellOptions[column.field]) {\n <one-grid-cell-option-menu\n #contextOptionMenuRef\n [node]=\"node\"\n [column]=\"column\"\n [options]=\"column.cellOptionMenu\"\n (cellOptionMenuSelect)=\"cellOptionMenuSelected($event)\"/>\n }\n\n <!-- Grid Cell Template -->\n @if(column?.cellRendererComponent) {\n <ng-container\n oneCellRendererComponent\n [cellRendererComponent]=\"column?.cellRendererComponent\"\n [params]=\"{ data: node.data, field: column.field, rowIndex: node.rowIndex, columnDef: column, node: node, context: context }\">\n </ng-container>\n }\n @else if (node.editing[column.field]) {\n <!-- Cell Editing Input -->\n <input class=\"one-cell-input\"\n name=\"{{ node.rowId + '' + column.field }}\"\n oneCellInputValidator\n [validationType]=\"column?.cellRendererParams?.inputType === 'number' ? 'number' : 'none'\"\n [placeholder]=\"column?.cellRendererParams?.placeholder\"\n [type]=\"column?.cellRendererParams?.inputType === 'number' ? 'text' : column?.cellRendererParams?.inputType\"\n [value]=\"node?.data[column?.field]\"\n [maxLength]=\"250\"\n (blur)=\"stopEdit(node, column, $event)\"\n (keydown.enter)=\"stopEdit(node, column, $event)\"\n (keydown.esc)=\"cancelEdit(node, column)\"\n />\n }\n @else if (column?.cellRenderer) {\n <div\n [ngStyle]=\"{ width: column.width + 'px' , position: 'relative' }\"\n [innerHTML]=\"node.cellStates | cellStateRenderer:column.field\"\n [class.editable-active]=\"node.cellStates | cellEditable:column:node:cellService.editableFn:cellService.updatableFn:allowedEdit\">\n </div>\n }\n @else {\n <div class=\"one-cell\"\n [class.align-content-left]=\"column?.alignContent === 'left'\"\n [class.align-content-center]=\"column?.alignContent === 'center'\"\n [class.align-content-right]=\"column?.alignContent === 'right'\"\n [ngClass]=\"colService.resolveCellPresentation(column, { node, data: node.data, columnDef: column })._resolvedCellClass\"\n [ngStyle]=\"colService.resolveCellPresentation(column, { node, data: node.data, columnDef: column })._resolvedCellStyle\"\n [style.padding-left.px]=\"column.autoGroupField && node.level | cellLevelPadding:24\"\n [class.one-cell-allowed-edit-active]=\"node.cellStates | cellEditable:column:node:cellService.editableFn:cellService.updatableFn:allowedEdit\">\n\n <!-- Cell Checkbox Selection -->\n @if (column?.checkboxSelection) {\n <one-grid-checkbox\n [node]=\"node\"\n [allowedEdit]=\"allowedEdit\"\n [api]=\"api\"\n (onRowSelection)=\"invokeRowActionSelection($event)\"\n />\n }\n\n <!-- Expand & Collapse Icon -->\n @if (((node?.group || detailRendererComponent) && column?.autoGroupField) || (masterDetail && node?.expandable && gridType === 'master' && column?.masterGroupField)) {\n <one-grid-cell-group-renderer\n [node]=\"node\"\n [masterDetail]=\"masterDetail\"\n [detailCellRendererParams]=\"detailCellRendererParams\"\n [detailRendererComponent]=\"detailRendererComponent\"\n (expansionChanged)=\"invokeExpansionChangedClick($event)\"\n />\n }\n\n @if(column?.cellRendererComponent) {\n <ng-container\n oneCellRendererComponent\n [cellRendererComponent]=\"column?.cellRendererComponent\"\n [params]=\"{ data: node.data, field: column.field, rowIndex: node.rowIndex, columnDef: column, node: node, context: context }\">\n </ng-container>\n }\n @else {\n <!-- Cell Value OR Placeholder -->\n <div oneCellTextExpand class=\"one-cell-text\" [class.one-cell-placeholder]=\"node.cellStates[column.field]?.type === 'placeholder'\">\n {{ (node.cellStates | cellStateRenderer:column.field) }}\n </div>\n }\n\n <!-- Cell Action Buttons -->\n @if (column.cellRendererParams | cellActionButtonEnable) {\n <one-grid-row-action\n [ngStyle]=\"{ marginLeft: 'auto' }\"\n [column]=\"column\"\n [node]=\"node\"\n [allowedEdit]=\"allowedEdit\"\n [masterNode]=\"masterNode\"\n [masterDetail]=\"masterDetail\"\n [gridType]=\"gridType\"\n [context]=\"context\"\n [cellRendererParams]=\"column?.cellRendererParams\"\n (onRowGotoDetail)=\"invokeRowActionGotoDetail($event)\"\n (onRowAddNew)=\"invokeRowActionAddNew($event)\"\n (onRowView)=\"invokeRowActionView($event)\"\n (onRowLocation)=\"invokeRowActionLocation($event)\"\n (onRowDocument)=\"invokeRowActionDocument($event)\"\n (onRowCopy)=\"invokeRowActionCopy($event)\"\n (onRowDelete)=\"invokeRowActionDelete($event)\"\n (onRowGotoList)=\"invokeRowActionGotoList($event)\"\n (onRowEdit)=\"invokeRowActionEdit($event)\"\n (onRowPrint)=\"invokeRowActionPrint($event)\"\n (onRowHistory)=\"invokeRowActionHistory($event)\"\n (onRowOption)=\"invokeRowActionOption($event)\"\n (onRowLanguage)=\"invokeRowActionLanguage($event)\"\n (onRowCellOption)=\"invokeRowActionCellOption($event)\"\n />\n }\n </div>\n }\n </div>\n</ng-template>\n" }]
|
|
2743
|
+
}], ctorParameters: () => [{ type: OgColumnService }, { type: OneGridCellService }, { type: OneGridEventService }, { type: i0.ChangeDetectorRef }], propDecorators: { bodyRef: [{
|
|
2744
|
+
type: ViewChild,
|
|
2745
|
+
args: ['bodyRef', { static: true }]
|
|
2746
|
+
}], rowData: [{
|
|
2747
|
+
type: Input,
|
|
2748
|
+
args: [{ required: true }]
|
|
2749
|
+
}], rowNumber: [{
|
|
2750
|
+
type: Input
|
|
2751
|
+
}], api: [{
|
|
2752
|
+
type: Input
|
|
2753
|
+
}], pagination: [{
|
|
2754
|
+
type: Input
|
|
2755
|
+
}], allowedEdit: [{
|
|
2756
|
+
type: Input
|
|
2757
|
+
}], enableGroupColumnDefs: [{
|
|
2758
|
+
type: Input
|
|
2759
|
+
}], submitted: [{
|
|
2760
|
+
type: Input
|
|
2761
|
+
}], context: [{
|
|
2762
|
+
type: Input
|
|
2763
|
+
}], getRowId: [{
|
|
2764
|
+
type: Input
|
|
2765
|
+
}], gridCopy$: [{
|
|
2766
|
+
type: Input,
|
|
2767
|
+
args: [{ required: true }]
|
|
2768
|
+
}], viewport: [{
|
|
2769
|
+
type: ViewChild,
|
|
2770
|
+
args: [CdkVirtualScrollViewport]
|
|
2771
|
+
}], gridType: [{
|
|
2772
|
+
type: Input
|
|
2773
|
+
}], masterDetail: [{
|
|
2774
|
+
type: Input
|
|
2775
|
+
}], masterNode: [{
|
|
2776
|
+
type: Input
|
|
2777
|
+
}], detailRowMaxHeight: [{
|
|
2778
|
+
type: Input
|
|
2779
|
+
}], detailCellRendererParams: [{
|
|
2780
|
+
type: Input
|
|
2781
|
+
}], detailGridTemplate: [{
|
|
2782
|
+
type: Input
|
|
2783
|
+
}], detailRendererComponent: [{
|
|
2784
|
+
type: Input
|
|
2785
|
+
}], treeData: [{
|
|
2786
|
+
type: Input
|
|
2787
|
+
}], treeDataChildrenField: [{
|
|
2788
|
+
type: Input
|
|
2789
|
+
}], autoGroupColumnDef: [{
|
|
2790
|
+
type: Input
|
|
2791
|
+
}], groupDefaultExpanded: [{
|
|
2792
|
+
type: Input
|
|
2793
|
+
}], onRowGotoDetail: [{
|
|
2794
|
+
type: Output
|
|
2795
|
+
}], onRowAddNew: [{
|
|
2796
|
+
type: Output
|
|
2797
|
+
}], onRowView: [{
|
|
2798
|
+
type: Output
|
|
2799
|
+
}], onRowCopy: [{
|
|
2800
|
+
type: Output
|
|
2801
|
+
}], onRowLocation: [{
|
|
2802
|
+
type: Output
|
|
2803
|
+
}], onRowDocument: [{
|
|
2804
|
+
type: Output
|
|
2805
|
+
}], onRowDelete: [{
|
|
2806
|
+
type: Output
|
|
2807
|
+
}], onRowGotoList: [{
|
|
2808
|
+
type: Output
|
|
2809
|
+
}], onRowEdit: [{
|
|
2810
|
+
type: Output
|
|
2811
|
+
}], onRowPrint: [{
|
|
2812
|
+
type: Output
|
|
2813
|
+
}], onRowHistory: [{
|
|
2814
|
+
type: Output
|
|
2815
|
+
}], onRowOption: [{
|
|
2816
|
+
type: Output
|
|
2817
|
+
}], onRowLanguage: [{
|
|
2818
|
+
type: Output
|
|
2819
|
+
}], onRowCellOption: [{
|
|
2820
|
+
type: Output
|
|
2821
|
+
}], onRowSelection: [{
|
|
2822
|
+
type: Output
|
|
2823
|
+
}], onShiftDoubleClick: [{
|
|
2824
|
+
type: Output
|
|
2825
|
+
}], rowCountChanged: [{
|
|
2826
|
+
type: Output
|
|
2827
|
+
}], expansionChanged: [{
|
|
2828
|
+
type: Output
|
|
2829
|
+
}], bodyScroll: [{
|
|
2830
|
+
type: Output
|
|
2831
|
+
}], cellOptionSelect: [{
|
|
2832
|
+
type: Output
|
|
2833
|
+
}], onDocumentClick: [{
|
|
2834
|
+
type: HostListener,
|
|
2835
|
+
args: ['document:click', ['$event']]
|
|
2836
|
+
}], onGlobalMouseUp: [{
|
|
2837
|
+
type: HostListener,
|
|
2838
|
+
args: ['document:mouseup']
|
|
2839
|
+
}] } });
|
|
2840
|
+
|
|
2841
|
+
class OneGridPaginationComponent {
|
|
2842
|
+
constructor() {
|
|
2843
|
+
this.paginate = {
|
|
2844
|
+
total: 0,
|
|
2845
|
+
currentPage: 1,
|
|
2846
|
+
lastPage: 1,
|
|
2847
|
+
perPage: 25,
|
|
2848
|
+
firstRowIndex: 1,
|
|
2849
|
+
lastRowIndex: 1,
|
|
2850
|
+
};
|
|
2851
|
+
this.goToFirst = new EventEmitter();
|
|
2852
|
+
this.goToPrevious = new EventEmitter();
|
|
2853
|
+
this.goToNext = new EventEmitter();
|
|
2854
|
+
this.goToLast = new EventEmitter();
|
|
2855
|
+
this.pageSizeChange = new EventEmitter();
|
|
2856
|
+
this.pageSize = OnePageSizeOption[0];
|
|
2857
|
+
this.pageSizeOptions = OnePageSizeOption;
|
|
2858
|
+
}
|
|
2859
|
+
ngAfterViewInit() {
|
|
2860
|
+
if (this.paginate?.pageSizeOptions) {
|
|
2861
|
+
this.pageSizeOptions = this.paginate.pageSizeOptions;
|
|
2862
|
+
}
|
|
2863
|
+
}
|
|
2864
|
+
goToFirstPage() {
|
|
2865
|
+
if (!(this.paginate?.perPage < this.paginate?.total && this.paginate?.currentPage > 1))
|
|
2866
|
+
return;
|
|
2867
|
+
this.goToFirst.emit(this.paginate?.currentPage);
|
|
2868
|
+
}
|
|
2869
|
+
goToPreviousPage() {
|
|
2870
|
+
if (!(this.paginate?.perPage < this.paginate?.total && this.paginate?.currentPage > 1))
|
|
2871
|
+
return;
|
|
2872
|
+
this.goToPrevious.emit(this.paginate?.currentPage);
|
|
2873
|
+
}
|
|
2874
|
+
goToNextPage() {
|
|
2875
|
+
if (!(this.paginate?.perPage < this.paginate?.total && this.paginate?.currentPage < this.paginate?.lastPage))
|
|
2876
|
+
return;
|
|
2877
|
+
this.goToNext.emit(this.paginate?.currentPage);
|
|
2878
|
+
}
|
|
2879
|
+
goToLastPage() {
|
|
2880
|
+
if (!(this.paginate?.perPage < this.paginate?.total && this.paginate?.currentPage < this.paginate?.lastPage))
|
|
2881
|
+
return;
|
|
2882
|
+
this.goToLast.emit(this.paginate?.currentPage);
|
|
2883
|
+
}
|
|
2884
|
+
onPageSizeChange(event) {
|
|
2885
|
+
const select = event.target;
|
|
2886
|
+
const newSize = Number(select.value);
|
|
2887
|
+
if (newSize !== this.pageSize) {
|
|
2888
|
+
this.pageSize = newSize;
|
|
2889
|
+
this.pageSizeChange.emit(this.pageSize);
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridPaginationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2893
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.12", type: OneGridPaginationComponent, selector: "one-grid-pagination", inputs: { paginate: "paginate" }, outputs: { goToFirst: "goToFirst", goToPrevious: "goToPrevious", goToNext: "goToNext", goToLast: "goToLast", pageSizeChange: "pageSizeChange" }, ngImport: i0, template: "<div class=\"one-grid-pagination\">\n <div class=\"one-pagination-row\">\n @if (paginate?.firstRowIndex > 0 && paginate?.lastRowIndex > 0 && paginate?.total > 0) {\n <div class=\"one-pagination-columns-group\">\n <div class=\"one-pagination-column\">\n <span>{{ paginate?.firstRowIndex }}</span>\n <span>-</span>\n <span>{{ paginate?.lastRowIndex }}</span>\n <span>/</span> \n <span>{{ paginate?.total }}</span>\n </div>\n </div>\n }\n <div class=\"one-pagination-columns-group\">\n <div class=\"one-pagination-column\">\n <button \n class=\"one-pagination-btn\"\n (click)=\"goToFirstPage()\"\n [class.disabled]=\"!(paginate?.perPage < paginate?.total && paginate?.currentPage > 1)\">\n <lucide-icon name=\"chevron-first\" [size]=\"16\" [strokeWidth]=\"2\"></lucide-icon>\n </button>\n <button\n class=\"one-pagination-btn\"\n (click)=\"goToPreviousPage()\"\n [class.disabled]=\"!(paginate?.perPage < paginate?.total && paginate?.currentPage > 1)\">\n <lucide-icon name=\"chevron-left\" [size]=\"16\" [strokeWidth]=\"2\"></lucide-icon>\n </button>\n </div>\n <div class=\"one-pagination-column\">\n {{ paginate?.currentPage }}<span>/</span>{{ paginate?.lastPage }} \n </div>\n <div class=\"one-pagination-column\">\n <button\n class=\"one-pagination-btn\"\n (click)=\"goToNextPage()\"\n [class.disabled]=\"!(paginate?.perPage < paginate?.total && paginate?.currentPage < paginate?.lastPage)\">\n <lucide-icon name=\"chevron-right\" [size]=\"16\" [strokeWidth]=\"2\"></lucide-icon>\n </button>\n <button\n class=\"one-pagination-btn\"\n (click)=\"goToLastPage()\"\n [class.disabled]=\"!(paginate?.perPage < paginate?.total && paginate?.currentPage < paginate?.lastPage)\">\n <lucide-icon name=\"chevron-last\" [size]=\"16\" [strokeWidth]=\"2\"></lucide-icon>\n </button>\n </div>\n <div class=\"one-pagination-columns-group\">\n <div class=\"one-pagination-column\">\n <select name=\"row-per-page\" [value]=\"pageSize\" (change)=\"onPageSizeChange($event)\">\n @for (size of pageSizeOptions; track $index) {\n <option [value]=\"size\">{{ size }} rows</option>\n }\n </select>\n </div>\n </div>\n </div>\n </div>\n</div>", styles: [""], dependencies: [{ kind: "directive", type: i3$1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3$1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "component", type: i3.LucideAngularComponent, selector: "lucide-angular, lucide-icon, i-lucide, span-lucide", inputs: ["class", "name", "img", "color", "absoluteStrokeWidth", "size", "strokeWidth"] }] }); }
|
|
2894
|
+
}
|
|
2895
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridPaginationComponent, decorators: [{
|
|
2896
|
+
type: Component,
|
|
2897
|
+
args: [{ standalone: false, selector: 'one-grid-pagination', template: "<div class=\"one-grid-pagination\">\n <div class=\"one-pagination-row\">\n @if (paginate?.firstRowIndex > 0 && paginate?.lastRowIndex > 0 && paginate?.total > 0) {\n <div class=\"one-pagination-columns-group\">\n <div class=\"one-pagination-column\">\n <span>{{ paginate?.firstRowIndex }}</span>\n <span>-</span>\n <span>{{ paginate?.lastRowIndex }}</span>\n <span>/</span> \n <span>{{ paginate?.total }}</span>\n </div>\n </div>\n }\n <div class=\"one-pagination-columns-group\">\n <div class=\"one-pagination-column\">\n <button \n class=\"one-pagination-btn\"\n (click)=\"goToFirstPage()\"\n [class.disabled]=\"!(paginate?.perPage < paginate?.total && paginate?.currentPage > 1)\">\n <lucide-icon name=\"chevron-first\" [size]=\"16\" [strokeWidth]=\"2\"></lucide-icon>\n </button>\n <button\n class=\"one-pagination-btn\"\n (click)=\"goToPreviousPage()\"\n [class.disabled]=\"!(paginate?.perPage < paginate?.total && paginate?.currentPage > 1)\">\n <lucide-icon name=\"chevron-left\" [size]=\"16\" [strokeWidth]=\"2\"></lucide-icon>\n </button>\n </div>\n <div class=\"one-pagination-column\">\n {{ paginate?.currentPage }}<span>/</span>{{ paginate?.lastPage }} \n </div>\n <div class=\"one-pagination-column\">\n <button\n class=\"one-pagination-btn\"\n (click)=\"goToNextPage()\"\n [class.disabled]=\"!(paginate?.perPage < paginate?.total && paginate?.currentPage < paginate?.lastPage)\">\n <lucide-icon name=\"chevron-right\" [size]=\"16\" [strokeWidth]=\"2\"></lucide-icon>\n </button>\n <button\n class=\"one-pagination-btn\"\n (click)=\"goToLastPage()\"\n [class.disabled]=\"!(paginate?.perPage < paginate?.total && paginate?.currentPage < paginate?.lastPage)\">\n <lucide-icon name=\"chevron-last\" [size]=\"16\" [strokeWidth]=\"2\"></lucide-icon>\n </button>\n </div>\n <div class=\"one-pagination-columns-group\">\n <div class=\"one-pagination-column\">\n <select name=\"row-per-page\" [value]=\"pageSize\" (change)=\"onPageSizeChange($event)\">\n @for (size of pageSizeOptions; track $index) {\n <option [value]=\"size\">{{ size }} rows</option>\n }\n </select>\n </div>\n </div>\n </div>\n </div>\n</div>" }]
|
|
2898
|
+
}], propDecorators: { paginate: [{
|
|
2899
|
+
type: Input
|
|
2900
|
+
}], goToFirst: [{
|
|
2901
|
+
type: Output
|
|
2902
|
+
}], goToPrevious: [{
|
|
2903
|
+
type: Output
|
|
2904
|
+
}], goToNext: [{
|
|
2905
|
+
type: Output
|
|
2906
|
+
}], goToLast: [{
|
|
2907
|
+
type: Output
|
|
2908
|
+
}], pageSizeChange: [{
|
|
2909
|
+
type: Output
|
|
2910
|
+
}] } });
|
|
2911
|
+
|
|
2912
|
+
class OneGridComponent {
|
|
2913
|
+
constructor(api, eventService, elementRef) {
|
|
2914
|
+
this.api = api;
|
|
2915
|
+
this.eventService = eventService;
|
|
2916
|
+
this.elementRef = elementRef;
|
|
2917
|
+
this.rowNumber = false;
|
|
2918
|
+
this.allowedEdit = true;
|
|
2919
|
+
this.submitted = false;
|
|
2920
|
+
this.context = null;
|
|
2921
|
+
this.rowData = [];
|
|
2922
|
+
this.rowSelection = null;
|
|
2923
|
+
this.enableGroupColumnDefs = false;
|
|
2924
|
+
this.groupColumnDefs = [];
|
|
2925
|
+
this.defaultColumnDef = {};
|
|
2926
|
+
this.columnDefs = [];
|
|
2927
|
+
// RXJS Properties
|
|
2928
|
+
this.gridCopy$ = new Subject();
|
|
2929
|
+
/**
|
|
2930
|
+
* Master Detail Feature
|
|
2931
|
+
*/
|
|
2932
|
+
this.gridType = 'master';
|
|
2933
|
+
this.masterDetail = false;
|
|
2934
|
+
this.masterNode = null;
|
|
2935
|
+
/**
|
|
2936
|
+
* Tree Data Feature
|
|
2937
|
+
*/
|
|
2938
|
+
this.treeData = false;
|
|
2939
|
+
this.treeDataChildrenField = null;
|
|
2940
|
+
this.groupDefaultExpanded = 0;
|
|
2941
|
+
/**
|
|
2942
|
+
* Bind Row Action Events & Data to Parent
|
|
2943
|
+
*/
|
|
2944
|
+
this.onGridReady = new EventEmitter();
|
|
2945
|
+
this.onRowGotoDetail = new EventEmitter();
|
|
2946
|
+
this.onRowAddNew = new EventEmitter();
|
|
2947
|
+
this.onRowView = new EventEmitter();
|
|
2948
|
+
this.onRowLocation = new EventEmitter();
|
|
2949
|
+
this.onRowDocument = new EventEmitter();
|
|
2950
|
+
this.onRowCopy = new EventEmitter();
|
|
2951
|
+
this.onRowDelete = new EventEmitter();
|
|
2952
|
+
this.onRowGotoList = new EventEmitter();
|
|
2953
|
+
this.onRowEdit = new EventEmitter();
|
|
2954
|
+
this.onRowPrint = new EventEmitter();
|
|
2955
|
+
this.onRowHistory = new EventEmitter();
|
|
2956
|
+
this.onRowOption = new EventEmitter();
|
|
2957
|
+
this.onRowLanguage = new EventEmitter();
|
|
2958
|
+
this.onRowSelection = new EventEmitter();
|
|
2959
|
+
this.onShiftDoubleClick = new EventEmitter();
|
|
2960
|
+
this.rowCountChanged = new EventEmitter();
|
|
2961
|
+
this.selectionChanged = new EventEmitter();
|
|
2962
|
+
this.expansionChanged = new EventEmitter();
|
|
2963
|
+
// For context menu option
|
|
2964
|
+
this.cellOptionSelect = new EventEmitter();
|
|
2965
|
+
this.onRowCellOption = new EventEmitter();
|
|
2966
|
+
/**
|
|
2967
|
+
* Bind One Grid Pagination Feature
|
|
2968
|
+
*/
|
|
2969
|
+
this.pagination = false;
|
|
2970
|
+
this.goToFirst = new EventEmitter();
|
|
2971
|
+
this.goToPrevious = new EventEmitter();
|
|
2972
|
+
this.goToNext = new EventEmitter();
|
|
2973
|
+
this.goToLast = new EventEmitter();
|
|
2974
|
+
this.pageSizeChange = new EventEmitter();
|
|
2975
|
+
/**
|
|
2976
|
+
* One Grid Properties
|
|
2977
|
+
*/
|
|
2978
|
+
this.bodyScrollLeft = 0;
|
|
2979
|
+
this._oneRowNumberColumnDef = null;
|
|
2980
|
+
this.subscriptions = new Subscription();
|
|
2981
|
+
}
|
|
2982
|
+
ngOnChanges(changes) {
|
|
2983
|
+
if (changes['masterNode'] && changes['masterNode'].isFirstChange) {
|
|
2984
|
+
if (this.masterDetail && this.masterNode.expanded && this.gridType === 'detail') {
|
|
2985
|
+
setTimeout(() => this.api.setRowData([...this.masterNode.detailRowData]));
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
if (changes["rowData"] && !changes["rowData"]?.firstChange) {
|
|
2989
|
+
this.treeData || this.masterDetail ? this.api.updateRowData(this.rowData) : this.api.setRowData(this.rowData);
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2992
|
+
ngOnInit() {
|
|
2993
|
+
/**
|
|
2994
|
+
* Init Row Number Column Def
|
|
2995
|
+
*/
|
|
2996
|
+
if (this.rowNumber) {
|
|
2997
|
+
this._oneRowNumberColumnDef = {
|
|
2998
|
+
groupId: this.columnDefs[0]?.groupId ?? null,
|
|
2999
|
+
field: '_oneRowNumber',
|
|
3000
|
+
headerName: 'Nº',
|
|
3001
|
+
resizable: true,
|
|
3002
|
+
headerStyle: {
|
|
3003
|
+
textAlign: 'center',
|
|
3004
|
+
display: 'flex',
|
|
3005
|
+
justifyContent: 'center',
|
|
3006
|
+
alignItem: 'center'
|
|
3007
|
+
},
|
|
3008
|
+
alignContent: 'right',
|
|
3009
|
+
cellClass: 'fw-bold',
|
|
3010
|
+
width: 60,
|
|
3011
|
+
minWidth: 40,
|
|
3012
|
+
maxWidth: 200
|
|
3013
|
+
};
|
|
3014
|
+
}
|
|
3015
|
+
/**
|
|
3016
|
+
* Initialize One Grid API
|
|
3017
|
+
*/
|
|
3018
|
+
this.api.init(this.gridType, this.rowSelection, this.columnDefs, this.defaultColumnDef, this.context, this.masterDetail, this.detailCellRendererParams, this.detailRendererComponent, this.treeData, this.groupColumnDefs);
|
|
3019
|
+
/**
|
|
3020
|
+
* Setup Master Detail Configuration
|
|
3021
|
+
*/
|
|
3022
|
+
if (this.masterDetail) {
|
|
3023
|
+
this.api.setGroupDefaultExpanded(this.groupDefaultExpanded);
|
|
3024
|
+
this.api.setGetDetailRowData(this.detailCellRendererParams?.getDetailRowData ?? null);
|
|
3025
|
+
if (this.rowNumber) {
|
|
3026
|
+
const columnDefs = _.concat(this._oneRowNumberColumnDef, this.columnDefs);
|
|
3027
|
+
setTimeout(() => this.api.setColumnDefs(columnDefs));
|
|
3028
|
+
}
|
|
3029
|
+
}
|
|
3030
|
+
/**
|
|
3031
|
+
* Setup Tree Data Configuration
|
|
3032
|
+
*/
|
|
3033
|
+
if (this.treeData) {
|
|
3034
|
+
this.gridType = 'tree';
|
|
3035
|
+
const columnDefs = this.rowNumber ? _.concat(this._oneRowNumberColumnDef, this.autoGroupColumnDef, this.columnDefs) : _.concat(this.autoGroupColumnDef, this.columnDefs);
|
|
3036
|
+
this.api.setTreeDataChildrenField(this.treeDataChildrenField);
|
|
3037
|
+
this.api.setGroupDefaultExpanded(this.groupDefaultExpanded);
|
|
3038
|
+
setTimeout(() => this.api.setColumnDefs(columnDefs));
|
|
3039
|
+
}
|
|
3040
|
+
// Listen Selection Changed Event
|
|
3041
|
+
this.subscriptions.add(this.eventService.addEventListener('selectionChanged', (payload) => {
|
|
3042
|
+
this.selectionChanged.emit(payload);
|
|
3043
|
+
}));
|
|
3044
|
+
}
|
|
3045
|
+
ngAfterViewInit() {
|
|
3046
|
+
const headerViewport = this.elementRef.nativeElement.querySelector('.one-grid-header-column');
|
|
3047
|
+
const bodyViewport = this.elementRef.nativeElement.querySelector('.one-grid-body-viewport');
|
|
3048
|
+
// Listen Scroll Event Changed
|
|
3049
|
+
this.subscriptions.add(fromEvent(bodyViewport, 'scroll').subscribe(() => {
|
|
3050
|
+
if (headerViewport) {
|
|
3051
|
+
headerViewport.scrollLeft = bodyViewport.scrollLeft;
|
|
3052
|
+
}
|
|
3053
|
+
}));
|
|
3054
|
+
/**
|
|
3055
|
+
* Emit Grid Ready Event
|
|
3056
|
+
*/
|
|
3057
|
+
this.onGridReady.emit({ api: this.api });
|
|
3058
|
+
}
|
|
3059
|
+
/**
|
|
3060
|
+
* Handle Body Scroll Event
|
|
3061
|
+
*/
|
|
3062
|
+
onBodyScroll(scrollLeft) {
|
|
3063
|
+
this.bodyScrollLeft = scrollLeft;
|
|
3064
|
+
}
|
|
3065
|
+
/**
|
|
3066
|
+
* Handle Ready Event of a nested Master Detail Grid
|
|
3067
|
+
*/
|
|
3068
|
+
onDetailGridReady(params) {
|
|
3069
|
+
params.api.setRowData(this.masterNode?.detailRowData ?? []);
|
|
3070
|
+
}
|
|
3071
|
+
/**
|
|
3072
|
+
* Passing copy event to grid body
|
|
3073
|
+
*/
|
|
3074
|
+
onGridCopy(event) {
|
|
3075
|
+
this.gridCopy$.next(event);
|
|
3076
|
+
}
|
|
3077
|
+
/**
|
|
3078
|
+
* Bind Row Action Events to Parent Component
|
|
3079
|
+
*/
|
|
3080
|
+
invokeRowActionGotoDetail(event) {
|
|
3081
|
+
this.onRowGotoDetail.emit(event);
|
|
3082
|
+
}
|
|
3083
|
+
invokeRowActionAddNew(event) {
|
|
3084
|
+
this.onRowAddNew.emit(event);
|
|
3085
|
+
}
|
|
3086
|
+
invokeRowActionView(event) {
|
|
3087
|
+
this.onRowView.emit(event);
|
|
3088
|
+
}
|
|
3089
|
+
invokeRowActionLocation(event) {
|
|
3090
|
+
this.onRowLocation.emit(event);
|
|
3091
|
+
}
|
|
3092
|
+
invokeRowActionDocument(event) {
|
|
3093
|
+
this.onRowDocument.emit(event);
|
|
3094
|
+
}
|
|
3095
|
+
invokeRowActionCopy(event) {
|
|
3096
|
+
this.onRowCopy.emit(event);
|
|
3097
|
+
}
|
|
3098
|
+
invokeRowActionDelete(event) {
|
|
3099
|
+
this.onRowDelete.emit(event);
|
|
3100
|
+
}
|
|
3101
|
+
invokeRowActionGotoList(event) {
|
|
3102
|
+
this.onRowGotoList.emit(event);
|
|
3103
|
+
}
|
|
3104
|
+
invokeRowActionEdit(event) {
|
|
3105
|
+
this.onRowEdit.emit(event);
|
|
3106
|
+
}
|
|
3107
|
+
invokeRowActionPrint(event) {
|
|
3108
|
+
this.onRowPrint.emit(event);
|
|
3109
|
+
}
|
|
3110
|
+
invokeRowActionHistory(event) {
|
|
3111
|
+
this.onRowHistory.emit(event);
|
|
3112
|
+
}
|
|
3113
|
+
invokeRowActionOption(event) {
|
|
3114
|
+
this.onRowOption.emit(event);
|
|
3115
|
+
}
|
|
3116
|
+
invokeRowActionLanguage(event) {
|
|
3117
|
+
this.onRowLanguage.emit(event);
|
|
3118
|
+
}
|
|
3119
|
+
invokeRowActionCellOption(event) {
|
|
3120
|
+
this.onRowCellOption.emit(event);
|
|
3121
|
+
}
|
|
3122
|
+
invokeRowActionSelection(event) {
|
|
3123
|
+
this.onRowSelection.emit(event);
|
|
3124
|
+
}
|
|
3125
|
+
invokeShiftDoubleClick(event) {
|
|
3126
|
+
this.onShiftDoubleClick.emit(event);
|
|
3127
|
+
}
|
|
3128
|
+
invokeRowCountChanged(length) {
|
|
3129
|
+
this.rowCountChanged.emit(length);
|
|
3130
|
+
}
|
|
3131
|
+
cellOptionMenuSelected(event) {
|
|
3132
|
+
this.cellOptionSelect.emit(event);
|
|
3133
|
+
}
|
|
3134
|
+
/**
|
|
3135
|
+
* Bing Pagination Events to Parent Component
|
|
3136
|
+
*/
|
|
3137
|
+
invokeGoToFirst() {
|
|
3138
|
+
this.goToFirst.emit();
|
|
3139
|
+
}
|
|
3140
|
+
invokeGoToPrevious() {
|
|
3141
|
+
this.goToPrevious.emit();
|
|
3142
|
+
}
|
|
3143
|
+
invokeGoToNext() {
|
|
3144
|
+
this.goToNext.emit();
|
|
3145
|
+
}
|
|
3146
|
+
invokeGoToLast() {
|
|
3147
|
+
this.goToLast.emit();
|
|
3148
|
+
}
|
|
3149
|
+
invokePageSizeChange(pageSize) {
|
|
3150
|
+
this.pageSizeChange.emit(pageSize);
|
|
3151
|
+
}
|
|
3152
|
+
invokeExpansionChangedClick(event) {
|
|
3153
|
+
this.expansionChanged.emit(event);
|
|
3154
|
+
}
|
|
3155
|
+
/**
|
|
3156
|
+
* Handle Unsubscribe All Event Listenders
|
|
3157
|
+
*/
|
|
3158
|
+
ngOnDestroy() {
|
|
3159
|
+
this.rowData = [];
|
|
3160
|
+
this.api.destroy();
|
|
3161
|
+
this.subscriptions.unsubscribe();
|
|
3162
|
+
}
|
|
3163
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridComponent, deps: [{ token: OneGridApi }, { token: OneGridEventService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3164
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.12", type: OneGridComponent, selector: "one-grid", inputs: { rowNumber: "rowNumber", allowedEdit: "allowedEdit", submitted: "submitted", context: "context", rowData: "rowData", rowSelection: "rowSelection", enableGroupColumnDefs: "enableGroupColumnDefs", groupColumnDefs: "groupColumnDefs", defaultColumnDef: "defaultColumnDef", columnDefs: "columnDefs", gridType: "gridType", masterDetail: "masterDetail", masterNode: "masterNode", detailCellRendererParams: "detailCellRendererParams", detailRendererComponent: "detailRendererComponent", treeData: "treeData", treeDataChildrenField: "treeDataChildrenField", autoGroupColumnDef: "autoGroupColumnDef", groupDefaultExpanded: "groupDefaultExpanded", pagination: "pagination", paginate: "paginate" }, outputs: { onGridReady: "onGridReady", onRowGotoDetail: "onRowGotoDetail", onRowAddNew: "onRowAddNew", onRowView: "onRowView", onRowLocation: "onRowLocation", onRowDocument: "onRowDocument", onRowCopy: "onRowCopy", onRowDelete: "onRowDelete", onRowGotoList: "onRowGotoList", onRowEdit: "onRowEdit", onRowPrint: "onRowPrint", onRowHistory: "onRowHistory", onRowOption: "onRowOption", onRowLanguage: "onRowLanguage", onRowSelection: "onRowSelection", onShiftDoubleClick: "onShiftDoubleClick", rowCountChanged: "rowCountChanged", selectionChanged: "selectionChanged", expansionChanged: "expansionChanged", cellOptionSelect: "cellOptionSelect", onRowCellOption: "onRowCellOption", goToFirst: "goToFirst", goToPrevious: "goToPrevious", goToNext: "goToNext", goToLast: "goToLast", pageSizeChange: "pageSizeChange" }, providers: [
|
|
3165
|
+
OneGridEventService,
|
|
3166
|
+
OneGridApi,
|
|
3167
|
+
OgColumnService,
|
|
3168
|
+
OneGridSelectionService,
|
|
3169
|
+
OneGridExpansionService,
|
|
3170
|
+
OneGridRowService,
|
|
3171
|
+
OneGridCellService
|
|
3172
|
+
], viewQueries: [{ propertyName: "ogRef", first: true, predicate: ["ogRef"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "<div #ogRef class=\"one-grid\" (copy)=\"onGridCopy($event)\" tabindex=\"0\">\n \n <!-- Headers -->\n <one-grid-header\n [api]=\"api\"\n [enableGroupColumnDefs]=\"enableGroupColumnDefs\"\n [allowedEdit]=\"allowedEdit\"\n [scrollLeft]=\"bodyScrollLeft\"\n />\n\n <!-- Body -->\n <one-grid-body\n [gridCopy$]=\"gridCopy$\"\n [rowData]=\"rowData\"\n [api]=\"api\"\n [rowNumber]=\"rowNumber\"\n [pagination]=\"pagination\"\n [allowedEdit]=\"allowedEdit\"\n [submitted]=\"submitted\"\n [context]=\"context\"\n [treeData]=\"treeData\"\n [gridType]=\"gridType\"\n [masterDetail]=\"masterDetail\"\n [masterNode]=\"masterNode\"\n [detailCellRendererParams]=\"detailCellRendererParams\"\n [detailRendererComponent]=\"detailRendererComponent\"\n [detailGridTemplate]=\"detailGridTpl\"\n [treeDataChildrenField]=\"treeDataChildrenField\"\n [autoGroupColumnDef]=\"autoGroupColumnDef\"\n [groupDefaultExpanded]=\"groupDefaultExpanded\"\n (expansionChanged)=\"invokeExpansionChangedClick($event)\"\n (onRowGotoDetail)=\"invokeRowActionGotoDetail($event)\"\n (onRowAddNew)=\"invokeRowActionAddNew($event)\"\n (onRowView)=\"invokeRowActionView($event)\"\n (onRowLocation)=\"invokeRowActionLocation($event)\"\n (onRowDocument)=\"invokeRowActionDocument($event)\"\n (onRowCopy)=\"invokeRowActionCopy($event)\"\n (onRowDelete)=\"invokeRowActionDelete($event)\"\n (onRowGotoList)=\"invokeRowActionGotoList($event)\"\n (onRowEdit)=\"invokeRowActionEdit($event)\"\n (onRowPrint)=\"invokeRowActionPrint($event)\"\n (onRowHistory)=\"invokeRowActionHistory($event)\"\n (onRowOption)=\"invokeRowActionOption($event)\"\n (onRowLanguage)=\"invokeRowActionLanguage($event)\"\n (onRowCellOption)=\"invokeRowActionCellOption($event)\"\n (onRowSelection)=\"invokeRowActionSelection($event)\"\n (onShiftDoubleClick)=\"invokeShiftDoubleClick($event)\"\n (rowCountChanged)=\"invokeRowCountChanged($event)\"\n (cellOptionSelect)=\"cellOptionMenuSelected($event)\"\n (bodyScroll)=\"onBodyScroll($event)\"\n />\n \n <!-- Pagination -->\n @if (pagination) {\n <one-grid-pagination\n [paginate]=\"paginate\"\n (goToFirst)=\"invokeGoToFirst()\"\n (goToLast)=\"invokeGoToLast()\"\n (goToPrevious)=\"invokeGoToPrevious()\"\n (goToNext)=\"invokeGoToNext()\"\n (pageSizeChange)=\"invokePageSizeChange($event)\"\n />\n }\n\n <!-- Master Detail Grid template, rendered inside one-grid-body via ngTemplateOutlet.\n Declared here (self-reference) so one-grid-body's template does not need to\n import one-grid, which would create an unsupported compile-time cycle. -->\n <ng-template #detailGridTpl let-node=\"node\">\n <one-grid\n [style.height.px]=\"node.detailRowHeight\"\n [gridType]=\"'detail'\"\n [masterNode]=\"node\"\n [masterDetail]=\"masterDetail\"\n [defaultColumnDef]=\"detailCellRendererParams.detailGridOptions.defaultColumnDef\"\n [columnDefs]=\"detailCellRendererParams.detailGridOptions.columnDefs\"\n [rowData]=\"node?.detailRowData\"\n [rowNumber]=\"detailCellRendererParams.detailGridOptions?.rowNumber\"\n [allowedEdit]=\"allowedEdit\"\n [submitted]=\"submitted\"\n [context]=\"context\"\n (expansionChanged)=\"invokeExpansionChangedClick($event)\"\n (onRowGotoDetail)=\"invokeRowActionGotoDetail($event)\"\n (onRowAddNew)=\"invokeRowActionAddNew($event)\"\n (onRowView)=\"invokeRowActionView($event)\"\n (onRowLocation)=\"invokeRowActionLocation($event)\"\n (onRowDocument)=\"invokeRowActionDocument($event)\"\n (onRowCopy)=\"invokeRowActionCopy($event)\"\n (onRowDelete)=\"invokeRowActionDelete($event)\"\n (onRowGotoList)=\"invokeRowActionGotoList($event)\"\n (onRowEdit)=\"invokeRowActionEdit($event)\"\n (onRowPrint)=\"invokeRowActionPrint($event)\"\n (onRowHistory)=\"invokeRowActionHistory($event)\"\n (onRowOption)=\"invokeRowActionOption($event)\"\n (onRowLanguage)=\"invokeRowActionLanguage($event)\"\n (onRowCellOption)=\"invokeRowActionCellOption($event)\"\n (onGridReady)=\"onDetailGridReady($event)\"\n />\n </ng-template>\n</div>", styles: [""], dependencies: [{ kind: "component", type: OneGridComponent, selector: "one-grid", inputs: ["rowNumber", "allowedEdit", "submitted", "context", "rowData", "rowSelection", "enableGroupColumnDefs", "groupColumnDefs", "defaultColumnDef", "columnDefs", "gridType", "masterDetail", "masterNode", "detailCellRendererParams", "detailRendererComponent", "treeData", "treeDataChildrenField", "autoGroupColumnDef", "groupDefaultExpanded", "pagination", "paginate"], outputs: ["onGridReady", "onRowGotoDetail", "onRowAddNew", "onRowView", "onRowLocation", "onRowDocument", "onRowCopy", "onRowDelete", "onRowGotoList", "onRowEdit", "onRowPrint", "onRowHistory", "onRowOption", "onRowLanguage", "onRowSelection", "onShiftDoubleClick", "rowCountChanged", "selectionChanged", "expansionChanged", "cellOptionSelect", "onRowCellOption", "goToFirst", "goToPrevious", "goToNext", "goToLast", "pageSizeChange"] }, { kind: "component", type: OneGridHeaderComponent, selector: "one-grid-header", inputs: ["scrollLeft", "allowedEdit", "enableGroupColumnDefs", "api"] }, { kind: "component", type: OneGridBodyComponent, selector: "one-grid-body", inputs: ["rowData", "rowNumber", "api", "pagination", "allowedEdit", "enableGroupColumnDefs", "submitted", "context", "getRowId", "gridCopy$", "gridType", "masterDetail", "masterNode", "detailRowMaxHeight", "detailCellRendererParams", "detailGridTemplate", "detailRendererComponent", "treeData", "treeDataChildrenField", "autoGroupColumnDef", "groupDefaultExpanded"], outputs: ["onRowGotoDetail", "onRowAddNew", "onRowView", "onRowCopy", "onRowLocation", "onRowDocument", "onRowDelete", "onRowGotoList", "onRowEdit", "onRowPrint", "onRowHistory", "onRowOption", "onRowLanguage", "onRowCellOption", "onRowSelection", "onShiftDoubleClick", "rowCountChanged", "expansionChanged", "bodyScroll", "cellOptionSelect"] }, { kind: "component", type: OneGridPaginationComponent, selector: "one-grid-pagination", inputs: ["paginate"], outputs: ["goToFirst", "goToPrevious", "goToNext", "goToLast", "pageSizeChange"] }] }); }
|
|
3173
|
+
}
|
|
3174
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridComponent, decorators: [{
|
|
3175
|
+
type: Component,
|
|
3176
|
+
args: [{ standalone: false, selector: 'one-grid', providers: [
|
|
3177
|
+
OneGridEventService,
|
|
3178
|
+
OneGridApi,
|
|
3179
|
+
OgColumnService,
|
|
3180
|
+
OneGridSelectionService,
|
|
3181
|
+
OneGridExpansionService,
|
|
3182
|
+
OneGridRowService,
|
|
3183
|
+
OneGridCellService
|
|
3184
|
+
], template: "<div #ogRef class=\"one-grid\" (copy)=\"onGridCopy($event)\" tabindex=\"0\">\n \n <!-- Headers -->\n <one-grid-header\n [api]=\"api\"\n [enableGroupColumnDefs]=\"enableGroupColumnDefs\"\n [allowedEdit]=\"allowedEdit\"\n [scrollLeft]=\"bodyScrollLeft\"\n />\n\n <!-- Body -->\n <one-grid-body\n [gridCopy$]=\"gridCopy$\"\n [rowData]=\"rowData\"\n [api]=\"api\"\n [rowNumber]=\"rowNumber\"\n [pagination]=\"pagination\"\n [allowedEdit]=\"allowedEdit\"\n [submitted]=\"submitted\"\n [context]=\"context\"\n [treeData]=\"treeData\"\n [gridType]=\"gridType\"\n [masterDetail]=\"masterDetail\"\n [masterNode]=\"masterNode\"\n [detailCellRendererParams]=\"detailCellRendererParams\"\n [detailRendererComponent]=\"detailRendererComponent\"\n [detailGridTemplate]=\"detailGridTpl\"\n [treeDataChildrenField]=\"treeDataChildrenField\"\n [autoGroupColumnDef]=\"autoGroupColumnDef\"\n [groupDefaultExpanded]=\"groupDefaultExpanded\"\n (expansionChanged)=\"invokeExpansionChangedClick($event)\"\n (onRowGotoDetail)=\"invokeRowActionGotoDetail($event)\"\n (onRowAddNew)=\"invokeRowActionAddNew($event)\"\n (onRowView)=\"invokeRowActionView($event)\"\n (onRowLocation)=\"invokeRowActionLocation($event)\"\n (onRowDocument)=\"invokeRowActionDocument($event)\"\n (onRowCopy)=\"invokeRowActionCopy($event)\"\n (onRowDelete)=\"invokeRowActionDelete($event)\"\n (onRowGotoList)=\"invokeRowActionGotoList($event)\"\n (onRowEdit)=\"invokeRowActionEdit($event)\"\n (onRowPrint)=\"invokeRowActionPrint($event)\"\n (onRowHistory)=\"invokeRowActionHistory($event)\"\n (onRowOption)=\"invokeRowActionOption($event)\"\n (onRowLanguage)=\"invokeRowActionLanguage($event)\"\n (onRowCellOption)=\"invokeRowActionCellOption($event)\"\n (onRowSelection)=\"invokeRowActionSelection($event)\"\n (onShiftDoubleClick)=\"invokeShiftDoubleClick($event)\"\n (rowCountChanged)=\"invokeRowCountChanged($event)\"\n (cellOptionSelect)=\"cellOptionMenuSelected($event)\"\n (bodyScroll)=\"onBodyScroll($event)\"\n />\n \n <!-- Pagination -->\n @if (pagination) {\n <one-grid-pagination\n [paginate]=\"paginate\"\n (goToFirst)=\"invokeGoToFirst()\"\n (goToLast)=\"invokeGoToLast()\"\n (goToPrevious)=\"invokeGoToPrevious()\"\n (goToNext)=\"invokeGoToNext()\"\n (pageSizeChange)=\"invokePageSizeChange($event)\"\n />\n }\n\n <!-- Master Detail Grid template, rendered inside one-grid-body via ngTemplateOutlet.\n Declared here (self-reference) so one-grid-body's template does not need to\n import one-grid, which would create an unsupported compile-time cycle. -->\n <ng-template #detailGridTpl let-node=\"node\">\n <one-grid\n [style.height.px]=\"node.detailRowHeight\"\n [gridType]=\"'detail'\"\n [masterNode]=\"node\"\n [masterDetail]=\"masterDetail\"\n [defaultColumnDef]=\"detailCellRendererParams.detailGridOptions.defaultColumnDef\"\n [columnDefs]=\"detailCellRendererParams.detailGridOptions.columnDefs\"\n [rowData]=\"node?.detailRowData\"\n [rowNumber]=\"detailCellRendererParams.detailGridOptions?.rowNumber\"\n [allowedEdit]=\"allowedEdit\"\n [submitted]=\"submitted\"\n [context]=\"context\"\n (expansionChanged)=\"invokeExpansionChangedClick($event)\"\n (onRowGotoDetail)=\"invokeRowActionGotoDetail($event)\"\n (onRowAddNew)=\"invokeRowActionAddNew($event)\"\n (onRowView)=\"invokeRowActionView($event)\"\n (onRowLocation)=\"invokeRowActionLocation($event)\"\n (onRowDocument)=\"invokeRowActionDocument($event)\"\n (onRowCopy)=\"invokeRowActionCopy($event)\"\n (onRowDelete)=\"invokeRowActionDelete($event)\"\n (onRowGotoList)=\"invokeRowActionGotoList($event)\"\n (onRowEdit)=\"invokeRowActionEdit($event)\"\n (onRowPrint)=\"invokeRowActionPrint($event)\"\n (onRowHistory)=\"invokeRowActionHistory($event)\"\n (onRowOption)=\"invokeRowActionOption($event)\"\n (onRowLanguage)=\"invokeRowActionLanguage($event)\"\n (onRowCellOption)=\"invokeRowActionCellOption($event)\"\n (onGridReady)=\"onDetailGridReady($event)\"\n />\n </ng-template>\n</div>" }]
|
|
3185
|
+
}], ctorParameters: () => [{ type: OneGridApi }, { type: OneGridEventService }, { type: i0.ElementRef }], propDecorators: { ogRef: [{
|
|
3186
|
+
type: ViewChild,
|
|
3187
|
+
args: ['ogRef', { static: true }]
|
|
3188
|
+
}], rowNumber: [{
|
|
3189
|
+
type: Input
|
|
3190
|
+
}], allowedEdit: [{
|
|
3191
|
+
type: Input
|
|
3192
|
+
}], submitted: [{
|
|
3193
|
+
type: Input
|
|
3194
|
+
}], context: [{
|
|
3195
|
+
type: Input
|
|
3196
|
+
}], rowData: [{
|
|
3197
|
+
type: Input
|
|
3198
|
+
}], rowSelection: [{
|
|
3199
|
+
type: Input
|
|
3200
|
+
}], enableGroupColumnDefs: [{
|
|
3201
|
+
type: Input
|
|
3202
|
+
}], groupColumnDefs: [{
|
|
3203
|
+
type: Input
|
|
3204
|
+
}], defaultColumnDef: [{
|
|
3205
|
+
type: Input
|
|
3206
|
+
}], columnDefs: [{
|
|
3207
|
+
type: Input
|
|
3208
|
+
}], gridType: [{
|
|
3209
|
+
type: Input
|
|
3210
|
+
}], masterDetail: [{
|
|
3211
|
+
type: Input
|
|
3212
|
+
}], masterNode: [{
|
|
3213
|
+
type: Input
|
|
3214
|
+
}], detailCellRendererParams: [{
|
|
3215
|
+
type: Input
|
|
3216
|
+
}], detailRendererComponent: [{
|
|
3217
|
+
type: Input
|
|
3218
|
+
}], treeData: [{
|
|
3219
|
+
type: Input
|
|
3220
|
+
}], treeDataChildrenField: [{
|
|
3221
|
+
type: Input
|
|
3222
|
+
}], autoGroupColumnDef: [{
|
|
3223
|
+
type: Input
|
|
3224
|
+
}], groupDefaultExpanded: [{
|
|
3225
|
+
type: Input
|
|
3226
|
+
}], onGridReady: [{
|
|
3227
|
+
type: Output
|
|
3228
|
+
}], onRowGotoDetail: [{
|
|
3229
|
+
type: Output
|
|
3230
|
+
}], onRowAddNew: [{
|
|
3231
|
+
type: Output
|
|
3232
|
+
}], onRowView: [{
|
|
3233
|
+
type: Output
|
|
3234
|
+
}], onRowLocation: [{
|
|
3235
|
+
type: Output
|
|
3236
|
+
}], onRowDocument: [{
|
|
3237
|
+
type: Output
|
|
3238
|
+
}], onRowCopy: [{
|
|
3239
|
+
type: Output
|
|
3240
|
+
}], onRowDelete: [{
|
|
3241
|
+
type: Output
|
|
3242
|
+
}], onRowGotoList: [{
|
|
3243
|
+
type: Output
|
|
3244
|
+
}], onRowEdit: [{
|
|
3245
|
+
type: Output
|
|
3246
|
+
}], onRowPrint: [{
|
|
3247
|
+
type: Output
|
|
3248
|
+
}], onRowHistory: [{
|
|
3249
|
+
type: Output
|
|
3250
|
+
}], onRowOption: [{
|
|
3251
|
+
type: Output
|
|
3252
|
+
}], onRowLanguage: [{
|
|
3253
|
+
type: Output
|
|
3254
|
+
}], onRowSelection: [{
|
|
3255
|
+
type: Output
|
|
3256
|
+
}], onShiftDoubleClick: [{
|
|
3257
|
+
type: Output
|
|
3258
|
+
}], rowCountChanged: [{
|
|
3259
|
+
type: Output
|
|
3260
|
+
}], selectionChanged: [{
|
|
3261
|
+
type: Output
|
|
3262
|
+
}], expansionChanged: [{
|
|
3263
|
+
type: Output
|
|
3264
|
+
}], cellOptionSelect: [{
|
|
3265
|
+
type: Output
|
|
3266
|
+
}], onRowCellOption: [{
|
|
3267
|
+
type: Output
|
|
3268
|
+
}], pagination: [{
|
|
3269
|
+
type: Input
|
|
3270
|
+
}], paginate: [{
|
|
3271
|
+
type: Input
|
|
3272
|
+
}], goToFirst: [{
|
|
3273
|
+
type: Output
|
|
3274
|
+
}], goToPrevious: [{
|
|
3275
|
+
type: Output
|
|
3276
|
+
}], goToNext: [{
|
|
3277
|
+
type: Output
|
|
3278
|
+
}], goToLast: [{
|
|
3279
|
+
type: Output
|
|
3280
|
+
}], pageSizeChange: [{
|
|
3281
|
+
type: Output
|
|
3282
|
+
}] } });
|
|
3283
|
+
|
|
3284
|
+
class OneGridStatusComponent {
|
|
3285
|
+
constructor() {
|
|
3286
|
+
this.value = '';
|
|
3287
|
+
this.label = 0;
|
|
3288
|
+
this.type = null;
|
|
3289
|
+
}
|
|
3290
|
+
oneInit(params) {
|
|
3291
|
+
this.params = params;
|
|
3292
|
+
this.label = params?.value ?? 0;
|
|
3293
|
+
this.type = this.getType(params.columnDef.field);
|
|
3294
|
+
this.value = this.getLabel(this.type, this.label);
|
|
3295
|
+
}
|
|
3296
|
+
refresh(params) {
|
|
3297
|
+
return false;
|
|
3298
|
+
}
|
|
3299
|
+
getType(field) {
|
|
3300
|
+
return field === 'enableStatus' || field === 'activeStatus' || field === 'operationActiveStatus' ? field : null;
|
|
3301
|
+
}
|
|
3302
|
+
getLabel(type, status) {
|
|
3303
|
+
if (!type)
|
|
3304
|
+
return 'N/A';
|
|
3305
|
+
const labels = { enableStatus: ['Disabled', 'Enabled'], activeStatus: ['Inactive', 'Active'], operationActiveStatus: ['Inactive', 'Active'] };
|
|
3306
|
+
return labels[type][status === 1 ? 1 : 0];
|
|
3307
|
+
}
|
|
3308
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridStatusComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3309
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: OneGridStatusComponent, selector: "one-grid-status", ngImport: i0, template: "<span class=\"one-cell-status\"\n [style.width.px]=\"params.columnDef?.width\"\n [style.min-width.px]=\"params.columnDef?.minWidth\"\n [style.max-width.px]=\"params.columnDef?.maxWidth\"\n >\n <span class=\"one-cell-status-body\" [ngClass]=\"label === 1 ? 'one-success-bg' : 'one-warning-bg'\">\n {{ value }}\n </span>\n</span>\n", styles: [""], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] }); }
|
|
3310
|
+
}
|
|
3311
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridStatusComponent, decorators: [{
|
|
3312
|
+
type: Component,
|
|
3313
|
+
args: [{ standalone: false, selector: 'one-grid-status', template: "<span class=\"one-cell-status\"\n [style.width.px]=\"params.columnDef?.width\"\n [style.min-width.px]=\"params.columnDef?.minWidth\"\n [style.max-width.px]=\"params.columnDef?.maxWidth\"\n >\n <span class=\"one-cell-status-body\" [ngClass]=\"label === 1 ? 'one-success-bg' : 'one-warning-bg'\">\n {{ value }}\n </span>\n</span>\n" }]
|
|
3314
|
+
}] });
|
|
3315
|
+
|
|
3316
|
+
class CellActionButtonVisiblePipe {
|
|
3317
|
+
transform(column, node) {
|
|
3318
|
+
return (node?.leaf && !(node?.group && node?.leafGroup) && !column?.autoGroupField) || (!node?.leaf && (node?.group || node?.leafGroup) && column?.autoGroupField && column?.editableLevels?.includes(node.level));
|
|
3319
|
+
}
|
|
3320
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellActionButtonVisiblePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
3321
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: CellActionButtonVisiblePipe, name: "cellActionButtonVisible" }); }
|
|
3322
|
+
}
|
|
3323
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellActionButtonVisiblePipe, decorators: [{
|
|
3324
|
+
type: Pipe,
|
|
3325
|
+
args: [{
|
|
3326
|
+
standalone: false,
|
|
3327
|
+
name: 'cellActionButtonVisible'
|
|
3328
|
+
}]
|
|
3329
|
+
}] });
|
|
3330
|
+
|
|
3331
|
+
class CellNumberValuePipe {
|
|
3332
|
+
transform(value) {
|
|
3333
|
+
if (value === null || value === undefined)
|
|
3334
|
+
return undefined;
|
|
3335
|
+
return Number(value);
|
|
3336
|
+
}
|
|
3337
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellNumberValuePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
3338
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: CellNumberValuePipe, name: "cellNumberValue" }); }
|
|
3339
|
+
}
|
|
3340
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellNumberValuePipe, decorators: [{
|
|
3341
|
+
type: Pipe,
|
|
3342
|
+
args: [{
|
|
3343
|
+
standalone: false,
|
|
3344
|
+
name: 'cellNumberValue'
|
|
3345
|
+
}]
|
|
3346
|
+
}] });
|
|
3347
|
+
|
|
3348
|
+
class CellFieldPipe {
|
|
3349
|
+
transform(rowIndex, field) {
|
|
3350
|
+
if (rowIndex === null || rowIndex === undefined || !field)
|
|
3351
|
+
return '';
|
|
3352
|
+
return getCellField(rowIndex, field);
|
|
3353
|
+
}
|
|
3354
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellFieldPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
3355
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: CellFieldPipe, name: "cellField" }); }
|
|
3356
|
+
}
|
|
3357
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellFieldPipe, decorators: [{
|
|
3358
|
+
type: Pipe,
|
|
3359
|
+
args: [{
|
|
3360
|
+
standalone: false,
|
|
3361
|
+
name: 'cellField'
|
|
3362
|
+
}]
|
|
3363
|
+
}] });
|
|
3364
|
+
|
|
3365
|
+
class CellStateGroupRendererPipe {
|
|
3366
|
+
constructor() {
|
|
3367
|
+
this._cellFieldValue = new CellFieldValuePipe();
|
|
3368
|
+
}
|
|
3369
|
+
transform(value, data, column) {
|
|
3370
|
+
return value ? this._cellFieldValue.transform(data, column.field) : column?.cellRendererParams?.placeholder ?? '';
|
|
3371
|
+
}
|
|
3372
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellStateGroupRendererPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
3373
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: CellStateGroupRendererPipe, name: "cellStateGroupRenderer" }); }
|
|
3374
|
+
}
|
|
3375
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CellStateGroupRendererPipe, decorators: [{
|
|
3376
|
+
type: Pipe,
|
|
3377
|
+
args: [{
|
|
3378
|
+
standalone: false,
|
|
3379
|
+
name: 'cellStateGroupRenderer'
|
|
3380
|
+
}]
|
|
3381
|
+
}] });
|
|
3382
|
+
|
|
3383
|
+
class OneGridCellCurrencyComponent {
|
|
3384
|
+
constructor(cellService, eventService) {
|
|
3385
|
+
this.cellService = cellService;
|
|
3386
|
+
this.eventService = eventService;
|
|
3387
|
+
this.value = '';
|
|
3388
|
+
this.allowedEdit = false;
|
|
3389
|
+
this.getCellField = getCellField;
|
|
3390
|
+
this.cellEditablePipe = new CellEditablePipe();
|
|
3391
|
+
}
|
|
3392
|
+
oneInit(params) {
|
|
3393
|
+
this.params = params;
|
|
3394
|
+
this.value = params.data[params.columnDef.field];
|
|
3395
|
+
this.result = this.value;
|
|
3396
|
+
this.allowedEdit = params.context.componentParent.allowedEdit || false;
|
|
3397
|
+
this.unsubscribe = this.eventService.addEventListener('cellStateChanged', (payload) => {
|
|
3398
|
+
if (this.params.node.rowId === payload.node.rowId) {
|
|
3399
|
+
this.result = this.cellService.generateCellState(this.params.node, this.params.columnDef).value;
|
|
3400
|
+
}
|
|
3401
|
+
});
|
|
3402
|
+
}
|
|
3403
|
+
refresh(params) {
|
|
3404
|
+
// Update params and values when grid data refreshes
|
|
3405
|
+
this.params = params;
|
|
3406
|
+
this.value = params.data[params.columnDef.field];
|
|
3407
|
+
this.result = this.value;
|
|
3408
|
+
this.allowedEdit = params.context.componentParent.allowedEdit || false;
|
|
3409
|
+
return true;
|
|
3410
|
+
}
|
|
3411
|
+
get isEditable() {
|
|
3412
|
+
if (!this.params.node || !this.params.columnDef)
|
|
3413
|
+
return false;
|
|
3414
|
+
return this.cellEditablePipe.transform(this.params.node.cellStates, this.params.columnDef, this.params.node, this.cellService.editableFn, this.cellService.updatableFn, this.allowedEdit);
|
|
3415
|
+
}
|
|
3416
|
+
startEdit(node, column) {
|
|
3417
|
+
if (!this.isEditable) {
|
|
3418
|
+
return;
|
|
3419
|
+
}
|
|
3420
|
+
if (node) {
|
|
3421
|
+
node.editing[column.field] = true;
|
|
3422
|
+
setTimeout(() => {
|
|
3423
|
+
const input = document.querySelector(`[data-cell-id="${getCellField(node.rowIndex, column.field)}"] input`);
|
|
3424
|
+
if (input) {
|
|
3425
|
+
input.focus();
|
|
3426
|
+
const value = input.value;
|
|
3427
|
+
if (value && ["text"].includes(input.type)) {
|
|
3428
|
+
input.setSelectionRange(value.length, value.length);
|
|
3429
|
+
}
|
|
3430
|
+
}
|
|
3431
|
+
}, 10);
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
stopEdit(node, column, event) {
|
|
3435
|
+
if (node) {
|
|
3436
|
+
node.data[column.field] = event.target.value === '' ? null : event.target.value;
|
|
3437
|
+
node.cellStates = this.cellService.generateCellStates(node);
|
|
3438
|
+
node.editing[column.field] = false;
|
|
3439
|
+
this.eventService.dispatchEvent('cellStateChanged', {
|
|
3440
|
+
data: { ...node.data },
|
|
3441
|
+
node: node,
|
|
3442
|
+
column: column
|
|
3443
|
+
});
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
cancelEdit(node, column) {
|
|
3447
|
+
if (node) {
|
|
3448
|
+
node.editing[column.field] = false;
|
|
3449
|
+
}
|
|
3450
|
+
}
|
|
3451
|
+
ngOnDestroy() {
|
|
3452
|
+
this.unsubscribe?.();
|
|
3453
|
+
}
|
|
3454
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridCellCurrencyComponent, deps: [{ token: OneGridCellService }, { token: OneGridEventService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3455
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.12", type: OneGridCellCurrencyComponent, selector: "app-one-grid-cell-currency", inputs: { allowedEdit: "allowedEdit" }, ngImport: i0, template: "<div class=\"cell-wrapper\"\n [class.editable]=\"isEditable\"\n [attr.data-cell-id]=\"getCellField(params.node?.rowIndex, params.columnDef?.field)\"\n [style.min-width.px]=\"params.columnDef?.minWidth\"\n [style.max-width.px]=\"params.columnDef?.maxWidth\">\n\n @if (params.node?.editing?.[params.columnDef?.field]) {\n <input class=\"one-cell-input\"\n name=\"{{ params.node?.rowIndex }}_{{ params.columnDef?.field }}\"\n oneCellInputValidator\n validationType=\"number\"\n [placeholder]=\"params.columnDef?.cellRendererParams?.placeholder || ''\"\n type=\"text\"\n [(ngModel)]=\"value\"\n [maxLength]=\"250\"\n (blur)=\"stopEdit(params.node, params.columnDef, $event)\"\n (keydown.enter)=\"stopEdit(params.node, params.columnDef, $event)\"\n (keydown.esc)=\"cancelEdit(params.node, params.columnDef)\" />\n }\n @else {\n <div class=\"d-flex justify-content-between px-2 pt-1\"\n [class.one-cell-allowed-edit-active]=\"isEditable\"\n (dblclick)=\"startEdit(params.node, params.columnDef)\">\n <span class=\"currency-code\" style=\"font-weight: bold;\">{{ this.params?.data?.currency?.currencyCode || 'USD' }}</span>\n <span class=\"amount-value\">\n {{ result | number:(this.params?.field === 'amount' ? '1.3-3' : '1.2-2') }}\n </span>\n </div>\n }\n</div>\n", styles: [".one-cell-input{position:absolute;top:0;left:0;width:calc(100% - 1px);height:100%;padding:0 6px;background-color:var(--one-grid-input-bg, var(--bs-input-bg, #fff));border:1px solid var(--one-grid-success, var(--bs-success, #198754));border-radius:var(--one-grid-action-btn-radius, 4px);z-index:5}.one-cell-input:focus{background:var(--one-grid-input-bg, var(--bs-input-bg, #fff));border:1px solid var(--one-grid-success, var(--bs-success, #198754))}:host{display:block;width:100%;height:100%;position:relative}.cell-wrapper{position:relative;width:100%;height:100%}.cell-wrapper.editable:before{content:\"\";position:absolute;top:4px;right:4px;width:4px;height:4px;background-color:var(--one-grid-success, var(--bs-success, #198754));border-radius:50%;z-index:1;opacity:.5;transition:opacity .2s ease}.cell-wrapper.editable:hover:before{opacity:1}\n"], dependencies: [{ kind: "directive", type: i3$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i3$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: OneCellInputValidatorDirective, selector: "[oneCellInputValidator]", inputs: ["validationType", "regex"] }, { kind: "pipe", type: i2.DecimalPipe, name: "number" }] }); }
|
|
3456
|
+
}
|
|
3457
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridCellCurrencyComponent, decorators: [{
|
|
3458
|
+
type: Component,
|
|
3459
|
+
args: [{ standalone: false, selector: 'app-one-grid-cell-currency', template: "<div class=\"cell-wrapper\"\n [class.editable]=\"isEditable\"\n [attr.data-cell-id]=\"getCellField(params.node?.rowIndex, params.columnDef?.field)\"\n [style.min-width.px]=\"params.columnDef?.minWidth\"\n [style.max-width.px]=\"params.columnDef?.maxWidth\">\n\n @if (params.node?.editing?.[params.columnDef?.field]) {\n <input class=\"one-cell-input\"\n name=\"{{ params.node?.rowIndex }}_{{ params.columnDef?.field }}\"\n oneCellInputValidator\n validationType=\"number\"\n [placeholder]=\"params.columnDef?.cellRendererParams?.placeholder || ''\"\n type=\"text\"\n [(ngModel)]=\"value\"\n [maxLength]=\"250\"\n (blur)=\"stopEdit(params.node, params.columnDef, $event)\"\n (keydown.enter)=\"stopEdit(params.node, params.columnDef, $event)\"\n (keydown.esc)=\"cancelEdit(params.node, params.columnDef)\" />\n }\n @else {\n <div class=\"d-flex justify-content-between px-2 pt-1\"\n [class.one-cell-allowed-edit-active]=\"isEditable\"\n (dblclick)=\"startEdit(params.node, params.columnDef)\">\n <span class=\"currency-code\" style=\"font-weight: bold;\">{{ this.params?.data?.currency?.currencyCode || 'USD' }}</span>\n <span class=\"amount-value\">\n {{ result | number:(this.params?.field === 'amount' ? '1.3-3' : '1.2-2') }}\n </span>\n </div>\n }\n</div>\n", styles: [".one-cell-input{position:absolute;top:0;left:0;width:calc(100% - 1px);height:100%;padding:0 6px;background-color:var(--one-grid-input-bg, var(--bs-input-bg, #fff));border:1px solid var(--one-grid-success, var(--bs-success, #198754));border-radius:var(--one-grid-action-btn-radius, 4px);z-index:5}.one-cell-input:focus{background:var(--one-grid-input-bg, var(--bs-input-bg, #fff));border:1px solid var(--one-grid-success, var(--bs-success, #198754))}:host{display:block;width:100%;height:100%;position:relative}.cell-wrapper{position:relative;width:100%;height:100%}.cell-wrapper.editable:before{content:\"\";position:absolute;top:4px;right:4px;width:4px;height:4px;background-color:var(--one-grid-success, var(--bs-success, #198754));border-radius:50%;z-index:1;opacity:.5;transition:opacity .2s ease}.cell-wrapper.editable:hover:before{opacity:1}\n"] }]
|
|
3460
|
+
}], ctorParameters: () => [{ type: OneGridCellService }, { type: OneGridEventService }], propDecorators: { allowedEdit: [{
|
|
3461
|
+
type: Input
|
|
3462
|
+
}] } });
|
|
3463
|
+
|
|
3464
|
+
class OneGridModule {
|
|
3465
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
3466
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: OneGridModule, declarations: [OneGridComponent,
|
|
3467
|
+
OneGridHeaderComponent,
|
|
3468
|
+
OneGridBodyComponent,
|
|
3469
|
+
OneGridCheckboxComponent,
|
|
3470
|
+
OneGridCheckboxHeaderComponent,
|
|
3471
|
+
OneGridRowActionComponent,
|
|
3472
|
+
OneGridPaginationComponent,
|
|
3473
|
+
OneGridStatusComponent,
|
|
3474
|
+
OneGridCellGroupRendererComponent,
|
|
3475
|
+
CellFieldValueEmptyPipe,
|
|
3476
|
+
CellValueGetterPipe,
|
|
3477
|
+
CellFieldValuePipe,
|
|
3478
|
+
CellActionButtonVisiblePipe,
|
|
3479
|
+
CellEditablePipe,
|
|
3480
|
+
CellInvalidPipe,
|
|
3481
|
+
CellSelectedPipe,
|
|
3482
|
+
CellActionButtonEnablePipe,
|
|
3483
|
+
CellNumberValuePipe,
|
|
3484
|
+
CellDisableResolverPipe,
|
|
3485
|
+
CellFieldPipe,
|
|
3486
|
+
CellKeyPipe,
|
|
3487
|
+
CellLevelPaddingPipe,
|
|
3488
|
+
ColumnSortStatePipe,
|
|
3489
|
+
HeaderCheckboxDisabledPipe,
|
|
3490
|
+
HeaderCheckboxCheckedPipe,
|
|
3491
|
+
HeaderCheckboxIndeterminatePipe,
|
|
3492
|
+
CellStateRendererPipe,
|
|
3493
|
+
CellStateGroupRendererPipe,
|
|
3494
|
+
OneCellInputValidatorDirective,
|
|
3495
|
+
OneCellRendererComponentDirective,
|
|
3496
|
+
OneCellTextExpandDirective,
|
|
3497
|
+
OneGridCellCurrencyComponent,
|
|
3498
|
+
OneGridCellOptionMenuComponent], imports: [CommonModule,
|
|
3499
|
+
FormsModule,
|
|
3500
|
+
ScrollingModule,
|
|
3501
|
+
NgbTypeahead,
|
|
3502
|
+
NgbHighlight,
|
|
3503
|
+
ReactiveFormsModule,
|
|
3504
|
+
CdkDragPlaceholder, i3.LucideAngularModule], exports: [OneGridComponent] }); }
|
|
3505
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridModule, imports: [CommonModule,
|
|
3506
|
+
FormsModule,
|
|
3507
|
+
ScrollingModule,
|
|
3508
|
+
NgbHighlight,
|
|
3509
|
+
ReactiveFormsModule,
|
|
3510
|
+
LucideAngularModule.pick(icons)] }); }
|
|
3511
|
+
}
|
|
3512
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridModule, decorators: [{
|
|
3513
|
+
type: NgModule,
|
|
3514
|
+
args: [{
|
|
3515
|
+
declarations: [
|
|
3516
|
+
OneGridComponent,
|
|
3517
|
+
OneGridHeaderComponent,
|
|
3518
|
+
OneGridBodyComponent,
|
|
3519
|
+
OneGridCheckboxComponent,
|
|
3520
|
+
OneGridCheckboxHeaderComponent,
|
|
3521
|
+
OneGridRowActionComponent,
|
|
3522
|
+
OneGridPaginationComponent,
|
|
3523
|
+
OneGridStatusComponent,
|
|
3524
|
+
OneGridCellGroupRendererComponent,
|
|
3525
|
+
CellFieldValueEmptyPipe,
|
|
3526
|
+
CellValueGetterPipe,
|
|
3527
|
+
CellFieldValuePipe,
|
|
3528
|
+
CellActionButtonVisiblePipe,
|
|
3529
|
+
CellEditablePipe,
|
|
3530
|
+
CellInvalidPipe,
|
|
3531
|
+
CellSelectedPipe,
|
|
3532
|
+
CellActionButtonEnablePipe,
|
|
3533
|
+
CellNumberValuePipe,
|
|
3534
|
+
CellDisableResolverPipe,
|
|
3535
|
+
CellFieldPipe,
|
|
3536
|
+
CellKeyPipe,
|
|
3537
|
+
CellLevelPaddingPipe,
|
|
3538
|
+
ColumnSortStatePipe,
|
|
3539
|
+
HeaderCheckboxDisabledPipe,
|
|
3540
|
+
HeaderCheckboxCheckedPipe,
|
|
3541
|
+
HeaderCheckboxIndeterminatePipe,
|
|
3542
|
+
CellStateRendererPipe,
|
|
3543
|
+
CellStateGroupRendererPipe,
|
|
3544
|
+
OneCellInputValidatorDirective,
|
|
3545
|
+
OneCellRendererComponentDirective,
|
|
3546
|
+
OneCellTextExpandDirective,
|
|
3547
|
+
OneGridCellCurrencyComponent,
|
|
3548
|
+
OneGridCellOptionMenuComponent
|
|
3549
|
+
],
|
|
3550
|
+
imports: [
|
|
3551
|
+
CommonModule,
|
|
3552
|
+
FormsModule,
|
|
3553
|
+
ScrollingModule,
|
|
3554
|
+
NgbTypeahead,
|
|
3555
|
+
NgbHighlight,
|
|
3556
|
+
ReactiveFormsModule,
|
|
3557
|
+
CdkDragPlaceholder,
|
|
3558
|
+
LucideAngularModule.pick(icons),
|
|
3559
|
+
],
|
|
3560
|
+
exports: [OneGridComponent]
|
|
3561
|
+
}]
|
|
3562
|
+
}] });
|
|
3563
|
+
|
|
3564
|
+
/*
|
|
3565
|
+
* Public API Surface of one-grid
|
|
3566
|
+
*/
|
|
3567
|
+
|
|
3568
|
+
/**
|
|
3569
|
+
* Generated bundle index. Do not edit.
|
|
3570
|
+
*/
|
|
3571
|
+
|
|
3572
|
+
export { OneGridApi, OneGridCellService, OneGridComponent, OneGridEventService, OneGridExpansionService, OneGridModule, OneGridSelectionService, OneGridTreeDataService, OnePageSizeOption, OneRowNode, ValidationRules, Validators, applyDefaultColumnDef, getCellError, resolveOneCellRendererParams, resolveOneColumDefParams, resolveOneValueGetterParams };
|
|
3573
|
+
//# sourceMappingURL=one-grid-core-angular.mjs.map
|