@things-factory/pdf 10.1.255 → 10.1.257

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.
@@ -40,7 +40,9 @@ export declare class IssueDocumentForm extends IssueDocumentForm_base {
40
40
  withAsOf: boolean;
41
41
  private purpose;
42
42
  private submittedTo;
43
- private busy;
43
+ private previewing;
44
+ private issuing;
45
+ private get busy();
44
46
  render(): import("lit-html").TemplateResult<1>;
45
47
  private get variables();
46
48
  /** The document as it would be issued with what is written now - unnumbered and marked as a preview, kept nowhere. */
@@ -4,7 +4,7 @@ import '@material/web/button/outlined-button.js';
4
4
  import gql from 'graphql-tag';
5
5
  import { css, html, LitElement } from 'lit';
6
6
  import { customElement, property, state } from 'lit/decorators.js';
7
- import { client } from '@operato/graphql';
7
+ import { client, MutationController } from '@operato/graphql';
8
8
  import { i18next, localize } from '@operato/i18n';
9
9
  import { notify, openPopup } from '@operato/layout';
10
10
  /** A kind as its owning module words it - `issued-document.<kind>` in that module's translations. */
@@ -54,7 +54,20 @@ let IssueDocumentForm = class IssueDocumentForm extends localize(i18next)(LitEle
54
54
  this.withAsOf = false;
55
55
  this.purpose = '';
56
56
  this.submittedTo = '';
57
- this.busy = false;
57
+ /* A preview being printed - a read on demand, opened once it is back. */
58
+ this.previewing = false;
59
+ this.issuing = new MutationController(this, gql `
60
+ mutation ($kind: String!, $refId: String, $input: IssueDocumentInput) {
61
+ issueDocument(kind: $kind, refId: $refId, input: $input) {
62
+ id
63
+ number
64
+ file {
65
+ fullpath
66
+ name
67
+ }
68
+ }
69
+ }
70
+ `);
58
71
  }
59
72
  static { this.styles = css `
60
73
  :host {
@@ -87,6 +100,9 @@ let IssueDocumentForm = class IssueDocumentForm extends localize(i18next)(LitEle
87
100
  gap: var(--spacing-medium, 8px);
88
101
  }
89
102
  `; }
103
+ get busy() {
104
+ return this.previewing || this.issuing.pending;
105
+ }
90
106
  render() {
91
107
  return html `
92
108
  ${this.withAsOf
@@ -105,7 +121,7 @@ let IssueDocumentForm = class IssueDocumentForm extends localize(i18next)(LitEle
105
121
  }
106
122
  /** The document as it would be issued with what is written now - unnumbered and marked as a preview, kept nowhere. */
107
123
  async preview() {
108
- this.busy = true;
124
+ this.previewing = true;
109
125
  try {
110
126
  const response = await client.query({
111
127
  query: gql `
@@ -127,31 +143,15 @@ let IssueDocumentForm = class IssueDocumentForm extends localize(i18next)(LitEle
127
143
  notify({ level: 'error', message: error?.message ?? String(error) });
128
144
  }
129
145
  finally {
130
- this.busy = false;
146
+ this.previewing = false;
131
147
  }
132
148
  }
133
149
  async issue() {
134
- this.busy = true;
150
+ const issued = (await this.issuing.run(this.variables))?.issueDocument;
151
+ if (!issued)
152
+ return;
153
+ notify({ message: i18next.t('text.issued-document-issued', { number: issued.number }) });
135
154
  try {
136
- const response = await client.mutate({
137
- mutation: gql `
138
- mutation ($kind: String!, $refId: String, $input: IssueDocumentInput) {
139
- issueDocument(kind: $kind, refId: $refId, input: $input) {
140
- id
141
- number
142
- file {
143
- fullpath
144
- name
145
- }
146
- }
147
- }
148
- `,
149
- variables: this.variables
150
- });
151
- if (response.errors?.length)
152
- throw response.errors[0];
153
- const issued = response.data.issueDocument;
154
- notify({ message: i18next.t('text.issued-document-issued', { number: issued.number }) });
155
155
  if (issued.file?.fullpath)
156
156
  await downloadIssuedFile(issued.file);
157
157
  this.dispatchEvent(new CustomEvent('issued', { detail: issued }));
@@ -159,9 +159,6 @@ let IssueDocumentForm = class IssueDocumentForm extends localize(i18next)(LitEle
159
159
  catch (error) {
160
160
  notify({ level: 'error', message: error?.message ?? String(error) });
161
161
  }
162
- finally {
163
- this.busy = false;
164
- }
165
162
  }
166
163
  };
167
164
  __decorate([
@@ -191,7 +188,7 @@ __decorate([
191
188
  __decorate([
192
189
  state(),
193
190
  __metadata("design:type", Object)
194
- ], IssueDocumentForm.prototype, "busy", void 0);
191
+ ], IssueDocumentForm.prototype, "previewing", void 0);
195
192
  IssueDocumentForm = __decorate([
196
193
  customElement('issue-document-form')
197
194
  ], IssueDocumentForm);
@@ -1 +1 @@
1
- {"version":3,"file":"issue-document.js","sourceRoot":"","sources":["../client/issue-document.ts"],"names":[],"mappings":";AAAA,OAAO,uCAAuC,CAAA;AAC9C,OAAO,yCAAyC,CAAA;AAEhD,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,MAAM,mBAAmB,CAAA;AAElE,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;AAEnD,qGAAqG;AACrG,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,IAAoB,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;AAI1I;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAgD;IACvF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,CAAA;IAC3E,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;IAC9E,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;IACtD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ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AAM,CAAC,IAAI,CAAC,CAAA;YAChE,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;QACnE,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QACtE,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,IAAI,GAAG,KAAK,CAAA;QACnB,CAAC;IACH,CAAC;;AA/EW;IAAX,QAAQ,EAAE;;+CAAU;AACT;IAAX,QAAQ,EAAE;;gDAAW;AACV;IAAX,QAAQ,EAAE;;+CAAU;AACQ;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;mDAAiB;AAC5B;IAAhB,KAAK,EAAE;;kDAAqB;AACZ;IAAhB,KAAK,EAAE;;sDAAyB;AAChB;IAAhB,KAAK,EAAE;;+CAAqB;AAvClB,iBAAiB;IAD7B,aAAa,CAAC,qBAAqB,CAAC;GACxB,iBAAiB,CAiH7B","sourcesContent":["import '@material/web/button/filled-button.js'\nimport '@material/web/button/outlined-button.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\n\n/** A kind as its owning module words it - `issued-document.<kind>` in that module's translations. */\nexport const issuedDocumentKindWord = (kind?: string | null) => (kind ? i18next.t(`issued-document.${kind}`, { defaultValue: kind }) : '')\n\nexport type IssuedDocument = { id: string; number: string; file?: { fullpath: string; name?: string | null } | null }\n\n/**\n * Save an issued file under its own name - `재직증명서_남종호_재직-2026-0001.pdf` - not the storage path the address\n * carries. The file is fetched with the session and handed to the browser as a download.\n */\nexport async function downloadIssuedFile(file: { fullpath: string; name?: string | null }): Promise<void> {\n const response = await fetch(file.fullpath, { credentials: 'same-origin' })\n if (!response.ok) throw new Error(`${response.status} ${response.statusText}`)\n const url = URL.createObjectURL(await response.blob())\n const link = Object.assign(document.createElement('a'), { href: url, download: file.name || file.fullpath.split('/').pop() || 'document.pdf' })\n document.body.appendChild(link)\n link.click()\n link.remove()\n setTimeout(() => URL.revokeObjectURL(url), 1000)\n}\n\n/** A PDF in a large popup - an issued file at its address, or a preview just printed. */\nexport function openPdfView(src: string, title: string) {\n return openPopup(html`<iframe title=${title} src=${src} style=\"display: block; width: 100%; height: 80vh; border: 0\"></iframe>`, { backdrop: true, size: 'large', title })\n}\n\n/**\n * Ask for what an issue needs - its purpose and where it goes, and the day it speaks of when the kind has one - then issue\n * it (`issueDocument`, ADR-0176) and open the file. Resolves with the issued row, or null when the person closed it.\n */\nexport function issueDocument(options: { kind: string; refId?: string; asOf?: string; withAsOf?: boolean }): Promise<IssuedDocument | null> {\n return new Promise(resolve => {\n let done: IssuedDocument | null = null\n const popup = openPopup(\n html`<issue-document-form\n .kind=${options.kind}\n .refId=${options.refId ?? ''}\n .asOf=${options.asOf ?? ''}\n .withAsOf=${!!options.withAsOf}\n @issued=${(e: CustomEvent) => ((done = e.detail), popup.close())}\n ></issue-document-form>`,\n { backdrop: true, size: 'small', title: i18next.t('title.issue-document', { kind: issuedDocumentKindWord(options.kind) }) }\n )\n popup.onclosed = () => resolve(done)\n })\n}\n\n@customElement('issue-document-form')\nexport class IssueDocumentForm extends localize(i18next)(LitElement) {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-medium, 8px);\n padding: var(--spacing-large, 12px);\n background-color: var(--md-sys-color-surface);\n }\n label {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-small, 4px);\n font: var(--label-font);\n color: var(--md-sys-color-on-surface);\n }\n input {\n box-sizing: border-box;\n width: 100%;\n background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n color: var(--input-field-color, var(--md-sys-color-on-surface));\n border: var(--border-dim-color);\n border-radius: var(--border-radius);\n padding: var(--input-padding);\n font: var(--input-font);\n }\n div[actions] {\n display: flex;\n justify-content: flex-end;\n gap: var(--spacing-medium, 8px);\n }\n `\n\n @property() kind = ''\n @property() refId = ''\n @property() asOf = ''\n @property({ type: Boolean }) withAsOf = false\n @state() private purpose = ''\n @state() private submittedTo = ''\n @state() private busy = false\n\n render() {\n return html`\n ${this.withAsOf\n ? html`<label>${i18next.t('field.issue-as-of')}<input type=\"date\" .value=${this.asOf} @input=${(e: any) => (this.asOf = e.target.value)} /></label>`\n : ''}\n <label>${i18next.t('field.issued-document-purpose')}<input .value=${this.purpose} @input=${(e: any) => (this.purpose = e.target.value)} /></label>\n <label>${i18next.t('field.issued-document-submitted-to')}<input .value=${this.submittedTo} @input=${(e: any) => (this.submittedTo = e.target.value)} /></label>\n <div actions>\n <md-outlined-button ?disabled=${this.busy} @click=${() => this.preview()}>${i18next.t('button.pdf-preview')}</md-outlined-button>\n <md-filled-button ?disabled=${this.busy} @click=${() => this.issue()}>${i18next.t('button.issue-document')}</md-filled-button>\n </div>\n `\n }\n\n private get variables() {\n return { kind: this.kind, refId: this.refId || null, input: { purpose: this.purpose, submittedTo: this.submittedTo, asOf: this.withAsOf ? this.asOf || null : null } }\n }\n\n /** The document as it would be issued with what is written now - unnumbered and marked as a preview, kept nowhere. */\n private async preview() {\n this.busy = true\n try {\n const response = await client.query({\n query: gql`\n query ($kind: String!, $refId: String, $input: IssueDocumentInput) {\n previewIssuedDocument(kind: $kind, refId: $refId, input: $input)\n }\n `,\n variables: this.variables,\n fetchPolicy: 'no-cache'\n })\n if (response.errors?.length) throw response.errors[0]\n const bytes = Uint8Array.from(atob(response.data.previewIssuedDocument), c => c.charCodeAt(0))\n const url = URL.createObjectURL(new Blob([bytes], { type: 'application/pdf' }))\n const popup = openPdfView(url, `${i18next.t('button.pdf-preview')} · ${issuedDocumentKindWord(this.kind)}`)\n popup.onclosed = () => URL.revokeObjectURL(url)\n } catch (error: any) {\n notify({ level: 'error', message: error?.message ?? String(error) })\n } finally {\n this.busy = false\n }\n }\n\n private async issue() {\n this.busy = true\n try {\n const response = await client.mutate({\n mutation: gql`\n mutation ($kind: String!, $refId: String, $input: IssueDocumentInput) {\n issueDocument(kind: $kind, refId: $refId, input: $input) {\n id\n number\n file {\n fullpath\n name\n }\n }\n }\n `,\n variables: this.variables\n })\n if (response.errors?.length) throw response.errors[0]\n const issued: IssuedDocument = response.data.issueDocument\n notify({ message: i18next.t('text.issued-document-issued', { number: issued.number }) })\n if (issued.file?.fullpath) await downloadIssuedFile(issued.file)\n this.dispatchEvent(new CustomEvent('issued', { detail: issued }))\n } catch (error: any) {\n notify({ level: 'error', message: error?.message ?? String(error) })\n } finally {\n this.busy = false\n }\n }\n}\n"]}
1
+ {"version":3,"file":"issue-document.js","sourceRoot":"","sources":["../client/issue-document.ts"],"names":[],"mappings":";AAAA,OAAO,uCAAuC,CAAA;AAC9C,OAAO,yCAAyC,CAAA;AAEhD,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,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEnD,qGAAqG;AACrG,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,IAAoB,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,C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 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { client, MutationController } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\n\n/** A kind as its owning module words it - `issued-document.<kind>` in that module's translations. */\nexport const issuedDocumentKindWord = (kind?: string | null) => (kind ? i18next.t(`issued-document.${kind}`, { defaultValue: kind }) : '')\n\nexport type IssuedDocument = { id: string; number: string; file?: { fullpath: string; name?: string | null } | null }\n\n/**\n * Save an issued file under its own name - `재직증명서_남종호_재직-2026-0001.pdf` - not the storage path the address\n * carries. The file is fetched with the session and handed to the browser as a download.\n */\nexport async function downloadIssuedFile(file: { fullpath: string; name?: string | null }): Promise<void> {\n const response = await fetch(file.fullpath, { credentials: 'same-origin' })\n if (!response.ok) throw new Error(`${response.status} ${response.statusText}`)\n const url = URL.createObjectURL(await response.blob())\n const link = Object.assign(document.createElement('a'), { href: url, download: file.name || file.fullpath.split('/').pop() || 'document.pdf' })\n document.body.appendChild(link)\n link.click()\n link.remove()\n setTimeout(() => URL.revokeObjectURL(url), 1000)\n}\n\n/** A PDF in a large popup - an issued file at its address, or a preview just printed. */\nexport function openPdfView(src: string, title: string) {\n return openPopup(html`<iframe title=${title} src=${src} style=\"display: block; width: 100%; height: 80vh; border: 0\"></iframe>`, { backdrop: true, size: 'large', title })\n}\n\n/**\n * Ask for what an issue needs - its purpose and where it goes, and the day it speaks of when the kind has one - then issue\n * it (`issueDocument`, ADR-0176) and open the file. Resolves with the issued row, or null when the person closed it.\n */\nexport function issueDocument(options: { kind: string; refId?: string; asOf?: string; withAsOf?: boolean }): Promise<IssuedDocument | null> {\n return new Promise(resolve => {\n let done: IssuedDocument | null = null\n const popup = openPopup(\n html`<issue-document-form\n .kind=${options.kind}\n .refId=${options.refId ?? ''}\n .asOf=${options.asOf ?? ''}\n .withAsOf=${!!options.withAsOf}\n @issued=${(e: CustomEvent) => ((done = e.detail), popup.close())}\n ></issue-document-form>`,\n { backdrop: true, size: 'small', title: i18next.t('title.issue-document', { kind: issuedDocumentKindWord(options.kind) }) }\n )\n popup.onclosed = () => resolve(done)\n })\n}\n\n@customElement('issue-document-form')\nexport class IssueDocumentForm extends localize(i18next)(LitElement) {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-medium, 8px);\n padding: var(--spacing-large, 12px);\n background-color: var(--md-sys-color-surface);\n }\n label {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-small, 4px);\n font: var(--label-font);\n color: var(--md-sys-color-on-surface);\n }\n input {\n box-sizing: border-box;\n width: 100%;\n background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n color: var(--input-field-color, var(--md-sys-color-on-surface));\n border: var(--border-dim-color);\n border-radius: var(--border-radius);\n padding: var(--input-padding);\n font: var(--input-font);\n }\n div[actions] {\n display: flex;\n justify-content: flex-end;\n gap: var(--spacing-medium, 8px);\n }\n `\n\n @property() kind = ''\n @property() refId = ''\n @property() asOf = ''\n @property({ type: Boolean }) withAsOf = false\n @state() private purpose = ''\n @state() private submittedTo = ''\n /* A preview being printed - a read on demand, opened once it is back. */\n @state() private previewing = false\n private issuing = new MutationController<{ issueDocument: IssuedDocument }>(\n this,\n gql`\n mutation ($kind: String!, $refId: String, $input: IssueDocumentInput) {\n issueDocument(kind: $kind, refId: $refId, input: $input) {\n id\n number\n file {\n fullpath\n name\n }\n }\n }\n `\n )\n\n private get busy() {\n return this.previewing || this.issuing.pending\n }\n\n render() {\n return html`\n ${this.withAsOf\n ? html`<label>${i18next.t('field.issue-as-of')}<input type=\"date\" .value=${this.asOf} @input=${(e: any) => (this.asOf = e.target.value)} /></label>`\n : ''}\n <label>${i18next.t('field.issued-document-purpose')}<input .value=${this.purpose} @input=${(e: any) => (this.purpose = e.target.value)} /></label>\n <label>${i18next.t('field.issued-document-submitted-to')}<input .value=${this.submittedTo} @input=${(e: any) => (this.submittedTo = e.target.value)} /></label>\n <div actions>\n <md-outlined-button ?disabled=${this.busy} @click=${() => this.preview()}>${i18next.t('button.pdf-preview')}</md-outlined-button>\n <md-filled-button ?disabled=${this.busy} @click=${() => this.issue()}>${i18next.t('button.issue-document')}</md-filled-button>\n </div>\n `\n }\n\n private get variables() {\n return { kind: this.kind, refId: this.refId || null, input: { purpose: this.purpose, submittedTo: this.submittedTo, asOf: this.withAsOf ? this.asOf || null : null } }\n }\n\n /** The document as it would be issued with what is written now - unnumbered and marked as a preview, kept nowhere. */\n private async preview() {\n this.previewing = true\n try {\n const response = await client.query({\n query: gql`\n query ($kind: String!, $refId: String, $input: IssueDocumentInput) {\n previewIssuedDocument(kind: $kind, refId: $refId, input: $input)\n }\n `,\n variables: this.variables,\n fetchPolicy: 'no-cache'\n })\n if (response.errors?.length) throw response.errors[0]\n const bytes = Uint8Array.from(atob(response.data.previewIssuedDocument), c => c.charCodeAt(0))\n const url = URL.createObjectURL(new Blob([bytes], { type: 'application/pdf' }))\n const popup = openPdfView(url, `${i18next.t('button.pdf-preview')} · ${issuedDocumentKindWord(this.kind)}`)\n popup.onclosed = () => URL.revokeObjectURL(url)\n } catch (error: any) {\n notify({ level: 'error', message: error?.message ?? String(error) })\n } finally {\n this.previewing = false\n }\n }\n\n private async issue() {\n const issued = (await this.issuing.run(this.variables))?.issueDocument\n if (!issued) return\n notify({ message: i18next.t('text.issued-document-issued', { number: issued.number }) })\n try {\n if (issued.file?.fullpath) await downloadIssuedFile(issued.file)\n this.dispatchEvent(new CustomEvent('issued', { detail: issued }))\n } catch (error: any) {\n notify({ level: 'error', message: error?.message ?? String(error) })\n }\n }\n}\n"]}
@@ -17,18 +17,18 @@ export declare class IssuedDocumentList extends IssuedDocumentList_base {
17
17
  protected mine: boolean;
18
18
  static styles: import("lit").CSSResult[];
19
19
  private gristConfig;
20
- private kinds;
21
- private issuable;
20
+ private kindsRead;
22
21
  private kind;
23
22
  private states;
24
- /** How many documents each state chip would show under the other conditions, counted by the list's own door. */
25
- private stateCounts;
26
23
  private from;
27
24
  private to;
28
25
  private selected;
29
26
  private reason;
30
- private busy;
27
+ private revoking;
31
28
  private grist;
29
+ private get kinds();
30
+ private get issuable();
31
+ private get busy();
32
32
  get context(): {
33
33
  title: string;
34
34
  actions: {
@@ -44,11 +44,16 @@ export declare class IssuedDocumentList extends IssuedDocumentList_base {
44
44
  render(): import("lit-html").TemplateResult<1>;
45
45
  pageInitialized(): Promise<void>;
46
46
  pageUpdated(changes: any): Promise<void>;
47
+ private conditions;
47
48
  fetchHandler({ page, limit }: FetchOption): Promise<{
48
49
  total: any;
49
50
  records: any;
50
51
  }>;
51
- private countStates;
52
+ countHandler({ signal }: FetchOption): Promise<{
53
+ state: {
54
+ [k: string]: any;
55
+ };
56
+ }>;
52
57
  private select;
53
58
  private revoke;
54
59
  }
@@ -8,7 +8,7 @@ import gql from 'graphql-tag';
8
8
  import { css, html, nothing } from 'lit';
9
9
  import { customElement, query, state } from 'lit/decorators.js';
10
10
  import { DataGrist } from '@operato/data-grist';
11
- import { client } from '@operato/graphql';
11
+ import { client, MutationController, QueryController } from '@operato/graphql';
12
12
  import { i18next, localize } from '@operato/i18n';
13
13
  import { notify } from '@operato/layout';
14
14
  import { PageView } from '@operato/shell';
@@ -26,19 +26,23 @@ let IssuedDocumentList = class IssuedDocumentList extends localize(i18next)(Page
26
26
  super(...arguments);
27
27
  /** 내 증명서: one's own - about oneself or issued by oneself - and the documents one issues here. Else the whole ledger. */
28
28
  this.mine = false;
29
- this.kinds = [];
30
- this.issuable = [];
29
+ /* The kinds this person may read, and the ones they issue here (ADR-0190). */
30
+ this.kindsRead = new QueryController(this, gql `query { issuedDocumentKinds { kind asOf issuable refId } }`);
31
31
  this.kind = '';
32
32
  /* 발급 · 취소 - none chosen is both. */
33
33
  this.states = [];
34
- /** How many documents each state chip would show under the other conditions, counted by the list's own door. */
35
- this.stateCounts = new Map();
36
34
  /* The days issued on, 'YYYY-MM-DD', either end open. */
37
35
  this.from = '';
38
36
  this.to = '';
39
37
  this.selected = null;
40
38
  this.reason = '';
41
- this.busy = false;
39
+ this.revoking = new MutationController(this, gql `
40
+ mutation ($id: String!, $reason: String!) {
41
+ revokeIssuedDocument(id: $id, reason: $reason) {
42
+ id
43
+ }
44
+ }
45
+ `);
42
46
  }
43
47
  static { this.styles = [
44
48
  WorkSurfacePageStyles,
@@ -101,6 +105,15 @@ let IssuedDocumentList = class IssuedDocumentList extends localize(i18next)(Page
101
105
  }
102
106
  `
103
107
  ]; }
108
+ get kinds() {
109
+ return (this.kindsRead.data?.issuedDocumentKinds ?? []).map(one => one.kind);
110
+ }
111
+ get issuable() {
112
+ return (this.kindsRead.data?.issuedDocumentKinds ?? []).filter(one => one.issuable);
113
+ }
114
+ get busy() {
115
+ return this.revoking.pending;
116
+ }
104
117
  get context() {
105
118
  return {
106
119
  title: i18next.t(this.mine ? 'title.my-issued-documents' : 'title.issued-document-list'),
@@ -140,7 +153,7 @@ let IssuedDocumentList = class IssuedDocumentList extends localize(i18next)(Page
140
153
  >${i18next.t('field.state')}
141
154
  <ox-input-select-buttons
142
155
  multiple
143
- .options=${['published', 'revoked'].map(value => ({ value, display: i18next.t(`text.issued-document-${value}`), count: this.stateCounts.get(value) ?? 0 }))}
156
+ .options=${['published', 'revoked'].map(value => ({ value, display: i18next.t(`text.issued-document-${value}`), count: this.grist?.counts?.state?.[value] ?? 0 }))}
144
157
  .value=${this.states}
145
158
  @change=${(e) => ((this.states = e.target.value ?? []), this.grist.fetch())}
146
159
  ></ox-input-select-buttons>
@@ -152,7 +165,7 @@ let IssuedDocumentList = class IssuedDocumentList extends localize(i18next)(Page
152
165
  <input type="date" .value=${this.to} @change=${(e) => ((this.to = e.target.value), this.grist.fetch())} />
153
166
  </label>
154
167
  </div>
155
- <ox-grist .mode=${'GRID'} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)} @select-record-change=${(e) => this.select(e.detail?.records)}></ox-grist>
168
+ <ox-grist .mode=${'GRID'} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)} .countHandler=${this.countHandler.bind(this)} @counts-change=${() => this.requestUpdate()} @select-record-change=${(e) => this.select(e.detail?.records)}></ox-grist>
156
169
  ${row && row.state === 'published'
157
170
  ? html `<div class="revoke">
158
171
  ${i18next.t('text.issued-document-revoke', { number: row.number })}
@@ -203,17 +216,13 @@ let IssuedDocumentList = class IssuedDocumentList extends localize(i18next)(Page
203
216
  ],
204
217
  rows: { appendable: false, selectable: { multiple: false } }
205
218
  };
206
- const response = await client.query({ query: gql `query { issuedDocumentKinds { kind asOf issuable refId } }`, fetchPolicy: 'no-cache' });
207
- const kinds = response.data?.issuedDocumentKinds ?? [];
208
- this.kinds = kinds.map((one) => one.kind);
209
- this.issuable = kinds.filter((one) => one.issuable);
210
- this.updateContext();
211
219
  }
212
220
  async pageUpdated(changes) {
213
221
  if (this.active && changes.active && this.grist)
214
222
  this.grist.fetch();
215
223
  }
216
- async fetchHandler({ page = 1, limit = 100 }) {
224
+ /* The list's conditions other than the state: the kind, the days issued on and the search. */
225
+ conditions() {
217
226
  const filters = [];
218
227
  if (this.kind)
219
228
  filters.push({ name: 'kind', operator: 'eq', value: this.kind });
@@ -221,7 +230,10 @@ let IssuedDocumentList = class IssuedDocumentList extends localize(i18next)(Page
221
230
  filters.push({ name: 'createdAt', operator: 'between', value: [this.from, this.to] });
222
231
  if (this.grist?.searchText)
223
232
  filters.push({ name: 'q', operator: 'search', value: this.grist.searchText });
224
- this.countStates(filters);
233
+ return filters;
234
+ }
235
+ async fetchHandler({ page = 1, limit = 100 }) {
236
+ const filters = this.conditions();
225
237
  if (this.states.length)
226
238
  filters.push({ name: 'state', operator: 'in', value: this.states });
227
239
  const response = await client.query({
@@ -235,7 +247,8 @@ let IssuedDocumentList = class IssuedDocumentList extends localize(i18next)(Page
235
247
  return { total: response.data?.list?.total ?? 0, records: response.data?.list?.items ?? [] };
236
248
  }
237
249
  /* The state chips' numbers: the list's door totals each state under the other conditions, in one request. */
238
- async countStates(filters) {
250
+ async countHandler({ signal }) {
251
+ const filters = this.conditions();
239
252
  const list = this.mine ? 'readableIssuedDocuments' : 'issuedDocuments';
240
253
  const states = ['published', 'revoked'];
241
254
  const response = await client.query({
@@ -243,11 +256,12 @@ let IssuedDocumentList = class IssuedDocumentList extends localize(i18next)(Page
243
256
  .map((_, at) => `c${at}: ${list}(filters: $f${at}, pagination: { page: 1, limit: 1 }${this.mine ? ', mine: true' : ''}) { total }`)
244
257
  .join(' ')} }`),
245
258
  variables: Object.fromEntries(states.map((state, at) => [`f${at}`, [...filters, { name: 'state', operator: 'in', value: [state] }]])),
246
- fetchPolicy: 'no-cache'
259
+ fetchPolicy: 'no-cache',
260
+ context: { fetchOptions: { signal }, queryDeduplication: false }
247
261
  });
248
262
  if (response.errors?.length)
249
- return console.error(response.errors);
250
- this.stateCounts = new Map(states.map((state, at) => [state, response.data?.[`c${at}`]?.total ?? 0]));
263
+ throw response.errors[0];
264
+ return { state: Object.fromEntries(states.map((state, at) => [state, response.data?.[`c${at}`]?.total ?? 0])) };
251
265
  }
252
266
  select(records) {
253
267
  const row = records?.[0] ?? null;
@@ -256,43 +270,17 @@ let IssuedDocumentList = class IssuedDocumentList extends localize(i18next)(Page
256
270
  this.selected = row;
257
271
  }
258
272
  async revoke() {
259
- this.busy = true;
260
- try {
261
- const response = await client.mutate({
262
- mutation: gql `
263
- mutation ($id: String!, $reason: String!) {
264
- revokeIssuedDocument(id: $id, reason: $reason) {
265
- id
266
- }
267
- }
268
- `,
269
- variables: { id: this.selected.id, reason: this.reason }
270
- });
271
- if (response.errors?.length)
272
- throw response.errors[0];
273
- notify({ message: i18next.t('text.issued-document-revoked-done', { number: this.selected.number }) });
274
- this.grist.fetch();
275
- }
276
- catch (error) {
277
- notify({ level: 'error', message: error?.message ?? String(error) });
278
- }
279
- finally {
280
- this.busy = false;
281
- }
273
+ const { id, number } = this.selected;
274
+ if (!(await this.revoking.run({ id, reason: this.reason })))
275
+ return;
276
+ notify({ message: i18next.t('text.issued-document-revoked-done', { number }) });
277
+ this.grist.fetch();
282
278
  }
283
279
  };
284
280
  __decorate([
285
281
  state(),
286
282
  __metadata("design:type", Object)
287
283
  ], IssuedDocumentList.prototype, "gristConfig", void 0);
288
- __decorate([
289
- state(),
290
- __metadata("design:type", Array)
291
- ], IssuedDocumentList.prototype, "kinds", void 0);
292
- __decorate([
293
- state(),
294
- __metadata("design:type", Array)
295
- ], IssuedDocumentList.prototype, "issuable", void 0);
296
284
  __decorate([
297
285
  state(),
298
286
  __metadata("design:type", Object)
@@ -301,10 +289,6 @@ __decorate([
301
289
  state(),
302
290
  __metadata("design:type", Array)
303
291
  ], IssuedDocumentList.prototype, "states", void 0);
304
- __decorate([
305
- state(),
306
- __metadata("design:type", Object)
307
- ], IssuedDocumentList.prototype, "stateCounts", void 0);
308
292
  __decorate([
309
293
  state(),
310
294
  __metadata("design:type", Object)
@@ -321,10 +305,6 @@ __decorate([
321
305
  state(),
322
306
  __metadata("design:type", Object)
323
307
  ], IssuedDocumentList.prototype, "reason", void 0);
324
- __decorate([
325
- state(),
326
- __metadata("design:type", Object)
327
- ], IssuedDocumentList.prototype, "busy", void 0);
328
308
  __decorate([
329
309
  query('ox-grist'),
330
310
  __metadata("design:type", DataGrist)
@@ -1 +1 @@
1
- {"version":3,"file":"issued-document-list.js","sourceRoot":"","sources":["../../../client/pages/issued-document/issued-document-list.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,iCAAiC,CAAA;AACxC,OAAO,2CAA2C,CAAA;AAClD,OAAO,6BAA6B,CAAA;AACpC,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,MAAM,qBAAqB,CAAA;AAC5D,OAAO,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D;AAEvC;IAAhB,KAAK,EAAE;;gDAAkB;AACT;IAAhB,KAAK,EAAE;;8CAAgB;AACP;IAAhB,KAAK,EAAE;;oDAA6B;AACpB;IAAhB,KAAK,EAAE;;kDAAoB;AACX;IAAhB,KAAK,EAAE;;gDAAqB;AAEF;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;iDAAA;AAjFjC,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CAuQ9B;;AAED,qGAAqG;AAE9F,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,kBAAkB;IAArD;;QACK,SAAI,GAAG,IAAI,CAAA;IACvB,CAAC;CAAA,CAAA;AAFY,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,oBAAoB,CAEhC","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@operato/data-grist/ox-grist.js'\nimport '@operato/input/ox-input-select-buttons.js'\nimport '@operato/input/ox-select.js'\nimport '@operato/popup/ox-popup-list.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, nothing } 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 { notify } from '@operato/layout'\nimport { PageView } from '@operato/shell'\nimport { CommonGristStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\n\nimport { downloadIssuedFile, issueDocument, issuedDocumentKindWord as kindWord, openPdfView } from '../../issue-document'\n\nconst FIELDS = 'id kind number subjectName purpose submittedTo state revokedAt revokeReason createdAt creator { id name } file { id fullpath name }'\n\n/**\n * 발급 대장 (ADR-0176 decision 2) - the documents issued, newest first: kind, number, whom or what each is about, what\n * for and to whom, who issued it and when, and whether it was revoked. Each person sees the kinds their own rules let\n * them read (the server asks each kind's module) - an employee their own certificates - and issues here what is about\n * the company or about themselves. A file is saved as it was issued; a mistaken one is revoked with a reason.\n */\n@customElement('issued-document-list')\nexport class IssuedDocumentList extends localize(i18next)(PageView) {\n /** 내 증명서: one's own - about oneself or issued by oneself - and the documents one issues here. Else the whole ledger. */\n protected mine = false\n\n static styles = [\n WorkSurfacePageStyles,\n ScrollbarStyles,\n CommonGristStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n }\n ox-grist {\n flex: 1;\n }\n .filters {\n display: flex;\n flex-wrap: wrap;\n gap: var(--spacing-medium, 8px) var(--spacing-large, 12px);\n align-items: center;\n padding: var(--spacing-medium, 8px) var(--spacing-large, 12px);\n }\n .revoke {\n display: flex;\n flex-wrap: wrap;\n gap: var(--spacing-medium, 8px);\n align-items: center;\n padding: var(--spacing-medium, 8px) var(--spacing-large, 12px);\n border-top: var(--border-dim-color);\n font: var(--label-font);\n }\n .revoke input {\n flex: 1;\n min-width: 200px;\n background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n color: var(--input-field-color, var(--md-sys-color-on-surface));\n border: var(--border-dim-color);\n border-radius: var(--border-radius);\n padding: var(--input-padding);\n font: var(--input-font);\n }\n .filters input[type='date'] {\n background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n color: var(--input-field-color, var(--md-sys-color-on-surface));\n border: var(--border-dim-color);\n border-radius: var(--border-radius);\n padding: var(--input-padding);\n font: var(--input-font);\n }\n .filters label {\n display: flex;\n align-items: center;\n gap: var(--spacing-medium, 8px);\n font: var(--label-font);\n white-space: nowrap;\n }\n .filters ox-input-select-buttons {\n flex: none;\n }\n ox-select {\n min-width: 200px;\n }\n `\n ]\n\n @state() private gristConfig: any\n @state() private kinds: string[] = []\n @state() private issuable: { kind: string; asOf: boolean; refId?: string | null }[] = []\n @state() private kind = ''\n /* 발급 · 취소 - none chosen is both. */\n @state() private states: string[] = []\n /** How many documents each state chip would show under the other conditions, counted by the list's own door. */\n @state() private stateCounts = new Map<string, number>()\n /* The days issued on, 'YYYY-MM-DD', either end open. */\n @state() private from = ''\n @state() private to = ''\n @state() private selected: any = null\n @state() private reason = ''\n @state() private busy = false\n\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t(this.mine ? 'title.my-issued-documents' : 'title.issued-document-list'),\n /* Issued in 내 증명서: a document about oneself (one's 재직증명서), and one about the company itself (a 주주명부). */\n actions: (this.mine ? this.issuable : []).map(one => ({\n title: i18next.t('button.issue-kind', { kind: kindWord(one.kind) }),\n icon: 'workspace_premium',\n action: async () => (await issueDocument({ kind: one.kind, refId: one.refId ?? undefined, withAsOf: one.asOf })) && this.grist.fetch()\n })),\n search: { handler: (search: string) => ((this.grist.searchText = search), this.grist.fetch()), value: this.grist?.searchText }\n }\n }\n\n render() {\n const row = this.selected\n return html`\n <div class=\"filters\">\n ${this.kinds.length > 1\n ? html`<label\n >${i18next.t('field.issued-document-kind')}\n <ox-select\n .value=${this.kind}\n @change=${(e: CustomEvent) => {\n const next = String(e.detail ?? '')\n if (next !== this.kind) (this.kind = next), this.grist.fetch()\n }}\n >\n <span slot=\"label\">${this.kind ? kindWord(this.kind) : i18next.t('text.all')}</span>\n <ox-popup-list align-left nowrap with-search>\n <div option value=\"\">${i18next.t('text.all')}</div>\n ${this.kinds.map(kind => html`<div option value=${kind}>${kindWord(kind)}</div>`)}\n </ox-popup-list>\n </ox-select>\n </label>`\n : nothing}\n <label\n >${i18next.t('field.state')}\n <ox-input-select-buttons\n multiple\n .options=${['published', 'revoked'].map(value => ({ value, display: i18next.t(`text.issued-document-${value}`), count: this.stateCounts.get(value) ?? 0 }))}\n .value=${this.states}\n @change=${(e: CustomEvent) => ((this.states = (e.target as any).value ?? []), this.grist.fetch())}\n ></ox-input-select-buttons>\n </label>\n <label\n >${i18next.t('field.issued-document-issued-on')}\n <input type=\"date\" .value=${this.from} @change=${(e: any) => ((this.from = e.target.value), this.grist.fetch())} />\n ~\n <input type=\"date\" .value=${this.to} @change=${(e: any) => ((this.to = e.target.value), this.grist.fetch())} />\n </label>\n </div>\n <ox-grist .mode=${'GRID'} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)} @select-record-change=${(e: any) => this.select(e.detail?.records)}></ox-grist>\n ${row && row.state === 'published'\n ? html`<div class=\"revoke\">\n ${i18next.t('text.issued-document-revoke', { number: row.number })}\n <input .value=${this.reason} placeholder=${i18next.t('field.issued-document-revoke-reason')} ?disabled=${this.busy} @input=${(e: any) => (this.reason = e.target.value)} />\n <button danger ?disabled=${this.busy || !this.reason.trim()} @click=${() => this.revoke()}>${i18next.t('button.issued-document-revoke')}</button>\n </div>`\n : nothing}\n `\n }\n\n async pageInitialized() {\n this.gristConfig = {\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: false },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'download',\n title: i18next.t('button.issued-document-open'),\n handlers: {\n click: (_c: any, _d: any, _col: any, record: any) =>\n record?.file?.fullpath && downloadIssuedFile(record.file).catch((error: any) => notify({ level: 'error', message: error?.message ?? String(error) }))\n }\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'visibility',\n title: i18next.t('button.pdf-preview'),\n handlers: {\n /* The issued file itself, as it went out - its number and seal - opened in place under its own name. */\n click: (_c: any, _d: any, _col: any, record: any) => record?.file?.fullpath && openPdfView(record.file.fullpath, `${kindWord(record.kind)} · ${record.number}`)\n }\n },\n { type: 'string', name: 'number', header: i18next.t('field.issued-document-number'), width: 140 },\n { type: 'string', name: 'kind', header: i18next.t('field.issued-document-kind'), record: { renderer: (value: string) => kindWord(value) }, width: 140 },\n { type: 'string', name: 'subjectName', header: i18next.t('field.issued-document-subject'), width: 160 },\n { type: 'string', name: 'purpose', header: i18next.t('field.issued-document-purpose'), width: 160 },\n { type: 'string', name: 'submittedTo', header: i18next.t('field.issued-document-submitted-to'), width: 160 },\n { type: 'datetime', name: 'createdAt', header: i18next.t('field.issued-document-issued-at'), width: 160 },\n { type: 'resource-object', name: 'creator', header: i18next.t('field.issued-document-issuer'), width: 110 },\n {\n type: 'string',\n name: 'state',\n header: i18next.t('field.state'),\n record: { renderer: (value: string, _c: any, record: any) => (value === 'revoked' ? `${i18next.t('text.issued-document-revoked')} · ${record.revokeReason ?? ''}` : i18next.t('text.issued-document-published')) },\n width: 200\n }\n ],\n rows: { appendable: false, selectable: { multiple: false } }\n }\n const response = await client.query({ query: gql`query { issuedDocumentKinds { kind asOf issuable refId } }`, fetchPolicy: 'no-cache' })\n const kinds = response.data?.issuedDocumentKinds ?? []\n this.kinds = kinds.map((one: any) => one.kind)\n this.issuable = kinds.filter((one: any) => one.issuable)\n this.updateContext()\n }\n\n async pageUpdated(changes: any) {\n if ((this as any).active && changes.active && this.grist) this.grist.fetch()\n }\n\n async fetchHandler({ page = 1, limit = 100 }: FetchOption) {\n const filters: any[] = []\n if (this.kind) filters.push({ name: 'kind', operator: 'eq', value: this.kind })\n if (this.from || this.to) filters.push({ name: 'createdAt', operator: 'between', value: [this.from, this.to] })\n if (this.grist?.searchText) filters.push({ name: 'q', operator: 'search', value: this.grist.searchText })\n this.countStates(filters)\n if (this.states.length) filters.push({ name: 'state', operator: 'in', value: this.states })\n const response = await client.query({\n query: gql(\n this.mine\n ? `query ($filters: [Filter!], $pagination: Pagination) { list: readableIssuedDocuments(filters: $filters, pagination: $pagination, mine: true) { items { ${FIELDS} } total } }`\n : `query ($filters: [Filter!], $pagination: Pagination) { list: issuedDocuments(filters: $filters, pagination: $pagination) { items { ${FIELDS} } total } }`\n ),\n variables: { filters, pagination: { page, limit } },\n fetchPolicy: 'no-cache'\n })\n this.select([])\n return { total: response.data?.list?.total ?? 0, records: response.data?.list?.items ?? [] }\n }\n\n /* The state chips' numbers: the list's door totals each state under the other conditions, in one request. */\n private async countStates(filters: any[]) {\n const list = this.mine ? 'readableIssuedDocuments' : 'issuedDocuments'\n const states = ['published', 'revoked']\n const response = await client.query({\n query: gql(\n `query (${states.map((_, at) => `$f${at}: [Filter!]`).join(', ')}) { ${states\n .map((_, at) => `c${at}: ${list}(filters: $f${at}, pagination: { page: 1, limit: 1 }${this.mine ? ', mine: true' : ''}) { total }`)\n .join(' ')} }`\n ),\n variables: Object.fromEntries(states.map((state, at) => [`f${at}`, [...filters, { name: 'state', operator: 'in', value: [state] }]])),\n fetchPolicy: 'no-cache'\n })\n if (response.errors?.length) return console.error(response.errors)\n this.stateCounts = new Map(states.map((state, at) => [state, response.data?.[`c${at}`]?.total ?? 0]))\n }\n\n private select(records: any[] | undefined) {\n const row = records?.[0] ?? null\n if (row?.id !== this.selected?.id) this.reason = ''\n this.selected = row\n }\n\n private async revoke() {\n this.busy = true\n try {\n const response = await client.mutate({\n mutation: gql`\n mutation ($id: String!, $reason: String!) {\n revokeIssuedDocument(id: $id, reason: $reason) {\n id\n }\n }\n `,\n variables: { id: this.selected.id, reason: this.reason }\n })\n if (response.errors?.length) throw response.errors[0]\n notify({ message: i18next.t('text.issued-document-revoked-done', { number: this.selected.number }) })\n this.grist.fetch()\n } catch (error: any) {\n notify({ level: 'error', message: error?.message ?? String(error) })\n } finally {\n this.busy = false\n }\n }\n}\n\n/** 내 정보 › 내 증명서 - the ledger's rows that are one's own, and the documents one issues for oneself. */\n@customElement('my-issued-document-list')\nexport class MyIssuedDocumentList extends IssuedDocumentList {\n protected mine = true\n}\n"]}
1
+ {"version":3,"file":"issued-document-list.js","sourceRoot":"","sources":["../../../client/pages/issued-document/issued-document-list.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,iCAAiC,CAAA;AACxC,OAAO,2CAA2C,CAAA;AAClD,OAAO,6BAA6B,CAAA;AACpC,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,MAAM,qBAAqB,CAAA;A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AAC;8BAAiB,SAAS;iDAAA;AA3FjC,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CA+Q9B;;AAED,qGAAqG;AAE9F,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,kBAAkB;IAArD;;QACK,SAAI,GAAG,IAAI,CAAA;IACvB,CAAC;CAAA,CAAA;AAFY,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,oBAAoB,CAEhC","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@operato/data-grist/ox-grist.js'\nimport '@operato/input/ox-input-select-buttons.js'\nimport '@operato/input/ox-select.js'\nimport '@operato/popup/ox-popup-list.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, nothing } from 'lit'\nimport { customElement, query, state } from 'lit/decorators.js'\n\nimport { DataGrist, FetchOption } from '@operato/data-grist'\nimport { client, MutationController, QueryController } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify } from '@operato/layout'\nimport { PageView } from '@operato/shell'\nimport { CommonGristStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\n\nimport { downloadIssuedFile, issueDocument, issuedDocumentKindWord as kindWord, openPdfView } from '../../issue-document'\n\nconst FIELDS = 'id kind number subjectName purpose submittedTo state revokedAt revokeReason createdAt creator { id name } file { id fullpath name }'\n\n/**\n * 발급 대장 (ADR-0176 decision 2) - the documents issued, newest first: kind, number, whom or what each is about, what\n * for and to whom, who issued it and when, and whether it was revoked. Each person sees the kinds their own rules let\n * them read (the server asks each kind's module) - an employee their own certificates - and issues here what is about\n * the company or about themselves. A file is saved as it was issued; a mistaken one is revoked with a reason.\n */\n@customElement('issued-document-list')\nexport class IssuedDocumentList extends localize(i18next)(PageView) {\n /** 내 증명서: one's own - about oneself or issued by oneself - and the documents one issues here. Else the whole ledger. */\n protected mine = false\n\n static styles = [\n WorkSurfacePageStyles,\n ScrollbarStyles,\n CommonGristStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n }\n ox-grist {\n flex: 1;\n }\n .filters {\n display: flex;\n flex-wrap: wrap;\n gap: var(--spacing-medium, 8px) var(--spacing-large, 12px);\n align-items: center;\n padding: var(--spacing-medium, 8px) var(--spacing-large, 12px);\n }\n .revoke {\n display: flex;\n flex-wrap: wrap;\n gap: var(--spacing-medium, 8px);\n align-items: center;\n padding: var(--spacing-medium, 8px) var(--spacing-large, 12px);\n border-top: var(--border-dim-color);\n font: var(--label-font);\n }\n .revoke input {\n flex: 1;\n min-width: 200px;\n background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n color: var(--input-field-color, var(--md-sys-color-on-surface));\n border: var(--border-dim-color);\n border-radius: var(--border-radius);\n padding: var(--input-padding);\n font: var(--input-font);\n }\n .filters input[type='date'] {\n background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n color: var(--input-field-color, var(--md-sys-color-on-surface));\n border: var(--border-dim-color);\n border-radius: var(--border-radius);\n padding: var(--input-padding);\n font: var(--input-font);\n }\n .filters label {\n display: flex;\n align-items: center;\n gap: var(--spacing-medium, 8px);\n font: var(--label-font);\n white-space: nowrap;\n }\n .filters ox-input-select-buttons {\n flex: none;\n }\n ox-select {\n min-width: 200px;\n }\n `\n ]\n\n @state() private gristConfig: any\n /* The kinds this person may read, and the ones they issue here (ADR-0190). */\n private kindsRead = new QueryController<{ issuedDocumentKinds: { kind: string; asOf: boolean; issuable: boolean; refId?: string | null }[] }>(\n this,\n gql`query { issuedDocumentKinds { kind asOf issuable refId } }`\n )\n @state() private kind = ''\n /* 발급 · 취소 - none chosen is both. */\n @state() private states: string[] = []\n /* The days issued on, 'YYYY-MM-DD', either end open. */\n @state() private from = ''\n @state() private to = ''\n @state() private selected: any = null\n @state() private reason = ''\n private revoking = new MutationController(\n this,\n gql`\n mutation ($id: String!, $reason: String!) {\n revokeIssuedDocument(id: $id, reason: $reason) {\n id\n }\n }\n `\n )\n\n @query('ox-grist') private grist!: DataGrist\n\n private get kinds(): string[] {\n return (this.kindsRead.data?.issuedDocumentKinds ?? []).map(one => one.kind)\n }\n\n private get issuable() {\n return (this.kindsRead.data?.issuedDocumentKinds ?? []).filter(one => one.issuable)\n }\n\n private get busy() {\n return this.revoking.pending\n }\n\n get context() {\n return {\n title: i18next.t(this.mine ? 'title.my-issued-documents' : 'title.issued-document-list'),\n /* Issued in 내 증명서: a document about oneself (one's 재직증명서), and one about the company itself (a 주주명부). */\n actions: (this.mine ? this.issuable : []).map(one => ({\n title: i18next.t('button.issue-kind', { kind: kindWord(one.kind) }),\n icon: 'workspace_premium',\n action: async () => (await issueDocument({ kind: one.kind, refId: one.refId ?? undefined, withAsOf: one.asOf })) && this.grist.fetch()\n })),\n search: { handler: (search: string) => ((this.grist.searchText = search), this.grist.fetch()), value: this.grist?.searchText }\n }\n }\n\n render() {\n const row = this.selected\n return html`\n <div class=\"filters\">\n ${this.kinds.length > 1\n ? html`<label\n >${i18next.t('field.issued-document-kind')}\n <ox-select\n .value=${this.kind}\n @change=${(e: CustomEvent) => {\n const next = String(e.detail ?? '')\n if (next !== this.kind) (this.kind = next), this.grist.fetch()\n }}\n >\n <span slot=\"label\">${this.kind ? kindWord(this.kind) : i18next.t('text.all')}</span>\n <ox-popup-list align-left nowrap with-search>\n <div option value=\"\">${i18next.t('text.all')}</div>\n ${this.kinds.map(kind => html`<div option value=${kind}>${kindWord(kind)}</div>`)}\n </ox-popup-list>\n </ox-select>\n </label>`\n : nothing}\n <label\n >${i18next.t('field.state')}\n <ox-input-select-buttons\n multiple\n .options=${['published', 'revoked'].map(value => ({ value, display: i18next.t(`text.issued-document-${value}`), count: this.grist?.counts?.state?.[value] ?? 0 }))}\n .value=${this.states}\n @change=${(e: CustomEvent) => ((this.states = (e.target as any).value ?? []), this.grist.fetch())}\n ></ox-input-select-buttons>\n </label>\n <label\n >${i18next.t('field.issued-document-issued-on')}\n <input type=\"date\" .value=${this.from} @change=${(e: any) => ((this.from = e.target.value), this.grist.fetch())} />\n ~\n <input type=\"date\" .value=${this.to} @change=${(e: any) => ((this.to = e.target.value), this.grist.fetch())} />\n </label>\n </div>\n <ox-grist .mode=${'GRID'} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)} .countHandler=${this.countHandler.bind(this)} @counts-change=${() => this.requestUpdate()} @select-record-change=${(e: any) => this.select(e.detail?.records)}></ox-grist>\n ${row && row.state === 'published'\n ? html`<div class=\"revoke\">\n ${i18next.t('text.issued-document-revoke', { number: row.number })}\n <input .value=${this.reason} placeholder=${i18next.t('field.issued-document-revoke-reason')} ?disabled=${this.busy} @input=${(e: any) => (this.reason = e.target.value)} />\n <button danger ?disabled=${this.busy || !this.reason.trim()} @click=${() => this.revoke()}>${i18next.t('button.issued-document-revoke')}</button>\n </div>`\n : nothing}\n `\n }\n\n async pageInitialized() {\n this.gristConfig = {\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: false },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'download',\n title: i18next.t('button.issued-document-open'),\n handlers: {\n click: (_c: any, _d: any, _col: any, record: any) =>\n record?.file?.fullpath && downloadIssuedFile(record.file).catch((error: any) => notify({ level: 'error', message: error?.message ?? String(error) }))\n }\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'visibility',\n title: i18next.t('button.pdf-preview'),\n handlers: {\n /* The issued file itself, as it went out - its number and seal - opened in place under its own name. */\n click: (_c: any, _d: any, _col: any, record: any) => record?.file?.fullpath && openPdfView(record.file.fullpath, `${kindWord(record.kind)} · ${record.number}`)\n }\n },\n { type: 'string', name: 'number', header: i18next.t('field.issued-document-number'), width: 140 },\n { type: 'string', name: 'kind', header: i18next.t('field.issued-document-kind'), record: { renderer: (value: string) => kindWord(value) }, width: 140 },\n { type: 'string', name: 'subjectName', header: i18next.t('field.issued-document-subject'), width: 160 },\n { type: 'string', name: 'purpose', header: i18next.t('field.issued-document-purpose'), width: 160 },\n { type: 'string', name: 'submittedTo', header: i18next.t('field.issued-document-submitted-to'), width: 160 },\n { type: 'datetime', name: 'createdAt', header: i18next.t('field.issued-document-issued-at'), width: 160 },\n { type: 'resource-object', name: 'creator', header: i18next.t('field.issued-document-issuer'), width: 110 },\n {\n type: 'string',\n name: 'state',\n header: i18next.t('field.state'),\n record: { renderer: (value: string, _c: any, record: any) => (value === 'revoked' ? `${i18next.t('text.issued-document-revoked')} · ${record.revokeReason ?? ''}` : i18next.t('text.issued-document-published')) },\n width: 200\n }\n ],\n rows: { appendable: false, selectable: { multiple: false } }\n }\n }\n\n async pageUpdated(changes: any) {\n if ((this as any).active && changes.active && this.grist) this.grist.fetch()\n }\n\n /* The list's conditions other than the state: the kind, the days issued on and the search. */\n private conditions(): any[] {\n const filters: any[] = []\n if (this.kind) filters.push({ name: 'kind', operator: 'eq', value: this.kind })\n if (this.from || this.to) filters.push({ name: 'createdAt', operator: 'between', value: [this.from, this.to] })\n if (this.grist?.searchText) filters.push({ name: 'q', operator: 'search', value: this.grist.searchText })\n return filters\n }\n\n async fetchHandler({ page = 1, limit = 100 }: FetchOption) {\n const filters = this.conditions()\n if (this.states.length) filters.push({ name: 'state', operator: 'in', value: this.states })\n const response = await client.query({\n query: gql(\n this.mine\n ? `query ($filters: [Filter!], $pagination: Pagination) { list: readableIssuedDocuments(filters: $filters, pagination: $pagination, mine: true) { items { ${FIELDS} } total } }`\n : `query ($filters: [Filter!], $pagination: Pagination) { list: issuedDocuments(filters: $filters, pagination: $pagination) { items { ${FIELDS} } total } }`\n ),\n variables: { filters, pagination: { page, limit } },\n fetchPolicy: 'no-cache'\n })\n this.select([])\n return { total: response.data?.list?.total ?? 0, records: response.data?.list?.items ?? [] }\n }\n\n /* The state chips' numbers: the list's door totals each state under the other conditions, in one request. */\n async countHandler({ signal }: FetchOption) {\n const filters = this.conditions()\n const list = this.mine ? 'readableIssuedDocuments' : 'issuedDocuments'\n const states = ['published', 'revoked']\n const response = await client.query({\n query: gql(\n `query (${states.map((_, at) => `$f${at}: [Filter!]`).join(', ')}) { ${states\n .map((_, at) => `c${at}: ${list}(filters: $f${at}, pagination: { page: 1, limit: 1 }${this.mine ? ', mine: true' : ''}) { total }`)\n .join(' ')} }`\n ),\n variables: Object.fromEntries(states.map((state, at) => [`f${at}`, [...filters, { name: 'state', operator: 'in', value: [state] }]])),\n fetchPolicy: 'no-cache',\n context: { fetchOptions: { signal }, queryDeduplication: false }\n })\n if (response.errors?.length) throw response.errors[0]\n return { state: Object.fromEntries(states.map((state, at) => [state, response.data?.[`c${at}`]?.total ?? 0])) }\n }\n\n private select(records: any[] | undefined) {\n const row = records?.[0] ?? null\n if (row?.id !== this.selected?.id) this.reason = ''\n this.selected = row\n }\n\n private async revoke() {\n const { id, number } = this.selected\n if (!(await this.revoking.run({ id, reason: this.reason }))) return\n notify({ message: i18next.t('text.issued-document-revoked-done', { number }) })\n this.grist.fetch()\n }\n}\n\n/** 내 정보 › 내 증명서 - the ledger's rows that are one's own, and the documents one issues for oneself. */\n@customElement('my-issued-document-list')\nexport class MyIssuedDocumentList extends IssuedDocumentList {\n protected mine = true\n}\n"]}
@@ -9,11 +9,17 @@ declare const PDFTemplateEditor_base: (new (...args: any[]) => import("lit").Lit
9
9
  export declare class PDFTemplateEditor extends PDFTemplateEditor_base {
10
10
  static styles: import("lit").CSSResult[];
11
11
  private templateId;
12
- private form;
13
12
  private sample;
14
13
  private preview;
15
- private busy;
16
- private failure;
14
+ private previewing;
15
+ private previewFailure;
16
+ private template;
17
+ private creating;
18
+ private updating;
19
+ private draft;
20
+ private get stored();
21
+ private get busy();
22
+ private get failure();
17
23
  get context(): {
18
24
  title: string;
19
25
  menu: string;
@@ -28,11 +34,10 @@ export declare class PDFTemplateEditor extends PDFTemplateEditor_base {
28
34
  }[];
29
35
  };
30
36
  pageUpdated(changes: any, lifecycle: any): void;
31
- private read;
32
- private run;
33
37
  private save;
34
38
  /** The saved template printed with the sample data — save first to see a change. */
35
39
  private showPreview;
40
+ private printPreview;
36
41
  private load;
37
42
  render(): import("lit-html").TemplateResult<1>;
38
43
  }