@things-factory/asset 10.1.229 → 10.1.231

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.
@@ -10,4 +10,4 @@ export declare function patchesOf(grist: DataGrist, fields: string[]): {
10
10
  * Save a grid: its rows with the deleted ones marked, through the module's `updateMultiple<Type>` - one transaction, so a
11
11
  * refusal keeps nothing. True when saved.
12
12
  */
13
- export declare function saveGrid(grist: DataGrist, fields: string[], mutation: string, type: string, extra?: Record<string, any>, deleting?: boolean): Promise<boolean>;
13
+ export declare function saveGrid(grist: DataGrist, fields: string[], mutation: string, type: string, extra?: Record<string, any>, deleting?: boolean, shape?: (patch: any) => any): Promise<boolean>;
@@ -16,10 +16,10 @@ export function patchesOf(grist, fields) {
16
16
  * Save a grid: its rows with the deleted ones marked, through the module's `updateMultiple<Type>` - one transaction, so a
17
17
  * refusal keeps nothing. True when saved.
18
18
  */
19
- export async function saveGrid(grist, fields, mutation, type, extra = {}, deleting = false) {
19
+ export async function saveGrid(grist, fields, mutation, type, extra = {}, deleting = false, shape = patch => patch) {
20
20
  const patches = deleting
21
21
  ? grist.selected.filter((record) => record.id).map((record) => ({ id: record.id, cuFlag: '-' }))
22
- : patchesOf(grist, fields);
22
+ : patchesOf(grist, fields).map(shape);
23
23
  if (!patches.length)
24
24
  return false;
25
25
  if (deleting) {
@@ -1 +1 @@
1
- {"version":3,"file":"grid.js","sourceRoot":"","sources":["../client/grid.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAG7B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAEtD,sDAAsD;AACtD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAU,EAAE,EA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,MAAM,MAAM,CAAC,MAAM,CAAC;YACnC,QAAQ,EAAE,GAAG,CAAA;oBACC,CAAC,GAAG,IAAI,EAAE,cAAc,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YACrD,QAAQ,IAAI,CAAC,GAAG,MAAM,EAAE,mBAAmB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;OAE5D;YACD,SAAS,EAAE,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE;SACjC,CAAC,CAAA;QACF,IAAK,QAAgB,CAAC,MAAM,EAAE,MAAM;YAAE,MAAM,QAAQ,CAAA;QACpD,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAA;QACjE,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QACrD,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { DataGrist } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next } from '@operato/i18n'\nimport { notify } from '@operato/layout'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\n\n/** What a failed call says, in the server's words. */\nexport const failureOf = (error: any) => error?.graphQLErrors?.[0]?.message ?? error?.errors?.[0]?.message ?? error?.message ?? String(error)\n\n/** The grid's new, changed and deleted rows as patches - all fields of a new row, the changed ones otherwise. */\nexport function patchesOf(grist: DataGrist, fields: string[]) {\n return grist.dirtyRecords.map((record: any) => {\n const changed = record.__dirty__ === '+' ? fields.filter(field => record[field] !== undefined) : Object.keys(record.__dirtyfields__ ?? {}).filter(field => fields.includes(field))\n return { ...(record.id ? { id: record.id } : {}), cuFlag: record.__dirty__, ...Object.fromEntries(changed.map(field => [field, record[field] === '' ? null : record[field]])) }\n })\n}\n\n/**\n * Save a grid: its rows with the deleted ones marked, through the module's `updateMultiple<Type>` - one transaction, so a\n * refusal keeps nothing. True when saved.\n */\nexport async function saveGrid(grist: DataGrist, fields: string[], mutation: string, type: string, extra: Record<string, any> = {}, deleting = false): Promise<boolean> {\n const patches = deleting\n ? grist.selected.filter((record: any) => record.id).map((record: any) => ({ id: record.id, cuFlag: '-' }))\n : patchesOf(grist, fields)\n if (!patches.length) return false\n if (deleting) {\n const confirmed = await OxPrompt.open({\n title: i18next.t('button.delete'),\n text: i18next.t('text.asset-delete-confirm', { count: patches.length }),\n confirmButton: { text: i18next.t('button.delete'), destructive: true },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n if (!confirmed) return false\n }\n const args = Object.keys(extra).map(name => `$${name}: String!`)\n const passes = Object.keys(extra).map(name => `${name}: $${name}`)\n try {\n const response = await client.mutate({\n mutation: gql`\n mutation (${[...args, `$patches: [${type}!]!`].join(', ')}) {\n ${mutation}(${[...passes, 'patches: $patches'].join(', ')}) { id }\n }\n `,\n variables: { ...extra, patches }\n })\n if ((response as any).errors?.length) throw response\n notify({ level: 'info', message: i18next.t('text.asset-saved') })\n return true\n } catch (error) {\n notify({ level: 'error', message: failureOf(error) })\n return false\n }\n}\n"]}
1
+ {"version":3,"file":"grid.js","sourceRoot":"","sources":["../client/grid.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAG7B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAEtD,sDAAsD;AACtD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,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QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;YACnC,QAAQ,EAAE,GAAG,CAAA;oBACC,CAAC,GAAG,IAAI,EAAE,cAAc,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YACrD,QAAQ,IAAI,CAAC,GAAG,MAAM,EAAE,mBAAmB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;OAE5D;YACD,SAAS,EAAE,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE;SACjC,CAAC,CAAA;QACF,IAAK,QAAgB,CAAC,MAAM,EAAE,MAAM;YAAE,MAAM,QAAQ,CAAA;QACpD,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAA;QACjE,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QACrD,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { DataGrist } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next } from '@operato/i18n'\nimport { notify } from '@operato/layout'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\n\n/** What a failed call says, in the server's words. */\nexport const failureOf = (error: any) => error?.graphQLErrors?.[0]?.message ?? error?.errors?.[0]?.message ?? error?.message ?? String(error)\n\n/** The grid's new, changed and deleted rows as patches - all fields of a new row, the changed ones otherwise. */\nexport function patchesOf(grist: DataGrist, fields: string[]) {\n return grist.dirtyRecords.map((record: any) => {\n const changed = record.__dirty__ === '+' ? fields.filter(field => record[field] !== undefined) : Object.keys(record.__dirtyfields__ ?? {}).filter(field => fields.includes(field))\n return { ...(record.id ? { id: record.id } : {}), cuFlag: record.__dirty__, ...Object.fromEntries(changed.map(field => [field, record[field] === '' ? null : record[field]])) }\n })\n}\n\n/**\n * Save a grid: its rows with the deleted ones marked, through the module's `updateMultiple<Type>` - one transaction, so a\n * refusal keeps nothing. True when saved.\n */\nexport async function saveGrid(\n grist: DataGrist,\n fields: string[],\n mutation: string,\n type: string,\n extra: Record<string, any> = {},\n deleting = false,\n shape: (patch: any) => any = patch => patch\n): Promise<boolean> {\n const patches = deleting\n ? grist.selected.filter((record: any) => record.id).map((record: any) => ({ id: record.id, cuFlag: '-' }))\n : patchesOf(grist, fields).map(shape)\n if (!patches.length) return false\n if (deleting) {\n const confirmed = await OxPrompt.open({\n title: i18next.t('button.delete'),\n text: i18next.t('text.asset-delete-confirm', { count: patches.length }),\n confirmButton: { text: i18next.t('button.delete'), destructive: true },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n if (!confirmed) return false\n }\n const args = Object.keys(extra).map(name => `$${name}: String!`)\n const passes = Object.keys(extra).map(name => `${name}: $${name}`)\n try {\n const response = await client.mutate({\n mutation: gql`\n mutation (${[...args, `$patches: [${type}!]!`].join(', ')}) {\n ${mutation}(${[...passes, 'patches: $patches'].join(', ')}) { id }\n }\n `,\n variables: { ...extra, patches }\n })\n if ((response as any).errors?.length) throw response\n notify({ level: 'info', message: i18next.t('text.asset-saved') })\n return true\n } catch (error) {\n notify({ level: 'error', message: failureOf(error) })\n return false\n }\n}\n"]}
@@ -41,8 +41,6 @@ export declare class InvestmentList extends InvestmentList_base {
41
41
  };
42
42
  };
43
43
  render(): import("lit-html").TemplateResult<1>;
44
- /** Counterparties to pick the company from - which one, nothing about it. */
45
- private counterparties;
46
44
  pageInitialized(): Promise<void>;
47
45
  fetchHandler({ page, limit, sortings, filters, search }: FetchOption): Promise<{
48
46
  total: any;
@@ -4,7 +4,7 @@ import '@operato/data-grist/ox-filters-form.js';
4
4
  import gql from 'graphql-tag';
5
5
  import { html } from 'lit';
6
6
  import { customElement, query, state } from 'lit/decorators.js';
7
- import { DataGrist } from '@operato/data-grist';
7
+ import { DataGrist, getEditor } from '@operato/data-grist';
8
8
  import { client } from '@operato/graphql';
9
9
  import { i18next, localize } from '@operato/i18n';
10
10
  import { navigate, PageView } from '@operato/shell';
@@ -12,7 +12,7 @@ import { CommonButtonStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarSty
12
12
  import { isMobileDevice } from '@operato/utils';
13
13
  import { saveGrid } from '../grid.js';
14
14
  import { amountText, fieldWord, percentText } from '../words.js';
15
- const FIELDS = ['name', 'counterpartyId', 'country', 'registrationNo', 'currency', 'fiscalYearEndMonth', 'reportDueMonths', 'representative', 'active', 'description'];
15
+ const FIELDS = ['name', 'counterparty', 'country', 'registrationNo', 'currency', 'fiscalYearEndMonth', 'reportDueMonths', 'representative', 'active', 'description'];
16
16
  /**
17
17
  * 보유 지분 — the companies the domain holds shares in (ADR-0175 decision 6), with where each holding stands now. A
18
18
  * company opens to its holding day by day, its reports, what it asked of us and what the law asks of us.
@@ -39,23 +39,6 @@ let InvestmentList = class InvestmentList extends localize(i18next)(PageView) {
39
39
  </div>
40
40
  </ox-grist>`;
41
41
  }
42
- /** Counterparties to pick the company from - which one, nothing about it. */
43
- async counterparties() {
44
- try {
45
- const response = await client.query({
46
- query: gql `
47
- query {
48
- counterpartyChoices(pagination: { page: 1, limit: 500 }) { items { id name } }
49
- }
50
- `,
51
- fetchPolicy: 'network-only'
52
- });
53
- return [{ value: '', display: '' }, ...(response.data?.counterpartyChoices?.items ?? []).map((one) => ({ value: one.id, display: one.name }))];
54
- }
55
- catch {
56
- return [{ value: '', display: '' }];
57
- }
58
- }
59
42
  async pageInitialized() {
60
43
  const editable = { editable: true };
61
44
  const text = (name, width, extra = {}) => ({ type: 'string', name, header: fieldWord('investee', name), width, sortable: true, ...extra, record: { ...editable, ...extra.record } });
@@ -72,7 +55,25 @@ let InvestmentList = class InvestmentList extends localize(i18next)(PageView) {
72
55
  { type: 'gutter', gutterName: 'row-selector', multiple: true },
73
56
  { type: 'gutter', gutterName: 'button', icon: 'open_in_new', handlers: { click: (_c, _d, _col, record) => open(record) } },
74
57
  text('name', 180, { record: { mandatory: true } }),
75
- { type: 'select', name: 'counterpartyId', header: fieldWord('investee', 'counterparty'), width: 160, record: { ...editable, options: await this.counterparties() } },
58
+ /* Picked in the framework's resource picker - searched by name or business number, which one and nothing about it. */
59
+ {
60
+ type: 'object',
61
+ name: 'counterparty',
62
+ header: fieldWord('investee', 'counterparty'),
63
+ width: 160,
64
+ record: {
65
+ ...editable,
66
+ editor: getEditor('resource-object'),
67
+ options: {
68
+ queryName: 'counterpartyChoices',
69
+ select: [
70
+ { name: 'id', hidden: true },
71
+ { name: 'name', header: fieldWord('investee', 'counterparty'), width: 220 },
72
+ { name: 'businessNumber', header: fieldWord('investee', 'business-number'), width: 130 }
73
+ ]
74
+ }
75
+ }
76
+ },
76
77
  shown('ourShares', 100, value => amountText(value)),
77
78
  shown('totalShares', 110, value => amountText(value)),
78
79
  shown('ratio', 80, value => percentText(value)),
@@ -94,7 +95,7 @@ let InvestmentList = class InvestmentList extends localize(i18next)(PageView) {
94
95
  query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $search: String) {
95
96
  responses: investees(filters: $filters, pagination: $pagination, sortings: $sortings, search: $search) {
96
97
  items {
97
- id name counterparty { id } country registrationNo currency fiscalYearEndMonth reportDueMonths representative active description
98
+ id name counterparty { id name } country registrationNo currency fiscalYearEndMonth reportDueMonths representative active description
98
99
  ourShares totalShares ratio
99
100
  }
100
101
  total
@@ -108,11 +109,13 @@ let InvestmentList = class InvestmentList extends localize(i18next)(PageView) {
108
109
  throw response;
109
110
  return {
110
111
  total: response.data.responses.total,
111
- records: response.data.responses.items.map(({ counterparty, ...one }) => ({ ...one, counterpartyId: counterparty?.id ?? '' }))
112
+ records: response.data.responses.items
112
113
  };
113
114
  }
114
115
  async save(deleting = false) {
115
- if (await saveGrid(this.grist, FIELDS, 'updateMultipleInvestee', 'InvesteePatch', {}, deleting))
116
+ /* The picked counterparty goes as its id. */
117
+ const shape = ({ counterparty, ...patch }) => (counterparty === undefined ? patch : { ...patch, counterpartyId: counterparty?.id ?? null });
118
+ if (await saveGrid(this.grist, FIELDS, 'updateMultipleInvestee', 'InvesteePatch', {}, deleting, shape))
116
119
  this.grist.fetch();
117
120
  }
118
121
  };
@@ -1 +1 @@
1
- {"version":3,"file":"investment-list.js","sourceRoot":"","sources":["../../client/pages/investment-list.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,wCAAwC,CAAA;AAE/C,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE/D,OAAO,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AACnI,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEhE,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAA;AAEtK;;;GAGG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ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AAc,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;SACpI,CAAA;IACH,CAAC;IAEO,KAAK,CAAC,IAAI,CAAC,QAAQ,GAAG,KAAK;QACjC,IAAI,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,wBAAwB,EAAE,eAAe,EAAE,EAAE,EAAE,QAAQ,CAAC;YAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACrH,CAAC;;AApGQ;IAAR,KAAK,EAAE;;mDAAiB;AACE;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;6CAAA;AAJjC,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CAwG1B","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 } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { navigate, PageView } from '@operato/shell'\nimport { CommonButtonStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\nimport { isMobileDevice } from '@operato/utils'\n\nimport { saveGrid } from '../grid.js'\nimport { amountText, fieldWord, percentText } from '../words.js'\n\nconst FIELDS = ['name', 'counterpartyId', 'country', 'registrationNo', 'currency', 'fiscalYearEndMonth', 'reportDueMonths', 'representative', 'active', 'description']\n\n/**\n * 보유 지분 — the companies the domain holds shares in (ADR-0175 decision 6), with where each holding stands now. A\n * company opens to its holding day by day, its reports, what it asked of us and what the law asks of us.\n */\n@customElement('investment-list')\nexport class InvestmentList extends localize(i18next)(PageView) {\n static styles = [WorkSurfacePageStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles]\n\n @state() gristConfig: any\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t('title.investment-list'),\n search: { handler: (search: string) => (this.grist.searchText = search), value: this.grist?.searchText || '' },\n filter: { handler: () => this.grist.toggleHeadroom() },\n actions: [\n { title: i18next.t('button.add'), icon: 'add', action: () => this.grist.addRecordToTop({ currency: 'KRW', active: true }) },\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: i18next.t('title.investment-list'), 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 /** Counterparties to pick the company from - which one, nothing about it. */\n private async counterparties(): Promise<{ value: string; display: string }[]> {\n try {\n const response = await client.query({\n query: gql`\n query {\n counterpartyChoices(pagination: { page: 1, limit: 500 }) { items { id name } }\n }\n `,\n fetchPolicy: 'network-only'\n })\n return [{ value: '', display: '' }, ...(response.data?.counterpartyChoices?.items ?? []).map((one: any) => ({ value: one.id, display: one.name }))]\n } catch {\n return [{ value: '', display: '' }]\n }\n }\n\n async pageInitialized() {\n const editable = { editable: true }\n const text = (name: string, width: number, extra: any = {}) => ({ type: 'string', name, header: fieldWord('investee', name), width, sortable: true, ...extra, record: { ...editable, ...extra.record } })\n const int = (name: string, width: number) => ({ type: 'integer', name, header: fieldWord('investee', name), width, record: { ...editable, align: 'right' } })\n const shown = (name: string, width: number, renderer: (value: any) => string) => ({ type: 'float', name, header: fieldWord('investee', name), width, record: { align: 'right', renderer } })\n const open = (record: any) => record?.id && navigate(`investee-page?id=${record.id}`)\n this.gristConfig = {\n rows: { appendable: true, selectable: { multiple: true } },\n pagination: { limit: 100, pages: [50, 100] },\n emptyNote: { title: i18next.t('text.investee-empty'), description: i18next.t('text.investee-empty-description') },\n list: { fields: ['name', 'ratio'], details: ['ourShares', 'totalShares'] },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { 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 text('name', 180, { record: { mandatory: true } }),\n { type: 'select', name: 'counterpartyId', header: fieldWord('investee', 'counterparty'), width: 160, record: { ...editable, options: await this.counterparties() } },\n shown('ourShares', 100, value => amountText(value)),\n shown('totalShares', 110, value => amountText(value)),\n shown('ratio', 80, value => percentText(value)),\n text('country', 60, { record: { align: 'center' } }),\n text('registrationNo', 140),\n text('currency', 60, { record: { align: 'center' } }),\n int('fiscalYearEndMonth', 80),\n int('reportDueMonths', 80),\n text('representative', 120),\n { type: 'checkbox', name: 'active', header: fieldWord('investee', 'active'), width: 60, record: editable },\n text('description', 200)\n ],\n sorters: [{ name: 'name' }]\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [], search }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $search: String) {\n responses: investees(filters: $filters, pagination: $pagination, sortings: $sortings, search: $search) {\n items {\n id name counterparty { id } country registrationNo currency fiscalYearEndMonth reportDueMonths representative active description\n ourShares totalShares ratio\n }\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 {\n total: response.data.responses.total,\n records: response.data.responses.items.map(({ counterparty, ...one }: any) => ({ ...one, counterpartyId: counterparty?.id ?? '' }))\n }\n }\n\n private async save(deleting = false) {\n if (await saveGrid(this.grist, FIELDS, 'updateMultipleInvestee', 'InvesteePatch', {}, deleting)) this.grist.fetch()\n }\n}\n"]}
1
+ {"version":3,"file":"investment-list.js","sourceRoot":"","sources":["../../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;6CAAA;AAJjC,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CA2G1B","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 { navigate, PageView } from '@operato/shell'\nimport { CommonButtonStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\nimport { isMobileDevice } from '@operato/utils'\n\nimport { saveGrid } from '../grid.js'\nimport { amountText, fieldWord, percentText } from '../words.js'\n\nconst FIELDS = ['name', 'counterparty', 'country', 'registrationNo', 'currency', 'fiscalYearEndMonth', 'reportDueMonths', 'representative', 'active', 'description']\n\n/**\n * 보유 지분 — the companies the domain holds shares in (ADR-0175 decision 6), with where each holding stands now. A\n * company opens to its holding day by day, its reports, what it asked of us and what the law asks of us.\n */\n@customElement('investment-list')\nexport class InvestmentList extends localize(i18next)(PageView) {\n static styles = [WorkSurfacePageStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles]\n\n @state() gristConfig: any\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t('title.investment-list'),\n search: { handler: (search: string) => (this.grist.searchText = search), value: this.grist?.searchText || '' },\n filter: { handler: () => this.grist.toggleHeadroom() },\n actions: [\n { title: i18next.t('button.add'), icon: 'add', action: () => this.grist.addRecordToTop({ currency: 'KRW', active: true }) },\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: i18next.t('title.investment-list'), 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: true }\n const text = (name: string, width: number, extra: any = {}) => ({ type: 'string', name, header: fieldWord('investee', name), width, sortable: true, ...extra, record: { ...editable, ...extra.record } })\n const int = (name: string, width: number) => ({ type: 'integer', name, header: fieldWord('investee', name), width, record: { ...editable, align: 'right' } })\n const shown = (name: string, width: number, renderer: (value: any) => string) => ({ type: 'float', name, header: fieldWord('investee', name), width, record: { align: 'right', renderer } })\n const open = (record: any) => record?.id && navigate(`investee-page?id=${record.id}`)\n this.gristConfig = {\n rows: { appendable: true, selectable: { multiple: true } },\n pagination: { limit: 100, pages: [50, 100] },\n emptyNote: { title: i18next.t('text.investee-empty'), description: i18next.t('text.investee-empty-description') },\n list: { fields: ['name', 'ratio'], details: ['ourShares', 'totalShares'] },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { 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 text('name', 180, { record: { mandatory: true } }),\n /* Picked in the framework's resource picker - searched by name or business number, which one and nothing about it. */\n {\n type: 'object',\n name: 'counterparty',\n header: fieldWord('investee', 'counterparty'),\n width: 160,\n record: {\n ...editable,\n editor: getEditor('resource-object'),\n options: {\n queryName: 'counterpartyChoices',\n select: [\n { name: 'id', hidden: true },\n { name: 'name', header: fieldWord('investee', 'counterparty'), width: 220 },\n { name: 'businessNumber', header: fieldWord('investee', 'business-number'), width: 130 }\n ]\n }\n }\n },\n shown('ourShares', 100, value => amountText(value)),\n shown('totalShares', 110, value => amountText(value)),\n shown('ratio', 80, value => percentText(value)),\n text('country', 60, { record: { align: 'center' } }),\n text('registrationNo', 140),\n text('currency', 60, { record: { align: 'center' } }),\n int('fiscalYearEndMonth', 80),\n int('reportDueMonths', 80),\n text('representative', 120),\n { type: 'checkbox', name: 'active', header: fieldWord('investee', 'active'), width: 60, record: editable },\n text('description', 200)\n ],\n sorters: [{ name: 'name' }]\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [], search }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $search: String) {\n responses: investees(filters: $filters, pagination: $pagination, sortings: $sortings, search: $search) {\n items {\n id name counterparty { id name } country registrationNo currency fiscalYearEndMonth reportDueMonths representative active description\n ourShares totalShares ratio\n }\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 {\n total: response.data.responses.total,\n records: response.data.responses.items\n }\n }\n\n private async save(deleting = false) {\n /* The picked counterparty goes as its id. */\n const shape = ({ counterparty, ...patch }: any) => (counterparty === undefined ? patch : { ...patch, counterpartyId: counterparty?.id ?? null })\n if (await saveGrid(this.grist, FIELDS, 'updateMultipleInvestee', 'InvesteePatch', {}, deleting, shape)) this.grist.fetch()\n }\n}\n"]}