inviton-powerduck 0.0.154 → 0.0.156
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/app/powerduck-initializer.ts +3 -3
- package/common/api-http.ts +20 -14
- package/common/css/ladda-themeless-zoomin.min.css +89 -89
- package/common/enum-translation/day-translator.ts +3 -2
- package/common/excel/excel-reader.ts +2 -9
- package/common/extensions/array-extensions.ts +116 -0
- package/common/extensions/string-extensions.ts +92 -0
- package/common/extensions/temporal-extensions.ts +115 -0
- package/common/scroll-utils.ts +2 -1
- package/common/temporal-helpers.ts +551 -0
- package/common/timezone-helper.ts +39 -29
- package/common/utils/cookie.ts +11 -8
- package/common/utils/date-localization-utils.ts +25 -19
- package/common/utils/date-utils.ts +37 -47
- package/common/utils/form-utils.ts +3 -1
- package/common/utils/language-utils.ts +21 -27
- package/common/utils/temporal-utils.ts +43 -0
- package/common/utils/upload-image-helper.ts +1 -1
- package/common/utils/utils.ts +14 -14
- package/common/validation.ts +17 -5
- package/components/chart-js/line-chart-flot.tsx +9 -9
- package/components/chart-js/thirdparty/flot/jquery.flot.categories.min.js +93 -93
- package/components/chart-js/thirdparty/flot/jquery.flot.crosshair.min.js +83 -83
- package/components/chart-js/thirdparty/flot/jquery.flot.navigate.min.js +270 -270
- package/components/chart-js/thirdparty/flot/jquery.flot.pie.min.js +507 -507
- package/components/chart-js/thirdparty/flot/jquery.flot.resize.js +7 -9
- package/components/chart-js/thirdparty/flot/jquery.flot.resize.min.js +9 -11
- package/components/chart-js/thirdparty/flot/jquery.flot.stack.min.js +104 -104
- package/components/chart-js/ts/line-chart-contracts.ts +2 -2
- package/components/container-with-breakpoints/ts/breakpoint-handler.ts +2 -2
- package/components/counter/testall.tsx +89 -75
- package/components/datatable/datatable.tsx +2379 -2375
- package/components/datatable/export-excel-modal.tsx +12 -14
- package/components/datatable/ts/reorder.ts +4 -2
- package/components/dropdown/index.tsx +48 -22
- package/components/dropdown/mobile/legacy_fdd.ts +10 -11
- package/components/dropzone/gallery-dropzone.tsx +394 -382
- package/components/fullcalendar/fullcalendar-draggable-event.tsx +8 -7
- package/components/fullcalendar/timegrid-calendar.tsx +60 -67
- package/components/image-crop/image-cropping-modal.tsx +9 -8
- package/components/image-crop/upload-and-crop.tsx +162 -162
- package/components/image-crop/vendor/jquery.Jcrop.min.css +344 -344
- package/components/import/import-mapper.tsx +2 -2
- package/components/input/daterange-picker.tsx +40 -59
- package/components/input/datetime-picker.tsx +45 -50
- package/components/input/plugins/daterangepicker/daterangepicker.min.css +400 -400
- package/components/input/plugins/daterangepicker/jquery.daterangepicker.min.js +346 -339
- package/components/input/plugins/daterangepicker/jquery.daterangepicker.ts +580 -402
- package/components/input/radio-button-group.tsx +2 -2
- package/components/input/ts/dateInputHelper.ts +1 -0
- package/components/input/wysiwig.tsx +12 -7
- package/components/svg/skilift-svg.tsx +6 -6
- package/package.json +2 -1
- package/common/date-wrapper.ts +0 -422
- package/common/utils/array-extend.ts +0 -215
- package/common/utils/array-remove.ts +0 -10
- package/common/utils/array-sort.ts +0 -56
- package/common/utils/capitalize-string.ts +0 -11
- package/common/utils/format-string.ts +0 -14
- package/common/utils/latinize-string.ts +0 -7
package/common/utils/cookie.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
1
2
|
import { DomainHelper } from './domain-helper';
|
|
2
3
|
|
|
3
4
|
// Cookie manipulation abstraction
|
|
@@ -12,7 +13,7 @@ export class CookieProvider {
|
|
|
12
13
|
static set(
|
|
13
14
|
name: string,
|
|
14
15
|
value: string,
|
|
15
|
-
expiration?:
|
|
16
|
+
expiration?: Temporal.PlainDateTime,
|
|
16
17
|
) {
|
|
17
18
|
let domain = DomainHelper.getCookieDomain();
|
|
18
19
|
if (domain.length > 0) {
|
|
@@ -21,12 +22,12 @@ export class CookieProvider {
|
|
|
21
22
|
|
|
22
23
|
let realExpiration;
|
|
23
24
|
if (expiration != null) {
|
|
24
|
-
realExpiration = expiration.
|
|
25
|
+
realExpiration = expiration.toZonedDateTime('UTC').epochMilliseconds;
|
|
25
26
|
} else {
|
|
26
27
|
realExpiration = '';
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
document.cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)};expires=${
|
|
30
|
+
document.cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)};expires=${realExpiration}${domain};path=/`;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
/**
|
|
@@ -39,8 +40,12 @@ export class CookieProvider {
|
|
|
39
40
|
const ca = document.cookie.split(';');
|
|
40
41
|
for (let i = 0; i < ca.length; i++) {
|
|
41
42
|
let c = ca[i];
|
|
42
|
-
while (c.charAt(0) == ' ') {
|
|
43
|
-
|
|
43
|
+
while (c.charAt(0) == ' ') {
|
|
44
|
+
c = c.substring(1);
|
|
45
|
+
}
|
|
46
|
+
if (c.includes(name)) {
|
|
47
|
+
return c.substring(name.length, c.length);
|
|
48
|
+
}
|
|
44
49
|
}
|
|
45
50
|
return null;
|
|
46
51
|
}
|
|
@@ -51,12 +56,10 @@ export class CookieProvider {
|
|
|
51
56
|
* @param name Name of the cookie
|
|
52
57
|
*/
|
|
53
58
|
static remove(name: string) {
|
|
54
|
-
const someDate = new Date(); // add arguments as needed
|
|
55
|
-
someDate.setTime(someDate.getTime() - 3 * 28 * 24 * 60 * 60);
|
|
56
59
|
CookieProvider.set(
|
|
57
60
|
name,
|
|
58
61
|
'',
|
|
59
|
-
|
|
62
|
+
Temporal.PlainDateTime.from('1990-01-01'),
|
|
60
63
|
);
|
|
61
64
|
}
|
|
62
65
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { DateWrapper } from '../date-wrapper';
|
|
2
1
|
// Due to some limitations of Date Internationalization API, this hacks are applied
|
|
2
|
+
import type { Temporal } from '@js-temporal/polyfill';
|
|
3
3
|
import PowerduckState from '../../app/powerduck-state';
|
|
4
|
-
import { capitalize } from '
|
|
4
|
+
import { capitalize } from '../extensions/string-extensions';
|
|
5
5
|
|
|
6
6
|
export default class DateLocalizationUtils {
|
|
7
7
|
private static readonly DATE_FORMAT_FOR_RANGE_PICKER = (function () {
|
|
8
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
8
9
|
const dummyDate = new Date(Date.UTC(
|
|
9
10
|
2022,
|
|
10
11
|
11,
|
|
@@ -21,6 +22,7 @@ export default class DateLocalizationUtils {
|
|
|
21
22
|
})();
|
|
22
23
|
|
|
23
24
|
private static readonly MONTH_IS_FIRST: boolean = (function () {
|
|
25
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
24
26
|
const dummyDate = new Date(Date.UTC(
|
|
25
27
|
2024,
|
|
26
28
|
9,
|
|
@@ -42,6 +44,7 @@ export default class DateLocalizationUtils {
|
|
|
42
44
|
})();
|
|
43
45
|
|
|
44
46
|
private static readonly PATTERN_WITHOUT_YEAR: string = (function () {
|
|
47
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
45
48
|
const dummyDate = new Date(Date.UTC(
|
|
46
49
|
2024,
|
|
47
50
|
9,
|
|
@@ -67,6 +70,7 @@ export default class DateLocalizationUtils {
|
|
|
67
70
|
})();
|
|
68
71
|
|
|
69
72
|
private static readonly PATTERN_WITH_YEAR: string = (function () {
|
|
73
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
70
74
|
const dummyDate = new Date(Date.UTC(
|
|
71
75
|
2024,
|
|
72
76
|
9,
|
|
@@ -93,6 +97,7 @@ export default class DateLocalizationUtils {
|
|
|
93
97
|
})();
|
|
94
98
|
|
|
95
99
|
private static readonly PATTERN_PLACEHOLDERED: string = (function () {
|
|
100
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
96
101
|
const dummyDate = new Date(Date.UTC(
|
|
97
102
|
2024,
|
|
98
103
|
9,
|
|
@@ -116,12 +121,13 @@ export default class DateLocalizationUtils {
|
|
|
116
121
|
}
|
|
117
122
|
})();
|
|
118
123
|
|
|
119
|
-
static formatRange = (from:
|
|
120
|
-
if (from.
|
|
124
|
+
static formatRange = (from: Temporal.PlainDateTime, to: Temporal.PlainDateTime): string => {
|
|
125
|
+
if (from.month == to.month) {
|
|
126
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
121
127
|
const convertDate = new Date(Date.UTC(
|
|
122
|
-
from.
|
|
123
|
-
from.
|
|
124
|
-
from.
|
|
128
|
+
from.year,
|
|
129
|
+
from.month - 1,
|
|
130
|
+
from.day,
|
|
125
131
|
));
|
|
126
132
|
convertDate.setDate(28);
|
|
127
133
|
|
|
@@ -132,10 +138,10 @@ export default class DateLocalizationUtils {
|
|
|
132
138
|
}).split('28').join('').split('.').join('').trim();
|
|
133
139
|
|
|
134
140
|
return this.PATTERN_WITH_YEAR
|
|
135
|
-
.replace('{{day}}', `${from.
|
|
141
|
+
.replace('{{day}}', `${from.day} - ${to.day}`)
|
|
136
142
|
.replace('{{month}}', monthName)
|
|
137
|
-
.replace('{{year}}', from.
|
|
138
|
-
} else if (from.
|
|
143
|
+
.replace('{{year}}', from.year.toString());
|
|
144
|
+
} else if (from.year == to.year) {
|
|
139
145
|
const fromDate = this.getFormatted(
|
|
140
146
|
from,
|
|
141
147
|
this.PATTERN_WITHOUT_YEAR,
|
|
@@ -149,7 +155,7 @@ export default class DateLocalizationUtils {
|
|
|
149
155
|
'short',
|
|
150
156
|
);
|
|
151
157
|
const rangeVal = `${fromDate} - ${toDate}`;
|
|
152
|
-
return this.PATTERN_PLACEHOLDERED.replace('{{date}}', rangeVal).replace('{{year}}', to.
|
|
158
|
+
return this.PATTERN_PLACEHOLDERED.replace('{{date}}', rangeVal).replace('{{year}}', to.year.toString());
|
|
153
159
|
} else {
|
|
154
160
|
const fromVal = this.getFormatted(
|
|
155
161
|
from,
|
|
@@ -170,7 +176,7 @@ export default class DateLocalizationUtils {
|
|
|
170
176
|
};
|
|
171
177
|
|
|
172
178
|
static getFormatedDateWithoutTime = (
|
|
173
|
-
dte:
|
|
179
|
+
dte: Temporal.PlainDateTime,
|
|
174
180
|
showYear: boolean,
|
|
175
181
|
day: 'numeric' | '2-digit' | undefined,
|
|
176
182
|
month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow' | undefined,
|
|
@@ -195,7 +201,7 @@ export default class DateLocalizationUtils {
|
|
|
195
201
|
};
|
|
196
202
|
|
|
197
203
|
private static getFormatted = (
|
|
198
|
-
dte:
|
|
204
|
+
dte: Temporal.PlainDateTime,
|
|
199
205
|
pattern: string,
|
|
200
206
|
day: 'numeric' | '2-digit' | undefined,
|
|
201
207
|
month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow' | undefined,
|
|
@@ -203,28 +209,28 @@ export default class DateLocalizationUtils {
|
|
|
203
209
|
): string => {
|
|
204
210
|
let monthVal: string;
|
|
205
211
|
try {
|
|
206
|
-
monthVal =
|
|
212
|
+
monthVal = dte.toLocaleString(PowerduckState.getCurrentLanguage(), {
|
|
207
213
|
month,
|
|
208
214
|
timeZone: 'UTC',
|
|
209
|
-
}));
|
|
215
|
+
})[capitalize]();
|
|
210
216
|
} catch (error) {
|
|
211
|
-
monthVal =
|
|
217
|
+
monthVal = dte.month.toString();
|
|
212
218
|
}
|
|
213
219
|
|
|
214
220
|
let dayVal: string;
|
|
215
221
|
if (day == '2-digit') {
|
|
216
|
-
dayVal = dte.
|
|
222
|
+
dayVal = dte.day.toString();
|
|
217
223
|
if (dayVal.length == 1) {
|
|
218
224
|
dayVal = `0${dayVal}`;
|
|
219
225
|
}
|
|
220
226
|
} else {
|
|
221
|
-
dayVal = dte.
|
|
227
|
+
dayVal = dte.day.toString();
|
|
222
228
|
}
|
|
223
229
|
|
|
224
230
|
if (year == null) {
|
|
225
231
|
return pattern.replace('{{day}}', dayVal).replace('{{month}}', monthVal);
|
|
226
232
|
} else {
|
|
227
|
-
return pattern.replace('{{day}}', dayVal).replace('{{month}}', monthVal).replace('{{year}}', dte.
|
|
233
|
+
return pattern.replace('{{day}}', dayVal).replace('{{month}}', monthVal).replace('{{year}}', dte.year.toString());
|
|
228
234
|
}
|
|
229
235
|
};
|
|
230
236
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
1
2
|
import PowerduckState from '../../app/powerduck-state';
|
|
2
|
-
import { DateWrapper } from '../date-wrapper';
|
|
3
3
|
|
|
4
4
|
const _isInteger = (val: any) => {
|
|
5
5
|
const digits = '1234567890';
|
|
@@ -31,29 +31,9 @@ const _getInt = (
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
export default class DateUtils {
|
|
34
|
-
static
|
|
35
|
-
const target = new Date(date.getTime());
|
|
36
|
-
// Nastaviť na najbližší štvrtok (ISO týždne začínajú v pondelok)
|
|
37
|
-
target.setHours(
|
|
38
|
-
0,
|
|
39
|
-
0,
|
|
40
|
-
0,
|
|
41
|
-
0,
|
|
42
|
-
);
|
|
43
|
-
target.setDate(target.getDate() + 3 - ((target.getDay() + 6) % 7));
|
|
44
|
-
const firstThursday = new Date(
|
|
45
|
-
target.getFullYear(),
|
|
46
|
-
0,
|
|
47
|
-
4,
|
|
48
|
-
);
|
|
49
|
-
firstThursday.setDate(firstThursday.getDate() + 3 - ((firstThursday.getDay() + 6) % 7));
|
|
50
|
-
const weekNumber = 1 + Math.round(((target.getTime() - firstThursday.getTime()) / 86400000 - 3) / 7);
|
|
51
|
-
return weekNumber;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static formatDate (date: Date | DateWrapper | number, format: string): string {
|
|
34
|
+
static formatDate(date: Temporal.PlainDateTime | number, format: string): string {
|
|
55
35
|
if (typeof date === 'number') {
|
|
56
|
-
date =
|
|
36
|
+
date = Temporal.Instant.fromEpochMilliseconds(date as number).toZonedDateTimeISO('UTC').toPlainDateTime();
|
|
57
37
|
}
|
|
58
38
|
|
|
59
39
|
format = `${format}`;
|
|
@@ -61,13 +41,12 @@ export default class DateUtils {
|
|
|
61
41
|
let i_format = 0;
|
|
62
42
|
let c = '';
|
|
63
43
|
let token = '';
|
|
64
|
-
let y = `${date.
|
|
65
|
-
const M = date.
|
|
66
|
-
const d = date.
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const s = date.getSeconds();
|
|
44
|
+
let y = `${date.year}`;
|
|
45
|
+
const M = date.month;
|
|
46
|
+
const d = date.day;
|
|
47
|
+
const H = date.hour;
|
|
48
|
+
const m = date.minute;
|
|
49
|
+
const s = date.second;
|
|
71
50
|
const LZ = x => (x < 0 || x > 9 ? '' : '0') + x;
|
|
72
51
|
|
|
73
52
|
const locale = PowerduckState.getCurrentLanguage();
|
|
@@ -83,12 +62,12 @@ export default class DateUtils {
|
|
|
83
62
|
value.yy = y.substring(2, 4);
|
|
84
63
|
value.M = M;
|
|
85
64
|
value.MM = LZ(M);
|
|
86
|
-
value.MMM = date.
|
|
87
|
-
value.MMMM = date.
|
|
65
|
+
value.MMM = date.toLocaleString(locale, { month: 'short', timeZone: 'UTC' });
|
|
66
|
+
value.MMMM = date.toLocaleString(locale, { month: 'long', timeZone: 'UTC' });
|
|
88
67
|
value.d = d;
|
|
89
68
|
value.dd = LZ(d);
|
|
90
|
-
value.E = date.
|
|
91
|
-
value.EEEE = date.
|
|
69
|
+
value.E = date.toLocaleString(locale, { weekday: 'short', timeZone: 'UTC' });
|
|
70
|
+
value.EEEE = date.toLocaleString(locale, { weekday: 'long', timeZone: 'UTC' });
|
|
92
71
|
value.H = H;
|
|
93
72
|
value.HH = LZ(H);
|
|
94
73
|
if (H == 0) {
|
|
@@ -134,7 +113,7 @@ export default class DateUtils {
|
|
|
134
113
|
return result;
|
|
135
114
|
};
|
|
136
115
|
|
|
137
|
-
static
|
|
116
|
+
static getTemporalFromFormat(val: string, format: string): Temporal.PlainDateTime {
|
|
138
117
|
// In case somehow the date is already a datewrapper
|
|
139
118
|
if ((val as any)._dte != null) {
|
|
140
119
|
return (val as any);
|
|
@@ -147,6 +126,7 @@ export default class DateUtils {
|
|
|
147
126
|
let c = '';
|
|
148
127
|
let token = '';
|
|
149
128
|
let x, y;
|
|
129
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
150
130
|
const now = new Date();
|
|
151
131
|
let year: any = now.getFullYear();
|
|
152
132
|
let month: any = now.getMonth() + 1;
|
|
@@ -159,13 +139,18 @@ export default class DateUtils {
|
|
|
159
139
|
const _isValidChar = (char: string): boolean => /[a-záčďéíĺľńóôŕšťúýž]/i.test(char);
|
|
160
140
|
const locale = PowerduckState.getCurrentLanguage();
|
|
161
141
|
const getMonthFromName = (monthName: string, isShort: boolean = false): number => {
|
|
162
|
-
|
|
142
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
143
|
+
const date = new Date(
|
|
144
|
+
2022,
|
|
145
|
+
0,
|
|
146
|
+
1,
|
|
147
|
+
);
|
|
163
148
|
|
|
164
149
|
for (let monthIndex = 0; monthIndex < 12; monthIndex++) {
|
|
165
150
|
date.setMonth(monthIndex);
|
|
166
151
|
const name = date.toLocaleDateString(locale, {
|
|
167
152
|
month: isShort ? 'short' : 'long',
|
|
168
|
-
timeZone: 'UTC'
|
|
153
|
+
timeZone: 'UTC',
|
|
169
154
|
}).toLowerCase();
|
|
170
155
|
|
|
171
156
|
if (name == monthName.toLowerCase()) {
|
|
@@ -177,13 +162,18 @@ export default class DateUtils {
|
|
|
177
162
|
};
|
|
178
163
|
|
|
179
164
|
const getDayFromName = (dayName: string, isShort: boolean = false): number => {
|
|
180
|
-
|
|
165
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
166
|
+
const date = new Date(
|
|
167
|
+
2022,
|
|
168
|
+
0,
|
|
169
|
+
2,
|
|
170
|
+
);
|
|
181
171
|
|
|
182
172
|
for (let dayIndex = 0; dayIndex < 7; dayIndex++) {
|
|
183
173
|
date.setDate(2 + dayIndex);
|
|
184
174
|
const name = date.toLocaleDateString(locale, {
|
|
185
175
|
weekday: isShort ? 'short' : 'long',
|
|
186
|
-
timeZone: 'UTC'
|
|
176
|
+
timeZone: 'UTC',
|
|
187
177
|
}).toLowerCase();
|
|
188
178
|
|
|
189
179
|
if (name == dayName.toLowerCase()) {
|
|
@@ -463,13 +453,13 @@ export default class DateUtils {
|
|
|
463
453
|
hh -= 12;
|
|
464
454
|
}
|
|
465
455
|
|
|
466
|
-
return
|
|
467
|
-
Number(year),
|
|
468
|
-
Number(month)
|
|
469
|
-
Number(date),
|
|
470
|
-
Number(hh),
|
|
471
|
-
Number(mm),
|
|
472
|
-
Number(ss),
|
|
473
|
-
);
|
|
456
|
+
return Temporal.PlainDateTime.from({
|
|
457
|
+
year: Number(year),
|
|
458
|
+
month: Number(month),
|
|
459
|
+
day: Number(date),
|
|
460
|
+
hour: Number(hh),
|
|
461
|
+
minute: Number(mm),
|
|
462
|
+
second: Number(ss),
|
|
463
|
+
});
|
|
474
464
|
}
|
|
475
465
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import TemporalUtils from './temporal-utils';
|
|
2
|
+
|
|
1
3
|
export interface FormUtilsField {
|
|
2
4
|
name: string;
|
|
3
5
|
value: string;
|
|
@@ -27,7 +29,7 @@ export default class FormUtils {
|
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
const formMethod = 'POST';
|
|
30
|
-
const formName = `frm${
|
|
32
|
+
const formName = `frm${TemporalUtils.dateNowMs()}`;
|
|
31
33
|
let newForm = `<form id="${formName}" method="${formMethod}" action="${url}" ${newWindow == true ? 'target="_blank"' : ''}>`;
|
|
32
34
|
|
|
33
35
|
arr.forEach((field) => {
|
|
@@ -2,10 +2,12 @@ import type { Currency } from '../enums/currency';
|
|
|
2
2
|
import PowerduckState from '../../app/powerduck-state';
|
|
3
3
|
import LanguageTranslator from '../enum-translation/language-translator';
|
|
4
4
|
import { Language } from '../enums/language';
|
|
5
|
-
import {
|
|
5
|
+
import { sortBy } from '../extensions/array-extensions';
|
|
6
6
|
|
|
7
|
+
// eslint-disable-next-line ts/no-namespace
|
|
7
8
|
export namespace LanguageUtils {
|
|
8
|
-
|
|
9
|
+
// eslint-disable-next-line import/no-mutable-exports, prefer-const
|
|
10
|
+
export let supportedLanguages = [
|
|
9
11
|
Language.sk,
|
|
10
12
|
Language.en,
|
|
11
13
|
];
|
|
@@ -17,15 +19,15 @@ export namespace LanguageUtils {
|
|
|
17
19
|
id: Language;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
const getAdjectiveName = (name: string): string => {
|
|
21
23
|
if (name.endsWith('ý')) {
|
|
22
24
|
name = `${name.substring(0, name.length - 1)}y`;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
return name;
|
|
26
|
-
}
|
|
28
|
+
};
|
|
27
29
|
|
|
28
|
-
export
|
|
30
|
+
export const getLanguageList = (sort?: boolean): Array<LanguageListItem> => {
|
|
29
31
|
const retVal = <Array<LanguageListItem>>[];
|
|
30
32
|
|
|
31
33
|
const getLanguage = (langCode: Language): LanguageListItem => {
|
|
@@ -81,43 +83,37 @@ export namespace LanguageUtils {
|
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
if (sort === true) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
arraySort(retVal, 'text');
|
|
86
|
+
try {
|
|
87
|
+
retVal.sort((a, b) => a.text.localeCompare(b.text));
|
|
88
|
+
} catch (e) {
|
|
89
|
+
retVal[sortBy](p => p.text);
|
|
90
|
+
}
|
|
90
91
|
}
|
|
91
|
-
}
|
|
92
92
|
|
|
93
|
-
LanguageUtils.getLanguageList =
|
|
94
|
-
return retVal;
|
|
95
|
-
};
|
|
93
|
+
(LanguageUtils as any).getLanguageList = () => retVal;
|
|
96
94
|
return retVal;
|
|
97
|
-
}
|
|
95
|
+
};
|
|
98
96
|
|
|
99
97
|
/**
|
|
100
98
|
* Returns enum value from string language code
|
|
101
99
|
*
|
|
102
100
|
* @param langCode 2-letter language code [sk, en, cs...]
|
|
103
101
|
*/
|
|
104
|
-
export
|
|
105
|
-
return (langCode as any) ?? Language.en;
|
|
106
|
-
}
|
|
102
|
+
export const getLanguageEnum = (langCode: string): Language => (langCode as any) ?? Language.en;
|
|
107
103
|
|
|
108
|
-
export
|
|
104
|
+
export const getLanguageFlagUrl = (languageFlag: string, svg?: boolean): string => {
|
|
109
105
|
if (!svg) {
|
|
110
106
|
return `${PowerduckState.getAssetRootDirectory()}/img/flags/${languageFlag}.png`;
|
|
111
107
|
} else {
|
|
112
108
|
return `${PowerduckState.getAssetRootDirectory()}/img/flags/svg/${languageFlag}.svg`;
|
|
113
109
|
}
|
|
114
|
-
}
|
|
110
|
+
};
|
|
115
111
|
|
|
116
|
-
export
|
|
112
|
+
export const floatToCurrency = (
|
|
117
113
|
value: number,
|
|
118
114
|
currency: string | Currency | number | any,
|
|
119
115
|
killZeroCents?: boolean,
|
|
120
|
-
): string {
|
|
116
|
+
): string => {
|
|
121
117
|
let currencyISO: string;
|
|
122
118
|
if (currency == null || currency == '') {
|
|
123
119
|
currencyISO = '?';
|
|
@@ -144,9 +140,7 @@ export namespace LanguageUtils {
|
|
|
144
140
|
return `${(Math.round(value * 100) / 100).toString()} ${currencyISO}`;
|
|
145
141
|
}
|
|
146
142
|
}
|
|
147
|
-
}
|
|
143
|
+
};
|
|
148
144
|
|
|
149
|
-
export
|
|
150
|
-
return PowerduckState.getResourceValue('negationBase') + str.toLowerCase();
|
|
151
|
-
}
|
|
145
|
+
export const negateString = (str: string): string => PowerduckState.getResourceValue('negationBase') + str.toLowerCase();
|
|
152
146
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
import { isNullOrEmpty } from './is-null-or-empty';
|
|
3
|
+
|
|
4
|
+
export default class TemporalUtils {
|
|
5
|
+
/*
|
|
6
|
+
* Returns the number of milliseconds for this date since the epoch, which is defined as the midnight at the beginning of January 1, 1970, UTC.
|
|
7
|
+
*/
|
|
8
|
+
static dateNowMs(): number {
|
|
9
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
10
|
+
return new Date().getTime();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static isSerializedDate(str: string): boolean {
|
|
14
|
+
return str != null && str.length > 18 && str.length < 29 && str.indexOf('T') == 10;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static fromDate(d: Date): Temporal.PlainDateTime {
|
|
18
|
+
if (d == null) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return Temporal.PlainDateTime.from({
|
|
23
|
+
year: d.getFullYear(),
|
|
24
|
+
month: d.getMonth() + 1, // JS Date months are 0-based
|
|
25
|
+
day: d.getDate(),
|
|
26
|
+
hour: d.getHours(),
|
|
27
|
+
minute: d.getMinutes(),
|
|
28
|
+
second: d.getSeconds(),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static fromString(val: string): Temporal.PlainDateTime {
|
|
33
|
+
if (isNullOrEmpty(val)) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return Temporal.PlainDateTime.from(val.split('Z')[0]);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static fromEpochMs(val: number): Temporal.PlainDateTime {
|
|
41
|
+
return Temporal.Instant.fromEpochMilliseconds(val).toZonedDateTimeISO('UTC').toPlainDateTime();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -27,7 +27,7 @@ compressionMaxMb: number = 0.5,
|
|
|
27
27
|
method: 'POST',
|
|
28
28
|
body: formData,
|
|
29
29
|
headers: {
|
|
30
|
-
|
|
30
|
+
[AppHttpProvider.authorizationHeaderName]: `Bearer ${AppHttpProvider.bearerToken}`,
|
|
31
31
|
'Accept-Language': PowerduckState.getCurrentLanguage(),
|
|
32
32
|
},
|
|
33
33
|
});
|
package/common/utils/utils.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import PowerduckState from '../../app/powerduck-state';
|
|
2
|
-
import { latinize } from '
|
|
2
|
+
import { latinize } from '../extensions/string-extensions';
|
|
3
|
+
import TemporalUtils from './temporal-utils';
|
|
3
4
|
|
|
4
5
|
export class PortalUtils {
|
|
5
6
|
private static _isTouchDeviceVal: boolean;
|
|
6
|
-
private static _isChromeBrowser: boolean
|
|
7
|
-
private static _treatAsMobileDeviceVal: boolean
|
|
7
|
+
private static _isChromeBrowser: boolean;
|
|
8
|
+
private static _treatAsMobileDeviceVal: boolean;
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Gets if current site is run inside an iframe
|
|
@@ -21,9 +22,7 @@ export class PortalUtils {
|
|
|
21
22
|
* Determines if current device runs iOS
|
|
22
23
|
*/
|
|
23
24
|
static isIOS(): boolean {
|
|
24
|
-
return (
|
|
25
|
-
(/iPad|iPhone|iPod/.test(navigator.userAgent) && !(window as any).MSStream) || navigator.userAgent.match(/(iPad)/) != null || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)
|
|
26
|
-
);
|
|
25
|
+
return ((/iPad|iPhone|iPod/.test(navigator.userAgent) && !(window as any).MSStream) || navigator.userAgent.match(/(iPad)/) != null || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1));
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
/**
|
|
@@ -78,7 +77,7 @@ export class PortalUtils {
|
|
|
78
77
|
* Performs normalization / unification for search
|
|
79
78
|
*/
|
|
80
79
|
static normalizeStringForSearch(str: string): string {
|
|
81
|
-
return
|
|
80
|
+
return str.toLowerCase()[latinize]().trim();
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
/**
|
|
@@ -145,8 +144,8 @@ export class PortalUtils {
|
|
|
145
144
|
}
|
|
146
145
|
|
|
147
146
|
/*
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
* Obtains URL for asset either on CDN, or on local
|
|
148
|
+
*/
|
|
150
149
|
static getAssetPath(path: string): string {
|
|
151
150
|
return PowerduckState.getCdnPath() + path;
|
|
152
151
|
}
|
|
@@ -283,7 +282,7 @@ export class PortalUtils {
|
|
|
283
282
|
* Recursively climbs UP the tree to determine first PARENT node of the scroll element to obtain the scroll target
|
|
284
283
|
* @param currentElem
|
|
285
284
|
*/
|
|
286
|
-
|
|
285
|
+
const getScrollTaget = (currentElem: HTMLElement): HTMLElement => {
|
|
287
286
|
if (
|
|
288
287
|
currentElem.scrollTop != 0
|
|
289
288
|
|| currentElem.nodeName == 'DIALOG'
|
|
@@ -297,7 +296,7 @@ export class PortalUtils {
|
|
|
297
296
|
} else {
|
|
298
297
|
return getScrollTaget(currentElem.parentElement);
|
|
299
298
|
}
|
|
300
|
-
}
|
|
299
|
+
};
|
|
301
300
|
|
|
302
301
|
const scrollElem = getScrollTaget(<HTMLElement>element);
|
|
303
302
|
const target = (<HTMLElement>element).getBoundingClientRect().top + scrollElem.scrollTop + (offset != null ? offset : 0);
|
|
@@ -312,7 +311,7 @@ export class PortalUtils {
|
|
|
312
311
|
* Recursively climbs DOWN the tree to determine first CHILD node of the scroll element to obtain the scroll target
|
|
313
312
|
* @param currentElem
|
|
314
313
|
*/
|
|
315
|
-
|
|
314
|
+
const getScrollTaget = (currentElem: HTMLElement): HTMLElement => {
|
|
316
315
|
if (currentElem.scrollTop != 0) {
|
|
317
316
|
return currentElem;
|
|
318
317
|
}
|
|
@@ -330,7 +329,7 @@ export class PortalUtils {
|
|
|
330
329
|
}
|
|
331
330
|
|
|
332
331
|
return null;
|
|
333
|
-
}
|
|
332
|
+
};
|
|
334
333
|
|
|
335
334
|
PortalUtils.scrollElement(getScrollTaget(document.body) || document.body.parentElement, 0);
|
|
336
335
|
}
|
|
@@ -400,6 +399,7 @@ export class PortalUtils {
|
|
|
400
399
|
} else {
|
|
401
400
|
arr = [];
|
|
402
401
|
for (const key in fieldArr) {
|
|
402
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
403
403
|
if (fieldArr.hasOwnProperty(key)) {
|
|
404
404
|
arr.push({
|
|
405
405
|
name: key,
|
|
@@ -410,7 +410,7 @@ export class PortalUtils {
|
|
|
410
410
|
}
|
|
411
411
|
|
|
412
412
|
const formMethod = 'POST';
|
|
413
|
-
const formName = `frm${
|
|
413
|
+
const formName = `frm${TemporalUtils.dateNowMs()}`;
|
|
414
414
|
let newForm = `<form id="${formName}" method="${formMethod}" action="${url}" target="_blank">`;
|
|
415
415
|
|
|
416
416
|
$.each(arr, (i, field) => {
|
package/common/validation.ts
CHANGED
|
@@ -23,10 +23,10 @@ import {
|
|
|
23
23
|
} from '@vuelidate/validators';
|
|
24
24
|
import PowerduckState from '../app/powerduck-state';
|
|
25
25
|
import LocalizedValueHelper from './localized-value-helper';
|
|
26
|
-
import { capitalize } from './utils/capitalize-string';
|
|
27
26
|
import { isNullOrEmpty } from './utils/is-null-or-empty';
|
|
27
|
+
import { capitalize } from './extensions/string-extensions';
|
|
28
28
|
|
|
29
|
-
const getFirstUnsattisfiedValidatorName = (valProp: Validation): string => {
|
|
29
|
+
const getFirstUnsattisfiedValidatorName = (valProp: Validation): string | null => {
|
|
30
30
|
const errors = valProp?.$errors || [];
|
|
31
31
|
for (const fieldError of errors) {
|
|
32
32
|
if (fieldError != null) {
|
|
@@ -37,16 +37,16 @@ const getFirstUnsattisfiedValidatorName = (valProp: Validation): string => {
|
|
|
37
37
|
return null;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
const getErrorMessage = (valProp: Validation, invalidValidatorName: string): string => {
|
|
40
|
+
const getErrorMessage = (valProp: Validation, invalidValidatorName: string): string | null => {
|
|
41
41
|
if (invalidValidatorName == null) {
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
if (invalidValidatorName == 'requiredIf' || invalidValidatorName == 'requiredLocalizedString') {
|
|
45
|
+
if (invalidValidatorName == 'requiredIf' || invalidValidatorName == 'requiredLocalizedString' || invalidValidatorName == 'requiredTemporal') {
|
|
46
46
|
invalidValidatorName = 'required';
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
let errMsg = PowerduckState.getResourceValue(`validationError${capitalize(
|
|
49
|
+
let errMsg = PowerduckState.getResourceValue(`validationError${invalidValidatorName[capitalize]()}` as any);
|
|
50
50
|
switch (invalidValidatorName) {
|
|
51
51
|
case 'minLength':
|
|
52
52
|
case 'minValue':
|
|
@@ -167,6 +167,18 @@ export class ValidationBuilder {
|
|
|
167
167
|
return this;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
requiredTemporal(): ValidationBuilder {
|
|
171
|
+
this._validationArgs.requiredTemporal = (value) => {
|
|
172
|
+
if (value === null || !value || typeof value !== 'object') {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return true;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
return this;
|
|
180
|
+
}
|
|
181
|
+
|
|
170
182
|
requiredUnless?(field: string | ((vm: any, parentVm?: PowerduckViewModelBase) => any)): ValidationBuilder {
|
|
171
183
|
this._validationArgs.requiredUnless = requiredUnless(field as string);
|
|
172
184
|
return this;
|