@things-factory/notification 7.0.1-alpha.4 → 7.0.1-alpha.43

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 (24) hide show
  1. package/client/bootstrap.ts +2 -1
  2. package/client/pages/notification/notification-list-page.ts +6 -5
  3. package/client/pages/notification-rule/notification-rule-importer.ts +4 -11
  4. package/client/pages/notification-rule/notification-rule-list-page.ts +6 -5
  5. package/client/viewparts/notification-sender.ts +10 -22
  6. package/client/viewparts/notification-setting-let.ts +27 -22
  7. package/dist-client/bootstrap.js +1 -1
  8. package/dist-client/bootstrap.js.map +1 -1
  9. package/dist-client/pages/notification/notification-list-page.js +6 -5
  10. package/dist-client/pages/notification/notification-list-page.js.map +1 -1
  11. package/dist-client/pages/notification-rule/notification-rule-importer.d.ts +1 -0
  12. package/dist-client/pages/notification-rule/notification-rule-importer.js +4 -11
  13. package/dist-client/pages/notification-rule/notification-rule-importer.js.map +1 -1
  14. package/dist-client/pages/notification-rule/notification-rule-list-page.js +6 -5
  15. package/dist-client/pages/notification-rule/notification-rule-list-page.js.map +1 -1
  16. package/dist-client/tsconfig.tsbuildinfo +1 -1
  17. package/dist-client/viewparts/notification-sender.d.ts +1 -2
  18. package/dist-client/viewparts/notification-sender.js +8 -19
  19. package/dist-client/viewparts/notification-sender.js.map +1 -1
  20. package/dist-client/viewparts/notification-setting-let.d.ts +3 -4
  21. package/dist-client/viewparts/notification-setting-let.js +27 -17
  22. package/dist-client/viewparts/notification-setting-let.js.map +1 -1
  23. package/dist-server/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +9 -9
@@ -1,7 +1,8 @@
1
1
  import gql from 'graphql-tag'
2
2
 
3
3
  import { notify } from '@operato/layout'
4
- import { auth } from '@things-factory/auth-base/dist-client'
4
+ import { auth } from '@things-factory/auth-base/dist-client/auth.js'
5
+
5
6
  import { i18next } from '@operato/i18n'
6
7
  import { notificationStore, route, store } from '@operato/shell'
7
8
  import { subscribe as graphqlSubscribe } from '@operato/graphql'
