@things-factory/notification 6.1.87 → 6.1.88

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 (44) hide show
  1. package/dist-client/pages/noti-box/noti-box-list-page.d.ts +49 -0
  2. package/dist-client/pages/noti-box/noti-box-list-page.js +262 -0
  3. package/dist-client/pages/noti-box/noti-box-list-page.js.map +1 -0
  4. package/dist-client/pages/noti-rule/noti-rule-importer.d.ts +22 -0
  5. package/dist-client/pages/noti-rule/noti-rule-importer.js +100 -0
  6. package/dist-client/pages/noti-rule/noti-rule-importer.js.map +1 -0
  7. package/dist-client/pages/noti-rule/noti-rule-list-page.d.ts +62 -0
  8. package/dist-client/pages/noti-rule/noti-rule-list-page.js +380 -0
  9. package/dist-client/pages/noti-rule/noti-rule-list-page.js.map +1 -0
  10. package/dist-server/service/noti-box/index.js +9 -0
  11. package/dist-server/service/noti-box/index.js.map +1 -0
  12. package/dist-server/service/noti-box/noti-box-mutation.js +110 -0
  13. package/dist-server/service/noti-box/noti-box-mutation.js.map +1 -0
  14. package/dist-server/service/noti-box/noti-box-query.js +109 -0
  15. package/dist-server/service/noti-box/noti-box-query.js.map +1 -0
  16. package/dist-server/service/noti-box/noti-box-type.js +69 -0
  17. package/dist-server/service/noti-box/noti-box-type.js.map +1 -0
  18. package/dist-server/service/noti-box/noti-box.js +107 -0
  19. package/dist-server/service/noti-box/noti-box.js.map +1 -0
  20. package/dist-server/service/noti-rule/event-subscriber.js +21 -0
  21. package/dist-server/service/noti-rule/event-subscriber.js.map +1 -0
  22. package/dist-server/service/noti-rule/index.js +12 -0
  23. package/dist-server/service/noti-rule/index.js.map +1 -0
  24. package/dist-server/service/noti-rule/noti-rule-history.js +139 -0
  25. package/dist-server/service/noti-rule/noti-rule-history.js.map +1 -0
  26. package/dist-server/service/noti-rule/noti-rule-mutation.js +168 -0
  27. package/dist-server/service/noti-rule/noti-rule-mutation.js.map +1 -0
  28. package/dist-server/service/noti-rule/noti-rule-query.js +97 -0
  29. package/dist-server/service/noti-rule/noti-rule-query.js.map +1 -0
  30. package/dist-server/service/noti-rule/noti-rule-type.js +102 -0
  31. package/dist-server/service/noti-rule/noti-rule-type.js.map +1 -0
  32. package/dist-server/service/noti-rule/noti-rule.js +146 -0
  33. package/dist-server/service/noti-rule/noti-rule.js.map +1 -0
  34. package/dist-server/service/notification-old/directive-notification.js +59 -0
  35. package/dist-server/service/notification-old/directive-notification.js.map +1 -0
  36. package/dist-server/service/notification-old/index.js +14 -0
  37. package/dist-server/service/notification-old/index.js.map +1 -0
  38. package/dist-server/service/notification-old/notification-resolver.js +45 -0
  39. package/dist-server/service/notification-old/notification-resolver.js.map +1 -0
  40. package/dist-server/service/notification-old/notification.js +49 -0
  41. package/dist-server/service/notification-old/notification.js.map +1 -0
  42. package/package.json +7 -7
  43. package/dist-server/migrations/index.js +0 -12
  44. package/dist-server/migrations/index.js.map +0 -1
