@mwater/visualization 5.4.1 → 5.4.3
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 +12 -20
- package/lib/dashboards/DashboardComponent.js +109 -69
- 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/languages.js +6 -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/Quickfilter.d.ts +2 -0
- package/lib/quickfilter/QuickfiltersComponent.d.ts +2 -0
- package/lib/quickfilter/QuickfiltersComponent.js +9 -7
- package/lib/quickfilter/QuickfiltersDesignComponent.d.ts +5 -30
- package/lib/quickfilter/QuickfiltersDesignComponent.js +56 -63
- 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 +1 -1
- 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/PivotChartLayoutComponent.js +1 -1
- 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 +189 -125
- 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/languages.ts +6 -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/Quickfilter.ts +3 -0
- package/src/quickfilter/QuickfiltersComponent.ts +13 -7
- package/src/quickfilter/QuickfiltersDesignComponent.tsx +127 -128
- 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 +2 -2
- 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,305 +0,0 @@
|
|
|
1
|
-
import _ from "lodash"
|
|
2
|
-
import React, { useState } from "react"
|
|
3
|
-
const R = React.createElement
|
|
4
|
-
import { DataSource, EnumValue, Expr, ExprUtils, Schema } from "@mwater/expressions"
|
|
5
|
-
import moment from "moment"
|
|
6
|
-
|
|
7
|
-
export interface EditExprCellComponentProps {
|
|
8
|
-
/** schema to use */
|
|
9
|
-
schema: Schema
|
|
10
|
-
/** dataSource to use */
|
|
11
|
-
dataSource: DataSource
|
|
12
|
-
/** Locale to use */
|
|
13
|
-
locale?: string
|
|
14
|
-
|
|
15
|
-
/** Size of control */
|
|
16
|
-
width: number
|
|
17
|
-
height: number
|
|
18
|
-
|
|
19
|
-
/** Expression being edited */
|
|
20
|
-
expr: Expr
|
|
21
|
-
/** Value of expression */
|
|
22
|
-
value?: any
|
|
23
|
-
/** Called when save is requested (e.g. enter in text box) */
|
|
24
|
-
onSave: () => void
|
|
25
|
-
/** Called when cancel is requested (e.g. esc in text box) */
|
|
26
|
-
onCancel: () => void
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface EditExprCellComponentState {
|
|
30
|
-
value: any
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Cell allows editing an expression column cell
|
|
34
|
-
// Store edited value here to prevent slow re-render of entire datagrid
|
|
35
|
-
export default class EditExprCellComponent extends React.Component<
|
|
36
|
-
EditExprCellComponentProps,
|
|
37
|
-
EditExprCellComponentState
|
|
38
|
-
> {
|
|
39
|
-
constructor(props: any) {
|
|
40
|
-
super(props)
|
|
41
|
-
this.state = { value: props.value }
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
getValue() {
|
|
45
|
-
return this.state.value
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Check if edit value has changed
|
|
49
|
-
hasChanged() {
|
|
50
|
-
return !_.isEqual(this.props.value, this.state.value)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
handleChange = (value: any) => {
|
|
54
|
-
this.setState({ value })
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
render() {
|
|
58
|
-
const exprUtils = new ExprUtils(this.props.schema)
|
|
59
|
-
|
|
60
|
-
// Get expression type
|
|
61
|
-
const exprType = exprUtils.getExprType(this.props.expr)
|
|
62
|
-
|
|
63
|
-
switch (exprType) {
|
|
64
|
-
case "text":
|
|
65
|
-
return R(TextEditComponent, {
|
|
66
|
-
value: this.state.value,
|
|
67
|
-
onChange: this.handleChange,
|
|
68
|
-
onSave: this.props.onSave,
|
|
69
|
-
onCancel: this.props.onCancel
|
|
70
|
-
})
|
|
71
|
-
case "number":
|
|
72
|
-
return R(NumberEditComponent, {
|
|
73
|
-
value: this.state.value,
|
|
74
|
-
onChange: this.handleChange,
|
|
75
|
-
onSave: this.props.onSave,
|
|
76
|
-
onCancel: this.props.onCancel
|
|
77
|
-
})
|
|
78
|
-
case "enum":
|
|
79
|
-
return R(EnumEditComponent, {
|
|
80
|
-
value: this.state.value,
|
|
81
|
-
onChange: this.handleChange,
|
|
82
|
-
enumValues: exprUtils.getExprEnumValues(this.props.expr)!,
|
|
83
|
-
onSave: this.props.onSave,
|
|
84
|
-
onCancel: this.props.onCancel,
|
|
85
|
-
locale: this.props.locale
|
|
86
|
-
})
|
|
87
|
-
case "date":
|
|
88
|
-
case "datetime":
|
|
89
|
-
return R(DateEditComponent, {
|
|
90
|
-
value: this.state.value,
|
|
91
|
-
onChange: this.handleChange,
|
|
92
|
-
onSave: this.props.onSave,
|
|
93
|
-
onCancel: this.props.onCancel,
|
|
94
|
-
datetime: exprType === "datetime"
|
|
95
|
-
})
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
throw new Error(`Unsupported type ${exprType} for editing`)
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
interface TextEditComponentProps {
|
|
103
|
-
/** Current value */
|
|
104
|
-
value?: any
|
|
105
|
-
/** Called with new value */
|
|
106
|
-
onChange: (value: any) => void
|
|
107
|
-
/** Called when save is requested (e.g. enter in text box) */
|
|
108
|
-
onSave: () => void
|
|
109
|
-
/** Called when cancel is requested (e.g. esc in text box) */
|
|
110
|
-
onCancel: () => void
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Simple text box
|
|
114
|
-
class TextEditComponent extends React.Component<TextEditComponentProps> {
|
|
115
|
-
input: HTMLInputElement | null
|
|
116
|
-
|
|
117
|
-
componentDidMount() {
|
|
118
|
-
// Focus when created
|
|
119
|
-
return this.input?.focus()
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
render() {
|
|
123
|
-
return R(
|
|
124
|
-
"div",
|
|
125
|
-
{ style: { paddingTop: 3 } },
|
|
126
|
-
R("input", {
|
|
127
|
-
ref: (c: HTMLInputElement | null) => {
|
|
128
|
-
this.input = c
|
|
129
|
-
},
|
|
130
|
-
type: "text",
|
|
131
|
-
className: "form-control",
|
|
132
|
-
value: this.props.value || "",
|
|
133
|
-
onChange: (ev: any) => this.props.onChange(ev.target.value || null),
|
|
134
|
-
onKeyUp: (ev: any) => {
|
|
135
|
-
if (ev.keyCode === 27) {
|
|
136
|
-
this.props.onCancel()
|
|
137
|
-
}
|
|
138
|
-
if (ev.keyCode === 13) {
|
|
139
|
-
return this.props.onSave()
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
})
|
|
143
|
-
)
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
interface NumberEditComponentProps {
|
|
148
|
-
/** Current value */
|
|
149
|
-
value?: any
|
|
150
|
-
/** Called with new value */
|
|
151
|
-
onChange: (value: any) => void
|
|
152
|
-
/** Called when save is requested (e.g. enter in text box) */
|
|
153
|
-
onSave: () => void
|
|
154
|
-
/** Called when cancel is requested (e.g. esc in text box) */
|
|
155
|
-
onCancel: () => void
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Simple number box
|
|
159
|
-
class NumberEditComponent extends React.Component<NumberEditComponentProps> {
|
|
160
|
-
input: HTMLInputElement | null
|
|
161
|
-
|
|
162
|
-
componentDidMount() {
|
|
163
|
-
// Focus when created
|
|
164
|
-
return this.input?.focus()
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
handleChange = (ev: any) => {
|
|
168
|
-
if (ev.target.value) {
|
|
169
|
-
return this.props.onChange(parseFloat(ev.target.value))
|
|
170
|
-
} else {
|
|
171
|
-
return this.props.onChange(null)
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
render() {
|
|
176
|
-
return R(
|
|
177
|
-
"div",
|
|
178
|
-
{ style: { paddingTop: 3 } },
|
|
179
|
-
R("input", {
|
|
180
|
-
ref: (c: any) => {
|
|
181
|
-
return (this.input = c)
|
|
182
|
-
},
|
|
183
|
-
type: "number",
|
|
184
|
-
step: "any",
|
|
185
|
-
className: "form-control",
|
|
186
|
-
value: this.props.value != null ? this.props.value : "",
|
|
187
|
-
onChange: this.handleChange,
|
|
188
|
-
onKeyUp: (ev: any) => {
|
|
189
|
-
if (ev.keyCode === 27) {
|
|
190
|
-
this.props.onCancel()
|
|
191
|
-
}
|
|
192
|
-
if (ev.keyCode === 13) {
|
|
193
|
-
return this.props.onSave()
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
})
|
|
197
|
-
)
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
interface EnumEditComponentProps {
|
|
202
|
-
/** Current value */
|
|
203
|
-
value?: any
|
|
204
|
-
/** Called with new value */
|
|
205
|
-
onChange: (value: any) => void
|
|
206
|
-
enumValues: EnumValue[]
|
|
207
|
-
/** Locale to use */
|
|
208
|
-
locale?: string
|
|
209
|
-
/** Called when save is requested (e.g. enter in text box) */
|
|
210
|
-
onSave: () => void
|
|
211
|
-
/** Called when cancel is requested (e.g. esc in text box) */
|
|
212
|
-
onCancel: () => void
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// Simple enum box
|
|
216
|
-
class EnumEditComponent extends React.Component<EnumEditComponentProps> {
|
|
217
|
-
render() {
|
|
218
|
-
return R(
|
|
219
|
-
"div",
|
|
220
|
-
{ style: { paddingTop: 3 } },
|
|
221
|
-
R(
|
|
222
|
-
"select",
|
|
223
|
-
{
|
|
224
|
-
value: this.props.value || "",
|
|
225
|
-
onChange: (ev: any) => this.props.onChange(ev.target.value || null),
|
|
226
|
-
className: "form-select"
|
|
227
|
-
},
|
|
228
|
-
R("option", { key: "", value: "" }, ""),
|
|
229
|
-
_.map(this.props.enumValues, (ev) => {
|
|
230
|
-
return R("option", { key: ev.id, value: ev.id }, ExprUtils.localizeString(ev.name, this.props.locale))
|
|
231
|
-
})
|
|
232
|
-
)
|
|
233
|
-
)
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/** Simple date editor */
|
|
238
|
-
function DateEditComponent(props: {
|
|
239
|
-
/** Current value */
|
|
240
|
-
value?: any
|
|
241
|
-
/** Called with new value */
|
|
242
|
-
onChange: (value: any) => void
|
|
243
|
-
/** Called when save is requested (e.g. enter in text box) */
|
|
244
|
-
onSave: () => void
|
|
245
|
-
/** Called when cancel is requested (e.g. esc in text box) */
|
|
246
|
-
onCancel: () => void
|
|
247
|
-
/** True if datetime, not date */
|
|
248
|
-
datetime: boolean
|
|
249
|
-
}) {
|
|
250
|
-
// // Focus when created
|
|
251
|
-
// return this.input?.focus()
|
|
252
|
-
|
|
253
|
-
// Format date
|
|
254
|
-
const [valueStr, setValueStr] = useState(props.datetime ?
|
|
255
|
-
(props.value ? moment(props.value, moment.ISO_8601).format("YYYY-MM-DD HH:mm") : "")
|
|
256
|
-
: props.value || ""
|
|
257
|
-
)
|
|
258
|
-
|
|
259
|
-
const [isValid, setIsValid] = useState(true)
|
|
260
|
-
|
|
261
|
-
// Parse date
|
|
262
|
-
function parseDate(value: string) {
|
|
263
|
-
if (!value) {
|
|
264
|
-
setIsValid(true)
|
|
265
|
-
return null
|
|
266
|
-
}
|
|
267
|
-
const m = moment(value, props.datetime ? "YYYY-MM-DD HH:mm" : "YYYY-MM-DD")
|
|
268
|
-
if (!m.isValid()) {
|
|
269
|
-
setIsValid(false)
|
|
270
|
-
return null
|
|
271
|
-
}
|
|
272
|
-
setIsValid(true)
|
|
273
|
-
if (props.datetime) {
|
|
274
|
-
return m.toISOString()
|
|
275
|
-
} else {
|
|
276
|
-
return m.format("YYYY-MM-DD")
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
return <div style={{ paddingTop: 3 }}>
|
|
281
|
-
<input
|
|
282
|
-
type="text"
|
|
283
|
-
className="form-control"
|
|
284
|
-
value={valueStr}
|
|
285
|
-
style={{ backgroundColor: isValid ? "white" : "pink" }}
|
|
286
|
-
onChange={ev => {
|
|
287
|
-
setValueStr(ev.target.value)
|
|
288
|
-
props.onChange(parseDate(ev.target.value))
|
|
289
|
-
}}
|
|
290
|
-
ref={c => {
|
|
291
|
-
if (c) {
|
|
292
|
-
c.focus()
|
|
293
|
-
}
|
|
294
|
-
}}
|
|
295
|
-
onKeyUp={(ev) => {
|
|
296
|
-
if (ev.keyCode === 27) {
|
|
297
|
-
props.onCancel()
|
|
298
|
-
}
|
|
299
|
-
if (ev.keyCode === 13) {
|
|
300
|
-
return props.onSave()
|
|
301
|
-
}
|
|
302
|
-
}}
|
|
303
|
-
/>
|
|
304
|
-
</div>
|
|
305
|
-
}
|
package/src/datagrids/README.md
DELETED
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
import PropTypes from "prop-types"
|
|
2
|
-
import _ from "lodash"
|
|
3
|
-
import React from "react"
|
|
4
|
-
const R = React.createElement
|
|
5
|
-
|
|
6
|
-
import { FilterExprComponent } from "@mwater/expressions-ui"
|
|
7
|
-
import { DataSource, ExprUtils, OpExpr, Schema } from "@mwater/expressions"
|
|
8
|
-
import { ExprCompiler } from "@mwater/expressions"
|
|
9
|
-
import NumberInputComponent from "@mwater/react-library/lib/NumberInputComponent"
|
|
10
|
-
import AxisComponent from "./../axes/AxisComponent"
|
|
11
|
-
import ColorComponent from "../ColorComponent"
|
|
12
|
-
import { TableSelectComponent } from "@mwater/expressions-ui"
|
|
13
|
-
import { default as Rcslider } from "rc-slider"
|
|
14
|
-
import EditPopupComponent from "./EditPopupComponent"
|
|
15
|
-
import ZoomLevelsComponent from "./ZoomLevelsComponent"
|
|
16
|
-
import * as PopupFilterJoinsUtils from "./PopupFilterJoinsUtils"
|
|
17
|
-
import { Checkbox } from "@mwater/react-library/lib/bootstrap"
|
|
18
|
-
import { BufferLayerDesign } from "./BufferLayerDesign"
|
|
19
|
-
import { JsonQLFilter } from "../JsonQLFilter"
|
|
20
|
-
import { areVectorMapsEnabled } from "./vectorMaps"
|
|
21
|
-
import EditHoverOver from "./EditHoverOver"
|
|
22
|
-
|
|
23
|
-
export interface BufferLayerDesignerComponentProps {
|
|
24
|
-
/** Schema to use */
|
|
25
|
-
schema: Schema
|
|
26
|
-
dataSource: DataSource
|
|
27
|
-
/** Design of the design */
|
|
28
|
-
design: BufferLayerDesign
|
|
29
|
-
/** Called with new design */
|
|
30
|
-
onDesignChange: (design: BufferLayerDesign) => void
|
|
31
|
-
filters?: JsonQLFilter[]
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default class BufferLayerDesignerComponent extends React.Component<BufferLayerDesignerComponentProps> {
|
|
35
|
-
// Apply updates to design
|
|
36
|
-
update(updates: any) {
|
|
37
|
-
return this.props.onDesignChange(_.extend({}, this.props.design, updates))
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Update axes with specified changes
|
|
41
|
-
updateAxes(changes: any) {
|
|
42
|
-
const axes = _.extend({}, this.props.design.axes, changes)
|
|
43
|
-
return this.update({ axes })
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
handleTableChange = (table: any) => {
|
|
47
|
-
return this.update({ table })
|
|
48
|
-
}
|
|
49
|
-
handleRadiusChange = (radius: any) => {
|
|
50
|
-
return this.update({ radius })
|
|
51
|
-
}
|
|
52
|
-
handleGeometryAxisChange = (axis: any) => {
|
|
53
|
-
return this.updateAxes({ geometry: axis })
|
|
54
|
-
}
|
|
55
|
-
handleFilterChange = (expr: any) => {
|
|
56
|
-
return this.update({ filter: expr })
|
|
57
|
-
}
|
|
58
|
-
handleColorChange = (color: any) => {
|
|
59
|
-
return this.update({ color })
|
|
60
|
-
}
|
|
61
|
-
handleColorAxisChange = (axis: any) => {
|
|
62
|
-
return this.updateAxes({ color: axis })
|
|
63
|
-
}
|
|
64
|
-
handleFillOpacityChange = (fillOpacity: any) => {
|
|
65
|
-
return this.update({ fillOpacity: fillOpacity / 100 })
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
handleUnionShapesChange = (unionShapes: boolean) => {
|
|
69
|
-
this.props.onDesignChange({ ...this.props.design, unionShapes })
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
renderTable() {
|
|
73
|
-
return R(
|
|
74
|
-
"div",
|
|
75
|
-
{ className: "mb-3" },
|
|
76
|
-
R("label", { className: "text-muted" }, R("i", { className: "fa fa-database" }), " ", T`Data Source`),
|
|
77
|
-
R(
|
|
78
|
-
"div",
|
|
79
|
-
{ style: { marginLeft: 10 } },
|
|
80
|
-
R(TableSelectComponent, {
|
|
81
|
-
schema: this.props.schema,
|
|
82
|
-
value: this.props.design.table,
|
|
83
|
-
onChange: this.handleTableChange,
|
|
84
|
-
filter: this.props.design.filter,
|
|
85
|
-
onFilterChange: this.handleFilterChange
|
|
86
|
-
})
|
|
87
|
-
)
|
|
88
|
-
)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
renderGeometryAxis() {
|
|
92
|
-
if (!this.props.design.table) {
|
|
93
|
-
return
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const title = R("span", null, R("span", { className: "fas fa-map-marker-alt" }), " ", T`Circle Centers`)
|
|
97
|
-
|
|
98
|
-
const filters = _.clone(this.props.filters) || []
|
|
99
|
-
|
|
100
|
-
if (this.props.design.filter != null) {
|
|
101
|
-
const exprCompiler = new ExprCompiler(this.props.schema)
|
|
102
|
-
const jsonql = exprCompiler.compileExpr({ expr: this.props.design.filter, tableAlias: "{alias}" })
|
|
103
|
-
if (jsonql) {
|
|
104
|
-
filters.push({ table: (this.props.design.filter as OpExpr).table!, jsonql })
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return R(
|
|
109
|
-
"div",
|
|
110
|
-
{ className: "mb-3" },
|
|
111
|
-
R("label", { className: "text-muted" }, title),
|
|
112
|
-
R(
|
|
113
|
-
"div",
|
|
114
|
-
{ style: { marginLeft: 10 } },
|
|
115
|
-
React.createElement(AxisComponent, {
|
|
116
|
-
schema: this.props.schema,
|
|
117
|
-
dataSource: this.props.dataSource,
|
|
118
|
-
table: this.props.design.table,
|
|
119
|
-
types: ["geometry"],
|
|
120
|
-
aggrNeed: "none",
|
|
121
|
-
value: this.props.design.axes.geometry,
|
|
122
|
-
onChange: this.handleGeometryAxisChange,
|
|
123
|
-
filters
|
|
124
|
-
})
|
|
125
|
-
)
|
|
126
|
-
)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
renderRadius() {
|
|
130
|
-
return R(
|
|
131
|
-
"div",
|
|
132
|
-
{ className: "mb-3" },
|
|
133
|
-
R("label", { className: "text-muted" }, T`Radius (meters)`),
|
|
134
|
-
": ",
|
|
135
|
-
React.createElement(NumberInputComponent, {
|
|
136
|
-
value: this.props.design.radius,
|
|
137
|
-
onChange: this.handleRadiusChange
|
|
138
|
-
})
|
|
139
|
-
)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
renderUnionShapes() {
|
|
143
|
-
// Only implemented for vector maps
|
|
144
|
-
if (!areVectorMapsEnabled()) {
|
|
145
|
-
return null
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return R(
|
|
149
|
-
"div",
|
|
150
|
-
{ className: "mb-3" },
|
|
151
|
-
React.createElement(
|
|
152
|
-
Checkbox,
|
|
153
|
-
{
|
|
154
|
-
value: this.props.design.unionShapes,
|
|
155
|
-
onChange: this.handleUnionShapesChange
|
|
156
|
-
},
|
|
157
|
-
T`Combine circles (advanced)`
|
|
158
|
-
)
|
|
159
|
-
)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
renderColor() {
|
|
163
|
-
if (!this.props.design.axes.geometry) {
|
|
164
|
-
return
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const filters = _.clone(this.props.filters) || []
|
|
168
|
-
|
|
169
|
-
if (this.props.design.filter != null) {
|
|
170
|
-
const exprCompiler = new ExprCompiler(this.props.schema)
|
|
171
|
-
const jsonql = exprCompiler.compileExpr({ expr: this.props.design.filter, tableAlias: "{alias}" })
|
|
172
|
-
if (jsonql) {
|
|
173
|
-
filters.push({ table: (this.props.design.filter as OpExpr).table!, jsonql })
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return R(
|
|
178
|
-
"div",
|
|
179
|
-
null,
|
|
180
|
-
!this.props.design.axes.color
|
|
181
|
-
? R(
|
|
182
|
-
"div",
|
|
183
|
-
{ className: "mb-3" },
|
|
184
|
-
R("label", { className: "text-muted" }, R("span", { className: "fas fa-tint" }), T`Circle Color`),
|
|
185
|
-
|
|
186
|
-
R(
|
|
187
|
-
"div",
|
|
188
|
-
null,
|
|
189
|
-
R(ColorComponent, {
|
|
190
|
-
color: this.props.design.color,
|
|
191
|
-
onChange: this.handleColorChange
|
|
192
|
-
})
|
|
193
|
-
)
|
|
194
|
-
)
|
|
195
|
-
: undefined,
|
|
196
|
-
|
|
197
|
-
R(
|
|
198
|
-
"div",
|
|
199
|
-
{ className: "mb-3" },
|
|
200
|
-
R("label", { className: "text-muted" }, R("span", { className: "fas fa-tint" }), T`Color By Data`),
|
|
201
|
-
|
|
202
|
-
R(AxisComponent, {
|
|
203
|
-
schema: this.props.schema,
|
|
204
|
-
dataSource: this.props.dataSource,
|
|
205
|
-
table: this.props.design.table,
|
|
206
|
-
types: ["text", "enum", "boolean", "date"],
|
|
207
|
-
aggrNeed: "none",
|
|
208
|
-
value: this.props.design.axes.color,
|
|
209
|
-
defaultColor: this.props.design.color,
|
|
210
|
-
showColorMap: true,
|
|
211
|
-
onChange: this.handleColorAxisChange,
|
|
212
|
-
allowExcludedValues: true,
|
|
213
|
-
reorderable: true,
|
|
214
|
-
filters
|
|
215
|
-
})
|
|
216
|
-
)
|
|
217
|
-
)
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
renderFillOpacity() {
|
|
221
|
-
return R(
|
|
222
|
-
"div",
|
|
223
|
-
{ className: "mb-3" },
|
|
224
|
-
R("label", { className: "text-muted" }, T`Circle Opacity (%)`),
|
|
225
|
-
": ",
|
|
226
|
-
React.createElement(Rcslider, {
|
|
227
|
-
min: 0,
|
|
228
|
-
max: 100,
|
|
229
|
-
step: 1,
|
|
230
|
-
tipTransitionName: "rc-slider-tooltip-zoom-down",
|
|
231
|
-
value: this.props.design.fillOpacity * 100,
|
|
232
|
-
onChange: this.handleFillOpacityChange
|
|
233
|
-
})
|
|
234
|
-
)
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
renderFilter() {
|
|
238
|
-
// If no data, hide
|
|
239
|
-
if (!this.props.design.axes.geometry) {
|
|
240
|
-
return null
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return R(
|
|
244
|
-
"div",
|
|
245
|
-
{ className: "mb-3" },
|
|
246
|
-
R("label", { className: "text-muted" }, R("span", { className: "fas fa-filter" }), T`Filters`),
|
|
247
|
-
R(
|
|
248
|
-
"div",
|
|
249
|
-
{ style: { marginLeft: 8 } },
|
|
250
|
-
React.createElement(FilterExprComponent, {
|
|
251
|
-
schema: this.props.schema,
|
|
252
|
-
dataSource: this.props.dataSource,
|
|
253
|
-
onChange: this.handleFilterChange,
|
|
254
|
-
table: this.props.design.table,
|
|
255
|
-
value: this.props.design.filter
|
|
256
|
-
})
|
|
257
|
-
)
|
|
258
|
-
)
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
renderPopup() {
|
|
262
|
-
if (!this.props.design.table) {
|
|
263
|
-
return null
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
return R(EditPopupComponent, {
|
|
267
|
-
design: this.props.design,
|
|
268
|
-
onDesignChange: this.props.onDesignChange,
|
|
269
|
-
schema: this.props.schema,
|
|
270
|
-
dataSource: this.props.dataSource,
|
|
271
|
-
table: this.props.design.table,
|
|
272
|
-
idTable: this.props.design.table,
|
|
273
|
-
defaultPopupFilterJoins: PopupFilterJoinsUtils.createDefaultPopupFilterJoins(this.props.design.table)
|
|
274
|
-
})
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
renderHoverOver() {
|
|
278
|
-
if (!this.props.design.table) {
|
|
279
|
-
return null
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
return R(EditHoverOver, {
|
|
283
|
-
design: this.props.design,
|
|
284
|
-
onDesignChange: this.props.onDesignChange,
|
|
285
|
-
schema: this.props.schema,
|
|
286
|
-
dataSource: this.props.dataSource,
|
|
287
|
-
table: this.props.design.table,
|
|
288
|
-
idTable: this.props.design.table,
|
|
289
|
-
defaultPopupFilterJoins: PopupFilterJoinsUtils.createDefaultPopupFilterJoins(this.props.design.table)
|
|
290
|
-
})
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
render() {
|
|
294
|
-
return R(
|
|
295
|
-
"div",
|
|
296
|
-
null,
|
|
297
|
-
this.renderTable(),
|
|
298
|
-
this.renderGeometryAxis(),
|
|
299
|
-
this.renderRadius(),
|
|
300
|
-
this.renderUnionShapes(),
|
|
301
|
-
this.renderColor(),
|
|
302
|
-
this.renderFillOpacity(),
|
|
303
|
-
this.renderFilter(),
|
|
304
|
-
this.renderPopup(),
|
|
305
|
-
this.renderHoverOver(),
|
|
306
|
-
this.props.design.table
|
|
307
|
-
? R(ZoomLevelsComponent, { design: this.props.design, onDesignChange: this.props.onDesignChange })
|
|
308
|
-
: undefined
|
|
309
|
-
)
|
|
310
|
-
}
|
|
311
|
-
}
|