@things-factory/notification 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.
- package/dist-client/bootstrap.js +2 -2
- package/dist-client/bootstrap.js.map +1 -1
- package/dist-client/pages/notification/notification-list-page.d.ts +1 -7
- package/dist-client/pages/notification/notification-list-page.js +44 -83
- package/dist-client/pages/notification/notification-list-page.js.map +1 -1
- package/dist-client/pages/notification-rule/notification-rule-list-page.d.ts +1 -7
- package/dist-client/pages/notification-rule/notification-rule-list-page.js +63 -120
- package/dist-client/pages/notification-rule/notification-rule-list-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/viewparts/notification-badge.d.ts +5 -10
- package/dist-client/viewparts/notification-badge.js +13 -4
- package/dist-client/viewparts/notification-badge.js.map +1 -1
- package/dist-client/viewparts/notification-list.d.ts +4 -8
- package/dist-client/viewparts/notification-list.js +10 -4
- package/dist-client/viewparts/notification-list.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
package/dist-client/bootstrap.js
CHANGED
|
@@ -2,7 +2,7 @@ import gql from 'graphql-tag';
|
|
|
2
2
|
import { notify } from '@operato/layout';
|
|
3
3
|
import { auth } from '@things-factory/auth-base/dist-client/auth.js';
|
|
4
4
|
import { i18next } from '@operato/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import { navigate, notificationStore, store } from '@operato/shell';
|
|
6
6
|
import { subscribe as graphqlSubscribe } from '@operato/graphql';
|
|
7
7
|
import { subscribe, unsubscribe, UPDATE_NOTIFICATION } from './actions/notification-fcm';
|
|
8
8
|
import notification from './reducers/notification';
|
|
@@ -78,7 +78,7 @@ export default async function bootstrap() {
|
|
|
78
78
|
case 'notificationclick':
|
|
79
79
|
const { action, notification } = data;
|
|
80
80
|
// TODO how to follow action with notification.data
|
|
81
|
-
notification.url &&
|
|
81
|
+
notification.url && navigate(notification.url);
|
|
82
82
|
break;
|
|
83
83
|
case 'show-reload-snackbar':
|
|
84
84
|
notify({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../client/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,+CAA+C,CAAA;AAEpE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../client/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,+CAA+C,CAAA;AAEpE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEhE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AACxF,OAAO,YAAY,MAAM,yBAAyB,CAAA;AAElD,IAAI,mBAAwB,CAAA;AAE5B,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,SAAS;IACrC,yBAAyB;IACzB,KAAK,CAAC,WAAW,CAAC,EAAE,YAAY,EAAE,CAAC,CAAA;IAEnC,KAAK,UAAU,cAAc,CAAC,YAAkB;QAC9C,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAC,QAAQ,EAAC,EAAE;YAC/B,IAAI,YAAY,EAAE,CAAC;gBACjB,MAAM,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;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,EAAE,CAAC;YACtB,cAAc,CAAC;gBACb,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;gBACrB,IAAI,EAAE,OAAO;gBACb,KAAK;gBACL,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO;aAChC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,cAAc,EAAE,CAAA;AACxB,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { notify } from '@operato/layout'\nimport { auth } from '@things-factory/auth-base/dist-client/auth.js'\n\nimport { i18next } from '@operato/i18n'\nimport { navigate, notificationStore, store } from '@operato/shell'\nimport { subscribe as graphqlSubscribe } from '@operato/graphql'\n\nimport { subscribe, unsubscribe, UPDATE_NOTIFICATION } from './actions/notification-fcm'\nimport notification from './reducers/notification'\n\nvar graphqlSubscription: any\n\nexport default async function bootstrap() {\n /* initialize reducers */\n store.addReducers({ notification })\n\n async function onnotification(notification?: any) {\n store.dispatch((async dispatch => {\n if (notification) {\n await notificationStore.add(notification)\n await notificationStore.limit()\n }\n\n const history = await notificationStore.getAll()\n\n dispatch({\n type: UPDATE_NOTIFICATION,\n history: [...history]\n })\n }) as any)\n }\n\n auth.on('presignout', async () => {\n try {\n await unsubscribe()\n /* await */ notificationStore.clear()\n } catch (err) {\n console.warn(err)\n }\n })\n\n auth.on('profile', async ({ credential }) => {\n try {\n await subscribe()\n } catch (err) {\n console.warn(err)\n }\n\n /*\n * subscription graphql notifications\n */\n var query = gql`\n subscription notification($subjects: [String!]) {\n notification(subjects: $subjects) {\n subject\n type\n title\n body\n url\n image\n timestamp\n }\n }\n `\n\n graphqlSubscription = await graphqlSubscribe(\n {\n query,\n variables: {\n subjects: ['info', 'warn', 'error', 'reload']\n }\n },\n {\n next({ data }) {\n const { notification } = data || {}\n onnotification({\n timestamp: Date.now(),\n ...notification\n })\n }\n }\n )\n })\n\n /* subscription web-push notification */\n const channel = new BroadcastChannel('notification')\n channel.addEventListener('message', async ({ data }) => {\n const { type } = data || {}\n\n switch (type) {\n case 'notificationclick':\n const { action, notification } = data\n\n // TODO how to follow action with notification.data\n notification.url && navigate(notification.url)\n break\n\n case 'show-reload-snackbar':\n notify({\n level: 'info',\n message: i18next.t('text.the application has been updated'),\n option: {\n action: {\n label: i18next.t('button.reload'),\n callback: () => window.location.reload()\n },\n timer: -1\n }\n })\n break\n\n case 'notification':\n default:\n onnotification()\n }\n })\n\n document.addEventListener('notify', (event: Event) => {\n let { message, level, ex = '', option = {} } = (event as CustomEvent).detail\n const title = message.split(' .\\n')[0]\n\n if (level === 'error') {\n onnotification({\n timestamp: Date.now(),\n type: 'ERROR',\n title,\n body: ex ? ex.message : message\n })\n }\n })\n\n await onnotification()\n}\n"]}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import '@operato/data-grist';
|
|
2
2
|
import { PageView } from '@operato/shell';
|
|
3
3
|
import { FetchOption } from '@operato/data-grist';
|
|
4
|
-
declare const NotificationListPage_base: (new (...args: any[]) =>
|
|
5
|
-
_storeUnsubscribe: import("redux").Unsubscribe;
|
|
6
|
-
connectedCallback(): void;
|
|
7
|
-
disconnectedCallback(): void;
|
|
8
|
-
stateChanged(_state: unknown): void;
|
|
9
|
-
readonly isConnected: boolean;
|
|
10
|
-
}) & (new (...args: any[]) => import("lit").LitElement) & typeof PageView & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
|
|
4
|
+
declare const NotificationListPage_base: (new (...args: any[]) => import("lit").LitElement) & typeof PageView & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
|
|
11
5
|
export declare class NotificationListPage extends NotificationListPage_base {
|
|
12
6
|
static styles: import("lit").CSSResult[];
|
|
13
7
|
gristConfig: any;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import '@operato/data-grist';
|
|
3
3
|
import { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles';
|
|
4
|
-
import { PageView
|
|
4
|
+
import { PageView } from '@operato/shell';
|
|
5
5
|
import { css, html } from 'lit';
|
|
6
6
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
7
7
|
import { ScopedElementsMixin } from '@open-wc/scoped-elements';
|
|
@@ -10,9 +10,8 @@ import { client } from '@operato/graphql';
|
|
|
10
10
|
import { i18next, localize } from '@operato/i18n';
|
|
11
11
|
import { notify } from '@operato/layout';
|
|
12
12
|
import { isMobileDevice } from '@operato/utils';
|
|
13
|
-
import { connect } from 'pwa-helpers/connect-mixin';
|
|
14
13
|
import gql from 'graphql-tag';
|
|
15
|
-
let NotificationListPage = class NotificationListPage extends
|
|
14
|
+
let NotificationListPage = class NotificationListPage extends localize(i18next)(ScopedElementsMixin(PageView)) {
|
|
16
15
|
constructor() {
|
|
17
16
|
super(...arguments);
|
|
18
17
|
this.mode = isMobileDevice() ? 'CARD' : 'GRID';
|
|
@@ -22,53 +21,43 @@ let NotificationListPage = class NotificationListPage extends connect(store)(loc
|
|
|
22
21
|
CommonGristStyles,
|
|
23
22
|
CommonHeaderStyles,
|
|
24
23
|
css `
|
|
25
|
-
:host {
|
|
26
|
-
display: flex;
|
|
24
|
+
:host { display: flex;
|
|
27
25
|
|
|
28
26
|
width: 100%;
|
|
29
27
|
|
|
30
28
|
--grid-record-emphasized-background-color: #8b0000;
|
|
31
29
|
--grid-record-emphasized-color: #ff6b6b;
|
|
32
|
-
|
|
30
|
+
}
|
|
33
31
|
|
|
34
|
-
ox-grist {
|
|
35
|
-
overflow-y: auto;
|
|
32
|
+
ox-grist { overflow-y: auto;
|
|
36
33
|
flex: 1;
|
|
37
|
-
|
|
34
|
+
}
|
|
38
35
|
|
|
39
|
-
ox-filters-form {
|
|
40
|
-
|
|
41
|
-
}
|
|
36
|
+
ox-filters-form { flex: 1;
|
|
37
|
+
}
|
|
42
38
|
`
|
|
43
39
|
]; }
|
|
44
40
|
get context() {
|
|
45
|
-
return {
|
|
46
|
-
|
|
47
|
-
search: {
|
|
48
|
-
handler: (search) => {
|
|
41
|
+
return { title: i18next.t('title.notification list'),
|
|
42
|
+
search: { handler: (search) => {
|
|
49
43
|
this.grist.searchText = search;
|
|
50
44
|
},
|
|
51
|
-
value: this.grist?.searchText || ''
|
|
52
|
-
|
|
53
|
-
filter: {
|
|
54
|
-
handler: () => {
|
|
45
|
+
value: this.grist?.searchText || '' },
|
|
46
|
+
filter: { handler: () => {
|
|
55
47
|
this.grist.toggleHeadroom();
|
|
56
48
|
}
|
|
57
49
|
},
|
|
58
50
|
help: 'notification/notification',
|
|
59
51
|
actions: [
|
|
60
|
-
{
|
|
61
|
-
title: i18next.t('button.save'),
|
|
52
|
+
{ title: i18next.t('button.save'),
|
|
62
53
|
action: this._updateNotification.bind(this),
|
|
63
54
|
...CommonButtonStyles.save
|
|
64
55
|
},
|
|
65
|
-
{
|
|
66
|
-
title: i18next.t('button.delete'),
|
|
56
|
+
{ title: i18next.t('button.delete'),
|
|
67
57
|
action: this._deleteNotification.bind(this),
|
|
68
58
|
...CommonButtonStyles.delete
|
|
69
59
|
}
|
|
70
|
-
]
|
|
71
|
-
};
|
|
60
|
+
] };
|
|
72
61
|
}
|
|
73
62
|
render() {
|
|
74
63
|
const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID');
|
|
@@ -89,100 +78,80 @@ let NotificationListPage = class NotificationListPage extends connect(store)(loc
|
|
|
89
78
|
`;
|
|
90
79
|
}
|
|
91
80
|
async pageInitialized(lifecycle) {
|
|
92
|
-
this.gristConfig = {
|
|
93
|
-
list: {
|
|
94
|
-
fields: ['title', 'body'],
|
|
81
|
+
this.gristConfig = { list: { fields: ['title', 'body'],
|
|
95
82
|
details: ['state', 'updatedAt']
|
|
96
83
|
},
|
|
97
84
|
columns: [
|
|
98
85
|
{ type: 'gutter', gutterName: 'sequence' },
|
|
99
86
|
{ type: 'gutter', gutterName: 'row-selector', multiple: true },
|
|
100
|
-
{
|
|
101
|
-
type: 'string',
|
|
87
|
+
{ type: 'string',
|
|
102
88
|
name: 'title',
|
|
103
89
|
header: i18next.t('field.title'),
|
|
104
|
-
record: {
|
|
105
|
-
editable: false
|
|
90
|
+
record: { editable: false
|
|
106
91
|
},
|
|
107
92
|
filter: 'search',
|
|
108
93
|
sortable: true,
|
|
109
94
|
width: 150
|
|
110
95
|
},
|
|
111
|
-
{
|
|
112
|
-
type: 'string',
|
|
96
|
+
{ type: 'string',
|
|
113
97
|
name: 'body',
|
|
114
98
|
header: i18next.t('field.body'),
|
|
115
|
-
record: {
|
|
116
|
-
editable: false
|
|
99
|
+
record: { editable: false
|
|
117
100
|
},
|
|
118
101
|
filter: 'search',
|
|
119
102
|
width: 200
|
|
120
103
|
},
|
|
121
|
-
{
|
|
122
|
-
type: 'checkbox',
|
|
104
|
+
{ type: 'checkbox',
|
|
123
105
|
name: 'state',
|
|
124
106
|
label: true,
|
|
125
107
|
header: i18next.t('field.state'),
|
|
126
|
-
record: {
|
|
127
|
-
editable: true
|
|
108
|
+
record: { editable: true
|
|
128
109
|
},
|
|
129
110
|
filter: true,
|
|
130
111
|
sortable: true,
|
|
131
112
|
width: 60
|
|
132
113
|
},
|
|
133
|
-
{
|
|
134
|
-
type: 'datetime',
|
|
114
|
+
{ type: 'datetime',
|
|
135
115
|
name: 'createdAt',
|
|
136
116
|
header: i18next.t('field.created_at'),
|
|
137
|
-
record: {
|
|
138
|
-
editable: false
|
|
117
|
+
record: { editable: false
|
|
139
118
|
},
|
|
140
119
|
sortable: true,
|
|
141
120
|
width: 180
|
|
142
121
|
}
|
|
143
122
|
],
|
|
144
|
-
rows: {
|
|
145
|
-
selectable: {
|
|
146
|
-
multiple: true
|
|
123
|
+
rows: { selectable: { multiple: true
|
|
147
124
|
}
|
|
148
125
|
},
|
|
149
126
|
sorters: [
|
|
150
|
-
{
|
|
151
|
-
name: 'createdAt',
|
|
127
|
+
{ name: 'createdAt',
|
|
152
128
|
desc: true
|
|
153
129
|
}
|
|
154
130
|
]
|
|
155
131
|
};
|
|
156
132
|
}
|
|
157
133
|
async pageUpdated(changes, lifecycle) {
|
|
158
|
-
if (this.active) {
|
|
159
|
-
// do something here when this page just became as active
|
|
134
|
+
if (this.active) { // do something here when this page just became as active
|
|
160
135
|
}
|
|
161
136
|
}
|
|
162
137
|
async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
|
|
163
|
-
const response = await client.query({
|
|
164
|
-
|
|
165
|
-
query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
|
|
166
|
-
responses: notiBoxes(filters: $filters, pagination: $pagination, sortings: $sortings) {
|
|
167
|
-
items {
|
|
168
|
-
id
|
|
138
|
+
const response = await client.query({ query: gql `
|
|
139
|
+
query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) { responses: notiBoxes(filters: $filters, pagination: $pagination, sortings: $sortings) { items { id
|
|
169
140
|
title
|
|
170
141
|
body
|
|
171
142
|
state
|
|
172
143
|
createdAt
|
|
173
|
-
|
|
144
|
+
}
|
|
174
145
|
total
|
|
175
|
-
|
|
176
|
-
|
|
146
|
+
}
|
|
147
|
+
}
|
|
177
148
|
`,
|
|
178
|
-
variables: {
|
|
179
|
-
filters,
|
|
149
|
+
variables: { filters,
|
|
180
150
|
pagination: { page, limit },
|
|
181
151
|
sortings
|
|
182
152
|
}
|
|
183
153
|
});
|
|
184
|
-
return {
|
|
185
|
-
total: response.data.responses.total || 0,
|
|
154
|
+
return { total: response.data.responses.total || 0,
|
|
186
155
|
records: response.data.responses.items || []
|
|
187
156
|
};
|
|
188
157
|
}
|
|
@@ -190,20 +159,16 @@ let NotificationListPage = class NotificationListPage extends connect(store)(loc
|
|
|
190
159
|
if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {
|
|
191
160
|
const ids = this.grist.selected.map(record => record.id);
|
|
192
161
|
if (ids && ids.length > 0) {
|
|
193
|
-
const response = await client.mutate({
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
deleteNotificationes(ids: $ids)
|
|
197
|
-
}
|
|
162
|
+
const response = await client.mutate({ mutation: gql `
|
|
163
|
+
mutation ($ids: [String!]!) { deleteNotificationes(ids: $ids)
|
|
164
|
+
}
|
|
198
165
|
`,
|
|
199
|
-
variables: {
|
|
200
|
-
ids
|
|
166
|
+
variables: { ids
|
|
201
167
|
}
|
|
202
168
|
});
|
|
203
169
|
if (!response.errors) {
|
|
204
170
|
this.grist.fetch();
|
|
205
|
-
notify({
|
|
206
|
-
message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
|
|
171
|
+
notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
|
|
207
172
|
});
|
|
208
173
|
}
|
|
209
174
|
}
|
|
@@ -221,16 +186,12 @@ let NotificationListPage = class NotificationListPage extends connect(store)(loc
|
|
|
221
186
|
patchField.cuFlag = patch.__dirty__;
|
|
222
187
|
return patchField;
|
|
223
188
|
});
|
|
224
|
-
const response = await client.mutate({
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
name
|
|
229
|
-
}
|
|
230
|
-
}
|
|
189
|
+
const response = await client.mutate({ mutation: gql `
|
|
190
|
+
mutation ($patches: [NotificationPatch!]!) { updateMultipleNotification(patches: $patches) { name
|
|
191
|
+
}
|
|
192
|
+
}
|
|
231
193
|
`,
|
|
232
|
-
variables: {
|
|
233
|
-
patches
|
|
194
|
+
variables: { patches
|
|
234
195
|
}
|
|
235
196
|
});
|
|
236
197
|
if (!response.errors) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-list-page.js","sourceRoot":"","sources":["../../../client/pages/notification/notification-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC5G,OAA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,CAAC,MAAM,EAAE,CAAC;gBACrB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;YACpB,CAAC;QACH,CAAC;IACH,CAAC;;AArN2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yDAAiB;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAoE;AAEpE;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;mDAAA;AA7BjC,oBAAoB;IADhC,aAAa,CAAC,wBAAwB,CAAC;GAC3B,oBAAoB,CAgPhC","sourcesContent":["import '@operato/data-grist'\n\nimport { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'\nimport { PageView, store } from '@operato/shell'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements'\nimport { ColumnConfig, DataGrist, FetchOption } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify } from '@operato/layout'\nimport { isMobileDevice } from '@operato/utils'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport gql from 'graphql-tag'\n\n@customElement('notification-list-page')\nexport class NotificationListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {\n static styles = [\n ScrollbarStyles,\n CommonGristStyles,\n CommonHeaderStyles,\n css`\n :host {\n display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-grist {\n overflow-y: auto;\n flex: 1;\n }\n\n ox-filters-form {\n flex: 1;\n }\n `\n ]\n\n @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.notification 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: 'notification/notification',\n actions: [\n {\n title: i18next.t('button.save'),\n action: this._updateNotification.bind(this),\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.delete'),\n action: this._deleteNotification.bind(this),\n ...CommonButtonStyles.delete\n }\n ]\n }\n }\n\n render() {\n const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form autofocus></ox-filters-form>\n\n <div id=\"modes\">\n <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>\n <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>\n <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>\n </div>\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) {\n this.gristConfig = {\n list: {\n fields: ['title', 'body'],\n details: ['state', 'updatedAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n {\n type: 'string',\n name: 'title',\n header: i18next.t('field.title'),\n record: {\n editable: false\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'string',\n name: 'body',\n header: i18next.t('field.body'),\n record: {\n editable: false\n },\n filter: 'search',\n width: 200\n },\n {\n type: 'checkbox',\n name: 'state',\n label: true,\n header: i18next.t('field.state'),\n record: {\n editable: true\n },\n filter: true,\n sortable: true,\n width: 60\n },\n {\n type: 'datetime',\n name: 'createdAt',\n header: i18next.t('field.created_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: 'createdAt',\n desc: true\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: notiBoxes(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n title\n body\n state\n createdAt\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 _deleteNotification() {\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 deleteNotificationes(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 _updateNotification() {\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: [NotificationPatch!]!) {\n updateMultipleNotification(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"]}
|
|
1
|
+
{"version":3,"file":"notification-list-page.js","sourceRoot":"","sources":["../../../client/pages/notification/notification-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EA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I,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;gBAAS,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;YACvD,CAAC;QACD,CAAC;IACD,CAAC;;AApK4B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yDAAiB;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAoE;AAEpE;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;mDAAA;AAzBjC,oBAAoB;IADhC,aAAa,CAAC,wBAAwB,CAAC;GAC3B,oBAAoB,CA2LhC","sourcesContent":["import '@operato/data-grist'\n\nimport { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'\nimport { PageView } from '@operato/shell'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements'\nimport { ColumnConfig, DataGrist, FetchOption } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify } from '@operato/layout'\nimport { isMobileDevice } from '@operato/utils'\n\nimport gql from 'graphql-tag'\n\n@customElement('notification-list-page')\nexport class NotificationListPage extends localize(i18next)(ScopedElementsMixin(PageView)) { static styles = [\n ScrollbarStyles,\n CommonGristStyles,\n CommonHeaderStyles,\n css`\n :host { display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-grist { overflow-y: auto;\n flex: 1;\n }\n\n ox-filters-form { flex: 1;\n }\n `\n ]\n\n @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.notification 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: 'notification/notification',\n actions: [\n { title: i18next.t('button.save'),\n action: this._updateNotification.bind(this),\n ...CommonButtonStyles.save\n },\n { title: i18next.t('button.delete'),\n action: this._deleteNotification.bind(this),\n ...CommonButtonStyles.delete\n }\n ]\n }\n }\n\n render() { const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form autofocus></ox-filters-form>\n\n <div id=\"modes\">\n <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>\n <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>\n <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>\n </div>\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) { this.gristConfig = { list: { fields: ['title', 'body'],\n details: ['state', 'updatedAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n { type: 'string',\n name: 'title',\n header: i18next.t('field.title'),\n record: { editable: false\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n { type: 'string',\n name: 'body',\n header: i18next.t('field.body'),\n record: { editable: false\n },\n filter: 'search',\n width: 200\n },\n { type: 'checkbox',\n name: 'state',\n label: true,\n header: i18next.t('field.state'),\n record: { editable: true\n },\n filter: true,\n sortable: true,\n width: 60\n },\n { type: 'datetime',\n name: 'createdAt',\n header: i18next.t('field.created_at'),\n record: { editable: false\n },\n sortable: true,\n width: 180\n }\n ],\n rows: { selectable: { multiple: true\n }\n },\n sorters: [\n { name: 'createdAt',\n desc: true\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: notiBoxes(filters: $filters, pagination: $pagination, sortings: $sortings) { items { id\n title\n body\n state\n createdAt\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 _deleteNotification() { 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!]!) { deleteNotificationes(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 _updateNotification() { 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: [NotificationPatch!]!) { updateMultipleNotification(patches: $patches) { name\n }\n }\n `,\n variables: { patches\n }\n })\n\n if (!response.errors) { this.grist.fetch()\n }\n }\n }\n}\n"]}
|
|
@@ -2,13 +2,7 @@ import '@operato/data-grist';
|
|
|
2
2
|
import { PageView } from '@operato/shell';
|
|
3
3
|
import { FetchOption } from '@operato/data-grist';
|
|
4
4
|
import { NotificationRuleImporter } from './notification-rule-importer';
|
|
5
|
-
declare const NotificationRuleListPage_base: (new (...args: any[]) =>
|
|
6
|
-
_storeUnsubscribe: import("redux").Unsubscribe;
|
|
7
|
-
connectedCallback(): void;
|
|
8
|
-
disconnectedCallback(): void;
|
|
9
|
-
stateChanged(_state: unknown): void;
|
|
10
|
-
readonly isConnected: boolean;
|
|
11
|
-
}) & (new (...args: any[]) => import("lit").LitElement) & typeof PageView & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
|
|
5
|
+
declare const NotificationRuleListPage_base: (new (...args: any[]) => import("lit").LitElement) & typeof PageView & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
|
|
12
6
|
export declare class NotificationRuleListPage extends NotificationRuleListPage_base {
|
|
13
7
|
static styles: import("lit").CSSResult[];
|
|
14
8
|
static get scopedElements(): {
|