@things-factory/auth-ui 8.0.0-beta.8 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/auth-style-sign.ts +194 -0
- package/client/bootstrap.ts +51 -0
- package/client/components/abstract-auth-page.ts +301 -0
- package/client/components/abstract-password-reset.ts +168 -0
- package/client/components/abstract-sign.ts +127 -0
- package/client/components/change-password.ts +153 -0
- package/client/components/contact-us.ts +113 -0
- package/client/components/create-domain-popup.ts +141 -0
- package/client/components/create-role.ts +123 -0
- package/client/components/create-user.ts +95 -0
- package/client/components/credential-manager.ts +64 -0
- package/client/components/delete-user-popup.ts +117 -0
- package/client/components/domain-switch.ts +127 -0
- package/client/components/invite-customer.ts +104 -0
- package/client/components/invite-user.ts +96 -0
- package/client/components/my-login-history.ts +101 -0
- package/client/components/ownership-transfer-popup.ts +110 -0
- package/client/components/partner-info-card.ts +89 -0
- package/client/components/partner-role-editor.ts +153 -0
- package/client/components/profile-component.ts +332 -0
- package/client/components/role-edit-form.ts +92 -0
- package/client/components/role-privilege-editor.ts +267 -0
- package/client/components/role-selector.ts +102 -0
- package/client/components/user-role-editor.ts +499 -0
- package/client/constants/application.ts +9 -0
- package/client/constants/index.ts +1 -0
- package/client/entries/auth/activate.ts +272 -0
- package/client/entries/auth/checkin.ts +190 -0
- package/client/entries/auth/forgot-password.ts +103 -0
- package/client/entries/auth/reset-password.ts +22 -0
- package/client/entries/auth/result.ts +193 -0
- package/client/entries/auth/signin.ts +18 -0
- package/client/entries/auth/signup.ts +109 -0
- package/client/entries/auth/unlock-user.ts +22 -0
- package/client/entries/oauth2/oauth2-decision-error-page.ts +50 -0
- package/client/entries/oauth2/oauth2-decision-page.ts +196 -0
- package/client/entries/public/home.ts +246 -0
- package/client/index.ts +124 -0
- package/client/pages/app-binding/app-binding.ts +423 -0
- package/client/pages/app-binding/app-bindings.ts +171 -0
- package/client/pages/appliance/appliance.ts +452 -0
- package/client/pages/appliance/home.ts +177 -0
- package/client/pages/appliance/register.ts +183 -0
- package/client/pages/application/application.ts +428 -0
- package/client/pages/application/applications.ts +182 -0
- package/client/pages/application/register.ts +211 -0
- package/client/pages/attribute/attribute-set-item-list.ts +237 -0
- package/client/pages/attribute/attribute-set-management.ts +282 -0
- package/client/pages/auth-provider/auth-provider-management.ts +381 -0
- package/client/pages/domain/domain-management.ts +410 -0
- package/client/pages/partner/partner-management.ts +112 -0
- package/client/pages/profile.ts +32 -0
- package/client/pages/role/role-management.ts +134 -0
- package/client/pages/user/user-management.ts +224 -0
- package/client/route.ts +67 -0
- package/client/themes/auth-theme.css +65 -0
- package/client/utils/password-rule.ts +37 -0
- package/dist-client/components/abstract-auth-page.js +10 -10
- package/dist-client/components/abstract-auth-page.js.map +1 -1
- package/dist-client/components/abstract-password-reset.d.ts +2 -1
- package/dist-client/components/abstract-password-reset.js +14 -7
- package/dist-client/components/abstract-password-reset.js.map +1 -1
- package/dist-client/components/abstract-sign.js +11 -12
- package/dist-client/components/abstract-sign.js.map +1 -1
- package/dist-client/components/contact-us.d.ts +1 -1
- package/dist-client/components/contact-us.js +7 -10
- package/dist-client/components/contact-us.js.map +1 -1
- package/dist-client/components/create-user.js +5 -28
- package/dist-client/components/create-user.js.map +1 -1
- package/dist-client/components/invite-user.js +11 -19
- package/dist-client/components/invite-user.js.map +1 -1
- package/dist-client/components/ownership-transfer-popup.js +3 -3
- package/dist-client/components/ownership-transfer-popup.js.map +1 -1
- package/dist-client/components/profile-component.d.ts +1 -5
- package/dist-client/components/profile-component.js +4 -64
- package/dist-client/components/profile-component.js.map +1 -1
- package/dist-client/components/role-privilege-editor.js +1 -2
- package/dist-client/components/role-privilege-editor.js.map +1 -1
- package/dist-client/components/user-role-editor.js +18 -18
- package/dist-client/components/user-role-editor.js.map +1 -1
- package/dist-client/entries/auth/checkin.js +1 -1
- package/dist-client/entries/auth/checkin.js.map +1 -1
- package/dist-client/entries/auth/forgot-password.js +2 -11
- package/dist-client/entries/auth/forgot-password.js.map +1 -1
- package/dist-client/entries/auth/signup.js +7 -13
- package/dist-client/entries/auth/signup.js.map +1 -1
- package/dist-client/index.js +1 -1
- package/dist-client/index.js.map +1 -1
- package/dist-client/pages/user/user-management.d.ts +1 -5
- package/dist-client/pages/user/user-management.js +7 -6
- package/dist-client/pages/user/user-management.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
- package/server/index.ts +0 -0
- package/translations/en.json +2 -6
- package/translations/ja.json +2 -6
- package/translations/ko.json +2 -6
- package/translations/ms.json +2 -6
- package/translations/zh.json +2 -6
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import '@material/web/button/elevated-button.js'
|
|
2
|
+
import '@material/web/button/outlined-button.js'
|
|
3
|
+
|
|
4
|
+
import gql from 'graphql-tag'
|
|
5
|
+
import { css, html } from 'lit'
|
|
6
|
+
import { customElement, property } from 'lit/decorators.js'
|
|
7
|
+
import { connect } from 'pwa-helpers/connect-mixin.js'
|
|
8
|
+
|
|
9
|
+
import { client } from '@operato/graphql'
|
|
10
|
+
import { navigate, PageView, store } from '@operato/shell'
|
|
11
|
+
|
|
12
|
+
@customElement('applications-page')
|
|
13
|
+
class Applications extends connect(store)(PageView) {
|
|
14
|
+
static styles = [
|
|
15
|
+
css`
|
|
16
|
+
:host {
|
|
17
|
+
background-color: var(--md-sys-color-background);
|
|
18
|
+
padding: var(--spacing-large);
|
|
19
|
+
|
|
20
|
+
overflow: auto;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
md-elevated-button {
|
|
24
|
+
text-transform: capitalize;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
md-outlined-button {
|
|
28
|
+
float: right;
|
|
29
|
+
margin-top: var(--spacing-medium);
|
|
30
|
+
text-transform: capitalize;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
h2 {
|
|
34
|
+
margin: var(--title-margin);
|
|
35
|
+
font: var(--title-font);
|
|
36
|
+
color: var(--title-text-color);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
[page-description] {
|
|
40
|
+
margin: var(--page-description-margin);
|
|
41
|
+
font: var(--page-description-font);
|
|
42
|
+
color: var(--page-description-color);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
table {
|
|
46
|
+
margin: var(--spacing-large) 0;
|
|
47
|
+
width: 100%;
|
|
48
|
+
border-collapse: collapse;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
tr {
|
|
52
|
+
background-color: var(--tr-background-color);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
tr:nth-child(odd) {
|
|
56
|
+
background-color: var(--tr-background-odd-color);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
tr:hover {
|
|
60
|
+
background-color: var(--tr-background-hover-color);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
th {
|
|
64
|
+
border-top: var(--th-border-top);
|
|
65
|
+
border-bottom: var(--td-border-bottom);
|
|
66
|
+
padding: var(--th-padding);
|
|
67
|
+
|
|
68
|
+
font: var(--th-font);
|
|
69
|
+
color: var(--th-color);
|
|
70
|
+
text-transform: var(--th-text-transform);
|
|
71
|
+
text-align: left;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
td {
|
|
75
|
+
padding: var(--td-padding);
|
|
76
|
+
border-bottom: var(--td-border-bottom);
|
|
77
|
+
font: var(--td-font);
|
|
78
|
+
color: var(--td-color);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
td a {
|
|
82
|
+
font: var(--td-font);
|
|
83
|
+
text-decoration: none;
|
|
84
|
+
color: var(--md-sys-color-on-surface);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
td a strong {
|
|
88
|
+
font: bold 16px var(--theme-font);
|
|
89
|
+
|
|
90
|
+
display: block;
|
|
91
|
+
text-decoration: none;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.text-align-center {
|
|
95
|
+
text-align: center;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.text-align-right {
|
|
99
|
+
text-align: right;
|
|
100
|
+
}
|
|
101
|
+
`
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
@property({ type: Array }) applications: any[] = []
|
|
105
|
+
|
|
106
|
+
get context() {
|
|
107
|
+
return {
|
|
108
|
+
title: `applications`,
|
|
109
|
+
help: 'auth/application'
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
render() {
|
|
114
|
+
var apps = this.applications || []
|
|
115
|
+
|
|
116
|
+
return html`
|
|
117
|
+
<div>
|
|
118
|
+
<h2>Registered Applications</h2>
|
|
119
|
+
<p page-description>
|
|
120
|
+
What type of app are you building?<br />Choose the app type that best suits the audience you’re building for.
|
|
121
|
+
</p>
|
|
122
|
+
|
|
123
|
+
<md-elevated-button @click=${e => navigate('application-register')}
|
|
124
|
+
>register new application</md-elevated-button
|
|
125
|
+
>
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<table>
|
|
129
|
+
<tr>
|
|
130
|
+
<th>app name</th>
|
|
131
|
+
<th>API health</th>
|
|
132
|
+
<th>Installs</th>
|
|
133
|
+
<th>status</th>
|
|
134
|
+
</tr>
|
|
135
|
+
${apps.map(
|
|
136
|
+
app => html`
|
|
137
|
+
<tr>
|
|
138
|
+
<td>
|
|
139
|
+
<a href=${`application/${app.id}`}>
|
|
140
|
+
<strong>${app.name}</strong>
|
|
141
|
+
${app.description}
|
|
142
|
+
</a>
|
|
143
|
+
</td>
|
|
144
|
+
<td>OK</td>
|
|
145
|
+
<td class="text-align-center">1</td>
|
|
146
|
+
<td>draft</td>
|
|
147
|
+
</tr>
|
|
148
|
+
`
|
|
149
|
+
)}
|
|
150
|
+
</table>
|
|
151
|
+
|
|
152
|
+
<md-outlined-button @click=${e => navigate('app-bindings')}>bound applications ..</md-outlined-button>
|
|
153
|
+
`
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async pageUpdated(changes, lifecycle, before) {
|
|
157
|
+
if (this.active) {
|
|
158
|
+
this.applications = (await this.fetchApplications()).items
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async fetchApplications() {
|
|
163
|
+
const response = await client.query({
|
|
164
|
+
query: gql`
|
|
165
|
+
query {
|
|
166
|
+
applications {
|
|
167
|
+
items {
|
|
168
|
+
id
|
|
169
|
+
name
|
|
170
|
+
description
|
|
171
|
+
}
|
|
172
|
+
total
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
`
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
if (!response.errors) {
|
|
179
|
+
return response.data.applications
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import gql from 'graphql-tag'
|
|
2
|
+
import { css, html } from 'lit'
|
|
3
|
+
import { customElement, property, query, state } from 'lit/decorators.js'
|
|
4
|
+
import { connect } from 'pwa-helpers/connect-mixin.js'
|
|
5
|
+
|
|
6
|
+
import { client } from '@operato/graphql'
|
|
7
|
+
import { navigate, PageView, store } from '@operato/shell'
|
|
8
|
+
|
|
9
|
+
@customElement('application-register')
|
|
10
|
+
class ApplicationRegister extends connect(store)(PageView) {
|
|
11
|
+
static styles = [
|
|
12
|
+
css`
|
|
13
|
+
:host {
|
|
14
|
+
background-color: var(--md-sys-color-background);
|
|
15
|
+
padding: var(--spacing-large);
|
|
16
|
+
|
|
17
|
+
position: relative;
|
|
18
|
+
|
|
19
|
+
overflow: auto;
|
|
20
|
+
}
|
|
21
|
+
h2 {
|
|
22
|
+
margin: var(--title-margin);
|
|
23
|
+
font: var(--title-font);
|
|
24
|
+
color: var(--title-text-color);
|
|
25
|
+
}
|
|
26
|
+
[page-description] {
|
|
27
|
+
margin: var(--page-description-margin);
|
|
28
|
+
font: var(--page-description-font);
|
|
29
|
+
color: var(--page-description-color);
|
|
30
|
+
}
|
|
31
|
+
[icon] {
|
|
32
|
+
position: absolute;
|
|
33
|
+
top: 10px;
|
|
34
|
+
right: 10px;
|
|
35
|
+
|
|
36
|
+
max-width: 80px;
|
|
37
|
+
}
|
|
38
|
+
[icon] img {
|
|
39
|
+
max-width: 100%;
|
|
40
|
+
max-height: 100%;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
img[pagedeco] {
|
|
44
|
+
width: 150px;
|
|
45
|
+
margin: 0 var(--spacing-large);
|
|
46
|
+
float: left;
|
|
47
|
+
position: relative;
|
|
48
|
+
top: -20px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[form-container] {
|
|
52
|
+
background-color: var(--md-sys-color-surface);
|
|
53
|
+
padding: var(--spacing-large);
|
|
54
|
+
border-radius: var(--border-radius);
|
|
55
|
+
box-shadow: var(--box-shadow);
|
|
56
|
+
max-width: var(--input-container-max-width);
|
|
57
|
+
position: relative;
|
|
58
|
+
top: -50px;
|
|
59
|
+
clear: both;
|
|
60
|
+
}
|
|
61
|
+
label {
|
|
62
|
+
font: var(--label-font);
|
|
63
|
+
color: var(--label-color, var(--md-sys-color-on-surface));
|
|
64
|
+
text-transform: var(--label-text-transform);
|
|
65
|
+
}
|
|
66
|
+
input {
|
|
67
|
+
border: var(--border-dim-color);
|
|
68
|
+
border-radius: var(--border-radius);
|
|
69
|
+
margin: var(--input-margin);
|
|
70
|
+
padding: var(--input-padding);
|
|
71
|
+
font: var(--input-font);
|
|
72
|
+
|
|
73
|
+
flex: 1;
|
|
74
|
+
}
|
|
75
|
+
select:focus,
|
|
76
|
+
input:focus {
|
|
77
|
+
outline: none;
|
|
78
|
+
}
|
|
79
|
+
[field-2column] {
|
|
80
|
+
display: grid;
|
|
81
|
+
grid-template-columns: 1fr 1fr;
|
|
82
|
+
grid-gap: 15px;
|
|
83
|
+
}
|
|
84
|
+
[field] {
|
|
85
|
+
display: flex;
|
|
86
|
+
flex-direction: column;
|
|
87
|
+
}
|
|
88
|
+
[grid-span] {
|
|
89
|
+
grid-column: span 2;
|
|
90
|
+
}
|
|
91
|
+
@media screen and (max-width: 480px) {
|
|
92
|
+
img[pagedeco] {
|
|
93
|
+
display: none;
|
|
94
|
+
}
|
|
95
|
+
[form-container] {
|
|
96
|
+
position: initial;
|
|
97
|
+
}
|
|
98
|
+
[field] {
|
|
99
|
+
grid-column: span 2;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
`
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
@property({ type: Object }) application: any
|
|
106
|
+
|
|
107
|
+
@query('form') form!: HTMLFormElement
|
|
108
|
+
|
|
109
|
+
@state() _icon?: string
|
|
110
|
+
|
|
111
|
+
get context() {
|
|
112
|
+
return {
|
|
113
|
+
title: `application registration`,
|
|
114
|
+
help: 'auth/application'
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
render() {
|
|
119
|
+
return html`
|
|
120
|
+
<img src="/assets/images/image-api.png" pagedeco />
|
|
121
|
+
<h2>Register new application</h2>
|
|
122
|
+
<p page-description>
|
|
123
|
+
You can register new application here.<br />
|
|
124
|
+
What type of app are you building? Choose the app type that best suits the audience you’re building for.
|
|
125
|
+
</p>
|
|
126
|
+
|
|
127
|
+
${this._icon
|
|
128
|
+
? html`
|
|
129
|
+
<div icon>
|
|
130
|
+
<img src=${this._icon} />
|
|
131
|
+
</div>
|
|
132
|
+
`
|
|
133
|
+
: html``}
|
|
134
|
+
|
|
135
|
+
<div form-container>
|
|
136
|
+
<form>
|
|
137
|
+
<div field-2column>
|
|
138
|
+
<div field grid-span>
|
|
139
|
+
<label for="name">name</label>
|
|
140
|
+
<input id="name" type="text" name="name" />
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
<div field grid-span>
|
|
144
|
+
<label for="description">description</label>
|
|
145
|
+
<input id="description" type="text" name="description" />
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
<div field grid-span>
|
|
149
|
+
<label for="app-url">application url</label>
|
|
150
|
+
<input id="app-url" type="text" name="url" />
|
|
151
|
+
</div>
|
|
152
|
+
|
|
153
|
+
<div field grid-span>
|
|
154
|
+
<label for="redirect-url">redirectUrl</label>
|
|
155
|
+
<input id="redirect-url" type="text" name="redirectUrl" />
|
|
156
|
+
</div>
|
|
157
|
+
|
|
158
|
+
<div field grid-span>
|
|
159
|
+
<label for="icon">application icon</label>
|
|
160
|
+
<input id="icon" type="text" name="icon" @change=${e => (this._icon = e.target.value)} />
|
|
161
|
+
</div>
|
|
162
|
+
|
|
163
|
+
<div field grid-span>
|
|
164
|
+
<label for="email">contact email</label>
|
|
165
|
+
<input id="email" type="text" name="email" />
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
<md-elevated-button grid-span @click=${this.createApplication.bind(this)}>register</md-elevated-button>
|
|
169
|
+
</div>
|
|
170
|
+
</form>
|
|
171
|
+
</div>
|
|
172
|
+
`
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async createApplication(e) {
|
|
176
|
+
e.preventDefault()
|
|
177
|
+
|
|
178
|
+
const formData = new FormData(this.form)
|
|
179
|
+
|
|
180
|
+
const application = Array.from(formData.entries()).reduce((application, [key, value]) => {
|
|
181
|
+
application[key] = value
|
|
182
|
+
return application
|
|
183
|
+
}, {})
|
|
184
|
+
|
|
185
|
+
const response = await client.mutate({
|
|
186
|
+
mutation: gql`
|
|
187
|
+
mutation ($application: NewApplication!) {
|
|
188
|
+
createApplication(application: $application) {
|
|
189
|
+
id
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
`,
|
|
193
|
+
variables: {
|
|
194
|
+
application
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
if (response.errors) {
|
|
199
|
+
console.log('creation fail.')
|
|
200
|
+
} else {
|
|
201
|
+
const id = response.data.createApplication.id
|
|
202
|
+
navigate(`application/${id}`)
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
pageUpdated(changes, lifecycle, before) {
|
|
207
|
+
if (this.active) {
|
|
208
|
+
this.form.reset()
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import '@material/web/icon/icon.js'
|
|
2
|
+
|
|
3
|
+
import gql from 'graphql-tag'
|
|
4
|
+
|
|
5
|
+
import { css, html, LitElement } from 'lit'
|
|
6
|
+
import { customElement, property, query, state } from 'lit/decorators.js'
|
|
7
|
+
|
|
8
|
+
import { client } from '@operato/graphql'
|
|
9
|
+
import { i18next, localize } from '@operato/i18n'
|
|
10
|
+
import { isMobileDevice } from '@operato/utils'
|
|
11
|
+
import { DataGrist, FetchOption } from '@operato/data-grist'
|
|
12
|
+
import { CommonHeaderStyles } from '@operato/styles'
|
|
13
|
+
|
|
14
|
+
@customElement('attribute-set-item-list')
|
|
15
|
+
class AttributeSetItemList extends localize(i18next)(LitElement) {
|
|
16
|
+
@property({ type: Object }) attribute: any
|
|
17
|
+
|
|
18
|
+
@state() gristConfig: any
|
|
19
|
+
|
|
20
|
+
static styles = [
|
|
21
|
+
CommonHeaderStyles,
|
|
22
|
+
css`
|
|
23
|
+
:host {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
|
|
27
|
+
background-color: var(--md-sys-color-surface);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
ox-grist {
|
|
31
|
+
flex: 1;
|
|
32
|
+
}
|
|
33
|
+
`
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
@query('ox-grist') private grist!: DataGrist
|
|
37
|
+
|
|
38
|
+
render() {
|
|
39
|
+
return html`
|
|
40
|
+
<ox-grist
|
|
41
|
+
.mode=${isMobileDevice() ? 'LIST' : 'GRID'}
|
|
42
|
+
.config=${this.gristConfig}
|
|
43
|
+
.fetchHandler=${this.fetchHandler.bind(this)}
|
|
44
|
+
></ox-grist>
|
|
45
|
+
|
|
46
|
+
<div class="footer">
|
|
47
|
+
<div filler></div>
|
|
48
|
+
<button danger @click=${this.deleteAttributeSetItems.bind(this)}>
|
|
49
|
+
<md-icon>delete_forever</md-icon>${i18next.t('button.delete')}
|
|
50
|
+
</button>
|
|
51
|
+
<button @click=${this.updateAttributeSetItems.bind(this)} done>
|
|
52
|
+
<md-icon>save</md-icon>${i18next.t('button.save')}
|
|
53
|
+
</button>
|
|
54
|
+
</div>
|
|
55
|
+
`
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async firstUpdated() {
|
|
59
|
+
this.gristConfig = {
|
|
60
|
+
list: { fields: ['name', 'description', 'active'] },
|
|
61
|
+
columns: [
|
|
62
|
+
{ type: 'gutter', gutterName: 'row-selector', multiple: true },
|
|
63
|
+
{
|
|
64
|
+
type: 'gutter',
|
|
65
|
+
gutterName: 'button',
|
|
66
|
+
icon: 'add',
|
|
67
|
+
handlers: {
|
|
68
|
+
click: 'record-copy'
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{ type: 'gutter', gutterName: 'sequence' },
|
|
72
|
+
{
|
|
73
|
+
type: 'gutter',
|
|
74
|
+
gutterName: 'button',
|
|
75
|
+
icon: 'arrow_upward',
|
|
76
|
+
handlers: {
|
|
77
|
+
click: 'move-up'
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: 'gutter',
|
|
82
|
+
gutterName: 'button',
|
|
83
|
+
icon: 'arrow_downward',
|
|
84
|
+
handlers: {
|
|
85
|
+
click: 'move-down'
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: 'string',
|
|
90
|
+
name: 'name',
|
|
91
|
+
header: i18next.t('field.name'),
|
|
92
|
+
record: {
|
|
93
|
+
editable: true
|
|
94
|
+
},
|
|
95
|
+
width: 140
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
type: 'string',
|
|
99
|
+
name: 'description',
|
|
100
|
+
header: i18next.t('field.description'),
|
|
101
|
+
record: {
|
|
102
|
+
editable: true
|
|
103
|
+
},
|
|
104
|
+
width: 180
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
type: 'varname',
|
|
108
|
+
name: 'tag',
|
|
109
|
+
header: i18next.t('field.tag'),
|
|
110
|
+
record: {
|
|
111
|
+
editable: true
|
|
112
|
+
},
|
|
113
|
+
width: 180
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
type: 'checkbox',
|
|
117
|
+
name: 'active',
|
|
118
|
+
label: true,
|
|
119
|
+
header: i18next.t('field.active'),
|
|
120
|
+
record: {
|
|
121
|
+
editable: true
|
|
122
|
+
},
|
|
123
|
+
sortable: true,
|
|
124
|
+
width: 60
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
type: 'checkbox',
|
|
128
|
+
name: 'hidden',
|
|
129
|
+
label: true,
|
|
130
|
+
header: i18next.t('field.hidden'),
|
|
131
|
+
record: {
|
|
132
|
+
editable: true
|
|
133
|
+
},
|
|
134
|
+
sortable: true,
|
|
135
|
+
width: 60
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: 'select',
|
|
139
|
+
name: 'type',
|
|
140
|
+
header: i18next.t('field.type'),
|
|
141
|
+
record: {
|
|
142
|
+
options: ['', 'number', 'text', 'select', 'boolean', 'date', 'datetime', 'file'],
|
|
143
|
+
editable: true
|
|
144
|
+
},
|
|
145
|
+
width: 120
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
type: 'parameters',
|
|
149
|
+
name: 'options',
|
|
150
|
+
header: i18next.t('field.options'),
|
|
151
|
+
record: {
|
|
152
|
+
editable: true,
|
|
153
|
+
renderer: 'json5',
|
|
154
|
+
options: async (value, column, record, row, field) => {
|
|
155
|
+
return {
|
|
156
|
+
name: record.type,
|
|
157
|
+
help: '',
|
|
158
|
+
spec:
|
|
159
|
+
record.type === 'select'
|
|
160
|
+
? [
|
|
161
|
+
{
|
|
162
|
+
type: 'options' /* property-editor type */,
|
|
163
|
+
name: 'options',
|
|
164
|
+
label: 'options'
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
: [],
|
|
168
|
+
context: this.grist,
|
|
169
|
+
objectified: true
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
width: 120
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
rows: {
|
|
177
|
+
selectable: {
|
|
178
|
+
multiple: true
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
pagination: {
|
|
182
|
+
infinite: true
|
|
183
|
+
},
|
|
184
|
+
sorters: []
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async fetchHandler({ filters, page, limit, sortings = [] }: FetchOption) {
|
|
189
|
+
const attributes = this.attribute.items || []
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
total: attributes.length,
|
|
193
|
+
records: attributes
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private async updateAttributeSetItems() {
|
|
198
|
+
this.grist.commit()
|
|
199
|
+
|
|
200
|
+
const response = await client.mutate({
|
|
201
|
+
mutation: gql`
|
|
202
|
+
mutation ($id: String!, $patch: AttributeSetPatch!) {
|
|
203
|
+
updateAttributeSet(id: $id, patch: $patch) {
|
|
204
|
+
entity
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
`,
|
|
208
|
+
variables: {
|
|
209
|
+
id: this.attribute.id,
|
|
210
|
+
patch: {
|
|
211
|
+
items: this.grist.data.records,
|
|
212
|
+
cuFlag: 'M'
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
if (!response.errors) {
|
|
218
|
+
await document.dispatchEvent(
|
|
219
|
+
new CustomEvent('notify', {
|
|
220
|
+
detail: {
|
|
221
|
+
message: i18next.t('text.info_x_successfully', {
|
|
222
|
+
x: i18next.t('button.save')
|
|
223
|
+
})
|
|
224
|
+
}
|
|
225
|
+
})
|
|
226
|
+
)
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
private async deleteAttributeSetItems() {
|
|
231
|
+
if (!confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {
|
|
232
|
+
return
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
this.grist.deleteSelectedRecords(false)
|
|
236
|
+
}
|
|
237
|
+
}
|