@things-factory/pdf 7.0.33 → 7.0.36

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.
Files changed (70) hide show
  1. package/client/bootstrap.js +6 -0
  2. package/client/pages/pdf-template/pdf-template-importer.ts +86 -0
  3. package/client/pages/pdf-template/pdf-template-list-page.ts +491 -0
  4. package/client/route.ts +7 -0
  5. package/client/tsconfig.json +13 -0
  6. package/dist-client/bootstrap.d.ts +1 -0
  7. package/dist-client/bootstrap.js +6 -0
  8. package/dist-client/bootstrap.js.map +1 -0
  9. package/dist-client/pages/pdf-template/pdf-template-importer.d.ts +23 -0
  10. package/dist-client/pages/pdf-template/pdf-template-importer.js +93 -0
  11. package/dist-client/pages/pdf-template/pdf-template-importer.js.map +1 -0
  12. package/dist-client/pages/pdf-template/pdf-template-list-page.d.ts +66 -0
  13. package/dist-client/pages/pdf-template/pdf-template-list-page.js +464 -0
  14. package/dist-client/pages/pdf-template/pdf-template-list-page.js.map +1 -0
  15. package/dist-client/route.d.ts +1 -0
  16. package/dist-client/route.js +8 -0
  17. package/dist-client/route.js.map +1 -0
  18. package/dist-client/tsconfig.tsbuildinfo +1 -0
  19. package/dist-server/index.d.ts +1 -0
  20. package/dist-server/index.js +2 -0
  21. package/dist-server/index.js.map +1 -1
  22. package/dist-server/routers/pdf-private-router.d.ts +1 -0
  23. package/dist-server/routers/pdf-private-router.js +25 -0
  24. package/dist-server/routers/pdf-private-router.js.map +1 -0
  25. package/dist-server/routers/pdf-public-router.d.ts +1 -0
  26. package/dist-server/routers/{pdf-router.js → pdf-public-router.js} +6 -6
  27. package/dist-server/routers/pdf-public-router.js.map +1 -0
  28. package/dist-server/routes.js +13 -2
  29. package/dist-server/routes.js.map +1 -1
  30. package/dist-server/service/index.d.ts +6 -0
  31. package/dist-server/service/index.js +23 -0
  32. package/dist-server/service/index.js.map +1 -0
  33. package/dist-server/service/pdf-template/index.d.ts +6 -0
  34. package/dist-server/service/pdf-template/index.js +10 -0
  35. package/dist-server/service/pdf-template/index.js.map +1 -0
  36. package/dist-server/service/pdf-template/pdf-template-mutation.d.ts +10 -0
  37. package/dist-server/service/pdf-template/pdf-template-mutation.js +127 -0
  38. package/dist-server/service/pdf-template/pdf-template-mutation.js.map +1 -0
  39. package/dist-server/service/pdf-template/pdf-template-query.d.ts +11 -0
  40. package/dist-server/service/pdf-template/pdf-template-query.js +79 -0
  41. package/dist-server/service/pdf-template/pdf-template-query.js.map +1 -0
  42. package/dist-server/service/pdf-template/pdf-template-type.d.ts +32 -0
  43. package/dist-server/service/pdf-template/pdf-template-type.js +125 -0
  44. package/dist-server/service/pdf-template/pdf-template-type.js.map +1 -0
  45. package/dist-server/service/pdf-template/pdf-template.d.ts +28 -0
  46. package/dist-server/service/pdf-template/pdf-template.js +125 -0
  47. package/dist-server/service/pdf-template/pdf-template.js.map +1 -0
  48. package/dist-server/tsconfig.tsbuildinfo +1 -1
  49. package/helps/pdf/pdf-template.md +160 -0
  50. package/package.json +13 -8
  51. package/server/index.ts +2 -0
  52. package/server/routers/pdf-private-router.ts +24 -0
  53. package/server/routers/{pdf-router.ts → pdf-public-router.ts} +4 -4
  54. package/server/routes.ts +14 -2
  55. package/server/service/index.ts +26 -0
  56. package/server/service/pdf-template/index.ts +7 -0
  57. package/server/service/pdf-template/pdf-template-mutation.ts +138 -0
  58. package/server/service/pdf-template/pdf-template-query.ts +51 -0
  59. package/server/service/pdf-template/pdf-template-type.ts +87 -0
  60. package/server/service/pdf-template/pdf-template.ts +108 -0
  61. package/server/tsconfig.json +10 -0
  62. package/things-factory.config.js +8 -1
  63. package/translations/en.json +11 -0
  64. package/translations/ja.json +9 -0
  65. package/translations/ko.json +11 -0
  66. package/translations/ms.json +9 -0
  67. package/translations/zh.json +9 -0
  68. package/dist-server/routers/pdf-router.d.ts +0 -1
  69. package/dist-server/routers/pdf-router.js.map +0 -1
  70. package/tsconfig.json +0 -9
