dashboardConfigCacheManager
Reference
- The
dashboardConfigCacheManageris a utility function that retrieve of dashboard configurations, such as filters, sorting, and selected widgets, using local storage. - It is used to retrieve dashboard state for a specific
typeName. - It retrieve previously saved filters, sorting, and selected widgets.
Props
typeName- Type:
string - Description: The name of the data type for which the dashboard configuration is being managed.
- Example:
"Project","Task".
- Type:
Methods
-
hydrateFiltersAndSort(widgetConfig)- Description: Retrieves the saved filters and sorting for a widget. If no cached data exists, it returns the default filters and sorting from
widgetConfig. - Parameters:
widgetConfig: The widget's configuration object.
- Returns: An object with
filterandsort.
- Description: Retrieves the saved filters and sorting for a widget. If no cached data exists, it returns the default filters and sorting from
-
hydrateSelectedWidget()- Description: Retrieves the ID of the previously selected widget from the cache.
- Returns: The ID of the selected widget or
nullif not found.
Usage Example
const typeName = 'Project';
const cacheManager = dashboardConfigCacheManager(typeName);
// Retrieve filters and sorting for a widget
const widgetConfig = { id: 'widget1', stateFilter: 'All', sortBy: 'Name' };
const { filter, sort } = cacheManager.hydrateFiltersAndSort(widgetConfig);
console.log(filter, sort);
// Retrieve the selected widget
const selectedWidget = cacheManager.hydrateSelectedWidget();
console.log(selectedWidget);