@things-factory/saas 10.1.236 → 10.1.238
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/saas-candidates.d.ts +33 -0
- package/dist-client/components/saas-candidates.js +157 -0
- package/dist-client/components/saas-candidates.js.map +1 -0
- package/dist-client/index.d.ts +1 -0
- package/dist-client/index.js +1 -0
- package/dist-client/index.js.map +1 -1
- package/dist-client/pages/saas-account-list.js +3 -0
- package/dist-client/pages/saas-account-list.js.map +1 -1
- package/dist-client/pages/saas-account-page.js +7 -2
- package/dist-client/pages/saas-account-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/role-tasks.js +3 -1
- package/dist-server/role-tasks.js.map +1 -1
- package/dist-server/service/checks.d.ts +4 -1
- package/dist-server/service/checks.js +5 -2
- package/dist-server/service/checks.js.map +1 -1
- package/dist-server/service/index.d.ts +4 -1
- package/dist-server/service/index.js +5 -1
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/saas-hidden-vendor.d.ts +19 -0
- package/dist-server/service/saas-hidden-vendor.js +53 -0
- package/dist-server/service/saas-hidden-vendor.js.map +1 -0
- package/dist-server/service/saas-mutation.d.ts +4 -1
- package/dist-server/service/saas-mutation.js +54 -0
- package/dist-server/service/saas-mutation.js.map +1 -1
- package/dist-server/service/saas-query.d.ts +2 -1
- package/dist-server/service/saas-query.js +16 -0
- package/dist-server/service/saas-query.js.map +1 -1
- package/dist-server/service/saas-rules.d.ts +41 -0
- package/dist-server/service/saas-rules.js +49 -1
- package/dist-server/service/saas-rules.js.map +1 -1
- package/dist-server/service/saas-seat.d.ts +1 -0
- package/dist-server/service/saas-seat.js +5 -0
- package/dist-server/service/saas-seat.js.map +1 -1
- package/dist-server/service/saas-service.d.ts +30 -7
- package/dist-server/service/saas-service.js +134 -17
- package/dist-server/service/saas-service.js.map +1 -1
- package/dist-server/service/saas-subscription.d.ts +2 -0
- package/dist-server/service/saas-subscription.js +10 -0
- package/dist-server/service/saas-subscription.js.map +1 -1
- package/dist-server/service/saas-sync.d.ts +34 -0
- package/dist-server/service/saas-sync.js +106 -0
- package/dist-server/service/saas-sync.js.map +1 -0
- package/dist-server/service/saas-type.d.ts +45 -0
- package/dist-server/service/saas-type.js +171 -1
- package/dist-server/service/saas-type.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/translations/en.json +23 -0
- package/translations/es.json +23 -0
- package/translations/ja.json +23 -0
- package/translations/ko.json +23 -0
- package/translations/ms.json +23 -0
- package/translations/zh.json +23 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import '@material/web/button/filled-button.js';
|
|
2
|
+
import '@material/web/button/text-button.js';
|
|
3
|
+
import '@operato/data-grist/ox-grist.js';
|
|
4
|
+
import '@operato/popup/ox-popup-actions.js';
|
|
5
|
+
import { LitElement } from 'lit';
|
|
6
|
+
declare const SaasCandidates_base: (new (...args: any[]) => LitElement) & typeof LitElement;
|
|
7
|
+
/**
|
|
8
|
+
* 장부에서 찾기 (ADR-0177 개정 1) - whom the bank and card lines show paid month after month that is no account or
|
|
9
|
+
* recurring item yet, a registered counterparty or a name the lines carry. Picked ones become accounts with a usage
|
|
10
|
+
* subscription at their monthly average (a name is registered as a counterparty); ones that are no subscription are
|
|
11
|
+
* hidden, and can be shown again.
|
|
12
|
+
*/
|
|
13
|
+
export declare class SaasCandidates extends SaasCandidates_base {
|
|
14
|
+
static styles: import("lit").CSSResult[];
|
|
15
|
+
made?: () => void;
|
|
16
|
+
/** The hidden ones instead of the candidates. */
|
|
17
|
+
hidden: boolean;
|
|
18
|
+
data: any;
|
|
19
|
+
private grist;
|
|
20
|
+
private gristConfig;
|
|
21
|
+
static open(options?: {
|
|
22
|
+
made?: () => void;
|
|
23
|
+
}): import("@operato/layout").PopupHandle<unknown>;
|
|
24
|
+
connectedCallback(): void;
|
|
25
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
26
|
+
private flip;
|
|
27
|
+
private read;
|
|
28
|
+
private picked;
|
|
29
|
+
private run;
|
|
30
|
+
private create;
|
|
31
|
+
private hide;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@material/web/button/filled-button.js';
|
|
3
|
+
import '@material/web/button/text-button.js';
|
|
4
|
+
import '@operato/data-grist/ox-grist.js';
|
|
5
|
+
import '@operato/popup/ox-popup-actions.js';
|
|
6
|
+
import gql from 'graphql-tag';
|
|
7
|
+
import { css, html, LitElement } from 'lit';
|
|
8
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
9
|
+
import { DataGrist } from '@operato/data-grist';
|
|
10
|
+
import { client } from '@operato/graphql';
|
|
11
|
+
import { i18next, localize } from '@operato/i18n';
|
|
12
|
+
import { notify, openPopup } from '@operato/layout';
|
|
13
|
+
import { closePopup } from '@operato/popup';
|
|
14
|
+
import { CommonPopupStyles } from '@operato/styles';
|
|
15
|
+
import { failureOf } from '@things-factory/asset/dist-client/grid.js';
|
|
16
|
+
import { amountText, fieldWord } from '../words.js';
|
|
17
|
+
const CANDIDATES = gql `
|
|
18
|
+
query ($hidden: Boolean) {
|
|
19
|
+
saasCandidates(hidden: $hidden) { key counterpartyId counterpartyName months average firstDate lastDate lastAmount currency billingDay }
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
/**
|
|
23
|
+
* 장부에서 찾기 (ADR-0177 개정 1) - whom the bank and card lines show paid month after month that is no account or
|
|
24
|
+
* recurring item yet, a registered counterparty or a name the lines carry. Picked ones become accounts with a usage
|
|
25
|
+
* subscription at their monthly average (a name is registered as a counterparty); ones that are no subscription are
|
|
26
|
+
* hidden, and can be shown again.
|
|
27
|
+
*/
|
|
28
|
+
let SaasCandidates = class SaasCandidates extends localize(i18next)(LitElement) {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
/** The hidden ones instead of the candidates. */
|
|
32
|
+
this.hidden = false;
|
|
33
|
+
this.data = { records: [], total: 0 };
|
|
34
|
+
this.gristConfig = {
|
|
35
|
+
rows: { appendable: false, selectable: { multiple: true } },
|
|
36
|
+
pagination: { infinite: true },
|
|
37
|
+
columns: [
|
|
38
|
+
{ type: 'gutter', gutterName: 'sequence' },
|
|
39
|
+
{ type: 'gutter', gutterName: 'row-selector', multiple: true },
|
|
40
|
+
{ type: 'string', name: 'counterpartyName', header: fieldWord('saas-candidate', 'counterparty'), width: 200 },
|
|
41
|
+
{ type: 'integer', name: 'months', header: fieldWord('saas-candidate', 'months'), width: 90, record: { align: 'right' } },
|
|
42
|
+
{ type: 'float', name: 'average', header: fieldWord('saas-candidate', 'average'), width: 130, record: { align: 'right', renderer: (value, _c, record) => `${amountText(value)} ${record?.currency ?? ''}` } },
|
|
43
|
+
{ type: 'string', name: 'lastDate', header: fieldWord('saas-candidate', 'last'), width: 200, record: { renderer: (value, _c, record) => `${value} · ${amountText(record?.lastAmount)}` } },
|
|
44
|
+
{ type: 'integer', name: 'billingDay', header: fieldWord('saas-account', 'billingDay'), width: 80, record: { align: 'right', renderer: (value) => (value === 31 ? i18next.t('text.saas-candidate-month-end') : value ?? '') } }
|
|
45
|
+
]
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
static { this.styles = [
|
|
49
|
+
CommonPopupStyles,
|
|
50
|
+
css `
|
|
51
|
+
:host {
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-direction: column;
|
|
54
|
+
background-color: var(--md-sys-color-surface);
|
|
55
|
+
min-height: 420px;
|
|
56
|
+
}
|
|
57
|
+
.note {
|
|
58
|
+
padding: var(--spacing-medium, 8px) var(--spacing-large, 12px);
|
|
59
|
+
font-size: var(--ui-t-caption, 12px);
|
|
60
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
61
|
+
}
|
|
62
|
+
ox-grist {
|
|
63
|
+
flex: 1;
|
|
64
|
+
overflow-y: auto;
|
|
65
|
+
}
|
|
66
|
+
`
|
|
67
|
+
]; }
|
|
68
|
+
static open(options = {}) {
|
|
69
|
+
return openPopup(html `<saas-candidates .made=${options.made}></saas-candidates>`, { backdrop: true, size: 'large', title: i18next.t('title.saas-candidates') });
|
|
70
|
+
}
|
|
71
|
+
connectedCallback() {
|
|
72
|
+
super.connectedCallback();
|
|
73
|
+
this.read();
|
|
74
|
+
}
|
|
75
|
+
render() {
|
|
76
|
+
return html `
|
|
77
|
+
<div class="note">${i18next.t(this.hidden ? 'text.saas-candidates-hidden-note' : 'text.saas-candidates-note')}</div>
|
|
78
|
+
<ox-grist .mode=${'GRID'} .config=${this.gristConfig} .data=${this.data}></ox-grist>
|
|
79
|
+
<ox-popup-actions>
|
|
80
|
+
<md-text-button slot="start" @click=${() => this.flip()}>${i18next.t(this.hidden ? 'button.saas-candidates-show' : 'button.saas-candidates-hidden')}</md-text-button>
|
|
81
|
+
<md-text-button slot="cancel" @click=${() => closePopup(this)}>${i18next.t('button.close')}</md-text-button>
|
|
82
|
+
${this.hidden
|
|
83
|
+
? html `<md-filled-button slot="confirm" @click=${() => this.hide(false)}>${i18next.t('button.saas-candidates-unhide')}</md-filled-button>`
|
|
84
|
+
: html `<md-text-button slot="cancel" @click=${() => this.hide(true)}>${i18next.t('button.saas-candidates-hide')}</md-text-button>
|
|
85
|
+
<md-filled-button slot="confirm" @click=${() => this.create()}>${i18next.t('button.saas-candidates-create')}</md-filled-button>`}
|
|
86
|
+
</ox-popup-actions>
|
|
87
|
+
`;
|
|
88
|
+
}
|
|
89
|
+
async flip() {
|
|
90
|
+
this.hidden = !this.hidden;
|
|
91
|
+
await this.read();
|
|
92
|
+
}
|
|
93
|
+
async read() {
|
|
94
|
+
try {
|
|
95
|
+
const response = await client.query({ query: CANDIDATES, variables: { hidden: this.hidden }, fetchPolicy: 'no-cache' });
|
|
96
|
+
if (response.errors?.length)
|
|
97
|
+
throw response;
|
|
98
|
+
const records = response.data.saasCandidates;
|
|
99
|
+
this.data = { records, total: records.length };
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
notify({ level: 'error', message: failureOf(error) });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
picked() {
|
|
106
|
+
return (this.grist?.selected ?? []).map(one => one.key);
|
|
107
|
+
}
|
|
108
|
+
async run(mutation, variables) {
|
|
109
|
+
const ids = this.picked();
|
|
110
|
+
if (!ids.length) {
|
|
111
|
+
notify({ level: 'warn', message: i18next.t('text.saas-candidates-pick') });
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
const response = await client.mutate({ mutation, variables: { ...variables, keys: ids } });
|
|
116
|
+
if (response.errors?.length)
|
|
117
|
+
throw response;
|
|
118
|
+
await this.read();
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
notify({ level: 'error', message: failureOf(error) });
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async create() {
|
|
127
|
+
const count = this.picked().length;
|
|
128
|
+
if (await this.run(gql `mutation ($keys: [String!]!) { createSaasAccountsFromCandidates(keys: $keys) { id } }`, {})) {
|
|
129
|
+
notify({ level: 'info', message: i18next.t('text.saas-candidates-made', { count }) });
|
|
130
|
+
this.made?.();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
async hide(hide) {
|
|
134
|
+
await this.run(gql `mutation ($keys: [String!]!, $hide: Boolean!) { hideSaasCandidates(keys: $keys, hide: $hide) }`, { hide });
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
__decorate([
|
|
138
|
+
property({ type: Object }),
|
|
139
|
+
__metadata("design:type", Function)
|
|
140
|
+
], SaasCandidates.prototype, "made", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
state(),
|
|
143
|
+
__metadata("design:type", Object)
|
|
144
|
+
], SaasCandidates.prototype, "hidden", void 0);
|
|
145
|
+
__decorate([
|
|
146
|
+
state(),
|
|
147
|
+
__metadata("design:type", Object)
|
|
148
|
+
], SaasCandidates.prototype, "data", void 0);
|
|
149
|
+
__decorate([
|
|
150
|
+
query('ox-grist'),
|
|
151
|
+
__metadata("design:type", DataGrist)
|
|
152
|
+
], SaasCandidates.prototype, "grist", void 0);
|
|
153
|
+
SaasCandidates = __decorate([
|
|
154
|
+
customElement('saas-candidates')
|
|
155
|
+
], SaasCandidates);
|
|
156
|
+
export { SaasCandidates };
|
|
157
|
+
//# sourceMappingURL=saas-candidates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"saas-candidates.js","sourceRoot":"","sources":["../../client/components/saas-candidates.ts"],"names":[],"mappings":";AAAA,OAAO,uCAAuC,CAAA;AAC9C,OAAO,qCAAqC,CAAA;AAC5C,OAAO,iCAAiC,CAAA;AACxC,OAAO,oCAAoC,CAAA;AAE3C,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAA;AAErE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEnD,MAAM,UAAU,GAAG,GAAG,CAAA;;;;CAIrB,CAAA;AAED;;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K,CAAC,EAAE,CAAC,CAAA;YACrD,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,MAAM;QAClB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,MAAM,CAAA;QAClC,IAAI,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAA,uFAAuF,EAAE,EAAE,CAAC,EAAE,CAAC;YACnH,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,2BAA2B,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAA;YACrF,IAAI,CAAC,IAAI,EAAE,EAAE,CAAA;QACf,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,IAAI,CAAC,IAAa;QAC9B,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAA,gGAAgG,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;IAC/H,CAAC;;AA5F2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CAAkB;AAGpC;IAAR,KAAK,EAAE;;8CAAe;AACd;IAAR,KAAK,EAAE;;4CAAsC;AACnB;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;6CAAA;AA3BjC,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CAmH1B","sourcesContent":["import '@material/web/button/filled-button.js'\nimport '@material/web/button/text-button.js'\nimport '@operato/data-grist/ox-grist.js'\nimport '@operato/popup/ox-popup-actions.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { DataGrist } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { closePopup } from '@operato/popup'\nimport { CommonPopupStyles } from '@operato/styles'\nimport { failureOf } from '@things-factory/asset/dist-client/grid.js'\n\nimport { amountText, fieldWord } from '../words.js'\n\nconst CANDIDATES = gql`\n query ($hidden: Boolean) {\n saasCandidates(hidden: $hidden) { key counterpartyId counterpartyName months average firstDate lastDate lastAmount currency billingDay }\n }\n`\n\n/**\n * 장부에서 찾기 (ADR-0177 개정 1) - whom the bank and card lines show paid month after month that is no account or\n * recurring item yet, a registered counterparty or a name the lines carry. Picked ones become accounts with a usage\n * subscription at their monthly average (a name is registered as a counterparty); ones that are no subscription are\n * hidden, and can be shown again.\n */\n@customElement('saas-candidates')\nexport class SaasCandidates extends localize(i18next)(LitElement) {\n static styles = [\n CommonPopupStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n background-color: var(--md-sys-color-surface);\n min-height: 420px;\n }\n .note {\n padding: var(--spacing-medium, 8px) var(--spacing-large, 12px);\n font-size: var(--ui-t-caption, 12px);\n color: var(--md-sys-color-on-surface-variant);\n }\n ox-grist {\n flex: 1;\n overflow-y: auto;\n }\n `\n ]\n\n @property({ type: Object }) made?: () => void\n\n /** The hidden ones instead of the candidates. */\n @state() hidden = false\n @state() data: any = { records: [], total: 0 }\n @query('ox-grist') private grist!: DataGrist\n\n private gristConfig = {\n rows: { appendable: false, selectable: { multiple: true } },\n pagination: { infinite: true },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n { type: 'string', name: 'counterpartyName', header: fieldWord('saas-candidate', 'counterparty'), width: 200 },\n { type: 'integer', name: 'months', header: fieldWord('saas-candidate', 'months'), width: 90, record: { align: 'right' } },\n { type: 'float', name: 'average', header: fieldWord('saas-candidate', 'average'), width: 130, record: { align: 'right', renderer: (value: number, _c: any, record: any) => `${amountText(value)} ${record?.currency ?? ''}` } },\n { type: 'string', name: 'lastDate', header: fieldWord('saas-candidate', 'last'), width: 200, record: { renderer: (value: string, _c: any, record: any) => `${value} · ${amountText(record?.lastAmount)}` } },\n { type: 'integer', name: 'billingDay', header: fieldWord('saas-account', 'billingDay'), width: 80, record: { align: 'right', renderer: (value: number) => (value === 31 ? i18next.t('text.saas-candidate-month-end') : value ?? '') } }\n ]\n }\n\n static open(options: { made?: () => void } = {}) {\n return openPopup(html`<saas-candidates .made=${options.made}></saas-candidates>`, { backdrop: true, size: 'large', title: i18next.t('title.saas-candidates') })\n }\n\n connectedCallback() {\n super.connectedCallback()\n this.read()\n }\n\n render() {\n return html`\n <div class=\"note\">${i18next.t(this.hidden ? 'text.saas-candidates-hidden-note' : 'text.saas-candidates-note')}</div>\n <ox-grist .mode=${'GRID'} .config=${this.gristConfig} .data=${this.data}></ox-grist>\n <ox-popup-actions>\n <md-text-button slot=\"start\" @click=${() => this.flip()}>${i18next.t(this.hidden ? 'button.saas-candidates-show' : 'button.saas-candidates-hidden')}</md-text-button>\n <md-text-button slot=\"cancel\" @click=${() => closePopup(this)}>${i18next.t('button.close')}</md-text-button>\n ${this.hidden\n ? html`<md-filled-button slot=\"confirm\" @click=${() => this.hide(false)}>${i18next.t('button.saas-candidates-unhide')}</md-filled-button>`\n : html`<md-text-button slot=\"cancel\" @click=${() => this.hide(true)}>${i18next.t('button.saas-candidates-hide')}</md-text-button>\n <md-filled-button slot=\"confirm\" @click=${() => this.create()}>${i18next.t('button.saas-candidates-create')}</md-filled-button>`}\n </ox-popup-actions>\n `\n }\n\n private async flip() {\n this.hidden = !this.hidden\n await this.read()\n }\n\n private async read() {\n try {\n const response: any = await client.query({ query: CANDIDATES, variables: { hidden: this.hidden }, fetchPolicy: 'no-cache' })\n if (response.errors?.length) throw response\n const records = response.data.saasCandidates\n this.data = { records, total: records.length }\n } catch (error) {\n notify({ level: 'error', message: failureOf(error) })\n }\n }\n\n private picked(): string[] {\n return ((this.grist?.selected ?? []) as any[]).map(one => one.key)\n }\n\n private async run(mutation: any, variables: any) {\n const ids = this.picked()\n if (!ids.length) {\n notify({ level: 'warn', message: i18next.t('text.saas-candidates-pick') })\n return false\n }\n try {\n const response: any = await client.mutate({ mutation, variables: { ...variables, keys: ids } })\n if (response.errors?.length) throw response\n await this.read()\n return true\n } catch (error) {\n notify({ level: 'error', message: failureOf(error) })\n return false\n }\n }\n\n private async create() {\n const count = this.picked().length\n if (await this.run(gql`mutation ($keys: [String!]!) { createSaasAccountsFromCandidates(keys: $keys) { id } }`, {})) {\n notify({ level: 'info', message: i18next.t('text.saas-candidates-made', { count }) })\n this.made?.()\n }\n }\n\n private async hide(hide: boolean) {\n await this.run(gql`mutation ($keys: [String!]!, $hide: Boolean!) { hideSaasCandidates(keys: $keys, hide: $hide) }`, { hide })\n }\n}\n"]}
|
package/dist-client/index.d.ts
CHANGED
package/dist-client/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { SaasBillEditor } from './components/saas-bill-editor.js';
|
|
2
|
+
export { SaasCandidates } from './components/saas-candidates.js';
|
|
2
3
|
export { registerSaasAccount360 } from './entity360/saas-account-360.js';
|
|
3
4
|
export { trendTitle } from './words.js';
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
package/dist-client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAA;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA","sourcesContent":["export { SaasBillEditor } from './components/saas-bill-editor.js'\nexport { registerSaasAccount360 } from './entity360/saas-account-360.js'\nexport { trendTitle } from './words.js'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAA;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA","sourcesContent":["export { SaasBillEditor } from './components/saas-bill-editor.js'\nexport { SaasCandidates } from './components/saas-candidates.js'\nexport { registerSaasAccount360 } from './entity360/saas-account-360.js'\nexport { trendTitle } from './words.js'\n"]}
|
|
@@ -13,6 +13,7 @@ import { CommonButtonStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarSty
|
|
|
13
13
|
import { isMobileDevice } from '@operato/utils';
|
|
14
14
|
/* The register grids' save, the asset module's - this module saves its grids the same way. */
|
|
15
15
|
import { saveGrid } from '@things-factory/asset/dist-client/grid.js';
|
|
16
|
+
import { SaasCandidates } from '../components/saas-candidates.js';
|
|
16
17
|
import { ACCOUNT_STATUSES, fieldWord, filterOptionsOf, optionsOf, picker, trendTitle } from '../words.js';
|
|
17
18
|
const FIELDS = ['name', 'counterparty', 'identifier', 'parent', 'purpose', 'billingEmail', 'paymentAccount', 'currency', 'billingDay', 'secretLocation', 'increaseAlertRate', 'status', 'closedOn', 'description'];
|
|
18
19
|
const ACCOUNT_FIELDS = `
|
|
@@ -41,6 +42,8 @@ let SaasAccountList = class SaasAccountList extends localize(i18next)(PageView)
|
|
|
41
42
|
? []
|
|
42
43
|
: [
|
|
43
44
|
{ title: i18next.t('button.saas-cost-trend'), icon: 'monitoring', action: () => navigate('saas-cost-trend') },
|
|
45
|
+
/* What the bank and card lines already say is subscribed to (ADR-0177 개정 1). */
|
|
46
|
+
{ title: i18next.t('button.saas-candidates'), icon: 'manage_search', action: () => SaasCandidates.open({ made: () => this.grist.fetch() }) },
|
|
44
47
|
{ title: i18next.t('button.add'), icon: 'add', action: () => this.grist.addRecordToTop({ currency: 'KRW', status: 'ACTIVE' }) },
|
|
45
48
|
{ title: i18next.t('button.delete'), action: () => this.save(true), ...CommonButtonStyles.delete },
|
|
46
49
|
{ title: i18next.t('button.save'), action: () => this.save(), ...CommonButtonStyles.save }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saas-account-list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E,CAAA;IAClI,CAAC;;AAxHQ;IAAR,KAAK,EAAE;;oDAAiB;AACE;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;8CAAA;AAPjC,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CA+H3B;;AAED,kHAAkH;AAE3G,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,eAAe;IAA/C;;QACK,SAAI,GAAG,IAAI,CAAA;IACvB,CAAC;CAAA,CAAA;AAFY,iBAAiB;IAD7B,aAAa,CAAC,sBAAsB,CAAC;GACzB,iBAAiB,CAE7B","sourcesContent":["import '@operato/data-grist/ox-grist.js'\nimport '@operato/data-grist/ox-filters-form.js'\n\nimport gql from 'graphql-tag'\nimport { html } from 'lit'\nimport { customElement, query, state } from 'lit/decorators.js'\n\nimport { DataGrist, FetchOption, getEditor } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { entity360Name } from '@operato/layout'\nimport { navigate, PageView } from '@operato/shell'\nimport { CommonButtonStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\nimport { isMobileDevice } from '@operato/utils'\n/* The register grids' save, the asset module's - this module saves its grids the same way. */\nimport { saveGrid } from '@things-factory/asset/dist-client/grid.js'\n\nimport { ACCOUNT_STATUSES, fieldWord, filterOptionsOf, optionsOf, picker, trendTitle } from '../words.js'\n\nconst FIELDS = ['name', 'counterparty', 'identifier', 'parent', 'purpose', 'billingEmail', 'paymentAccount', 'currency', 'billingDay', 'secretLocation', 'increaseAlertRate', 'status', 'closedOn', 'description']\nconst ACCOUNT_FIELDS = `\n id name counterparty { id name } identifier parent { id name } purpose admins { id name } billingEmail\n paymentAccount { id name } currency billingDay secretLocation increaseAlertRate status closedOn description\n trend { months values nextMonths expected currency }\n`\n\n/**\n * 구독 서비스 — the accounts the domain holds with vendors (ADR-0177 decision 2), typed like a spreadsheet and saved together.\n * An account opens to its subscriptions, their seats, its admins and its bills.\n */\n@customElement('saas-account-list')\nexport class SaasAccountList extends localize(i18next)(PageView) {\n static styles = [WorkSurfacePageStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles]\n\n /** Only the accounts the signed-in person administers, opened and not kept here. */\n protected mine = false\n\n @state() gristConfig: any\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n const title = i18next.t(this.mine ? 'title.my-saas-account-list' : 'title.saas-account-list')\n return {\n title,\n search: { handler: (search: string) => (this.grist.searchText = search), value: this.grist?.searchText || '' },\n filter: { handler: () => this.grist.toggleHeadroom() },\n actions: this.mine\n ? []\n : [\n { title: i18next.t('button.saas-cost-trend'), icon: 'monitoring', action: () => navigate('saas-cost-trend') },\n { title: i18next.t('button.add'), icon: 'add', action: () => this.grist.addRecordToTop({ currency: 'KRW', status: 'ACTIVE' }) },\n { title: i18next.t('button.delete'), action: () => this.save(true), ...CommonButtonStyles.delete },\n { title: i18next.t('button.save'), action: () => this.save(), ...CommonButtonStyles.save }\n ],\n exportable: { name: title, data: () => this.grist.exportRecords() }\n }\n }\n\n render() {\n return html`<ox-grist class=\"page-fill\" search-mode=\"term\" .mode=${isMobileDevice() ? 'CARD' : 'GRID'} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\"><ox-filters-form without-search autofocus></ox-filters-form></div>\n </div>\n </ox-grist>`\n }\n\n async pageInitialized() {\n const editable = { editable: !this.mine }\n const text = (name: string, width: number, extra: any = {}) => ({ type: 'string', name, header: fieldWord('saas-account', name), width, sortable: true, ...extra, record: { ...editable, ...extra.record } })\n const object = (name: string, width: number, queryName: string, columns: { name: string; header?: string }[]) => ({\n type: 'object',\n name,\n header: fieldWord('saas-account', name),\n width,\n record: { ...editable, editor: getEditor('resource-object'), options: picker(queryName, columns) }\n })\n const open = (record: any) => record?.id && navigate(`saas-account-page?id=${record.id}`)\n this.gristConfig = {\n rows: { appendable: !this.mine, selectable: { multiple: !this.mine } },\n pagination: { limit: 100, pages: [50, 100] },\n emptyNote: {\n title: i18next.t(this.mine ? 'text.my-saas-account-empty' : 'text.saas-account-empty'),\n description: i18next.t(this.mine ? 'text.my-saas-account-empty-description' : 'text.saas-account-empty-description')\n },\n list: { fields: ['name', 'identifier'], details: ['purpose', 'admins'] },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n ...(this.mine ? [] : [{ type: 'gutter', gutterName: 'row-selector', multiple: true }]),\n { type: 'gutter', gutterName: 'button', icon: 'open_in_new', handlers: { click: (_c: any, _d: any, _col: any, record: any) => open(record) } },\n /* The name opens the account's 360 (ADR-0067); a new row is typed into. */\n text('name', 180, { record: { mandatory: true, renderer: (value: string, _c: any, record: any) => (record?.id ? entity360Name({ __typename: 'SaasAccount', ...record }, value) : value ?? '') } }),\n /* The last twelve months billed, the next three expected dashed (ADR-0177 decision 10). */\n { type: 'sparkline', name: 'trend', header: fieldWord('saas-account', 'trend'), width: 120, record: { options: { title: (value: any) => trendTitle(value) } } },\n object('counterparty', 150, 'counterpartyChoices', [{ name: 'name', header: fieldWord('saas-account', 'counterparty') }]),\n text('identifier', 150),\n object('parent', 140, 'saasAccounts', [{ name: 'name', header: fieldWord('saas-account', 'parent') }]),\n text('purpose', 120),\n {\n type: 'string',\n name: 'admins',\n header: fieldWord('saas-account', 'admins'),\n width: 160,\n record: { renderer: (value: any[]) => (value ?? []).map(one => one.name).join(', ') }\n },\n object('paymentAccount', 150, 'bankAccounts', [{ name: 'name', header: fieldWord('saas-account', 'paymentAccount') }]),\n text('currency', 60, { record: { align: 'center' } }),\n { type: 'integer', name: 'billingDay', header: fieldWord('saas-account', 'billingDay'), width: 70, record: { ...editable, align: 'right' } },\n { type: 'float', name: 'increaseAlertRate', header: fieldWord('saas-account', 'increaseAlertRate'), width: 80, hidden: true, record: { ...editable, align: 'right' } },\n text('billingEmail', 160, { hidden: true }),\n text('secretLocation', 160),\n {\n type: 'select',\n name: 'status',\n header: fieldWord('saas-account', 'status'),\n width: 80,\n sortable: true,\n record: { ...editable, options: optionsOf('saas-account-status', ACCOUNT_STATUSES) },\n filter: { type: 'select', operator: 'eq', options: filterOptionsOf('saas-account-status', ACCOUNT_STATUSES) }\n },\n text('closedOn', 100, { record: { align: 'center' } }),\n text('description', 200)\n ],\n sorters: [{ name: 'name' }]\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [], search }: FetchOption) {\n if (this.mine) {\n const response = await client.query({ query: gql`query { rows: mySaasAccounts { ${ACCOUNT_FIELDS} } }`, fetchPolicy: 'network-only' })\n if (response.errors?.length) throw response\n return { total: response.data.rows.length, records: response.data.rows }\n }\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $search: String) {\n responses: saasAccounts(filters: $filters, pagination: $pagination, sortings: $sortings, search: $search) {\n items { ${ACCOUNT_FIELDS} }\n total\n }\n }\n `,\n variables: { filters, pagination: { page, limit }, sortings, search: search?.trim() || undefined },\n fetchPolicy: 'network-only'\n })\n if (response.errors?.length) throw response\n return { total: response.data.responses.total, records: response.data.responses.items }\n }\n\n private async save(deleting = false) {\n /* A picked row goes as its id. */\n const shape = ({ counterparty, parent, paymentAccount, ...patch }: any) => ({\n ...patch,\n ...(counterparty === undefined ? {} : { counterpartyId: counterparty?.id ?? null }),\n ...(parent === undefined ? {} : { parentId: parent?.id ?? null }),\n ...(paymentAccount === undefined ? {} : { paymentAccountId: paymentAccount?.id ?? null })\n })\n if (await saveGrid(this.grist, FIELDS, 'updateMultipleSaasAccount', 'SaasAccountPatch', {}, deleting, shape)) this.grist.fetch()\n }\n}\n\n/** 내가 관리하는 구독 서비스 — the accounts the signed-in person is named an admin of, whatever their seat (ADR-0177 Q4). */\n@customElement('my-saas-account-list')\nexport class MySaasAccountList extends SaasAccountList {\n protected mine = true\n}\n"]}
|
|
1
|
+
{"version":3,"file":"saas-account-list.js","sourceRoot":"","sources":["../../client/pages/saas-account-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CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,cAAc,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC;SAC1F,CAAC,CAAA;QACF,IAAI,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC;YAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IAClI,CAAC;;AA1HQ;IAAR,KAAK,EAAE;;oDAAiB;AACE;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;8CAAA;AAPjC,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAiI3B;;AAED,kHAAkH;AAE3G,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,eAAe;IAA/C;;QACK,SAAI,GAAG,IAAI,CAAA;IACvB,CAAC;CAAA,CAAA;AAFY,iBAAiB;IAD7B,aAAa,CAAC,sBAAsB,CAAC;GACzB,iBAAiB,CAE7B","sourcesContent":["import '@operato/data-grist/ox-grist.js'\nimport '@operato/data-grist/ox-filters-form.js'\n\nimport gql from 'graphql-tag'\nimport { html } from 'lit'\nimport { customElement, query, state } from 'lit/decorators.js'\n\nimport { DataGrist, FetchOption, getEditor } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { entity360Name } from '@operato/layout'\nimport { navigate, PageView } from '@operato/shell'\nimport { CommonButtonStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\nimport { isMobileDevice } from '@operato/utils'\n/* The register grids' save, the asset module's - this module saves its grids the same way. */\nimport { saveGrid } from '@things-factory/asset/dist-client/grid.js'\n\nimport { SaasCandidates } from '../components/saas-candidates.js'\nimport { ACCOUNT_STATUSES, fieldWord, filterOptionsOf, optionsOf, picker, trendTitle } from '../words.js'\n\nconst FIELDS = ['name', 'counterparty', 'identifier', 'parent', 'purpose', 'billingEmail', 'paymentAccount', 'currency', 'billingDay', 'secretLocation', 'increaseAlertRate', 'status', 'closedOn', 'description']\nconst ACCOUNT_FIELDS = `\n id name counterparty { id name } identifier parent { id name } purpose admins { id name } billingEmail\n paymentAccount { id name } currency billingDay secretLocation increaseAlertRate status closedOn description\n trend { months values nextMonths expected currency }\n`\n\n/**\n * 구독 서비스 — the accounts the domain holds with vendors (ADR-0177 decision 2), typed like a spreadsheet and saved together.\n * An account opens to its subscriptions, their seats, its admins and its bills.\n */\n@customElement('saas-account-list')\nexport class SaasAccountList extends localize(i18next)(PageView) {\n static styles = [WorkSurfacePageStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles]\n\n /** Only the accounts the signed-in person administers, opened and not kept here. */\n protected mine = false\n\n @state() gristConfig: any\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n const title = i18next.t(this.mine ? 'title.my-saas-account-list' : 'title.saas-account-list')\n return {\n title,\n search: { handler: (search: string) => (this.grist.searchText = search), value: this.grist?.searchText || '' },\n filter: { handler: () => this.grist.toggleHeadroom() },\n actions: this.mine\n ? []\n : [\n { title: i18next.t('button.saas-cost-trend'), icon: 'monitoring', action: () => navigate('saas-cost-trend') },\n /* What the bank and card lines already say is subscribed to (ADR-0177 개정 1). */\n { title: i18next.t('button.saas-candidates'), icon: 'manage_search', action: () => SaasCandidates.open({ made: () => this.grist.fetch() }) },\n { title: i18next.t('button.add'), icon: 'add', action: () => this.grist.addRecordToTop({ currency: 'KRW', status: 'ACTIVE' }) },\n { title: i18next.t('button.delete'), action: () => this.save(true), ...CommonButtonStyles.delete },\n { title: i18next.t('button.save'), action: () => this.save(), ...CommonButtonStyles.save }\n ],\n exportable: { name: title, data: () => this.grist.exportRecords() }\n }\n }\n\n render() {\n return html`<ox-grist class=\"page-fill\" search-mode=\"term\" .mode=${isMobileDevice() ? 'CARD' : 'GRID'} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\"><ox-filters-form without-search autofocus></ox-filters-form></div>\n </div>\n </ox-grist>`\n }\n\n async pageInitialized() {\n const editable = { editable: !this.mine }\n const text = (name: string, width: number, extra: any = {}) => ({ type: 'string', name, header: fieldWord('saas-account', name), width, sortable: true, ...extra, record: { ...editable, ...extra.record } })\n const object = (name: string, width: number, queryName: string, columns: { name: string; header?: string }[]) => ({\n type: 'object',\n name,\n header: fieldWord('saas-account', name),\n width,\n record: { ...editable, editor: getEditor('resource-object'), options: picker(queryName, columns) }\n })\n const open = (record: any) => record?.id && navigate(`saas-account-page?id=${record.id}`)\n this.gristConfig = {\n rows: { appendable: !this.mine, selectable: { multiple: !this.mine } },\n pagination: { limit: 100, pages: [50, 100] },\n emptyNote: {\n title: i18next.t(this.mine ? 'text.my-saas-account-empty' : 'text.saas-account-empty'),\n description: i18next.t(this.mine ? 'text.my-saas-account-empty-description' : 'text.saas-account-empty-description')\n },\n list: { fields: ['name', 'identifier'], details: ['purpose', 'admins'] },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n ...(this.mine ? [] : [{ type: 'gutter', gutterName: 'row-selector', multiple: true }]),\n { type: 'gutter', gutterName: 'button', icon: 'open_in_new', handlers: { click: (_c: any, _d: any, _col: any, record: any) => open(record) } },\n /* The name opens the account's 360 (ADR-0067); a new row is typed into. */\n text('name', 180, { record: { mandatory: true, renderer: (value: string, _c: any, record: any) => (record?.id ? entity360Name({ __typename: 'SaasAccount', ...record }, value) : value ?? '') } }),\n /* The last twelve months billed, the next three expected dashed (ADR-0177 decision 10). */\n { type: 'sparkline', name: 'trend', header: fieldWord('saas-account', 'trend'), width: 120, record: { options: { title: (value: any) => trendTitle(value) } } },\n object('counterparty', 150, 'counterpartyChoices', [{ name: 'name', header: fieldWord('saas-account', 'counterparty') }]),\n text('identifier', 150),\n object('parent', 140, 'saasAccounts', [{ name: 'name', header: fieldWord('saas-account', 'parent') }]),\n text('purpose', 120),\n {\n type: 'string',\n name: 'admins',\n header: fieldWord('saas-account', 'admins'),\n width: 160,\n record: { renderer: (value: any[]) => (value ?? []).map(one => one.name).join(', ') }\n },\n object('paymentAccount', 150, 'bankAccounts', [{ name: 'name', header: fieldWord('saas-account', 'paymentAccount') }]),\n text('currency', 60, { record: { align: 'center' } }),\n { type: 'integer', name: 'billingDay', header: fieldWord('saas-account', 'billingDay'), width: 70, record: { ...editable, align: 'right' } },\n { type: 'float', name: 'increaseAlertRate', header: fieldWord('saas-account', 'increaseAlertRate'), width: 80, hidden: true, record: { ...editable, align: 'right' } },\n text('billingEmail', 160, { hidden: true }),\n text('secretLocation', 160),\n {\n type: 'select',\n name: 'status',\n header: fieldWord('saas-account', 'status'),\n width: 80,\n sortable: true,\n record: { ...editable, options: optionsOf('saas-account-status', ACCOUNT_STATUSES) },\n filter: { type: 'select', operator: 'eq', options: filterOptionsOf('saas-account-status', ACCOUNT_STATUSES) }\n },\n text('closedOn', 100, { record: { align: 'center' } }),\n text('description', 200)\n ],\n sorters: [{ name: 'name' }]\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [], search }: FetchOption) {\n if (this.mine) {\n const response = await client.query({ query: gql`query { rows: mySaasAccounts { ${ACCOUNT_FIELDS} } }`, fetchPolicy: 'network-only' })\n if (response.errors?.length) throw response\n return { total: response.data.rows.length, records: response.data.rows }\n }\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $search: String) {\n responses: saasAccounts(filters: $filters, pagination: $pagination, sortings: $sortings, search: $search) {\n items { ${ACCOUNT_FIELDS} }\n total\n }\n }\n `,\n variables: { filters, pagination: { page, limit }, sortings, search: search?.trim() || undefined },\n fetchPolicy: 'network-only'\n })\n if (response.errors?.length) throw response\n return { total: response.data.responses.total, records: response.data.responses.items }\n }\n\n private async save(deleting = false) {\n /* A picked row goes as its id. */\n const shape = ({ counterparty, parent, paymentAccount, ...patch }: any) => ({\n ...patch,\n ...(counterparty === undefined ? {} : { counterpartyId: counterparty?.id ?? null }),\n ...(parent === undefined ? {} : { parentId: parent?.id ?? null }),\n ...(paymentAccount === undefined ? {} : { paymentAccountId: paymentAccount?.id ?? null })\n })\n if (await saveGrid(this.grist, FIELDS, 'updateMultipleSaasAccount', 'SaasAccountPatch', {}, deleting, shape)) this.grist.fetch()\n }\n}\n\n/** 내가 관리하는 구독 서비스 — the accounts the signed-in person is named an admin of, whatever their seat (ADR-0177 Q4). */\n@customElement('my-saas-account-list')\nexport class MySaasAccountList extends SaasAccountList {\n protected mine = true\n}\n"]}
|
|
@@ -201,6 +201,9 @@ let SaasAccountPage = class SaasAccountPage extends localize(i18next)(PageView)
|
|
|
201
201
|
{ type: 'checkbox', name: 'autoRenew', header: fieldWord(set, 'autoRenew'), width: 70, record: editable },
|
|
202
202
|
int('noticeDays'),
|
|
203
203
|
{ type: 'integer', name: 'seatsHeld', header: fieldWord(set, 'seatsHeld'), width: 70, record: { align: 'right' } },
|
|
204
|
+
/* Read from the vendor's tenant (ADR-0177 개정 2) - its seats and quantity follow the tenant. */
|
|
205
|
+
{ type: 'string', name: 'vendorKey', header: fieldWord(set, 'vendorKey'), width: 90, record: { renderer: (value) => (value ? i18next.t('text.saas-synced') : '') } },
|
|
206
|
+
{ type: 'checkbox', name: 'trial', header: fieldWord(set, 'trial'), width: 70 },
|
|
204
207
|
object('department', 120, 'departments', [{ name: 'name', header: fieldWord(set, 'department') }]),
|
|
205
208
|
object('asset', 140, 'assets', [{ name: 'name', header: fieldWord(set, 'asset') }]),
|
|
206
209
|
{ type: 'select', name: 'status', header: fieldWord(set, 'status'), width: 90, record: { ...editable, options: optionsOf('saas-subscription-status', SUBSCRIPTION_STATUSES) } },
|
|
@@ -210,6 +213,8 @@ let SaasAccountPage = class SaasAccountPage extends localize(i18next)(PageView)
|
|
|
210
213
|
seats: [
|
|
211
214
|
object('employee', 140, 'employees', [{ name: 'name', header: fieldWord(set, 'employee') }, { name: 'controlNo', header: i18next.t('field.control-no') }]),
|
|
212
215
|
text('holder', 140),
|
|
216
|
+
/* The vendor's login - a sync's (ADR-0177 개정 2), read only. */
|
|
217
|
+
{ type: 'string', name: 'login', header: fieldWord(set, 'login'), width: 180 },
|
|
213
218
|
day('fromOn'),
|
|
214
219
|
day('untilOn'),
|
|
215
220
|
text('description', 240)
|
|
@@ -257,8 +262,8 @@ let SaasAccountPage = class SaasAccountPage extends localize(i18next)(PageView)
|
|
|
257
262
|
return { total: records.length, records };
|
|
258
263
|
}
|
|
259
264
|
const queries = {
|
|
260
|
-
subscriptions: `rows: saasSubscriptions(accountId: $id) { id name billing quantity unitPrice amount budget everyMonths startOn renewalOn autoRenew noticeDays seatsHeld department { id name } asset { id name } status endedOn description }`,
|
|
261
|
-
seats: `rows: saasSeats(subscriptionId: $id) { id employee { id name } holder fromOn untilOn description }`,
|
|
265
|
+
subscriptions: `rows: saasSubscriptions(accountId: $id) { id name billing quantity unitPrice amount budget everyMonths startOn renewalOn autoRenew noticeDays seatsHeld vendorKey trial department { id name } asset { id name } status endedOn description }`,
|
|
266
|
+
seats: `rows: saasSeats(subscriptionId: $id) { id employee { id name } holder login fromOn untilOn description }`,
|
|
262
267
|
bills: `rows: saasBills(accountId: $id) { id month billedOn total description lines { subscription { id name } label amount } }`
|
|
263
268
|
};
|
|
264
269
|
const response = await client.query({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saas-account-page.js","sourceRoot":"","sources":["../../client/pages/saas-account-page.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,mCAAmC,CAAA;AAE1C,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE/D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AA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,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC,EAAE,2BAA2B,EAAE,kBAAkB,CAAC,EAAE,CAAC;YACzF,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;YACjB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC;IACH,CAAC;;AAxPQ;IAAR,KAAK,EAAE;;kDAAe;AACd;IAAR,KAAK,EAAE;;gDAAc;AACb;IAAR,KAAK,EAAE;;sDAA0B;AACzB;IAAR,KAAK,EAAE;;uDAAoB;AACnB;IAAR,KAAK,EAAE;;4CAA2B;AAC1B;IAAR,KAAK,EAAE;;+CAAe;AACd;IAAR,KAAK,EAAE;;oDAAiB;AACE;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;8CAAA;AA7DjC,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CA+S3B","sourcesContent":["import '@operato/data-grist/ox-grist.js'\nimport '../components/saas-bill-editor.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, nothing } from 'lit'\nimport { customElement, query, state } from 'lit/decorators.js'\n\nimport { DataGrist, getEditor } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { navigate, PageView } from '@operato/shell'\nimport { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'\nimport { saveGrid } from '@things-factory/asset/dist-client/grid.js'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client'\n\nimport { SaasBillEditor } from '../components/saas-bill-editor.js'\nimport { amountText, BILLINGS, fieldWord, optionsOf, picker, SUBSCRIPTION_STATUSES } from '../words.js'\n\ntype Tab = 'subscriptions' | 'seats' | 'bills' | 'admins'\nconst TABS: Tab[] = ['subscriptions', 'seats', 'bills', 'admins']\n\nconst SUBSCRIPTION_FIELDS = ['name', 'billing', 'quantity', 'unitPrice', 'amount', 'budget', 'everyMonths', 'startOn', 'renewalOn', 'autoRenew', 'noticeDays', 'department', 'asset', 'status', 'endedOn', 'description']\nconst SEAT_FIELDS = ['employee', 'holder', 'fromOn', 'untilOn', 'description']\n\n/**\n * 구독 서비스 한 계정 — tab by tab its subscriptions, the seats of one of them, its bills month by month and who administers\n * it (ADR-0177 decisions 2-6). The keepers keep all of it; an admin keeps what is under their own account, not the account\n * or its admins.\n */\n@customElement('saas-account-page')\nexport class SaasAccountPage extends localize(i18next)(PageView) {\n static styles = [\n CommonGristStyles,\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n }\n .head {\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n gap: var(--spacing-small, 4px) var(--spacing-large, 12px);\n padding: var(--spacing-medium, 8px) var(--spacing-large, 12px);\n color: var(--md-sys-color-on-surface-variant);\n }\n .tabs {\n display: flex;\n gap: var(--spacing-small, 4px);\n overflow-x: auto;\n padding: 0 var(--spacing-large, 12px) var(--spacing-medium, 8px);\n }\n .tabs button {\n flex: none;\n padding: 4px var(--spacing-large, 12px);\n border: 1px solid var(--ui-line-soft, var(--md-sys-color-outline-variant));\n border-radius: 999px;\n background: none;\n color: var(--md-sys-color-on-surface);\n font: inherit;\n font-size: var(--ui-t-body, 14px);\n cursor: pointer;\n }\n .tabs button[aria-selected='true'] {\n border-color: var(--md-sys-color-primary);\n background: var(--md-sys-color-primary-container);\n color: var(--md-sys-color-on-primary-container);\n }\n .tabs.sub button {\n font-size: var(--ui-t-caption, 12px);\n }\n .empty {\n padding: var(--spacing-large, 12px);\n color: var(--md-sys-color-on-surface-variant);\n }\n ox-grist {\n flex: 1;\n overflow-y: auto;\n }\n `\n ]\n\n @state() accountId = ''\n @state() account?: any\n @state() subscriptions: any[] = []\n @state() subscriptionId = ''\n @state() tab: Tab = 'subscriptions'\n @state() keeper = false\n @state() gristConfig: any\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n const editing = this.tab !== 'admins' || this.keeper\n const actions =\n this.tab === 'bills'\n ? [{ title: i18next.t('button.saas-bill-new'), icon: 'add', action: () => this.openBill() }]\n : editing && (this.tab !== 'seats' || this.subscriptionId)\n ? [\n { title: i18next.t('button.add'), icon: 'add', action: () => this.grist.addRecordToTop(this.blank()) },\n { title: i18next.t('button.delete'), action: () => this.save(true), ...CommonButtonStyles.delete },\n { title: i18next.t('button.save'), action: () => this.save(), ...CommonButtonStyles.save }\n ]\n : []\n return { title: this.account?.name ?? i18next.t('title.saas-account-page'), actions }\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (!this.active) return\n const params = lifecycle?.params ?? {}\n this.tab = TABS.includes(params.tab) ? params.tab : 'subscriptions'\n const id = params.id ?? ''\n if (id !== this.accountId || changes.active) {\n this.accountId = id\n this.keeper = await hasPrivilege({ category: 'saas', privilege: 'mutation', domainOwnerGranted: true })\n await this.read()\n }\n this.subscriptionId = params.subscription ?? this.seatPlans()[0]?.id ?? ''\n this.gristConfig = this.configOf(this.tab)\n this.updateContext()\n }\n\n private seatPlans() {\n return this.subscriptions.filter(one => one.billing === 'SEAT')\n }\n\n private async read() {\n if (!this.accountId) return\n const response = await client.query({\n query: gql`\n query ($id: String!) {\n saasAccount(id: $id) { id name identifier purpose currency billingDay secretLocation paymentAccount { id name } parent { id name } admins { id name controlNo } }\n saasSubscriptions(accountId: $id) { id name billing status }\n }\n `,\n variables: { id: this.accountId },\n fetchPolicy: 'network-only'\n })\n this.account = response.data?.saasAccount\n this.subscriptions = response.data?.saasSubscriptions ?? []\n }\n\n private blank(): any {\n const today = new Date().toISOString().slice(0, 10)\n if (this.tab === 'subscriptions') return { billing: 'FIXED', everyMonths: 1, startOn: today, autoRenew: true, status: 'ACTIVE' }\n return this.tab === 'seats' ? { fromOn: today } : {}\n }\n\n render() {\n const one = this.account\n const tabs = this.account?.parent ? (['admins'] as Tab[]) : TABS\n return html`\n <div class=\"head\">\n ${one\n ? html`<span>\n ${[\n one.identifier,\n one.parent ? i18next.t('text.saas-account-under', { name: one.parent.name }) : null,\n one.purpose,\n one.currency,\n one.billingDay ? i18next.t('text.saas-account-billing-day', { day: one.billingDay }) : null,\n one.paymentAccount?.name,\n one.secretLocation ? i18next.t('text.saas-account-secret-at', { where: one.secretLocation }) : null\n ]\n .filter(Boolean)\n .join(' · ')}\n </span>`\n : nothing}\n </div>\n <div class=\"tabs\" role=\"tablist\">\n ${tabs.map(\n tab => html`<button role=\"tab\" aria-selected=${String(this.tab === tab)} @click=${() => navigate(`saas-account-page?id=${this.accountId}&tab=${tab}`)}>${i18next.t(`text.saas-tab-${tab}`)}</button>`\n )}\n </div>\n ${this.tab === 'seats'\n ? this.seatPlans().length\n ? html`<div class=\"tabs sub\" role=\"tablist\">\n ${this.seatPlans().map(\n sub =>\n html`<button role=\"tab\" aria-selected=${String(this.subscriptionId === sub.id)} @click=${() => navigate(`saas-account-page?id=${this.accountId}&tab=seats&subscription=${sub.id}`)}>\n ${sub.name}\n </button>`\n )}\n </div>`\n : html`<div class=\"empty\">${i18next.t('text.saas-seats-no-plan')}</div>`\n : nothing}\n ${this.gristConfig && (this.tab !== 'seats' || this.subscriptionId)\n ? html`<ox-grist .mode=${'GRID'} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}></ox-grist>`\n : nothing}\n `\n }\n\n private configOf(tab: Tab) {\n const editable = { editable: tab !== 'bills' && (tab !== 'admins' || this.keeper) }\n const set = `saas-${tab === 'subscriptions' ? 'subscription' : tab === 'seats' ? 'seat' : tab === 'bills' ? 'bill' : 'admin'}`\n const text = (name: string, width: number, extra: any = {}) => ({ type: 'string', name, header: fieldWord(set, name), width, ...extra, record: { ...editable, ...extra.record } })\n const day = (name: string, extra: any = {}) => text(name, 100, { ...extra, record: { align: 'center', ...extra.record } })\n const money = (name: string, extra: any = {}) => ({ type: 'float', name, header: fieldWord(set, name), width: 110, ...extra, record: { ...editable, align: 'right', renderer: (value: number) => amountText(value), ...extra.record } })\n const int = (name: string, width = 70) => ({ type: 'integer', name, header: fieldWord(set, name), width, record: { ...editable, align: 'right' } })\n const object = (name: string, width: number, queryName: string, columns: { name: string; header?: string }[]) => ({\n type: 'object',\n name,\n header: fieldWord(set, name),\n width,\n record: { ...editable, editor: getEditor('resource-object'), options: picker(queryName, columns) }\n })\n const columns: Record<Tab, any[]> = {\n subscriptions: [\n text('name', 200, { record: { mandatory: true } }),\n { type: 'select', name: 'billing', header: fieldWord(set, 'billing'), width: 90, record: { ...editable, mandatory: true, options: optionsOf('saas-billing', BILLINGS) } },\n money('quantity', { width: 70, record: { renderer: (value: number) => amountText(value) } }),\n money('unitPrice'),\n money('amount'),\n money('budget'),\n int('everyMonths'),\n day('startOn', { record: { mandatory: true } }),\n day('renewalOn'),\n { type: 'checkbox', name: 'autoRenew', header: fieldWord(set, 'autoRenew'), width: 70, record: editable },\n int('noticeDays'),\n { type: 'integer', name: 'seatsHeld', header: fieldWord(set, 'seatsHeld'), width: 70, record: { align: 'right' } },\n object('department', 120, 'departments', [{ name: 'name', header: fieldWord(set, 'department') }]),\n object('asset', 140, 'assets', [{ name: 'name', header: fieldWord(set, 'asset') }]),\n { type: 'select', name: 'status', header: fieldWord(set, 'status'), width: 90, record: { ...editable, options: optionsOf('saas-subscription-status', SUBSCRIPTION_STATUSES) } },\n day('endedOn'),\n text('description', 200)\n ],\n seats: [\n object('employee', 140, 'employees', [{ name: 'name', header: fieldWord(set, 'employee') }, { name: 'controlNo', header: i18next.t('field.control-no') }]),\n text('holder', 140),\n day('fromOn'),\n day('untilOn'),\n text('description', 240)\n ],\n bills: [\n text('month', 90, { record: { align: 'center' } }),\n day('billedOn'),\n money('total', { width: 140, header: `${fieldWord(set, 'total')} (${this.account?.currency ?? ''})` }),\n { type: 'string', name: 'lines', header: fieldWord(set, 'lines'), width: 360, record: { renderer: (lines: any[]) => (lines ?? []).map(line => `${line.subscription?.name ?? line.label ?? ''} ${amountText(line.amount)}`).join(' · ') } },\n text('description', 200)\n ],\n admins: [\n object('employee', 160, 'employees', [{ name: 'name', header: fieldWord(set, 'employee') }, { name: 'controlNo', header: i18next.t('field.control-no') }]),\n { type: 'string', name: 'controlNo', header: i18next.t('field.control-no'), width: 100 }\n ]\n }\n return {\n rows: { appendable: !!editable.editable, selectable: { multiple: !!editable.editable } },\n pagination: { infinite: true },\n emptyNote: { title: i18next.t(`text.saas-${tab}-empty`) },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n ...(editable.editable ? [{ type: 'gutter', gutterName: 'row-selector', multiple: true }] : []),\n ...(tab === 'bills'\n ? [{ type: 'gutter', gutterName: 'button', icon: 'edit', handlers: { click: (_c: any, _d: any, _col: any, record: any) => record?.id && this.openBill(record) } }]\n : tab === 'subscriptions'\n ? [\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'group',\n handlers: { click: (_c: any, _d: any, _col: any, record: any) => record?.id && record.billing === 'SEAT' && navigate(`saas-account-page?id=${this.accountId}&tab=seats&subscription=${record.id}`) }\n }\n ]\n : []),\n ...columns[tab]\n ]\n }\n }\n\n async fetchHandler() {\n if (!this.accountId) return { total: 0, records: [] }\n if (this.tab === 'admins') {\n const records = (this.account?.admins ?? []).map((one: any) => ({ id: one.id, employee: { id: one.id, name: one.name }, controlNo: one.controlNo }))\n return { total: records.length, records }\n }\n const queries: Record<Exclude<Tab, 'admins'>, string> = {\n subscriptions: `rows: saasSubscriptions(accountId: $id) { id name billing quantity unitPrice amount budget everyMonths startOn renewalOn autoRenew noticeDays seatsHeld department { id name } asset { id name } status endedOn description }`,\n seats: `rows: saasSeats(subscriptionId: $id) { id employee { id name } holder fromOn untilOn description }`,\n bills: `rows: saasBills(accountId: $id) { id month billedOn total description lines { subscription { id name } label amount } }`\n }\n const response = await client.query({\n query: gql`query ($id: String!) { ${queries[this.tab]} }`,\n variables: { id: this.tab === 'seats' ? this.subscriptionId : this.accountId },\n fetchPolicy: 'network-only'\n })\n if (response.errors?.length) throw response\n return { total: response.data.rows.length, records: response.data.rows }\n }\n\n private openBill(bill?: any) {\n SaasBillEditor.open({\n accountId: this.accountId,\n currency: this.account?.currency ?? '',\n subscriptions: this.subscriptions,\n bill,\n saved: () => this.grist?.fetch()\n })\n }\n\n private async save(deleting = false) {\n if (this.tab === 'admins') return this.saveAdmins(deleting)\n /* A picked row goes as its id. */\n const shape = ({ department, asset, employee, ...patch }: any) => ({\n ...patch,\n ...(department === undefined ? {} : { departmentId: department?.id ?? null }),\n ...(asset === undefined ? {} : { assetId: asset?.id ?? null }),\n ...(employee === undefined ? {} : { employeeId: employee?.id ?? null })\n })\n const saved =\n this.tab === 'subscriptions'\n ? await saveGrid(this.grist, SUBSCRIPTION_FIELDS, 'updateMultipleSaasSubscription', 'SaasSubscriptionPatch', { accountId: this.accountId }, deleting, shape)\n : await saveGrid(this.grist, SEAT_FIELDS, 'updateMultipleSaasSeat', 'SaasSeatPatch', { subscriptionId: this.subscriptionId }, deleting, shape)\n if (saved) {\n this.grist.fetch()\n if (this.tab === 'subscriptions') await this.read()\n }\n }\n\n /** The admins are a field of the account - the grid's rows, less the deleted, saved as its list. */\n private async saveAdmins(deleting: boolean) {\n const removed = new Set(deleting ? this.grist.selected.map((one: any) => one.employee?.id ?? one.id) : [])\n const rows = (this.grist.dirtyData?.records ?? []).filter((one: any) => one.__dirty__ !== '-' && one.employee?.id && !removed.has(one.employee.id))\n const adminIds = [...new Set(rows.map((one: any) => one.employee.id))]\n const grist = {\n dirtyRecords: [{ id: this.accountId, __dirty__: 'M', __dirtyfields__: { adminIds: true }, adminIds }],\n selected: []\n } as any\n if (await saveGrid(grist, ['adminIds'], 'updateMultipleSaasAccount', 'SaasAccountPatch')) {\n await this.read()\n this.grist.fetch()\n }\n }\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"saas-account-page.js","sourceRoot":"","sources":["../../client/pages/saas-account-page.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,mCAAmC,CAAA;AAE1C,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,C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AU,CAAC;8BAAiB,SAAS;8CAAA;AA7DjC,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAoT3B","sourcesContent":["import '@operato/data-grist/ox-grist.js'\nimport '../components/saas-bill-editor.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, nothing } from 'lit'\nimport { customElement, query, state } from 'lit/decorators.js'\n\nimport { DataGrist, getEditor } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { navigate, PageView } from '@operato/shell'\nimport { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'\nimport { saveGrid } from '@things-factory/asset/dist-client/grid.js'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client'\n\nimport { SaasBillEditor } from '../components/saas-bill-editor.js'\nimport { amountText, BILLINGS, fieldWord, optionsOf, picker, SUBSCRIPTION_STATUSES } from '../words.js'\n\ntype Tab = 'subscriptions' | 'seats' | 'bills' | 'admins'\nconst TABS: Tab[] = ['subscriptions', 'seats', 'bills', 'admins']\n\nconst SUBSCRIPTION_FIELDS = ['name', 'billing', 'quantity', 'unitPrice', 'amount', 'budget', 'everyMonths', 'startOn', 'renewalOn', 'autoRenew', 'noticeDays', 'department', 'asset', 'status', 'endedOn', 'description']\nconst SEAT_FIELDS = ['employee', 'holder', 'fromOn', 'untilOn', 'description']\n\n/**\n * 구독 서비스 한 계정 — tab by tab its subscriptions, the seats of one of them, its bills month by month and who administers\n * it (ADR-0177 decisions 2-6). The keepers keep all of it; an admin keeps what is under their own account, not the account\n * or its admins.\n */\n@customElement('saas-account-page')\nexport class SaasAccountPage extends localize(i18next)(PageView) {\n static styles = [\n CommonGristStyles,\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n }\n .head {\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n gap: var(--spacing-small, 4px) var(--spacing-large, 12px);\n padding: var(--spacing-medium, 8px) var(--spacing-large, 12px);\n color: var(--md-sys-color-on-surface-variant);\n }\n .tabs {\n display: flex;\n gap: var(--spacing-small, 4px);\n overflow-x: auto;\n padding: 0 var(--spacing-large, 12px) var(--spacing-medium, 8px);\n }\n .tabs button {\n flex: none;\n padding: 4px var(--spacing-large, 12px);\n border: 1px solid var(--ui-line-soft, var(--md-sys-color-outline-variant));\n border-radius: 999px;\n background: none;\n color: var(--md-sys-color-on-surface);\n font: inherit;\n font-size: var(--ui-t-body, 14px);\n cursor: pointer;\n }\n .tabs button[aria-selected='true'] {\n border-color: var(--md-sys-color-primary);\n background: var(--md-sys-color-primary-container);\n color: var(--md-sys-color-on-primary-container);\n }\n .tabs.sub button {\n font-size: var(--ui-t-caption, 12px);\n }\n .empty {\n padding: var(--spacing-large, 12px);\n color: var(--md-sys-color-on-surface-variant);\n }\n ox-grist {\n flex: 1;\n overflow-y: auto;\n }\n `\n ]\n\n @state() accountId = ''\n @state() account?: any\n @state() subscriptions: any[] = []\n @state() subscriptionId = ''\n @state() tab: Tab = 'subscriptions'\n @state() keeper = false\n @state() gristConfig: any\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n const editing = this.tab !== 'admins' || this.keeper\n const actions =\n this.tab === 'bills'\n ? [{ title: i18next.t('button.saas-bill-new'), icon: 'add', action: () => this.openBill() }]\n : editing && (this.tab !== 'seats' || this.subscriptionId)\n ? [\n { title: i18next.t('button.add'), icon: 'add', action: () => this.grist.addRecordToTop(this.blank()) },\n { title: i18next.t('button.delete'), action: () => this.save(true), ...CommonButtonStyles.delete },\n { title: i18next.t('button.save'), action: () => this.save(), ...CommonButtonStyles.save }\n ]\n : []\n return { title: this.account?.name ?? i18next.t('title.saas-account-page'), actions }\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (!this.active) return\n const params = lifecycle?.params ?? {}\n this.tab = TABS.includes(params.tab) ? params.tab : 'subscriptions'\n const id = params.id ?? ''\n if (id !== this.accountId || changes.active) {\n this.accountId = id\n this.keeper = await hasPrivilege({ category: 'saas', privilege: 'mutation', domainOwnerGranted: true })\n await this.read()\n }\n this.subscriptionId = params.subscription ?? this.seatPlans()[0]?.id ?? ''\n this.gristConfig = this.configOf(this.tab)\n this.updateContext()\n }\n\n private seatPlans() {\n return this.subscriptions.filter(one => one.billing === 'SEAT')\n }\n\n private async read() {\n if (!this.accountId) return\n const response = await client.query({\n query: gql`\n query ($id: String!) {\n saasAccount(id: $id) { id name identifier purpose currency billingDay secretLocation paymentAccount { id name } parent { id name } admins { id name controlNo } }\n saasSubscriptions(accountId: $id) { id name billing status }\n }\n `,\n variables: { id: this.accountId },\n fetchPolicy: 'network-only'\n })\n this.account = response.data?.saasAccount\n this.subscriptions = response.data?.saasSubscriptions ?? []\n }\n\n private blank(): any {\n const today = new Date().toISOString().slice(0, 10)\n if (this.tab === 'subscriptions') return { billing: 'FIXED', everyMonths: 1, startOn: today, autoRenew: true, status: 'ACTIVE' }\n return this.tab === 'seats' ? { fromOn: today } : {}\n }\n\n render() {\n const one = this.account\n const tabs = this.account?.parent ? (['admins'] as Tab[]) : TABS\n return html`\n <div class=\"head\">\n ${one\n ? html`<span>\n ${[\n one.identifier,\n one.parent ? i18next.t('text.saas-account-under', { name: one.parent.name }) : null,\n one.purpose,\n one.currency,\n one.billingDay ? i18next.t('text.saas-account-billing-day', { day: one.billingDay }) : null,\n one.paymentAccount?.name,\n one.secretLocation ? i18next.t('text.saas-account-secret-at', { where: one.secretLocation }) : null\n ]\n .filter(Boolean)\n .join(' · ')}\n </span>`\n : nothing}\n </div>\n <div class=\"tabs\" role=\"tablist\">\n ${tabs.map(\n tab => html`<button role=\"tab\" aria-selected=${String(this.tab === tab)} @click=${() => navigate(`saas-account-page?id=${this.accountId}&tab=${tab}`)}>${i18next.t(`text.saas-tab-${tab}`)}</button>`\n )}\n </div>\n ${this.tab === 'seats'\n ? this.seatPlans().length\n ? html`<div class=\"tabs sub\" role=\"tablist\">\n ${this.seatPlans().map(\n sub =>\n html`<button role=\"tab\" aria-selected=${String(this.subscriptionId === sub.id)} @click=${() => navigate(`saas-account-page?id=${this.accountId}&tab=seats&subscription=${sub.id}`)}>\n ${sub.name}\n </button>`\n )}\n </div>`\n : html`<div class=\"empty\">${i18next.t('text.saas-seats-no-plan')}</div>`\n : nothing}\n ${this.gristConfig && (this.tab !== 'seats' || this.subscriptionId)\n ? html`<ox-grist .mode=${'GRID'} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}></ox-grist>`\n : nothing}\n `\n }\n\n private configOf(tab: Tab) {\n const editable = { editable: tab !== 'bills' && (tab !== 'admins' || this.keeper) }\n const set = `saas-${tab === 'subscriptions' ? 'subscription' : tab === 'seats' ? 'seat' : tab === 'bills' ? 'bill' : 'admin'}`\n const text = (name: string, width: number, extra: any = {}) => ({ type: 'string', name, header: fieldWord(set, name), width, ...extra, record: { ...editable, ...extra.record } })\n const day = (name: string, extra: any = {}) => text(name, 100, { ...extra, record: { align: 'center', ...extra.record } })\n const money = (name: string, extra: any = {}) => ({ type: 'float', name, header: fieldWord(set, name), width: 110, ...extra, record: { ...editable, align: 'right', renderer: (value: number) => amountText(value), ...extra.record } })\n const int = (name: string, width = 70) => ({ type: 'integer', name, header: fieldWord(set, name), width, record: { ...editable, align: 'right' } })\n const object = (name: string, width: number, queryName: string, columns: { name: string; header?: string }[]) => ({\n type: 'object',\n name,\n header: fieldWord(set, name),\n width,\n record: { ...editable, editor: getEditor('resource-object'), options: picker(queryName, columns) }\n })\n const columns: Record<Tab, any[]> = {\n subscriptions: [\n text('name', 200, { record: { mandatory: true } }),\n { type: 'select', name: 'billing', header: fieldWord(set, 'billing'), width: 90, record: { ...editable, mandatory: true, options: optionsOf('saas-billing', BILLINGS) } },\n money('quantity', { width: 70, record: { renderer: (value: number) => amountText(value) } }),\n money('unitPrice'),\n money('amount'),\n money('budget'),\n int('everyMonths'),\n day('startOn', { record: { mandatory: true } }),\n day('renewalOn'),\n { type: 'checkbox', name: 'autoRenew', header: fieldWord(set, 'autoRenew'), width: 70, record: editable },\n int('noticeDays'),\n { type: 'integer', name: 'seatsHeld', header: fieldWord(set, 'seatsHeld'), width: 70, record: { align: 'right' } },\n /* Read from the vendor's tenant (ADR-0177 개정 2) - its seats and quantity follow the tenant. */\n { type: 'string', name: 'vendorKey', header: fieldWord(set, 'vendorKey'), width: 90, record: { renderer: (value: string) => (value ? i18next.t('text.saas-synced') : '') } },\n { type: 'checkbox', name: 'trial', header: fieldWord(set, 'trial'), width: 70 },\n object('department', 120, 'departments', [{ name: 'name', header: fieldWord(set, 'department') }]),\n object('asset', 140, 'assets', [{ name: 'name', header: fieldWord(set, 'asset') }]),\n { type: 'select', name: 'status', header: fieldWord(set, 'status'), width: 90, record: { ...editable, options: optionsOf('saas-subscription-status', SUBSCRIPTION_STATUSES) } },\n day('endedOn'),\n text('description', 200)\n ],\n seats: [\n object('employee', 140, 'employees', [{ name: 'name', header: fieldWord(set, 'employee') }, { name: 'controlNo', header: i18next.t('field.control-no') }]),\n text('holder', 140),\n /* The vendor's login - a sync's (ADR-0177 개정 2), read only. */\n { type: 'string', name: 'login', header: fieldWord(set, 'login'), width: 180 },\n day('fromOn'),\n day('untilOn'),\n text('description', 240)\n ],\n bills: [\n text('month', 90, { record: { align: 'center' } }),\n day('billedOn'),\n money('total', { width: 140, header: `${fieldWord(set, 'total')} (${this.account?.currency ?? ''})` }),\n { type: 'string', name: 'lines', header: fieldWord(set, 'lines'), width: 360, record: { renderer: (lines: any[]) => (lines ?? []).map(line => `${line.subscription?.name ?? line.label ?? ''} ${amountText(line.amount)}`).join(' · ') } },\n text('description', 200)\n ],\n admins: [\n object('employee', 160, 'employees', [{ name: 'name', header: fieldWord(set, 'employee') }, { name: 'controlNo', header: i18next.t('field.control-no') }]),\n { type: 'string', name: 'controlNo', header: i18next.t('field.control-no'), width: 100 }\n ]\n }\n return {\n rows: { appendable: !!editable.editable, selectable: { multiple: !!editable.editable } },\n pagination: { infinite: true },\n emptyNote: { title: i18next.t(`text.saas-${tab}-empty`) },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n ...(editable.editable ? [{ type: 'gutter', gutterName: 'row-selector', multiple: true }] : []),\n ...(tab === 'bills'\n ? [{ type: 'gutter', gutterName: 'button', icon: 'edit', handlers: { click: (_c: any, _d: any, _col: any, record: any) => record?.id && this.openBill(record) } }]\n : tab === 'subscriptions'\n ? [\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'group',\n handlers: { click: (_c: any, _d: any, _col: any, record: any) => record?.id && record.billing === 'SEAT' && navigate(`saas-account-page?id=${this.accountId}&tab=seats&subscription=${record.id}`) }\n }\n ]\n : []),\n ...columns[tab]\n ]\n }\n }\n\n async fetchHandler() {\n if (!this.accountId) return { total: 0, records: [] }\n if (this.tab === 'admins') {\n const records = (this.account?.admins ?? []).map((one: any) => ({ id: one.id, employee: { id: one.id, name: one.name }, controlNo: one.controlNo }))\n return { total: records.length, records }\n }\n const queries: Record<Exclude<Tab, 'admins'>, string> = {\n subscriptions: `rows: saasSubscriptions(accountId: $id) { id name billing quantity unitPrice amount budget everyMonths startOn renewalOn autoRenew noticeDays seatsHeld vendorKey trial department { id name } asset { id name } status endedOn description }`,\n seats: `rows: saasSeats(subscriptionId: $id) { id employee { id name } holder login fromOn untilOn description }`,\n bills: `rows: saasBills(accountId: $id) { id month billedOn total description lines { subscription { id name } label amount } }`\n }\n const response = await client.query({\n query: gql`query ($id: String!) { ${queries[this.tab]} }`,\n variables: { id: this.tab === 'seats' ? this.subscriptionId : this.accountId },\n fetchPolicy: 'network-only'\n })\n if (response.errors?.length) throw response\n return { total: response.data.rows.length, records: response.data.rows }\n }\n\n private openBill(bill?: any) {\n SaasBillEditor.open({\n accountId: this.accountId,\n currency: this.account?.currency ?? '',\n subscriptions: this.subscriptions,\n bill,\n saved: () => this.grist?.fetch()\n })\n }\n\n private async save(deleting = false) {\n if (this.tab === 'admins') return this.saveAdmins(deleting)\n /* A picked row goes as its id. */\n const shape = ({ department, asset, employee, ...patch }: any) => ({\n ...patch,\n ...(department === undefined ? {} : { departmentId: department?.id ?? null }),\n ...(asset === undefined ? {} : { assetId: asset?.id ?? null }),\n ...(employee === undefined ? {} : { employeeId: employee?.id ?? null })\n })\n const saved =\n this.tab === 'subscriptions'\n ? await saveGrid(this.grist, SUBSCRIPTION_FIELDS, 'updateMultipleSaasSubscription', 'SaasSubscriptionPatch', { accountId: this.accountId }, deleting, shape)\n : await saveGrid(this.grist, SEAT_FIELDS, 'updateMultipleSaasSeat', 'SaasSeatPatch', { subscriptionId: this.subscriptionId }, deleting, shape)\n if (saved) {\n this.grist.fetch()\n if (this.tab === 'subscriptions') await this.read()\n }\n }\n\n /** The admins are a field of the account - the grid's rows, less the deleted, saved as its list. */\n private async saveAdmins(deleting: boolean) {\n const removed = new Set(deleting ? this.grist.selected.map((one: any) => one.employee?.id ?? one.id) : [])\n const rows = (this.grist.dirtyData?.records ?? []).filter((one: any) => one.__dirty__ !== '-' && one.employee?.id && !removed.has(one.employee.id))\n const adminIds = [...new Set(rows.map((one: any) => one.employee.id))]\n const grist = {\n dirtyRecords: [{ id: this.accountId, __dirty__: 'M', __dirtyfields__: { adminIds: true }, adminIds }],\n selected: []\n } as any\n if (await saveGrid(grist, ['adminIds'], 'updateMultipleSaasAccount', 'SaasAccountPatch')) {\n await this.read()\n this.grist.fetch()\n }\n }\n}\n\n"]}
|