@adaptabletools/adaptable-cjs
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
135 lines (134 loc) • 5.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserInterfaceApiImpl = void 0;
const tslib_1 = require("tslib");
const PopupRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/PopupRedux"));
const ArrayExtensions_1 = require("../../Utilities/Extensions/ArrayExtensions");
const WindowPopups_1 = require("../../View/Components/Popups/WindowPopups/WindowPopups");
const UserInterfaceInternalApi_1 = require("../Internal/UserInterfaceInternalApi");
const ApiBase_1 = require("./ApiBase");
const PopupRedux_1 = require("../../Redux/ActionsReducers/PopupRedux");
class UserInterfaceApiImpl extends ApiBase_1.ApiBase {
constructor(_adaptable) {
super(_adaptable);
this.showProgressIndicatorTimeout = null;
this.internalApi = new UserInterfaceInternalApi_1.UserInterfaceInternalApi(_adaptable);
}
getColorPalette() {
let colorPalette = this.getUserInterfaceOptions().colorPalette;
// first do the function then get hardcoded items
if (colorPalette != null && typeof colorPalette === 'function') {
const currentTheme = this.getThemeApi().getCurrentTheme();
const colours = colorPalette(currentTheme);
return colours;
}
else {
let arr = colorPalette;
if (arr && ArrayExtensions_1.ArrayExtensions.IsNotNullOrEmpty(arr)) {
return arr;
}
}
return [];
}
getStyleClassNames() {
return this.getUserInterfaceOptions().styleClassNames;
}
getEditableCellStyle() {
return this.getUserInterfaceOptions().editableCellStyle;
}
getEditedCellStyle() {
return this.getUserInterfaceOptions().editedCellStyle;
}
getReadOnlyCellStyle() {
return this.getUserInterfaceOptions().readOnlyCellStyle;
}
getAdaptableObjectTags() {
const objectTags = this.getUserInterfaceOptions().objectTags;
if (objectTags != null && typeof objectTags === 'function') {
return objectTags(this.getAdaptableInternalApi().buildBaseContext());
}
else {
let arr = objectTags;
if (arr && ArrayExtensions_1.ArrayExtensions.IsNotNullOrEmpty(arr)) {
return arr;
}
}
}
getAdaptableObjectsWithTag(tag, adaptableModule) {
if (adaptableModule) {
const module = this.getAdaptableInternalApi()
.getModuleService()
.getModuleById(adaptableModule);
if (!module) {
return undefined;
}
return module
.getModuleAdaptableObjects()
?.filter((ao) => ao.Tags?.includes(tag));
}
else {
const modules = this.getAdaptableInternalApi().getModules();
let returnObjects = [];
modules.forEach((module) => {
returnObjects.push(...module
.getModuleAdaptableObjects()
?.filter((ao) => ao.Tags?.includes(tag)));
});
return returnObjects;
}
}
getCustomIconDefinition(iconName) {
let customIcon = undefined;
const customIcons = this.getUserInterfaceOptions().customIcons ?? [];
customIcon = customIcons.find((icon) => icon.name === iconName);
if (customIcon) {
return customIcon.icon;
}
return customIcon;
}
showProgressIndicator(config) {
const close = () => {
this.hideProgressIndicator();
};
if (config.delay) {
this.showProgressIndicatorTimeout = setTimeout(() => {
this.dispatchAction((0, PopupRedux_1.ProgressIndicatorShow)(config));
}, config.delay);
}
else {
this.dispatchAction((0, PopupRedux_1.ProgressIndicatorShow)(config));
}
return { close };
}
hideProgressIndicator() {
if (this.showProgressIndicatorTimeout) {
clearTimeout(this.showProgressIndicatorTimeout);
this.showProgressIndicatorTimeout = null;
}
this.dispatchAction((0, PopupRedux_1.ProgressIndicatorHide)());
}
openCustomWindowPopup(config) {
const close = () => {
this.dispatchAction(PopupRedux.PopupHideWindow(config.id));
};
const action = PopupRedux.PopupShowWindow({
Id: config.id,
Title: config.title,
FactoryId: WindowPopups_1.CUSTOM_WINDOW_FACTORY_ID,
PopupProps: {
render: config.render,
frameworkComponent: config.frameworkComponent,
onFrameworkComponentDestroyed: config.onFrameworkComponentDestroyed,
size: config.size,
position: config.position,
},
Icon: config.icon,
});
this.dispatchAction(action);
return { close };
}
closeCustomWindowPopup(windowId) {
this.dispatchAction(PopupRedux.PopupHideWindow(windowId));
}
}
exports.UserInterfaceApiImpl = UserInterfaceApiImpl;