@things-factory/auth-ui 10.1.7 → 10.1.16
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.d.ts +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 +3 -0
- package/dist-client/components/role-privilege-picker.js +19 -0
- package/dist-client/components/role-privilege-picker.js.map +1 -1
- package/dist-client/components/role-template-picker.js +6 -8
- package/dist-client/components/role-template-picker.js.map +1 -1
- package/dist-client/pages/role/role-list-page.d.ts +20 -0
- package/dist-client/pages/role/role-list-page.js +58 -1
- package/dist-client/pages/role/role-list-page.js.map +1 -1
- package/dist-client/pages/role/role-privilege-page.d.ts +18 -0
- package/dist-client/pages/role/role-privilege-page.js +124 -25
- package/dist-client/pages/role/role-privilege-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/utils/privilege-axis.d.ts +52 -0
- package/dist-client/utils/privilege-axis.js +55 -0
- package/dist-client/utils/privilege-axis.js.map +1 -0
- package/dist-client/utils/privilege-axis.test.d.ts +1 -0
- package/dist-client/utils/privilege-axis.test.js +39 -0
- package/dist-client/utils/privilege-axis.test.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/translations/en.json +2 -0
- package/translations/ja.json +2 -0
- package/translations/ko.json +2 -0
- package/translations/ms.json +2 -0
- package/translations/zh.json +2 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** 검색·선택 상태는 Lit 화면 밖에서도 같은 규칙으로 검증한다. */
|
|
2
|
+
export type PrivilegeModuleRef = {
|
|
3
|
+
category: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* 모듈은 코드(category)와 사람이 보는 이름 모두로 찾는다. 관리자가 「사용자」를 입력했는데
|
|
7
|
+
* 내부 코드 `user`만 비교하면 결과가 없다고 나오는 것은 검색으로서 실패다.
|
|
8
|
+
*/
|
|
9
|
+
export declare function filterPrivilegeModules<T extends PrivilegeModuleRef>(modules: T[], keyword: string, labelOf: (category: string) => string): T[];
|
|
10
|
+
/** 검색 결과가 바뀌어 선택한 모듈이 사라지면 첫 결과를 연다. */
|
|
11
|
+
export declare function selectedVisibleModule<T extends PrivilegeModuleRef>(modules: T[], selected: string): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 모듈은 코드(category)와 사람이 보는 이름 모두로 찾는다. 관리자가 「사용자」를 입력했는데
|
|
3
|
+
* 내부 코드 `user`만 비교하면 결과가 없다고 나오는 것은 검색으로서 실패다.
|
|
4
|
+
*/
|
|
5
|
+
export function filterPrivilegeModules(modules, keyword, labelOf) {
|
|
6
|
+
const needle = keyword.trim().toLocaleLowerCase();
|
|
7
|
+
if (!needle)
|
|
8
|
+
return modules;
|
|
9
|
+
return modules.filter(module => [module.category, labelOf(module.category)].some(value => value.toLocaleLowerCase().includes(needle)));
|
|
10
|
+
}
|
|
11
|
+
/** 검색 결과가 바뀌어 선택한 모듈이 사라지면 첫 결과를 연다. */
|
|
12
|
+
export function selectedVisibleModule(modules, selected) {
|
|
13
|
+
return modules.some(module => module.category === selected) ? selected : modules[0]?.category || '';
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=role-privilege-picker-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"role-privilege-picker-state.js","sourceRoot":"","sources":["../../client/components/role-privilege-picker-state.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAY,EACZ,OAAe,EACf,OAAqC;IAErC,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,iBAAiB,EAAE,CAAA;IACjD,IAAI,CAAC,MAAM;QAAE,OAAO,OAAO,CAAA;IAE3B,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAC7B,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CACtG,CAAA;AACH,CAAC;AAED,wCAAwC;AACxC,MAAM,UAAU,qBAAqB,CAA+B,OAAY,EAAE,QAAgB;IAChG,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,IAAI,EAAE,CAAA;AACrG,CAAC","sourcesContent":["/** 검색·선택 상태는 Lit 화면 밖에서도 같은 규칙으로 검증한다. */\nexport type PrivilegeModuleRef = { category: string }\n\n/**\n * 모듈은 코드(category)와 사람이 보는 이름 모두로 찾는다. 관리자가 「사용자」를 입력했는데\n * 내부 코드 `user`만 비교하면 결과가 없다고 나오는 것은 검색으로서 실패다.\n */\nexport function filterPrivilegeModules<T extends PrivilegeModuleRef>(\n modules: T[],\n keyword: string,\n labelOf: (category: string) => string\n): T[] {\n const needle = keyword.trim().toLocaleLowerCase()\n if (!needle) return modules\n\n return modules.filter(module =>\n [module.category, labelOf(module.category)].some(value => value.toLocaleLowerCase().includes(needle))\n )\n}\n\n/** 검색 결과가 바뀌어 선택한 모듈이 사라지면 첫 결과를 연다. */\nexport function selectedVisibleModule<T extends PrivilegeModuleRef>(modules: T[], selected: string): string {\n return modules.some(module => module.category === selected) ? selected : modules[0]?.category || ''\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { filterPrivilegeModules, selectedVisibleModule } from './role-privilege-picker-state';
|
|
2
|
+
const modules = [{ category: 'user' }, { category: 'board' }, { category: 'worklist' }];
|
|
3
|
+
const labels = { user: '사용자', board: '보드', worklist: '작업지시' };
|
|
4
|
+
const labelOf = (category) => labels[category] || category;
|
|
5
|
+
describe('권한 모듈 검색', () => {
|
|
6
|
+
it('화면에 보이는 한글 모듈명으로 찾는다', () => {
|
|
7
|
+
expect(filterPrivilegeModules(modules, '사용자', labelOf)).toEqual([{ category: 'user' }]);
|
|
8
|
+
});
|
|
9
|
+
it('코드 모듈명으로도 찾는다', () => {
|
|
10
|
+
expect(filterPrivilegeModules(modules, 'work', labelOf)).toEqual([{ category: 'worklist' }]);
|
|
11
|
+
});
|
|
12
|
+
it('검색 결과에서 사라진 선택은 첫 결과로 옮긴다', () => {
|
|
13
|
+
const visible = filterPrivilegeModules(modules, '작업', labelOf);
|
|
14
|
+
expect(selectedVisibleModule(visible, 'user')).toBe('worklist');
|
|
15
|
+
});
|
|
16
|
+
it('아직 보이는 선택은 유지한다', () => {
|
|
17
|
+
expect(selectedVisibleModule(modules, 'board')).toBe('board');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=role-privilege-picker-state.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"role-privilege-picker-state.test.js","sourceRoot":"","sources":["../../client/components/role-privilege-picker-state.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAE7F,MAAM,OAAO,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAA;AACvF,MAAM,MAAM,GAA2B,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;AACrF,MAAM,OAAO,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAA;AAElE,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE;QAC9B,MAAM,CAAC,sBAAsB,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;IACzF,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;QACvB,MAAM,CAAC,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA;IAC9F,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACnC,MAAM,OAAO,GAAG,sBAAsB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;QAC9D,MAAM,CAAC,qBAAqB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACjE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,iBAAiB,EAAE,GAAG,EAAE;QACzB,MAAM,CAAC,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC/D,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { filterPrivilegeModules, selectedVisibleModule } from './role-privilege-picker-state'\n\nconst modules = [{ category: 'user' }, { category: 'board' }, { category: 'worklist' }]\nconst labels: Record<string, string> = { user: '사용자', board: '보드', worklist: '작업지시' }\nconst labelOf = (category: string) => labels[category] || category\n\ndescribe('권한 모듈 검색', () => {\n it('화면에 보이는 한글 모듈명으로 찾는다', () => {\n expect(filterPrivilegeModules(modules, '사용자', labelOf)).toEqual([{ category: 'user' }])\n })\n\n it('코드 모듈명으로도 찾는다', () => {\n expect(filterPrivilegeModules(modules, 'work', labelOf)).toEqual([{ category: 'worklist' }])\n })\n\n it('검색 결과에서 사라진 선택은 첫 결과로 옮긴다', () => {\n const visible = filterPrivilegeModules(modules, '작업', labelOf)\n expect(selectedVisibleModule(visible, 'user')).toBe('worklist')\n })\n\n it('아직 보이는 선택은 유지한다', () => {\n expect(selectedVisibleModule(modules, 'board')).toBe('board')\n })\n})\n"]}
|
|
@@ -31,7 +31,10 @@ export declare class RolePrivilegePicker extends LitElement {
|
|
|
31
31
|
static styles: CSSResultGroup;
|
|
32
32
|
/** 담는 페이지. 이 부품은 그것의 `renderPickerBody()` 를 그린다. */
|
|
33
33
|
page?: any;
|
|
34
|
+
private searchInput?;
|
|
35
|
+
private readonly onSearchInput;
|
|
34
36
|
connectedCallback(): void;
|
|
35
37
|
disconnectedCallback(): void;
|
|
36
38
|
render(): any;
|
|
39
|
+
updated(): void;
|
|
37
40
|
}
|
|
@@ -30,6 +30,14 @@ import { RolePrivilegePage } from '../pages/role/role-privilege-page.js';
|
|
|
30
30
|
* 페이지가 이 파일을 **동적으로** 들이기 때문에 이 import 가 순환이 되지 않는다.
|
|
31
31
|
*/
|
|
32
32
|
let RolePrivilegePicker = class RolePrivilegePicker extends LitElement {
|
|
33
|
+
constructor() {
|
|
34
|
+
super(...arguments);
|
|
35
|
+
this.onSearchInput = (event) => {
|
|
36
|
+
/* ox-input-search 는 값을 확정할 때만 host `change`를 낸다. 모듈을 찾는 일은 입력 중에도
|
|
37
|
+
결과가 바뀌어야 하므로, 이 팝업의 shadow root 안 native input을 직접 듣는다. */
|
|
38
|
+
this.page?.updateKeyword?.(event);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
33
41
|
static { this.styles = RolePrivilegePage.styles; }
|
|
34
42
|
connectedCallback() {
|
|
35
43
|
super.connectedCallback();
|
|
@@ -38,6 +46,8 @@ let RolePrivilegePicker = class RolePrivilegePicker extends LitElement {
|
|
|
38
46
|
}
|
|
39
47
|
}
|
|
40
48
|
disconnectedCallback() {
|
|
49
|
+
this.searchInput?.removeEventListener('input', this.onSearchInput);
|
|
50
|
+
this.searchInput = undefined;
|
|
41
51
|
super.disconnectedCallback();
|
|
42
52
|
if (this.page?.picker === this) {
|
|
43
53
|
this.page.picker = undefined;
|
|
@@ -46,6 +56,15 @@ let RolePrivilegePicker = class RolePrivilegePicker extends LitElement {
|
|
|
46
56
|
render() {
|
|
47
57
|
return this.page?.renderPickerBody?.() ?? html ``;
|
|
48
58
|
}
|
|
59
|
+
updated() {
|
|
60
|
+
const nextSearchInput = this.renderRoot.querySelector('ox-input-search')?.shadowRoot?.querySelector('input');
|
|
61
|
+
if (nextSearchInput === this.searchInput) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this.searchInput?.removeEventListener('input', this.onSearchInput);
|
|
65
|
+
this.searchInput = nextSearchInput;
|
|
66
|
+
this.searchInput?.addEventListener('input', this.onSearchInput);
|
|
67
|
+
}
|
|
49
68
|
};
|
|
50
69
|
__decorate([
|
|
51
70
|
property({ type: Object }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role-privilege-picker.js","sourceRoot":"","sources":["../../client/components/role-privilege-picker.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,oCAAoC,CAAA;AAC3C,OAAO,mCAAmC,CAAA;AAE1C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAEtC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAExE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEI,IAAM,mBAAmB,GAAz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,IAAI,EAAE,gBAAgB,EAAE,EAAE,IAAI,IAAI,CAAA,EAAE,CAAA;IAClD,CAAC;IAED,OAAO;QACL,MAAM,eAAe,GAAI,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,iBAAiB,CAAS,EAAE,UAAU,EAAE,aAAa,CAC1G,OAAO,CACwB,CAAA;QAEjC,IAAI,eAAe,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC;YACzC,OAAM;QACR,CAAC;QAED,IAAI,CAAC,WAAW,EAAE,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAA;QAClE,IAAI,CAAC,WAAW,GAAG,eAAe,CAAA;QAClC,IAAI,CAAC,WAAW,EAAE,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAA;IACjE,CAAC;;AA1C2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;iDAAW;AAJ3B,mBAAmB;IAD/B,aAAa,CAAC,uBAAuB,CAAC;GAC1B,mBAAmB,CA+C/B","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@material/web/checkbox/checkbox.js'\nimport '@operato/input/ox-input-search.js'\n\nimport { html, LitElement } from 'lit'\nimport type { CSSResultGroup } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { RolePrivilegePage } from '../pages/role/role-privilege-page.js'\n\n/**\n * 「할 수 있는 일 더하기」의 **그릇**.\n *\n * ── 왜 팝업인가 (사용자, 2026-09-11) ────────────────────────────────────────\n * 「'할 수 있는 일 더하기' 작동을 팝업으로 넓게 할 수 있었으면 어떤가? 지금은 좁아보이고」\n *\n * 페이지 안에 펼치면 본문(할 수 있는 일)이 아래로 밀리고, 남은 폭에서 모듈 46개와 축 목록을\n * 함께 봐야 한다. 고르는 동안은 **고르는 것만** 보는 것이 맞다.\n *\n * ── 이 부품은 아무것도 안 그린다 ────────────────────────────────────────────\n * 모듈 접기·축 줄·유령 규칙이 전부 페이지의 상태(`modules`·`assigned`·`selected`·`keyword`)를\n * 본다. 그것을 여기로 옮기면 **상태가 두 벌**이 되고, 그 순간 어느 쪽이 저장 범위인지\n * 흐려진다 — 옛 편집기가 `querySelectorAll` 로 범위를 만들던 결함이 정확히 그 모양이었다.\n *\n * 그래서 그리기는 페이지가 하고(`renderPickerBody`), 여기는 담아서 띄우기만 한다. 대신\n * 페이지가 토글할 때 이 부품에게 다시 그리라고 알린다(`page.picker`).\n *\n * ── 스타일도 한 벌이다 ──────────────────────────────────────────────────────\n * 팝업은 페이지의 shadow root **밖**에 뜨므로 페이지 스타일이 여기까지 안 온다. 베껴 두면\n * 한쪽만 고쳐지는 날이 오고, 오늘 이 화면에서 그 부류를 이미 만났다 — 칩 시절 CSS 가 남아\n * 새 규칙을 이겼다. 그래서 페이지의 `styles` 를 그대로 가져간다.\n *\n * 페이지가 이 파일을 **동적으로** 들이기 때문에 이 import 가 순환이 되지 않는다.\n */\n@customElement('role-privilege-picker')\nexport class RolePrivilegePicker extends LitElement {\n static styles: CSSResultGroup = RolePrivilegePage.styles as CSSResultGroup\n\n /** 담는 페이지. 이 부품은 그것의 `renderPickerBody()` 를 그린다. */\n @property({ type: Object }) page?: any\n\n private searchInput?: HTMLInputElement\n\n private readonly onSearchInput = (event: Event) => {\n /* ox-input-search 는 값을 확정할 때만 host `change`를 낸다. 모듈을 찾는 일은 입력 중에도\n 결과가 바뀌어야 하므로, 이 팝업의 shadow root 안 native input을 직접 듣는다. */\n this.page?.updateKeyword?.(event)\n }\n\n connectedCallback() {\n super.connectedCallback()\n if (this.page) {\n this.page.picker = this\n }\n }\n\n disconnectedCallback() {\n this.searchInput?.removeEventListener('input', this.onSearchInput)\n this.searchInput = undefined\n super.disconnectedCallback()\n if (this.page?.picker === this) {\n this.page.picker = undefined\n }\n }\n\n render() {\n return this.page?.renderPickerBody?.() ?? html``\n }\n\n updated() {\n const nextSearchInput = (this.renderRoot.querySelector('ox-input-search') as any)?.shadowRoot?.querySelector(\n 'input'\n ) as HTMLInputElement | undefined\n\n if (nextSearchInput === this.searchInput) {\n return\n }\n\n this.searchInput?.removeEventListener('input', this.onSearchInput)\n this.searchInput = nextSearchInput\n this.searchInput?.addEventListener('input', this.onSearchInput)\n }\n}\n"]}
|
|
@@ -5,12 +5,13 @@ import { css, html, LitElement, nothing } from 'lit';
|
|
|
5
5
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
6
6
|
import { client, gqlContext } from '@operato/graphql';
|
|
7
7
|
import { i18next, localize } from '@operato/i18n';
|
|
8
|
+
import { axisLabel } from '../utils/privilege-axis.js';
|
|
8
9
|
import { CommonHeaderStyles, FormFieldStyles, ScrollbarStyles } from '@operato/styles';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
/*
|
|
11
|
+
* The axis vocabulary lives in `utils/privilege-axis.ts` now — one table, not the copy that
|
|
12
|
+
* used to sit here beside an identical one in `role-privilege-page.ts`. It also stopped
|
|
13
|
+
* translating `query`/`mutation` into 「읽기」/「쓰기」; that file says why.
|
|
14
|
+
*/
|
|
14
15
|
/**
|
|
15
16
|
* The module, in words people use.
|
|
16
17
|
*
|
|
@@ -22,9 +23,6 @@ const AXIS_LABEL = {
|
|
|
22
23
|
function moduleLabel(category) {
|
|
23
24
|
return i18next.t(`privilege.category.${category}`, { defaultValue: category });
|
|
24
25
|
}
|
|
25
|
-
function axisLabel(axis) {
|
|
26
|
-
return AXIS_LABEL[axis] ? i18next.t(AXIS_LABEL[axis]) : axis;
|
|
27
|
-
}
|
|
28
26
|
/** Stable order inside a group, by the name a person actually reads. */
|
|
29
27
|
function byName(a, b) {
|
|
30
28
|
return moduleLabel(a.category).localeCompare(moduleLabel(b.category));
|
|
@@ -1 +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,MAA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AkB,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"]}
|
|
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,mBA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Q,CAAC,CAAC,CAAA;IAC9E,CAAC;IAEO,KAAK,CAAC,MAAM;QAClB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO;YAC1B,CAAC,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,eAAe,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;YAC/E,CAAC,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,kBAAkB,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'\n\nimport { axisLabel } from '../utils/privilege-axis.js'\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\n/*\n * The axis vocabulary lives in `utils/privilege-axis.ts` now — one table, not the copy that\n * used to sit here beside an identical one in `role-privilege-page.ts`. It also stopped\n * translating `query`/`mutation` into 「읽기」/「쓰기」; that file says why.\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\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"]}
|
|
@@ -44,6 +44,12 @@ export declare class RoleListPage extends RoleListPageBase {
|
|
|
44
44
|
private total;
|
|
45
45
|
private filtered;
|
|
46
46
|
private mySubdomain;
|
|
47
|
+
/**
|
|
48
|
+
* 물려받는 곳. `null` 이면 최상위, `undefined` 면 아직 안 읽었다.
|
|
49
|
+
*
|
|
50
|
+
* 셋을 가르는 이유는 화면이 「모른다」와 「없다」를 다르게 그려야 하기 때문이다.
|
|
51
|
+
*/
|
|
52
|
+
private parentDomain;
|
|
47
53
|
private scope;
|
|
48
54
|
/**
|
|
49
55
|
* 묶음마다 몇 건인가.
|
|
@@ -96,6 +102,20 @@ export declare class RoleListPage extends RoleListPageBase {
|
|
|
96
102
|
* 아직 못 센 묶음은 수를 **안 그린다** — 0 으로 메우면 「없다」와 같아 보인다.
|
|
97
103
|
*/
|
|
98
104
|
private renderScopes;
|
|
105
|
+
/**
|
|
106
|
+
* 어디에서 물려받나 — **있을 때나 없을 때나 같은 자리에서 말한다.**
|
|
107
|
+
*
|
|
108
|
+
* 「상속」 단추만 두면 눌러 보기 전에는 그것이 무엇을 뜻하는지 알 수 없다. 부모가 있는
|
|
109
|
+
* 도메인에서는 **어느 도메인인지**가 필요하고(그 역할을 고치러 가야 할 곳이다), 최상위
|
|
110
|
+
* 도메인에서는 **물려받는 곳이 없다는 사실**이 필요하다. 후자를 안 적으면 「상속 0」이
|
|
111
|
+
* 「아직 안 만들었나」로 읽힌다.
|
|
112
|
+
*
|
|
113
|
+
* 단추를 숨기지 않는다. 숨기면 최상위 도메인의 관리자는 상속이라는 것이 있다는 사실
|
|
114
|
+
* 자체를 모르고, 자식 도메인을 만든 뒤에 갑자기 나타나는 단추를 만난다.
|
|
115
|
+
*
|
|
116
|
+
* 아직 프로필을 못 읽었으면 **아무것도 안 적는다** — 모르는 것을 「없다」로 적지 않는다.
|
|
117
|
+
*/
|
|
118
|
+
private renderLineage;
|
|
99
119
|
private onScope;
|
|
100
120
|
/**
|
|
101
121
|
* 세 묶음의 건수.
|
|
@@ -60,6 +60,12 @@ let RoleListPage = class RoleListPage extends RoleListPageBase {
|
|
|
60
60
|
* 견준다 — 두 도메인이 같은 subdomain 을 가질 수 없으므로 id 와 같은 답이다.
|
|
61
61
|
*/
|
|
62
62
|
this.mySubdomain = '';
|
|
63
|
+
/**
|
|
64
|
+
* 물려받는 곳. `null` 이면 최상위, `undefined` 면 아직 안 읽었다.
|
|
65
|
+
*
|
|
66
|
+
* 셋을 가르는 이유는 화면이 「모른다」와 「없다」를 다르게 그려야 하기 때문이다.
|
|
67
|
+
*/
|
|
68
|
+
this.parentDomain = undefined;
|
|
63
69
|
/*
|
|
64
70
|
* **어느 묶음을 보고 있나 — 기본값은 「우리 역할」이다.**
|
|
65
71
|
*
|
|
@@ -127,6 +133,19 @@ let RoleListPage = class RoleListPage extends RoleListPageBase {
|
|
|
127
133
|
display: flex;
|
|
128
134
|
align-items: center;
|
|
129
135
|
gap: 4px;
|
|
136
|
+
flex-wrap: wrap;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/*
|
|
140
|
+
어디에서 물려받나 — 단추가 아니라 **사실을 적은 글**이다. 그래서 알약도 테두리도 없다.
|
|
141
|
+
고르는 것과 읽는 것이 같은 모양이면 눌러 보게 된다.
|
|
142
|
+
|
|
143
|
+
단추 줄에서 한 칸 떨어뜨린다. 붙여 두면 네 번째 단추로 보인다.
|
|
144
|
+
*/
|
|
145
|
+
[lineage] {
|
|
146
|
+
margin-left: 8px;
|
|
147
|
+
font-size: 0.78rem;
|
|
148
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
130
149
|
}
|
|
131
150
|
|
|
132
151
|
button[scope] {
|
|
@@ -291,9 +310,36 @@ let RoleListPage = class RoleListPage extends RoleListPageBase {
|
|
|
291
310
|
${this.counts[scope] === undefined ? nothing : html `<span count>${this.counts[scope]}</span>`}
|
|
292
311
|
</button>
|
|
293
312
|
`)}
|
|
313
|
+
${this.renderLineage()}
|
|
294
314
|
</div>
|
|
295
315
|
`;
|
|
296
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* 어디에서 물려받나 — **있을 때나 없을 때나 같은 자리에서 말한다.**
|
|
319
|
+
*
|
|
320
|
+
* 「상속」 단추만 두면 눌러 보기 전에는 그것이 무엇을 뜻하는지 알 수 없다. 부모가 있는
|
|
321
|
+
* 도메인에서는 **어느 도메인인지**가 필요하고(그 역할을 고치러 가야 할 곳이다), 최상위
|
|
322
|
+
* 도메인에서는 **물려받는 곳이 없다는 사실**이 필요하다. 후자를 안 적으면 「상속 0」이
|
|
323
|
+
* 「아직 안 만들었나」로 읽힌다.
|
|
324
|
+
*
|
|
325
|
+
* 단추를 숨기지 않는다. 숨기면 최상위 도메인의 관리자는 상속이라는 것이 있다는 사실
|
|
326
|
+
* 자체를 모르고, 자식 도메인을 만든 뒤에 갑자기 나타나는 단추를 만난다.
|
|
327
|
+
*
|
|
328
|
+
* 아직 프로필을 못 읽었으면 **아무것도 안 적는다** — 모르는 것을 「없다」로 적지 않는다.
|
|
329
|
+
*/
|
|
330
|
+
renderLineage() {
|
|
331
|
+
if (this.parentDomain === undefined) {
|
|
332
|
+
return nothing;
|
|
333
|
+
}
|
|
334
|
+
const from = this.parentDomain?.name || this.parentDomain?.subdomain;
|
|
335
|
+
return html `
|
|
336
|
+
<span lineage>
|
|
337
|
+
${from
|
|
338
|
+
? i18next.t('text.inherited from x', { x: from })
|
|
339
|
+
: i18next.t('text.this domain is top level and inherits from nowhere')}
|
|
340
|
+
</span>
|
|
341
|
+
`;
|
|
342
|
+
}
|
|
297
343
|
onScope(scope) {
|
|
298
344
|
if (this.scope === scope) {
|
|
299
345
|
return;
|
|
@@ -389,7 +435,14 @@ let RoleListPage = class RoleListPage extends RoleListPageBase {
|
|
|
389
435
|
>`;
|
|
390
436
|
}
|
|
391
437
|
async pageInitialized() {
|
|
392
|
-
|
|
438
|
+
const mine = await getDomain();
|
|
439
|
+
this.mySubdomain = mine?.subdomain || '';
|
|
440
|
+
/*
|
|
441
|
+
* `undefined` 는 「아직 모른다」, `null` 은 「부모가 없다」다. 프로필이 `parent` 칸을
|
|
442
|
+
* 들고 오므로 둘이 갈린다 — 옛 서버가 그 칸을 안 보내면 `undefined` 로 남아 아무것도
|
|
443
|
+
* 안 적는다. 「모른다」를 「없다」로 접지 않는다.
|
|
444
|
+
*/
|
|
445
|
+
this.parentDomain = mine && 'parent' in mine ? mine.parent : undefined;
|
|
393
446
|
this.countScopes();
|
|
394
447
|
this.config = {
|
|
395
448
|
/*
|
|
@@ -803,6 +856,10 @@ __decorate([
|
|
|
803
856
|
state(),
|
|
804
857
|
__metadata("design:type", String)
|
|
805
858
|
], RoleListPage.prototype, "mySubdomain", void 0);
|
|
859
|
+
__decorate([
|
|
860
|
+
state(),
|
|
861
|
+
__metadata("design:type", Object)
|
|
862
|
+
], RoleListPage.prototype, "parentDomain", void 0);
|
|
806
863
|
__decorate([
|
|
807
864
|
state(),
|
|
808
865
|
__metadata("design:type", String)
|