@things-factory/pdf 9.1.13 → 10.0.0-beta.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.
@@ -5,7 +5,7 @@ import '@operato/data-grist/ox-grist.js';
5
5
  import '@operato/data-grist/ox-filters-form.js';
6
6
  import '@operato/data-grist/ox-record-creator.js';
7
7
  import { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles';
8
- import { PageView, store } from '@operato/shell';
8
+ import { PageView } from '@operato/shell';
9
9
  import { css, html } from 'lit';
10
10
  import { customElement, property, query } from 'lit/decorators.js';
11
11
  import { ScopedElementsMixin } from '@open-wc/scoped-elements';
@@ -15,10 +15,9 @@ import { i18next, localize } from '@operato/i18n';
15
15
  import { notify, openPopup } from '@operato/layout';
16
16
  import { OxPrompt } from '@operato/popup';
17
17
  import { isMobileDevice } from '@operato/utils';
18
- import { connect } from 'pwa-helpers/connect-mixin';
19
18
  import gql from 'graphql-tag';
20
19
  import { PDFTemplateImporter } from './pdf-template-importer';
21
- let PDFTemplateListPage = class PDFTemplateListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
20
+ let PDFTemplateListPage = class PDFTemplateListPage extends localize(i18next)(ScopedElementsMixin(PageView)) {
22
21
  constructor() {
23
22
  super(...arguments);
24
23
  this.mode = isMobileDevice() ? 'CARD' : 'GRID';
@@ -28,65 +27,52 @@ let PDFTemplateListPage = class PDFTemplateListPage extends connect(store)(local
28
27
  CommonGristStyles,
29
28
  CommonHeaderStyles,
30
29
  css `
31
- :host {
32
- display: flex;
30
+ :host { display: flex;
33
31
 
34
32
  width: 100%;
35
33
 
36
34
  --grid-record-emphasized-background-color: #8b0000;
37
35
  --grid-record-emphasized-color: #ff6b6b;
38
- }
36
+ }
39
37
 
40
- ox-grist {
41
- overflow-y: auto;
38
+ ox-grist { overflow-y: auto;
42
39
  flex: 1;
43
- }
40
+ }
44
41
 
45
- ox-filters-form {
46
- flex: 1;
47
- }
42
+ ox-filters-form { flex: 1;
43
+ }
48
44
  `
49
45
  ]; }
50
46
  static get scopedElements() {
51
- return {
52
- 'pdf-template-importer': PDFTemplateImporter
47
+ return { 'pdf-template-importer': PDFTemplateImporter
53
48
  };
54
49
  }
55
50
  get context() {
56
- return {
57
- title: i18next.t('title.pdf-template list'),
58
- search: {
59
- handler: (search) => {
51
+ return { title: i18next.t('title.pdf-template list'),
52
+ search: { handler: (search) => {
60
53
  this.grist.searchText = search;
61
54
  },
62
- value: this.grist.searchText
63
- },
64
- filter: {
65
- handler: () => {
55
+ value: this.grist.searchText },
56
+ filter: { handler: () => {
66
57
  this.grist.toggleHeadroom();
67
58
  }
68
59
  },
69
60
  help: 'pdf/pdf-template',
70
61
  actions: [
71
- {
72
- title: i18next.t('button.save'),
62
+ { title: i18next.t('button.save'),
73
63
  action: this._updatePDFTemplate.bind(this),
74
64
  ...CommonButtonStyles.save
75
65
  },
76
- {
77
- title: i18next.t('button.delete'),
66
+ { title: i18next.t('button.delete'),
78
67
  action: this._deletePDFTemplate.bind(this),
79
68
  ...CommonButtonStyles.delete
80
69
  }
81
70
  ],
82
- exportable: {
83
- name: i18next.t('title.pdf-template list'),
71
+ exportable: { name: i18next.t('title.pdf-template list'),
84
72
  data: this.exportHandler.bind(this)
85
73
  },
86
- importable: {
87
- handler: this.importHandler.bind(this)
88
- }
89
- };
74
+ importable: { handler: this.importHandler.bind(this)
75
+ } };
90
76
  }
91
77
  render() {
92
78
  const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID');
@@ -113,189 +99,148 @@ let PDFTemplateListPage = class PDFTemplateListPage extends connect(store)(local
113
99
  `;
114
100
  }
115
101
  async pageInitialized(lifecycle) {
116
- this.gristConfig = {
117
- list: {
118
- fields: ['name', 'description'],
102
+ this.gristConfig = { list: { fields: ['name', 'description'],
119
103
  details: ['active', 'updatedAt']
120
104
  },
121
105
  columns: [
122
106
  { type: 'gutter', gutterName: 'sequence' },
123
107
  { type: 'gutter', gutterName: 'row-selector', multiple: true },
124
- {
125
- type: 'string',
108
+ { type: 'string',
126
109
  name: 'name',
127
110
  header: i18next.t('field.name'),
128
- record: {
129
- editable: true
111
+ record: { editable: true
130
112
  },
131
113
  filter: 'search',
132
114
  sortable: true,
133
115
  width: 150
134
116
  },
135
- {
136
- type: 'string',
117
+ { type: 'string',
137
118
  name: 'description',
138
119
  header: i18next.t('field.description'),
139
- record: {
140
- editable: true
120
+ record: { editable: true
141
121
  },
142
122
  filter: 'search',
143
123
  width: 200
144
124
  },
145
- {
146
- type: 'checkbox',
125
+ { type: 'checkbox',
147
126
  name: 'active',
148
127
  label: true,
149
128
  header: i18next.t('field.active'),
150
- record: {
151
- editable: true
129
+ record: { editable: true
152
130
  },
153
131
  filter: true,
154
132
  sortable: true,
155
133
  width: 60
156
134
  },
157
- {
158
- type: 'string',
135
+ { type: 'string',
159
136
  name: 'state',
160
137
  label: true,
161
138
  header: i18next.t('field.state'),
162
- record: {
163
- editable: true
139
+ record: { editable: true
164
140
  },
165
141
  width: 120
166
142
  },
167
- {
168
- type: 'template',
143
+ { type: 'template',
169
144
  name: 'content_template',
170
145
  label: true,
171
146
  header: i18next.t('field.content_template'),
172
- record: {
173
- editable: true,
174
- options: {
175
- language: 'html'
147
+ record: { editable: true,
148
+ options: { language: 'html'
176
149
  }
177
150
  },
178
151
  width: 120
179
152
  },
180
- {
181
- type: 'template',
153
+ { type: 'template',
182
154
  name: 'header_template',
183
155
  label: true,
184
156
  header: i18next.t('field.header_template'),
185
- record: {
186
- editable: true,
187
- options: {
188
- language: 'html'
157
+ record: { editable: true,
158
+ options: { language: 'html'
189
159
  }
190
160
  },
191
161
  width: 120
192
162
  },
193
- {
194
- type: 'template',
163
+ { type: 'template',
195
164
  name: 'footer_template',
196
165
  label: true,
197
166
  header: i18next.t('field.footer_template'),
198
- record: {
199
- editable: true,
200
- options: {
201
- language: 'html'
167
+ record: { editable: true,
168
+ options: { language: 'html'
202
169
  }
203
170
  },
204
171
  width: 120
205
172
  },
206
- {
207
- type: 'template',
173
+ { type: 'template',
208
174
  name: 'cover_template',
209
175
  label: true,
210
176
  header: i18next.t('field.cover_template'),
211
- record: {
212
- editable: true,
213
- options: {
214
- language: 'html'
177
+ record: { editable: true,
178
+ options: { language: 'html'
215
179
  }
216
180
  },
217
181
  width: 120
218
182
  },
219
- {
220
- type: 'template',
183
+ { type: 'template',
221
184
  name: 'last_template',
222
185
  label: true,
223
186
  header: i18next.t('field.last_template'),
224
- record: {
225
- editable: true,
226
- options: {
227
- language: 'html'
187
+ record: { editable: true,
188
+ options: { language: 'html'
228
189
  }
229
190
  },
230
191
  width: 120
231
192
  },
232
- {
233
- type: 'select',
193
+ { type: 'select',
234
194
  name: 'page_size',
235
195
  label: true,
236
196
  header: i18next.t('field.page_size'),
237
- record: {
238
- editable: true,
197
+ record: { editable: true,
239
198
  options: ['', 'A4', 'B4']
240
199
  },
241
200
  width: 120
242
201
  },
243
- {
244
- type: 'string',
202
+ { type: 'string',
245
203
  name: 'watermark',
246
204
  label: true,
247
205
  header: i18next.t('field.watermark'),
248
- record: {
249
- editable: true
206
+ record: { editable: true
250
207
  },
251
208
  width: 120
252
209
  },
253
- {
254
- type: 'resource-object',
210
+ { type: 'resource-object',
255
211
  name: 'updater',
256
212
  header: i18next.t('field.updater'),
257
- record: {
258
- editable: false
213
+ record: { editable: false
259
214
  },
260
215
  sortable: true,
261
216
  width: 120
262
217
  },
263
- {
264
- type: 'datetime',
218
+ { type: 'datetime',
265
219
  name: 'updatedAt',
266
220
  header: i18next.t('field.updated_at'),
267
- record: {
268
- editable: false
221
+ record: { editable: false
269
222
  },
270
223
  sortable: true,
271
224
  width: 180
272
225
  }
273
226
  ],
274
- rows: {
275
- appendable: false,
276
- selectable: {
277
- multiple: true
227
+ rows: { appendable: false,
228
+ selectable: { multiple: true
278
229
  }
279
230
  },
280
231
  sorters: [
281
- {
282
- name: 'name'
232
+ { name: 'name'
283
233
  }
284
234
  ]
285
235
  };
286
236
  }
287
237
  async pageUpdated(changes, lifecycle) {
288
- if (this.active) {
289
- // do something here when this page just became as active
238
+ if (this.active) { // do something here when this page just became as active
290
239
  }
291
240
  }
292
241
  async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
293
- const response = await client.query({
294
- query: gql `
295
- query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
296
- responses: PDFTemplates(filters: $filters, pagination: $pagination, sortings: $sortings) {
297
- items {
298
- id
242
+ const response = await client.query({ query: gql `
243
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) { responses: PDFTemplates(filters: $filters, pagination: $pagination, sortings: $sortings) { items { id
299
244
  name
300
245
  description
301
246
  active
@@ -307,50 +252,42 @@ let PDFTemplateListPage = class PDFTemplateListPage extends connect(store)(local
307
252
  last_template
308
253
  page_size
309
254
  watermark
310
- updater {
311
- id
255
+ updater { id
312
256
  name
313
- }
257
+ }
314
258
  updatedAt
315
- }
259
+ }
316
260
  total
317
- }
318
- }
261
+ }
262
+ }
319
263
  `,
320
- variables: {
321
- filters,
264
+ variables: { filters,
322
265
  pagination: { page, limit },
323
266
  sortings
324
267
  }
325
268
  });
326
- return {
327
- total: response.data.responses.total || 0,
269
+ return { total: response.data.responses.total || 0,
328
270
  records: response.data.responses.items || []
329
271
  };
330
272
  }
331
273
  async _deletePDFTemplate() {
332
- if (await OxPrompt.open({
333
- title: i18next.t('text.are_you_sure'),
274
+ if (await OxPrompt.open({ title: i18next.t('text.are_you_sure'),
334
275
  text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),
335
276
  confirmButton: { text: i18next.t('button.confirm') },
336
277
  cancelButton: { text: i18next.t('button.cancel') }
337
278
  })) {
338
279
  const ids = this.grist.selected.map(record => record.id);
339
280
  if (ids && ids.length > 0) {
340
- const response = await client.mutate({
341
- mutation: gql `
342
- mutation ($ids: [String!]!) {
343
- deletePDFTemplates(ids: $ids)
344
- }
281
+ const response = await client.mutate({ mutation: gql `
282
+ mutation ($ids: [String!]!) { deletePDFTemplates(ids: $ids)
283
+ }
345
284
  `,
346
- variables: {
347
- ids
285
+ variables: { ids
348
286
  }
349
287
  });
350
288
  if (!response.errors) {
351
289
  this.grist.fetch();
352
- notify({
353
- message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
290
+ notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
354
291
  });
355
292
  }
356
293
  }
@@ -368,16 +305,12 @@ let PDFTemplateListPage = class PDFTemplateListPage extends connect(store)(local
368
305
  patchField.cuFlag = patch.__dirty__;
369
306
  return patchField;
370
307
  });
371
- const response = await client.mutate({
372
- mutation: gql `
373
- mutation ($patches: [PDFTemplatePatch!]!) {
374
- updateMultiplePDFTemplate(patches: $patches) {
375
- name
376
- }
377
- }
308
+ const response = await client.mutate({ mutation: gql `
309
+ mutation ($patches: [PDFTemplatePatch!]!) { updateMultiplePDFTemplate(patches: $patches) { name
310
+ }
311
+ }
378
312
  `,
379
- variables: {
380
- patches
313
+ variables: { patches
381
314
  }
382
315
  });
383
316
  if (!response.errors) {
@@ -387,26 +320,19 @@ let PDFTemplateListPage = class PDFTemplateListPage extends connect(store)(local
387
320
  }
388
321
  async creationCallback(pdfTemplate) {
389
322
  try {
390
- const response = await client.query({
391
- query: gql `
392
- mutation ($pdfTemplate: NewPDFTemplate!) {
393
- createPDFTemplate(pdfTemplate: $pdfTemplate) {
394
- id
395
- }
396
- }
323
+ const response = await client.query({ query: gql `
324
+ mutation ($pdfTemplate: NewPDFTemplate!) { createPDFTemplate(pdfTemplate: $pdfTemplate) { id
325
+ }
326
+ }
397
327
  `,
398
- variables: {
399
- pdfTemplate
328
+ variables: { pdfTemplate
400
329
  },
401
- context: {
402
- hasUpload: true
330
+ context: { hasUpload: true
403
331
  }
404
332
  });
405
333
  if (!response.errors) {
406
334
  this.grist.fetch();
407
- document.dispatchEvent(new CustomEvent('notify', {
408
- detail: {
409
- message: i18next.t('text.data_created_successfully')
335
+ document.dispatchEvent(new CustomEvent('notify', { detail: { message: i18next.t('text.data_created_successfully')
410
336
  }
411
337
  }));
412
338
  }
@@ -414,9 +340,7 @@ let PDFTemplateListPage = class PDFTemplateListPage extends connect(store)(local
414
340
  }
415
341
  catch (ex) {
416
342
  console.error(ex);
417
- document.dispatchEvent(new CustomEvent('notify', {
418
- detail: {
419
- type: 'error',
343
+ document.dispatchEvent(new CustomEvent('notify', { detail: { type: 'error',
420
344
  message: i18next.t('text.error')
421
345
  }
422
346
  }));
@@ -443,8 +367,7 @@ let PDFTemplateListPage = class PDFTemplateListPage extends connect(store)(local
443
367
  this.grist.fetch();
444
368
  }}
445
369
  ></pdf-template-importer>
446
- `, {
447
- backdrop: true,
370
+ `, { backdrop: true,
448
371
  size: 'large',
449
372
  title: i18next.t('title.import pdf-template')
450
373
  });
@@ -1 +1 @@
1
- {"version":3,"file":"pdf-template-list-page.js","sourceRoot":"","sources":["../../../client/pages/pdf-template/pdf-template-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,yCAAyC,CAAA;AAChD,OAAO,iCAAiC,CAAA;AACxC,OAAO,wCAAwC,CAAA;AAC/C,OAAO,0CAA0C,CAAA;AAEjD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC5G,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAgB,SAAS,EAAe,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ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nCjC,mBAAmB;IAD/B,aAAa,CAAC,wBAAwB,CAAC;GAC3B,mBAAmB,CAkd/B","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@material/web/button/elevated-button.js'\nimport '@operato/data-grist/ox-grist.js'\nimport '@operato/data-grist/ox-filters-form.js'\nimport '@operato/data-grist/ox-record-creator.js'\n\nimport { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'\nimport { PageView, store } from '@operato/shell'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements'\nimport { ColumnConfig, DataGrist, FetchOption } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { OxPopup, OxPrompt } from '@operato/popup'\nimport { isMobileDevice } from '@operato/utils'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport gql from 'graphql-tag'\n\nimport { PDFTemplateImporter } from './pdf-template-importer'\n\n@customElement('pdf-template-list-page')\nexport class PDFTemplateListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {\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: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-grist {\n overflow-y: auto;\n flex: 1;\n }\n\n ox-filters-form {\n flex: 1;\n }\n `\n ]\n\n static get scopedElements() {\n return {\n 'pdf-template-importer': PDFTemplateImporter\n }\n }\n\n @property({ type: Object }) gristConfig: any\n @property({ type: String }) mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'\n\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t('title.pdf-template list'),\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n value: this.grist.searchText\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n help: 'pdf/pdf-template',\n actions: [\n {\n title: i18next.t('button.save'),\n action: this._updatePDFTemplate.bind(this),\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.delete'),\n action: this._deletePDFTemplate.bind(this),\n ...CommonButtonStyles.delete\n }\n ],\n exportable: {\n name: i18next.t('title.pdf-template list'),\n data: this.exportHandler.bind(this)\n },\n importable: {\n handler: this.importHandler.bind(this)\n }\n }\n }\n\n render() {\n const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form autofocus without-search></ox-filters-form>\n\n <div id=\"modes\">\n <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>\n <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>\n <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>\n </div>\n\n <ox-record-creator id=\"add\" .callback=${this.creationCallback.bind(this)}>\n <button>\n <md-icon>add</md-icon>\n </button>\n </ox-record-creator>\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) {\n this.gristConfig = {\n list: {\n fields: ['name', 'description'],\n details: ['active', 'updatedAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: {\n editable: true\n },\n filter: 'search',\n width: 200\n },\n {\n type: 'checkbox',\n name: 'active',\n label: true,\n header: i18next.t('field.active'),\n record: {\n editable: true\n },\n filter: true,\n sortable: true,\n width: 60\n },\n {\n type: 'string',\n name: 'state',\n label: true,\n header: i18next.t('field.state'),\n record: {\n editable: true\n },\n width: 120\n },\n {\n type: 'template',\n name: 'content_template',\n label: true,\n header: i18next.t('field.content_template'),\n record: {\n editable: true,\n options: {\n language: 'html'\n }\n },\n width: 120\n },\n {\n type: 'template',\n name: 'header_template',\n label: true,\n header: i18next.t('field.header_template'),\n record: {\n editable: true,\n options: {\n language: 'html'\n }\n },\n width: 120\n },\n {\n type: 'template',\n name: 'footer_template',\n label: true,\n header: i18next.t('field.footer_template'),\n record: {\n editable: true,\n options: {\n language: 'html'\n }\n },\n width: 120\n },\n {\n type: 'template',\n name: 'cover_template',\n label: true,\n header: i18next.t('field.cover_template'),\n record: {\n editable: true,\n options: {\n language: 'html'\n }\n },\n width: 120\n },\n {\n type: 'template',\n name: 'last_template',\n label: true,\n header: i18next.t('field.last_template'),\n record: {\n editable: true,\n options: {\n language: 'html'\n }\n },\n width: 120\n },\n {\n type: 'select',\n name: 'page_size',\n label: true,\n header: i18next.t('field.page_size'),\n record: {\n editable: true,\n options: ['', 'A4', 'B4']\n },\n width: 120\n },\n {\n type: 'string',\n name: 'watermark',\n label: true,\n header: i18next.t('field.watermark'),\n record: {\n editable: true\n },\n width: 120\n },\n\n {\n type: 'resource-object',\n name: 'updater',\n header: i18next.t('field.updater'),\n record: {\n editable: false\n },\n sortable: true,\n width: 120\n },\n {\n type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n record: {\n editable: false\n },\n sortable: true,\n width: 180\n }\n ],\n rows: {\n appendable: false,\n selectable: {\n multiple: true\n }\n },\n sorters: [\n {\n name: 'name'\n }\n ]\n }\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (this.active) {\n // do something here when this page just became as active\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n responses: PDFTemplates(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n description\n active\n state\n content_template\n header_template\n footer_template\n cover_template\n last_template\n page_size\n watermark\n updater {\n id\n name\n }\n updatedAt\n }\n total\n }\n }\n `,\n variables: {\n filters,\n pagination: { page, limit },\n sortings\n }\n })\n\n return {\n total: response.data.responses.total || 0,\n records: response.data.responses.items || []\n }\n }\n\n async _deletePDFTemplate() {\n if (\n await OxPrompt.open({\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) {\n const ids = this.grist.selected.map(record => record.id)\n if (ids && ids.length > 0) {\n const response = await client.mutate({\n mutation: gql`\n mutation ($ids: [String!]!) {\n deletePDFTemplates(ids: $ids)\n }\n `,\n variables: {\n ids\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n notify({\n message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })\n })\n }\n }\n }\n }\n\n async _updatePDFTemplate() {\n let patches = this.grist.dirtyRecords\n if (patches && patches.length) {\n patches = patches.map(patch => {\n let patchField: any = patch.id ? { id: patch.id } : {}\n const dirtyFields = patch.__dirtyfields__\n for (let key in dirtyFields) {\n patchField[key] = dirtyFields[key].after\n }\n patchField.cuFlag = patch.__dirty__\n\n return patchField\n })\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($patches: [PDFTemplatePatch!]!) {\n updateMultiplePDFTemplate(patches: $patches) {\n name\n }\n }\n `,\n variables: {\n patches\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n }\n }\n }\n\n async creationCallback(pdfTemplate) {\n try {\n const response = await client.query({\n query: gql`\n mutation ($pdfTemplate: NewPDFTemplate!) {\n createPDFTemplate(pdfTemplate: $pdfTemplate) {\n id\n }\n }\n `,\n variables: {\n pdfTemplate\n },\n context: {\n hasUpload: true\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n message: i18next.t('text.data_created_successfully')\n }\n })\n )\n }\n\n return true\n } catch (ex) {\n console.error(ex)\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n type: 'error',\n message: i18next.t('text.error')\n }\n })\n )\n return false\n }\n }\n\n async exportHandler() {\n const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records\n const targetFieldSet = new Set(['id', 'name', 'description', 'active'])\n\n return exportTargets.map(pdfTemplate => {\n let tempObj = {}\n for (const field of targetFieldSet) {\n tempObj[field] = pdfTemplate[field]\n }\n\n return tempObj\n })\n }\n\n async importHandler(records) {\n const popup = openPopup(\n html`\n <pdf-template-importer\n .pdfTemplates=${records}\n @imported=${() => {\n history.back()\n this.grist.fetch()\n }}\n ></pdf-template-importer>\n `,\n {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.import pdf-template')\n }\n )\n\n popup.onclosed = () => {\n this.grist.fetch()\n }\n }\n}\n"]}
1
+ {"version":3,"file":"pdf-template-list-page.js","sourceRoot":"","sources":["../../../client/pages/pdf-template/pdf-template-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,yCAAyC,CAAA;AAChD,OAAO,iCAAiC,CAAA;AACxC,OAAO,wCAAwC,CAAA;AAC/C,OAAO,0CAA0C,CAAA;AAEjD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC5G,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAgB,SAAS,EAAe,MAAM,q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CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;iDAAoE;AAEpE;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;kDAAA;AA7BjC,mBAAmB;IAD/B,aAAa,CAAC,wBAAwB,CAAC;GAC3B,mBAAmB,CA4W/B","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@material/web/button/elevated-button.js'\nimport '@operato/data-grist/ox-grist.js'\nimport '@operato/data-grist/ox-filters-form.js'\nimport '@operato/data-grist/ox-record-creator.js'\n\nimport { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'\nimport { PageView } from '@operato/shell'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements'\nimport { ColumnConfig, DataGrist, FetchOption } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { OxPopup, OxPrompt } from '@operato/popup'\nimport { isMobileDevice } from '@operato/utils'\n\nimport gql from 'graphql-tag'\n\nimport { PDFTemplateImporter } from './pdf-template-importer'\n\n@customElement('pdf-template-list-page')\nexport class PDFTemplateListPage extends localize(i18next)(ScopedElementsMixin(PageView)) { static styles = [\n ScrollbarStyles,\n CommonGristStyles,\n CommonHeaderStyles,\n css`\n :host { display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-grist { overflow-y: auto;\n flex: 1;\n }\n\n ox-filters-form { flex: 1;\n }\n `\n ]\n\n static get scopedElements() { return { 'pdf-template-importer': PDFTemplateImporter\n }\n }\n\n @property({ type: Object }) gristConfig: any\n @property({ type: String }) mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'\n\n @query('ox-grist') private grist!: DataGrist\n\n get context() { return { title: i18next.t('title.pdf-template list'),\n search: { handler: (search: string) => { this.grist.searchText = search\n },\n value: this.grist.searchText\n },\n filter: { handler: () => { this.grist.toggleHeadroom()\n }\n },\n help: 'pdf/pdf-template',\n actions: [\n { title: i18next.t('button.save'),\n action: this._updatePDFTemplate.bind(this),\n ...CommonButtonStyles.save\n },\n { title: i18next.t('button.delete'),\n action: this._deletePDFTemplate.bind(this),\n ...CommonButtonStyles.delete\n }\n ],\n exportable: { name: i18next.t('title.pdf-template list'),\n data: this.exportHandler.bind(this)\n },\n importable: { handler: this.importHandler.bind(this)\n }\n }\n }\n\n render() { const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form autofocus without-search></ox-filters-form>\n\n <div id=\"modes\">\n <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>\n <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>\n <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>\n </div>\n\n <ox-record-creator id=\"add\" .callback=${this.creationCallback.bind(this)}>\n <button>\n <md-icon>add</md-icon>\n </button>\n </ox-record-creator>\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) { this.gristConfig = { list: { fields: ['name', 'description'],\n details: ['active', 'updatedAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n { type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: { editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n { type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: { editable: true\n },\n filter: 'search',\n width: 200\n },\n { type: 'checkbox',\n name: 'active',\n label: true,\n header: i18next.t('field.active'),\n record: { editable: true\n },\n filter: true,\n sortable: true,\n width: 60\n },\n { type: 'string',\n name: 'state',\n label: true,\n header: i18next.t('field.state'),\n record: { editable: true\n },\n width: 120\n },\n { type: 'template',\n name: 'content_template',\n label: true,\n header: i18next.t('field.content_template'),\n record: { editable: true,\n options: { language: 'html'\n }\n },\n width: 120\n },\n { type: 'template',\n name: 'header_template',\n label: true,\n header: i18next.t('field.header_template'),\n record: { editable: true,\n options: { language: 'html'\n }\n },\n width: 120\n },\n { type: 'template',\n name: 'footer_template',\n label: true,\n header: i18next.t('field.footer_template'),\n record: { editable: true,\n options: { language: 'html'\n }\n },\n width: 120\n },\n { type: 'template',\n name: 'cover_template',\n label: true,\n header: i18next.t('field.cover_template'),\n record: { editable: true,\n options: { language: 'html'\n }\n },\n width: 120\n },\n { type: 'template',\n name: 'last_template',\n label: true,\n header: i18next.t('field.last_template'),\n record: { editable: true,\n options: { language: 'html'\n }\n },\n width: 120\n },\n { type: 'select',\n name: 'page_size',\n label: true,\n header: i18next.t('field.page_size'),\n record: { editable: true,\n options: ['', 'A4', 'B4']\n },\n width: 120\n },\n { type: 'string',\n name: 'watermark',\n label: true,\n header: i18next.t('field.watermark'),\n record: { editable: true\n },\n width: 120\n },\n\n { type: 'resource-object',\n name: 'updater',\n header: i18next.t('field.updater'),\n record: { editable: false\n },\n sortable: true,\n width: 120\n },\n { type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n record: { editable: false\n },\n sortable: true,\n width: 180\n }\n ],\n rows: { appendable: false,\n selectable: { multiple: true\n }\n },\n sorters: [\n { name: 'name'\n }\n ]\n }\n }\n\n async pageUpdated(changes: any, lifecycle: any) { if (this.active) { // do something here when this page just became as active\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) { const response = await client.query({ query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) { responses: PDFTemplates(filters: $filters, pagination: $pagination, sortings: $sortings) { items { id\n name\n description\n active\n state\n content_template\n header_template\n footer_template\n cover_template\n last_template\n page_size\n watermark\n updater { id\n name\n }\n updatedAt\n }\n total\n }\n }\n `,\n variables: { filters,\n pagination: { page, limit },\n sortings\n }\n })\n\n return { total: response.data.responses.total || 0,\n records: response.data.responses.items || []\n }\n }\n\n async _deletePDFTemplate() { if (\n await OxPrompt.open({ title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) { const ids = this.grist.selected.map(record => record.id)\n if (ids && ids.length > 0) { const response = await client.mutate({ mutation: gql`\n mutation ($ids: [String!]!) { deletePDFTemplates(ids: $ids)\n }\n `,\n variables: { ids\n }\n })\n\n if (!response.errors) { this.grist.fetch()\n notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })\n })\n }\n }\n }\n }\n\n async _updatePDFTemplate() { let patches = this.grist.dirtyRecords\n if (patches && patches.length) { patches = patches.map(patch => { let patchField: any = patch.id ? { id: patch.id } : {}\n const dirtyFields = patch.__dirtyfields__\n for (let key in dirtyFields) { patchField[key] = dirtyFields[key].after\n }\n patchField.cuFlag = patch.__dirty__\n\n return patchField\n })\n\n const response = await client.mutate({ mutation: gql`\n mutation ($patches: [PDFTemplatePatch!]!) { updateMultiplePDFTemplate(patches: $patches) { name\n }\n }\n `,\n variables: { patches\n }\n })\n\n if (!response.errors) { this.grist.fetch()\n }\n }\n }\n\n async creationCallback(pdfTemplate) { try { const response = await client.query({ query: gql`\n mutation ($pdfTemplate: NewPDFTemplate!) { createPDFTemplate(pdfTemplate: $pdfTemplate) { id\n }\n }\n `,\n variables: { pdfTemplate\n },\n context: { hasUpload: true\n }\n })\n\n if (!response.errors) { this.grist.fetch()\n document.dispatchEvent(\n new CustomEvent('notify', { detail: { message: i18next.t('text.data_created_successfully')\n }\n })\n )\n }\n\n return true\n } catch (ex) { console.error(ex)\n document.dispatchEvent(\n new CustomEvent('notify', { detail: { type: 'error',\n message: i18next.t('text.error')\n }\n })\n )\n return false\n }\n }\n\n async exportHandler() { const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records\n const targetFieldSet = new Set(['id', 'name', 'description', 'active'])\n\n return exportTargets.map(pdfTemplate => { let tempObj = {}\n for (const field of targetFieldSet) { tempObj[field] = pdfTemplate[field]\n }\n\n return tempObj\n })\n }\n\n async importHandler(records) { const popup = openPopup(\n html`\n <pdf-template-importer\n .pdfTemplates=${records}\n @imported=${() => { history.back()\n this.grist.fetch()\n }}\n ></pdf-template-importer>\n `,\n { backdrop: true,\n size: 'large',\n title: i18next.t('title.import pdf-template')\n }\n )\n\n popup.onclosed = () => { this.grist.fetch()\n }\n }\n}\n"]}