@things-factory/auth-ui 6.2.6 → 6.2.8

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 (41) hide show
  1. package/client/components/create-domain-popup.ts +2 -2
  2. package/client/components/create-role.ts +38 -34
  3. package/client/components/create-user.ts +27 -52
  4. package/client/components/invite-customer.ts +29 -29
  5. package/client/components/invite-user.ts +15 -14
  6. package/client/components/ownership-transfer-popup.ts +29 -30
  7. package/client/components/partner-role-editor.ts +28 -28
  8. package/client/components/role-privilege-editor.ts +30 -29
  9. package/client/components/role-selector.ts +2 -2
  10. package/client/components/user-role-editor.ts +64 -66
  11. package/client/entries/oauth2/oauth2-decision-page.ts +2 -2
  12. package/client/pages/role/role-management.ts +0 -1
  13. package/client/pages/user/user-management.ts +26 -26
  14. package/dist-client/components/create-domain-popup.js +2 -2
  15. package/dist-client/components/create-domain-popup.js.map +1 -1
  16. package/dist-client/components/create-role.js +30 -27
  17. package/dist-client/components/create-role.js.map +1 -1
  18. package/dist-client/components/create-user.js +26 -51
  19. package/dist-client/components/create-user.js.map +1 -1
  20. package/dist-client/components/invite-customer.js +24 -25
  21. package/dist-client/components/invite-customer.js.map +1 -1
  22. package/dist-client/components/invite-user.js +8 -9
  23. package/dist-client/components/invite-user.js.map +1 -1
  24. package/dist-client/components/ownership-transfer-popup.js +23 -23
  25. package/dist-client/components/ownership-transfer-popup.js.map +1 -1
  26. package/dist-client/components/partner-role-editor.js +21 -22
  27. package/dist-client/components/partner-role-editor.js.map +1 -1
  28. package/dist-client/components/role-privilege-editor.js +23 -23
  29. package/dist-client/components/role-privilege-editor.js.map +1 -1
  30. package/dist-client/components/role-selector.js +2 -2
  31. package/dist-client/components/role-selector.js.map +1 -1
  32. package/dist-client/components/user-role-editor.js +54 -58
  33. package/dist-client/components/user-role-editor.js.map +1 -1
  34. package/dist-client/entries/oauth2/oauth2-decision-page.js +2 -2
  35. package/dist-client/entries/oauth2/oauth2-decision-page.js.map +1 -1
  36. package/dist-client/pages/role/role-management.js +0 -1
  37. package/dist-client/pages/role/role-management.js.map +1 -1
  38. package/dist-client/pages/user/user-management.js +19 -20
  39. package/dist-client/pages/user/user-management.js.map +1 -1
  40. package/dist-client/tsconfig.tsbuildinfo +1 -1
  41. package/package.json +3 -4
@@ -10,7 +10,7 @@ import { client, gqlContext } from '@operato/graphql'
10
10
  import { i18next } from '@operato/i18n'
11
11
  import { openPopup } from '@operato/layout'
12
12
  import { store } from '@operato/shell'
13
- import { CustomAlert } from '@things-factory/shell/client'
13
+ import { OxPrompt } from '@operato/popup/ox-prompt.js'
14
14
 
15
15
  import { RoleSelector } from './role-selector'
16
16
 
