@things-factory/auth-ui 10.1.6 → 10.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/components/role-privilege-picker-state.d.ts +11 -0
- package/dist-client/components/role-privilege-picker-state.js +15 -0
- package/dist-client/components/role-privilege-picker-state.js.map +1 -0
- package/dist-client/components/role-privilege-picker-state.test.js +20 -0
- package/dist-client/components/role-privilege-picker-state.test.js.map +1 -0
- package/dist-client/components/role-privilege-picker.d.ts +40 -0
- package/dist-client/components/role-privilege-picker.js +77 -0
- package/dist-client/components/role-privilege-picker.js.map +1 -0
- package/dist-client/components/role-template-picker.d.ts +83 -0
- package/dist-client/components/role-template-picker.js +487 -0
- package/dist-client/components/role-template-picker.js.map +1 -0
- package/dist-client/pages/role/role-list-page.d.ts +104 -13
- package/dist-client/pages/role/role-list-page.js +396 -72
- package/dist-client/pages/role/role-list-page.js.map +1 -1
- package/dist-client/pages/role/role-privilege-page.d.ts +113 -37
- package/dist-client/pages/role/role-privilege-page.js +426 -139
- package/dist-client/pages/role/role-privilege-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/translations/en.json +27 -1
- package/translations/ja.json +14 -1
- package/translations/ko.json +26 -0
- package/translations/ms.json +15 -2
- package/translations/zh.json +14 -1
- package/dist-client/components/create-role.d.ts +0 -1
- package/dist-client/components/create-role.js +0 -117
- package/dist-client/components/create-role.js.map +0 -1
- package/dist-client/components/credential-manager.d.ts +0 -11
- package/dist-client/components/credential-manager.js +0 -64
- package/dist-client/components/credential-manager.js.map +0 -1
- package/dist-client/components/role-detail.d.ts +0 -144
- package/dist-client/components/role-detail.js +0 -698
- package/dist-client/components/role-detail.js.map +0 -1
- package/dist-client/components/role-edit-form.js +0 -95
- package/dist-client/components/role-edit-form.js.map +0 -1
- package/dist-client/components/role-privilege-editor.d.ts +0 -1
- package/dist-client/components/role-privilege-editor.js +0 -368
- package/dist-client/components/role-privilege-editor.js.map +0 -1
- package/dist-client/pages/role/role-management.d.ts +0 -4
- package/dist-client/pages/role/role-management.js +0 -137
- package/dist-client/pages/role/role-management.js.map +0 -1
- package/dist-client/pages/user/user-management.d.ts +0 -35
- package/dist-client/pages/user/user-management.js +0 -223
- package/dist-client/pages/user/user-management.js.map +0 -1
- /package/dist-client/components/{role-edit-form.d.ts → role-privilege-picker-state.test.d.ts} +0 -0
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@material/web/icon/icon.js';
|
|
3
|
+
import gql from 'graphql-tag';
|
|
4
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
5
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
6
|
+
import { client, gqlContext } from '@operato/graphql';
|
|
7
|
+
import { i18next, localize } from '@operato/i18n';
|
|
8
|
+
import { CommonHeaderStyles, FormFieldStyles, ScrollbarStyles } from '@operato/styles';
|
|
9
|
+
const AXIS_LABEL = {
|
|
10
|
+
query: 'label.read',
|
|
11
|
+
mutation: 'label.write',
|
|
12
|
+
execute: 'label.execute'
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The module, in words people use.
|
|
16
|
+
*
|
|
17
|
+
* Same rule as the role privilege page (`moduleLabel` there): use
|
|
18
|
+
* `privilege.category.<category>` when it exists and **fall back to the code word**. Not
|
|
19
|
+
* inventing one is the point — a made-up name would read as product vocabulary and hide
|
|
20
|
+
* from the UX lane that the sentence is still missing.
|
|
21
|
+
*/
|
|
22
|
+
function moduleLabel(category) {
|
|
23
|
+
return i18next.t(`privilege.category.${category}`, { defaultValue: category });
|
|
24
|
+
}
|
|
25
|
+
function axisLabel(axis) {
|
|
26
|
+
return AXIS_LABEL[axis] ? i18next.t(AXIS_LABEL[axis]) : axis;
|
|
27
|
+
}
|
|
28
|
+
/** Stable order inside a group, by the name a person actually reads. */
|
|
29
|
+
function byName(a, b) {
|
|
30
|
+
return moduleLabel(a.category).localeCompare(moduleLabel(b.category));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Starting a role.
|
|
34
|
+
*
|
|
35
|
+
* ── Why this stands where the blank row used to ──────────────────────────────
|
|
36
|
+
* A new plant has no roles, and the old answer to "make one" was an empty line waiting for
|
|
37
|
+
* a name. Naming it is the easy half; the hard half is which of 84 privileges belong to a
|
|
38
|
+
* quality inspector, and that is a judgement the product has made and the plant has not.
|
|
39
|
+
*
|
|
40
|
+
* miratek is the case: two roles (Administrator, TWIN-CONNECTOR), no MES seats, and eleven
|
|
41
|
+
* approval doors standing empty because there is nothing to route them to. Read from
|
|
42
|
+
* inside, that looks like a plant that has not decided. It is a plant with nothing to
|
|
43
|
+
* decide from.
|
|
44
|
+
*
|
|
45
|
+
* ── Both doors, in one place ─────────────────────────────────────────────────
|
|
46
|
+
* The templates come first and the blank name last, because the order is what teaches: a
|
|
47
|
+
* plant that sees "quality inspector, 7 privileges" learns what a seat looks like before
|
|
48
|
+
* it is asked to invent one. Hiding the blank door would be worse, though — the seats a
|
|
49
|
+
* factory actually has ("night shift lead", "outside inspector") are its own, and the
|
|
50
|
+
* product does not know them.
|
|
51
|
+
*
|
|
52
|
+
* ── Why the name is editable ─────────────────────────────────────────────────
|
|
53
|
+
* The template knows the seat exists; it does not know what the people there call it. And
|
|
54
|
+
* because a role is also what an approval line points at, the same seat is sometimes
|
|
55
|
+
* needed twice — a day and a night inspector hold the same privileges and take different
|
|
56
|
+
* approvals. A fixed name would allow each template exactly once per domain.
|
|
57
|
+
*/
|
|
58
|
+
let RoleTemplatePicker = class RoleTemplatePicker extends localize(i18next)(LitElement) {
|
|
59
|
+
constructor() {
|
|
60
|
+
super(...arguments);
|
|
61
|
+
this.templates = [];
|
|
62
|
+
/** `undefined` means "the blank door" — name the seat yourself. */
|
|
63
|
+
this.scratch = false;
|
|
64
|
+
this.name = '';
|
|
65
|
+
this.description = '';
|
|
66
|
+
}
|
|
67
|
+
static { this.styles = [
|
|
68
|
+
ScrollbarStyles,
|
|
69
|
+
/*
|
|
70
|
+
* Native controls, styled by the shared block.
|
|
71
|
+
*
|
|
72
|
+
* This used `md-filled-text-field` and the Material buttons until the user looked at it
|
|
73
|
+
* (2026-09-11): "too big, and the style does not fit." They are right — a filled field
|
|
74
|
+
* with a floating label is a form control from a different density than the pills,
|
|
75
|
+
* chips and 30px rows this product uses everywhere else.
|
|
76
|
+
*
|
|
77
|
+
* `FormFieldStyles` exists precisely for this: a component draws its input inside its
|
|
78
|
+
* own shadow root, where the theme stylesheet cannot reach, so the token wiring has to
|
|
79
|
+
* be declared per component. It goes first so local rules below can override it.
|
|
80
|
+
*/
|
|
81
|
+
FormFieldStyles,
|
|
82
|
+
/* The popup footer already has a convention — plain buttons, pill on pointer devices. */
|
|
83
|
+
CommonHeaderStyles,
|
|
84
|
+
css `
|
|
85
|
+
:host {
|
|
86
|
+
display: flex;
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
background-color: var(--md-sys-color-surface-container-lowest);
|
|
89
|
+
color: var(--md-sys-color-on-surface);
|
|
90
|
+
height: 100%;
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
[body] {
|
|
95
|
+
display: grid;
|
|
96
|
+
grid-template-columns: minmax(240px, 320px) 1fr;
|
|
97
|
+
gap: var(--spacing-medium, 8px);
|
|
98
|
+
padding: var(--spacing-medium, 8px);
|
|
99
|
+
flex: 1;
|
|
100
|
+
min-height: 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
[panel] {
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-direction: column;
|
|
106
|
+
min-height: 0;
|
|
107
|
+
background-color: var(--md-sys-color-surface);
|
|
108
|
+
border-radius: var(--md-sys-shape-corner-medium, 8px);
|
|
109
|
+
overflow: hidden;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
[panel] > header {
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
gap: 6px;
|
|
116
|
+
padding: var(--spacing-small, 6px) var(--spacing-medium, 8px);
|
|
117
|
+
font-size: var(--fontsize-small, 13px);
|
|
118
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
119
|
+
background-color: var(--md-sys-color-surface-container);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
[count] {
|
|
123
|
+
color: var(--md-sys-color-primary);
|
|
124
|
+
font-weight: 600;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
ul {
|
|
128
|
+
list-style: none;
|
|
129
|
+
margin: 0;
|
|
130
|
+
padding: 0;
|
|
131
|
+
overflow-y: auto;
|
|
132
|
+
flex: 1;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
li[seat] {
|
|
136
|
+
display: flex;
|
|
137
|
+
flex-direction: column;
|
|
138
|
+
gap: 2px;
|
|
139
|
+
padding: var(--spacing-small, 6px) var(--spacing-medium, 8px);
|
|
140
|
+
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
|
141
|
+
cursor: pointer;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
li[seat]:hover {
|
|
145
|
+
background-color: var(--md-sys-color-surface-container-high);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
li[seat][selected] {
|
|
149
|
+
background-color: var(--md-sys-color-secondary-container);
|
|
150
|
+
color: var(--md-sys-color-on-secondary-container);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
li[seat] [title-row] {
|
|
154
|
+
display: flex;
|
|
155
|
+
align-items: center;
|
|
156
|
+
gap: 6px;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
li[seat] [name] {
|
|
160
|
+
font-weight: 600;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
li[seat] small {
|
|
164
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
165
|
+
font-size: var(--fontsize-small, 12px);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
li[seat][selected] small {
|
|
169
|
+
color: inherit;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
[tag] {
|
|
173
|
+
font-size: var(--fontsize-smaller, 11px);
|
|
174
|
+
padding: 0 6px;
|
|
175
|
+
border-radius: var(--md-sys-shape-corner-full, 999px);
|
|
176
|
+
background-color: var(--md-sys-color-surface-container-highest);
|
|
177
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
[tag][warn] {
|
|
181
|
+
background-color: var(--md-sys-color-error-container);
|
|
182
|
+
color: var(--md-sys-color-on-error-container);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
[detail] {
|
|
186
|
+
display: flex;
|
|
187
|
+
flex-direction: column;
|
|
188
|
+
gap: var(--spacing-large, 14px);
|
|
189
|
+
padding: var(--spacing-large, 14px);
|
|
190
|
+
overflow-y: auto;
|
|
191
|
+
flex: 1;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* 곁말 — 필드 밑에 붙거나 혼자 선다. 본문과 같은 무게로 두면 읽는 순서가 흐려진다. */
|
|
195
|
+
[note],
|
|
196
|
+
label[field] small {
|
|
197
|
+
margin: 0;
|
|
198
|
+
font-size: var(--fontsize-small, 12px);
|
|
199
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
200
|
+
line-height: 1.5;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
dl[grants] {
|
|
204
|
+
display: grid;
|
|
205
|
+
grid-template-columns: minmax(8em, max-content) 1fr;
|
|
206
|
+
/* 줄 사이가 2px 이었다. 이름이 위아래로 붙어 한 덩어리로 읽혔다. */
|
|
207
|
+
gap: 6px var(--spacing-large, 14px);
|
|
208
|
+
margin: 0;
|
|
209
|
+
align-items: baseline;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/*
|
|
213
|
+
* 모듈 이름이 **기준선**이다 — 굵기로 두 칸이 저절로 갈린다.
|
|
214
|
+
*
|
|
215
|
+
* 처음엔 거꾸로였다: 이름을 흐리게 두고 「쓰기」를 굵게 했더니, 눈이 먼저 닿는 것이
|
|
216
|
+
* 오른쪽 칸이 되어 왼쪽이 뭘 말하는지 훑어지지 않았다. 사람이 이 표에서 찾는 것은
|
|
217
|
+
* 「이 자리가 **어느 모듈**을 여나」이고, 읽기냐 쓰기냐는 그 다음이다.
|
|
218
|
+
*/
|
|
219
|
+
dl[grants] dt {
|
|
220
|
+
color: var(--md-sys-color-on-surface);
|
|
221
|
+
font-size: var(--fontsize-small, 13px);
|
|
222
|
+
font-weight: 600;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
dl[grants] dd {
|
|
226
|
+
margin: 0;
|
|
227
|
+
display: flex;
|
|
228
|
+
flex-wrap: wrap;
|
|
229
|
+
/* 낱말 사이 가운뎃점 — 「읽기 쓰기」가 한 낱말로 붙어 보이던 것을 가른다. */
|
|
230
|
+
gap: 0 6px;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
dl[grants] dd [axis] + [axis]::before {
|
|
234
|
+
content: '·';
|
|
235
|
+
margin-right: 6px;
|
|
236
|
+
color: var(--md-sys-color-outline);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
[axis] {
|
|
240
|
+
font-size: var(--fontsize-small, 12px);
|
|
241
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
[axis][missing] {
|
|
245
|
+
text-decoration: line-through;
|
|
246
|
+
color: var(--md-sys-color-outline);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
[empty] {
|
|
250
|
+
margin: auto;
|
|
251
|
+
text-align: center;
|
|
252
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
253
|
+
font-size: var(--fontsize-small, 13px);
|
|
254
|
+
padding: var(--spacing-large, 16px);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/* 자리 배치만 더한다 — 모양은 CommonHeaderStyles 의 .footer 가 갖는다. */
|
|
258
|
+
.footer {
|
|
259
|
+
justify-content: flex-end;
|
|
260
|
+
}
|
|
261
|
+
`
|
|
262
|
+
]; }
|
|
263
|
+
async connectedCallback() {
|
|
264
|
+
super.connectedCallback();
|
|
265
|
+
await this.fetchTemplates();
|
|
266
|
+
}
|
|
267
|
+
async fetchTemplates() {
|
|
268
|
+
const response = await client.query({
|
|
269
|
+
query: gql `
|
|
270
|
+
query {
|
|
271
|
+
roleTemplates {
|
|
272
|
+
id
|
|
273
|
+
name
|
|
274
|
+
description
|
|
275
|
+
privilegeCount
|
|
276
|
+
missingCount
|
|
277
|
+
defaultNameTaken
|
|
278
|
+
grantsNothingDeliberately
|
|
279
|
+
grants {
|
|
280
|
+
category
|
|
281
|
+
axes
|
|
282
|
+
missingAxes
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
`,
|
|
287
|
+
context: gqlContext()
|
|
288
|
+
});
|
|
289
|
+
/*
|
|
290
|
+
* A GraphQL error arrives as `data: null` with `errors` set, and `?? []` would draw
|
|
291
|
+
* that as "this installation offers nothing" — a refusal made to look like an answer.
|
|
292
|
+
*/
|
|
293
|
+
if (response.errors?.length) {
|
|
294
|
+
document.dispatchEvent(new CustomEvent('notify', { detail: { level: 'error', message: response.errors[0]?.message } }));
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
this.templates = response.data?.roleTemplates || [];
|
|
298
|
+
}
|
|
299
|
+
render() {
|
|
300
|
+
return html `
|
|
301
|
+
<div body>
|
|
302
|
+
<div panel>
|
|
303
|
+
<header>
|
|
304
|
+
${i18next.t('field.seat')}
|
|
305
|
+
<span count>${this.templates.length}</span>
|
|
306
|
+
</header>
|
|
307
|
+
<ul>
|
|
308
|
+
${this.templates.map(template => html `
|
|
309
|
+
<li seat ?selected=${!this.scratch && this.selected?.id === template.id} @click=${() => this.pick(template)}>
|
|
310
|
+
<div title-row>
|
|
311
|
+
<span name>${template.name}</span>
|
|
312
|
+
${template.defaultNameTaken
|
|
313
|
+
? html `<span tag>${i18next.t('text.already in this domain')}</span>`
|
|
314
|
+
: nothing}
|
|
315
|
+
${template.missingCount
|
|
316
|
+
? html `<span tag warn>${i18next.t('text.x not here', { x: template.missingCount })}</span>`
|
|
317
|
+
: nothing}
|
|
318
|
+
</div>
|
|
319
|
+
<small>${this.summarize(template)}</small>
|
|
320
|
+
</li>
|
|
321
|
+
`)}
|
|
322
|
+
<li seat ?selected=${this.scratch} @click=${() => this.pickScratch()}>
|
|
323
|
+
<div title-row>
|
|
324
|
+
<md-icon>edit</md-icon>
|
|
325
|
+
<span name>${i18next.t('button.name it yourself')}</span>
|
|
326
|
+
</div>
|
|
327
|
+
<small>${i18next.t('text.start from a blank seat')}</small>
|
|
328
|
+
</li>
|
|
329
|
+
</ul>
|
|
330
|
+
</div>
|
|
331
|
+
|
|
332
|
+
<div panel>${this.renderDetail()}</div>
|
|
333
|
+
</div>
|
|
334
|
+
|
|
335
|
+
<div class="footer">
|
|
336
|
+
<button @click=${() => this.dispatchEvent(new CustomEvent('close'))}>${i18next.t('button.cancel')}</button>
|
|
337
|
+
<button ok ?disabled=${!this.canCreate()} @click=${() => this.create()}>${i18next.t('button.create')}</button>
|
|
338
|
+
</div>
|
|
339
|
+
`;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* What the seat opens, in one line — **counted, not interpreted.**
|
|
343
|
+
*
|
|
344
|
+
* This briefly said "changes 6 · only sees 8", which read well and was not something the
|
|
345
|
+
* data supports: the privilege axis is an unconstrained string and its name does not
|
|
346
|
+
* determine what the resolver behind it does. Counting is safe; grouping by meaning was
|
|
347
|
+
* not. See `renderOpens`.
|
|
348
|
+
*
|
|
349
|
+
* "0 privileges" is still two different facts and must not be merged: granting nothing
|
|
350
|
+
* on purpose is an approval seat, and a template whose grants are all missing here is a
|
|
351
|
+
* defect (`missingCount`).
|
|
352
|
+
*/
|
|
353
|
+
summarize(template) {
|
|
354
|
+
if (template.grantsNothingDeliberately) {
|
|
355
|
+
return i18next.t('text.opens nothing, receives approvals');
|
|
356
|
+
}
|
|
357
|
+
return i18next.t('text.x modules y privileges', {
|
|
358
|
+
x: template.grants.filter(grant => grant.axes.length).length,
|
|
359
|
+
y: template.privilegeCount
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
renderDetail() {
|
|
363
|
+
if (this.scratch) {
|
|
364
|
+
return html `
|
|
365
|
+
<header>${i18next.t('button.name it yourself')}</header>
|
|
366
|
+
<div detail>
|
|
367
|
+
<label field>
|
|
368
|
+
${i18next.t('field.name')}
|
|
369
|
+
<input .value=${this.name} @input=${(e) => (this.name = e.target.value)} />
|
|
370
|
+
</label>
|
|
371
|
+
<label field>
|
|
372
|
+
${i18next.t('field.description')}
|
|
373
|
+
<input .value=${this.description} @input=${(e) => (this.description = e.target.value)} />
|
|
374
|
+
</label>
|
|
375
|
+
<small>${i18next.t('text.a blank seat opens nothing until you give it privileges')}</small>
|
|
376
|
+
</div>
|
|
377
|
+
`;
|
|
378
|
+
}
|
|
379
|
+
if (!this.selected) {
|
|
380
|
+
return html `<div empty>${i18next.t('text.pick a seat to see what it opens')}</div>`;
|
|
381
|
+
}
|
|
382
|
+
const template = this.selected;
|
|
383
|
+
return html `
|
|
384
|
+
<header>${template.name}</header>
|
|
385
|
+
<div detail>
|
|
386
|
+
<label field>
|
|
387
|
+
${i18next.t('field.name')}
|
|
388
|
+
<input .value=${this.name} @input=${(e) => (this.name = e.target.value)} />
|
|
389
|
+
<small>${i18next.t('text.this plant may call the seat what it likes')}</small>
|
|
390
|
+
</label>
|
|
391
|
+
${template.defaultNameTaken && this.name === template.name
|
|
392
|
+
? html `<p note>${i18next.t('text.a role of this name exists and will be added to')}</p>`
|
|
393
|
+
: nothing}
|
|
394
|
+
${this.renderOpens(template)}
|
|
395
|
+
</div>
|
|
396
|
+
`;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* 이 자리가 무엇을 여나 — **선언된 것만.**
|
|
400
|
+
*
|
|
401
|
+
* ⚠ 여기 「바꿀 수 있는 것 / 볼 수만 있는 것」 두 묶음이 있었다. 사용자가 물었다(2026-09-11):
|
|
402
|
+
* 「바꿀 수 있고, 볼 수만 있는 것을 너가 어떻게 알아? 논리적이지 않은 것을 우겨넣지 말고.」
|
|
403
|
+
*
|
|
404
|
+
* 몰랐다. 지어낸 것이다. 근거가 없는 이유가 둘이다.
|
|
405
|
+
*
|
|
406
|
+
* ① `@privilege(privilege:)` 는 **제약 없는 문자열**이다(지시자 선언이 `privilege: String`
|
|
407
|
+
* 이고 enum 이 아니다). 지금 쓰인 값이 mutation 484 · query 314 로 둘뿐인 것은 **오늘
|
|
408
|
+
* 그렇게 쓴 것**이지 둘로 한정된 것이 아니다. 내 코드는 `axis !== 'query'` 로 갈랐으므로,
|
|
409
|
+
* 처음 보는 값은 **알아서가 아니라 query 가 아니라서** 「바꿀 수 있는 것」으로 떨어졌다.
|
|
410
|
+
* ② 이름이 뜻을 보장하지 않는다. 축 이름과 실제 GraphQL 연산이 어긋나는 자리가 6곳이고,
|
|
411
|
+
* 그중 둘은 이 기능의 내 파일이다(`role-template-query.ts` — 템플릿을 **읽는** 질의에
|
|
412
|
+
* `privilege: "mutation"` 을 달았다. 역할을 만드는 문이라서 그게 맞다). 축은 연산 종류가
|
|
413
|
+
* 아니라 **어느 문을 지나야 하나**의 이름이다.
|
|
414
|
+
*
|
|
415
|
+
* 그래서 화면은 선언된 것을 그대로 낸다 — 어느 모듈에, 어느 권한이. 읽히게 만드는 것
|
|
416
|
+
* (굵기·줄 간격·가운뎃점)은 아무것도 주장하지 않으므로 그대로 둔다.
|
|
417
|
+
*/
|
|
418
|
+
renderOpens(template) {
|
|
419
|
+
if (template.grantsNothingDeliberately) {
|
|
420
|
+
return html `<p note>${i18next.t('text.opens nothing, receives approvals')}</p>`;
|
|
421
|
+
}
|
|
422
|
+
return html `
|
|
423
|
+
<dl grants>
|
|
424
|
+
${[...template.grants].sort(byName).map(grant => html `
|
|
425
|
+
<dt>${moduleLabel(grant.category)}</dt>
|
|
426
|
+
<dd>
|
|
427
|
+
${grant.axes.map(axis => html `<span axis>${axisLabel(axis)}</span>`)}
|
|
428
|
+
${grant.missingAxes.map(axis => html `<span axis missing>${axisLabel(axis)}</span>`)}
|
|
429
|
+
</dd>
|
|
430
|
+
`)}
|
|
431
|
+
</dl>
|
|
432
|
+
${template.missingCount
|
|
433
|
+
? html `<p note>${i18next.t('text.struck through are not installed here')}</p>`
|
|
434
|
+
: nothing}
|
|
435
|
+
`;
|
|
436
|
+
}
|
|
437
|
+
pick(template) {
|
|
438
|
+
this.scratch = false;
|
|
439
|
+
this.selected = template;
|
|
440
|
+
this.name = template.name;
|
|
441
|
+
}
|
|
442
|
+
pickScratch() {
|
|
443
|
+
this.scratch = true;
|
|
444
|
+
this.selected = undefined;
|
|
445
|
+
this.name = '';
|
|
446
|
+
}
|
|
447
|
+
canCreate() {
|
|
448
|
+
return Boolean(this.name.trim()) && (this.scratch || Boolean(this.selected));
|
|
449
|
+
}
|
|
450
|
+
async create() {
|
|
451
|
+
const created = this.scratch
|
|
452
|
+
? await this.page?.createBlankRole?.(this.name.trim(), this.description.trim())
|
|
453
|
+
: await this.page?.createFromTemplate?.(this.selected.id, this.name.trim());
|
|
454
|
+
if (created) {
|
|
455
|
+
this.dispatchEvent(new CustomEvent('close'));
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
__decorate([
|
|
460
|
+
property({ type: Object }),
|
|
461
|
+
__metadata("design:type", Object)
|
|
462
|
+
], RoleTemplatePicker.prototype, "page", void 0);
|
|
463
|
+
__decorate([
|
|
464
|
+
state(),
|
|
465
|
+
__metadata("design:type", Array)
|
|
466
|
+
], RoleTemplatePicker.prototype, "templates", void 0);
|
|
467
|
+
__decorate([
|
|
468
|
+
state(),
|
|
469
|
+
__metadata("design:type", Object)
|
|
470
|
+
], RoleTemplatePicker.prototype, "selected", void 0);
|
|
471
|
+
__decorate([
|
|
472
|
+
state(),
|
|
473
|
+
__metadata("design:type", Object)
|
|
474
|
+
], RoleTemplatePicker.prototype, "scratch", void 0);
|
|
475
|
+
__decorate([
|
|
476
|
+
state(),
|
|
477
|
+
__metadata("design:type", Object)
|
|
478
|
+
], RoleTemplatePicker.prototype, "name", void 0);
|
|
479
|
+
__decorate([
|
|
480
|
+
state(),
|
|
481
|
+
__metadata("design:type", Object)
|
|
482
|
+
], RoleTemplatePicker.prototype, "description", void 0);
|
|
483
|
+
RoleTemplatePicker = __decorate([
|
|
484
|
+
customElement('role-template-picker')
|
|
485
|
+
], RoleTemplatePicker);
|
|
486
|
+
export { RoleTemplatePicker };
|
|
487
|
+
//# sourceMappingURL=role-template-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"role-template-picker.js","sourceRoot":"","sources":["../../client/components/role-template-picker.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAIlE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AActF,MAAM,UAAU,GAA2B;IACzC,KAAK,EAAE,YAAY;IACnB,QAAQ,EAAE,aAAa;IACvB,OAAO,EAAE,eAAe;CACzB,CAAA;AAED;;;;;;;GAOG;AACH,SAAS,WAAW,CAAC,QAAgB;IACnC,OAAO,OAAO,CAAC,CAAC,CAAC,sBAAsB,QAAQ,EAAE,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAA;AAChF,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,U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,EAAE,CAAC,IAAI,CAAC,QAAS,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QAE9E,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,CAAA;QAC9C,CAAC;IACH,CAAC;;AAlO2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDAAW;AAErB;IAAhB,KAAK,EAAE;;qDAAuC;AAC9B;IAAhB,KAAK,EAAE;;oDAAgC;AAEvB;IAAhB,KAAK,EAAE;;mDAAwB;AACf;IAAhB,KAAK,EAAE;;gDAAkB;AACT;IAAhB,KAAK,EAAE;;uDAAyB;AA7MtB,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CAya9B","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport type { CSSResultGroup } from 'lit'\n\nimport { client, gqlContext } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { CommonHeaderStyles, FormFieldStyles, ScrollbarStyles } from '@operato/styles'\n\ntype GrantView = { category: string; axes: string[]; missingAxes: string[] }\ntype TemplateView = {\n id: string\n name: string\n description?: string\n grants: GrantView[]\n privilegeCount: number\n missingCount: number\n defaultNameTaken: boolean\n grantsNothingDeliberately: boolean\n}\n\nconst AXIS_LABEL: Record<string, string> = {\n query: 'label.read',\n mutation: 'label.write',\n execute: 'label.execute'\n}\n\n/**\n * The module, in words people use.\n *\n * Same rule as the role privilege page (`moduleLabel` there): use\n * `privilege.category.<category>` when it exists and **fall back to the code word**. Not\n * inventing one is the point — a made-up name would read as product vocabulary and hide\n * from the UX lane that the sentence is still missing.\n */\nfunction moduleLabel(category: string): string {\n return i18next.t(`privilege.category.${category}`, { defaultValue: category })\n}\n\nfunction axisLabel(axis: string): string {\n return AXIS_LABEL[axis] ? i18next.t(AXIS_LABEL[axis]) : axis\n}\n\n/** Stable order inside a group, by the name a person actually reads. */\nfunction byName(a: GrantView, b: GrantView): number {\n return moduleLabel(a.category).localeCompare(moduleLabel(b.category))\n}\n\n/**\n * Starting a role.\n *\n * ── Why this stands where the blank row used to ──────────────────────────────\n * A new plant has no roles, and the old answer to \"make one\" was an empty line waiting for\n * a name. Naming it is the easy half; the hard half is which of 84 privileges belong to a\n * quality inspector, and that is a judgement the product has made and the plant has not.\n *\n * miratek is the case: two roles (Administrator, TWIN-CONNECTOR), no MES seats, and eleven\n * approval doors standing empty because there is nothing to route them to. Read from\n * inside, that looks like a plant that has not decided. It is a plant with nothing to\n * decide from.\n *\n * ── Both doors, in one place ─────────────────────────────────────────────────\n * The templates come first and the blank name last, because the order is what teaches: a\n * plant that sees \"quality inspector, 7 privileges\" learns what a seat looks like before\n * it is asked to invent one. Hiding the blank door would be worse, though — the seats a\n * factory actually has (\"night shift lead\", \"outside inspector\") are its own, and the\n * product does not know them.\n *\n * ── Why the name is editable ─────────────────────────────────────────────────\n * The template knows the seat exists; it does not know what the people there call it. And\n * because a role is also what an approval line points at, the same seat is sometimes\n * needed twice — a day and a night inspector hold the same privileges and take different\n * approvals. A fixed name would allow each template exactly once per domain.\n */\n@customElement('role-template-picker')\nexport class RoleTemplatePicker extends localize(i18next)(LitElement) {\n static styles: CSSResultGroup = [\n ScrollbarStyles,\n /*\n * Native controls, styled by the shared block.\n *\n * This used `md-filled-text-field` and the Material buttons until the user looked at it\n * (2026-09-11): \"too big, and the style does not fit.\" They are right — a filled field\n * with a floating label is a form control from a different density than the pills,\n * chips and 30px rows this product uses everywhere else.\n *\n * `FormFieldStyles` exists precisely for this: a component draws its input inside its\n * own shadow root, where the theme stylesheet cannot reach, so the token wiring has to\n * be declared per component. It goes first so local rules below can override it.\n */\n FormFieldStyles,\n /* The popup footer already has a convention — plain buttons, pill on pointer devices. */\n CommonHeaderStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n background-color: var(--md-sys-color-surface-container-lowest);\n color: var(--md-sys-color-on-surface);\n height: 100%;\n overflow: hidden;\n }\n\n [body] {\n display: grid;\n grid-template-columns: minmax(240px, 320px) 1fr;\n gap: var(--spacing-medium, 8px);\n padding: var(--spacing-medium, 8px);\n flex: 1;\n min-height: 0;\n }\n\n [panel] {\n display: flex;\n flex-direction: column;\n min-height: 0;\n background-color: var(--md-sys-color-surface);\n border-radius: var(--md-sys-shape-corner-medium, 8px);\n overflow: hidden;\n }\n\n [panel] > header {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: var(--spacing-small, 6px) var(--spacing-medium, 8px);\n font-size: var(--fontsize-small, 13px);\n color: var(--md-sys-color-on-surface-variant);\n background-color: var(--md-sys-color-surface-container);\n }\n\n [count] {\n color: var(--md-sys-color-primary);\n font-weight: 600;\n }\n\n ul {\n list-style: none;\n margin: 0;\n padding: 0;\n overflow-y: auto;\n flex: 1;\n }\n\n li[seat] {\n display: flex;\n flex-direction: column;\n gap: 2px;\n padding: var(--spacing-small, 6px) var(--spacing-medium, 8px);\n border-bottom: 1px solid var(--md-sys-color-outline-variant);\n cursor: pointer;\n }\n\n li[seat]:hover {\n background-color: var(--md-sys-color-surface-container-high);\n }\n\n li[seat][selected] {\n background-color: var(--md-sys-color-secondary-container);\n color: var(--md-sys-color-on-secondary-container);\n }\n\n li[seat] [title-row] {\n display: flex;\n align-items: center;\n gap: 6px;\n }\n\n li[seat] [name] {\n font-weight: 600;\n }\n\n li[seat] small {\n color: var(--md-sys-color-on-surface-variant);\n font-size: var(--fontsize-small, 12px);\n }\n\n li[seat][selected] small {\n color: inherit;\n }\n\n [tag] {\n font-size: var(--fontsize-smaller, 11px);\n padding: 0 6px;\n border-radius: var(--md-sys-shape-corner-full, 999px);\n background-color: var(--md-sys-color-surface-container-highest);\n color: var(--md-sys-color-on-surface-variant);\n }\n\n [tag][warn] {\n background-color: var(--md-sys-color-error-container);\n color: var(--md-sys-color-on-error-container);\n }\n\n [detail] {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-large, 14px);\n padding: var(--spacing-large, 14px);\n overflow-y: auto;\n flex: 1;\n }\n\n /* 곁말 — 필드 밑에 붙거나 혼자 선다. 본문과 같은 무게로 두면 읽는 순서가 흐려진다. */\n [note],\n label[field] small {\n margin: 0;\n font-size: var(--fontsize-small, 12px);\n color: var(--md-sys-color-on-surface-variant);\n line-height: 1.5;\n }\n\n dl[grants] {\n display: grid;\n grid-template-columns: minmax(8em, max-content) 1fr;\n /* 줄 사이가 2px 이었다. 이름이 위아래로 붙어 한 덩어리로 읽혔다. */\n gap: 6px var(--spacing-large, 14px);\n margin: 0;\n align-items: baseline;\n }\n\n /*\n * 모듈 이름이 **기준선**이다 — 굵기로 두 칸이 저절로 갈린다.\n *\n * 처음엔 거꾸로였다: 이름을 흐리게 두고 「쓰기」를 굵게 했더니, 눈이 먼저 닿는 것이\n * 오른쪽 칸이 되어 왼쪽이 뭘 말하는지 훑어지지 않았다. 사람이 이 표에서 찾는 것은\n * 「이 자리가 **어느 모듈**을 여나」이고, 읽기냐 쓰기냐는 그 다음이다.\n */\n dl[grants] dt {\n color: var(--md-sys-color-on-surface);\n font-size: var(--fontsize-small, 13px);\n font-weight: 600;\n }\n\n dl[grants] dd {\n margin: 0;\n display: flex;\n flex-wrap: wrap;\n /* 낱말 사이 가운뎃점 — 「읽기 쓰기」가 한 낱말로 붙어 보이던 것을 가른다. */\n gap: 0 6px;\n }\n\n dl[grants] dd [axis] + [axis]::before {\n content: '·';\n margin-right: 6px;\n color: var(--md-sys-color-outline);\n }\n\n [axis] {\n font-size: var(--fontsize-small, 12px);\n color: var(--md-sys-color-on-surface-variant);\n }\n\n [axis][missing] {\n text-decoration: line-through;\n color: var(--md-sys-color-outline);\n }\n\n [empty] {\n margin: auto;\n text-align: center;\n color: var(--md-sys-color-on-surface-variant);\n font-size: var(--fontsize-small, 13px);\n padding: var(--spacing-large, 16px);\n }\n\n /* 자리 배치만 더한다 — 모양은 CommonHeaderStyles 의 .footer 가 갖는다. */\n .footer {\n justify-content: flex-end;\n }\n `\n ]\n\n @property({ type: Object }) page?: any\n\n @state() private templates: TemplateView[] = []\n @state() private selected?: TemplateView\n /** `undefined` means \"the blank door\" — name the seat yourself. */\n @state() private scratch = false\n @state() private name = ''\n @state() private description = ''\n\n async connectedCallback() {\n super.connectedCallback()\n await this.fetchTemplates()\n }\n\n private async fetchTemplates() {\n const response = await client.query({\n query: gql`\n query {\n roleTemplates {\n id\n name\n description\n privilegeCount\n missingCount\n defaultNameTaken\n grantsNothingDeliberately\n grants {\n category\n axes\n missingAxes\n }\n }\n }\n `,\n context: gqlContext()\n })\n\n /*\n * A GraphQL error arrives as `data: null` with `errors` set, and `?? []` would draw\n * that as \"this installation offers nothing\" — a refusal made to look like an answer.\n */\n if (response.errors?.length) {\n document.dispatchEvent(\n new CustomEvent('notify', { detail: { level: 'error', message: response.errors[0]?.message } })\n )\n return\n }\n\n this.templates = response.data?.roleTemplates || []\n }\n\n render() {\n return html`\n <div body>\n <div panel>\n <header>\n ${i18next.t('field.seat')}\n <span count>${this.templates.length}</span>\n </header>\n <ul>\n ${this.templates.map(\n template => html`\n <li seat ?selected=${!this.scratch && this.selected?.id === template.id} @click=${() => this.pick(template)}>\n <div title-row>\n <span name>${template.name}</span>\n ${template.defaultNameTaken\n ? html`<span tag>${i18next.t('text.already in this domain')}</span>`\n : nothing}\n ${template.missingCount\n ? html`<span tag warn>${i18next.t('text.x not here', { x: template.missingCount })}</span>`\n : nothing}\n </div>\n <small>${this.summarize(template)}</small>\n </li>\n `\n )}\n <li seat ?selected=${this.scratch} @click=${() => this.pickScratch()}>\n <div title-row>\n <md-icon>edit</md-icon>\n <span name>${i18next.t('button.name it yourself')}</span>\n </div>\n <small>${i18next.t('text.start from a blank seat')}</small>\n </li>\n </ul>\n </div>\n\n <div panel>${this.renderDetail()}</div>\n </div>\n\n <div class=\"footer\">\n <button @click=${() => this.dispatchEvent(new CustomEvent('close'))}>${i18next.t('button.cancel')}</button>\n <button ok ?disabled=${!this.canCreate()} @click=${() => this.create()}>${i18next.t('button.create')}</button>\n </div>\n `\n }\n\n /**\n * What the seat opens, in one line — **counted, not interpreted.**\n *\n * This briefly said \"changes 6 · only sees 8\", which read well and was not something the\n * data supports: the privilege axis is an unconstrained string and its name does not\n * determine what the resolver behind it does. Counting is safe; grouping by meaning was\n * not. See `renderOpens`.\n *\n * \"0 privileges\" is still two different facts and must not be merged: granting nothing\n * on purpose is an approval seat, and a template whose grants are all missing here is a\n * defect (`missingCount`).\n */\n private summarize(template: TemplateView) {\n if (template.grantsNothingDeliberately) {\n return i18next.t('text.opens nothing, receives approvals')\n }\n\n return i18next.t('text.x modules y privileges', {\n x: template.grants.filter(grant => grant.axes.length).length,\n y: template.privilegeCount\n })\n }\n\n private renderDetail() {\n if (this.scratch) {\n return html`\n <header>${i18next.t('button.name it yourself')}</header>\n <div detail>\n <label field>\n ${i18next.t('field.name')}\n <input .value=${this.name} @input=${(e: any) => (this.name = e.target.value)} />\n </label>\n <label field>\n ${i18next.t('field.description')}\n <input .value=${this.description} @input=${(e: any) => (this.description = e.target.value)} />\n </label>\n <small>${i18next.t('text.a blank seat opens nothing until you give it privileges')}</small>\n </div>\n `\n }\n\n if (!this.selected) {\n return html`<div empty>${i18next.t('text.pick a seat to see what it opens')}</div>`\n }\n\n const template = this.selected\n\n return html`\n <header>${template.name}</header>\n <div detail>\n <label field>\n ${i18next.t('field.name')}\n <input .value=${this.name} @input=${(e: any) => (this.name = e.target.value)} />\n <small>${i18next.t('text.this plant may call the seat what it likes')}</small>\n </label>\n ${template.defaultNameTaken && this.name === template.name\n ? html`<p note>${i18next.t('text.a role of this name exists and will be added to')}</p>`\n : nothing}\n ${this.renderOpens(template)}\n </div>\n `\n }\n\n /**\n * 이 자리가 무엇을 여나 — **선언된 것만.**\n *\n * ⚠ 여기 「바꿀 수 있는 것 / 볼 수만 있는 것」 두 묶음이 있었다. 사용자가 물었다(2026-09-11):\n * 「바꿀 수 있고, 볼 수만 있는 것을 너가 어떻게 알아? 논리적이지 않은 것을 우겨넣지 말고.」\n *\n * 몰랐다. 지어낸 것이다. 근거가 없는 이유가 둘이다.\n *\n * ① `@privilege(privilege:)` 는 **제약 없는 문자열**이다(지시자 선언이 `privilege: String`\n * 이고 enum 이 아니다). 지금 쓰인 값이 mutation 484 · query 314 로 둘뿐인 것은 **오늘\n * 그렇게 쓴 것**이지 둘로 한정된 것이 아니다. 내 코드는 `axis !== 'query'` 로 갈랐으므로,\n * 처음 보는 값은 **알아서가 아니라 query 가 아니라서** 「바꿀 수 있는 것」으로 떨어졌다.\n * ② 이름이 뜻을 보장하지 않는다. 축 이름과 실제 GraphQL 연산이 어긋나는 자리가 6곳이고,\n * 그중 둘은 이 기능의 내 파일이다(`role-template-query.ts` — 템플릿을 **읽는** 질의에\n * `privilege: \"mutation\"` 을 달았다. 역할을 만드는 문이라서 그게 맞다). 축은 연산 종류가\n * 아니라 **어느 문을 지나야 하나**의 이름이다.\n *\n * 그래서 화면은 선언된 것을 그대로 낸다 — 어느 모듈에, 어느 권한이. 읽히게 만드는 것\n * (굵기·줄 간격·가운뎃점)은 아무것도 주장하지 않으므로 그대로 둔다.\n */\n private renderOpens(template: TemplateView) {\n if (template.grantsNothingDeliberately) {\n return html`<p note>${i18next.t('text.opens nothing, receives approvals')}</p>`\n }\n\n return html`\n <dl grants>\n ${[...template.grants].sort(byName).map(\n grant => html`\n <dt>${moduleLabel(grant.category)}</dt>\n <dd>\n ${grant.axes.map(axis => html`<span axis>${axisLabel(axis)}</span>`)}\n ${grant.missingAxes.map(axis => html`<span axis missing>${axisLabel(axis)}</span>`)}\n </dd>\n `\n )}\n </dl>\n ${template.missingCount\n ? html`<p note>${i18next.t('text.struck through are not installed here')}</p>`\n : nothing}\n `\n }\n\n private pick(template: TemplateView) {\n this.scratch = false\n this.selected = template\n this.name = template.name\n }\n\n private pickScratch() {\n this.scratch = true\n this.selected = undefined\n this.name = ''\n }\n\n private canCreate() {\n return Boolean(this.name.trim()) && (this.scratch || Boolean(this.selected))\n }\n\n private async create() {\n const created = this.scratch\n ? await this.page?.createBlankRole?.(this.name.trim(), this.description.trim())\n : await this.page?.createFromTemplate?.(this.selected!.id, this.name.trim())\n\n if (created) {\n this.dispatchEvent(new CustomEvent('close'))\n }\n }\n}\n"]}
|