UNPKG

@adaptabletools/adaptable

Version:

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

177 lines (176 loc) 7.26 kB
import Helper from '../Helpers/Helper'; import { HOST_URL_DOCS } from '../Constants/DocumentationLinkConstants'; import { ALL_MODULES } from '../../AdaptableState/Common/Types'; export class ModuleService { constructor(adaptableApi) { this.adaptableApi = adaptableApi; this.adaptableApi = adaptableApi; } isModuleAvailable(adaptableModule) { let module = this.getModuleCollection().get(adaptableModule); if (!module) { return false; } return module.isModuleAvailable(); } isModuleName(adaptableModule) { return ALL_MODULES.includes(adaptableModule); } isModuleEditable(adaptableModule) { let module = this.getModuleCollection().get(adaptableModule); if (!module) { return false; } return module.isModuleEditable(); } getModuleFriendlyName(adaptableModule) { return this.getModuleInfoByModule(adaptableModule)?.FriendlyName ?? adaptableModule; } createModuleUIItems() { this.createSettingsPanelItems(); this.createModuleButtonsForDashboardAndToolPanel(); } createSettingsPanelItems() { const settingsPanelItems = []; this.getModuleCollection().forEach((module) => { const settingsPanelMenuItem = module.createModuleMenuItem('ModuleMenu'); if (Helper.objectExists(settingsPanelMenuItem)) { if (settingsPanelItems.findIndex((m) => m.category == settingsPanelMenuItem.category) == -1) { settingsPanelItems.push(settingsPanelMenuItem); } } }); // store Settings Panel items in Internal State as they never change and we often re-use this.adaptableApi.internalApi.setSettingsPanelItems(settingsPanelItems); } createModuleButtonsForDashboardAndToolPanel() { const moduleButtons = []; this.getModuleCollection().forEach((module) => { const moduleButton = module.createModuleMenuItem('ModuleButton'); if (Helper.objectExists(moduleButton)) { if (moduleButtons.findIndex((m) => m.category == moduleButton.category) == -1) { moduleButtons.push(moduleButton); } } }); // store Dashboard Buttons in Internal State as they never change l this.adaptableApi.internalApi.setDashboardModuleButtons(moduleButtons); } getTeamSharingAction(adaptableModule) { let module = this.getModuleCollection().get(adaptableModule); if (!module) { return undefined; } return module.getTeamSharingAction(); } getModuleById(adaptableModule) { // @ts-ignore TODO: make modules generic return this.getModuleCollection().get(adaptableModule); } getModuleInfoByModule(adaptableModule) { const module = this.getModuleById(adaptableModule); return module ? module.moduleInfo : undefined; } getModuleInfoByFriendlyName(friendlyName) { for (let module of this.getModuleCollection().values()) { let moduleInfo = module.moduleInfo; if (moduleInfo && moduleInfo.FriendlyName == friendlyName) { return moduleInfo; } } return undefined; } getPopupMaxWidth(adaptableModule) { return this.getModuleById(adaptableModule)?.getPopupMaxWidth(); } getModuleCollection() { return this.adaptableApi.internalApi.getModules(); } getModuleDocumentationPageByModule(adaptableModule) { let url = `${HOST_URL_DOCS}/`; let learnUrl = url + 'guide/'; switch (adaptableModule) { case 'Alert': return learnUrl + 'handbook-alerting'; case 'BulkUpdate': return url + 'handbook-editing-bulk-update'; case 'CalculatedColumn': return learnUrl + 'handbook-calculated-column'; case 'CellSummary': return learnUrl + 'handbook-summarising'; case 'Charting': return learnUrl + 'handbook-charts'; case 'ColumnFilter': return learnUrl + 'handbook-column-filter'; case 'ColumnInfo': return learnUrl + 'dev-guide-tutorial-grid-column-info'; case 'Comment': return learnUrl + 'handbook-comments'; case 'CustomSort': return learnUrl + 'handbook-sorting-custom'; case 'Dashboard': return learnUrl + 'ui-dashboard'; case 'DataChangeHistory': return learnUrl + 'handbook-monitoring-data-change-history'; case 'DataImport': return learnUrl + 'handbook-importing'; case 'DataSet': return learnUrl + 'handbook-data-sets'; case 'Export': return learnUrl + 'handbook-exporting'; case 'Fdc3': return learnUrl + 'handbook-fdc3'; case 'FlashingCell': return learnUrl + 'handbook-flashing-cell'; case 'FormatColumn': return learnUrl + 'handbook-column-formatting'; case 'FreeTextColumn': return learnUrl + 'handbook-freetext-column'; case 'GridFilter': return learnUrl + 'handbook-grid-filter'; case 'GridInfo': return learnUrl + 'dev-guide-tutorial-grid-column-info'; case 'Layout': return learnUrl + 'handbook-layouts'; case 'NamedQuery': return learnUrl + 'handbook-named-queries'; case 'Note': return learnUrl + 'handbook-notes'; case 'PlusMinus': return learnUrl + 'handbook-editing-plus-minus'; case 'QuickSearch': return learnUrl + 'handbook-quick-search'; case 'Schedule': return learnUrl + 'handbook-scheduling'; case 'SettingsPanel': return learnUrl + 'ui-settings-panel'; case 'Shortcut': return learnUrl + 'handbook-editing-shortcut'; case 'SmartEdit': return learnUrl + 'handbook-editing-smart-edit'; case 'StateManagement': return learnUrl + 'dev-guide-adaptable-state-management'; case 'StatusBar': return learnUrl + 'ui-status-bar'; case 'StyledColumn': return learnUrl + 'handbook-styled-column-overview'; case 'SystemStatus': return learnUrl + 'handbook-system-status-message'; case 'TeamSharing': return learnUrl + 'handbook-team-sharing'; case 'Theme': return learnUrl + 'handbook-theming'; case 'ToolPanel': return learnUrl + 'ui-tool-panel'; case 'IPushPull': return learnUrl + 'integrations-ipushpull'; case 'OpenFin': return learnUrl + 'integrations-openfin'; default: return 'good'; } } destroy() { // TO DO } }