@mwater/visualization 5.1.0 → 5.3.0
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.d.ts +10 -11
- package/lib/ColorComponent.js +78 -29
- package/lib/ColorSchemeFactory.d.ts +13 -2
- package/lib/ColorSchemeFactory.js +7 -5
- package/lib/CustomColorsContext.d.ts +6 -0
- package/lib/CustomColorsContext.js +6 -0
- package/lib/FiltersDesignerComponent.d.ts +1 -4
- package/lib/FiltersDesignerComponent.js +2 -3
- package/lib/GlobalFilter.d.ts +13 -0
- package/lib/GlobalFilter.js +2 -0
- package/lib/LocaleContextInjector.d.ts +5 -11
- package/lib/LocaleContextInjector.js +4 -12
- package/lib/MWaterAddRelatedFormComponent.js +3 -3
- package/lib/MWaterAddRelatedIndicatorComponent.d.ts +1 -4
- package/lib/MWaterAddRelatedIndicatorComponent.js +6 -6
- package/lib/MWaterCompleteTableSelectComponent.d.ts +7 -25
- package/lib/MWaterCompleteTableSelectComponent.js +36 -36
- package/lib/MWaterContextComponent.d.ts +19 -9
- package/lib/MWaterContextComponent.js +38 -22
- package/lib/MWaterCustomTablesetListComponent.js +9 -3
- package/lib/MWaterGlobalFiltersComponent.d.ts +6 -5
- package/lib/MWaterGlobalFiltersComponent.js +4 -4
- package/lib/MWaterLoaderComponent.d.ts +15 -3
- package/lib/MWaterLoaderComponent.js +11 -2
- package/lib/MWaterTableSelectComponent.d.ts +1 -4
- package/lib/MWaterTableSelectComponent.js +10 -12
- package/lib/UIComponents.d.ts +2 -2
- package/lib/UIComponents.js +4 -12
- package/lib/axes/Axis.d.ts +20 -25
- package/lib/axes/AxisBuilder.d.ts +7 -4
- package/lib/axes/AxisBuilder.js +12 -8
- package/lib/axes/AxisComponent.d.ts +6 -9
- package/lib/axes/AxisComponent.js +1 -2
- package/lib/axes/ColorPaletteCollectionComponent.d.ts +5 -12
- package/lib/axes/ColorPaletteCollectionComponent.js +67 -36
- package/lib/dashboards/DashboardComponent.d.ts +4 -17
- package/lib/dashboards/DashboardComponent.js +20 -67
- package/lib/dashboards/DashboardDesign.d.ts +5 -20
- package/lib/dashboards/DashboardUpgrader.js +36 -1
- package/lib/dashboards/DashboardViewComponent.d.ts +5 -34
- package/lib/dashboards/DashboardViewComponent.js +112 -136
- package/lib/dashboards/FontStyleEditor.d.ts +8 -0
- package/lib/dashboards/FontStyleEditor.js +130 -0
- package/lib/dashboards/LayoutOptionsComponent.d.ts +0 -1
- package/lib/dashboards/LayoutOptionsComponent.js +209 -39
- package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -2
- package/lib/dashboards/ServerDashboardDataSource.js +52 -33
- package/lib/dashboards/SettingsModalComponent.d.ts +4 -15
- package/lib/dashboards/SettingsModalComponent.js +24 -38
- package/lib/dashboards/WidgetComponent.d.ts +3 -3
- package/lib/dashboards/WidgetComponent.js +3 -6
- package/lib/dashboards/WidgetDataSourcePrioritizer.d.ts +20 -0
- package/lib/dashboards/WidgetDataSourcePrioritizer.js +72 -0
- package/lib/dashboards/layoutOptions.d.ts +83 -0
- package/lib/dashboards/layoutOptions.js +436 -10
- package/lib/datagrids/DatagridComponent.d.ts +2 -9
- package/lib/datagrids/DatagridDataSource.d.ts +3 -3
- package/lib/datagrids/DatagridDataSource.js +0 -14
- package/lib/datagrids/DatagridDesign.d.ts +7 -6
- package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -93
- package/lib/datagrids/DatagridDesignerComponent.js +8 -6
- package/lib/datagrids/DatagridViewComponent.js +1 -1
- package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -20
- package/lib/datagrids/FindReplaceModalComponent.js +27 -13
- package/lib/datagrids/ServerDatagridDataSource.d.ts +8 -7
- package/lib/datagrids/ServerDatagridDataSource.js +88 -36
- package/lib/demo.js +4 -4
- package/lib/index.css +5 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +0 -1
- package/lib/layouts/LayoutManager.d.ts +33 -29
- package/lib/layouts/LayoutManager.js +2 -8
- package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +26 -56
- package/lib/layouts/blocks/BlocksDisplayComponent.js +122 -205
- package/lib/layouts/blocks/BlocksLayoutManager.d.ts +6 -22
- package/lib/layouts/blocks/BlocksLayoutManager.js +5 -14
- package/lib/layouts/blocks/HorizontalBlockComponent.d.ts +5 -4
- package/lib/layouts/blocks/HorizontalBlockComponent.js +5 -5
- package/lib/layouts/grid/GridLayoutManager.d.ts +2 -1
- package/lib/mWaterLoader.d.ts +2 -0
- package/lib/mWaterLoader.js +2 -1
- package/lib/maps/AddLayerComponent.d.ts +6 -8
- package/lib/maps/AddLayerComponent.js +6 -6
- package/lib/maps/BingLayer.js +10 -20
- package/lib/maps/BufferLayer.js +5 -2
- package/lib/maps/ChoroplethLayer.js +2 -1
- package/lib/maps/ClusterLayer.js +3 -1
- package/lib/maps/DirectMapDataSource.d.ts +5 -2
- package/lib/maps/DirectMapDataSource.js +2 -1
- package/lib/maps/EditPopupComponent.js +2 -1
- package/lib/maps/GridLayer.js +5 -3
- package/lib/maps/GridLayerDesigner.js +0 -1
- package/lib/maps/LayerSwitcherComponent.js +1 -1
- package/lib/maps/MapComponent.d.ts +3 -11
- package/lib/maps/MapComponent.js +3 -3
- package/lib/maps/MapDesign.d.ts +2 -13
- package/lib/maps/MapFiltersDesignerComponent.d.ts +0 -4
- package/lib/maps/MapFiltersDesignerComponent.js +4 -5
- package/lib/maps/MarkersLayer.js +30 -25
- package/lib/maps/RasterMapViewComponent.d.ts +3 -13
- package/lib/maps/RasterMapViewComponent.js +3 -3
- package/lib/maps/RegionSelectComponent.d.ts +2 -1
- package/lib/maps/ServerMapDataSource.d.ts +3 -4
- package/lib/maps/ServerMapDataSource.js +5 -5
- package/lib/maps/VectorMapViewComponent.js +2 -1
- package/lib/maps/mapSymbols.js +2 -0
- package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/lib/maps/vectorMaps.d.ts +1 -0
- package/lib/maps/vectorMaps.js +70 -56
- package/lib/quickfilter/QuickfilterCompiler.d.ts +1 -1
- package/lib/quickfilter/QuickfiltersComponent.d.ts +1 -4
- package/lib/quickfilter/QuickfiltersComponent.js +3 -3
- package/lib/richtext/DropdownPaletteItem.d.ts +32 -0
- package/lib/richtext/DropdownPaletteItem.js +82 -0
- package/lib/richtext/FontColorPaletteItem.d.ts +1 -5
- package/lib/richtext/FontColorPaletteItem.js +32 -27
- package/lib/richtext/ItemsHtmlConverter.js +12 -3
- package/lib/richtext/RichTextComponent.d.ts +26 -52
- package/lib/richtext/RichTextComponent.js +166 -128
- package/lib/valueFormatter.js +6 -1
- package/lib/wellknown.d.ts +5 -0
- package/lib/wellknown.js +288 -0
- package/lib/widgets/DropdownWidgetComponent.d.ts +8 -25
- package/lib/widgets/DropdownWidgetComponent.js +48 -25
- package/lib/widgets/IFrameWidgetComponent.d.ts +3 -11
- package/lib/widgets/ImageWidgetComponent.d.ts +8 -27
- package/lib/widgets/MapWidget.d.ts +4 -7
- package/lib/widgets/MapWidget.js +2 -1
- package/lib/widgets/MarkdownWidget.d.ts +2 -7
- package/lib/widgets/TOCWidget.d.ts +2 -9
- package/lib/widgets/TOCWidget.js +2 -1
- package/lib/widgets/Widget.d.ts +2 -0
- package/lib/widgets/WidgetDataSource.d.ts +3 -1
- package/lib/widgets/charts/Chart.d.ts +0 -1
- package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartViewComponent.js +11 -3
- package/lib/widgets/charts/ChartWidget.d.ts +1 -74
- package/lib/widgets/charts/ChartWidget.js +4 -183
- package/lib/widgets/charts/ChartWidgetComponent.d.ts +51 -0
- package/lib/widgets/charts/ChartWidgetComponent.js +167 -0
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.d.ts +1 -4
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +4 -4
- package/lib/widgets/charts/imagemosaic/ImagePopupComponent.d.ts +2 -7
- package/lib/widgets/charts/layered/LayeredChart.d.ts +5 -10
- package/lib/widgets/charts/layered/LayeredChart.js +6 -7
- package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +4 -2
- package/lib/widgets/charts/layered/LayeredChartCompiler.js +46 -32
- package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +4 -0
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +5 -31
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +21 -3
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +1 -7
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -1
- package/lib/widgets/charts/layered/LayeredChartViewComponent.d.ts +1 -4
- package/lib/widgets/charts/layered/LayeredChartViewComponent.js +89 -38
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +5 -105
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.js +122 -166
- package/lib/widgets/charts/pivot/PivotChart.d.ts +6 -0
- package/lib/widgets/charts/pivot/PivotChart.js +47 -17
- package/lib/widgets/charts/pivot/PivotChartDesign.d.ts +11 -0
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +11 -7
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +1 -1
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +2 -2
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +20 -36
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +0 -1
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.d.ts +23 -2
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +215 -181
- package/lib/widgets/charts/pivot/PivotChartUtils.d.ts +2 -2
- package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +9 -47
- package/lib/widgets/charts/pivot/PivotChartViewComponent.js +20 -60
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +55 -58
- package/lib/widgets/charts/table/TableChart.js +8 -4
- package/lib/widgets/charts/table/TableChartDesignerComponent.js +3 -3
- package/lib/widgets/charts/table/TableChartViewComponent.js +30 -16
- package/lib/widgets/text/ExprInsertModalComponent.d.ts +2 -13
- package/lib/widgets/text/ExprUpdateModalComponent.d.ts +2 -13
- package/lib/widgets/text/TextComponent.d.ts +5 -12
- package/lib/widgets/text/TextComponent.js +19 -39
- package/lib/widgets/text/TextWidget.d.ts +2 -1
- package/lib/widgets/text/TextWidget.js +5 -1
- package/lib/widgets/text/TextWidgetComponent.d.ts +15 -3
- package/lib/widgets/text/TextWidgetComponent.js +76 -19
- package/lib/widgets/text/TextWidgetDesign.d.ts +16 -2
- package/lib/widgets/text/TextWidgetDesign.js +6 -0
- package/package.json +4 -4
- package/src/ColorComponent.tsx +177 -0
- package/src/ColorSchemeFactory.ts +12 -6
- package/src/CustomColorsContext.tsx +8 -0
- package/src/FiltersDesignerComponent.ts +3 -4
- package/src/GlobalFilter.ts +17 -0
- package/src/LocaleContextInjector.tsx +14 -13
- package/src/MWaterAddRelatedFormComponent.ts +3 -3
- package/src/MWaterAddRelatedIndicatorComponent.ts +6 -6
- package/src/MWaterCompleteTableSelectComponent.tsx +36 -36
- package/src/MWaterContextComponent.tsx +42 -33
- package/src/MWaterCustomTablesetListComponent.tsx +21 -3
- package/src/MWaterGlobalFiltersComponent.ts +8 -8
- package/src/MWaterLoaderComponent.ts +14 -4
- package/src/MWaterTableSelectComponent.tsx +11 -12
- package/src/{UIComponents.ts → UIComponents.tsx} +7 -15
- package/src/axes/Axis.ts +24 -25
- package/src/axes/AxisBuilder.ts +16 -13
- package/src/axes/AxisComponent.ts +3 -4
- package/src/axes/{ColorPaletteCollectionComponent.ts → ColorPaletteCollectionComponent.tsx} +87 -61
- package/src/dashboards/DashboardComponent.tsx +73 -147
- package/src/dashboards/DashboardDesign.ts +5 -25
- package/src/dashboards/DashboardUpgrader.ts +41 -1
- package/src/dashboards/DashboardViewComponent.tsx +313 -0
- package/src/dashboards/FontStyleEditor.tsx +166 -0
- package/src/dashboards/LayoutOptionsComponent.tsx +377 -71
- package/src/dashboards/ServerDashboardDataSource.ts +52 -33
- package/src/dashboards/SettingsModalComponent.tsx +170 -0
- package/src/dashboards/WidgetComponent.tsx +6 -12
- package/src/dashboards/WidgetDataSourcePrioritizer.ts +82 -0
- package/src/dashboards/layoutOptions.tsx +581 -0
- package/src/datagrids/DatagridDataSource.ts +6 -12
- package/src/datagrids/DatagridDesign.ts +8 -3
- package/src/datagrids/DatagridDesignerComponent.tsx +22 -18
- package/src/datagrids/DatagridViewComponent.ts +3 -3
- package/src/datagrids/ExprCellComponent.ts +0 -1
- package/src/datagrids/FindReplaceModalComponent.ts +39 -22
- package/src/datagrids/ServerDatagridDataSource.ts +107 -45
- package/src/demo.ts +4 -4
- package/src/index.css +5 -0
- package/src/index.ts +2 -1
- package/src/layouts/LayoutManager.ts +44 -42
- package/src/layouts/blocks/BlocksDisplayComponent.tsx +498 -0
- package/src/layouts/blocks/BlocksLayoutManager.ts +6 -15
- package/src/layouts/blocks/HorizontalBlockComponent.ts +9 -8
- package/src/mWaterLoader.ts +4 -1
- package/src/maps/AddLayerComponent.ts +9 -9
- package/src/maps/BingLayer.ts +16 -26
- package/src/maps/BufferLayer.ts +5 -2
- package/src/maps/ChoroplethLayer.ts +2 -1
- package/src/maps/ClusterLayer.ts +3 -1
- package/src/maps/DirectMapDataSource.ts +12 -3
- package/src/maps/EditPopupComponent.ts +2 -1
- package/src/maps/GridLayer.ts +5 -3
- package/src/maps/GridLayerDesigner.tsx +0 -1
- package/src/maps/LayerSwitcherComponent.tsx +1 -1
- package/src/maps/MapComponent.ts +3 -3
- package/src/maps/MapDesign.ts +2 -17
- package/src/maps/{MapFiltersDesignerComponent.ts → MapFiltersDesignerComponent.tsx} +25 -25
- package/src/maps/MarkersLayer.ts +38 -41
- package/src/maps/RasterMapViewComponent.ts +3 -3
- package/src/maps/ServerMapDataSource.ts +8 -8
- package/src/maps/VectorMapViewComponent.tsx +2 -2
- package/src/maps/mapSymbols.ts +2 -0
- package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/src/maps/vectorMaps.tsx +88 -74
- package/src/quickfilter/QuickfilterCompiler.ts +1 -1
- package/src/quickfilter/QuickfiltersComponent.ts +3 -3
- package/src/richtext/DropdownPaletteItem.tsx +144 -0
- package/src/richtext/FontColorPaletteItem.tsx +160 -0
- package/src/richtext/ItemsHtmlConverter.ts +15 -5
- package/src/richtext/RichTextComponent.tsx +274 -232
- package/src/valueFormatter.ts +5 -1
- package/src/wellknown.ts +286 -0
- package/src/widgets/DropdownWidgetComponent.tsx +75 -0
- package/src/widgets/MapWidget.ts +5 -2
- package/src/widgets/TOCWidget.ts +2 -1
- package/src/widgets/Widget.ts +3 -0
- package/src/widgets/WidgetDataSource.ts +3 -1
- package/src/widgets/charts/Chart.ts +1 -1
- package/src/widgets/charts/ChartViewComponent.ts +16 -3
- package/src/widgets/charts/ChartWidget.ts +3 -275
- package/src/widgets/charts/ChartWidgetComponent.tsx +281 -0
- package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +4 -4
- package/src/widgets/charts/layered/LayeredChart.ts +4 -6
- package/src/widgets/charts/layered/LayeredChartCompiler.ts +80 -63
- package/src/widgets/charts/layered/LayeredChartDesign.ts +7 -1
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +43 -10
- package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +6 -6
- package/src/widgets/charts/layered/LayeredChartViewComponent.ts +140 -88
- package/src/widgets/charts/pivot/IntersectionDesignerComponent.tsx +305 -221
- package/src/widgets/charts/pivot/PivotChart.ts +56 -18
- package/src/widgets/charts/pivot/PivotChartDesign.ts +12 -0
- package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +4 -3
- package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +39 -76
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +0 -1
- package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +230 -189
- package/src/widgets/charts/pivot/PivotChartUtils.ts +4 -4
- package/src/widgets/charts/pivot/{PivotChartViewComponent.ts → PivotChartViewComponent.tsx} +86 -89
- package/src/widgets/charts/table/TableChart.ts +8 -4
- package/src/widgets/charts/table/TableChartDesignerComponent.ts +4 -4
- package/src/widgets/charts/table/TableChartViewComponent.ts +32 -19
- package/src/widgets/text/TextComponent.tsx +47 -49
- package/src/widgets/text/TextWidget.ts +8 -3
- package/src/widgets/text/TextWidgetComponent.tsx +249 -0
- package/src/widgets/text/TextWidgetDesign.ts +26 -2
- package/src/ColorComponent.ts +0 -117
- package/src/dashboards/DashboardViewComponent.ts +0 -304
- package/src/dashboards/SettingsModalComponent.ts +0 -169
- package/src/dashboards/layoutOptions.ts +0 -40
- package/src/layout-styles.css +0 -263
- package/src/layouts/blocks/BlocksDisplayComponent.ts +0 -461
- package/src/layouts/grid/GridLayoutComponent.ts +0 -67
- package/src/layouts/grid/GridLayoutManager.ts +0 -185
- package/src/layouts/grid/LegoLayoutEngine.ts +0 -142
- package/src/layouts/grid/PaletteItemComponent.ts +0 -28
- package/src/layouts/grid/README.md +0 -14
- package/src/layouts/grid/WidgetContainerComponent.ts +0 -420
- package/src/richtext/FontColorPaletteItem.ts +0 -172
- package/src/richtext/FontSizePaletteItem.ts +0 -110
- package/src/widgets/DropdownWidgetComponent.ts +0 -78
- package/src/widgets/text/TextWidgetComponent.ts +0 -120
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _ from "lodash"
|
|
2
2
|
import $ from "jquery"
|
|
3
|
-
import PropTypes from "prop-types"
|
|
4
3
|
import React from "react"
|
|
5
4
|
const R = React.createElement
|
|
6
5
|
import querystring from "querystring"
|
|
@@ -13,6 +12,7 @@ import { MWaterCustomTablesetListComponent } from "./MWaterCustomTablesetListCom
|
|
|
13
12
|
import { MWaterMetricsTableListComponent } from "./MWaterMetricsTableListComponent"
|
|
14
13
|
import { Form } from "@mwater/forms"
|
|
15
14
|
import { MWaterAssetSystemsListComponent } from "./MWaterAssetSystemsListComponent"
|
|
15
|
+
import { LocaleContext } from "@mwater/expressions-ui/lib/contexts"
|
|
16
16
|
|
|
17
17
|
const sitesOrder: { [table: string]: number } = {
|
|
18
18
|
"entities.water_point": 1,
|
|
@@ -52,7 +52,7 @@ interface MWaterCompleteTableSelectComponentProps {
|
|
|
52
52
|
export default class MWaterCompleteTableSelectComponent extends React.Component<MWaterCompleteTableSelectComponentProps, {
|
|
53
53
|
showLegacyAssets: boolean
|
|
54
54
|
}> {
|
|
55
|
-
static
|
|
55
|
+
static contextType = LocaleContext
|
|
56
56
|
|
|
57
57
|
constructor(props: MWaterCompleteTableSelectComponentProps) {
|
|
58
58
|
super(props)
|
|
@@ -104,8 +104,8 @@ export default class MWaterCompleteTableSelectComponent extends React.Component<
|
|
|
104
104
|
_.map(types, (tableId) => {
|
|
105
105
|
table = this.props.schema.getTable(tableId)!
|
|
106
106
|
return {
|
|
107
|
-
name: ExprUtils.localizeString(table.name, this.context
|
|
108
|
-
desc: ExprUtils.localizeString(table.desc, this.context
|
|
107
|
+
name: ExprUtils.localizeString(table.name, this.context),
|
|
108
|
+
desc: ExprUtils.localizeString(table.desc, this.context),
|
|
109
109
|
onClick: this.props.onChange.bind(null, table.id)
|
|
110
110
|
}
|
|
111
111
|
})
|
|
@@ -159,8 +159,8 @@ export default class MWaterCompleteTableSelectComponent extends React.Component<
|
|
|
159
159
|
return R(uiComponents.OptionListComponent, {
|
|
160
160
|
items: _.map(sweetSenseTables, (table) => {
|
|
161
161
|
return {
|
|
162
|
-
name: ExprUtils.localizeString(table.name, this.context
|
|
163
|
-
desc: ExprUtils.localizeString(table.desc, this.context
|
|
162
|
+
name: ExprUtils.localizeString(table.name, this.context),
|
|
163
|
+
desc: ExprUtils.localizeString(table.desc, this.context),
|
|
164
164
|
onClick: this.props.onChange.bind(null, table.id)
|
|
165
165
|
}
|
|
166
166
|
})
|
|
@@ -177,7 +177,7 @@ export default class MWaterCompleteTableSelectComponent extends React.Component<
|
|
|
177
177
|
extraTables: this.props.extraTables,
|
|
178
178
|
onExtraTableAdd: this.handleExtraTableAdd,
|
|
179
179
|
onExtraTableRemove: this.handleExtraTableRemove,
|
|
180
|
-
locale: this.context
|
|
180
|
+
locale: this.context
|
|
181
181
|
})
|
|
182
182
|
}
|
|
183
183
|
|
|
@@ -191,7 +191,7 @@ export default class MWaterCompleteTableSelectComponent extends React.Component<
|
|
|
191
191
|
extraTables: this.props.extraTables,
|
|
192
192
|
onExtraTableAdd: this.handleExtraTableAdd,
|
|
193
193
|
onExtraTableRemove: this.handleExtraTableRemove,
|
|
194
|
-
locale: this.context
|
|
194
|
+
locale: this.context
|
|
195
195
|
})
|
|
196
196
|
}
|
|
197
197
|
|
|
@@ -208,8 +208,8 @@ export default class MWaterCompleteTableSelectComponent extends React.Component<
|
|
|
208
208
|
continue
|
|
209
209
|
}
|
|
210
210
|
items.push({
|
|
211
|
-
name: ExprUtils.localizeString(table.name, this.context
|
|
212
|
-
desc: ExprUtils.localizeString(table.desc, this.context
|
|
211
|
+
name: ExprUtils.localizeString(table.name, this.context),
|
|
212
|
+
desc: ExprUtils.localizeString(table.desc, this.context),
|
|
213
213
|
onClick: this.props.onChange.bind(null, table.id)
|
|
214
214
|
})
|
|
215
215
|
}
|
|
@@ -236,7 +236,7 @@ export default class MWaterCompleteTableSelectComponent extends React.Component<
|
|
|
236
236
|
extraTables: this.props.extraTables,
|
|
237
237
|
onExtraTableAdd: this.handleExtraTableAdd,
|
|
238
238
|
onExtraTableRemove: this.handleExtraTableRemove,
|
|
239
|
-
locale: this.context
|
|
239
|
+
locale: this.context
|
|
240
240
|
})
|
|
241
241
|
}
|
|
242
242
|
|
|
@@ -294,8 +294,8 @@ export default class MWaterCompleteTableSelectComponent extends React.Component<
|
|
|
294
294
|
return R(uiComponents.OptionListComponent, {
|
|
295
295
|
items: _.map(otherTables, (table) => {
|
|
296
296
|
return {
|
|
297
|
-
name: ExprUtils.localizeString(table.name, this.context
|
|
298
|
-
desc: ExprUtils.localizeString(table.desc, this.context
|
|
297
|
+
name: ExprUtils.localizeString(table.name, this.context),
|
|
298
|
+
desc: ExprUtils.localizeString(table.desc, this.context),
|
|
299
299
|
onClick: this.props.onChange.bind(null, table.id)
|
|
300
300
|
}
|
|
301
301
|
})
|
|
@@ -383,7 +383,7 @@ interface FormsListComponentState {
|
|
|
383
383
|
|
|
384
384
|
// Searchable list of forms
|
|
385
385
|
class FormsListComponent extends React.Component<FormsListComponentProps, FormsListComponentState> {
|
|
386
|
-
static
|
|
386
|
+
static contextType = LocaleContext
|
|
387
387
|
|
|
388
388
|
constructor(props: any) {
|
|
389
389
|
super(props)
|
|
@@ -424,7 +424,7 @@ class FormsListComponent extends React.Component<FormsListComponentProps, FormsL
|
|
|
424
424
|
// TODO use name instead of design.name
|
|
425
425
|
this.setState({
|
|
426
426
|
forms: _.map(forms, (form) => {
|
|
427
|
-
let desc = ExprUtils.localizeString(form.design.description,
|
|
427
|
+
let desc = ExprUtils.localizeString(form.design.description, null) || ""
|
|
428
428
|
if (desc) {
|
|
429
429
|
desc += " - "
|
|
430
430
|
}
|
|
@@ -432,7 +432,7 @@ class FormsListComponent extends React.Component<FormsListComponentProps, FormsL
|
|
|
432
432
|
|
|
433
433
|
return {
|
|
434
434
|
id: form._id,
|
|
435
|
-
name: ExprUtils.localizeString(form.design.name,
|
|
435
|
+
name: ExprUtils.localizeString(form.design.name, null),
|
|
436
436
|
desc
|
|
437
437
|
}
|
|
438
438
|
})
|
|
@@ -447,7 +447,7 @@ class FormsListComponent extends React.Component<FormsListComponentProps, FormsL
|
|
|
447
447
|
confirm(
|
|
448
448
|
`Remove ${ExprUtils.localizeString(
|
|
449
449
|
table.name,
|
|
450
|
-
this.context
|
|
450
|
+
this.context
|
|
451
451
|
)}? Any widgets that depend on it will no longer work properly.`
|
|
452
452
|
)
|
|
453
453
|
) {
|
|
@@ -496,8 +496,8 @@ class FormsListComponent extends React.Component<FormsListComponentProps, FormsL
|
|
|
496
496
|
? R(uiComponents.OptionListComponent, {
|
|
497
497
|
items: _.map(tables, (table) => {
|
|
498
498
|
return {
|
|
499
|
-
name: ExprUtils.localizeString(table.name, this.context
|
|
500
|
-
desc: ExprUtils.localizeString(table.desc, this.context
|
|
499
|
+
name: ExprUtils.localizeString(table.name, this.context),
|
|
500
|
+
desc: ExprUtils.localizeString(table.desc, this.context),
|
|
501
501
|
onClick: this.props.onChange.bind(null, table.id),
|
|
502
502
|
onRemove: this.handleTableRemove.bind(null, table)
|
|
503
503
|
}
|
|
@@ -562,7 +562,7 @@ interface IndicatorsListComponentState {
|
|
|
562
562
|
|
|
563
563
|
// Searchable list of indicators
|
|
564
564
|
class IndicatorsListComponent extends React.Component<IndicatorsListComponentProps, IndicatorsListComponentState> {
|
|
565
|
-
static
|
|
565
|
+
static contextType = LocaleContext
|
|
566
566
|
addIndicatorConfirmPopup: AddIndicatorConfirmPopupComponent | null
|
|
567
567
|
|
|
568
568
|
constructor(props: any) {
|
|
@@ -590,7 +590,7 @@ class IndicatorsListComponent extends React.Component<IndicatorsListComponentPro
|
|
|
590
590
|
[
|
|
591
591
|
(indicator: any) => ((this.props.extraTables || []).includes("indicator_values:" + indicator._id) ? 0 : 1),
|
|
592
592
|
(indicator: any) => (indicator.design.recommended ? 0 : 1),
|
|
593
|
-
(indicator: any) => ExprUtils.localizeString(indicator.design.name, this.context
|
|
593
|
+
(indicator: any) => ExprUtils.localizeString(indicator.design.name, this.context)
|
|
594
594
|
],
|
|
595
595
|
["asc", "asc", "asc"]
|
|
596
596
|
)
|
|
@@ -598,8 +598,8 @@ class IndicatorsListComponent extends React.Component<IndicatorsListComponentPro
|
|
|
598
598
|
return this.setState({
|
|
599
599
|
indicators: _.map(indicators, (indicator) => ({
|
|
600
600
|
id: indicator._id,
|
|
601
|
-
name: ExprUtils.localizeString(indicator.design.name, this.context
|
|
602
|
-
desc: ExprUtils.localizeString(indicator.design.desc, this.context
|
|
601
|
+
name: ExprUtils.localizeString(indicator.design.name, this.context),
|
|
602
|
+
desc: ExprUtils.localizeString(indicator.design.desc, this.context)
|
|
603
603
|
}))
|
|
604
604
|
})
|
|
605
605
|
}).fail((xhr: any) => {
|
|
@@ -612,7 +612,7 @@ class IndicatorsListComponent extends React.Component<IndicatorsListComponentPro
|
|
|
612
612
|
confirm(
|
|
613
613
|
`Remove ${ExprUtils.localizeString(
|
|
614
614
|
table.name,
|
|
615
|
-
this.context
|
|
615
|
+
this.context
|
|
616
616
|
)}? Any widgets that depend on it will no longer work properly.`
|
|
617
617
|
)
|
|
618
618
|
) {
|
|
@@ -679,8 +679,8 @@ class IndicatorsListComponent extends React.Component<IndicatorsListComponentPro
|
|
|
679
679
|
? R(uiComponents.OptionListComponent, {
|
|
680
680
|
items: _.map(tables, (table) => {
|
|
681
681
|
return {
|
|
682
|
-
name: ExprUtils.localizeString(table.name, this.context
|
|
683
|
-
desc: ExprUtils.localizeString(table.desc, this.context
|
|
682
|
+
name: ExprUtils.localizeString(table.name, this.context),
|
|
683
|
+
desc: ExprUtils.localizeString(table.desc, this.context),
|
|
684
684
|
onClick: this.handleSelect.bind(null, table.id),
|
|
685
685
|
onRemove: this.handleTableRemove.bind(null, table)
|
|
686
686
|
}
|
|
@@ -738,7 +738,7 @@ class AddIndicatorConfirmPopupComponent extends React.Component<
|
|
|
738
738
|
AddIndicatorConfirmPopupComponentProps,
|
|
739
739
|
AddIndicatorConfirmPopupComponentState
|
|
740
740
|
> {
|
|
741
|
-
static
|
|
741
|
+
static contextType = LocaleContext
|
|
742
742
|
|
|
743
743
|
constructor(props: any) {
|
|
744
744
|
super(props)
|
|
@@ -781,8 +781,8 @@ are certain that you want to use the raw indicator table`
|
|
|
781
781
|
|
|
782
782
|
R(uiComponents.OptionListComponent, {
|
|
783
783
|
items: _.map(entityColumns, (entityColumn) => ({
|
|
784
|
-
name: ExprUtils.localizeString(entityColumn.name, this.context
|
|
785
|
-
desc: ExprUtils.localizeString(entityColumn.desc, this.context
|
|
784
|
+
name: ExprUtils.localizeString(entityColumn.name, this.context),
|
|
785
|
+
desc: ExprUtils.localizeString(entityColumn.desc, this.context),
|
|
786
786
|
onClick: () => {
|
|
787
787
|
// Select table
|
|
788
788
|
this.props.onChange(entityColumn.join!.toTable)
|
|
@@ -845,7 +845,7 @@ interface IssuesListComponentState {
|
|
|
845
845
|
|
|
846
846
|
// Searchable list of issue types
|
|
847
847
|
class IssuesListComponent extends React.Component<IssuesListComponentProps, IssuesListComponentState> {
|
|
848
|
-
static
|
|
848
|
+
static contextType = LocaleContext
|
|
849
849
|
|
|
850
850
|
constructor(props: any) {
|
|
851
851
|
super(props)
|
|
@@ -869,7 +869,7 @@ class IssuesListComponent extends React.Component<IssuesListComponentProps, Issu
|
|
|
869
869
|
[
|
|
870
870
|
(issueType) => ((this.props.extraTables || []).includes("issues:" + issueType._id) ? 0 : 1),
|
|
871
871
|
(issueType) => (issueType.created.by === this.props.user ? 0 : 1),
|
|
872
|
-
(issueType) => ExprUtils.localizeString(issueType.name, this.context
|
|
872
|
+
(issueType) => ExprUtils.localizeString(issueType.name, this.context)
|
|
873
873
|
],
|
|
874
874
|
["asc", "asc", "asc"]
|
|
875
875
|
)
|
|
@@ -877,8 +877,8 @@ class IssuesListComponent extends React.Component<IssuesListComponentProps, Issu
|
|
|
877
877
|
return this.setState({
|
|
878
878
|
issueTypes: _.map(issueTypes, (issueType) => ({
|
|
879
879
|
id: issueType._id,
|
|
880
|
-
name: ExprUtils.localizeString(issueType.name, this.context
|
|
881
|
-
desc: ExprUtils.localizeString(issueType.desc, this.context
|
|
880
|
+
name: ExprUtils.localizeString(issueType.name, this.context),
|
|
881
|
+
desc: ExprUtils.localizeString(issueType.desc, this.context)
|
|
882
882
|
}))
|
|
883
883
|
})
|
|
884
884
|
}).fail((xhr: any) => {
|
|
@@ -891,7 +891,7 @@ class IssuesListComponent extends React.Component<IssuesListComponentProps, Issu
|
|
|
891
891
|
confirm(
|
|
892
892
|
`Remove ${ExprUtils.localizeString(
|
|
893
893
|
table.name,
|
|
894
|
-
this.context
|
|
894
|
+
this.context
|
|
895
895
|
)}? Any widgets that depend on it will no longer work properly.`
|
|
896
896
|
)
|
|
897
897
|
) {
|
|
@@ -940,8 +940,8 @@ class IssuesListComponent extends React.Component<IssuesListComponentProps, Issu
|
|
|
940
940
|
? R(uiComponents.OptionListComponent, {
|
|
941
941
|
items: _.map(tables, (table) => {
|
|
942
942
|
return {
|
|
943
|
-
name: ExprUtils.localizeString(table.name, this.context
|
|
944
|
-
desc: ExprUtils.localizeString(table.desc, this.context
|
|
943
|
+
name: ExprUtils.localizeString(table.name, this.context),
|
|
944
|
+
desc: ExprUtils.localizeString(table.desc, this.context),
|
|
945
945
|
onClick: this.props.onChange.bind(null, table.id),
|
|
946
946
|
onRemove: this.handleTableRemove.bind(null, table)
|
|
947
947
|
}
|
|
@@ -1,15 +1,36 @@
|
|
|
1
|
-
import PropTypes from "prop-types"
|
|
2
1
|
import _ from "lodash"
|
|
3
|
-
import React from "react"
|
|
2
|
+
import React, { createContext } from "react"
|
|
4
3
|
const R = React.createElement
|
|
5
4
|
|
|
6
5
|
import MWaterTableSelectComponent from "./MWaterTableSelectComponent"
|
|
7
6
|
import MWaterAddRelatedFormComponent from "./MWaterAddRelatedFormComponent"
|
|
8
7
|
import MWaterAddRelatedIndicatorComponent from "./MWaterAddRelatedIndicatorComponent"
|
|
9
8
|
import MWaterGlobalFiltersComponent from "./MWaterGlobalFiltersComponent"
|
|
10
|
-
import { Schema, Section } from "@mwater/expressions"
|
|
9
|
+
import { DataSource, Schema, Section } from "@mwater/expressions"
|
|
11
10
|
import { CustomTableSelectComponentFactoryContext, CustomTableSelectComponentFactoryOptions, DecorateScalarExprTreeSectionChildrenContext, DecorateScalarExprTreeSectionChildrenOptions } from "@mwater/expressions-ui"
|
|
12
11
|
import { IsScalarExprTreeSectionInitiallyOpenContext, IsScalarExprTreeSectionMatchContext } from "@mwater/expressions-ui"
|
|
12
|
+
import { GlobalFilter } from "./GlobalFilter"
|
|
13
|
+
import { AddLayerComponentProps } from "./maps/AddLayerComponent"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export interface GlobalFiltersElementFactoryProps {
|
|
17
|
+
schema: Schema
|
|
18
|
+
dataSource: DataSource
|
|
19
|
+
filterableTables: string[]
|
|
20
|
+
globalFilters?: GlobalFilter[]
|
|
21
|
+
onChange: (globalFilters: GlobalFilter[]) => void
|
|
22
|
+
|
|
23
|
+
/** If true, return null element if not applicable to filterableTables */
|
|
24
|
+
nullIfIrrelevant?: boolean
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type GlobalFiltersElementFactory = (props: GlobalFiltersElementFactoryProps) => React.ReactElement | null
|
|
28
|
+
|
|
29
|
+
export const GlobalFiltersElementFactoryContext = createContext<GlobalFiltersElementFactory | null>(null)
|
|
30
|
+
|
|
31
|
+
export type AddLayerElementFactory = (props: AddLayerComponentProps) => React.ReactElement | null
|
|
32
|
+
|
|
33
|
+
export const AddLayerElementFactoryContext = createContext<AddLayerElementFactory | undefined>(undefined)
|
|
13
34
|
|
|
14
35
|
/**
|
|
15
36
|
* Creates several contexts to allow selecting of a table in an mWater-friendly way
|
|
@@ -18,7 +39,7 @@ import { IsScalarExprTreeSectionInitiallyOpenContext, IsScalarExprTreeSectionMat
|
|
|
18
39
|
export default class MWaterContextComponent extends React.Component<{
|
|
19
40
|
apiUrl: string
|
|
20
41
|
client?: string
|
|
21
|
-
/**
|
|
42
|
+
/** user id of logged in user */
|
|
22
43
|
user?: string
|
|
23
44
|
schema: Schema
|
|
24
45
|
/** Extra tables to load in schema. Forms are not loaded by default as they are too many */
|
|
@@ -26,14 +47,8 @@ export default class MWaterContextComponent extends React.Component<{
|
|
|
26
47
|
/** Called when extra tables are changed and schema will be reloaded */
|
|
27
48
|
onExtraTablesChange?: (extraTables: string[]) => void
|
|
28
49
|
/** Override default add layer component. See AddLayerComponent for details */
|
|
29
|
-
addLayerElementFactory?:
|
|
50
|
+
addLayerElementFactory?: AddLayerElementFactory
|
|
30
51
|
}> {
|
|
31
|
-
static childContextTypes = {
|
|
32
|
-
addLayerElementFactory: PropTypes.func, // Call with props of AddLayerComponent
|
|
33
|
-
globalFiltersElementFactory: PropTypes.func, // Call with props { schema, dataSource, filterableTables, globalFilters, onChange, nullIfIrrelevant }.
|
|
34
|
-
// Displays a component to edit global filters. nullIfIrrelevant causes null element if not applicable to filterableTables
|
|
35
|
-
}
|
|
36
|
-
|
|
37
52
|
createTableSelectElementFactory = (options: CustomTableSelectComponentFactoryOptions) => {
|
|
38
53
|
return (
|
|
39
54
|
<MWaterTableSelectComponent
|
|
@@ -51,22 +66,12 @@ export default class MWaterContextComponent extends React.Component<{
|
|
|
51
66
|
)
|
|
52
67
|
}
|
|
53
68
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (this.props.addLayerElementFactory) {
|
|
58
|
-
context.addLayerElementFactory = this.props.addLayerElementFactory
|
|
69
|
+
createGlobalFiltersElementFactory = (props: GlobalFiltersElementFactoryProps) => {
|
|
70
|
+
if (props.nullIfIrrelevant && !_.any(props.filterableTables, (t: string) => t.match(/^entities./))) {
|
|
71
|
+
return null
|
|
59
72
|
}
|
|
60
73
|
|
|
61
|
-
|
|
62
|
-
if (props.nullIfIrrelevant && !_.any(props.filterableTables, (t: string) => t.match(/^entities./))) {
|
|
63
|
-
return null
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return React.createElement(MWaterGlobalFiltersComponent, props)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return context
|
|
74
|
+
return <MWaterGlobalFiltersComponent {...props} />
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
isScalarExprTreeSectionMatch = (options: { tableId: string; section: Section; filter?: string }) => {
|
|
@@ -128,13 +133,17 @@ export default class MWaterContextComponent extends React.Component<{
|
|
|
128
133
|
|
|
129
134
|
render() {
|
|
130
135
|
return <CustomTableSelectComponentFactoryContext.Provider value={this.createTableSelectElementFactory}>
|
|
131
|
-
<
|
|
132
|
-
<
|
|
133
|
-
<
|
|
134
|
-
{this.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
<GlobalFiltersElementFactoryContext.Provider value={this.createGlobalFiltersElementFactory}>
|
|
137
|
+
<IsScalarExprTreeSectionMatchContext.Provider value={this.isScalarExprTreeSectionMatch}>
|
|
138
|
+
<IsScalarExprTreeSectionInitiallyOpenContext.Provider value={this.isScalarExprTreeSectionInitiallyOpen}>
|
|
139
|
+
<DecorateScalarExprTreeSectionChildrenContext.Provider value={this.decorateScalarExprTreeSectionChildren}>
|
|
140
|
+
<AddLayerElementFactoryContext.Provider value={this.props.addLayerElementFactory}>
|
|
141
|
+
{this.props.children}
|
|
142
|
+
</AddLayerElementFactoryContext.Provider>
|
|
143
|
+
</DecorateScalarExprTreeSectionChildrenContext.Provider>
|
|
144
|
+
</IsScalarExprTreeSectionInitiallyOpenContext.Provider>
|
|
145
|
+
|
|
146
|
+
</IsScalarExprTreeSectionMatchContext.Provider>
|
|
147
|
+
</GlobalFiltersElementFactoryContext.Provider> </CustomTableSelectComponentFactoryContext.Provider>
|
|
139
148
|
}
|
|
140
149
|
}
|
|
@@ -27,14 +27,19 @@ export const MWaterCustomTablesetListComponent = (props: {
|
|
|
27
27
|
const [search, setSearch] = useState<string | null>("")
|
|
28
28
|
const [extraTableNeeded, setExtraTableNeeded] = useState<string>()
|
|
29
29
|
|
|
30
|
+
const [showSystem, setShowSystem] = useState(false)
|
|
31
|
+
|
|
30
32
|
// Get list of all tablesets
|
|
31
33
|
useEffect(() => {
|
|
32
34
|
fetch(`${props.apiUrl}custom_tablesets?client=${props.client || ""}`)
|
|
33
35
|
.then((response) => response.json())
|
|
34
|
-
.then((
|
|
36
|
+
.then((tablesets) => {
|
|
37
|
+
// Filter out non-normal
|
|
38
|
+
tablesets = tablesets.filter((ts: CustomTableset) => ts.type === "normal")
|
|
39
|
+
|
|
35
40
|
// Put included ones first
|
|
36
41
|
setTablesets(
|
|
37
|
-
_.sortByAll(
|
|
42
|
+
_.sortByAll(tablesets, [
|
|
38
43
|
(ts) => (props.extraTables.some((t) => (t || "").startsWith(`custom.${ts.code}.`)) ? 0 : 1),
|
|
39
44
|
(ts) => ExprUtils.localizeString(ts.design.name, props.locale)
|
|
40
45
|
])
|
|
@@ -117,10 +122,17 @@ export const MWaterCustomTablesetListComponent = (props: {
|
|
|
117
122
|
)
|
|
118
123
|
}
|
|
119
124
|
|
|
125
|
+
const visibleTablesets = tablesets.filter((ts) => (showSystem || !ts.design.system) && !ts.design.deprecated)
|
|
126
|
+
|
|
120
127
|
return (
|
|
121
128
|
<div>
|
|
122
129
|
<TextInput value={search} onChange={setSearch} placeholder="Search..." />
|
|
123
|
-
{
|
|
130
|
+
{visibleTablesets.map((ts) => renderTableset(ts))}
|
|
131
|
+
<div>
|
|
132
|
+
<button className="btn btn-link btn-sm" onClick={() => setShowSystem(!showSystem)}>
|
|
133
|
+
{showSystem ? "Hide system tables" : "Show system tables"}
|
|
134
|
+
</button>
|
|
135
|
+
</div>
|
|
124
136
|
</div>
|
|
125
137
|
)
|
|
126
138
|
}
|
|
@@ -137,5 +149,11 @@ interface CustomTableset {
|
|
|
137
149
|
desc?: LocalizedString
|
|
138
150
|
|
|
139
151
|
tables: Table[]
|
|
152
|
+
|
|
153
|
+
/** True if tableset is deprecated */
|
|
154
|
+
deprecated?: boolean
|
|
155
|
+
|
|
156
|
+
/** True if tableset is for system use and should only be visible to admins in the UI */
|
|
157
|
+
system?: boolean
|
|
140
158
|
}
|
|
141
159
|
}
|
|
@@ -2,19 +2,19 @@ import _ from "lodash"
|
|
|
2
2
|
import React from "react"
|
|
3
3
|
const R = React.createElement
|
|
4
4
|
|
|
5
|
-
import querystring from "querystring"
|
|
6
5
|
import * as ui from "@mwater/react-library/lib/bootstrap"
|
|
7
6
|
import { IdLiteralComponent } from "@mwater/expressions-ui"
|
|
8
7
|
import { DataSource, Schema } from "@mwater/expressions"
|
|
8
|
+
import { GlobalFilter } from "./GlobalFilter"
|
|
9
9
|
|
|
10
10
|
export interface MWaterGlobalFiltersComponentProps {
|
|
11
11
|
/** Schema of the database */
|
|
12
12
|
schema: Schema
|
|
13
13
|
/** Data source to use to get values */
|
|
14
14
|
dataSource: DataSource
|
|
15
|
-
filterableTables:
|
|
16
|
-
globalFilters?:
|
|
17
|
-
onChange:
|
|
15
|
+
filterableTables: string[]
|
|
16
|
+
globalFilters?: GlobalFilter[]
|
|
17
|
+
onChange: (globalFilters: GlobalFilter[]) => void
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
// Control to edit the global filters (_managed_by and admin_region)
|
|
@@ -36,7 +36,7 @@ export default class MWaterGlobalFiltersComponent extends React.Component<MWater
|
|
|
36
36
|
})
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
this.props.onChange(globalFilters)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
handleManagedByChange = (managedBy: any) => {
|
|
@@ -56,13 +56,13 @@ export default class MWaterGlobalFiltersComponent extends React.Component<MWater
|
|
|
56
56
|
})
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
this.props.onChange(globalFilters)
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
render() {
|
|
63
63
|
// Find managed by
|
|
64
64
|
let adminRegions, managedBy
|
|
65
|
-
const managedByEntry = _.find(this.props.globalFilters, (gf) => gf.op === "within" && gf.columnId === "_managed_by")
|
|
65
|
+
const managedByEntry = _.find(this.props.globalFilters || [], (gf) => gf.op === "within" && gf.columnId === "_managed_by")
|
|
66
66
|
if (managedByEntry) {
|
|
67
67
|
managedBy = managedByEntry.exprs[0].value.split(":")[1]
|
|
68
68
|
} else {
|
|
@@ -71,7 +71,7 @@ export default class MWaterGlobalFiltersComponent extends React.Component<MWater
|
|
|
71
71
|
|
|
72
72
|
// Find admin region
|
|
73
73
|
const adminRegionEntry = _.find(
|
|
74
|
-
this.props.globalFilters,
|
|
74
|
+
this.props.globalFilters || [],
|
|
75
75
|
(gf) => gf.op === "within any" && gf.columnId === "admin_region"
|
|
76
76
|
)
|
|
77
77
|
if (adminRegionEntry) {
|
|
@@ -6,7 +6,7 @@ import { DataSource, Schema } from "@mwater/expressions"
|
|
|
6
6
|
import AsyncLoadComponent from "@mwater/react-library/lib/AsyncLoadComponent"
|
|
7
7
|
import LoadingComponent from "@mwater/react-library/lib/LoadingComponent"
|
|
8
8
|
import mWaterLoader from "./mWaterLoader"
|
|
9
|
-
import MWaterContextComponent from "./MWaterContextComponent"
|
|
9
|
+
import MWaterContextComponent, { AddLayerElementFactory } from "./MWaterContextComponent"
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Loads an mWater schema from the server and creates child with schema and dataSource
|
|
@@ -29,10 +29,12 @@ export default class MWaterLoaderComponent extends AsyncLoadComponent<
|
|
|
29
29
|
/** Locales of the schema to load. Default is all. */
|
|
30
30
|
locales?: string[]
|
|
31
31
|
/** Override default add layer component. See AddLayerComponent for details */
|
|
32
|
-
addLayerElementFactory?:
|
|
32
|
+
addLayerElementFactory?: AddLayerElementFactory
|
|
33
33
|
children: (error: any, config?: { schema: Schema; dataSource: DataSource }) => ReactElement<any>
|
|
34
34
|
/** Custom error formatter that returns React node or string, gets passed the error response from server */
|
|
35
35
|
errorFormatter?: (data: any, defaultError: string) => string
|
|
36
|
+
/** Origin of usage. e.g. "dashboards:43445364..." */
|
|
37
|
+
origin?: string
|
|
36
38
|
},
|
|
37
39
|
{
|
|
38
40
|
error: any
|
|
@@ -73,13 +75,21 @@ export default class MWaterLoaderComponent extends AsyncLoadComponent<
|
|
|
73
75
|
share: props.share,
|
|
74
76
|
asUser: props.asUser,
|
|
75
77
|
extraTables: props.extraTables,
|
|
76
|
-
locales: props.locales
|
|
78
|
+
locales: props.locales,
|
|
79
|
+
origin: props.origin
|
|
77
80
|
},
|
|
78
81
|
(error: any, config: any) => {
|
|
79
82
|
if (error) {
|
|
80
83
|
const defaultError = `Cannot load one of the forms that this depends on. Perhaps the administrator has not shared the form with you? Details: ${error.message}`
|
|
81
84
|
if (this.props.errorFormatter) {
|
|
82
|
-
|
|
85
|
+
try {
|
|
86
|
+
const parsedError = JSON.parse(error.message)
|
|
87
|
+
if (parsedError) {
|
|
88
|
+
return callback({ error: this.props.errorFormatter(parsedError, defaultError) })
|
|
89
|
+
}
|
|
90
|
+
} catch (e) {
|
|
91
|
+
// Ignore
|
|
92
|
+
}
|
|
83
93
|
}
|
|
84
94
|
return callback({ error: defaultError })
|
|
85
95
|
}
|
|
@@ -7,7 +7,7 @@ import { ExprUtils, Schema } from "@mwater/expressions"
|
|
|
7
7
|
import MWaterResponsesFilterComponent from "./MWaterResponsesFilterComponent"
|
|
8
8
|
import ModalPopupComponent from "@mwater/react-library/lib/ModalPopupComponent"
|
|
9
9
|
import MWaterCompleteTableSelectComponent from "./MWaterCompleteTableSelectComponent"
|
|
10
|
-
import { ActiveTablesContext } from "@mwater/expressions-ui"
|
|
10
|
+
import { ActiveTablesContext, LocaleContext } from "@mwater/expressions-ui"
|
|
11
11
|
|
|
12
12
|
export interface MWaterTableSelectComponentProps {
|
|
13
13
|
/** Url to hit api */
|
|
@@ -36,9 +36,7 @@ export default class MWaterTableSelectComponent extends React.Component<
|
|
|
36
36
|
MWaterTableSelectComponentProps,
|
|
37
37
|
MWaterTableSelectComponentState
|
|
38
38
|
> {
|
|
39
|
-
static
|
|
40
|
-
locale: PropTypes.string, // e.g. "en"
|
|
41
|
-
}
|
|
39
|
+
static contextType = LocaleContext
|
|
42
40
|
|
|
43
41
|
toggleEdit: any
|
|
44
42
|
|
|
@@ -139,9 +137,12 @@ export default class MWaterTableSelectComponent extends React.Component<
|
|
|
139
137
|
},
|
|
140
138
|
forceOpen: !this.props.table, // Must have table
|
|
141
139
|
label: this.props.table
|
|
142
|
-
? ExprUtils.localizeString(this.props.schema.getTable(this.props.table)?.name, this.context
|
|
140
|
+
? ExprUtils.localizeString(this.props.schema.getTable(this.props.table)?.name, this.context)
|
|
143
141
|
: "",
|
|
144
|
-
editor
|
|
142
|
+
editor,
|
|
143
|
+
onRemove: () => {
|
|
144
|
+
this.props.onChange(null)
|
|
145
|
+
}
|
|
145
146
|
}),
|
|
146
147
|
|
|
147
148
|
// Make sure table still exists
|
|
@@ -184,9 +185,7 @@ class EditModeTableSelectComponent extends React.Component<
|
|
|
184
185
|
EditModeTableSelectComponentProps,
|
|
185
186
|
EditModeTableSelectComponentState
|
|
186
187
|
> {
|
|
187
|
-
static
|
|
188
|
-
locale: PropTypes.string, // e.g. "en"
|
|
189
|
-
}
|
|
188
|
+
static contextType = LocaleContext
|
|
190
189
|
|
|
191
190
|
constructor(props: any) {
|
|
192
191
|
super(props)
|
|
@@ -237,7 +236,7 @@ class EditModeTableSelectComponent extends React.Component<
|
|
|
237
236
|
|
|
238
237
|
// Sort by name
|
|
239
238
|
tables = _.sortBy(tables, (tableId) =>
|
|
240
|
-
ExprUtils.localizeString(this.props.schema.getTable(tableId)!.name, this.context
|
|
239
|
+
ExprUtils.localizeString(this.props.schema.getTable(tableId)!.name, this.context)
|
|
241
240
|
)
|
|
242
241
|
|
|
243
242
|
return tables
|
|
@@ -279,8 +278,8 @@ class EditModeTableSelectComponent extends React.Component<
|
|
|
279
278
|
<OptionListComponent items={this.getTableShortlist(activeTables).map((tableId) => {
|
|
280
279
|
const table = this.props.schema.getTable(tableId)!
|
|
281
280
|
return {
|
|
282
|
-
name: ExprUtils.localizeString(table.name, this.context
|
|
283
|
-
desc: ExprUtils.localizeString(table.desc, this.context
|
|
281
|
+
name: ExprUtils.localizeString(table.name, this.context),
|
|
282
|
+
desc: ExprUtils.localizeString(table.desc, this.context),
|
|
284
283
|
onClick: () => this.props.onChange(table.id)
|
|
285
284
|
}
|
|
286
285
|
})} />
|
|
@@ -9,6 +9,7 @@ import { Radio } from "@mwater/react-library/lib/bootstrap"
|
|
|
9
9
|
export interface SectionComponentProps {
|
|
10
10
|
icon?: string
|
|
11
11
|
label?: any
|
|
12
|
+
required?: boolean
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
// Miscellaneous ui components
|
|
@@ -28,7 +29,8 @@ export class SectionComponent extends React.Component<SectionComponentProps> {
|
|
|
28
29
|
this.props.icon && this.props.icon.match(/^glyphicon-/)
|
|
29
30
|
? [R("span", { className: `glyphicon ${this.props.icon}` }), " "]
|
|
30
31
|
: undefined,
|
|
31
|
-
this.props.label
|
|
32
|
+
this.props.label,
|
|
33
|
+
this.props.required ? <span style={{ color: "red" }}> *</span> : undefined
|
|
32
34
|
),
|
|
33
35
|
R("div", { style: { marginLeft: 10 } }, this.props.children)
|
|
34
36
|
)
|
|
@@ -205,7 +207,7 @@ export interface ToggleEditComponentProps {
|
|
|
205
207
|
initiallyOpen?: boolean
|
|
206
208
|
label: any
|
|
207
209
|
editor: any
|
|
208
|
-
onRemove?:
|
|
210
|
+
onRemove?: () => void
|
|
209
211
|
}
|
|
210
212
|
|
|
211
213
|
interface ToggleEditComponentState {
|
|
@@ -221,25 +223,15 @@ export class ToggleEditComponent extends React.Component<ToggleEditComponentProp
|
|
|
221
223
|
}
|
|
222
224
|
|
|
223
225
|
close = () => {
|
|
224
|
-
|
|
225
|
-
if (this.editorComp) {
|
|
226
|
-
this.editorHeight = ReactDOM.findDOMNode(this.editorComp).clientHeight
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return this.setState({ open: false })
|
|
226
|
+
this.setState({ open: false })
|
|
230
227
|
}
|
|
231
228
|
|
|
232
229
|
open = () => {
|
|
233
|
-
|
|
230
|
+
this.setState({ open: true })
|
|
234
231
|
}
|
|
235
232
|
|
|
236
233
|
handleToggle = () => {
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// Save editor comp
|
|
241
|
-
editorRef = (editorComp: any) => {
|
|
242
|
-
return (this.editorComp = editorComp)
|
|
234
|
+
this.setState({ open: !this.state.open })
|
|
243
235
|
}
|
|
244
236
|
|
|
245
237
|
render() {
|