@things-factory/quotation 6.0.46

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 (98) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/assets/images/hatiolab-logo.png +0 -0
  3. package/client/actions/main.ts +1 -0
  4. package/client/activities/activity-quotation-edit.ts +90 -0
  5. package/client/activities/activity-quotation-view.ts +90 -0
  6. package/client/bootstrap.ts +8 -0
  7. package/client/index.ts +1 -0
  8. package/client/pages/main.ts +25 -0
  9. package/client/pages/quotation/quotation-importer.ts +97 -0
  10. package/client/pages/quotation/quotation-list-page.ts +348 -0
  11. package/client/reducers/main.ts +17 -0
  12. package/client/route.ts +11 -0
  13. package/client/tsconfig.json +11 -0
  14. package/dist-client/actions/main.d.ts +1 -0
  15. package/dist-client/actions/main.js +2 -0
  16. package/dist-client/actions/main.js.map +1 -0
  17. package/dist-client/activities/activity-quotation-edit.d.ts +14 -0
  18. package/dist-client/activities/activity-quotation-edit.js +87 -0
  19. package/dist-client/activities/activity-quotation-edit.js.map +1 -0
  20. package/dist-client/activities/activity-quotation-view.d.ts +14 -0
  21. package/dist-client/activities/activity-quotation-view.js +87 -0
  22. package/dist-client/activities/activity-quotation-view.js.map +1 -0
  23. package/dist-client/bootstrap.d.ts +1 -0
  24. package/dist-client/bootstrap.js +8 -0
  25. package/dist-client/bootstrap.js.map +1 -0
  26. package/dist-client/index.d.ts +1 -0
  27. package/dist-client/index.js +2 -0
  28. package/dist-client/index.js.map +1 -0
  29. package/dist-client/pages/main.d.ts +1 -0
  30. package/dist-client/pages/main.js +27 -0
  31. package/dist-client/pages/main.js.map +1 -0
  32. package/dist-client/pages/quotation/quotation-importer.d.ts +22 -0
  33. package/dist-client/pages/quotation/quotation-importer.js +100 -0
  34. package/dist-client/pages/quotation/quotation-importer.js.map +1 -0
  35. package/dist-client/pages/quotation/quotation-list-page.d.ts +62 -0
  36. package/dist-client/pages/quotation/quotation-list-page.js +326 -0
  37. package/dist-client/pages/quotation/quotation-list-page.js.map +1 -0
  38. package/dist-client/reducers/main.d.ts +6 -0
  39. package/dist-client/reducers/main.js +14 -0
  40. package/dist-client/reducers/main.js.map +1 -0
  41. package/dist-client/route.d.ts +1 -0
  42. package/dist-client/route.js +11 -0
  43. package/dist-client/route.js.map +1 -0
  44. package/dist-client/tsconfig.tsbuildinfo +1 -0
  45. package/dist-server/activities/activity-quotation.js +113 -0
  46. package/dist-server/activities/activity-quotation.js.map +1 -0
  47. package/dist-server/activities/index.js +17 -0
  48. package/dist-server/activities/index.js.map +1 -0
  49. package/dist-server/controllers/index.js +1 -0
  50. package/dist-server/controllers/index.js.map +1 -0
  51. package/dist-server/index.js +7 -0
  52. package/dist-server/index.js.map +1 -0
  53. package/dist-server/middlewares/index.js +8 -0
  54. package/dist-server/middlewares/index.js.map +1 -0
  55. package/dist-server/migrations/index.js +12 -0
  56. package/dist-server/migrations/index.js.map +1 -0
  57. package/dist-server/routes.js +25 -0
  58. package/dist-server/routes.js.map +1 -0
  59. package/dist-server/service/index.js +23 -0
  60. package/dist-server/service/index.js.map +1 -0
  61. package/dist-server/service/quotation/event-subscriber.js +21 -0
  62. package/dist-server/service/quotation/event-subscriber.js.map +1 -0
  63. package/dist-server/service/quotation/index.js +12 -0
  64. package/dist-server/service/quotation/index.js.map +1 -0
  65. package/dist-server/service/quotation/quotation-history.js +123 -0
  66. package/dist-server/service/quotation/quotation-history.js.map +1 -0
  67. package/dist-server/service/quotation/quotation-mutation.js +168 -0
  68. package/dist-server/service/quotation/quotation-mutation.js.map +1 -0
  69. package/dist-server/service/quotation/quotation-query.js +97 -0
  70. package/dist-server/service/quotation/quotation-query.js.map +1 -0
  71. package/dist-server/service/quotation/quotation-type.js +86 -0
  72. package/dist-server/service/quotation/quotation-type.js.map +1 -0
  73. package/dist-server/service/quotation/quotation.js +110 -0
  74. package/dist-server/service/quotation/quotation.js.map +1 -0
  75. package/dist-server/tsconfig.tsbuildinfo +1 -0
  76. package/helps/quotation/quotation.md +160 -0
  77. package/package.json +36 -0
  78. package/server/activities/activity-quotation.ts +112 -0
  79. package/server/activities/index.ts +17 -0
  80. package/server/controllers/index.ts +0 -0
  81. package/server/index.ts +4 -0
  82. package/server/middlewares/index.ts +3 -0
  83. package/server/migrations/index.ts +9 -0
  84. package/server/routes.ts +28 -0
  85. package/server/service/index.ts +22 -0
  86. package/server/service/quotation/event-subscriber.ts +17 -0
  87. package/server/service/quotation/index.ts +9 -0
  88. package/server/service/quotation/quotation-history.ts +110 -0
  89. package/server/service/quotation/quotation-mutation.ts +198 -0
  90. package/server/service/quotation/quotation-query.ts +62 -0
  91. package/server/service/quotation/quotation-type.ts +61 -0
  92. package/server/service/quotation/quotation.ts +95 -0
  93. package/server/tsconfig.json +10 -0
  94. package/things-factory.config.js +11 -0
  95. package/translations/en.json +1 -0
  96. package/translations/ko.json +1 -0
  97. package/translations/ms.json +1 -0
  98. package/translations/zh.json +1 -0
