dashboardConfigCacheManager
Reference
dashboardConfigCacheManagersaves and restores a user's choices on a type dashboard: the filters and sort applied to each widget, the selected widget and the selected template.- The choices are saved in the browser, separately from the dashboard configuration. A new dashboard configuration from the server does not wipe them.
- When an admin changes a widget (its title, columns, filters or any other setting), the choices made on that widget are reset to the widget's defaults. Choices on the other widgets are kept.
- Choices are kept until the user signs out.
Parameters
-
typeName- Type:
string - Description: The name of the type whose dashboard is being managed.
- Example:
"Project","Task".
- Type:
-
isDashboardV2(optional)- Type:
boolean, defaultfalse - Description:
truefor a Design Studio dashboard (layout templates),falsefor an older type dashboard.
- Type:
Methods
| Method | Description | Returns |
|---|---|---|
hydrateFiltersAndSort(widgetConfig) | The saved filters and sort for the widget (widgetConfig.templateWidgetKey or widgetConfig.id). When nothing is saved, or the widget was changed, the defaults from widgetConfig. | { filter, sort } |
persistFilters(widgetId, filters) | Saves the applied filters for a widget. Ignored when the widget is not in the dashboard configuration. | — |
persistSort(widgetId, sort) | Saves the applied sort ({ sortBy, isSortByDescending }) for a widget. | — |
persistSelectedWidget(widgetId) | Saves the selected widget. | — |
hydrateSelectedWidget() | The saved selected widget. Nothing is returned when the widget was changed or removed. | Widget id, undefined, or null when no configuration is loaded |
persistSelectedTemplate(templateName) | Saves the selected template (Design Studio dashboards). | — |
hydrateSelectedTemplate() | The saved selected template, while that template still exists. | Template name, undefined, or null when no configuration is loaded |
getCachedTypeConfig() | The dashboard configuration with the user's choices merged in: appliedFilters and appliedSort on each widget, plus selectedWidgetId and selectedTemplateName. A new object on every call. | Configuration object, or null |
Usage Example
const cacheManager = dashboardConfigCacheManager("Project");
// Restore filters and sort for a widget (defaults come from widgetConfig)
const widgetConfig = { id: "widget1", stateFilter: "All", sortBy: "Name" };
const { filter, sort } = cacheManager.hydrateFiltersAndSort(widgetConfig);
// Save the user's changes
cacheManager.persistFilters("widget1", { ...filter, stateFilter: "Open" });
cacheManager.persistSort("widget1", {
sortBy: "Name",
isSortByDescending: true,
});
// Restore the selected widget
const selectedWidgetId = cacheManager.hydrateSelectedWidget();