@things-factory/invoice 10.1.265 → 10.1.267
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/document/document-party.d.ts +4 -35
- package/dist-client/document/document-party.js +2 -189
- package/dist-client/document/document-party.js.map +1 -1
- package/dist-client/index.d.ts +1 -1
- package/dist-client/index.js +1 -1
- package/dist-client/index.js.map +1 -1
- package/dist-client/invoice-files.js +1 -0
- package/dist-client/invoice-files.js.map +1 -1
- package/dist-client/pages/invoice-editor.d.ts +1 -0
- package/dist-client/pages/invoice-editor.js +2 -1
- package/dist-client/pages/invoice-editor.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/viewparts/document-defaults-setting-let.d.ts +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/translations/en.json +0 -3
- package/translations/es.json +0 -3
- package/translations/ja.json +0 -3
- package/translations/ko.json +0 -3
- package/translations/ms.json +0 -3
- package/translations/zh.json +0 -3
|
@@ -1,40 +1,9 @@
|
|
|
1
|
-
import '@
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export type DocumentParty = {
|
|
5
|
-
id: string;
|
|
6
|
-
name: string;
|
|
7
|
-
businessNumber?: string | null;
|
|
8
|
-
};
|
|
1
|
+
import type { CounterpartyPick } from '@things-factory/biz-base/dist-client';
|
|
2
|
+
/** A counterparty as a document's party - which one, its name and registration number (biz-base `CounterpartyPick`). */
|
|
3
|
+
export type DocumentParty = CounterpartyPick;
|
|
9
4
|
/**
|
|
10
5
|
* The counterparty a party's name is - the one choice of that name, case and spaces aside (ADR-0170 decision 11); null
|
|
11
6
|
* when none or more than one is, or the choices cannot be read. Searched by the name's longest word, so 「(주) 하티오랩」
|
|
12
|
-
* finds 「(주)하티오랩」.
|
|
7
|
+
* finds 「(주)하티오랩」. The party is picked with biz-base `counterparty-select`.
|
|
13
8
|
*/
|
|
14
9
|
export declare function partyOfName(name: unknown): Promise<DocumentParty | null>;
|
|
15
|
-
declare const DocumentPartySelect_base: (new (...args: any[]) => LitElement) & typeof LitElement;
|
|
16
|
-
/**
|
|
17
|
-
* Picking a counterparty for a document - one field that finds as it is typed and lists what it found under it; a
|
|
18
|
-
* click takes one and fires `party` with it (or with null when cleared). Every editor of a commercial document picks
|
|
19
|
-
* its party here - invoice and quotation (ADR-0120 decision 1). Reads `counterpartyChoices`, which every seat may.
|
|
20
|
-
*/
|
|
21
|
-
export declare class DocumentPartySelect extends DocumentPartySelect_base {
|
|
22
|
-
static styles: import("lit").CSSResult[];
|
|
23
|
-
/** The party chosen, shown as the field's placeholder until something is typed. */
|
|
24
|
-
party: DocumentParty | null;
|
|
25
|
-
disabled: boolean;
|
|
26
|
-
private search;
|
|
27
|
-
/** The words the list is found by - undefined while no list is open. */
|
|
28
|
-
private finding?;
|
|
29
|
-
private active;
|
|
30
|
-
private timer?;
|
|
31
|
-
private choices;
|
|
32
|
-
/** The list under the field: what was found, or null while it is closed or not read. */
|
|
33
|
-
private get found();
|
|
34
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
35
|
-
private findSoon;
|
|
36
|
-
private find;
|
|
37
|
-
private key;
|
|
38
|
-
private choose;
|
|
39
|
-
}
|
|
40
|
-
export {};
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import '@material/web/icon/icon.js';
|
|
3
1
|
import gql from 'graphql-tag';
|
|
4
|
-
import {
|
|
5
|
-
import { customElement, property, state } from 'lit/decorators.js';
|
|
6
|
-
import { client, QueryController } from '@operato/graphql';
|
|
7
|
-
import { i18next, localize } from '@operato/i18n';
|
|
8
|
-
import { ButtonStyles } from '@operato/styles';
|
|
2
|
+
import { client } from '@operato/graphql';
|
|
9
3
|
import { partyNamed } from '@things-factory/invoice/dist-shared/document-start.js';
|
|
10
4
|
const CHOICES = gql `
|
|
11
5
|
query ($search: String, $pagination: Pagination) {
|
|
@@ -17,7 +11,7 @@ const CHOICES = gql `
|
|
|
17
11
|
/**
|
|
18
12
|
* The counterparty a party's name is - the one choice of that name, case and spaces aside (ADR-0170 decision 11); null
|
|
19
13
|
* when none or more than one is, or the choices cannot be read. Searched by the name's longest word, so 「(주) 하티오랩」
|
|
20
|
-
* finds 「(주)하티오랩」.
|
|
14
|
+
* finds 「(주)하티오랩」. The party is picked with biz-base `counterparty-select`.
|
|
21
15
|
*/
|
|
22
16
|
export async function partyOfName(name) {
|
|
23
17
|
const word = String(name ?? '')
|
|
@@ -33,185 +27,4 @@ export async function partyOfName(name) {
|
|
|
33
27
|
return null;
|
|
34
28
|
}
|
|
35
29
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Picking a counterparty for a document - one field that finds as it is typed and lists what it found under it; a
|
|
38
|
-
* click takes one and fires `party` with it (or with null when cleared). Every editor of a commercial document picks
|
|
39
|
-
* its party here - invoice and quotation (ADR-0120 decision 1). Reads `counterpartyChoices`, which every seat may.
|
|
40
|
-
*/
|
|
41
|
-
let DocumentPartySelect = class DocumentPartySelect extends localize(i18next)(LitElement) {
|
|
42
|
-
constructor() {
|
|
43
|
-
super(...arguments);
|
|
44
|
-
/** The party chosen, shown as the field's placeholder until something is typed. */
|
|
45
|
-
this.party = null;
|
|
46
|
-
this.disabled = false;
|
|
47
|
-
this.search = '';
|
|
48
|
-
this.active = 0;
|
|
49
|
-
/* The choices for the words found by - only the answer to the last thing typed is shown, and the list found before
|
|
50
|
-
stays while the next is read (ADR-0190). */
|
|
51
|
-
this.choices = new QueryController(this, CHOICES, {
|
|
52
|
-
keepPrevious: true,
|
|
53
|
-
variables: () => this.finding === undefined || this.disabled ? undefined : { search: this.finding.trim() || undefined, pagination: { page: 1, limit: 30 } }
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
static { this.styles = [
|
|
57
|
-
ButtonStyles,
|
|
58
|
-
css `
|
|
59
|
-
:host {
|
|
60
|
-
position: relative;
|
|
61
|
-
display: block;
|
|
62
|
-
}
|
|
63
|
-
.field {
|
|
64
|
-
display: flex;
|
|
65
|
-
gap: var(--spacing-small, 4px);
|
|
66
|
-
align-items: center;
|
|
67
|
-
}
|
|
68
|
-
input {
|
|
69
|
-
flex: 1;
|
|
70
|
-
min-width: 0;
|
|
71
|
-
box-sizing: border-box;
|
|
72
|
-
height: var(--form-element-height-medium, 32px);
|
|
73
|
-
padding: 0 var(--spacing-medium, 8px);
|
|
74
|
-
border: var(--input-field-border, 1px solid var(--md-sys-color-outline));
|
|
75
|
-
border-radius: var(--input-field-border-radius, var(--md-sys-shape-corner-small, 4px));
|
|
76
|
-
background: var(--input-field-background, var(--md-sys-color-surface-container-highest));
|
|
77
|
-
font: inherit;
|
|
78
|
-
font-size: var(--ui-t-body, 13px);
|
|
79
|
-
color: var(--ui-ink, var(--md-sys-color-on-surface));
|
|
80
|
-
}
|
|
81
|
-
input:focus-visible {
|
|
82
|
-
outline: none;
|
|
83
|
-
border-color: var(--md-sys-color-primary);
|
|
84
|
-
}
|
|
85
|
-
ul {
|
|
86
|
-
position: absolute;
|
|
87
|
-
z-index: 10;
|
|
88
|
-
left: 0;
|
|
89
|
-
right: 0;
|
|
90
|
-
top: calc(100% + 2px);
|
|
91
|
-
max-height: 260px;
|
|
92
|
-
overflow-y: auto;
|
|
93
|
-
margin: 0;
|
|
94
|
-
padding: var(--spacing-small, 4px) 0;
|
|
95
|
-
list-style: none;
|
|
96
|
-
border: 1px solid var(--md-sys-color-outline-variant);
|
|
97
|
-
border-radius: var(--ui-r, 10px);
|
|
98
|
-
background: var(--md-sys-color-surface-container-lowest);
|
|
99
|
-
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
|
|
100
|
-
}
|
|
101
|
-
li {
|
|
102
|
-
display: flex;
|
|
103
|
-
justify-content: space-between;
|
|
104
|
-
gap: var(--spacing-large, 12px);
|
|
105
|
-
padding: 6px var(--spacing-large, 12px);
|
|
106
|
-
cursor: pointer;
|
|
107
|
-
font-size: var(--ui-t-body, 13px);
|
|
108
|
-
color: var(--ui-ink, var(--md-sys-color-on-surface));
|
|
109
|
-
}
|
|
110
|
-
li:hover,
|
|
111
|
-
li[active] {
|
|
112
|
-
background: var(--md-sys-color-surface-container-high);
|
|
113
|
-
}
|
|
114
|
-
li small {
|
|
115
|
-
white-space: nowrap;
|
|
116
|
-
}
|
|
117
|
-
li small,
|
|
118
|
-
li.none {
|
|
119
|
-
color: var(--ui-muted, var(--md-sys-color-on-surface-variant));
|
|
120
|
-
}
|
|
121
|
-
li.none {
|
|
122
|
-
cursor: default;
|
|
123
|
-
}
|
|
124
|
-
`
|
|
125
|
-
]; }
|
|
126
|
-
/** The list under the field: what was found, or null while it is closed or not read. */
|
|
127
|
-
get found() {
|
|
128
|
-
if (this.finding === undefined || !this.choices.data)
|
|
129
|
-
return null;
|
|
130
|
-
return this.choices.data.counterparties?.items ?? [];
|
|
131
|
-
}
|
|
132
|
-
render() {
|
|
133
|
-
return html `
|
|
134
|
-
<div class="field">
|
|
135
|
-
<input
|
|
136
|
-
.value=${this.search}
|
|
137
|
-
placeholder=${this.party?.name ?? i18next.t('text.invoice-counterparty-search')}
|
|
138
|
-
aria-label=${i18next.t('field.counterparty')}
|
|
139
|
-
?disabled=${this.disabled}
|
|
140
|
-
@focus=${() => this.find()}
|
|
141
|
-
@input=${(e) => ((this.search = e.target.value), this.findSoon())}
|
|
142
|
-
@keydown=${(e) => this.key(e)}
|
|
143
|
-
@blur=${() => setTimeout(() => (this.finding = undefined), 150)}
|
|
144
|
-
/>
|
|
145
|
-
${this.party && !this.disabled
|
|
146
|
-
? html `<button quiet icon-only title=${i18next.t('button.invoice-counterparty-clear')} aria-label=${i18next.t('button.invoice-counterparty-clear')} @click=${() => this.choose(null)}>
|
|
147
|
-
<md-icon>close</md-icon>
|
|
148
|
-
</button>`
|
|
149
|
-
: nothing}
|
|
150
|
-
</div>
|
|
151
|
-
${this.found
|
|
152
|
-
? html `<ul role="listbox">
|
|
153
|
-
${this.found.length
|
|
154
|
-
? this.found.map((one, index) => html `<li role="option" ?active=${index === this.active} @mousedown=${(e) => (e.preventDefault(), this.choose(one))}>
|
|
155
|
-
<span>${one.name}</span>${one.businessNumber ? html `<small>${one.businessNumber}</small>` : nothing}
|
|
156
|
-
</li>`)
|
|
157
|
-
: html `<li class="none">${i18next.t('text.invoice-counterparty-none')}</li>`}
|
|
158
|
-
</ul>`
|
|
159
|
-
: nothing}
|
|
160
|
-
`;
|
|
161
|
-
}
|
|
162
|
-
findSoon() {
|
|
163
|
-
clearTimeout(this.timer);
|
|
164
|
-
this.timer = setTimeout(() => this.find(), 250);
|
|
165
|
-
}
|
|
166
|
-
find() {
|
|
167
|
-
if (this.disabled)
|
|
168
|
-
return;
|
|
169
|
-
this.finding = this.search;
|
|
170
|
-
this.active = 0;
|
|
171
|
-
}
|
|
172
|
-
key(e) {
|
|
173
|
-
if (!this.found?.length || e.isComposing)
|
|
174
|
-
return;
|
|
175
|
-
if (e.key === 'ArrowDown')
|
|
176
|
-
this.active = Math.min(this.active + 1, this.found.length - 1);
|
|
177
|
-
else if (e.key === 'ArrowUp')
|
|
178
|
-
this.active = Math.max(this.active - 1, 0);
|
|
179
|
-
else if (e.key === 'Enter')
|
|
180
|
-
this.choose(this.found[this.active]);
|
|
181
|
-
else if (e.key === 'Escape')
|
|
182
|
-
this.finding = undefined;
|
|
183
|
-
else
|
|
184
|
-
return;
|
|
185
|
-
e.preventDefault();
|
|
186
|
-
}
|
|
187
|
-
choose(party) {
|
|
188
|
-
this.search = '';
|
|
189
|
-
this.finding = undefined;
|
|
190
|
-
this.dispatchEvent(new CustomEvent('party', { detail: party, bubbles: true, composed: true }));
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
__decorate([
|
|
194
|
-
property({ attribute: false }),
|
|
195
|
-
__metadata("design:type", Object)
|
|
196
|
-
], DocumentPartySelect.prototype, "party", void 0);
|
|
197
|
-
__decorate([
|
|
198
|
-
property({ type: Boolean }),
|
|
199
|
-
__metadata("design:type", Object)
|
|
200
|
-
], DocumentPartySelect.prototype, "disabled", void 0);
|
|
201
|
-
__decorate([
|
|
202
|
-
state(),
|
|
203
|
-
__metadata("design:type", Object)
|
|
204
|
-
], DocumentPartySelect.prototype, "search", void 0);
|
|
205
|
-
__decorate([
|
|
206
|
-
state(),
|
|
207
|
-
__metadata("design:type", String)
|
|
208
|
-
], DocumentPartySelect.prototype, "finding", void 0);
|
|
209
|
-
__decorate([
|
|
210
|
-
state(),
|
|
211
|
-
__metadata("design:type", Object)
|
|
212
|
-
], DocumentPartySelect.prototype, "active", void 0);
|
|
213
|
-
DocumentPartySelect = __decorate([
|
|
214
|
-
customElement('document-party-select')
|
|
215
|
-
], DocumentPartySelect);
|
|
216
|
-
export { DocumentPartySelect };
|
|
217
30
|
//# sourceMappingURL=document-party.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-party.js","sourceRoot":"","sources":["../../client/document/document-party.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,uDAAuD,CAAA;AAKlF,MAAM,OAAO,GAAG,GAAG,CAAA;;;;;;CAMlB,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAa;IAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;SAC5B,KAAK,C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AuB,CAAC;GAC1B,mBAAmB,CA6J/B","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { client, QueryController } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { ButtonStyles } from '@operato/styles'\nimport { partyNamed } from '@things-factory/invoice/dist-shared/document-start.js'\n\n/** A counterparty as a document's party - which one, its name and registration number (`counterpartyChoices`). */\nexport type DocumentParty = { id: string; name: string; businessNumber?: string | null }\n\nconst CHOICES = gql`\n query ($search: String, $pagination: Pagination) {\n counterparties: counterpartyChoices(search: $search, pagination: $pagination) {\n items { id name businessNumber }\n }\n }\n`\n\n/**\n * The counterparty a party's name is - the one choice of that name, case and spaces aside (ADR-0170 decision 11); null\n * when none or more than one is, or the choices cannot be read. Searched by the name's longest word, so 「(주) 하티오랩」\n * finds 「(주)하티오랩」.\n */\nexport async function partyOfName(name: unknown): Promise<DocumentParty | null> {\n const word = String(name ?? '')\n .split(/\\s+/)\n .reduce((longest, one) => (one.length > longest.length ? one : longest), '')\n if (!word) return null\n try {\n const response = await client.query({ query: CHOICES, variables: { search: word, pagination: { page: 1, limit: 100 } }, fetchPolicy: 'no-cache' })\n return partyNamed(name, (response.data?.counterparties?.items ?? []) as DocumentParty[]) ?? null\n } catch {\n return null\n }\n}\n\n/**\n * Picking a counterparty for a document - one field that finds as it is typed and lists what it found under it; a\n * click takes one and fires `party` with it (or with null when cleared). Every editor of a commercial document picks\n * its party here - invoice and quotation (ADR-0120 decision 1). Reads `counterpartyChoices`, which every seat may.\n */\n@customElement('document-party-select')\nexport class DocumentPartySelect extends localize(i18next)(LitElement) {\n static styles = [\n ButtonStyles,\n css`\n :host {\n position: relative;\n display: block;\n }\n .field {\n display: flex;\n gap: var(--spacing-small, 4px);\n align-items: center;\n }\n input {\n flex: 1;\n min-width: 0;\n box-sizing: border-box;\n height: var(--form-element-height-medium, 32px);\n padding: 0 var(--spacing-medium, 8px);\n border: var(--input-field-border, 1px solid var(--md-sys-color-outline));\n border-radius: var(--input-field-border-radius, var(--md-sys-shape-corner-small, 4px));\n background: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n font: inherit;\n font-size: var(--ui-t-body, 13px);\n color: var(--ui-ink, var(--md-sys-color-on-surface));\n }\n input:focus-visible {\n outline: none;\n border-color: var(--md-sys-color-primary);\n }\n ul {\n position: absolute;\n z-index: 10;\n left: 0;\n right: 0;\n top: calc(100% + 2px);\n max-height: 260px;\n overflow-y: auto;\n margin: 0;\n padding: var(--spacing-small, 4px) 0;\n list-style: none;\n border: 1px solid var(--md-sys-color-outline-variant);\n border-radius: var(--ui-r, 10px);\n background: var(--md-sys-color-surface-container-lowest);\n box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);\n }\n li {\n display: flex;\n justify-content: space-between;\n gap: var(--spacing-large, 12px);\n padding: 6px var(--spacing-large, 12px);\n cursor: pointer;\n font-size: var(--ui-t-body, 13px);\n color: var(--ui-ink, var(--md-sys-color-on-surface));\n }\n li:hover,\n li[active] {\n background: var(--md-sys-color-surface-container-high);\n }\n li small {\n white-space: nowrap;\n }\n li small,\n li.none {\n color: var(--ui-muted, var(--md-sys-color-on-surface-variant));\n }\n li.none {\n cursor: default;\n }\n `\n ]\n\n /** The party chosen, shown as the field's placeholder until something is typed. */\n @property({ attribute: false }) party: DocumentParty | null = null\n @property({ type: Boolean }) disabled = false\n\n @state() private search = ''\n /** The words the list is found by - undefined while no list is open. */\n @state() private finding?: string\n @state() private active = 0\n\n private timer?: ReturnType<typeof setTimeout>\n\n /* The choices for the words found by - only the answer to the last thing typed is shown, and the list found before\n stays while the next is read (ADR-0190). */\n private choices = new QueryController(this, CHOICES, {\n keepPrevious: true,\n variables: () =>\n this.finding === undefined || this.disabled ? undefined : { search: this.finding.trim() || undefined, pagination: { page: 1, limit: 30 } }\n })\n\n /** The list under the field: what was found, or null while it is closed or not read. */\n private get found(): DocumentParty[] | null {\n if (this.finding === undefined || !this.choices.data) return null\n return this.choices.data.counterparties?.items ?? []\n }\n\n render() {\n return html`\n <div class=\"field\">\n <input\n .value=${this.search}\n placeholder=${this.party?.name ?? i18next.t('text.invoice-counterparty-search')}\n aria-label=${i18next.t('field.counterparty')}\n ?disabled=${this.disabled}\n @focus=${() => this.find()}\n @input=${(e: any) => ((this.search = e.target.value), this.findSoon())}\n @keydown=${(e: KeyboardEvent) => this.key(e)}\n @blur=${() => setTimeout(() => (this.finding = undefined), 150)}\n />\n ${this.party && !this.disabled\n ? html`<button quiet icon-only title=${i18next.t('button.invoice-counterparty-clear')} aria-label=${i18next.t('button.invoice-counterparty-clear')} @click=${() => this.choose(null)}>\n <md-icon>close</md-icon>\n </button>`\n : nothing}\n </div>\n ${this.found\n ? html`<ul role=\"listbox\">\n ${this.found.length\n ? this.found.map(\n (one, index) =>\n html`<li role=\"option\" ?active=${index === this.active} @mousedown=${(e: Event) => (e.preventDefault(), this.choose(one))}>\n <span>${one.name}</span>${one.businessNumber ? html`<small>${one.businessNumber}</small>` : nothing}\n </li>`\n )\n : html`<li class=\"none\">${i18next.t('text.invoice-counterparty-none')}</li>`}\n </ul>`\n : nothing}\n `\n }\n\n private findSoon() {\n clearTimeout(this.timer)\n this.timer = setTimeout(() => this.find(), 250)\n }\n\n private find() {\n if (this.disabled) return\n this.finding = this.search\n this.active = 0\n }\n\n private key(e: KeyboardEvent) {\n if (!this.found?.length || e.isComposing) return\n if (e.key === 'ArrowDown') this.active = Math.min(this.active + 1, this.found.length - 1)\n else if (e.key === 'ArrowUp') this.active = Math.max(this.active - 1, 0)\n else if (e.key === 'Enter') this.choose(this.found[this.active])\n else if (e.key === 'Escape') this.finding = undefined\n else return\n e.preventDefault()\n }\n\n private choose(party: DocumentParty | null) {\n this.search = ''\n this.finding = undefined\n this.dispatchEvent(new CustomEvent('party', { detail: party, bubbles: true, composed: true }))\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"document-party.js","sourceRoot":"","sources":["../../client/document/document-party.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,uDAAuD,CAAA;AAKlF,MAAM,OAAO,GAAG,GAAG,CAAA;;;;;;CAMlB,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAa;IAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;SAC5B,KAAK,CAAC,KAAK,CAAC;SACZ,MAAM,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAA;IAC9E,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IACtB,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAA;QAClJ,OAAO,UAAU,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,CAAoB,CAAC,IAAI,IAAI,CAAA;IAClG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { client } from '@operato/graphql'\nimport type { CounterpartyPick } from '@things-factory/biz-base/dist-client'\nimport { partyNamed } from '@things-factory/invoice/dist-shared/document-start.js'\n\n/** A counterparty as a document's party - which one, its name and registration number (biz-base `CounterpartyPick`). */\nexport type DocumentParty = CounterpartyPick\n\nconst CHOICES = gql`\n query ($search: String, $pagination: Pagination) {\n counterparties: counterpartyChoices(search: $search, pagination: $pagination) {\n items { id name businessNumber }\n }\n }\n`\n\n/**\n * The counterparty a party's name is - the one choice of that name, case and spaces aside (ADR-0170 decision 11); null\n * when none or more than one is, or the choices cannot be read. Searched by the name's longest word, so 「(주) 하티오랩」\n * finds 「(주)하티오랩」. The party is picked with biz-base `counterparty-select`.\n */\nexport async function partyOfName(name: unknown): Promise<DocumentParty | null> {\n const word = String(name ?? '')\n .split(/\\s+/)\n .reduce((longest, one) => (one.length > longest.length ? one : longest), '')\n if (!word) return null\n try {\n const response = await client.query({ query: CHOICES, variables: { search: word, pagination: { page: 1, limit: 100 } }, fetchPolicy: 'no-cache' })\n return partyNamed(name, (response.data?.counterparties?.items ?? []) as DocumentParty[]) ?? null\n } catch {\n return null\n }\n}\n"]}
|
package/dist-client/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { documentLinesConfig, linesOf, onLineChange, reckonLines, settleLine } f
|
|
|
6
6
|
export { defaultTaxRate } from '@things-factory/invoice/dist-shared/document-amounts.js';
|
|
7
7
|
export { printDocument, PRINT_LANGUAGES, type PrintLanguage } from './document/document-print.js';
|
|
8
8
|
export { DocumentPreview, openDocumentPreview, type DocumentFile, type DocumentFileFormat, type DocumentFileLoader } from './document/document-preview.js';
|
|
9
|
-
export {
|
|
9
|
+
export { partyOfName, type DocumentParty } from './document/document-party.js';
|
|
10
10
|
export { DOCUMENT_DEFAULTS, DOCUMENT_DEFAULTS_READER, headFromDefaults, OUR_SIDE_FIELDS, oursFromLast, type DocumentDefaults } from './document/document-defaults.js';
|
|
11
11
|
export { daysAfter, nextInvoiceNumber, partyNamed, sameName } from '@things-factory/invoice/dist-shared/document-start.js';
|
|
12
12
|
export { issuePeriodOf } from '@things-factory/invoice/dist-shared/invoice-standing.js';
|
package/dist-client/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export { documentLinesConfig, linesOf, onLineChange, reckonLines, settleLine } f
|
|
|
6
6
|
export { defaultTaxRate } from '@things-factory/invoice/dist-shared/document-amounts.js';
|
|
7
7
|
export { printDocument, PRINT_LANGUAGES } from './document/document-print.js';
|
|
8
8
|
export { DocumentPreview, openDocumentPreview } from './document/document-preview.js';
|
|
9
|
-
export {
|
|
9
|
+
export { partyOfName } from './document/document-party.js';
|
|
10
10
|
export { DOCUMENT_DEFAULTS, DOCUMENT_DEFAULTS_READER, headFromDefaults, OUR_SIDE_FIELDS, oursFromLast } from './document/document-defaults.js';
|
|
11
11
|
export { daysAfter, nextInvoiceNumber, partyNamed, sameName } from '@things-factory/invoice/dist-shared/document-start.js';
|
|
12
12
|
export { issuePeriodOf } from '@things-factory/invoice/dist-shared/invoice-standing.js';
|
package/dist-client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,wBAAwB,EAA2B,MAAM,qBAAqB,CAAA;AACpH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC/G,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,kBAAkB,EAAE,oBAAoB,EAAsB,MAAM,6BAA6B,CAAA;AAC3I,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAClH,OAAO,EAAE,cAAc,EAAE,MAAM,yDAAyD,CAAA;AACxF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAsB,MAAM,8BAA8B,CAAA;AACjG,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAuE,MAAM,gCAAgC,CAAA;AAC1J,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,wBAAwB,EAA2B,MAAM,qBAAqB,CAAA;AACpH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC/G,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,kBAAkB,EAAE,oBAAoB,EAAsB,MAAM,6BAA6B,CAAA;AAC3I,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAClH,OAAO,EAAE,cAAc,EAAE,MAAM,yDAAyD,CAAA;AACxF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAsB,MAAM,8BAA8B,CAAA;AACjG,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAuE,MAAM,gCAAgC,CAAA;AAC1J,OAAO,EAAE,WAAW,EAAsB,MAAM,8BAA8B,CAAA;AAC9E,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAyB,MAAM,iCAAiC,CAAA;AACrK,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,uDAAuD,CAAA;AAC1H,OAAO,EAAE,aAAa,EAAE,MAAM,yDAAyD,CAAA;AACvF,cAAc,8CAA8C,CAAA","sourcesContent":["export { configureInvoiceLinkSection, configureInvoice360Query, type InvoiceLinkSection } from './invoice-attach.js'\nexport { counterpartOf, invoiceStatusWord } from './entity360/invoice-360.js'\nexport { currencyChoices, currencyDigits, documentAmount, documentNumber } from './document/document-amount.js'\nexport { DocumentFormStyles, HEAD_FIELDS, renderDocumentHead, renderDocumentTotals, type DocumentValue } from './document/document-form.js'\nexport { documentLinesConfig, linesOf, onLineChange, reckonLines, settleLine } from './document/document-lines.js'\nexport { defaultTaxRate } from '@things-factory/invoice/dist-shared/document-amounts.js'\nexport { printDocument, PRINT_LANGUAGES, type PrintLanguage } from './document/document-print.js'\nexport { DocumentPreview, openDocumentPreview, type DocumentFile, type DocumentFileFormat, type DocumentFileLoader } from './document/document-preview.js'\nexport { partyOfName, type DocumentParty } from './document/document-party.js'\nexport { DOCUMENT_DEFAULTS, DOCUMENT_DEFAULTS_READER, headFromDefaults, OUR_SIDE_FIELDS, oursFromLast, type DocumentDefaults } from './document/document-defaults.js'\nexport { daysAfter, nextInvoiceNumber, partyNamed, sameName } from '@things-factory/invoice/dist-shared/document-start.js'\nexport { issuePeriodOf } from '@things-factory/invoice/dist-shared/invoice-standing.js'\nexport * from './viewparts/document-defaults-setting-let.js'\n"]}
|
|
@@ -142,6 +142,7 @@ let InvoiceFiles = class InvoiceFiles extends localize(i18next)(LitElement) {
|
|
|
142
142
|
hide-filelist
|
|
143
143
|
multiple
|
|
144
144
|
icon="attach_file"
|
|
145
|
+
.dropTarget=${this}
|
|
145
146
|
.label=${i18next.t('button.invoice-file-attach')}
|
|
146
147
|
?disabled=${!editable}
|
|
147
148
|
.progress=${touch() ? undefined : this.progress}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoice-files.js","sourceRoot":"","sources":["../client/invoice-files.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,0EAA0E;AAC1E,OAAO,qBAAqB,CAAA;AAC5B,OAAO,iCAAiC,CAAA;AAExC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,kBAAkB,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web/icon/icon.js'\n/* The tile is not a subpath of its own; the package root registers it. */\nimport '@operato/attachment'\nimport '@operato/input/ox-input-file.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { MutationController, QueryController, uploadContext } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client/index.js'\n\nimport { invoice360Query } from './invoice-attach'\n\ntype InvoiceFile = { id: string; name: string; mimetype?: string; fullpath: string }\n\n/** The phone's camera is offered where a finger taps - on a desktop the file button is the only way in. */\nconst touch = () => window.matchMedia('(pointer: coarse)').matches\n\n/**\n * The files an invoice keeps - the signed copy, the order, the delivery note. Each opens in its own tab. Whoever may\n * change invoices attaches (a photo taken on the spot, or any file) and takes one off; it is saved at once.\n */\n@customElement('invoice-files')\nexport class InvoiceFiles extends localize(i18next)(LitElement) {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-medium, 8px);\n color: var(--ui-ink);\n }\n .tiles {\n display: flex;\n flex-wrap: wrap;\n gap: var(--spacing-medium, 8px);\n padding-top: 6px;\n }\n .tile {\n position: relative;\n display: flex;\n flex-direction: column;\n width: 72px;\n gap: var(--spacing-tiny, 2px);\n }\n .tile a {\n display: block;\n width: 100%;\n aspect-ratio: 1;\n border-radius: var(--ui-r-small, 6px);\n border: 1px solid var(--ui-line);\n background: var(--ui-panel-2);\n overflow: hidden;\n }\n .tile ox-attachment-tile,\n .tile img {\n width: 100%;\n height: 100%;\n }\n .tile img {\n object-fit: cover;\n }\n .name {\n font-size: var(--ui-t-small, 11.5px);\n color: var(--ui-muted);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .tile button {\n position: absolute;\n top: -6px;\n right: -6px;\n display: grid;\n place-items: center;\n width: 20px;\n height: 20px;\n padding: 0;\n border: 1px solid var(--ui-line);\n border-radius: 50%;\n background: var(--ui-panel);\n color: var(--ui-muted);\n cursor: pointer;\n }\n .tile button md-icon {\n --md-icon-size: 14px;\n }\n .pickers {\n display: flex;\n flex-wrap: wrap;\n gap: var(--spacing-small, 4px);\n }\n .none {\n font-size: var(--ui-t-small, 11.5px);\n color: var(--ui-muted);\n }\n `\n ]\n\n @property() invoiceId?: string\n @state() mayChange = false\n @state() progress?: number\n\n /* The files of the invoice named (ADR-0190). */\n private filesRead = new QueryController(\n this,\n gql(`query ($id: String!) { invoice: ${invoice360Query()}(id: $id) { id files { id name mimetype fullpath } } }`),\n { variables: () => (this.invoiceId ? { id: this.invoiceId } : undefined) }\n )\n\n /* Attaching or taking off reads the files again. */\n private changing = new MutationController(\n this,\n gql`\n mutation ($id: String!, $attach: [Upload!], $remove: [String!]) {\n changeInvoiceFiles(id: $id, attach: $attach, remove: $remove) {\n id\n }\n }\n `,\n { refetch: () => [this.filesRead] }\n )\n\n private get files(): InvoiceFile[] {\n return this.filesRead.data?.invoice?.files ?? []\n }\n\n private get busy() {\n return this.changing.pending\n }\n\n connectedCallback() {\n super.connectedCallback()\n hasPrivilege({ privilege: 'mutation', category: 'invoice', domainOwnerGranted: true }).then(may => (this.mayChange = !!may))\n }\n\n render() {\n const editable = this.mayChange && !this.busy\n return html`\n ${this.files.length\n ? html`<div class=\"tiles\">${this.files.map(one => this.tile(one, editable))}</div>`\n : html`<span class=\"none\">${i18next.t('text.invoice-files-none')}</span>`}\n ${this.mayChange\n ? html`<div class=\"pickers\">\n ${touch()\n ? html`<ox-input-file\n quiet\n hide-filelist\n accept=\"image/*\"\n capture=\"environment\"\n icon=\"photo_camera\"\n .label=${i18next.t('button.invoice-file-photo')}\n ?disabled=${!editable}\n .progress=${this.progress}\n @change=${(e: CustomEvent) => this.pick(e)}\n ></ox-input-file>`\n : nothing}\n <ox-input-file\n quiet\n hide-filelist\n multiple\n icon=\"attach_file\"\n .label=${i18next.t('button.invoice-file-attach')}\n ?disabled=${!editable}\n .progress=${touch() ? undefined : this.progress}\n @change=${(e: CustomEvent) => this.pick(e)}\n ></ox-input-file>\n </div>`\n : nothing}\n `\n }\n\n private tile(one: InvoiceFile, editable: boolean) {\n return html`<span class=\"tile\">\n <a href=${one.fullpath} target=\"_blank\" rel=\"noopener\" title=${one.name}\n >${one.mimetype?.startsWith('image/')\n ? html`<img src=${one.fullpath} alt=${one.name} />`\n : html`<ox-attachment-tile .src=${one.fullpath} .path=${one.name} .mimetype=${one.mimetype ?? ''}></ox-attachment-tile>`}</a\n >\n <span class=\"name\">${one.name}</span>\n ${this.mayChange\n ? html`<button type=\"button\" ?disabled=${!editable} title=${i18next.t('button.invoice-file-remove')} aria-label=${i18next.t('button.invoice-file-remove')} @click=${() => this.takeOff(one)}>\n <md-icon>close</md-icon>\n </button>`\n : nothing}\n </span>`\n }\n\n private async pick(e: CustomEvent) {\n const picked = [...((e.detail as File[]) ?? [])]\n /* The picker's own reset says `change` again, with nothing - that one is let go. */\n if (!picked.length) return\n ;(e.target as any).reset?.()\n await this.change({ attach: picked })\n }\n\n private async takeOff(one: InvoiceFile) {\n const sure = await OxPrompt.open({\n title: i18next.t('button.invoice-file-remove'),\n text: i18next.t('text.invoice-file-remove-confirm', { name: one.name }),\n confirmButton: { text: i18next.t('button.invoice-file-remove'), destructive: true } as any,\n cancelButton: { text: i18next.t('button.cancel') }\n } as any)\n if (sure) await this.change({ remove: [one.id] })\n }\n\n private async change({ attach = [], remove = [] }: { attach?: File[]; remove?: string[] }) {\n if (!this.invoiceId || this.busy) return\n await this.changing.run({ id: this.invoiceId, attach, remove }, { context: attach.length ? uploadContext(fraction => (this.progress = fraction)) : {} })\n this.progress = undefined\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"invoice-files.js","sourceRoot":"","sources":["../client/invoice-files.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,0EAA0E;AAC1E,OAAO,qBAAqB,CAAA;AAC5B,OAAO,iCAAiC,CAAA;A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AAI,CAAC,QAAQ,GAAG,SAAS,CAAA;IAC3B,CAAC;;AAhHW;IAAX,QAAQ,EAAE;;+CAAmB;AACrB;IAAR,KAAK,EAAE;;+CAAkB;AACjB;IAAR,KAAK,EAAE;;8CAAkB;AA9Ef,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CA6LxB","sourcesContent":["import '@material/web/icon/icon.js'\n/* The tile is not a subpath of its own; the package root registers it. */\nimport '@operato/attachment'\nimport '@operato/input/ox-input-file.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { MutationController, QueryController, uploadContext } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client/index.js'\n\nimport { invoice360Query } from './invoice-attach'\n\ntype InvoiceFile = { id: string; name: string; mimetype?: string; fullpath: string }\n\n/** The phone's camera is offered where a finger taps - on a desktop the file button is the only way in. */\nconst touch = () => window.matchMedia('(pointer: coarse)').matches\n\n/**\n * The files an invoice keeps - the signed copy, the order, the delivery note. Each opens in its own tab. Whoever may\n * change invoices attaches (a photo taken on the spot, or any file) and takes one off; it is saved at once.\n */\n@customElement('invoice-files')\nexport class InvoiceFiles extends localize(i18next)(LitElement) {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-medium, 8px);\n color: var(--ui-ink);\n }\n .tiles {\n display: flex;\n flex-wrap: wrap;\n gap: var(--spacing-medium, 8px);\n padding-top: 6px;\n }\n .tile {\n position: relative;\n display: flex;\n flex-direction: column;\n width: 72px;\n gap: var(--spacing-tiny, 2px);\n }\n .tile a {\n display: block;\n width: 100%;\n aspect-ratio: 1;\n border-radius: var(--ui-r-small, 6px);\n border: 1px solid var(--ui-line);\n background: var(--ui-panel-2);\n overflow: hidden;\n }\n .tile ox-attachment-tile,\n .tile img {\n width: 100%;\n height: 100%;\n }\n .tile img {\n object-fit: cover;\n }\n .name {\n font-size: var(--ui-t-small, 11.5px);\n color: var(--ui-muted);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .tile button {\n position: absolute;\n top: -6px;\n right: -6px;\n display: grid;\n place-items: center;\n width: 20px;\n height: 20px;\n padding: 0;\n border: 1px solid var(--ui-line);\n border-radius: 50%;\n background: var(--ui-panel);\n color: var(--ui-muted);\n cursor: pointer;\n }\n .tile button md-icon {\n --md-icon-size: 14px;\n }\n .pickers {\n display: flex;\n flex-wrap: wrap;\n gap: var(--spacing-small, 4px);\n }\n .none {\n font-size: var(--ui-t-small, 11.5px);\n color: var(--ui-muted);\n }\n `\n ]\n\n @property() invoiceId?: string\n @state() mayChange = false\n @state() progress?: number\n\n /* The files of the invoice named (ADR-0190). */\n private filesRead = new QueryController(\n this,\n gql(`query ($id: String!) { invoice: ${invoice360Query()}(id: $id) { id files { id name mimetype fullpath } } }`),\n { variables: () => (this.invoiceId ? { id: this.invoiceId } : undefined) }\n )\n\n /* Attaching or taking off reads the files again. */\n private changing = new MutationController(\n this,\n gql`\n mutation ($id: String!, $attach: [Upload!], $remove: [String!]) {\n changeInvoiceFiles(id: $id, attach: $attach, remove: $remove) {\n id\n }\n }\n `,\n { refetch: () => [this.filesRead] }\n )\n\n private get files(): InvoiceFile[] {\n return this.filesRead.data?.invoice?.files ?? []\n }\n\n private get busy() {\n return this.changing.pending\n }\n\n connectedCallback() {\n super.connectedCallback()\n hasPrivilege({ privilege: 'mutation', category: 'invoice', domainOwnerGranted: true }).then(may => (this.mayChange = !!may))\n }\n\n render() {\n const editable = this.mayChange && !this.busy\n return html`\n ${this.files.length\n ? html`<div class=\"tiles\">${this.files.map(one => this.tile(one, editable))}</div>`\n : html`<span class=\"none\">${i18next.t('text.invoice-files-none')}</span>`}\n ${this.mayChange\n ? html`<div class=\"pickers\">\n ${touch()\n ? html`<ox-input-file\n quiet\n hide-filelist\n accept=\"image/*\"\n capture=\"environment\"\n icon=\"photo_camera\"\n .label=${i18next.t('button.invoice-file-photo')}\n ?disabled=${!editable}\n .progress=${this.progress}\n @change=${(e: CustomEvent) => this.pick(e)}\n ></ox-input-file>`\n : nothing}\n <ox-input-file\n quiet\n hide-filelist\n multiple\n icon=\"attach_file\"\n .dropTarget=${this}\n .label=${i18next.t('button.invoice-file-attach')}\n ?disabled=${!editable}\n .progress=${touch() ? undefined : this.progress}\n @change=${(e: CustomEvent) => this.pick(e)}\n ></ox-input-file>\n </div>`\n : nothing}\n `\n }\n\n private tile(one: InvoiceFile, editable: boolean) {\n return html`<span class=\"tile\">\n <a href=${one.fullpath} target=\"_blank\" rel=\"noopener\" title=${one.name}\n >${one.mimetype?.startsWith('image/')\n ? html`<img src=${one.fullpath} alt=${one.name} />`\n : html`<ox-attachment-tile .src=${one.fullpath} .path=${one.name} .mimetype=${one.mimetype ?? ''}></ox-attachment-tile>`}</a\n >\n <span class=\"name\">${one.name}</span>\n ${this.mayChange\n ? html`<button type=\"button\" ?disabled=${!editable} title=${i18next.t('button.invoice-file-remove')} aria-label=${i18next.t('button.invoice-file-remove')} @click=${() => this.takeOff(one)}>\n <md-icon>close</md-icon>\n </button>`\n : nothing}\n </span>`\n }\n\n private async pick(e: CustomEvent) {\n const picked = [...((e.detail as File[]) ?? [])]\n /* The picker's own reset says `change` again, with nothing - that one is let go. */\n if (!picked.length) return\n ;(e.target as any).reset?.()\n await this.change({ attach: picked })\n }\n\n private async takeOff(one: InvoiceFile) {\n const sure = await OxPrompt.open({\n title: i18next.t('button.invoice-file-remove'),\n text: i18next.t('text.invoice-file-remove-confirm', { name: one.name }),\n confirmButton: { text: i18next.t('button.invoice-file-remove'), destructive: true } as any,\n cancelButton: { text: i18next.t('button.cancel') }\n } as any)\n if (sure) await this.change({ remove: [one.id] })\n }\n\n private async change({ attach = [], remove = [] }: { attach?: File[]; remove?: string[] }) {\n if (!this.invoiceId || this.busy) return\n await this.changing.run({ id: this.invoiceId, attach, remove }, { context: attach.length ? uploadContext(fraction => (this.progress = fraction)) : {} })\n this.progress = undefined\n }\n}\n"]}
|
|
@@ -5,6 +5,7 @@ import { PageView } from '@operato/shell';
|
|
|
5
5
|
import { type DocumentValue } from '../document/document-form';
|
|
6
6
|
import { type DocumentDefaults } from '../document/document-defaults';
|
|
7
7
|
import '../invoice-files';
|
|
8
|
+
import '@things-factory/biz-base/dist-client';
|
|
8
9
|
declare const InvoiceEditor_base: (new (...args: any[]) => import("lit").LitElement) & typeof PageView;
|
|
9
10
|
/**
|
|
10
11
|
* 청구서 편집 — the head, the lines, the totals by tax kind and rate, and what an application links it to.
|
|
@@ -22,6 +22,7 @@ import { openDocumentPreview } from '../document/document-preview';
|
|
|
22
22
|
import { invoiceStatusWord } from '../entity360/invoice-360';
|
|
23
23
|
import { invoiceLinkSection } from '../invoice-attach';
|
|
24
24
|
import '../invoice-files';
|
|
25
|
+
import '@things-factory/biz-base/dist-client';
|
|
25
26
|
const FIELDS = `
|
|
26
27
|
id number status direction currency language counterpartyId counterparty { id name } supplierName supplierAddress supplierRegistrationNumber buyerName buyerAddress
|
|
27
28
|
buyerRegistrationNumber issueDate dueDate purchaseOrder paymentTerms bankDetails notes sourceReference taxBasis voidReason
|
|
@@ -263,7 +264,7 @@ let InvoiceEditor = class InvoiceEditor extends localize(i18next)(PageView) {
|
|
|
263
264
|
const name = this.form.direction === 'PURCHASE' ? this.form.supplierName : this.form.buyerName;
|
|
264
265
|
return html `<label
|
|
265
266
|
>${i18next.t('field.counterparty')}
|
|
266
|
-
<
|
|
267
|
+
<counterparty-select .party=${this.form.counterparty ?? null} ?disabled=${!editable} @counterparty=${(e) => this.chooseParty(e.detail)}></counterparty-select>
|
|
267
268
|
${this.invoice && !this.form.counterpartyId && String(name ?? '').trim() ? html `<span class="quiet">${i18next.t('text.invoice-counterparty-unlinked')}</span>` : nothing}
|
|
268
269
|
</label>`;
|
|
269
270
|
}
|