UNPKG

@adaptabletools/adaptable

Version:

Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

349 lines (348 loc) 12.4 kB
import * as GeneralConstants from '../Utilities/Constants/GeneralConstants'; import { getGraySwatchColor, getSwatchColorVar } from '../View/UIHelper'; import { ACCESS_LEVEL_FULL, EMPTY_STRING, EMPTY_ARRAY, DEFAULT_DATE_FORMAT_PATTERN_WITH_TIME, SYSTEM_REPORT_NAMES, SYSTEM_REPORT_FORMATS, SYSTEM_EXPORT_DESTINATIONS, } from '../Utilities/Constants/GeneralConstants'; import { SystemAlertPredicateIds, SystemBadgeStylePredicateIds, SystemFilterPredicateIds, SystemFlashingCellPredicateIds, SystemFormatColumnPredicateIds, } from '../AdaptableState/Common/AdaptablePredicate'; import * as ModuleConstants from '../Utilities/Constants/ModuleConstants'; import { addUuidsToInitialState } from '../Utilities/Helpers/AdaptableHelper'; import { defaultsDeep } from '../Utilities/Extensions/ObjectExtensions'; const DefaultAdaptableOptions = { adaptableId: GeneralConstants.ADAPTABLE_ID, adaptableStateKey: undefined, primaryKey: EMPTY_STRING, autogeneratePrimaryKey: false, userName: 'anonymous', initialState: undefined, adaptableContext: {}, actionColumnOptions: { actionColumns: undefined, }, alertOptions: { alertForms: undefined, maxAlertsInStore: 20, cellHighlightDuration: 2000, rowHighlightDuration: 4000, statusbarHighlightDuration: 2000, dataChangeDetectionPolicy: 'rawValue', commandHandlers: undefined, alertMessageText: undefined, showMissingPrimaryKeyAlert: false, alertMessageHeader: undefined, }, calendarOptions: { holidays: undefined }, cellSummaryOptions: { customCellSummaryOperations: undefined, numericDisplayFormat: { FractionDigits: 2, }, }, chartingOptions: { saveChartBehaviour: 'none', agGridContainerName: GeneralConstants.AG_GRID_CHART_WINDOW, externalChartingOptions: {}, chartContainers: undefined, }, columnOptions: { columnFriendlyName: undefined, columnTypes: EMPTY_ARRAY, showMissingColumnsWarning: true, addColumnGroupToColumnFriendlyName: false, columnHeader: undefined, }, columnMenuOptions: { customColumnMenu: undefined, }, commentOptions: { showPopupCloseButton: true, dateFormat: DEFAULT_DATE_FORMAT_PATTERN_WITH_TIME, isCellCommentable: undefined, loadCommentThreads: undefined, persistCommentThreads: undefined, showCommentAction: 'hover', }, containerOptions: { adaptableContainer: 'adaptable', agGridContainer: 'grid', modalContainer: undefined, systemStatusContainer: undefined, alertContainer: undefined, transposedViewContainer: undefined, }, contextMenuOptions: { customContextMenu: undefined, }, customSortOptions: { customSortComparers: undefined }, dashboardOptions: { canFloat: true, showQuickSearchInHeader: true, customDashboardButtons: undefined, customToolbars: undefined, buttonsLocation: 'right', }, dataChangeHistoryOptions: { activeByDefault: false, showDataChange: undefined, changeHistoryButton: undefined, showLastDataChangeOnly: true, maxDataChangesInStore: undefined, }, dataImportOptions: { fileHandlers: undefined, textHandler: undefined, validate: undefined, handleImportedData: undefined, }, dataSetOptions: { dataSets: EMPTY_ARRAY }, editOptions: { validateOnServer: undefined, displayServerValidationMessages: true, isCellEditable: undefined, smartEditOptions: { customOperations: undefined, }, customEditColumnValues: undefined, showSelectCellEditor: undefined, plusMinusOptions: { incrementKey: '+', decrementKey: '-', }, }, entitlementOptions: { defaultAccessLevel: ACCESS_LEVEL_FULL, moduleEntitlements: undefined, }, exportOptions: { exportDataFormat: 'rawValue', exportDateFormat: undefined, customDestinations: undefined, processExport: undefined, appendFileTimestamp: false, systemReportNames: SYSTEM_REPORT_NAMES, systemReportFormats: SYSTEM_REPORT_FORMATS, systemExportDestinations: SYSTEM_EXPORT_DESTINATIONS, reportFilename: undefined, csvSeparator: ',', skipColumnHeaders: false, excelSheetName: 'Sheet 1', isColumnExportable: undefined, getDetailRows: undefined, }, expressionOptions: { evaluateAdaptableQLExternally: undefined, displayColumnFriendlyNamesForExpressions: true, systemBooleanFunctions: undefined, systemScalarFunctions: undefined, systemObservableFunctions: undefined, systemAggregatedBooleanFunctions: undefined, systemAggregatedScalarFunctions: undefined, moduleExpressionFunctions: undefined, performExpressionValidation: true, maxTimeframeSize: 28800000, caseSensitiveExpressions: false, customAggregatedFunctions: undefined, customBooleanFunctions: undefined, customQueryVariables: undefined, customScalarFunctions: undefined, fields: undefined, isColumnQueryable: undefined, }, fdc3Options: { enableLogging: false, actionColumnDefaultConfiguration: { columnId: 'fdc3ActionColumn', headerName: 'FDC3 Actions', width: 200, resizable: true, movable: false, rowScope: { ExcludeDataRows: false, ExcludeGroupRows: true, ExcludeSummaryRows: true, ExcludeTotalRows: true, }, }, uiControlsDefaultConfiguration: { contexts: {}, intents: {}, }, }, filterOptions: { clearFiltersOnStartUp: false, enableFilterOnSpecialColumns: true, useAdaptableFiltering: true, showDatePicker: true, isRowFilterable: undefined, customInFilterValues: undefined, columnFilterOptions: { indicateFilteredColumns: true, manuallyApplyColumnFilter: false, defaultNumericColumnFilter: 'Equals', defaultTextColumnFilter: 'Contains', defaultDateColumnFilter: 'On', defaultArrayColumnFilter: 'In', hideQuickFilterDropdown: undefined, quickFilterDebounce: 250, quickFilterHeight: null, showQuickFilter: true, quickFilterWildcards: {}, }, gridFilterOptions: { availableFilterEditors: ['ExpressionEditor', 'QueryBuilder'], }, }, flashingCellOptions: { defaultFlashDuration: 500, defaultFlashTarget: 'cell', defaultDownChangeStyle: { BackColor: getSwatchColorVar(18), }, defaultUpChangeStyle: { BackColor: getSwatchColorVar(7), }, defaultNeutralChangeStyle: { BackColor: getGraySwatchColor(), }, }, formatColumnOptions: { customDisplayFormatters: undefined, }, layoutOptions: { layoutCreationDefaultProperties: undefined, pivotPreviewColumns: undefined, layoutViewOptions: { maxColumnsToDisplay: 10, }, layoutTagOptions: { autoGenerateTagsForLayouts: false, isObjectExtendedInLayout: undefined, autoCheckTagsForLayouts: false, }, }, noteOptions: { showPopupCloseButton: true, dateFormat: DEFAULT_DATE_FORMAT_PATTERN_WITH_TIME, isCellNotable: undefined, showNoteAction: 'hover', }, notificationsOptions: { maxNotifications: 3, position: 'BottomRight', duration: 3000, showProgressBar: false, closeWhenClicked: false, pauseWhenHovering: false, isDraggable: false, transition: 'Slide', showApplicationIcon: false, showSystemStatusMessageNotifications: false, maxSystemMessagesInStore: 100, }, predicateOptions: { customPredicateDefs: [], systemFilterPredicates: SystemFilterPredicateIds, systemAlertPredicates: SystemAlertPredicateIds, systemFormatColumnPredicates: SystemFormatColumnPredicateIds, systemFlashingCellPredicates: SystemFlashingCellPredicateIds, systemBadgeStylePredicates: SystemBadgeStylePredicateIds, caseSensitivePredicates: false, evaluateInPredicateUsingTime: false, }, quickSearchOptions: { clearQuickSearchOnStartUp: false, quickSearchPlaceholder: 'Search', filterGridAfterQuickSearch: false, isQuickSearchCaseSensitive: false, getCellSearchText: undefined, isCellSearchable: undefined, }, rowFormOptions: { autoHandle: true, disableInlineEditing: false, setPrimaryKeyValue: undefined, rowFormTitle: undefined, rowFormDescription: undefined, rowFormFieldLabel: undefined, rowFormButtons: undefined, onRowFormSubmit: undefined, includeColumnInRowForm: undefined, }, settingsPanelOptions: { popupType: 'modal', title: ModuleConstants.SettingsPanelFriendlyName, icon: 'ConfigurationIcon', alwaysShowInDashboard: false, alwaysShowInToolPanel: false, showModuleIcons: true, position: undefined, size: undefined, customSettingsPanels: undefined, gridInfoTabs: ['Grid Options', 'Grid Summary', 'Grid State'], }, wizardOptions: { popupType: undefined, position: undefined, size: undefined, }, stateOptions: { debounceStateDelay: 400, applyState: (state) => state, saveState: (state) => state, loadState: undefined, persistState: undefined, clearState: undefined, autoMigrateState: true, }, teamSharingOptions: { enableTeamSharing: false, persistSharedEntities: undefined, loadSharedEntities: undefined, applySharedEntities: (sharedEntities) => sharedEntities, saveSharedEntities: (sharedEntities) => sharedEntities, updateInterval: 0, updateNotification: undefined, suppressOverrideConfigWarning: false, showUpdateNotificationOncePerUpdate: false, }, toolPanelOptions: { showToolPanelsDropdown: true, customButtons: undefined, customToolPanels: undefined, }, userInterfaceOptions: { alternativeModuleNames: undefined, applicationIcon: undefined, useCustomMacLikeScrollbars: false, customIcons: undefined, objectTags: undefined, loadingScreenOptions: { showLoadingScreen: true, loadingScreenDelay: 200, loadingScreenTitle: 'Initialising Grid', loadingScreenText: 'Retrieving your settings and setting up the grid...', }, englishVariant: 'GB', disableDeleteConfirmation: false, dateInputOptions: { useNativeInput: false, dateFormat: 'yyyy-MM-dd', showWeekNumber: false, showOutsideDays: true, datepickerButtons: ['close', 'today'], }, editableCellStyle: undefined, readOnlyCellStyle: undefined, editedCellStyle: undefined, styleClassNames: EMPTY_ARRAY, showDocumentationLinks: true, showAdapTableVersion: true, showAgGridVersion: true, }, }; export function applyDefaultAdaptableOptions(adaptableOptions) { const adaptableOptsWithDefaults = defaultsDeep({ ...adaptableOptions }, DefaultAdaptableOptions); adaptableOptsWithDefaults.adaptableStateKey = adaptableOptsWithDefaults.adaptableStateKey ?? adaptableOptsWithDefaults.adaptableId; const { initialState } = adaptableOptsWithDefaults; adaptableOptsWithDefaults.initialState = addUuidsToInitialState(initialState); return adaptableOptsWithDefaults; } export const getDefaultAdaptableOptions = () => DefaultAdaptableOptions;