@foxy.io/elements 1.32.0 → 1.33.0-beta.1
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/cdn/foxy-address-form.js +1 -1
- package/dist/cdn/foxy-admin-subscription-form.js +1 -1
- package/dist/cdn/foxy-api-browser.js +1 -1
- package/dist/cdn/foxy-applied-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-attribute-form.js +1 -1
- package/dist/cdn/foxy-cart-form.js +2 -2
- package/dist/cdn/foxy-client-form.js +1 -1
- package/dist/cdn/foxy-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-coupon-codes-form.js +1 -1
- package/dist/cdn/foxy-coupon-form.js +1 -1
- package/dist/cdn/foxy-custom-field-form.js +1 -1
- package/dist/cdn/foxy-customer-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings-form.js +1 -1
- package/dist/cdn/foxy-customer-portal.js +1 -1
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-downloadable-form.js +1 -1
- package/dist/cdn/foxy-email-template-form.js +1 -1
- package/dist/cdn/foxy-filter-attribute-form.js +1 -1
- package/dist/cdn/foxy-generate-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-code-form.js +1 -1
- package/dist/cdn/foxy-gift-card-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-form.js +1 -1
- package/dist/cdn/foxy-integration-form.js +1 -1
- package/dist/cdn/foxy-item-category-form.js +1 -1
- package/dist/cdn/foxy-item-form.js +1 -1
- package/dist/cdn/foxy-item-option-form.js +1 -1
- package/dist/cdn/foxy-native-integration-form.js +1 -1
- package/dist/cdn/foxy-passkey-form.js +1 -1
- package/dist/cdn/foxy-payment-method-card.js +1 -1
- package/dist/cdn/foxy-payments-api-fraud-protection-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-method-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-preset-form.js +1 -1
- package/dist/cdn/foxy-store-form.js +1 -1
- package/dist/cdn/foxy-store-shipping-method-form.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +1 -1
- package/dist/cdn/foxy-subscription-settings-form.js +1 -1
- package/dist/cdn/foxy-template-config-form.js +1 -1
- package/dist/cdn/foxy-template-form.js +1 -1
- package/dist/cdn/foxy-template-set-form.js +1 -1
- package/dist/cdn/foxy-transaction.js +1 -1
- package/dist/cdn/foxy-update-payment-method-form.js +1 -1
- package/dist/cdn/foxy-user-form.js +1 -1
- package/dist/cdn/foxy-user-invitation-form.js +1 -1
- package/dist/cdn/foxy-users-table.js +1 -1
- package/dist/cdn/foxy-webhook-form.js +1 -1
- package/dist/cdn/shared-0203d3da.js +1 -0
- package/dist/cdn/shared-14179b23.js +1 -0
- package/dist/cdn/shared-529f2b48.js +2 -0
- package/dist/cdn/translations/email-template-form/en.json +99 -27
- package/dist/cdn/translations/item-category-form/en.json +1 -1
- package/dist/cdn/translations/store-form/en.json +1 -1
- package/dist/cdn/translations/subscription-settings-form/en.json +6 -6
- package/dist/cdn/translations/template-form/en.json +67 -19
- package/dist/elements/internal/InternalResourcePickerControl/InternalResourcePickerControlForm.d.ts +1 -2
- package/dist/elements/internal/InternalResourcePickerControl/InternalResourcePickerControlForm.js +0 -3
- package/dist/elements/internal/InternalResourcePickerControl/InternalResourcePickerControlForm.js.map +1 -1
- package/dist/elements/internal/InternalSourceControl/InternalSourceControl.js +6 -26
- package/dist/elements/internal/InternalSourceControl/InternalSourceControl.js.map +1 -1
- package/dist/elements/internal/InternalTimestampsControl/InternalTimestampsControl.js +1 -1
- package/dist/elements/internal/InternalTimestampsControl/InternalTimestampsControl.js.map +1 -1
- package/dist/elements/public/CartForm/internal/InternalCartFormCreateSessionAction/InternalCartFormCreateSessionAction.js +0 -1
- package/dist/elements/public/CartForm/internal/InternalCartFormCreateSessionAction/InternalCartFormCreateSessionAction.js.map +1 -1
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.d.ts +12 -20
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js +100 -333
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js.map +1 -1
- package/dist/elements/public/EmailTemplateForm/index.d.ts +5 -7
- package/dist/elements/public/EmailTemplateForm/index.js +5 -7
- package/dist/elements/public/EmailTemplateForm/index.js.map +1 -1
- package/dist/elements/public/EmailTemplateForm/internal/InternalEmailTemplateFormAsyncAction/InternalEmailTemplateFormAsyncAction.d.ts +10 -0
- package/dist/elements/public/EmailTemplateForm/internal/InternalEmailTemplateFormAsyncAction/InternalEmailTemplateFormAsyncAction.js +49 -0
- package/dist/elements/public/EmailTemplateForm/internal/InternalEmailTemplateFormAsyncAction/InternalEmailTemplateFormAsyncAction.js.map +1 -0
- package/dist/elements/public/EmailTemplateForm/internal/InternalEmailTemplateFormAsyncAction/index.d.ts +5 -0
- package/dist/elements/public/EmailTemplateForm/internal/InternalEmailTemplateFormAsyncAction/index.js +7 -0
- package/dist/elements/public/EmailTemplateForm/internal/InternalEmailTemplateFormAsyncAction/index.js.map +1 -0
- package/dist/elements/public/EmailTemplateForm/types.d.ts +3 -1
- package/dist/elements/public/EmailTemplateForm/types.js.map +1 -1
- package/dist/elements/public/SubscriptionSettingsForm/SubscriptionSettingsForm.js +6 -6
- package/dist/elements/public/SubscriptionSettingsForm/SubscriptionSettingsForm.js.map +1 -1
- package/dist/elements/public/TemplateForm/TemplateForm.d.ts +10 -18
- package/dist/elements/public/TemplateForm/TemplateForm.js +54 -305
- package/dist/elements/public/TemplateForm/TemplateForm.js.map +1 -1
- package/dist/elements/public/TemplateForm/index.d.ts +4 -6
- package/dist/elements/public/TemplateForm/index.js +4 -6
- package/dist/elements/public/TemplateForm/index.js.map +1 -1
- package/dist/elements/public/TemplateForm/internal/InternalTemplateFormAsyncAction/InternalTemplateFormAsyncAction.d.ts +10 -0
- package/dist/elements/public/TemplateForm/internal/InternalTemplateFormAsyncAction/InternalTemplateFormAsyncAction.js +49 -0
- package/dist/elements/public/TemplateForm/internal/InternalTemplateFormAsyncAction/InternalTemplateFormAsyncAction.js.map +1 -0
- package/dist/elements/public/TemplateForm/internal/InternalTemplateFormAsyncAction/index.d.ts +5 -0
- package/dist/elements/public/TemplateForm/internal/InternalTemplateFormAsyncAction/index.js +7 -0
- package/dist/elements/public/TemplateForm/internal/InternalTemplateFormAsyncAction/index.js.map +1 -0
- package/package.json +1 -1
- package/dist/cdn/shared-015da8ca.js +0 -1
- package/dist/cdn/shared-d0e0f8a1.js +0 -2
- package/dist/cdn/shared-fb18400f.js +0 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { InternalControl } from "../../../../internal/InternalControl/InternalControl.js";
|
|
2
|
+
import { NucleonElement } from "../../../NucleonElement/NucleonElement.js";
|
|
3
|
+
import { html } from 'lit-element';
|
|
4
|
+
export class InternalEmailTemplateFormAsyncAction extends InternalControl {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.theme = null;
|
|
8
|
+
this.href = null;
|
|
9
|
+
this.__state = 'idle';
|
|
10
|
+
}
|
|
11
|
+
static get properties() {
|
|
12
|
+
return {
|
|
13
|
+
...super.properties,
|
|
14
|
+
__state: { type: String },
|
|
15
|
+
theme: { type: String },
|
|
16
|
+
href: { type: String },
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
renderControl() {
|
|
20
|
+
const state = this.__state;
|
|
21
|
+
const theme = state === 'fail' ? 'error' : state === 'idle' ? '' : '';
|
|
22
|
+
return html `
|
|
23
|
+
<vaadin-button
|
|
24
|
+
theme=${`${this.theme} ${theme !== null && theme !== void 0 ? theme : ''}`.trim()}
|
|
25
|
+
?disabled=${state === 'busy' || this.disabled}
|
|
26
|
+
@click=${this.__submit}
|
|
27
|
+
>
|
|
28
|
+
<foxy-i18n key=${state} infer=""></foxy-i18n>
|
|
29
|
+
</vaadin-button>
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
async __submit() {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
if (this.__state === 'busy')
|
|
35
|
+
return;
|
|
36
|
+
try {
|
|
37
|
+
this.__state = 'busy';
|
|
38
|
+
const api = new NucleonElement.API(this);
|
|
39
|
+
const response = await api.fetch((_a = this.href) !== null && _a !== void 0 ? _a : '', { method: 'POST' });
|
|
40
|
+
this.__state = response.ok ? 'idle' : 'fail';
|
|
41
|
+
if (response.ok)
|
|
42
|
+
(_b = this.nucleon) === null || _b === void 0 ? void 0 : _b.refresh();
|
|
43
|
+
}
|
|
44
|
+
catch (_c) {
|
|
45
|
+
this.__state = 'fail';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=InternalEmailTemplateFormAsyncAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InternalEmailTemplateFormAsyncAction.js","sourceRoot":"","sources":["../../../../../../src/elements/public/EmailTemplateForm/internal/InternalEmailTemplateFormAsyncAction/InternalEmailTemplateFormAsyncAction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,gEAA6D;AACvF,OAAO,EAAE,cAAc,EAAE,kDAA+C;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,MAAM,OAAO,oCAAqC,SAAQ,eAAe;IAAzE;;QAUE,UAAK,GAAkB,IAAI,CAAC;QAE5B,SAAI,GAAkB,IAAI,CAAC;QAEnB,YAAO,GAAG,MAAM,CAAC;IAgC3B,CAAC;IA7CC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;YACzB,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;YACvB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;SACvB,CAAC;IACJ,CAAC;IAQD,aAAa;QACX,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,MAAM,KAAK,GAAG,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAEtE,OAAO,IAAI,CAAA;;gBAEC,GAAG,IAAI,CAAC,KAAK,IAAI,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,EAAE,CAAC,IAAI,EAAE;oBACjC,KAAK,KAAK,MAAM,IAAI,IAAI,CAAC,QAAQ;iBACpC,IAAI,CAAC,QAAQ;;yBAEL,KAAK;;KAEzB,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,QAAQ;;QACpB,IAAI,IAAI,CAAC,OAAO,KAAK,MAAM;YAAE,OAAO;QAEpC,IAAI;YACF,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;YAEtB,MAAM,GAAG,GAAG,IAAI,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACzC,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,KAAK,OAAC,IAAI,CAAC,IAAI,mCAAI,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YAEtE,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;YAC7C,IAAI,QAAQ,CAAC,EAAE;gBAAE,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,GAAG;SAC1C;QAAC,WAAM;YACN,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;SACvB;IACH,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations, TemplateResult } from 'lit-element';\n\nimport { InternalControl } from '../../../../internal/InternalControl/InternalControl';\nimport { NucleonElement } from '../../../NucleonElement/NucleonElement';\nimport { html } from 'lit-element';\n\nexport class InternalEmailTemplateFormAsyncAction extends InternalControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __state: { type: String },\n theme: { type: String },\n href: { type: String },\n };\n }\n\n theme: string | null = null;\n\n href: string | null = null;\n\n private __state = 'idle';\n\n renderControl(): TemplateResult {\n const state = this.__state;\n const theme = state === 'fail' ? 'error' : state === 'idle' ? '' : '';\n\n return html`\n <vaadin-button\n theme=${`${this.theme} ${theme ?? ''}`.trim()}\n ?disabled=${state === 'busy' || this.disabled}\n @click=${this.__submit}\n >\n <foxy-i18n key=${state} infer=\"\"></foxy-i18n>\n </vaadin-button>\n `;\n }\n\n private async __submit(): Promise<void> {\n if (this.__state === 'busy') return;\n\n try {\n this.__state = 'busy';\n\n const api = new NucleonElement.API(this);\n const response = await api.fetch(this.href ?? '', { method: 'POST' });\n\n this.__state = response.ok ? 'idle' : 'fail';\n if (response.ok) this.nucleon?.refresh();\n } catch {\n this.__state = 'fail';\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import '@vaadin/vaadin-button';
|
|
2
|
+
import '../../../../internal/InternalControl/index';
|
|
3
|
+
import '../../../I18n/index';
|
|
4
|
+
import { InternalEmailTemplateFormAsyncAction as Control } from './InternalEmailTemplateFormAsyncAction';
|
|
5
|
+
export { Control as InternalEmailTemplateFormAsyncAction };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import '@vaadin/vaadin-button';
|
|
2
|
+
import "../../../../internal/InternalControl/index.js";
|
|
3
|
+
import "../../../I18n/index.js";
|
|
4
|
+
import { InternalEmailTemplateFormAsyncAction as Control } from "./InternalEmailTemplateFormAsyncAction.js";
|
|
5
|
+
customElements.define('foxy-internal-email-template-form-async-action', Control);
|
|
6
|
+
export { Control as InternalEmailTemplateFormAsyncAction };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/elements/public/EmailTemplateForm/internal/InternalEmailTemplateFormAsyncAction/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAC/B,uDAAoD;AACpD,gCAA6B;AAE7B,OAAO,EAAE,oCAAoC,IAAI,OAAO,EAAE,kDAA+C;AAEzG,cAAc,CAAC,MAAM,CAAC,gDAAgD,EAAE,OAAO,CAAC,CAAC;AAEjF,OAAO,EAAE,OAAO,IAAI,oCAAoC,EAAE,CAAC","sourcesContent":["import '@vaadin/vaadin-button';\nimport '../../../../internal/InternalControl/index';\nimport '../../../I18n/index';\n\nimport { InternalEmailTemplateFormAsyncAction as Control } from './InternalEmailTemplateFormAsyncAction';\n\ncustomElements.define('foxy-internal-email-template-form-async-action', Control);\n\nexport { Control as InternalEmailTemplateFormAsyncAction };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/elements/public/EmailTemplateForm/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nexport type Data = Resource<Rels.EmailTemplate
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/elements/public/EmailTemplateForm/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\n// TODO: simplify once SDK types are updated\nexport type Data = Resource<Rels.EmailTemplate> & { subject: string };\n"]}
|
|
@@ -124,6 +124,12 @@ export class SubscriptionSettingsForm extends Base {
|
|
|
124
124
|
>
|
|
125
125
|
</foxy-internal-switch-control>
|
|
126
126
|
|
|
127
|
+
<foxy-internal-switch-control
|
|
128
|
+
infer="send-email-receipts-for-automated-billing"
|
|
129
|
+
helper-text-as-tooltip
|
|
130
|
+
>
|
|
131
|
+
</foxy-internal-switch-control>
|
|
132
|
+
|
|
127
133
|
<foxy-internal-switch-control
|
|
128
134
|
infer="prevent-customer-cancel-with-past-due"
|
|
129
135
|
helper-text-as-tooltip
|
|
@@ -158,12 +164,6 @@ export class SubscriptionSettingsForm extends Base {
|
|
|
158
164
|
</foxy-internal-summary-control>
|
|
159
165
|
|
|
160
166
|
<foxy-internal-summary-control infer="emails-group">
|
|
161
|
-
<foxy-internal-switch-control
|
|
162
|
-
infer="send-email-receipts-for-automated-billing"
|
|
163
|
-
helper-text-as-tooltip
|
|
164
|
-
>
|
|
165
|
-
</foxy-internal-switch-control>
|
|
166
|
-
|
|
167
167
|
<foxy-internal-editable-list-control
|
|
168
168
|
layout="summary-item"
|
|
169
169
|
infer="reminder-email-schedule"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionSettingsForm.js","sourceRoot":"","sources":["../../../../src/elements/public/SubscriptionSettingsForm/SubscriptionSettingsForm.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,GAAG,4BAA4B,CAAC;AACxC,MAAM,IAAI,GAAG,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,OAAO,wBAAyB,SAAQ,IAAU;IAAxD;;QAkBU,mCAA8B,GAAa;YACjD,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,WAAW,EAAE;YACjD,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,EAAE;SAC9C,CAAC;QAEM,iCAA4B,GAAG;YACrC,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,GAAG;YACT,GAAG,EAAE,GAAG;SACT,CAAC;QAEM,kDAA6C,GAAG,GAAG,EAAE;;YAC3D,MAAM,IAAI,eAAG,IAAI,CAAC,IAAI,CAAC,uCAAuC,0CAAE,KAAK,CAAC,GAAG,oCAAK,EAAE,CAAC;YAEjF,OAAO,IAAI;iBACR,GAAG,CAAC,WAAW,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BACpC,IAAI,CAAC,+BAA+B;sBACpC,IAAI,CAAC,+BAA+B;;;;;;;yBAOjC,IAAI,CAAC,4BAA4B;sBACpC,IAAI,CAAC,6CAA6C;sBAClD,IAAI,CAAC,6CAA6C;;;;;;;;;;;;;mBAarD,IAAI,CAAC,4BAA4B;;;;;;;;QAQ5C,KAAK,CAAC,UAAU,EAAE;KACrB,CAAC;IACJ,CAAC;IAED,IAAY,4BAA4B;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC;QACjD,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACnE,CAAC;CACF","sourcesContent":["import type { TemplateResult } from 'lit-html';\nimport type { NucleonV8N } from '../NucleonElement/types';\nimport type { Option } from '../../internal/InternalCheckboxGroupControl/types';\nimport type { Item } from '../../internal/InternalEditableListControl/types';\nimport type { Data } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { html } from 'lit-html';\n\nconst NS = 'subscription-settings-form';\nconst Base = TranslatableMixin(InternalForm, NS);\n\n/**\n * Form element for managing `fx:subscription_settings` resources.\n *\n * @element foxy-subscription-settings-form\n * @since 1.21.0\n */\nexport class SubscriptionSettingsForm extends Base<Data> {\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ expiring_soon_payment_reminder_schedule: v }) => {\n return !v || v.length <= 100 || 'expiring-soon-payment-reminder-schedule:v8n_too_long';\n },\n ({ reattempt_bypass_strings: v }) => {\n return !v || v.length <= 400 || 'reattempt-bypass-strings:v8n_too_long';\n },\n ({ reminder_email_schedule: v }) => {\n return !v || v.length <= 100 || 'reminder-email-schedule:v8n_too_long';\n },\n ({ reattempt_schedule: v }) => {\n return !v || v.length <= 100 || 'reattempt-schedule:v8n_too_long';\n },\n ];\n }\n\n private __pastDueAmountHandlingOptions: Option[] = [\n { label: 'option_increment', value: 'increment' },\n { label: 'option_replace', value: 'replace' },\n ];\n\n private __positiveIntegerInputParams = {\n type: 'number',\n step: '1',\n min: '0',\n };\n\n private __expiringSoonPaymentReminderScheduleGetValue = () => {\n const days = this.form.expiring_soon_payment_reminder_schedule?.split(',') ?? [];\n\n return days\n .map(dayAsString => parseInt(dayAsString))\n .filter((day, index, allDays) => !isNaN(day) && allDays.indexOf(day) === index)\n .sort((dayA, dayB) => dayB - dayA)\n .map(day => ({ value: String(day), label: this.t('day', { count: day }) }));\n };\n\n private __expiringSoonPaymentReminderScheduleSetValue = (newItems: Item[]) => {\n this.edit({\n expiring_soon_payment_reminder_schedule: newItems.map(({ value }) => value).join(),\n });\n };\n\n private __reminderEmailScheduleGetValue = () => {\n const days = this.form.reminder_email_schedule?.split(',') ?? [];\n\n return days\n .map(dayAsString => parseInt(dayAsString))\n .filter((day, index, allDays) => !isNaN(day) && allDays.indexOf(day) === index)\n .sort((dayA, dayB) => dayA - dayB)\n .map(day => ({ value: String(day), label: this.t('day', { count: day }) }));\n };\n\n private __reminderEmailScheduleSetValue = (newItems: Item[]) => {\n this.edit({ reminder_email_schedule: newItems.map(({ value }) => value).join() });\n };\n\n private __reattemptScheduleGetValue = () => {\n const days = this.form.reattempt_schedule?.split(',') ?? [];\n\n return days\n .map(dayAsString => parseInt(dayAsString))\n .filter((day, index, allDays) => !isNaN(day) && allDays.indexOf(day) === index)\n .sort((dayA, dayB) => dayA - dayB)\n .map(day => ({ value: String(day), label: this.t('day', { count: day }) }));\n };\n\n private __reattemptScheduleSetValue = (newItems: Item[]) => {\n this.edit({ reattempt_schedule: newItems.map(({ value }) => value).join() });\n };\n\n private __getReattemptBypassStringsValue = () => {\n const strings = this.form.reattempt_bypass_strings?.split(',') ?? [];\n\n return strings\n .map(text => text.trim())\n .filter((text, index, strings) => text && strings.indexOf(text) === index)\n .map(text => ({ value: text }));\n };\n\n private __setReattemptBypassStringsValue = (newValue: Item[]) => {\n this.edit({ reattempt_bypass_strings: newValue.map(({ value }) => value).join() });\n };\n\n private __reattemptBypassLogicOptions: Option[] = [\n { value: '', label: 'option_always_reattempt' },\n { value: 'skip_if_exists', label: 'option_skip_if_exists' },\n { value: 'reattempt_if_exists', label: 'option_reattempt_if_exists' },\n ];\n\n get hiddenSelector(): BooleanSelector {\n const alwaysMatch = ['header:copy-id', super.hiddenSelector.toString()];\n\n if (!this.form.reattempt_bypass_logic) {\n alwaysMatch.push('reattempts-group:reattempt-bypass-strings');\n }\n\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n renderBody(): TemplateResult {\n return html`\n ${this.renderHeader()}\n\n <foxy-internal-summary-control infer=\"past-due-amount-group\">\n <foxy-internal-select-control\n layout=\"summary-item\"\n infer=\"past-due-amount-handling\"\n .options=${this.__pastDueAmountHandlingOptions}\n >\n </foxy-internal-select-control>\n\n <foxy-internal-switch-control\n infer=\"automatically-charge-past-due-amount\"\n helper-text-as-tooltip\n >\n </foxy-internal-switch-control>\n\n <foxy-internal-switch-control\n infer=\"reset-nextdate-on-makeup-payment\"\n helper-text-as-tooltip\n >\n </foxy-internal-switch-control>\n\n <foxy-internal-switch-control\n infer=\"prevent-customer-cancel-with-past-due\"\n helper-text-as-tooltip\n >\n </foxy-internal-switch-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"reattempts-group\">\n <foxy-internal-select-control\n layout=\"summary-item\"\n infer=\"reattempt-bypass-logic\"\n .options=${this.__reattemptBypassLogicOptions}\n >\n </foxy-internal-select-control>\n\n <foxy-internal-editable-list-control\n layout=\"summary-item\"\n infer=\"reattempt-bypass-strings\"\n .getValue=${this.__getReattemptBypassStringsValue}\n .setValue=${this.__setReattemptBypassStringsValue}\n >\n </foxy-internal-editable-list-control>\n\n <foxy-internal-editable-list-control\n layout=\"summary-item\"\n infer=\"reattempt-schedule\"\n .inputParams=${this.__positiveIntegerInputParams}\n .getValue=${this.__reattemptScheduleGetValue}\n .setValue=${this.__reattemptScheduleSetValue}\n >\n </foxy-internal-editable-list-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"emails-group\">\n <foxy-internal-switch-control\n infer=\"send-email-receipts-for-automated-billing\"\n helper-text-as-tooltip\n >\n </foxy-internal-switch-control>\n\n <foxy-internal-editable-list-control\n layout=\"summary-item\"\n infer=\"reminder-email-schedule\"\n .inputParams=${this.__positiveIntegerInputParams}\n .getValue=${this.__reminderEmailScheduleGetValue}\n .setValue=${this.__reminderEmailScheduleSetValue}\n >\n </foxy-internal-editable-list-control>\n\n <foxy-internal-editable-list-control\n layout=\"summary-item\"\n infer=\"expiring-soon-payment-reminder-schedule\"\n .inputParams=${this.__positiveIntegerInputParams}\n .getValue=${this.__expiringSoonPaymentReminderScheduleGetValue}\n .setValue=${this.__expiringSoonPaymentReminderScheduleSetValue}\n >\n </foxy-internal-editable-list-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"modification-group\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"modification-url\">\n </foxy-internal-text-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"cancellation-group\">\n <foxy-internal-number-control\n layout=\"summary-item\"\n suffix=${this.__cancellationScheduleSuffix}\n infer=\"cancellation-schedule\"\n step=\"1\"\n min=\"1\"\n >\n </foxy-internal-number-control>\n </foxy-internal-summary-control>\n\n ${super.renderBody()}\n `;\n }\n\n private get __cancellationScheduleSuffix() {\n const schedule = this.form.cancellation_schedule;\n return schedule ? this.t('day_suffix', { count: schedule }) : '';\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SubscriptionSettingsForm.js","sourceRoot":"","sources":["../../../../src/elements/public/SubscriptionSettingsForm/SubscriptionSettingsForm.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAm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html';\nimport type { NucleonV8N } from '../NucleonElement/types';\nimport type { Option } from '../../internal/InternalCheckboxGroupControl/types';\nimport type { Item } from '../../internal/InternalEditableListControl/types';\nimport type { Data } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { html } from 'lit-html';\n\nconst NS = 'subscription-settings-form';\nconst Base = TranslatableMixin(InternalForm, NS);\n\n/**\n * Form element for managing `fx:subscription_settings` resources.\n *\n * @element foxy-subscription-settings-form\n * @since 1.21.0\n */\nexport class SubscriptionSettingsForm extends Base<Data> {\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ expiring_soon_payment_reminder_schedule: v }) => {\n return !v || v.length <= 100 || 'expiring-soon-payment-reminder-schedule:v8n_too_long';\n },\n ({ reattempt_bypass_strings: v }) => {\n return !v || v.length <= 400 || 'reattempt-bypass-strings:v8n_too_long';\n },\n ({ reminder_email_schedule: v }) => {\n return !v || v.length <= 100 || 'reminder-email-schedule:v8n_too_long';\n },\n ({ reattempt_schedule: v }) => {\n return !v || v.length <= 100 || 'reattempt-schedule:v8n_too_long';\n },\n ];\n }\n\n private __pastDueAmountHandlingOptions: Option[] = [\n { label: 'option_increment', value: 'increment' },\n { label: 'option_replace', value: 'replace' },\n ];\n\n private __positiveIntegerInputParams = {\n type: 'number',\n step: '1',\n min: '0',\n };\n\n private __expiringSoonPaymentReminderScheduleGetValue = () => {\n const days = this.form.expiring_soon_payment_reminder_schedule?.split(',') ?? [];\n\n return days\n .map(dayAsString => parseInt(dayAsString))\n .filter((day, index, allDays) => !isNaN(day) && allDays.indexOf(day) === index)\n .sort((dayA, dayB) => dayB - dayA)\n .map(day => ({ value: String(day), label: this.t('day', { count: day }) }));\n };\n\n private __expiringSoonPaymentReminderScheduleSetValue = (newItems: Item[]) => {\n this.edit({\n expiring_soon_payment_reminder_schedule: newItems.map(({ value }) => value).join(),\n });\n };\n\n private __reminderEmailScheduleGetValue = () => {\n const days = this.form.reminder_email_schedule?.split(',') ?? [];\n\n return days\n .map(dayAsString => parseInt(dayAsString))\n .filter((day, index, allDays) => !isNaN(day) && allDays.indexOf(day) === index)\n .sort((dayA, dayB) => dayA - dayB)\n .map(day => ({ value: String(day), label: this.t('day', { count: day }) }));\n };\n\n private __reminderEmailScheduleSetValue = (newItems: Item[]) => {\n this.edit({ reminder_email_schedule: newItems.map(({ value }) => value).join() });\n };\n\n private __reattemptScheduleGetValue = () => {\n const days = this.form.reattempt_schedule?.split(',') ?? [];\n\n return days\n .map(dayAsString => parseInt(dayAsString))\n .filter((day, index, allDays) => !isNaN(day) && allDays.indexOf(day) === index)\n .sort((dayA, dayB) => dayA - dayB)\n .map(day => ({ value: String(day), label: this.t('day', { count: day }) }));\n };\n\n private __reattemptScheduleSetValue = (newItems: Item[]) => {\n this.edit({ reattempt_schedule: newItems.map(({ value }) => value).join() });\n };\n\n private __getReattemptBypassStringsValue = () => {\n const strings = this.form.reattempt_bypass_strings?.split(',') ?? [];\n\n return strings\n .map(text => text.trim())\n .filter((text, index, strings) => text && strings.indexOf(text) === index)\n .map(text => ({ value: text }));\n };\n\n private __setReattemptBypassStringsValue = (newValue: Item[]) => {\n this.edit({ reattempt_bypass_strings: newValue.map(({ value }) => value).join() });\n };\n\n private __reattemptBypassLogicOptions: Option[] = [\n { value: '', label: 'option_always_reattempt' },\n { value: 'skip_if_exists', label: 'option_skip_if_exists' },\n { value: 'reattempt_if_exists', label: 'option_reattempt_if_exists' },\n ];\n\n get hiddenSelector(): BooleanSelector {\n const alwaysMatch = ['header:copy-id', super.hiddenSelector.toString()];\n\n if (!this.form.reattempt_bypass_logic) {\n alwaysMatch.push('reattempts-group:reattempt-bypass-strings');\n }\n\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n renderBody(): TemplateResult {\n return html`\n ${this.renderHeader()}\n\n <foxy-internal-summary-control infer=\"past-due-amount-group\">\n <foxy-internal-select-control\n layout=\"summary-item\"\n infer=\"past-due-amount-handling\"\n .options=${this.__pastDueAmountHandlingOptions}\n >\n </foxy-internal-select-control>\n\n <foxy-internal-switch-control\n infer=\"automatically-charge-past-due-amount\"\n helper-text-as-tooltip\n >\n </foxy-internal-switch-control>\n\n <foxy-internal-switch-control\n infer=\"reset-nextdate-on-makeup-payment\"\n helper-text-as-tooltip\n >\n </foxy-internal-switch-control>\n\n <foxy-internal-switch-control\n infer=\"send-email-receipts-for-automated-billing\"\n helper-text-as-tooltip\n >\n </foxy-internal-switch-control>\n\n <foxy-internal-switch-control\n infer=\"prevent-customer-cancel-with-past-due\"\n helper-text-as-tooltip\n >\n </foxy-internal-switch-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"reattempts-group\">\n <foxy-internal-select-control\n layout=\"summary-item\"\n infer=\"reattempt-bypass-logic\"\n .options=${this.__reattemptBypassLogicOptions}\n >\n </foxy-internal-select-control>\n\n <foxy-internal-editable-list-control\n layout=\"summary-item\"\n infer=\"reattempt-bypass-strings\"\n .getValue=${this.__getReattemptBypassStringsValue}\n .setValue=${this.__setReattemptBypassStringsValue}\n >\n </foxy-internal-editable-list-control>\n\n <foxy-internal-editable-list-control\n layout=\"summary-item\"\n infer=\"reattempt-schedule\"\n .inputParams=${this.__positiveIntegerInputParams}\n .getValue=${this.__reattemptScheduleGetValue}\n .setValue=${this.__reattemptScheduleSetValue}\n >\n </foxy-internal-editable-list-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"emails-group\">\n <foxy-internal-editable-list-control\n layout=\"summary-item\"\n infer=\"reminder-email-schedule\"\n .inputParams=${this.__positiveIntegerInputParams}\n .getValue=${this.__reminderEmailScheduleGetValue}\n .setValue=${this.__reminderEmailScheduleSetValue}\n >\n </foxy-internal-editable-list-control>\n\n <foxy-internal-editable-list-control\n layout=\"summary-item\"\n infer=\"expiring-soon-payment-reminder-schedule\"\n .inputParams=${this.__positiveIntegerInputParams}\n .getValue=${this.__expiringSoonPaymentReminderScheduleGetValue}\n .setValue=${this.__expiringSoonPaymentReminderScheduleSetValue}\n >\n </foxy-internal-editable-list-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"modification-group\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"modification-url\">\n </foxy-internal-text-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"cancellation-group\">\n <foxy-internal-number-control\n layout=\"summary-item\"\n suffix=${this.__cancellationScheduleSuffix}\n infer=\"cancellation-schedule\"\n step=\"1\"\n min=\"1\"\n >\n </foxy-internal-number-control>\n </foxy-internal-summary-control>\n\n ${super.renderBody()}\n `;\n }\n\n private get __cancellationScheduleSuffix() {\n const schedule = this.form.cancellation_schedule;\n return schedule ? this.t('day_suffix', { count: schedule }) : '';\n }\n}\n"]}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Data } from './types';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
declare const Base: typeof
|
|
1
|
+
import type { TemplateResult } from 'lit-element';
|
|
2
|
+
import type { Data } from './types';
|
|
3
|
+
import { BooleanSelector } from '@foxy.io/sdk/core';
|
|
4
|
+
import { InternalForm } from '../../internal/InternalForm/InternalForm';
|
|
5
|
+
declare const Base: typeof InternalForm & import("lit-element").Constructor<import("../../../mixins/translatable").TranslatableMixinHost> & {
|
|
6
6
|
defaultNS: string;
|
|
7
|
-
}
|
|
8
|
-
styles: import("lit-element").CSSResultArray;
|
|
9
|
-
} & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/src/types").ScopedElementsHost>;
|
|
7
|
+
};
|
|
10
8
|
/**
|
|
11
9
|
* Form element for creating or editing templates (`fx:cart_include_template`, `fx:checkout_template`, `fx:cart_template`).
|
|
12
10
|
*
|
|
@@ -14,17 +12,11 @@ declare const Base: typeof NucleonElement & import("lit-element").Constructor<im
|
|
|
14
12
|
* @since 1.14.0
|
|
15
13
|
*/
|
|
16
14
|
export declare class TemplateForm extends Base<Data> {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
render(): TemplateResult;
|
|
15
|
+
get readonlySelector(): BooleanSelector;
|
|
16
|
+
get disabledSelector(): BooleanSelector;
|
|
17
|
+
get hiddenSelector(): BooleanSelector;
|
|
18
|
+
renderBody(): TemplateResult;
|
|
22
19
|
protected _sendPost(edits: Partial<Data>): Promise<Data>;
|
|
23
20
|
protected _sendPatch(edits: Partial<Data>): Promise<Data>;
|
|
24
|
-
private __renderDescription;
|
|
25
|
-
private __renderContent;
|
|
26
|
-
private __renderTimestamps;
|
|
27
|
-
private __renderAction;
|
|
28
|
-
private __cache;
|
|
29
21
|
}
|
|
30
22
|
export {};
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { html } from 'lit-element';
|
|
2
|
-
import { Choice, Group, Metadata } from "../../private/index.js";
|
|
3
|
-
import { ScopedElementsMixin } from '@open-wc/scoped-elements';
|
|
4
|
-
import { ChoiceChangeEvent } from "../../private/events.js";
|
|
5
|
-
import { ConfigurableMixin } from "../../../mixins/configurable.js";
|
|
6
|
-
import { NucleonElement } from "../NucleonElement/NucleonElement.js";
|
|
7
|
-
import { ThemeableMixin } from "../../../mixins/themeable.js";
|
|
8
1
|
import { TranslatableMixin } from "../../../mixins/translatable.js";
|
|
9
|
-
import {
|
|
2
|
+
import { BooleanSelector } from '@foxy.io/sdk/core';
|
|
3
|
+
import { InternalForm } from "../../internal/InternalForm/InternalForm.js";
|
|
4
|
+
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
5
|
+
import { html } from 'lit-element';
|
|
10
6
|
const NS = 'template-form';
|
|
11
|
-
const Base =
|
|
7
|
+
const Base = TranslatableMixin(InternalForm, NS);
|
|
12
8
|
/**
|
|
13
9
|
* Form element for creating or editing templates (`fx:cart_include_template`, `fx:checkout_template`, `fx:cart_template`).
|
|
14
10
|
*
|
|
@@ -16,321 +12,74 @@ const Base = ScopedElementsMixin(ThemeableMixin(ConfigurableMixin(TranslatableMi
|
|
|
16
12
|
* @since 1.14.0
|
|
17
13
|
*/
|
|
18
14
|
export class TemplateForm extends Base {
|
|
19
|
-
|
|
20
|
-
super(
|
|
21
|
-
this.
|
|
22
|
-
|
|
15
|
+
get readonlySelector() {
|
|
16
|
+
const alwaysMatch = [super.readonlySelector.toString()];
|
|
17
|
+
if (this.form.content_url)
|
|
18
|
+
alwaysMatch.unshift('content');
|
|
19
|
+
return new BooleanSelector(alwaysMatch.join(' ').trim());
|
|
23
20
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
get disabledSelector() {
|
|
22
|
+
const alwaysMatch = [super.disabledSelector.toString()];
|
|
23
|
+
if (!this.in({ idle: { snapshot: 'clean' } }) || !this.data.content_url) {
|
|
24
|
+
alwaysMatch.unshift('source:cache');
|
|
25
|
+
}
|
|
26
|
+
return new BooleanSelector(alwaysMatch.join(' ').trim());
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
'foxy-i18n': customElements.get('foxy-i18n'),
|
|
38
|
-
'vaadin-text-field': customElements.get('vaadin-text-field'),
|
|
39
|
-
'vaadin-button': customElements.get('vaadin-button'),
|
|
40
|
-
'x-metadata': Metadata,
|
|
41
|
-
'x-choice': Choice,
|
|
42
|
-
'x-group': Group,
|
|
43
|
-
};
|
|
28
|
+
get hiddenSelector() {
|
|
29
|
+
var _a;
|
|
30
|
+
const alwaysMatch = [super.hiddenSelector.toString()];
|
|
31
|
+
if (!((_a = this.data) === null || _a === void 0 ? void 0 : _a.content_url))
|
|
32
|
+
alwaysMatch.unshift('source:cache');
|
|
33
|
+
return new BooleanSelector(alwaysMatch.join(' ').trim());
|
|
44
34
|
}
|
|
45
|
-
|
|
46
|
-
var _a
|
|
47
|
-
const { hiddenSelector, href, lang, ns } = this;
|
|
48
|
-
const action = href ? 'delete' : 'create';
|
|
49
|
-
const isBusy = this.in('busy');
|
|
50
|
-
const isFail = this.in('fail');
|
|
35
|
+
renderBody() {
|
|
36
|
+
var _a;
|
|
51
37
|
return html `
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
38
|
+
${this.renderHeader()}
|
|
39
|
+
|
|
40
|
+
<foxy-internal-summary-control infer="general">
|
|
41
|
+
<foxy-internal-text-control layout="summary-item" infer="description">
|
|
42
|
+
</foxy-internal-text-control>
|
|
43
|
+
</foxy-internal-summary-control>
|
|
44
|
+
|
|
45
|
+
${this.renderTemplateOrSlot()}
|
|
46
|
+
|
|
47
|
+
<foxy-internal-source-control infer="content"></foxy-internal-source-control>
|
|
57
48
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
49
|
+
<foxy-internal-summary-control infer="source">
|
|
50
|
+
<foxy-internal-text-control layout="summary-item" infer="content-url">
|
|
51
|
+
</foxy-internal-text-control>
|
|
52
|
+
|
|
53
|
+
<foxy-internal-template-form-async-action
|
|
54
|
+
theme="tertiary-inline"
|
|
55
|
+
infer="cache"
|
|
56
|
+
href=${ifDefined((_a = this.data) === null || _a === void 0 ? void 0 : _a._links['fx:cache'].href)}
|
|
64
57
|
>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
lang=${lang}
|
|
70
|
-
ns="${ns} ${(_b = (_a = customElements.get('foxy-spinner')) === null || _a === void 0 ? void 0 : _a.defaultNS) !== null && _b !== void 0 ? _b : ''}"
|
|
71
|
-
>
|
|
72
|
-
</foxy-spinner>
|
|
73
|
-
</div>
|
|
74
|
-
</div>
|
|
58
|
+
</foxy-internal-template-form-async-action>
|
|
59
|
+
</foxy-internal-summary-control>
|
|
60
|
+
|
|
61
|
+
${super.renderBody()}
|
|
75
62
|
`;
|
|
76
63
|
}
|
|
77
64
|
async _sendPost(edits) {
|
|
78
65
|
const data = await super._sendPost(edits);
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
66
|
+
if (edits.content_url) {
|
|
67
|
+
const url = data._links['fx:cache'].href;
|
|
68
|
+
const response = await new TemplateForm.API(this).fetch(url, { method: 'POST' });
|
|
69
|
+
if (!response.ok)
|
|
70
|
+
throw ['error:failed_to_cache'];
|
|
71
|
+
}
|
|
85
72
|
return await this._fetch(data._links.self.href);
|
|
86
73
|
}
|
|
87
74
|
async _sendPatch(edits) {
|
|
88
75
|
const data = await super._sendPatch(edits);
|
|
89
76
|
if (!edits.content_url)
|
|
90
77
|
return data;
|
|
91
|
-
this.__cacheState = 'busy';
|
|
92
78
|
const url = data._links['fx:cache'].href;
|
|
93
79
|
const response = await new TemplateForm.API(this).fetch(url, { method: 'POST' });
|
|
94
|
-
|
|
80
|
+
if (!response.ok)
|
|
81
|
+
throw ['error:failed_to_cache'];
|
|
95
82
|
return await this._fetch(data._links.self.href);
|
|
96
83
|
}
|
|
97
|
-
__renderDescription() {
|
|
98
|
-
var _a, _b;
|
|
99
|
-
const scope = 'description';
|
|
100
|
-
return html `
|
|
101
|
-
<div>
|
|
102
|
-
${this.renderTemplateOrSlot(`${scope}:before`)}
|
|
103
|
-
|
|
104
|
-
<vaadin-text-field
|
|
105
|
-
data-testid=${scope}
|
|
106
|
-
class="w-full mb-s"
|
|
107
|
-
label=${this.t(scope)}
|
|
108
|
-
?disabled=${!this.in('idle') || this.disabledSelector.matches(scope)}
|
|
109
|
-
?readonly=${this.readonlySelector.matches(scope)}
|
|
110
|
-
.value=${(_b = (_a = this.form) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : ''}
|
|
111
|
-
@keydown=${(evt) => evt.key === 'Enter' && this.submit()}
|
|
112
|
-
@input=${(evt) => {
|
|
113
|
-
this.edit({ description: evt.currentTarget.value });
|
|
114
|
-
}}
|
|
115
|
-
>
|
|
116
|
-
</vaadin-text-field>
|
|
117
|
-
|
|
118
|
-
${this.renderTemplateOrSlot(`${scope}:after`)}
|
|
119
|
-
</div>
|
|
120
|
-
`;
|
|
121
|
-
}
|
|
122
|
-
__renderContent() {
|
|
123
|
-
var _a, _b;
|
|
124
|
-
const scope = 'content';
|
|
125
|
-
const url = this.form.content_url;
|
|
126
|
-
const source = this.form.content;
|
|
127
|
-
const contentChoice = url ? 'url' : source ? 'clipboard' : this.__contentChoice;
|
|
128
|
-
const isDisabled = !this.in('idle') || this.disabledSelector.matches(scope);
|
|
129
|
-
const isReadonly = this.readonlySelector.matches(scope);
|
|
130
|
-
const isSyncProhibited = isReadonly || !((_a = this.data) === null || _a === void 0 ? void 0 : _a.content_url) || url !== this.data.content_url;
|
|
131
|
-
return html `
|
|
132
|
-
<div data-testid="content">
|
|
133
|
-
<x-group frame>
|
|
134
|
-
<foxy-i18n
|
|
135
|
-
class=${classMap({ 'transition-colors': true, 'text-disabled': isDisabled })}
|
|
136
|
-
lang=${this.lang}
|
|
137
|
-
slot="header"
|
|
138
|
-
key="template"
|
|
139
|
-
ns=${this.ns}
|
|
140
|
-
>
|
|
141
|
-
</foxy-i18n>
|
|
142
|
-
|
|
143
|
-
<x-choice
|
|
144
|
-
data-testid="content-type"
|
|
145
|
-
.value=${contentChoice}
|
|
146
|
-
.items=${['default', 'url', 'clipboard']}
|
|
147
|
-
?readonly=${isReadonly}
|
|
148
|
-
?disabled=${isDisabled}
|
|
149
|
-
@change=${(evt) => {
|
|
150
|
-
if (evt instanceof ChoiceChangeEvent) {
|
|
151
|
-
this.edit({ content: '', content_url: '' });
|
|
152
|
-
this.__contentChoice = evt.detail;
|
|
153
|
-
}
|
|
154
|
-
}}
|
|
155
|
-
>
|
|
156
|
-
${['default', 'url', 'clipboard'].map(value => {
|
|
157
|
-
return html `
|
|
158
|
-
<div slot="${value}-label" class="py-s leading-s">
|
|
159
|
-
<foxy-i18n class="block" lang=${this.lang} key="template_${value}" ns=${this.ns}>
|
|
160
|
-
</foxy-i18n>
|
|
161
|
-
</div>
|
|
162
|
-
`;
|
|
163
|
-
})}
|
|
164
|
-
|
|
165
|
-
<div
|
|
166
|
-
style="--lumo-border-radius: var(--lumo-border-radius-s)"
|
|
167
|
-
class="mb-m"
|
|
168
|
-
slot="url"
|
|
169
|
-
?hidden=${contentChoice !== 'url'}
|
|
170
|
-
>
|
|
171
|
-
<div class="flex items-end mt-0">
|
|
172
|
-
<vaadin-text-field
|
|
173
|
-
data-testid="content-url"
|
|
174
|
-
placeholder="https://example.com/my-template"
|
|
175
|
-
label=${this.t('url')}
|
|
176
|
-
class="flex-1 min-w-0"
|
|
177
|
-
?readonly=${isReadonly}
|
|
178
|
-
?disabled=${isDisabled}
|
|
179
|
-
.value=${this.form.content_url}
|
|
180
|
-
@keydown=${(evt) => evt.key === 'Enter' && this.submit()}
|
|
181
|
-
@input=${(evt) => {
|
|
182
|
-
const value = evt.currentTarget.value;
|
|
183
|
-
this.edit({ content: '', content_url: value });
|
|
184
|
-
}}
|
|
185
|
-
>
|
|
186
|
-
</vaadin-text-field>
|
|
187
|
-
|
|
188
|
-
<vaadin-button
|
|
189
|
-
data-testid="cache"
|
|
190
|
-
class="relative flex-shrink-0 ml-s"
|
|
191
|
-
?hidden=${isSyncProhibited}
|
|
192
|
-
?disabled=${isDisabled || this.__cacheState === 'busy'}
|
|
193
|
-
@click=${this.__cache}
|
|
194
|
-
>
|
|
195
|
-
<foxy-i18n
|
|
196
|
-
class=${classMap({
|
|
197
|
-
'relative transition-opacity': true,
|
|
198
|
-
'opacity-0': this.__cacheState !== 'idle',
|
|
199
|
-
})}
|
|
200
|
-
lang=${this.lang}
|
|
201
|
-
key="cache"
|
|
202
|
-
ns=${this.ns}
|
|
203
|
-
>
|
|
204
|
-
</foxy-i18n>
|
|
205
|
-
|
|
206
|
-
<div
|
|
207
|
-
class=${classMap({
|
|
208
|
-
'absolute inset-0 flex transition-opacity': true,
|
|
209
|
-
'opacity-0': this.__cacheState === 'idle',
|
|
210
|
-
})}
|
|
211
|
-
>
|
|
212
|
-
<foxy-spinner
|
|
213
|
-
layout="no-label"
|
|
214
|
-
class="m-auto"
|
|
215
|
-
state=${this.__cacheState === 'fail' ? 'error' : 'busy'}
|
|
216
|
-
lang=${this.lang}
|
|
217
|
-
ns=${this.ns}
|
|
218
|
-
>
|
|
219
|
-
</foxy-spinner>
|
|
220
|
-
</div>
|
|
221
|
-
</vaadin-button>
|
|
222
|
-
</div>
|
|
223
|
-
|
|
224
|
-
<foxy-internal-source-control
|
|
225
|
-
placeholder=${this.t('url_source_placeholder')}
|
|
226
|
-
helper-text=""
|
|
227
|
-
label=${this.t('url_source_label')}
|
|
228
|
-
infer="content"
|
|
229
|
-
class="mt-m${((_b = this.data) === null || _b === void 0 ? void 0 : _b.content) ? '' : ' hidden'}"
|
|
230
|
-
>
|
|
231
|
-
</foxy-internal-source-control>
|
|
232
|
-
</div>
|
|
233
|
-
|
|
234
|
-
<foxy-internal-source-control
|
|
235
|
-
placeholder=${this.t('clipboard_source_placeholder')}
|
|
236
|
-
helper-text=""
|
|
237
|
-
label=${this.t('clipboard_source_label')}
|
|
238
|
-
infer="content"
|
|
239
|
-
class="mb-m${contentChoice === 'clipboard' ? '' : ' hidden'}"
|
|
240
|
-
style="--lumo-border-radius: var(--lumo-border-radius-s)"
|
|
241
|
-
slot="clipboard"
|
|
242
|
-
>
|
|
243
|
-
</foxy-internal-source-control>
|
|
244
|
-
</x-choice>
|
|
245
|
-
</x-group>
|
|
246
|
-
</div>
|
|
247
|
-
`;
|
|
248
|
-
}
|
|
249
|
-
__renderTimestamps() {
|
|
250
|
-
const scope = 'timestamps';
|
|
251
|
-
return html `
|
|
252
|
-
<div>
|
|
253
|
-
${this.renderTemplateOrSlot(`${scope}:before`)}
|
|
254
|
-
|
|
255
|
-
<x-metadata
|
|
256
|
-
data-testid="timestamps"
|
|
257
|
-
.items=${['date_modified', 'date_created'].map(field => {
|
|
258
|
-
var _a;
|
|
259
|
-
return ({
|
|
260
|
-
name: this.t(field),
|
|
261
|
-
value: ((_a = this.data) === null || _a === void 0 ? void 0 : _a[field]) ? this.t('date', { value: new Date(this.data[field]) })
|
|
262
|
-
: '',
|
|
263
|
-
});
|
|
264
|
-
})}
|
|
265
|
-
>
|
|
266
|
-
</x-metadata>
|
|
267
|
-
|
|
268
|
-
${this.renderTemplateOrSlot(`${scope}:after`)}
|
|
269
|
-
</div>
|
|
270
|
-
`;
|
|
271
|
-
}
|
|
272
|
-
__renderAction(action) {
|
|
273
|
-
const { disabledSelector, href, lang, ns } = this;
|
|
274
|
-
const isTemplateValid = this.in({ idle: { template: { dirty: 'valid' } } });
|
|
275
|
-
const isSnapshotValid = this.in({ idle: { snapshot: { dirty: 'valid' } } });
|
|
276
|
-
const isDisabled = !this.in('idle') || disabledSelector.matches(action, true);
|
|
277
|
-
const isValid = isTemplateValid || isSnapshotValid;
|
|
278
|
-
const handleClick = (evt) => {
|
|
279
|
-
if (action === 'delete') {
|
|
280
|
-
const confirm = this.renderRoot.querySelector('#confirm');
|
|
281
|
-
confirm.show(evt.currentTarget);
|
|
282
|
-
}
|
|
283
|
-
else {
|
|
284
|
-
this.submit();
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
return html `
|
|
288
|
-
<div>
|
|
289
|
-
${this.renderTemplateOrSlot(`${action}:before`)}
|
|
290
|
-
|
|
291
|
-
<foxy-internal-confirm-dialog
|
|
292
|
-
message="delete_prompt"
|
|
293
|
-
confirm="delete"
|
|
294
|
-
cancel="cancel"
|
|
295
|
-
header="delete"
|
|
296
|
-
theme="primary error"
|
|
297
|
-
lang=${lang}
|
|
298
|
-
ns=${ns}
|
|
299
|
-
id="confirm"
|
|
300
|
-
data-testid="confirm"
|
|
301
|
-
@hide=${(evt) => {
|
|
302
|
-
if (!evt.detail.cancelled)
|
|
303
|
-
this.delete();
|
|
304
|
-
}}
|
|
305
|
-
>
|
|
306
|
-
</foxy-internal-confirm-dialog>
|
|
307
|
-
|
|
308
|
-
<vaadin-button
|
|
309
|
-
class="w-full"
|
|
310
|
-
theme=${this.in('idle') ? (href ? 'error' : 'primary success') : ''}
|
|
311
|
-
data-testid=${action}
|
|
312
|
-
?disabled=${(this.in({ idle: 'template' }) && !isValid) || isDisabled}
|
|
313
|
-
@click=${handleClick}
|
|
314
|
-
>
|
|
315
|
-
<foxy-i18n ns=${ns} key=${action} lang=${lang}></foxy-i18n>
|
|
316
|
-
</vaadin-button>
|
|
317
|
-
|
|
318
|
-
${this.renderTemplateOrSlot(`${action}:after`)}
|
|
319
|
-
</div>
|
|
320
|
-
`;
|
|
321
|
-
}
|
|
322
|
-
async __cache() {
|
|
323
|
-
var _a, _b;
|
|
324
|
-
this.__cacheState = 'busy';
|
|
325
|
-
try {
|
|
326
|
-
const url = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a._links['fx:cache'].href) !== null && _b !== void 0 ? _b : '';
|
|
327
|
-
const response = await new TemplateForm.API(this).fetch(url, { method: 'POST' });
|
|
328
|
-
this.__cacheState = response.ok ? 'idle' : 'fail';
|
|
329
|
-
this.refresh();
|
|
330
|
-
}
|
|
331
|
-
catch (_c) {
|
|
332
|
-
this.__cacheState = 'fail';
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
84
|
}
|
|
336
85
|
//# sourceMappingURL=TemplateForm.js.map
|