@@ -0,0 +1,326 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@operato/data-grist';
3
+ import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles';
4
+ import { PageView, store } from '@operato/shell';
5
+ import { css, html } from 'lit';
6
+ import { customElement, property, query } from 'lit/decorators.js';
7
+ import { ScopedElementsMixin } from '@open-wc/scoped-elements';
8
+ import { DataGrist } from '@operato/data-grist';
9
+ import { client } from '@operato/graphql';
10
+ import { i18next, localize } from '@operato/i18n';
11
+ import { notify, openPopup } from '@operato/layout';
12
+ import { OxPopup } from '@operato/popup';
13
+ import { isMobileDevice } from '@operato/utils';
14
+ import { connect } from 'pwa-helpers/connect-mixin';
15
+ import gql from 'graphql-tag';
16
+ import { QuotationImporter } from './quotation-importer';
17
+ let QuotationListPage = class QuotationListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.mode = isMobileDevice() ? 'CARD' : 'GRID';
21
+ }
22
+ static get scopedElements() {
23
+ return {
24
+ 'quotation-importer': QuotationImporter
25
+ };
26
+ }
27
+ get context() {
28
+ return {
29
+ search: {
30
+ handler: (search) => {
31
+ this.grist.searchText = search;
32
+ },
33
+ placeholder: i18next.t('title.quotation list'),
34
+ value: this.grist.searchText
35
+ },
36
+ filter: {
37
+ handler: () => {
38
+ this.grist.toggleHeadroom();
39
+ }
40
+ },
41
+ help: 'quotation/quotation',
42
+ actions: [
43
+ Object.assign({ title: i18next.t('button.save'), action: this._updateQuotation.bind(this) }, CommonButtonStyles.save),
44
+ Object.assign({ title: i18next.t('button.delete'), action: this._deleteQuotation.bind(this) }, CommonButtonStyles.delete)
45
+ ],
46
+ exportable: {
47
+ name: i18next.t('title.quotation list'),
48
+ data: this.exportHandler.bind(this)
49
+ },
50
+ importable: {
51
+ handler: this.importHandler.bind(this)
52
+ }
53
+ };
54
+ }
55
+ render() {
56
+ const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID');
57
+ return html `
58
+ <ox-grist
59
+ .mode=${mode}
60
+ .config=${this.gristConfig}
61
+ .fetchHandler=${this.fetchHandler.bind(this)}
62
+ >
63
+ <div slot="headroom">
64
+ <div id="filters">
65
+ <ox-filters-form autofocus></ox-filters-form>
66
+ </div>
67
+
68
+ <div id="sorters">
69
+ Sort
70
+ <mwc-icon
71
+ @click=${e => {
72
+ const target = e.currentTarget;
73
+ this.sortersControl.open({
74
+ right: 0,
75
+ top: target.offsetTop + target.offsetHeight
76
+ });
77
+ }}
78
+ >expand_more</mwc-icon
79
+ >
80
+ <ox-popup id="sorter-control">
81
+ <ox-sorters-control> </ox-sorters-control>
82
+ </ox-popup>
83
+ </div>
84
+
85
+ <div id="modes">
86
+ <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>
87
+ <mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>
88
+ <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
89
+ </div>
90
+ </div>
91
+ </ox-grist>
92
+ `;
93
+ }
94
+ async pageInitialized(lifecycle) {
95
+ this.gristConfig = {
96
+ list: {
97
+ fields: ['name', 'description'],
98
+ details: ['active', 'updatedAt']
99
+ },
100
+ columns: [
101
+ { type: 'gutter', gutterName: 'sequence' },
102
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
103
+ {
104
+ type: 'string',
105
+ name: 'name',
106
+ header: i18next.t('field.name'),
107
+ record: {
108
+ editable: true
109
+ },
110
+ filter: 'search',
111
+ sortable: true,
112
+ width: 150
113
+ },
114
+ {
115
+ type: 'string',
116
+ name: 'description',
117
+ header: i18next.t('field.description'),
118
+ record: {
119
+ editable: true
120
+ },
121
+ filter: 'search',
122
+ width: 200
123
+ },
124
+ {
125
+ type: 'checkbox',
126
+ name: 'active',
127
+ label: true,
128
+ header: i18next.t('field.active'),
129
+ record: {
130
+ editable: true
131
+ },
132
+ filter: true,
133
+ sortable: true,
134
+ width: 60
135
+ },
136
+ {
137
+ type: 'resource-object',
138
+ name: 'updater',
139
+ header: i18next.t('field.updater'),
140
+ record: {
141
+ editable: false
142
+ },
143
+ sortable: true,
144
+ width: 120
145
+ },
146
+ {
147
+ type: 'datetime',
148
+ name: 'updatedAt',
149
+ header: i18next.t('field.updated_at'),
150
+ record: {
151
+ editable: false
152
+ },
153
+ sortable: true,
154
+ width: 180
155
+ }
156
+ ],
157
+ rows: {
158
+ selectable: {
159
+ multiple: true
160
+ }
161
+ },
162
+ sorters: [
163
+ {
164
+ name: 'name'
165
+ }
166
+ ]
167
+ };
168
+ }
169
+ async pageUpdated(changes, lifecycle) {
170
+ if (this.active) {
171
+ // do something here when this page just became as active
172
+ }
173
+ }
174
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
175
+ const response = await client.query({
176
+ query: gql `
177
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
178
+ responses: quotations(filters: $filters, pagination: $pagination, sortings: $sortings) {
179
+ items {
180
+ id
181
+ name
182
+ description
183
+ active
184
+ updater {
185
+ id
186
+ name
187
+ }
188
+ updatedAt
189
+ }
190
+ total
191
+ }
192
+ }
193
+ `,
194
+ variables: {
195
+ filters,
196
+ pagination: { page, limit },
197
+ sortings
198
+ }
199
+ });
200
+ return {
201
+ total: response.data.responses.total || 0,
202
+ records: response.data.responses.items || []
203
+ };
204
+ }
205
+ async _deleteQuotation() {
206
+ if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {
207
+ const ids = this.grist.selected.map(record => record.id);
208
+ if (ids && ids.length > 0) {
209
+ const response = await client.mutate({
210
+ mutation: gql `
211
+ mutation ($ids: [String!]!) {
212
+ deleteQuotations(ids: $ids)
213
+ }
214
+ `,
215
+ variables: {
216
+ ids
217
+ }
218
+ });
219
+ if (!response.errors) {
220
+ this.grist.fetch();
221
+ notify({
222
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
223
+ });
224
+ }
225
+ }
226
+ }
227
+ }
228
+ async _updateQuotation() {
229
+ let patches = this.grist.dirtyRecords;
230
+ if (patches && patches.length) {
231
+ patches = patches.map(patch => {
232
+ let patchField = patch.id ? { id: patch.id } : {};
233
+ const dirtyFields = patch.__dirtyfields__;
234
+ for (let key in dirtyFields) {
235
+ patchField[key] = dirtyFields[key].after;
236
+ }
237
+ patchField.cuFlag = patch.__dirty__;
238
+ return patchField;
239
+ });
240
+ const response = await client.mutate({
241
+ mutation: gql `
242
+ mutation ($patches: [QuotationPatch!]!) {
243
+ updateMultipleQuotation(patches: $patches) {
244
+ name
245
+ }
246
+ }
247
+ `,
248
+ variables: {
249
+ patches
250
+ }
251
+ });
252
+ if (!response.errors) {
253
+ this.grist.fetch();
254
+ }
255
+ }
256
+ }
257
+ async exportHandler() {
258
+ const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records;
259
+ const targetFieldSet = new Set([
260
+ 'id',
261
+ 'name',
262
+ 'description',
263
+ 'active'
264
+ ]);
265
+ return exportTargets.map(quotation => {
266
+ let tempObj = {};
267
+ for (const field of targetFieldSet) {
268
+ tempObj[field] = quotation[field];
269
+ }
270
+ return tempObj;
271
+ });
272
+ }
273
+ async importHandler(records) {
274
+ const popup = openPopup(html `
275
+ <quotation-importer
276
+ .quotations=${records}
277
+ @imported=${() => {
278
+ history.back();
279
+ this.grist.fetch();
280
+ }}
281
+ ></quotation-importer>
282
+ `, {
283
+ backdrop: true,
284
+ size: 'large',
285
+ title: i18next.t('title.import quotation')
286
+ });
287
+ popup.onclosed = () => {
288
+ this.grist.fetch();
289
+ };
290
+ }
291
+ };
292
+ QuotationListPage.styles = [
293
+ ScrollbarStyles,
294
+ CommonGristStyles,
295
+ css `
296
+ :host {
297
+ display: flex;
298
+
299
+ width: 100%;
300
+
301
+ --grid-record-emphasized-background-color: red;
302
+ --grid-record-emphasized-color: yellow;
303
+ }
304
+ `
305
+ ];
306
+ __decorate([
307
+ property({ type: Object }),
308
+ __metadata("design:type", Object)
309
+ ], QuotationListPage.prototype, "gristConfig", void 0);
310
+ __decorate([
311
+ property({ type: String }),
312
+ __metadata("design:type", String)
313
+ ], QuotationListPage.prototype, "mode", void 0);
314
+ __decorate([
315
+ query('ox-grist'),
316
+ __metadata("design:type", DataGrist)
317
+ ], QuotationListPage.prototype, "grist", void 0);
318
+ __decorate([
319
+ query('#sorter-control'),
320
+ __metadata("design:type", OxPopup)
321
+ ], QuotationListPage.prototype, "sortersControl", void 0);
322
+ QuotationListPage = __decorate([
323
+ customElement('quotation-list-page')
324
+ ], QuotationListPage);
325
+ export { QuotationListPage };
326
+ //# sourceMappingURL=quotation-list-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quotation-list-page.js","sourceRoot":"","sources":["../../../client/pages/quotation/quotation-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,i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AG,SAAS,CAAC,KAAK,CAAC,CAAA;aAClC;YAED,OAAO,OAAO,CAAA;QAChB,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAO;QACzB,MAAM,KAAK,GAAG,SAAS,CACrB,IAAI,CAAA;;wBAEc,OAAO;sBACT,GAAG,EAAE;YACf,OAAO,CAAC,IAAI,EAAE,CAAA;YACd,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC;;OAEJ,EACD;YACE,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC;SAC3C,CACF,CAAA;QAED,KAAK,CAAC,QAAQ,GAAG,GAAG,EAAE;YACpB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC,CAAA;IACH,CAAC;;AA9TM,wBAAM,GAAG;IACd,eAAe;IACf,iBAAiB;IACjB,GAAG,CAAA;;;;;;;;;KASF;CACF,CAAA;AAQD;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sDAAiB;AAC5C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;+CAAoE;AAE/F;IAAC,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;gDAAA;AAC5C;IAAC,KAAK,CAAC,iBAAiB,CAAC;8BAA0B,OAAO;yDAAA;AA3B/C,iBAAiB;IAD7B,aAAa,CAAC,qBAAqB,CAAC;GACxB,iBAAiB,CAiU7B;SAjUY,iBAAiB","sourcesContent":["import '@operato/data-grist'\n\nimport { CommonButtonStyles, 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 {\n ColumnConfig,\n DataGrist,\n FetchOption,\n SortersControl\n} from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { OxPopup } from '@operato/popup'\nimport { isMobileDevice } from '@operato/utils'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport gql from 'graphql-tag'\n\nimport { QuotationImporter } from './quotation-importer'\n\n@customElement('quotation-list-page')\nexport class QuotationListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {\n\n static styles = [\n ScrollbarStyles,\n CommonGristStyles,\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 ]\n\n static get scopedElements() {\n return {\n 'quotation-importer': QuotationImporter\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 @query('#sorter-control') private sortersControl!: OxPopup\n\n get context() {\n return {\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n placeholder: i18next.t('title.quotation list'),\n value: this.grist.searchText\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n help: 'quotation/quotation',\n actions: [\n {\n title: i18next.t('button.save'),\n action: this._updateQuotation.bind(this),\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.delete'),\n action: this._deleteQuotation.bind(this),\n ...CommonButtonStyles.delete\n }\n ],\n exportable: {\n name: i18next.t('title.quotation 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\n .mode=${mode}\n .config=${this.gristConfig}\n .fetchHandler=${this.fetchHandler.bind(this)}\n >\n <div slot=\"headroom\">\n <div id=\"filters\">\n <ox-filters-form autofocus></ox-filters-form>\n </div>\n\n <div id=\"sorters\">\n Sort\n <mwc-icon\n @click=${e => {\n const target = e.currentTarget\n this.sortersControl.open({\n right: 0,\n top: target.offsetTop + target.offsetHeight\n })\n }}\n >expand_more</mwc-icon\n >\n <ox-popup id=\"sorter-control\">\n <ox-sorters-control> </ox-sorters-control>\n </ox-popup>\n </div>\n\n <div id=\"modes\">\n <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>\n <mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>\n <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>\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: '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 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: quotations(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n description\n active\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 _deleteQuotation() {\n if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {\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 deleteQuotations(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 _updateQuotation() {\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: [QuotationPatch!]!) {\n updateMultipleQuotation(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 exportHandler() {\n const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records\n const targetFieldSet = new Set([\n 'id',\n 'name',\n 'description',\n 'active'\n ])\n\n return exportTargets.map(quotation => {\n let tempObj = {}\n for (const field of targetFieldSet) {\n tempObj[field] = quotation[field]\n }\n\n return tempObj\n })\n }\n\n async importHandler(records) {\n const popup = openPopup(\n html`\n <quotation-importer\n .quotations=${records}\n @imported=${() => {\n history.back()\n this.grist.fetch()\n }}\n ></quotation-importer>\n `,\n {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.import quotation')\n }\n )\n \n popup.onclosed = () => {\n this.grist.fetch()\n }\n }\n}\n\n"]}
@@ -0,0 +1,6 @@
1
+ declare const quotation: (state: {
2
+ quotation: string;
3
+ } | undefined, action: any) => {
4
+ quotation: string;
5
+ };
6
+ export default quotation;
@@ -0,0 +1,14 @@
1
+ import { UPDATE_QUOTATION } from '../actions/main';
2
+ const INITIAL_STATE = {
3
+ quotation: 'ABC'
4
+ };
5
+ const quotation = (state = INITIAL_STATE, action) => {
6
+ switch (action.type) {
7
+ case UPDATE_QUOTATION:
8
+ return Object.assign({}, state);
9
+ default:
10
+ return state;
11
+ }
12
+ };
13
+ export default quotation;
14
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../client/reducers/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD,MAAM,aAAa,GAAG;IACpB,SAAS,EAAE,KAAK;CACjB,CAAA;AAED,MAAM,SAAS,GAAG,CAAC,KAAK,GAAG,aAAa,EAAE,MAAM,EAAE,EAAE;IAClD,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,KAAK,gBAAgB;YACnB,yBAAY,KAAK,EAAE;QAErB;YACE,OAAO,KAAK,CAAA;KACf;AACH,CAAC,CAAA;AAED,eAAe,SAAS,CAAA","sourcesContent":["import { UPDATE_QUOTATION } from '../actions/main'\n\nconst INITIAL_STATE = {\n quotation: 'ABC'\n}\n\nconst quotation = (state = INITIAL_STATE, action) => {\n switch (action.type) {\n case UPDATE_QUOTATION:\n return { ...state }\n\n default:\n return state\n }\n}\n\nexport default quotation\n"]}
@@ -0,0 +1 @@
1
+ export default function route(page: string): "quotation-main" | "quotation-list" | undefined;
@@ -0,0 +1,11 @@
1
+ export default function route(page) {
2
+ switch (page) {
3
+ case 'quotation-main':
4
+ import('./pages/main');
5
+ return page;
6
+ case 'quotation-list':
7
+ import('./pages/quotation/quotation-list-page');
8
+ return page;
9
+ }
10
+ }
11
+ //# sourceMappingURL=route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.js","sourceRoot":"","sources":["../client/route.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,IAAY;IACxC,QAAQ,IAAI,EAAE;QACZ,KAAK,gBAAgB;YACnB,MAAM,CAAC,cAAc,CAAC,CAAA;YACtB,OAAO,IAAI,CAAA;QAEb,KAAK,gBAAgB;YACnB,MAAM,CAAC,uCAAuC,CAAC,CAAA;YAC/C,OAAO,IAAI,CAAA;KACd;AACH,CAAC","sourcesContent":["export default function route(page: string) {\n switch (page) {\n case 'quotation-main':\n import('./pages/main')\n return page\n \n case 'quotation-list':\n import('./pages/quotation/quotation-list-page')\n return page\n }\n}\n"]}