@@ -85,7 +85,7 @@ export class NotificationListPage extends connect(store)(localize(i18next)(Scope
85
85
 
86
86
  <div id="sorters">
87
87
  Sort
88
- <mwc-icon
88
+ <md-icon
89
89
  @click=${e => {
90
90
  const target = e.currentTarget
91
91
  this.sortersControl.open({
@@ -93,7 +93,7 @@ export class NotificationListPage extends connect(store)(localize(i18next)(Scope
93
93
  top: target.offsetTop + target.offsetHeight
94
94
  })
95
95
  }}
96
- >expand_more</mwc-icon
96
+ >expand_more</md-icon
97
97
  >
98
98
  <ox-popup id="sorter-control">
99
99
  <ox-sorters-control> </ox-sorters-control>
@@ -101,9 +101,10 @@ export class NotificationListPage extends connect(store)(localize(i18next)(Scope
101
101
  </div>
102
102
 
103
103
  <div id="modes">
104
- <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>
105
- <mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>
106
- <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
104
+ <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>
105
+ <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>
106
+ <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>
107
+ </div>
107
108
  </div>
108
109
  </div>
109
110
  </ox-grist>
@@ -1,3 +1,4 @@
1
+ import '@material/web/icon/icon.js'
1
2
  import '@operato/data-grist'
2
3
 
3
4
  import gql from 'graphql-tag'
@@ -7,9 +8,11 @@ import { property } from 'lit/decorators.js'
7
8
  import { client } from '@operato/graphql'
8
9
  import { i18next } from '@operato/i18n'
9
10
  import { isMobileDevice } from '@operato/utils'
11
+ import { ButtonContainerStyles } from '@operato/styles'
10
12
 
11
13
  export class NotificationRuleImporter extends LitElement {
12
14
  static styles = [
15
+ ButtonContainerStyles,
13
16
  css`
14
17
  :host {
15
18
  display: flex;
@@ -21,16 +24,6 @@ export class NotificationRuleImporter extends LitElement {
21
24
  ox-grist {
22
25
  flex: 1;
23
26
  }
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
27
  `
35
28
  ]
36
29
 
@@ -71,7 +64,7 @@ export class NotificationRuleImporter extends LitElement {
71
64
  ></ox-grist>
72
65
 
73
66
  <div class="button-container">
74
- <mwc-button raised @click="${this.save.bind(this)}">${i18next.t('button.save')}</mwc-button>
67
+ <button @click="${this.save.bind(this)}"><md-icon>save</md-icon>${i18next.t('button.save')}</button>
75
68
  </div>
76
69
  `
77
70
  }
@@ -100,7 +100,7 @@ export class NotificationRuleListPage extends connect(store)(localize(i18next)(S
100
100
 
101
101
  <div id="sorters">
102
102
  Sort
103
- <mwc-icon
103
+ <md-icon
104
104
  @click=${e => {
105
105
  const target = e.currentTarget
106
106
  this.sortersControl.open({
@@ -108,7 +108,7 @@ export class NotificationRuleListPage extends connect(store)(localize(i18next)(S
108
108
  top: target.offsetTop + target.offsetHeight
109
109
  })
110
110
  }}
111
- >expand_more</mwc-icon
111
+ >expand_more</md-icon
112
112
  >
113
113
  <ox-popup id="sorter-control">
114
114
  <ox-sorters-control> </ox-sorters-control>
@@ -116,9 +116,10 @@ export class NotificationRuleListPage extends connect(store)(localize(i18next)(S
116
116
  </div>
117
117
 
118
118
  <div id="modes">
119
- <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>
120
- <mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>
121
- <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
119
+ <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>
120
+ <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>
121
+ <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>
122
+ </div>
122
123
  </div>
123
124
  </div>
124
125
  </ox-grist>
@@ -1,11 +1,11 @@
1
- import '@material/mwc-formfield'
2
1
  import '@material/mwc-button'
3
- import '@material/mwc-checkbox'
4
2
  import '@operato/i18n/ox-i18n.js'
3
+ import '@material/web/checkbox/checkbox.js'
5
4
 
6
5
  import { css, html, LitElement } from 'lit'
7
6
  import { customElement, property } from 'lit/decorators.js'
8
- import { auth } from '@things-factory/auth-base/dist-client'
7
+ import { auth } from '@things-factory/auth-base/dist-client/auth.js'
8
+
9
9
  import { i18next, localize } from '@operato/i18n'
10
10
  import { ScrollbarStyles } from '@operato/styles'
11
11
 
@@ -67,25 +67,15 @@ export class NotificationSender extends localize(i18next)(LitElement) {
67
67
  required
68
68
  icon="account_circle"
69
69
  ></mwc-textfield>
70
- <mwc-textfield
71
- type="text"
72
- name="title"
73
- .label=${i18next.t('field.title')}
74
- required
75
- icon="notifications_none"
76
- ></mwc-textfield>
70
+ <mwc-textfield type="text" name="title" .label=${i18next.t('field.title')} required icon="notifications_none"></mwc-textfield>
77
71
 
78
- <mwc-textfield
79
- type="text"
80
- name="image"
81
- .label=${i18next.t('field.image')}
82
- icon="insert_photo"
83
- ></mwc-textfield>
72
+ <mwc-textfield type="text" name="image" .label=${i18next.t('field.image')} icon="insert_photo"></mwc-textfield>
84
73
  <mwc-textfield type="text" name="url" .label=${i18next.t('field.url')} icon="link"></mwc-textfield>
85
74
  <mwc-textarea type="text" name="body" .label=${i18next.t('field.body')} required rows="5"></mwc-textarea>
86
- <mwc-formfield label="In-App Message">
87
- <mwc-checkbox name="inappmsg"></mwc-checkbox>
88
- </mwc-formfield>
75
+ <label>
76
+ <md-checkbox name="inappmsg"></md-checkbox>
77
+ In-App Message
78
+ </label>
89
79
  </div>
90
80
 
91
81
  <div buttons>
@@ -118,9 +108,7 @@ export class NotificationSender extends localize(i18next)(LitElement) {
118
108
  }
119
109
 
120
110
  onReset() {
121
- ;['receivers', 'title', 'body', 'image', 'url'].map(
122
- key => ((this.renderRoot.querySelector(`[name="${key}"]`)! as any).value = '')
123
- )
111
+ ;['receivers', 'title', 'body', 'image', 'url'].map(key => ((this.renderRoot.querySelector(`[name="${key}"]`)! as any).value = ''))
124
112
  ;(this.renderRoot.querySelector(`[name="inappmsg"]`)! as any).checked = false
125
113
  }
126
114
  }
@@ -1,9 +1,8 @@
1
+ import '@material/web/icon/icon.js'
2
+ import '@material/web/switch/switch.js'
3
+ import '@operato/i18n/ox-i18n.js'
1
4
  import '@things-factory/setting-base'
2
5
  import './notification-sender'
3
- import '@material/mwc-formfield'
4
- import '@material/mwc-switch'
5
- import '@material/mwc-button'
6
- import '@operato/i18n/ox-i18n.js'
7
6
 
8
7
  import Clipboard from 'clipboard'
9
8
  import { css, html, LitElement } from 'lit'
@@ -33,6 +32,10 @@ export class NotificationSettingLet extends localize(i18next)(LitElement) {
33
32
  }
34
33
 
35
34
  label {
35
+ display: flex;
36
+ gap: 10px;
37
+ align-items: center;
38
+
36
39
  font: var(--label-font);
37
40
  color: var(--label-color);
38
41
  text-transform: var(--label-text-transform);
@@ -53,9 +56,15 @@ export class NotificationSettingLet extends localize(i18next)(LitElement) {
53
56
  }
54
57
 
55
58
  [button-in-field] {
59
+ --md-icon-size: 18px;
56
60
  position: absolute;
57
61
  top: 24px;
58
62
  right: 4px;
63
+ width: 30px;
64
+ padding: 2px;
65
+ border-radius: var(--border-radius, 5px);
66
+ color: var(--theme-white-color, #fff);
67
+ background-color: var(--secondary-color, #394e64);
59
68
  }
60
69
  `
61
70
  ]
@@ -74,24 +83,20 @@ export class NotificationSettingLet extends localize(i18next)(LitElement) {
74
83
 
75
84
  ${supported
76
85
  ? html`
77
- <div slot="content" onoff>
78
- <mwc-formfield label=${String(i18next.t('label.allow push message'))}>
79
- <mwc-switch label="allow message" ?selected=${!!this.subscription} @click=${e =>
80
- this.onClickSwitch(e)}></mwc-switch>
81
- </mwc-formfield>
82
- <mwc-button test outlined label=${String(i18next.t('button.push message test'))} @click=${e =>
83
- this.ontest()}></mwc-button>
84
- </div>
85
-
86
- <div slot="content" info>
87
- <label for="subscription-token"><ox-i18n msgid="label.subscription token"></ox-i18n></label>
88
- <input id="subscription-token" type="text" name="subscription-token" .value=${
89
- this.subscription || ''
90
- } readonly />
91
- <mwc-button dense unelevated button-in-field clipboard-copy @click=${e =>
92
- e.preventDefault()}><ox-i18n msgid="button.copy"></mwc-button>
93
- </div>
94
- `
86
+ <div slot="content" onoff>
87
+ <label>
88
+ <md-switch label="allow message" ?selected=${!!this.subscription} @click=${e => this.onClickSwitch(e)}></md-switch>
89
+ ${String(i18next.t('label.allow push message'))}
90
+ </label>
91
+ <md-outlined-button test label=${String(i18next.t('button.push message test'))} @click=${e => this.ontest()}></md-outlined-button>
92
+ </div>
93
+
94
+ <div slot="content" info>
95
+ <label for="subscription-token"><ox-i18n msgid="label.subscription token"></ox-i18n></label>
96
+ <input id="subscription-token" type="text" name="subscription-token" .value=${this.subscription || ''} readonly />
97
+ <md-icon button-in-field clipboard-copy @click=${e => e.preventDefault()}>content_copy</md-icon>
98
+ </div>
99
+ `
95
100
  : html` <div slot="content">${i18next.t('text.push notification is not supported in your browser')}</div>`}
96
101
  </setting-let>
97
102
  `
@@ -1,6 +1,6 @@
1
1
  import gql from 'graphql-tag';
2
2
  import { notify } from '@operato/layout';
3
- import { auth } from '@things-factory/auth-base/dist-client';
3
+ import { auth } from '@things-factory/auth-base/dist-client/auth.js';
4
4
  import { i18next } from '@operato/i18n';
5
5
  import { notificationStore, route, store } from '@operato/shell';
6
6
  import { subscribe as graphqlSubscribe } from '@operato/graphql';
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../client/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MA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EAAE,OAAO,CAAC,CAAC,CAAC,uCAAuC,CAAC;oBAC3D,MAAM,EAAE;wBACN,MAAM,EAAE;4BACN,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;4BACjC,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;yBACzC;wBACD,KAAK,EAAE,CAAC,CAAC;qBACV;iBACF,CAAC,CAAA;gBACF,MAAK;YAEP,KAAK,cAAc,CAAC;YACpB;gBACE,cAAc,EAAE,CAAA;SACnB;IACH,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,KAAY,EAAE,EAAE;QACnD,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,GAAI,KAAqB,CAAC,MAAM,CAAA;QAC5E,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;QAEtC,IAAI,KAAK,KAAK,OAAO,EAAE;YACrB,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;SACH;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'\nimport { i18next } from '@operato/i18n'\nimport { notificationStore, route, 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 && route(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
+ {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../client/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,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E,OAAO,CAAC,CAAC,CAAC,uCAAuC,CAAC;oBAC3D,MAAM,EAAE;wBACN,MAAM,EAAE;4BACN,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;4BACjC,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;yBACzC;wBACD,KAAK,EAAE,CAAC,CAAC;qBACV;iBACF,CAAC,CAAA;gBACF,MAAK;YAEP,KAAK,cAAc,CAAC;YACpB;gBACE,cAAc,EAAE,CAAA;SACnB;IACH,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,KAAY,EAAE,EAAE;QACnD,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,GAAI,KAAqB,CAAC,MAAM,CAAA;QAC5E,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;QAEtC,IAAI,KAAK,KAAK,OAAO,EAAE;YACrB,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;SACH;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 { notificationStore, route, 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 && route(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"]}
@@ -51,7 +51,7 @@ let NotificationListPage = class NotificationListPage extends connect(store)(loc
51
51
 
52
52
  <div id="sorters">
53
53
  Sort
54
- <mwc-icon
54
+ <md-icon
55
55
  @click=${e => {
56
56
  const target = e.currentTarget;
57
57
  this.sortersControl.open({
@@ -59,7 +59,7 @@ let NotificationListPage = class NotificationListPage extends connect(store)(loc
59
59
  top: target.offsetTop + target.offsetHeight
60
60
  });
61
61
  }}
62
- >expand_more</mwc-icon
62
+ >expand_more</md-icon
63
63
  >
64
64
  <ox-popup id="sorter-control">
65
65
  <ox-sorters-control> </ox-sorters-control>
@@ -67,9 +67,10 @@ let NotificationListPage = class NotificationListPage extends connect(store)(loc
67
67
  </div>
68
68
 
69
69
  <div id="modes">
70
- <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>
71
- <mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>
72
- <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
70
+ <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>
71
+ <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>
72
+ <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>
73
+ </div>
73
74
  </div>
74
75
  </div>
75
76
  </ox-grist>
@@ -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,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACxF,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AA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;IACf,iBAAiB;IACjB,GAAG,CAAA;;;;;;;;;;;;;;KAcF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yDAAiB;AAC5C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAoE;AAE/F;IAAC,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;mDAAA;AAC5C;IAAC,KAAK,CAAC,iBAAiB,CAAC;8BAA0B,OAAO;4DAAA;AAzB/C,oBAAoB;IADhC,aAAa,CAAC,wBAAwB,CAAC;GAC3B,oBAAoB,CA6PhC;SA7PY,oBAAoB","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('notification-list-page')\nexport class NotificationListPage 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: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-grist {\n overflow-y: auto;\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 @query('#sorter-control') private sortersControl!: OxPopup\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\">\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 _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,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACxF,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChD,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,EAAgB,SAAS,EAA+B,MAAM,qBAAqB,CAAA;AAC1F,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,GAAG,MAAM,aAAa,CAAA;AAGtB,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAAnG;;QAsBuB,SAAI,GAA6B,cAAc,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAA;IAwOjG,CAAC;IAnOC,IAA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AW,EAAE;oBAC3B,UAAU,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,CAAA;iBACzC;gBACD,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,CAAA;gBAEnC,OAAO,UAAU,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;;AA5PM,2BAAM,GAAG;IACd,eAAe;IACf,iBAAiB;IACjB,GAAG,CAAA;;;;;;;;;;;;;;KAcF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yDAAiB;AAC5C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAoE;AAE/F;IAAC,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;mDAAA;AAC5C;IAAC,KAAK,CAAC,iBAAiB,CAAC;8BAA0B,OAAO;4DAAA;AAzB/C,oBAAoB;IADhC,aAAa,CAAC,wBAAwB,CAAC;GAC3B,oBAAoB,CA8PhC;SA9PY,oBAAoB","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('notification-list-page')\nexport class NotificationListPage 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: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-grist {\n overflow-y: auto;\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 @query('#sorter-control') private sortersControl!: OxPopup\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\">\n <div id=\"filters\">\n <ox-filters-form autofocus></ox-filters-form>\n </div>\n\n <div id=\"sorters\">\n Sort\n <md-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</md-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 <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,3 +1,4 @@
1
+ import '@material/web/icon/icon.js';
1
2
  import '@operato/data-grist';
2
3
  import { LitElement } from 'lit';
3
4
  export declare class NotificationRuleImporter extends LitElement {
@@ -1,4 +1,5 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
+ import '@material/web/icon/icon.js';
2
3
  import '@operato/data-grist';
3
4
  import gql from 'graphql-tag';
4
5
  import { css, html, LitElement } from 'lit';
@@ -6,6 +7,7 @@ import { property } from 'lit/decorators.js';
6
7
  import { client } from '@operato/graphql';
7
8
  import { i18next } from '@operato/i18n';
8
9
  import { isMobileDevice } from '@operato/utils';
10
+ import { ButtonContainerStyles } from '@operato/styles';
9
11
  export class NotificationRuleImporter extends LitElement {
10
12
  constructor() {
11
13
  super(...arguments);
@@ -46,7 +48,7 @@ export class NotificationRuleImporter extends LitElement {
46
48
  ></ox-grist>
47
49
 
48
50
  <div class="button-container">
49
- <mwc-button raised @click="${this.save.bind(this)}">${i18next.t('button.save')}</mwc-button>
51
+ <button @click="${this.save.bind(this)}"><md-icon>save</md-icon>${i18next.t('button.save')}</button>
50
52
  </div>
51
53
  `;
52
54
  }
@@ -66,6 +68,7 @@ export class NotificationRuleImporter extends LitElement {
66
68
  }
67
69
  }
68
70
  NotificationRuleImporter.styles = [
71
+ ButtonContainerStyles,
69
72
  css `
70
73
  :host {
71
74
  display: flex;
@@ -77,16 +80,6 @@ NotificationRuleImporter.styles = [
77
80
  ox-grist {
78
81
  flex: 1;
79
82
  }
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
83
  `
91
84
  ];
92
85
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"notification-rule-importer.js","sourceRoot":"","sources":["../../../client/pages/notification-rule/notification-rule-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,wBAAyB,SAAQ,UAAU;IAAxD;;QA0B6B,sBAAiB,GAAU,EAAE,CAAA;QAC5B,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,KA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ato/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 NotificationRuleImporter 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 }) notificationRules: 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 render() {\n return html`\n <ox-grist\n .mode=${isMobileDevice() ? 'LIST' : 'GRID'}\n .config=${this.columns}\n .data=${{\n records: this.notificationRules\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 importNotificationRules($notificationRules: [NotificationRulePatch!]!) {\n importNotificationRules(notificationRules: $notificationRules)\n }\n `,\n variables: { notificationRules: this.notificationRules }\n })\n\n if (response.errors?.length) return\n\n this.dispatchEvent(new CustomEvent('imported'))\n }\n}\n"]}
1
+ {"version":3,"file":"notification-rule-importer.js","sourceRoot":"","sources":["../../../client/pages/notification-rule/notification-rule-importer.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,qBAAqB,CAAA;AAE5B,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,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AAI,CAAC,4BAA4B,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC;;KAE7F,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,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE;SACzD,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;;AAvEM,+BAAM,GAAG;IACd,qBAAqB;IACrB,GAAG,CAAA;;;;;;;;;;;KAWF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;mEAA8B;AACxD;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yDAuB1B","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@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'\nimport { ButtonContainerStyles } from '@operato/styles'\n\nexport class NotificationRuleImporter extends LitElement {\n static styles = [\n ButtonContainerStyles,\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 ]\n\n @property({ type: Array }) notificationRules: 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 render() {\n return html`\n <ox-grist\n .mode=${isMobileDevice() ? 'LIST' : 'GRID'}\n .config=${this.columns}\n .data=${{\n records: this.notificationRules\n }}\n ></ox-grist>\n\n <div class=\"button-container\">\n <button @click=\"${this.save.bind(this)}\"><md-icon>save</md-icon>${i18next.t('button.save')}</button>\n </div>\n `\n }\n\n async save() {\n const response = await client.mutate({\n mutation: gql`\n mutation importNotificationRules($notificationRules: [NotificationRulePatch!]!) {\n importNotificationRules(notificationRules: $notificationRules)\n }\n `,\n variables: { notificationRules: this.notificationRules }\n })\n\n if (response.errors?.length) return\n\n this.dispatchEvent(new CustomEvent('imported'))\n }\n}\n"]}
@@ -64,7 +64,7 @@ let NotificationRuleListPage = class NotificationRuleListPage extends connect(st
64
64
 
65
65
  <div id="sorters">
66
66
  Sort
67
- <mwc-icon
67
+ <md-icon
68
68
  @click=${e => {
69
69
  const target = e.currentTarget;
70
70
  this.sortersControl.open({
@@ -72,7 +72,7 @@ let NotificationRuleListPage = class NotificationRuleListPage extends connect(st
72
72
  top: target.offsetTop + target.offsetHeight
73
73
  });
74
74
  }}
75
- >expand_more</mwc-icon
75
+ >expand_more</md-icon
76
76
  >
77
77
  <ox-popup id="sorter-control">
78
78
  <ox-sorters-control> </ox-sorters-control>
@@ -80,9 +80,10 @@ let NotificationRuleListPage = class NotificationRuleListPage extends connect(st
80
80
  </div>
81
81
 
82
82
  <div id="modes">
83
- <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>
84
- <mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>
85
- <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
83
+ <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>
84
+ <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>
85
+ <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>
86
+ </div>
86
87
  </div>
87
88
  </div>
88
89
  </ox-grist>
@@ -1 +1 @@
1
- {"version":3,"file":"notification-rule-list-page.js","sourceRoot":"","sources":["../../../client/pages/notification-rule/notification-rule-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACxF,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChD,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,EAAgB,SAAS,EAA+B,MAAM,qBAAqB,CAAA;AAC1F,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,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAA;AAGhE,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAAvG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AM,EAAE,CAAC;;sDAAoE;AAE/F;IAAC,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;uDAAA;AAC5C;IAAC,KAAK,CAAC,iBAAiB,CAAC;8BAA0B,OAAO;gEAAA;AA/B/C,wBAAwB;IADpC,aAAa,CAAC,6BAA6B,CAAC;GAChC,wBAAwB,CA2XpC;SA3XY,wBAAwB","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, openPopup } from '@operato/layout'\nimport { OxPopup } from '@operato/popup'\nimport { isMobileDevice } from '@operato/utils'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport gql from 'graphql-tag'\n\nimport { NotificationRuleImporter } from './notification-rule-importer'\n\n@customElement('notification-rule-list-page')\nexport class NotificationRuleListPage 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: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-grist {\n overflow-y: auto;\n flex: 1;\n }\n `\n ]\n\n static get scopedElements() {\n return {\n 'notification-rule-importer': NotificationRuleImporter\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 title: i18next.t('title.notification-rule 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-rule',\n actions: [\n {\n title: i18next.t('button.save'),\n action: this._updateNotificationRule.bind(this),\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.delete'),\n action: this._deleteNotificationRule.bind(this),\n ...CommonButtonStyles.delete\n }\n ],\n exportable: {\n name: i18next.t('title.notification-rule list'),\n data: this.exportHandler.bind(this)\n },\n importable: {\n handler: this.importHandler.bind(this)\n }\n }\n }\n\n render() {\n const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist .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 thumbnail: 'thumbnail',\n fields: ['name', 'description'],\n details: ['title', 'updatedAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: {\n editable: true\n },\n filter: 'search',\n width: 200\n },\n {\n type: 'string',\n name: 'title',\n header: i18next.t('field.title'),\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'text',\n name: 'body',\n header: i18next.t('field.body'),\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'string',\n name: 'url',\n header: i18next.t('field.url'),\n record: {\n editable: true\n },\n sortable: true,\n width: 150\n },\n {\n type: 'image',\n name: 'thumbnail',\n header: i18next.t('field.thumbnail'),\n record: { editable: true },\n width: 120\n },\n {\n type: 'select',\n name: 'state',\n label: true,\n header: i18next.t('field.state'),\n record: {\n options: [\n {},\n {\n display: i18next.t('text.draft'),\n value: 'DRAFT'\n },\n {\n display: i18next.t('text.released'),\n value: 'RELEASED'\n }\n ]\n },\n sortable: true,\n filter: true,\n width: 60\n },\n {\n type: 'recipients',\n name: 'recipients',\n header: i18next.t('field.recipients'),\n record: {\n editable: true\n },\n width: 50\n },\n {\n type: 'resource-object',\n name: 'updater',\n header: i18next.t('field.updater'),\n record: {\n editable: false\n },\n sortable: true,\n width: 120\n },\n {\n type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n record: {\n editable: false\n },\n sortable: true,\n width: 180\n }\n ],\n rows: {\n selectable: {\n multiple: true\n }\n },\n sorters: [\n {\n name: 'name'\n }\n ]\n }\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (this.active) {\n // do something here when this page just became as active\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n responses: notificationRules(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n description\n title\n body\n url\n thumbnail\n state\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 _deleteNotificationRule() {\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 deleteNotificationRules(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 _updateNotificationRule() {\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: [NotificationRulePatch!]!) {\n updateMultipleNotificationRule(patches: $patches) {\n name\n }\n }\n `,\n variables: {\n patches\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n }\n }\n }\n\n async exportHandler() {\n const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records\n const targetFieldSet = new Set(['id', 'name', 'description', 'active'])\n\n return exportTargets.map(notificationRule => {\n let tempObj = {}\n for (const field of targetFieldSet) {\n tempObj[field] = notificationRule[field]\n }\n\n return tempObj\n })\n }\n\n async importHandler(records) {\n const popup = openPopup(\n html`\n <notification-rule-importer\n .notificationRules=${records}\n @imported=${() => {\n history.back()\n this.grist.fetch()\n }}\n ></notification-rule-importer>\n `,\n {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.import notification-rule')\n }\n )\n\n popup.onclosed = () => {\n this.grist.fetch()\n }\n }\n}\n"]}
1
+ {"version":3,"file":"notification-rule-list-page.js","sourceRoot":"","sources":["../../../client/p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wBAAwB,CA4XpC;SA5XY,wBAAwB","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, openPopup } from '@operato/layout'\nimport { OxPopup } from '@operato/popup'\nimport { isMobileDevice } from '@operato/utils'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport gql from 'graphql-tag'\n\nimport { NotificationRuleImporter } from './notification-rule-importer'\n\n@customElement('notification-rule-list-page')\nexport class NotificationRuleListPage 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: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-grist {\n overflow-y: auto;\n flex: 1;\n }\n `\n ]\n\n static get scopedElements() {\n return {\n 'notification-rule-importer': NotificationRuleImporter\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 title: i18next.t('title.notification-rule 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-rule',\n actions: [\n {\n title: i18next.t('button.save'),\n action: this._updateNotificationRule.bind(this),\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.delete'),\n action: this._deleteNotificationRule.bind(this),\n ...CommonButtonStyles.delete\n }\n ],\n exportable: {\n name: i18next.t('title.notification-rule list'),\n data: this.exportHandler.bind(this)\n },\n importable: {\n handler: this.importHandler.bind(this)\n }\n }\n }\n\n render() {\n const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist .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 <md-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</md-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 <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 thumbnail: 'thumbnail',\n fields: ['name', 'description'],\n details: ['title', 'updatedAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: {\n editable: true\n },\n filter: 'search',\n width: 200\n },\n {\n type: 'string',\n name: 'title',\n header: i18next.t('field.title'),\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'text',\n name: 'body',\n header: i18next.t('field.body'),\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'string',\n name: 'url',\n header: i18next.t('field.url'),\n record: {\n editable: true\n },\n sortable: true,\n width: 150\n },\n {\n type: 'image',\n name: 'thumbnail',\n header: i18next.t('field.thumbnail'),\n record: { editable: true },\n width: 120\n },\n {\n type: 'select',\n name: 'state',\n label: true,\n header: i18next.t('field.state'),\n record: {\n options: [\n {},\n {\n display: i18next.t('text.draft'),\n value: 'DRAFT'\n },\n {\n display: i18next.t('text.released'),\n value: 'RELEASED'\n }\n ]\n },\n sortable: true,\n filter: true,\n width: 60\n },\n {\n type: 'recipients',\n name: 'recipients',\n header: i18next.t('field.recipients'),\n record: {\n editable: true\n },\n width: 50\n },\n {\n type: 'resource-object',\n name: 'updater',\n header: i18next.t('field.updater'),\n record: {\n editable: false\n },\n sortable: true,\n width: 120\n },\n {\n type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n record: {\n editable: false\n },\n sortable: true,\n width: 180\n }\n ],\n rows: {\n selectable: {\n multiple: true\n }\n },\n sorters: [\n {\n name: 'name'\n }\n ]\n }\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (this.active) {\n // do something here when this page just became as active\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n responses: notificationRules(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n description\n title\n body\n url\n thumbnail\n state\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 _deleteNotificationRule() {\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 deleteNotificationRules(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 _updateNotificationRule() {\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: [NotificationRulePatch!]!) {\n updateMultipleNotificationRule(patches: $patches) {\n name\n }\n }\n `,\n variables: {\n patches\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n }\n }\n }\n\n async exportHandler() {\n const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records\n const targetFieldSet = new Set(['id', 'name', 'description', 'active'])\n\n return exportTargets.map(notificationRule => {\n let tempObj = {}\n for (const field of targetFieldSet) {\n tempObj[field] = notificationRule[field]\n }\n\n return tempObj\n })\n }\n\n async importHandler(records) {\n const popup = openPopup(\n html`\n <notification-rule-importer\n .notificationRules=${records}\n @imported=${() => {\n history.back()\n this.grist.fetch()\n }}\n ></notification-rule-importer>\n `,\n {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.import notification-rule')\n }\n )\n\n popup.onclosed = () => {\n this.grist.fetch()\n }\n }\n}\n"]}