UNPKG

@finos/legend-data-cube

Version:
493 lines 18.1 kB
/** * Copyright (c) 2020-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { getDataType, getAggregateOperation, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FONT_BOLD, DEFAULT_FONT_ITALIC, DEFAULT_FONT_UNDERLINED, DEFAULT_FONT_STRIKETHROUGH, DEFAULT_TEXT_ALIGN, DEFAULT_FOREGROUND_COLOR, DEFAULT_NEGATIVE_FOREGROUND_COLOR, DEFAULT_ZERO_FOREGROUND_COLOR, DEFAULT_ERROR_FOREGROUND_COLOR, DEFAULT_BACKGROUND_COLOR, } from '../../core/DataCubeQueryEngine.js'; import {} from '@finos/legend-shared'; import { makeObservable, observable, action, computed } from 'mobx'; import { DataCubeColumnConfiguration, DataCubeConfiguration, DataCubePivotLayoutConfiguration, } from '../../core/model/DataCubeConfiguration.js'; import {} from '../../core/DataCubeSnapshot.js'; import {} from '../../core/aggregation/DataCubeQueryAggregateOperation.js'; export class DataCubeEditorMutableColumnConfiguration extends DataCubeColumnConfiguration { dataType; aggregateOperation; static create(json, snapshot, aggregateOperations) { const configuration = Object.assign(new DataCubeEditorMutableColumnConfiguration('', ''), DataCubeColumnConfiguration.serialization.fromJson(json)); configuration.dataType = getDataType(configuration.type); configuration.aggregateOperation = getAggregateOperation(configuration.aggregateOperator, aggregateOperations); makeObservable(configuration, { kind: observable, setKind: action, displayName: observable, setDisplayName: action, decimals: observable, setDecimals: action, displayCommas: observable, setDisplayCommas: action, negativeNumberInParens: observable, setNegativeNumberInParens: action, numberScale: observable, setNumberScale: action, missingValueDisplayText: observable, setMissingValueDisplayText: action, unit: observable, setUnit: action, fontFamily: observable, setFontFamily: action, fontSize: observable, setFontSize: action, fontBold: observable, setFontBold: action, fontItalic: observable, setFontItalic: action, fontUnderline: observable, setFontUnderline: action, fontStrikethrough: observable, setFontStrikethrough: action, fontCase: observable, setFontCase: action, textAlign: observable, setTextAlign: action, normalForegroundColor: observable, setNormalForegroundColor: action, negativeForegroundColor: observable, setNegativeForegroundColor: action, zeroForegroundColor: observable, setZeroForegroundColor: action, errorForegroundColor: observable, setErrorForegroundColor: action, normalBackgroundColor: observable, setNormalBackgroundColor: action, negativeBackgroundColor: observable, setNegativeBackgroundColor: action, zeroBackgroundColor: observable, setZeroBackgroundColor: action, errorBackgroundColor: observable, setErrorBackgroundColor: action, isSelected: observable, setIsSelected: action, hideFromView: observable, setHideFromView: action, blur: observable, setBlur: action, fixedWidth: observable, setFixedWidth: action, minWidth: observable, setMinWidth: action, maxWidth: observable, setMaxWidth: action, pinned: observable, setPinned: action, displayAsLink: observable, setDisplayAsLink: action, linkLabelParameter: observable, setLinkLabelParameter: action, isUsingDefaultStyling: computed, useDefaultStyling: action, aggregateOperator: observable, aggregateOperation: observable, setAggregateOperation: action, aggregationParameters: observable, setAggregationParameters: action, excludedFromPivot: observable, setExcludedFromPivot: action, pivotSortDirection: observable, setPivotSortDirection: action, pivotStatisticColumnFunction: observable, setPivotStatisticColumnFunction: action, }); return configuration; } get isUsingDefaultStyling() { return (this.fontFamily === undefined && this.fontSize === undefined && this.fontBold === undefined && this.fontItalic === undefined && this.fontUnderline === undefined && this.fontStrikethrough === undefined && this.textAlign === undefined && this.normalForegroundColor === undefined && this.negativeForegroundColor === undefined && this.zeroForegroundColor === undefined && this.errorForegroundColor === undefined && this.normalBackgroundColor === undefined && this.negativeBackgroundColor === undefined && this.zeroBackgroundColor === undefined && this.errorBackgroundColor === undefined); } useDefaultStyling() { this.fontFamily = undefined; this.fontSize = undefined; this.fontBold = undefined; this.fontItalic = undefined; this.fontUnderline = undefined; this.fontStrikethrough = undefined; this.textAlign = undefined; this.normalForegroundColor = undefined; this.negativeForegroundColor = undefined; this.zeroForegroundColor = undefined; this.errorForegroundColor = undefined; this.normalBackgroundColor = undefined; this.negativeBackgroundColor = undefined; this.zeroBackgroundColor = undefined; this.errorBackgroundColor = undefined; } setKind(value) { this.kind = value; } setDisplayName(value) { this.displayName = value; } setDecimals(value) { this.decimals = value; } setDisplayCommas(value) { this.displayCommas = value; } setNegativeNumberInParens(value) { this.negativeNumberInParens = value; } setNumberScale(value) { this.numberScale = value; } setMissingValueDisplayText(value) { this.missingValueDisplayText = value; } setUnit(value) { this.unit = value; } setFontFamily(value) { this.fontFamily = value; } setFontSize(value) { this.fontSize = value; } setFontBold(value) { this.fontBold = value; } setFontItalic(value) { this.fontItalic = value; } setFontUnderline(value) { this.fontUnderline = value; } setFontStrikethrough(value) { this.fontStrikethrough = value; } setFontCase(value) { this.fontCase = value; } setTextAlign(value) { this.textAlign = value; } setNormalForegroundColor(value) { this.normalForegroundColor = value; } setNegativeForegroundColor(value) { this.negativeForegroundColor = value; } setZeroForegroundColor(value) { this.zeroForegroundColor = value; } setErrorForegroundColor(value) { this.errorForegroundColor = value; } setNormalBackgroundColor(value) { this.normalBackgroundColor = value; } setNegativeBackgroundColor(value) { this.negativeBackgroundColor = value; } setZeroBackgroundColor(value) { this.zeroBackgroundColor = value; } setErrorBackgroundColor(value) { this.errorBackgroundColor = value; } setIsSelected(value) { this.isSelected = value; } setHideFromView(value) { this.hideFromView = value; } setBlur(value) { this.blur = value; } setFixedWidth(value) { this.fixedWidth = value; } setMinWidth(value) { this.minWidth = value; } setMaxWidth(value) { this.maxWidth = value; } setPinned(value) { this.pinned = value; } setDisplayAsLink(value) { this.displayAsLink = value; } setLinkLabelParameter(value) { this.linkLabelParameter = value; } setAggregateOperation(value) { this.aggregateOperation = value; this.aggregateOperator = value.operator; } setAggregationParameters(value) { this.aggregationParameters = value; } setExcludedFromPivot(value) { this.excludedFromPivot = value; } setPivotSortDirection(value) { this.pivotSortDirection = value; } setPivotStatisticColumnFunction(value) { this.pivotStatisticColumnFunction = value; } } export class DataCubeEditorMutablePivotLayoutConfiguration extends DataCubePivotLayoutConfiguration { static create(json) { const configuration = Object.assign(new DataCubeEditorMutablePivotLayoutConfiguration(), DataCubePivotLayoutConfiguration.serialization.fromJson(json)); makeObservable(configuration, { expandedPaths: observable, setExpandedPaths: action, }); return configuration; } setExpandedPaths(value) { this.expandedPaths = value; } } export class DataCubeEditorMutableConfiguration extends DataCubeConfiguration { static create(json) { const configuration = Object.assign(new DataCubeEditorMutableConfiguration(), DataCubeConfiguration.serialization.fromJson(json)); configuration.columns = []; makeObservable(configuration, { name: observable, setName: action, description: observable, setDescription: action, showHorizontalGridLines: observable, setShowHorizontalGridLines: action, showVerticalGridLines: observable, setShowVerticalGridLines: action, gridLineColor: observable, setGridLineColor: action, gridMode: observable, setGridMode: action, fontFamily: observable, setFontFamily: action, fontSize: observable, setFontSize: action, fontBold: observable, setFontBold: action, fontItalic: observable, setFontItalic: action, fontUnderline: observable, setFontUnderline: action, fontStrikethrough: observable, setFontStrikethrough: action, fontCase: observable, setFontCase: action, textAlign: observable, setTextAlign: action, normalForegroundColor: observable, setNormalForegroundColor: action, negativeForegroundColor: observable, setNegativeForegroundColor: action, zeroForegroundColor: observable, setZeroForegroundColor: action, errorForegroundColor: observable, setErrorForegroundColor: action, normalBackgroundColor: observable, setNormalBackgroundColor: action, negativeBackgroundColor: observable, setNegativeBackgroundColor: action, zeroBackgroundColor: observable, setZeroBackgroundColor: action, errorBackgroundColor: observable, setErrorBackgroundColor: action, alternateRows: observable, setAlternateRows: action, alternateRowsColor: observable, setAlternateRowsColor: action, alternateRowsCount: observable, setAlternateRowsCount: action, alternateRowsStandardMode: observable, setAlternateRowsStandardMode: action, showSelectionStats: observable, setShowSelectionStats: action, showWarningForTruncatedResult: observable, setShowWarningForTruncatedResult: action, initialExpandLevel: observable, setInitialExpandLevel: action, showRootAggregation: observable, setShowRootAggregation: action, showLeafCount: observable, setShowLeafCount: action, treeColumnSortDirection: observable, setTreeColumnSortDirection: action, pivotStatisticColumnName: observable, setPivotStatisticColumnName: action, pivotStatisticColumnPlacement: observable, setPivotStatisticColumnPlacement: action, isUsingDefaultStyling: computed, useDefaultStyling: action, }); return configuration; } get isUsingDefaultStyling() { return (this.fontFamily === DEFAULT_FONT_FAMILY && this.fontSize === DEFAULT_FONT_SIZE && this.fontBold === DEFAULT_FONT_BOLD && this.fontItalic === DEFAULT_FONT_ITALIC && this.fontUnderline === DEFAULT_FONT_UNDERLINED && this.fontStrikethrough === DEFAULT_FONT_STRIKETHROUGH && this.textAlign === DEFAULT_TEXT_ALIGN && this.normalForegroundColor === DEFAULT_FOREGROUND_COLOR && this.negativeForegroundColor === DEFAULT_NEGATIVE_FOREGROUND_COLOR && this.zeroForegroundColor === DEFAULT_ZERO_FOREGROUND_COLOR && this.errorForegroundColor === DEFAULT_ERROR_FOREGROUND_COLOR && this.normalBackgroundColor === DEFAULT_BACKGROUND_COLOR && this.negativeBackgroundColor === DEFAULT_BACKGROUND_COLOR && this.zeroBackgroundColor === DEFAULT_BACKGROUND_COLOR && this.errorBackgroundColor === DEFAULT_BACKGROUND_COLOR); } useDefaultStyling() { this.fontFamily = DEFAULT_FONT_FAMILY; this.fontSize = DEFAULT_FONT_SIZE; this.fontBold = DEFAULT_FONT_BOLD; this.fontItalic = DEFAULT_FONT_ITALIC; this.fontUnderline = DEFAULT_FONT_UNDERLINED; this.fontStrikethrough = DEFAULT_FONT_STRIKETHROUGH; this.textAlign = DEFAULT_TEXT_ALIGN; this.normalForegroundColor = DEFAULT_FOREGROUND_COLOR; this.negativeForegroundColor = DEFAULT_NEGATIVE_FOREGROUND_COLOR; this.zeroForegroundColor = DEFAULT_ZERO_FOREGROUND_COLOR; this.errorForegroundColor = DEFAULT_ERROR_FOREGROUND_COLOR; this.normalBackgroundColor = DEFAULT_BACKGROUND_COLOR; this.negativeBackgroundColor = DEFAULT_BACKGROUND_COLOR; this.zeroBackgroundColor = DEFAULT_BACKGROUND_COLOR; this.errorBackgroundColor = DEFAULT_BACKGROUND_COLOR; } setName(value) { this.name = value; } setDescription(value) { this.description = value; } setShowHorizontalGridLines(value) { this.showHorizontalGridLines = value; } setShowVerticalGridLines(value) { this.showVerticalGridLines = value; } setGridLineColor(value) { this.gridLineColor = value; } setGridMode(value) { this.gridMode = value; } setFontFamily(value) { this.fontFamily = value; } setFontSize(value) { this.fontSize = value; } setFontBold(value) { this.fontBold = value; } setFontItalic(value) { this.fontItalic = value; } setFontUnderline(value) { this.fontUnderline = value; } setFontStrikethrough(value) { this.fontStrikethrough = value; } setFontCase(value) { this.fontCase = value; } setTextAlign(value) { this.textAlign = value; } setNormalForegroundColor(value) { this.normalForegroundColor = value; } setNegativeForegroundColor(value) { this.negativeForegroundColor = value; } setZeroForegroundColor(value) { this.zeroForegroundColor = value; } setErrorForegroundColor(value) { this.errorForegroundColor = value; } setNormalBackgroundColor(value) { this.normalBackgroundColor = value; } setNegativeBackgroundColor(value) { this.negativeBackgroundColor = value; } setZeroBackgroundColor(value) { this.zeroBackgroundColor = value; } setErrorBackgroundColor(value) { this.errorBackgroundColor = value; } setAlternateRows(value) { this.alternateRows = value; } setAlternateRowsColor(value) { this.alternateRowsColor = value; } setAlternateRowsCount(value) { this.alternateRowsCount = value; } setAlternateRowsStandardMode(value) { this.alternateRowsStandardMode = value; } setShowSelectionStats(value) { this.showSelectionStats = value; } setShowWarningForTruncatedResult(value) { this.showWarningForTruncatedResult = value; } setInitialExpandLevel(value) { this.initialExpandLevel = value; } setShowRootAggregation(value) { this.showRootAggregation = value; } setShowLeafCount(value) { this.showLeafCount = value; } setTreeColumnSortDirection(value) { this.treeColumnSortDirection = value; } setPivotStatisticColumnPlacement(value) { this.pivotStatisticColumnPlacement = value; } setPivotStatisticColumnName(value) { this.pivotStatisticColumnName = value; } setExpandedPaths(value) { this.pivotLayout.expandedPaths = value; } } //# sourceMappingURL=DataCubeEditorMutableConfiguration.js.map