@foxy.io/elements 1.13.0-beta.2 → 1.14.0-beta.2
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-access-recovery-form.js +1 -1
- package/dist/cdn/foxy-address-card.js +1 -1
- package/dist/cdn/foxy-address-form.js +1 -1
- package/dist/cdn/foxy-applied-tax-card.js +1 -1
- package/dist/cdn/foxy-attribute-card.js +1 -1
- package/dist/cdn/foxy-attribute-form.js +1 -1
- package/dist/cdn/foxy-cancellation-form.js +1 -1
- package/dist/cdn/foxy-collection-page.js +1 -1
- package/dist/cdn/foxy-collection-pages.js +1 -1
- package/dist/cdn/foxy-custom-field-card.js +1 -1
- package/dist/cdn/foxy-custom-field-form.js +1 -1
- package/dist/cdn/foxy-customer-card.js +1 -1
- package/dist/cdn/foxy-customer-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings.js +1 -1
- package/dist/cdn/foxy-customer-portal.js +1 -1
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-customers-table.js +1 -1
- package/dist/cdn/foxy-discount-card.js +1 -1
- package/dist/cdn/foxy-donation.js +1 -1
- package/dist/cdn/foxy-email-template-form.js +1 -0
- package/dist/cdn/foxy-error-entry-card.js +1 -1
- package/dist/cdn/foxy-form-dialog.js +1 -1
- package/dist/cdn/foxy-i18n.js +1 -1
- package/dist/cdn/foxy-items-form.js +1 -1
- package/dist/cdn/foxy-payment-card.js +1 -1
- package/dist/cdn/foxy-payment-method-card.js +1 -1
- package/dist/cdn/foxy-query-builder.js +1 -1
- package/dist/cdn/foxy-sign-in-form.js +1 -1
- package/dist/cdn/foxy-spinner.js +1 -1
- package/dist/cdn/foxy-subscription-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +1 -1
- package/dist/cdn/foxy-subscriptions-table.js +1 -1
- package/dist/cdn/foxy-table.js +1 -1
- package/dist/cdn/foxy-tax-card.js +1 -1
- package/dist/cdn/foxy-tax-form.js +1 -1
- package/dist/cdn/foxy-template-form.js +1 -0
- package/dist/cdn/foxy-transaction-card.js +1 -1
- package/dist/cdn/foxy-transactions-table.js +1 -1
- package/dist/cdn/foxy-user-form.js +1 -1
- package/dist/cdn/foxy-users-table.js +1 -1
- package/dist/cdn/{shared-145cc9eb.js → shared-151ca103.js} +1 -1
- package/dist/cdn/{shared-f47647ac.js → shared-35415106.js} +1 -1
- package/dist/cdn/{shared-4a990126.js → shared-35502e88.js} +1 -1
- package/dist/cdn/{shared-c1e0e11f.js → shared-5388f705.js} +1 -1
- package/dist/cdn/{shared-036a8b21.js → shared-566252ac.js} +1 -1
- package/dist/cdn/{shared-a99dea97.js → shared-5d286626.js} +1 -1
- package/dist/cdn/{shared-d9159fe1.js → shared-6783c996.js} +1 -1
- package/dist/cdn/shared-7f588649.js +1 -0
- package/dist/cdn/{shared-bf09e011.js → shared-9467cb31.js} +6 -6
- package/dist/cdn/{shared-91a9e922.js → shared-99f45065.js} +4 -4
- package/dist/cdn/{shared-67157a25.js → shared-dbbe03f9.js} +1 -1
- package/dist/cdn/{shared-e55b6bb7.js → shared-e057788f.js} +1 -1
- package/dist/cdn/shared-ebbef842.js +1 -0
- package/dist/cdn/{shared-b77179fd.js → shared-f2a4fd27.js} +1 -1
- package/dist/cdn/{shared-296637c5.js → shared-fd5b81be.js} +1 -1
- package/dist/cdn/translations/shared/en.json +11 -0
- package/dist/elements/private/Choice/Choice.js +1 -3
- package/dist/elements/private/Choice/Choice.js.map +1 -1
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.d.ts +24 -0
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js +307 -0
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js.map +1 -0
- package/dist/elements/public/EmailTemplateForm/index.d.ts +9 -0
- package/dist/elements/public/EmailTemplateForm/index.js +11 -0
- package/dist/elements/public/EmailTemplateForm/index.js.map +1 -0
- package/dist/elements/public/EmailTemplateForm/types.d.ts +3 -0
- package/dist/elements/public/EmailTemplateForm/types.js +2 -0
- package/dist/elements/public/EmailTemplateForm/types.js.map +1 -0
- package/dist/elements/public/TaxForm/TaxForm.d.ts +2 -0
- package/dist/elements/public/TaxForm/TaxForm.js +37 -8
- package/dist/elements/public/TaxForm/TaxForm.js.map +1 -1
- package/dist/elements/public/TaxForm/index.d.ts +1 -0
- package/dist/elements/public/TaxForm/index.js +1 -0
- package/dist/elements/public/TaxForm/index.js.map +1 -1
- package/dist/elements/public/TemplateForm/TemplateForm.d.ts +23 -0
- package/dist/elements/public/TemplateForm/TemplateForm.js +299 -0
- package/dist/elements/public/TemplateForm/TemplateForm.js.map +1 -0
- package/dist/elements/public/TemplateForm/index.d.ts +9 -0
- package/dist/elements/public/TemplateForm/index.js +11 -0
- package/dist/elements/public/TemplateForm/index.js.map +1 -0
- package/dist/elements/public/TemplateForm/types.d.ts +3 -0
- package/dist/elements/public/TemplateForm/types.js +2 -0
- package/dist/elements/public/TemplateForm/types.js.map +1 -0
- package/dist/elements/public/index.d.ts +2 -0
- package/dist/elements/public/index.defined.d.ts +2 -0
- package/dist/elements/public/index.defined.js +2 -0
- package/dist/elements/public/index.defined.js.map +1 -1
- package/dist/elements/public/index.js +2 -0
- package/dist/elements/public/index.js.map +1 -1
- package/dist/mixins/themeable.js +8 -0
- package/dist/mixins/themeable.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdn/shared-b0b1d248.js +0 -1
- package/dist/cdn/shared-f2cf6cfb.js +0 -1
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { css, html } from 'lit-element';
|
|
2
|
+
import { Choice, Group, PropertyTable } 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
|
+
import { TranslatableMixin } from "../../../mixins/translatable.js";
|
|
9
|
+
import { classMap } from "../../../utils/class-map.js";
|
|
10
|
+
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
11
|
+
const NS = 'email-template-form';
|
|
12
|
+
const Base = ScopedElementsMixin(ThemeableMixin(ConfigurableMixin(TranslatableMixin(NucleonElement, NS))));
|
|
13
|
+
export class EmailTemplateForm extends Base {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.__cacheState = 'idle';
|
|
17
|
+
this.__contentChoice = 'default';
|
|
18
|
+
}
|
|
19
|
+
static get properties() {
|
|
20
|
+
return {
|
|
21
|
+
...super.properties,
|
|
22
|
+
__cacheState: { attribute: false },
|
|
23
|
+
__contentChoice: { attribute: false },
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
static get styles() {
|
|
27
|
+
return [
|
|
28
|
+
...super.styles,
|
|
29
|
+
css `#cached-content::part(input-field){
|
|
30
|
+
max-height:15em;
|
|
31
|
+
}
|
|
32
|
+
`,
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
static get scopedElements() {
|
|
36
|
+
return {
|
|
37
|
+
'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),
|
|
38
|
+
'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),
|
|
39
|
+
'foxy-spinner': customElements.get('foxy-spinner'),
|
|
40
|
+
'foxy-i18n': customElements.get('foxy-i18n'),
|
|
41
|
+
'vaadin-text-field': customElements.get('vaadin-text-field'),
|
|
42
|
+
'vaadin-text-area': customElements.get('vaadin-text-area'),
|
|
43
|
+
'vaadin-button': customElements.get('vaadin-button'),
|
|
44
|
+
'x-property-table': PropertyTable,
|
|
45
|
+
'x-choice': Choice,
|
|
46
|
+
'x-group': Group,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
render() {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
const { hiddenSelector, href, lang, ns } = this;
|
|
52
|
+
const action = href ? 'delete' : 'create';
|
|
53
|
+
const isBusy = this.in('busy');
|
|
54
|
+
const isFail = this.in('fail');
|
|
55
|
+
return html `
|
|
56
|
+
<div class="space-y-m">
|
|
57
|
+
${hiddenSelector.matches('description', true) ? '' : this.__renderDescription()}
|
|
58
|
+
${hiddenSelector.matches('content', true) ? '' : this.__renderContent()}
|
|
59
|
+
${hiddenSelector.matches('timestamps', true) || !href ? '' : this.__renderTimestamps()}
|
|
60
|
+
${hiddenSelector.matches(action) ? '' : this.__renderAction(action)}
|
|
61
|
+
|
|
62
|
+
<div
|
|
63
|
+
data-testid="spinner"
|
|
64
|
+
class=${classMap({
|
|
65
|
+
'transition duration-500 ease-in-out absolute inset-0 flex': true,
|
|
66
|
+
'opacity-0 pointer-events-none': !isBusy && !isFail,
|
|
67
|
+
})}
|
|
68
|
+
>
|
|
69
|
+
<foxy-spinner
|
|
70
|
+
layout="vertical"
|
|
71
|
+
class="m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l"
|
|
72
|
+
state=${isFail ? 'error' : isBusy ? 'busy' : 'empty'}
|
|
73
|
+
lang=${lang}
|
|
74
|
+
ns="${ns} ${(_b = (_a = customElements.get('foxy-spinner')) === null || _a === void 0 ? void 0 : _a.defaultNS) !== null && _b !== void 0 ? _b : ''}"
|
|
75
|
+
>
|
|
76
|
+
</foxy-spinner>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
__renderDescription() {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
return html `
|
|
84
|
+
<div>
|
|
85
|
+
${this.renderTemplateOrSlot('description:before')}
|
|
86
|
+
|
|
87
|
+
<vaadin-text-field
|
|
88
|
+
class="w-full mb-s"
|
|
89
|
+
label=${this.t('description')}
|
|
90
|
+
.value=${(_b = (_a = this.form) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : ''}
|
|
91
|
+
@keydown=${(evt) => evt.key === 'Enter' && this.submit()}
|
|
92
|
+
@input=${(evt) => {
|
|
93
|
+
this.edit({ description: evt.currentTarget.value });
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
</vaadin-text-field>
|
|
97
|
+
|
|
98
|
+
${this.renderTemplateOrSlot('description:after')}
|
|
99
|
+
</div>
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
__renderContent() {
|
|
103
|
+
return html `
|
|
104
|
+
<div>
|
|
105
|
+
${this.renderTemplateOrSlot('content:before')}
|
|
106
|
+
|
|
107
|
+
<div class="space-y-l">
|
|
108
|
+
${this.__renderTabContent('content_text_url', 'content_text', 'text_template')}
|
|
109
|
+
${this.__renderTabContent('content_html_url', 'content_html', 'html_template')}
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
${this.renderTemplateOrSlot('content:after')}
|
|
113
|
+
</div>
|
|
114
|
+
`;
|
|
115
|
+
}
|
|
116
|
+
__renderTabContent(urlPath, textPath, header) {
|
|
117
|
+
var _a;
|
|
118
|
+
const contentChoice = this.form[urlPath]
|
|
119
|
+
? 'url'
|
|
120
|
+
: this.form[textPath]
|
|
121
|
+
? 'clipboard'
|
|
122
|
+
: this.__contentChoice;
|
|
123
|
+
return html `
|
|
124
|
+
<x-group frame>
|
|
125
|
+
<foxy-i18n lang=${this.lang} slot="header" key=${header} ns=${this.ns}></foxy-i18n>
|
|
126
|
+
|
|
127
|
+
<x-choice
|
|
128
|
+
data-testid="template-type"
|
|
129
|
+
.value=${contentChoice}
|
|
130
|
+
.items=${['default', 'url', 'clipboard']}
|
|
131
|
+
?readonly=${this.readonlySelector.matches('content', true)}
|
|
132
|
+
?disabled=${this.in('busy') || this.disabledSelector.matches('content', true)}
|
|
133
|
+
@change=${(evt) => {
|
|
134
|
+
if (evt instanceof ChoiceChangeEvent) {
|
|
135
|
+
this.edit({ [textPath]: '', [urlPath]: '' });
|
|
136
|
+
this.__contentChoice = evt.detail; // TODO
|
|
137
|
+
}
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
${['default', 'url', 'clipboard'].map(value => {
|
|
141
|
+
return html `
|
|
142
|
+
<div slot="${value}-label" class="py-s">
|
|
143
|
+
<foxy-i18n class="block" lang=${this.lang} key="template_${value}" ns=${this.ns}>
|
|
144
|
+
</foxy-i18n>
|
|
145
|
+
|
|
146
|
+
<foxy-i18n
|
|
147
|
+
class="block text-s opacity-70"
|
|
148
|
+
lang=${this.lang}
|
|
149
|
+
key="template_${value}_explainer"
|
|
150
|
+
ns=${this.ns}
|
|
151
|
+
>
|
|
152
|
+
</foxy-i18n>
|
|
153
|
+
</div>
|
|
154
|
+
`;
|
|
155
|
+
})}
|
|
156
|
+
|
|
157
|
+
<div slot="url" ?hidden=${contentChoice !== 'url'}>
|
|
158
|
+
<div class="flex items-center mt-0 mb-m">
|
|
159
|
+
<vaadin-text-field
|
|
160
|
+
data-testid="content_url"
|
|
161
|
+
value=${ifDefined(this.form[urlPath])}
|
|
162
|
+
class="mr-s flex-grow"
|
|
163
|
+
@input=${(evt) => {
|
|
164
|
+
const value = evt.currentTarget.value;
|
|
165
|
+
this.edit({ [textPath]: '', [urlPath]: value });
|
|
166
|
+
}}
|
|
167
|
+
>
|
|
168
|
+
</vaadin-text-field>
|
|
169
|
+
|
|
170
|
+
${this.form[urlPath] === ((_a = this.data) === null || _a === void 0 ? void 0 : _a[urlPath])
|
|
171
|
+
? html `
|
|
172
|
+
<vaadin-button
|
|
173
|
+
class="relative"
|
|
174
|
+
?disabled=${this.__cacheState === 'busy'}
|
|
175
|
+
@click=${this.__cache}
|
|
176
|
+
>
|
|
177
|
+
<foxy-i18n
|
|
178
|
+
class=${classMap({
|
|
179
|
+
'relative transition-opacity': true,
|
|
180
|
+
'opacity-0': this.__cacheState !== 'idle',
|
|
181
|
+
})}
|
|
182
|
+
lang=${this.lang}
|
|
183
|
+
key="cache"
|
|
184
|
+
ns=${this.ns}
|
|
185
|
+
>
|
|
186
|
+
</foxy-i18n>
|
|
187
|
+
|
|
188
|
+
<div
|
|
189
|
+
class=${classMap({
|
|
190
|
+
'absolute inset-0 flex transition-opacity': true,
|
|
191
|
+
'opacity-0': this.__cacheState === 'idle',
|
|
192
|
+
})}
|
|
193
|
+
>
|
|
194
|
+
<foxy-spinner
|
|
195
|
+
layout="no-label"
|
|
196
|
+
class="m-auto"
|
|
197
|
+
state=${this.__cacheState === 'fail' ? 'error' : 'busy'}
|
|
198
|
+
lang=${this.lang}
|
|
199
|
+
ns=${this.ns}
|
|
200
|
+
>
|
|
201
|
+
</foxy-spinner>
|
|
202
|
+
</div>
|
|
203
|
+
</vaadin-button>
|
|
204
|
+
`
|
|
205
|
+
: ''}
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
|
|
209
|
+
<div slot="clipboard" ?hidden=${contentChoice !== 'clipboard'}>
|
|
210
|
+
<vaadin-text-area
|
|
211
|
+
id="cached-content"
|
|
212
|
+
data-testid="content"
|
|
213
|
+
class="w-full mb-m"
|
|
214
|
+
.value=${this.form[textPath]}
|
|
215
|
+
@input=${(evt) => {
|
|
216
|
+
const value = evt.currentTarget.value;
|
|
217
|
+
this.edit({ [textPath]: value, [urlPath]: '' });
|
|
218
|
+
}}
|
|
219
|
+
>
|
|
220
|
+
</vaadin-text-area>
|
|
221
|
+
</div>
|
|
222
|
+
</x-choice>
|
|
223
|
+
</x-group>
|
|
224
|
+
`;
|
|
225
|
+
}
|
|
226
|
+
__renderTimestamps() {
|
|
227
|
+
return html `
|
|
228
|
+
<div>
|
|
229
|
+
${this.renderTemplateOrSlot('timestamps:before')}
|
|
230
|
+
|
|
231
|
+
<x-property-table
|
|
232
|
+
data-testid="timestamps"
|
|
233
|
+
.items=${['date_modified', 'date_created'].map(field => ({
|
|
234
|
+
name: this.t(field),
|
|
235
|
+
value: this.data ? this.t('date', { value: new Date(this.data[field]) }) : '',
|
|
236
|
+
}))}
|
|
237
|
+
>
|
|
238
|
+
</x-property-table>
|
|
239
|
+
|
|
240
|
+
${this.renderTemplateOrSlot('timestamps:after')}
|
|
241
|
+
</div>
|
|
242
|
+
`;
|
|
243
|
+
}
|
|
244
|
+
__renderAction(action) {
|
|
245
|
+
const { disabledSelector, href, lang, ns } = this;
|
|
246
|
+
const isTemplateValid = this.in({ idle: { template: { dirty: 'valid' } } });
|
|
247
|
+
const isSnapshotValid = this.in({ idle: { snapshot: { dirty: 'valid' } } });
|
|
248
|
+
const isDisabled = !this.in('idle') || disabledSelector.matches(action, true);
|
|
249
|
+
const isValid = isTemplateValid || isSnapshotValid;
|
|
250
|
+
const handleClick = (evt) => {
|
|
251
|
+
if (action === 'delete') {
|
|
252
|
+
const confirm = this.renderRoot.querySelector('#confirm');
|
|
253
|
+
confirm.show(evt.currentTarget);
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
this.submit();
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
return html `
|
|
260
|
+
<div>
|
|
261
|
+
${this.renderTemplateOrSlot(`${action}:before`)}
|
|
262
|
+
|
|
263
|
+
<foxy-internal-confirm-dialog
|
|
264
|
+
message="delete_prompt"
|
|
265
|
+
confirm="delete"
|
|
266
|
+
cancel="cancel"
|
|
267
|
+
header="delete"
|
|
268
|
+
theme="primary error"
|
|
269
|
+
lang=${lang}
|
|
270
|
+
ns=${ns}
|
|
271
|
+
id="confirm"
|
|
272
|
+
data-testid="confirm"
|
|
273
|
+
@hide=${(evt) => {
|
|
274
|
+
if (!evt.detail.cancelled)
|
|
275
|
+
this.delete();
|
|
276
|
+
}}
|
|
277
|
+
>
|
|
278
|
+
</foxy-internal-confirm-dialog>
|
|
279
|
+
|
|
280
|
+
<vaadin-button
|
|
281
|
+
class="w-full"
|
|
282
|
+
theme=${this.in('idle') ? `primary ${href ? 'error' : 'success'}` : ''}
|
|
283
|
+
data-testid=${action}
|
|
284
|
+
?disabled=${(this.in({ idle: 'template' }) && !isValid) || isDisabled}
|
|
285
|
+
@click=${handleClick}
|
|
286
|
+
>
|
|
287
|
+
<foxy-i18n ns=${ns} key=${action} lang=${lang}></foxy-i18n>
|
|
288
|
+
</vaadin-button>
|
|
289
|
+
|
|
290
|
+
${this.renderTemplateOrSlot(`${action}:after`)}
|
|
291
|
+
</div>
|
|
292
|
+
`;
|
|
293
|
+
}
|
|
294
|
+
async __cache() {
|
|
295
|
+
var _a, _b;
|
|
296
|
+
this.__cacheState = 'busy';
|
|
297
|
+
try {
|
|
298
|
+
const url = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a._links['fx:cache'].href) !== null && _b !== void 0 ? _b : '';
|
|
299
|
+
const response = await new EmailTemplateForm.API(this).fetch(url, { method: 'POST' });
|
|
300
|
+
this.__cacheState = response.ok ? 'idle' : 'fail';
|
|
301
|
+
}
|
|
302
|
+
catch (_c) {
|
|
303
|
+
this.__cacheState = 'fail';
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
//# sourceMappingURL=EmailTemplateForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailTemplateForm.js","sourceRoot":"","sources":["../../../../src/elements/public/EmailTemplateForm/EmailTemplateForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwD,GAAG,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,+BAA4B;AACnE,OAAO,EAAqB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,gCAA6B;AACzD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAIjE,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAGlE,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,MAAM,EAAE,GAAG,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CAAC,CAAC,CAAC,EAAE;wBACxD,MAAM;sBACR,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,UAAU;mBAC5D,WAAW;;0BAEJ,EAAE,QAAQ,MAAM,SAAS,IAAI;;;UAG7C,IAAI,CAAC,oBAAoB,CAAC,GAAG,MAAM,QAAQ,CAAC;;KAEjD,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,OAAO;;QACnB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;QAE3B,IAAI;YACF,MAAM,GAAG,eAAG,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,UAAU,EAAE,IAAI,mCAAI,EAAE,CAAC;YACrD,MAAM,QAAQ,GAAG,MAAM,IAAI,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YAEtF,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;SACnD;QAAC,WAAM;YACN,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;SAC5B;IACH,CAAC;CACF","sourcesContent":["import { CSSResultArray, PropertyDeclarations, TemplateResult, css, html } from 'lit-element';\nimport { Choice, Group, PropertyTable } from '../../private/index';\nimport { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\n\nimport { ChoiceChangeEvent } from '../../private/events';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { Data } from './types';\nimport { DialogHideEvent } from '../../private/Dialog/DialogHideEvent';\nimport { InternalConfirmDialog } from '../../internal/InternalConfirmDialog/InternalConfirmDialog';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { TextAreaElement } from '@vaadin/vaadin-text-field/vaadin-text-area';\nimport { TextFieldElement } from '@vaadin/vaadin-text-field';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { ifDefined } from 'lit-html/directives/if-defined';\n\nconst NS = 'email-template-form';\nconst Base = ScopedElementsMixin(\n ThemeableMixin(ConfigurableMixin(TranslatableMixin(NucleonElement, NS)))\n);\n\nexport class EmailTemplateForm extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __cacheState: { attribute: false },\n __contentChoice: { attribute: false },\n };\n }\n\n static get styles(): CSSResultArray {\n return [\n ...super.styles,\n css`\n #cached-content::part(input-field) {\n max-height: 15em;\n }\n `,\n ];\n }\n\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'vaadin-text-area': customElements.get('vaadin-text-area'),\n 'vaadin-button': customElements.get('vaadin-button'),\n 'x-property-table': PropertyTable,\n 'x-choice': Choice,\n 'x-group': Group,\n };\n }\n\n private __cacheState: 'idle' | 'busy' | 'fail' = 'idle';\n\n private __contentChoice: 'default' | 'url' | 'clipboard' = 'default';\n\n render(): TemplateResult {\n const { hiddenSelector, href, lang, ns } = this;\n const action = href ? 'delete' : 'create';\n const isBusy = this.in('busy');\n const isFail = this.in('fail');\n\n return html`\n <div class=\"space-y-m\">\n ${hiddenSelector.matches('description', true) ? '' : this.__renderDescription()}\n ${hiddenSelector.matches('content', true) ? '' : this.__renderContent()}\n ${hiddenSelector.matches('timestamps', true) || !href ? '' : this.__renderTimestamps()}\n ${hiddenSelector.matches(action) ? '' : this.__renderAction(action)}\n\n <div\n data-testid=\"spinner\"\n class=${classMap({\n 'transition duration-500 ease-in-out absolute inset-0 flex': true,\n 'opacity-0 pointer-events-none': !isBusy && !isFail,\n })}\n >\n <foxy-spinner\n layout=\"vertical\"\n class=\"m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l\"\n state=${isFail ? 'error' : isBusy ? 'busy' : 'empty'}\n lang=${lang}\n ns=\"${ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n private __renderDescription() {\n return html`\n <div>\n ${this.renderTemplateOrSlot('description:before')}\n\n <vaadin-text-field\n class=\"w-full mb-s\"\n label=${this.t('description')}\n .value=${this.form?.description ?? ''}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.submit()}\n @input=${(evt: CustomEvent) => {\n this.edit({ description: (evt.currentTarget as TextFieldElement).value });\n }}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot('description:after')}\n </div>\n `;\n }\n\n private __renderContent() {\n return html`\n <div>\n ${this.renderTemplateOrSlot('content:before')}\n\n <div class=\"space-y-l\">\n ${this.__renderTabContent('content_text_url', 'content_text', 'text_template')}\n ${this.__renderTabContent('content_html_url', 'content_html', 'html_template')}\n </div>\n\n ${this.renderTemplateOrSlot('content:after')}\n </div>\n `;\n }\n\n private __renderTabContent(\n urlPath: 'content_text_url' | 'content_html_url',\n textPath: 'content_text' | 'content_html',\n header: string\n ) {\n const contentChoice = this.form[urlPath]\n ? 'url'\n : this.form[textPath]\n ? 'clipboard'\n : this.__contentChoice;\n\n return html`\n <x-group frame>\n <foxy-i18n lang=${this.lang} slot=\"header\" key=${header} ns=${this.ns}></foxy-i18n>\n\n <x-choice\n data-testid=\"template-type\"\n .value=${contentChoice}\n .items=${['default', 'url', 'clipboard']}\n ?readonly=${this.readonlySelector.matches('content', true)}\n ?disabled=${this.in('busy') || this.disabledSelector.matches('content', true)}\n @change=${(evt: Event) => {\n if (evt instanceof ChoiceChangeEvent) {\n this.edit({ [textPath]: '', [urlPath]: '' });\n this.__contentChoice = evt.detail as any; // TODO\n }\n }}\n >\n ${['default', 'url', 'clipboard'].map(value => {\n return html`\n <div slot=\"${value}-label\" class=\"py-s\">\n <foxy-i18n class=\"block\" lang=${this.lang} key=\"template_${value}\" ns=${this.ns}>\n </foxy-i18n>\n\n <foxy-i18n\n class=\"block text-s opacity-70\"\n lang=${this.lang}\n key=\"template_${value}_explainer\"\n ns=${this.ns}\n >\n </foxy-i18n>\n </div>\n `;\n })}\n\n <div slot=\"url\" ?hidden=${contentChoice !== 'url'}>\n <div class=\"flex items-center mt-0 mb-m\">\n <vaadin-text-field\n data-testid=\"content_url\"\n value=${ifDefined(this.form[urlPath])}\n class=\"mr-s flex-grow\"\n @input=${(evt: CustomEvent) => {\n const value = (evt.currentTarget as TextFieldElement).value;\n this.edit({ [textPath]: '', [urlPath]: value });\n }}\n >\n </vaadin-text-field>\n\n ${this.form[urlPath] === this.data?.[urlPath]\n ? html`\n <vaadin-button\n class=\"relative\"\n ?disabled=${this.__cacheState === 'busy'}\n @click=${this.__cache}\n >\n <foxy-i18n\n class=${classMap({\n 'relative transition-opacity': true,\n 'opacity-0': this.__cacheState !== 'idle',\n })}\n lang=${this.lang}\n key=\"cache\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n <div\n class=${classMap({\n 'absolute inset-0 flex transition-opacity': true,\n 'opacity-0': this.__cacheState === 'idle',\n })}\n >\n <foxy-spinner\n layout=\"no-label\"\n class=\"m-auto\"\n state=${this.__cacheState === 'fail' ? 'error' : 'busy'}\n lang=${this.lang}\n ns=${this.ns}\n >\n </foxy-spinner>\n </div>\n </vaadin-button>\n `\n : ''}\n </div>\n </div>\n\n <div slot=\"clipboard\" ?hidden=${contentChoice !== 'clipboard'}>\n <vaadin-text-area\n id=\"cached-content\"\n data-testid=\"content\"\n class=\"w-full mb-m\"\n .value=${this.form[textPath]}\n @input=${(evt: CustomEvent) => {\n const value = (evt.currentTarget as TextAreaElement).value;\n this.edit({ [textPath]: value, [urlPath]: '' });\n }}\n >\n </vaadin-text-area>\n </div>\n </x-choice>\n </x-group>\n `;\n }\n\n private __renderTimestamps() {\n return html`\n <div>\n ${this.renderTemplateOrSlot('timestamps:before')}\n\n <x-property-table\n data-testid=\"timestamps\"\n .items=${(['date_modified', 'date_created'] as const).map(field => ({\n name: this.t(field),\n value: this.data ? this.t('date', { value: new Date(this.data[field]) }) : '',\n }))}\n >\n </x-property-table>\n\n ${this.renderTemplateOrSlot('timestamps:after')}\n </div>\n `;\n }\n\n private __renderAction(action: string) {\n const { disabledSelector, href, lang, ns } = this;\n\n const isTemplateValid = this.in({ idle: { template: { dirty: 'valid' } } });\n const isSnapshotValid = this.in({ idle: { snapshot: { dirty: 'valid' } } });\n const isDisabled = !this.in('idle') || disabledSelector.matches(action, true);\n const isValid = isTemplateValid || isSnapshotValid;\n\n const handleClick = (evt: Event) => {\n if (action === 'delete') {\n const confirm = this.renderRoot.querySelector('#confirm');\n (confirm as InternalConfirmDialog).show(evt.currentTarget as HTMLElement);\n } else {\n this.submit();\n }\n };\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${action}:before`)}\n\n <foxy-internal-confirm-dialog\n message=\"delete_prompt\"\n confirm=\"delete\"\n cancel=\"cancel\"\n header=\"delete\"\n theme=\"primary error\"\n lang=${lang}\n ns=${ns}\n id=\"confirm\"\n data-testid=\"confirm\"\n @hide=${(evt: DialogHideEvent) => {\n if (!evt.detail.cancelled) this.delete();\n }}\n >\n </foxy-internal-confirm-dialog>\n\n <vaadin-button\n class=\"w-full\"\n theme=${this.in('idle') ? `primary ${href ? 'error' : 'success'}` : ''}\n data-testid=${action}\n ?disabled=${(this.in({ idle: 'template' }) && !isValid) || isDisabled}\n @click=${handleClick}\n >\n <foxy-i18n ns=${ns} key=${action} lang=${lang}></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot(`${action}:after`)}\n </div>\n `;\n }\n\n private async __cache(): Promise<void> {\n this.__cacheState = 'busy';\n\n try {\n const url = this.data?._links['fx:cache'].href ?? '';\n const response = await new EmailTemplateForm.API(this).fetch(url, { method: 'POST' });\n\n this.__cacheState = response.ok ? 'idle' : 'fail';\n } catch {\n this.__cacheState = 'fail';\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import '@vaadin/vaadin-text-field/vaadin-text-field';
|
|
2
|
+
import '@vaadin/vaadin-text-field/vaadin-text-area';
|
|
3
|
+
import '@vaadin/vaadin-button';
|
|
4
|
+
import '../../internal/InternalConfirmDialog/index';
|
|
5
|
+
import '../../internal/InternalSandbox/index';
|
|
6
|
+
import '../Spinner/index';
|
|
7
|
+
import '../I18n/index';
|
|
8
|
+
import { EmailTemplateForm } from './EmailTemplateForm';
|
|
9
|
+
export { EmailTemplateForm };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import '@vaadin/vaadin-text-field/vaadin-text-field';
|
|
2
|
+
import '@vaadin/vaadin-text-field/vaadin-text-area';
|
|
3
|
+
import '@vaadin/vaadin-button';
|
|
4
|
+
import "../../internal/InternalConfirmDialog/index.js";
|
|
5
|
+
import "../../internal/InternalSandbox/index.js";
|
|
6
|
+
import "../Spinner/index.js";
|
|
7
|
+
import "../I18n/index.js";
|
|
8
|
+
import { EmailTemplateForm } from "./EmailTemplateForm.js";
|
|
9
|
+
customElements.define('foxy-email-template-form', EmailTemplateForm);
|
|
10
|
+
export { EmailTemplateForm };
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/elements/public/EmailTemplateForm/index.ts"],"names":[],"mappings":"AAAA,OAAO,6CAA6C,CAAC;AACrD,OAAO,4CAA4C,CAAC;AACpD,OAAO,uBAAuB,CAAC;AAC/B,uDAAoD;AACpD,iDAA8C;AAC9C,6BAA0B;AAC1B,0BAAuB;AAEvB,OAAO,EAAE,iBAAiB,EAAE,+BAA4B;AAExD,cAAc,CAAC,MAAM,CAAC,0BAA0B,EAAE,iBAAiB,CAAC,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import '@vaadin/vaadin-text-field/vaadin-text-field';\nimport '@vaadin/vaadin-text-field/vaadin-text-area';\nimport '@vaadin/vaadin-button';\nimport '../../internal/InternalConfirmDialog/index';\nimport '../../internal/InternalSandbox/index';\nimport '../Spinner/index';\nimport '../I18n/index';\n\nimport { EmailTemplateForm } from './EmailTemplateForm';\n\ncustomElements.define('foxy-email-template-form', EmailTemplateForm);\n\nexport { EmailTemplateForm };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/elements/public/EmailTemplateForm/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Rels } from '@foxy.io/sdk/backend';\nimport { Resource } from '@foxy.io/sdk/core';\n\nexport type Data = Resource<Rels.EmailTemplate>;\n"]}
|
|
@@ -59,6 +59,7 @@ export declare class TaxForm extends Base<Data> {
|
|
|
59
59
|
static get properties(): PropertyDeclarations;
|
|
60
60
|
static get v8n(): NucleonV8N<Data>;
|
|
61
61
|
templates: Templates;
|
|
62
|
+
private __previousCountry;
|
|
62
63
|
private __countries;
|
|
63
64
|
private __regions;
|
|
64
65
|
private __countriesService;
|
|
@@ -101,5 +102,6 @@ export declare class TaxForm extends Base<Data> {
|
|
|
101
102
|
private __renderTimestamps;
|
|
102
103
|
private __renderCreate;
|
|
103
104
|
private __renderDelete;
|
|
105
|
+
private __submitOnEnter;
|
|
104
106
|
}
|
|
105
107
|
export {};
|
|
@@ -63,6 +63,7 @@ export class TaxForm extends Base {
|
|
|
63
63
|
constructor() {
|
|
64
64
|
super(...arguments);
|
|
65
65
|
this.templates = {};
|
|
66
|
+
this.__previousCountry = undefined;
|
|
66
67
|
this.__countries = '';
|
|
67
68
|
this.__regions = '';
|
|
68
69
|
this.__countriesService = interpret(Nucleon.machine.withConfig({
|
|
@@ -96,6 +97,7 @@ export class TaxForm extends Base {
|
|
|
96
97
|
'vaadin-combo-box': customElements.get('vaadin-combo-box'),
|
|
97
98
|
'vaadin-button': customElements.get('vaadin-button'),
|
|
98
99
|
'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),
|
|
100
|
+
'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),
|
|
99
101
|
'foxy-spinner': customElements.get('foxy-spinner'),
|
|
100
102
|
'foxy-i18n': customElements.get('foxy-i18n'),
|
|
101
103
|
'x-property-table': PropertyTable,
|
|
@@ -179,6 +181,7 @@ export class TaxForm extends Base {
|
|
|
179
181
|
${this.__isDeleteHidden ? null : this.__renderDelete()}
|
|
180
182
|
|
|
181
183
|
<div
|
|
184
|
+
data-testid="spinner"
|
|
182
185
|
class=${classMap({
|
|
183
186
|
'transition duration-500 ease-in-out absolute inset-0 flex': true,
|
|
184
187
|
'opacity-0 pointer-events-none': !this.in('busy') && !this.in('fail'),
|
|
@@ -198,6 +201,10 @@ export class TaxForm extends Base {
|
|
|
198
201
|
}
|
|
199
202
|
updated(changes) {
|
|
200
203
|
super.updated(changes);
|
|
204
|
+
if (this.form.country !== this.__previousCountry) {
|
|
205
|
+
this.__previousCountry = this.form.country;
|
|
206
|
+
this.__regionsService.send({ type: 'FETCH' });
|
|
207
|
+
}
|
|
201
208
|
// vaadin's combo box doesn't seem to validate on its own
|
|
202
209
|
this.renderRoot.querySelectorAll('vaadin-combo-box').forEach(e => e.validate());
|
|
203
210
|
}
|
|
@@ -285,6 +292,7 @@ export class TaxForm extends Base {
|
|
|
285
292
|
${this.renderTemplateOrSlot('name:before')}
|
|
286
293
|
|
|
287
294
|
<vaadin-text-field
|
|
295
|
+
data-testid="name"
|
|
288
296
|
class="w-full"
|
|
289
297
|
label=${this.t('name')}
|
|
290
298
|
value=${ifDefined(this.form.name)}
|
|
@@ -293,6 +301,7 @@ export class TaxForm extends Base {
|
|
|
293
301
|
?disabled=${this.in('busy') || this.disabledSelector.matches('name', true)}
|
|
294
302
|
?readonly=${this.readonlySelector.matches('name', true)}
|
|
295
303
|
required
|
|
304
|
+
@keydown=${this.__submitOnEnter}
|
|
296
305
|
@input=${(evt) => {
|
|
297
306
|
const newName = evt.currentTarget.value;
|
|
298
307
|
this.edit({ name: newName });
|
|
@@ -312,6 +321,7 @@ export class TaxForm extends Base {
|
|
|
312
321
|
${this.renderTemplateOrSlot('type:before')}
|
|
313
322
|
|
|
314
323
|
<x-dropdown
|
|
324
|
+
data-testid="type"
|
|
315
325
|
label=${this.t('type')}
|
|
316
326
|
value=${ifDefined(this.form.type)}
|
|
317
327
|
class="w-full"
|
|
@@ -355,8 +365,9 @@ export class TaxForm extends Base {
|
|
|
355
365
|
item-value-path="cc2"
|
|
356
366
|
item-label-path="default"
|
|
357
367
|
item-id-path="cc2"
|
|
368
|
+
data-testid="country"
|
|
358
369
|
label="${this.t('country')}${isLoadingItems ? ` • ${this.t('loading_busy')}` : ''}"
|
|
359
|
-
value=${ifDefined(this.form.country)}
|
|
370
|
+
value=${ifDefined(isLoadingItems ? undefined : this.form.country)}
|
|
360
371
|
class="w-full"
|
|
361
372
|
.checkValidity=${this.__getValidator('country')}
|
|
362
373
|
.errorMessage=${this.__getErrorMessage('country')}
|
|
@@ -399,8 +410,9 @@ export class TaxForm extends Base {
|
|
|
399
410
|
item-value-path="code"
|
|
400
411
|
item-label-path="default"
|
|
401
412
|
item-id-path="code"
|
|
413
|
+
data-testid="region"
|
|
402
414
|
label="${this.t('region')}${isLoadingItems ? ` • ${this.t('loading_busy')}` : ''}"
|
|
403
|
-
value=${ifDefined(this.form.region)}
|
|
415
|
+
value=${ifDefined(isLoadingItems ? undefined : this.form.region)}
|
|
404
416
|
class="w-full"
|
|
405
417
|
.checkValidity=${this.__getValidator('region')}
|
|
406
418
|
.errorMessage=${this.__getErrorMessage('region')}
|
|
@@ -426,6 +438,7 @@ export class TaxForm extends Base {
|
|
|
426
438
|
${this.renderTemplateOrSlot('city:before')}
|
|
427
439
|
|
|
428
440
|
<vaadin-text-field
|
|
441
|
+
data-testid="city"
|
|
429
442
|
class="w-full"
|
|
430
443
|
label=${this.t('city')}
|
|
431
444
|
value=${ifDefined(this.form.city)}
|
|
@@ -434,6 +447,7 @@ export class TaxForm extends Base {
|
|
|
434
447
|
?disabled=${this.in('busy') || this.disabledSelector.matches('city', true)}
|
|
435
448
|
?readonly=${this.readonlySelector.matches('city', true)}
|
|
436
449
|
required
|
|
450
|
+
@keydown=${this.__submitOnEnter}
|
|
437
451
|
@input=${(evt) => {
|
|
438
452
|
const newCity = evt.currentTarget.value;
|
|
439
453
|
this.edit({ city: newCity });
|
|
@@ -462,6 +476,7 @@ export class TaxForm extends Base {
|
|
|
462
476
|
${this.renderTemplateOrSlot('provider:before')}
|
|
463
477
|
|
|
464
478
|
<x-dropdown
|
|
479
|
+
data-testid="provider"
|
|
465
480
|
label=${this.t('tax_rate_provider')}
|
|
466
481
|
value=${this.form.service_provider || (this.form.is_live ? 'default' : 'none')}
|
|
467
482
|
class="w-full"
|
|
@@ -497,6 +512,7 @@ export class TaxForm extends Base {
|
|
|
497
512
|
${this.renderTemplateOrSlot('rate:before')}
|
|
498
513
|
|
|
499
514
|
<vaadin-integer-field
|
|
515
|
+
data-testid="rate"
|
|
500
516
|
class="w-full"
|
|
501
517
|
label=${this.t('tax_rate')}
|
|
502
518
|
value=${ifDefined(this.form.rate)}
|
|
@@ -508,6 +524,7 @@ export class TaxForm extends Base {
|
|
|
508
524
|
?disabled=${this.in('busy') || this.disabledSelector.matches('rate', true)}
|
|
509
525
|
?readonly=${this.readonlySelector.matches('rate', true)}
|
|
510
526
|
required
|
|
527
|
+
@keydown=${this.__submitOnEnter}
|
|
511
528
|
@change=${(evt) => {
|
|
512
529
|
const newRate = parseInt(evt.currentTarget.value);
|
|
513
530
|
this.edit({ rate: newRate });
|
|
@@ -525,8 +542,9 @@ export class TaxForm extends Base {
|
|
|
525
542
|
${this.renderTemplateOrSlot('apply-to-shipping:before')}
|
|
526
543
|
|
|
527
544
|
<x-checkbox
|
|
545
|
+
data-testid="apply-to-shipping"
|
|
528
546
|
class="leading-s"
|
|
529
|
-
?disabled=${this.disabledSelector.matches('apply-to-shipping', true)}
|
|
547
|
+
?disabled=${this.in('busy') || this.disabledSelector.matches('apply-to-shipping', true)}
|
|
530
548
|
?readonly=${this.readonlySelector.matches('apply-to-shipping', true)}
|
|
531
549
|
?checked=${!!this.form.apply_to_shipping}
|
|
532
550
|
@change=${(evt) => this.edit({ apply_to_shipping: evt.detail })}
|
|
@@ -558,8 +576,9 @@ export class TaxForm extends Base {
|
|
|
558
576
|
${this.renderTemplateOrSlot('use-origin-rates:before')}
|
|
559
577
|
|
|
560
578
|
<x-checkbox
|
|
579
|
+
data-testid="use-origin-rates"
|
|
561
580
|
class="leading-s"
|
|
562
|
-
?disabled=${this.disabledSelector.matches('use-origin-rates', true)}
|
|
581
|
+
?disabled=${this.in('busy') || this.disabledSelector.matches('use-origin-rates', true)}
|
|
563
582
|
?readonly=${this.readonlySelector.matches('use-origin-rates', true)}
|
|
564
583
|
?checked=${!!this.form.use_origin_rates}
|
|
565
584
|
@change=${(evt) => this.edit({ use_origin_rates: evt.detail })}
|
|
@@ -586,14 +605,16 @@ export class TaxForm extends Base {
|
|
|
586
605
|
`;
|
|
587
606
|
}
|
|
588
607
|
__renderExemptAllCustomerTaxIds() {
|
|
608
|
+
const scope = 'exempt-all-customer-tax-ids';
|
|
589
609
|
return html `
|
|
590
610
|
<div>
|
|
591
|
-
${this.renderTemplateOrSlot(
|
|
611
|
+
${this.renderTemplateOrSlot(`${scope}:before`)}
|
|
592
612
|
|
|
593
613
|
<x-checkbox
|
|
614
|
+
data-testid="${scope}"
|
|
594
615
|
class="leading-s"
|
|
595
|
-
?disabled=${this.disabledSelector.matches(
|
|
596
|
-
?readonly=${this.readonlySelector.matches(
|
|
616
|
+
?disabled=${this.in('busy') || this.disabledSelector.matches(scope, true)}
|
|
617
|
+
?readonly=${this.readonlySelector.matches(scope, true)}
|
|
597
618
|
?checked=${!!this.form.exempt_all_customer_tax_ids}
|
|
598
619
|
@change=${(evt) => {
|
|
599
620
|
this.edit({ exempt_all_customer_tax_ids: evt.detail });
|
|
@@ -616,7 +637,7 @@ export class TaxForm extends Base {
|
|
|
616
637
|
</foxy-i18n>
|
|
617
638
|
</x-checkbox>
|
|
618
639
|
|
|
619
|
-
${this.renderTemplateOrSlot(
|
|
640
|
+
${this.renderTemplateOrSlot(`${scope}:after`)}
|
|
620
641
|
</div>
|
|
621
642
|
`;
|
|
622
643
|
}
|
|
@@ -626,6 +647,7 @@ export class TaxForm extends Base {
|
|
|
626
647
|
${this.renderTemplateOrSlot('timestamps:before')}
|
|
627
648
|
|
|
628
649
|
<x-property-table
|
|
650
|
+
data-testid="timestamps"
|
|
629
651
|
.items=${['date_modified', 'date_created'].map(field => ({
|
|
630
652
|
name: this.t(field),
|
|
631
653
|
value: this.data ? this.t('date', { value: new Date(this.data[field]) }) : '',
|
|
@@ -651,6 +673,7 @@ export class TaxForm extends Base {
|
|
|
651
673
|
${this.renderTemplateOrSlot('create:before')}
|
|
652
674
|
|
|
653
675
|
<vaadin-button
|
|
676
|
+
data-testid="create"
|
|
654
677
|
class="w-full"
|
|
655
678
|
theme="primary success"
|
|
656
679
|
?disabled=${isBusy || isInvalid || this.disabledSelector.matches('create', true)}
|
|
@@ -667,6 +690,7 @@ export class TaxForm extends Base {
|
|
|
667
690
|
return html `
|
|
668
691
|
<div>
|
|
669
692
|
<foxy-internal-confirm-dialog
|
|
693
|
+
data-testid="confirm"
|
|
670
694
|
message="delete_prompt"
|
|
671
695
|
confirm="delete"
|
|
672
696
|
cancel="cancel"
|
|
@@ -682,6 +706,7 @@ export class TaxForm extends Base {
|
|
|
682
706
|
${this.renderTemplateOrSlot('delete:before')}
|
|
683
707
|
|
|
684
708
|
<vaadin-button
|
|
709
|
+
data-testid="delete"
|
|
685
710
|
theme="primary error"
|
|
686
711
|
class="w-full"
|
|
687
712
|
?disabled=${this.in('busy') || this.disabledSelector.matches('delete', true)}
|
|
@@ -697,5 +722,9 @@ export class TaxForm extends Base {
|
|
|
697
722
|
</div>
|
|
698
723
|
`;
|
|
699
724
|
}
|
|
725
|
+
__submitOnEnter(evt) {
|
|
726
|
+
if (evt.key === 'Enter')
|
|
727
|
+
this.submit();
|
|
728
|
+
}
|
|
700
729
|
}
|
|
701
730
|
//# sourceMappingURL=TaxForm.js.map
|