@things-factory/contact 9.1.19 → 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.
|
@@ -4,13 +4,7 @@ import { PageView } from '@operato/shell';
|
|
|
4
4
|
import { FetchOption } from '@operato/data-grist';
|
|
5
5
|
import '../components/contact-popup';
|
|
6
6
|
import { ContactImporter } from './contact-importer';
|
|
7
|
-
declare const ContactListPage_base: (new (...args: any[]) =>
|
|
8
|
-
_storeUnsubscribe: import("redux").Unsubscribe;
|
|
9
|
-
connectedCallback(): void;
|
|
10
|
-
disconnectedCallback(): void;
|
|
11
|
-
stateChanged(_state: unknown): void;
|
|
12
|
-
readonly isConnected: boolean;
|
|
13
|
-
}) & (new (...args: any[]) => import("lit").LitElement) & typeof PageView & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
|
|
7
|
+
declare const ContactListPage_base: (new (...args: any[]) => import("lit").LitElement) & typeof PageView & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
|
|
14
8
|
export declare class ContactListPage extends ContactListPage_base {
|
|
15
9
|
static styles: import("lit").CSSResult[];
|
|
16
10
|
static get scopedElements(): {
|
|
@@ -2,7 +2,7 @@ import { __decorate, __metadata } from "tslib";
|
|
|
2
2
|
import '@operato/data-grist';
|
|
3
3
|
import '@operato/context/ox-context-page-toolbar.js';
|
|
4
4
|
import { CommonGristStyles, CommonHeaderStyles, ScrollbarStyles } from '@operato/styles';
|
|
5
|
-
import { PageView
|
|
5
|
+
import { PageView } from '@operato/shell';
|
|
6
6
|
import { css, html } from 'lit';
|
|
7
7
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
8
8
|
import { ScopedElementsMixin } from '@open-wc/scoped-elements';
|
|
@@ -11,11 +11,10 @@ import { client } from '@operato/graphql';
|
|
|
11
11
|
import { i18next, localize } from '@operato/i18n';
|
|
12
12
|
import { notify, openPopup } from '@operato/layout';
|
|
13
13
|
import { isMobileDevice } from '@operato/utils';
|
|
14
|
-
import { connect } from 'pwa-helpers/connect-mixin';
|
|
15
14
|
import gql from 'graphql-tag';
|
|
16
15
|
import '../components/contact-popup';
|
|
17
16
|
import { ContactImporter } from './contact-importer';
|
|
18
|
-
let ContactListPage = class ContactListPage extends
|
|
17
|
+
let ContactListPage = class ContactListPage extends localize(i18next)(ScopedElementsMixin(PageView)) {
|
|
19
18
|
constructor() {
|
|
20
19
|
super(...arguments);
|
|
21
20
|
this.mode = isMobileDevice() ? 'CARD' : 'GRID';
|
|
@@ -25,8 +24,7 @@ let ContactListPage = class ContactListPage extends connect(store)(localize(i18n
|
|
|
25
24
|
CommonGristStyles,
|
|
26
25
|
CommonHeaderStyles,
|
|
27
26
|
css `
|
|
28
|
-
:host {
|
|
29
|
-
display: flex;
|
|
27
|
+
:host { display: flex;
|
|
30
28
|
|
|
31
29
|
width: 100%;
|
|
32
30
|
|
|
@@ -34,62 +32,49 @@ let ContactListPage = class ContactListPage extends connect(store)(localize(i18n
|
|
|
34
32
|
|
|
35
33
|
--grid-record-emphasized-background-color: #8b0000;
|
|
36
34
|
--grid-record-emphasized-color: #ff6b6b;
|
|
37
|
-
|
|
35
|
+
}
|
|
38
36
|
|
|
39
|
-
ox-grist {
|
|
40
|
-
overflow-y: auto;
|
|
37
|
+
ox-grist { overflow-y: auto;
|
|
41
38
|
flex: 1;
|
|
42
|
-
|
|
39
|
+
}
|
|
43
40
|
|
|
44
|
-
.header {
|
|
45
|
-
|
|
46
|
-
}
|
|
41
|
+
.header { grid-template-areas: 'filters actions';
|
|
42
|
+
}
|
|
47
43
|
`
|
|
48
44
|
]; }
|
|
49
45
|
static get scopedElements() {
|
|
50
|
-
return {
|
|
51
|
-
'contact-importer': ContactImporter
|
|
46
|
+
return { 'contact-importer': ContactImporter
|
|
52
47
|
};
|
|
53
48
|
}
|
|
54
49
|
get context() {
|
|
55
|
-
return {
|
|
56
|
-
|
|
57
|
-
search: {
|
|
58
|
-
handler: (search) => {
|
|
50
|
+
return { title: i18next.t('title.contact list'),
|
|
51
|
+
search: { handler: (search) => {
|
|
59
52
|
this.grist.searchText = search;
|
|
60
53
|
},
|
|
61
|
-
value: this.grist?.searchText || ''
|
|
62
|
-
|
|
63
|
-
filter: {
|
|
64
|
-
handler: () => {
|
|
54
|
+
value: this.grist?.searchText || '' },
|
|
55
|
+
filter: { handler: () => {
|
|
65
56
|
this.grist.toggleHeadroom();
|
|
66
57
|
}
|
|
67
58
|
},
|
|
68
59
|
help: 'contact/contact',
|
|
69
60
|
actions: [
|
|
70
|
-
{
|
|
71
|
-
icon: 'add',
|
|
61
|
+
{ icon: 'add',
|
|
72
62
|
title: i18next.t('button.add'),
|
|
73
63
|
action: this.onCreateContact.bind(this)
|
|
74
64
|
},
|
|
75
|
-
{
|
|
76
|
-
icon: 'delete',
|
|
65
|
+
{ icon: 'delete',
|
|
77
66
|
title: i18next.t('button.delete'),
|
|
78
67
|
action: this.onDeleteContact.bind(this),
|
|
79
|
-
emphasis: {
|
|
80
|
-
danger: true
|
|
68
|
+
emphasis: { danger: true
|
|
81
69
|
}
|
|
82
70
|
}
|
|
83
71
|
],
|
|
84
|
-
exportable: {
|
|
85
|
-
name: i18next.t('title.contact list'),
|
|
72
|
+
exportable: { name: i18next.t('title.contact list'),
|
|
86
73
|
data: this.exportHandler.bind(this)
|
|
87
74
|
},
|
|
88
|
-
importable: {
|
|
89
|
-
handler: this.importHandler.bind(this)
|
|
75
|
+
importable: { handler: this.importHandler.bind(this)
|
|
90
76
|
},
|
|
91
|
-
toolbar: false
|
|
92
|
-
};
|
|
77
|
+
toolbar: false };
|
|
93
78
|
}
|
|
94
79
|
render() {
|
|
95
80
|
const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID');
|
|
@@ -102,115 +87,93 @@ let ContactListPage = class ContactListPage extends connect(store)(localize(i18n
|
|
|
102
87
|
`;
|
|
103
88
|
}
|
|
104
89
|
async pageInitialized(lifecycle) {
|
|
105
|
-
this.gristConfig = {
|
|
106
|
-
|
|
107
|
-
list: {
|
|
108
|
-
thumbnail: 'profile',
|
|
90
|
+
this.gristConfig = { pagination: { pages: [100, 200, 500] },
|
|
91
|
+
list: { thumbnail: 'profile',
|
|
109
92
|
fields: ['name', 'company'],
|
|
110
93
|
details: ['email', 'updatedAt']
|
|
111
94
|
},
|
|
112
95
|
columns: [
|
|
113
96
|
{ type: 'gutter', gutterName: 'sequence' },
|
|
114
97
|
{ type: 'gutter', gutterName: 'row-selector', multiple: true },
|
|
115
|
-
{
|
|
116
|
-
type: 'image',
|
|
98
|
+
{ type: 'image',
|
|
117
99
|
name: 'profile',
|
|
118
100
|
header: i18next.t('button.edit-contact'),
|
|
119
101
|
width: 80,
|
|
120
|
-
record: {
|
|
121
|
-
align: 'center',
|
|
102
|
+
record: { align: 'center',
|
|
122
103
|
renderer: function (value, column, record, rowIndex, field) {
|
|
123
104
|
return html `<ox-pfp-view .profile=${record.profile} .name=${record.name || '+'}></ox-pfp-view>`;
|
|
124
105
|
}
|
|
125
106
|
}
|
|
126
107
|
},
|
|
127
|
-
{
|
|
128
|
-
type: 'string',
|
|
108
|
+
{ type: 'string',
|
|
129
109
|
name: 'name',
|
|
130
110
|
header: i18next.t('field.name'),
|
|
131
|
-
record: {
|
|
132
|
-
editable: false
|
|
111
|
+
record: { editable: false
|
|
133
112
|
},
|
|
134
113
|
filter: 'search',
|
|
135
114
|
sortable: true,
|
|
136
115
|
width: 100
|
|
137
116
|
},
|
|
138
|
-
{
|
|
139
|
-
type: 'string',
|
|
117
|
+
{ type: 'string',
|
|
140
118
|
name: 'company',
|
|
141
119
|
header: i18next.t('field.company'),
|
|
142
|
-
record: {
|
|
143
|
-
editable: false
|
|
120
|
+
record: { editable: false
|
|
144
121
|
},
|
|
145
122
|
filter: 'search',
|
|
146
123
|
sortable: true,
|
|
147
124
|
width: 135
|
|
148
125
|
},
|
|
149
|
-
{
|
|
150
|
-
type: 'string',
|
|
126
|
+
{ type: 'string',
|
|
151
127
|
name: 'department',
|
|
152
128
|
header: i18next.t('field.department'),
|
|
153
|
-
record: {
|
|
154
|
-
editable: false
|
|
129
|
+
record: { editable: false
|
|
155
130
|
},
|
|
156
131
|
sortable: false,
|
|
157
132
|
width: 135
|
|
158
133
|
},
|
|
159
|
-
{
|
|
160
|
-
type: 'string',
|
|
134
|
+
{ type: 'string',
|
|
161
135
|
name: 'email',
|
|
162
136
|
header: i18next.t('field.email'),
|
|
163
|
-
record: {
|
|
164
|
-
editable: false
|
|
137
|
+
record: { editable: false
|
|
165
138
|
},
|
|
166
139
|
sortable: false,
|
|
167
140
|
width: 190
|
|
168
141
|
},
|
|
169
|
-
{
|
|
170
|
-
type: 'string',
|
|
142
|
+
{ type: 'string',
|
|
171
143
|
name: 'phone',
|
|
172
144
|
header: i18next.t('field.phone'),
|
|
173
|
-
record: {
|
|
174
|
-
editable: false
|
|
145
|
+
record: { editable: false
|
|
175
146
|
},
|
|
176
147
|
sortable: false,
|
|
177
148
|
width: 120
|
|
178
149
|
},
|
|
179
|
-
{
|
|
180
|
-
type: 'string',
|
|
150
|
+
{ type: 'string',
|
|
181
151
|
name: 'address',
|
|
182
152
|
header: i18next.t('field.address'),
|
|
183
|
-
record: {
|
|
184
|
-
editable: false
|
|
153
|
+
record: { editable: false
|
|
185
154
|
},
|
|
186
155
|
sortable: false,
|
|
187
156
|
width: 390
|
|
188
157
|
},
|
|
189
|
-
{
|
|
190
|
-
type: 'resource-object',
|
|
158
|
+
{ type: 'resource-object',
|
|
191
159
|
name: 'updater',
|
|
192
160
|
header: i18next.t('field.updater'),
|
|
193
|
-
record: {
|
|
194
|
-
editable: false
|
|
161
|
+
record: { editable: false
|
|
195
162
|
},
|
|
196
163
|
sortable: false,
|
|
197
164
|
width: 90
|
|
198
165
|
},
|
|
199
|
-
{
|
|
200
|
-
type: 'datetime',
|
|
166
|
+
{ type: 'datetime',
|
|
201
167
|
name: 'updatedAt',
|
|
202
168
|
header: i18next.t('field.updated_at'),
|
|
203
|
-
record: {
|
|
204
|
-
editable: false
|
|
169
|
+
record: { editable: false
|
|
205
170
|
},
|
|
206
171
|
sortable: true,
|
|
207
172
|
width: 180
|
|
208
173
|
},
|
|
209
|
-
{
|
|
210
|
-
type: 'image',
|
|
174
|
+
{ type: 'image',
|
|
211
175
|
name: 'profile',
|
|
212
|
-
record: {
|
|
213
|
-
renderer: function (value, column, record, rowIndex, field) {
|
|
176
|
+
record: { renderer: function (value, column, record, rowIndex, field) {
|
|
214
177
|
return html `<ox-pfp-view
|
|
215
178
|
style="height:90%; width: unset; aspect-ratio: 1 / 1;"
|
|
216
179
|
.profile=${record.profile}
|
|
@@ -221,39 +184,29 @@ let ContactListPage = class ContactListPage extends connect(store)(localize(i18n
|
|
|
221
184
|
hidden: true
|
|
222
185
|
}
|
|
223
186
|
],
|
|
224
|
-
rows: {
|
|
225
|
-
handlers: {
|
|
226
|
-
click: (columns, data, column, record, rowIndex, target) => {
|
|
187
|
+
rows: { handlers: { click: (columns, data, column, record, rowIndex, target) => {
|
|
227
188
|
this.openContactPopup(record);
|
|
228
189
|
}
|
|
229
190
|
},
|
|
230
191
|
appendable: false,
|
|
231
|
-
selectable: {
|
|
232
|
-
multiple: true
|
|
192
|
+
selectable: { multiple: true
|
|
233
193
|
}
|
|
234
194
|
},
|
|
235
195
|
sorters: [
|
|
236
|
-
{
|
|
237
|
-
name: 'company'
|
|
196
|
+
{ name: 'company'
|
|
238
197
|
},
|
|
239
|
-
{
|
|
240
|
-
name: 'name'
|
|
198
|
+
{ name: 'name'
|
|
241
199
|
}
|
|
242
200
|
]
|
|
243
201
|
};
|
|
244
202
|
}
|
|
245
203
|
async pageUpdated(changes, lifecycle) {
|
|
246
|
-
if (this.active) {
|
|
247
|
-
// do something here when this page just became as active
|
|
204
|
+
if (this.active) { // do something here when this page just became as active
|
|
248
205
|
}
|
|
249
206
|
}
|
|
250
207
|
async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
|
|
251
|
-
const response = await client.query({
|
|
252
|
-
|
|
253
|
-
query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
|
|
254
|
-
responses: contacts(filters: $filters, pagination: $pagination, sortings: $sortings) {
|
|
255
|
-
items {
|
|
256
|
-
id
|
|
208
|
+
const response = await client.query({ query: gql `
|
|
209
|
+
query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) { responses: contacts(filters: $filters, pagination: $pagination, sortings: $sortings) { items { id
|
|
257
210
|
name
|
|
258
211
|
company
|
|
259
212
|
email
|
|
@@ -261,30 +214,26 @@ let ContactListPage = class ContactListPage extends connect(store)(localize(i18n
|
|
|
261
214
|
address
|
|
262
215
|
department
|
|
263
216
|
note
|
|
264
|
-
profile {
|
|
265
|
-
left
|
|
217
|
+
profile { left
|
|
266
218
|
top
|
|
267
219
|
zoom
|
|
268
220
|
picture
|
|
269
|
-
|
|
270
|
-
updater {
|
|
271
|
-
id
|
|
221
|
+
}
|
|
222
|
+
updater { id
|
|
272
223
|
name
|
|
273
|
-
|
|
224
|
+
}
|
|
274
225
|
updatedAt
|
|
275
|
-
|
|
226
|
+
}
|
|
276
227
|
total
|
|
277
|
-
|
|
278
|
-
|
|
228
|
+
}
|
|
229
|
+
}
|
|
279
230
|
`,
|
|
280
|
-
variables: {
|
|
281
|
-
filters,
|
|
231
|
+
variables: { filters,
|
|
282
232
|
pagination: { page, limit },
|
|
283
233
|
sortings
|
|
284
234
|
}
|
|
285
235
|
});
|
|
286
|
-
return {
|
|
287
|
-
total: response.data.responses.total || 0,
|
|
236
|
+
return { total: response.data.responses.total || 0,
|
|
288
237
|
records: response.data.responses.items || []
|
|
289
238
|
};
|
|
290
239
|
}
|
|
@@ -292,20 +241,16 @@ let ContactListPage = class ContactListPage extends connect(store)(localize(i18n
|
|
|
292
241
|
if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {
|
|
293
242
|
const ids = this.grist.selected.map(record => record.id);
|
|
294
243
|
if (ids && ids.length > 0) {
|
|
295
|
-
const response = await client.mutate({
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
deleteContacts(ids: $ids)
|
|
299
|
-
}
|
|
244
|
+
const response = await client.mutate({ mutation: gql `
|
|
245
|
+
mutation ($ids: [String!]!) { deleteContacts(ids: $ids)
|
|
246
|
+
}
|
|
300
247
|
`,
|
|
301
|
-
variables: {
|
|
302
|
-
ids
|
|
248
|
+
variables: { ids
|
|
303
249
|
}
|
|
304
250
|
});
|
|
305
251
|
if (!response.errors) {
|
|
306
252
|
this.grist.fetch();
|
|
307
|
-
notify({
|
|
308
|
-
message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
|
|
253
|
+
notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
|
|
309
254
|
});
|
|
310
255
|
}
|
|
311
256
|
}
|
|
@@ -323,29 +268,23 @@ let ContactListPage = class ContactListPage extends connect(store)(localize(i18n
|
|
|
323
268
|
patchField.cuFlag = patch.__dirty__;
|
|
324
269
|
return patchField;
|
|
325
270
|
});
|
|
326
|
-
const response = await client.mutate({
|
|
327
|
-
|
|
328
|
-
mutation ($patches: [ContactPatch!]!) {
|
|
329
|
-
updateMultipleContact(patches: $patches) {
|
|
330
|
-
name
|
|
271
|
+
const response = await client.mutate({ mutation: gql `
|
|
272
|
+
mutation ($patches: [ContactPatch!]!) { updateMultipleContact(patches: $patches) { name
|
|
331
273
|
company
|
|
332
274
|
email
|
|
333
|
-
profile {
|
|
334
|
-
left
|
|
275
|
+
profile { left
|
|
335
276
|
top
|
|
336
277
|
zoom
|
|
337
278
|
picture
|
|
338
|
-
|
|
339
|
-
updater {
|
|
340
|
-
id
|
|
279
|
+
}
|
|
280
|
+
updater { id
|
|
341
281
|
name
|
|
342
|
-
|
|
282
|
+
}
|
|
343
283
|
updatedAt
|
|
344
|
-
|
|
345
|
-
|
|
284
|
+
}
|
|
285
|
+
}
|
|
346
286
|
`,
|
|
347
|
-
variables: {
|
|
348
|
-
patches
|
|
287
|
+
variables: { patches
|
|
349
288
|
}
|
|
350
289
|
});
|
|
351
290
|
if (!response.errors) {
|
|
@@ -373,8 +312,7 @@ let ContactListPage = class ContactListPage extends connect(store)(localize(i18n
|
|
|
373
312
|
this.grist.fetch();
|
|
374
313
|
}}
|
|
375
314
|
></contact-importer>
|
|
376
|
-
`, {
|
|
377
|
-
backdrop: true,
|
|
315
|
+
`, { backdrop: true,
|
|
378
316
|
size: 'large',
|
|
379
317
|
title: i18next.t('title.import contact')
|
|
380
318
|
});
|
|
@@ -383,8 +321,7 @@ let ContactListPage = class ContactListPage extends connect(store)(localize(i18n
|
|
|
383
321
|
};
|
|
384
322
|
}
|
|
385
323
|
async openContactPopup(record) {
|
|
386
|
-
const popup = openPopup(html ` <contact-popup .contactId=${record.id}></contact-popup> `, {
|
|
387
|
-
backdrop: true,
|
|
324
|
+
const popup = openPopup(html ` <contact-popup .contactId=${record.id}></contact-popup> `, { backdrop: true,
|
|
388
325
|
size: 'large',
|
|
389
326
|
title: i18next.t('title.contact')
|
|
390
327
|
});
|
|
@@ -393,8 +330,7 @@ let ContactListPage = class ContactListPage extends connect(store)(localize(i18n
|
|
|
393
330
|
};
|
|
394
331
|
}
|
|
395
332
|
async onCreateContact() {
|
|
396
|
-
const popup = openPopup(html ` <contact-popup edit-mode></contact-popup> `, {
|
|
397
|
-
backdrop: true,
|
|
333
|
+
const popup = openPopup(html ` <contact-popup edit-mode></contact-popup> `, { backdrop: true,
|
|
398
334
|
size: 'large',
|
|
399
335
|
title: i18next.t('title.contact')
|
|
400
336
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contact-list-page.js","sourceRoot":"","sources":["../../client/pages/contact-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAC5B,OAAO,6CAA6C,CAAA;AAEpD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACxF,OAAO,EA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,SAAS,CAAC,IAAI,CAAA,6CAA6C,EAAE;YACzE,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;SAClC,CAAC,CAAA;QACF,KAAK,CAAC,QAAQ,GAAG,GAAG,EAAE;YACpB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC,CAAA;IACH,CAAC;;AAzX2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAiB;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CAAoE;AAEpE;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;8CAAA;AArCjC,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CA4Z3B","sourcesContent":["import '@operato/data-grist'\nimport '@operato/context/ox-context-page-toolbar.js'\n\nimport { CommonGristStyles, CommonHeaderStyles, 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 { DataGrist, FetchOption } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { isMobileDevice } from '@operato/utils'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport gql from 'graphql-tag'\n\nimport '../components/contact-popup'\nimport { ContactImporter } from './contact-importer'\n\n@customElement('contact-list-page')\nexport class ContactListPage 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 --ox-pfp-size: 40px;\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 .header {\n grid-template-areas: 'filters actions';\n }\n `\n ]\n\n static get scopedElements() {\n return {\n 'contact-importer': ContactImporter\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.contact 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: 'contact/contact',\n actions: [\n {\n icon: 'add',\n title: i18next.t('button.add'),\n action: this.onCreateContact.bind(this)\n },\n {\n icon: 'delete',\n title: i18next.t('button.delete'),\n action: this.onDeleteContact.bind(this),\n emphasis: {\n danger: true\n }\n }\n ],\n exportable: {\n name: i18next.t('title.contact list'),\n data: this.exportHandler.bind(this)\n },\n importable: {\n handler: this.importHandler.bind(this)\n },\n toolbar: false\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 <ox-context-page-toolbar class=\"actions\" .context=${this.context}></ox-context-page-toolbar>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) {\n this.gristConfig = {\n pagination: { pages: [100, 200, 500] },\n list: {\n thumbnail: 'profile',\n fields: ['name', 'company'],\n details: ['email', 'updatedAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n {\n type: 'image',\n name: 'profile',\n header: i18next.t('button.edit-contact'),\n width: 80,\n record: {\n align: 'center',\n renderer: function (value, column, record, rowIndex, field) {\n return html`<ox-pfp-view .profile=${record.profile} .name=${record.name || '+'}></ox-pfp-view>`\n }\n }\n },\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: {\n editable: false\n },\n filter: 'search',\n sortable: true,\n width: 100\n },\n {\n type: 'string',\n name: 'company',\n header: i18next.t('field.company'),\n record: {\n editable: false\n },\n filter: 'search',\n sortable: true,\n width: 135\n },\n {\n type: 'string',\n name: 'department',\n header: i18next.t('field.department'),\n record: {\n editable: false\n },\n sortable: false,\n width: 135\n },\n {\n type: 'string',\n name: 'email',\n header: i18next.t('field.email'),\n record: {\n editable: false\n },\n sortable: false,\n width: 190\n },\n {\n type: 'string',\n name: 'phone',\n header: i18next.t('field.phone'),\n record: {\n editable: false\n },\n sortable: false,\n width: 120\n },\n {\n type: 'string',\n name: 'address',\n header: i18next.t('field.address'),\n record: {\n editable: false\n },\n sortable: false,\n width: 390\n },\n {\n type: 'resource-object',\n name: 'updater',\n header: i18next.t('field.updater'),\n record: {\n editable: false\n },\n sortable: false,\n width: 90\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 type: 'image',\n name: 'profile',\n record: {\n renderer: function (value, column, record, rowIndex, field) {\n return html`<ox-pfp-view\n style=\"height:90%; width: unset; aspect-ratio: 1 / 1;\"\n .profile=${record.profile}\n .name=${record.name}\n ></ox-pfp-view>`\n }\n },\n hidden: true\n }\n ],\n rows: {\n handlers: {\n click: (columns, data, column, record, rowIndex, target) => {\n this.openContactPopup(record)\n }\n },\n appendable: false,\n selectable: {\n multiple: true\n }\n },\n sorters: [\n {\n name: 'company'\n },\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: contacts(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n company\n email\n phone\n address\n department\n note\n profile {\n left\n top\n zoom\n picture\n }\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 onDeleteContact() {\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 deleteContacts(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 _updateContact() {\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: [ContactPatch!]!) {\n updateMultipleContact(patches: $patches) {\n name\n company\n email\n profile {\n left\n top\n zoom\n picture\n }\n updater {\n id\n name\n }\n updatedAt\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(['id', 'name', 'company', 'email', 'phone', 'address', 'note'])\n\n return exportTargets.map(contact => {\n let tempObj = {}\n for (const field of targetFieldSet) {\n tempObj[field] = contact[field]\n }\n\n return tempObj\n })\n }\n\n async importHandler(records) {\n const popup = openPopup(\n html`\n <contact-importer\n .contacts=${records}\n @imported=${() => {\n history.back()\n this.grist.fetch()\n }}\n ></contact-importer>\n `,\n {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.import contact')\n }\n )\n\n popup.onclosed = () => {\n this.grist.fetch()\n }\n }\n\n async openContactPopup(record: any) {\n const popup = openPopup(html` <contact-popup .contactId=${record.id}></contact-popup> `, {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.contact')\n })\n popup.onclosed = () => {\n this.grist.fetch()\n }\n }\n\n async onCreateContact() {\n const popup = openPopup(html` <contact-popup edit-mode></contact-popup> `, {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.contact')\n })\n popup.onclosed = () => {\n this.grist.fetch()\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"contact-list-page.js","sourceRoot":"","sources":["../../client/pages/contact-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAC5B,OAAO,6CAA6C,CAAA;AAEpD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACxF,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,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,6BAA6B,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,MA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Styles, CommonHeaderStyles, 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 { DataGrist, FetchOption } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { isMobileDevice } from '@operato/utils'\n\nimport gql from 'graphql-tag'\n\nimport '../components/contact-popup'\nimport { ContactImporter } from './contact-importer'\n\n@customElement('contact-list-page')\nexport class ContactListPage 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 --ox-pfp-size: 40px;\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 .header { grid-template-areas: 'filters actions';\n }\n `\n ]\n\n static get scopedElements() { return { 'contact-importer': ContactImporter\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.contact 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: 'contact/contact',\n actions: [\n { icon: 'add',\n title: i18next.t('button.add'),\n action: this.onCreateContact.bind(this)\n },\n { icon: 'delete',\n title: i18next.t('button.delete'),\n action: this.onDeleteContact.bind(this),\n emphasis: { danger: true\n }\n }\n ],\n exportable: { name: i18next.t('title.contact list'),\n data: this.exportHandler.bind(this)\n },\n importable: { handler: this.importHandler.bind(this)\n },\n toolbar: false\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 <ox-context-page-toolbar class=\"actions\" .context=${this.context}></ox-context-page-toolbar>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) { this.gristConfig = { pagination: { pages: [100, 200, 500] },\n list: { thumbnail: 'profile',\n fields: ['name', 'company'],\n details: ['email', 'updatedAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n { type: 'image',\n name: 'profile',\n header: i18next.t('button.edit-contact'),\n width: 80,\n record: { align: 'center',\n renderer: function (value, column, record, rowIndex, field) { return html`<ox-pfp-view .profile=${record.profile} .name=${record.name || '+'}></ox-pfp-view>`\n }\n }\n },\n { type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: { editable: false\n },\n filter: 'search',\n sortable: true,\n width: 100\n },\n { type: 'string',\n name: 'company',\n header: i18next.t('field.company'),\n record: { editable: false\n },\n filter: 'search',\n sortable: true,\n width: 135\n },\n { type: 'string',\n name: 'department',\n header: i18next.t('field.department'),\n record: { editable: false\n },\n sortable: false,\n width: 135\n },\n { type: 'string',\n name: 'email',\n header: i18next.t('field.email'),\n record: { editable: false\n },\n sortable: false,\n width: 190\n },\n { type: 'string',\n name: 'phone',\n header: i18next.t('field.phone'),\n record: { editable: false\n },\n sortable: false,\n width: 120\n },\n { type: 'string',\n name: 'address',\n header: i18next.t('field.address'),\n record: { editable: false\n },\n sortable: false,\n width: 390\n },\n { type: 'resource-object',\n name: 'updater',\n header: i18next.t('field.updater'),\n record: { editable: false\n },\n sortable: false,\n width: 90\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 { type: 'image',\n name: 'profile',\n record: { renderer: function (value, column, record, rowIndex, field) { return html`<ox-pfp-view\n style=\"height:90%; width: unset; aspect-ratio: 1 / 1;\"\n .profile=${record.profile}\n .name=${record.name}\n ></ox-pfp-view>`\n }\n },\n hidden: true\n }\n ],\n rows: { handlers: { click: (columns, data, column, record, rowIndex, target) => { this.openContactPopup(record)\n }\n },\n appendable: false,\n selectable: { multiple: true\n }\n },\n sorters: [\n { name: 'company'\n },\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: contacts(filters: $filters, pagination: $pagination, sortings: $sortings) { items { id\n name\n company\n email\n phone\n address\n department\n note\n profile { left\n top\n zoom\n picture\n }\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 onDeleteContact() { if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) { 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!]!) { deleteContacts(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 _updateContact() { 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: [ContactPatch!]!) { updateMultipleContact(patches: $patches) { name\n company\n email\n profile { left\n top\n zoom\n picture\n }\n updater { id\n name\n }\n updatedAt\n }\n }\n `,\n variables: { patches\n }\n })\n\n if (!response.errors) { this.grist.fetch()\n }\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', 'company', 'email', 'phone', 'address', 'note'])\n\n return exportTargets.map(contact => { let tempObj = {}\n for (const field of targetFieldSet) { tempObj[field] = contact[field]\n }\n\n return tempObj\n })\n }\n\n async importHandler(records) { const popup = openPopup(\n html`\n <contact-importer\n .contacts=${records}\n @imported=${() => { history.back()\n this.grist.fetch()\n }}\n ></contact-importer>\n `,\n { backdrop: true,\n size: 'large',\n title: i18next.t('title.import contact')\n }\n )\n\n popup.onclosed = () => { this.grist.fetch()\n }\n }\n\n async openContactPopup(record: any) { const popup = openPopup(html` <contact-popup .contactId=${record.id}></contact-popup> `, { backdrop: true,\n size: 'large',\n title: i18next.t('title.contact')\n })\n popup.onclosed = () => { this.grist.fetch()\n }\n }\n\n async onCreateContact() { const popup = openPopup(html` <contact-popup edit-mode></contact-popup> `, { backdrop: true,\n size: 'large',\n title: i18next.t('title.contact')\n })\n popup.onclosed = () => { this.grist.fetch()\n }\n }\n}\n"]}
|