@things-factory/contact 6.0.0-zeta.26

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 (105) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/assets/images/hatiolab-logo.png +0 -0
  3. package/client/bootstrap.ts +1 -0
  4. package/client/index.ts +0 -0
  5. package/client/pages/contact/contact-importer.ts +97 -0
  6. package/client/pages/contact/contact-list-page.ts +348 -0
  7. package/client/route.ts +7 -0
  8. package/client/tsconfig.json +11 -0
  9. package/dist-client/actions/main.d.ts +1 -0
  10. package/dist-client/actions/main.js +2 -0
  11. package/dist-client/actions/main.js.map +1 -0
  12. package/dist-client/bootstrap.d.ts +1 -0
  13. package/dist-client/bootstrap.js +2 -0
  14. package/dist-client/bootstrap.js.map +1 -0
  15. package/dist-client/components/contact-editor.d.ts +3 -0
  16. package/dist-client/components/contact-editor.js +4 -0
  17. package/dist-client/components/contact-editor.js.map +1 -0
  18. package/dist-client/index.d.ts +0 -0
  19. package/dist-client/index.js +2 -0
  20. package/dist-client/index.js.map +1 -0
  21. package/dist-client/pages/address/address-importer.d.ts +22 -0
  22. package/dist-client/pages/address/address-importer.js +100 -0
  23. package/dist-client/pages/address/address-importer.js.map +1 -0
  24. package/dist-client/pages/address/address-list-page.d.ts +62 -0
  25. package/dist-client/pages/address/address-list-page.js +326 -0
  26. package/dist-client/pages/address/address-list-page.js.map +1 -0
  27. package/dist-client/pages/contact/contact-importer.d.ts +22 -0
  28. package/dist-client/pages/contact/contact-importer.js +100 -0
  29. package/dist-client/pages/contact/contact-importer.js.map +1 -0
  30. package/dist-client/pages/contact/contact-list-page.d.ts +62 -0
  31. package/dist-client/pages/contact/contact-list-page.js +326 -0
  32. package/dist-client/pages/contact/contact-list-page.js.map +1 -0
  33. package/dist-client/pages/contact-item/contact-item-importer.d.ts +22 -0
  34. package/dist-client/pages/contact-item/contact-item-importer.js +100 -0
  35. package/dist-client/pages/contact-item/contact-item-importer.js.map +1 -0
  36. package/dist-client/pages/contact-item/contact-item-list-page.d.ts +62 -0
  37. package/dist-client/pages/contact-item/contact-item-list-page.js +326 -0
  38. package/dist-client/pages/contact-item/contact-item-list-page.js.map +1 -0
  39. package/dist-client/pages/email/email-importer.d.ts +22 -0
  40. package/dist-client/pages/email/email-importer.js +100 -0
  41. package/dist-client/pages/email/email-importer.js.map +1 -0
  42. package/dist-client/pages/email/email-list-page.d.ts +62 -0
  43. package/dist-client/pages/email/email-list-page.js +326 -0
  44. package/dist-client/pages/email/email-list-page.js.map +1 -0
  45. package/dist-client/pages/main.d.ts +1 -0
  46. package/dist-client/pages/main.js +27 -0
  47. package/dist-client/pages/main.js.map +1 -0
  48. package/dist-client/pages/phone/phone-importer.d.ts +22 -0
  49. package/dist-client/pages/phone/phone-importer.js +100 -0
  50. package/dist-client/pages/phone/phone-importer.js.map +1 -0
  51. package/dist-client/pages/phone/phone-list-page.d.ts +62 -0
  52. package/dist-client/pages/phone/phone-list-page.js +326 -0
  53. package/dist-client/pages/phone/phone-list-page.js.map +1 -0
  54. package/dist-client/reducers/main.d.ts +6 -0
  55. package/dist-client/reducers/main.js +14 -0
  56. package/dist-client/reducers/main.js.map +1 -0
  57. package/dist-client/route.d.ts +1 -0
  58. package/dist-client/route.js +8 -0
  59. package/dist-client/route.js.map +1 -0
  60. package/dist-client/tsconfig.tsbuildinfo +1 -0
  61. package/dist-server/controllers/index.js +1 -0
  62. package/dist-server/controllers/index.js.map +1 -0
  63. package/dist-server/index.js +7 -0
  64. package/dist-server/index.js.map +1 -0
  65. package/dist-server/middlewares/index.js +8 -0
  66. package/dist-server/middlewares/index.js.map +1 -0
  67. package/dist-server/migrations/index.js +12 -0
  68. package/dist-server/migrations/index.js.map +1 -0
  69. package/dist-server/routes.js +25 -0
  70. package/dist-server/routes.js.map +1 -0
  71. package/dist-server/service/contact/contact-item.js +44 -0
  72. package/dist-server/service/contact/contact-item.js.map +1 -0
  73. package/dist-server/service/contact/contact-mutation.js +168 -0
  74. package/dist-server/service/contact/contact-mutation.js.map +1 -0
  75. package/dist-server/service/contact/contact-query.js +94 -0
  76. package/dist-server/service/contact/contact-query.js.map +1 -0
  77. package/dist-server/service/contact/contact-type.js +50 -0
  78. package/dist-server/service/contact/contact-type.js.map +1 -0
  79. package/dist-server/service/contact/contact.js +96 -0
  80. package/dist-server/service/contact/contact.js.map +1 -0
  81. package/dist-server/service/contact/index.js +10 -0
  82. package/dist-server/service/contact/index.js.map +1 -0
  83. package/dist-server/service/index.js +23 -0
  84. package/dist-server/service/index.js.map +1 -0
  85. package/dist-server/tsconfig.tsbuildinfo +1 -0
  86. package/helps/contact/contact.md +160 -0
  87. package/package.json +37 -0
  88. package/server/controllers/index.ts +0 -0
  89. package/server/index.ts +4 -0
  90. package/server/middlewares/index.ts +3 -0
  91. package/server/migrations/index.ts +9 -0
  92. package/server/routes.ts +28 -0
  93. package/server/service/contact/contact-item.ts +31 -0
  94. package/server/service/contact/contact-mutation.ts +195 -0
  95. package/server/service/contact/contact-query.ts +59 -0
  96. package/server/service/contact/contact-type.ts +35 -0
  97. package/server/service/contact/contact.ts +89 -0
  98. package/server/service/contact/index.ts +7 -0
  99. package/server/service/index.ts +22 -0
  100. package/server/tsconfig.json +10 -0
  101. package/things-factory.config.js +8 -0
  102. package/translations/en.json +1 -0
  103. package/translations/ko.json +1 -0
  104. package/translations/ms.json +1 -0
  105. package/translations/zh.json +1 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
+ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
+
8
+ <!-- ## [Unreleased] -->
Binary file
@@ -0,0 +1 @@
1
+ export default function bootstrap() {}
File without changes
@@ -0,0 +1,97 @@
1
+ import '@operato/data-grist'
2
+
3
+ import gql from 'graphql-tag'
4
+ import { css, html, LitElement } from 'lit'
5
+ import { property } from 'lit/decorators.js'
6
+
7
+ import { client } from '@operato/graphql'
8
+ import { i18next } from '@operato/i18n'
9
+ import { isMobileDevice } from '@operato/utils'
10
+
11
+ export class ContactImporter extends LitElement {
12
+ static styles = [
13
+ css`
14
+ :host {
15
+ display: flex;
16
+ flex-direction: column;
17
+
18
+ background-color: #fff;
19
+ }
20
+
21
+ ox-grist {
22
+ flex: 1;
23
+ }
24
+
25
+ .button-container {
26
+ display: flex;
27
+ margin-left: auto;
28
+ padding: var(--padding-default);
29
+ }
30
+
31
+ mwc-button {
32
+ margin-left: var(--margin-default);
33
+ }
34
+ `
35
+ ]
36
+
37
+ @property({ type: Array }) contacts: any[] = []
38
+ @property({ type: Object }) columns = {
39
+ list: { fields: ['name', 'description'] },
40
+ pagination: { infinite: true },
41
+ columns: [
42
+ {
43
+ type: 'string',
44
+ name: 'name',
45
+ header: i18next.t('field.name'),
46
+ width: 150
47
+ },
48
+ {
49
+ type: 'string',
50
+ name: 'description',
51
+ header: i18next.t('field.description'),
52
+ width: 200
53
+ },
54
+ {
55
+ type: 'checkbox',
56
+ name: 'active',
57
+ header: i18next.t('field.active'),
58
+ width: 60
59
+ }
60
+ ]
61
+ }
62
+
63
+
64
+ render() {
65
+ return html`
66
+ <ox-grist
67
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
68
+ .config=${this.columns}
69
+ .data=${
70
+ {
71
+ records: this.contacts
72
+ }
73
+ }
74
+ ></ox-grist>
75
+
76
+ <div class="button-container">
77
+ <mwc-button raised @click="${this.save.bind(this)}">${i18next.t('button.save')}</mwc-button>
78
+ </div>
79
+ `
80
+ }
81
+
82
+ async save() {
83
+ const response = await client.mutate({
84
+ mutation: gql`
85
+ mutation importContacts($contacts: [ContactPatch!]!) {
86
+ importContacts(contacts: $contacts)
87
+ }
88
+ `,
89
+ variables: { contacts: this.contacts }
90
+ })
91
+
92
+ if (response.errors?.length) return
93
+
94
+ this.dispatchEvent(new CustomEvent('imported'))
95
+ }
96
+ }
97
+
@@ -0,0 +1,348 @@
1
+ import '@operato/data-grist'
2
+
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 {
9
+ ColumnConfig,
10
+ DataGrist,
11
+ FetchOption,
12
+ SortersControl
13
+ } from '@operato/data-grist'
14
+ import { client } from '@operato/graphql'
15
+ import { i18next, localize } from '@operato/i18n'
16
+ import { notify, openPopup } from '@operato/layout'
17
+ import { OxPopup } from '@operato/popup'
18
+ import { isMobileDevice } from '@operato/utils'
19
+
20
+ import { connect } from 'pwa-helpers/connect-mixin'
21
+ import gql from 'graphql-tag'
22
+
23
+ import { ContactImporter } from './contact-importer'
24
+
25
+ @customElement('contact-list-page')
26
+ export class ContactListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
27
+
28
+ static styles = [
29
+ ScrollbarStyles,
30
+ CommonGristStyles,
31
+ css`
32
+ :host {
33
+ display: flex;
34
+
35
+ width: 100%;
36
+
37
+ --grid-record-emphasized-background-color: red;
38
+ --grid-record-emphasized-color: yellow;
39
+ }
40
+ `
41
+ ]
42
+
43
+ static get scopedElements() {
44
+ return {
45
+ 'contact-importer': ContactImporter
46
+ }
47
+ }
48
+
49
+ @property({ type: Object }) gristConfig: any
50
+ @property({ type: String }) mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'
51
+
52
+ @query('ox-grist') private grist!: DataGrist
53
+ @query('#sorter-control') private sortersControl!: OxPopup
54
+
55
+ get context() {
56
+ return {
57
+ search: {
58
+ handler: (search: string) => {
59
+ this.grist.searchText = search
60
+ },
61
+ placeholder: i18next.t('title.contact list'),
62
+ value: this.grist.searchText
63
+ },
64
+ filter: {
65
+ handler: () => {
66
+ this.grist.toggleHeadroom()
67
+ }
68
+ },
69
+ help: 'contact/contact',
70
+ actions: [
71
+ {
72
+ title: i18next.t('button.save'),
73
+ action: this._updateContact.bind(this),
74
+ ...CommonButtonStyles.save
75
+ },
76
+ {
77
+ title: i18next.t('button.delete'),
78
+ action: this._deleteContact.bind(this),
79
+ ...CommonButtonStyles.delete
80
+ }
81
+ ],
82
+ exportable: {
83
+ name: i18next.t('title.contact list'),
84
+ data: this.exportHandler.bind(this)
85
+ },
86
+ importable: {
87
+ handler: this.importHandler.bind(this)
88
+ }
89
+ }
90
+ }
91
+
92
+ render() {
93
+ const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')
94
+
95
+ return html`
96
+ <ox-grist
97
+ .mode=${mode}
98
+ .config=${this.gristConfig}
99
+ .fetchHandler=${this.fetchHandler.bind(this)}
100
+ >
101
+ <div slot="headroom">
102
+ <div id="filters">
103
+ <ox-filters-form autofocus></ox-filters-form>
104
+ </div>
105
+
106
+ <div id="sorters">
107
+ Sort
108
+ <mwc-icon
109
+ @click=${e => {
110
+ const target = e.currentTarget
111
+ this.sortersControl.open({
112
+ right: 0,
113
+ top: target.offsetTop + target.offsetHeight
114
+ })
115
+ }}
116
+ >expand_more</mwc-icon
117
+ >
118
+ <ox-popup id="sorter-control">
119
+ <ox-sorters-control> </ox-sorters-control>
120
+ </ox-popup>
121
+ </div>
122
+
123
+ <div id="modes">
124
+ <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>
125
+ <mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>
126
+ <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
127
+ </div>
128
+ </div>
129
+ </ox-grist>
130
+ `
131
+ }
132
+
133
+ async pageInitialized(lifecycle: any) {
134
+ this.gristConfig = {
135
+ list: {
136
+ fields: ['name', 'description'],
137
+ details: ['active', 'updatedAt']
138
+ },
139
+ columns: [
140
+ { type: 'gutter', gutterName: 'sequence' },
141
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
142
+ {
143
+ type: 'string',
144
+ name: 'name',
145
+ header: i18next.t('field.name'),
146
+ record: {
147
+ editable: true
148
+ },
149
+ filter: 'search',
150
+ sortable: true,
151
+ width: 150
152
+ },
153
+ {
154
+ type: 'string',
155
+ name: 'description',
156
+ header: i18next.t('field.description'),
157
+ record: {
158
+ editable: true
159
+ },
160
+ filter: 'search',
161
+ width: 200
162
+ },
163
+ {
164
+ type: 'checkbox',
165
+ name: 'active',
166
+ label: true,
167
+ header: i18next.t('field.active'),
168
+ record: {
169
+ editable: true
170
+ },
171
+ filter: true,
172
+ sortable: true,
173
+ width: 60
174
+ },
175
+ {
176
+ type: 'resource-object',
177
+ name: 'updater',
178
+ header: i18next.t('field.updater'),
179
+ record: {
180
+ editable: false
181
+ },
182
+ sortable: true,
183
+ width: 120
184
+ },
185
+ {
186
+ type: 'datetime',
187
+ name: 'updatedAt',
188
+ header: i18next.t('field.updated_at'),
189
+ record: {
190
+ editable: false
191
+ },
192
+ sortable: true,
193
+ width: 180
194
+ }
195
+ ],
196
+ rows: {
197
+ selectable: {
198
+ multiple: true
199
+ }
200
+ },
201
+ sorters: [
202
+ {
203
+ name: 'name'
204
+ }
205
+ ]
206
+ }
207
+ }
208
+
209
+ async pageUpdated(changes: any, lifecycle: any) {
210
+ if (this.active) {
211
+ // do something here when this page just became as active
212
+ }
213
+ }
214
+
215
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {
216
+ const response = await client.query({
217
+ query: gql`
218
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
219
+ responses: contacts(filters: $filters, pagination: $pagination, sortings: $sortings) {
220
+ items {
221
+ id
222
+ name
223
+ description
224
+ active
225
+ updater {
226
+ id
227
+ name
228
+ }
229
+ updatedAt
230
+ }
231
+ total
232
+ }
233
+ }
234
+ `,
235
+ variables: {
236
+ filters,
237
+ pagination: { page, limit },
238
+ sortings
239
+ }
240
+ })
241
+
242
+ return {
243
+ total: response.data.responses.total || 0,
244
+ records: response.data.responses.items || []
245
+ }
246
+ }
247
+
248
+ async _deleteContact() {
249
+ if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {
250
+ const ids = this.grist.selected.map(record => record.id)
251
+ if (ids && ids.length > 0) {
252
+ const response = await client.mutate({
253
+ mutation: gql`
254
+ mutation ($ids: [String!]!) {
255
+ deleteContacts(ids: $ids)
256
+ }
257
+ `,
258
+ variables: {
259
+ ids
260
+ }
261
+ })
262
+
263
+ if (!response.errors) {
264
+ this.grist.fetch()
265
+ notify({
266
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
267
+ })
268
+ }
269
+ }
270
+ }
271
+ }
272
+
273
+ async _updateContact() {
274
+ let patches = this.grist.dirtyRecords
275
+ if (patches && patches.length) {
276
+ patches = patches.map(patch => {
277
+ let patchField: any = patch.id ? { id: patch.id } : {}
278
+ const dirtyFields = patch.__dirtyfields__
279
+ for (let key in dirtyFields) {
280
+ patchField[key] = dirtyFields[key].after
281
+ }
282
+ patchField.cuFlag = patch.__dirty__
283
+
284
+ return patchField
285
+ })
286
+
287
+ const response = await client.mutate({
288
+ mutation: gql`
289
+ mutation ($patches: [ContactPatch!]!) {
290
+ updateMultipleContact(patches: $patches) {
291
+ name
292
+ }
293
+ }
294
+ `,
295
+ variables: {
296
+ patches
297
+ }
298
+ })
299
+
300
+ if (!response.errors) {
301
+ this.grist.fetch()
302
+ }
303
+ }
304
+ }
305
+
306
+ async exportHandler() {
307
+ const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records
308
+ const targetFieldSet = new Set([
309
+ 'id',
310
+ 'name',
311
+ 'description',
312
+ 'active'
313
+ ])
314
+
315
+ return exportTargets.map(contact => {
316
+ let tempObj = {}
317
+ for (const field of targetFieldSet) {
318
+ tempObj[field] = contact[field]
319
+ }
320
+
321
+ return tempObj
322
+ })
323
+ }
324
+
325
+ async importHandler(records) {
326
+ const popup = openPopup(
327
+ html`
328
+ <contact-importer
329
+ .contacts=${records}
330
+ @imported=${() => {
331
+ history.back()
332
+ this.grist.fetch()
333
+ }}
334
+ ></contact-importer>
335
+ `,
336
+ {
337
+ backdrop: true,
338
+ size: 'large',
339
+ title: i18next.t('title.import contact')
340
+ }
341
+ )
342
+
343
+ popup.onclosed = () => {
344
+ this.grist.fetch()
345
+ }
346
+ }
347
+ }
348
+
@@ -0,0 +1,7 @@
1
+ export default function route(page: string) {
2
+ switch (page) {
3
+ case 'contact-list':
4
+ import('./pages/contact/contact-list-page')
5
+ return page
6
+ }
7
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../../tsconfig-base.json",
3
+ "compilerOptions": {
4
+ "strict": true,
5
+ "declaration": true,
6
+ "module": "esnext",
7
+ "outDir": "../dist-client",
8
+ "baseUrl": "./"
9
+ },
10
+ "include": ["./**/*"]
11
+ }
@@ -0,0 +1 @@
1
+ export declare const UPDATE_CONTACT = "UPDATE_CONTACT";
@@ -0,0 +1,2 @@
1
+ export const UPDATE_CONTACT = 'UPDATE_CONTACT';
2
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../client/actions/main.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAA","sourcesContent":["export const UPDATE_CONTACT = 'UPDATE_CONTACT'\n"]}
@@ -0,0 +1 @@
1
+ export default function bootstrap(): void;
@@ -0,0 +1,2 @@
1
+ export default function bootstrap() { }
2
+ //# sourceMappingURL=bootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../client/bootstrap.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,SAAS,KAAI,CAAC","sourcesContent":["export default function bootstrap() {}\n"]}
@@ -0,0 +1,3 @@
1
+ import { LitElement } from 'lit';
2
+ export declare class ContactEditor extends LitElement {
3
+ }
@@ -0,0 +1,4 @@
1
+ import { LitElement } from 'lit';
2
+ export class ContactEditor extends LitElement {
3
+ }
4
+ //# sourceMappingURL=contact-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contact-editor.js","sourceRoot":"","sources":["../../client/components/contact-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAEhC,MAAM,OAAO,aAAc,SAAQ,UAAU;CAAG","sourcesContent":["import { LitElement } from 'lit'\n\nexport class ContactEditor extends LitElement {}\n"]}
File without changes
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"","sourcesContent":[""]}
@@ -0,0 +1,22 @@
1
+ import '@operato/data-grist';
2
+ import { LitElement } from 'lit';
3
+ export declare class AddressImporter extends LitElement {
4
+ static styles: import("lit").CSSResult[];
5
+ addresses: any[];
6
+ columns: {
7
+ list: {
8
+ fields: string[];
9
+ };
10
+ pagination: {
11
+ infinite: boolean;
12
+ };
13
+ columns: {
14
+ type: string;
15
+ name: string;
16
+ header: string;
17
+ width: number;
18
+ }[];
19
+ };
20
+ render(): import("lit-html").TemplateResult<1>;
21
+ save(): Promise<void>;
22
+ }
@@ -0,0 +1,100 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@operato/data-grist';
3
+ import gql from 'graphql-tag';
4
+ import { css, html, LitElement } from 'lit';
5
+ import { property } from 'lit/decorators.js';
6
+ import { client } from '@operato/graphql';
7
+ import { i18next } from '@operato/i18n';
8
+ import { isMobileDevice } from '@operato/utils';
9
+ export class AddressImporter extends LitElement {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.addresses = [];
13
+ this.columns = {
14
+ list: { fields: ['name', 'description'] },
15
+ pagination: { infinite: true },
16
+ columns: [
17
+ {
18
+ type: 'string',
19
+ name: 'name',
20
+ header: i18next.t('field.name'),
21
+ width: 150
22
+ },
23
+ {
24
+ type: 'string',
25
+ name: 'description',
26
+ header: i18next.t('field.description'),
27
+ width: 200
28
+ },
29
+ {
30
+ type: 'checkbox',
31
+ name: 'active',
32
+ header: i18next.t('field.active'),
33
+ width: 60
34
+ }
35
+ ]
36
+ };
37
+ }
38
+ render() {
39
+ return html `
40
+ <ox-grist
41
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
42
+ .config=${this.columns}
43
+ .data=${{
44
+ records: this.addresses
45
+ }}
46
+ ></ox-grist>
47
+
48
+ <div class="button-container">
49
+ <mwc-button raised @click="${this.save.bind(this)}">${i18next.t('button.save')}</mwc-button>
50
+ </div>
51
+ `;
52
+ }
53
+ async save() {
54
+ var _a;
55
+ const response = await client.mutate({
56
+ mutation: gql `
57
+ mutation importAddresses($addresses: [AddressPatch!]!) {
58
+ importAddresses(addresses: $addresses)
59
+ }
60
+ `,
61
+ variables: { addresses: this.addresses }
62
+ });
63
+ if ((_a = response.errors) === null || _a === void 0 ? void 0 : _a.length)
64
+ return;
65
+ this.dispatchEvent(new CustomEvent('imported'));
66
+ }
67
+ }
68
+ AddressImporter.styles = [
69
+ css `
70
+ :host {
71
+ display: flex;
72
+ flex-direction: column;
73
+
74
+ background-color: #fff;
75
+ }
76
+
77
+ ox-grist {
78
+ flex: 1;
79
+ }
80
+
81
+ .button-container {
82
+ display: flex;
83
+ margin-left: auto;
84
+ padding: var(--padding-default);
85
+ }
86
+
87
+ mwc-button {
88
+ margin-left: var(--margin-default);
89
+ }
90
+ `
91
+ ];
92
+ __decorate([
93
+ property({ type: Array }),
94
+ __metadata("design:type", Array)
95
+ ], AddressImporter.prototype, "addresses", void 0);
96
+ __decorate([
97
+ property({ type: Object }),
98
+ __metadata("design:type", Object)
99
+ ], AddressImporter.prototype, "columns", void 0);
100
+ //# sourceMappingURL=address-importer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-importer.js","sourceRoot":"","sources":["../../../client/pages/address/address-importer.ts"],"names":[],"mappings":";AAAA,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;AAE/C,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAA/C;;QA0B6B,cAAS,GAAU,EAAE,CAAA;QACpB,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;IAmCH,CAAC;IAhCC,MAAM;QACJ,OAAO,IAAI,CAAA;;gBAEC,cAAc,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;kBAChC,IAAI,CAAC,OAAO;gBAEpB;YACE,OAAO,EAAE,IAAI,CAAC,SAAS;SAE3B;;;;qCAI6B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC;;KAEjF,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,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE;SACzC,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;;AAnFM,sBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;KAqBF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;kDAAsB;AAChD;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDAuB1B","sourcesContent":["import '@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'\n\nexport class AddressImporter extends LitElement {\n static styles = [\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 .button-container {\n display: flex;\n margin-left: auto;\n padding: var(--padding-default);\n }\n\n mwc-button {\n margin-left: var(--margin-default);\n }\n `\n ]\n\n @property({ type: Array }) addresses: 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\n render() {\n return html`\n <ox-grist\n .mode=${isMobileDevice() ? 'LIST' : 'GRID'}\n .config=${this.columns}\n .data=${\n { \n records: this.addresses \n }\n }\n ></ox-grist>\n\n <div class=\"button-container\">\n <mwc-button raised @click=\"${this.save.bind(this)}\">${i18next.t('button.save')}</mwc-button>\n </div>\n `\n }\n\n async save() {\n const response = await client.mutate({\n mutation: gql`\n mutation importAddresses($addresses: [AddressPatch!]!) {\n importAddresses(addresses: $addresses)\n }\n `,\n variables: { addresses: this.addresses }\n })\n\n if (response.errors?.length) return\n\n this.dispatchEvent(new CustomEvent('imported'))\n }\n}\n\n"]}