UNPKG

@adaptabletools/adaptable-cjs

Version:

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

96 lines (95 loc) 5.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FormatColumnSummary = exports.FormatColumnSummaryComponent = void 0; const tslib_1 = require("tslib"); const React = tslib_1.__importStar(require("react")); const EditableConfigEntityState_1 = require("../Components/SharedProps/EditableConfigEntityState"); const react_redux_1 = require("react-redux"); const Helper_1 = require("../../Utilities/Helpers/Helper"); const FormatColumnRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/FormatColumnRedux")); const ObjectFactory_1 = require("../../Utilities/ObjectFactory"); const ModuleConstants = tslib_1.__importStar(require("../../Utilities/Constants/ModuleConstants")); const ModuleHeader_1 = require("../Components/ModuleSummary/ModuleHeader"); const ModuleDetail_1 = require("../Components/ModuleSummary/ModuleDetail"); const ModuleProfile_1 = require("../Components/ModuleProfile"); const StyleVisualItem_1 = require("../Components/StyleVisualItem"); const TeamSharingRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/TeamSharingRedux")); const UIHelper_1 = require("../UIHelper"); const FormatColumnWizard_1 = require("./Wizard/FormatColumnWizard"); class FormatColumnSummaryComponent extends React.Component { constructor(props) { super(props); this.onFinishWizard = (formatColumn) => { if (this.props.FormatColumns.find((x) => x.Uuid == formatColumn.Uuid)) { this.props.onEditFormatColumn(formatColumn); } else { this.props.onAddFormatColumn(formatColumn); } this.setState({ editedAdaptableObject: null, wizardStartIndex: 0, wizardStatus: EditableConfigEntityState_1.WizardStatus.None, }); }; this.state = UIHelper_1.UIHelper.getEmptyConfigState(); } render() { const [formatColumn] = this.props.api.formatColumnApi.getFormatColumnsForColumn(this.props.summarisedColumn); let noFormatColumn = formatColumn == null; let formatColumnRow; if (noFormatColumn) { formatColumnRow = (React.createElement(ModuleHeader_1.ModuleHeader, { key: this.props.moduleInfo.FriendlyName, moduleInfo: this.props.moduleInfo, moduleSummary: 'No Format Column Set', onNew: () => this.onNew(), newButtonTooltip: this.props.moduleInfo.FriendlyName, accessLevel: this.props.accessLevel })); } else { formatColumnRow = (React.createElement(ModuleDetail_1.ModuleDetail, { key: this.props.moduleInfo.FriendlyName, item1: React.createElement(ModuleProfile_1.ModuleProfile, { moduleInfo: this.props.moduleInfo }), item2: React.createElement(StyleVisualItem_1.StyleVisualItem, { Style: formatColumn.Style }), configEnity: formatColumn, showShare: this.props.teamSharingActivated, moduleInfo: this.props.moduleInfo, onEdit: () => this.onEdit(formatColumn), onShare: (config) => this.props.onShare(formatColumn, config), onDelete: FormatColumnRedux.FormatColumnDelete(formatColumn), showBold: true, accessLevel: this.props.accessLevel })); } return (React.createElement("div", null, formatColumnRow, this.state.editedAdaptableObject && (React.createElement(FormatColumnWizard_1.FormatColumnWizard, { moduleInfo: this.props.moduleInfo, data: this.state.editedAdaptableObject, configEntities: this.props.FormatColumns, wizardStartIndex: this.state.wizardStartIndex, onCloseWizard: this.onCloseWizard, onFinishWizard: this.onFinishWizard })))); } onNew() { let configEntity = ObjectFactory_1.ObjectFactory.CreateEmptyFormatColumn(); configEntity.Scope = { ColumnIds: [this.props.summarisedColumn.columnId], }; this.setState({ editedAdaptableObject: configEntity, wizardStartIndex: 1, wizardStatus: EditableConfigEntityState_1.WizardStatus.New, }); } onEdit(formatColumn) { let clonedObject = Helper_1.Helper.cloneObject(formatColumn); this.setState({ editedAdaptableObject: clonedObject, wizardStartIndex: 1, wizardStatus: EditableConfigEntityState_1.WizardStatus.Edit, }); } onCloseWizard() { this?.setState?.({ editedAdaptableObject: null, wizardStartIndex: 0, wizardStatus: EditableConfigEntityState_1.WizardStatus.None, }); } canFinishWizard() { let formatColumn = this.state.editedAdaptableObject; return formatColumn.Scope != undefined && UIHelper_1.UIHelper.IsNotEmptyStyle(formatColumn.Style); } } exports.FormatColumnSummaryComponent = FormatColumnSummaryComponent; function mapStateToProps(state, ownProps) { return { FormatColumns: state.FormatColumn.FormatColumns, }; } function mapDispatchToProps(dispatch) { return { onAddFormatColumn: (FormatColumn) => dispatch(FormatColumnRedux.FormatColumnAdd(FormatColumn)), onEditFormatColumn: (FormatColumn) => dispatch(FormatColumnRedux.FormatColumnEdit(FormatColumn)), onShare: (entity, config) => dispatch(TeamSharingRedux.TeamSharingShare(entity, ModuleConstants.FormatColumnModuleId, config)), }; } exports.FormatColumnSummary = (0, react_redux_1.connect)(mapStateToProps, mapDispatchToProps)(FormatColumnSummaryComponent);