@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.
@@ -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, PopupHandle } from '@operato/popup'
7
8
 
8
9
  import {
9
10
  ColumnConfig,
@@ -34,6 +35,7 @@ const FETCH_ATTACHMENT_LIST_GQL = (listParam: any) => {
34
35
  category
35
36
  fullpath
36
37
  path
38
+ tags
37
39
  createdAt
38
40
  updatedAt
39
41
  }
@@ -59,6 +61,24 @@ const CREATE_ATTACHMENTS_GQL = gql`
59
61
  encoding
60
62
  category
61
63
  path
64
+ tags
65
+ createdAt
66
+ updatedAt
67
+ }
68
+ }
69
+ `
70
+
71
+ const UPDATE_ATTACHMENT_GQL = gql`
72
+ mutation UpdateAttachment($patch: AttachmentPatch!, $id: String!) {
73
+ updateAttachment(patch: $patch, id: $id) {
74
+ id
75
+ name
76
+ description
77
+ mimetype
78
+ encoding
79
+ category
80
+ path
81
+ tags
62
82
  createdAt
63
83
  updatedAt
64
84
  }
@@ -136,7 +156,7 @@ export class OxAttachmentList extends LitElement {
136
156
  list: {
137
157
  thumbnail: 'thumbnail',
138
158
  fields: ['name'],
139
- details: ['updatedAt']
159
+ details: ['tags', 'updatedAt']
140
160
  },
141
161
  columns: [
142
162
  {
@@ -147,6 +167,24 @@ export class OxAttachmentList extends LitElement {
147
167
  type: 'gutter',
148
168
  gutterName: 'sequence'
149
169
  },
170
+ {
171
+ type: 'gutter',
172
+ gutterName: 'button',
173
+ icon: 'tag',
174
+ title: i18next.t('field.hashtags'),
175
+ handlers: {
176
+ click: (
177
+ columns: ColumnConfig[],
178
+ data: GristData,
179
+ column: ColumnConfig,
180
+ record: GristRecord,
181
+ rowIndex: number,
182
+ target: HTMLElement
183
+ ): void => {
184
+ this.popupHashtagEditor(record)
185
+ }
186
+ }
187
+ },
150
188
  {
151
189
  type: 'gutter',
152
190
  gutterName: 'button',
@@ -241,16 +279,13 @@ export class OxAttachmentList extends LitElement {
241
279
  {
242
280
  type: 'string',
243
281
  name: 'id',
282
+ filter: 'search',
244
283
  hidden: true
245
284
  },
246
285
  {
247
286
  type: 'string',
248
287
  name: 'name',
249
- header: 'name',
250
- record: {
251
- editable: true,
252
- align: 'left'
253
- },
288
+ header: i18next.t('field.name'),
254
289
  width: 200,
255
290
  filter: 'search',
256
291
  sortable: true
@@ -258,21 +293,14 @@ export class OxAttachmentList extends LitElement {
258
293
  {
259
294
  type: 'string',
260
295
  name: 'description',
261
- header: 'description',
262
- record: {
263
- editable: true,
264
- align: 'left'
265
- },
296
+ header: i18next.t('field.description'),
266
297
  width: 200,
267
298
  filter: 'search'
268
299
  },
269
300
  {
270
301
  type: 'select-buttons',
271
302
  name: 'category',
272
- header: 'category',
273
- record: {
274
- editable: false
275
- },
303
+ header: i18next.t('field.category'),
276
304
  hidden: true,
277
305
  filter: {
278
306
  operator: 'in',
@@ -281,6 +309,17 @@ export class OxAttachmentList extends LitElement {
281
309
  label: ''
282
310
  }
283
311
  },
312
+ {
313
+ type: 'hashtags',
314
+ name: 'tags',
315
+ header: i18next.t('field.hashtags'),
316
+ label: true,
317
+ record: {
318
+ editable: false
319
+ },
320
+ filter: 'search',
321
+ width: 200
322
+ },
284
323
  {
285
324
  type: 'image',
286
325
  name: 'thumbnail',
@@ -317,20 +356,14 @@ export class OxAttachmentList extends LitElement {
317
356
  {
318
357
  type: 'datetime',
319
358
  name: 'updatedAt',
320
- header: 'updated at',
321
- record: {
322
- editable: true
323
- },
359
+ header: i18next.t('field.updated-at'),
324
360
  sortable: true,
325
361
  width: 180
326
362
  },
327
363
  {
328
364
  type: 'datetime',
329
365
  name: 'createdAt',
330
- header: 'created at',
331
- record: {
332
- editable: true
333
- },
366
+ header: i18next.t('field.created-at'),
334
367
  sortable: true,
335
368
  width: 180
336
369
  }
@@ -340,9 +373,6 @@ export class OxAttachmentList extends LitElement {
340
373
  selectable: {
341
374
  multiple: true
342
375
  },
343
- handlers: {
344
- click: 'select-row-toggle'
345
- },
346
376
  classifier: function (
347
377
  record: GristRecord,
348
378
  rowIndex: number
@@ -435,6 +465,13 @@ export class OxAttachmentList extends LitElement {
435
465
  })
436
466
  }
437
467
 
468
+ async updateAttachment(patch: any) {
469
+ const response = await client.mutate({
470
+ mutation: UPDATE_ATTACHMENT_GQL,
471
+ variables: patch
472
+ })
473
+ }
474
+
438
475
  async deleteAttachment(id: string) {
439
476
  const response = await client.mutate({
440
477
  mutation: DELETE_ATTACHMENT_GQL,
@@ -445,4 +482,27 @@ export class OxAttachmentList extends LitElement {
445
482
 
446
483
  return response.data
447
484
  }
485
+
486
+ popupHashtagEditor(record: GristRecord) {
487
+ const hashtags = Array.isArray(record.tags) ? [...record.tags] : []
488
+
489
+ const confirmCallback = async (newval: any) => {
490
+ await this.updateAttachment({
491
+ id: record.id,
492
+ patch: { tags: newval }
493
+ })
494
+
495
+ this.refreshAttachments()
496
+ }
497
+
498
+ openPopup(
499
+ html`
500
+ <ox-popup-hashtags-input .value=${hashtags} .confirmCallback=${confirmCallback}></ox-popup-hashtags-input>
501
+ `,
502
+ {
503
+ backdrop: true,
504
+ title: i18next.t('title.edit hashtags')
505
+ }
506
+ )
507
+ }
448
508
  }