@things-factory/saas 10.1.247 → 10.1.248

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/package.json +4 -4
  2. package/dist-client/bootstrap.d.ts +0 -1
  3. package/dist-client/bootstrap.js +0 -5
  4. package/dist-client/bootstrap.js.map +0 -1
  5. package/dist-client/entity360/saas-account-360.d.ts +0 -11
  6. package/dist-client/entity360/saas-account-360.js +0 -178
  7. package/dist-client/entity360/saas-account-360.js.map +0 -1
  8. package/dist-client/index.d.ts +0 -1
  9. package/dist-client/index.js +0 -2
  10. package/dist-client/index.js.map +0 -1
  11. package/dist-client/pages/saas-account-list.d.ts +0 -57
  12. package/dist-client/pages/saas-account-list.js +0 -169
  13. package/dist-client/pages/saas-account-list.js.map +0 -1
  14. package/dist-client/pages/saas-account-page.d.ts +0 -52
  15. package/dist-client/pages/saas-account-page.js +0 -332
  16. package/dist-client/pages/saas-account-page.js.map +0 -1
  17. package/dist-client/route.d.ts +0 -1
  18. package/dist-client/route.js +0 -13
  19. package/dist-client/route.js.map +0 -1
  20. package/dist-client/tsconfig.tsbuildinfo +0 -1
  21. package/dist-client/words.d.ts +0 -34
  22. package/dist-client/words.js +0 -22
  23. package/dist-client/words.js.map +0 -1
  24. package/dist-server/index.d.ts +0 -1
  25. package/dist-server/index.js +0 -9
  26. package/dist-server/index.js.map +0 -1
  27. package/dist-server/role-tasks.d.ts +0 -2
  28. package/dist-server/role-tasks.js +0 -18
  29. package/dist-server/role-tasks.js.map +0 -1
  30. package/dist-server/service/checks.d.ts +0 -27
  31. package/dist-server/service/checks.js +0 -70
  32. package/dist-server/service/checks.js.map +0 -1
  33. package/dist-server/service/index.d.ts +0 -18
  34. package/dist-server/service/index.js +0 -34
  35. package/dist-server/service/index.js.map +0 -1
  36. package/dist-server/service/saas-access.d.ts +0 -20
  37. package/dist-server/service/saas-access.js +0 -36
  38. package/dist-server/service/saas-access.js.map +0 -1
  39. package/dist-server/service/saas-account.d.ts +0 -39
  40. package/dist-server/service/saas-account.js +0 -151
  41. package/dist-server/service/saas-account.js.map +0 -1
  42. package/dist-server/service/saas-mutation.d.ts +0 -10
  43. package/dist-server/service/saas-mutation.js +0 -87
  44. package/dist-server/service/saas-mutation.js.map +0 -1
  45. package/dist-server/service/saas-query.d.ts +0 -21
  46. package/dist-server/service/saas-query.js +0 -168
  47. package/dist-server/service/saas-query.js.map +0 -1
  48. package/dist-server/service/saas-rules.d.ts +0 -41
  49. package/dist-server/service/saas-rules.js +0 -62
  50. package/dist-server/service/saas-rules.js.map +0 -1
  51. package/dist-server/service/saas-seat.d.ts +0 -26
  52. package/dist-server/service/saas-seat.js +0 -110
  53. package/dist-server/service/saas-seat.js.map +0 -1
  54. package/dist-server/service/saas-service.d.ts +0 -19
  55. package/dist-server/service/saas-service.js +0 -223
  56. package/dist-server/service/saas-service.js.map +0 -1
  57. package/dist-server/service/saas-subscription.d.ts +0 -45
  58. package/dist-server/service/saas-subscription.js +0 -174
  59. package/dist-server/service/saas-subscription.js.map +0 -1
  60. package/dist-server/service/saas-sync.d.ts +0 -34
  61. package/dist-server/service/saas-sync.js +0 -106
  62. package/dist-server/service/saas-sync.js.map +0 -1
  63. package/dist-server/service/saas-type.d.ts +0 -89
  64. package/dist-server/service/saas-type.js +0 -338
  65. package/dist-server/service/saas-type.js.map +0 -1
  66. package/dist-server/tsconfig.tsbuildinfo +0 -1
