@everymatrix/cashier-method-details 1.34.0 → 1.34.2
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@everymatrix/cashier-method-details",
|
3
|
-
"version": "1.34.
|
3
|
+
"version": "1.34.2",
|
4
4
|
"main": "index.js",
|
5
5
|
"svelte": "src/index.ts",
|
6
6
|
"scripts": {
|
@@ -35,5 +35,5 @@
|
|
35
35
|
"publishConfig": {
|
36
36
|
"access": "public"
|
37
37
|
},
|
38
|
-
"gitHead": "
|
38
|
+
"gitHead": "99004a0501ea8fb9219aac803a986e470f556838"
|
39
39
|
}
|
@@ -17,7 +17,7 @@
|
|
17
17
|
import FlatpickrLanguages from "flatpickr/dist/l10n";
|
18
18
|
import dayjs from 'dayjs';
|
19
19
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
20
|
-
import type {PaymentMethod} from "./CashierMethodDetails.types";
|
20
|
+
import type {DateTimeFormat, PaymentMethod} from "./CashierMethodDetails.types";
|
21
21
|
export class PaymentMethodDetails {
|
22
22
|
name: string;
|
23
23
|
label: string;
|
@@ -52,12 +52,12 @@
|
|
52
52
|
this.description = element.Description || null;
|
53
53
|
this.type = fieldTypeMap.get(element.Type) || null;
|
54
54
|
this.defaultValue = this.calcDefaultValue(element);
|
55
|
-
this.format = element.Format
|
56
|
-
this.placeholder = element.Placeholder
|
55
|
+
this.format = this.setPlaceHolderOrFormat(element, FieldParams.Format);
|
56
|
+
this.placeholder = this.setPlaceHolderOrFormat(element, FieldParams.Placeholder);
|
57
57
|
this.isReadonly = element.IsReadonly || false;
|
58
58
|
this.isRequired = element.IsRequired || false;
|
59
|
-
this.maxValue = element.MaxValue
|
60
|
-
this.minValue = element.MinValue
|
59
|
+
this.maxValue = this.setValue(element, FieldParams.MaxValue);
|
60
|
+
this.minValue = this.setValue(element, FieldParams.MinValue);
|
61
61
|
this.isPrimaryField = element.IsPrimaryField || false;
|
62
62
|
this.demandUserInput = element.DemandUserInput || false;
|
63
63
|
this.autoTrim = element.AutoTrim || false;
|
@@ -70,12 +70,28 @@
|
|
70
70
|
}
|
71
71
|
|
72
72
|
calcDefaultValue(element) {
|
73
|
-
if (this.type ===
|
73
|
+
if (this.type === FieldTypes.Boolean) {
|
74
74
|
return element.DefaultValue === 'True';
|
75
|
+
} else if (defaultDateTimeFormatMap.has(element.Type)){
|
76
|
+
return this.setValue(element, FieldParams.DefaultValue)
|
75
77
|
} else {
|
76
78
|
return element.DefaultValue || null;
|
77
79
|
}
|
78
80
|
}
|
81
|
+
setPlaceholderOrFormat(element, paramsType) {
|
82
|
+
if (defaultDateTimeFormatMap.has(element.Type) && !dateTimeFormatsMap.get(element.Placeholder)) {
|
83
|
+
return defaultDateTimeFormatMap.get(element.Type)[paramsType];
|
84
|
+
} else {
|
85
|
+
return element[paramsType] || null;
|
86
|
+
}
|
87
|
+
}
|
88
|
+
setValue(element, paramsType: string): string | null {
|
89
|
+
if (defaultDateTimeFormatMap.has(element.Type) && !dateTimeFormatsMap.get(element.Placeholder)) {
|
90
|
+
return dayjs(element[paramsType], element.Placeholder).format(defaultDateTimeFormatMap.get(element.Type).Placeholder)
|
91
|
+
} else {
|
92
|
+
return element[paramsType] || null;
|
93
|
+
}
|
94
|
+
}
|
79
95
|
get descriptionWithLink(): string {
|
80
96
|
if ((FieldTypes[this.type] === 'Boolean' && this.placeholder) || (FieldTypes[this.type] === 'Link')) {
|
81
97
|
const regex = /{link}/i;
|
@@ -132,6 +148,28 @@
|
|
132
148
|
QRCode = 'QR'
|
133
149
|
}
|
134
150
|
|
151
|
+
enum FieldParams {
|
152
|
+
MaxValue = 'MaxValue',
|
153
|
+
MinValue = 'MinValue',
|
154
|
+
DefaultValue = 'DefaultValue',
|
155
|
+
Placeholder = 'Placeholder',
|
156
|
+
Format = 'Format'
|
157
|
+
}
|
158
|
+
|
159
|
+
const defaultDateTimeFormatMap = new Map<FieldTypes, DateTimeFormat>([
|
160
|
+
[FieldTypes.Date, {Placeholder: 'MM/DD/YYYY', Format: '^\\d{2}\/\\d{2}\/\\d{4}$' }],
|
161
|
+
[FieldTypes.Time, { Placeholder: 'HH:mm', Format: '^\\d{2}:\\d{2}$' }],
|
162
|
+
[FieldTypes.DateTime, {Placeholder: 'MM/DD/YYYY HH:mm', Format: '^\\d{2}\/\\d{2}\/\\d{4} \\d{2}:\\d{2}$'}]
|
163
|
+
]);
|
164
|
+
const dateTimeFormatsMap = new Map<string, string>([
|
165
|
+
['MM/DD/YYYY HH:mm', 'm/d/Y H:i'],
|
166
|
+
['DD.MM.YYYY HH:mm', 'd.m.Y H:i'],
|
167
|
+
['YYYY-MM-DD', 'Y-m-d'],
|
168
|
+
['MM/DD/YYYY', 'm/d/Y'],
|
169
|
+
['DD/MM/YYYY', 'd/m/Y'],
|
170
|
+
['YYYY.MM.DD', 'Y.m.d'],
|
171
|
+
['HH:mm', 'H:i']
|
172
|
+
]);
|
135
173
|
const fieldTypeMap = new Map([
|
136
174
|
[['Unknown', 0], FieldTypes.Unknown],
|
137
175
|
[['Text', 1], FieldTypes.Text],
|
@@ -157,9 +195,6 @@
|
|
157
195
|
export let playersession: string;
|
158
196
|
export let lang: string = 'en';
|
159
197
|
export let local: string = 'en-US';
|
160
|
-
export let dateformat: string = "d/m/Y";
|
161
|
-
export let timeformat: string = "H:i";
|
162
|
-
export let dateandtimeformat: string = 'd/m/Y H:i';
|
163
198
|
export let translationurl: string;
|
164
199
|
export let customerid: string;
|
165
200
|
export let currency: string;
|
@@ -228,7 +263,7 @@
|
|
228
263
|
if (!el) {
|
229
264
|
return;
|
230
265
|
}
|
231
|
-
flatpickr(el
|
266
|
+
flatpickr(el).destroy();
|
232
267
|
})
|
233
268
|
}
|
234
269
|
showReceiptPage = false;
|
@@ -268,20 +303,15 @@
|
|
268
303
|
[FieldTypes.Time]: {
|
269
304
|
noCalendar: true,
|
270
305
|
enableTime: true,
|
271
|
-
dateFormat: timeformat,
|
272
|
-
time_24hr: timeformat === 'H:i',
|
273
306
|
allowInput: true
|
274
307
|
},
|
275
308
|
[FieldTypes.Date]: {
|
276
|
-
dateFormat: dateformat,
|
277
309
|
allowInput: true,
|
278
310
|
locale: {...FlatpickrLanguages[lang]}
|
279
311
|
},
|
280
312
|
[FieldTypes.DateTime]: {
|
281
|
-
dateFormat: dateandtimeformat,
|
282
313
|
allowInput: true,
|
283
314
|
enableTime: true,
|
284
|
-
time_24hr: timeformat === 'H:i',
|
285
315
|
locale: {...FlatpickrLanguages[lang]}
|
286
316
|
}
|
287
317
|
}
|
@@ -290,9 +320,12 @@
|
|
290
320
|
return;
|
291
321
|
}
|
292
322
|
const field = JSON.parse(el.dataset.field);
|
293
|
-
|
323
|
+
const dateFormat = dateTimeFormatsMap.get(field.placeholder);
|
324
|
+
const timeformat = field.type === FieldTypes.DateTime ? dateTimeFormatsMap.get(field.placeholder.split(' ')[1]) : dateFormat;
|
325
|
+
flatpickr(el, {...dateOptions[field.type], dateFormat: dateFormat, time_24hr: timeformat === 'H:i', maxDate: field.maxValue, minDate: field.minValue, defaultDate: field.defaultValue,
|
294
326
|
onReady: (selectedDates, dateStr) => {
|
295
|
-
|
327
|
+
prepareFields[field.name] = dateStr;
|
328
|
+
dateTimeValidation(field);
|
296
329
|
},
|
297
330
|
onClose: (selectedDates, dateStr, instance) => {
|
298
331
|
if(!fieldValidation[field.name]) {
|
@@ -397,7 +430,7 @@
|
|
397
430
|
const messageHandler = (e:any) => {
|
398
431
|
if (e.data.type == 'ErrorResponseCode') {
|
399
432
|
errorResponseCode = e.data.errorResponseCode;
|
400
|
-
showReceiptPage = e.data.
|
433
|
+
showReceiptPage = e.data.showErrorOutsideReceiptPage;
|
401
434
|
}
|
402
435
|
if (e.data.type == 'ReceiptLoaded') {
|
403
436
|
closeIframe()
|
@@ -930,6 +963,9 @@
|
|
930
963
|
{endpoint}
|
931
964
|
{customerid}
|
932
965
|
{assetsurl}
|
966
|
+
showerrors="false"
|
967
|
+
showclosebutton="true"
|
968
|
+
showcontactbutton="true"
|
933
969
|
transactionid="{transactionId}"
|
934
970
|
session="{playersession}"
|
935
971
|
>
|