@operato/attachment 1.0.0-alpha.5 → 1.0.0-alpha.50

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 CHANGED
@@ -3,6 +3,375 @@
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.50](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.49...v1.0.0-alpha.50) (2022-04-04)
7
+
8
+ **Note:** Version bump only for package @operato/attachment
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.0.0-alpha.49](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.48...v1.0.0-alpha.49) (2022-04-04)
15
+
16
+
17
+ ### :bug: Bug Fix
18
+
19
+ * lit@2.2.1 ([6707752](https://github.com/hatiolab/operato/commit/6707752907d24f7ecbe248cba18a4b18cfda282f))
20
+
21
+
22
+
23
+ ## [1.0.0-alpha.48](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.47...v1.0.0-alpha.48) (2022-04-03)
24
+
25
+ **Note:** Version bump only for package @operato/attachment
26
+
27
+
28
+
29
+
30
+
31
+ ## [1.0.0-alpha.47](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.46...v1.0.0-alpha.47) (2022-04-02)
32
+
33
+ **Note:** Version bump only for package @operato/attachment
34
+
35
+
36
+
37
+
38
+
39
+ ## [1.0.0-alpha.46](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.45...v1.0.0-alpha.46) (2022-04-02)
40
+
41
+ **Note:** Version bump only for package @operato/attachment
42
+
43
+
44
+
45
+
46
+
47
+ ## [1.0.0-alpha.45](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.44...v1.0.0-alpha.45) (2022-03-31)
48
+
49
+ **Note:** Version bump only for package @operato/attachment
50
+
51
+
52
+
53
+
54
+
55
+ ## [1.0.0-alpha.44](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.43...v1.0.0-alpha.44) (2022-03-31)
56
+
57
+ **Note:** Version bump only for package @operato/attachment
58
+
59
+
60
+
61
+
62
+
63
+ ## [1.0.0-alpha.43](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.42...v1.0.0-alpha.43) (2022-03-30)
64
+
65
+ **Note:** Version bump only for package @operato/attachment
66
+
67
+
68
+
69
+
70
+
71
+ ## [1.0.0-alpha.42](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.41...v1.0.0-alpha.42) (2022-03-29)
72
+
73
+ **Note:** Version bump only for package @operato/attachment
74
+
75
+
76
+
77
+
78
+
79
+ ## [1.0.0-alpha.41](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.40...v1.0.0-alpha.41) (2022-03-27)
80
+
81
+ **Note:** Version bump only for package @operato/attachment
82
+
83
+
84
+
85
+
86
+
87
+ ## [1.0.0-alpha.40](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.39...v1.0.0-alpha.40) (2022-03-26)
88
+
89
+ **Note:** Version bump only for package @operato/attachment
90
+
91
+
92
+
93
+
94
+
95
+ ## [1.0.0-alpha.39](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.38...v1.0.0-alpha.39) (2022-03-25)
96
+
97
+ **Note:** Version bump only for package @operato/attachment
98
+
99
+
100
+
101
+
102
+
103
+ ## [1.0.0-alpha.38](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.37...v1.0.0-alpha.38) (2022-03-25)
104
+
105
+ **Note:** Version bump only for package @operato/attachment
106
+
107
+
108
+
109
+
110
+
111
+ ## [1.0.0-alpha.37](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.36...v1.0.0-alpha.37) (2022-03-25)
112
+
113
+ **Note:** Version bump only for package @operato/attachment
114
+
115
+
116
+
117
+
118
+
119
+ ## [1.0.0-alpha.36](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.35...v1.0.0-alpha.36) (2022-03-21)
120
+
121
+ **Note:** Version bump only for package @operato/attachment
122
+
123
+
124
+
125
+
126
+
127
+ ## [1.0.0-alpha.35](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.34...v1.0.0-alpha.35) (2022-03-21)
128
+
129
+ **Note:** Version bump only for package @operato/attachment
130
+
131
+
132
+
133
+
134
+
135
+ ## [1.0.0-alpha.34](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.33...v1.0.0-alpha.34) (2022-03-20)
136
+
137
+ **Note:** Version bump only for package @operato/attachment
138
+
139
+
140
+
141
+
142
+
143
+ ## [1.0.0-alpha.33](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.32...v1.0.0-alpha.33) (2022-03-19)
144
+
145
+ **Note:** Version bump only for package @operato/attachment
146
+
147
+
148
+
149
+
150
+
151
+ ## [1.0.0-alpha.32](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.31...v1.0.0-alpha.32) (2022-03-19)
152
+
153
+ **Note:** Version bump only for package @operato/attachment
154
+
155
+
156
+
157
+
158
+
159
+ ## [1.0.0-alpha.31](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.30...v1.0.0-alpha.31) (2022-03-19)
160
+
161
+ **Note:** Version bump only for package @operato/attachment
162
+
163
+
164
+
165
+
166
+
167
+ ## [1.0.0-alpha.30](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.29...v1.0.0-alpha.30) (2022-03-18)
168
+
169
+ **Note:** Version bump only for package @operato/attachment
170
+
171
+
172
+
173
+
174
+
175
+ ## [1.0.0-alpha.29](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.28...v1.0.0-alpha.29) (2022-03-17)
176
+
177
+ **Note:** Version bump only for package @operato/attachment
178
+
179
+
180
+
181
+
182
+
183
+ ## [1.0.0-alpha.28](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.26...v1.0.0-alpha.28) (2022-03-17)
184
+
185
+ **Note:** Version bump only for package @operato/attachment
186
+
187
+
188
+
189
+
190
+
191
+ ## [1.0.0-alpha.27](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.26...v1.0.0-alpha.27) (2022-03-17)
192
+
193
+ **Note:** Version bump only for package @operato/attachment
194
+
195
+
196
+
197
+
198
+
199
+ ## [1.0.0-alpha.26](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.25...v1.0.0-alpha.26) (2022-03-17)
200
+
201
+ **Note:** Version bump only for package @operato/attachment
202
+
203
+
204
+
205
+
206
+
207
+ ## [1.0.0-alpha.25](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.24...v1.0.0-alpha.25) (2022-03-17)
208
+
209
+ **Note:** Version bump only for package @operato/attachment
210
+
211
+
212
+
213
+
214
+
215
+ ## [1.0.0-alpha.24](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.23...v1.0.0-alpha.24) (2022-03-17)
216
+
217
+ **Note:** Version bump only for package @operato/attachment
218
+
219
+
220
+
221
+
222
+
223
+ ## [1.0.0-alpha.23](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.22...v1.0.0-alpha.23) (2022-03-17)
224
+
225
+ **Note:** Version bump only for package @operato/attachment
226
+
227
+
228
+
229
+
230
+
231
+ ## [1.0.0-alpha.22](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.21...v1.0.0-alpha.22) (2022-03-17)
232
+
233
+ **Note:** Version bump only for package @operato/attachment
234
+
235
+
236
+
237
+
238
+
239
+ ## [1.0.0-alpha.21](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.20...v1.0.0-alpha.21) (2022-03-16)
240
+
241
+ **Note:** Version bump only for package @operato/attachment
242
+
243
+
244
+
245
+
246
+
247
+ ## [1.0.0-alpha.20](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.19...v1.0.0-alpha.20) (2022-03-15)
248
+
249
+ **Note:** Version bump only for package @operato/attachment
250
+
251
+
252
+
253
+
254
+
255
+ ## [1.0.0-alpha.19](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.18...v1.0.0-alpha.19) (2022-03-14)
256
+
257
+ **Note:** Version bump only for package @operato/attachment
258
+
259
+
260
+
261
+
262
+
263
+ ## [1.0.0-alpha.18](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.17...v1.0.0-alpha.18) (2022-03-14)
264
+
265
+ **Note:** Version bump only for package @operato/attachment
266
+
267
+
268
+
269
+
270
+
271
+ ## [1.0.0-alpha.17](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.16...v1.0.0-alpha.17) (2022-03-13)
272
+
273
+ **Note:** Version bump only for package @operato/attachment
274
+
275
+
276
+
277
+
278
+
279
+ ## [1.0.0-alpha.16](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.15...v1.0.0-alpha.16) (2022-03-13)
280
+
281
+ **Note:** Version bump only for package @operato/attachment
282
+
283
+
284
+
285
+
286
+
287
+ ## [1.0.0-alpha.15](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.14...v1.0.0-alpha.15) (2022-03-13)
288
+
289
+ **Note:** Version bump only for package @operato/attachment
290
+
291
+
292
+
293
+
294
+
295
+ ## [1.0.0-alpha.14](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.13...v1.0.0-alpha.14) (2022-03-13)
296
+
297
+ **Note:** Version bump only for package @operato/attachment
298
+
299
+
300
+
301
+
302
+
303
+ ## [1.0.0-alpha.13](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.12...v1.0.0-alpha.13) (2022-03-13)
304
+
305
+ **Note:** Version bump only for package @operato/attachment
306
+
307
+
308
+
309
+
310
+
311
+ ## [1.0.0-alpha.12](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.11...v1.0.0-alpha.12) (2022-03-13)
312
+
313
+
314
+ ### :bug: Bug Fix
315
+
316
+ * missing import ([c9ed5f9](https://github.com/hatiolab/operato/commit/c9ed5f9c3566e899ebd40e920d9f08200ca5a5c6))
317
+
318
+
319
+ ### :rocket: New Features
320
+
321
+ * migrate input, property-editor from things-factory ([4800d85](https://github.com/hatiolab/operato/commit/4800d859473bf623325233a7f2af851e5d093dcb))
322
+
323
+
324
+
325
+ ## [1.0.0-alpha.11](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.10...v1.0.0-alpha.11) (2022-03-12)
326
+
327
+
328
+ ### :bug: Bug Fix
329
+
330
+ * ox-property-editor-attachment-selector ([a1a2d20](https://github.com/hatiolab/operato/commit/a1a2d20640746c891248fdb729097614676c9cff))
331
+
332
+
333
+
334
+ ## [1.0.0-alpha.10](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.9...v1.0.0-alpha.10) (2022-03-12)
335
+
336
+ **Note:** Version bump only for package @operato/attachment
337
+
338
+
339
+
340
+
341
+
342
+ ## [1.0.0-alpha.9](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.8...v1.0.0-alpha.9) (2022-03-12)
343
+
344
+
345
+ ### :rocket: New Features
346
+
347
+ * settled concept for input, property-editor, grist-editor, so on ([0c9e1d0](https://github.com/hatiolab/operato/commit/0c9e1d054c7aef5d965868242cf471667af7a3c3))
348
+
349
+
350
+
351
+ ## [1.0.0-alpha.8](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.7...v1.0.0-alpha.8) (2022-03-11)
352
+
353
+ **Note:** Version bump only for package @operato/attachment
354
+
355
+
356
+
357
+
358
+
359
+ ## [1.0.0-alpha.7](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.6...v1.0.0-alpha.7) (2022-03-11)
360
+
361
+ **Note:** Version bump only for package @operato/attachment
362
+
363
+
364
+
365
+
366
+
367
+ ## [1.0.0-alpha.6](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.5...v1.0.0-alpha.6) (2022-03-11)
368
+
369
+ **Note:** Version bump only for package @operato/attachment
370
+
371
+
372
+
373
+
374
+
6
375
  ## [1.0.0-alpha.5](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.4...v1.0.0-alpha.5) (2022-03-11)
7
376
 
8
377
  **Note:** Version bump only for package @operato/attachment
@@ -1,7 +1,7 @@
1
1
  import '@operato/data-grist';
2
2
  import '@operato/input/ox-input-file.js';
3
- import { LitElement, PropertyValues } from 'lit';
4
3
  import { ColumnConfig, FieldRenderer, FiltersForm, GristData, GristRecord, QueryFilter, SortersConfig } from '@operato/data-grist';
4
+ import { LitElement, PropertyValues } from 'lit';
5
5
  export declare class OxAttachmentList extends LitElement {
6
6
  static styles: import("lit").CSSResult[];
7
7
  categories: any[];
@@ -108,9 +108,12 @@ export declare class OxAttachmentList extends LitElement {
108
108
  renderer: FieldRenderer;
109
109
  align?: undefined;
110
110
  };
111
+ handlers: {
112
+ click: (columns: ColumnConfig[], data: GristData, column: ColumnConfig, record: GristRecord, rowIndex: number, target: HTMLElement) => void;
113
+ dblclick?: undefined;
114
+ };
111
115
  gutterName?: undefined;
112
116
  icon?: undefined;
113
- handlers?: undefined;
114
117
  header?: undefined;
115
118
  width?: undefined;
116
119
  filter?: undefined;
@@ -1,12 +1,12 @@
1
1
  import { __decorate } from "tslib";
2
2
  import '@operato/data-grist';
3
3
  import '@operato/input/ox-input-file.js';
4
+ import { LitElement, css, html } from 'lit';
5
+ import { ScrollbarStyles, TooltipStyles } from '@operato/styles';
6
+ import { buildArgs, client } from '@operato/graphql';
7
+ import { customElement, property, query } from 'lit/decorators.js';
4
8
  import gql from 'graphql-tag';
5
9
  import i18next from 'i18next';
6
- import { css, html, LitElement } from 'lit';
7
- import { customElement, property, query } from 'lit/decorators.js';
8
- import { buildArgs, client } from '@operato/graphql';
9
- import { ScrollbarStyles, TooltipStyles } from '@operato/styles';
10
10
  import { sleep } from '@operato/utils';
11
11
  const FETCH_ATTACHMENT_LIST_GQL = (listParam) => {
12
12
  return gql `
@@ -212,6 +212,11 @@ let OxAttachmentList = class OxAttachmentList extends LitElement {
212
212
  </div>
213
213
  `;
214
214
  }
215
+ },
216
+ handlers: {
217
+ click: (columns, data, column, record, rowIndex, target) => {
218
+ this.onClickSelect(record);
219
+ }
215
220
  }
216
221
  },
217
222
  {
@@ -1 +1 @@
1
- {"version":3,"file":"ox-attachment-list.js","sourceRoot":"","sources":["../../src/ox-attachment-list.ts"],"names":[],"mappings":";AAAA,OAAO,qB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1B,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,CAuZ5B;SAvZY,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 { 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 navigator.clipboard.writeText(`${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 },\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;AAaxC,OAAO,EAAE,UAAU,EAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,GAAG,MAAM,aAAa,C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AC,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 {\n ColumnConfig,\n DataGrist,\n FieldRenderer,\n FiltersForm,\n GristData,\n GristRecord,\n PaginationConfig,\n QueryFilter,\n SortersConfig\n} from '@operato/data-grist'\nimport { LitElement, PropertyValues, css, html } from 'lit'\nimport { ScrollbarStyles, TooltipStyles } from '@operato/styles'\nimport { buildArgs, client } from '@operato/graphql'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport gql from 'graphql-tag'\nimport i18next from 'i18next'\nimport { 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 navigator.clipboard.writeText(`${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"]}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import '@material/mwc-icon';
5
+ import './ox-attachment-list.js';
6
+ import { LitElement } from 'lit';
7
+ export declare class OxPropertyEditorAttachmentSelector extends LitElement {
8
+ static styles: import("lit").CSSResult[];
9
+ value: string;
10
+ properties: any;
11
+ private popup?;
12
+ render(): import("lit-html").TemplateResult<1>;
13
+ getIconByCategory(): "image" | "library_music" | "video_library" | "attachment";
14
+ _onInputChanged(e: KeyboardEvent): void;
15
+ openSelector(): void;
16
+ }
@@ -0,0 +1,108 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { __decorate } from "tslib";
5
+ import '@material/mwc-icon';
6
+ import './ox-attachment-list.js';
7
+ import { LitElement, css, html } from 'lit';
8
+ import { openPopup } from '@operato/layout';
9
+ import { customElement, property } from 'lit/decorators.js';
10
+ import { i18next } from '@operato/i18n';
11
+ let OxPropertyEditorAttachmentSelector = class OxPropertyEditorAttachmentSelector extends LitElement {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.value = '';
15
+ }
16
+ render() {
17
+ return html `
18
+ <input
19
+ id="text"
20
+ type="text"
21
+ .value=${this.value || ''}
22
+ @change=${(e) => this._onInputChanged(e)}
23
+ />
24
+
25
+ <mwc-icon @click=${() => this.openSelector()}>${this.getIconByCategory()}</mwc-icon>
26
+ `;
27
+ }
28
+ getIconByCategory() {
29
+ var { category } = this.properties || {};
30
+ switch (category) {
31
+ case 'audio':
32
+ return 'library_music';
33
+ case 'video':
34
+ return 'video_library';
35
+ case 'image':
36
+ return 'image';
37
+ case 'text':
38
+ case 'application':
39
+ default:
40
+ return 'attachment';
41
+ }
42
+ }
43
+ _onInputChanged(e) {
44
+ this.value = e.target.value;
45
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
46
+ }
47
+ openSelector() {
48
+ if (this.popup) {
49
+ delete this.popup;
50
+ }
51
+ /*
52
+ * 기존 설정된 이미지가 선택된 상태가 되게 하기 위해서는 selector에 value를 전달해줄 필요가 있음.
53
+ * 주의. value는 object일 수도 있고, string일 수도 있다.
54
+ * string인 경우에는 해당 보드의 id로 해석한다.
55
+ */
56
+ var value = this.value || {};
57
+ var { category = 'application' } = this.properties || {};
58
+ var template = html `
59
+ <ox-attachment-list
60
+ .creatable=${true}
61
+ .category=${category}
62
+ @attachment-selected=${async (e) => {
63
+ var attachment = e.detail.attachment;
64
+ this.value = `/attachment/${attachment.path}`;
65
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
66
+ this.popup && this.popup.close();
67
+ }}
68
+ ></ox-attachment-list>
69
+ `;
70
+ this.popup = openPopup(template, {
71
+ backdrop: true,
72
+ size: 'large',
73
+ title: i18next.t('title.select attachment')
74
+ });
75
+ }
76
+ };
77
+ OxPropertyEditorAttachmentSelector.styles = [
78
+ css `
79
+ :host {
80
+ position: relative;
81
+ display: inline-block;
82
+ }
83
+
84
+ input[type='text'] {
85
+ box-sizing: border-box;
86
+ width: 100%;
87
+ height: 100%;
88
+ border: 1px solid rgba(0, 0, 0, 0.2);
89
+ }
90
+
91
+ mwc-icon {
92
+ position: absolute;
93
+ top: 0;
94
+ right: 3px;
95
+ }
96
+ `
97
+ ];
98
+ __decorate([
99
+ property({ type: String })
100
+ ], OxPropertyEditorAttachmentSelector.prototype, "value", void 0);
101
+ __decorate([
102
+ property({ type: Object })
103
+ ], OxPropertyEditorAttachmentSelector.prototype, "properties", void 0);
104
+ OxPropertyEditorAttachmentSelector = __decorate([
105
+ customElement('ox-attachment-selector')
106
+ ], OxPropertyEditorAttachmentSelector);
107
+ export { OxPropertyEditorAttachmentSelector };
108
+ //# sourceMappingURL=ox-attachment-selector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-attachment-selector.js","sourceRoot":"","sources":["../../src/ox-attachment-selector.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,oBAAoB,CAAA;AAC3B,OAAO,yBAAyB,CAAA;AAEhC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,IAAa,kCAAkC,GAA/C,MAAa,kCAAmC,SAAQ,UAAU;IAAlE;;QAuB8B,UAAK,GAAW,EAAE,CAAA;IAyEhD,CAAC;IApEC,MAAM;QACJ,OAAO,IAAI,CAAA;;;;iBAIE,IAAI,CAAC,KAAK,IAAI,EAAE;kBACf,CAAC,CAAgB,EAAE,E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C,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;YAEhF,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QAClC,CAAC;;KAEJ,CAAA;QAED,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE;YAC/B,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,yBAAyB,CAAC;SAC5C,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AA/FQ,yCAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;KAkBF;CACF,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iEAAmB;AAClB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sEAAgB;AAxBhC,kCAAkC;IAD9C,aAAa,CAAC,wBAAwB,CAAC;GAC3B,kCAAkC,CAgG9C;SAhGY,kCAAkC","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/mwc-icon'\nimport './ox-attachment-list.js'\n\nimport { LitElement, css, html } from 'lit'\nimport { PopupHandle, openPopup } from '@operato/layout'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\n\n@customElement('ox-attachment-selector')\nexport class OxPropertyEditorAttachmentSelector extends LitElement {\n static styles = [\n css`\n :host {\n position: relative;\n display: inline-block;\n }\n\n input[type='text'] {\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n border: 1px solid rgba(0, 0, 0, 0.2);\n }\n\n mwc-icon {\n position: absolute;\n top: 0;\n right: 3px;\n }\n `\n ]\n\n @property({ type: String }) value: string = ''\n @property({ type: Object }) properties: any\n\n private popup?: PopupHandle\n\n render() {\n return html`\n <input\n id=\"text\"\n type=\"text\"\n .value=${this.value || ''}\n @change=${(e: KeyboardEvent) => this._onInputChanged(e)}\n />\n\n <mwc-icon @click=${() => this.openSelector()}>${this.getIconByCategory()}</mwc-icon>\n `\n }\n\n getIconByCategory() {\n var { category } = this.properties || {}\n switch (category) {\n case 'audio':\n return 'library_music'\n case 'video':\n return 'video_library'\n case 'image':\n return 'image'\n case 'text':\n case 'application':\n default:\n return 'attachment'\n }\n }\n\n _onInputChanged(e: KeyboardEvent) {\n this.value = (e.target as HTMLInputElement).value\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n\n openSelector() {\n if (this.popup) {\n delete this.popup\n }\n\n /*\n * 기존 설정된 이미지가 선택된 상태가 되게 하기 위해서는 selector에 value를 전달해줄 필요가 있음.\n * 주의. value는 object일 수도 있고, string일 수도 있다.\n * string인 경우에는 해당 보드의 id로 해석한다.\n */\n var value = this.value || {}\n var { category = 'application' } = this.properties || {}\n\n var template = html`\n <ox-attachment-list\n .creatable=${true}\n .category=${category}\n @attachment-selected=${async (e: CustomEvent) => {\n var attachment = e.detail.attachment\n this.value = `/attachment/${attachment.path}`\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n\n this.popup && this.popup.close()\n }}\n ></ox-attachment-list>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.select attachment')\n })\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ import './ox-attachment-selector';