@@ -62,14 +62,17 @@ class UserRoleEditor extends connect(store)(LitElement) {
62
62
  [detail] li input {
63
63
  flex: 1;
64
64
  }
65
+
65
66
  [buttons] {
66
67
  margin: 0;
67
- padding: var(--padding-default);
68
+ padding: 5px;
68
69
  background-color: rgba(var(--primary-color-rgb), 0.2);
69
70
  }
71
+
70
72
  mwc-button {
71
- margin-right: var(--padding-narrow);
73
+ margin: 5px;
72
74
  }
75
+
73
76
  [danger] {
74
77
  --mdc-theme-primary: var(--mdc-danger-button-primary-color);
75
78
  }
@@ -122,20 +125,15 @@ class UserRoleEditor extends connect(store)(LitElement) {
122
125
  : ''}
123
126
  </ul>
124
127
 
125
- <role-selector
126
- .roleCategory="${currentDomainName}"
127
- .user="${this.user}"
128
- .roles="${domainRoles}"
129
- .userRoles="${this.userRoles}"
130
- ></role-selector>
128
+ <role-selector .user=${this.user} .roles=${domainRoles} .userRoles=${this.userRoles}></role-selector>
131
129
 
132
130
  ${Object.keys(grantedRoles).map(
133
131
  partnerName => html`
134
132
  <role-selector
135
- .roleCategory="${partnerName}"
136
- .user="${this.user}"
137
- .roles="${this.grantedRoles[partnerName]}"
138
- .userRoles="${this.userRoles}"
133
+ .roleCategory=${partnerName}
134
+ .user=${this.user}
135
+ .roles=${this.grantedRoles[partnerName]}
136
+ .userRoles=${this.userRoles}
139
137
  >
140
138
  </role-selector>
141
139
  `
@@ -398,19 +396,8 @@ class UserRoleEditor extends connect(store)(LitElement) {
398
396
  }
399
397
 
400
398
  async onDelete(user) {
401
- const answer = await CustomAlert({
402
- title: i18next.t('text.are_you_sure'),
403
- text: i18next.t('text.are_you_sure_to_x_user', {
404
- x: i18next.t('button.delete')
405
- }),
406
- confirmButton: { text: i18next.t('button.delete') },
407
- cancelButton: { text: i18next.t('button.cancel') }
408
- })
409
-
410
- if (!answer.value) return
411
-
412
399
  if (user.owner) {
413
- await CustomAlert({
400
+ await OxPrompt.open({
414
401
  type: 'warning',
415
402
  title: i18next.t('text.cannot_delete'),
416
403
  text: i18next.t('text.x_cannot_delete', {
@@ -422,24 +409,35 @@ class UserRoleEditor extends connect(store)(LitElement) {
422
409
  return
423
410
  }
424
411
 
425
- const response = await client.mutate({
426
- mutation: gql`
427
- mutation deleteDomaineUser($email: String!) {
428
- deleteDomainUser(email: $email)
429
- }
430
- `,
431
- variables: { email: user.email },
432
- context: gqlContext()
433
- })
434
-
435
- if (!response.errors) {
436
- await CustomAlert({
437
- type: 'success',
438
- title: i18next.t('text.completed'),
439
- confirmButton: { text: i18next.t('button.confirm') }
412
+ if (
413
+ await OxPrompt.open({
414
+ title: i18next.t('text.are_you_sure'),
415
+ text: i18next.t('text.are_you_sure_to_x_user', {
416
+ x: i18next.t('button.delete')
417
+ }),
418
+ confirmButton: { text: i18next.t('button.delete') },
419
+ cancelButton: { text: i18next.t('button.cancel') }
420
+ })
421
+ ) {
422
+ const response = await client.mutate({
423
+ mutation: gql`
424
+ mutation deleteDomaineUser($email: String!) {
425
+ deleteDomainUser(email: $email)
426
+ }
427
+ `,
428
+ variables: { email: user.email },
429
+ context: gqlContext()
440
430
  })
441
431
 
442
- this.dispatchUserUpdated()
432
+ if (!response.errors) {
433
+ await OxPrompt.open({
434
+ type: 'success',
435
+ title: i18next.t('text.completed'),
436
+ confirmButton: { text: i18next.t('button.confirm') }
437
+ })
438
+
439
+ this.dispatchUserUpdated()
440
+ }
443
441
  }
444
442
  }
445
443
 
@@ -459,32 +457,32 @@ class UserRoleEditor extends connect(store)(LitElement) {
459
457
  }
460
458
 
461
459
  async onResetPassword(user) {
462
- const answer = await CustomAlert({
463
- title: i18next.t('text.are_you_sure'),
464
- text: i18next.t('text.are_you_sure_to_x', { x: i18next.t('title.reset password') }),
465
- confirmButton: { text: i18next.t('button.confirm') },
466
- cancelButton: { text: i18next.t('button.cancel') }
467
- })
468
-
469
- if (!answer.value) return
470
-
471
- const response = await client.mutate({
472
- mutation: gql`
473
- mutation resetPasswordToDefault($userId: String!) {
474
- resetPasswordToDefault(userId: $userId)
475
- }
476
- `,
477
- variables: { userId: user.id },
478
- context: gqlContext()
479
- })
480
-
481
- if (!response.errors) {
482
- await CustomAlert({
483
- type: 'success',
484
- title: i18next.t('text.completed'),
485
- text: i18next.t('text.password reset succeed'),
486
- confirmButton: { text: i18next.t('button.confirm') }
460
+ if (
461
+ await OxPrompt.open({
462
+ title: i18next.t('text.are_you_sure'),
463
+ text: i18next.t('text.are_you_sure_to_x', { x: i18next.t('title.reset password') }),
464
+ confirmButton: { text: i18next.t('button.confirm') },
465
+ cancelButton: { text: i18next.t('button.cancel') }
466
+ })
467
+ ) {
468
+ const response = await client.mutate({
469
+ mutation: gql`
470
+ mutation resetPasswordToDefault($userId: String!) {
471
+ resetPasswordToDefault(userId: $userId)
472
+ }
473
+ `,
474
+ variables: { userId: user.id },
475
+ context: gqlContext()
487
476
  })
477
+
478
+ if (!response.errors) {
479
+ await OxPrompt.open({
480
+ type: 'success',
481
+ title: i18next.t('text.completed'),
482
+ text: i18next.t('text.password reset succeed'),
483
+ confirmButton: { text: i18next.t('button.confirm') }
484
+ })
485
+ }
488
486
  }
489
487
  }
490
488
 
@@ -7,7 +7,7 @@ import { customElement, property, query } from 'lit/decorators.js'
7
7
 
8
8
  import { client } from '@operato/graphql'
9
9
  import { i18next } from '@operato/i18n'
10
- import { CustomAlert } from '@things-factory/shell/client'
10
+ import { OxPrompt } from '@operato/popup/ox-prompt.js'
11
11
 
12
12
  @customElement('oauth2-decision')
13
13
  class OAuth2DecisionPage extends LitElement {
@@ -152,7 +152,7 @@ class OAuth2DecisionPage extends LitElement {
152
152
  async decision(allowOrCancel) {
153
153
  const selectedRoles = this.selectedRoles()
154
154
  if (allowOrCancel && !selectedRoles?.length) {
155
- CustomAlert({
155
+ await OxPrompt.open({
156
156
  title: i18next.t('title.nothing selected'),
157
157
  text: i18next.t('text.should select at least one of x', { x: i18next.t('label.role') }),
158
158
  confirmButton: { text: i18next.t('button.confirm') }
@@ -67,7 +67,6 @@ class RoleManagement extends connect(store)(PageView) {
67
67
 
68
68
  return html`
69
69
  <h2>Roles</h2>
70
- <div subtitle>${i18next.t('text.create role')}</div>
71
70
  <create-role
72
71
  @fetch-roles=${async () => {
73
72
  this.roles = await this.fetchRoles()
@@ -11,7 +11,7 @@ import { customElement, property, query } from 'lit/decorators.js'
11
11
  import { client, gqlContext } from '@operato/graphql'
12
12
  import { i18next } from '@operato/i18n'
13
13
  import { PageView } from '@operato/shell'
14
- import { CustomAlert } from '@things-factory/shell/client'
14
+ import { OxPrompt } from '@operato/popup/ox-prompt.js'
15
15
 
16
16
  @customElement('user-management')
17
17
  class UserManagement extends PageView {
@@ -196,34 +196,34 @@ class UserManagement extends PageView {
196
196
  }
197
197
 
198
198
  async createUser(user) {
199
- const result = await CustomAlert({
200
- title: i18next.t('text.are_you_sure'),
201
- text: i18next.t('text.are_you_sure_to_x_user', { x: i18next.t('button.create') }),
202
- confirmButton: { text: i18next.t('button.confirm') },
203
- cancelButton: { text: i18next.t('button.cancel') }
204
- })
205
-
206
- if (!result.value) return
207
-
208
- const response = await client.mutate({
209
- mutation: gql`
210
- mutation createUser($user: NewUser!) {
211
- createUser(user: $user) {
212
- name
199
+ if (
200
+ await OxPrompt.open({
201
+ title: i18next.t('text.are_you_sure'),
202
+ text: i18next.t('text.are_you_sure_to_x_user', { x: i18next.t('button.create') }),
203
+ confirmButton: { text: i18next.t('button.confirm') },
204
+ cancelButton: { text: i18next.t('button.cancel') }
205
+ })
206
+ ) {
207
+ const response = await client.mutate({
208
+ mutation: gql`
209
+ mutation createUser($user: NewUser!) {
210
+ createUser(user: $user) {
211
+ name
212
+ }
213
213
  }
214
- }
215
- `,
216
- variables: { user },
217
- context: gqlContext()
218
- })
219
-
220
- if (!response.errors) {
221
- await CustomAlert({
222
- title: i18next.t('text.completed'),
223
- confirmButton: { text: i18next.t('button.confirm') }
214
+ `,
215
+ variables: { user },
216
+ context: gqlContext()
224
217
  })
225
218
 
226
- await this.refreshUsers()
219
+ if (!response.errors) {
220
+ await OxPrompt.open({
221
+ title: i18next.t('text.completed'),
222
+ confirmButton: { text: i18next.t('button.confirm') }
223
+ })
224
+
225
+ await this.refreshUsers()
226
+ }
227
227
  }
228
228
  }
229
229
 
@@ -5,7 +5,7 @@ import { css, html, LitElement } from 'lit';
5
5
  import { customElement, query } from 'lit/decorators.js';
6
6
  import { client } from '@operato/graphql';
7
7
  import { i18next, localize } from '@operato/i18n';
8
- import { CustomAlert } from '@things-factory/shell/client';
8
+ import { OxPrompt } from '@operato/popup/ox-prompt.js';
9
9
  let CreateDomainPopup = class CreateDomainPopup extends localize(i18next)(LitElement) {
10
10
  render() {
11
11
  return html `
@@ -63,7 +63,7 @@ let CreateDomainPopup = class CreateDomainPopup extends localize(i18next)(LitEle
63
63
  variables: { domainInput }
64
64
  });
65
65
  if (!response.errors) {
66
- await CustomAlert({
66
+ await OxPrompt.open({
67
67
  type: 'success',
68
68
  title: i18next.t('text.completed'),
69
69
  text: i18next.t('text.x_created_successfully', { x: i18next.t('label.domain') }),
@@ -1 +1 @@
1
- {"version":3,"file":"create-domain-popup.js","sourceRoot":"","sources":["../../client/components/create-domain-popup.ts"],"names":[],"mappings":";AAAA,OAAO,sBAAsB,CAAA;AAE7B,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAA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AG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuCF;CACF,CAAA;AAED;IAAC,KAAK,CAAC,oBAAoB,CAAC;8BAAa,gBAAgB;oDAAA;AA5CrD,iBAAiB;IADtB,aAAa,CAAC,qBAAqB,CAAC;GAC/B,iBAAiB,CA6HtB","sourcesContent":["import '@material/mwc-button'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, query } from 'lit/decorators.js'\n\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { CustomAlert } from '@things-factory/shell/client'\n\n@customElement('create-domain-popup')\nclass CreateDomainPopup extends localize(i18next)(LitElement) {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n background-color: var(--main-section-background-color);\n padding: var(--padding-wide);\n overflow: auto;\n }\n input.checkValidName {\n background-color: #fce6e6;\n }\n mwc-button {\n display: flex;\n justify-content: center;\n }\n label {\n display: flex;\n flex-direction: column;\n\n font: var(--label-font);\n color: var(--label-color);\n text-transform: var(--label-text-transform);\n }\n input {\n border: var(--border-dark-color);\n border-radius: var(--border-radius);\n margin: var(--input-margin);\n padding: var(--input-padding);\n background-color: var(--theme-white-color);\n font: var(--input-font);\n\n flex: 1;\n }\n [field] {\n grid-column: span 2;\n }\n [buttons] {\n margin-top: auto;\n }\n `\n ]\n\n @query('input[name=\"name\"]') nameInput!: HTMLInputElement\n\n render() {\n return html`\n <div field grid-span>\n <label\n >${i18next.t('label.x name', { x: i18next.t('label.domain') })}<input\n type=\"text\"\n name=\"name\"\n @input=${this.checkValidation}\n autofocus\n /></label>\n </div>\n\n <div field grid-span>\n <label>${i18next.t('label.description')}<input type=\"text\" name=\"description\" /></label>\n </div>\n\n <div buttons>\n <mwc-button raised @click=${e => this.onCreateDomain()}>${i18next.t('button.create')}</mwc-button>\n </div>\n `\n }\n\n firstUpdated() {\n this.nameInput.focus() // autofocus\n }\n\n get inputData() {\n return this.renderRoot.querySelectorAll('input')\n }\n\n checkValidation(e) {\n const currentInput = e.currentTarget\n const regExp = /^[a-zA-Z ]+$/\n\n if (!regExp.test(currentInput.value)) {\n currentInput.classList.add('checkValidName')\n } else {\n currentInput.classList.remove('checkValidName')\n }\n }\n\n async onCreateDomain() {\n const domainInput: { [prop: string]: string } = {}\n this.inputData.forEach(data => (domainInput[data.name] = data.value))\n const regExp = /^[a-zA-z0-9- ]+$/\n\n if (!regExp.test(domainInput.name)) {\n return this.showToast(i18next.t('error: domain name should consist only of letters or dashes'))\n }\n\n const response = await client.mutate({\n mutation: gql`\n mutation domainRegister($domainInput: DomainGeneratorInput!) {\n domainRegister(domainInput: $domainInput) {\n id\n name\n }\n }\n `,\n variables: { domainInput }\n })\n\n if (!response.errors) {\n await CustomAlert({\n type: 'success',\n title: i18next.t('text.completed'),\n text: i18next.t('text.x_created_successfully', { x: i18next.t('label.domain') }),\n confirmButton: { text: i18next.t('button.confirm') }\n })\n\n history.back()\n\n this.dispatchEvent(new CustomEvent('fetch-data'))\n }\n }\n\n showToast(message) {\n document.dispatchEvent(new CustomEvent('notify', { detail: { message } }))\n }\n}\n"]}
1
+ {"version":3,"file":"create-domain-popup.js","sourceRoot":"","sources":["../../client/components/create-domain-popup.ts"],"names":[],"mappings":";AAAA,OAAO,sBAAsB,CAAA;AAE7B,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAGtD,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,QAAQ,CAAC,OAAO,CA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AAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,6DAA6D,CAAC,CAAC,CAAA;SAChG;QAED,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;YACnC,QAAQ,EAAE,GAAG,CAAA;;;;;;;OAOZ;YACD,SAAS,EAAE,EAAE,WAAW,EAAE;SAC3B,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;YACpB,MAAM,QAAQ,CAAC,IAAI,CAAC;gBAClB,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC;gBAClC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,6BAA6B,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC;gBAChF,aAAa,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,EAAE;aACrD,CAAC,CAAA;YAEF,OAAO,CAAC,IAAI,EAAE,CAAA;YAEd,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,YAAY,CAAC,CAAC,CAAA;SAClD;IACH,CAAC;IAED,SAAS,CAAC,OAAO;QACf,QAAQ,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;IAC5E,CAAC;;AA3HM,wBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuCF;CACF,CAAA;AAED;IAAC,KAAK,CAAC,oBAAoB,CAAC;8BAAa,gBAAgB;oDAAA;AA5CrD,iBAAiB;IADtB,aAAa,CAAC,qBAAqB,CAAC;GAC/B,iBAAiB,CA6HtB","sourcesContent":["import '@material/mwc-button'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, query } from 'lit/decorators.js'\n\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\n\n@customElement('create-domain-popup')\nclass CreateDomainPopup extends localize(i18next)(LitElement) {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n background-color: var(--main-section-background-color);\n padding: var(--padding-wide);\n overflow: auto;\n }\n input.checkValidName {\n background-color: #fce6e6;\n }\n mwc-button {\n display: flex;\n justify-content: center;\n }\n label {\n display: flex;\n flex-direction: column;\n\n font: var(--label-font);\n color: var(--label-color);\n text-transform: var(--label-text-transform);\n }\n input {\n border: var(--border-dark-color);\n border-radius: var(--border-radius);\n margin: var(--input-margin);\n padding: var(--input-padding);\n background-color: var(--theme-white-color);\n font: var(--input-font);\n\n flex: 1;\n }\n [field] {\n grid-column: span 2;\n }\n [buttons] {\n margin-top: auto;\n }\n `\n ]\n\n @query('input[name=\"name\"]') nameInput!: HTMLInputElement\n\n render() {\n return html`\n <div field grid-span>\n <label\n >${i18next.t('label.x name', { x: i18next.t('label.domain') })}<input\n type=\"text\"\n name=\"name\"\n @input=${this.checkValidation}\n autofocus\n /></label>\n </div>\n\n <div field grid-span>\n <label>${i18next.t('label.description')}<input type=\"text\" name=\"description\" /></label>\n </div>\n\n <div buttons>\n <mwc-button raised @click=${e => this.onCreateDomain()}>${i18next.t('button.create')}</mwc-button>\n </div>\n `\n }\n\n firstUpdated() {\n this.nameInput.focus() // autofocus\n }\n\n get inputData() {\n return this.renderRoot.querySelectorAll('input')\n }\n\n checkValidation(e) {\n const currentInput = e.currentTarget\n const regExp = /^[a-zA-Z ]+$/\n\n if (!regExp.test(currentInput.value)) {\n currentInput.classList.add('checkValidName')\n } else {\n currentInput.classList.remove('checkValidName')\n }\n }\n\n async onCreateDomain() {\n const domainInput: { [prop: string]: string } = {}\n this.inputData.forEach(data => (domainInput[data.name] = data.value))\n const regExp = /^[a-zA-z0-9- ]+$/\n\n if (!regExp.test(domainInput.name)) {\n return this.showToast(i18next.t('error: domain name should consist only of letters or dashes'))\n }\n\n const response = await client.mutate({\n mutation: gql`\n mutation domainRegister($domainInput: DomainGeneratorInput!) {\n domainRegister(domainInput: $domainInput) {\n id\n name\n }\n }\n `,\n variables: { domainInput }\n })\n\n if (!response.errors) {\n await OxPrompt.open({\n type: 'success',\n title: i18next.t('text.completed'),\n text: i18next.t('text.x_created_successfully', { x: i18next.t('label.domain') }),\n confirmButton: { text: i18next.t('button.confirm') }\n })\n\n history.back()\n\n this.dispatchEvent(new CustomEvent('fetch-data'))\n }\n }\n\n showToast(message) {\n document.dispatchEvent(new CustomEvent('notify', { detail: { message } }))\n }\n}\n"]}
@@ -5,22 +5,26 @@ import { css, html, LitElement } from 'lit';
5
5
  import { customElement, query } from 'lit/decorators.js';
6
6
  import { client, gqlContext } from '@operato/graphql';
7
7
  import { i18next, localize } from '@operato/i18n';
8
- import { CustomAlert } from '@things-factory/shell/client';
8
+ import { OxPrompt } from '@operato/popup/ox-prompt.js';
9
9
  let CreateRole = class CreateRole extends localize(i18next)(LitElement) {
10
10
  render() {
11
11
  return html `
12
12
  <mwc-textfield
13
13
  type="text"
14
14
  name="name"
15
- label=${i18next.t('label.x name', { x: i18next.t('label.role') })}
15
+ label=${String(i18next.t('label.x name', { x: i18next.t('label.role') }))}
16
16
  ></mwc-textfield>
17
17
  <mwc-textfield
18
18
  type="text"
19
19
  name="description"
20
- label=${i18next.t('label.x description', { x: i18next.t('label.role') })}
20
+ label=${String(i18next.t('label.x description', { x: i18next.t('label.role') }))}
21
21
  ></mwc-textfield>
22
22
 
23
- <mwc-button @click=${this.onCreateRole.bind(this)} outlined label="${i18next.t('button.create')}"></mwc-button>
23
+ <mwc-button
24
+ @click=${this.onCreateRole.bind(this)}
25
+ outlined
26
+ label=${String(i18next.t('button.create'))}
27
+ ></mwc-button>
24
28
  `;
25
29
  }
26
30
  async onCreateRole() {
@@ -32,35 +36,34 @@ let CreateRole = class CreateRole extends localize(i18next)(LitElement) {
32
36
  }
33
37
  role.name = name;
34
38
  role.description = description;
35
- const result = await CustomAlert({
39
+ if (await OxPrompt.open({
36
40
  title: i18next.t('text.are_you_sure'),
37
41
  text: i18next.t('text.do_you_want_to_create_x', { x: i18next.t('label.role') }),
38
42
  confirmButton: { text: i18next.t('button.confirm') },
39
43
  cancelButton: { text: i18next.t('button.cancel') }
40
- });
41
- if (!result.value)
42
- return;
43
- const response = await client.mutate({
44
- mutation: gql `
45
- mutation createRole($role: NewRole!) {
46
- createRole(role: $role) {
47
- name
44
+ })) {
45
+ const response = await client.mutate({
46
+ mutation: gql `
47
+ mutation createRole($role: NewRole!) {
48
+ createRole(role: $role) {
49
+ name
50
+ }
48
51
  }
49
- }
50
- `,
51
- variables: { role },
52
- context: gqlContext()
53
- });
54
- if (!response.errors) {
55
- await this.dispatchEvent(new CustomEvent('fetch-roles'));
56
- await CustomAlert({
57
- type: 'success',
58
- title: i18next.t('text.completed'),
59
- text: i18next.t('text.data_uploaded_successfully'),
60
- confirmButton: { text: i18next.t('button.confirm') }
52
+ `,
53
+ variables: { role },
54
+ context: gqlContext()
61
55
  });
62
- this.nameInput.value = '';
63
- this.descriptionInput.value = '';
56
+ if (!response.errors) {
57
+ await this.dispatchEvent(new CustomEvent('fetch-roles'));
58
+ await OxPrompt.open({
59
+ type: 'success',
60
+ title: i18next.t('text.completed'),
61
+ text: i18next.t('text.data_uploaded_successfully'),
62
+ confirmButton: { text: i18next.t('button.confirm') }
63
+ });
64
+ this.nameInput.value = '';
65
+ this.descriptionInput.value = '';
66
+ }
64
67
  }
65
68
  }
66
69
  showToast(message) {
@@ -1 +1 @@
1
- {"version":3,"file":"create-role.js","sourceRoot":"","sources":["../../client/components/create-role.ts"],"names":[],"mappings":";AAAA,OAAO,yBAAyB,CAAA;AAEhC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,K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AAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IACrG,CAAC;;AA1GM,iBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiClB,CAAA;AAED;IAAC,KAAK,CAAC,aAAa,CAAC;8BAAa,gBAAgB;6CAAA;AAClD;IAAC,KAAK,CAAC,oBAAoB,CAAC;8BAAoB,gBAAgB;oDAAA;AArC5D,UAAU;IADf,aAAa,CAAC,aAAa,CAAC;GACvB,UAAU,CA4Gf","sourcesContent":["import '@material/mwc-textfield'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, query } from 'lit/decorators.js'\n\nimport { client, gqlContext } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { CustomAlert } from '@things-factory/shell/client'\n\n@customElement('create-role')\nclass CreateRole extends localize(i18next)(LitElement) {\n static styles = css`\n :host {\n --mdc-text-field-fill-color: var(--theme-white-color);\n background-color: var(--theme-white-color);\n margin: var(--margin-wide) 0;\n padding: var(--padding-wide);\n border-radius: var(--border-radius);\n box-shadow: var(--box-shadow);\n\n display: grid;\n grid-template-columns: 1fr 2fr auto;\n gap: 5px 15px;\n clear: both;\n max-width: var(--input-container-max-width);\n\n align-items: center;\n }\n\n mwc-button {\n margin: var(--input-margin);\n }\n\n @media screen and (max-width: 480px) {\n :host {\n grid-template-columns: 1fr 1fr;\n }\n\n mwc-button {\n grid-column: span 2;\n\n margin: var(--input-margin);\n }\n }\n `\n\n @query('[name=name]') nameInput!: HTMLInputElement\n @query('[name=description]') descriptionInput!: HTMLInputElement\n\n render() {\n return html`\n <mwc-textfield\n type=\"text\"\n name=\"name\"\n label=${i18next.t('label.x name', { x: i18next.t('label.role') })}\n ></mwc-textfield>\n <mwc-textfield\n type=\"text\"\n name=\"description\"\n label=${i18next.t('label.x description', { x: i18next.t('label.role') })}\n ></mwc-textfield>\n\n <mwc-button @click=${this.onCreateRole.bind(this)} outlined label=\"${i18next.t('button.create')}\"></mwc-button>\n `\n }\n\n async onCreateRole() {\n let role: { name?: string; description?: string } = {}\n\n const name = this.nameInput.value.trim()\n const description = this.descriptionInput.value\n\n if (!name) {\n return this.showToast(i18next.t('error.value is empty', { value: i18next.t('field.name') }))\n }\n\n role.name = name\n role.description = description\n\n const result = await CustomAlert({\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.do_you_want_to_create_x', { x: i18next.t('label.role') }),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n\n if (!result.value) return\n\n const response = await client.mutate({\n mutation: gql`\n mutation createRole($role: NewRole!) {\n createRole(role: $role) {\n name\n }\n }\n `,\n variables: { role },\n context: gqlContext()\n })\n\n if (!response.errors) {\n await this.dispatchEvent(new CustomEvent('fetch-roles'))\n\n await CustomAlert({\n type: 'success',\n title: i18next.t('text.completed'),\n text: i18next.t('text.data_uploaded_successfully'),\n confirmButton: { text: i18next.t('button.confirm') }\n })\n\n this.nameInput.value = ''\n this.descriptionInput.value = ''\n }\n }\n\n showToast(message) {\n document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))\n }\n}\n"]}
1
+ {"version":3,"file":"create-role.js","sourceRoot":"","sources":["../../client/components/create-role.ts"],"names":[],"mappings":";AAAA,OAAO,yBAAyB,CAAA;AAEhC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAGtD,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,QAAQ,C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B,CAAC;8BAAoB,gBAAgB;oDAAA;AArC5D,UAAU;IADf,aAAa,CAAC,aAAa,CAAC;GACvB,UAAU,CAgHf","sourcesContent":["import '@material/mwc-textfield'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, query } from 'lit/decorators.js'\n\nimport { client, gqlContext } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\n\n@customElement('create-role')\nclass CreateRole extends localize(i18next)(LitElement) {\n static styles = css`\n :host {\n --mdc-text-field-fill-color: var(--theme-white-color);\n background-color: var(--theme-white-color);\n margin: var(--margin-wide) 0;\n padding: var(--padding-wide);\n border-radius: var(--border-radius);\n box-shadow: var(--box-shadow);\n\n display: grid;\n grid-template-columns: 1fr 2fr auto;\n gap: 5px 15px;\n clear: both;\n max-width: var(--input-container-max-width);\n\n align-items: center;\n }\n\n mwc-button {\n margin: var(--input-margin);\n }\n\n @media screen and (max-width: 480px) {\n :host {\n grid-template-columns: 1fr 1fr;\n }\n\n mwc-button {\n grid-column: span 2;\n\n margin: var(--input-margin);\n }\n }\n `\n\n @query('[name=name]') nameInput!: HTMLInputElement\n @query('[name=description]') descriptionInput!: HTMLInputElement\n\n render() {\n return html`\n <mwc-textfield\n type=\"text\"\n name=\"name\"\n label=${String(i18next.t('label.x name', { x: i18next.t('label.role') }))}\n ></mwc-textfield>\n <mwc-textfield\n type=\"text\"\n name=\"description\"\n label=${String(i18next.t('label.x description', { x: i18next.t('label.role') }))}\n ></mwc-textfield>\n\n <mwc-button\n @click=${this.onCreateRole.bind(this)}\n outlined\n label=${String(i18next.t('button.create'))}\n ></mwc-button>\n `\n }\n\n async onCreateRole() {\n let role: { name?: string; description?: string } = {}\n\n const name = this.nameInput.value.trim()\n const description = this.descriptionInput.value\n\n if (!name) {\n return this.showToast(i18next.t('error.value is empty', { value: i18next.t('field.name') }))\n }\n\n role.name = name\n role.description = description\n\n if (\n await OxPrompt.open({\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.do_you_want_to_create_x', { x: i18next.t('label.role') }),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) {\n const response = await client.mutate({\n mutation: gql`\n mutation createRole($role: NewRole!) {\n createRole(role: $role) {\n name\n }\n }\n `,\n variables: { role },\n context: gqlContext()\n })\n\n if (!response.errors) {\n await this.dispatchEvent(new CustomEvent('fetch-roles'))\n\n await OxPrompt.open({\n type: 'success',\n title: i18next.t('text.completed'),\n text: i18next.t('text.data_uploaded_successfully'),\n confirmButton: { text: i18next.t('button.confirm') }\n })\n\n this.nameInput.value = ''\n this.descriptionInput.value = ''\n }\n }\n }\n\n showToast(message) {\n document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))\n }\n}\n"]}
@@ -5,28 +5,19 @@ import { i18next } from '@operato/i18n';
5
5
  let CreateUser = class CreateUser extends LitElement {
6
6
  render() {
7
7
  return html `
8
- <div field-2column>
9
- <div field>
10
- <label
11
- >${i18next.t('label.x name', { x: i18next.t('label.user') })}
12
- <input name="name" type="text" required />
13
- </label>
14
- </div>
15
- <div field>
16
- <label
17
- >${i18next.t('field.email')}
18
- <input name="email" type="email" required autocapitalize="off" />
19
- </label>
20
- </div>
8
+ <mwc-textfield
9
+ type="text"
10
+ name="name"
11
+ label=${String(i18next.t('label.x name', { x: i18next.t('label.user') }))}
12
+ ></mwc-textfield>
21
13
 
22
- <div>
23
- <mwc-button
24
- @click=${this.onCreateUser.bind(this)}
25
- outlined
26
- label="${i18next.t('button.create')}"
27
- ></mwc-button>
28
- </div>
29
- </div>
14
+ <mwc-textfield type="email" name="email" label=${String(i18next.t('field.email'))}></mwc-textfield>
15
+
16
+ <mwc-button
17
+ @click=${this.onCreateUser.bind(this)}
18
+ outlined
19
+ label=${String(i18next.t('button.create'))}
20
+ ></mwc-button>
30
21
  `;
31
22
  }
32
23
  async onCreateUser() {
@@ -56,61 +47,45 @@ let CreateUser = class CreateUser extends LitElement {
56
47
  }
57
48
  };
58
49
  CreateUser.styles = css `
59
- [field-2column] {
50
+ :host {
51
+ --mdc-text-field-fill-color: var(--theme-white-color);
60
52
  background-color: var(--theme-white-color);
61
53
  margin: var(--margin-wide) 0;
62
54
  padding: var(--padding-wide);
63
55
  border-radius: var(--border-radius);
64
56
  box-shadow: var(--box-shadow);
57
+
65
58
  display: grid;
66
- grid-template-columns: 1fr 1fr;
59
+ grid-template-columns: 1fr 2fr auto;
67
60
  gap: 5px 15px;
68
61
  clear: both;
69
62
  max-width: var(--input-container-max-width);
70
- }
71
- [field] {
72
- display: flex;
73
- flex-direction: column;
74
- padding-bottom: var(--padding-default);
75
- }
76
- [grid-span] {
77
- grid-column: span 2;
78
- }
79
63
 
80
- input {
81
- border: var(--border-dark-color);
82
- border-radius: var(--border-radius);
83
- margin: var(--input-margin);
84
- padding: var(--input-padding);
85
- min-width: 250px;
86
- font: var(--input-font);
64
+ align-items: center;
87
65
  }
88
- label {
89
- display: flex;
90
- flex-direction: column;
91
66
 
92
- font: var(--label-font);
93
- color: var(--label-color);
94
- text-transform: var(--label-text-transform);
95
- }
96
67
  mwc-button {
97
68
  margin: var(--input-margin);
98
69
  }
70
+
99
71
  @media screen and (max-width: 480px) {
100
- div {
101
- display: grid;
72
+ :host {
73
+ grid-template-columns: 1fr 1fr;
102
74
  }
103
- [field] {
75
+
76
+ mwc-button {
104
77
  grid-column: span 2;
78
+
79
+ margin: var(--input-margin);
105
80
  }
106
81
  }
107
82
  `;
108
83
  __decorate([
109
- query('input[name=name]'),
84
+ query('[name=name]'),
110
85
  __metadata("design:type", HTMLInputElement)
111
86
  ], CreateUser.prototype, "nameInput", void 0);
112
87
  __decorate([
113
- query('input[name=email]'),
88
+ query('[name=email]'),
114
89
  __metadata("design:type", HTMLInputElement)
115
90
  ], CreateUser.prototype, "emailInput", void 0);
116
91
  CreateUser = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"create-user.js","source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aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;YAE1E,IAAI,CAAC,SAAS,CAAC,KAAK,GAAG,EAAE,CAAA;YACzB,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,EAAE,CAAA;SAC3B;QAAC,OAAO,CAAM,EAAE;YACf,QAAQ,CAAC,aAAa,CACpB,IAAI,WAAW,CAAC,QAAQ,EAAE;gBACxB,MAAM,EAAE;oBACN,KAAK,EAAE,OAAO;oBACd,OAAO,EAAE,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;iBACxC;aACF,CAAC,CACH,CAAA;SACF;IACH,CAAC;;AA9GM,iBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDlB,CAAA;AAED;IAAC,KAAK,CAAC,kBAAkB,CAAC;8BAAa,gBAAgB;6CAAA;AACvD;IAAC,KAAK,CAAC,mBAAmB,CAAC;8BAAc,gBAAgB;8CAAA;AArDrD,UAAU;IADf,aAAa,CAAC,aAAa,CAAC;GACvB,UAAU,CAgHf","sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { customElement, query } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\n\n@customElement('create-user')\nclass CreateUser extends LitElement {\n static styles = css`\n [field-2column] {\n background-color: var(--theme-white-color);\n margin: var(--margin-wide) 0;\n padding: var(--padding-wide);\n border-radius: var(--border-radius);\n box-shadow: var(--box-shadow);\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 5px 15px;\n clear: both;\n max-width: var(--input-container-max-width);\n }\n [field] {\n display: flex;\n flex-direction: column;\n padding-bottom: var(--padding-default);\n }\n [grid-span] {\n grid-column: span 2;\n }\n\n input {\n border: var(--border-dark-color);\n border-radius: var(--border-radius);\n margin: var(--input-margin);\n padding: var(--input-padding);\n min-width: 250px;\n font: var(--input-font);\n }\n label {\n display: flex;\n flex-direction: column;\n\n font: var(--label-font);\n color: var(--label-color);\n text-transform: var(--label-text-transform);\n }\n mwc-button {\n margin: var(--input-margin);\n }\n @media screen and (max-width: 480px) {\n div {\n display: grid;\n }\n [field] {\n grid-column: span 2;\n }\n }\n `\n\n @query('input[name=name]') nameInput!: HTMLInputElement\n @query('input[name=email]') emailInput!: HTMLInputElement\n\n render() {\n return html`\n <div field-2column>\n <div field>\n <label\n >${i18next.t('label.x name', { x: i18next.t('label.user') })}\n <input name=\"name\" type=\"text\" required />\n </label>\n </div>\n <div field>\n <label\n >${i18next.t('field.email')}\n <input name=\"email\" type=\"email\" required autocapitalize=\"off\" />\n </label>\n </div>\n\n <div>\n <mwc-button\n @click=${this.onCreateUser.bind(this)}\n outlined\n label=\"${i18next.t('button.create')}\"\n ></mwc-button>\n </div>\n </div>\n `\n }\n\n async onCreateUser() {\n try {\n if (!this.emailInput.checkValidity()) {\n throw new Error(i18next.t('error.not valid pattern of type', { type: 'e-mail' }))\n }\n\n if (!this.nameInput.value) {\n throw new Error(i18next.t('error.value is empty', { value: 'name' }))\n }\n\n const user = {\n name: this.nameInput.value.trim(),\n email: this.emailInput.value.trim()\n }\n\n await this.dispatchEvent(new CustomEvent('create-user', { detail: user }))\n\n this.nameInput.value = ''\n this.emailInput.value = ''\n } catch (e: any) {\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n level: 'error',\n message: 'message' in e ? e.message : e\n }\n })\n )\n }\n }\n}\n"]}
1
+ {"version":3,"file":"create-user.js","sourceRoot":"","sources":["../../client/components/create-user.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,UAAU;IAu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,WAAW,CAAC,QAAQ,EAAE;gBACxB,MAAM,EAAE;oBACN,KAAK,EAAE,OAAO;oBACd,OAAO,EAAE,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;iBACxC;aACF,CAAC,CACH,CAAA;SACF;IACH,CAAC;;AArFM,iBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiClB,CAAA;AAED;IAAC,KAAK,CAAC,aAAa,CAAC;8BAAa,gBAAgB;6CAAA;AAClD;IAAC,KAAK,CAAC,cAAc,CAAC;8BAAc,gBAAgB;8CAAA;AArChD,UAAU;IADf,aAAa,CAAC,aAAa,CAAC;GACvB,UAAU,CAuFf","sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { customElement, query } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\n\n@customElement('create-user')\nclass CreateUser extends LitElement {\n static styles = css`\n :host {\n --mdc-text-field-fill-color: var(--theme-white-color);\n background-color: var(--theme-white-color);\n margin: var(--margin-wide) 0;\n padding: var(--padding-wide);\n border-radius: var(--border-radius);\n box-shadow: var(--box-shadow);\n\n display: grid;\n grid-template-columns: 1fr 2fr auto;\n gap: 5px 15px;\n clear: both;\n max-width: var(--input-container-max-width);\n\n align-items: center;\n }\n\n mwc-button {\n margin: var(--input-margin);\n }\n\n @media screen and (max-width: 480px) {\n :host {\n grid-template-columns: 1fr 1fr;\n }\n\n mwc-button {\n grid-column: span 2;\n\n margin: var(--input-margin);\n }\n }\n `\n\n @query('[name=name]') nameInput!: HTMLInputElement\n @query('[name=email]') emailInput!: HTMLInputElement\n\n render() {\n return html`\n <mwc-textfield\n type=\"text\"\n name=\"name\"\n label=${String(i18next.t('label.x name', { x: i18next.t('label.user') }))}\n ></mwc-textfield>\n\n <mwc-textfield type=\"email\" name=\"email\" label=${String(i18next.t('field.email'))}></mwc-textfield>\n\n <mwc-button\n @click=${this.onCreateUser.bind(this)}\n outlined\n label=${String(i18next.t('button.create'))}\n ></mwc-button>\n `\n }\n\n async onCreateUser() {\n try {\n if (!this.emailInput.checkValidity()) {\n throw new Error(i18next.t('error.not valid pattern of type', { type: 'e-mail' }))\n }\n\n if (!this.nameInput.value) {\n throw new Error(i18next.t('error.value is empty', { value: 'name' }))\n }\n\n const user = {\n name: this.nameInput.value.trim(),\n email: this.emailInput.value.trim()\n }\n\n await this.dispatchEvent(new CustomEvent('create-user', { detail: user }))\n\n this.nameInput.value = ''\n this.emailInput.value = ''\n } catch (e: any) {\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n level: 'error',\n message: 'message' in e ? e.message : e\n }\n })\n )\n }\n }\n}\n"]}