@@ -0,0 +1,93 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@material/web/icon/icon.js';
3
+ import '@operato/data-grist';
4
+ import gql from 'graphql-tag';
5
+ import { css, html, LitElement } from 'lit';
6
+ import { property } from 'lit/decorators.js';
7
+ import { client } from '@operato/graphql';
8
+ import { i18next } from '@operato/i18n';
9
+ import { isMobileDevice } from '@operato/utils';
10
+ import { ButtonContainerStyles } from '@operato/styles';
11
+ export class PDFTemplateImporter extends LitElement {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.pdfTemplates = [];
15
+ this.columns = {
16
+ list: { fields: ['name', 'description'] },
17
+ pagination: { infinite: true },
18
+ columns: [
19
+ {
20
+ type: 'string',
21
+ name: 'name',
22
+ header: i18next.t('field.name'),
23
+ width: 150
24
+ },
25
+ {
26
+ type: 'string',
27
+ name: 'description',
28
+ header: i18next.t('field.description'),
29
+ width: 200
30
+ },
31
+ {
32
+ type: 'checkbox',
33
+ name: 'active',
34
+ header: i18next.t('field.active'),
35
+ width: 60
36
+ }
37
+ ]
38
+ };
39
+ }
40
+ render() {
41
+ return html `
42
+ <ox-grist
43
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
44
+ .config=${this.columns}
45
+ .data=${{
46
+ records: this.pdfTemplates
47
+ }}
48
+ ></ox-grist>
49
+
50
+ <div class="button-container">
51
+ <button @click="${this.save.bind(this)}"><md-icon>save</md-icon>${i18next.t('button.save')}</button>
52
+ </div>
53
+ `;
54
+ }
55
+ async save() {
56
+ var _a;
57
+ const response = await client.mutate({
58
+ mutation: gql `
59
+ mutation importPDFTemplates($pdfTemplates: [PDFTemplatePatch!]!) {
60
+ importPDFTemplates(pdfTemplates: $pdfTemplates)
61
+ }
62
+ `,
63
+ variables: { pdfTemplates: this.pdfTemplates }
64
+ });
65
+ if ((_a = response.errors) === null || _a === void 0 ? void 0 : _a.length)
66
+ return;
67
+ this.dispatchEvent(new CustomEvent('imported'));
68
+ }
69
+ }
70
+ PDFTemplateImporter.styles = [
71
+ ButtonContainerStyles,
72
+ css `
73
+ :host {
74
+ display: flex;
75
+ flex-direction: column;
76
+
77
+ background-color: #fff;
78
+ }
79
+
80
+ ox-grist {
81
+ flex: 1;
82
+ }
83
+ `
84
+ ];
85
+ __decorate([
86
+ property({ type: Array }),
87
+ __metadata("design:type", Array)
88
+ ], PDFTemplateImporter.prototype, "pdfTemplates", void 0);
89
+ __decorate([
90
+ property({ type: Object }),
91
+ __metadata("design:type", Object)
92
+ ], PDFTemplateImporter.prototype, "columns", void 0);
93
+ //# sourceMappingURL=pdf-template-importer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdf-template-importer.js","sourceRoot":"","sources":["../../../client/pages/pdf-template/pdf-template-importer.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,qBAAqB,CAAA;AAE5B,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAEvD,MAAM,OAAO,mBAAoB,SAAQ,UAAU;IAAnD;;QAiB6B,iBAAY,GAAU,EAAE,CAAA;QACvB,YAAO,GAAG;YACpC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE;YACzC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;YAC9B,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,MAAM;oBACZ,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC;oBAC/B,KAAK,EAAE,GAAG;iBACX;gBACD;oBACE,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,aAAa;oBACnB,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC;oBACtC,KAAK,EAAE,GAAG;iBACX;gBACD;oBACE,IAAI,EAAE,UAAU;oBAChB,IAAI,EAAE,QAAQ;oBACd,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC;oBACjC,KAAK,EAAE,EAAE;iBACV;aACF;SACF,CAAA;IAgCH,CAAC;IA9BC,MAAM;QACJ,OAAO,IAAI,CAAA;;gBAEC,cAAc,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;kBAChC,IAAI,CAAC,OAAO;gBACd;YACN,OAAO,EAAE,IAAI,CAAC,YAAY;SAC3B;;;;0BAIiB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,4BAA4B,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC;;KAE7F,CAAA;IACH,CAAC;IAED,KAAK,CAAC,IAAI;;QACR,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;YACnC,QAAQ,EAAE,GAAG,CAAA;;;;OAIZ;YACD,SAAS,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE;SAC/C,CAAC,CAAA;QAEF,IAAI,MAAA,QAAQ,CAAC,MAAM,0CAAE,MAAM;YAAE,OAAM;QAEnC,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC,CAAA;IACjD,CAAC;;AAvEM,0BAAM,GAAG;IACd,qBAAqB;IACrB,GAAG,CAAA;;;;;;;;;;;KAWF;CACF,AAdY,CAcZ;AAE0B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;yDAAyB;AACvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAuB1B","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@operato/data-grist'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { property } from 'lit/decorators.js'\n\nimport { client } from '@operato/graphql'\nimport { i18next } from '@operato/i18n'\nimport { isMobileDevice } from '@operato/utils'\nimport { ButtonContainerStyles } from '@operato/styles'\n\nexport class PDFTemplateImporter extends LitElement {\n static styles = [\n ButtonContainerStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n background-color: #fff;\n }\n\n ox-grist {\n flex: 1;\n }\n `\n ]\n\n @property({ type: Array }) pdfTemplates: any[] = []\n @property({ type: Object }) columns = {\n list: { fields: ['name', 'description'] },\n pagination: { infinite: true },\n columns: [\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n width: 150\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n width: 200\n },\n {\n type: 'checkbox',\n name: 'active',\n header: i18next.t('field.active'),\n width: 60\n }\n ]\n }\n\n render() {\n return html`\n <ox-grist\n .mode=${isMobileDevice() ? 'LIST' : 'GRID'}\n .config=${this.columns}\n .data=${{\n records: this.pdfTemplates\n }}\n ></ox-grist>\n\n <div class=\"button-container\">\n <button @click=\"${this.save.bind(this)}\"><md-icon>save</md-icon>${i18next.t('button.save')}</button>\n </div>\n `\n }\n\n async save() {\n const response = await client.mutate({\n mutation: gql`\n mutation importPDFTemplates($pdfTemplates: [PDFTemplatePatch!]!) {\n importPDFTemplates(pdfTemplates: $pdfTemplates)\n }\n `,\n variables: { pdfTemplates: this.pdfTemplates }\n })\n\n if (response.errors?.length) return\n\n this.dispatchEvent(new CustomEvent('imported'))\n }\n}\n"]}
@@ -0,0 +1,66 @@
1
+ import '@material/web/icon/icon.js';
2
+ import '@material/web/button/elevated-button.js';
3
+ import '@operato/data-grist/ox-grist.js';
4
+ import '@operato/data-grist/ox-filters-form.js';
5
+ import '@operato/data-grist/ox-record-creator.js';
6
+ import { PageView } from '@operato/shell';
7
+ import { FetchOption } from '@operato/data-grist';
8
+ import { PDFTemplateImporter } from './pdf-template-importer';
9
+ declare const PDFTemplateListPage_base: (new (...args: any[]) => {
10
+ _storeUnsubscribe: import("redux").Unsubscribe;
11
+ connectedCallback(): void;
12
+ disconnectedCallback(): void;
13
+ stateChanged(_state: unknown): void;
14
+ readonly isConnected: boolean;
15
+ }) & (new (...args: any[]) => import("lit").LitElement) & typeof PageView & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
16
+ export declare class PDFTemplateListPage extends PDFTemplateListPage_base {
17
+ static styles: import("lit").CSSResult[];
18
+ static get scopedElements(): {
19
+ 'pdf-template-importer': typeof PDFTemplateImporter;
20
+ };
21
+ gristConfig: any;
22
+ mode: 'CARD' | 'GRID' | 'LIST';
23
+ private grist;
24
+ get context(): {
25
+ title: string;
26
+ search: {
27
+ handler: (search: string) => void;
28
+ value: string;
29
+ };
30
+ filter: {
31
+ handler: () => void;
32
+ };
33
+ help: string;
34
+ actions: {
35
+ icon: string;
36
+ emphasis: {
37
+ raised: boolean;
38
+ outlined: boolean;
39
+ dense: boolean;
40
+ danger: boolean;
41
+ };
42
+ title: string;
43
+ action: () => Promise<void>;
44
+ }[];
45
+ exportable: {
46
+ name: string;
47
+ data: () => Promise<{}[]>;
48
+ };
49
+ importable: {
50
+ handler: (records: any) => Promise<void>;
51
+ };
52
+ };
53
+ render(): import("lit-html").TemplateResult<1>;
54
+ pageInitialized(lifecycle: any): Promise<void>;
55
+ pageUpdated(changes: any, lifecycle: any): Promise<void>;
56
+ fetchHandler({ page, limit, sortings, filters }: FetchOption): Promise<{
57
+ total: any;
58
+ records: any;
59
+ }>;
60
+ _deletePDFTemplate(): Promise<void>;
61
+ _updatePDFTemplate(): Promise<void>;
62
+ creationCallback(pdfTemplate: any): Promise<boolean>;
63
+ exportHandler(): Promise<{}[]>;
64
+ importHandler(records: any): Promise<void>;
65
+ }
66
+ export {};
@@ -0,0 +1,464 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@material/web/icon/icon.js';
3
+ import '@material/web/button/elevated-button.js';
4
+ import '@operato/data-grist/ox-grist.js';
5
+ import '@operato/data-grist/ox-filters-form.js';
6
+ import '@operato/data-grist/ox-record-creator.js';
7
+ import { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles';
8
+ import { PageView, store } from '@operato/shell';
9
+ import { css, html } from 'lit';
10
+ import { customElement, property, query } from 'lit/decorators.js';
11
+ import { ScopedElementsMixin } from '@open-wc/scoped-elements';
12
+ import { DataGrist } from '@operato/data-grist';
13
+ import { client } from '@operato/graphql';
14
+ import { i18next, localize } from '@operato/i18n';
15
+ import { notify, openPopup } from '@operato/layout';
16
+ import { OxPrompt } from '@operato/popup';
17
+ import { isMobileDevice } from '@operato/utils';
18
+ import { connect } from 'pwa-helpers/connect-mixin';
19
+ import gql from 'graphql-tag';
20
+ import { PDFTemplateImporter } from './pdf-template-importer';
21
+ let PDFTemplateListPage = class PDFTemplateListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
22
+ constructor() {
23
+ super(...arguments);
24
+ this.mode = isMobileDevice() ? 'CARD' : 'GRID';
25
+ }
26
+ static get scopedElements() {
27
+ return {
28
+ 'pdf-template-importer': PDFTemplateImporter
29
+ };
30
+ }
31
+ get context() {
32
+ return {
33
+ title: i18next.t('title.pdf-template list'),
34
+ search: {
35
+ handler: (search) => {
36
+ this.grist.searchText = search;
37
+ },
38
+ value: this.grist.searchText
39
+ },
40
+ filter: {
41
+ handler: () => {
42
+ this.grist.toggleHeadroom();
43
+ }
44
+ },
45
+ help: 'pdf/pdf-template',
46
+ actions: [
47
+ Object.assign({ title: i18next.t('button.save'), action: this._updatePDFTemplate.bind(this) }, CommonButtonStyles.save),
48
+ Object.assign({ title: i18next.t('button.delete'), action: this._deletePDFTemplate.bind(this) }, CommonButtonStyles.delete)
49
+ ],
50
+ exportable: {
51
+ name: i18next.t('title.pdf-template list'),
52
+ data: this.exportHandler.bind(this)
53
+ },
54
+ importable: {
55
+ handler: this.importHandler.bind(this)
56
+ }
57
+ };
58
+ }
59
+ render() {
60
+ const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID');
61
+ return html `
62
+ <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
63
+ <div slot="headroom" class="header">
64
+ <div class="filters">
65
+ <ox-filters-form autofocus without-search></ox-filters-form>
66
+
67
+ <div id="modes">
68
+ <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>
69
+ <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>
70
+ <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>
71
+ </div>
72
+
73
+ <ox-record-creator id="add" .callback=${this.creationCallback.bind(this)}>
74
+ <button>
75
+ <md-icon>add</md-icon>
76
+ </button>
77
+ </ox-record-creator>
78
+ </div>
79
+ </div>
80
+ </ox-grist>
81
+ `;
82
+ }
83
+ async pageInitialized(lifecycle) {
84
+ this.gristConfig = {
85
+ list: {
86
+ fields: ['name', 'description'],
87
+ details: ['active', 'updatedAt']
88
+ },
89
+ columns: [
90
+ { type: 'gutter', gutterName: 'sequence' },
91
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
92
+ {
93
+ type: 'string',
94
+ name: 'name',
95
+ header: i18next.t('field.name'),
96
+ record: {
97
+ editable: true
98
+ },
99
+ filter: 'search',
100
+ sortable: true,
101
+ width: 150
102
+ },
103
+ {
104
+ type: 'string',
105
+ name: 'description',
106
+ header: i18next.t('field.description'),
107
+ record: {
108
+ editable: true
109
+ },
110
+ filter: 'search',
111
+ width: 200
112
+ },
113
+ {
114
+ type: 'checkbox',
115
+ name: 'active',
116
+ label: true,
117
+ header: i18next.t('field.active'),
118
+ record: {
119
+ editable: true
120
+ },
121
+ filter: true,
122
+ sortable: true,
123
+ width: 60
124
+ },
125
+ {
126
+ type: 'string',
127
+ name: 'state',
128
+ label: true,
129
+ header: i18next.t('field.state'),
130
+ record: {
131
+ editable: true
132
+ },
133
+ width: 120
134
+ },
135
+ {
136
+ type: 'template',
137
+ name: 'content_template',
138
+ label: true,
139
+ header: i18next.t('field.content_template'),
140
+ record: {
141
+ editable: true,
142
+ options: {
143
+ language: 'html'
144
+ }
145
+ },
146
+ width: 120
147
+ },
148
+ {
149
+ type: 'template',
150
+ name: 'header_template',
151
+ label: true,
152
+ header: i18next.t('field.header_template'),
153
+ record: {
154
+ editable: true,
155
+ options: {
156
+ language: 'html'
157
+ }
158
+ },
159
+ width: 120
160
+ },
161
+ {
162
+ type: 'template',
163
+ name: 'footer_template',
164
+ label: true,
165
+ header: i18next.t('field.footer_template'),
166
+ record: {
167
+ editable: true,
168
+ options: {
169
+ language: 'html'
170
+ }
171
+ },
172
+ width: 120
173
+ },
174
+ {
175
+ type: 'template',
176
+ name: 'cover_template',
177
+ label: true,
178
+ header: i18next.t('field.cover_template'),
179
+ record: {
180
+ editable: true,
181
+ options: {
182
+ language: 'html'
183
+ }
184
+ },
185
+ width: 120
186
+ },
187
+ {
188
+ type: 'template',
189
+ name: 'last_template',
190
+ label: true,
191
+ header: i18next.t('field.last_template'),
192
+ record: {
193
+ editable: true,
194
+ options: {
195
+ language: 'html'
196
+ }
197
+ },
198
+ width: 120
199
+ },
200
+ {
201
+ type: 'select',
202
+ name: 'page_size',
203
+ label: true,
204
+ header: i18next.t('field.page_size'),
205
+ record: {
206
+ editable: true,
207
+ options: ['', 'A4', 'B4']
208
+ },
209
+ width: 120
210
+ },
211
+ {
212
+ type: 'string',
213
+ name: 'watermark',
214
+ label: true,
215
+ header: i18next.t('field.watermark'),
216
+ record: {
217
+ editable: true
218
+ },
219
+ width: 120
220
+ },
221
+ {
222
+ type: 'resource-object',
223
+ name: 'updater',
224
+ header: i18next.t('field.updater'),
225
+ record: {
226
+ editable: false
227
+ },
228
+ sortable: true,
229
+ width: 120
230
+ },
231
+ {
232
+ type: 'datetime',
233
+ name: 'updatedAt',
234
+ header: i18next.t('field.updated_at'),
235
+ record: {
236
+ editable: false
237
+ },
238
+ sortable: true,
239
+ width: 180
240
+ }
241
+ ],
242
+ rows: {
243
+ appendable: false,
244
+ selectable: {
245
+ multiple: true
246
+ }
247
+ },
248
+ sorters: [
249
+ {
250
+ name: 'name'
251
+ }
252
+ ]
253
+ };
254
+ }
255
+ async pageUpdated(changes, lifecycle) {
256
+ if (this.active) {
257
+ // do something here when this page just became as active
258
+ }
259
+ }
260
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
261
+ const response = await client.query({
262
+ query: gql `
263
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
264
+ responses: PDFTemplates(filters: $filters, pagination: $pagination, sortings: $sortings) {
265
+ items {
266
+ id
267
+ name
268
+ description
269
+ active
270
+ state
271
+ content_template
272
+ header_template
273
+ footer_template
274
+ cover_template
275
+ last_template
276
+ page_size
277
+ watermark
278
+ updater {
279
+ id
280
+ name
281
+ }
282
+ updatedAt
283
+ }
284
+ total
285
+ }
286
+ }
287
+ `,
288
+ variables: {
289
+ filters,
290
+ pagination: { page, limit },
291
+ sortings
292
+ }
293
+ });
294
+ return {
295
+ total: response.data.responses.total || 0,
296
+ records: response.data.responses.items || []
297
+ };
298
+ }
299
+ async _deletePDFTemplate() {
300
+ if (await OxPrompt.open({
301
+ title: i18next.t('text.are_you_sure'),
302
+ text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),
303
+ confirmButton: { text: i18next.t('button.confirm') },
304
+ cancelButton: { text: i18next.t('button.cancel') }
305
+ })) {
306
+ const ids = this.grist.selected.map(record => record.id);
307
+ if (ids && ids.length > 0) {
308
+ const response = await client.mutate({
309
+ mutation: gql `
310
+ mutation ($ids: [String!]!) {
311
+ deletePDFTemplates(ids: $ids)
312
+ }
313
+ `,
314
+ variables: {
315
+ ids
316
+ }
317
+ });
318
+ if (!response.errors) {
319
+ this.grist.fetch();
320
+ notify({
321
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
322
+ });
323
+ }
324
+ }
325
+ }
326
+ }
327
+ async _updatePDFTemplate() {
328
+ let patches = this.grist.dirtyRecords;
329
+ if (patches && patches.length) {
330
+ patches = patches.map(patch => {
331
+ let patchField = patch.id ? { id: patch.id } : {};
332
+ const dirtyFields = patch.__dirtyfields__;
333
+ for (let key in dirtyFields) {
334
+ patchField[key] = dirtyFields[key].after;
335
+ }
336
+ patchField.cuFlag = patch.__dirty__;
337
+ return patchField;
338
+ });
339
+ const response = await client.mutate({
340
+ mutation: gql `
341
+ mutation ($patches: [PDFTemplatePatch!]!) {
342
+ updateMultiplePDFTemplate(patches: $patches) {
343
+ name
344
+ }
345
+ }
346
+ `,
347
+ variables: {
348
+ patches
349
+ }
350
+ });
351
+ if (!response.errors) {
352
+ this.grist.fetch();
353
+ }
354
+ }
355
+ }
356
+ async creationCallback(pdfTemplate) {
357
+ try {
358
+ const response = await client.query({
359
+ query: gql `
360
+ mutation ($pdfTemplate: NewPDFTemplate!) {
361
+ createPDFTemplate(pdfTemplate: $pdfTemplate) {
362
+ id
363
+ }
364
+ }
365
+ `,
366
+ variables: {
367
+ pdfTemplate
368
+ },
369
+ context: {
370
+ hasUpload: true
371
+ }
372
+ });
373
+ if (!response.errors) {
374
+ this.grist.fetch();
375
+ document.dispatchEvent(new CustomEvent('notify', {
376
+ detail: {
377
+ message: i18next.t('text.data_created_successfully')
378
+ }
379
+ }));
380
+ }
381
+ return true;
382
+ }
383
+ catch (ex) {
384
+ console.error(ex);
385
+ document.dispatchEvent(new CustomEvent('notify', {
386
+ detail: {
387
+ type: 'error',
388
+ message: i18next.t('text.error')
389
+ }
390
+ }));
391
+ return false;
392
+ }
393
+ }
394
+ async exportHandler() {
395
+ const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records;
396
+ const targetFieldSet = new Set(['id', 'name', 'description', 'active']);
397
+ return exportTargets.map(pdfTemplate => {
398
+ let tempObj = {};
399
+ for (const field of targetFieldSet) {
400
+ tempObj[field] = pdfTemplate[field];
401
+ }
402
+ return tempObj;
403
+ });
404
+ }
405
+ async importHandler(records) {
406
+ const popup = openPopup(html `
407
+ <pdf-template-importer
408
+ .pdfTemplates=${records}
409
+ @imported=${() => {
410
+ history.back();
411
+ this.grist.fetch();
412
+ }}
413
+ ></pdf-template-importer>
414
+ `, {
415
+ backdrop: true,
416
+ size: 'large',
417
+ title: i18next.t('title.import pdf-template')
418
+ });
419
+ popup.onclosed = () => {
420
+ this.grist.fetch();
421
+ };
422
+ }
423
+ };
424
+ PDFTemplateListPage.styles = [
425
+ ScrollbarStyles,
426
+ CommonGristStyles,
427
+ CommonHeaderStyles,
428
+ css `
429
+ :host {
430
+ display: flex;
431
+
432
+ width: 100%;
433
+
434
+ --grid-record-emphasized-background-color: #8b0000;
435
+ --grid-record-emphasized-color: #ff6b6b;
436
+ }
437
+
438
+ ox-grist {
439
+ overflow-y: auto;
440
+ flex: 1;
441
+ }
442
+
443
+ ox-filters-form {
444
+ flex: 1;
445
+ }
446
+ `
447
+ ];
448
+ __decorate([
449
+ property({ type: Object }),
450
+ __metadata("design:type", Object)
451
+ ], PDFTemplateListPage.prototype, "gristConfig", void 0);
452
+ __decorate([
453
+ property({ type: String }),
454
+ __metadata("design:type", String)
455
+ ], PDFTemplateListPage.prototype, "mode", void 0);
456
+ __decorate([
457
+ query('ox-grist'),
458
+ __metadata("design:type", DataGrist)
459
+ ], PDFTemplateListPage.prototype, "grist", void 0);
460
+ PDFTemplateListPage = __decorate([
461
+ customElement('pdf-template-list-page')
462
+ ], PDFTemplateListPage);
463
+ export { PDFTemplateListPage };
464
+ //# sourceMappingURL=pdf-template-list-page.js.map