@mwater/visualization 5.4.0 → 5.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ColorComponent.js +2 -1
- package/lib/IdSelection.d.ts +16 -0
- package/lib/IdSelection.js +59 -0
- package/lib/MWaterAddRelatedIndicatorComponent.js +2 -2
- package/lib/MWaterCompleteTableSelectComponent.d.ts +3 -8
- package/lib/MWaterCompleteTableSelectComponent.js +36 -42
- package/lib/MWaterLoaderComponent.d.ts +11 -10
- package/lib/MWaterLoaderComponent.js +1 -1
- package/lib/MWaterResponsesFilterComponent.js +1 -1
- package/lib/MWaterTableSelectComponent.d.ts +0 -1
- package/lib/MWaterTableSelectComponent.js +4 -6
- package/lib/autotranslate.d.ts +20 -0
- package/lib/autotranslate.js +122 -0
- package/lib/axes/AxisBuilder.js +3 -3
- package/lib/axes/AxisColorEditorComponent.js +4 -0
- package/lib/axes/AxisComponent.d.ts +8 -12
- package/lib/axes/AxisComponent.js +32 -80
- package/lib/axes/CategoryMapComponent.js +4 -4
- package/lib/axes/RangesComponent.js +2 -2
- package/lib/dashboards/DashboardComponent.d.ts +6 -0
- package/lib/dashboards/DashboardComponent.js +44 -12
- package/lib/dashboards/DashboardDesign.d.ts +11 -2
- package/lib/dashboards/DashboardUtils.d.ts +5 -0
- package/lib/dashboards/DashboardUtils.js +30 -0
- package/lib/dashboards/DashboardViewComponent.d.ts +2 -0
- package/lib/dashboards/DashboardViewComponent.js +16 -3
- package/lib/dashboards/ServerDashboardDataSource.js +2 -1
- package/lib/dashboards/SettingsModalComponent.d.ts +1 -1
- package/lib/dashboards/SettingsModalComponent.js +256 -19
- package/lib/dashboards/WidgetComponent.d.ts +6 -3
- package/lib/dashboards/WidgetComponent.js +3 -1
- package/lib/datagrids/CellEditor.d.ts +19 -0
- package/lib/datagrids/CellEditor.js +223 -0
- package/lib/datagrids/DatagridComponent.d.ts +18 -87
- package/lib/datagrids/DatagridComponent.js +304 -222
- package/lib/datagrids/DatagridViewComponent.d.ts +15 -53
- package/lib/datagrids/DatagridViewComponent.js +256 -257
- package/lib/datagrids/DirectDatagridDataSource.js +2 -3
- package/lib/datagrids/ExprCellComponent.d.ts +8 -15
- package/lib/datagrids/ExprCellComponent.js +11 -15
- package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -6
- package/lib/datagrids/FindReplaceModalComponent.js +38 -75
- package/lib/index.css +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/layouts/blocks/HorizontalBlockComponent.js +2 -2
- package/lib/mWaterLoader.d.ts +1 -1
- package/lib/maps/BufferLayer.d.ts +7 -5
- package/lib/maps/BufferLayer.js +69 -48
- package/lib/maps/BufferLayerDesign.d.ts +21 -14
- package/lib/maps/BufferLayerDesignerComponent.d.ts +16 -31
- package/lib/maps/BufferLayerDesignerComponent.js +68 -102
- package/lib/maps/ChoroplethLayer.d.ts +5 -4
- package/lib/maps/ChoroplethLayer.js +32 -9
- package/lib/maps/ChoroplethLayerDesign.d.ts +6 -2
- package/lib/maps/ChoroplethLayerDesigner.js +4 -2
- package/lib/maps/ClusterLayer.d.ts +3 -4
- package/lib/maps/ClusterLayer.js +2 -1
- package/lib/maps/DetailLevelSelectComponent.js +1 -1
- package/lib/maps/DirectMapDataSource.js +2 -1
- package/lib/maps/EditPopupComponent.js +5 -3
- package/lib/maps/GridLayer.d.ts +3 -4
- package/lib/maps/GridLayer.js +2 -1
- package/lib/maps/GridLayerDesigner.js +5 -3
- package/lib/maps/HoverContent.d.ts +11 -3
- package/lib/maps/HoverContent.js +25 -9
- package/lib/maps/Layer.d.ts +24 -3
- package/lib/maps/Layer.js +5 -1
- package/lib/maps/LayerFactory.js +0 -8
- package/lib/maps/LayerLegendComponent.js +0 -1
- package/lib/maps/LayerSwitcherComponent.d.ts +1 -0
- package/lib/maps/LayerSwitcherComponent.js +1 -1
- package/lib/maps/LeafletMapComponent.js +3 -1
- package/lib/maps/LegendComponent.d.ts +1 -0
- package/lib/maps/LegendComponent.js +9 -1
- package/lib/maps/MWaterServerLayer.d.ts +2 -2
- package/lib/maps/MWaterServerLayer.js +2 -2
- package/lib/maps/MapComponent.js +3 -3
- package/lib/maps/MapDesign.d.ts +2 -0
- package/lib/maps/MapDesignerComponent.d.ts +4 -3
- package/lib/maps/MapDesignerComponent.js +68 -74
- package/lib/maps/MapLayerViewDesignerComponent.js +2 -2
- package/lib/maps/MapUtils.d.ts +4 -0
- package/lib/maps/MapUtils.js +19 -0
- package/lib/maps/MapViewComponent.d.ts +8 -3
- package/lib/maps/MarkersLayer.d.ts +5 -4
- package/lib/maps/MarkersLayer.js +33 -7
- package/lib/maps/MarkersLayerDesign.d.ts +19 -16
- package/lib/maps/PopupFilterJoinsUtils.d.ts +6 -3
- package/lib/maps/PopupFilterJoinsUtils.js +0 -6
- package/lib/maps/RasterMapViewComponent.d.ts +3 -31
- package/lib/maps/RasterMapViewComponent.js +7 -2
- package/lib/maps/ServerMapDataSource.js +2 -1
- package/lib/maps/SwitchableTileUrlLayer.d.ts +3 -3
- package/lib/maps/SwitchableTileUrlLayer.js +2 -1
- package/lib/maps/TileUrlLayer.d.ts +4 -5
- package/lib/maps/TileUrlLayer.js +2 -1
- package/lib/maps/VectorMapViewComponent.d.ts +5 -37
- package/lib/maps/VectorMapViewComponent.js +19 -8
- package/lib/maps/maps.d.ts +3 -0
- package/lib/quickfilter/QuickfiltersComponent.d.ts +2 -0
- package/lib/quickfilter/QuickfiltersComponent.js +9 -7
- package/lib/quickfilter/QuickfiltersDesignComponent.d.ts +1 -1
- package/lib/quickfilter/QuickfiltersDesignComponent.js +19 -35
- package/lib/richtext/ExprItemsHtmlConverter.d.ts +5 -2
- package/lib/richtext/ExprItemsHtmlConverter.js +4 -4
- package/lib/richtext/ExprItemsTranslator.d.ts +5 -0
- package/lib/richtext/ExprItemsTranslator.js +149 -0
- package/lib/richtext/ItemsHtmlConverter.d.ts +1 -1
- package/lib/richtext/ItemsHtmlConverter.js +31 -15
- package/lib/wellknown.js +12 -9
- package/lib/widgets/IFrameWidget.d.ts +4 -4
- package/lib/widgets/ImageWidget.d.ts +7 -4
- package/lib/widgets/ImageWidget.js +9 -1
- package/lib/widgets/ImageWidgetComponent.d.ts +1 -0
- package/lib/widgets/ImageWidgetComponent.js +1 -1
- package/lib/widgets/MapWidget.d.ts +5 -48
- package/lib/widgets/MapWidget.js +26 -63
- package/lib/widgets/MarkdownWidget.d.ts +3 -0
- package/lib/widgets/MarkdownWidget.js +3 -0
- package/lib/widgets/TOCWidget.d.ts +15 -27
- package/lib/widgets/TOCWidget.js +107 -183
- package/lib/widgets/Widget.d.ts +18 -7
- package/lib/widgets/Widget.js +4 -0
- package/lib/widgets/WidgetScopesViewComponent.js +1 -1
- package/lib/widgets/charts/Chart.d.ts +10 -1
- package/lib/widgets/charts/Chart.js +22 -11
- package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartViewComponent.js +6 -3
- package/lib/widgets/charts/ChartWidget.d.ts +2 -0
- package/lib/widgets/charts/ChartWidget.js +9 -1
- package/lib/widgets/charts/ChartWidgetComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartWidgetComponent.js +2 -2
- package/lib/widgets/charts/calendar/CalendarChart.d.ts +1 -0
- package/lib/widgets/charts/calendar/CalendarChart.js +26 -0
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +3 -1
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.d.ts +1 -0
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.js +8 -0
- package/lib/widgets/charts/layered/LayeredChart.d.ts +2 -0
- package/lib/widgets/charts/layered/LayeredChart.js +63 -3
- package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +1 -1
- package/lib/widgets/charts/layered/LayeredChartCompiler.js +3 -3
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/layered/LayeredChartViewComponent.js +8 -3
- package/lib/widgets/charts/pivot/PivotChart.d.ts +1 -0
- package/lib/widgets/charts/pivot/PivotChart.js +63 -0
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +1 -0
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +1 -1
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +6 -0
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.js +7 -4
- package/lib/widgets/charts/table/OrderingsComponent.js +1 -1
- package/lib/widgets/charts/table/TableChart.d.ts +1 -0
- package/lib/widgets/charts/table/TableChart.js +15 -0
- package/lib/widgets/text/TextComponent.d.ts +11 -4
- package/lib/widgets/text/TextComponent.js +11 -8
- package/lib/widgets/text/TextWidget.d.ts +6 -3
- package/lib/widgets/text/TextWidget.js +7 -1
- package/lib/widgets/text/TextWidgetComponent.d.ts +4 -0
- package/lib/widgets/text/TextWidgetComponent.js +7 -1
- package/lib/widgets/text/TextWidgetDesign.d.ts +2 -4
- package/lib/widgets/text/TextWidgetDesign.js +1 -1
- package/package.json +7 -8
- package/src/ColorComponent.tsx +1 -2
- package/src/IdSelection.ts +62 -0
- package/src/MWaterAddRelatedIndicatorComponent.ts +3 -2
- package/src/MWaterCompleteTableSelectComponent.tsx +36 -46
- package/src/MWaterLoaderComponent.ts +28 -26
- package/src/MWaterResponsesFilterComponent.ts +5 -2
- package/src/MWaterTableSelectComponent.tsx +5 -9
- package/src/autotranslate.ts +141 -0
- package/src/axes/AxisBuilder.ts +3 -3
- package/src/axes/AxisColorEditorComponent.tsx +5 -0
- package/src/axes/{AxisComponent.ts → AxisComponent.tsx} +106 -106
- package/src/axes/CategoryMapComponent.ts +4 -4
- package/src/axes/RangesComponent.ts +3 -2
- package/src/dashboards/DashboardComponent.tsx +79 -14
- package/src/dashboards/DashboardDesign.ts +9 -2
- package/src/dashboards/DashboardUtils.ts +39 -0
- package/src/dashboards/DashboardViewComponent.tsx +22 -3
- package/src/dashboards/ServerDashboardDataSource.ts +2 -1
- package/src/dashboards/SettingsModalComponent.tsx +450 -35
- package/src/dashboards/WidgetComponent.tsx +12 -6
- package/src/datagrids/CellEditor.tsx +354 -0
- package/src/datagrids/DatagridComponent.tsx +646 -0
- package/src/datagrids/DatagridViewComponent.tsx +539 -0
- package/src/datagrids/DirectDatagridDataSource.ts +2 -3
- package/src/datagrids/{ExprCellComponent.ts → ExprCellComponent.tsx} +28 -23
- package/src/datagrids/{FindReplaceModalComponent.ts → FindReplaceModalComponent.tsx} +109 -122
- package/src/index.css +1 -1
- package/src/index.ts +0 -1
- package/src/layouts/blocks/HorizontalBlockComponent.ts +2 -2
- package/src/mWaterLoader.ts +1 -1
- package/src/maps/BufferLayer.ts +83 -60
- package/src/maps/BufferLayerDesign.ts +20 -14
- package/src/maps/BufferLayerDesignerComponent.tsx +309 -0
- package/src/maps/ChoroplethLayer.ts +40 -19
- package/src/maps/ChoroplethLayerDesign.ts +4 -2
- package/src/maps/ChoroplethLayerDesigner.tsx +4 -2
- package/src/maps/ClusterLayer.ts +4 -10
- package/src/maps/DetailLevelSelectComponent.ts +1 -1
- package/src/maps/DirectMapDataSource.ts +2 -1
- package/src/maps/EditPopupComponent.ts +7 -3
- package/src/maps/GridLayer.ts +4 -10
- package/src/maps/GridLayerDesigner.tsx +5 -3
- package/src/maps/HoverContent.tsx +40 -16
- package/src/maps/Layer.ts +28 -10
- package/src/maps/LayerFactory.ts +0 -8
- package/src/maps/LayerLegendComponent.ts +2 -4
- package/src/maps/LayerSwitcherComponent.tsx +6 -2
- package/src/maps/LeafletMapComponent.tsx +3 -1
- package/src/maps/LegendComponent.tsx +10 -1
- package/src/maps/MWaterServerLayer.ts +3 -3
- package/src/maps/MapComponent.ts +3 -3
- package/src/maps/MapDesign.ts +3 -0
- package/src/maps/MapDesignerComponent.tsx +165 -162
- package/src/maps/MapLayerViewDesignerComponent.ts +2 -2
- package/src/maps/MapUtils.ts +24 -0
- package/src/maps/MapViewComponent.tsx +11 -3
- package/src/maps/MarkersLayer.ts +44 -18
- package/src/maps/MarkersLayerDesign.ts +19 -16
- package/src/maps/PopupFilterJoinsUtils.ts +6 -2
- package/src/maps/RasterMapViewComponent.ts +9 -45
- package/src/maps/ServerMapDataSource.ts +2 -2
- package/src/maps/SwitchableTileUrlLayer.tsx +4 -10
- package/src/maps/TileUrlLayer.tsx +4 -10
- package/src/maps/VectorMapViewComponent.tsx +28 -55
- package/src/maps/maps.ts +3 -0
- package/src/quickfilter/QuickfiltersComponent.ts +13 -7
- package/src/quickfilter/QuickfiltersDesignComponent.tsx +56 -74
- package/src/richtext/ExprItemsHtmlConverter.ts +9 -5
- package/src/richtext/ExprItemsTranslator.ts +176 -0
- package/src/richtext/ItemsHtmlConverter.ts +33 -18
- package/src/wellknown.ts +33 -30
- package/src/widgets/ImageWidget.ts +10 -1
- package/src/widgets/ImageWidgetComponent.ts +3 -2
- package/src/widgets/{MapWidget.ts → MapWidget.tsx} +90 -101
- package/src/widgets/MarkdownWidget.ts +3 -0
- package/src/widgets/TOCWidget.tsx +281 -0
- package/src/widgets/Widget.ts +25 -5
- package/src/widgets/WidgetScopesViewComponent.ts +2 -1
- package/src/widgets/charts/Chart.ts +31 -12
- package/src/widgets/charts/ChartViewComponent.ts +13 -3
- package/src/widgets/charts/ChartWidget.ts +11 -1
- package/src/widgets/charts/ChartWidgetComponent.tsx +9 -1
- package/src/widgets/charts/calendar/CalendarChart.ts +29 -0
- package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +3 -1
- package/src/widgets/charts/imagemosaic/ImageMosaicChart.ts +9 -0
- package/src/widgets/charts/layered/LayeredChart.ts +71 -3
- package/src/widgets/charts/layered/LayeredChartCompiler.ts +4 -4
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +4 -2
- package/src/widgets/charts/layered/LayeredChartViewComponent.ts +10 -4
- package/src/widgets/charts/pivot/PivotChart.ts +73 -0
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +1 -1
- package/src/widgets/charts/pivot/SegmentDesignerComponent.tsx +6 -4
- package/src/widgets/charts/table/OrderingsComponent.tsx +2 -1
- package/src/widgets/charts/table/TableChart.ts +17 -0
- package/src/widgets/text/TextComponent.tsx +22 -12
- package/src/widgets/text/TextWidget.ts +9 -2
- package/src/widgets/text/TextWidgetComponent.tsx +16 -1
- package/src/widgets/text/TextWidgetDesign.ts +4 -7
- package/test/IdSelectionTests.ts +54 -0
- package/test/LayeredChartCompilerTests.ts +0 -2
- package/test/richtext/ExprItemsTranslatorTests.ts +144 -0
- package/test/wellknownTests.ts +144 -0
- package/src/datagrids/DatagridComponent.ts +0 -478
- package/src/datagrids/DatagridViewComponent.ts +0 -464
- package/src/datagrids/EditExprCellComponent.tsx +0 -305
- package/src/datagrids/README.md +0 -3
- package/src/maps/BufferLayerDesignerComponent.ts +0 -311
- package/src/widgets/TOCWidget.ts +0 -326
- package/test/LegoLayoutEngineTests.ts +0 -69
|
@@ -1,478 +0,0 @@
|
|
|
1
|
-
import _ from "lodash"
|
|
2
|
-
import React, { ReactNode } from "react"
|
|
3
|
-
const R = React.createElement
|
|
4
|
-
|
|
5
|
-
import AutoSizeComponent from "@mwater/react-library/lib/AutoSizeComponent"
|
|
6
|
-
import ActionCancelModalComponent from "@mwater/react-library/lib/ActionCancelModalComponent"
|
|
7
|
-
import { DataSource, Expr, ExprUtils, Schema } from "@mwater/expressions"
|
|
8
|
-
import { ExprCompiler } from "@mwater/expressions"
|
|
9
|
-
import { ExprCleaner } from "@mwater/expressions"
|
|
10
|
-
import DatagridViewComponent, { RowUpdate } from "./DatagridViewComponent"
|
|
11
|
-
import DatagridDesignerComponent from "./DatagridDesignerComponent"
|
|
12
|
-
import DatagridUtils from "./DatagridUtils"
|
|
13
|
-
|
|
14
|
-
import QuickfiltersComponent from "../quickfilter/QuickfiltersComponent"
|
|
15
|
-
import QuickfilterCompiler from "../quickfilter/QuickfilterCompiler"
|
|
16
|
-
import FindReplaceModalComponent from "./FindReplaceModalComponent"
|
|
17
|
-
import DatagridDataSource from "./DatagridDataSource"
|
|
18
|
-
import { DatagridDesign, JsonQLFilter } from ".."
|
|
19
|
-
import { format as d3Format } from "d3-format"
|
|
20
|
-
import { LocaleContext } from "@mwater/expressions-ui"
|
|
21
|
-
|
|
22
|
-
export interface DatagridComponentProps {
|
|
23
|
-
/** schema to use */
|
|
24
|
-
schema: Schema
|
|
25
|
-
|
|
26
|
-
/** dataSource to use */
|
|
27
|
-
dataSource: DataSource
|
|
28
|
-
|
|
29
|
-
/** datagrid dataSource to use */
|
|
30
|
-
datagridDataSource: DatagridDataSource
|
|
31
|
-
|
|
32
|
-
design: DatagridDesign
|
|
33
|
-
/** Called when design changes */
|
|
34
|
-
onDesignChange?: (design: DatagridDesign) => void
|
|
35
|
-
|
|
36
|
-
/** Extra element to include in title at left */
|
|
37
|
-
titleElem?: ReactNode
|
|
38
|
-
/** Extra elements to add to right */
|
|
39
|
-
extraTitleButtonsElem?: ReactNode
|
|
40
|
-
|
|
41
|
-
/** Check if a value is editable by testing if underlying expression is editable */
|
|
42
|
-
canEditExpr?: (tableId: string, rowId: any, expr: Expr) => Promise<boolean>
|
|
43
|
-
|
|
44
|
-
/** Update cell values by updating set of expressions and values */
|
|
45
|
-
updateExprValues?: (tableId: string, rowUpdates: RowUpdate[]) => Promise<void>
|
|
46
|
-
|
|
47
|
-
/** Called when row is clicked with (tableId, rowId) */
|
|
48
|
-
onRowClick?: (tableId: string, rowId: any) => void
|
|
49
|
-
|
|
50
|
-
/** Called when row is double-clicked with (tableId, rowId) */
|
|
51
|
-
onRowDoubleClick?: (tableId: string, rowId: any) => void
|
|
52
|
-
|
|
53
|
-
/** Locked quickfilter values. See README in quickfilters */
|
|
54
|
-
quickfilterLocks?: any[]
|
|
55
|
-
|
|
56
|
-
// Filters to add to the datagrid
|
|
57
|
-
filters?: JsonQLFilter[]
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
interface DatagridComponentState {
|
|
61
|
-
/** is design being edited */
|
|
62
|
-
editingDesign: boolean
|
|
63
|
-
/** True if cells can be edited directly */
|
|
64
|
-
cellEditingEnabled: boolean
|
|
65
|
-
/** Height of quickfilters */
|
|
66
|
-
quickfiltersHeight: number | null
|
|
67
|
-
quickfiltersValues: null | any[]
|
|
68
|
-
refreshKey: number
|
|
69
|
-
/** Number of rows */
|
|
70
|
-
numRows?: number
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Datagrid with decorations
|
|
74
|
-
// See README.md for description of datagrid format
|
|
75
|
-
// Design should be cleaned already before being passed in (see DatagridUtils)
|
|
76
|
-
export default class DatagridComponent extends React.Component<
|
|
77
|
-
DatagridComponentProps,
|
|
78
|
-
DatagridComponentState
|
|
79
|
-
> {
|
|
80
|
-
datagridView?: DatagridViewComponent | null
|
|
81
|
-
quickfilters?: HTMLElement | null
|
|
82
|
-
findReplaceModal: FindReplaceModalComponent | null
|
|
83
|
-
|
|
84
|
-
constructor(props: DatagridComponentProps) {
|
|
85
|
-
super(props)
|
|
86
|
-
|
|
87
|
-
this.state = {
|
|
88
|
-
editingDesign: false, // is design being edited
|
|
89
|
-
cellEditingEnabled: false, // True if cells can be edited directly
|
|
90
|
-
quickfiltersHeight: null, // Height of quickfilters
|
|
91
|
-
quickfiltersValues: null,
|
|
92
|
-
refreshKey: 1
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
reload() {
|
|
97
|
-
this.datagridView?.reload()
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
componentDidMount() {
|
|
101
|
-
this.loadRowCount()
|
|
102
|
-
this.updateHeight()
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
componentDidUpdate(prevProps: DatagridComponentProps, prevState: DatagridComponentState) {
|
|
106
|
-
if (!_.isEqual(prevProps.design, this.props.design) || !_.isEqual(prevState.quickfiltersValues, this.state.quickfiltersValues) || prevState.refreshKey !== this.state.refreshKey) {
|
|
107
|
-
this.loadRowCount()
|
|
108
|
-
}
|
|
109
|
-
this.updateHeight()
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
loadRowCount() {
|
|
113
|
-
if (!this.props.design.showNumRows) {
|
|
114
|
-
return
|
|
115
|
-
}
|
|
116
|
-
let filters = this.props.filters || []
|
|
117
|
-
|
|
118
|
-
// Compile quickfilters
|
|
119
|
-
filters = filters.concat(this.getQuickfilterFilters())
|
|
120
|
-
this.props.datagridDataSource.countRows(this.props.design,
|
|
121
|
-
filters,
|
|
122
|
-
(error: any, numRows: any) => {
|
|
123
|
-
if (error) {
|
|
124
|
-
console.error(error)
|
|
125
|
-
alert(T`Error loading data`)
|
|
126
|
-
return
|
|
127
|
-
}
|
|
128
|
-
console.log(numRows)
|
|
129
|
-
this.setState({ numRows })
|
|
130
|
-
})
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
handleRefreshData = () => {
|
|
134
|
-
this.props.dataSource.clearCache?.()
|
|
135
|
-
this.setState({ refreshKey: this.state.refreshKey + 1 })
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
updateHeight() {
|
|
139
|
-
// Calculate quickfilters height
|
|
140
|
-
if (this.quickfilters) {
|
|
141
|
-
if (this.state.quickfiltersHeight !== this.quickfilters.offsetHeight) {
|
|
142
|
-
return this.setState({ quickfiltersHeight: this.quickfilters.offsetHeight })
|
|
143
|
-
}
|
|
144
|
-
} else {
|
|
145
|
-
return this.setState({ quickfiltersHeight: 0 })
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Get the values of the quick filters
|
|
150
|
-
getQuickfilterValues = () => {
|
|
151
|
-
return this.state.quickfiltersValues || []
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Get filters that are applied by the quickfilters
|
|
155
|
-
getQuickfilterFilters = () => {
|
|
156
|
-
return new QuickfilterCompiler(this.props.schema).compile(
|
|
157
|
-
this.props.design.quickfilters,
|
|
158
|
-
this.state.quickfiltersValues,
|
|
159
|
-
this.props.quickfilterLocks
|
|
160
|
-
)
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
handleCellEditingToggle = () => {
|
|
164
|
-
if (this.state.cellEditingEnabled) {
|
|
165
|
-
return this.setState({ cellEditingEnabled: false })
|
|
166
|
-
} else {
|
|
167
|
-
if (confirm(T`Turn on cell editing? This will allow you to edit the live data and is an advanced feature.`)) {
|
|
168
|
-
return this.setState({ cellEditingEnabled: true })
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
handleEdit = () => {
|
|
174
|
-
return this.setState({ editingDesign: true })
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// Get datagrid filter compiled for quickfilter filtering
|
|
178
|
-
getCompiledFilters(): JsonQLFilter[] {
|
|
179
|
-
let jsonql
|
|
180
|
-
const exprCompiler = new ExprCompiler(this.props.schema)
|
|
181
|
-
const exprUtils = new ExprUtils(this.props.schema)
|
|
182
|
-
const exprCleaner = new ExprCleaner(this.props.schema)
|
|
183
|
-
|
|
184
|
-
const compiledFilters: JsonQLFilter[] = []
|
|
185
|
-
|
|
186
|
-
if (this.props.design.filter) {
|
|
187
|
-
// First clean the filter
|
|
188
|
-
const cleanExpr = exprCleaner.cleanExpr(this.props.design.filter, { table: this.props.design.table! })
|
|
189
|
-
|
|
190
|
-
jsonql = exprCompiler.compileExpr({ expr: cleanExpr, tableAlias: "{alias}" })
|
|
191
|
-
if (jsonql) {
|
|
192
|
-
compiledFilters.push({
|
|
193
|
-
table: this.props.design.table!,
|
|
194
|
-
jsonql
|
|
195
|
-
})
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// Add global filters
|
|
200
|
-
for (let filter of this.props.design.globalFilters || []) {
|
|
201
|
-
// Check if exists and is correct type
|
|
202
|
-
const column = this.props.schema.getColumn(this.props.design.table!, filter.columnId)
|
|
203
|
-
if (!column) {
|
|
204
|
-
continue
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const columnExpr: Expr = { type: "field", table: this.props.design.table!, column: column.id }
|
|
208
|
-
if (exprUtils.getExprType(columnExpr) !== filter.columnType) {
|
|
209
|
-
continue
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// Create expr
|
|
213
|
-
let expr: Expr = {
|
|
214
|
-
type: "op",
|
|
215
|
-
op: filter.op,
|
|
216
|
-
table: this.props.design.table!,
|
|
217
|
-
exprs: [columnExpr as Expr].concat(filter.exprs)
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// Clean expr
|
|
221
|
-
expr = exprCleaner.cleanExpr(expr, { table: this.props.design.table! })
|
|
222
|
-
|
|
223
|
-
jsonql = exprCompiler.compileExpr({ expr, tableAlias: "{alias}" })
|
|
224
|
-
if (jsonql) {
|
|
225
|
-
compiledFilters.push({
|
|
226
|
-
table: this.props.design.table!,
|
|
227
|
-
jsonql
|
|
228
|
-
})
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
return compiledFilters
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// Toggle to allow cell editing
|
|
236
|
-
renderCellEdit() {
|
|
237
|
-
if (!this.props.canEditExpr) {
|
|
238
|
-
return null
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const label = [
|
|
242
|
-
R("i", { className: this.state.cellEditingEnabled ? "fa fa-fw fa-check-square" : "fa fa-fw fa-square-o" }),
|
|
243
|
-
" ",
|
|
244
|
-
T`Cell Editing`
|
|
245
|
-
]
|
|
246
|
-
|
|
247
|
-
return R(
|
|
248
|
-
"a",
|
|
249
|
-
{
|
|
250
|
-
key: "cell-edit",
|
|
251
|
-
className: "btn btn-link btn-sm",
|
|
252
|
-
onClick: this.handleCellEditingToggle
|
|
253
|
-
},
|
|
254
|
-
label
|
|
255
|
-
)
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
renderEditButton() {
|
|
259
|
-
if (!this.props.onDesignChange) {
|
|
260
|
-
return null
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
return R(
|
|
264
|
-
"button",
|
|
265
|
-
{
|
|
266
|
-
type: "button",
|
|
267
|
-
className: "btn btn-primary",
|
|
268
|
-
onClick: this.handleEdit
|
|
269
|
-
},
|
|
270
|
-
R("span", { className: "fas fa-cog" }),
|
|
271
|
-
" ",
|
|
272
|
-
T`Settings`
|
|
273
|
-
)
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
renderFindReplace() {
|
|
277
|
-
if (!this.state.cellEditingEnabled) {
|
|
278
|
-
return null
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
return R(
|
|
282
|
-
"a",
|
|
283
|
-
{
|
|
284
|
-
key: "findreplace",
|
|
285
|
-
className: "btn btn-link btn-sm",
|
|
286
|
-
onClick: () => this.findReplaceModal!.show()
|
|
287
|
-
},
|
|
288
|
-
T`Find/Replace`
|
|
289
|
-
)
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
renderTitleBar() {
|
|
293
|
-
return R(
|
|
294
|
-
"div",
|
|
295
|
-
{ style: { position: "absolute", top: 0, left: 0, right: 0, height: 40, padding: 4 } },
|
|
296
|
-
R(
|
|
297
|
-
"div",
|
|
298
|
-
{ style: { float: "right" } },
|
|
299
|
-
this.props.design.showNumRows && this.state.numRows ? R("small", { className: 'text-muted text-sm' }, `${d3Format(',')(this.state.numRows)} rows`) : undefined,
|
|
300
|
-
this.renderFindReplace(),
|
|
301
|
-
this.renderCellEdit(),
|
|
302
|
-
this.renderEditButton(),
|
|
303
|
-
R(
|
|
304
|
-
"a",
|
|
305
|
-
{ key: "refresh", className: "btn btn-link btn-sm", onClick: this.handleRefreshData },
|
|
306
|
-
R("span", { className: "fas fa-sync" }),
|
|
307
|
-
R("span", { className: "hide-600px" }, T`Refresh`)
|
|
308
|
-
),
|
|
309
|
-
this.props.extraTitleButtonsElem
|
|
310
|
-
),
|
|
311
|
-
this.props.titleElem
|
|
312
|
-
)
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
renderQuickfilter() {
|
|
316
|
-
return R(
|
|
317
|
-
"div",
|
|
318
|
-
{
|
|
319
|
-
style: { position: "absolute", top: 40, left: 0, right: 0 },
|
|
320
|
-
ref: (c) => {
|
|
321
|
-
this.quickfilters = c
|
|
322
|
-
}
|
|
323
|
-
},
|
|
324
|
-
R(QuickfiltersComponent, {
|
|
325
|
-
design: this.props.design.quickfilters!,
|
|
326
|
-
schema: this.props.schema,
|
|
327
|
-
dataSource: this.props.dataSource,
|
|
328
|
-
quickfiltersDataSource: this.props.datagridDataSource.getQuickfiltersDataSource(),
|
|
329
|
-
values: this.state.quickfiltersValues || [],
|
|
330
|
-
onValuesChange: (values: any) => this.setState({ quickfiltersValues: values }),
|
|
331
|
-
locks: this.props.quickfilterLocks,
|
|
332
|
-
filters: this.getCompiledFilters()
|
|
333
|
-
})
|
|
334
|
-
)
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// Renders the editor modal
|
|
338
|
-
renderEditor() {
|
|
339
|
-
if (!this.state.editingDesign) {
|
|
340
|
-
return
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
return R(DatagridEditorComponent, {
|
|
344
|
-
schema: this.props.schema,
|
|
345
|
-
dataSource: this.props.dataSource,
|
|
346
|
-
design: this.props.design,
|
|
347
|
-
onDesignChange: (design: any) => {
|
|
348
|
-
// If quickfilters have changed, reset values
|
|
349
|
-
if (!_.isEqual(this.props.design.quickfilters, design.quickfilters)) {
|
|
350
|
-
this.setState({ quickfiltersValues: null })
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
this.props.onDesignChange!(design)
|
|
354
|
-
|
|
355
|
-
return this.setState({ editingDesign: false })
|
|
356
|
-
},
|
|
357
|
-
onCancel: () => this.setState({ editingDesign: false })
|
|
358
|
-
})
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
renderFindReplaceModal(filters: any) {
|
|
362
|
-
return R(FindReplaceModalComponent, {
|
|
363
|
-
ref: (c: FindReplaceModalComponent | null) => {
|
|
364
|
-
this.findReplaceModal = c
|
|
365
|
-
},
|
|
366
|
-
schema: this.props.schema,
|
|
367
|
-
dataSource: this.props.dataSource,
|
|
368
|
-
datagridDataSource: this.props.datagridDataSource,
|
|
369
|
-
design: this.props.design,
|
|
370
|
-
filters,
|
|
371
|
-
updateExprValues: this.props.updateExprValues!,
|
|
372
|
-
onUpdate: () => {
|
|
373
|
-
// Reload
|
|
374
|
-
return this.datagridView?.reload()
|
|
375
|
-
}
|
|
376
|
-
})
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
render() {
|
|
380
|
-
let filters = this.props.filters || []
|
|
381
|
-
|
|
382
|
-
// Compile quickfilters
|
|
383
|
-
filters = filters.concat(this.getQuickfilterFilters())
|
|
384
|
-
|
|
385
|
-
return R(LocaleContext.Provider, { value: this.props.design.locale || "en" },
|
|
386
|
-
R(
|
|
387
|
-
"div",
|
|
388
|
-
{
|
|
389
|
-
style: {
|
|
390
|
-
width: "100%",
|
|
391
|
-
height: "100%",
|
|
392
|
-
position: "relative",
|
|
393
|
-
paddingTop: 40 + (this.state.quickfiltersHeight || 0)
|
|
394
|
-
}
|
|
395
|
-
},
|
|
396
|
-
this.renderTitleBar(),
|
|
397
|
-
this.renderQuickfilter(),
|
|
398
|
-
|
|
399
|
-
this.renderEditor(),
|
|
400
|
-
this.renderFindReplaceModal(filters),
|
|
401
|
-
|
|
402
|
-
R(AutoSizeComponent, { injectWidth: true, injectHeight: true } as any, (size: any) => {
|
|
403
|
-
// Clean before displaying
|
|
404
|
-
const design = new DatagridUtils(this.props.schema).cleanDesign(this.props.design)
|
|
405
|
-
|
|
406
|
-
if (!new DatagridUtils(this.props.schema).validateDesign(design)) {
|
|
407
|
-
return R(DatagridViewComponent, {
|
|
408
|
-
ref: (view: DatagridViewComponent | null) => {
|
|
409
|
-
this.datagridView = view
|
|
410
|
-
},
|
|
411
|
-
width: size.width - 1, // minus 1 px to test if it solves the jitter with scroll
|
|
412
|
-
height: size.height - 1,
|
|
413
|
-
pageSize: 100,
|
|
414
|
-
schema: this.props.schema,
|
|
415
|
-
dataSource: this.props.dataSource,
|
|
416
|
-
datagridDataSource: this.props.datagridDataSource,
|
|
417
|
-
design,
|
|
418
|
-
filters,
|
|
419
|
-
onDesignChange: this.props.onDesignChange,
|
|
420
|
-
onRowClick: this.props.onRowClick,
|
|
421
|
-
onRowDoubleClick: this.props.onRowDoubleClick,
|
|
422
|
-
canEditExpr: this.state.cellEditingEnabled ? this.props.canEditExpr : undefined,
|
|
423
|
-
updateExprValues: this.state.cellEditingEnabled ? this.props.updateExprValues : undefined,
|
|
424
|
-
refreshKey: this.state.refreshKey
|
|
425
|
-
})
|
|
426
|
-
} else if (this.props.onDesignChange) {
|
|
427
|
-
return R(
|
|
428
|
-
"div",
|
|
429
|
-
{ style: { textAlign: "center", marginTop: size.height / 2 } },
|
|
430
|
-
R("a", { className: "btn btn-link", onClick: this.handleEdit }, T`Click Here to Configure`)
|
|
431
|
-
)
|
|
432
|
-
} else {
|
|
433
|
-
return null
|
|
434
|
-
}
|
|
435
|
-
})
|
|
436
|
-
)
|
|
437
|
-
)
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
interface DatagridEditorComponentProps {
|
|
442
|
-
schema: Schema
|
|
443
|
-
dataSource: DataSource
|
|
444
|
-
design: DatagridDesign
|
|
445
|
-
onDesignChange: (design: DatagridDesign) => void
|
|
446
|
-
onCancel: () => void
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
/** Popup editor */
|
|
450
|
-
class DatagridEditorComponent extends React.Component<DatagridEditorComponentProps, { design: DatagridDesign }> {
|
|
451
|
-
constructor(props: DatagridEditorComponentProps) {
|
|
452
|
-
super(props)
|
|
453
|
-
|
|
454
|
-
this.state = {
|
|
455
|
-
design: props.design
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
render() {
|
|
460
|
-
return R(
|
|
461
|
-
ActionCancelModalComponent,
|
|
462
|
-
{
|
|
463
|
-
onAction: () => {
|
|
464
|
-
this.props.onDesignChange(this.state.design)
|
|
465
|
-
return this.setState({ design: this.props.design })
|
|
466
|
-
},
|
|
467
|
-
onCancel: this.props.onCancel,
|
|
468
|
-
size: "large"
|
|
469
|
-
},
|
|
470
|
-
R(DatagridDesignerComponent, {
|
|
471
|
-
schema: this.props.schema,
|
|
472
|
-
dataSource: this.props.dataSource,
|
|
473
|
-
design: this.state.design,
|
|
474
|
-
onDesignChange: (design: any) => this.setState({ design })
|
|
475
|
-
})
|
|
476
|
-
)
|
|
477
|
-
}
|
|
478
|
-
}
|