@@ -0,0 +1,49 @@
1
+ import '@operato/data-grist';
2
+ import { PageView } from '@operato/shell';
3
+ import { FetchOption } from '@operato/data-grist';
4
+ declare const NotiBoxListPage_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>;
11
+ export declare class NotiBoxListPage extends NotiBoxListPage_base {
12
+ static styles: import("lit").CSSResult[];
13
+ gristConfig: any;
14
+ mode: 'CARD' | 'GRID' | 'LIST';
15
+ private grist;
16
+ private sortersControl;
17
+ get context(): {
18
+ search: {
19
+ handler: (search: string) => void;
20
+ placeholder: string;
21
+ value: string;
22
+ };
23
+ filter: {
24
+ handler: () => void;
25
+ };
26
+ help: string;
27
+ actions: {
28
+ icon: string;
29
+ emphasis: {
30
+ raised: boolean;
31
+ outlined: boolean;
32
+ dense: boolean;
33
+ danger: boolean;
34
+ };
35
+ title: string;
36
+ action: () => Promise<void>;
37
+ }[];
38
+ };
39
+ render(): import("lit-html").TemplateResult<1>;
40
+ pageInitialized(lifecycle: any): Promise<void>;
41
+ pageUpdated(changes: any, lifecycle: any): Promise<void>;
42
+ fetchHandler({ page, limit, sortings, filters }: FetchOption): Promise<{
43
+ total: any;
44
+ records: any;
45
+ }>;
46
+ _deleteNotiBox(): Promise<void>;
47
+ _updateNotiBox(): Promise<void>;
48
+ }
49
+ export {};
@@ -0,0 +1,262 @@
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 } 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
+ let NotiBoxListPage = class NotiBoxListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.mode = isMobileDevice() ? 'CARD' : 'GRID';
20
+ }
21
+ get context() {
22
+ return {
23
+ search: {
24
+ handler: (search) => {
25
+ this.grist.searchText = search;
26
+ },
27
+ placeholder: i18next.t('title.noti-box list'),
28
+ value: this.grist.searchText
29
+ },
30
+ filter: {
31
+ handler: () => {
32
+ this.grist.toggleHeadroom();
33
+ }
34
+ },
35
+ help: 'notification/noti-box',
36
+ actions: [
37
+ Object.assign({ title: i18next.t('button.save'), action: this._updateNotiBox.bind(this) }, CommonButtonStyles.save),
38
+ Object.assign({ title: i18next.t('button.delete'), action: this._deleteNotiBox.bind(this) }, CommonButtonStyles.delete)
39
+ ]
40
+ };
41
+ }
42
+ render() {
43
+ const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID');
44
+ return html `
45
+ <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
46
+ <div slot="headroom">
47
+ <div id="filters">
48
+ <ox-filters-form autofocus></ox-filters-form>
49
+ </div>
50
+
51
+ <div id="sorters">
52
+ Sort
53
+ <mwc-icon
54
+ @click=${e => {
55
+ const target = e.currentTarget;
56
+ this.sortersControl.open({
57
+ right: 0,
58
+ top: target.offsetTop + target.offsetHeight
59
+ });
60
+ }}
61
+ >expand_more</mwc-icon
62
+ >
63
+ <ox-popup id="sorter-control">
64
+ <ox-sorters-control> </ox-sorters-control>
65
+ </ox-popup>
66
+ </div>
67
+
68
+ <div id="modes">
69
+ <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>
70
+ <mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>
71
+ <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
72
+ </div>
73
+ </div>
74
+ </ox-grist>
75
+ `;
76
+ }
77
+ async pageInitialized(lifecycle) {
78
+ this.gristConfig = {
79
+ list: {
80
+ fields: ['title', 'body'],
81
+ details: ['state', 'updatedAt']
82
+ },
83
+ columns: [
84
+ { type: 'gutter', gutterName: 'sequence' },
85
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
86
+ {
87
+ type: 'string',
88
+ name: 'title',
89
+ header: i18next.t('field.title'),
90
+ record: {
91
+ editable: false
92
+ },
93
+ filter: 'search',
94
+ sortable: true,
95
+ width: 150
96
+ },
97
+ {
98
+ type: 'string',
99
+ name: 'body',
100
+ header: i18next.t('field.body'),
101
+ record: {
102
+ editable: false
103
+ },
104
+ filter: 'search',
105
+ width: 200
106
+ },
107
+ {
108
+ type: 'checkbox',
109
+ name: 'state',
110
+ label: true,
111
+ header: i18next.t('field.state'),
112
+ record: {
113
+ editable: true
114
+ },
115
+ filter: true,
116
+ sortable: true,
117
+ width: 60
118
+ },
119
+ {
120
+ type: 'datetime',
121
+ name: 'createdAt',
122
+ header: i18next.t('field.created_at'),
123
+ record: {
124
+ editable: false
125
+ },
126
+ sortable: true,
127
+ width: 180
128
+ }
129
+ ],
130
+ rows: {
131
+ selectable: {
132
+ multiple: true
133
+ }
134
+ },
135
+ sorters: [
136
+ {
137
+ name: 'createdAt',
138
+ desc: true
139
+ }
140
+ ]
141
+ };
142
+ }
143
+ async pageUpdated(changes, lifecycle) {
144
+ if (this.active) {
145
+ // do something here when this page just became as active
146
+ }
147
+ }
148
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
149
+ const response = await client.query({
150
+ query: gql `
151
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
152
+ responses: notiBoxes(filters: $filters, pagination: $pagination, sortings: $sortings) {
153
+ items {
154
+ id
155
+ title
156
+ body
157
+ state
158
+ createdAt
159
+ }
160
+ total
161
+ }
162
+ }
163
+ `,
164
+ variables: {
165
+ filters,
166
+ pagination: { page, limit },
167
+ sortings
168
+ }
169
+ });
170
+ return {
171
+ total: response.data.responses.total || 0,
172
+ records: response.data.responses.items || []
173
+ };
174
+ }
175
+ async _deleteNotiBox() {
176
+ if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {
177
+ const ids = this.grist.selected.map(record => record.id);
178
+ if (ids && ids.length > 0) {
179
+ const response = await client.mutate({
180
+ mutation: gql `
181
+ mutation ($ids: [String!]!) {
182
+ deleteNotiBoxes(ids: $ids)
183
+ }
184
+ `,
185
+ variables: {
186
+ ids
187
+ }
188
+ });
189
+ if (!response.errors) {
190
+ this.grist.fetch();
191
+ notify({
192
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
193
+ });
194
+ }
195
+ }
196
+ }
197
+ }
198
+ async _updateNotiBox() {
199
+ let patches = this.grist.dirtyRecords;
200
+ if (patches && patches.length) {
201
+ patches = patches.map(patch => {
202
+ let patchField = patch.id ? { id: patch.id } : {};
203
+ const dirtyFields = patch.__dirtyfields__;
204
+ for (let key in dirtyFields) {
205
+ patchField[key] = dirtyFields[key].after;
206
+ }
207
+ patchField.cuFlag = patch.__dirty__;
208
+ return patchField;
209
+ });
210
+ const response = await client.mutate({
211
+ mutation: gql `
212
+ mutation ($patches: [NotiBoxPatch!]!) {
213
+ updateMultipleNotiBox(patches: $patches) {
214
+ name
215
+ }
216
+ }
217
+ `,
218
+ variables: {
219
+ patches
220
+ }
221
+ });
222
+ if (!response.errors) {
223
+ this.grist.fetch();
224
+ }
225
+ }
226
+ }
227
+ };
228
+ NotiBoxListPage.styles = [
229
+ ScrollbarStyles,
230
+ CommonGristStyles,
231
+ css `
232
+ :host {
233
+ display: flex;
234
+
235
+ width: 100%;
236
+
237
+ --grid-record-emphasized-background-color: red;
238
+ --grid-record-emphasized-color: yellow;
239
+ }
240
+ `
241
+ ];
242
+ __decorate([
243
+ property({ type: Object }),
244
+ __metadata("design:type", Object)
245
+ ], NotiBoxListPage.prototype, "gristConfig", void 0);
246
+ __decorate([
247
+ property({ type: String }),
248
+ __metadata("design:type", String)
249
+ ], NotiBoxListPage.prototype, "mode", void 0);
250
+ __decorate([
251
+ query('ox-grist'),
252
+ __metadata("design:type", DataGrist)
253
+ ], NotiBoxListPage.prototype, "grist", void 0);
254
+ __decorate([
255
+ query('#sorter-control'),
256
+ __metadata("design:type", OxPopup)
257
+ ], NotiBoxListPage.prototype, "sortersControl", void 0);
258
+ NotiBoxListPage = __decorate([
259
+ customElement('noti-box-list-page')
260
+ ], NotiBoxListPage);
261
+ export { NotiBoxListPage };
262
+ //# sourceMappingURL=noti-box-list-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noti-box-list-page.js","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AU,CAAA;YACnB,CAAC,CAAC,CAAA;YAEF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;gBACnC,QAAQ,EAAE,GAAG,CAAA;;;;;;SAMZ;gBACD,SAAS,EAAE;oBACT,OAAO;iBACR;aACF,CAAC,CAAA;YAEF,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;gBACpB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;aACnB;SACF;IACH,CAAC;;AAtPM,sBAAM,GAAG;IACd,eAAe;IACf,iBAAiB;IACjB,GAAG,CAAA;;;;;;;;;KASF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAiB;AAC5C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CAAoE;AAE/F;IAAC,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;8CAAA;AAC5C;IAAC,KAAK,CAAC,iBAAiB,CAAC;8BAA0B,OAAO;uDAAA;AApB/C,eAAe;IAD3B,aAAa,CAAC,oBAAoB,CAAC;GACvB,eAAe,CAwP3B;SAxPY,eAAe","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 { ColumnConfig, DataGrist, FetchOption, SortersControl } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify } 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\n@customElement('noti-box-list-page')\nexport class NotiBoxListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {\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 @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.noti-box list'),\n value: this.grist.searchText\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n help: 'notification/noti-box',\n actions: [\n {\n title: i18next.t('button.save'),\n action: this._updateNotiBox.bind(this),\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.delete'),\n action: this._deleteNotiBox.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\">\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: ['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 _deleteNotiBox() {\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 deleteNotiBoxes(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 _updateNotiBox() {\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: [NotiBoxPatch!]!) {\n updateMultipleNotiBox(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"]}
@@ -0,0 +1,22 @@
1
+ import '@operato/data-grist';
2
+ import { LitElement } from 'lit';
3
+ export declare class NotiRuleImporter extends LitElement {
4
+ static styles: import("lit").CSSResult[];
5
+ notiRules: 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 NotiRuleImporter extends LitElement {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.notiRules = [];
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.notiRules
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 importNotiRules($notiRules: [NotiRulePatch!]!) {
58
+ importNotiRules(notiRules: $notiRules)
59
+ }
60
+ `,
61
+ variables: { notiRules: this.notiRules }
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
+ NotiRuleImporter.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
+ ], NotiRuleImporter.prototype, "notiRules", void 0);
96
+ __decorate([
97
+ property({ type: Object }),
98
+ __metadata("design:type", Object)
99
+ ], NotiRuleImporter.prototype, "columns", void 0);
100
+ //# sourceMappingURL=noti-rule-importer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noti-rule-importer.js","sourceRoot":"","sources":["../../../client/pages/noti-rule/noti-rule-importer.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;A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AI,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,uBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;KAqBF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;mDAAsB;AAChD;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;iDAuB1B","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 NotiRuleImporter 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 }) notiRules: 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.notiRules \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 importNotiRules($notiRules: [NotiRulePatch!]!) {\n importNotiRules(notiRules: $notiRules)\n }\n `,\n variables: { notiRules: this.notiRules }\n })\n\n if (response.errors?.length) return\n\n this.dispatchEvent(new CustomEvent('imported'))\n }\n}\n\n"]}
@@ -0,0 +1,62 @@
1
+ import '@operato/data-grist';
2
+ import { PageView } from '@operato/shell';
3
+ import { FetchOption } from '@operato/data-grist';
4
+ import { NotiRuleImporter } from './noti-rule-importer';
5
+ declare const NotiRuleListPage_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>;
12
+ export declare class NotiRuleListPage extends NotiRuleListPage_base {
13
+ static styles: import("lit").CSSResult[];
14
+ static get scopedElements(): {
15
+ 'noti-rule-importer': typeof NotiRuleImporter;
16
+ };
17
+ gristConfig: any;
18
+ mode: 'CARD' | 'GRID' | 'LIST';
19
+ private grist;
20
+ private sortersControl;
21
+ get context(): {
22
+ search: {
23
+ handler: (search: string) => void;
24
+ placeholder: string;
25
+ value: string;
26
+ };
27
+ filter: {
28
+ handler: () => void;
29
+ };
30
+ help: string;
31
+ actions: {
32
+ icon: string;
33
+ emphasis: {
34
+ raised: boolean;
35
+ outlined: boolean;
36
+ dense: boolean;
37
+ danger: boolean;
38
+ };
39
+ title: string;
40
+ action: () => Promise<void>;
41
+ }[];
42
+ exportable: {
43
+ name: string;
44
+ data: () => Promise<{}[]>;
45
+ };
46
+ importable: {
47
+ handler: (records: any) => Promise<void>;
48
+ };
49
+ };
50
+ render(): import("lit-html").TemplateResult<1>;
51
+ pageInitialized(lifecycle: any): Promise<void>;
52
+ pageUpdated(changes: any, lifecycle: any): Promise<void>;
53
+ fetchHandler({ page, limit, sortings, filters }: FetchOption): Promise<{
54
+ total: any;
55
+ records: any;
56
+ }>;
57
+ _deleteNotiRule(): Promise<void>;
58
+ _updateNotiRule(): Promise<void>;
59
+ exportHandler(): Promise<{}[]>;
60
+ importHandler(records: any): Promise<void>;
61
+ }
62
+ export {};