@qrvey/utils 1.2.9-17 → 1.2.9-20
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/README.md +729 -729
- package/dist/cjs/filters/helpers/builder/getFilterBuilderGeneralConfig.js +1 -1
- package/dist/cjs/filters/helpers/ui/getUIValues.js +1 -1
- package/dist/cjs/filters/interfaces/builder/IFilterBuilderConfig.d.ts +0 -2
- package/dist/cjs/filters/interfaces/builder/IFilterBuilderGeneralConfig.d.ts +2 -1
- package/dist/cjs/filters/interfaces/panel/IFilterPanelConfig.d.ts +2 -3
- package/dist/cjs/filters/interfaces/ui/IFUTransformFilterValuesSettings.d.ts +2 -1
- package/dist/cjs/format/localization.d.ts +1 -0
- package/dist/cjs/format/localization.js +12 -3
- package/dist/cjs/globalization/helpers/getI18nCalendar.d.ts +4 -0
- package/dist/cjs/globalization/helpers/getI18nCalendar.js +69 -0
- package/dist/cjs/globalization/helpers/index.d.ts +1 -0
- package/dist/cjs/globalization/helpers/index.js +1 -0
- package/dist/cjs/globalization/interfaces/II18nConfig.d.ts +6 -0
- package/dist/cjs/globalization/interfaces/{IResourceI18n.js → II18nConfig.js} +0 -0
- package/dist/cjs/globalization/interfaces/{IResourceI18n.d.ts → II18nResource.d.ts} +1 -1
- package/dist/cjs/globalization/interfaces/II18nResource.js +2 -0
- package/dist/cjs/globalization/interfaces/bucket_builder/II18nBucketBuilderModalBucket.d.ts +2 -0
- package/dist/cjs/globalization/interfaces/calendar/II18nCalendar.d.ts +7 -0
- package/dist/cjs/globalization/interfaces/calendar/II18nCalendar.js +2 -0
- package/dist/cjs/globalization/interfaces/calendar/II18nCalendarProperties.d.ts +9 -0
- package/dist/cjs/globalization/interfaces/calendar/II18nCalendarProperties.js +2 -0
- package/dist/cjs/globalization/interfaces/calendar/index.d.ts +2 -0
- package/dist/cjs/globalization/interfaces/calendar/index.js +14 -0
- package/dist/cjs/globalization/interfaces/common/II18nCommon.d.ts +2 -0
- package/dist/cjs/globalization/interfaces/common/II18nDayNames.d.ts +7 -0
- package/dist/cjs/globalization/interfaces/filters/II18nFilter.d.ts +2 -0
- package/dist/cjs/globalization/interfaces/filters/II18nTokenBox.d.ts +6 -0
- package/dist/cjs/globalization/interfaces/filters/II18nTokenBox.js +2 -0
- package/dist/cjs/globalization/interfaces/formula_builder/II18nFormulaBuilderListModal.d.ts +2 -0
- package/dist/cjs/globalization/interfaces/index.d.ts +3 -1
- package/dist/cjs/globalization/interfaces/index.js +3 -1
- package/dist/cjs/globalization/interfaces/style_themes/II18nStyleThemesTooltips.d.ts +1 -0
- package/dist/cjs/globalization/labels/I18N_DEFAULT.d.ts +2 -2
- package/dist/cjs/globalization/labels/bucket_builder/I18N_BUCKET_BUILDER.js +2 -0
- package/dist/cjs/globalization/labels/calendar/I18N_CALENDAR.d.ts +2 -0
- package/dist/cjs/globalization/labels/calendar/I18N_CALENDAR.js +10 -0
- package/dist/cjs/globalization/labels/calendar/index.d.ts +1 -0
- package/dist/cjs/globalization/labels/calendar/index.js +13 -0
- package/dist/cjs/globalization/labels/common/I18N_COMMON.js +2 -0
- package/dist/cjs/globalization/labels/common/I18N_DAY_NAMES.js +7 -0
- package/dist/cjs/globalization/labels/filters/I18N_FILTER.js +6 -0
- package/dist/cjs/globalization/labels/formula_builder/I18N_FORMULA_BUILDER.js +3 -1
- package/dist/cjs/globalization/labels/index.d.ts +1 -0
- package/dist/cjs/globalization/labels/index.js +1 -0
- package/dist/cjs/globalization/labels/style_themes/I18N_STYLE_THEMES.js +1 -0
- package/dist/cjs/globalization/service/i18nextBuilder.d.ts +3 -3
- package/dist/cjs/globalization/service/initI18n.d.ts +2 -2
- package/dist/cjs/qrvey/helpers/transformValue.js +2 -1
- package/dist/cjs/qrvey/interfaces/ITransformValueSettings.d.ts +2 -1
- package/dist/cjs/services/api/getDatasetColumns.api.js +2 -3
- package/dist/filters/helpers/builder/getFilterBuilderGeneralConfig.js +1 -1
- package/dist/filters/helpers/ui/getUIValues.js +1 -1
- package/dist/filters/interfaces/builder/IFilterBuilderConfig.d.ts +0 -2
- package/dist/filters/interfaces/builder/IFilterBuilderGeneralConfig.d.ts +2 -1
- package/dist/filters/interfaces/panel/IFilterPanelConfig.d.ts +2 -3
- package/dist/filters/interfaces/ui/IFUTransformFilterValuesSettings.d.ts +2 -1
- package/dist/format/localization.d.ts +1 -0
- package/dist/format/localization.js +10 -2
- package/dist/globalization/helpers/getI18nCalendar.d.ts +4 -0
- package/dist/globalization/helpers/getI18nCalendar.js +65 -0
- package/dist/globalization/helpers/index.d.ts +1 -0
- package/dist/globalization/helpers/index.js +1 -0
- package/dist/globalization/interfaces/II18nConfig.d.ts +6 -0
- package/dist/globalization/interfaces/{IResourceI18n.js → II18nConfig.js} +0 -0
- package/dist/globalization/interfaces/{IResourceI18n.d.ts → II18nResource.d.ts} +1 -1
- package/dist/globalization/interfaces/II18nResource.js +1 -0
- package/dist/globalization/interfaces/bucket_builder/II18nBucketBuilderModalBucket.d.ts +2 -0
- package/dist/globalization/interfaces/calendar/II18nCalendar.d.ts +7 -0
- package/dist/globalization/interfaces/calendar/II18nCalendar.js +1 -0
- package/dist/globalization/interfaces/calendar/II18nCalendarProperties.d.ts +9 -0
- package/dist/globalization/interfaces/calendar/II18nCalendarProperties.js +1 -0
- package/dist/globalization/interfaces/calendar/index.d.ts +2 -0
- package/dist/globalization/interfaces/calendar/index.js +2 -0
- package/dist/globalization/interfaces/common/II18nCommon.d.ts +2 -0
- package/dist/globalization/interfaces/common/II18nDayNames.d.ts +7 -0
- package/dist/globalization/interfaces/filters/II18nFilter.d.ts +2 -0
- package/dist/globalization/interfaces/filters/II18nTokenBox.d.ts +6 -0
- package/dist/globalization/interfaces/filters/II18nTokenBox.js +1 -0
- package/dist/globalization/interfaces/formula_builder/II18nFormulaBuilderListModal.d.ts +2 -0
- package/dist/globalization/interfaces/index.d.ts +3 -1
- package/dist/globalization/interfaces/index.js +3 -1
- package/dist/globalization/interfaces/style_themes/II18nStyleThemesTooltips.d.ts +1 -0
- package/dist/globalization/labels/I18N_DEFAULT.d.ts +2 -2
- package/dist/globalization/labels/bucket_builder/I18N_BUCKET_BUILDER.js +2 -0
- package/dist/globalization/labels/calendar/I18N_CALENDAR.d.ts +2 -0
- package/dist/globalization/labels/calendar/I18N_CALENDAR.js +7 -0
- package/dist/globalization/labels/calendar/index.d.ts +1 -0
- package/dist/globalization/labels/calendar/index.js +1 -0
- package/dist/globalization/labels/common/I18N_COMMON.js +2 -0
- package/dist/globalization/labels/common/I18N_DAY_NAMES.js +7 -0
- package/dist/globalization/labels/filters/I18N_FILTER.js +6 -0
- package/dist/globalization/labels/formula_builder/I18N_FORMULA_BUILDER.js +3 -1
- package/dist/globalization/labels/index.d.ts +1 -0
- package/dist/globalization/labels/index.js +1 -0
- package/dist/globalization/labels/style_themes/I18N_STYLE_THEMES.js +1 -0
- package/dist/globalization/service/i18nextBuilder.d.ts +3 -3
- package/dist/globalization/service/initI18n.d.ts +2 -2
- package/dist/qrvey/helpers/transformValue.js +2 -1
- package/dist/qrvey/interfaces/ITransformValueSettings.d.ts +2 -1
- package/dist/services/api/getDatasetColumns.api.js +3 -4
- package/package.json +1 -1
- package/src/filters/helpers/builder/getFilterBuilderGeneralConfig.ts +1 -1
- package/src/filters/helpers/ui/getUIValues.ts +1 -1
- package/src/filters/interfaces/builder/IFilterBuilderConfig.ts +0 -2
- package/src/filters/interfaces/builder/IFilterBuilderGeneralConfig.ts +3 -1
- package/src/filters/interfaces/panel/IFilterPanelConfig.ts +2 -3
- package/src/filters/interfaces/ui/IFUTransformFilterValuesSettings.ts +2 -1
- package/src/format/localization.ts +12 -2
- package/src/globalization/helpers/getI18nCalendar.ts +68 -0
- package/src/globalization/helpers/index.ts +1 -0
- package/src/globalization/interfaces/II18nConfig.ts +7 -0
- package/src/globalization/interfaces/{IResourceI18n.ts → II18nResource.ts} +1 -1
- package/src/globalization/interfaces/bucket_builder/II18nBucketBuilderModalBucket.ts +2 -0
- package/src/globalization/interfaces/calendar/II18nCalendar.ts +7 -0
- package/src/globalization/interfaces/calendar/II18nCalendarProperties.ts +9 -0
- package/src/globalization/interfaces/calendar/index.ts +2 -0
- package/src/globalization/interfaces/common/II18nCommon.ts +2 -0
- package/src/globalization/interfaces/common/II18nDayNames.ts +8 -0
- package/src/globalization/interfaces/filters/II18nFilter.ts +2 -0
- package/src/globalization/interfaces/filters/II18nTokenBox.ts +6 -0
- package/src/globalization/interfaces/formula_builder/II18nFormulaBuilderListModal.ts +3 -1
- package/src/globalization/interfaces/index.ts +3 -1
- package/src/globalization/interfaces/style_themes/II18nStyleThemesTooltips.ts +1 -0
- package/src/globalization/labels/I18N_DEFAULT.ts +2 -2
- package/src/globalization/labels/bucket_builder/I18N_BUCKET_BUILDER.ts +2 -0
- package/src/globalization/labels/calendar/I18N_CALENDAR.ts +9 -0
- package/src/globalization/labels/calendar/index.ts +1 -0
- package/src/globalization/labels/common/I18N_COMMON.ts +2 -0
- package/src/globalization/labels/common/I18N_DAY_NAMES.ts +8 -0
- package/src/globalization/labels/filters/I18N_FILTER.ts +6 -0
- package/src/globalization/labels/formula_builder/I18N_FORMULA_BUILDER.ts +3 -1
- package/src/globalization/labels/index.ts +1 -0
- package/src/globalization/labels/style_themes/I18N_STYLE_THEMES.ts +1 -0
- package/src/globalization/service/i18nextBuilder.ts +4 -4
- package/src/globalization/service/initI18n.ts +3 -3
- package/src/qrvey/helpers/transformValue.ts +1 -1
- package/src/qrvey/interfaces/ITransformValueSettings.ts +2 -1
- package/src/services/api/getDatasetColumns.api.ts +3 -4
- package/test/columns/isNumericalColumn.test.js +154 -0
|
@@ -7,6 +7,16 @@ export const getLang = (locale: string | Record<string, any>) => {
|
|
|
7
7
|
else return { lang: locale === "browser" ? window.navigator.language : locale };
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
+
export const chooseLang = (config: Record<string, any>): string => {
|
|
11
|
+
const lang: string | Record<string, any> = (
|
|
12
|
+
config?.i18n?.lang ||
|
|
13
|
+
config?.i18n?.locale?.lang ||
|
|
14
|
+
config?.locale?.lang ||
|
|
15
|
+
config.lang
|
|
16
|
+
);
|
|
17
|
+
return (<any>lang)?.lang || lang || LANG_DEFAULT;
|
|
18
|
+
};
|
|
19
|
+
|
|
10
20
|
export const formatWithLocale = (value: any, outputFormat: IFormatOutputFormat, config: IFormatConfig = {}): any => {
|
|
11
21
|
switch (outputFormat.type) {
|
|
12
22
|
case 'DATE':
|
|
@@ -38,10 +48,10 @@ function formatLocaleNumber(value: any, outputFormat: IFormatOutputFormat, confi
|
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
function getLocaleOptions(outputFormat: IFormatOutputFormat) {
|
|
41
|
-
const { format, decimals, currency
|
|
51
|
+
const { format, decimals, currency } = outputFormat;
|
|
42
52
|
switch(format) {
|
|
43
53
|
case LOCALE_FORMATS.CURRENCY: {
|
|
44
|
-
const iso = currencyISO.find(item => item.text ===
|
|
54
|
+
const iso = currencyISO.find(item => (item.text === currency.text) || (item.text.includes(currency.label)));
|
|
45
55
|
return { style: LOCALE_STYLES.CURRENCY, currency: iso.label, maximumFractionDigits: decimals, minimumFractionDigits: 0 };
|
|
46
56
|
}
|
|
47
57
|
case LOCALE_FORMATS.SCIENTIFIC: return { style: LOCALE_STYLES.DECIMAL,
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { II18nCalendarProperties } from "../interfaces/calendar/II18nCalendarProperties";
|
|
2
|
+
import { II18nServiceTranslate } from "../interfaces/II18nServiceTranslate";
|
|
3
|
+
import { I18nService } from "../service/i18nextBuilder";
|
|
4
|
+
|
|
5
|
+
export function getI18nCalendar(locale: I18nService | II18nServiceTranslate): II18nCalendarProperties {
|
|
6
|
+
const localeOverride = locale instanceof I18nService ? locale : typeof locale === 'function' ? { translate: locale } : undefined;
|
|
7
|
+
if (!localeOverride) return undefined;
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
clear: localeOverride.translate('common.calendar.clear'),
|
|
11
|
+
days: [
|
|
12
|
+
localeOverride.translate('common.day_names.sunday_dddd'),
|
|
13
|
+
localeOverride.translate('common.day_names.monday_dddd'),
|
|
14
|
+
localeOverride.translate('common.day_names.tuesday_dddd'),
|
|
15
|
+
localeOverride.translate('common.day_names.wednesday_dddd'),
|
|
16
|
+
localeOverride.translate('common.day_names.thursday_dddd'),
|
|
17
|
+
localeOverride.translate('common.day_names.friday_dddd'),
|
|
18
|
+
localeOverride.translate('common.day_names.saturday_dddd')
|
|
19
|
+
],
|
|
20
|
+
daysMin: [
|
|
21
|
+
localeOverride.translate('common.day_names.sunday_dd'),
|
|
22
|
+
localeOverride.translate('common.day_names.monday_dd'),
|
|
23
|
+
localeOverride.translate('common.day_names.tuesday_dd'),
|
|
24
|
+
localeOverride.translate('common.day_names.wednesday_dd'),
|
|
25
|
+
localeOverride.translate('common.day_names.thursday_dd'),
|
|
26
|
+
localeOverride.translate('common.day_names.friday_dd'),
|
|
27
|
+
localeOverride.translate('common.day_names.saturday_dd')
|
|
28
|
+
],
|
|
29
|
+
daysShort: [
|
|
30
|
+
localeOverride.translate('common.day_names.sunday_ddd'),
|
|
31
|
+
localeOverride.translate('common.day_names.monday_ddd'),
|
|
32
|
+
localeOverride.translate('common.day_names.tuesday_ddd'),
|
|
33
|
+
localeOverride.translate('common.day_names.wednesday_ddd'),
|
|
34
|
+
localeOverride.translate('common.day_names.thursday_ddd'),
|
|
35
|
+
localeOverride.translate('common.day_names.friday_ddd'),
|
|
36
|
+
localeOverride.translate('common.day_names.saturday_ddd')
|
|
37
|
+
],
|
|
38
|
+
months: [
|
|
39
|
+
localeOverride.translate('common.date_grouping.january_mmmm'),
|
|
40
|
+
localeOverride.translate('common.date_grouping.february_mmmm'),
|
|
41
|
+
localeOverride.translate('common.date_grouping.march_mmmm'),
|
|
42
|
+
localeOverride.translate('common.date_grouping.april_mmmm'),
|
|
43
|
+
localeOverride.translate('common.date_grouping.may_mmmm'),
|
|
44
|
+
localeOverride.translate('common.date_grouping.june_mmmm'),
|
|
45
|
+
localeOverride.translate('common.date_grouping.july_mmmm'),
|
|
46
|
+
localeOverride.translate('common.date_grouping.august_mmmm'),
|
|
47
|
+
localeOverride.translate('common.date_grouping.september_mmmm'),
|
|
48
|
+
localeOverride.translate('common.date_grouping.october_mmmm'),
|
|
49
|
+
localeOverride.translate('common.date_grouping.november_mmmm'),
|
|
50
|
+
localeOverride.translate('common.date_grouping.december_mmmm')
|
|
51
|
+
],
|
|
52
|
+
monthsShort: [
|
|
53
|
+
localeOverride.translate('common.date_grouping.january_mmm'),
|
|
54
|
+
localeOverride.translate('common.date_grouping.february_mmm'),
|
|
55
|
+
localeOverride.translate('common.date_grouping.march_mmm'),
|
|
56
|
+
localeOverride.translate('common.date_grouping.april_mmm'),
|
|
57
|
+
localeOverride.translate('common.date_grouping.may_mmm'),
|
|
58
|
+
localeOverride.translate('common.date_grouping.june_mmm'),
|
|
59
|
+
localeOverride.translate('common.date_grouping.july_mmm'),
|
|
60
|
+
localeOverride.translate('common.date_grouping.august_mmm'),
|
|
61
|
+
localeOverride.translate('common.date_grouping.september_mmm'),
|
|
62
|
+
localeOverride.translate('common.date_grouping.october_mmm'),
|
|
63
|
+
localeOverride.translate('common.date_grouping.november_mmm'),
|
|
64
|
+
localeOverride.translate('common.date_grouping.december_mmm')
|
|
65
|
+
],
|
|
66
|
+
today: localeOverride.translate('common.calendar.today')
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { II18nResource } from "./II18nResource";
|
|
2
|
+
|
|
3
|
+
export interface II18nConfig {
|
|
4
|
+
lang?: string; // Language format for getting stored traslations of the labels (en-US)
|
|
5
|
+
locale?: string; // Language format for transform number and date values (en-US)
|
|
6
|
+
lang_object?: II18nResource; // Oject Structure to translate labels
|
|
7
|
+
}
|
|
@@ -12,7 +12,7 @@ import { II18nCrossTabs } from './cross_tabs';
|
|
|
12
12
|
import { II18nChartBuilder } from '.';
|
|
13
13
|
import { II18nStyleThemes } from './style_themes/II18nStyleThemes';
|
|
14
14
|
|
|
15
|
-
export interface
|
|
15
|
+
export interface II18nResource {
|
|
16
16
|
bucket_builder?: II18nBucketBuilder;
|
|
17
17
|
chart_builder?: II18nChartBuilder;
|
|
18
18
|
common?: II18nCommon;
|
|
@@ -5,9 +5,11 @@ import { II18nColumnTypesSuffixes } from "./II18nColumnTypesSuffixes";
|
|
|
5
5
|
import { II18nDateGrouping } from "./II18nDateGrouping";
|
|
6
6
|
import { II18nDayNames } from "./II18nDayNames";
|
|
7
7
|
import { II18nUnits } from "./II18nUnits";
|
|
8
|
+
import { II18nCalendar } from "../calendar/II18nCalendar";
|
|
8
9
|
|
|
9
10
|
export interface II18nCommon {
|
|
10
11
|
aggregate_labels: II18nAgreggateLabels;
|
|
12
|
+
calendar: II18nCalendar;
|
|
11
13
|
column_types: II18nColumnTypes;
|
|
12
14
|
column_types_suffixes: II18nColumnTypesSuffixes;
|
|
13
15
|
date_grouping: II18nDateGrouping;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
export interface II18nDayNames {
|
|
2
|
+
sunday_dd: string;
|
|
3
|
+
monday_dd: string;
|
|
4
|
+
tuesday_dd: string;
|
|
5
|
+
wednesday_dd: string;
|
|
6
|
+
thursday_dd: string;
|
|
7
|
+
friday_dd: string;
|
|
8
|
+
saturday_dd: string;
|
|
9
|
+
|
|
2
10
|
sunday_ddd: string;
|
|
3
11
|
monday_ddd: string;
|
|
4
12
|
tuesday_ddd: string;
|
|
@@ -7,6 +7,7 @@ import { II18nFilterOperator } from "./II18nFilterOperator";
|
|
|
7
7
|
import { II18nFilterScopes } from "./II18nFilterScopes";
|
|
8
8
|
import { II18nFilterPanelScopeTitle } from "./II18nFilterPanelScopeTitle";
|
|
9
9
|
import { II18nFilterDateSections } from "./II18nFilterDateSections";
|
|
10
|
+
import { II18nTokenBox } from './II18nTokenBox';
|
|
10
11
|
|
|
11
12
|
export interface II18nFilter {
|
|
12
13
|
date_sections: II18nFilterDateSections;
|
|
@@ -16,6 +17,7 @@ export interface II18nFilter {
|
|
|
16
17
|
scope_title: II18nFilterPanelScopeTitle;
|
|
17
18
|
scopes: II18nFilterScopes;
|
|
18
19
|
slidebar: II18nSlidebar;
|
|
20
|
+
token_box?: II18nTokenBox;
|
|
19
21
|
validators: II18nFilterValidator;
|
|
20
22
|
value_container: II18nValueContainer;
|
|
21
23
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './bucket_builder/index';
|
|
2
|
+
export * from './calendar/index';
|
|
2
3
|
export * from './chart_builder/index';
|
|
3
4
|
export * from './columns/index';
|
|
4
5
|
export * from './common/index';
|
|
@@ -10,6 +11,7 @@ export * from './panel/index';
|
|
|
10
11
|
export * from './style_themes/index';
|
|
11
12
|
export * from './table_charts/index';
|
|
12
13
|
|
|
14
|
+
export * from './II18nConfig';
|
|
15
|
+
export * from './II18nResource';
|
|
13
16
|
export * from './II18nServiceTranslate';
|
|
14
17
|
export * from './II18nServiceTranslateOption';
|
|
15
|
-
export * from './IResourceI18n';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { II18nResource } from "../interfaces/II18nResource";
|
|
2
2
|
import { I18N_DASHBOARD } from "./dashboard/I18N_DASHBOARD";
|
|
3
3
|
import { I18N_PANEL } from "./panel/I18N_PANEL";
|
|
4
4
|
import { I18N_FILTER } from "./filters/I18N_FILTER";
|
|
@@ -14,7 +14,7 @@ import { I18N_CHART_BUILDER } from "./chart_builder";
|
|
|
14
14
|
import { I18N_STYLE_THEMES } from "./style_themes";
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
export const I18N_DEFAULT:
|
|
17
|
+
export const I18N_DEFAULT: II18nResource = {
|
|
18
18
|
bucket_builder: I18N_BUCKET_BUILDER,
|
|
19
19
|
chart_builder: I18N_CHART_BUILDER,
|
|
20
20
|
common: I18N_COMMON,
|
|
@@ -96,6 +96,8 @@ export const I18N_BUCKET_BUILDER: II18nBucketBuilder = {
|
|
|
96
96
|
loading: 'Loading dependencies...',
|
|
97
97
|
title: 'Buckets',
|
|
98
98
|
add_bucketed_column: 'Add Bucketed Column',
|
|
99
|
+
information_text_link: 'Learn how to',
|
|
100
|
+
information_text_text: 'create and work with buckets',
|
|
99
101
|
},
|
|
100
102
|
operator: {
|
|
101
103
|
greater_than: 'Greater than',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './I18N_CALENDAR';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RELATIVE_UNIT_INFO } from "../../../dates/relative/constants/RELATIVE_UNIT_INFO";
|
|
2
2
|
import { II18nCommon } from "../../interfaces/common/II18nCommon";
|
|
3
|
+
import { I18N_CALENDAR } from "../calendar";
|
|
3
4
|
import { I18N_AGGREGATE_LABEL } from "./I18N_AGGREGATE_LABEL";
|
|
4
5
|
import { I18N_COLUMN_LABEL } from "./I18N_COLUMN_LABEL";
|
|
5
6
|
import { I18N_COLUMN_PROPERTY_LABEL } from "./I18N_COLUMN_PROPERTY_LABEL";
|
|
@@ -8,6 +9,7 @@ import { I18N_DAY_NAMES } from "./I18N_DAY_NAMES";
|
|
|
8
9
|
|
|
9
10
|
export const I18N_COMMON: II18nCommon = {
|
|
10
11
|
aggregate_labels: I18N_AGGREGATE_LABEL,
|
|
12
|
+
calendar: I18N_CALENDAR,
|
|
11
13
|
column_types: I18N_COLUMN_LABEL,
|
|
12
14
|
column_types_suffixes: {
|
|
13
15
|
slidebar_one: 'Step',
|
|
@@ -4,6 +4,14 @@ import { capitalize } from "../../../general/string/capitalize";
|
|
|
4
4
|
import { II18nDayNames } from "../../interfaces/common/II18nDayNames";
|
|
5
5
|
|
|
6
6
|
export const I18N_DAY_NAMES: II18nDayNames = {
|
|
7
|
+
sunday_dd: capitalize(DATE_WEEK_DAYS[0].substring(0, 2)),
|
|
8
|
+
monday_dd: capitalize(DATE_WEEK_DAYS[1].substring(0, 2)),
|
|
9
|
+
tuesday_dd: capitalize(DATE_WEEK_DAYS[2].substring(0, 2)),
|
|
10
|
+
wednesday_dd: capitalize(DATE_WEEK_DAYS[3].substring(0, 2)),
|
|
11
|
+
thursday_dd: capitalize(DATE_WEEK_DAYS[4].substring(0, 2)),
|
|
12
|
+
friday_dd: capitalize(DATE_WEEK_DAYS[5].substring(0, 2)),
|
|
13
|
+
saturday_dd: capitalize(DATE_WEEK_DAYS[6].substring(0, 2)),
|
|
14
|
+
|
|
7
15
|
sunday_ddd: capitalize(DATE_WEEK_DAYS[0]),
|
|
8
16
|
monday_ddd: capitalize(DATE_WEEK_DAYS[1]),
|
|
9
17
|
tuesday_ddd: capitalize(DATE_WEEK_DAYS[2]),
|
|
@@ -28,6 +28,12 @@ export const I18N_FILTER: II18nFilter = {
|
|
|
28
28
|
},
|
|
29
29
|
scopes: I18N_FILTER_SCOPE,
|
|
30
30
|
slidebar: I18N_SLIDEBAR,
|
|
31
|
+
token_box: {
|
|
32
|
+
data_tokens: 'DataTokens',
|
|
33
|
+
search: 'Search',
|
|
34
|
+
system_tokens: 'SystemTokens',
|
|
35
|
+
user_tokens: 'UserTokens',
|
|
36
|
+
},
|
|
31
37
|
validators: I18N_FILTER_VALIDATOR,
|
|
32
38
|
value_container: I18N_VALUE_CONTAINER,
|
|
33
39
|
};
|
|
@@ -4,7 +4,9 @@ export const I18N_FORMULA_BUILDER: II18nFormulaBuilder = {
|
|
|
4
4
|
list_modal: {
|
|
5
5
|
title_header: 'Formulas',
|
|
6
6
|
create_button: 'Create Formula',
|
|
7
|
-
empty_message: 'No Formulas Yet'
|
|
7
|
+
empty_message: 'No Formulas Yet',
|
|
8
|
+
information_text_link: 'Learn how to',
|
|
9
|
+
information_text_text: 'create and work with formulas',
|
|
8
10
|
},
|
|
9
11
|
list_table: {
|
|
10
12
|
name: 'Formula Name',
|
|
@@ -52,5 +52,6 @@ export const I18N_STYLE_THEMES: II18nStyleThemes = {
|
|
|
52
52
|
title: 'Style Themes',
|
|
53
53
|
tooltips: {
|
|
54
54
|
theme_used_in_all_applications: 'This theme is being used in all applications',
|
|
55
|
+
theme_will_be_used_in_all_applications: 'This theme will be used in all applications'
|
|
55
56
|
}
|
|
56
57
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { IResourceI18n } from "../interfaces";
|
|
2
1
|
import i18next from 'i18next';
|
|
3
2
|
import { mergeDeep } from "../../general/object/mergeDeep";
|
|
3
|
+
import { II18nResource } from '../interfaces/II18nResource';
|
|
4
4
|
import { II18nServiceTranslateOption } from "../interfaces/II18nServiceTranslateOption";
|
|
5
5
|
|
|
6
6
|
export class I18nServiceBuilder {
|
|
7
7
|
|
|
8
|
-
public static async buildI18n(i18nDefault:
|
|
8
|
+
public static async buildI18n(i18nDefault: II18nResource, i18nResource: II18nResource): Promise<I18nService> {
|
|
9
9
|
return await this._initI18n(i18nDefault, i18nResource);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
private static async _initI18n(i18nDefault:
|
|
12
|
+
private static async _initI18n(i18nDefault: II18nResource, i18nResource: II18nResource): Promise<I18nService> {
|
|
13
13
|
|
|
14
14
|
if (!i18next.isInitialized) {
|
|
15
15
|
await i18next
|
|
@@ -30,7 +30,7 @@ export class I18nServiceBuilder {
|
|
|
30
30
|
return new I18nServiceConcrete(i18next);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
public static setTranslations(i18nDefault, i18nResource:
|
|
33
|
+
public static setTranslations(i18nDefault, i18nResource: II18nResource): II18nResource {
|
|
34
34
|
return mergeDeep(i18nResource, i18nDefault, { mergeExistingValues: false });
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { II18nResource } from "../interfaces/II18nResource";
|
|
2
2
|
import { I18nService, I18nServiceBuilder } from "../service/i18nextBuilder";
|
|
3
3
|
|
|
4
|
-
export async function initI18n(i18nConfig:
|
|
4
|
+
export async function initI18n(i18nConfig: II18nResource = {}, i18nDefault: II18nResource = {}): Promise<I18nService> {
|
|
5
5
|
return await I18nServiceBuilder.buildI18n(i18nDefault, i18nConfig);
|
|
6
|
-
}
|
|
6
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IColumn } from "../../columns/interfaces/IColumn";
|
|
2
2
|
import { IColumnPropertyType } from "../../columns/interfaces/IColumnPropertyType";
|
|
3
|
+
import { II18nConfig } from "../../globalization/interfaces/II18nConfig";
|
|
3
4
|
import { II18nServiceTranslate } from "../../globalization/interfaces/II18nServiceTranslate";
|
|
4
5
|
|
|
5
6
|
export interface ITransformValueSettings {
|
|
@@ -7,6 +8,6 @@ export interface ITransformValueSettings {
|
|
|
7
8
|
property: IColumnPropertyType;
|
|
8
9
|
|
|
9
10
|
translate: II18nServiceTranslate; // Function for getting translations
|
|
10
|
-
|
|
11
|
+
i18n: II18nConfig; // The i18n configuration;
|
|
11
12
|
suffixTranslateLabel?: string // The i18n label for the suffix values.
|
|
12
13
|
}
|
|
@@ -3,8 +3,7 @@ import { IDataset } from "../../qrvey/interfaces/IDataset";
|
|
|
3
3
|
import { CHART_ENDPOINT } from "../constants/CHART_ENDPOINT";
|
|
4
4
|
import Request from "../helpers/Request";
|
|
5
5
|
import { BDatasetsToUIDatasets } from "../adapters/BDatasetsToUIDatasets.adapter";
|
|
6
|
-
import {
|
|
7
|
-
import { getLang } from "../..";
|
|
6
|
+
import { chooseLang } from "../..";
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Get a dataset by Qrvey ID
|
|
@@ -12,11 +11,11 @@ import { getLang } from "../..";
|
|
|
12
11
|
* @returns a promise
|
|
13
12
|
*/
|
|
14
13
|
export function getDatasetColumns(config: IGeneralWidgetConfig, qrveyid?: string): Promise<IDataset[]> {
|
|
14
|
+
const lang = chooseLang(config);
|
|
15
15
|
return Request.post({ ...config, qrveyid, endpoint: CHART_ENDPOINT }, '/question/list', {
|
|
16
|
-
'lang': getLang(config.lang || config.locale || LANG_DEFAULT).lang,
|
|
17
16
|
'optionsAttributes': ['id', 'text', 'type', 'property', 'linked', 'linkid', 'qrveyid', 'bucketId', 'formulaId', 'formulaType', 'geogroup', 'outputFormat'],
|
|
18
17
|
'extend': true
|
|
19
|
-
})
|
|
18
|
+
}, { lang })
|
|
20
19
|
.then(BDatasetsToUIDatasets)
|
|
21
20
|
.catch(_e => []);
|
|
22
21
|
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
const { COLUMN, FORMULA, isNumericalColumn } = require("../../dist/cjs");
|
|
2
|
+
|
|
3
|
+
const column1 = {
|
|
4
|
+
id: '123',
|
|
5
|
+
qrveyid: 'abc',
|
|
6
|
+
type: COLUMN.NUMERIC
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const column2 = {
|
|
10
|
+
id: '222',
|
|
11
|
+
qrveyid: 'abc',
|
|
12
|
+
type: COLUMN.RATING
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const column3 = {
|
|
16
|
+
id: '333',
|
|
17
|
+
qrveyid: 'abc',
|
|
18
|
+
type: COLUMN.SLIDEBAR
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const column4 = {
|
|
22
|
+
formulaid: '456',
|
|
23
|
+
formulaType: FORMULA.NUMBER,
|
|
24
|
+
id: '456',
|
|
25
|
+
qrveyid: 'abc',
|
|
26
|
+
type: COLUMN.FORMULA
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const wrongColumn1 = {
|
|
30
|
+
formulaid: '456',
|
|
31
|
+
formulaType: FORMULA.DATE,
|
|
32
|
+
id: '494',
|
|
33
|
+
qrveyid: 'abc',
|
|
34
|
+
type: COLUMN.FORMULA
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const wrongColumn2 = {
|
|
38
|
+
id: '789',
|
|
39
|
+
qrveyid: 'abc',
|
|
40
|
+
type: COLUMN.TEXTFIELD
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
describe('Testing undefined/empty arguments', function () {
|
|
44
|
+
const empty1 = undefined;
|
|
45
|
+
const empty2 = null;
|
|
46
|
+
const empty3 = '';
|
|
47
|
+
const empty4 = [];
|
|
48
|
+
const empty5 = {};
|
|
49
|
+
|
|
50
|
+
test('no argument passed', function () {
|
|
51
|
+
const validation = isNumericalColumn();
|
|
52
|
+
expect(validation).toBeFalsy();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('Undefined argument', function () {
|
|
56
|
+
const validation = isNumericalColumn(empty1);
|
|
57
|
+
expect(validation).toBeFalsy();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('Null argument', function () {
|
|
61
|
+
const validation = isNumericalColumn(empty2);
|
|
62
|
+
expect(validation).toBeFalsy();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('Empty string argument', function () {
|
|
66
|
+
const validation = isNumericalColumn(empty3);
|
|
67
|
+
expect(validation).toBeFalsy();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('Empty array argument', function () {
|
|
71
|
+
const validation = isNumericalColumn(empty4);
|
|
72
|
+
expect(validation).toBeFalsy();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('Empty object argument', function () {
|
|
76
|
+
const validation = isNumericalColumn(empty5);
|
|
77
|
+
expect(validation).toBeFalsy();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('Testing no-object arguments', function () {
|
|
82
|
+
const variable1 = 1;
|
|
83
|
+
const variable2 = false;
|
|
84
|
+
const variable3 = new Date();
|
|
85
|
+
const variable4 = ['Hello', 'World'];
|
|
86
|
+
const variable5 = (num1 = 1, num2 = 2) => num1 + num2;
|
|
87
|
+
|
|
88
|
+
test('Numeric variable', function () {
|
|
89
|
+
const validation = isNumericalColumn(variable1);
|
|
90
|
+
expect(validation).toBeFalsy();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('Boolean variable', function () {
|
|
94
|
+
const validation = isNumericalColumn(variable2);
|
|
95
|
+
expect(validation).toBeFalsy();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('Date object variable', function () {
|
|
99
|
+
const validation = isNumericalColumn(variable3);
|
|
100
|
+
expect(validation).toBeFalsy();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('Array variable', function () {
|
|
104
|
+
const validation = isNumericalColumn(variable4);
|
|
105
|
+
expect(validation).toBeFalsy();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('Function-like variable', function () {
|
|
109
|
+
const validation = isNumericalColumn(variable5);
|
|
110
|
+
expect(validation).toBeFalsy();
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe('Testing invalid expected object', function () {
|
|
115
|
+
const variable1 = { tag1: 'value1', tag2: 'value2' };
|
|
116
|
+
|
|
117
|
+
test('Different expected object', function () {
|
|
118
|
+
const validation = isNumericalColumn(variable1);
|
|
119
|
+
expect(validation).toBeFalsy();
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('Different column type 2', function () {
|
|
123
|
+
const validation = isNumericalColumn(wrongColumn1);
|
|
124
|
+
expect(validation).toBeFalsy();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test('Different column type 1', function () {
|
|
128
|
+
const validation = isNumericalColumn(wrongColumn2);
|
|
129
|
+
expect(validation).toBeFalsy();
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe('Regular scenarios', function () {
|
|
134
|
+
test('Scenario #1 - Numeric column type', function () {
|
|
135
|
+
const validation = isNumericalColumn(column1);
|
|
136
|
+
expect(validation).toBeTruthy();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test('Scenario #2 - Rating column type', function () {
|
|
140
|
+
const validation = isNumericalColumn(column2);
|
|
141
|
+
expect(validation).toBeTruthy();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('Scenario #4 - Slidebar column type', function () {
|
|
145
|
+
const validation = isNumericalColumn(column3);
|
|
146
|
+
expect(validation).toBeTruthy();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('Scenario #4 - Formula column type with a number type', function () {
|
|
150
|
+
const validation = isNumericalColumn(column4);
|
|
151
|
+
expect(validation).toBeTruthy();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
});
|