@operato/attachment 1.0.0-beta.8 → 1.0.1
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 +366 -0
- package/dist/src/ox-attachment-list.d.ts +27 -10
- package/dist/src/ox-attachment-list.js +17 -35
- package/dist/src/ox-attachment-list.js.map +1 -1
- package/dist/src/ox-attachment-selector.d.ts +1 -1
- package/dist/src/ox-property-editor-attachment-selector.js +4 -4
- package/dist/src/ox-property-editor-attachment-selector.js.map +1 -1
- package/dist/src/ox-property-editor-image-selector.js +5 -5
- package/dist/src/ox-property-editor-image-selector.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
- package/src/ox-attachment-list.ts +21 -39
- package/src/ox-property-editor-attachment-selector.ts +5 -4
- package/src/ox-property-editor-image-selector.ts +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,372 @@
|
|
|
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.1](https://github.com/hatiolab/operato/compare/v1.0.0...v1.0.1) (2022-07-25)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :bug: Bug Fix
|
|
10
|
+
|
|
11
|
+
* support ox-grist filters-form for ox-grist-editor-resource-object ([e7ffdaa](https://github.com/hatiolab/operato/commit/e7ffdaa9951a4596aff7ec7c60848570605c54ac))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [1.0.0](https://github.com/hatiolab/operato/compare/v1.0.0-beta.51...v1.0.0) (2022-07-24)
|
|
16
|
+
|
|
17
|
+
**Note:** Version bump only for package @operato/attachment
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## [1.0.0-beta.51](https://github.com/hatiolab/operato/compare/v1.0.0-beta.50...v1.0.0-beta.51) (2022-07-22)
|
|
24
|
+
|
|
25
|
+
**Note:** Version bump only for package @operato/attachment
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## [1.0.0-beta.50](https://github.com/hatiolab/operato/compare/v1.0.0-beta.49...v1.0.0-beta.50) (2022-07-18)
|
|
32
|
+
|
|
33
|
+
**Note:** Version bump only for package @operato/attachment
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## [1.0.0-beta.49](https://github.com/hatiolab/operato/compare/v1.0.0-beta.48...v1.0.0-beta.49) (2022-07-17)
|
|
40
|
+
|
|
41
|
+
**Note:** Version bump only for package @operato/attachment
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## [1.0.0-beta.48](https://github.com/hatiolab/operato/compare/v1.0.0-beta.47...v1.0.0-beta.48) (2022-07-17)
|
|
48
|
+
|
|
49
|
+
**Note:** Version bump only for package @operato/attachment
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## [1.0.0-beta.47](https://github.com/hatiolab/operato/compare/v1.0.0-beta.46...v1.0.0-beta.47) (2022-07-15)
|
|
56
|
+
|
|
57
|
+
**Note:** Version bump only for package @operato/attachment
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
## [1.0.0-beta.46](https://github.com/hatiolab/operato/compare/v1.0.0-beta.45...v1.0.0-beta.46) (2022-07-11)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### :bug: Bug Fix
|
|
67
|
+
|
|
68
|
+
* property-editor spec. changed ([b10e4ef](https://github.com/hatiolab/operato/commit/b10e4ef151450a0ca19cbf00c9c96da80ddaaed8))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
## [1.0.0-beta.45](https://github.com/hatiolab/operato/compare/v1.0.0-beta.44...v1.0.0-beta.45) (2022-07-09)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
### :bug: Bug Fix
|
|
76
|
+
|
|
77
|
+
* upgrade dependencies ([4986392](https://github.com/hatiolab/operato/commit/4986392e64524b5602cc9a144def239e85524bee))
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
## [1.0.0-beta.44](https://github.com/hatiolab/operato/compare/v1.0.0-beta.43...v1.0.0-beta.44) (2022-07-07)
|
|
82
|
+
|
|
83
|
+
**Note:** Version bump only for package @operato/attachment
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
## [1.0.0-beta.43](https://github.com/hatiolab/operato/compare/v1.0.0-beta.42...v1.0.0-beta.43) (2022-07-03)
|
|
90
|
+
|
|
91
|
+
**Note:** Version bump only for package @operato/attachment
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
## [1.0.0-beta.42](https://github.com/hatiolab/operato/compare/v1.0.0-beta.41...v1.0.0-beta.42) (2022-07-03)
|
|
98
|
+
|
|
99
|
+
**Note:** Version bump only for package @operato/attachment
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
## [1.0.0-beta.41](https://github.com/hatiolab/operato/compare/v1.0.0-beta.40...v1.0.0-beta.41) (2022-06-30)
|
|
106
|
+
|
|
107
|
+
**Note:** Version bump only for package @operato/attachment
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
## [1.0.0-beta.40](https://github.com/hatiolab/operato/compare/v1.0.0-beta.39...v1.0.0-beta.40) (2022-06-29)
|
|
114
|
+
|
|
115
|
+
**Note:** Version bump only for package @operato/attachment
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
## [1.0.0-beta.39](https://github.com/hatiolab/operato/compare/v1.0.0-beta.38...v1.0.0-beta.39) (2022-06-22)
|
|
122
|
+
|
|
123
|
+
**Note:** Version bump only for package @operato/attachment
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
## [1.0.0-beta.38](https://github.com/hatiolab/operato/compare/v1.0.0-beta.37...v1.0.0-beta.38) (2022-06-20)
|
|
130
|
+
|
|
131
|
+
**Note:** Version bump only for package @operato/attachment
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
## [1.0.0-beta.37](https://github.com/hatiolab/operato/compare/v1.0.0-beta.36...v1.0.0-beta.37) (2022-06-20)
|
|
138
|
+
|
|
139
|
+
**Note:** Version bump only for package @operato/attachment
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
## [1.0.0-beta.36](https://github.com/hatiolab/operato/compare/v1.0.0-beta.35...v1.0.0-beta.36) (2022-06-16)
|
|
146
|
+
|
|
147
|
+
**Note:** Version bump only for package @operato/attachment
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
## [1.0.0-beta.35](https://github.com/hatiolab/operato/compare/v1.0.0-beta.34...v1.0.0-beta.35) (2022-06-16)
|
|
154
|
+
|
|
155
|
+
**Note:** Version bump only for package @operato/attachment
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
## [1.0.0-beta.34](https://github.com/hatiolab/operato/compare/v1.0.0-beta.33...v1.0.0-beta.34) (2022-06-16)
|
|
162
|
+
|
|
163
|
+
**Note:** Version bump only for package @operato/attachment
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
## [1.0.0-beta.33](https://github.com/hatiolab/operato/compare/v1.0.0-beta.32...v1.0.0-beta.33) (2022-06-16)
|
|
170
|
+
|
|
171
|
+
**Note:** Version bump only for package @operato/attachment
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
## [1.0.0-beta.32](https://github.com/hatiolab/operato/compare/v1.0.0-beta.31...v1.0.0-beta.32) (2022-06-15)
|
|
178
|
+
|
|
179
|
+
**Note:** Version bump only for package @operato/attachment
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
## [1.0.0-beta.31](https://github.com/hatiolab/operato/compare/v1.0.0-beta.30...v1.0.0-beta.31) (2022-06-15)
|
|
186
|
+
|
|
187
|
+
**Note:** Version bump only for package @operato/attachment
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
## [1.0.0-beta.30](https://github.com/hatiolab/operato/compare/v1.0.0-beta.29...v1.0.0-beta.30) (2022-06-13)
|
|
194
|
+
|
|
195
|
+
**Note:** Version bump only for package @operato/attachment
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
## [1.0.0-beta.29](https://github.com/hatiolab/operato/compare/v1.0.0-beta.28...v1.0.0-beta.29) (2022-06-10)
|
|
202
|
+
|
|
203
|
+
**Note:** Version bump only for package @operato/attachment
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
## [1.0.0-beta.28](https://github.com/hatiolab/operato/compare/v1.0.0-beta.27...v1.0.0-beta.28) (2022-06-10)
|
|
210
|
+
|
|
211
|
+
**Note:** Version bump only for package @operato/attachment
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
## [1.0.0-beta.27](https://github.com/hatiolab/operato/compare/v1.0.0-beta.26...v1.0.0-beta.27) (2022-06-09)
|
|
218
|
+
|
|
219
|
+
**Note:** Version bump only for package @operato/attachment
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
## [1.0.0-beta.26](https://github.com/hatiolab/operato/compare/v1.0.0-beta.25...v1.0.0-beta.26) (2022-06-04)
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
### :bug: Bug Fix
|
|
229
|
+
|
|
230
|
+
* remove empty valued filters from data-grist default filters ([4a23485](https://github.com/hatiolab/operato/commit/4a2348525bdee4e1cd43abad469ad9451e6d7f5d))
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
## [1.0.0-beta.25](https://github.com/hatiolab/operato/compare/v1.0.0-beta.24...v1.0.0-beta.25) (2022-06-02)
|
|
235
|
+
|
|
236
|
+
**Note:** Version bump only for package @operato/attachment
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
## [1.0.0-beta.24](https://github.com/hatiolab/operato/compare/v1.0.0-beta.23...v1.0.0-beta.24) (2022-06-02)
|
|
243
|
+
|
|
244
|
+
**Note:** Version bump only for package @operato/attachment
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
## [1.0.0-beta.23](https://github.com/hatiolab/operato/compare/v1.0.0-beta.22...v1.0.0-beta.23) (2022-06-02)
|
|
251
|
+
|
|
252
|
+
**Note:** Version bump only for package @operato/attachment
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
## [1.0.0-beta.22](https://github.com/hatiolab/operato/compare/v1.0.0-beta.21...v1.0.0-beta.22) (2022-05-31)
|
|
259
|
+
|
|
260
|
+
**Note:** Version bump only for package @operato/attachment
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
## [1.0.0-beta.21](https://github.com/hatiolab/operato/compare/v1.0.0-beta.20...v1.0.0-beta.21) (2022-05-31)
|
|
267
|
+
|
|
268
|
+
**Note:** Version bump only for package @operato/attachment
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
## [1.0.0-beta.20](https://github.com/hatiolab/operato/compare/v1.0.0-beta.19...v1.0.0-beta.20) (2022-05-30)
|
|
275
|
+
|
|
276
|
+
**Note:** Version bump only for package @operato/attachment
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
## [1.0.0-beta.19](https://github.com/hatiolab/operato/compare/v1.0.0-beta.18...v1.0.0-beta.19) (2022-05-29)
|
|
283
|
+
|
|
284
|
+
**Note:** Version bump only for package @operato/attachment
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
## [1.0.0-beta.18](https://github.com/hatiolab/operato/compare/v1.0.0-beta.17...v1.0.0-beta.18) (2022-05-27)
|
|
291
|
+
|
|
292
|
+
**Note:** Version bump only for package @operato/attachment
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
## [1.0.0-beta.17](https://github.com/hatiolab/operato/compare/v1.0.0-beta.16...v1.0.0-beta.17) (2022-05-25)
|
|
299
|
+
|
|
300
|
+
**Note:** Version bump only for package @operato/attachment
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
## [1.0.0-beta.16](https://github.com/hatiolab/operato/compare/v1.0.0-beta.15...v1.0.0-beta.16) (2022-05-23)
|
|
307
|
+
|
|
308
|
+
**Note:** Version bump only for package @operato/attachment
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
## [1.0.0-beta.15](https://github.com/hatiolab/operato/compare/v1.0.0-beta.14...v1.0.0-beta.15) (2022-05-20)
|
|
315
|
+
|
|
316
|
+
**Note:** Version bump only for package @operato/attachment
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
## [1.0.0-beta.14](https://github.com/hatiolab/operato/compare/v1.0.0-beta.13...v1.0.0-beta.14) (2022-05-19)
|
|
323
|
+
|
|
324
|
+
**Note:** Version bump only for package @operato/attachment
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
## [1.0.0-beta.13](https://github.com/hatiolab/operato/compare/v1.0.0-beta.12...v1.0.0-beta.13) (2022-05-19)
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
### :bug: Bug Fix
|
|
334
|
+
|
|
335
|
+
* incorrect package.json scripts for storybooks ([8c8c405](https://github.com/hatiolab/operato/commit/8c8c405443247108b9c411b8161c008d9b6a2261))
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
## [1.0.0-beta.12](https://github.com/hatiolab/operato/compare/v1.0.0-beta.11...v1.0.0-beta.12) (2022-05-13)
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
### :rocket: New Features
|
|
343
|
+
|
|
344
|
+
* storybook started ([90c08c9](https://github.com/hatiolab/operato/commit/90c08c9a15e5fe554baaa1becca07793e8434799))
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
## [1.0.0-beta.11](https://github.com/hatiolab/operato/compare/v1.0.0-beta.10...v1.0.0-beta.11) (2022-05-01)
|
|
349
|
+
|
|
350
|
+
**Note:** Version bump only for package @operato/attachment
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
## [1.0.0-beta.10](https://github.com/hatiolab/operato/compare/v1.0.0-beta.9...v1.0.0-beta.10) (2022-04-28)
|
|
357
|
+
|
|
358
|
+
**Note:** Version bump only for package @operato/attachment
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
## [1.0.0-beta.9](https://github.com/hatiolab/operato/compare/v1.0.0-beta.8...v1.0.0-beta.9) (2022-04-28)
|
|
365
|
+
|
|
366
|
+
**Note:** Version bump only for package @operato/attachment
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
6
372
|
## [1.0.0-beta.8](https://github.com/hatiolab/operato/compare/v1.0.0-beta.7...v1.0.0-beta.8) (2022-04-27)
|
|
7
373
|
|
|
8
374
|
**Note:** Version bump only for package @operato/attachment
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import '@operato/data-grist';
|
|
2
2
|
import '@operato/input/ox-input-file.js';
|
|
3
|
-
import { LitElement
|
|
4
|
-
import { ColumnConfig, FieldRenderer, FiltersForm, GristData, GristRecord,
|
|
3
|
+
import { LitElement } from 'lit';
|
|
4
|
+
import { ColumnConfig, FetchOption, FieldRenderer, FiltersForm, FilterValue, GristData, GristRecord, SortersConfig } from '@operato/data-grist';
|
|
5
5
|
export declare class OxAttachmentList extends LitElement {
|
|
6
6
|
static styles: import("lit").CSSResult[];
|
|
7
|
-
categories: any[];
|
|
8
7
|
category: string;
|
|
9
8
|
creatable: boolean;
|
|
10
9
|
private grist;
|
|
11
10
|
fileUploader: any;
|
|
12
11
|
filtersForm: FiltersForm;
|
|
13
12
|
render(): import("lit-html").TemplateResult<1>;
|
|
14
|
-
fetchHandler({ page, limit,
|
|
15
|
-
page: number;
|
|
16
|
-
limit: number;
|
|
17
|
-
sorters: SortersConfig;
|
|
18
|
-
}): Promise<{
|
|
13
|
+
fetchHandler({ page, limit, sortings, filters }: FetchOption): Promise<{
|
|
19
14
|
total: any;
|
|
20
15
|
records: any;
|
|
21
16
|
}>;
|
|
@@ -71,6 +66,7 @@ export declare class OxAttachmentList extends LitElement {
|
|
|
71
66
|
record: {
|
|
72
67
|
editable: boolean;
|
|
73
68
|
align: string;
|
|
69
|
+
options?: undefined;
|
|
74
70
|
renderer?: undefined;
|
|
75
71
|
};
|
|
76
72
|
width: number;
|
|
@@ -87,6 +83,7 @@ export declare class OxAttachmentList extends LitElement {
|
|
|
87
83
|
record: {
|
|
88
84
|
editable: boolean;
|
|
89
85
|
align: string;
|
|
86
|
+
options?: undefined;
|
|
90
87
|
renderer?: undefined;
|
|
91
88
|
};
|
|
92
89
|
width: number;
|
|
@@ -99,6 +96,25 @@ export declare class OxAttachmentList extends LitElement {
|
|
|
99
96
|
icon?: undefined;
|
|
100
97
|
hidden?: undefined;
|
|
101
98
|
sortable?: undefined;
|
|
99
|
+
} | {
|
|
100
|
+
type: string;
|
|
101
|
+
name: string;
|
|
102
|
+
header: string;
|
|
103
|
+
record: {
|
|
104
|
+
options: string[];
|
|
105
|
+
editable: boolean;
|
|
106
|
+
align?: undefined;
|
|
107
|
+
renderer?: undefined;
|
|
108
|
+
};
|
|
109
|
+
hidden: boolean;
|
|
110
|
+
filter: {
|
|
111
|
+
value: string;
|
|
112
|
+
};
|
|
113
|
+
gutterName?: undefined;
|
|
114
|
+
icon?: undefined;
|
|
115
|
+
handlers?: undefined;
|
|
116
|
+
width?: undefined;
|
|
117
|
+
sortable?: undefined;
|
|
102
118
|
} | {
|
|
103
119
|
type: string;
|
|
104
120
|
name: string;
|
|
@@ -107,6 +123,7 @@ export declare class OxAttachmentList extends LitElement {
|
|
|
107
123
|
editable: boolean;
|
|
108
124
|
renderer: FieldRenderer;
|
|
109
125
|
align?: undefined;
|
|
126
|
+
options?: undefined;
|
|
110
127
|
};
|
|
111
128
|
handlers: {
|
|
112
129
|
click: (columns: ColumnConfig[], data: GristData, column: ColumnConfig, record: GristRecord, rowIndex: number, target: HTMLElement) => void;
|
|
@@ -125,6 +142,7 @@ export declare class OxAttachmentList extends LitElement {
|
|
|
125
142
|
record: {
|
|
126
143
|
editable: boolean;
|
|
127
144
|
align?: undefined;
|
|
145
|
+
options?: undefined;
|
|
128
146
|
renderer?: undefined;
|
|
129
147
|
};
|
|
130
148
|
sortable: boolean;
|
|
@@ -156,7 +174,6 @@ export declare class OxAttachmentList extends LitElement {
|
|
|
156
174
|
};
|
|
157
175
|
};
|
|
158
176
|
firstUpdated(): Promise<void>;
|
|
159
|
-
updated(changes: PropertyValues<this>): void;
|
|
160
177
|
onClickSelect(attachment: any): void;
|
|
161
178
|
onCreateAttachment(e: CustomEvent): Promise<void>;
|
|
162
179
|
onDeleteAttachment(id: string): Promise<void>;
|
|
@@ -164,7 +181,7 @@ export declare class OxAttachmentList extends LitElement {
|
|
|
164
181
|
getAttachments({ page, limit, filters, sortings }?: {
|
|
165
182
|
page?: number;
|
|
166
183
|
limit?: number;
|
|
167
|
-
filters?:
|
|
184
|
+
filters?: FilterValue[];
|
|
168
185
|
sortings?: SortersConfig;
|
|
169
186
|
}): Promise<any>;
|
|
170
187
|
createAttachments(files: File[]): Promise<void>;
|
|
@@ -2,7 +2,6 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import '@operato/data-grist';
|
|
3
3
|
import '@operato/input/ox-input-file.js';
|
|
4
4
|
import gql from 'graphql-tag';
|
|
5
|
-
import i18next from 'i18next';
|
|
6
5
|
import { css, html, LitElement } from 'lit';
|
|
7
6
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
8
7
|
import { buildArgs, client } from '@operato/graphql';
|
|
@@ -52,7 +51,6 @@ const CREATE_ATTACHMENTS_GQL = gql `
|
|
|
52
51
|
let OxAttachmentList = class OxAttachmentList extends LitElement {
|
|
53
52
|
constructor() {
|
|
54
53
|
super(...arguments);
|
|
55
|
-
this.categories = ['audio', 'video', 'image', 'text', 'application'];
|
|
56
54
|
this.category = '';
|
|
57
55
|
this.creatable = false;
|
|
58
56
|
}
|
|
@@ -60,23 +58,8 @@ let OxAttachmentList = class OxAttachmentList extends LitElement {
|
|
|
60
58
|
return html `
|
|
61
59
|
<ox-grist .config=${this.gristConfig} .mode=${'CARD'} auto-fetch .fetchHandler=${this.fetchHandler.bind(this)}>
|
|
62
60
|
<div slot="headroom" id="headroom">
|
|
63
|
-
|
|
64
61
|
<div id="filters">
|
|
65
|
-
<ox-filters-form
|
|
66
|
-
slot="headroom"
|
|
67
|
-
@change=${(e) => this.grist.fetch(true)}
|
|
68
|
-
></ox-filters-form>
|
|
69
|
-
|
|
70
|
-
<select
|
|
71
|
-
@change=${(e) => {
|
|
72
|
-
var _a;
|
|
73
|
-
this.category = (_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.value;
|
|
74
|
-
this.requestUpdate();
|
|
75
|
-
}}
|
|
76
|
-
>
|
|
77
|
-
<option value="">${i18next.t('text.please choose a category')}</option>
|
|
78
|
-
${this.categories.map(category => html ` <option value=${category} ?selected=${this.category == category}>${category}</option> `)}
|
|
79
|
-
</select>
|
|
62
|
+
<ox-filters-form autofocus></ox-filters-form>
|
|
80
63
|
</div>
|
|
81
64
|
|
|
82
65
|
<ox-input-file
|
|
@@ -85,12 +68,12 @@ let OxAttachmentList = class OxAttachmentList extends LitElement {
|
|
|
85
68
|
hide-filelist
|
|
86
69
|
@change=${this.onCreateAttachment.bind(this)}
|
|
87
70
|
></ox-input-file>
|
|
71
|
+
</div>
|
|
88
72
|
</ox-grist>
|
|
89
73
|
`;
|
|
90
74
|
}
|
|
91
|
-
async fetchHandler({ page, limit,
|
|
92
|
-
const
|
|
93
|
-
const { items: records, total } = await this.getAttachments({ page, limit, filters, sortings: sorters });
|
|
75
|
+
async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
|
|
76
|
+
const { items: records, total } = await this.getAttachments({ page, limit, filters, sortings });
|
|
94
77
|
return {
|
|
95
78
|
total,
|
|
96
79
|
records
|
|
@@ -194,6 +177,19 @@ let OxAttachmentList = class OxAttachmentList extends LitElement {
|
|
|
194
177
|
}
|
|
195
178
|
}
|
|
196
179
|
},
|
|
180
|
+
{
|
|
181
|
+
type: 'select',
|
|
182
|
+
name: 'category',
|
|
183
|
+
header: 'category',
|
|
184
|
+
record: {
|
|
185
|
+
options: ['', 'audio', 'video', 'image', 'text', 'application'],
|
|
186
|
+
editable: false
|
|
187
|
+
},
|
|
188
|
+
hidden: true,
|
|
189
|
+
filter: {
|
|
190
|
+
value: this.category
|
|
191
|
+
}
|
|
192
|
+
},
|
|
197
193
|
{
|
|
198
194
|
type: 'image',
|
|
199
195
|
name: 'thumbnail',
|
|
@@ -263,11 +259,6 @@ let OxAttachmentList = class OxAttachmentList extends LitElement {
|
|
|
263
259
|
async firstUpdated() {
|
|
264
260
|
this.refreshAttachments();
|
|
265
261
|
}
|
|
266
|
-
updated(changes) {
|
|
267
|
-
if (changes.has('category')) {
|
|
268
|
-
this.refreshAttachments();
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
262
|
onClickSelect(attachment) {
|
|
272
263
|
this.dispatchEvent(new CustomEvent('attachment-selected', {
|
|
273
264
|
composed: true,
|
|
@@ -295,12 +286,6 @@ let OxAttachmentList = class OxAttachmentList extends LitElement {
|
|
|
295
286
|
limit,
|
|
296
287
|
page
|
|
297
288
|
};
|
|
298
|
-
if (this.category)
|
|
299
|
-
filters.push({
|
|
300
|
-
name: 'category',
|
|
301
|
-
operator: 'eq',
|
|
302
|
-
value: this.category
|
|
303
|
-
});
|
|
304
289
|
var params = {
|
|
305
290
|
filters,
|
|
306
291
|
sortings,
|
|
@@ -392,9 +377,6 @@ OxAttachmentList.styles = [
|
|
|
392
377
|
}
|
|
393
378
|
`
|
|
394
379
|
];
|
|
395
|
-
__decorate([
|
|
396
|
-
property({ type: Array })
|
|
397
|
-
], OxAttachmentList.prototype, "categories", void 0);
|
|
398
380
|
__decorate([
|
|
399
381
|
property({ type: String })
|
|
400
382
|
], OxAttachmentList.prototype, "category", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-attachment-list.js","sourceRoot":"","sources":["../../src/ox-attachment-list.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAC5B,OAAO,iCAAiC,CAAA;AAExC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,E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;;;;;;;;;;;;;;;;;;;KA+CF;CACF,CAAA;AAE0B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;oDAAuE;AACrE;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAsB;AACpB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAA2B;AAEpC;IAAlB,KAAK,CAAC,UAAU,CAAC;+CAA0B;AACpB;IAAvB,KAAK,CAAC,eAAe,CAAC;sDAAmB;AAChB;IAAzB,KAAK,CAAC,iBAAiB,CAAC;qDAA0B;AA5DxC,gBAAgB;IAD5B,aAAa,CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CAma5B;SAnaY,gBAAgB","sourcesContent":["import '@operato/data-grist'\nimport '@operato/input/ox-input-file.js'\n\nimport gql from 'graphql-tag'\nimport i18next from 'i18next'\nimport { css, html, LitElement, PropertyValues } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport {\n ColumnConfig,\n DataGrist,\n FieldRenderer,\n FiltersForm,\n GristData,\n GristRecord,\n PaginationConfig,\n QueryFilter,\n SortersConfig\n} from '@operato/data-grist'\nimport { buildArgs, client } from '@operato/graphql'\nimport { ScrollbarStyles, TooltipStyles } from '@operato/styles'\nimport { copyToClipboard, sleep } from '@operato/utils'\n\nconst FETCH_ATTACHMENT_LIST_GQL = (listParam: any) => {\n return gql`\n {\n attachments(${buildArgs(listParam)}) {\n items {\n id\n name\n description\n mimetype\n encoding\n category\n fullpath\n path\n createdAt\n updatedAt\n }\n total\n }\n }\n`\n}\n\nconst DELETE_ATTACHMENT_GQL = gql`\n mutation DeleteAttachment($id: String!) {\n deleteAttachment(id: $id)\n }\n`\n\nconst CREATE_ATTACHMENTS_GQL = gql`\n mutation ($attachments: [NewAttachment!]!) {\n createAttachments(attachments: $attachments) {\n id\n name\n description\n mimetype\n encoding\n category\n path\n createdAt\n updatedAt\n }\n }\n`\n\n@customElement('ox-attachment-list')\nexport class OxAttachmentList extends LitElement {\n static styles = [\n ScrollbarStyles,\n TooltipStyles,\n css`\n :host {\n display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: red;\n --grid-record-emphasized-color: yellow;\n }\n\n ox-grist {\n flex: 1;\n overflow-y: auto;\n\n --grid-record-emphasized-background-color: red;\n --grid-record-emphasized-color: yellow;\n }\n\n #headroom {\n align-items: center;\n padding: var(--padding-default) var(--padding-wide);\n border-top: 2px solid rgba(0, 0, 0, 0.2);\n background-color: var(--theme-white-color);\n box-shadow: var(--box-shadow);\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 select {\n border: 0;\n outline: none;\n text-align: right;\n }\n\n @media only screen and (max-width: 460px) {\n #filters {\n flex-direction: column;\n }\n }\n `\n ]\n\n @property({ type: Array }) categories: any[] = ['audio', 'video', 'image', 'text', 'application']\n @property({ type: String }) category: string = ''\n @property({ type: Boolean }) creatable: boolean = false\n\n @query('ox-grist') private grist!: DataGrist\n @query('ox-input-file') fileUploader!: any\n @query('ox-filters-form') filtersForm!: FiltersForm\n\n render() {\n return html`\n <ox-grist .config=${this.gristConfig} .mode=${'CARD'} auto-fetch .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\" id=\"headroom\">\n \n <div id=\"filters\">\n <ox-filters-form\n slot=\"headroom\"\n @change=${(e: Event) => this.grist.fetch(true)}\n ></ox-filters-form>\n\n <select\n @change=${(e: Event) => {\n this.category = (e.currentTarget as HTMLInputElement)?.value\n this.requestUpdate()\n }}\n >\n <option value=\"\">${i18next.t('text.please choose a category')}</option>\n ${this.categories.map(\n category =>\n html` <option value=${category} ?selected=${this.category == category}>${category}</option> `\n )}\n </select>\n </div>\n\n <ox-input-file\n accept=\"*/*\"\n multiple=\"true\"\n hide-filelist\n @change=${this.onCreateAttachment.bind(this)}\n ></ox-input-file>\n </ox-grist>\n `\n }\n\n async fetchHandler({ page, limit, sorters = [] }: { page: number; limit: number; sorters: SortersConfig }) {\n const filters: QueryFilter[] = await this.filtersForm.getQueryFilters()\n const { items: records, total } = await this.getAttachments({ page, limit, filters, sortings: sorters })\n\n return {\n total,\n records\n }\n }\n\n get gristConfig() {\n return {\n list: {\n thumbnail: 'thumbnail',\n fields: ['name'],\n details: ['updatedAt']\n },\n columns: [\n {\n type: 'gutter',\n gutterName: 'dirty'\n },\n {\n type: 'gutter',\n gutterName: 'sequence'\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'open_in_new',\n handlers: {\n click: (\n columns: ColumnConfig[],\n data: GristData,\n column: ColumnConfig,\n record: GristRecord,\n rowIndex: number,\n target: HTMLElement\n ): void => {\n window.open(record.fullpath, '_blank')\n }\n }\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'link',\n handlers: {\n click: async (\n columns: ColumnConfig[],\n data: GristData,\n column: ColumnConfig,\n record: GristRecord,\n rowIndex: number,\n target: HTMLElement\n ): Promise<void> => {\n var { protocol, hostname, port } = location\n await copyToClipboard(`${protocol}//${hostname}:${port}${record.fullpath}`)\n\n target.setAttribute('data-tooltip', 'url copied!')\n await sleep(2000)\n target.removeAttribute('data-tooltip')\n }\n }\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'delete',\n handlers: {\n click: async (\n columns: ColumnConfig[],\n data: GristData,\n column: ColumnConfig,\n record: GristRecord,\n rowIndex: number,\n target: HTMLElement\n ): Promise<void> => {\n await this.deleteAttachment(record.id!)\n this.refreshAttachments()\n }\n }\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'save_alt',\n handlers: {\n click: (\n columns: ColumnConfig[],\n data: GristData,\n column: ColumnConfig,\n record: GristRecord,\n rowIndex: number,\n target: HTMLElement\n ): void => {\n const element = document.createElement('a')\n element.setAttribute('href', record.fullpath)\n element.setAttribute('download', record.name!)\n document.body.appendChild(element)\n element.click()\n }\n }\n },\n {\n type: 'string',\n name: 'id',\n hidden: true\n },\n {\n type: 'string',\n name: 'name',\n header: 'name',\n record: {\n editable: true,\n align: 'left'\n },\n width: 200,\n filter: 'search',\n sortable: true\n },\n {\n type: 'string',\n name: 'description',\n header: 'description',\n record: {\n editable: true,\n align: 'left'\n },\n width: 200,\n filter: 'search',\n handlers: {\n dblclick: (\n columns: ColumnConfig[],\n data: GristData,\n column: ColumnConfig,\n record: GristRecord,\n rowIndex: number\n ): void => {\n alert(`${column.name} ${record[column.name]}, row : ${rowIndex}`)\n }\n }\n },\n {\n type: 'image',\n name: 'thumbnail',\n hidden: true,\n record: {\n editable: false,\n renderer: function (value, column, record, rowIndex, owner) {\n return record.category == 'image'\n ? html` <img src=${record.fullpath} style=\"max-width: 100%; max-height: 100%;\" /> `\n : record.category == 'video'\n ? html` <video src=${record.fullpath} style=\"width: 100%; height: 100%;\" controls></video> `\n : html`\n <div style=\"width: 100%; height: 100%;\" etc>\n <mwc-icon outlined>insert_drive_file</mwc-icon>\n <span>${record.path.substr(record.path.lastIndexOf('.'))}</span>\n </div>\n `\n } as FieldRenderer\n },\n handlers: {\n click: (\n columns: ColumnConfig[],\n data: GristData,\n column: ColumnConfig,\n record: GristRecord,\n rowIndex: number,\n target: HTMLElement\n ): void => {\n this.onClickSelect(record)\n }\n }\n },\n {\n type: 'datetime',\n name: 'updatedAt',\n header: 'updated at',\n record: {\n editable: true\n },\n sortable: true,\n width: 180\n },\n {\n type: 'datetime',\n name: 'createdAt',\n header: 'created at',\n record: {\n editable: true\n },\n sortable: true,\n width: 180\n }\n ],\n rows: {\n selectable: {\n multiple: true\n },\n handlers: {\n click: 'select-row-toggle'\n },\n classifier: function (\n record: GristRecord,\n rowIndex: number\n ): { emphasized?: boolean | string | string[]; [key: string]: any } | void {}\n },\n sorters: [\n {\n name: 'name',\n desc: false\n }\n ],\n pagination: {\n pages: [20, 30, 50, 100, 200]\n }\n }\n }\n\n async firstUpdated() {\n this.refreshAttachments()\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('category')) {\n this.refreshAttachments()\n }\n }\n\n onClickSelect(attachment: any) {\n this.dispatchEvent(\n new CustomEvent('attachment-selected', {\n composed: true,\n bubbles: true,\n detail: {\n attachment\n }\n })\n )\n }\n\n async onCreateAttachment(e: CustomEvent) {\n const files = e.detail\n\n await this.createAttachments(files)\n this.refreshAttachments()\n }\n\n async onDeleteAttachment(id: string) {\n await this.deleteAttachment(id)\n\n this.refreshAttachments()\n }\n\n async refreshAttachments() {\n this.grist.fetch()\n }\n\n async getAttachments({\n page = 1,\n limit = 30,\n filters = [],\n sortings = []\n }: { page?: number; limit?: number; filters?: QueryFilter[]; sortings?: SortersConfig } = {}) {\n var pagination: PaginationConfig = {\n limit,\n page\n }\n\n if (this.category)\n filters.push({\n name: 'category',\n operator: 'eq',\n value: this.category\n })\n\n var params = {\n filters,\n sortings,\n pagination\n }\n\n var attachmentListResponse = await client.query({\n query: FETCH_ATTACHMENT_LIST_GQL(params)\n })\n\n if (!attachmentListResponse || !attachmentListResponse.data) {\n return {}\n }\n\n return attachmentListResponse?.data?.attachments || {}\n }\n\n async createAttachments(files: File[]) {\n /*\n ref. https://github.com/jaydenseric/graphql-multipart-request-spec#client\n */\n\n const response = await client.mutate({\n mutation: CREATE_ATTACHMENTS_GQL,\n variables: {\n attachments: files.map(file => {\n return { file }\n })\n },\n context: {\n hasUpload: true\n }\n })\n }\n\n async deleteAttachment(id: string) {\n const response = await client.mutate({\n mutation: DELETE_ATTACHMENT_GQL,\n variables: {\n id\n }\n })\n\n return response.data\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ox-attachment-list.js","sourceRoot":"","sources":["../../src/ox-attachment-list.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAC5B,OAAO,iCAAiC,CAAA;AAExC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EA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CAAC,MAAM,CAAC;YACnC,QAAQ,EAAE,sBAAsB;YAChC,SAAS,EAAE;gBACT,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;oBAC5B,OAAO,EAAE,IAAI,EAAE,CAAA;gBACjB,CAAC,CAAC;aACH;YACD,OAAO,EAAE;gBACP,SAAS,EAAE,IAAI;aAChB;SACF,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,EAAU;QAC/B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;YACnC,QAAQ,EAAE,qBAAqB;YAC/B,SAAS,EAAE;gBACT,EAAE;aACH;SACF,CAAC,CAAA;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAA;IACtB,CAAC;CACF,CAAA;AAhZQ,uBAAM,GAAG;IACd,eAAe;IACf,aAAa;IACb,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+CF;CACF,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAsB;AACpB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAA2B;AAEpC;IAAlB,KAAK,CAAC,UAAU,CAAC;+CAA0B;AACpB;IAAvB,KAAK,CAAC,eAAe,CAAC;sDAAmB;AAChB;IAAzB,KAAK,CAAC,iBAAiB,CAAC;qDAA0B;AA3DxC,gBAAgB;IAD5B,aAAa,CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CAiZ5B;SAjZY,gBAAgB","sourcesContent":["import '@operato/data-grist'\nimport '@operato/input/ox-input-file.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport {\n ColumnConfig,\n DataGrist,\n FetchOption,\n FieldRenderer,\n FiltersForm,\n FilterValue,\n GristData,\n GristRecord,\n PaginationConfig,\n SortersConfig\n} from '@operato/data-grist'\nimport { buildArgs, client } from '@operato/graphql'\nimport { ScrollbarStyles, TooltipStyles } from '@operato/styles'\nimport { copyToClipboard, sleep } from '@operato/utils'\n\nconst FETCH_ATTACHMENT_LIST_GQL = (listParam: any) => {\n return gql`\n {\n attachments(${buildArgs(listParam)}) {\n items {\n id\n name\n description\n mimetype\n encoding\n category\n fullpath\n path\n createdAt\n updatedAt\n }\n total\n }\n }\n`\n}\n\nconst DELETE_ATTACHMENT_GQL = gql`\n mutation DeleteAttachment($id: String!) {\n deleteAttachment(id: $id)\n }\n`\n\nconst CREATE_ATTACHMENTS_GQL = gql`\n mutation ($attachments: [NewAttachment!]!) {\n createAttachments(attachments: $attachments) {\n id\n name\n description\n mimetype\n encoding\n category\n path\n createdAt\n updatedAt\n }\n }\n`\n\n@customElement('ox-attachment-list')\nexport class OxAttachmentList extends LitElement {\n static styles = [\n ScrollbarStyles,\n TooltipStyles,\n css`\n :host {\n display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: red;\n --grid-record-emphasized-color: yellow;\n }\n\n ox-grist {\n flex: 1;\n overflow-y: auto;\n\n --grid-record-emphasized-background-color: red;\n --grid-record-emphasized-color: yellow;\n }\n\n #headroom {\n align-items: center;\n padding: var(--padding-default) var(--padding-wide);\n border-top: 2px solid rgba(0, 0, 0, 0.2);\n background-color: var(--theme-white-color);\n box-shadow: var(--box-shadow);\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 select {\n border: 0;\n outline: none;\n text-align: right;\n }\n\n @media only screen and (max-width: 460px) {\n #filters {\n flex-direction: column;\n }\n }\n `\n ]\n\n @property({ type: String }) category: string = ''\n @property({ type: Boolean }) creatable: boolean = false\n\n @query('ox-grist') private grist!: DataGrist\n @query('ox-input-file') fileUploader!: any\n @query('ox-filters-form') filtersForm!: FiltersForm\n\n render() {\n return html`\n <ox-grist .config=${this.gristConfig} .mode=${'CARD'} auto-fetch .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\" id=\"headroom\">\n <div id=\"filters\">\n <ox-filters-form autofocus></ox-filters-form>\n </div>\n\n <ox-input-file\n accept=\"*/*\"\n multiple=\"true\"\n hide-filelist\n @change=${this.onCreateAttachment.bind(this)}\n ></ox-input-file>\n </div>\n </ox-grist>\n `\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {\n const { items: records, total } = await this.getAttachments({ page, limit, filters, sortings })\n\n return {\n total,\n records\n }\n }\n\n get gristConfig() {\n return {\n list: {\n thumbnail: 'thumbnail',\n fields: ['name'],\n details: ['updatedAt']\n },\n columns: [\n {\n type: 'gutter',\n gutterName: 'dirty'\n },\n {\n type: 'gutter',\n gutterName: 'sequence'\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'open_in_new',\n handlers: {\n click: (\n columns: ColumnConfig[],\n data: GristData,\n column: ColumnConfig,\n record: GristRecord,\n rowIndex: number,\n target: HTMLElement\n ): void => {\n window.open(record.fullpath, '_blank')\n }\n }\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'link',\n handlers: {\n click: async (\n columns: ColumnConfig[],\n data: GristData,\n column: ColumnConfig,\n record: GristRecord,\n rowIndex: number,\n target: HTMLElement\n ): Promise<void> => {\n var { protocol, hostname, port } = location\n await copyToClipboard(`${protocol}//${hostname}:${port}${record.fullpath}`)\n\n target.setAttribute('data-tooltip', 'url copied!')\n await sleep(2000)\n target.removeAttribute('data-tooltip')\n }\n }\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'delete',\n handlers: {\n click: async (\n columns: ColumnConfig[],\n data: GristData,\n column: ColumnConfig,\n record: GristRecord,\n rowIndex: number,\n target: HTMLElement\n ): Promise<void> => {\n await this.deleteAttachment(record.id!)\n this.refreshAttachments()\n }\n }\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'save_alt',\n handlers: {\n click: (\n columns: ColumnConfig[],\n data: GristData,\n column: ColumnConfig,\n record: GristRecord,\n rowIndex: number,\n target: HTMLElement\n ): void => {\n const element = document.createElement('a')\n element.setAttribute('href', record.fullpath)\n element.setAttribute('download', record.name!)\n document.body.appendChild(element)\n element.click()\n }\n }\n },\n {\n type: 'string',\n name: 'id',\n hidden: true\n },\n {\n type: 'string',\n name: 'name',\n header: 'name',\n record: {\n editable: true,\n align: 'left'\n },\n width: 200,\n filter: 'search',\n sortable: true\n },\n {\n type: 'string',\n name: 'description',\n header: 'description',\n record: {\n editable: true,\n align: 'left'\n },\n width: 200,\n filter: 'search',\n handlers: {\n dblclick: (\n columns: ColumnConfig[],\n data: GristData,\n column: ColumnConfig,\n record: GristRecord,\n rowIndex: number\n ): void => {\n alert(`${column.name} ${record[column.name]}, row : ${rowIndex}`)\n }\n }\n },\n {\n type: 'select',\n name: 'category',\n header: 'category',\n record: {\n options: ['', 'audio', 'video', 'image', 'text', 'application'],\n editable: false\n },\n hidden: true,\n filter: {\n value: this.category\n }\n },\n {\n type: 'image',\n name: 'thumbnail',\n hidden: true,\n record: {\n editable: false,\n renderer: function (value, column, record, rowIndex, owner) {\n return record.category == 'image'\n ? html` <img src=${record.fullpath} style=\"max-width: 100%; max-height: 100%;\" /> `\n : record.category == 'video'\n ? html` <video src=${record.fullpath} style=\"width: 100%; height: 100%;\" controls></video> `\n : html`\n <div style=\"width: 100%; height: 100%;\" etc>\n <mwc-icon outlined>insert_drive_file</mwc-icon>\n <span>${record.path.substr(record.path.lastIndexOf('.'))}</span>\n </div>\n `\n } as FieldRenderer\n },\n handlers: {\n click: (\n columns: ColumnConfig[],\n data: GristData,\n column: ColumnConfig,\n record: GristRecord,\n rowIndex: number,\n target: HTMLElement\n ): void => {\n this.onClickSelect(record)\n }\n }\n },\n {\n type: 'datetime',\n name: 'updatedAt',\n header: 'updated at',\n record: {\n editable: true\n },\n sortable: true,\n width: 180\n },\n {\n type: 'datetime',\n name: 'createdAt',\n header: 'created at',\n record: {\n editable: true\n },\n sortable: true,\n width: 180\n }\n ],\n rows: {\n selectable: {\n multiple: true\n },\n handlers: {\n click: 'select-row-toggle'\n },\n classifier: function (\n record: GristRecord,\n rowIndex: number\n ): { emphasized?: boolean | string | string[]; [key: string]: any } | void {}\n },\n sorters: [\n {\n name: 'name',\n desc: false\n }\n ],\n pagination: {\n pages: [20, 30, 50, 100, 200]\n }\n }\n }\n\n async firstUpdated() {\n this.refreshAttachments()\n }\n\n onClickSelect(attachment: any) {\n this.dispatchEvent(\n new CustomEvent('attachment-selected', {\n composed: true,\n bubbles: true,\n detail: {\n attachment\n }\n })\n )\n }\n\n async onCreateAttachment(e: CustomEvent) {\n const files = e.detail\n\n await this.createAttachments(files)\n this.refreshAttachments()\n }\n\n async onDeleteAttachment(id: string) {\n await this.deleteAttachment(id)\n\n this.refreshAttachments()\n }\n\n async refreshAttachments() {\n this.grist.fetch()\n }\n\n async getAttachments({\n page = 1,\n limit = 30,\n filters = [],\n sortings = []\n }: { page?: number; limit?: number; filters?: FilterValue[]; sortings?: SortersConfig } = {}) {\n var pagination: PaginationConfig = {\n limit,\n page\n }\n\n var params = {\n filters,\n sortings,\n pagination\n }\n\n var attachmentListResponse = await client.query({\n query: FETCH_ATTACHMENT_LIST_GQL(params)\n })\n\n if (!attachmentListResponse || !attachmentListResponse.data) {\n return {}\n }\n\n return attachmentListResponse?.data?.attachments || {}\n }\n\n async createAttachments(files: File[]) {\n /*\n ref. https://github.com/jaydenseric/graphql-multipart-request-spec#client\n */\n\n const response = await client.mutate({\n mutation: CREATE_ATTACHMENTS_GQL,\n variables: {\n attachments: files.map(file => {\n return { file }\n })\n },\n context: {\n hasUpload: true\n }\n })\n }\n\n async deleteAttachment(id: string) {\n const response = await client.mutate({\n mutation: DELETE_ATTACHMENT_GQL,\n variables: {\n id\n }\n })\n\n return response.data\n }\n}\n"]}
|
|
@@ -10,7 +10,7 @@ export declare class OxPropertyEditorAttachmentSelector extends LitElement {
|
|
|
10
10
|
properties: any;
|
|
11
11
|
private popup?;
|
|
12
12
|
render(): import("lit-html").TemplateResult<1>;
|
|
13
|
-
getIconByCategory(): "
|
|
13
|
+
getIconByCategory(): "image" | "library_music" | "video_library" | "attachment";
|
|
14
14
|
_onInputChanged(e: KeyboardEvent): void;
|
|
15
15
|
openSelector(): void;
|
|
16
16
|
}
|