@qrvey/utils 1.5.0 → 1.6.0-0-to-0
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/cjs/column_format/helpers/columnTypeByChart.d.ts +1 -1
- package/dist/cjs/column_format/helpers/defineTableChartFormat.js +2 -2
- package/dist/cjs/column_format/helpers/defineXYChartFormat.js +9 -2
- package/dist/cjs/column_format/interfaces/IChartColumn.d.ts +2 -0
- package/dist/cjs/columns/constants/COLUMN.d.ts +1 -0
- package/dist/cjs/columns/constants/COLUMN.js +1 -0
- package/dist/cjs/columns/constants/COLUMNS.js +1 -0
- package/dist/cjs/columns/constants/COLUMN_INFO.js +7 -0
- package/dist/cjs/columns/constants/COLUMN_INFO_LIST.js +1 -0
- package/dist/cjs/columns/constants/COLUMN_LABEL.d.ts +1 -0
- package/dist/cjs/columns/constants/COLUMN_LABEL.js +1 -1
- package/dist/cjs/columns/constants/COLUMN_PROPERTY_INFO.js +1 -1
- package/dist/cjs/columns/constants/COLUMN_PROPERTY_LABEL.d.ts +4 -0
- package/dist/cjs/columns/constants/COLUMN_PROPERTY_LABEL.js +2 -1
- package/dist/cjs/columns/interfaces/IColumnTimeGroupSettings.d.ts +7 -0
- package/dist/cjs/columns/interfaces/IColumnTimeGroupSettings.js +2 -0
- package/dist/cjs/dates/adapters/hmsToDate.d.ts +7 -0
- package/dist/cjs/dates/adapters/hmsToDate.js +24 -0
- package/dist/cjs/dates/adapters/index.d.ts +1 -0
- package/dist/cjs/dates/adapters/index.js +1 -0
- package/dist/cjs/dates/constants/TIME_GROUPING_PROPERTY_INFO.d.ts +5 -0
- package/dist/cjs/dates/constants/TIME_GROUPING_PROPERTY_INFO.js +31 -0
- package/dist/cjs/dates/constants/TIME_GROUPING_PROPERTY_INFO_LIST.d.ts +2 -0
- package/dist/cjs/dates/constants/TIME_GROUPING_PROPERTY_INFO_LIST.js +10 -0
- package/dist/cjs/dates/constants/TIME_GROUPING_PROPERTY_LABEL.d.ts +5 -0
- package/dist/cjs/dates/constants/TIME_GROUPING_PROPERTY_LABEL.js +9 -0
- package/dist/cjs/dates/constants/index.d.ts +3 -0
- package/dist/cjs/dates/constants/index.js +3 -0
- package/dist/cjs/filters/helpers/backend/getBackendGroupValue.js +3 -1
- package/dist/cjs/filters/helpers/backend/getBackendProperty.js +2 -1
- package/dist/cjs/filters/services/UChartApi.js +6 -2
- package/dist/cjs/filters/services/UChartPaginationApi.js +6 -2
- package/dist/cjs/format/definition.d.ts +1 -0
- package/dist/cjs/format/definition.js +2 -1
- package/dist/cjs/format/format.d.ts +12 -0
- package/dist/cjs/format/format.js +32 -4
- package/dist/cjs/globalization/interfaces/common/II18nColumnProperties.d.ts +3 -0
- package/dist/cjs/globalization/labels/common/I18N_COLUMN_LABEL.d.ts +1 -0
- package/dist/cjs/globalization/labels/common/I18N_COLUMN_LABEL.js +1 -0
- package/dist/cjs/globalization/labels/common/I18N_COLUMN_PROPERTY_LABEL.js +3 -0
- package/dist/cjs/qrvey/helpers/transformValue.js +5 -0
- package/dist/column_format/helpers/columnTypeByChart.d.ts +1 -1
- package/dist/column_format/helpers/defineTableChartFormat.js +2 -2
- package/dist/column_format/helpers/defineXYChartFormat.js +9 -2
- package/dist/column_format/interfaces/IChartColumn.d.ts +2 -0
- package/dist/columns/constants/COLUMN.d.ts +1 -0
- package/dist/columns/constants/COLUMN.js +1 -0
- package/dist/columns/constants/COLUMNS.js +1 -0
- package/dist/columns/constants/COLUMN_INFO.js +7 -0
- package/dist/columns/constants/COLUMN_INFO_LIST.js +1 -0
- package/dist/columns/constants/COLUMN_LABEL.d.ts +1 -0
- package/dist/columns/constants/COLUMN_LABEL.js +1 -1
- package/dist/columns/constants/COLUMN_PROPERTY_INFO.js +1 -1
- package/dist/columns/constants/COLUMN_PROPERTY_LABEL.d.ts +4 -0
- package/dist/columns/constants/COLUMN_PROPERTY_LABEL.js +2 -1
- package/dist/columns/interfaces/IColumnTimeGroupSettings.d.ts +7 -0
- package/dist/columns/interfaces/IColumnTimeGroupSettings.js +1 -0
- package/dist/dates/adapters/hmsToDate.d.ts +7 -0
- package/dist/dates/adapters/hmsToDate.js +20 -0
- package/dist/dates/adapters/index.d.ts +1 -0
- package/dist/dates/adapters/index.js +1 -0
- package/dist/dates/constants/TIME_GROUPING_PROPERTY_INFO.d.ts +5 -0
- package/dist/dates/constants/TIME_GROUPING_PROPERTY_INFO.js +28 -0
- package/dist/dates/constants/TIME_GROUPING_PROPERTY_INFO_LIST.d.ts +2 -0
- package/dist/dates/constants/TIME_GROUPING_PROPERTY_INFO_LIST.js +7 -0
- package/dist/dates/constants/TIME_GROUPING_PROPERTY_LABEL.d.ts +5 -0
- package/dist/dates/constants/TIME_GROUPING_PROPERTY_LABEL.js +6 -0
- package/dist/dates/constants/index.d.ts +3 -0
- package/dist/dates/constants/index.js +3 -0
- package/dist/filters/helpers/backend/getBackendGroupValue.js +3 -1
- package/dist/filters/helpers/backend/getBackendProperty.js +2 -1
- package/dist/filters/services/UChartApi.js +6 -2
- package/dist/filters/services/UChartPaginationApi.js +6 -2
- package/dist/format/definition.d.ts +1 -0
- package/dist/format/definition.js +1 -0
- package/dist/format/format.d.ts +12 -0
- package/dist/format/format.js +30 -4
- package/dist/globalization/interfaces/common/II18nColumnProperties.d.ts +3 -0
- package/dist/globalization/labels/common/I18N_COLUMN_LABEL.d.ts +1 -0
- package/dist/globalization/labels/common/I18N_COLUMN_LABEL.js +1 -0
- package/dist/globalization/labels/common/I18N_COLUMN_PROPERTY_LABEL.js +3 -0
- package/dist/qrvey/helpers/transformValue.js +5 -0
- package/package.json +1 -1
|
@@ -46,13 +46,13 @@ export const defineTableChartFormat = (column, settings) => {
|
|
|
46
46
|
if (noFormatSupported) {
|
|
47
47
|
return STRING_FORMAT.NONE;
|
|
48
48
|
}
|
|
49
|
+
if (selectedFormat)
|
|
50
|
+
return selectedFormat;
|
|
49
51
|
if (hasDefaultFormat) {
|
|
50
52
|
const columnDefaultFormat = defaultFormat ||
|
|
51
53
|
outputFormat || { type: "DATE", format: "MM/DD/YYYY" };
|
|
52
54
|
return Object.assign(Object.assign({}, defaultFormat), { format: defaultText, originalFormat: Object.assign({}, columnDefaultFormat), type: "DATE" });
|
|
53
55
|
}
|
|
54
|
-
if (selectedFormat)
|
|
55
|
-
return selectedFormat;
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
case COLUMN.NUMERIC:
|
|
@@ -3,6 +3,7 @@ import { COLUMN } from "../../columns/constants/COLUMN";
|
|
|
3
3
|
import { STANDARD_NUMERIC_FORMATS, } from "../../format/definition";
|
|
4
4
|
import { isEmpty } from "../../general/mix/isEmpty";
|
|
5
5
|
import { CALCULATION_LABEL } from "../../qrvey/constants/CALCULATION_LABEL";
|
|
6
|
+
import { SHELF_TYPE } from "../constants";
|
|
6
7
|
import { CHART_GROUPS } from "../constants/CHART_GROUP";
|
|
7
8
|
import { DATEGROUP_UNSUPPORT_FORMAT } from "../constants/DATEGROUP_UNSUPPORT_FORMAT";
|
|
8
9
|
import { STRING_FORMAT } from "../constants/STRING_FORMAT";
|
|
@@ -15,7 +16,7 @@ import { columnTypeByChart } from "./columnTypeByChart";
|
|
|
15
16
|
* @param {IColumnFormatSettings} settings - IColumnFormatSettings
|
|
16
17
|
*/
|
|
17
18
|
export const defineXYChartFormat = (column, settings) => {
|
|
18
|
-
const { aggregate, type, defaultFormat, outputFormat, selectedFormat, dateGroup, calculation, } = column;
|
|
19
|
+
const { aggregate, type, defaultFormat, outputFormat, selectedFormat, dateGroup, timeGroup, calculation, } = column;
|
|
19
20
|
const { shelfType, withoutFormat } = settings;
|
|
20
21
|
const columnDefaultFormat = defaultFormat || outputFormat;
|
|
21
22
|
//Defaults
|
|
@@ -27,7 +28,7 @@ export const defineXYChartFormat = (column, settings) => {
|
|
|
27
28
|
format: "Percentage" /* LOCALE_FORMATS.PERCENTAGE */,
|
|
28
29
|
};
|
|
29
30
|
const columnType = columnTypeByChart(column, shelfType, CHART_GROUPS.XY);
|
|
30
|
-
const noFormatSupported = DATEGROUP_UNSUPPORT_FORMAT.some((gp) => gp === (dateGroup === null || dateGroup === void 0 ? void 0 : dateGroup.label));
|
|
31
|
+
const noFormatSupported = DATEGROUP_UNSUPPORT_FORMAT.some((gp) => gp === (dateGroup === null || dateGroup === void 0 ? void 0 : dateGroup.label) || gp === (timeGroup === null || timeGroup === void 0 ? void 0 : timeGroup.label));
|
|
31
32
|
const isUsedAsNumericColumn = type !== columnType;
|
|
32
33
|
const columnCurrentFormat = isUsedAsNumericColumn
|
|
33
34
|
? selectedFormat
|
|
@@ -47,6 +48,7 @@ export const defineXYChartFormat = (column, settings) => {
|
|
|
47
48
|
case COLUMN.IMAGE:
|
|
48
49
|
case COLUMN.TEXT_LABEL:
|
|
49
50
|
return STRING_FORMAT.NONE;
|
|
51
|
+
case COLUMN.TIME:
|
|
50
52
|
case COLUMN.DATE: {
|
|
51
53
|
if (noFormatSupported) {
|
|
52
54
|
return STRING_FORMAT.NONE;
|
|
@@ -54,6 +56,11 @@ export const defineXYChartFormat = (column, settings) => {
|
|
|
54
56
|
else if (hasDefaultFormat) {
|
|
55
57
|
return Object.assign(Object.assign({}, columnDefaultFormat), { format: defaultText, originalFormat: Object.assign({}, outputFormat) });
|
|
56
58
|
}
|
|
59
|
+
else if (columnType === COLUMN.TIME &&
|
|
60
|
+
shelfType === SHELF_TYPE.SERIES &&
|
|
61
|
+
(selectedFormat === null || selectedFormat === void 0 ? void 0 : selectedFormat.type) !== COLUMN.TIME) {
|
|
62
|
+
return outputFormat;
|
|
63
|
+
}
|
|
57
64
|
return selectedFormat;
|
|
58
65
|
}
|
|
59
66
|
case COLUMN.NUMERIC:
|
|
@@ -2,12 +2,14 @@ import { IColumnSortingSettings, IColumnType, IFormatOutputFormat, IFormulaType
|
|
|
2
2
|
import { IColumnAggregate } from "../../columns/interfaces/IColumnAggregate";
|
|
3
3
|
import { IColumnDateGroupSettings } from "../../columns/interfaces/IColumnDateGroupSettings";
|
|
4
4
|
import { IColumnScale } from "../../columns/interfaces/IColumnScale";
|
|
5
|
+
import { IColumnTimeGroupSettings } from "../../columns/interfaces/IColumnTimeGroupSettings";
|
|
5
6
|
import { IColumnCalculation } from "../../columns/interfaces/IColunmCalculation";
|
|
6
7
|
import { IFormatDefaultFormat } from "../../interfaces/format/IFormatDefaultFormat";
|
|
7
8
|
export interface IChartColumn {
|
|
8
9
|
aggregate: IColumnAggregate;
|
|
9
10
|
colIndex: number;
|
|
10
11
|
dateGroup?: IColumnDateGroupSettings;
|
|
12
|
+
timeGroup?: IColumnTimeGroupSettings;
|
|
11
13
|
defaultFormat: IFormatDefaultFormat;
|
|
12
14
|
format?: string;
|
|
13
15
|
formulaType?: IFormulaType;
|
|
@@ -41,6 +41,13 @@ export const COLUMN_INFO = Object.assign(Object.assign(Object.assign({ [COLUMN.S
|
|
|
41
41
|
value: COLUMN.DATE,
|
|
42
42
|
displayed: true,
|
|
43
43
|
i18nLabelPath: "common.column_types.date_label",
|
|
44
|
+
}, [COLUMN.TIME]: {
|
|
45
|
+
label: COLUMN_LABEL.TIME,
|
|
46
|
+
shortLabel: "Time",
|
|
47
|
+
abbrLabel: "TI",
|
|
48
|
+
value: COLUMN.TIME,
|
|
49
|
+
displayed: true,
|
|
50
|
+
i18nLabelPath: "common.column_types.time_label",
|
|
44
51
|
}, [COLUMN.SIGNATURE]: {
|
|
45
52
|
label: COLUMN_LABEL.SIGNATURE,
|
|
46
53
|
shortLabel: "Signature",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { COMPLEX_COLUMN_LABEL } from "./COMPLEX_COLUMN_LABEL";
|
|
2
2
|
import { COMPOUND_COLUMN_LABEL } from "./COMPOUND_COLUMN_LABEL";
|
|
3
3
|
import { NUMERICAL_COLUMN_LABEL } from "./NUMERICAL_COLUMN_LABEL";
|
|
4
|
-
export const COLUMN_LABEL = Object.assign(Object.assign(Object.assign({ SINGLE_CHOICE: "Single Choice", MULTIPLE_CHOICE: "Multiple Choice", YES_NO: "Yes No", RANKING: "Ranking", DATE: "Date", SIGNATURE: "Signature", DROPDOWN: "Dropdown", IMAGE: "Image", EMAIL_FORM: "Email Form", PHONE: "Phone", PASSWORD: "Password", CHECKLIST: "Check List", NPS_SCORE: "NPS Score", NPS_FEEDBACK: "NPS Feedback", TEXT: "Text", TEXT_LABEL: "Text Label", TEXT_CATEGORY: "Text Category", LOOKUP: "Lookup", HEADLINE: "Headline", SECTION: "Section", FORMULA: "Formula", AGGREGATED_FORMULA: "Aggregated Formula", BUCKET: "Bucket", STRING: "String" }, NUMERICAL_COLUMN_LABEL), COMPOUND_COLUMN_LABEL), COMPLEX_COLUMN_LABEL);
|
|
4
|
+
export const COLUMN_LABEL = Object.assign(Object.assign(Object.assign({ SINGLE_CHOICE: "Single Choice", MULTIPLE_CHOICE: "Multiple Choice", YES_NO: "Yes No", RANKING: "Ranking", DATE: "Date", TIME: "Time", SIGNATURE: "Signature", DROPDOWN: "Dropdown", IMAGE: "Image", EMAIL_FORM: "Email Form", PHONE: "Phone", PASSWORD: "Password", CHECKLIST: "Check List", NPS_SCORE: "NPS Score", NPS_FEEDBACK: "NPS Feedback", TEXT: "Text", TEXT_LABEL: "Text Label", TEXT_CATEGORY: "Text Category", LOOKUP: "Lookup", HEADLINE: "Headline", SECTION: "Section", FORMULA: "Formula", AGGREGATED_FORMULA: "Aggregated Formula", BUCKET: "Bucket", STRING: "String" }, NUMERICAL_COLUMN_LABEL), COMPOUND_COLUMN_LABEL), COMPLEX_COLUMN_LABEL);
|
|
@@ -28,4 +28,4 @@ export const COLUMN_PROPERTY_INFO = Object.assign(Object.assign({ [COLUMN.LOOKUP
|
|
|
28
28
|
...DATE_GROUPING_TIME_PROPERTY_INFO_LIST,
|
|
29
29
|
...DATE_DISTINCT_PROPERTY_INFO_LIST,
|
|
30
30
|
...DATE_DISTINCT_TIME_PROPERTY_INFO_LIST,
|
|
31
|
-
] }, COMPOUND_COLUMN_PROPERTY_INFO), COMPLEX_COLUMN_PROPERTY_INFO);
|
|
31
|
+
], [COLUMN.TIME]: [...DATE_GROUPING_TIME_PROPERTY_INFO_LIST] }, COMPOUND_COLUMN_PROPERTY_INFO), COMPLEX_COLUMN_PROPERTY_INFO);
|
|
@@ -4,6 +4,7 @@ import { DATE_DISTINCT_PROPERTY_LABEL } from "../../dates/constants/DATE_DISTINC
|
|
|
4
4
|
import { DATE_DISTINCT_TIME_PROPERTY_LABEL } from "../../dates/constants/DATE_DISTINCT_TIME_PROPERTY_LABEL";
|
|
5
5
|
import { COMPLEX_COLUMN_PROPERTY_LABEL } from "./COMPLEX_COLUMN_PROPERTY_LABEL";
|
|
6
6
|
import { COMPOUND_COLUMN_PROPERTY_LABEL } from "./COMPOUND_COLUMN_PROPERTY_LABEL";
|
|
7
|
+
import { TIME_GROUPING_PROPERTY_LABEL } from "../../dates/constants/TIME_GROUPING_PROPERTY_LABEL";
|
|
7
8
|
export declare const COLUMN_PROPERTY_LABEL: {
|
|
8
9
|
NAME_FIRST: COMPOUND_COLUMN_PROPERTY_LABEL.NAME_FIRST;
|
|
9
10
|
NAME_LAST: COMPOUND_COLUMN_PROPERTY_LABEL.NAME_LAST;
|
|
@@ -39,6 +40,9 @@ export declare const COLUMN_PROPERTY_LABEL: {
|
|
|
39
40
|
YEAR_QUARTER: DATE_DISTINCT_PROPERTY_LABEL.YEAR_QUARTER;
|
|
40
41
|
YEAR_MONTH: DATE_DISTINCT_PROPERTY_LABEL.YEAR_MONTH;
|
|
41
42
|
MONTH_DAY: DATE_DISTINCT_PROPERTY_LABEL.MONTH_DAY;
|
|
43
|
+
TIME_HOUR: TIME_GROUPING_PROPERTY_LABEL.TIME_HOUR;
|
|
44
|
+
TIME_MINUTE: TIME_GROUPING_PROPERTY_LABEL.TIME_MINUTE;
|
|
45
|
+
TIME_SECOND: TIME_GROUPING_PROPERTY_LABEL.TIME_SECOND;
|
|
42
46
|
HOUR: DATE_GROUPING_TIME_PROPERTY_LABEL.HOUR;
|
|
43
47
|
MINUTE: DATE_GROUPING_TIME_PROPERTY_LABEL.MINUTE;
|
|
44
48
|
SECOND: DATE_GROUPING_TIME_PROPERTY_LABEL.SECOND;
|
|
@@ -4,4 +4,5 @@ import { DATE_DISTINCT_PROPERTY_LABEL } from "../../dates/constants/DATE_DISTINC
|
|
|
4
4
|
import { DATE_DISTINCT_TIME_PROPERTY_LABEL } from "../../dates/constants/DATE_DISTINCT_TIME_PROPERTY_LABEL";
|
|
5
5
|
import { COMPLEX_COLUMN_PROPERTY_LABEL } from "./COMPLEX_COLUMN_PROPERTY_LABEL";
|
|
6
6
|
import { COMPOUND_COLUMN_PROPERTY_LABEL } from "./COMPOUND_COLUMN_PROPERTY_LABEL";
|
|
7
|
-
|
|
7
|
+
import { TIME_GROUPING_PROPERTY_LABEL } from "../../dates/constants/TIME_GROUPING_PROPERTY_LABEL";
|
|
8
|
+
export const COLUMN_PROPERTY_LABEL = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ IMAGE_ANSWER_ID: "answer_id", LOOKUP_DISPLAY: "display", LOOKUP_VALUE: "value" }, DATE_GROUPING_PROPERTY_LABEL), DATE_GROUPING_TIME_PROPERTY_LABEL), TIME_GROUPING_PROPERTY_LABEL), DATE_DISTINCT_PROPERTY_LABEL), DATE_DISTINCT_TIME_PROPERTY_LABEL), COMPLEX_COLUMN_PROPERTY_LABEL), COMPOUND_COLUMN_PROPERTY_LABEL);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transforms String time from a [H:m:s] format to Date object.
|
|
3
|
+
* @param monthYearDate String of [H:m:s] time
|
|
4
|
+
* @param time Flag to parse the object date to milliseconds.
|
|
5
|
+
* @returns The date object or the date in milliseconds. If the argument is an unexpected time, the function will return the same value
|
|
6
|
+
*/
|
|
7
|
+
export declare function hmsToDate(hmsDate: string, time?: boolean): string | Date | number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
2
|
+
import { isTokenLabel } from "../../tokens/isTokenLabel";
|
|
3
|
+
import { DATE_FORMAT } from "../constants/DATE_FORMAT";
|
|
4
|
+
import { validateDate } from "../helpers/validateDate";
|
|
5
|
+
/**
|
|
6
|
+
* Transforms String time from a [H:m:s] format to Date object.
|
|
7
|
+
* @param monthYearDate String of [H:m:s] time
|
|
8
|
+
* @param time Flag to parse the object date to milliseconds.
|
|
9
|
+
* @returns The date object or the date in milliseconds. If the argument is an unexpected time, the function will return the same value
|
|
10
|
+
*/
|
|
11
|
+
export function hmsToDate(hmsDate, time = false) {
|
|
12
|
+
if (isEmpty(hmsDate) ||
|
|
13
|
+
isTokenLabel(hmsDate) ||
|
|
14
|
+
typeof hmsDate !== "string" ||
|
|
15
|
+
!validateDate(hmsDate, DATE_FORMAT.DAY_TIME))
|
|
16
|
+
return hmsDate;
|
|
17
|
+
const [hour, minute, second] = hmsDate.split(":");
|
|
18
|
+
const start = new Date(0, 0, 0, +hour, +minute, +second);
|
|
19
|
+
return time ? +start : start;
|
|
20
|
+
}
|
|
@@ -4,6 +4,7 @@ export * from "./dateToMonthYear";
|
|
|
4
4
|
export * from "./dateToQuarterYear";
|
|
5
5
|
export * from "./dateToWeekYear";
|
|
6
6
|
export * from "./dateToYear";
|
|
7
|
+
export * from "./hmsToDate";
|
|
7
8
|
export * from "./mdyDateToDate";
|
|
8
9
|
export * from "./monthYearToDate";
|
|
9
10
|
export * from "./quarterYearToDate";
|
|
@@ -4,6 +4,7 @@ export * from "./dateToMonthYear";
|
|
|
4
4
|
export * from "./dateToQuarterYear";
|
|
5
5
|
export * from "./dateToWeekYear";
|
|
6
6
|
export * from "./dateToYear";
|
|
7
|
+
export * from "./hmsToDate";
|
|
7
8
|
export * from "./mdyDateToDate";
|
|
8
9
|
export * from "./monthYearToDate";
|
|
9
10
|
export * from "./quarterYearToDate";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IColumnPropertyInfo } from "../../columns/interfaces/IColumnPropertyInfo";
|
|
2
|
+
import { IColumnPropertyType } from "../../columns/interfaces/IColumnPropertyType";
|
|
3
|
+
export declare const TIME_GROUPING_PROPERTY_INFO: {
|
|
4
|
+
[key in IColumnPropertyType]?: IColumnPropertyInfo;
|
|
5
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DATE_GROUPING_TIME_PROPERTY } from "./DATE_GROUPING_TIME_PROPERTY";
|
|
2
|
+
import { TIME_GROUPING_PROPERTY_LABEL } from "./TIME_GROUPING_PROPERTY_LABEL";
|
|
3
|
+
export const TIME_GROUPING_PROPERTY_INFO = {
|
|
4
|
+
[DATE_GROUPING_TIME_PROPERTY.HOUR]: {
|
|
5
|
+
label: TIME_GROUPING_PROPERTY_LABEL.TIME_HOUR,
|
|
6
|
+
shortLabel: "Full Hour",
|
|
7
|
+
abbrLabel: "F-H",
|
|
8
|
+
value: DATE_GROUPING_TIME_PROPERTY.HOUR,
|
|
9
|
+
displayed: true,
|
|
10
|
+
i18nLabelPath: "common.properties.time_hour_label",
|
|
11
|
+
},
|
|
12
|
+
[DATE_GROUPING_TIME_PROPERTY.MINUTE]: {
|
|
13
|
+
label: TIME_GROUPING_PROPERTY_LABEL.TIME_MINUTE,
|
|
14
|
+
shortLabel: "Full Minute",
|
|
15
|
+
abbrLabel: "F-M",
|
|
16
|
+
value: DATE_GROUPING_TIME_PROPERTY.MINUTE,
|
|
17
|
+
displayed: true,
|
|
18
|
+
i18nLabelPath: "common.properties.time_minute_label",
|
|
19
|
+
},
|
|
20
|
+
[DATE_GROUPING_TIME_PROPERTY.SECOND]: {
|
|
21
|
+
label: TIME_GROUPING_PROPERTY_LABEL.TIME_SECOND,
|
|
22
|
+
shortLabel: "Full Second",
|
|
23
|
+
abbrLabel: "F-S",
|
|
24
|
+
value: DATE_GROUPING_TIME_PROPERTY.SECOND,
|
|
25
|
+
displayed: true,
|
|
26
|
+
i18nLabelPath: "common.properties.time_second_label",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TIME_GROUPING_PROPERTY_INFO } from "./TIME_GROUPING_PROPERTY_INFO";
|
|
2
|
+
import { DATE_GROUPING_TIME_PROPERTY } from "./DATE_GROUPING_TIME_PROPERTY";
|
|
3
|
+
export const TIME_GROUPING_PROPERTY_INFO_LIST = [
|
|
4
|
+
TIME_GROUPING_PROPERTY_INFO[DATE_GROUPING_TIME_PROPERTY.HOUR],
|
|
5
|
+
TIME_GROUPING_PROPERTY_INFO[DATE_GROUPING_TIME_PROPERTY.MINUTE],
|
|
6
|
+
TIME_GROUPING_PROPERTY_INFO[DATE_GROUPING_TIME_PROPERTY.SECOND],
|
|
7
|
+
];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export var TIME_GROUPING_PROPERTY_LABEL;
|
|
2
|
+
(function (TIME_GROUPING_PROPERTY_LABEL) {
|
|
3
|
+
TIME_GROUPING_PROPERTY_LABEL["TIME_HOUR"] = "Full Hour";
|
|
4
|
+
TIME_GROUPING_PROPERTY_LABEL["TIME_MINUTE"] = "Full Minute";
|
|
5
|
+
TIME_GROUPING_PROPERTY_LABEL["TIME_SECOND"] = "Full Second";
|
|
6
|
+
})(TIME_GROUPING_PROPERTY_LABEL || (TIME_GROUPING_PROPERTY_LABEL = {}));
|
|
@@ -38,3 +38,6 @@ export * from "./DATE_YEAR_MONTHS_MMMM";
|
|
|
38
38
|
export * from "./DATE_YEAR_QUARTERS";
|
|
39
39
|
export * from "./DATE_YEAR_QUARTERS_RANGE";
|
|
40
40
|
export * from "./DATETIME_COLUMN_FORMAT";
|
|
41
|
+
export * from "./TIME_GROUPING_PROPERTY_INFO_LIST";
|
|
42
|
+
export * from "./TIME_GROUPING_PROPERTY_INFO";
|
|
43
|
+
export * from "./TIME_GROUPING_PROPERTY_LABEL";
|
|
@@ -38,3 +38,6 @@ export * from "./DATE_YEAR_MONTHS_MMMM";
|
|
|
38
38
|
export * from "./DATE_YEAR_QUARTERS";
|
|
39
39
|
export * from "./DATE_YEAR_QUARTERS_RANGE";
|
|
40
40
|
export * from "./DATETIME_COLUMN_FORMAT";
|
|
41
|
+
export * from "./TIME_GROUPING_PROPERTY_INFO_LIST";
|
|
42
|
+
export * from "./TIME_GROUPING_PROPERTY_INFO";
|
|
43
|
+
export * from "./TIME_GROUPING_PROPERTY_LABEL";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { adaptDateGroupingProperty } from "../../adapters/adaptDateGroupingProperty";
|
|
2
2
|
import { isDateColumn } from "../../../columns/helpers/isDateColumn";
|
|
3
3
|
import { isEmpty } from "../../../general/mix/isEmpty";
|
|
4
|
+
import { COLUMN } from "../../../columns/constants/COLUMN";
|
|
4
5
|
/**
|
|
5
6
|
* Gets a group value for the backend logic structure
|
|
6
7
|
* @param filter The filter
|
|
@@ -8,7 +9,8 @@ import { isEmpty } from "../../../general/mix/isEmpty";
|
|
|
8
9
|
*/
|
|
9
10
|
export function getBackendGroupValue(filter) {
|
|
10
11
|
if (isEmpty(filter.column.aggregate) &&
|
|
11
|
-
isDateColumn(filter.column)
|
|
12
|
+
(isDateColumn(filter.column) ||
|
|
13
|
+
filter.column.type === COLUMN.TIME) &&
|
|
12
14
|
filter.property != null) {
|
|
13
15
|
return adaptDateGroupingProperty(filter.property);
|
|
14
16
|
}
|
|
@@ -11,7 +11,8 @@ import { isNullValidator } from "../common/isNullValidator";
|
|
|
11
11
|
export function getBackendProperty(filter) {
|
|
12
12
|
if (isEmpty(filter.column.aggregate)) {
|
|
13
13
|
if (isNullValidator(filter.validator) ||
|
|
14
|
-
isDateColumn(filter.column)
|
|
14
|
+
isDateColumn(filter.column) ||
|
|
15
|
+
filter.column.type === COLUMN.TIME) {
|
|
15
16
|
return undefined;
|
|
16
17
|
}
|
|
17
18
|
else if (filter.column.type === COLUMN.EXPRESSION &&
|
|
@@ -213,7 +213,9 @@ UChartApi._getSummariesBody = (uFilter) => {
|
|
|
213
213
|
const summary = {
|
|
214
214
|
aggregate: _get(column, "aggregate.label", AGGREGATE.COUNT),
|
|
215
215
|
questionid: column.id,
|
|
216
|
-
property: !isDateColumn(uFilter.column)
|
|
216
|
+
property: !isDateColumn(uFilter.column) && uFilter.column.type !== COLUMN.TIME
|
|
217
|
+
? uFilter.property
|
|
218
|
+
: undefined,
|
|
217
219
|
type: column.type,
|
|
218
220
|
};
|
|
219
221
|
let summaries = [summary];
|
|
@@ -235,7 +237,8 @@ UChartApi._refineBodies = (bodies, uFilter) => {
|
|
|
235
237
|
const _bodies = cloneDeep(bodies);
|
|
236
238
|
if (uFilter.property != null) {
|
|
237
239
|
_bodies.forEach((body) => {
|
|
238
|
-
if (isDateColumn(uFilter.column)
|
|
240
|
+
if (isDateColumn(uFilter.column) ||
|
|
241
|
+
uFilter.column.type === COLUMN.TIME) {
|
|
239
242
|
body.groupType = "DATE";
|
|
240
243
|
body.groupValue = uFilter.property.toUpperCase();
|
|
241
244
|
}
|
|
@@ -255,6 +258,7 @@ UChartApi._refineBodies = (bodies, uFilter) => {
|
|
|
255
258
|
UChartApi._getValidationType = (column, validator) => {
|
|
256
259
|
if (isDateColumn(column) ||
|
|
257
260
|
column.type === COLUMN.BUCKET ||
|
|
261
|
+
column.type === COLUMN.TIME ||
|
|
258
262
|
isNumericalColumn(column)) {
|
|
259
263
|
return FILTER_VALIDATOR.EQUALS;
|
|
260
264
|
}
|
|
@@ -227,7 +227,9 @@ UChartPaginationApi._getSummariesBody = (uFilter) => {
|
|
|
227
227
|
const summary = {
|
|
228
228
|
aggregate: _get(column, "aggregate.label", AGGREGATE.COUNT),
|
|
229
229
|
questionid: column.id,
|
|
230
|
-
property: !isDateColumn(uFilter.column)
|
|
230
|
+
property: !isDateColumn(uFilter.column) && uFilter.column.type !== COLUMN.TIME
|
|
231
|
+
? uFilter.property
|
|
232
|
+
: undefined,
|
|
231
233
|
type: column.type,
|
|
232
234
|
};
|
|
233
235
|
let summaries = [summary];
|
|
@@ -249,7 +251,8 @@ UChartPaginationApi._refineBodies = (bodies, uFilter) => {
|
|
|
249
251
|
const _bodies = cloneDeep(bodies);
|
|
250
252
|
if (uFilter.property != null) {
|
|
251
253
|
_bodies.forEach((body) => {
|
|
252
|
-
if (isDateColumn(uFilter.column)
|
|
254
|
+
if (isDateColumn(uFilter.column) ||
|
|
255
|
+
uFilter.column.type === COLUMN.TIME) {
|
|
253
256
|
body.groupType = "DATE";
|
|
254
257
|
body.groupValue = uFilter.property.toUpperCase();
|
|
255
258
|
}
|
|
@@ -269,6 +272,7 @@ UChartPaginationApi._refineBodies = (bodies, uFilter) => {
|
|
|
269
272
|
UChartPaginationApi._getValidationType = (column, validator) => {
|
|
270
273
|
if (isDateColumn(column) ||
|
|
271
274
|
column.type === COLUMN.BUCKET ||
|
|
275
|
+
column.type === COLUMN.TIME ||
|
|
272
276
|
isNumericalColumn(column)) {
|
|
273
277
|
return FILTER_VALIDATOR.EQUALS;
|
|
274
278
|
}
|
package/dist/format/format.d.ts
CHANGED
|
@@ -6,6 +6,18 @@ export declare function formatAbbreviated(num: any, decimals: any): any;
|
|
|
6
6
|
* @param bytes type number
|
|
7
7
|
*/
|
|
8
8
|
export declare function formatFileSize(bytes: number): string;
|
|
9
|
+
/**
|
|
10
|
+
* It returns true if the given string is a valid time string, and false otherwise
|
|
11
|
+
* @param {string} [timeString] - The time string to validate.
|
|
12
|
+
* @returns A boolean value.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isValidTimeString(timeString?: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* It takes a time string and a format string and returns a formatted time string
|
|
17
|
+
* @param {any} timeString - The time string to be formatted.
|
|
18
|
+
* @param {string} format - The format of the time string.
|
|
19
|
+
*/
|
|
20
|
+
export declare function formatTime(timeString: any, format: string): any;
|
|
9
21
|
export declare const addFormat: (value: any, outputFormat?: any, config?: IFormatConfig) => any;
|
|
10
22
|
export declare const parseFormulaType: (type: string) => "DATE" | "NUMERIC" | "TEXT_LABEL";
|
|
11
23
|
export declare const validateColumnType: (column: any) => any;
|
package/dist/format/format.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { format as d3Format } from "d3";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
|
-
import { DATEGROUP_FORMATTING_UNSUPPORT, appliesFormatting, hasfileSizeProperty, isTextColumn, } from "./definition";
|
|
3
|
+
import { DATEGROUP_FORMATTING_UNSUPPORT, appliesFormatting, hasfileSizeProperty, isTextColumn, DEFAULT_DATE, } from "./definition";
|
|
4
4
|
import isoWeek from "dayjs/plugin/isoWeek";
|
|
5
5
|
import advancedFormat from "dayjs/plugin/advancedFormat";
|
|
6
6
|
import { isEmpty } from "../general/mix/isEmpty";
|
|
@@ -96,18 +96,44 @@ export function formatFileSize(bytes) {
|
|
|
96
96
|
? `${fixDecimals(megaBytes)} MB`
|
|
97
97
|
: `${Math.round(megaBytes)} MB`;
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* It returns true if the given string is a valid time string, and false otherwise
|
|
101
|
+
* @param {string} [timeString] - The time string to validate.
|
|
102
|
+
* @returns A boolean value.
|
|
103
|
+
*/
|
|
104
|
+
export function isValidTimeString(timeString = "") {
|
|
105
|
+
const regex = new RegExp("^(?:[01]\\d|2[0-3]):(?:[0-5]\\d):(?:[0-5]\\d)$", "g");
|
|
106
|
+
return regex.test(timeString);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* It takes a time string and a format string and returns a formatted time string
|
|
110
|
+
* @param {any} timeString - The time string to be formatted.
|
|
111
|
+
* @param {string} format - The format of the time string.
|
|
112
|
+
*/
|
|
113
|
+
export function formatTime(timeString, format) {
|
|
114
|
+
if (!format || isEmpty(timeString) || !isNaN(timeString))
|
|
115
|
+
return timeString;
|
|
116
|
+
if (!isValidTimeString(timeString))
|
|
117
|
+
return timeString;
|
|
118
|
+
return dayjs(`${DEFAULT_DATE} ${timeString}`).format(format.replace("HH24", "HH").replace("MI", "mm").replace("SS", "ss"));
|
|
119
|
+
}
|
|
99
120
|
export const addFormat = (value, outputFormat = "None", config) => {
|
|
100
|
-
var _a, _b;
|
|
121
|
+
var _a, _b, _c, _d;
|
|
101
122
|
if (isEmpty(value) || (typeof value === "object" && isEmpty(value[0])))
|
|
102
123
|
return value;
|
|
103
124
|
switch (outputFormat.type) {
|
|
125
|
+
case "TIME":
|
|
126
|
+
return formatTime(value, (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === "Default" &&
|
|
127
|
+
((_a = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _a === void 0 ? void 0 : _a.format)
|
|
128
|
+
? (_b = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _b === void 0 ? void 0 : _b.format
|
|
129
|
+
: outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format);
|
|
104
130
|
case "DATE":
|
|
105
131
|
case "DATETIME":
|
|
106
132
|
return (config === null || config === void 0 ? void 0 : config.lang) && outputFormat.format === "Default"
|
|
107
133
|
? formatWithLocale(value, outputFormat, config)
|
|
108
134
|
: formatDate(value, (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === "Default" &&
|
|
109
|
-
((
|
|
110
|
-
? (
|
|
135
|
+
((_c = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _c === void 0 ? void 0 : _c.format)
|
|
136
|
+
? (_d = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _d === void 0 ? void 0 : _d.format
|
|
111
137
|
: outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format);
|
|
112
138
|
case "NUMERIC": {
|
|
113
139
|
const parse = parseFloat(value);
|
|
@@ -10,6 +10,9 @@ export interface II18nColumnProperties {
|
|
|
10
10
|
date_hour_label: string;
|
|
11
11
|
date_minute_label: string;
|
|
12
12
|
date_second_label: string;
|
|
13
|
+
time_hour_label: string;
|
|
14
|
+
time_minute_label: string;
|
|
15
|
+
time_second_label: string;
|
|
13
16
|
date_quarter_only_label: string;
|
|
14
17
|
date_month_only_label: string;
|
|
15
18
|
date_day_only_label: string;
|
|
@@ -6,6 +6,7 @@ export const I18N_COLUMN_LABEL = {
|
|
|
6
6
|
yes_no_label: COLUMN_LABEL.YES_NO,
|
|
7
7
|
ranking_label: COLUMN_LABEL.RANKING,
|
|
8
8
|
date_label: COLUMN_LABEL.DATE,
|
|
9
|
+
time_label: COLUMN_LABEL.TIME,
|
|
9
10
|
slidebar_label: COLUMN_LABEL.SLIDEBAR,
|
|
10
11
|
signature_label: COLUMN_LABEL.SIGNATURE,
|
|
11
12
|
dropdown_label: COLUMN_LABEL.DROPDOWN,
|
|
@@ -11,6 +11,9 @@ export const I18N_COLUMN_PROPERTY_LABEL = {
|
|
|
11
11
|
date_hour_label: COLUMN_PROPERTY_LABEL.HOUR,
|
|
12
12
|
date_minute_label: COLUMN_PROPERTY_LABEL.MINUTE,
|
|
13
13
|
date_second_label: COLUMN_PROPERTY_LABEL.SECOND,
|
|
14
|
+
time_hour_label: COLUMN_PROPERTY_LABEL.TIME_HOUR,
|
|
15
|
+
time_minute_label: COLUMN_PROPERTY_LABEL.TIME_MINUTE,
|
|
16
|
+
time_second_label: COLUMN_PROPERTY_LABEL.TIME_SECOND,
|
|
14
17
|
date_quarter_only_label: COLUMN_PROPERTY_LABEL.YEAR_QUARTER,
|
|
15
18
|
date_month_only_label: COLUMN_PROPERTY_LABEL.YEAR_MONTH,
|
|
16
19
|
date_day_only_label: COLUMN_PROPERTY_LABEL.MONTH_DAY,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { COLUMN } from "../../columns/constants/COLUMN";
|
|
1
2
|
import { isDateColumn } from "../../columns/helpers/isDateColumn";
|
|
2
3
|
import { isNumericalColumn } from "../../columns/helpers/isNumericalColumn";
|
|
3
4
|
import { DATE_GROUPING_PROPERTY } from "../../dates/constants/DATE_GROUPING_PROPERTY";
|
|
@@ -39,6 +40,10 @@ function getOutputFormat(settings) {
|
|
|
39
40
|
type = "DATE";
|
|
40
41
|
format = "Default";
|
|
41
42
|
}
|
|
43
|
+
else if (settings.column.type === COLUMN.TIME) {
|
|
44
|
+
type = "TIME";
|
|
45
|
+
format = "Default";
|
|
46
|
+
}
|
|
42
47
|
else if (isNumericalColumn(settings.column)) {
|
|
43
48
|
type = "NUMERIC";
|
|
44
49
|
}
|