@operato/attachment 7.0.67 → 7.0.78

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,23 @@
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
+ ### [7.0.78](https://github.com/hatiolab/operato/compare/v7.0.77...v7.0.78) (2024-08-31)
7
+
8
+
9
+ ### :bug: Bug Fix
10
+
11
+ * for hashtags related components ([7785990](https://github.com/hatiolab/operato/commit/77859908ff01bd858456079f545d3909b59f3521))
12
+
13
+
14
+
15
+ ### [7.0.73](https://github.com/hatiolab/operato/compare/v7.0.72...v7.0.73) (2024-08-28)
16
+
17
+ **Note:** Version bump only for package @operato/attachment
18
+
19
+
20
+
21
+
22
+
6
23
  ### [7.0.67](https://github.com/hatiolab/operato/compare/v7.0.66...v7.0.67) (2024-08-26)
7
24
 
8
25
  **Note:** Version bump only for package @operato/attachment
@@ -29,12 +29,13 @@ export declare class OxAttachmentList extends LitElement {
29
29
  iconOnly?: undefined;
30
30
  danger?: undefined;
31
31
  name?: undefined;
32
+ filter?: undefined;
32
33
  hidden?: undefined;
33
34
  header?: undefined;
34
- record?: undefined;
35
35
  width?: undefined;
36
- filter?: undefined;
37
36
  sortable?: undefined;
37
+ label?: undefined;
38
+ record?: undefined;
38
39
  } | {
39
40
  type: string;
40
41
  gutterName: string;
@@ -46,12 +47,13 @@ export declare class OxAttachmentList extends LitElement {
46
47
  iconOnly?: undefined;
47
48
  danger?: undefined;
48
49
  name?: undefined;
50
+ filter?: undefined;
49
51
  hidden?: undefined;
50
52
  header?: undefined;
51
- record?: undefined;
52
53
  width?: undefined;
53
- filter?: undefined;
54
54
  sortable?: undefined;
55
+ label?: undefined;
56
+ record?: undefined;
55
57
  } | {
56
58
  type: string;
57
59
  gutterName: string;
@@ -63,12 +65,13 @@ export declare class OxAttachmentList extends LitElement {
63
65
  };
64
66
  danger?: undefined;
65
67
  name?: undefined;
68
+ filter?: undefined;
66
69
  hidden?: undefined;
67
70
  header?: undefined;
68
- record?: undefined;
69
71
  width?: undefined;
70
- filter?: undefined;
71
72
  sortable?: undefined;
73
+ label?: undefined;
74
+ record?: undefined;
72
75
  } | {
73
76
  type: string;
74
77
  gutterName: string;
@@ -80,15 +83,17 @@ export declare class OxAttachmentList extends LitElement {
80
83
  click: (columns: ColumnConfig[], data: GristData, column: ColumnConfig, record: GristRecord, rowIndex: number, target: HTMLElement) => Promise<void>;
81
84
  };
82
85
  name?: undefined;
86
+ filter?: undefined;
83
87
  hidden?: undefined;
84
88
  header?: undefined;
85
- record?: undefined;
86
89
  width?: undefined;
87
- filter?: undefined;
88
90
  sortable?: undefined;
91
+ label?: undefined;
92
+ record?: undefined;
89
93
  } | {
90
94
  type: string;
91
95
  name: string;
96
+ filter: string;
92
97
  hidden: boolean;
93
98
  gutterName?: undefined;
94
99
  icon?: undefined;
@@ -97,19 +102,14 @@ export declare class OxAttachmentList extends LitElement {
97
102
  iconOnly?: undefined;
98
103
  danger?: undefined;
99
104
  header?: undefined;
100
- record?: undefined;
101
105
  width?: undefined;
102
- filter?: undefined;
103
106
  sortable?: undefined;
107
+ label?: undefined;
108
+ record?: undefined;
104
109
  } | {
105
110
  type: string;
106
111
  name: string;
107
112
  header: string;
108
- record: {
109
- editable: boolean;
110
- align: string;
111
- renderer?: undefined;
112
- };
113
113
  width: number;
114
114
  filter: string;
115
115
  sortable: boolean;
@@ -120,15 +120,12 @@ export declare class OxAttachmentList extends LitElement {
120
120
  iconOnly?: undefined;
121
121
  danger?: undefined;
122
122
  hidden?: undefined;
123
+ label?: undefined;
124
+ record?: undefined;
123
125
  } | {
124
126
  type: string;
125
127
  name: string;
126
128
  header: string;
127
- record: {
128
- editable: boolean;
129
- align: string;
130
- renderer?: undefined;
131
- };
132
129
  width: number;
133
130
  filter: string;
134
131
  gutterName?: undefined;
@@ -139,15 +136,12 @@ export declare class OxAttachmentList extends LitElement {
139
136
  danger?: undefined;
140
137
  hidden?: undefined;
141
138
  sortable?: undefined;
139
+ label?: undefined;
140
+ record?: undefined;
142
141
  } | {
143
142
  type: string;
144
143
  name: string;
145
144
  header: string;
146
- record: {
147
- editable: boolean;
148
- align?: undefined;
149
- renderer?: undefined;
150
- };
151
145
  hidden: boolean;
152
146
  filter: {
153
147
  operator: string;
@@ -163,6 +157,27 @@ export declare class OxAttachmentList extends LitElement {
163
157
  danger?: undefined;
164
158
  width?: undefined;
165
159
  sortable?: undefined;
160
+ label?: undefined;
161
+ record?: undefined;
162
+ } | {
163
+ type: string;
164
+ name: string;
165
+ header: string;
166
+ label: boolean;
167
+ record: {
168
+ editable: boolean;
169
+ renderer?: undefined;
170
+ };
171
+ filter: string;
172
+ width: number;
173
+ gutterName?: undefined;
174
+ icon?: undefined;
175
+ title?: undefined;
176
+ handlers?: undefined;
177
+ iconOnly?: undefined;
178
+ danger?: undefined;
179
+ hidden?: undefined;
180
+ sortable?: undefined;
166
181
  } | {
167
182
  type: string;
168
183
  name: string;
@@ -170,7 +185,6 @@ export declare class OxAttachmentList extends LitElement {
170
185
  record: {
171
186
  editable: boolean;
172
187
  renderer: FieldRenderer;
173
- align?: undefined;
174
188
  };
175
189
  handlers: {
176
190
  click: (columns: ColumnConfig[], data: GristData, column: ColumnConfig, record: GristRecord, rowIndex: number, target: HTMLElement) => void;
@@ -181,18 +195,14 @@ export declare class OxAttachmentList extends LitElement {
181
195
  title?: undefined;
182
196
  iconOnly?: undefined;
183
197
  danger?: undefined;
184
- header?: undefined;
185
198
  filter?: undefined;
199
+ header?: undefined;
186
200
  sortable?: undefined;
201
+ label?: undefined;
187
202
  } | {
188
203
  type: string;
189
204
  name: string;
190
205
  header: string;
191
- record: {
192
- editable: boolean;
193
- align?: undefined;
194
- renderer?: undefined;
195
- };
196
206
  sortable: boolean;
197
207
  width: number;
198
208
  gutterName?: undefined;
@@ -201,17 +211,16 @@ export declare class OxAttachmentList extends LitElement {
201
211
  handlers?: undefined;
202
212
  iconOnly?: undefined;
203
213
  danger?: undefined;
204
- hidden?: undefined;
205
214
  filter?: undefined;
215
+ hidden?: undefined;
216
+ label?: undefined;
217
+ record?: undefined;
206
218
  })[];
207
219
  rows: {
208
220
  appendable: boolean;
209
221
  selectable: {
210
222
  multiple: boolean;
211
223
  };
212
- handlers: {
213
- click: string;
214
- };
215
224
  classifier: (record: GristRecord, rowIndex: number) => {
216
225
  emphasized?: boolean | string | string[];
217
226
  [key: string]: any;
@@ -237,5 +246,7 @@ export declare class OxAttachmentList extends LitElement {
237
246
  sortings?: SortersConfig;
238
247
  }): Promise<any>;
239
248
  createAttachments(files: File[]): Promise<void>;
249
+ updateAttachment(patch: any): Promise<void>;
240
250
  deleteAttachment(id: string): Promise<any>;
251
+ popupHashtagEditor(record: GristRecord): void;
241
252
  }
@@ -4,6 +4,7 @@ import '@operato/input/ox-input-file.js';
4
4
  import gql from 'graphql-tag';
5
5
  import { css, html, LitElement } from 'lit';
6
6
  import { customElement, property, query } from 'lit/decorators.js';
7
+ import { openPopup } from '@operato/popup';
7
8
  import { buildArgs, client } from '@operato/graphql';
8
9
  import { ScrollbarStyles, CommonGristStyles, CommonHeaderStyles } from '@operato/styles';
9
10
  import { i18next } from '@operato/i18n';
@@ -21,6 +22,7 @@ const FETCH_ATTACHMENT_LIST_GQL = (listParam) => {
21
22
  category
22
23
  fullpath
23
24
  path
25
+ tags
24
26
  createdAt
25
27
  updatedAt
26
28
  }
@@ -44,6 +46,23 @@ const CREATE_ATTACHMENTS_GQL = gql `
44
46
  encoding
45
47
  category
46
48
  path
49
+ tags
50
+ createdAt
51
+ updatedAt
52
+ }
53
+ }
54
+ `;
55
+ const UPDATE_ATTACHMENT_GQL = gql `
56
+ mutation UpdateAttachment($patch: AttachmentPatch!, $id: String!) {
57
+ updateAttachment(patch: $patch, id: $id) {
58
+ id
59
+ name
60
+ description
61
+ mimetype
62
+ encoding
63
+ category
64
+ path
65
+ tags
47
66
  createdAt
48
67
  updatedAt
49
68
  }
@@ -86,7 +105,7 @@ let OxAttachmentList = class OxAttachmentList extends LitElement {
86
105
  list: {
87
106
  thumbnail: 'thumbnail',
88
107
  fields: ['name'],
89
- details: ['updatedAt']
108
+ details: ['tags', 'updatedAt']
90
109
  },
91
110
  columns: [
92
111
  {
@@ -97,6 +116,17 @@ let OxAttachmentList = class OxAttachmentList extends LitElement {
97
116
  type: 'gutter',
98
117
  gutterName: 'sequence'
99
118
  },
119
+ {
120
+ type: 'gutter',
121
+ gutterName: 'button',
122
+ icon: 'tag',
123
+ title: i18next.t('field.hashtags'),
124
+ handlers: {
125
+ click: (columns, data, column, record, rowIndex, target) => {
126
+ this.popupHashtagEditor(record);
127
+ }
128
+ }
129
+ },
100
130
  {
101
131
  type: 'gutter',
102
132
  gutterName: 'button',
@@ -160,16 +190,13 @@ let OxAttachmentList = class OxAttachmentList extends LitElement {
160
190
  {
161
191
  type: 'string',
162
192
  name: 'id',
193
+ filter: 'search',
163
194
  hidden: true
164
195
  },
165
196
  {
166
197
  type: 'string',
167
198
  name: 'name',
168
- header: 'name',
169
- record: {
170
- editable: true,
171
- align: 'left'
172
- },
199
+ header: i18next.t('field.name'),
173
200
  width: 200,
174
201
  filter: 'search',
175
202
  sortable: true
@@ -177,21 +204,14 @@ let OxAttachmentList = class OxAttachmentList extends LitElement {
177
204
  {
178
205
  type: 'string',
179
206
  name: 'description',
180
- header: 'description',
181
- record: {
182
- editable: true,
183
- align: 'left'
184
- },
207
+ header: i18next.t('field.description'),
185
208
  width: 200,
186
209
  filter: 'search'
187
210
  },
188
211
  {
189
212
  type: 'select-buttons',
190
213
  name: 'category',
191
- header: 'category',
192
- record: {
193
- editable: false
194
- },
214
+ header: i18next.t('field.category'),
195
215
  hidden: true,
196
216
  filter: {
197
217
  operator: 'in',
@@ -200,6 +220,17 @@ let OxAttachmentList = class OxAttachmentList extends LitElement {
200
220
  label: ''
201
221
  }
202
222
  },
223
+ {
224
+ type: 'hashtags',
225
+ name: 'tags',
226
+ header: i18next.t('field.hashtags'),
227
+ label: true,
228
+ record: {
229
+ editable: false
230
+ },
231
+ filter: 'search',
232
+ width: 200
233
+ },
203
234
  {
204
235
  type: 'image',
205
236
  name: 'thumbnail',
@@ -229,20 +260,14 @@ let OxAttachmentList = class OxAttachmentList extends LitElement {
229
260
  {
230
261
  type: 'datetime',
231
262
  name: 'updatedAt',
232
- header: 'updated at',
233
- record: {
234
- editable: true
235
- },
263
+ header: i18next.t('field.updated-at'),
236
264
  sortable: true,
237
265
  width: 180
238
266
  },
239
267
  {
240
268
  type: 'datetime',
241
269
  name: 'createdAt',
242
- header: 'created at',
243
- record: {
244
- editable: true
245
- },
270
+ header: i18next.t('field.created-at'),
246
271
  sortable: true,
247
272
  width: 180
248
273
  }
@@ -252,9 +277,6 @@ let OxAttachmentList = class OxAttachmentList extends LitElement {
252
277
  selectable: {
253
278
  multiple: true
254
279
  },
255
- handlers: {
256
- click: 'select-row-toggle'
257
- },
258
280
  classifier: function (record, rowIndex) { }
259
281
  },
260
282
  sorters: [
@@ -324,6 +346,12 @@ let OxAttachmentList = class OxAttachmentList extends LitElement {
324
346
  }
325
347
  });
326
348
  }
349
+ async updateAttachment(patch) {
350
+ const response = await client.mutate({
351
+ mutation: UPDATE_ATTACHMENT_GQL,
352
+ variables: patch
353
+ });
354
+ }
327
355
  async deleteAttachment(id) {
328
356
  const response = await client.mutate({
329
357
  mutation: DELETE_ATTACHMENT_GQL,
@@ -333,6 +361,22 @@ let OxAttachmentList = class OxAttachmentList extends LitElement {
333
361
  });
334
362
  return response.data;
335
363
  }
364
+ popupHashtagEditor(record) {
365
+ const hashtags = Array.isArray(record.tags) ? [...record.tags] : [];
366
+ const confirmCallback = async (newval) => {
367
+ await this.updateAttachment({
368
+ id: record.id,
369
+ patch: { tags: newval }
370
+ });
371
+ this.refreshAttachments();
372
+ };
373
+ openPopup(html `
374
+ <ox-popup-hashtags-input .value=${hashtags} .confirmCallback=${confirmCallback}></ox-popup-hashtags-input>
375
+ `, {
376
+ backdrop: true,
377
+ title: i18next.t('title.edit hashtags')
378
+ });
379
+ }
336
380
  };
337
381
  OxAttachmentList.styles = [
338
382
  ScrollbarStyles,
@@ -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,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAalE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACxF,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEvD,MAAM,yBAAyB,GAAG,CAAC,SAAc,EAAE,EAAE;IACnD,OAAO,GAAG,CAAA;;kBAEM,SAAS,CAAC,SAAS,CAAC;;;;;;;;;;;;;;;;CAgBrC,CAAA;AACD,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAG,GAAG,CAAA;;;;CAIhC,CAAA;AAED,MAAM,sBAAsB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;CAcjC,CAAA;AAGM,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,UAAU;IAAzC;;QA8BuB,aAAQ,GAAW,EAAE,CAAA;QACpB,cAAS,GAAY,KAAK,CAAA;QACG,kBAAa,GAAY,KAAK,CAAA;IA2V1F,CAAC;IAtVC,MAAM;QACJ,OAAO,IAAI,CAAA;0BACW,IAAI,CAAC,WAAW,UAAU,MAA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Q,EAAE,qBAAqB;YAC/B,SAAS,EAAE;gBACT,EAAE;aACH;SACF,CAAC,CAAA;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAA;IACtB,CAAC;;AAzXM,uBAAM,GAAG;IACd,eAAe;IACf,iBAAiB;IACjB,kBAAkB;IAClB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;KAsBF;CACF,AA3BY,CA2BZ;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAsB;AACpB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAA2B;AACG;IAAzD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;uDAA+B;AAErE;IAAlB,KAAK,CAAC,UAAU,CAAC;+CAAkB;AACZ;IAAvB,KAAK,CAAC,eAAe,CAAC;sDAAmB;AAnC/B,gBAAgB;IAD5B,aAAa,CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CA2X5B","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 FilterValue,\n GristData,\n GristRecord,\n PaginationConfig,\n SortersConfig\n} from '@operato/data-grist'\nimport { buildArgs, client } from '@operato/graphql'\nimport { ScrollbarStyles, CommonGristStyles, CommonHeaderStyles } from '@operato/styles'\nimport { i18next } from '@operato/i18n'\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 CommonGristStyles,\n CommonHeaderStyles,\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 .header .filters {\n flex-direction: column;\n align-items: stretch;\n }\n `\n ]\n\n @property({ type: String }) category: string = ''\n @property({ type: Boolean }) creatable: boolean = false\n @property({ type: Boolean, attribute: 'without-search' }) withoutSearch: boolean = false\n\n @query('ox-grist') grist!: DataGrist\n @query('ox-input-file') fileUploader!: any\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\" class=\"header\">\n <div class=\"filters\">\n <ox-input-file\n accept=\"*/*\"\n multiple=\"true\"\n hide-filelist\n @change=${this.onCreateAttachment.bind(this)}\n ></ox-input-file>\n\n <ox-filters-form autofocus .withoutSearch=${this.withoutSearch}></ox-filters-form>\n </div>\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 title: i18next.t('button.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 title: i18next.t('button.copy-url'),\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\n const rect = target.getBoundingClientRect()\n target.style.setProperty('--tooltip-top', `${rect.top}px`)\n target.style.setProperty('--tooltip-left', `${rect.left}px`)\n\n await sleep(2000)\n target.removeAttribute('data-tooltip')\n }\n }\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'save_alt',\n iconOnly: false,\n title: i18next.t('button.download'),\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 element.remove()\n }\n }\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'delete',\n iconOnly: false,\n danger: true,\n title: i18next.t('button.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: '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 },\n {\n type: 'select-buttons',\n name: 'category',\n header: 'category',\n record: {\n editable: false\n },\n hidden: true,\n filter: {\n operator: 'in',\n options: ['audio', 'video', 'image', 'text', 'application'],\n value: this.category,\n label: ''\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 <md-icon style=\"--md-icon-size: 24px;\">insert_drive_file</md-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 width: 120\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 appendable: false,\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 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,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,SAAS,EAAe,MAAM,gBAAgB,CAAA;AAavD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACxF,OAAO,EAAE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AAK,CAAC,eAAe,CAAC;sDAAmB;AAnC/B,gBAAgB;IAD5B,aAAa,CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CAma5B","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'\nimport { openPopup, PopupHandle } from '@operato/popup'\n\nimport {\n ColumnConfig,\n DataGrist,\n FetchOption,\n FieldRenderer,\n FilterValue,\n GristData,\n GristRecord,\n PaginationConfig,\n SortersConfig\n} from '@operato/data-grist'\nimport { buildArgs, client } from '@operato/graphql'\nimport { ScrollbarStyles, CommonGristStyles, CommonHeaderStyles } from '@operato/styles'\nimport { i18next } from '@operato/i18n'\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 tags\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 tags\n createdAt\n updatedAt\n }\n }\n`\n\nconst UPDATE_ATTACHMENT_GQL = gql`\n mutation UpdateAttachment($patch: AttachmentPatch!, $id: String!) {\n updateAttachment(patch: $patch, id: $id) {\n id\n name\n description\n mimetype\n encoding\n category\n path\n tags\n createdAt\n updatedAt\n }\n }\n`\n\n@customElement('ox-attachment-list')\nexport class OxAttachmentList extends LitElement {\n static styles = [\n ScrollbarStyles,\n CommonGristStyles,\n CommonHeaderStyles,\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 .header .filters {\n flex-direction: column;\n align-items: stretch;\n }\n `\n ]\n\n @property({ type: String }) category: string = ''\n @property({ type: Boolean }) creatable: boolean = false\n @property({ type: Boolean, attribute: 'without-search' }) withoutSearch: boolean = false\n\n @query('ox-grist') grist!: DataGrist\n @query('ox-input-file') fileUploader!: any\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\" class=\"header\">\n <div class=\"filters\">\n <ox-input-file\n accept=\"*/*\"\n multiple=\"true\"\n hide-filelist\n @change=${this.onCreateAttachment.bind(this)}\n ></ox-input-file>\n\n <ox-filters-form autofocus .withoutSearch=${this.withoutSearch}></ox-filters-form>\n </div>\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: ['tags', '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: 'tag',\n title: i18next.t('field.hashtags'),\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.popupHashtagEditor(record)\n }\n }\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'open_in_new',\n title: i18next.t('button.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 title: i18next.t('button.copy-url'),\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\n const rect = target.getBoundingClientRect()\n target.style.setProperty('--tooltip-top', `${rect.top}px`)\n target.style.setProperty('--tooltip-left', `${rect.left}px`)\n\n await sleep(2000)\n target.removeAttribute('data-tooltip')\n }\n }\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'save_alt',\n iconOnly: false,\n title: i18next.t('button.download'),\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 element.remove()\n }\n }\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'delete',\n iconOnly: false,\n danger: true,\n title: i18next.t('button.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: 'string',\n name: 'id',\n filter: 'search',\n hidden: true\n },\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n width: 200,\n filter: 'search',\n sortable: true\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n width: 200,\n filter: 'search'\n },\n {\n type: 'select-buttons',\n name: 'category',\n header: i18next.t('field.category'),\n hidden: true,\n filter: {\n operator: 'in',\n options: ['audio', 'video', 'image', 'text', 'application'],\n value: this.category,\n label: ''\n }\n },\n {\n type: 'hashtags',\n name: 'tags',\n header: i18next.t('field.hashtags'),\n label: true,\n record: {\n editable: false\n },\n filter: 'search',\n width: 200\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 <md-icon style=\"--md-icon-size: 24px;\">insert_drive_file</md-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 width: 120\n },\n {\n type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated-at'),\n sortable: true,\n width: 180\n },\n {\n type: 'datetime',\n name: 'createdAt',\n header: i18next.t('field.created-at'),\n sortable: true,\n width: 180\n }\n ],\n rows: {\n appendable: false,\n selectable: {\n multiple: true\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 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 updateAttachment(patch: any) {\n const response = await client.mutate({\n mutation: UPDATE_ATTACHMENT_GQL,\n variables: patch\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 popupHashtagEditor(record: GristRecord) {\n const hashtags = Array.isArray(record.tags) ? [...record.tags] : []\n\n const confirmCallback = async (newval: any) => {\n await this.updateAttachment({\n id: record.id,\n patch: { tags: newval }\n })\n\n this.refreshAttachments()\n }\n\n openPopup(\n html`\n <ox-popup-hashtags-input .value=${hashtags} .confirmCallback=${confirmCallback}></ox-popup-hashtags-input>\n `,\n {\n backdrop: true,\n title: i18next.t('title.edit hashtags')\n }\n )\n }\n}\n"]}