@mwater/visualization 5.0.1 → 5.2.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/GlobalFilter.d.ts +13 -0
- package/lib/GlobalFilter.js +2 -0
- package/lib/MWaterAddRelatedFormComponent.d.ts +1 -1
- package/lib/MWaterAddRelatedFormComponent.js +10 -17
- package/lib/MWaterCompleteTableSelectComponent.d.ts +2 -9
- package/lib/MWaterContextComponent.d.ts +31 -9
- package/lib/MWaterContextComponent.js +85 -76
- package/lib/MWaterCustomTablesetListComponent.js +9 -3
- package/lib/MWaterGlobalFiltersComponent.d.ts +6 -5
- package/lib/MWaterGlobalFiltersComponent.js +4 -4
- package/lib/MWaterLoaderComponent.d.ts +14 -4
- package/lib/MWaterLoaderComponent.js +10 -2
- package/lib/MWaterTableSelectComponent.d.ts +0 -1
- package/lib/MWaterTableSelectComponent.js +20 -41
- package/lib/axes/Axis.d.ts +20 -25
- package/lib/axes/AxisBuilder.js +9 -7
- package/lib/axes/AxisComponent.d.ts +4 -4
- package/lib/axes/RangesComponent.d.ts +12 -6
- package/lib/axes/RangesComponent.js +21 -10
- package/lib/dashboards/DashboardComponent.d.ts +1 -14
- package/lib/dashboards/DashboardComponent.js +18 -56
- package/lib/dashboards/DashboardDesign.d.ts +2 -17
- package/lib/dashboards/DashboardViewComponent.js +3 -4
- package/lib/dashboards/LayoutOptionsComponent.js +4 -3
- package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -0
- package/lib/dashboards/ServerDashboardDataSource.js +3 -0
- package/lib/dashboards/SettingsModalComponent.d.ts +4 -15
- package/lib/dashboards/SettingsModalComponent.js +24 -38
- package/lib/datagrids/DatagridComponent.d.ts +10 -13
- package/lib/datagrids/DatagridComponent.js +27 -5
- package/lib/datagrids/DatagridDataSource.d.ts +3 -2
- package/lib/datagrids/DatagridDataSource.js +0 -11
- package/lib/datagrids/DatagridDesign.d.ts +2 -0
- package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -93
- package/lib/datagrids/DatagridDesignerComponent.js +11 -8
- package/lib/datagrids/DatagridViewComponent.js +2 -2
- package/lib/datagrids/DirectDatagridDataSource.d.ts +1 -0
- package/lib/datagrids/DirectDatagridDataSource.js +26 -0
- package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -20
- package/lib/datagrids/FindReplaceModalComponent.js +27 -13
- package/lib/datagrids/ServerDatagridDataSource.d.ts +2 -1
- package/lib/datagrids/ServerDatagridDataSource.js +16 -3
- package/lib/demo.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -4
- package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +2 -1
- package/lib/layouts/blocks/BlocksDisplayComponent.js +2 -2
- package/lib/layouts/grid/GridLayoutManager.d.ts +2 -1
- package/lib/layouts/grid/LegoLayoutEngine.d.ts +1 -1
- package/lib/maps/BufferLayer.js +3 -1
- package/lib/maps/BufferLayerDesignerComponent.js +2 -2
- package/lib/maps/ChoroplethLayerDesigner.js +2 -2
- package/lib/maps/ClusterLayer.js +3 -1
- package/lib/maps/ClusterLayerDesignerComponent.js +2 -2
- package/lib/maps/DirectMapDataSource.js +1 -2
- package/lib/maps/GridLayer.js +5 -3
- package/lib/maps/GridLayerDesigner.js +2 -3
- package/lib/maps/LayerSwitcherComponent.js +1 -1
- package/lib/maps/MapComponent.d.ts +2 -7
- package/lib/maps/MapDesign.d.ts +2 -13
- package/lib/maps/MapDesignerComponent.d.ts +1 -12
- package/lib/maps/MapDesignerComponent.js +5 -12
- package/lib/maps/MapFiltersDesignerComponent.d.ts +0 -4
- package/lib/maps/MapFiltersDesignerComponent.js +4 -5
- package/lib/maps/MarkersLayerDesignerComponent.js +2 -2
- package/lib/maps/PopupFilterJoinsUtils.d.ts +6 -1
- package/lib/maps/PopupFilterJoinsUtils.js +4 -3
- package/lib/maps/RasterMapViewComponent.d.ts +2 -9
- package/lib/maps/RegionSelectComponent.d.ts +2 -1
- package/lib/maps/ServerMapDataSource.d.ts +1 -1
- package/lib/maps/UtfGridLayer.js +1 -1
- package/lib/maps/vectorMaps.d.ts +1 -0
- package/lib/maps/vectorMaps.js +10 -2
- package/lib/quickfilter/QuickfilterCompiler.d.ts +1 -1
- package/lib/widgets/IFrameWidgetComponent.d.ts +2 -9
- package/lib/widgets/ImageWidgetComponent.d.ts +6 -24
- package/lib/widgets/ImageWidgetComponent.js +2 -2
- package/lib/widgets/MapWidget.d.ts +2 -7
- package/lib/widgets/MarkdownWidget.d.ts +2 -7
- package/lib/widgets/TOCWidget.d.ts +2 -9
- package/lib/widgets/charts/ChartWidget.d.ts +3 -15
- package/lib/widgets/charts/calendar/CalendarChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.d.ts +1 -1
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.js +1 -1
- package/lib/widgets/charts/imagemosaic/ImageMosaicChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/imagemosaic/ImagePopupComponent.d.ts +2 -7
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +2 -31
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +2 -7
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -2
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +73 -66
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +10 -6
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +3 -22
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +55 -58
- package/lib/widgets/charts/table/TableChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/table/TableChartViewComponent.js +21 -7
- package/lib/widgets/text/ExprInsertModalComponent.d.ts +2 -13
- package/lib/widgets/text/ExprItemEditorComponent.js +2 -2
- package/lib/widgets/text/ExprUpdateModalComponent.d.ts +2 -13
- package/lib/widgets/text/TextWidgetDesign.d.ts +3 -1
- package/package.json +1 -1
- package/src/GlobalFilter.ts +17 -0
- package/src/MWaterAddRelatedFormComponent.ts +15 -20
- package/src/MWaterContextComponent.tsx +158 -0
- package/src/MWaterCustomTablesetListComponent.tsx +21 -3
- package/src/MWaterGlobalFiltersComponent.ts +8 -8
- package/src/MWaterLoaderComponent.ts +10 -3
- package/src/{MWaterTableSelectComponent.ts → MWaterTableSelectComponent.tsx} +61 -66
- package/src/axes/Axis.ts +24 -25
- package/src/axes/AxisBuilder.ts +10 -9
- package/src/axes/RangesComponent.ts +27 -16
- package/src/dashboards/{DashboardComponent.ts → DashboardComponent.tsx} +39 -80
- package/src/dashboards/DashboardDesign.ts +2 -22
- package/src/dashboards/DashboardViewComponent.ts +4 -5
- package/src/dashboards/LayoutOptionsComponent.tsx +6 -4
- package/src/dashboards/ServerDashboardDataSource.ts +16 -12
- package/src/dashboards/SettingsModalComponent.tsx +170 -0
- package/src/datagrids/DatagridComponent.ts +45 -14
- package/src/datagrids/DatagridDataSource.ts +10 -8
- package/src/datagrids/DatagridDesign.ts +3 -0
- package/src/datagrids/DatagridDesignerComponent.tsx +31 -19
- package/src/datagrids/DatagridViewComponent.ts +4 -4
- package/src/datagrids/DirectDatagridDataSource.ts +35 -0
- package/src/datagrids/ExprCellComponent.ts +0 -1
- package/src/datagrids/FindReplaceModalComponent.ts +39 -22
- package/src/datagrids/ServerDatagridDataSource.ts +23 -6
- package/src/demo.ts +1 -1
- package/src/index.ts +1 -2
- package/src/layouts/blocks/BlocksDisplayComponent.ts +2 -2
- package/src/layouts/grid/LegoLayoutEngine.ts +2 -2
- package/src/layouts/grid/WidgetContainerComponent.ts +2 -2
- package/src/maps/BingLayer.ts +2 -2
- package/src/maps/BufferLayer.ts +3 -1
- package/src/maps/BufferLayerDesignerComponent.ts +1 -1
- package/src/maps/ChoroplethLayerDesigner.tsx +1 -1
- package/src/maps/ClusterLayer.ts +3 -1
- package/src/maps/ClusterLayerDesignerComponent.ts +1 -1
- package/src/maps/DirectMapDataSource.ts +1 -2
- package/src/maps/GridLayer.ts +5 -3
- package/src/maps/GridLayerDesigner.tsx +1 -2
- package/src/maps/LayerSwitcherComponent.tsx +1 -1
- package/src/maps/LegendGroup.ts +1 -1
- package/src/maps/MWaterServerLayer.ts +2 -2
- package/src/maps/MapDesign.ts +2 -17
- package/src/maps/{MapDesignerComponent.ts → MapDesignerComponent.tsx} +8 -16
- package/src/maps/{MapFiltersDesignerComponent.ts → MapFiltersDesignerComponent.tsx} +25 -25
- package/src/maps/MarkersLayerDesignerComponent.ts +1 -1
- package/src/maps/PopupFilterJoinsUtils.ts +4 -4
- package/src/maps/ServerMapDataSource.ts +7 -7
- package/src/maps/SwitchableTileUrlLayerDesigner.tsx +1 -13
- package/src/maps/UtfGridLayer.ts +4 -4
- package/src/maps/VectorMapViewComponent.tsx +0 -1
- package/src/maps/mapboxUtils.ts +2 -2
- package/src/maps/vectorMaps.tsx +10 -1
- package/src/quickfilter/QuickfilterCompiler.ts +1 -1
- package/src/richtext/ExprItemsHtmlConverter.ts +1 -1
- package/src/richtext/FontColorPaletteItem.ts +1 -1
- package/src/richtext/FontSizePaletteItem.ts +1 -1
- package/src/richtext/ItemsHtmlConverter.ts +2 -2
- package/src/widgets/ImageWidgetComponent.ts +1 -1
- package/src/widgets/charts/calendar/CalendarChartDesignerComponent.ts +1 -1
- package/src/widgets/charts/imagemosaic/ImageMosaicChart.ts +1 -1
- package/src/widgets/charts/imagemosaic/ImageMosaicChartDesignerComponent.ts +1 -1
- package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +1 -1
- package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +1 -1
- package/src/widgets/charts/table/TableChartDesignerComponent.ts +1 -1
- package/src/widgets/charts/table/TableChartViewComponent.ts +21 -7
- package/src/widgets/text/ExprItemEditorComponent.tsx +1 -1
- package/src/widgets/text/TextWidgetDesign.ts +4 -1
- package/src/MWaterContextComponent.ts +0 -141
- package/src/TableSelectComponent.ts +0 -60
- package/src/dashboards/SettingsModalComponent.ts +0 -169
|
@@ -35,7 +35,7 @@ interface ServerMapDataSourceOptions {
|
|
|
35
35
|
mapId: string
|
|
36
36
|
|
|
37
37
|
/** revision to use to allow caching */
|
|
38
|
-
rev:
|
|
38
|
+
rev: number
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
interface ServerMapLayerDataSourceOptions extends ServerMapDataSourceOptions {
|
|
@@ -79,7 +79,7 @@ export default class ServerMapDataSource implements MapDataSource {
|
|
|
79
79
|
|
|
80
80
|
$.getJSON(url, (data: any) => {
|
|
81
81
|
return callback(null, data)
|
|
82
|
-
}).fail((xhr) => {
|
|
82
|
+
}).fail((xhr: any) => {
|
|
83
83
|
console.log(xhr.responseText)
|
|
84
84
|
return callback(new Error(xhr.responseText))
|
|
85
85
|
})
|
|
@@ -317,9 +317,9 @@ class ServerMapLayerPopupWidgetDataSource implements WidgetDataSource {
|
|
|
317
317
|
`maps/${this.options.mapId}/layers/${this.options.layerId}/widgets/${this.options.popupWidgetId}/data?` +
|
|
318
318
|
querystring.stringify(query)
|
|
319
319
|
|
|
320
|
-
return $.getJSON(url, (data) => {
|
|
320
|
+
return $.getJSON(url, (data: any) => {
|
|
321
321
|
return callback(null, data)
|
|
322
|
-
}).fail((xhr) => {
|
|
322
|
+
}).fail((xhr: any) => {
|
|
323
323
|
console.log(xhr.responseText)
|
|
324
324
|
return callback(new Error(xhr.responseText))
|
|
325
325
|
})
|
|
@@ -374,7 +374,7 @@ class ServerQuickfilterDataSource implements QuickfiltersDataSource {
|
|
|
374
374
|
`maps/${this.options.mapId}/quickfilters/${index}/values?` +
|
|
375
375
|
querystring.stringify(query)
|
|
376
376
|
|
|
377
|
-
const headers = {}
|
|
377
|
+
const headers: any = {}
|
|
378
378
|
const cacheExpiry = this.options.dataSource.getCacheExpiry()
|
|
379
379
|
if (cacheExpiry) {
|
|
380
380
|
const seconds = Math.floor((new Date().getTime() - cacheExpiry) / 1000)
|
|
@@ -387,10 +387,10 @@ class ServerQuickfilterDataSource implements QuickfiltersDataSource {
|
|
|
387
387
|
url,
|
|
388
388
|
headers
|
|
389
389
|
})
|
|
390
|
-
.done((data) => {
|
|
390
|
+
.done((data: any) => {
|
|
391
391
|
return callback(null, data)
|
|
392
392
|
})
|
|
393
|
-
.fail((xhr) => {
|
|
393
|
+
.fail((xhr: any) => {
|
|
394
394
|
console.log(xhr.responseText)
|
|
395
395
|
return callback(new Error(xhr.responseText))
|
|
396
396
|
})
|
|
@@ -3,22 +3,10 @@ import React from "react"
|
|
|
3
3
|
const R = React.createElement
|
|
4
4
|
import { produce } from "immer"
|
|
5
5
|
|
|
6
|
-
import { ExprComponent, FilterExprComponent } from "@mwater/expressions-ui"
|
|
7
|
-
import { ExprCompiler, Schema, DataSource, Expr, OpExpr } from "@mwater/expressions"
|
|
8
|
-
import AxisComponent from "./../axes/AxisComponent"
|
|
9
|
-
import TableSelectComponent from "../TableSelectComponent"
|
|
10
|
-
import ColorComponent from "../ColorComponent"
|
|
11
|
-
import Rcslider from "rc-slider"
|
|
12
|
-
import ChoroplethLayerDesign from "./ChoroplethLayerDesign"
|
|
13
6
|
import { JsonQLFilter } from "../index"
|
|
14
|
-
import
|
|
15
|
-
import ZoomLevelsComponent from "./ZoomLevelsComponent"
|
|
16
|
-
import ui, { Radio } from "@mwater/react-library/lib/bootstrap"
|
|
17
|
-
import { Axis } from "../axes/Axis"
|
|
7
|
+
import { Radio } from "@mwater/react-library/lib/bootstrap"
|
|
18
8
|
import { SwitchableTileUrlLayerDesign } from "./SwitchableTileUrlLayer"
|
|
19
9
|
|
|
20
|
-
import AdminScopeAndDetailLevelComponent from "./AdminScopeAndDetailLevelComponent"
|
|
21
|
-
import ScopeAndDetailLevelComponent from "./ScopeAndDetailLevelComponent"
|
|
22
10
|
|
|
23
11
|
/** Designer for a switchable tile url layer */
|
|
24
12
|
export default class SwitchableTileUrlLayerDesigner extends React.Component<{
|
package/src/maps/UtfGridLayer.ts
CHANGED
|
@@ -65,8 +65,8 @@ module.exports = L.Layer.extend({
|
|
|
65
65
|
|
|
66
66
|
//Find a unique id in window we can use for our callbacks
|
|
67
67
|
//Required for jsonP
|
|
68
|
-
|
|
69
|
-
while (window["lu" + i]) {
|
|
68
|
+
let i = 0
|
|
69
|
+
while ((window as any)["lu" + i]) {
|
|
70
70
|
i++
|
|
71
71
|
}
|
|
72
72
|
this._windowKey = "lu" + i
|
|
@@ -244,9 +244,9 @@ module.exports = L.Layer.extend({
|
|
|
244
244
|
script.setAttribute("type", "text/javascript")
|
|
245
245
|
script.setAttribute("src", url)
|
|
246
246
|
|
|
247
|
-
window[wk][functionName] = function (data: any) {
|
|
247
|
+
;(window as any)[wk][functionName] = function (data: any) {
|
|
248
248
|
self._cache[key] = data
|
|
249
|
-
delete window[wk][functionName]
|
|
249
|
+
delete (window as any)[wk][functionName]
|
|
250
250
|
head.removeChild(script)
|
|
251
251
|
}
|
|
252
252
|
|
package/src/maps/mapboxUtils.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Axis } from "../axes/Axis"
|
|
|
3
3
|
|
|
4
4
|
/** Compile a color mapped axis to mapbox format case statement */
|
|
5
5
|
export function compileColorMapToMapbox(axis: Axis | null | undefined, defaultColor: string): DataDrivenPropertyValueSpecification<string> | string {
|
|
6
|
-
let compiled:
|
|
6
|
+
let compiled: any
|
|
7
7
|
|
|
8
8
|
if (axis && axis.colorMap && axis.colorMap.length > 0) {
|
|
9
9
|
const excludedValues = axis.excludedValues || []
|
|
@@ -31,7 +31,7 @@ export function compileColorMapToMapbox(axis: Axis | null | undefined, defaultCo
|
|
|
31
31
|
|
|
32
32
|
/** Compile a color that is transparent if excluded to mapbox format case statement */
|
|
33
33
|
export function compileColorToMapbox(color: string, excludedValues?: any[]): DataDrivenPropertyValueSpecification<string> | string {
|
|
34
|
-
let compiled:
|
|
34
|
+
let compiled: any
|
|
35
35
|
|
|
36
36
|
if (excludedValues) {
|
|
37
37
|
// Create match operator
|
package/src/maps/vectorMaps.tsx
CHANGED
|
@@ -7,6 +7,13 @@ import "maplibre-gl/dist/maplibre-gl.css"
|
|
|
7
7
|
import "./VectorMapViewComponent.css"
|
|
8
8
|
import React from "react"
|
|
9
9
|
|
|
10
|
+
/** Set to true to enable printing by preserving the drawing buffer */
|
|
11
|
+
let printingModeEnabled = false
|
|
12
|
+
|
|
13
|
+
export function setPrintingModeEnabled(val: boolean) {
|
|
14
|
+
printingModeEnabled = val
|
|
15
|
+
}
|
|
16
|
+
|
|
10
17
|
/* Hooks and functions related to displaying a vector map */
|
|
11
18
|
|
|
12
19
|
let mapTilerApiKey = ""
|
|
@@ -58,7 +65,8 @@ export function useVectorMap(options: {
|
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
const observer = new IntersectionObserver(function(entries) {
|
|
61
|
-
|
|
68
|
+
// When in printing mode, always visible as we need to render the map
|
|
69
|
+
setMapDivVisible(entries[0].isIntersecting || printingModeEnabled)
|
|
62
70
|
})
|
|
63
71
|
observer.observe(divRef)
|
|
64
72
|
return () => {
|
|
@@ -98,6 +106,7 @@ export function useVectorMap(options: {
|
|
|
98
106
|
[-179.9, -85], // Southwest coordinates
|
|
99
107
|
[179.9, 85] // Northeast coordinates
|
|
100
108
|
],
|
|
109
|
+
preserveDrawingBuffer: printingModeEnabled
|
|
101
110
|
})
|
|
102
111
|
|
|
103
112
|
setHasWebGLContext(true)
|
|
@@ -81,7 +81,7 @@ export default class QuickfilterCompiler {
|
|
|
81
81
|
return filters
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
compileToFilterExpr(expr: any, value: any, multi
|
|
84
|
+
compileToFilterExpr(expr: any, value: any, multi?: boolean): OpExpr | null {
|
|
85
85
|
// Get type of expr
|
|
86
86
|
const type = new ExprUtils(this.schema).getExprType(expr)
|
|
87
87
|
const idTable = new ExprUtils(this.schema).getExprIdTable(expr)
|
|
@@ -121,7 +121,7 @@ export default class ExprItemsHtmlConverter extends ItemsHtmlConverter {
|
|
|
121
121
|
const items = super.convertElemToItems(elem)
|
|
122
122
|
|
|
123
123
|
// Ensure exprs have unique ids
|
|
124
|
-
const takenIds = {}
|
|
124
|
+
const takenIds: { [id: string]: boolean } = {}
|
|
125
125
|
var uniqueify = (items: any) => {
|
|
126
126
|
for (let item of items) {
|
|
127
127
|
if (item.type === "expr") {
|
|
@@ -215,7 +215,7 @@ export default class ItemsHtmlConverter {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
// Whitelist allowed tags and styles
|
|
218
|
-
var allowedTags = {
|
|
218
|
+
var allowedTags: { [tag: string]: number } = {
|
|
219
219
|
div: 1,
|
|
220
220
|
p: 1,
|
|
221
221
|
ul: 1,
|
|
@@ -236,7 +236,7 @@ var allowedTags = {
|
|
|
236
236
|
strong: 1,
|
|
237
237
|
font: 1
|
|
238
238
|
}
|
|
239
|
-
var allowedStyles = {
|
|
239
|
+
var allowedStyles: { [style: string]: number } = {
|
|
240
240
|
"text-align": 1,
|
|
241
241
|
"font-weight": 1,
|
|
242
242
|
"font-style": 1,
|
|
@@ -10,7 +10,7 @@ import DropdownWidgetComponent from "./DropdownWidgetComponent"
|
|
|
10
10
|
import ModalPopupComponent from "@mwater/react-library/lib/ModalPopupComponent"
|
|
11
11
|
import TabbedComponent from "@mwater/react-library/lib/TabbedComponent"
|
|
12
12
|
import { ExprComponent } from "@mwater/expressions-ui"
|
|
13
|
-
import TableSelectComponent from "
|
|
13
|
+
import { TableSelectComponent } from "@mwater/expressions-ui"
|
|
14
14
|
import ImageUploaderComponent from "./ImageUploaderComponent"
|
|
15
15
|
import ImagelistCarouselComponent from "./ImagelistCarouselComponent"
|
|
16
16
|
import { DataSource, Schema } from "@mwater/expressions"
|
|
@@ -7,7 +7,7 @@ import { DataSource, ExprUtils, Schema } from "@mwater/expressions"
|
|
|
7
7
|
import AxisBuilder from "../../../axes/AxisBuilder"
|
|
8
8
|
import AxisComponent from "../../../axes/AxisComponent"
|
|
9
9
|
import { FilterExprComponent } from "@mwater/expressions-ui"
|
|
10
|
-
import TableSelectComponent from "
|
|
10
|
+
import { TableSelectComponent } from "@mwater/expressions-ui"
|
|
11
11
|
import ColorComponent from "../../../ColorComponent"
|
|
12
12
|
import { CalendarChartDesign } from "./CalendarChart"
|
|
13
13
|
|
|
@@ -183,7 +183,7 @@ export default class ImageMosaicChart extends Chart {
|
|
|
183
183
|
|
|
184
184
|
createDataTable(design: any, schema: Schema, dataSource: DataSource, data: any) {
|
|
185
185
|
alert("Not available for Image Mosaics")
|
|
186
|
-
return
|
|
186
|
+
return []
|
|
187
187
|
}
|
|
188
188
|
// TODO
|
|
189
189
|
// renderHeaderCell = (column) =>
|
|
@@ -8,7 +8,7 @@ import { DataSource, ExprUtils, Schema } from "@mwater/expressions"
|
|
|
8
8
|
import AxisBuilder from "../../../axes/AxisBuilder"
|
|
9
9
|
import AxisComponent from "../../../axes/AxisComponent"
|
|
10
10
|
import { FilterExprComponent } from "@mwater/expressions-ui"
|
|
11
|
-
import TableSelectComponent from "
|
|
11
|
+
import { TableSelectComponent } from "@mwater/expressions-ui"
|
|
12
12
|
|
|
13
13
|
export interface ImageMosaicChartDesignerComponentProps {
|
|
14
14
|
design: any
|
|
@@ -11,7 +11,7 @@ import ColorComponent from "../../../ColorComponent"
|
|
|
11
11
|
import * as LayeredChartUtils from "./LayeredChartUtils"
|
|
12
12
|
import LayeredChartCompiler from "./LayeredChartCompiler"
|
|
13
13
|
import * as uiComponents from "../../../UIComponents"
|
|
14
|
-
import TableSelectComponent from "
|
|
14
|
+
import { TableSelectComponent } from "@mwater/expressions-ui"
|
|
15
15
|
import * as ui from "@mwater/react-library/lib/bootstrap"
|
|
16
16
|
import { Checkbox } from "@mwater/react-library/lib/bootstrap"
|
|
17
17
|
import PopoverHelpComponent from "@mwater/react-library/lib/PopoverHelpComponent"
|
|
@@ -5,7 +5,7 @@ const R = React.createElement
|
|
|
5
5
|
import uuid from "uuid"
|
|
6
6
|
import * as ui from "@mwater/react-library/lib/bootstrap"
|
|
7
7
|
import { FilterExprComponent } from "@mwater/expressions-ui"
|
|
8
|
-
import TableSelectComponent from "
|
|
8
|
+
import { TableSelectComponent } from "@mwater/expressions-ui"
|
|
9
9
|
import AxisComponent from "../../../axes/AxisComponent"
|
|
10
10
|
import { DataSource, Schema } from "@mwater/expressions"
|
|
11
11
|
|
|
@@ -9,7 +9,7 @@ import { LinkComponent } from "@mwater/expressions-ui"
|
|
|
9
9
|
import { ExprComponent } from "@mwater/expressions-ui"
|
|
10
10
|
import { FilterExprComponent } from "@mwater/expressions-ui"
|
|
11
11
|
import OrderingsComponent from "./OrderingsComponent"
|
|
12
|
-
import TableSelectComponent from "
|
|
12
|
+
import { TableSelectComponent } from "@mwater/expressions-ui"
|
|
13
13
|
import ReorderableListComponent from "@mwater/react-library/lib/reorderable/ReorderableListComponent"
|
|
14
14
|
import * as ui from "@mwater/react-library/lib/bootstrap"
|
|
15
15
|
import { getFormatOptions } from "../../../valueFormatter"
|
|
@@ -223,7 +223,7 @@ class TableContentsComponent extends React.Component<TableContentsComponentProps
|
|
|
223
223
|
|
|
224
224
|
renderImage(id: any) {
|
|
225
225
|
const url = this.props.dataSource.getImageUrl(id)
|
|
226
|
-
return R("a", { href: url, key: id, target: "_blank", style: { paddingLeft: 5, paddingRight: 5 } }, "Image")
|
|
226
|
+
return R("a", { href: url, onClick: (e) => {e.stopPropagation()}, key: id, target: "_blank", style: { paddingLeft: 5, paddingRight: 5 } }, "Image")
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
renderCell(rowIndex: any, columnIndex: any) {
|
|
@@ -264,7 +264,9 @@ class TableContentsComponent extends React.Component<TableContentsComponentProps
|
|
|
264
264
|
// Convert to node based on type
|
|
265
265
|
switch (exprType) {
|
|
266
266
|
case "text":
|
|
267
|
-
|
|
267
|
+
if (_.isString(value)) {
|
|
268
|
+
node = R(Linkify, { properties: { target: "_blank" } }, value)
|
|
269
|
+
}
|
|
268
270
|
break
|
|
269
271
|
case "number":
|
|
270
272
|
case "geometry":
|
|
@@ -272,21 +274,33 @@ class TableContentsComponent extends React.Component<TableContentsComponentProps
|
|
|
272
274
|
break
|
|
273
275
|
case "boolean":
|
|
274
276
|
case "enum":
|
|
277
|
+
node = exprUtils.stringifyExprLiteral(column.textAxis?.expr, value, this.context.locale)
|
|
278
|
+
break
|
|
275
279
|
case "enumset":
|
|
276
280
|
case "text[]":
|
|
277
|
-
|
|
281
|
+
if (_.isArray(value)) {
|
|
282
|
+
node = exprUtils.stringifyExprLiteral(column.textAxis?.expr, value, this.context.locale)
|
|
283
|
+
}
|
|
278
284
|
break
|
|
279
285
|
case "date":
|
|
280
|
-
|
|
286
|
+
if (_.isString(value)) {
|
|
287
|
+
node = formatValue(exprType, value, column.format)
|
|
288
|
+
}
|
|
281
289
|
break
|
|
282
290
|
case "datetime":
|
|
283
|
-
|
|
291
|
+
if (_.isString(value)) {
|
|
292
|
+
node = formatValue(exprType, value, column.format)
|
|
293
|
+
}
|
|
284
294
|
break
|
|
285
295
|
case "image":
|
|
286
|
-
|
|
296
|
+
if (_.isObject(value) && value.id != null) {
|
|
297
|
+
node = this.renderImage(value.id)
|
|
298
|
+
}
|
|
287
299
|
break
|
|
288
300
|
case "imagelist":
|
|
289
|
-
|
|
301
|
+
if (_.isArray(value)) {
|
|
302
|
+
node = _.map(value, (v: Image) => this.renderImage(v.id))
|
|
303
|
+
}
|
|
290
304
|
break
|
|
291
305
|
default:
|
|
292
306
|
node = "" + value
|
|
@@ -5,7 +5,7 @@ const R = React.createElement
|
|
|
5
5
|
|
|
6
6
|
import { DataSource, ExprUtils, Schema } from "@mwater/expressions"
|
|
7
7
|
import { ExprComponent } from "@mwater/expressions-ui"
|
|
8
|
-
import TableSelectComponent from "
|
|
8
|
+
import { TableSelectComponent } from "@mwater/expressions-ui"
|
|
9
9
|
import { getFormatOptions } from "../../valueFormatter"
|
|
10
10
|
import { getDefaultFormat } from "../../valueFormatter"
|
|
11
11
|
import { Checkbox } from "@mwater/react-library/lib/bootstrap"
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { HtmlItemExpr } from "../../richtext/ExprItemsHtmlConverter"
|
|
2
|
+
import { HtmlItem } from "../../richtext/ItemsHtmlConverter"
|
|
3
|
+
|
|
1
4
|
export interface TextWidgetDesign {
|
|
2
5
|
/** Text widget stores its content as array of items. See ItemsHtmlConverter TODO */
|
|
3
|
-
items:
|
|
6
|
+
items: (HtmlItem | HtmlItemExpr)[]
|
|
4
7
|
|
|
5
8
|
/** "title" for title block. default is "default" */
|
|
6
9
|
style?: "title" | "default"
|
|
@@ -1,141 +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 MWaterTableSelectComponent from "./MWaterTableSelectComponent"
|
|
7
|
-
import MWaterAddRelatedFormComponent from "./MWaterAddRelatedFormComponent"
|
|
8
|
-
import MWaterAddRelatedIndicatorComponent from "./MWaterAddRelatedIndicatorComponent"
|
|
9
|
-
import MWaterGlobalFiltersComponent from "./MWaterGlobalFiltersComponent"
|
|
10
|
-
import { Schema } from "@mwater/expressions"
|
|
11
|
-
|
|
12
|
-
/** Creates a tableSelectElementFactory context to allow selecting of a table in an mWater-friendly way
|
|
13
|
-
* and several other context items
|
|
14
|
-
*/
|
|
15
|
-
export default class MWaterContextComponent extends React.Component<{
|
|
16
|
-
apiUrl: string
|
|
17
|
-
client?: string
|
|
18
|
-
/** user id of logged in user */
|
|
19
|
-
user?: string
|
|
20
|
-
schema: Schema
|
|
21
|
-
/** Extra tables to load in schema. Forms are not loaded by default as they are too many */
|
|
22
|
-
extraTables?: string[]
|
|
23
|
-
/** Called when extra tables are changed and schema will be reloaded */
|
|
24
|
-
onExtraTablesChange?: (extraTables: string[]) => void
|
|
25
|
-
/** Override default add layer component. See AddLayerComponent for details */
|
|
26
|
-
addLayerElementFactory?: any
|
|
27
|
-
}> {
|
|
28
|
-
static childContextTypes = {
|
|
29
|
-
tableSelectElementFactory: PropTypes.func, // Call with props of TableSelectComponent
|
|
30
|
-
addLayerElementFactory: PropTypes.func, // Call with props of AddLayerComponent
|
|
31
|
-
globalFiltersElementFactory: PropTypes.func, // Call with props { schema, dataSource, filterableTables, globalFilters, onChange, nullIfIrrelevant }.
|
|
32
|
-
// Displays a component to edit global filters. nullIfIrrelevant causes null element if not applicable to filterableTables
|
|
33
|
-
|
|
34
|
-
// Decorates sections (the children element, specifically) in the expression picker
|
|
35
|
-
decorateScalarExprTreeSectionChildren: PropTypes.func,
|
|
36
|
-
|
|
37
|
-
// Function to override initial open state of a section. Passed { tableId: id of table, section: section object from schema, filter: optional string filter }
|
|
38
|
-
// Should return true to set initially open
|
|
39
|
-
isScalarExprTreeSectionInitiallyOpen: PropTypes.func,
|
|
40
|
-
|
|
41
|
-
// Function to override filtering of a section. Passed { tableId: id of table, section: section object from schema, filter: optional string filter }
|
|
42
|
-
// Should return null for default, true to include, false to exclude
|
|
43
|
-
isScalarExprTreeSectionMatch: PropTypes.func
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
getChildContext() {
|
|
47
|
-
const context: any = {}
|
|
48
|
-
|
|
49
|
-
context.tableSelectElementFactory = (props: any) => {
|
|
50
|
-
return React.createElement(MWaterTableSelectComponent, {
|
|
51
|
-
apiUrl: this.props.apiUrl,
|
|
52
|
-
client: this.props.client,
|
|
53
|
-
schema: props.schema,
|
|
54
|
-
user: this.props.user,
|
|
55
|
-
table: props.value,
|
|
56
|
-
onChange: props.onChange,
|
|
57
|
-
extraTables: this.props.extraTables,
|
|
58
|
-
onExtraTablesChange: this.props.onExtraTablesChange,
|
|
59
|
-
filter: props.filter,
|
|
60
|
-
onFilterChange: props.onFilterChange
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (this.props.addLayerElementFactory) {
|
|
65
|
-
context.addLayerElementFactory = this.props.addLayerElementFactory
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
context.globalFiltersElementFactory = (props: any) => {
|
|
69
|
-
if (props.nullIfIrrelevant && !_.any(props.filterableTables, (t: string) => t.match(/^entities./))) {
|
|
70
|
-
return null
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return React.createElement(MWaterGlobalFiltersComponent, props)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
context.decorateScalarExprTreeSectionChildren = (options: any) => {
|
|
77
|
-
// If related forms section of entities table or assets table
|
|
78
|
-
if ((options.tableId.match(/^entities\./) || options.tableId.match(/^assets:/)) && options.section.id === "!related_forms") {
|
|
79
|
-
return R(
|
|
80
|
-
"div",
|
|
81
|
-
{ key: "_add_related_form_parent" },
|
|
82
|
-
options.children,
|
|
83
|
-
R(MWaterAddRelatedFormComponent, {
|
|
84
|
-
key: "_add_related_form",
|
|
85
|
-
table: options.tableId,
|
|
86
|
-
apiUrl: this.props.apiUrl,
|
|
87
|
-
client: this.props.client,
|
|
88
|
-
user: this.props.user,
|
|
89
|
-
schema: this.props.schema,
|
|
90
|
-
onSelect: this.handleAddTable
|
|
91
|
-
})
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// If indicators section of entities table
|
|
96
|
-
if (options.tableId.match(/^entities\./) && options.section.id === "!indicators") {
|
|
97
|
-
return R(
|
|
98
|
-
"div",
|
|
99
|
-
{ key: "_add_related_indicator_parent" },
|
|
100
|
-
options.children,
|
|
101
|
-
R(MWaterAddRelatedIndicatorComponent, {
|
|
102
|
-
key: "_add_related_indicator",
|
|
103
|
-
table: options.tableId,
|
|
104
|
-
apiUrl: this.props.apiUrl,
|
|
105
|
-
client: this.props.client,
|
|
106
|
-
user: this.props.user,
|
|
107
|
-
schema: this.props.schema,
|
|
108
|
-
onSelect: this.handleAddTable,
|
|
109
|
-
filter: options.filter
|
|
110
|
-
})
|
|
111
|
-
)
|
|
112
|
-
} else {
|
|
113
|
-
return options.children
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Always match indicator section
|
|
118
|
-
context.isScalarExprTreeSectionMatch = (options: any) => {
|
|
119
|
-
if (options.tableId.match(/^entities\./) && options.section.id === "!indicators") {
|
|
120
|
-
return true
|
|
121
|
-
}
|
|
122
|
-
return null
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Nothing initially open
|
|
126
|
-
context.isScalarExprTreeSectionInitiallyOpen = (options: any) => {
|
|
127
|
-
return null
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return context
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
handleAddTable = (table: any) => {
|
|
134
|
-
const extraTables = _.union(this.props.extraTables || [], [table])
|
|
135
|
-
return this.props.onExtraTablesChange!(extraTables)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
render() {
|
|
139
|
-
return this.props.children
|
|
140
|
-
}
|
|
141
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import _ from "lodash"
|
|
2
|
-
import PropTypes from "prop-types"
|
|
3
|
-
import React from "react"
|
|
4
|
-
import * as ui from "./UIComponents"
|
|
5
|
-
import { Expr, ExprUtils, Schema } from "@mwater/expressions"
|
|
6
|
-
const R = React.createElement
|
|
7
|
-
|
|
8
|
-
export interface TableSelectComponentProps {
|
|
9
|
-
schema: Schema
|
|
10
|
-
/** Current table id */
|
|
11
|
-
value?: string | null
|
|
12
|
-
/** Newly selected table id */
|
|
13
|
-
onChange: (tableId: string) => void
|
|
14
|
-
/** Some table select components (not the default) can also perform filtering. Include these props to enable this */
|
|
15
|
-
filter?: Expr
|
|
16
|
-
onFilterChange?: (filter: Expr) => void
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default class TableSelectComponent extends React.Component<TableSelectComponentProps> {
|
|
20
|
-
static contextTypes = {
|
|
21
|
-
tableSelectElementFactory: PropTypes.func, // Can be overridden by setting tableSelectElementFactory in context that takes ({ schema, value, onChange, filter, onFilterChange })
|
|
22
|
-
locale: PropTypes.string, // e.g. "en"
|
|
23
|
-
|
|
24
|
-
// Optional list of tables (ids) being used. Some overrides of the table select component may use this to present
|
|
25
|
-
// an initially short list to select from
|
|
26
|
-
activeTables: PropTypes.arrayOf(PropTypes.string.isRequired)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
render() {
|
|
30
|
-
if (this.context.tableSelectElementFactory) {
|
|
31
|
-
return this.context.tableSelectElementFactory(this.props)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return React.createElement(ui.ToggleEditComponent, {
|
|
35
|
-
forceOpen: !this.props.value,
|
|
36
|
-
label: this.props.value
|
|
37
|
-
? ExprUtils.localizeString(
|
|
38
|
-
this.props.schema.getTable(this.props.value)?.name || "(not found)",
|
|
39
|
-
this.context.locale
|
|
40
|
-
)
|
|
41
|
-
: R("i", null, "Select..."),
|
|
42
|
-
editor: (onClose: any) => {
|
|
43
|
-
return React.createElement(ui.OptionListComponent, {
|
|
44
|
-
hint: "Select source to get data from",
|
|
45
|
-
items: _.map(
|
|
46
|
-
_.filter(this.props.schema.getTables(), (table) => !table.deprecated),
|
|
47
|
-
(table) => ({
|
|
48
|
-
name: ExprUtils.localizeString(table.name, this.context.locale),
|
|
49
|
-
desc: ExprUtils.localizeString(table.desc, this.context.locale),
|
|
50
|
-
onClick: () => {
|
|
51
|
-
onClose()
|
|
52
|
-
return this.props.onChange(table.id)
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
)
|
|
56
|
-
})
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
}
|