@operato/data-grist 2.0.0-alpha.117 → 2.0.0-alpha.119

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.
@@ -0,0 +1 @@
1
+ export * from './ox-grist-personalizer'
@@ -1,8 +1,9 @@
1
- import '@material/web/icon/icon.js'
1
+ import '@material/web/button/outlined-button.js'
2
2
 
3
3
  import { css, html, LitElement } from 'lit'
4
4
  import { customElement, property, state } from 'lit/decorators.js'
5
5
 
6
+ import { i18next } from '@operato/i18n'
6
7
  import { OxPopupList } from '@operato/popup'
7
8
 
8
9
  import { GristConfig, PersonalGristPreference } from '../types'
@@ -39,22 +40,26 @@ export class OxGristPersonalizer extends LitElement {
39
40
  @click=${(e: MouseEvent) => {
40
41
  const grist = this.closest('ox-grist') as DataGrist
41
42
 
42
- const { compiledConfig: config } = grist
43
- const columns = (config as GristConfig).columns.filter(
44
- column => column.name && column.type !== 'gutter' && column.name != 'id'
45
- )
46
-
47
- this.preference = columns.map(column => {
48
- return {
49
- name: column.name,
50
- hidden: column.hidden,
51
- width: column.width
52
- }
53
- })
43
+ const { config, compiledConfig } = grist
44
+ const { columns: compiledColumns } = compiledConfig
45
+
46
+ const columns = (config as GristConfig).columns
47
+ .filter(column => column.name && column.type !== 'gutter' && !column.hidden)
48
+ .map(column => compiledColumns.find(compiledColumn => compiledColumn.name == column.name)!)
49
+
50
+ this.preference = {
51
+ columns: columns.map(column => {
52
+ return {
53
+ name: column.name,
54
+ hidden: column.hidden,
55
+ width: column.width
56
+ }
57
+ })
58
+ }
54
59
 
55
60
  const template = html`
56
61
  <div class="personalizer-header" slot="header">
57
- select to show<md-icon
62
+ ${i18next.t('text.column visibility setting')}<md-outlined-button
58
63
  style="margin-left: auto;"
59
64
  @click=${async (e: MouseEvent) => {
60
65
  if (grist.personalConfigProvider) {
@@ -62,13 +67,13 @@ export class OxGristPersonalizer extends LitElement {
62
67
  }
63
68
  ;((e.target as HTMLElement).closest('ox-popup-list') as OxPopupList)?.close()
64
69
  }}
65
- >save</md-icon
70
+ >${i18next.t('button.save')}</md-outlined-button
66
71
  >
67
72
  </div>
68
73
 
69
74
  ${columns.map(
70
75
  column =>
71
- html`<ox-checkbox label="checkbox" ?checked=${!column.hidden} value=${column.name} option />${column.name}</ox-checkbox>`
76
+ html`<ox-checkbox label="checkbox" ?checked=${!column.hidden} value=${column.name} option />${column.header.renderer(column)}</ox-checkbox>`
72
77
  )}
73
78
  `
74
79
 
@@ -80,13 +85,17 @@ export class OxGristPersonalizer extends LitElement {
80
85
  left: e.pageX,
81
86
  styles: css`
82
87
  :host {
83
- width: 200px;
84
- max-height: 300px;
88
+ width: 240px;
89
+ max-height: 360px;
85
90
  overflow: scroll;
86
91
  }
87
92
 
88
93
  ::slotted(.personalizer-header) {
89
94
  --md-icon-size: 1.2em;
95
+ --md-outlined-button-container-height: 24px;
96
+ --md-outlined-button-container-shape: 4px;
97
+ --md-outlined-button-leading-space: 4px;
98
+ --md-outlined-button-trailing-space: 4px;
90
99
 
91
100
  display: flex;
92
101
  flex-direction: row;
@@ -1,6 +1,8 @@
1
1
  import '@material/web/icon/icon.js'
2
2
  import '@operato/popup/ox-popup-list.js'
3
3
 
4
+ import { sleep } from '@operato/utils'
5
+
4
6
  import '../src/index.js'
5
7
  import '../src/filters/filters-form.js'
6
8
  import '../src/sorters/sorters-control.js'
@@ -387,7 +389,8 @@ const Template: Story<ArgTypes> = ({ config, mode = 'GRID', urlParamsSensitive =
387
389
  .config=${config}
388
390
  .fetchHandler=${fetchHandler}
389
391
  .personalConfigProvider=${{
390
- load() {
392
+ async load() {
393
+ await sleep(1000)
391
394
  return {
392
395
  columns: [
393
396
  { name: 'name', hidden: false, width: 200 },
@@ -395,7 +398,8 @@ const Template: Story<ArgTypes> = ({ config, mode = 'GRID', urlParamsSensitive =
395
398
  ]
396
399
  }
397
400
  },
398
- save(preference: PersonalGristPreference) {
401
+ async save(preference: PersonalGristPreference) {
402
+ await sleep(1000)
399
403
  console.log('saving preference', preference)
400
404
  return preference
401
405
  }