@operato/data-grist 2.0.0-alpha.111 → 2.0.0-alpha.114
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 +9 -0
- package/dist/src/data-grid/data-grid-accum-field.js +4 -1
- package/dist/src/data-grid/data-grid-accum-field.js.map +1 -1
- package/dist/src/data-grid/data-grid-field.js +4 -1
- package/dist/src/data-grid/data-grid-field.js.map +1 -1
- package/dist/src/data-grist.d.ts +6 -2
- package/dist/src/data-grist.js +19 -5
- package/dist/src/data-grist.js.map +1 -1
- package/dist/stories/accumulator.stories.d.ts +41 -0
- package/dist/stories/accumulator.stories.js +243 -0
- package/dist/stories/accumulator.stories.js.map +1 -0
- package/dist/stories/grid-setting.stories.d.ts +3 -2
- package/dist/stories/grid-setting.stories.js +73 -5
- package/dist/stories/grid-setting.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/data-grid/data-grid-accum-field.ts +3 -1
- package/src/data-grid/data-grid-field.ts +3 -1
- package/src/data-grist.ts +24 -5
- package/stories/grid-setting.stories.ts +88 -7
- package/yarn-error.log +0 -16971
package/src/data-grist.ts
CHANGED
@@ -170,8 +170,13 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
170
170
|
*/
|
171
171
|
@property({ type: Boolean, attribute: 'url-params-sensitive' }) urlParamsSensitive?: boolean
|
172
172
|
|
173
|
-
@
|
174
|
-
|
173
|
+
@property({ type: Object }) personalSetting?: {
|
174
|
+
columns?: Partial<ColumnConfig>[]
|
175
|
+
[key: string]: any
|
176
|
+
}
|
177
|
+
|
178
|
+
@state() _data: GristData = ZERO_DATA // copy data, dirty data
|
179
|
+
@state() _config: GristConfig = ZERO_CONFIG // compiled configuration
|
175
180
|
@state() private _showSpinner: boolean = false
|
176
181
|
|
177
182
|
@query('slot[name=headroom]') head!: HTMLElement
|
@@ -300,9 +305,23 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
300
305
|
}
|
301
306
|
}
|
302
307
|
|
303
|
-
|
308
|
+
public applyUpdatedConfiguration() {
|
309
|
+
const config = this.config
|
310
|
+
const { columns } = config
|
311
|
+
|
312
|
+
if (this.personalSetting) {
|
313
|
+
const { columns: personalColumns } = this.personalSetting
|
314
|
+
|
315
|
+
if (personalColumns) {
|
316
|
+
config.columns = columns.map((column: Partial<ColumnConfig>) => {
|
317
|
+
const personalColumn = personalColumns.find(pcolumn => pcolumn.name == column.name)
|
318
|
+
return personalColumn ? { ...column, ...personalColumn } : column
|
319
|
+
})
|
320
|
+
}
|
321
|
+
}
|
322
|
+
|
304
323
|
this._config = buildConfig({
|
305
|
-
...
|
324
|
+
...config
|
306
325
|
})
|
307
326
|
|
308
327
|
this.dispatchEvent(
|
@@ -534,7 +553,7 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
534
553
|
}
|
535
554
|
|
536
555
|
if (changes.has('config')) {
|
537
|
-
this.
|
556
|
+
this.applyUpdatedConfiguration()
|
538
557
|
}
|
539
558
|
|
540
559
|
if (changes.has('fetchHandler')) {
|
@@ -7,12 +7,14 @@ import '@material/web/icon/icon.js'
|
|
7
7
|
|
8
8
|
import { html, TemplateResult } from 'lit'
|
9
9
|
|
10
|
+
import { OxPopupList } from '@operato/popup'
|
10
11
|
import { CommonHeaderStyles, CommonGristStyles } from '@operato/styles'
|
11
12
|
|
12
13
|
import {
|
13
14
|
ColumnConfig,
|
14
15
|
FetchHandler,
|
15
16
|
GristClassifier,
|
17
|
+
GristConfig,
|
16
18
|
GristEventHandlerSet,
|
17
19
|
GristRecord,
|
18
20
|
ValidationCallback
|
@@ -353,9 +355,9 @@ interface Story<T> {
|
|
353
355
|
|
354
356
|
interface ArgTypes {
|
355
357
|
config: object
|
356
|
-
mode:
|
358
|
+
mode: 'GRID' | 'LIST' | 'CARD'
|
357
359
|
urlParamsSensitive: boolean
|
358
|
-
fetchHandler:
|
360
|
+
fetchHandler: FetchHandler
|
359
361
|
}
|
360
362
|
|
361
363
|
const Template: Story<ArgTypes> = ({ config, mode = 'GRID', urlParamsSensitive = false, fetchHandler }: ArgTypes) =>
|
@@ -377,14 +379,52 @@ const Template: Story<ArgTypes> = ({ config, mode = 'GRID', urlParamsSensitive =
|
|
377
379
|
<link href="/themes/grist-theme.css" rel="stylesheet" />
|
378
380
|
|
379
381
|
<style>
|
380
|
-
${CommonGristStyles.cssText}
|
381
|
-
|
382
|
+
${CommonGristStyles.cssText} ${CommonHeaderStyles.cssText}
|
383
|
+
</style>
|
384
|
+
|
385
|
+
<style>
|
386
|
+
ox-popup-list {
|
387
|
+
width: 200px;
|
388
|
+
max-height: 300px;
|
389
|
+
overflow: scroll;
|
390
|
+
}
|
391
|
+
|
392
|
+
[slot='setting'] {
|
393
|
+
--md-icon-size: 14px;
|
394
|
+
width: 16px;
|
395
|
+
height: 16px;
|
396
|
+
background-color: rgba(var(--secondary-color-rgb), 0.6);
|
397
|
+
border-radius: 0px 0px 7px 7px;
|
398
|
+
color: var(--theme-white-color);
|
399
|
+
cursor: pointer;
|
400
|
+
}
|
401
|
+
|
402
|
+
[slot='setting']:hover {
|
403
|
+
color: var(--primary-color);
|
404
|
+
}
|
405
|
+
|
406
|
+
ox-popup-list {
|
407
|
+
.header {
|
408
|
+
display: flex;
|
409
|
+
flex-direction: row;
|
410
|
+
align-items: center;
|
411
|
+
text-transform: capitalize;
|
412
|
+
}
|
413
|
+
|
414
|
+
.header md-icon {
|
415
|
+
--md-icon-size: 1.2em;
|
416
|
+
margin-left: auto;
|
417
|
+
}
|
418
|
+
}
|
382
419
|
</style>
|
383
420
|
|
384
421
|
<ox-grist
|
385
|
-
.config=${config}
|
386
422
|
.mode=${mode}
|
423
|
+
.config=${config}
|
387
424
|
.fetchHandler=${fetchHandler}
|
425
|
+
.personalSetting=${{
|
426
|
+
columns: [{ name: 'description', hidden: true }]
|
427
|
+
}}
|
388
428
|
?url-params-sensitive=${urlParamsSensitive}
|
389
429
|
@filters-change=${(e: Event) => console.log('filters', (e.target as any).filters)}
|
390
430
|
>
|
@@ -426,8 +466,49 @@ const Template: Story<ArgTypes> = ({ config, mode = 'GRID', urlParamsSensitive =
|
|
426
466
|
slot="setting"
|
427
467
|
@click=${(e: MouseEvent) => {
|
428
468
|
const grist = (e.target as HTMLElement).closest('ox-grist') as DataGrist
|
429
|
-
|
430
|
-
grist
|
469
|
+
|
470
|
+
const { compiledConfig: config } = grist
|
471
|
+
const columns = (config as GristConfig).columns.filter(
|
472
|
+
column => column.name && column.type !== 'gutter' && column.name != 'id'
|
473
|
+
)
|
474
|
+
|
475
|
+
const template = html`
|
476
|
+
<div class="header">
|
477
|
+
select to show<md-icon
|
478
|
+
@click=${(e: MouseEvent) =>
|
479
|
+
((e.target as HTMLElement).closest('ox-popup-list') as OxPopupList)?.close()}
|
480
|
+
>save</md-icon
|
481
|
+
>
|
482
|
+
</div>
|
483
|
+
${columns.map(
|
484
|
+
column =>
|
485
|
+
html`<ox-checkbox label="checkbox" ?checked=${!column.hidden} value=${column.name} option />${column.name}</ox-checkbox>`
|
486
|
+
)}
|
487
|
+
`
|
488
|
+
|
489
|
+
const popup = OxPopupList.open({
|
490
|
+
template,
|
491
|
+
multiple: true,
|
492
|
+
attrSelected: 'checked',
|
493
|
+
top: e.pageY,
|
494
|
+
left: e.pageX
|
495
|
+
})
|
496
|
+
|
497
|
+
popup.onselect = (e: Event) => {
|
498
|
+
console.log('select', e.target, (e as CustomEvent).detail, (e.target as OxPopupList).value)
|
499
|
+
const selected = (e as CustomEvent).detail
|
500
|
+
|
501
|
+
const pconfig = grist.personalSetting || {}
|
502
|
+
pconfig.columns = columns.map(column => {
|
503
|
+
return {
|
504
|
+
name: column.name,
|
505
|
+
hidden: selected.indexOf(column.name) == -1
|
506
|
+
}
|
507
|
+
})
|
508
|
+
grist.personalSetting = pconfig
|
509
|
+
|
510
|
+
grist.applyUpdatedConfiguration()
|
511
|
+
}
|
431
512
|
}}
|
432
513
|
>tune</md-icon
|
433
514
|
>
|