@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
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import _ from "lodash"
|
|
2
|
+
import React, { useState, ChangeEvent, useCallback } from "react"
|
|
3
|
+
import { EnumValue, LiteralType, ExprUtils, Schema, DataSource } from "@mwater/expressions"
|
|
4
|
+
import { RenderCellEditorProps } from "@mwater/react-library/lib/GridComponent"
|
|
5
|
+
import ReactSelect from "react-select"
|
|
6
|
+
import DatePicker from "react-datepicker"
|
|
7
|
+
import "react-datepicker/dist/react-datepicker.css"
|
|
8
|
+
import moment, { Moment } from "moment"
|
|
9
|
+
import { IdLiteralComponent } from "@mwater/expressions-ui"
|
|
10
|
+
|
|
11
|
+
/** Determine if type can be edited */
|
|
12
|
+
export function canEditType(type: LiteralType) {
|
|
13
|
+
return ["text", "number", "enum", "enumset", "boolean", "date", "datetime", "id", "id[]"].includes(type)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Cell editor for a cell of the grid */
|
|
17
|
+
export const CellEditor = (props: {
|
|
18
|
+
type: LiteralType
|
|
19
|
+
enumValues?: EnumValue[]
|
|
20
|
+
idTable?: string
|
|
21
|
+
initialValue: any
|
|
22
|
+
editorOptions: RenderCellEditorProps
|
|
23
|
+
/** Update the cell value. Returns true if successful, false if cancelled */
|
|
24
|
+
updateCellValue: (value: any) => Promise<boolean>
|
|
25
|
+
locale?: string
|
|
26
|
+
schema: Schema
|
|
27
|
+
dataSource: DataSource
|
|
28
|
+
}) => {
|
|
29
|
+
const editorOptions = props.editorOptions
|
|
30
|
+
const [value, setValue] = useState(props.initialValue)
|
|
31
|
+
const [valid, setValid] = useState(true)
|
|
32
|
+
|
|
33
|
+
// Hook save function
|
|
34
|
+
editorOptions.setSaveEdit(() => {
|
|
35
|
+
if (!valid) {
|
|
36
|
+
return Promise.resolve(false)
|
|
37
|
+
}
|
|
38
|
+
if (value == props.initialValue) {
|
|
39
|
+
return Promise.resolve(true)
|
|
40
|
+
}
|
|
41
|
+
return props.updateCellValue(value)
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
if (editorOptions.saving) {
|
|
45
|
+
return (
|
|
46
|
+
<div style={{ backgroundColor: "#EEE", width: editorOptions.width, height: editorOptions.height, padding: 10 }}>
|
|
47
|
+
<i className="fa fa-spinner fa-spin" />
|
|
48
|
+
</div>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (props.type == "text") {
|
|
53
|
+
return (
|
|
54
|
+
<input
|
|
55
|
+
type="text"
|
|
56
|
+
value={value || ""}
|
|
57
|
+
className="form-control"
|
|
58
|
+
onChange={(ev) => {
|
|
59
|
+
setValue(ev.target.value || null)
|
|
60
|
+
}}
|
|
61
|
+
onKeyDown={(ev) => {
|
|
62
|
+
if (ev.keyCode == 13) {
|
|
63
|
+
editorOptions.onEndEdit()
|
|
64
|
+
}
|
|
65
|
+
}}
|
|
66
|
+
style={{ height: editorOptions.height }}
|
|
67
|
+
ref={(node) => {
|
|
68
|
+
if (node) {
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
if (node) {
|
|
71
|
+
node.focus()
|
|
72
|
+
}
|
|
73
|
+
}, 0)
|
|
74
|
+
}
|
|
75
|
+
}}
|
|
76
|
+
/>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (props.type == "number") {
|
|
81
|
+
return (
|
|
82
|
+
<NumberInput
|
|
83
|
+
value={value}
|
|
84
|
+
onChange={setValue}
|
|
85
|
+
onValid={setValid}
|
|
86
|
+
height={editorOptions.height}
|
|
87
|
+
onEnter={editorOptions.onEndEdit}
|
|
88
|
+
/>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (props.type == "enum") {
|
|
93
|
+
return <EnumEditor value={value} onChange={setValue} enumValues={props.enumValues!} locale={props.locale} />
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (props.type == "enumset") {
|
|
97
|
+
return <EnumsetEditor value={value} onChange={setValue} enumValues={props.enumValues!} locale={props.locale} />
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (props.type == "boolean") {
|
|
101
|
+
return <BooleanEditor value={value} onChange={setValue} />
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (props.type == "date") {
|
|
105
|
+
return <DateEditor value={value} onChange={setValue} locale={props.locale} />
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (props.type == "datetime") {
|
|
109
|
+
return <DatetimeEditor value={value} onChange={setValue} locale={props.locale} />
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (props.type == "id") {
|
|
113
|
+
return (
|
|
114
|
+
<IdLiteralComponent
|
|
115
|
+
schema={props.schema}
|
|
116
|
+
dataSource={props.dataSource}
|
|
117
|
+
idTable={props.idTable!}
|
|
118
|
+
value={value}
|
|
119
|
+
onChange={setValue}
|
|
120
|
+
/>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (props.type == "id[]") {
|
|
125
|
+
return (
|
|
126
|
+
<IdLiteralComponent
|
|
127
|
+
schema={props.schema}
|
|
128
|
+
dataSource={props.dataSource}
|
|
129
|
+
idTable={props.idTable!}
|
|
130
|
+
value={value}
|
|
131
|
+
onChange={setValue}
|
|
132
|
+
multi
|
|
133
|
+
/>
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// if (props.type == "geometry") {
|
|
138
|
+
// const str = value.type == "Point" ? `${value.coordinates[1].toFixed(6)} ${value.coordinates[0].toFixed(6)}` : value.type
|
|
139
|
+
// return <div className="custom-table-grid-cell-text">
|
|
140
|
+
// { str }
|
|
141
|
+
// </div>
|
|
142
|
+
// }
|
|
143
|
+
|
|
144
|
+
// TODO
|
|
145
|
+
// text[]
|
|
146
|
+
// image
|
|
147
|
+
// imagelist
|
|
148
|
+
// json
|
|
149
|
+
|
|
150
|
+
return <div />
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Number input that calls onChange when number is valid and updates valid status */
|
|
154
|
+
const NumberInput = (props: {
|
|
155
|
+
value: number | null
|
|
156
|
+
height: number
|
|
157
|
+
onChange: (value: number | null) => void
|
|
158
|
+
onValid: (valid: boolean) => void
|
|
159
|
+
onEnter: () => void
|
|
160
|
+
}) => {
|
|
161
|
+
const [str, setStr] = useState(props.value != null ? props.value + "" : "")
|
|
162
|
+
|
|
163
|
+
const handleChange = (ev: ChangeEvent<HTMLInputElement>) => {
|
|
164
|
+
const text = ev.target.value
|
|
165
|
+
setStr(text)
|
|
166
|
+
if (!text) {
|
|
167
|
+
props.onChange(null)
|
|
168
|
+
props.onValid(true)
|
|
169
|
+
} else {
|
|
170
|
+
const num = parseFloat(text)
|
|
171
|
+
if (!isNaN(num)) {
|
|
172
|
+
props.onChange(num)
|
|
173
|
+
props.onValid(true)
|
|
174
|
+
} else {
|
|
175
|
+
props.onValid(false)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<input
|
|
182
|
+
type="number"
|
|
183
|
+
value={str}
|
|
184
|
+
className="form-control"
|
|
185
|
+
onChange={handleChange}
|
|
186
|
+
style={{ height: props.height }}
|
|
187
|
+
onKeyDown={(ev) => {
|
|
188
|
+
if (ev.keyCode == 13) {
|
|
189
|
+
props.onEnter()
|
|
190
|
+
}
|
|
191
|
+
}}
|
|
192
|
+
ref={(node) => {
|
|
193
|
+
if (node) {
|
|
194
|
+
setTimeout(() => {
|
|
195
|
+
if (node) {
|
|
196
|
+
node.focus()
|
|
197
|
+
}
|
|
198
|
+
}, 0)
|
|
199
|
+
}
|
|
200
|
+
}}
|
|
201
|
+
/>
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Editor for an enum value */
|
|
206
|
+
const EnumEditor = (props: {
|
|
207
|
+
value: any
|
|
208
|
+
onChange: (value: any) => void
|
|
209
|
+
enumValues: EnumValue[]
|
|
210
|
+
locale?: string
|
|
211
|
+
}) => {
|
|
212
|
+
const options = props.enumValues.map((v) => ({ label: ExprUtils.localizeString(v.name, props.locale), value: v.id }))
|
|
213
|
+
return (
|
|
214
|
+
<ReactSelect
|
|
215
|
+
options={options}
|
|
216
|
+
isClearable={true}
|
|
217
|
+
onChange={(opt: any) => props.onChange(opt ? (opt as any).value : null)}
|
|
218
|
+
value={options.find((opt: any) => opt.value == props.value) || null}
|
|
219
|
+
styles={{
|
|
220
|
+
// Keep menu above modal
|
|
221
|
+
menu: (style) => ({ ...style, zIndex: 2000 })
|
|
222
|
+
}}
|
|
223
|
+
ref={(node) => {
|
|
224
|
+
if (node) {
|
|
225
|
+
setTimeout(() => {
|
|
226
|
+
if (node) {
|
|
227
|
+
node.focus()
|
|
228
|
+
}
|
|
229
|
+
}, 0)
|
|
230
|
+
}
|
|
231
|
+
}}
|
|
232
|
+
/>
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** Editor for an enumset value */
|
|
237
|
+
const EnumsetEditor = (props: {
|
|
238
|
+
value: any
|
|
239
|
+
onChange: (value: any) => void
|
|
240
|
+
enumValues: EnumValue[]
|
|
241
|
+
locale?: string
|
|
242
|
+
}) => {
|
|
243
|
+
const options = props.enumValues.map((v) => ({ label: ExprUtils.localizeString(v.name, props.locale), value: v.id }))
|
|
244
|
+
|
|
245
|
+
const value = _.map(props.value || [], (v) => _.find(options, (o) => o.value == v)) || []
|
|
246
|
+
|
|
247
|
+
return (
|
|
248
|
+
<ReactSelect
|
|
249
|
+
options={options}
|
|
250
|
+
isClearable={true}
|
|
251
|
+
isMulti={true}
|
|
252
|
+
onChange={(opt: any) => {
|
|
253
|
+
props.onChange(opt && opt.length > 0 ? _.pluck(opt, "value") : null)
|
|
254
|
+
}}
|
|
255
|
+
value={value as any}
|
|
256
|
+
styles={{
|
|
257
|
+
// Keep menu above modal
|
|
258
|
+
menu: (style) => ({ ...style, zIndex: 2000 })
|
|
259
|
+
}}
|
|
260
|
+
ref={(node) => {
|
|
261
|
+
if (node) {
|
|
262
|
+
setTimeout(() => {
|
|
263
|
+
if (node) {
|
|
264
|
+
node.focus()
|
|
265
|
+
}
|
|
266
|
+
}, 0)
|
|
267
|
+
}
|
|
268
|
+
}}
|
|
269
|
+
/>
|
|
270
|
+
)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** Editor for a boolean value */
|
|
274
|
+
const BooleanEditor = (props: { value: any; onChange: (value: any) => void }) => {
|
|
275
|
+
const options = [
|
|
276
|
+
{ label: T`True`, value: true },
|
|
277
|
+
{ label: T`False`, value: false }
|
|
278
|
+
]
|
|
279
|
+
|
|
280
|
+
return (
|
|
281
|
+
<ReactSelect
|
|
282
|
+
options={options}
|
|
283
|
+
isClearable={true}
|
|
284
|
+
onChange={(opt: any) => props.onChange(opt ? (opt as any).value : null)}
|
|
285
|
+
value={options.find((opt) => opt.value == props.value) || null}
|
|
286
|
+
styles={{
|
|
287
|
+
// Keep menu above modal
|
|
288
|
+
menu: (style) => ({ ...style, zIndex: 2000 })
|
|
289
|
+
}}
|
|
290
|
+
ref={(node) => {
|
|
291
|
+
if (node) {
|
|
292
|
+
setTimeout(() => {
|
|
293
|
+
if (node) {
|
|
294
|
+
node.focus()
|
|
295
|
+
}
|
|
296
|
+
}, 0)
|
|
297
|
+
}
|
|
298
|
+
}}
|
|
299
|
+
/>
|
|
300
|
+
)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** Editor for a date */
|
|
304
|
+
const DateEditor = (props: { value: any; onChange: (value: any) => void; locale?: string }) => {
|
|
305
|
+
const momentDate = props.value ? moment(props.value, "YYYY-MM-DD") : null
|
|
306
|
+
|
|
307
|
+
const handleChange = useCallback(
|
|
308
|
+
(value: Moment) => {
|
|
309
|
+
props.onChange(value ? value.format("YYYY-MM-DD") : null)
|
|
310
|
+
},
|
|
311
|
+
[props.onChange]
|
|
312
|
+
)
|
|
313
|
+
|
|
314
|
+
return (
|
|
315
|
+
<div style={{ padding: 2 }}>
|
|
316
|
+
<DatePicker
|
|
317
|
+
isClearable={true}
|
|
318
|
+
selected={momentDate}
|
|
319
|
+
onChange={handleChange}
|
|
320
|
+
dateFormat="YYYY-MM-DD"
|
|
321
|
+
className="form-control"
|
|
322
|
+
locale={props.locale}
|
|
323
|
+
/>
|
|
324
|
+
</div>
|
|
325
|
+
)
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** Editor for a date */
|
|
329
|
+
const DatetimeEditor = (props: { value: any; onChange: (value: any) => void; locale?: string }) => {
|
|
330
|
+
const momentDate = props.value ? moment(props.value, moment.ISO_8601) : null
|
|
331
|
+
|
|
332
|
+
const handleChange = useCallback(
|
|
333
|
+
(value: Moment) => {
|
|
334
|
+
props.onChange(value ? value.toISOString() : null)
|
|
335
|
+
},
|
|
336
|
+
[props.onChange]
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
return (
|
|
340
|
+
<div style={{ padding: 2 }}>
|
|
341
|
+
<DatePicker
|
|
342
|
+
fixedHeight={true}
|
|
343
|
+
isClearable={true}
|
|
344
|
+
selected={momentDate}
|
|
345
|
+
onChange={handleChange}
|
|
346
|
+
dateFormat="YYYY-MM-DD HH:mm"
|
|
347
|
+
className="form-control"
|
|
348
|
+
showTimeSelect={true}
|
|
349
|
+
timeFormat="HH:mm"
|
|
350
|
+
locale={props.locale}
|
|
351
|
+
/>
|
|
352
|
+
</div>
|
|
353
|
+
)
|
|
354
|
+
}
|