@operato/app 0.4.3 → 1.0.0-alpha.11
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 +98 -0
- package/demo/data-grist-test.html +456 -0
- package/dist/src/grist/code-editor.d.ts +6 -0
- package/dist/src/grist/code-editor.js +55 -0
- package/dist/src/grist/code-editor.js.map +1 -0
- package/dist/src/grist/id-selector.js +1 -1
- package/dist/src/grist/id-selector.js.map +1 -1
- package/dist/src/grist/index.js +4 -0
- package/dist/src/grist/index.js.map +1 -1
- package/dist/src/grist/object-editor.d.ts +18 -0
- package/dist/src/grist/object-editor.js +152 -0
- package/dist/src/grist/object-editor.js.map +1 -0
- package/dist/src/grist/object-selector.d.ts +38 -0
- package/dist/src/grist/object-selector.js +338 -0
- package/dist/src/grist/object-selector.js.map +1 -0
- package/dist/src/grist/parameters-editor-builder.d.ts +4 -0
- package/dist/src/grist/parameters-editor-builder.js +119 -0
- package/dist/src/grist/parameters-editor-builder.js.map +1 -0
- package/dist/src/grist/parameters-editor-popup.d.ts +13 -0
- package/dist/src/grist/parameters-editor-popup.js +111 -0
- package/dist/src/grist/parameters-editor-popup.js.map +1 -0
- package/dist/src/grist/parameters-editor.d.ts +19 -0
- package/dist/src/grist/parameters-editor.js +105 -0
- package/dist/src/grist/parameters-editor.js.map +1 -0
- package/dist/src/input/ox-input-background-pattern.d.ts +31 -0
- package/dist/src/input/ox-input-background-pattern.js +147 -0
- package/dist/src/input/ox-input-background-pattern.js.map +1 -0
- package/dist/src/input/ox-input-color-gradient.d.ts +25 -0
- package/dist/src/input/ox-input-color-gradient.js +318 -0
- package/dist/src/input/ox-input-color-gradient.js.map +1 -0
- package/dist/src/input/ox-input-fill-style.d.ts +42 -0
- package/dist/src/input/ox-input-fill-style.js +325 -0
- package/dist/src/input/ox-input-fill-style.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -11
- package/src/grist/code-editor.ts +77 -0
- package/src/grist/id-selector.ts +2 -10
- package/src/grist/index.ts +4 -0
- package/src/grist/object-editor.ts +154 -0
- package/src/grist/object-selector.ts +346 -0
- package/src/grist/parameters-editor-builder.ts +130 -0
- package/src/grist/parameters-editor-popup.ts +106 -0
- package/src/grist/parameters-editor.ts +112 -0
- package/src/input/ox-input-background-pattern.ts +163 -0
- package/src/input/ox-input-color-gradient.ts +341 -0
- package/src/input/ox-input-fill-style.ts +360 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,104 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.0-alpha.11](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.10...v1.0.0-alpha.11) (2022-03-12)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :bug: Bug Fix
|
|
10
|
+
|
|
11
|
+
* code-editor for grist ([cb80692](https://github.com/hatiolab/operato/commit/cb80692039e41d7b94b98ac1845822563e179e24))
|
|
12
|
+
* ox-property-editor-attachment-selector ([a1a2d20](https://github.com/hatiolab/operato/commit/a1a2d20640746c891248fdb729097614676c9cff))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## [1.0.0-alpha.10](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.9...v1.0.0-alpha.10) (2022-03-12)
|
|
17
|
+
|
|
18
|
+
**Note:** Version bump only for package @operato/app
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## [1.0.0-alpha.9](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.8...v1.0.0-alpha.9) (2022-03-12)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### :rocket: New Features
|
|
28
|
+
|
|
29
|
+
* settled concept for input, property-editor, grist-editor, so on ([0c9e1d0](https://github.com/hatiolab/operato/commit/0c9e1d054c7aef5d965868242cf471667af7a3c3))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## [1.0.0-alpha.8](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.7...v1.0.0-alpha.8) (2022-03-11)
|
|
34
|
+
|
|
35
|
+
**Note:** Version bump only for package @operato/app
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## [1.0.0-alpha.7](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.6...v1.0.0-alpha.7) (2022-03-11)
|
|
42
|
+
|
|
43
|
+
**Note:** Version bump only for package @operato/app
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## [1.0.0-alpha.6](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.5...v1.0.0-alpha.6) (2022-03-11)
|
|
50
|
+
|
|
51
|
+
**Note:** Version bump only for package @operato/app
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## [1.0.0-alpha.5](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.4...v1.0.0-alpha.5) (2022-03-11)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### :rocket: New Features
|
|
61
|
+
|
|
62
|
+
* start migration grist editors from things-factory ([8b31c7f](https://github.com/hatiolab/operato/commit/8b31c7f00ae9b32e68f6860c559a768c3d456704))
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
### :bug: Bug Fix
|
|
66
|
+
|
|
67
|
+
* migrate parameter-editor from things-factory ([019a30d](https://github.com/hatiolab/operato/commit/019a30df6fd4c8a273d4194d13f5784ed6f8d956))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## [1.0.0-alpha.4](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.3...v1.0.0-alpha.4) (2022-03-11)
|
|
72
|
+
|
|
73
|
+
**Note:** Version bump only for package @operato/app
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
## [1.0.0-alpha.3](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.2...v1.0.0-alpha.3) (2022-03-10)
|
|
80
|
+
|
|
81
|
+
**Note:** Version bump only for package @operato/app
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
## [1.0.0-alpha.2](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2022-03-10)
|
|
88
|
+
|
|
89
|
+
**Note:** Version bump only for package @operato/app
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
## [1.0.0-alpha.1](https://github.com/hatiolab/operato/compare/v0.4.3...v1.0.0-alpha.1) (2022-03-09)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
### :rocket: New Features
|
|
99
|
+
|
|
100
|
+
* 1.0-alpha ([42f87cf](https://github.com/hatiolab/operato/commit/42f87cf6a3cef0381db91ecb1179e63c64c01370))
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
6
104
|
### [0.4.3](https://github.com/hatiolab/operato/compare/v0.4.2...v0.4.3) (2022-03-06)
|
|
7
105
|
|
|
8
106
|
**Note:** Version bump only for package @operato/app
|
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en-GB">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" />
|
|
6
|
+
<style>
|
|
7
|
+
body {
|
|
8
|
+
/* box-sizing: border-box; */
|
|
9
|
+
margin: 0;
|
|
10
|
+
padding: 0;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
|
|
13
|
+
/* This is a font-stack that tries to use the system-default sans-serifs first */
|
|
14
|
+
font-family: Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
15
|
+
line-height: 1.5;
|
|
16
|
+
-webkit-font-smoothing: antialiased;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#app {
|
|
20
|
+
width: 100vw;
|
|
21
|
+
height: 100vh;
|
|
22
|
+
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#demo {
|
|
28
|
+
flex: 1;
|
|
29
|
+
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
grist-demo {
|
|
36
|
+
flex: 1;
|
|
37
|
+
overflow: auto;
|
|
38
|
+
}
|
|
39
|
+
</style>
|
|
40
|
+
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet" />
|
|
41
|
+
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
|
|
42
|
+
|
|
43
|
+
<link href="/themes/app-theme.css" rel="stylesheet" />
|
|
44
|
+
<link href="/themes/oops-theme.css" rel="stylesheet" />
|
|
45
|
+
<link href="/themes/grist-theme.css" rel="stylesheet" />
|
|
46
|
+
</head>
|
|
47
|
+
|
|
48
|
+
<body>
|
|
49
|
+
<script type="module">
|
|
50
|
+
import { LitElement, html, css, render } from 'lit'
|
|
51
|
+
import '../dist/index.js'
|
|
52
|
+
import '../dist/src/filters/filters-form.js'
|
|
53
|
+
import '../dist/src/sorters/sorters-control.js'
|
|
54
|
+
import '../dist/src/record-view/record-creator.js'
|
|
55
|
+
import '@operato/popup/ox-popup-list.js'
|
|
56
|
+
import '@material/mwc-icon'
|
|
57
|
+
import { CommonGristStyles } from '@operato/styles'
|
|
58
|
+
|
|
59
|
+
const fetchHandler = async ({ page, limit, sorters = [] }) => {
|
|
60
|
+
var total = 120993
|
|
61
|
+
var start = (page - 1) * limit
|
|
62
|
+
|
|
63
|
+
await new Promise(resolve => setTimeout(resolve, 500))
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
total,
|
|
67
|
+
records: Array(limit * page > total ? total % limit : limit)
|
|
68
|
+
.fill()
|
|
69
|
+
.map((item, idx) => {
|
|
70
|
+
return {
|
|
71
|
+
id: idx,
|
|
72
|
+
name: idx % 2 ? `shnam-${start + idx + 1}` : `heartyoh-${start + idx + 1}`,
|
|
73
|
+
description:
|
|
74
|
+
idx % 2 ? `hatiolabmanager${start + idx + 1}1234567890` : `hatiosea manager-${start + idx + 1}`,
|
|
75
|
+
email: idx % 2 ? `shnam-${start + idx + 1}@gmail.com` : `heartyoh-${start + idx + 1}@gmail.com`,
|
|
76
|
+
active: Math.round(Math.random() * 2) % 2 ? true : false,
|
|
77
|
+
barcode: idx % 2 ? `1234567890${start + idx + 1}` : `0987654321${start + idx + 1}`,
|
|
78
|
+
company:
|
|
79
|
+
idx % 2
|
|
80
|
+
? {
|
|
81
|
+
id: '2',
|
|
82
|
+
name: 'HatioLAB',
|
|
83
|
+
description: `경기도 성남시-${start + idx + 1}`
|
|
84
|
+
}
|
|
85
|
+
: {
|
|
86
|
+
id: '3',
|
|
87
|
+
name: 'HatioSEA',
|
|
88
|
+
description: `말레이시아 세티아알람-${start + idx + 1}`
|
|
89
|
+
},
|
|
90
|
+
thumbnail:
|
|
91
|
+
idx % 4 === 0
|
|
92
|
+
? '' /* no source */
|
|
93
|
+
: idx % 4 === 1
|
|
94
|
+
? `http://www.hatiolab.com/assets/img/operato-biz3.png`
|
|
95
|
+
: idx % 4 === 2
|
|
96
|
+
? `http://www.hatiolab.com/assets/img/thingsboard-30.png`
|
|
97
|
+
: `http://www.hatiolab.com/wrong-url.png` /* wrong source */,
|
|
98
|
+
role: ['admin', 'worker', 'tester'][idx % 3],
|
|
99
|
+
color: idx % 2 ? `#87f018` : `#180f87`,
|
|
100
|
+
rate: Math.round(Math.random() * 100),
|
|
101
|
+
dynamicType: ['text', 'email', 'checkbox', 'color', 'progress', 'barcode'][idx % 5],
|
|
102
|
+
dynamicValue: ['abcdefghijkl', 'heartyoh@hatiolab.com', 'true', 'orange', '50', '1234567890'][idx % 5],
|
|
103
|
+
homepage:
|
|
104
|
+
idx % 2
|
|
105
|
+
? `http://hatiolab.com/${start + idx + 1}`
|
|
106
|
+
: `http://deadpool.hatiolab.com/${start + idx + 1}`,
|
|
107
|
+
json5: {
|
|
108
|
+
abc: 'abc',
|
|
109
|
+
value: 123
|
|
110
|
+
},
|
|
111
|
+
createdAt: Date.now(),
|
|
112
|
+
updatedAt: Date.now()
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const config = {
|
|
119
|
+
list: {
|
|
120
|
+
thumbnail: 'thumbnail',
|
|
121
|
+
fields: ['name', 'description'],
|
|
122
|
+
details: ['role', 'email']
|
|
123
|
+
},
|
|
124
|
+
columns: [
|
|
125
|
+
{
|
|
126
|
+
type: 'gutter',
|
|
127
|
+
gutterName: 'dirty'
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
type: 'gutter',
|
|
131
|
+
gutterName: 'sequence'
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
type: 'gutter',
|
|
135
|
+
gutterName: 'row-selector',
|
|
136
|
+
multiple: true
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
type: 'gutter',
|
|
140
|
+
gutterName: 'button',
|
|
141
|
+
icon: 'edit',
|
|
142
|
+
handlers: {
|
|
143
|
+
click: function () {
|
|
144
|
+
console.log('clicked')
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
type: 'gutter',
|
|
150
|
+
gutterName: 'button',
|
|
151
|
+
icon: 'add',
|
|
152
|
+
handlers: {
|
|
153
|
+
click: 'record-copy'
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
type: 'gutter',
|
|
158
|
+
gutterName: 'button',
|
|
159
|
+
icon: 'arrow_downward',
|
|
160
|
+
handlers: {
|
|
161
|
+
click: 'move-down'
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
type: 'string',
|
|
166
|
+
name: 'id',
|
|
167
|
+
hidden: true
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
type: 'link',
|
|
171
|
+
name: 'name',
|
|
172
|
+
label: true,
|
|
173
|
+
header: 'name',
|
|
174
|
+
record: {
|
|
175
|
+
editable: true,
|
|
176
|
+
options: {
|
|
177
|
+
// href: 'http://hatiolab.com',
|
|
178
|
+
href: function (column, record, rowIndex) {
|
|
179
|
+
return record['homepage']
|
|
180
|
+
},
|
|
181
|
+
target: '_blank'
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
filter: 'search',
|
|
185
|
+
sortable: true,
|
|
186
|
+
width: 120
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
type: 'string',
|
|
190
|
+
name: 'description',
|
|
191
|
+
header: 'description',
|
|
192
|
+
filter: 'search',
|
|
193
|
+
record: {
|
|
194
|
+
editable: true,
|
|
195
|
+
align: 'left'
|
|
196
|
+
},
|
|
197
|
+
width: 200,
|
|
198
|
+
handlers: {
|
|
199
|
+
click: (columns, data, column, record, rowIndex, target) => {
|
|
200
|
+
alert(`${column.name} ${record[column.name]}, row : ${rowIndex}`)
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
type: 'email',
|
|
206
|
+
name: 'email',
|
|
207
|
+
label: true,
|
|
208
|
+
header: 'email',
|
|
209
|
+
record: {
|
|
210
|
+
editable: true
|
|
211
|
+
},
|
|
212
|
+
filter: 'search',
|
|
213
|
+
sortable: true,
|
|
214
|
+
width: 130,
|
|
215
|
+
validation: function (after, before, record, column) {
|
|
216
|
+
if (after.indexOf('@') == -1) {
|
|
217
|
+
document.dispatchEvent(
|
|
218
|
+
new CustomEvent('notify', {
|
|
219
|
+
detail: {
|
|
220
|
+
type: 'error',
|
|
221
|
+
message: `invalid value - ${after}`
|
|
222
|
+
}
|
|
223
|
+
})
|
|
224
|
+
)
|
|
225
|
+
return false
|
|
226
|
+
}
|
|
227
|
+
return true
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
type: 'boolean',
|
|
232
|
+
name: 'active',
|
|
233
|
+
header: 'active',
|
|
234
|
+
record: {
|
|
235
|
+
editable: true
|
|
236
|
+
},
|
|
237
|
+
filter: true,
|
|
238
|
+
handlers: {
|
|
239
|
+
dblclick: () => {
|
|
240
|
+
const grist = document.querySelector('ox-grist')
|
|
241
|
+
console.log(grist.dirtyRecords)
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
sortable: true,
|
|
245
|
+
width: 60
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
type: 'select',
|
|
249
|
+
name: 'role',
|
|
250
|
+
label: true,
|
|
251
|
+
header: 'role',
|
|
252
|
+
record: {
|
|
253
|
+
options: ['', 'admin', 'worker', 'tester'],
|
|
254
|
+
editable: true
|
|
255
|
+
},
|
|
256
|
+
filter: true,
|
|
257
|
+
sortable: true,
|
|
258
|
+
width: 120
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
type: 'color',
|
|
262
|
+
name: 'color',
|
|
263
|
+
header: 'color',
|
|
264
|
+
record: {
|
|
265
|
+
editable: true
|
|
266
|
+
},
|
|
267
|
+
sortable: true,
|
|
268
|
+
width: 50
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
type: 'float',
|
|
272
|
+
name: 'rate',
|
|
273
|
+
header: 'rate',
|
|
274
|
+
record: {
|
|
275
|
+
align: 'right',
|
|
276
|
+
editable: true
|
|
277
|
+
},
|
|
278
|
+
filter: 'between',
|
|
279
|
+
sortable: true,
|
|
280
|
+
width: 50
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
type: 'json5',
|
|
284
|
+
name: 'json5',
|
|
285
|
+
header: 'JSON5',
|
|
286
|
+
width: 200
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
type: 'image',
|
|
290
|
+
name: 'thumbnail',
|
|
291
|
+
header: 'thumbnail',
|
|
292
|
+
record: {
|
|
293
|
+
editable: true
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
type: 'datetime',
|
|
298
|
+
name: 'updatedAt',
|
|
299
|
+
header: 'updated at',
|
|
300
|
+
record: {
|
|
301
|
+
editable: true
|
|
302
|
+
},
|
|
303
|
+
filter: 'between',
|
|
304
|
+
sortable: true,
|
|
305
|
+
width: 180
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
type: 'datetime',
|
|
309
|
+
name: 'createdAt',
|
|
310
|
+
header: 'created at',
|
|
311
|
+
record: {
|
|
312
|
+
editable: false
|
|
313
|
+
},
|
|
314
|
+
sortable: true,
|
|
315
|
+
width: 180
|
|
316
|
+
}
|
|
317
|
+
],
|
|
318
|
+
rows: {
|
|
319
|
+
selectable: {
|
|
320
|
+
multiple: true
|
|
321
|
+
},
|
|
322
|
+
handlers: {
|
|
323
|
+
click: 'select-row-toggle'
|
|
324
|
+
},
|
|
325
|
+
classifier: function (record, rowIndex) {
|
|
326
|
+
const rate = record['rate']
|
|
327
|
+
const emphasized =
|
|
328
|
+
rate < 10 ? ['black', 'white'] : rate < 25 ? ['yellow', 'blue'] : rate < 40 ? ['cyan', 'red'] : undefined
|
|
329
|
+
return {
|
|
330
|
+
emphasized
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
sorters: [
|
|
335
|
+
{
|
|
336
|
+
name: 'name',
|
|
337
|
+
desc: true
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
name: 'email'
|
|
341
|
+
}
|
|
342
|
+
],
|
|
343
|
+
pagination: {
|
|
344
|
+
pages: [20, 30, 50, 100, 200]
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
class GristDemo extends LitElement {
|
|
349
|
+
static styles = [
|
|
350
|
+
CommonGristStyles,
|
|
351
|
+
css`
|
|
352
|
+
:host {
|
|
353
|
+
display: flex;
|
|
354
|
+
flex-direction: column;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
#tailer {
|
|
358
|
+
display: flex;
|
|
359
|
+
flex-direction: row;
|
|
360
|
+
margin: 0 var(--margin-default);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
#tailer a {
|
|
364
|
+
padding: 0 var(--padding-default) 0 var(--padding-default);
|
|
365
|
+
margin: 0 var(--margin-narrow);
|
|
366
|
+
border-right: 1px solid rgba(0, 0, 0, 0.1);
|
|
367
|
+
font-size: var(--fontsize-default);
|
|
368
|
+
color: var(--primary-color);
|
|
369
|
+
}
|
|
370
|
+
`
|
|
371
|
+
]
|
|
372
|
+
|
|
373
|
+
static get properties() {
|
|
374
|
+
return {
|
|
375
|
+
mode: String
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
get grist() {
|
|
380
|
+
return this.renderRoot.querySelector('ox-grist')
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
render() {
|
|
384
|
+
const mode = this.mode || 'CARD'
|
|
385
|
+
|
|
386
|
+
return html`
|
|
387
|
+
<ox-grist .config=${config} .mode=${mode} auto-fetch .fetchHandler=${fetchHandler}>
|
|
388
|
+
<div id="filters" slot="headroom">
|
|
389
|
+
<ox-filters-form @filters-change=${e => console.log('changed', e.detail)}></ox-filters-form>
|
|
390
|
+
</div>
|
|
391
|
+
|
|
392
|
+
<div slot="headroom" id="headroom">
|
|
393
|
+
<div id="tailer">
|
|
394
|
+
<a href="./report-test.html">Report Test</a>
|
|
395
|
+
<a
|
|
396
|
+
href="#"
|
|
397
|
+
@click=${() => {
|
|
398
|
+
this.renderRoot.querySelector('ox-grist').reset()
|
|
399
|
+
}}
|
|
400
|
+
>Reset</a
|
|
401
|
+
>
|
|
402
|
+
<a
|
|
403
|
+
href="#"
|
|
404
|
+
@click=${() => {
|
|
405
|
+
this.renderRoot.querySelector('ox-grist').fetch(true)
|
|
406
|
+
}}
|
|
407
|
+
>Fetch</a
|
|
408
|
+
>
|
|
409
|
+
</div>
|
|
410
|
+
|
|
411
|
+
<div id="sorters">
|
|
412
|
+
Sort
|
|
413
|
+
<mwc-icon
|
|
414
|
+
@click=${e => {
|
|
415
|
+
const target = e.currentTarget
|
|
416
|
+
this.renderRoot.querySelector('#sorter-control').open({
|
|
417
|
+
right: 0,
|
|
418
|
+
top: target.offsetTop + target.offsetHeight
|
|
419
|
+
})
|
|
420
|
+
}}
|
|
421
|
+
>expand_more</mwc-icon
|
|
422
|
+
>
|
|
423
|
+
<ox-popup id="sorter-control">
|
|
424
|
+
<ox-sorters-control> </ox-sorters-control>
|
|
425
|
+
</ox-popup>
|
|
426
|
+
</div>
|
|
427
|
+
|
|
428
|
+
<div id="modes">
|
|
429
|
+
<mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>view_list</mwc-icon>
|
|
430
|
+
<mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>menu</mwc-icon>
|
|
431
|
+
<mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
|
|
432
|
+
</div>
|
|
433
|
+
|
|
434
|
+
<ox-record-creator id="add" light-popup>
|
|
435
|
+
<button><mwc-icon>add</mwc-icon></button>
|
|
436
|
+
</ox-record-creator>
|
|
437
|
+
|
|
438
|
+
<button @click=${e => this.grist.cloneSelectedRecords()}><mwc-icon>add</mwc-icon></button>
|
|
439
|
+
</div>
|
|
440
|
+
</ox-grist>
|
|
441
|
+
`
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
customElements.define('grist-demo', GristDemo)
|
|
446
|
+
|
|
447
|
+
setTimeout(() => {
|
|
448
|
+
render(html` <grist-demo mode="LIST"></grist-demo> `, document.querySelector('#demo'))
|
|
449
|
+
})
|
|
450
|
+
</script>
|
|
451
|
+
|
|
452
|
+
<div id="app">
|
|
453
|
+
<div id="demo"></div>
|
|
454
|
+
</div>
|
|
455
|
+
</body>
|
|
456
|
+
</html>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import '@material/mwc-icon';
|
|
3
|
+
import { InputEditor } from '@operato/data-grist';
|
|
4
|
+
import { client, gqlContext } from '@operato/graphql';
|
|
5
|
+
import { customElement } from 'lit/decorators.js';
|
|
6
|
+
import gql from 'graphql-tag';
|
|
7
|
+
import { html } from 'lit';
|
|
8
|
+
const FETCH_COMMON_CODE_GQL = (codeName) => gql `
|
|
9
|
+
{
|
|
10
|
+
commonCode(name: "${codeName}") {
|
|
11
|
+
details {
|
|
12
|
+
name
|
|
13
|
+
description
|
|
14
|
+
rank
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
let CodeEditor = class CodeEditor extends InputEditor {
|
|
20
|
+
async firstUpdated() {
|
|
21
|
+
super.firstUpdated();
|
|
22
|
+
var { codeName, codes } = this.column.record || {};
|
|
23
|
+
if (!codes && codeName) {
|
|
24
|
+
/* codeName으로 fetch 해와서, this.column.record.codes에 보관한다. */
|
|
25
|
+
var response = await client.query({
|
|
26
|
+
query: FETCH_COMMON_CODE_GQL(codeName),
|
|
27
|
+
context: gqlContext()
|
|
28
|
+
});
|
|
29
|
+
var commonCode = response && response.data && response.data.commonCode;
|
|
30
|
+
if (commonCode) {
|
|
31
|
+
this.column.record.codes = [{ name: '', description: '' }].concat(commonCode.details.sort(function (a, b) {
|
|
32
|
+
return a.rank - b.rank;
|
|
33
|
+
}));
|
|
34
|
+
this.requestUpdate();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
get editorTemplate() {
|
|
39
|
+
var { codes } = this.column.record || {};
|
|
40
|
+
return html `
|
|
41
|
+
<select>
|
|
42
|
+
${(codes || ['']).map((code) => html `
|
|
43
|
+
<option ?selected=${code.name == this.value} value=${code.name}>
|
|
44
|
+
${code.name}${code.description ? ` - ${code.description}` : ''}
|
|
45
|
+
</option>
|
|
46
|
+
`)}
|
|
47
|
+
</select>
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
CodeEditor = __decorate([
|
|
52
|
+
customElement('code-editor')
|
|
53
|
+
], CodeEditor);
|
|
54
|
+
export { CodeEditor };
|
|
55
|
+
//# sourceMappingURL=code-editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-editor.js","sourceRoot":"","sources":["../../../src/grist/code-editor.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAgB,MAAM,qBAAqB,CAAA;AAC/D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAc1B,MAAM,qBAAqB,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,GAAG,CAAA;;sBAEjC,QAAQ;;;;;;;;CAQ7B,CAAA;AAGD,IAAa,UAAU,GAAvB,MAAa,UAAW,SAAQ,WAAW;IACzC,KAAK,CAAC,YAAY;QAChB,KAAK,CAAC,YAAY,EAAE,CAAA;QAEpB,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAA;QAElD,IAAI,CAAC,KAAK,IAAI,QAAQ,EAAE;YACtB,2DAA2D;YAC3D,IAAI,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;gBAChC,KAAK,EAAE,qBAAqB,CAAC,QAAQ,CAAC;gBACtC,OAAO,EAAE,UAAU,EAAE;aACtB,CAAC,CAAA;YAEF,IAAI,UAAU,GAAG,QAAQ,IAAI,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAA;YAEtE,IAAI,UAAU,EAAE;gBACd,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,CAC/D,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAmB,EAAE,CAAmB;oBACxE,OAAO,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAA;gBACxB,CAAC,CAAC,CACH,CAAA;gBAED,IAAI,CAAC,aAAa,EAAE,CAAA;aACrB;SACF;IACH,CAAC;IAED,IAAI,cAAc;QAChB,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAA;QAExC,OAAO,IAAI,CAAA;;UAEL,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CACnB,CAAC,IAAgB,EAAE,EAAE,CAAC,IAAI,CAAA;gCACJ,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,UAAU,IAAI,CAAC,IAAI;gBAC1D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE;;WAEjE,CACF;;KAEJ,CAAA;IACH,CAAC;CACF,CAAA;AA1CY,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CA0CtB;SA1CY,UAAU","sourcesContent":["import '@material/mwc-icon'\n\nimport { InputEditor, RecordConfig } from '@operato/data-grist'\nimport { client, gqlContext } from '@operato/graphql'\n\nimport { customElement } from 'lit/decorators.js'\nimport gql from 'graphql-tag'\nimport { html } from 'lit'\n\ntype CommonCodeDetail = {\n name: string\n description: string\n rank: number\n}\n\ntype CommonCode = {\n name: string\n description: string\n details: CommonCodeDetail[]\n}\n\nconst FETCH_COMMON_CODE_GQL = (codeName: string) => gql`\n{\n commonCode(name: \"${codeName}\") {\n details {\n name\n description\n rank\n }\n }\n}\n`\n\n@customElement('code-editor')\nexport class CodeEditor extends InputEditor {\n async firstUpdated() {\n super.firstUpdated()\n\n var { codeName, codes } = this.column.record || {}\n\n if (!codes && codeName) {\n /* codeName으로 fetch 해와서, this.column.record.codes에 보관한다. */\n var response = await client.query({\n query: FETCH_COMMON_CODE_GQL(codeName),\n context: gqlContext()\n })\n\n var commonCode = response && response.data && response.data.commonCode\n\n if (commonCode) {\n this.column.record.codes = [{ name: '', description: '' }].concat(\n commonCode.details.sort(function (a: CommonCodeDetail, b: CommonCodeDetail) {\n return a.rank - b.rank\n })\n )\n\n this.requestUpdate()\n }\n }\n }\n\n get editorTemplate() {\n var { codes } = this.column.record || {}\n\n return html`\n <select>\n ${(codes || ['']).map(\n (code: CommonCode) => html`\n <option ?selected=${code.name == this.value} value=${code.name}>\n ${code.name}${code.description ? ` - ${code.description}` : ''}\n </option>\n `\n )}\n </select>\n `\n }\n}\n"]}
|
|
@@ -21,7 +21,7 @@ let IdSelector = class IdSelector extends LitElement {
|
|
|
21
21
|
.fetchHandler=${this.fetchHandler.bind(this)}
|
|
22
22
|
.selectedRecords=${this.selectedRecords}
|
|
23
23
|
>
|
|
24
|
-
<div id="filters" slot="
|
|
24
|
+
<div id="filters" slot="headroom">
|
|
25
25
|
<ox-filters-form></ox-filters-form>
|
|
26
26
|
</div>
|
|
27
27
|
</ox-grist>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-selector.js","sourceRoot":"","sources":["../../../src/grist/id-selector.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,
|
|
1
|
+
{"version":3,"file":"id-selector.js","sourceRoot":"","sources":["../../../src/grist/id-selector.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAA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Ae;AACd;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAY;AACX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wCAA4B;AAC3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAmB;AAClB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAe;AACd;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAA4D;AAC5D;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;mDAAoC;AAE3C;IAAlB,KAAK,CAAC,UAAU,CAAC;yCAAkB;AAxCzB,UAAU;IADtB,aAAa,CAAC,gBAAgB,CAAC;GACnB,UAAU,CAgLtB;SAhLY,UAAU","sourcesContent":["import '@operato/data-grist'\n\nimport { DataGrist, FetchOption, GristData, GristRecord, ZERO_DATA } from '@operato/data-grist'\nimport { LitElement, css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { client } from '@operato/graphql'\nimport gql from 'graphql-tag'\nimport { i18next } from '@operato/i18n'\nimport { isMobileDevice } from '@operato/utils'\n\n@customElement('ox-id-selector')\nexport class IdSelector extends LitElement {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n\n background-color: #fff;\n\n width: var(--overlay-center-normal-width, 50%);\n height: var(--overlay-center-normal-height, 50%);\n }\n\n ox-grist {\n flex: 1;\n }\n\n #filters {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n }\n\n #filters > * {\n padding: var(--padding-default) var(--padding-wide);\n }\n\n .button-container {\n display: flex;\n margin-left: auto;\n }\n `\n\n @property({ type: String }) value?: string\n @property({ type: Object }) config: any\n @property({ type: Object }) data: GristData = ZERO_DATA\n @property({ type: String }) queryName!: string\n @property({ type: Object }) basicArgs: any\n @property({ type: Object }) confirmCallback?: (record: GristRecord | undefined) => void\n @property({ type: Array }) selectedRecords: GristRecord[] = []\n\n @query('ox-grist') grist!: DataGrist\n\n render() {\n return html`\n <ox-grist\n .mode=${isMobileDevice() ? 'LIST' : 'GRID'}\n .config=${this.config}\n .fetchHandler=${this.fetchHandler.bind(this)}\n .selectedRecords=${this.selectedRecords}\n >\n <div id=\"filters\" slot=\"headroom\">\n <ox-filters-form></ox-filters-form>\n </div>\n </ox-grist>\n\n <div class=\"button-container\">\n <mwc-button @click=${this.oncancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>\n <mwc-button @click=${this.onconfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>\n </div>\n `\n }\n\n oncancel() {\n history.back()\n }\n\n onconfirm() {\n this.confirmCallback && this.confirmCallback(this.selected)\n history.back()\n }\n\n async firstUpdated() {\n this.config = {\n columns: [\n {\n type: 'gutter',\n gutterName: 'sequence'\n },\n {\n type: 'gutter',\n gutterName: 'row-selector',\n multiple: false\n },\n {\n type: 'string',\n name: 'id',\n header: i18next.t('field.id'),\n hidden: true\n },\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: {\n align: 'left'\n },\n filter: 'search',\n sortable: true,\n width: 160\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: {\n align: 'left'\n },\n filter: 'search',\n sortable: true,\n width: 300\n }\n ],\n rows: {\n selectable: {\n multiple: false\n },\n handlers: {\n click: 'select-row'\n }\n },\n pagination: {\n infinite: true\n }\n }\n\n await this.updateComplete\n\n /* TODO config가 설정될 때, fetch() 가 동작하므로, fetch 완료 이벤트를 받아서, selected를 설정해주는 것이 좋겠다. \n 현재는 fetch() 가 두번 일어난다.\n */\n await this.grist.fetch()\n\n var selected = this.grist.data.records.find(item => this.value == item.id)\n if (selected) {\n this.selectedRecords = [selected]\n }\n /* TODO config가 설정될 때, fetch() 가 동작하므로, fetch 완료 이벤트를 받아서, selected를 설정해주는 것이 좋겠다. */\n\n await this.updateComplete\n this.grist.focus()\n }\n\n async fetchHandler({ page = 1, limit = 100, sorters = [], filters = [] }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n q: ${this.queryName}(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n description\n }\n total\n }\n }\n `,\n variables: {\n filters,\n pagination: { page, limit },\n sortings: sorters\n }\n })\n\n return {\n total: response.data.q.total || 0,\n records: response.data.q.items || []\n }\n }\n\n get selected() {\n var grist = this.renderRoot.querySelector('ox-grist') as DataGrist\n\n var selected = grist.selected\n\n return selected && selected.length > 0 ? selected[0] : undefined\n }\n}\n"]}
|