@operato/data-grist 1.17.9 → 1.19.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@operato/data-grist",
3
- "version": "1.17.9",
3
+ "version": "1.19.0",
4
4
  "description": "User interface for grid (desktop) and list (mobile)",
5
5
  "author": "heartyoh",
6
6
  "main": "dist/index.js",
@@ -57,11 +57,11 @@
57
57
  "dependencies": {
58
58
  "@material/mwc-icon": "^0.27.0",
59
59
  "@operato/headroom": "^1.17.9",
60
- "@operato/input": "^1.17.9",
61
- "@operato/popup": "^1.17.9",
60
+ "@operato/input": "^1.19.0",
61
+ "@operato/popup": "^1.19.0",
62
62
  "@operato/pull-to-refresh": "^1.17.9",
63
- "@operato/styles": "^1.17.9",
64
- "@operato/utils": "^1.17.9",
63
+ "@operato/styles": "^1.18.0",
64
+ "@operato/utils": "^1.19.0",
65
65
  "i18next": "^21.5.4",
66
66
  "json5": "^2.2.0",
67
67
  "lit": "^2.5.0",
@@ -100,5 +100,5 @@
100
100
  "prettier --write"
101
101
  ]
102
102
  },
103
- "gitHead": "3ee2a9ccedbe46a0ff0277e41bb75ba5428d4e04"
103
+ "gitHead": "8fe8f9edb649dc99453b5f3970244df21502a042"
104
104
  }
@@ -3,6 +3,12 @@ import '@operato/input/ox-checkbox.js'
3
3
  import { FilterConfigObject, FilterSelectRenderer } from '../types'
4
4
 
5
5
  import { html } from 'lit-html'
6
+ import { i18next } from '@operato/i18n'
7
+
8
+ interface Option {
9
+ display: string
10
+ value: string
11
+ }
6
12
 
7
13
  export const FilterSelect: FilterSelectRenderer = (column, value, owner) => {
8
14
  /* value는 filters-form이나 grid-header에서 처리되므로 이 곳에서는 무시한다. */
@@ -39,17 +45,41 @@ export const FilterSelect: FilterSelectRenderer = (column, value, owner) => {
39
45
 
40
46
  return operator === 'in'
41
47
  ? html`
48
+ <ox-checkbox
49
+ checkAll
50
+ @click=${(e: any) => {
51
+ // 전체 체크시 모든 옵션으로 변경 or 공백으로 변경
52
+ const checked = e.target.checked
53
+ const val = checked ? options.map((opt: Option) => opt.value) : []
54
+
55
+ e.target?.dispatchEvent(new CustomEvent('select', { bubbles: true, detail: val }))
56
+ }}
57
+ >${i18next.t('label.all')}</ox-checkbox
58
+ >
42
59
  ${options
43
- ?.filter((option: { display: string; value: any }) => !!option)
60
+ ?.filter((option: Option) => !!option.value)
44
61
  .map(
45
- (option: { display: string; value: any }) =>
46
- html` <ox-checkbox option value=${option.value}>${option.display}</ox-checkbox> `
62
+ (option: Option) =>
63
+ html`
64
+ <ox-checkbox
65
+ option
66
+ value=${option.value}
67
+ @change=${(e: any) => {
68
+ // 체크가 바뀌었을때 전체 체크 버튼 자동 체크 or 체크 해제
69
+ const parent = e.target.parentElement
70
+ const checkCnt = e.target.checked ? 1 : -1
71
+ const checkedLen = parent.querySelectorAll('ox-checkbox[option][checked]').length + checkCnt
72
+
73
+ // TODO 필터는 공백값 지워지면 제거 예정
74
+ parent.querySelector('ox-checkbox[checkAll]').checked =
75
+ options.filter((option: Option) => !!option.value).length === checkedLen
76
+ }}
77
+ >${option.display}</ox-checkbox
78
+ >
79
+ `
47
80
  )}
48
81
  `
49
82
  : html`
50
- ${options?.map(
51
- (option: { display: string; value: any }) =>
52
- html` <div option value=${option.value}>${option.display}&nbsp;</div> `
53
- )}
83
+ ${options?.map((option: Option) => html` <div option value=${option.value}>${option.display}&nbsp;</div> `)}
54
84
  `
55
85
  }
@@ -178,18 +178,33 @@ export class FiltersForm extends LitElement {
178
178
  name=${name}
179
179
  placeholder=${labelText}
180
180
  .value=${value}
181
- @change=${(e: CustomEvent) =>
181
+ @change=${(e: CustomEvent) => {
182
+ // 멀티 셀렉트가 한개도 선택이 안되었다면 빈값이 아닌 나의 모든 값들을 넣음 (필터에서 뺀 상태까지 검색 방지)
183
+ let val = e.detail
184
+ if (e.detail?.length === 0) {
185
+ val = column.record.options
186
+ .filter((option: any) => (typeof option === 'string' ? !!option : !!option.value)) // 빈값 제거 (TODO 필터는 공백값 지워지면 제거 예정)
187
+ .map((opt: any) => (typeof opt === 'string' ? opt : opt.value)) // 값 리스트
188
+
189
+ // 전체 값을 선택
190
+ const input = this.renderRoot.querySelector(`form [name="${name}"]`) as HTMLInputElement
191
+ input.value = val
192
+ // "전체" 버튼 체크
193
+ ;(input.querySelector('ox-checkbox[checkAll]') as HTMLInputElement).checked = true
194
+ }
195
+
182
196
  e.target?.dispatchEvent(
183
197
  new CustomEvent('filter-change', {
184
198
  detail: {
185
199
  name,
186
200
  operator,
187
- value: e.detail
201
+ value: val
188
202
  }
189
203
  })
190
- )}
204
+ )
205
+ }}
191
206
  >
192
- <ox-popup-list multiple attr-selected="checked" with-search>
207
+ <ox-popup-list multiple attr-selected="checked" with-search align-left>
193
208
  ${renderer(column, value, this)}
194
209
  </ox-popup-list>
195
210
  </ox-select>
@@ -133,6 +133,27 @@ function buildConfig({ headerFilter }: { headerFilter: boolean }) {
133
133
  header: 'date',
134
134
  width: 120
135
135
  },
136
+ {
137
+ type: 'select',
138
+ name: 'role',
139
+ label: true,
140
+ header: 'role',
141
+ record: {
142
+ // options: ['', 'admin', 'worker', 'tester'],
143
+ options: [
144
+ { display: 'admin', value: 'admin' },
145
+ { display: 'worker', value: 'worker' },
146
+ { display: 'tester', value: 'tester' }
147
+ ],
148
+ editable: true
149
+ },
150
+ filter: {
151
+ operator: 'in',
152
+ value: ['worker']
153
+ },
154
+ sortable: true,
155
+ width: 120
156
+ },
136
157
  {
137
158
  type: 'object',
138
159
  name: 'routing',
@@ -3,5 +3,6 @@
3
3
  "label.accumulator_avg": "avg",
4
4
  "label.accumulator_count": "cnt",
5
5
  "label.accumulator_max": "min",
6
- "label.accumulator_min": "max"
6
+ "label.accumulator_min": "max",
7
+ "label.all": "All"
7
8
  }
@@ -3,5 +3,6 @@
3
3
  "label.accumulator_avg": "평균",
4
4
  "label.accumulator_count": "계수",
5
5
  "label.accumulator_max": "최소",
6
- "label.accumulator_min": "최대"
6
+ "label.accumulator_min": "최대",
7
+ "label.all": "전체"
7
8
  }