@@ -1,332 +0,0 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import '@operato/data-grist/ox-grist.js';
3
- import gql from 'graphql-tag';
4
- import { css, html, nothing } from 'lit';
5
- import { customElement, query, state } from 'lit/decorators.js';
6
- import { DataGrist, getEditor } from '@operato/data-grist';
7
- import { client } from '@operato/graphql';
8
- import { i18next, localize } from '@operato/i18n';
9
- import { navigate, PageView } from '@operato/shell';
10
- import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles';
11
- import { saveGrid } from '@things-factory/asset/dist-client';
12
- import { hasPrivilege } from '@things-factory/auth-base/dist-client';
13
- import { amountText, BILLINGS, fieldWord, optionsOf, picker, SUBSCRIPTION_STATUSES } from '../words.js';
14
- const TABS = ['subscriptions', 'seats', 'admins'];
15
- const SUBSCRIPTION_FIELDS = ['name', 'billing', 'quantity', 'unitPrice', 'startOn', 'renewalOn', 'autoRenew', 'noticeDays', 'department', 'asset', 'status', 'endedOn', 'description'];
16
- const SEAT_FIELDS = ['employee', 'holder', 'fromOn', 'untilOn', 'description'];
17
- /**
18
- * 구독 서비스 한 계정 — tab by tab its subscriptions, the seats of one of them and who administers it (ADR-0177 decisions
19
- * 2-6; its money is a recurring item's, 개정 7). The keepers keep all of it; an admin keeps what is under their own account, not the account
20
- * or its admins.
21
- */
22
- let SaasAccountPage = class SaasAccountPage extends localize(i18next)(PageView) {
23
- constructor() {
24
- super(...arguments);
25
- this.accountId = '';
26
- this.subscriptions = [];
27
- this.subscriptionId = '';
28
- this.tab = 'subscriptions';
29
- this.keeper = false;
30
- }
31
- static { this.styles = [
32
- CommonGristStyles,
33
- ScrollbarStyles,
34
- css `
35
- :host {
36
- display: flex;
37
- flex-direction: column;
38
- overflow: hidden;
39
- }
40
- .head {
41
- display: flex;
42
- flex-wrap: wrap;
43
- align-items: baseline;
44
- gap: var(--spacing-small, 4px) var(--spacing-large, 12px);
45
- padding: var(--spacing-medium, 8px) var(--spacing-large, 12px);
46
- color: var(--md-sys-color-on-surface-variant);
47
- }
48
- .tabs {
49
- display: flex;
50
- gap: var(--spacing-small, 4px);
51
- overflow-x: auto;
52
- padding: 0 var(--spacing-large, 12px) var(--spacing-medium, 8px);
53
- }
54
- .tabs button {
55
- flex: none;
56
- padding: 4px var(--spacing-large, 12px);
57
- border: 1px solid var(--ui-line-soft, var(--md-sys-color-outline-variant));
58
- border-radius: 999px;
59
- background: none;
60
- color: var(--md-sys-color-on-surface);
61
- font: inherit;
62
- font-size: var(--ui-t-body, 14px);
63
- cursor: pointer;
64
- }
65
- .tabs button[aria-selected='true'] {
66
- border-color: var(--md-sys-color-primary);
67
- background: var(--md-sys-color-primary-container);
68
- color: var(--md-sys-color-on-primary-container);
69
- }
70
- .tabs.sub button {
71
- font-size: var(--ui-t-caption, 12px);
72
- }
73
- .empty {
74
- padding: var(--spacing-large, 12px);
75
- color: var(--md-sys-color-on-surface-variant);
76
- }
77
- ox-grist {
78
- flex: 1;
79
- overflow-y: auto;
80
- }
81
- `
82
- ]; }
83
- get context() {
84
- const editing = this.tab !== 'admins' || this.keeper;
85
- const actions = editing && (this.tab !== 'seats' || this.subscriptionId)
86
- ? [
87
- { title: i18next.t('button.add'), icon: 'add', action: () => this.grist.addRecordToTop(this.blank()) },
88
- { title: i18next.t('button.delete'), action: () => this.save(true), ...CommonButtonStyles.delete },
89
- { title: i18next.t('button.save'), action: () => this.save(), ...CommonButtonStyles.save }
90
- ]
91
- : [];
92
- return { title: this.account?.name ?? i18next.t('title.saas-account-page'), actions };
93
- }
94
- async pageUpdated(changes, lifecycle) {
95
- if (!this.active)
96
- return;
97
- const params = lifecycle?.params ?? {};
98
- this.tab = TABS.includes(params.tab) ? params.tab : 'subscriptions';
99
- const id = params.id ?? '';
100
- if (id !== this.accountId || changes.active) {
101
- this.accountId = id;
102
- this.keeper = await hasPrivilege({ category: 'saas', privilege: 'mutation', domainOwnerGranted: true });
103
- await this.read();
104
- }
105
- this.subscriptionId = params.subscription ?? this.seatPlans()[0]?.id ?? '';
106
- this.gristConfig = this.configOf(this.tab);
107
- this.updateContext();
108
- }
109
- seatPlans() {
110
- return this.subscriptions.filter(one => one.billing === 'SEAT');
111
- }
112
- async read() {
113
- if (!this.accountId)
114
- return;
115
- const response = await client.query({
116
- query: gql `
117
- query ($id: String!) {
118
- saasAccount(id: $id) { id name identifier purpose currency secretLocation paymentAccount { id name } parent { id name } admins { id name controlNo } }
119
- saasSubscriptions(accountId: $id) { id name billing status }
120
- }
121
- `,
122
- variables: { id: this.accountId },
123
- fetchPolicy: 'network-only'
124
- });
125
- this.account = response.data?.saasAccount;
126
- this.subscriptions = response.data?.saasSubscriptions ?? [];
127
- }
128
- blank() {
129
- const today = new Date().toISOString().slice(0, 10);
130
- if (this.tab === 'subscriptions')
131
- return { billing: 'FIXED', startOn: today, autoRenew: true, status: 'ACTIVE' };
132
- return this.tab === 'seats' ? { fromOn: today } : {};
133
- }
134
- render() {
135
- const one = this.account;
136
- const tabs = this.account?.parent ? ['admins'] : TABS;
137
- return html `
138
- <div class="head">
139
- ${one
140
- ? html `<span>
141
- ${[
142
- one.identifier,
143
- one.parent ? i18next.t('text.saas-account-under', { name: one.parent.name }) : null,
144
- one.purpose,
145
- one.currency,
146
- one.paymentAccount?.name,
147
- one.secretLocation ? i18next.t('text.saas-account-secret-at', { where: one.secretLocation }) : null
148
- ]
149
- .filter(Boolean)
150
- .join(' · ')}
151
- </span>`
152
- : nothing}
153
- </div>
154
- <div class="tabs" role="tablist">
155
- ${tabs.map(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>`)}
156
- </div>
157
- ${this.tab === 'seats'
158
- ? this.seatPlans().length
159
- ? html `<div class="tabs sub" role="tablist">
160
- ${this.seatPlans().map(sub => html `<button role="tab" aria-selected=${String(this.subscriptionId === sub.id)} @click=${() => navigate(`saas-account-page?id=${this.accountId}&tab=seats&subscription=${sub.id}`)}>
161
- ${sub.name}
162
- </button>`)}
163
- </div>`
164
- : html `<div class="empty">${i18next.t('text.saas-seats-no-plan')}</div>`
165
- : nothing}
166
- ${this.gristConfig && (this.tab !== 'seats' || this.subscriptionId)
167
- ? html `<ox-grist .mode=${'GRID'} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}></ox-grist>`
168
- : nothing}
169
- `;
170
- }
171
- configOf(tab) {
172
- const editable = { editable: tab !== 'admins' || this.keeper };
173
- const set = `saas-${tab === 'subscriptions' ? 'subscription' : tab === 'seats' ? 'seat' : 'admin'}`;
174
- const text = (name, width, extra = {}) => ({ type: 'string', name, header: fieldWord(set, name), width, ...extra, record: { ...editable, ...extra.record } });
175
- const day = (name, extra = {}) => text(name, 100, { ...extra, record: { align: 'center', ...extra.record } });
176
- const money = (name, extra = {}) => ({ type: 'float', name, header: fieldWord(set, name), width: 110, ...extra, record: { ...editable, align: 'right', renderer: (value) => amountText(value), ...extra.record } });
177
- const int = (name, width = 70) => ({ type: 'integer', name, header: fieldWord(set, name), width, record: { ...editable, align: 'right' } });
178
- const object = (name, width, queryName, columns) => ({
179
- type: 'object',
180
- name,
181
- header: fieldWord(set, name),
182
- width,
183
- record: { ...editable, editor: getEditor('resource-object'), options: picker(queryName, columns) }
184
- });
185
- const columns = {
186
- subscriptions: [
187
- text('name', 200, { record: { mandatory: true } }),
188
- { type: 'select', name: 'billing', header: fieldWord(set, 'billing'), width: 90, record: { ...editable, mandatory: true, options: optionsOf('saas-billing', BILLINGS) } },
189
- money('quantity', { width: 70, record: { renderer: (value) => amountText(value) } }),
190
- /* For reference - the money is the recurring item's (개정 7-3). */
191
- money('unitPrice'),
192
- money('referenceAmount', { record: { editable: false } }),
193
- day('startOn', { record: { mandatory: true } }),
194
- day('renewalOn'),
195
- { type: 'checkbox', name: 'autoRenew', header: fieldWord(set, 'autoRenew'), width: 70, record: editable },
196
- int('noticeDays'),
197
- { type: 'integer', name: 'seatsHeld', header: fieldWord(set, 'seatsHeld'), width: 70, record: { align: 'right' } },
198
- /* Read from the vendor's tenant (ADR-0177 개정 2) - its seats and quantity follow the tenant. */
199
- { type: 'string', name: 'vendorKey', header: fieldWord(set, 'vendorKey'), width: 90, record: { renderer: (value) => (value ? i18next.t('text.saas-synced') : '') } },
200
- { type: 'checkbox', name: 'trial', header: fieldWord(set, 'trial'), width: 70 },
201
- object('department', 120, 'departments', [{ name: 'name', header: fieldWord(set, 'department') }]),
202
- object('asset', 140, 'assets', [{ name: 'name', header: fieldWord(set, 'asset') }]),
203
- { type: 'select', name: 'status', header: fieldWord(set, 'status'), width: 90, record: { ...editable, options: optionsOf('saas-subscription-status', SUBSCRIPTION_STATUSES) } },
204
- day('endedOn'),
205
- text('description', 200)
206
- ],
207
- seats: [
208
- object('employee', 140, 'employees', [{ name: 'name', header: fieldWord(set, 'employee') }, { name: 'controlNo', header: i18next.t('field.control-no') }]),
209
- text('holder', 140),
210
- /* The vendor's login - a sync's (ADR-0177 개정 2), read only. */
211
- { type: 'string', name: 'login', header: fieldWord(set, 'login'), width: 180 },
212
- day('fromOn'),
213
- day('untilOn'),
214
- text('description', 240)
215
- ],
216
- admins: [
217
- object('employee', 160, 'employees', [{ name: 'name', header: fieldWord(set, 'employee') }, { name: 'controlNo', header: i18next.t('field.control-no') }]),
218
- { type: 'string', name: 'controlNo', header: i18next.t('field.control-no'), width: 100 }
219
- ]
220
- };
221
- return {
222
- rows: { appendable: !!editable.editable, selectable: { multiple: !!editable.editable } },
223
- pagination: { infinite: true },
224
- emptyNote: { title: i18next.t(`text.saas-${tab}-empty`) },
225
- columns: [
226
- { type: 'gutter', gutterName: 'sequence' },
227
- ...(editable.editable ? [{ type: 'gutter', gutterName: 'row-selector', multiple: true }] : []),
228
- ...(tab === 'subscriptions'
229
- ? [
230
- {
231
- type: 'gutter',
232
- gutterName: 'button',
233
- icon: 'group',
234
- handlers: { click: (_c, _d, _col, record) => record?.id && record.billing === 'SEAT' && navigate(`saas-account-page?id=${this.accountId}&tab=seats&subscription=${record.id}`) }
235
- }
236
- ]
237
- : []),
238
- ...columns[tab]
239
- ]
240
- };
241
- }
242
- async fetchHandler() {
243
- if (!this.accountId)
244
- return { total: 0, records: [] };
245
- if (this.tab === 'admins') {
246
- const records = (this.account?.admins ?? []).map((one) => ({ id: one.id, employee: { id: one.id, name: one.name }, controlNo: one.controlNo }));
247
- return { total: records.length, records };
248
- }
249
- const queries = {
250
- subscriptions: `rows: saasSubscriptions(accountId: $id) { id name billing quantity unitPrice referenceAmount startOn renewalOn autoRenew noticeDays seatsHeld vendorKey trial department { id name } asset { id name } status endedOn description }`,
251
- seats: `rows: saasSeats(subscriptionId: $id) { id employee { id name } holder login fromOn untilOn description }`
252
- };
253
- const response = await client.query({
254
- query: gql `query ($id: String!) { ${queries[this.tab]} }`,
255
- variables: { id: this.tab === 'seats' ? this.subscriptionId : this.accountId },
256
- fetchPolicy: 'network-only'
257
- });
258
- if (response.errors?.length)
259
- throw response;
260
- return { total: response.data.rows.length, records: response.data.rows };
261
- }
262
- async save(deleting = false) {
263
- if (this.tab === 'admins')
264
- return this.saveAdmins(deleting);
265
- /* A picked row goes as its id. */
266
- const shape = ({ department, asset, employee, ...patch }) => ({
267
- ...patch,
268
- ...(department === undefined ? {} : { departmentId: department?.id ?? null }),
269
- ...(asset === undefined ? {} : { assetId: asset?.id ?? null }),
270
- ...(employee === undefined ? {} : { employeeId: employee?.id ?? null })
271
- });
272
- const saved = this.tab === 'subscriptions'
273
- ? await saveGrid(this.grist, SUBSCRIPTION_FIELDS, 'updateMultipleSaasSubscription', 'SaasSubscriptionPatch', { accountId: this.accountId }, deleting, shape)
274
- : await saveGrid(this.grist, SEAT_FIELDS, 'updateMultipleSaasSeat', 'SaasSeatPatch', { subscriptionId: this.subscriptionId }, deleting, shape);
275
- if (saved) {
276
- this.grist.fetch();
277
- if (this.tab === 'subscriptions')
278
- await this.read();
279
- }
280
- }
281
- /** The admins are a field of the account - the grid's rows, less the deleted, saved as its list. */
282
- async saveAdmins(deleting) {
283
- const removed = new Set(deleting ? this.grist.selected.map((one) => one.employee?.id ?? one.id) : []);
284
- const rows = (this.grist.dirtyData?.records ?? []).filter((one) => one.__dirty__ !== '-' && one.employee?.id && !removed.has(one.employee.id));
285
- const adminIds = [...new Set(rows.map((one) => one.employee.id))];
286
- const grist = {
287
- dirtyRecords: [{ id: this.accountId, __dirty__: 'M', __dirtyfields__: { adminIds: true }, adminIds }],
288
- selected: []
289
- };
290
- if (await saveGrid(grist, ['adminIds'], 'updateMultipleSaasAccount', 'SaasAccountPatch')) {
291
- await this.read();
292
- this.grist.fetch();
293
- }
294
- }
295
- };
296
- __decorate([
297
- state(),
298
- __metadata("design:type", Object)
299
- ], SaasAccountPage.prototype, "accountId", void 0);
300
- __decorate([
301
- state(),
302
- __metadata("design:type", Object)
303
- ], SaasAccountPage.prototype, "account", void 0);
304
- __decorate([
305
- state(),
306
- __metadata("design:type", Array)
307
- ], SaasAccountPage.prototype, "subscriptions", void 0);
308
- __decorate([
309
- state(),
310
- __metadata("design:type", Object)
311
- ], SaasAccountPage.prototype, "subscriptionId", void 0);
312
- __decorate([
313
- state(),
314
- __metadata("design:type", String)
315
- ], SaasAccountPage.prototype, "tab", void 0);
316
- __decorate([
317
- state(),
318
- __metadata("design:type", Object)
319
- ], SaasAccountPage.prototype, "keeper", void 0);
320
- __decorate([
321
- state(),
322
- __metadata("design:type", Object)
323
- ], SaasAccountPage.prototype, "gristConfig", void 0);
324
- __decorate([
325
- query('ox-grist'),
326
- __metadata("design:type", DataGrist)
327
- ], SaasAccountPage.prototype, "grist", void 0);
328
- SaasAccountPage = __decorate([
329
- customElement('saas-account-page')
330
- ], SaasAccountPage);
331
- export { SaasAccountPage };
332
- //# sourceMappingURL=saas-account-page.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"saas-account-page.js","sourceRoot":"","sources":["../../client/pages/saas-account-page.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AAExC,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;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAA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;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,CA4R3B","sourcesContent":["import '@operato/data-grist/ox-grist.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'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client'\n\nimport { amountText, BILLINGS, fieldWord, optionsOf, picker, SUBSCRIPTION_STATUSES } from '../words.js'\n\ntype Tab = 'subscriptions' | 'seats' | 'admins'\nconst TABS: Tab[] = ['subscriptions', 'seats', 'admins']\n\nconst SUBSCRIPTION_FIELDS = ['name', 'billing', 'quantity', 'unitPrice', '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 and who administers it (ADR-0177 decisions\n * 2-6; its money is a recurring item's, 개정 7). 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 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 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', 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.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 !== 'admins' || this.keeper }\n const set = `saas-${tab === 'subscriptions' ? 'subscription' : tab === 'seats' ? 'seat' : '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 /* For reference - the money is the recurring item's (개정 7-3). */\n money('unitPrice'),\n money('referenceAmount', { record: { editable: false } }),\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 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 === '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 referenceAmount 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 }\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 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 +0,0 @@
1
- export default function route(page: string): "saas-account-list" | "my-saas-account-list" | "saas-account-page" | undefined;
@@ -1,13 +0,0 @@
1
- /* The pages this module brings to an application that puts them in its menu (ADR-0177). */
2
- export default function route(page) {
3
- switch (page) {
4
- case 'saas-account-list':
5
- case 'my-saas-account-list':
6
- import('./pages/saas-account-list.js');
7
- return page;
8
- case 'saas-account-page':
9
- import('./pages/saas-account-page.js');
10
- return page;
11
- }
12
- }
13
- //# sourceMappingURL=route.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"route.js","sourceRoot":"","sources":["../client/route.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,IAAY;IACxC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,mBAAmB,CAAC;QACzB,KAAK,sBAAsB;YACzB,MAAM,CAAC,8BAA8B,CAAC,CAAA;YACtC,OAAO,IAAI,CAAA;QAEb,KAAK,mBAAmB;YACtB,MAAM,CAAC,8BAA8B,CAAC,CAAA;YACtC,OAAO,IAAI,CAAA;IACf,CAAC;AACH,CAAC","sourcesContent":["/* The pages this module brings to an application that puts them in its menu (ADR-0177). */\nexport default function route(page: string) {\n switch (page) {\n case 'saas-account-list':\n case 'my-saas-account-list':\n import('./pages/saas-account-list.js')\n return page\n\n case 'saas-account-page':\n import('./pages/saas-account-page.js')\n return page\n }\n}\n"]}