@things-factory/sales 10.1.256 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"opportunity-editor.js","sourceRoot":"","sources":["../../client/pages/opportunity-editor.ts"],"names":[],"mappings":";AAAA,OAAO,sCAAsC,CAAA;AAE7C,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACnF,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AAEzG,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExD,MAAM,MAAM,GAAG;;;;CAId,CAAA;AAiBD,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAE1E;;;;;;GAMG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,QAAQ,CAAC,OAAO,CAAC,CAAC,QAA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C,CAAC,CAAC,gCAAgC,CAAC;IAC7C,CAAC,CAAC,MAAM,KAAK,QAAQ;QACnB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,+BAA+B,CAAC;QAC5C,CAAC,CAAC,MAAM,KAAK,KAAK;YAChB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,4BAA4B,CAAC;YACzC,CAAC,CAAC,MAAM,KAAK,MAAM;gBACjB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,6BAA6B,CAAC;gBAC1C,CAAC,CAAC,MAAM,KAAK,UAAU;oBACrB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,iCAAiC,CAAC;oBAC9C,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAA;AAEzD,SAAS,KAAK,CAAC,SAAmD,EAAE;IAClE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,MAAM,CAAC,CAAA;IACrD,OAAO;QACL,IAAI,EAAE,EAAE;QACR,YAAY,EAAE,IAAI;QAClB,WAAW,EAAE,IAAI;QACjB,MAAM,EAAE,GAAG;QACX,QAAQ,EAAE,KAAK;QACf,kBAAkB,EAAE,SAAS,EAAE;QAC/B,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE;QACjD,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,EAAE;KAChB,CAAA;AACH,CAAC","sourcesContent":["import '@operato/list-state/ox-page-state.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, nothing } from 'lit'\nimport { customElement, state } from 'lit/decorators.js'\n\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify } from '@operato/layout'\nimport { navigate, PageView } from '@operato/shell'\nimport { ButtonStyles, DocumentPageStyles, FormFieldStyles } from '@operato/styles'\nimport { currencyChoices, documentAmount, DocumentFormStyles } from '@things-factory/invoice/dist-client'\n\nimport { opportunitySection } from '../opportunity-attach'\nimport { opportunityStageWord } from '../opportunity-words'\nimport { quotationStatusWord } from '../quotation-words'\n\nconst FIELDS = `\n id name stage probability amount currency expectedCloseMonth closedOn lostReason description\n counterpartyId endCustomerId ownerId counterparty { id name } endCustomer { id name } owner { id name }\n quotations { id number version status issueDate validUntil totalAmount currency }\n`\n\ntype Party = { id: string; name: string; businessNumber?: string }\ntype Picker = { search: string; found: Party[] }\ntype Form = {\n name: string\n counterparty: Party | null\n endCustomer: Party | null\n amount: string\n currency: string\n expectedCloseMonth: string\n stage: string\n probability: string\n ownerId: string\n description: string\n}\n\nconst thisMonth = () => new Date().toLocaleDateString('en-CA').slice(0, 7)\n\n/**\n * 영업 기회 편집 — with whom, for how much, by when and how likely.\n *\n * A person moves an open opportunity through the stages; changing the stage puts that stage's probability in, and the\n * person may change it. An open one is closed as lost with the reason; a lost one is opened again by choosing an open\n * stage. Winning is the application's: it closes the opportunity when the opportunity becomes its contract.\n */\n@customElement('opportunity-editor')\nexport class OpportunityEditor extends localize(i18next)(PageView) {\n static styles = [\n FormFieldStyles,\n ButtonStyles,\n DocumentPageStyles,\n DocumentFormStyles,\n css`\n .party {\n display: flex;\n gap: var(--spacing-small);\n align-items: center;\n }\n .party input {\n flex: 1;\n }\n table {\n width: 100%;\n border-collapse: collapse;\n font-variant-numeric: tabular-nums;\n }\n th,\n td {\n text-align: left;\n padding: var(--spacing-small);\n border-bottom: 1px solid var(--ui-line-soft);\n font-size: var(--ui-t-body);\n }\n th.number,\n td.number {\n text-align: right;\n }\n td a {\n color: inherit;\n text-decoration: underline;\n }\n `\n ]\n\n @state() opportunity: any = null\n @state() form: Form = blank()\n @state() pickers: Record<'counterparty' | 'endCustomer', Picker> = { counterparty: { search: '', found: [] }, endCustomer: { search: '', found: [] } }\n @state() stages: { stage: string; probability: number; open: boolean }[] = []\n @state() owners: { id: string; name: string; email?: string }[] = []\n /** Whether the application's section is this person's to read - asked once, before it is shown. */\n @state() sectionReadable = false\n @state() events: any[] = []\n @state() reason = ''\n @state() loading = false\n @state() error: unknown = null\n @state() busy = false\n\n private isOpen(stage: string) {\n return this.stages.some(one => one.stage === stage && one.open)\n }\n\n /** Won is final; a lost one is changed only by being opened again. */\n get editable() {\n return !this.busy && this.opportunity?.stage !== 'WON' && this.isOpen(this.form.stage)\n }\n\n get context() {\n const actions: any[] = []\n if (this.editable) actions.push({ title: i18next.t('button.save'), icon: 'save', emphasis: { raised: true }, action: () => this.save() })\n return {\n title: this.opportunity ? `${i18next.t('title.opportunity')} ${this.opportunity.name}` : i18next.t('title.opportunity-new'),\n ...(this.opportunity ? { description: opportunityStageWord(this.opportunity.stage) } : {}),\n frame: 'document',\n /* Opened from the opportunity list; the menu marks it. */\n menu: 'opportunity-list',\n actions: this.error ? [] : actions\n }\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (!this.active || !(changes.active || changes.params)) return\n if (!this.stages.length) await this.readChoices()\n const section = opportunitySection()\n if (section && !this.sectionReadable) (section.readable?.() ?? Promise.resolve(true)).then(may => (this.sectionReadable = !!may))\n const id = lifecycle?.params?.id\n if (!id) {\n this.opportunity = null\n this.form = blank(this.stages)\n this.events = []\n this.updateContext()\n return\n }\n if (id !== this.opportunity?.id) await this.load(id)\n }\n\n render() {\n const attached = this.opportunity && this.sectionReadable ? opportunitySection() : undefined\n const editable = this.editable\n const set = (patch: Partial<Form>) => (this.form = { ...this.form, ...patch })\n const stageChoices = this.stages.filter(one => one.open || one.stage === this.opportunity?.stage)\n return html`<ox-page-state .loading=${this.loading} .error=${this.error} @retry=${() => this.opportunity && this.load(this.opportunity.id)}>\n <div class=\"page\">\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.opportunity-section-head')}</h3></header>\n <div class=\"form\">\n <label class=\"wide\"\n >${i18next.t('field.opportunity-name')}\n <input .value=${this.form.name} ?disabled=${!editable} @input=${(e: any) => set({ name: e.target.value })}\n /></label>\n ${this.renderParty('counterparty', i18next.t('field.opportunity-counterparty'), editable)}\n ${this.renderParty('endCustomer', i18next.t('field.opportunity-end-customer'), editable)}\n <label\n >${i18next.t('field.opportunity-amount')}\n <input type=\"number\" min=\"0\" .value=${this.form.amount} ?disabled=${!editable} @input=${(e: any) => set({ amount: e.target.value })}\n /></label>\n <label\n >${i18next.t('field.opportunity-currency')}\n <select .value=${this.form.currency} ?disabled=${!editable} @change=${(e: any) => set({ currency: e.target.value })}>\n ${currencyChoices().map((code: string) => html`<option value=${code} ?selected=${code === this.form.currency}>${code}</option>`)}\n </select>\n </label>\n <label\n >${i18next.t('field.opportunity-expected-close-month')}\n <input type=\"month\" .value=${this.form.expectedCloseMonth} ?disabled=${!editable} @input=${(e: any) => set({ expectedCloseMonth: e.target.value })}\n /></label>\n <label\n >${i18next.t('field.opportunity-owner')}\n <select .value=${this.form.ownerId} ?disabled=${!editable} @change=${(e: any) => set({ ownerId: e.target.value })}>\n ${this.form.ownerId ? nothing : html`<option value=\"\" selected>${i18next.t('text.opportunity-owner-me')}</option>`}\n ${this.owners.map(one => html`<option value=${one.id} ?selected=${one.id === this.form.ownerId}>${one.name}</option>`)}\n </select>\n </label>\n <label class=\"wide\"\n >${i18next.t('field.opportunity-description')}\n <textarea .value=${this.form.description} ?disabled=${!editable} @input=${(e: any) => set({ description: e.target.value })}></textarea>\n </label>\n </div>\n </section>\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.opportunity-section-stage')}</h3></header>\n <div class=\"form\">\n <label\n >${i18next.t('field.opportunity-stage')}\n <select .value=${this.form.stage} ?disabled=${this.busy || this.opportunity?.stage === 'WON'} @change=${(e: any) => this.chooseStage(e.target.value)}>\n ${stageChoices.map(one => html`<option value=${one.stage} ?selected=${one.stage === this.form.stage} ?disabled=${!one.open}>${opportunityStageWord(one.stage)}</option>`)}\n </select>\n </label>\n <label\n >${i18next.t('field.opportunity-probability')}\n <input type=\"number\" min=\"0\" max=\"100\" step=\"1\" .value=${this.form.probability} ?disabled=${!editable} @input=${(e: any) => set({ probability: e.target.value })}\n /></label>\n ${this.opportunity?.closedOn\n ? html`<label>${i18next.t('field.opportunity-closed-on')} <strong>${this.opportunity.closedOn}</strong></label>`\n : nothing}\n </div>\n </section>\n ${this.opportunity && this.isOpen(this.opportunity.stage) ? this.renderLose() : nothing}\n ${this.opportunity?.lostReason\n ? html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('field.opportunity-lost-reason')}</h3></header>\n <p>${this.opportunity.lostReason}</p>\n </section>`\n : nothing}\n ${this.opportunity ? this.renderQuotations() : nothing}\n ${attached && this.opportunity\n ? html`<section class=\"page-section\" @opportunity-changed=${() => this.load(this.opportunity.id)}>\n <header class=\"page-section-header\"><h3>${attached.heading()}</h3></header>\n ${attached.render(this.opportunity)}\n </section>`\n : nothing}\n ${this.events.length ? this.renderEvents() : nothing}\n </div>\n </ox-page-state>`\n }\n\n /** A counterparty of the domain, found by name or business number. */\n private renderParty(which: 'counterparty' | 'endCustomer', label: string, editable: boolean) {\n const picker = this.pickers[which]\n const chosen = this.form[which]\n return html`<label\n >${label}\n <span class=\"party\">\n <input\n .value=${picker.search}\n placeholder=${chosen?.name ?? i18next.t('text.opportunity-counterparty-search')}\n ?disabled=${!editable}\n @input=${(e: any) => this.setPicker(which, { search: e.target.value })}\n @keydown=${(e: KeyboardEvent) => e.key === 'Enter' && this.findParties(which)}\n />\n <button ?disabled=${!editable} @click=${() => this.findParties(which)}>${i18next.t('button.search')}</button>\n ${which === 'endCustomer' && chosen ? html`<button ?disabled=${!editable} @click=${() => (this.form = { ...this.form, endCustomer: null })}>${i18next.t('button.opportunity-clear')}</button>` : nothing}\n </span>\n ${picker.found.length\n ? html`<select ?disabled=${!editable} @change=${(e: any) => this.chooseParty(which, picker.found.find(one => one.id === e.target.value) ?? null)}>\n <option value=\"\">${chosen?.name ?? ''}</option>\n ${picker.found.map(one => html`<option value=${one.id}>${one.name}${one.businessNumber ? ` (${one.businessNumber})` : ''}</option>`)}\n </select>`\n : nothing}\n </label>`\n }\n\n private renderLose() {\n return html`<section class=\"page-section\">\n <header class=\"page-section-header\">\n <h3>${i18next.t('text.opportunity-section-lose')}</h3>\n <div class=\"page-section-actions\">\n <button ?disabled=${this.busy || !this.reason.trim()} @click=${() => this.lose()}>${i18next.t('button.opportunity-lose')}</button>\n </div>\n </header>\n <div class=\"form\">\n <label class=\"wide\"\n >${i18next.t('field.opportunity-lost-reason')}\n <input .value=${this.reason} ?disabled=${this.busy} @input=${(e: any) => (this.reason = e.target.value)}\n /></label>\n </div>\n </section>`\n }\n\n /** The quotations that answer this opportunity; a new one is written from here and answers it. */\n private renderQuotations() {\n const quotations: any[] = this.opportunity.quotations ?? []\n return html`<section class=\"page-section\">\n <header class=\"page-section-header\">\n <h3>${i18next.t('text.opportunity-section-quotations')}</h3>\n <div class=\"page-section-actions\">\n <button ?disabled=${this.busy || this.opportunity.stage === 'WON' || this.opportunity.stage === 'LOST'} @click=${() => navigate(`quotation-editor?opportunity=${this.opportunity.id}`)}>\n ${i18next.t('button.opportunity-new-quotation')}\n </button>\n </div>\n </header>\n ${quotations.length\n ? html`<table>\n <thead>\n <tr>\n <th>${i18next.t('field.quotation-number')}</th>\n <th>${i18next.t('field.quotation-version')}</th>\n <th>${i18next.t('field.quotation-status')}</th>\n <th>${i18next.t('field.quotation-issue-date')}</th>\n <th class=\"number\">${i18next.t('field.quotation-total-amount')}</th>\n </tr>\n </thead>\n <tbody>\n ${quotations.map(\n one => html`<tr>\n <td><a href=${`quotation-editor?id=${one.id}`}>${one.number}</a></td>\n <td>v${one.version}</td>\n <td>${quotationStatusWord(one.status)}</td>\n <td>${one.issueDate ?? ''}</td>\n <td class=\"number\">${documentAmount(one.totalAmount, one.currency || 'KRW')}</td>\n </tr>`\n )}\n </tbody>\n </table>`\n : nothing}\n </section>`\n }\n\n private renderEvents() {\n return html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.opportunity-section-history')}</h3></header>\n <table>\n <thead>\n <tr>\n <th>${i18next.t('field.opportunity-event-at')}</th>\n <th>${i18next.t('field.opportunity-event-actor')}</th>\n <th>${i18next.t('field.opportunity-event-action')}</th>\n <th>${i18next.t('field.opportunity-stage')}</th>\n <th class=\"number\">${i18next.t('field.opportunity-probability')}</th>\n </tr>\n </thead>\n <tbody>\n ${this.events.map(\n one => html`<tr>\n <td>${one.createdAt ? new Date(one.createdAt).toLocaleString() : ''}</td>\n <td>${one.actor?.name ?? ''}</td>\n <td>${eventWord(one.action)}${one.reason ? ` · ${one.reason}` : ''}</td>\n <td>${one.fromStage ? `${opportunityStageWord(one.fromStage)} → ` : ''}${opportunityStageWord(one.stage)}</td>\n <td class=\"number\">${one.probability}%</td>\n </tr>`\n )}\n </tbody>\n </table>\n </section>`\n }\n\n private setPicker(which: 'counterparty' | 'endCustomer', patch: Partial<Picker>) {\n this.pickers = { ...this.pickers, [which]: { ...this.pickers[which], ...patch } }\n }\n\n private chooseParty(which: 'counterparty' | 'endCustomer', party: Party | null) {\n if (!party) return\n this.form = { ...this.form, [which]: party }\n this.setPicker(which, { search: '', found: [] })\n }\n\n /** The stage's own probability comes in with it; the person may change it afterwards. */\n private chooseStage(stage: string) {\n const given = this.stages.find(one => one.stage === stage)\n this.form = { ...this.form, stage, probability: given ? String(given.probability) : this.form.probability }\n }\n\n private async readChoices() {\n try {\n const response = await client.query({\n query: gql`\n query {\n opportunityStages { stage probability open }\n opportunityOwners { id name email }\n }\n `,\n fetchPolicy: 'no-cache'\n })\n if (response.errors?.length) throw response\n this.stages = response.data.opportunityStages\n this.owners = response.data.opportunityOwners\n } catch (error) {\n this.error = error\n }\n }\n\n private async findParties(which: 'counterparty' | 'endCustomer') {\n await this.run(async () => {\n const response = await client.query({\n query: gql`\n query ($search: String, $pagination: Pagination) {\n counterparties: counterpartyChoices(search: $search, pagination: $pagination) {\n items { id name businessNumber }\n }\n }\n `,\n variables: { search: this.pickers[which].search.trim() || undefined, pagination: { page: 1, limit: 30 } },\n fetchPolicy: 'no-cache'\n })\n if (response.errors?.length) throw response\n const found: Party[] = response.data.counterparties.items ?? []\n if (found.length === 1) this.chooseParty(which, found[0])\n else this.setPicker(which, { found })\n })\n }\n\n private async load(id: string) {\n this.loading = true\n this.error = null\n try {\n const response = await client.query({\n query: gql(`query ($id: String!) { opportunity(id: $id) { ${FIELDS} } opportunityEvents(opportunityId: $id) { id action fromStage stage probability reason createdAt actor { id name } } }`),\n variables: { id },\n fetchPolicy: 'no-cache'\n })\n if (response.errors?.length) throw response\n if (!response.data.opportunity) throw new Error(i18next.t('text.opportunity-not-found'))\n this.show(response.data.opportunity, response.data.opportunityEvents)\n } catch (error) {\n this.error = error\n } finally {\n this.loading = false\n this.updateContext()\n }\n }\n\n private show(opportunity: any, events: any[]) {\n this.opportunity = opportunity\n this.events = events\n this.form = {\n name: opportunity.name,\n counterparty: opportunity.counterparty,\n endCustomer: opportunity.endCustomer,\n amount: String(opportunity.amount ?? 0),\n currency: opportunity.currency,\n expectedCloseMonth: opportunity.expectedCloseMonth,\n stage: opportunity.stage,\n probability: String(opportunity.probability),\n ownerId: opportunity.ownerId ?? '',\n description: opportunity.description ?? ''\n }\n this.reason = ''\n }\n\n private async run<T>(work: () => Promise<T>): Promise<T | undefined> {\n if (this.busy) return undefined\n this.busy = true\n try {\n return await work()\n } catch (error: any) {\n notify({ level: 'error', message: error?.graphQLErrors?.[0]?.message ?? error?.errors?.[0]?.message ?? error?.message ?? String(error) })\n return undefined\n } finally {\n this.busy = false\n }\n }\n\n private input() {\n const { name, counterparty, endCustomer, amount, currency, expectedCloseMonth, stage, probability, ownerId, description } = this.form\n return {\n name,\n counterpartyId: counterparty?.id ?? '',\n endCustomerId: endCustomer?.id ?? null,\n amount: Number(amount || 0),\n currency,\n expectedCloseMonth,\n stage,\n probability: probability === '' ? null : Number(probability),\n ownerId: ownerId || null,\n description\n }\n }\n\n private async save() {\n const id = this.opportunity?.id\n const saved = await this.run(async () => {\n const response = await client.mutate({\n mutation: gql(\n id\n ? `mutation ($id: String!, $opportunity: NewOpportunity!) { opportunity: updateOpportunity(id: $id, opportunity: $opportunity) { id } }`\n : `mutation ($opportunity: NewOpportunity!) { opportunity: createOpportunity(opportunity: $opportunity) { id } }`\n ),\n variables: { ...(id ? { id } : {}), opportunity: this.input() }\n })\n if (response.errors?.length) throw response\n return response.data.opportunity as { id: string }\n })\n if (!saved) return\n if (!id) navigate(`opportunity-editor?id=${saved.id}`)\n else await this.load(id)\n }\n\n private async lose() {\n const id = this.opportunity!.id\n const lost = await this.run(async () => {\n const response = await client.mutate({\n mutation: gql`\n mutation ($id: String!, $reason: String!) {\n loseOpportunity(id: $id, reason: $reason) { id }\n }\n `,\n variables: { id, reason: this.reason.trim() }\n })\n if (response.errors?.length) throw response\n return response.data.loseOpportunity\n })\n if (lost) await this.load(id)\n }\n}\n\nconst eventWord = (action?: string) =>\n action === 'CREATED'\n ? i18next.t('text.opportunity-event-created')\n : action === 'STAGED'\n ? i18next.t('text.opportunity-event-staged')\n : action === 'WON'\n ? i18next.t('text.opportunity-event-won')\n : action === 'LOST'\n ? i18next.t('text.opportunity-event-lost')\n : action === 'REOPENED'\n ? i18next.t('text.opportunity-event-reopened')\n : i18next.t('text.opportunity-event-updated')\n\nfunction blank(stages: { stage: string; probability: number }[] = []): Form {\n const lead = stages.find(one => one.stage === 'LEAD')\n return {\n name: '',\n counterparty: null,\n endCustomer: null,\n amount: '0',\n currency: 'KRW',\n expectedCloseMonth: thisMonth(),\n stage: 'LEAD',\n probability: lead ? String(lead.probability) : '',\n ownerId: '',\n description: ''\n }\n}\n"]}
1
+ {"version":3,"file":"opportunity-editor.js","sourceRoot":"","sources":["../../client/pages/opportunity-editor.ts"],"names":[],"mappings":";AAAA,OAAO,sCAAsC,CAAA;AAE7C,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM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SAAS,EAAE;QAC/B,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE;QACjD,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,EAAE;KAChB,CAAA;AACH,CAAC","sourcesContent":["import '@operato/list-state/ox-page-state.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, nothing } from 'lit'\nimport { customElement, state } from 'lit/decorators.js'\n\nimport { client, MutationController, QueryController } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { navigate, PageView, DraftController } from '@operato/shell'\nimport { ButtonStyles, DocumentPageStyles, FormFieldStyles } from '@operato/styles'\nimport { currencyChoices, documentAmount, DocumentFormStyles } from '@things-factory/invoice/dist-client'\n\nimport { opportunitySection } from '../opportunity-attach'\nimport { opportunityStageWord } from '../opportunity-words'\nimport { quotationStatusWord } from '../quotation-words'\n\nconst FIELDS = `\n id name stage probability amount currency expectedCloseMonth closedOn lostReason description\n counterpartyId endCustomerId ownerId counterparty { id name } endCustomer { id name } owner { id name }\n quotations { id number version status issueDate validUntil totalAmount currency }\n`\n\ntype Party = { id: string; name: string; businessNumber?: string }\ntype Picker = { search: string; found: Party[] }\ntype Form = {\n name: string\n counterparty: Party | null\n endCustomer: Party | null\n amount: string\n currency: string\n expectedCloseMonth: string\n stage: string\n probability: string\n ownerId: string\n description: string\n}\n\nconst READ = gql(`\n query ($id: String!) {\n opportunity(id: $id) { ${FIELDS} }\n opportunityEvents(opportunityId: $id) { id action fromStage stage probability reason createdAt actor { id name } }\n }\n`)\n\nconst thisMonth = () => new Date().toLocaleDateString('en-CA').slice(0, 7)\n\n/**\n * 영업 기회 편집 — with whom, for how much, by when and how likely.\n *\n * A person moves an open opportunity through the stages; changing the stage puts that stage's probability in, and the\n * person may change it. An open one is closed as lost with the reason; a lost one is opened again by choosing an open\n * stage. Winning is the application's: it closes the opportunity when the opportunity becomes its contract.\n */\n@customElement('opportunity-editor')\nexport class OpportunityEditor extends localize(i18next)(PageView) {\n static styles = [\n FormFieldStyles,\n ButtonStyles,\n DocumentPageStyles,\n DocumentFormStyles,\n css`\n .party {\n display: flex;\n gap: var(--spacing-small);\n align-items: center;\n }\n .party input {\n flex: 1;\n }\n table {\n width: 100%;\n border-collapse: collapse;\n font-variant-numeric: tabular-nums;\n }\n th,\n td {\n text-align: left;\n padding: var(--spacing-small);\n border-bottom: 1px solid var(--ui-line-soft);\n font-size: var(--ui-t-body);\n }\n th.number,\n td.number {\n text-align: right;\n }\n td a {\n color: inherit;\n text-decoration: underline;\n }\n `\n ]\n\n /** The opportunity the address names; none for a new one. */\n @state() private opportunityId = ''\n @state() pickers: Record<'counterparty' | 'endCustomer', Picker> = { counterparty: { search: '', found: [] }, endCustomer: { search: '', found: [] } }\n /** Whether the application's section is this person's to read - asked once, before it is shown. */\n @state() sectionReadable = false\n\n /* The stages with their probabilities and who may own one, and the opportunity the address names (ADR-0190). */\n private choices = new QueryController(\n this,\n gql`\n query {\n opportunityStages { stage probability open }\n opportunityOwners { id name email }\n }\n `\n )\n private record = new QueryController(this, READ, { variables: () => (this.opportunityId ? { id: this.opportunityId } : undefined) })\n\n /* What is typed over the opportunity read - a new one starts blank, at the first stage. */\n private draft = new DraftController<Form>(this, { read: () => (this.opportunityId ? this.opportunity && formOf(this.opportunity) : blank(this.stages)), key: () => this.opportunityId })\n /* The reason a lost one is closed with. */\n private loss = new DraftController<{ reason: string }>(this, { read: () => ({ reason: '' }), key: () => this.opportunityId })\n\n /* Every change reads the opportunity again once it is done. */\n private saves = {\n create: new MutationController(this, gql`mutation ($opportunity: NewOpportunity!) { opportunity: createOpportunity(opportunity: $opportunity) { id } }`),\n update: this.change(gql`mutation ($id: String!, $opportunity: NewOpportunity!) { opportunity: updateOpportunity(id: $id, opportunity: $opportunity) { id } }`),\n lose: this.change(gql`mutation ($id: String!, $reason: String!) { loseOpportunity(id: $id, reason: $reason) { id } }`)\n }\n\n private change(mutation: any) {\n return new MutationController(this, mutation, { refetch: () => [this.record] })\n }\n\n private get opportunity(): any {\n return (this.opportunityId && this.record.data?.opportunity) || null\n }\n\n private get events(): any[] {\n return (this.opportunityId && this.record.data?.opportunityEvents) || []\n }\n\n private get stages(): { stage: string; probability: number; open: boolean }[] {\n return this.choices.data?.opportunityStages ?? []\n }\n\n private get owners(): { id: string; name: string; email?: string }[] {\n return this.choices.data?.opportunityOwners ?? []\n }\n\n /** The form as it shows: each field's edit, else what was read (blank while it is read). */\n private get form(): Form {\n return Object.fromEntries(Object.entries(blank(this.stages)).map(([name, given]) => [name, this.draft.value(name as keyof Form) ?? given])) as Form\n }\n\n private get reason() {\n return this.loss.value('reason') ?? ''\n }\n\n /** A failed read, or an opportunity the address names that is not there. */\n private get error(): unknown {\n if (this.choices.error || this.record.error) return this.choices.error ?? this.record.error\n return this.opportunityId && this.record.data && !this.record.data.opportunity ? new Error(i18next.t('text.opportunity-not-found')) : null\n }\n\n private get loading() {\n return this.choices.loading || this.record.loading\n }\n\n private get busy() {\n return Object.values(this.saves).some(save => save.pending)\n }\n\n private isOpen(stage: string) {\n return this.stages.some(one => one.stage === stage && one.open)\n }\n\n /** Won is final; a lost one is changed only by being opened again. */\n get editable() {\n return !this.busy && this.opportunity?.stage !== 'WON' && this.isOpen(this.form.stage)\n }\n\n get context() {\n const actions: any[] = []\n if (this.editable) actions.push({ title: i18next.t('button.save'), icon: 'save', emphasis: { raised: true }, action: () => this.save() })\n return {\n title: this.opportunity ? `${i18next.t('title.opportunity')} ${this.opportunity.name}` : i18next.t('title.opportunity-new'),\n ...(this.opportunity ? { description: opportunityStageWord(this.opportunity.stage) } : {}),\n frame: 'document',\n /* Opened from the opportunity list; the menu marks it. */\n menu: 'opportunity-list',\n actions: this.error ? [] : actions\n }\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (!this.active || !(changes.active || changes.params)) return\n const section = opportunitySection()\n if (section && !this.sectionReadable) (section.readable?.() ?? Promise.resolve(true)).then(may => (this.sectionReadable = !!may))\n this.opportunityId = lifecycle?.params?.id ?? ''\n }\n\n render() {\n const attached = this.opportunity && this.sectionReadable ? opportunitySection() : undefined\n const editable = this.editable\n const set = (patch: Partial<Form>) => this.edit(patch)\n const stageChoices = this.stages.filter(one => one.open || one.stage === this.opportunity?.stage)\n return html`<ox-page-state .loading=${this.loading} .error=${this.error} @retry=${() => (this.choices.refetch(), this.record.refetch())}>\n <div class=\"page\">\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.opportunity-section-head')}</h3></header>\n <div class=\"form\">\n <label class=\"wide\"\n >${i18next.t('field.opportunity-name')}\n <input .value=${this.form.name} ?disabled=${!editable} @input=${(e: any) => set({ name: e.target.value })}\n /></label>\n ${this.renderParty('counterparty', i18next.t('field.opportunity-counterparty'), editable)}\n ${this.renderParty('endCustomer', i18next.t('field.opportunity-end-customer'), editable)}\n <label\n >${i18next.t('field.opportunity-amount')}\n <input type=\"number\" min=\"0\" .value=${this.form.amount} ?disabled=${!editable} @input=${(e: any) => set({ amount: e.target.value })}\n /></label>\n <label\n >${i18next.t('field.opportunity-currency')}\n <select .value=${this.form.currency} ?disabled=${!editable} @change=${(e: any) => set({ currency: e.target.value })}>\n ${currencyChoices().map((code: string) => html`<option value=${code} ?selected=${code === this.form.currency}>${code}</option>`)}\n </select>\n </label>\n <label\n >${i18next.t('field.opportunity-expected-close-month')}\n <input type=\"month\" .value=${this.form.expectedCloseMonth} ?disabled=${!editable} @input=${(e: any) => set({ expectedCloseMonth: e.target.value })}\n /></label>\n <label\n >${i18next.t('field.opportunity-owner')}\n <select .value=${this.form.ownerId} ?disabled=${!editable} @change=${(e: any) => set({ ownerId: e.target.value })}>\n ${this.form.ownerId ? nothing : html`<option value=\"\" selected>${i18next.t('text.opportunity-owner-me')}</option>`}\n ${this.owners.map(one => html`<option value=${one.id} ?selected=${one.id === this.form.ownerId}>${one.name}</option>`)}\n </select>\n </label>\n <label class=\"wide\"\n >${i18next.t('field.opportunity-description')}\n <textarea .value=${this.form.description} ?disabled=${!editable} @input=${(e: any) => set({ description: e.target.value })}></textarea>\n </label>\n </div>\n </section>\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.opportunity-section-stage')}</h3></header>\n <div class=\"form\">\n <label\n >${i18next.t('field.opportunity-stage')}\n <select .value=${this.form.stage} ?disabled=${this.busy || this.opportunity?.stage === 'WON'} @change=${(e: any) => this.chooseStage(e.target.value)}>\n ${stageChoices.map(one => html`<option value=${one.stage} ?selected=${one.stage === this.form.stage} ?disabled=${!one.open}>${opportunityStageWord(one.stage)}</option>`)}\n </select>\n </label>\n <label\n >${i18next.t('field.opportunity-probability')}\n <input type=\"number\" min=\"0\" max=\"100\" step=\"1\" .value=${this.form.probability} ?disabled=${!editable} @input=${(e: any) => set({ probability: e.target.value })}\n /></label>\n ${this.opportunity?.closedOn\n ? html`<label>${i18next.t('field.opportunity-closed-on')} <strong>${this.opportunity.closedOn}</strong></label>`\n : nothing}\n </div>\n </section>\n ${this.opportunity && this.isOpen(this.opportunity.stage) ? this.renderLose() : nothing}\n ${this.opportunity?.lostReason\n ? html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('field.opportunity-lost-reason')}</h3></header>\n <p>${this.opportunity.lostReason}</p>\n </section>`\n : nothing}\n ${this.opportunity ? this.renderQuotations() : nothing}\n ${attached && this.opportunity\n ? html`<section class=\"page-section\" @opportunity-changed=${() => this.record.refetch()}>\n <header class=\"page-section-header\"><h3>${attached.heading()}</h3></header>\n ${attached.render(this.opportunity)}\n </section>`\n : nothing}\n ${this.events.length ? this.renderEvents() : nothing}\n </div>\n </ox-page-state>`\n }\n\n /** A counterparty of the domain, found by name or business number. */\n private renderParty(which: 'counterparty' | 'endCustomer', label: string, editable: boolean) {\n const picker = this.pickers[which]\n const chosen = this.form[which]\n return html`<label\n >${label}\n <span class=\"party\">\n <input\n .value=${picker.search}\n placeholder=${chosen?.name ?? i18next.t('text.opportunity-counterparty-search')}\n ?disabled=${!editable}\n @input=${(e: any) => this.setPicker(which, { search: e.target.value })}\n @keydown=${(e: KeyboardEvent) => e.key === 'Enter' && this.findParties(which)}\n />\n <button ?disabled=${!editable} @click=${() => this.findParties(which)}>${i18next.t('button.search')}</button>\n ${which === 'endCustomer' && chosen ? html`<button ?disabled=${!editable} @click=${() => this.edit({ endCustomer: null })}>${i18next.t('button.opportunity-clear')}</button>` : nothing}\n </span>\n ${picker.found.length\n ? html`<select ?disabled=${!editable} @change=${(e: any) => this.chooseParty(which, picker.found.find(one => one.id === e.target.value) ?? null)}>\n <option value=\"\">${chosen?.name ?? ''}</option>\n ${picker.found.map(one => html`<option value=${one.id}>${one.name}${one.businessNumber ? ` (${one.businessNumber})` : ''}</option>`)}\n </select>`\n : nothing}\n </label>`\n }\n\n private renderLose() {\n return html`<section class=\"page-section\">\n <header class=\"page-section-header\">\n <h3>${i18next.t('text.opportunity-section-lose')}</h3>\n <div class=\"page-section-actions\">\n <button ?disabled=${this.busy || !this.reason.trim()} @click=${() => this.lose()}>${i18next.t('button.opportunity-lose')}</button>\n </div>\n </header>\n <div class=\"form\">\n <label class=\"wide\"\n >${i18next.t('field.opportunity-lost-reason')}\n <input .value=${this.reason} ?disabled=${this.busy} @input=${(e: any) => this.loss.set('reason', e.target.value)}\n /></label>\n </div>\n </section>`\n }\n\n /** The quotations that answer this opportunity; a new one is written from here and answers it. */\n private renderQuotations() {\n const quotations: any[] = this.opportunity.quotations ?? []\n return html`<section class=\"page-section\">\n <header class=\"page-section-header\">\n <h3>${i18next.t('text.opportunity-section-quotations')}</h3>\n <div class=\"page-section-actions\">\n <button ?disabled=${this.busy || this.opportunity.stage === 'WON' || this.opportunity.stage === 'LOST'} @click=${() => navigate(`quotation-editor?opportunity=${this.opportunity.id}`)}>\n ${i18next.t('button.opportunity-new-quotation')}\n </button>\n </div>\n </header>\n ${quotations.length\n ? html`<table>\n <thead>\n <tr>\n <th>${i18next.t('field.quotation-number')}</th>\n <th>${i18next.t('field.quotation-version')}</th>\n <th>${i18next.t('field.quotation-status')}</th>\n <th>${i18next.t('field.quotation-issue-date')}</th>\n <th class=\"number\">${i18next.t('field.quotation-total-amount')}</th>\n </tr>\n </thead>\n <tbody>\n ${quotations.map(\n one => html`<tr>\n <td><a href=${`quotation-editor?id=${one.id}`}>${one.number}</a></td>\n <td>v${one.version}</td>\n <td>${quotationStatusWord(one.status)}</td>\n <td>${one.issueDate ?? ''}</td>\n <td class=\"number\">${documentAmount(one.totalAmount, one.currency || 'KRW')}</td>\n </tr>`\n )}\n </tbody>\n </table>`\n : nothing}\n </section>`\n }\n\n private renderEvents() {\n return html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.opportunity-section-history')}</h3></header>\n <table>\n <thead>\n <tr>\n <th>${i18next.t('field.opportunity-event-at')}</th>\n <th>${i18next.t('field.opportunity-event-actor')}</th>\n <th>${i18next.t('field.opportunity-event-action')}</th>\n <th>${i18next.t('field.opportunity-stage')}</th>\n <th class=\"number\">${i18next.t('field.opportunity-probability')}</th>\n </tr>\n </thead>\n <tbody>\n ${this.events.map(\n one => html`<tr>\n <td>${one.createdAt ? new Date(one.createdAt).toLocaleString() : ''}</td>\n <td>${one.actor?.name ?? ''}</td>\n <td>${eventWord(one.action)}${one.reason ? ` · ${one.reason}` : ''}</td>\n <td>${one.fromStage ? `${opportunityStageWord(one.fromStage)} → ` : ''}${opportunityStageWord(one.stage)}</td>\n <td class=\"number\">${one.probability}%</td>\n </tr>`\n )}\n </tbody>\n </table>\n </section>`\n }\n\n private edit(patch: Partial<Form>) {\n for (const [name, value] of Object.entries(patch)) this.draft.set(name as keyof Form, value)\n }\n\n private setPicker(which: 'counterparty' | 'endCustomer', patch: Partial<Picker>) {\n this.pickers = { ...this.pickers, [which]: { ...this.pickers[which], ...patch } }\n }\n\n private chooseParty(which: 'counterparty' | 'endCustomer', party: Party | null) {\n if (!party) return\n this.edit({ [which]: party })\n this.setPicker(which, { search: '', found: [] })\n }\n\n /** The stage's own probability comes in with it; the person may change it afterwards. */\n private chooseStage(stage: string) {\n const given = this.stages.find(one => one.stage === stage)\n this.edit({ stage, probability: given ? String(given.probability) : this.form.probability })\n }\n\n /**\n * The counterparties the words find - a look-up on asking, not a read the page keeps: one match is taken at once,\n * more are listed to choose from. A failure is told by the GraphQL link.\n */\n private async findParties(which: 'counterparty' | 'endCustomer') {\n try {\n const response = await client.query({\n query: gql`\n query ($search: String, $pagination: Pagination) {\n counterparties: counterpartyChoices(search: $search, pagination: $pagination) {\n items { id name businessNumber }\n }\n }\n `,\n variables: { search: this.pickers[which].search.trim() || undefined, pagination: { page: 1, limit: 30 } },\n fetchPolicy: 'no-cache'\n })\n const found: Party[] = response.data?.counterparties?.items ?? []\n if (found.length === 1) this.chooseParty(which, found[0])\n else this.setPicker(which, { found })\n } catch {\n /* Told by the GraphQL link. */\n }\n }\n\n private input() {\n const { name, counterparty, endCustomer, amount, currency, expectedCloseMonth, stage, probability, ownerId, description } = this.form\n return {\n name,\n counterpartyId: counterparty?.id ?? '',\n endCustomerId: endCustomer?.id ?? null,\n amount: Number(amount || 0),\n currency,\n expectedCloseMonth,\n stage,\n probability: probability === '' ? null : Number(probability),\n ownerId: ownerId || null,\n description\n }\n }\n\n /** A new one is opened once it is made; the edits sent are cleared once the save answered. */\n private async save() {\n if (this.busy) return\n const id = this.opportunityId\n const saved = await this.draft.submit(() =>\n id ? this.saves.update.run({ id, opportunity: this.input() }) : this.saves.create.run({ opportunity: this.input() })\n )\n if (saved && !id) navigate(`opportunity-editor?id=${saved.opportunity.id}`)\n }\n\n private async lose() {\n if (this.busy) return\n const id = this.opportunityId\n await this.loss.submit(sent => this.saves.lose.run({ id, reason: (sent.reason ?? '').trim() }))\n }\n}\n\nconst eventWord = (action?: string) =>\n action === 'CREATED'\n ? i18next.t('text.opportunity-event-created')\n : action === 'STAGED'\n ? i18next.t('text.opportunity-event-staged')\n : action === 'WON'\n ? i18next.t('text.opportunity-event-won')\n : action === 'LOST'\n ? i18next.t('text.opportunity-event-lost')\n : action === 'REOPENED'\n ? i18next.t('text.opportunity-event-reopened')\n : i18next.t('text.opportunity-event-updated')\n\n/** The form of an opportunity as read. */\nfunction formOf(opportunity: any): Form {\n return {\n name: opportunity.name,\n counterparty: opportunity.counterparty,\n endCustomer: opportunity.endCustomer,\n amount: String(opportunity.amount ?? 0),\n currency: opportunity.currency,\n expectedCloseMonth: opportunity.expectedCloseMonth,\n stage: opportunity.stage,\n probability: String(opportunity.probability),\n ownerId: opportunity.ownerId ?? '',\n description: opportunity.description ?? ''\n }\n}\n\nfunction blank(stages: { stage: string; probability: number }[] = []): Form {\n const lead = stages.find(one => one.stage === 'LEAD')\n return {\n name: '',\n counterparty: null,\n endCustomer: null,\n amount: '0',\n currency: 'KRW',\n expectedCloseMonth: thisMonth(),\n stage: 'LEAD',\n probability: lead ? String(lead.probability) : '',\n ownerId: '',\n description: ''\n }\n}\n"]}
@@ -19,8 +19,9 @@ export declare class OpportunityList extends OpportunityList_base {
19
19
  private stages?;
20
20
  private owner;
21
21
  private closePeriod;
22
- private owners;
22
+ private ownerChoices;
23
23
  private grist;
24
+ private get owners();
24
25
  get context(): {
25
26
  title: string;
26
27
  search: {
@@ -45,8 +46,6 @@ export declare class OpportunityList extends OpportunityList_base {
45
46
  };
46
47
  render(): import("lit-html").TemplateResult<1>;
47
48
  pageInitialized(): Promise<void>;
48
- /** The people an opportunity may be put in the charge of - the editor's choices. */
49
- private readOwners;
50
49
  fetchHandler({ page, limit, sortings, filters, search }: FetchOption): Promise<{
51
50
  total: number;
52
51
  records: any[];
@@ -5,7 +5,7 @@ import gql from 'graphql-tag';
5
5
  import { html } from 'lit';
6
6
  import { customElement, query, state } from 'lit/decorators.js';
7
7
  import { DataGrist } from '@operato/data-grist';
8
- import { client } from '@operato/graphql';
8
+ import { client, QueryController } from '@operato/graphql';
9
9
  import { i18next, localize } from '@operato/i18n';
10
10
  import { entity360Name } from '@operato/layout';
11
11
  import { navigate, PageView } from '@operato/shell';
@@ -33,9 +33,13 @@ let OpportunityList = class OpportunityList extends localize(i18next)(PageView)
33
33
  /* The person in charge narrowed to (a user id), and the expected-close period. */
34
34
  this.owner = '';
35
35
  this.closePeriod = '';
36
- this.owners = [];
36
+ /* The people an opportunity may be put in the charge of - the editor's choices (ADR-0190). */
37
+ this.ownerChoices = new QueryController(this, gql `{ opportunityOwners { id name } }`);
37
38
  }
38
39
  static { this.styles = [WorkSurfacePageStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles]; }
40
+ get owners() {
41
+ return (this.ownerChoices.data?.opportunityOwners ?? []).map((one) => ({ value: one.id, display: one.name }));
42
+ }
39
43
  get context() {
40
44
  return {
41
45
  title: i18next.t('title.opportunity-list'),
@@ -88,7 +92,6 @@ let OpportunityList = class OpportunityList extends localize(i18next)(PageView)
88
92
  </ox-grist>`;
89
93
  }
90
94
  async pageInitialized() {
91
- this.readOwners();
92
95
  const open = (record) => record?.id && navigate(`opportunity-editor?id=${record.id}`);
93
96
  const party = (value) => (value ? entity360Name({ __typename: 'Counterparty', ...value }, value.name) : '');
94
97
  const readonly = (type, name, header, width, extra = {}) => ({
@@ -125,11 +128,6 @@ let OpportunityList = class OpportunityList extends localize(i18next)(PageView)
125
128
  sorters: [{ name: 'expectedCloseMonth' }]
126
129
  };
127
130
  }
128
- /** The people an opportunity may be put in the charge of - the editor's choices. */
129
- async readOwners() {
130
- const response = await client.query({ query: gql `{ opportunityOwners { id name } }`, fetchPolicy: 'no-cache' });
131
- this.owners = (response.data?.opportunityOwners ?? []).map((one) => ({ value: one.id, display: one.name }));
132
- }
133
131
  async fetchHandler({ page = 1, limit = 50, sortings = [], filters = [], search }) {
134
132
  search = search?.trim() || undefined;
135
133
  filters = [...filters, ...this.headroomFilters()];
@@ -215,10 +213,6 @@ __decorate([
215
213
  state(),
216
214
  __metadata("design:type", Object)
217
215
  ], OpportunityList.prototype, "closePeriod", void 0);
218
- __decorate([
219
- state(),
220
- __metadata("design:type", Array)
221
- ], OpportunityList.prototype, "owners", void 0);
222
216
  __decorate([
223
217
  query('ox-grist'),
224
218
  __metadata("design:type", DataGrist)
@@ -1 +1 @@
1
- {"version":3,"file":"opportunity-list.js","sourceRoot":"","sources":["../../client/pages/opportunity-list.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,2CAA2C,CAAA;AAElD,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE/D,OAAO,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAC/G,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAA;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAE3D,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAA;AAI1D;;;;;;;;GAQG;AAEI,IAAM,eAAe,GAArB,M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;;;;;;;;OAQT;YACD,SAAS,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;YAC9B,WAAW,EAAE,cAAc;SAC5B,CAAC,CAAA;QACF,IAAI,QAAQ,CAAC,MAAM,EAAE,MAAM;YAAE,MAAM,QAAQ,CAAA;QAC3C,OAAO,CAAC,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,sBAAsC,CAAC,CAAA;IAClF,CAAC;IAEO,KAAK,CAAC,SAAS,CAAC,OAAc,EAAE,UAA2C,EAAE,QAAe,EAAE,MAAe;QACnH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;YAClC,KAAK,EAAE,GAAG,CAAA;;;;;;;;;;;;;;;;;;OAkBT;YACD,SAAS,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE;YACpD,WAAW,EAAE,cAAc;SAC5B,CAAC,CAAA;QACF,IAAI,QAAQ,CAAC,MAAM,EAAE,MAAM;YAAE,MAAM,QAAQ,CAAA;QAC3C,OAAO,QAAQ,CAAC,IAAI,CAAC,SAA4C,CAAA;IACnE,CAAC;;AArLQ;IAAR,KAAK,EAAE;;oDAAiB;AACR;IAAhB,KAAK,EAAE;;oDAAuC;AAE9B;IAAhB,KAAK,EAAE;;+CAA0B;AAEjB;IAAhB,KAAK,EAAE;;8CAAmB;AACV;IAAhB,KAAK,EAAE;;oDAAyB;AAChB;IAAhB,KAAK,EAAE;;+CAA0D;AACvC;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;8CAAA;AAXjC,eAAe;IAD3B,aAAa,CAAC,kBAAkB,CAAC;GACrB,eAAe,CAyL3B","sourcesContent":["import '@operato/data-grist/ox-grist.js'\nimport '@operato/input/ox-input-select-buttons.js'\n\nimport gql from 'graphql-tag'\nimport { html } from 'lit'\nimport { customElement, query, state } from 'lit/decorators.js'\n\nimport { DataGrist, FetchOption } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { entity360Name } from '@operato/layout'\nimport { navigate, PageView } from '@operato/shell'\nimport { CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\nimport { isMobileDevice } from '@operato/utils'\nimport { SELECTION_ROW_PICKER } from '@things-factory/ai-assistant/dist-client/index.js'\nimport { documentAmount } from '@things-factory/invoice/dist-client'\n\nimport { closeMonthsOf } from '../close-months'\nimport { headroomChoice } from '../headroom-choice'\nimport { opportunityStageWord } from '../opportunity-words'\n\nconst today = () => new Date().toLocaleDateString('en-CA')\n\ntype StageCount = { stage: string; count: number; open: boolean }\n\n/**\n * 영업 기회 — every opportunity of the domain, narrowed by stage. The name opens its 360; the edit gutter its editor. Rows\n * picked go to the assistant (「AI와 작업」) as `opportunity:<uuid>`, read by the opportunity list's read (sales-read.ts).\n *\n * The person in charge and the expected-close period narrow it from the headroom. The stages are chips that narrow\n * the list, each with how many opportunities it holds under the other conditions — counted by the server, so the\n * numbers agree with one another whichever chips are pressed. The list opens on the open stages, won and lost left\n * out; with none pressed every stage shows.\n */\n@customElement('opportunity-list')\nexport class OpportunityList extends localize(i18next)(PageView) {\n static styles = [WorkSurfacePageStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles]\n\n @state() gristConfig: any\n @state() private stageCounts: StageCount[] = []\n /* The stages chosen; none until the first counts say which stages are open. */\n @state() private stages?: string[]\n /* The person in charge narrowed to (a user id), and the expected-close period. */\n @state() private owner = ''\n @state() private closePeriod = ''\n @state() private owners: { value: string; display: string }[] = []\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t('title.opportunity-list'),\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n value: this.grist?.searchText || ''\n },\n /* Narrowing by stage stays in the headroom, and this folds it. */\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n actions: [{ title: i18next.t('button.opportunity-new'), icon: 'add', emphasis: { raised: true }, action: () => navigate('opportunity-editor') }],\n exportable: { name: i18next.t('title.opportunity-list'), data: () => this.grist.exportRecords() }\n }\n }\n\n render() {\n return html`<ox-assistant-selection-bar\n .gridOf=${() => this.grist}\n name=${i18next.t('title.opportunity-list')}\n list=\"opportunities\"\n axis=\"opportunity\"\n .labelOf=${(row: any) => [row.name, row.counterparty?.name].filter(Boolean).join(' · ')}\n ></ox-assistant-selection-bar>\n <ox-grist\n class=\"page-fill\"\n search-mode=\"term\"\n .mode=${isMobileDevice() ? 'CARD' : 'GRID'}\n .config=${this.gristConfig}\n .fetchHandler=${this.fetchHandler.bind(this)}\n >\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n ${headroomChoice(\n i18next.t('field.opportunity-owner'),\n this.owner,\n [{ value: '', display: i18next.t('text.opportunity-owner-all') }, ...this.owners],\n value => ((this.owner = value), this.grist.fetch())\n )}\n ${headroomChoice(\n i18next.t('field.opportunity-expected-close-month'),\n this.closePeriod,\n ['', 'this-month', 'next-month', 'this-quarter', 'this-year'].map(value => ({ value, display: i18next.t(`text.opportunity-close-${value || 'all'}`) })),\n value => ((this.closePeriod = value), this.grist.fetch())\n )}\n <ox-input-select-buttons\n multiple\n .value=${this.stages ?? []}\n .options=${this.stageCounts.map(({ stage, count }) => ({ value: stage, display: opportunityStageWord(stage), count }))}\n @change=${(e: CustomEvent) => {\n this.stages = (e.currentTarget as any).value ?? []\n this.grist.fetch()\n }}\n ></ox-input-select-buttons>\n </div>\n </div>\n </ox-grist>`\n }\n\n async pageInitialized() {\n this.readOwners()\n const open = (record: any) => record?.id && navigate(`opportunity-editor?id=${record.id}`)\n const party = (value?: { id: string; name: string }) => (value ? entity360Name({ __typename: 'Counterparty', ...value }, value.name) : '')\n const readonly = (type: string, name: string, header: string, width: number, extra: any = {}) => ({\n type,\n name,\n header,\n width,\n sortable: true,\n ...extra,\n record: { editable: false, ...extra.record }\n })\n this.gristConfig = {\n rows: { appendable: false, selectable: { multiple: true } },\n pagination: { limit: 50, pages: [50, 100, 500] },\n emptyNote: { title: i18next.t('text.opportunity-empty'), description: i18next.t('text.opportunity-empty-description') },\n list: { fields: ['name', 'counterparty'], details: ['stage', 'expectedCloseMonth', 'amount'] },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n SELECTION_ROW_PICKER,\n { type: 'gutter', gutterName: 'button', icon: 'edit_note', handlers: { click: (_c: any, _d: any, _col: any, record: any) => open(record) } },\n readonly('string', 'name', i18next.t('field.opportunity-name'), 220, {\n record: { renderer: (_v: any, _c: any, record: any) => (record?.id ? entity360Name({ __typename: 'Opportunity', ...record }, record.name) : '') }\n }),\n readonly('string', 'counterparty', i18next.t('field.opportunity-counterparty'), 180, { sortable: false, record: { renderer: (value: any) => party(value) } }),\n readonly('string', 'endCustomer', i18next.t('field.opportunity-end-customer'), 160, { sortable: false, record: { renderer: (value: any) => party(value) } }),\n readonly('string', 'stage', i18next.t('field.opportunity-stage'), 90, { record: { renderer: (value: string) => opportunityStageWord(value) } }),\n readonly('integer', 'probability', i18next.t('field.opportunity-probability'), 70, { record: { align: 'right', renderer: (value: number) => `${value ?? 0}%` } }),\n readonly('float', 'amount', i18next.t('field.opportunity-amount'), 150, {\n record: { align: 'right', renderer: (value: number, _c: any, record: any) => documentAmount(value, record?.currency || 'KRW') }\n }),\n readonly('string', 'expectedCloseMonth', i18next.t('field.opportunity-expected-close-month'), 100),\n readonly('string', 'owner', i18next.t('field.opportunity-owner'), 110, { sortable: false, record: { renderer: (value: any) => value?.name ?? '' } })\n ],\n sorters: [{ name: 'expectedCloseMonth' }]\n }\n }\n\n /** The people an opportunity may be put in the charge of - the editor's choices. */\n private async readOwners() {\n const response = await client.query({ query: gql`{ opportunityOwners { id name } }`, fetchPolicy: 'no-cache' })\n this.owners = (response.data?.opportunityOwners ?? []).map((one: any) => ({ value: one.id, display: one.name }))\n }\n\n async fetchHandler({ page = 1, limit = 50, sortings = [], filters = [], search }: FetchOption) {\n search = search?.trim() || undefined\n filters = [...filters, ...this.headroomFilters()]\n const counting = this.fetchStageCounts(filters, search)\n if (!this.stages) this.stages = (await counting).filter(one => one.open).map(one => one.stage)\n const stages = this.stages.length ? [{ name: 'stage', operator: 'in', value: this.stages }] : []\n const [response] = await Promise.all([this.fetchPage([...filters, ...stages], { page, limit }, sortings, search), counting])\n return { total: response.total, records: response.items }\n }\n\n /* The owner and the close period as the list's filters - the stage counts are under them too. */\n private headroomFilters(): any[] {\n const months = closeMonthsOf(this.closePeriod, today())\n return [\n ...(this.owner ? [{ name: 'ownerId', operator: 'eq', value: this.owner }] : []),\n ...(months ? [{ name: 'expectedCloseMonth', operator: 'between', value: months }] : [])\n ]\n }\n\n private async fetchStageCounts(filters: any[], search?: string) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $search: String) {\n opportunityStageCounts(filters: $filters, search: $search) {\n stage\n count\n open\n }\n }\n `,\n variables: { filters, search },\n fetchPolicy: 'network-only'\n })\n if (response.errors?.length) throw response\n return (this.stageCounts = response.data.opportunityStageCounts as StageCount[])\n }\n\n private async fetchPage(filters: any[], pagination: { page: number; limit: number }, sortings: any[], search?: string) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $search: String) {\n responses: opportunities(filters: $filters, pagination: $pagination, sortings: $sortings, search: $search) {\n items {\n id\n name\n stage\n probability\n amount\n currency\n expectedCloseMonth\n counterparty { id name }\n endCustomer { id name }\n owner { id name }\n }\n total\n }\n }\n `,\n variables: { filters, pagination, sortings, search },\n fetchPolicy: 'network-only'\n })\n if (response.errors?.length) throw response\n return response.data.responses as { items: any[]; total: number }\n }\n}\n"]}
1
+ {"version":3,"file":"opportunity-list.js","sourceRoot":"","sources":["../../client/pages/opportunity-list.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,2CAA2C,CAAA;AAElD,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OA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OAkBT;YACD,SAAS,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE;YACpD,WAAW,EAAE,cAAc;SAC5B,CAAC,CAAA;QACF,IAAI,QAAQ,CAAC,MAAM,EAAE,MAAM;YAAE,MAAM,QAAQ,CAAA;QAC3C,OAAO,QAAQ,CAAC,IAAI,CAAC,SAA4C,CAAA;IACnE,CAAC;;AAnLQ;IAAR,KAAK,EAAE;;oDAAiB;AACR;IAAhB,KAAK,EAAE;;oDAAuC;AAE9B;IAAhB,KAAK,EAAE;;+CAA0B;AAEjB;IAAhB,KAAK,EAAE;;8CAAmB;AACV;IAAhB,KAAK,EAAE;;oDAAyB;AAGN;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;8CAAA;AAZjC,eAAe;IAD3B,aAAa,CAAC,kBAAkB,CAAC;GACrB,eAAe,CAuL3B","sourcesContent":["import '@operato/data-grist/ox-grist.js'\nimport '@operato/input/ox-input-select-buttons.js'\n\nimport gql from 'graphql-tag'\nimport { html } from 'lit'\nimport { customElement, query, state } from 'lit/decorators.js'\n\nimport { DataGrist, FetchOption } from '@operato/data-grist'\nimport { client, QueryController } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { entity360Name } from '@operato/layout'\nimport { navigate, PageView } from '@operato/shell'\nimport { CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\nimport { isMobileDevice } from '@operato/utils'\nimport { SELECTION_ROW_PICKER } from '@things-factory/ai-assistant/dist-client/index.js'\nimport { documentAmount } from '@things-factory/invoice/dist-client'\n\nimport { closeMonthsOf } from '../close-months'\nimport { headroomChoice } from '../headroom-choice'\nimport { opportunityStageWord } from '../opportunity-words'\n\nconst today = () => new Date().toLocaleDateString('en-CA')\n\ntype StageCount = { stage: string; count: number; open: boolean }\n\n/**\n * 영업 기회 — every opportunity of the domain, narrowed by stage. The name opens its 360; the edit gutter its editor. Rows\n * picked go to the assistant (「AI와 작업」) as `opportunity:<uuid>`, read by the opportunity list's read (sales-read.ts).\n *\n * The person in charge and the expected-close period narrow it from the headroom. The stages are chips that narrow\n * the list, each with how many opportunities it holds under the other conditions — counted by the server, so the\n * numbers agree with one another whichever chips are pressed. The list opens on the open stages, won and lost left\n * out; with none pressed every stage shows.\n */\n@customElement('opportunity-list')\nexport class OpportunityList extends localize(i18next)(PageView) {\n static styles = [WorkSurfacePageStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles]\n\n @state() gristConfig: any\n @state() private stageCounts: StageCount[] = []\n /* The stages chosen; none until the first counts say which stages are open. */\n @state() private stages?: string[]\n /* The person in charge narrowed to (a user id), and the expected-close period. */\n @state() private owner = ''\n @state() private closePeriod = ''\n /* The people an opportunity may be put in the charge of - the editor's choices (ADR-0190). */\n private ownerChoices = new QueryController(this, gql`{ opportunityOwners { id name } }`)\n @query('ox-grist') private grist!: DataGrist\n\n private get owners(): { value: string; display: string }[] {\n return (this.ownerChoices.data?.opportunityOwners ?? []).map((one: any) => ({ value: one.id, display: one.name }))\n }\n\n get context() {\n return {\n title: i18next.t('title.opportunity-list'),\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n value: this.grist?.searchText || ''\n },\n /* Narrowing by stage stays in the headroom, and this folds it. */\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n actions: [{ title: i18next.t('button.opportunity-new'), icon: 'add', emphasis: { raised: true }, action: () => navigate('opportunity-editor') }],\n exportable: { name: i18next.t('title.opportunity-list'), data: () => this.grist.exportRecords() }\n }\n }\n\n render() {\n return html`<ox-assistant-selection-bar\n .gridOf=${() => this.grist}\n name=${i18next.t('title.opportunity-list')}\n list=\"opportunities\"\n axis=\"opportunity\"\n .labelOf=${(row: any) => [row.name, row.counterparty?.name].filter(Boolean).join(' · ')}\n ></ox-assistant-selection-bar>\n <ox-grist\n class=\"page-fill\"\n search-mode=\"term\"\n .mode=${isMobileDevice() ? 'CARD' : 'GRID'}\n .config=${this.gristConfig}\n .fetchHandler=${this.fetchHandler.bind(this)}\n >\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n ${headroomChoice(\n i18next.t('field.opportunity-owner'),\n this.owner,\n [{ value: '', display: i18next.t('text.opportunity-owner-all') }, ...this.owners],\n value => ((this.owner = value), this.grist.fetch())\n )}\n ${headroomChoice(\n i18next.t('field.opportunity-expected-close-month'),\n this.closePeriod,\n ['', 'this-month', 'next-month', 'this-quarter', 'this-year'].map(value => ({ value, display: i18next.t(`text.opportunity-close-${value || 'all'}`) })),\n value => ((this.closePeriod = value), this.grist.fetch())\n )}\n <ox-input-select-buttons\n multiple\n .value=${this.stages ?? []}\n .options=${this.stageCounts.map(({ stage, count }) => ({ value: stage, display: opportunityStageWord(stage), count }))}\n @change=${(e: CustomEvent) => {\n this.stages = (e.currentTarget as any).value ?? []\n this.grist.fetch()\n }}\n ></ox-input-select-buttons>\n </div>\n </div>\n </ox-grist>`\n }\n\n async pageInitialized() {\n const open = (record: any) => record?.id && navigate(`opportunity-editor?id=${record.id}`)\n const party = (value?: { id: string; name: string }) => (value ? entity360Name({ __typename: 'Counterparty', ...value }, value.name) : '')\n const readonly = (type: string, name: string, header: string, width: number, extra: any = {}) => ({\n type,\n name,\n header,\n width,\n sortable: true,\n ...extra,\n record: { editable: false, ...extra.record }\n })\n this.gristConfig = {\n rows: { appendable: false, selectable: { multiple: true } },\n pagination: { limit: 50, pages: [50, 100, 500] },\n emptyNote: { title: i18next.t('text.opportunity-empty'), description: i18next.t('text.opportunity-empty-description') },\n list: { fields: ['name', 'counterparty'], details: ['stage', 'expectedCloseMonth', 'amount'] },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n SELECTION_ROW_PICKER,\n { type: 'gutter', gutterName: 'button', icon: 'edit_note', handlers: { click: (_c: any, _d: any, _col: any, record: any) => open(record) } },\n readonly('string', 'name', i18next.t('field.opportunity-name'), 220, {\n record: { renderer: (_v: any, _c: any, record: any) => (record?.id ? entity360Name({ __typename: 'Opportunity', ...record }, record.name) : '') }\n }),\n readonly('string', 'counterparty', i18next.t('field.opportunity-counterparty'), 180, { sortable: false, record: { renderer: (value: any) => party(value) } }),\n readonly('string', 'endCustomer', i18next.t('field.opportunity-end-customer'), 160, { sortable: false, record: { renderer: (value: any) => party(value) } }),\n readonly('string', 'stage', i18next.t('field.opportunity-stage'), 90, { record: { renderer: (value: string) => opportunityStageWord(value) } }),\n readonly('integer', 'probability', i18next.t('field.opportunity-probability'), 70, { record: { align: 'right', renderer: (value: number) => `${value ?? 0}%` } }),\n readonly('float', 'amount', i18next.t('field.opportunity-amount'), 150, {\n record: { align: 'right', renderer: (value: number, _c: any, record: any) => documentAmount(value, record?.currency || 'KRW') }\n }),\n readonly('string', 'expectedCloseMonth', i18next.t('field.opportunity-expected-close-month'), 100),\n readonly('string', 'owner', i18next.t('field.opportunity-owner'), 110, { sortable: false, record: { renderer: (value: any) => value?.name ?? '' } })\n ],\n sorters: [{ name: 'expectedCloseMonth' }]\n }\n }\n\n async fetchHandler({ page = 1, limit = 50, sortings = [], filters = [], search }: FetchOption) {\n search = search?.trim() || undefined\n filters = [...filters, ...this.headroomFilters()]\n const counting = this.fetchStageCounts(filters, search)\n if (!this.stages) this.stages = (await counting).filter(one => one.open).map(one => one.stage)\n const stages = this.stages.length ? [{ name: 'stage', operator: 'in', value: this.stages }] : []\n const [response] = await Promise.all([this.fetchPage([...filters, ...stages], { page, limit }, sortings, search), counting])\n return { total: response.total, records: response.items }\n }\n\n /* The owner and the close period as the list's filters - the stage counts are under them too. */\n private headroomFilters(): any[] {\n const months = closeMonthsOf(this.closePeriod, today())\n return [\n ...(this.owner ? [{ name: 'ownerId', operator: 'eq', value: this.owner }] : []),\n ...(months ? [{ name: 'expectedCloseMonth', operator: 'between', value: months }] : [])\n ]\n }\n\n private async fetchStageCounts(filters: any[], search?: string) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $search: String) {\n opportunityStageCounts(filters: $filters, search: $search) {\n stage\n count\n open\n }\n }\n `,\n variables: { filters, search },\n fetchPolicy: 'network-only'\n })\n if (response.errors?.length) throw response\n return (this.stageCounts = response.data.opportunityStageCounts as StageCount[])\n }\n\n private async fetchPage(filters: any[], pagination: { page: number; limit: number }, sortings: any[], search?: string) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $search: String) {\n responses: opportunities(filters: $filters, pagination: $pagination, sortings: $sortings, search: $search) {\n items {\n id\n name\n stage\n probability\n amount\n currency\n expectedCloseMonth\n counterparty { id name }\n endCustomer { id name }\n owner { id name }\n }\n total\n }\n }\n `,\n variables: { filters, pagination, sortings, search },\n fetchPolicy: 'network-only'\n })\n if (response.errors?.length) throw response\n return response.data.responses as { items: any[]; total: number }\n }\n}\n"]}
@@ -2,8 +2,9 @@ import '@operato/data-grist/ox-grist.js';
2
2
  import '@operato/list-state/ox-page-state.js';
3
3
  import '@operato/input/ox-select.js';
4
4
  import '@operato/popup/ox-popup-list.js';
5
+ import type { PropertyValues } from 'lit';
5
6
  import { PageView } from '@operato/shell';
6
- import { type DocumentDefaults, type DocumentParty, type DocumentValue } from '@things-factory/invoice/dist-client';
7
+ import { type DocumentDefaults, type DocumentValue } from '@things-factory/invoice/dist-client';
7
8
  import '@things-factory/invoice/dist-client/document/document-party.js';
8
9
  import '../sales-product-pick';
9
10
  /** The next quotation number of a year after those given - 「Q2026-001」, 「Q2026-002」 … */
@@ -17,29 +18,43 @@ declare const QuotationEditor_base: (new (...args: any[]) => import("lit").LitEl
17
18
  */
18
19
  export declare class QuotationEditor extends QuotationEditor_base {
19
20
  static styles: import("lit").CSSResult[];
20
- quotation: DocumentValue | null;
21
- form: DocumentValue;
22
- loading: boolean;
23
- error: unknown;
24
- busy: boolean;
25
- reason: string;
21
+ /** What the address opens: a quotation by id, or a new one - written from an opportunity, it answers that one. */
22
+ private address?;
26
23
  gristConfig: any;
27
- /** The open opportunities a draft may answer, and the one it answers when that one is closed. */
28
- opportunities: {
29
- id: string;
30
- name: string;
31
- counterparty?: DocumentParty | null;
32
- }[];
33
- /** The company's words a new quotation starts with, the terms it offers and how long an offer holds (ADR-0170). */
34
- defaults: DocumentDefaults | null;
35
- /** The counterparty the buyer was taken from on this screen - shown in the picker. */
36
- party: DocumentParty | null;
24
+ /** Whether this person may read the company's words - unknown, and nothing read, until asked. */
25
+ private defaultsReadable;
37
26
  /** The totals of the lines as typed - reckoned as the quotation will keep them, shown before it is saved. */
38
- amounts: Partial<DocumentValue>;
27
+ private typedAmounts;
39
28
  /** Whether this person may write invoices - an accepted quotation then makes one. */
40
29
  invoiceWriter: boolean;
41
30
  /** Whether the application's section is this person's to read - asked once, before it is shown. */
42
31
  sectionReadable: boolean;
32
+ /** An invoice being made of this quotation - its look-ups and its save. */
33
+ private making;
34
+ private companyDefaults;
35
+ private openOpportunities;
36
+ private record;
37
+ private starts;
38
+ private draft;
39
+ private decline;
40
+ private saves;
41
+ private saving;
42
+ private get quotationId();
43
+ /** The company's words a new quotation starts with, the terms it offers and how long an offer holds (ADR-0170) - none until read. */
44
+ get defaults(): DocumentDefaults | null;
45
+ get quotation(): DocumentValue | null;
46
+ private get opportunities();
47
+ /** What the form shows unedited: the quotation read, or what a new one starts with. */
48
+ private get formRead();
49
+ /** The form as it shows: each field's edit, else what was read. */
50
+ get form(): DocumentValue;
51
+ /** The totals of the lines as typed, else as the quotation keeps them. */
52
+ get amounts(): Partial<DocumentValue>;
53
+ get reason(): string;
54
+ /** A failed read, or a quotation the address names that is not there. */
55
+ get error(): unknown;
56
+ get loading(): boolean;
57
+ get busy(): boolean;
43
58
  private grist?;
44
59
  get editable(): boolean;
45
60
  get context(): {
@@ -49,7 +64,11 @@ export declare class QuotationEditor extends QuotationEditor_base {
49
64
  description?: string | undefined;
50
65
  title: string;
51
66
  };
52
- pageUpdated(changes: any, lifecycle: any): Promise<void>;
67
+ pageUpdated(changes: any, lifecycle: any): void;
68
+ private lined?;
69
+ private relined;
70
+ willUpdate(changes: PropertyValues): void;
71
+ updated(changes: PropertyValues): void;
53
72
  render(): import("lit-html").TemplateResult<1>;
54
73
  private renderDecline;
55
74
  /**
@@ -59,6 +78,8 @@ export declare class QuotationEditor extends QuotationEditor_base {
59
78
  private addProduct;
60
79
  /** The discount of the whole quotation as typed, and the totals after it. */
61
80
  private discount;
81
+ /** Edits of several fields at once. */
82
+ private put;
62
83
  /** A change of the head; a new currency reckons the lines in its minor unit; the last day follows a moved issue day. */
63
84
  private edit;
64
85
  /** The opportunity it answers - found by typing; choosing one takes its counterparty as the buyer when none is written. */
@@ -67,22 +88,20 @@ export declare class QuotationEditor extends QuotationEditor_base {
67
88
  private takeParty;
68
89
  /**
69
90
  * What a new quotation starts with, so a person writes only what is new: the next number of the year, the last day an
70
- * offer holds, the company's own words (ADR-0170), and what they leave blank of our side as the last sales quotation
71
- * wrote it.
91
+ * offer holds, the company's own words (ADR-0170), what they leave blank of our side as the last sales quotation
92
+ * wrote it, and the counterparty of the opportunity it answers.
72
93
  */
73
- private prefill;
94
+ private get start();
74
95
  /** Days an offer holds - the company's, or thirty. */
75
96
  private get validDays();
76
97
  private opportunityChoices;
77
- private readOpportunities;
78
98
  private configure;
79
- private load;
80
- private show;
81
- private run;
82
99
  private input;
100
+ /** A new one is opened once it is made; the edits sent are cleared once the save answered. Answers the quotation's id. */
83
101
  private save;
84
102
  /** Asked first - to whom and how much, fixed after - then save what is on screen and send it. */
85
103
  private send;
104
+ /** A step of the quotation's life; a revision opens the new version. */
86
105
  private change;
87
106
  /**
88
107
  * An invoice draft of an accepted quotation (ADR-0170 decision 11): its parties, currency, language, terms, account,