@operato/data-grist 2.0.0-alpha.6 → 2.0.0-alpha.60
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/CHANGELOG.md +263 -0
- package/dist/src/accumulator/accumulator.js +4 -4
- package/dist/src/accumulator/accumulator.js.map +1 -1
- package/dist/src/configure/rows-option-builder.js +2 -1
- package/dist/src/configure/rows-option-builder.js.map +1 -1
- package/dist/src/configure/zero-config.js +1 -0
- package/dist/src/configure/zero-config.js.map +1 -1
- package/dist/src/data-card/data-card.d.ts +1 -1
- package/dist/src/data-card/event-handlers/record-card-click-handler.js +1 -1
- package/dist/src/data-card/event-handlers/record-card-click-handler.js.map +1 -1
- package/dist/src/data-card/record-card.d.ts +1 -1
- package/dist/src/data-grid/data-grid-accum-field.js +3 -2
- package/dist/src/data-grid/data-grid-accum-field.js.map +1 -1
- package/dist/src/data-grid/data-grid-body.d.ts +3 -3
- package/dist/src/data-grid/data-grid-body.js +9 -4
- package/dist/src/data-grid/data-grid-body.js.map +1 -1
- package/dist/src/data-grid/data-grid-field.d.ts +1 -1
- package/dist/src/data-grid/data-grid-field.js +2 -2
- package/dist/src/data-grid/data-grid-field.js.map +1 -1
- package/dist/src/data-grid/data-grid-footer.d.ts +1 -1
- package/dist/src/data-grid/data-grid-header.js +1 -3
- package/dist/src/data-grid/data-grid-header.js.map +1 -1
- package/dist/src/data-grid/data-grid.d.ts +1 -1
- package/dist/src/data-grid/data-grid.js +1 -1
- package/dist/src/data-grid/data-grid.js.map +1 -1
- package/dist/src/data-grist.d.ts +226 -4
- package/dist/src/data-grist.js +196 -4
- package/dist/src/data-grist.js.map +1 -1
- package/dist/src/data-list/data-list-gutter.js +12 -0
- package/dist/src/data-list/data-list-gutter.js.map +1 -1
- package/dist/src/data-list/data-list.d.ts +1 -1
- package/dist/src/data-list/event-handlers/record-partial-click-handler.js +1 -1
- package/dist/src/data-list/event-handlers/record-partial-click-handler.js.map +1 -1
- package/dist/src/data-list/record-partial.d.ts +1 -1
- package/dist/src/data-list/record-partial.js +2 -0
- package/dist/src/data-list/record-partial.js.map +1 -1
- package/dist/src/data-manipulator.d.ts +6 -6
- package/dist/src/data-manipulator.js +44 -29
- package/dist/src/data-manipulator.js.map +1 -1
- package/dist/src/data-report/data-report-body.d.ts +1 -1
- package/dist/src/data-report/data-report-component.d.ts +1 -1
- package/dist/src/data-report.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-checkbox.d.ts +3 -2
- package/dist/src/editors/ox-grist-editor-checkbox.js +9 -2
- package/dist/src/editors/ox-grist-editor-checkbox.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-color.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-date.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-datetime.d.ts +2 -2
- package/dist/src/editors/ox-grist-editor-datetime.js +1 -2
- package/dist/src/editors/ox-grist-editor-datetime.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-email.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-file.d.ts +3 -2
- package/dist/src/editors/ox-grist-editor-file.js +8 -2
- package/dist/src/editors/ox-grist-editor-file.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-image.d.ts +2 -2
- package/dist/src/editors/ox-grist-editor-image.js +8 -8
- package/dist/src/editors/ox-grist-editor-image.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-month.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-multiple-select.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-number.d.ts +3 -2
- package/dist/src/editors/ox-grist-editor-number.js +10 -9
- package/dist/src/editors/ox-grist-editor-number.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-password.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-select.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-tel.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-text.d.ts +2 -1
- package/dist/src/editors/ox-grist-editor-text.js +3 -0
- package/dist/src/editors/ox-grist-editor-text.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-textarea.d.ts +2 -1
- package/dist/src/editors/ox-grist-editor-textarea.js +3 -0
- package/dist/src/editors/ox-grist-editor-textarea.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-time.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-tree.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-week.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor.d.ts +4 -4
- package/dist/src/editors/ox-grist-editor.js +14 -12
- package/dist/src/editors/ox-grist-editor.js.map +1 -1
- package/dist/src/editors/ox-input-tree.d.ts +1 -1
- package/dist/src/empty-note.d.ts +1 -1
- package/dist/src/filters/filter-range-date.js +12 -1
- package/dist/src/filters/filter-range-date.js.map +1 -1
- package/dist/src/filters/filters-form.d.ts +1 -0
- package/dist/src/filters/filters-form.js +41 -23
- package/dist/src/filters/filters-form.js.map +1 -1
- package/dist/src/handlers/contextmenu-tree-mutation.js +1 -19
- package/dist/src/handlers/contextmenu-tree-mutation.js.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/record-view/record-creator.d.ts +1 -1
- package/dist/src/record-view/record-view-body.d.ts +2 -2
- package/dist/src/record-view/record-view.d.ts +1 -1
- package/dist/src/renderers/ox-grist-renderer-progress.d.ts +1 -1
- package/dist/src/renderers/ox-grist-renderer-tree.d.ts +1 -1
- package/dist/src/renderers/ox-grist-renderer.d.ts +2 -2
- package/dist/src/types.d.ts +1 -8
- package/dist/src/types.js.map +1 -1
- package/dist/stories/accumulator.stories.js +117 -114
- package/dist/stories/accumulator.stories.js.map +1 -1
- package/dist/stories/dynamic-editable.stories.js +89 -80
- package/dist/stories/dynamic-editable.stories.js.map +1 -1
- package/dist/stories/grist-modes.stories.js +23 -2
- package/dist/stories/grist-modes.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/default-value/default-value.md +1 -1
- package/docs/default-value/value-generator/date-generator.md +2 -2
- package/docs/default-value/value-generator/month-date-generator.md +2 -2
- package/docs/default-value/value-generator/week-date-generator.md +2 -2
- package/docs/default-value/value-generator/year-date-generator.md +2 -2
- package/package.json +20 -19
- package/src/accumulator/accumulator.ts +4 -4
- package/src/configure/rows-option-builder.ts +11 -1
- package/src/configure/zero-config.ts +1 -0
- package/src/data-card/event-handlers/record-card-click-handler.ts +1 -1
- package/src/data-grid/data-grid-accum-field.ts +3 -2
- package/src/data-grid/data-grid-body.ts +10 -5
- package/src/data-grid/data-grid-field.ts +1 -1
- package/src/data-grid/data-grid-header.ts +2 -4
- package/src/data-grid/data-grid.ts +3 -3
- package/src/data-grist.ts +251 -4
- package/src/data-list/data-list-gutter.ts +12 -0
- package/src/data-list/event-handlers/record-partial-click-handler.ts +1 -1
- package/src/data-list/record-partial.ts +2 -0
- package/src/data-manipulator.ts +52 -31
- package/src/editors/ox-grist-editor-checkbox.ts +12 -2
- package/src/editors/ox-grist-editor-datetime.ts +1 -2
- package/src/editors/ox-grist-editor-file.ts +12 -2
- package/src/editors/ox-grist-editor-image.ts +10 -7
- package/src/editors/ox-grist-editor-number.ts +11 -9
- package/src/editors/ox-grist-editor-text.ts +4 -0
- package/src/editors/ox-grist-editor-textarea.ts +4 -0
- package/src/editors/ox-grist-editor.ts +14 -10
- package/src/filters/filter-range-date.ts +16 -1
- package/src/filters/filters-form.ts +69 -46
- package/src/handlers/contextmenu-tree-mutation.ts +1 -19
- package/src/index.ts +0 -1
- package/src/types.ts +1 -9
- package/stories/accumulator.stories.ts +118 -119
- package/stories/dynamic-editable.stories.ts +96 -86
- package/stories/grist-modes.stories.ts +23 -2
- package/themes/grist-theme.css +1 -1
- package/dist/src/value-generator/date-generator.d.ts +0 -6
- package/dist/src/value-generator/date-generator.js +0 -30
- package/dist/src/value-generator/date-generator.js.map +0 -1
- package/dist/src/value-generator/hour-time-generator.d.ts +0 -7
- package/dist/src/value-generator/hour-time-generator.js +0 -29
- package/dist/src/value-generator/hour-time-generator.js.map +0 -1
- package/dist/src/value-generator/index.d.ts +0 -1
- package/dist/src/value-generator/index.js +0 -2
- package/dist/src/value-generator/index.js.map +0 -1
- package/dist/src/value-generator/minute-time-generator.d.ts +0 -7
- package/dist/src/value-generator/minute-time-generator.js +0 -29
- package/dist/src/value-generator/minute-time-generator.js.map +0 -1
- package/dist/src/value-generator/month-date-generator.d.ts +0 -7
- package/dist/src/value-generator/month-date-generator.js +0 -31
- package/dist/src/value-generator/month-date-generator.js.map +0 -1
- package/dist/src/value-generator/now-generator.d.ts +0 -4
- package/dist/src/value-generator/now-generator.js +0 -8
- package/dist/src/value-generator/now-generator.js.map +0 -1
- package/dist/src/value-generator/registry.d.ts +0 -11
- package/dist/src/value-generator/registry.js +0 -50
- package/dist/src/value-generator/registry.js.map +0 -1
- package/dist/src/value-generator/time-generator.d.ts +0 -6
- package/dist/src/value-generator/time-generator.js +0 -28
- package/dist/src/value-generator/time-generator.js.map +0 -1
- package/dist/src/value-generator/today-generator.d.ts +0 -4
- package/dist/src/value-generator/today-generator.js +0 -8
- package/dist/src/value-generator/today-generator.js.map +0 -1
- package/dist/src/value-generator/week-date-generator.d.ts +0 -7
- package/dist/src/value-generator/week-date-generator.js +0 -29
- package/dist/src/value-generator/week-date-generator.js.map +0 -1
- package/dist/src/value-generator/year-date-generator.d.ts +0 -7
- package/dist/src/value-generator/year-date-generator.js +0 -29
- package/dist/src/value-generator/year-date-generator.js.map +0 -1
- package/src/value-generator/date-generator.ts +0 -35
- package/src/value-generator/hour-time-generator.ts +0 -43
- package/src/value-generator/index.ts +0 -1
- package/src/value-generator/minute-time-generator.ts +0 -43
- package/src/value-generator/month-date-generator.ts +0 -38
- package/src/value-generator/now-generator.ts +0 -10
- package/src/value-generator/registry.ts +0 -58
- package/src/value-generator/time-generator.ts +0 -33
- package/src/value-generator/today-generator.ts +0 -10
- package/src/value-generator/week-date-generator.ts +0 -40
- package/src/value-generator/year-date-generator.ts +0 -36
package/src/data-grist.ts
CHANGED
@@ -33,6 +33,11 @@ import {
|
|
33
33
|
} from './types'
|
34
34
|
import { convertListParamToSearchString, convertSearchStringToListParam } from './utils'
|
35
35
|
|
36
|
+
/**
|
37
|
+
* A custom element for rendering data in a grid, list, or card format.
|
38
|
+
*
|
39
|
+
* @element ox-grist
|
40
|
+
*/
|
36
41
|
@customElement('ox-grist')
|
37
42
|
export class DataGrist extends LitElement implements DataConsumer {
|
38
43
|
static styles = [
|
@@ -80,21 +85,89 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
80
85
|
box-sizing: border-box;
|
81
86
|
background-color: var(--grist-background-color);
|
82
87
|
|
83
|
-
z-index:
|
88
|
+
z-index: 2;
|
84
89
|
}
|
85
90
|
`
|
86
91
|
]
|
87
92
|
|
93
|
+
/**
|
94
|
+
* The rendering mode of the component, which can be 'GRID', 'LIST', or 'CARD'.
|
95
|
+
* Default is 'GRID'.
|
96
|
+
*
|
97
|
+
* @property {string}
|
98
|
+
*/
|
88
99
|
@property() mode: 'GRID' | 'LIST' | 'CARD' = 'GRID'
|
100
|
+
|
101
|
+
/**
|
102
|
+
* The configuration object for the data grist.
|
103
|
+
*
|
104
|
+
* @property {Object}
|
105
|
+
*/
|
89
106
|
@property() config: any
|
107
|
+
|
108
|
+
/**
|
109
|
+
* The data to be displayed in the data grist.
|
110
|
+
*
|
111
|
+
* @property {GristData}
|
112
|
+
*/
|
90
113
|
@property({ type: Object }) data: GristData = ZERO_DATA
|
114
|
+
|
115
|
+
/**
|
116
|
+
* An array of selected records in the data grist.
|
117
|
+
*
|
118
|
+
* @property {GristRecord[]}
|
119
|
+
*/
|
91
120
|
@property({ type: Array }) selectedRecords?: GristRecord[]
|
121
|
+
|
122
|
+
/**
|
123
|
+
* Indicates whether explicit fetching of data is enabled. If true, data will be fetched
|
124
|
+
* only when `fetch` method is called. Default is false.
|
125
|
+
*
|
126
|
+
* @property {boolean}
|
127
|
+
*/
|
92
128
|
@property({ type: Boolean, attribute: 'explicit-fetch' }) explicitFetch: boolean = false
|
129
|
+
|
130
|
+
/**
|
131
|
+
* The fetch handler function used to retrieve data from a remote source.
|
132
|
+
*
|
133
|
+
* @property {FetchHandler}
|
134
|
+
*/
|
93
135
|
@property() fetchHandler?: FetchHandler
|
136
|
+
|
137
|
+
/**
|
138
|
+
* Additional fetch options to be passed to the fetch handler.
|
139
|
+
*
|
140
|
+
* @property {Object}
|
141
|
+
*/
|
94
142
|
@property() fetchOptions: any
|
143
|
+
|
144
|
+
/**
|
145
|
+
* An array of filter values to be applied to the data grist.
|
146
|
+
*
|
147
|
+
* @property {FilterValue[]}
|
148
|
+
*/
|
95
149
|
@property({ type: Array }) filters?: FilterValue[]
|
150
|
+
|
151
|
+
/**
|
152
|
+
* An array of sorters to determine the order of records in the data grist.
|
153
|
+
*
|
154
|
+
* @property {SortersConfig}
|
155
|
+
*/
|
96
156
|
@property({ type: Array }) sorters?: SortersConfig
|
157
|
+
|
158
|
+
/**
|
159
|
+
* The pagination configuration for the data grist.
|
160
|
+
*
|
161
|
+
* @property {PaginationConfig}
|
162
|
+
*/
|
97
163
|
@property({ type: Object }) pagination?: PaginationConfig
|
164
|
+
|
165
|
+
/**
|
166
|
+
* Indicates whether URL parameters are sensitive to changes. If true, changes in URL
|
167
|
+
* parameters will trigger data fetching. Default is undefined.
|
168
|
+
*
|
169
|
+
* @property {boolean}
|
170
|
+
*/
|
98
171
|
@property({ type: Boolean, attribute: 'url-params-sensitive' }) urlParamsSensitive?: boolean
|
99
172
|
|
100
173
|
@state() _data: GristData = ZERO_DATA
|
@@ -372,10 +445,22 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
372
445
|
}
|
373
446
|
}
|
374
447
|
|
448
|
+
/**
|
449
|
+
* Gets the current state of the component. The state includes information about the
|
450
|
+
* dirty records and their changes.
|
451
|
+
*
|
452
|
+
* @getter
|
453
|
+
* @public
|
454
|
+
* @type {string}
|
455
|
+
*/
|
375
456
|
get state() {
|
376
457
|
return JSON.stringify(this.dirtyData)
|
377
458
|
}
|
378
459
|
|
460
|
+
/**
|
461
|
+
* Undoes the previous change in the component's data by restoring it to the previous state.
|
462
|
+
* This method is part of the TimeCapsule feature, allowing users to revert changes.
|
463
|
+
*/
|
379
464
|
undo() {
|
380
465
|
if (!this.timeCapsule?.backwardable) {
|
381
466
|
return
|
@@ -384,6 +469,10 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
384
469
|
this._data = JSON.parse(this.timeCapsule?.backward())
|
385
470
|
}
|
386
471
|
|
472
|
+
/**
|
473
|
+
* Redoes the previously undone change in the component's data by restoring it to the next state.
|
474
|
+
* This method is part of the TimeCapsule feature, allowing users to reapply changes.
|
475
|
+
*/
|
387
476
|
redo() {
|
388
477
|
if (!this.timeCapsule?.forwardable) {
|
389
478
|
return
|
@@ -392,6 +481,13 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
392
481
|
this._data = JSON.parse(this.timeCapsule?.forward())
|
393
482
|
}
|
394
483
|
|
484
|
+
/**
|
485
|
+
* Fetches data from a data source and updates the component's data. This method is used to retrieve
|
486
|
+
* new data or refresh the existing data in the component.
|
487
|
+
*
|
488
|
+
* @method
|
489
|
+
* @param {boolean} reset - If true, the method resets the scroll position to the top.
|
490
|
+
*/
|
395
491
|
async fetch(reset = true) {
|
396
492
|
if (!this.compiledConfig) {
|
397
493
|
/* avoid to be here */
|
@@ -499,19 +595,58 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
499
595
|
}
|
500
596
|
}
|
501
597
|
|
598
|
+
/**
|
599
|
+
* Represents the compiled configuration of the component, which includes various settings and
|
600
|
+
* column configurations. You can access this property to get information about how the component
|
601
|
+
* is configured.
|
602
|
+
*
|
603
|
+
* @getter
|
604
|
+
* @public
|
605
|
+
* @type {GristConfig}
|
606
|
+
*/
|
502
607
|
get compiledConfig(): GristConfig {
|
503
608
|
return this._config
|
504
609
|
}
|
505
610
|
|
611
|
+
/**
|
612
|
+
* Returns the dirty data in the component, which includes the records that have been added,
|
613
|
+
* modified, or deleted but have not been committed to the main data yet.
|
614
|
+
*
|
615
|
+
* @getter
|
616
|
+
* @public
|
617
|
+
* @type {GristData} - An object representing the dirty data.
|
618
|
+
*/
|
506
619
|
get dirtyData(): GristData {
|
507
620
|
return (this.grist as any)?.data || {}
|
508
621
|
}
|
509
622
|
|
623
|
+
/**
|
624
|
+
* Returns an array of GristRecord objects representing the records in the dirty state. These are
|
625
|
+
* the records that have been added, modified, or deleted but have not been committed to the main
|
626
|
+
* data yet.
|
627
|
+
*
|
628
|
+
* @getter
|
629
|
+
* @public
|
630
|
+
* @type {GristRecord[]} - An array of GristRecord objects representing the dirty records.
|
631
|
+
*/
|
510
632
|
get dirtyRecords() {
|
511
633
|
var { records = [] } = this.dirtyData
|
512
634
|
return records.filter(record => record['__dirty__'])
|
513
635
|
}
|
514
636
|
|
637
|
+
/**
|
638
|
+
* Exports a list of patches representing the changes in the dirty state of records. Each patch
|
639
|
+
* contains information about whether a record was added, modified, or deleted, along with the
|
640
|
+
* record's unique identifier and the changed field values.
|
641
|
+
*
|
642
|
+
* @param {Object} options - Export options that control the format of the patch list.
|
643
|
+
* @param {string} options.flagName - The name of the flag field in the patch indicating the change type (default: 'patchFlag').
|
644
|
+
* @param {string} options.addedFlag - The flag value for added records (default: '+').
|
645
|
+
* @param {string} options.deletedFlag - The flag value for deleted records (default: '-').
|
646
|
+
* @param {string} options.modifiedFlag - The flag value for modified records (default: 'M').
|
647
|
+
* @param {string} options.idField - The name of the unique identifier field (default: 'id').
|
648
|
+
* @returns {Object[]} - An array of objects representing the patches.
|
649
|
+
*/
|
515
650
|
exportPatchList({ flagName = 'patchFlag', addedFlag = '+', deletedFlag = '-', modifiedFlag = 'M', idField = 'id' }) {
|
516
651
|
let dirtyRecords = this.dirtyRecords
|
517
652
|
if (!dirtyRecords || dirtyRecords.length == 0) {
|
@@ -536,6 +671,15 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
536
671
|
})
|
537
672
|
}
|
538
673
|
|
674
|
+
/**
|
675
|
+
* Exports the selected records or all records in the component, depending on the specified options.
|
676
|
+
* You can use this method to export data from the component in various formats or for different purposes.
|
677
|
+
*
|
678
|
+
* @param {Object} options - Export options that control the behavior of the export.
|
679
|
+
* @param {boolean} options.ifSelectedOnly - If true, exports only the selected records. If false, exports all records.
|
680
|
+
* @param {boolean} options.includeHiddenField - If true, includes hidden fields in the exported data.
|
681
|
+
* @returns {Object[]} - An array of objects representing the exported records.
|
682
|
+
*/
|
539
683
|
exportRecords({ ifSelectedOnly = true, includeHiddenField = true } = {}) {
|
540
684
|
let records = ifSelectedOnly ? this.selected : this.data.records
|
541
685
|
|
@@ -557,11 +701,27 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
557
701
|
})
|
558
702
|
}
|
559
703
|
|
704
|
+
/**
|
705
|
+
* Gets the currently selected records in the component. It returns an array of GristRecord objects
|
706
|
+
* that are currently selected. You can access this getter to retrieve the selected records.
|
707
|
+
*
|
708
|
+
* @getter
|
709
|
+
* @public
|
710
|
+
* @type {GristRecord[]}
|
711
|
+
*/
|
560
712
|
get selected() {
|
561
713
|
var { records = [] } = this.grist?.data
|
562
714
|
return records.filter(record => record['__selected__'])
|
563
715
|
}
|
564
716
|
|
717
|
+
/**
|
718
|
+
* Sets the currently selected records in the component. You can use this setter to programmatically
|
719
|
+
* select specific records by providing an array of GristRecord objects to be selected.
|
720
|
+
*
|
721
|
+
* @setter
|
722
|
+
* @public
|
723
|
+
* @type {GristRecord[]}
|
724
|
+
*/
|
565
725
|
set selected(selected: GristRecord[]) {
|
566
726
|
if (!this.grist) {
|
567
727
|
console.warn('grist not ready')
|
@@ -572,6 +732,15 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
572
732
|
this.refresh()
|
573
733
|
}
|
574
734
|
|
735
|
+
/**
|
736
|
+
* Selects records in the component based on the provided selector function. You can use this method
|
737
|
+
* to programmatically select specific records in the component.
|
738
|
+
*
|
739
|
+
* @method
|
740
|
+
* @param {GristSelectFunction} selector - A function that determines which records to select.
|
741
|
+
* @param {boolean} reset - If true, clears the previous selection before applying the new one.
|
742
|
+
* If false, adds to the existing selection.
|
743
|
+
*/
|
575
744
|
select(selector: GristSelectFunction, reset: boolean = false) {
|
576
745
|
var { records = [] } = this.grist?.data
|
577
746
|
|
@@ -583,20 +752,36 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
583
752
|
this.refresh()
|
584
753
|
}
|
585
754
|
|
755
|
+
/**
|
756
|
+
* Shows the loading spinner in the component's UI to indicate ongoing data loading or processing.
|
757
|
+
* You can call this method to display the spinner when necessary.
|
758
|
+
*/
|
586
759
|
showSpinner() {
|
587
760
|
this._showSpinner = true
|
588
761
|
}
|
589
762
|
|
763
|
+
/**
|
764
|
+
* Hides the loading spinner in the component's UI to indicate that data loading or processing has completed.
|
765
|
+
* You can call this method to hide the spinner when loading or processing is finished.
|
766
|
+
*/
|
590
767
|
hideSpinner() {
|
591
768
|
this._showSpinner = false
|
592
769
|
}
|
593
770
|
|
771
|
+
/**
|
772
|
+
* Focuses on the component, making it the active element in the document. This method is useful
|
773
|
+
* when you want to programmatically set focus to the component.
|
774
|
+
*/
|
594
775
|
focus() {
|
595
776
|
super.focus()
|
596
777
|
|
597
778
|
this.grist.focus()
|
598
779
|
}
|
599
780
|
|
781
|
+
/**
|
782
|
+
* Commits the changes made in the dirty state to the component's data. This method updates the
|
783
|
+
* component's data with the changes made in the dirty state and clears the dirty state.
|
784
|
+
*/
|
600
785
|
commit() {
|
601
786
|
var { page, total, limit, records } = this.grist.data
|
602
787
|
|
@@ -626,6 +811,10 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
626
811
|
}
|
627
812
|
}
|
628
813
|
|
814
|
+
/**
|
815
|
+
* Shows the headroom element in the component. The headroom element is typically used for
|
816
|
+
* displaying additional information or controls at the top of the component.
|
817
|
+
*/
|
629
818
|
showHeadroom() {
|
630
819
|
if (this.head) {
|
631
820
|
this.head.style.display = 'block'
|
@@ -633,6 +822,10 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
633
822
|
}
|
634
823
|
}
|
635
824
|
|
825
|
+
/**
|
826
|
+
* Hides the headroom element in the component. This method hides the additional information
|
827
|
+
* or controls displayed at the top of the component.
|
828
|
+
*/
|
636
829
|
hideHeadroom() {
|
637
830
|
if (this.head) {
|
638
831
|
this.head.style.display = 'none'
|
@@ -640,6 +833,10 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
640
833
|
}
|
641
834
|
}
|
642
835
|
|
836
|
+
/**
|
837
|
+
* Toggles the visibility of the headroom element in the component. If the headroom element is
|
838
|
+
* currently visible, this method hides it. If it's hidden, this method shows it.
|
839
|
+
*/
|
643
840
|
toggleHeadroom() {
|
644
841
|
if (this.head) {
|
645
842
|
const display = this.head.style.display
|
@@ -660,13 +857,14 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
660
857
|
}
|
661
858
|
|
662
859
|
/**
|
663
|
-
*
|
860
|
+
* Resets the component's data to its original state before any changes were made.
|
861
|
+
* This method discards all unsaved changes and restores the data to its initial state.
|
664
862
|
*
|
665
863
|
* @method
|
666
|
-
*
|
667
|
-
* TODO tree 형태의 데이타로 _data를 만들 때, children, collapsed 등을 감안한다.
|
864
|
+
* @public
|
668
865
|
*/
|
669
866
|
reset() {
|
867
|
+
// TODO tree 형태의 데이타로 _data를 만들 때, children, collapsed 등을 감안한다.
|
670
868
|
var {
|
671
869
|
limit = ZERO_PAGINATION.limit,
|
672
870
|
page = ZERO_PAGINATION.page,
|
@@ -741,6 +939,10 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
741
939
|
}
|
742
940
|
}
|
743
941
|
|
942
|
+
/**
|
943
|
+
* Checks for dirty records in the component's data and marks them as dirty.
|
944
|
+
* Dirty records are those that have unsaved changes.
|
945
|
+
*/
|
744
946
|
checkDirties() {
|
745
947
|
const records = this.dirtyRecords
|
746
948
|
const { columns = [] } = this.compiledConfig || {}
|
@@ -771,6 +973,10 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
771
973
|
this.snapshotTaker?.touch()
|
772
974
|
}
|
773
975
|
|
976
|
+
/**
|
977
|
+
* Clones the selected records in the component's data. It creates a copy of the selected records
|
978
|
+
* and marks them as new (added) records.
|
979
|
+
*/
|
774
980
|
cloneSelectedRecords() {
|
775
981
|
const records = this.selected || ([] as GristRecord[])
|
776
982
|
|
@@ -792,6 +998,37 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
792
998
|
this.checkDirties()
|
793
999
|
}
|
794
1000
|
|
1001
|
+
/**
|
1002
|
+
* Adds child nodes to selected records in the component's tree data. It allows users to add child nodes
|
1003
|
+
* to the selected parent records.
|
1004
|
+
*/
|
1005
|
+
addChildNodes() {
|
1006
|
+
const records = this.selected || ([] as GristRecord[])
|
1007
|
+
|
1008
|
+
records.forEach(record => {
|
1009
|
+
this.grist.addChildNode(record)
|
1010
|
+
})
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
/**
|
1014
|
+
* Adds sibling nodes to selected records in the component's tree data. It allows users to add sibling nodes
|
1015
|
+
* to the selected records.
|
1016
|
+
*/
|
1017
|
+
addSiblingNodes() {
|
1018
|
+
const records = this.selected || ([] as GristRecord[])
|
1019
|
+
|
1020
|
+
records.forEach(record => {
|
1021
|
+
this.grist.addSiblingNode(record)
|
1022
|
+
})
|
1023
|
+
}
|
1024
|
+
|
1025
|
+
/**
|
1026
|
+
* Deletes the selected records in the component's data. It removes the selected records from the data,
|
1027
|
+
* optionally marking them as deleted.
|
1028
|
+
*
|
1029
|
+
* @method
|
1030
|
+
* @param {boolean} dirty - If true, the method marks the records as deleted.
|
1031
|
+
*/
|
795
1032
|
deleteSelectedRecords(dirty = true) {
|
796
1033
|
const records = this.selected || ([] as GristRecord[])
|
797
1034
|
|
@@ -807,10 +1044,20 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
807
1044
|
this.checkDirties()
|
808
1045
|
}
|
809
1046
|
|
1047
|
+
/**
|
1048
|
+
* Retrieves the search text used for filtering records.
|
1049
|
+
*
|
1050
|
+
* @property {string}
|
1051
|
+
*/
|
810
1052
|
get searchText() {
|
811
1053
|
return (this.filters?.find(filter => filter.operator === 'search')?.value as string)?.match(/^\%(.*)\%$/)?.[1] || ''
|
812
1054
|
}
|
813
1055
|
|
1056
|
+
/**
|
1057
|
+
* Sets the search text for filtering records.
|
1058
|
+
*
|
1059
|
+
* @property {string}
|
1060
|
+
*/
|
814
1061
|
set searchText(searchText: string) {
|
815
1062
|
var filters = (this.filters || []).filter((filter: FilterValue) => filter.operator !== 'search')
|
816
1063
|
|
@@ -22,6 +22,18 @@ export class DataListGutter extends LitElement {
|
|
22
22
|
font-size: var(--grid-record-wide-fontsize);
|
23
23
|
text-overflow: ellipsis;
|
24
24
|
color: var(--grid-record-color);
|
25
|
+
|
26
|
+
padding-right: 10px;
|
27
|
+
}
|
28
|
+
|
29
|
+
:host-context(.expand)::after {
|
30
|
+
content: '';
|
31
|
+
position: absolute;
|
32
|
+
left: 50%;
|
33
|
+
top: 50%;
|
34
|
+
transform: translate(-50%, -50%);
|
35
|
+
width: 150%;
|
36
|
+
height: 220%;
|
25
37
|
}
|
26
38
|
|
27
39
|
* {
|
@@ -29,6 +29,6 @@ export function recordPartialClickHandler(this: RecordPartial, e: MouseEvent): v
|
|
29
29
|
rowsClick(this.config.columns, this.data, column, this.record, rowIndex, target)
|
30
30
|
} else {
|
31
31
|
/* content 가 클릭된 경우 - 레코드뷰 팝업을 실행한다. */
|
32
|
-
this.popupRecordView()
|
32
|
+
this.config.rows.editable && this.popupRecordView()
|
33
33
|
}
|
34
34
|
}
|
@@ -39,6 +39,7 @@ export class RecordPartial extends LitElement {
|
|
39
39
|
border-bottom: var(--data-list-item-border-bottom);
|
40
40
|
position: relative;
|
41
41
|
min-height: 42px;
|
42
|
+
padding-left: 7px;
|
42
43
|
}
|
43
44
|
|
44
45
|
:host([dirty])::before {
|
@@ -173,6 +174,7 @@ export class RecordPartial extends LitElement {
|
|
173
174
|
gutter =>
|
174
175
|
html`
|
175
176
|
<ox-list-gutter
|
177
|
+
class=${gutter.name === 'detail' ? 'expand' : ''}
|
176
178
|
.rowIndex=${rowIndex}
|
177
179
|
.column=${gutter}
|
178
180
|
.record=${record}
|
package/src/data-manipulator.ts
CHANGED
@@ -64,14 +64,16 @@ export class DataManipulator extends LitElement {
|
|
64
64
|
})
|
65
65
|
|
66
66
|
/* tree processing */
|
67
|
-
this.addEventListener('collapse-all', (e: Event) => this.
|
68
|
-
this.addEventListener('expand-all', (e: Event) => this.
|
69
|
-
this.addEventListener('collapse-node', (e: Event) => this.
|
70
|
-
this.addEventListener('expand-node', (e: Event) => this.
|
67
|
+
this.addEventListener('collapse-all', (e: Event) => this.collapseAll())
|
68
|
+
this.addEventListener('expand-all', (e: Event) => this.expandAll())
|
69
|
+
this.addEventListener('collapse-node', (e: Event) => this.collapseNode((e as CustomEvent).detail as GristRecord))
|
70
|
+
this.addEventListener('expand-node', (e: Event) => this.expandNode((e as CustomEvent).detail as GristRecord))
|
71
71
|
this.addEventListener('check-in-tree', (e: Event) => this.onCheckInTree(e as CustomEvent))
|
72
72
|
|
73
|
-
this.addEventListener('add-sibling-node', (e: Event) =>
|
74
|
-
|
73
|
+
this.addEventListener('add-sibling-node', (e: Event) =>
|
74
|
+
this.addSiblingNode((e as CustomEvent).detail as GristRecord)
|
75
|
+
)
|
76
|
+
this.addEventListener('add-child-node', (e: Event) => this.addChildNode((e as CustomEvent).detail as GristRecord))
|
75
77
|
}
|
76
78
|
|
77
79
|
onFieldChange({
|
@@ -212,36 +214,46 @@ export class DataManipulator extends LitElement {
|
|
212
214
|
this.requestUpdate()
|
213
215
|
}
|
214
216
|
|
215
|
-
|
217
|
+
collapseAll() {
|
216
218
|
this.refresh(false)
|
217
219
|
}
|
218
220
|
|
219
|
-
|
221
|
+
expandAll() {
|
220
222
|
this.refresh(true)
|
221
223
|
}
|
222
224
|
|
223
|
-
|
224
|
-
const record = e.detail as GristRecord
|
225
|
+
collapseNode(record: GristRecord) {
|
225
226
|
record.__expanded__ = false
|
226
227
|
|
227
228
|
this.refresh()
|
228
229
|
}
|
229
230
|
|
230
|
-
|
231
|
-
const record = e.detail as GristRecord
|
231
|
+
expandNode(record: GristRecord) {
|
232
232
|
record.__expanded__ = true
|
233
233
|
|
234
234
|
this.refresh()
|
235
235
|
}
|
236
236
|
|
237
|
-
|
237
|
+
// onCollapse(e: CustomEvent) {
|
238
|
+
// const record = e.detail as GristRecord
|
239
|
+
// record.__expanded__ = false
|
240
|
+
|
241
|
+
// this.refresh()
|
242
|
+
// }
|
243
|
+
|
244
|
+
// onExpand(e: CustomEvent) {
|
245
|
+
// const record = e.detail as GristRecord
|
246
|
+
// record.__expanded__ = true
|
247
|
+
|
248
|
+
// this.refresh()
|
249
|
+
// }
|
250
|
+
|
251
|
+
addSiblingNode(record: GristRecord) {
|
238
252
|
const { records } = this.data
|
239
253
|
const toplevelRecords = records.filter(
|
240
254
|
record => !record.__depth__
|
241
255
|
) /* __depth__ 가 설정되지 않았거나, 0 인 경우만 수집 */
|
242
256
|
|
243
|
-
const field = e.detail
|
244
|
-
const { record } = field
|
245
257
|
const { __depth__ } = record as GristRecord
|
246
258
|
|
247
259
|
function findParent(record: GristRecord, parent?: GristRecord): GristRecord | undefined {
|
@@ -264,15 +276,27 @@ export class DataManipulator extends LitElement {
|
|
264
276
|
const sibling = {
|
265
277
|
__depth__,
|
266
278
|
__dirty__: '+'
|
267
|
-
}
|
279
|
+
} as GristRecord
|
268
280
|
|
269
281
|
if (parent) {
|
270
|
-
const {
|
282
|
+
const { id } = parent as GristRecord
|
271
283
|
|
272
|
-
|
284
|
+
sibling.parent = { id }
|
285
|
+
|
286
|
+
if (!parent.__children__) {
|
273
287
|
parent.__children__ = [sibling]
|
274
288
|
} else {
|
275
|
-
|
289
|
+
let index = parent.__children__.indexOf(record)
|
290
|
+
|
291
|
+
if (index !== -1) {
|
292
|
+
parent.__children__ = [
|
293
|
+
...parent.__children__.slice(0, index + 1),
|
294
|
+
sibling,
|
295
|
+
...parent.__children__.slice(index + 1)
|
296
|
+
]
|
297
|
+
} else {
|
298
|
+
parent.__children__ = [...parent.__children__, sibling]
|
299
|
+
}
|
276
300
|
}
|
277
301
|
|
278
302
|
parent.__expanded__ = true
|
@@ -283,25 +307,25 @@ export class DataManipulator extends LitElement {
|
|
283
307
|
this.refresh()
|
284
308
|
}
|
285
309
|
|
286
|
-
|
287
|
-
const
|
288
|
-
const { record } = field
|
289
|
-
|
290
|
-
const { __children__, __depth__, __seq__ } = record as GristRecord
|
310
|
+
addChildNode(record: GristRecord) {
|
311
|
+
const { id: parentId, __children__, __depth__ } = record as GristRecord
|
291
312
|
const child = {
|
313
|
+
parent: {
|
314
|
+
id: parentId
|
315
|
+
},
|
292
316
|
__depth__: (__depth__ || 0) + 1,
|
293
317
|
__dirty__: '+'
|
294
318
|
}
|
295
319
|
|
296
|
-
if (!__children__) {
|
320
|
+
if (!record.__children__) {
|
297
321
|
record.__children__ = [child]
|
298
322
|
} else {
|
299
|
-
record.__children__.
|
323
|
+
record.__children__.unshift(child)
|
300
324
|
}
|
301
325
|
|
302
326
|
record.__expanded__ = true
|
303
327
|
|
304
|
-
|
328
|
+
// this.requestUpdate()
|
305
329
|
|
306
330
|
this.refresh()
|
307
331
|
}
|
@@ -388,10 +412,7 @@ export class DataManipulator extends LitElement {
|
|
388
412
|
|
389
413
|
private traverseRefresh(record: GristRecord, forceExpandOrCollapse?: boolean): GristRecord[] {
|
390
414
|
if (forceExpandOrCollapse !== undefined) {
|
391
|
-
record =
|
392
|
-
...record,
|
393
|
-
__expanded__: forceExpandOrCollapse
|
394
|
-
}
|
415
|
+
record.__expanded__ = forceExpandOrCollapse
|
395
416
|
}
|
396
417
|
|
397
418
|
const { __expanded__, __children__ = [] } = record
|
@@ -4,8 +4,18 @@ import { html } from 'lit'
|
|
4
4
|
|
5
5
|
@customElement('ox-grist-editor-checkbox')
|
6
6
|
export class OxGristEditorCheckbox extends OxGristEditor {
|
7
|
-
|
8
|
-
|
7
|
+
_onchange(e: Event) {
|
8
|
+
e.stopPropagation()
|
9
|
+
|
10
|
+
const input = e.target as HTMLInputElement
|
11
|
+
|
12
|
+
this._dirtyValue = this.formatFromEditor(input.checked)
|
13
|
+
}
|
14
|
+
|
15
|
+
formatFromEditor(value: any) {
|
16
|
+
if (typeof value == 'boolean') {
|
17
|
+
return value
|
18
|
+
}
|
9
19
|
}
|
10
20
|
|
11
21
|
formatForEditor(value: any): any {
|
@@ -15,8 +15,7 @@ export class OxGristEditorDateTime extends OxGristEditor {
|
|
15
15
|
return new Date(timestamp - tzoffset).toISOString().slice(0, -1)
|
16
16
|
}
|
17
17
|
|
18
|
-
formatFromEditor(
|
19
|
-
var value = (e.target as HTMLInputElement).value
|
18
|
+
formatFromEditor(value: any) {
|
20
19
|
var datetime = new Date(value)
|
21
20
|
|
22
21
|
return datetime.getTime()
|
@@ -5,8 +5,18 @@ import { OxGristEditor } from './ox-grist-editor.js'
|
|
5
5
|
|
6
6
|
@customElement('ox-grist-editor-file')
|
7
7
|
export class OxGristEditorFile extends OxGristEditor {
|
8
|
-
|
9
|
-
|
8
|
+
_onchange(e: Event) {
|
9
|
+
e.stopPropagation()
|
10
|
+
|
11
|
+
const input = e.target as HTMLInputElement
|
12
|
+
|
13
|
+
this._dirtyValue = this.formatFromEditor(input.files)
|
14
|
+
|
15
|
+
this._onfocusout()
|
16
|
+
}
|
17
|
+
|
18
|
+
formatFromEditor(value: any): any {
|
19
|
+
return value
|
10
20
|
}
|
11
21
|
|
12
22
|
get editorTemplate() {
|