@gooddata/sdk-ui-dashboard 11.42.0 → 11.43.0-alpha.1
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/NOTICE +128 -128
- package/esm/__version.d.ts +1 -1
- package/esm/__version.d.ts.map +1 -1
- package/esm/__version.js +1 -1
- package/esm/index.d.ts +3 -2
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -1
- package/esm/model/commandHandlers/filterContext/dateFilter/removeDateFiltersHandler.d.ts.map +1 -1
- package/esm/model/commandHandlers/filterContext/dateFilter/removeDateFiltersHandler.js +22 -4
- package/esm/model/commandHandlers/scheduledEmail/createScheduledEmailHandler.d.ts.map +1 -1
- package/esm/model/commandHandlers/scheduledEmail/createScheduledEmailHandler.js +3 -1
- package/esm/model/commandHandlers/scheduledEmail/csvRawExecutionDefinition.d.ts +2 -2
- package/esm/model/commandHandlers/scheduledEmail/csvRawExecutionDefinition.d.ts.map +1 -1
- package/esm/model/commandHandlers/scheduledEmail/csvRawExecutionDefinition.js +36 -3
- package/esm/model/commandHandlers/scheduledEmail/saveScheduledEmailHandler.d.ts.map +1 -1
- package/esm/model/commandHandlers/scheduledEmail/saveScheduledEmailHandler.js +3 -1
- package/esm/model/store/executionResults/executionResultsSelectors.d.ts +4 -0
- package/esm/model/store/executionResults/executionResultsSelectors.d.ts.map +1 -1
- package/esm/model/store/executionResults/executionResultsSelectors.js +4 -1
- package/esm/model/store/filtering/dashboardFilterSelectors.d.ts +1 -30
- package/esm/model/store/filtering/dashboardFilterSelectors.d.ts.map +1 -1
- package/esm/model/store/filtering/dashboardFilterSelectors.js +3 -0
- package/esm/model/store/filtering/types.d.ts +33 -0
- package/esm/model/store/filtering/types.d.ts.map +1 -0
- package/esm/model/store/filtering/types.js +2 -0
- package/esm/model/store/tabs/dateFilterConfig/dateFilterConfigSelectors.d.ts +14 -0
- package/esm/model/store/tabs/dateFilterConfig/dateFilterConfigSelectors.d.ts.map +1 -1
- package/esm/model/store/tabs/dateFilterConfig/dateFilterConfigSelectors.js +35 -0
- package/esm/model/store/tabs/parameters/parametersSelectors.d.ts +12 -0
- package/esm/model/store/tabs/parameters/parametersSelectors.d.ts.map +1 -1
- package/esm/model/store/tabs/parameters/parametersSelectors.js +37 -12
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingDialog/DefaultAlertingDialog.d.ts.map +1 -1
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingDialog/DefaultAlertingDialog.js +9 -3
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingManagementDialog/components/PauseAlertRunner.js +1 -1
- package/esm/presentation/automations/connectors/hooks/useBuildAutomationsContext.d.ts +3 -0
- package/esm/presentation/automations/connectors/hooks/useBuildAutomationsContext.d.ts.map +1 -0
- package/esm/presentation/automations/connectors/hooks/useBuildAutomationsContext.js +110 -0
- package/esm/presentation/automations/connectors/hooks/useBuildAutomationsContext.test.d.ts +2 -0
- package/esm/presentation/automations/connectors/hooks/useBuildAutomationsContext.test.d.ts.map +1 -0
- package/esm/presentation/automations/connectors/hooks/useBuildAutomationsContext.test.js +99 -0
- package/esm/presentation/automations/connectors/hooks/useWidgetAutomationFilters.d.ts +4 -0
- package/esm/presentation/automations/connectors/hooks/useWidgetAutomationFilters.d.ts.map +1 -0
- package/esm/presentation/automations/connectors/hooks/useWidgetAutomationFilters.js +46 -0
- package/esm/presentation/automations/contexts/AutomationsContext.d.ts +42 -2
- package/esm/presentation/automations/contexts/AutomationsContext.d.ts.map +1 -1
- package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/DefaultScheduledEmailDialog.d.ts.map +1 -1
- package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/DefaultScheduledEmailDialog.js +8 -2
- package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useEditScheduledEmail.d.ts +1 -1
- package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useEditScheduledEmail.d.ts.map +1 -1
- package/esm/presentation/automations/scheduledEmail/hooks/useWidgetAutomationFilters.d.ts +2 -3
- package/esm/presentation/automations/scheduledEmail/hooks/useWidgetAutomationFilters.d.ts.map +1 -1
- package/esm/presentation/automations/scheduledEmail/hooks/useWidgetAutomationFilters.js +4 -45
- package/esm/presentation/automations/shared/automationFilters/components/AutomationDateFilter.d.ts.map +1 -1
- package/esm/presentation/automations/shared/automationFilters/components/AutomationDateFilter.js +9 -16
- package/esm/presentation/automations/shared/automationFilters/components/AutomationDateFilter.test.d.ts +2 -0
- package/esm/presentation/automations/shared/automationFilters/components/AutomationDateFilter.test.d.ts.map +1 -0
- package/esm/presentation/automations/shared/automationFilters/components/AutomationDateFilter.test.js +131 -0
- package/esm/presentation/automations/shared/automationFilters/components/AutomationFiltersSelect.d.ts +1 -1
- package/esm/presentation/automations/shared/automationFilters/components/AutomationFiltersSelect.d.ts.map +1 -1
- package/esm/presentation/automations/shared/automationFilters/hooks/useAutomationVisibleFilters.d.ts.map +1 -1
- package/esm/presentation/automations/shared/automationFilters/hooks/useAutomationVisibleFilters.js +1 -1
- package/esm/presentation/automations/shared/automationFilters/hooks/useDefaultSelectedFiltersForExistingAutomation.d.ts +1 -1
- package/esm/presentation/automations/shared/automationFilters/hooks/useDefaultSelectedFiltersForExistingAutomation.d.ts.map +1 -1
- package/esm/presentation/automations/shared/automationFilters/hooks/useDefaultSelectedFiltersForExistingAutomation.js +4 -6
- package/esm/presentation/automations/shared/automationFilters/hooks/useDefaultSelectedFiltersForNewAutomation.d.ts +1 -1
- package/esm/presentation/automations/shared/automationFilters/hooks/useDefaultSelectedFiltersForNewAutomation.d.ts.map +1 -1
- package/esm/presentation/automations/shared/automationFilters/hooks/useDefaultSelectedFiltersForNewAutomation.js +3 -4
- package/esm/presentation/automations/shared/automationFilters/hooks/useValidateExistingAutomationFilters.d.ts +1 -1
- package/esm/presentation/automations/shared/automationFilters/hooks/useValidateExistingAutomationFilters.d.ts.map +1 -1
- package/esm/presentation/automations/shared/automationFilters/hooks/useValidateExistingAutomationFilters.js +4 -10
- package/esm/presentation/automations/shared/automationFilters/useAutomationFilters.d.ts +1 -1
- package/esm/presentation/automations/shared/automationFilters/useAutomationFilters.d.ts.map +1 -1
- package/esm/presentation/automations/shared/automationFilters/useAutomationFilters.js +3 -28
- package/esm/presentation/automations/shared/automationFilters/useAutomationFiltersSelect.d.ts +2 -2
- package/esm/presentation/automations/shared/automationFilters/useAutomationFiltersSelect.d.ts.map +1 -1
- package/esm/presentation/automations/shared/automationFilters/useAutomationFiltersSelect.js +2 -5
- package/esm/presentation/automations/shared/automationFilters/utils.d.ts +1 -1
- package/esm/presentation/automations/shared/automationFilters/utils.d.ts.map +1 -1
- package/esm/presentation/automations/shared/dateFilterConfig/dateFilterConfigConverters.d.ts +10 -0
- package/esm/presentation/automations/shared/dateFilterConfig/dateFilterConfigConverters.d.ts.map +1 -0
- package/esm/presentation/automations/shared/dateFilterConfig/dateFilterConfigConverters.js +89 -0
- package/esm/presentation/automations/shared/dateFilterConfig/dateFilterOptionMapping.d.ts +34 -0
- package/esm/presentation/automations/shared/dateFilterConfig/dateFilterOptionMapping.d.ts.map +1 -0
- package/esm/presentation/automations/shared/dateFilterConfig/dateFilterOptionMapping.js +261 -0
- package/esm/presentation/automations/shared/dateFilterConfig/defaultConfig.d.ts +12 -0
- package/esm/presentation/automations/shared/dateFilterConfig/defaultConfig.d.ts.map +1 -0
- package/esm/presentation/automations/shared/dateFilterConfig/defaultConfig.js +437 -0
- package/esm/presentation/automations/shared/exportUtils/filterUtils.d.ts +3 -0
- package/esm/presentation/automations/shared/exportUtils/filterUtils.d.ts.map +1 -0
- package/esm/presentation/automations/shared/exportUtils/filterUtils.js +14 -0
- package/esm/presentation/automations/shared/hooks/useAttributeFilterDisplayFormFromMap.d.ts +3 -0
- package/esm/presentation/automations/shared/hooks/useAttributeFilterDisplayFormFromMap.d.ts.map +1 -0
- package/esm/presentation/automations/shared/hooks/useAttributeFilterDisplayFormFromMap.js +7 -0
- package/esm/presentation/automations/shared/hooks/useCommonDateFilterTitle.d.ts +3 -0
- package/esm/presentation/automations/shared/hooks/useCommonDateFilterTitle.d.ts.map +1 -0
- package/esm/presentation/automations/shared/hooks/useCommonDateFilterTitle.js +6 -0
- package/esm/presentation/automations/shared/hooks/useDateFiltersTitles.d.ts +4 -0
- package/esm/presentation/automations/shared/hooks/useDateFiltersTitles.d.ts.map +1 -0
- package/esm/presentation/automations/shared/hooks/useDateFiltersTitles.js +19 -0
- package/esm/presentation/automations/shared/hooks/useFiltersNamings.d.ts +13 -0
- package/esm/presentation/automations/shared/hooks/useFiltersNamings.d.ts.map +1 -0
- package/esm/presentation/automations/shared/hooks/useFiltersNamings.js +196 -0
- package/esm/presentation/automations/shared/utils/automationUtils.d.ts +24 -0
- package/esm/presentation/automations/shared/utils/automationUtils.d.ts.map +1 -0
- package/esm/presentation/automations/shared/utils/automationUtils.js +135 -0
- package/esm/presentation/automations/shared/utils/filterContextUtils.d.ts +4 -0
- package/esm/presentation/automations/shared/utils/filterContextUtils.d.ts.map +1 -0
- package/esm/presentation/automations/shared/utils/filterContextUtils.js +67 -0
- package/esm/presentation/filterBar/attributeFilter/dashboardDropdownBody/configuration/hooks/useDependentDateFilterConfigurationState.d.ts.map +1 -1
- package/esm/presentation/filterBar/attributeFilter/dashboardDropdownBody/configuration/hooks/useDependentDateFilterConfigurationState.js +34 -16
- package/esm/presentation/filterBar/attributeFilter/dashboardDropdownBody/configuration/hooks/useDependentDateFiltersConfiguration.d.ts.map +1 -1
- package/esm/presentation/filterBar/attributeFilter/dashboardDropdownBody/configuration/hooks/useDependentDateFiltersConfiguration.js +23 -8
- package/esm/presentation/filterBar/attributeFilter/useDependentDateFilters.d.ts.map +1 -1
- package/esm/presentation/filterBar/attributeFilter/useDependentDateFilters.js +17 -6
- package/esm/presentation/topBar/menuButton/DefaultMenuButton.js +1 -1
- package/esm/presentation/widget/insight/ViewModeDashboardInsight/InsightDrillDialog/DrillDialogInsight.d.ts.map +1 -1
- package/esm/presentation/widget/insight/ViewModeDashboardInsight/InsightDrillDialog/DrillDialogInsight.js +11 -2
- package/esm/presentation/widget/insight/configuration/InsightAlertConfig/hooks/useCreateAlert.d.ts.map +1 -0
- package/esm/presentation/widget/insight/configuration/InsightAlertConfig/hooks/useInsightWidgetAlerting.d.ts.map +1 -1
- package/esm/presentation/widget/insight/configuration/InsightAlertConfig/hooks/useInsightWidgetAlerting.js +2 -2
- package/esm/presentation/widget/insight/configuration/InsightAlertConfig/hooks/useSaveAlertToBackend.d.ts.map +1 -0
- package/esm/presentation/widget/insight/configuration/InsightAlertConfig/hooks/useUpdateAlert.d.ts.map +1 -0
- package/esm/presentation/widget/insight/configuration/InsightAlertConfig/hooks/useWidgetAutomationFilters.d.ts +4 -0
- package/esm/presentation/widget/insight/configuration/InsightAlertConfig/hooks/useWidgetAutomationFilters.d.ts.map +1 -0
- package/esm/presentation/widget/insight/configuration/InsightAlertConfig/hooks/useWidgetAutomationFilters.js +46 -0
- package/esm/presentation/widget/insight/configuration/InsightAlertsNew.d.ts.map +1 -1
- package/esm/presentation/widget/insight/configuration/InsightAlertsNew.js +1 -1
- package/esm/presentation/widget/insightMenu/DefaultDashboardInsightMenu/DashboardInsightMenu/DashboardInsightMenuItemButton.d.ts.map +1 -1
- package/esm/presentation/widget/insightMenu/DefaultDashboardInsightMenu/DashboardInsightMenu/DashboardInsightMenuItemButton.js +2 -2
- package/esm/presentation/widget/insightMenu/types.js +1 -1
- package/esm/presentation/widget/widget/warningPartialResult/InsightWidgetWarningPartialResult.d.ts.map +1 -1
- package/esm/presentation/widget/widget/warningPartialResult/InsightWidgetWarningPartialResult.js +1 -1
- package/esm/sdk-ui-dashboard.d.ts +11 -2
- package/esm/tsdoc-metadata.json +1 -1
- package/package.json +20 -20
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingDialog/hooks/useCreateAlert.d.ts.map +0 -1
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingDialog/hooks/useSaveAlertToBackend.d.ts.map +0 -1
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingDialog/hooks/useUpdateAlert.d.ts.map +0 -1
- /package/esm/presentation/{automations/_staging/alerting/DefaultAlertingDialog → widget/insight/configuration/InsightAlertConfig}/hooks/useCreateAlert.d.ts +0 -0
- /package/esm/presentation/{automations/_staging/alerting/DefaultAlertingDialog → widget/insight/configuration/InsightAlertConfig}/hooks/useCreateAlert.js +0 -0
- /package/esm/presentation/{automations/_staging/alerting/DefaultAlertingDialog → widget/insight/configuration/InsightAlertConfig}/hooks/useSaveAlertToBackend.d.ts +0 -0
- /package/esm/presentation/{automations/_staging/alerting/DefaultAlertingDialog → widget/insight/configuration/InsightAlertConfig}/hooks/useSaveAlertToBackend.js +0 -0
- /package/esm/presentation/{automations/_staging/alerting/DefaultAlertingDialog → widget/insight/configuration/InsightAlertConfig}/hooks/useUpdateAlert.d.ts +0 -0
- /package/esm/presentation/{automations/_staging/alerting/DefaultAlertingDialog → widget/insight/configuration/InsightAlertConfig}/hooks/useUpdateAlert.js +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type IDateFilterConfig } from "@gooddata/sdk-model";
|
|
2
|
+
import { type IDateFilterOptionsByType } from "@gooddata/sdk-ui-filters";
|
|
3
|
+
/**
|
|
4
|
+
* Converts date filter config - as stored on the backend - into the date filter options that are aimed for
|
|
5
|
+
* consumption by the actual date filtering view components.
|
|
6
|
+
*
|
|
7
|
+
* @param config - date filter config from backend
|
|
8
|
+
*/
|
|
9
|
+
export declare function convertDateFilterConfigToDateFilterOptions(config: IDateFilterConfig): IDateFilterOptionsByType;
|
|
10
|
+
//# sourceMappingURL=dateFilterConfigConverters.d.ts.map
|
package/esm/presentation/automations/shared/dateFilterConfig/dateFilterConfigConverters.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateFilterConfigConverters.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/automations/shared/dateFilterConfig/dateFilterConfigConverters.ts"],"names":[],"mappings":"AAKA,OAAO,EAIH,KAAK,iBAAiB,EAIzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGH,KAAK,wBAAwB,EAIhC,MAAM,0BAA0B,CAAC;AAKlC;;;;;GAKG;AACH,wBAAgB,0CAA0C,CACtD,MAAM,EAAE,iBAAiB,GAC1B,wBAAwB,CAgB1B"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// (C) 2019-2026 GoodData Corporation
|
|
2
|
+
import { endOfDay, format, startOfDay, subMonths } from "date-fns";
|
|
3
|
+
import { groupBy, isEmpty, max, min } from "lodash-es";
|
|
4
|
+
// TODO: this import was coming from internal/esm and was wrecking tests
|
|
5
|
+
const PLATFORM_DATE_FORMAT = "yyyy-MM-dd HH:mm";
|
|
6
|
+
/**
|
|
7
|
+
* Converts date filter config - as stored on the backend - into the date filter options that are aimed for
|
|
8
|
+
* consumption by the actual date filtering view components.
|
|
9
|
+
*
|
|
10
|
+
* @param config - date filter config from backend
|
|
11
|
+
*/
|
|
12
|
+
export function convertDateFilterConfigToDateFilterOptions(config) {
|
|
13
|
+
const allTime = convertAllTime(config.allTime);
|
|
14
|
+
const emptyValues = convertEmptyValues(config.emptyValues);
|
|
15
|
+
const absoluteForm = convertAbsoluteForm(config.absoluteForm);
|
|
16
|
+
const relativeForm = convertRelativeForm(config.relativeForm);
|
|
17
|
+
const absolutePreset = convertAbsolutePresets(config.absolutePresets);
|
|
18
|
+
const relativePreset = convertRelativePresets(config.relativePresets);
|
|
19
|
+
return removeEmptyKeysFromDateFilterOptions({
|
|
20
|
+
allTime,
|
|
21
|
+
emptyValues,
|
|
22
|
+
absoluteForm,
|
|
23
|
+
absolutePreset,
|
|
24
|
+
relativeForm,
|
|
25
|
+
relativePreset,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function convertAllTime(filter) {
|
|
29
|
+
return (filter && {
|
|
30
|
+
...filter,
|
|
31
|
+
type: "allTime",
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function convertEmptyValues(filter) {
|
|
35
|
+
return (filter && {
|
|
36
|
+
...filter,
|
|
37
|
+
type: "emptyValues",
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function convertAbsoluteForm(filter) {
|
|
41
|
+
return (filter && {
|
|
42
|
+
...filter,
|
|
43
|
+
from: format(startOfDay(subMonths(new Date(), 1)), PLATFORM_DATE_FORMAT),
|
|
44
|
+
to: format(endOfDay(new Date()), PLATFORM_DATE_FORMAT),
|
|
45
|
+
type: "absoluteForm",
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function convertRelativeForm(filter) {
|
|
49
|
+
return (filter && {
|
|
50
|
+
from: undefined,
|
|
51
|
+
// we order the granularities anyway, this lets the user to config the default
|
|
52
|
+
granularity: filter.availableGranularities[0],
|
|
53
|
+
localIdentifier: filter.localIdentifier,
|
|
54
|
+
name: filter.name,
|
|
55
|
+
to: undefined,
|
|
56
|
+
type: "relativeForm",
|
|
57
|
+
visible: filter.visible,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function convertAbsolutePresets(filters) {
|
|
61
|
+
return filters?.map((preset) => sanitizeDateFilterOption({
|
|
62
|
+
...preset,
|
|
63
|
+
type: "absolutePreset",
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
function convertRelativePresets(filters) {
|
|
67
|
+
return (filters &&
|
|
68
|
+
groupBy(filters.map((preset) => sanitizeDateFilterOption({
|
|
69
|
+
...preset,
|
|
70
|
+
type: "relativePreset",
|
|
71
|
+
})), (preset) => preset.granularity));
|
|
72
|
+
}
|
|
73
|
+
function removeEmptyKeysFromDateFilterOptions({ absoluteForm, absolutePreset, allTime, emptyValues, relativeForm, relativePreset, }) {
|
|
74
|
+
return {
|
|
75
|
+
...(allTime && { allTime }),
|
|
76
|
+
...(emptyValues && { emptyValues }),
|
|
77
|
+
...(absoluteForm && { absoluteForm }),
|
|
78
|
+
...(!isEmpty(absolutePreset) && { absolutePreset }),
|
|
79
|
+
...(relativeForm && { relativeForm }),
|
|
80
|
+
...(!isEmpty(relativePreset) && { relativePreset }),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function sanitizeDateFilterOption(option) {
|
|
84
|
+
return {
|
|
85
|
+
...option,
|
|
86
|
+
from: min([option.from, option.to]),
|
|
87
|
+
to: max([option.from, option.to]),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type IDashboardDateFilter } from "@gooddata/sdk-model";
|
|
2
|
+
import { type DateFilterOption, type IDateFilterOptionsByType } from "@gooddata/sdk-ui-filters";
|
|
3
|
+
interface IDateFilterOptionInfo {
|
|
4
|
+
dateFilterOption: DateFilterOption;
|
|
5
|
+
excludeCurrentPeriod: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Tries to match a preset or a form with the provided value. Prioritizes the provided option if possible.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* This is to handle cases when user picked a form and filled values that match an existing preset.
|
|
12
|
+
* In those cases we want to show the form as picked even though a preset would otherwise be preferred.
|
|
13
|
+
*
|
|
14
|
+
* @param dateFilter - value to match against
|
|
15
|
+
* @param availableOptions - date options available
|
|
16
|
+
* @param preferredOptionId - id of the option that should be matched first if possible
|
|
17
|
+
*/
|
|
18
|
+
export declare function matchDateFilterToDateFilterOptionWithPreference(dateFilter: IDashboardDateFilter | undefined, availableOptions: IDateFilterOptionsByType, preferredOptionId: string | undefined): IDateFilterOptionInfo;
|
|
19
|
+
/**
|
|
20
|
+
* Tries to match a preset or a form with the provided value. Prioritizes presets over forms.
|
|
21
|
+
* @param dateFilterValue - value to match against
|
|
22
|
+
* @param availableOptions - date options available
|
|
23
|
+
*/
|
|
24
|
+
export declare function matchDateFilterToDateFilterOption(dateFilter: IDashboardDateFilter | undefined, availableOptions: IDateFilterOptionsByType): IDateFilterOptionInfo;
|
|
25
|
+
/**
|
|
26
|
+
* Flattens the provided date filter options. The flattening maintains a stable, predefined order in which
|
|
27
|
+
* the options should be rendered by the date filter component.
|
|
28
|
+
*
|
|
29
|
+
* @param dateFilterOptions - available options to flatten
|
|
30
|
+
*/
|
|
31
|
+
export declare function flattenDateFilterOptions(dateFilterOptions: IDateFilterOptionsByType): DateFilterOption[];
|
|
32
|
+
export declare function findDateFilterOptionByValue(dateFilter: IDashboardDateFilter, dateFilterOptions: IDateFilterOptionsByType): DateFilterOption | undefined;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=dateFilterOptionMapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateFilterOptionMapping.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/automations/shared/dateFilterConfig/dateFilterOptionMapping.ts"],"names":[],"mappings":"AAIA,OAAO,EAKH,KAAK,oBAAoB,EAM5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAKhC,MAAM,0BAA0B,CAAC;AAUlC,UAAU,qBAAqB;IAC3B,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,oBAAoB,EAAE,OAAO,CAAC;CACjC;AAaD;;;;;;;;;;GAUG;AACH,wBAAgB,+CAA+C,CAC3D,UAAU,EAAE,oBAAoB,GAAG,SAAS,EAC5C,gBAAgB,EAAE,wBAAwB,EAC1C,iBAAiB,EAAE,MAAM,GAAG,SAAS,GACtC,qBAAqB,CAmBvB;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC7C,UAAU,EAAE,oBAAoB,GAAG,SAAS,EAC5C,gBAAgB,EAAE,wBAAwB,GAC3C,qBAAqB,CAqEvB;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,iBAAiB,EAAE,wBAAwB,GAAG,gBAAgB,EAAE,CAmBxG;AAsDD,wBAAgB,2BAA2B,CACvC,UAAU,EAAE,oBAAoB,EAChC,iBAAiB,EAAE,wBAAwB,gCAG9C"}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
// (C) 2021-2026 GoodData Corporation
|
|
2
|
+
import { compact } from "lodash-es";
|
|
3
|
+
import { isAllTimeDashboardDateFilter, isLowerBound, isUpperBound, } from "@gooddata/sdk-model";
|
|
4
|
+
import { isAbsoluteDateFilterOption, isRelativeDateFilterOption, } from "@gooddata/sdk-ui-filters";
|
|
5
|
+
const VIRTUAL_PRESET_IDENTIFIER = "GDC__VIRTUAL_PRESET";
|
|
6
|
+
const virtualPresetBase = {
|
|
7
|
+
localIdentifier: VIRTUAL_PRESET_IDENTIFIER,
|
|
8
|
+
name: "",
|
|
9
|
+
visible: false,
|
|
10
|
+
};
|
|
11
|
+
const isAllTimeDateFilter = (dateFilter) => dateFilter && isAllTimeDashboardDateFilter(dateFilter);
|
|
12
|
+
function applyEmptyValueHandling(dateFilterOption, dateFilter) {
|
|
13
|
+
const emptyValueHandling = dateFilter?.dateFilter.emptyValueHandling;
|
|
14
|
+
return emptyValueHandling ? { ...dateFilterOption, emptyValueHandling } : dateFilterOption;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Tries to match a preset or a form with the provided value. Prioritizes the provided option if possible.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* This is to handle cases when user picked a form and filled values that match an existing preset.
|
|
21
|
+
* In those cases we want to show the form as picked even though a preset would otherwise be preferred.
|
|
22
|
+
*
|
|
23
|
+
* @param dateFilter - value to match against
|
|
24
|
+
* @param availableOptions - date options available
|
|
25
|
+
* @param preferredOptionId - id of the option that should be matched first if possible
|
|
26
|
+
*/
|
|
27
|
+
export function matchDateFilterToDateFilterOptionWithPreference(dateFilter, availableOptions, preferredOptionId) {
|
|
28
|
+
const preferredOption = preferredOptionId
|
|
29
|
+
? findDateFilterOptionById(preferredOptionId, availableOptions)
|
|
30
|
+
: undefined;
|
|
31
|
+
const isAllTime = isAllTimeDateFilter(dateFilter);
|
|
32
|
+
// we only really need to handle the cases when the selected option is a form
|
|
33
|
+
// other cases are correctly handled by the unbiased matching function
|
|
34
|
+
if (dateFilter &&
|
|
35
|
+
!isAllTime &&
|
|
36
|
+
(preferredOption?.type === "absoluteForm" || preferredOption?.type === "relativeForm") &&
|
|
37
|
+
canReconstructFormForStoredFilter(availableOptions, dateFilter)) {
|
|
38
|
+
return reconstructFormForStoredFilter(availableOptions, dateFilter);
|
|
39
|
+
}
|
|
40
|
+
return matchDateFilterToDateFilterOption(dateFilter, availableOptions);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Tries to match a preset or a form with the provided value. Prioritizes presets over forms.
|
|
44
|
+
* @param dateFilterValue - value to match against
|
|
45
|
+
* @param availableOptions - date options available
|
|
46
|
+
*/
|
|
47
|
+
export function matchDateFilterToDateFilterOption(dateFilter, availableOptions) {
|
|
48
|
+
// no value means common All Time, try matching against All time (if it is available) or create virtual preset for it
|
|
49
|
+
const isAllTime = isAllTimeDateFilter(dateFilter);
|
|
50
|
+
if (!dateFilter || isAllTime) {
|
|
51
|
+
const emptyValueHandling = dateFilter?.dateFilter.emptyValueHandling;
|
|
52
|
+
if (emptyValueHandling === "only") {
|
|
53
|
+
const { emptyValues: emptyValuesOption } = availableOptions;
|
|
54
|
+
if (isDateFilterOptionVisible(emptyValuesOption)) {
|
|
55
|
+
return {
|
|
56
|
+
dateFilterOption: { ...emptyValuesOption, emptyValueHandling: "only" },
|
|
57
|
+
excludeCurrentPeriod: false,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const { allTime } = availableOptions;
|
|
62
|
+
if (allTime) {
|
|
63
|
+
return {
|
|
64
|
+
dateFilterOption: applyEmptyValueHandling(allTime, dateFilter),
|
|
65
|
+
excludeCurrentPeriod: false,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const virtual = createVirtualPresetForStoredFilter(undefined);
|
|
69
|
+
return {
|
|
70
|
+
...virtual,
|
|
71
|
+
dateFilterOption: applyEmptyValueHandling(virtual.dateFilterOption, dateFilter),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
// try matching the filter as is
|
|
75
|
+
const matchingFilter = findDateFilterOptionByValue(dateFilter, availableOptions);
|
|
76
|
+
if (matchingFilter) {
|
|
77
|
+
return {
|
|
78
|
+
dateFilterOption: applyEmptyValueHandling(matchingFilter, dateFilter),
|
|
79
|
+
excludeCurrentPeriod: false,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
// try matching the filter with excludeCurrentPeriod === true, but only for relativeFormPresets
|
|
83
|
+
if (dateFilter.dateFilter.type === "relative" && dateFilter.dateFilter.to?.toString() === "-1") {
|
|
84
|
+
const filterToMatch = {
|
|
85
|
+
dateFilter: {
|
|
86
|
+
...dateFilter.dateFilter,
|
|
87
|
+
from: Number.parseInt(dateFilter.dateFilter.from.toString(), 10) + 1,
|
|
88
|
+
to: 0,
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
const matchingFilter = findDateFilterOptionByValueAndType(filterToMatch, availableOptions, "relativePreset");
|
|
92
|
+
if (matchingFilter) {
|
|
93
|
+
return {
|
|
94
|
+
dateFilterOption: applyEmptyValueHandling(matchingFilter, dateFilter),
|
|
95
|
+
excludeCurrentPeriod: true,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// the stored filter must be a form with custom values
|
|
100
|
+
if (canReconstructFormForStoredFilter(availableOptions, dateFilter)) {
|
|
101
|
+
return reconstructFormForStoredFilter(availableOptions, dateFilter);
|
|
102
|
+
}
|
|
103
|
+
// we cannot use the form because it is disabled or otherwise incompatible
|
|
104
|
+
// -> we must create a virtual hidden preset
|
|
105
|
+
const virtual = createVirtualPresetForStoredFilter(dateFilter);
|
|
106
|
+
return { ...virtual, dateFilterOption: applyEmptyValueHandling(virtual.dateFilterOption, dateFilter) };
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Flattens the provided date filter options. The flattening maintains a stable, predefined order in which
|
|
110
|
+
* the options should be rendered by the date filter component.
|
|
111
|
+
*
|
|
112
|
+
* @param dateFilterOptions - available options to flatten
|
|
113
|
+
*/
|
|
114
|
+
export function flattenDateFilterOptions(dateFilterOptions) {
|
|
115
|
+
const relativePresets = Object.values((dateFilterOptions.relativePreset ?? {})).flat();
|
|
116
|
+
// the order is significant here
|
|
117
|
+
// the first visible filter is selected for new dashboards if none is specified in config
|
|
118
|
+
return compact([
|
|
119
|
+
dateFilterOptions.allTime,
|
|
120
|
+
dateFilterOptions.emptyValues,
|
|
121
|
+
...(dateFilterOptions.absolutePreset || []),
|
|
122
|
+
...relativePresets,
|
|
123
|
+
dateFilterOptions.absoluteForm,
|
|
124
|
+
dateFilterOptions.relativeForm,
|
|
125
|
+
]);
|
|
126
|
+
}
|
|
127
|
+
function canReconstructFormForStoredFilter(options, dateFilter) {
|
|
128
|
+
switch (dateFilter.dateFilter.type) {
|
|
129
|
+
case "absolute":
|
|
130
|
+
return isDateFilterOptionVisible(options.absoluteForm);
|
|
131
|
+
case "relative":
|
|
132
|
+
return isDateFilterOptionVisible(options.relativeForm);
|
|
133
|
+
default:
|
|
134
|
+
throw new Error("Unknown dateFilterValue type");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function reconstructFormForStoredFilter(options, dateFilter) {
|
|
138
|
+
if (dateFilter.dateFilter.type === "absolute") {
|
|
139
|
+
const dateFilterOption = {
|
|
140
|
+
...options.absoluteForm,
|
|
141
|
+
from: dateFilter.dateFilter.from.toString(),
|
|
142
|
+
to: dateFilter.dateFilter.to.toString(),
|
|
143
|
+
type: "absoluteForm",
|
|
144
|
+
...(dateFilter.dateFilter.emptyValueHandling
|
|
145
|
+
? { emptyValueHandling: dateFilter.dateFilter.emptyValueHandling }
|
|
146
|
+
: {}),
|
|
147
|
+
};
|
|
148
|
+
return { dateFilterOption, excludeCurrentPeriod: false };
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
const dateFilterOption = {
|
|
152
|
+
...options.relativeForm,
|
|
153
|
+
from: Number.parseInt(dateFilter.dateFilter.from.toString(), 10),
|
|
154
|
+
to: Number.parseInt(dateFilter.dateFilter.to.toString(), 10),
|
|
155
|
+
granularity: dateFilter.dateFilter.granularity,
|
|
156
|
+
type: "relativeForm",
|
|
157
|
+
...(dateFilter.dateFilter.emptyValueHandling
|
|
158
|
+
? { emptyValueHandling: dateFilter.dateFilter.emptyValueHandling }
|
|
159
|
+
: {}),
|
|
160
|
+
};
|
|
161
|
+
return { dateFilterOption, excludeCurrentPeriod: false };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function isDateFilterOptionVisible(option) {
|
|
165
|
+
return !!option?.visible;
|
|
166
|
+
}
|
|
167
|
+
function findDateFilterOptionById(id, dateFilterOptions) {
|
|
168
|
+
return flattenDateFilterOptions(dateFilterOptions).find((option) => option.localIdentifier === id);
|
|
169
|
+
}
|
|
170
|
+
export function findDateFilterOptionByValue(dateFilter, dateFilterOptions) {
|
|
171
|
+
return flattenDateFilterOptions(dateFilterOptions).find(filterMatchesData(dateFilter));
|
|
172
|
+
}
|
|
173
|
+
function findDateFilterOptionByValueAndType(dateFilter, dateFilterOptions, type) {
|
|
174
|
+
return flattenDateFilterOptions(dateFilterOptions)
|
|
175
|
+
.filter((option) => option.type === type)
|
|
176
|
+
.find(filterMatchesData(dateFilter));
|
|
177
|
+
}
|
|
178
|
+
const filterMatchesData = (dateFilter) => (filter) => {
|
|
179
|
+
if (!filter) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
const data = dateFilter.dateFilter;
|
|
183
|
+
if (isAbsoluteDateFilterOption(filter)) {
|
|
184
|
+
return data.type === "absolute" && filter.from === data.from && filter.to === data.to;
|
|
185
|
+
}
|
|
186
|
+
if (isRelativeDateFilterOption(filter)) {
|
|
187
|
+
// Check if boundedFilter properties match exactly
|
|
188
|
+
const boundedFiltersMatch = (() => {
|
|
189
|
+
// If both don't have boundedFilter, they match
|
|
190
|
+
if (!filter.boundedFilter && !data.boundedFilter) {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
// If only one has boundedFilter, they don't match
|
|
194
|
+
if (!filter.boundedFilter || !data.boundedFilter) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
// Both have boundedFilter - check granularity first
|
|
198
|
+
if (filter.boundedFilter.granularity !== data.boundedFilter.granularity) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
// Both must be the same type (both lower or both upper)
|
|
202
|
+
if (isLowerBound(filter.boundedFilter) && isLowerBound(data.boundedFilter)) {
|
|
203
|
+
return filter.boundedFilter.from === data.boundedFilter.from;
|
|
204
|
+
}
|
|
205
|
+
else if (isUpperBound(filter.boundedFilter) && isUpperBound(data.boundedFilter)) {
|
|
206
|
+
return filter.boundedFilter.to === data.boundedFilter.to;
|
|
207
|
+
}
|
|
208
|
+
// Different bound types don't match
|
|
209
|
+
return false;
|
|
210
|
+
})();
|
|
211
|
+
return (data.type === "relative" &&
|
|
212
|
+
filter.from?.toString() === data.from?.toString() &&
|
|
213
|
+
filter.to?.toString() === data.to?.toString() &&
|
|
214
|
+
filter.granularity === data.granularity &&
|
|
215
|
+
boundedFiltersMatch);
|
|
216
|
+
}
|
|
217
|
+
return false;
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Creates a virtual preset with values corresponding to a provided server-side value.
|
|
221
|
+
* This is used in situations when a dashboard was saved with setting
|
|
222
|
+
* that can no longer be reproduced by the available options (e.g. relativeForm was used and later, was disabled)
|
|
223
|
+
*/
|
|
224
|
+
function createVirtualPresetForStoredFilter(dateFilter) {
|
|
225
|
+
if (!dateFilter) {
|
|
226
|
+
const dateFilterOption = {
|
|
227
|
+
...virtualPresetBase,
|
|
228
|
+
type: "allTime",
|
|
229
|
+
};
|
|
230
|
+
return { dateFilterOption, excludeCurrentPeriod: false };
|
|
231
|
+
}
|
|
232
|
+
const { type, from, to, granularity } = dateFilter.dateFilter;
|
|
233
|
+
if (type === "absolute") {
|
|
234
|
+
const dateFilterOption = {
|
|
235
|
+
...virtualPresetBase,
|
|
236
|
+
from: from.toString(),
|
|
237
|
+
to: to.toString(),
|
|
238
|
+
type: "absolutePreset",
|
|
239
|
+
...(dateFilter.dateFilter.emptyValueHandling
|
|
240
|
+
? { emptyValueHandling: dateFilter.dateFilter.emptyValueHandling }
|
|
241
|
+
: {}),
|
|
242
|
+
};
|
|
243
|
+
return { dateFilterOption, excludeCurrentPeriod: false };
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
const dateFilterOption = {
|
|
247
|
+
...virtualPresetBase,
|
|
248
|
+
from: Number.parseInt(from.toString(), 10),
|
|
249
|
+
to: Number.parseInt(to.toString(), 10),
|
|
250
|
+
granularity,
|
|
251
|
+
type: "relativePreset",
|
|
252
|
+
...(dateFilter.dateFilter.boundedFilter
|
|
253
|
+
? { boundedFilter: dateFilter.dateFilter.boundedFilter }
|
|
254
|
+
: {}),
|
|
255
|
+
...(dateFilter.dateFilter.emptyValueHandling
|
|
256
|
+
? { emptyValueHandling: dateFilter.dateFilter.emptyValueHandling }
|
|
257
|
+
: {}),
|
|
258
|
+
};
|
|
259
|
+
return { dateFilterOption, excludeCurrentPeriod: false };
|
|
260
|
+
}
|
|
261
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type IDateFilterConfig } from "@gooddata/sdk-model";
|
|
2
|
+
/**
|
|
3
|
+
* Default date filter preset for standard calendar.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_DATE_FILTER_PRESET = "THIS_MONTH";
|
|
6
|
+
/**
|
|
7
|
+
* Default date filter preset for fiscal calendar.
|
|
8
|
+
* Used when fiscal calendar is set as the default calendar type.
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEFAULT_FISCAL_DATE_FILTER_PRESET = "THIS_FISCAL_MONTH";
|
|
11
|
+
export declare const defaultDateFilterConfig: IDateFilterConfig;
|
|
12
|
+
//# sourceMappingURL=defaultConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultConfig.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/automations/shared/dateFilterConfig/defaultConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,iBAAiB,EAAS,MAAM,qBAAqB,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,0BAA0B,eAAe,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,iCAAiC,sBAAsB,CAAC;AAErE,eAAO,MAAM,uBAAuB,EAAE,iBAyarC,CAAC"}
|