@mwater/visualization 5.4.1 → 5.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ColorComponent.js +2 -1
- package/lib/IdSelection.d.ts +16 -0
- package/lib/IdSelection.js +59 -0
- package/lib/MWaterAddRelatedIndicatorComponent.js +2 -2
- package/lib/MWaterCompleteTableSelectComponent.d.ts +3 -8
- package/lib/MWaterCompleteTableSelectComponent.js +36 -42
- package/lib/MWaterLoaderComponent.d.ts +11 -10
- package/lib/MWaterLoaderComponent.js +1 -1
- package/lib/MWaterResponsesFilterComponent.js +1 -1
- package/lib/MWaterTableSelectComponent.d.ts +0 -1
- package/lib/MWaterTableSelectComponent.js +4 -6
- package/lib/autotranslate.d.ts +20 -0
- package/lib/autotranslate.js +122 -0
- package/lib/axes/AxisBuilder.js +3 -3
- package/lib/axes/AxisColorEditorComponent.js +4 -0
- package/lib/axes/AxisComponent.d.ts +8 -12
- package/lib/axes/AxisComponent.js +32 -80
- package/lib/axes/CategoryMapComponent.js +4 -4
- package/lib/axes/RangesComponent.js +2 -2
- package/lib/dashboards/DashboardComponent.d.ts +6 -0
- package/lib/dashboards/DashboardComponent.js +44 -12
- package/lib/dashboards/DashboardDesign.d.ts +11 -2
- package/lib/dashboards/DashboardUtils.d.ts +5 -0
- package/lib/dashboards/DashboardUtils.js +30 -0
- package/lib/dashboards/DashboardViewComponent.d.ts +2 -0
- package/lib/dashboards/DashboardViewComponent.js +16 -3
- package/lib/dashboards/ServerDashboardDataSource.js +2 -1
- package/lib/dashboards/SettingsModalComponent.d.ts +1 -1
- package/lib/dashboards/SettingsModalComponent.js +256 -19
- package/lib/dashboards/WidgetComponent.d.ts +6 -3
- package/lib/dashboards/WidgetComponent.js +3 -1
- package/lib/datagrids/CellEditor.d.ts +19 -0
- package/lib/datagrids/CellEditor.js +223 -0
- package/lib/datagrids/DatagridComponent.d.ts +18 -87
- package/lib/datagrids/DatagridComponent.js +304 -222
- package/lib/datagrids/DatagridViewComponent.d.ts +15 -53
- package/lib/datagrids/DatagridViewComponent.js +256 -257
- package/lib/datagrids/DirectDatagridDataSource.js +2 -3
- package/lib/datagrids/ExprCellComponent.d.ts +8 -15
- package/lib/datagrids/ExprCellComponent.js +11 -15
- package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -6
- package/lib/datagrids/FindReplaceModalComponent.js +38 -75
- package/lib/index.css +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/layouts/blocks/HorizontalBlockComponent.js +2 -2
- package/lib/mWaterLoader.d.ts +1 -1
- package/lib/maps/BufferLayer.d.ts +7 -5
- package/lib/maps/BufferLayer.js +69 -48
- package/lib/maps/BufferLayerDesign.d.ts +21 -14
- package/lib/maps/BufferLayerDesignerComponent.d.ts +16 -31
- package/lib/maps/BufferLayerDesignerComponent.js +68 -102
- package/lib/maps/ChoroplethLayer.d.ts +5 -4
- package/lib/maps/ChoroplethLayer.js +32 -9
- package/lib/maps/ChoroplethLayerDesign.d.ts +6 -2
- package/lib/maps/ChoroplethLayerDesigner.js +4 -2
- package/lib/maps/ClusterLayer.d.ts +3 -4
- package/lib/maps/ClusterLayer.js +2 -1
- package/lib/maps/DetailLevelSelectComponent.js +1 -1
- package/lib/maps/DirectMapDataSource.js +2 -1
- package/lib/maps/EditPopupComponent.js +5 -3
- package/lib/maps/GridLayer.d.ts +3 -4
- package/lib/maps/GridLayer.js +2 -1
- package/lib/maps/GridLayerDesigner.js +5 -3
- package/lib/maps/HoverContent.d.ts +11 -3
- package/lib/maps/HoverContent.js +25 -9
- package/lib/maps/Layer.d.ts +24 -3
- package/lib/maps/Layer.js +5 -1
- package/lib/maps/LayerFactory.js +0 -8
- package/lib/maps/LayerLegendComponent.js +0 -1
- package/lib/maps/LayerSwitcherComponent.d.ts +1 -0
- package/lib/maps/LayerSwitcherComponent.js +1 -1
- package/lib/maps/LeafletMapComponent.js +3 -1
- package/lib/maps/LegendComponent.d.ts +1 -0
- package/lib/maps/LegendComponent.js +9 -1
- package/lib/maps/MWaterServerLayer.d.ts +2 -2
- package/lib/maps/MWaterServerLayer.js +2 -2
- package/lib/maps/MapComponent.js +3 -3
- package/lib/maps/MapDesign.d.ts +2 -0
- package/lib/maps/MapDesignerComponent.d.ts +4 -3
- package/lib/maps/MapDesignerComponent.js +68 -74
- package/lib/maps/MapLayerViewDesignerComponent.js +2 -2
- package/lib/maps/MapUtils.d.ts +4 -0
- package/lib/maps/MapUtils.js +19 -0
- package/lib/maps/MapViewComponent.d.ts +8 -3
- package/lib/maps/MarkersLayer.d.ts +5 -4
- package/lib/maps/MarkersLayer.js +33 -7
- package/lib/maps/MarkersLayerDesign.d.ts +19 -16
- package/lib/maps/PopupFilterJoinsUtils.d.ts +6 -3
- package/lib/maps/PopupFilterJoinsUtils.js +0 -6
- package/lib/maps/RasterMapViewComponent.d.ts +3 -31
- package/lib/maps/RasterMapViewComponent.js +7 -2
- package/lib/maps/ServerMapDataSource.js +2 -1
- package/lib/maps/SwitchableTileUrlLayer.d.ts +3 -3
- package/lib/maps/SwitchableTileUrlLayer.js +2 -1
- package/lib/maps/TileUrlLayer.d.ts +4 -5
- package/lib/maps/TileUrlLayer.js +2 -1
- package/lib/maps/VectorMapViewComponent.d.ts +5 -37
- package/lib/maps/VectorMapViewComponent.js +19 -8
- package/lib/maps/maps.d.ts +3 -0
- package/lib/quickfilter/QuickfiltersComponent.d.ts +2 -0
- package/lib/quickfilter/QuickfiltersComponent.js +9 -7
- package/lib/quickfilter/QuickfiltersDesignComponent.d.ts +1 -1
- package/lib/quickfilter/QuickfiltersDesignComponent.js +19 -35
- package/lib/richtext/ExprItemsHtmlConverter.d.ts +5 -2
- package/lib/richtext/ExprItemsHtmlConverter.js +4 -4
- package/lib/richtext/ExprItemsTranslator.d.ts +5 -0
- package/lib/richtext/ExprItemsTranslator.js +149 -0
- package/lib/richtext/ItemsHtmlConverter.d.ts +1 -1
- package/lib/richtext/ItemsHtmlConverter.js +31 -15
- package/lib/wellknown.js +12 -9
- package/lib/widgets/IFrameWidget.d.ts +4 -4
- package/lib/widgets/ImageWidget.d.ts +7 -4
- package/lib/widgets/ImageWidget.js +9 -1
- package/lib/widgets/ImageWidgetComponent.d.ts +1 -0
- package/lib/widgets/ImageWidgetComponent.js +1 -1
- package/lib/widgets/MapWidget.d.ts +5 -48
- package/lib/widgets/MapWidget.js +26 -63
- package/lib/widgets/MarkdownWidget.d.ts +3 -0
- package/lib/widgets/MarkdownWidget.js +3 -0
- package/lib/widgets/TOCWidget.d.ts +15 -27
- package/lib/widgets/TOCWidget.js +107 -183
- package/lib/widgets/Widget.d.ts +18 -7
- package/lib/widgets/Widget.js +4 -0
- package/lib/widgets/WidgetScopesViewComponent.js +1 -1
- package/lib/widgets/charts/Chart.d.ts +10 -1
- package/lib/widgets/charts/Chart.js +22 -11
- package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartViewComponent.js +6 -3
- package/lib/widgets/charts/ChartWidget.d.ts +2 -0
- package/lib/widgets/charts/ChartWidget.js +9 -1
- package/lib/widgets/charts/ChartWidgetComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartWidgetComponent.js +2 -2
- package/lib/widgets/charts/calendar/CalendarChart.d.ts +1 -0
- package/lib/widgets/charts/calendar/CalendarChart.js +26 -0
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +3 -1
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.d.ts +1 -0
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.js +8 -0
- package/lib/widgets/charts/layered/LayeredChart.d.ts +2 -0
- package/lib/widgets/charts/layered/LayeredChart.js +63 -3
- package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +1 -1
- package/lib/widgets/charts/layered/LayeredChartCompiler.js +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 +79 -14
- package/src/dashboards/DashboardDesign.ts +9 -2
- package/src/dashboards/DashboardUtils.ts +39 -0
- package/src/dashboards/DashboardViewComponent.tsx +22 -3
- package/src/dashboards/ServerDashboardDataSource.ts +2 -1
- package/src/dashboards/SettingsModalComponent.tsx +450 -35
- package/src/dashboards/WidgetComponent.tsx +12 -6
- package/src/datagrids/CellEditor.tsx +354 -0
- package/src/datagrids/DatagridComponent.tsx +646 -0
- package/src/datagrids/DatagridViewComponent.tsx +539 -0
- package/src/datagrids/DirectDatagridDataSource.ts +2 -3
- package/src/datagrids/{ExprCellComponent.ts → ExprCellComponent.tsx} +28 -23
- package/src/datagrids/{FindReplaceModalComponent.ts → FindReplaceModalComponent.tsx} +109 -122
- package/src/index.css +1 -1
- package/src/index.ts +0 -1
- package/src/layouts/blocks/HorizontalBlockComponent.ts +2 -2
- package/src/mWaterLoader.ts +1 -1
- package/src/maps/BufferLayer.ts +83 -60
- package/src/maps/BufferLayerDesign.ts +20 -14
- package/src/maps/BufferLayerDesignerComponent.tsx +309 -0
- package/src/maps/ChoroplethLayer.ts +40 -19
- package/src/maps/ChoroplethLayerDesign.ts +4 -2
- package/src/maps/ChoroplethLayerDesigner.tsx +4 -2
- package/src/maps/ClusterLayer.ts +4 -10
- package/src/maps/DetailLevelSelectComponent.ts +1 -1
- package/src/maps/DirectMapDataSource.ts +2 -1
- package/src/maps/EditPopupComponent.ts +7 -3
- package/src/maps/GridLayer.ts +4 -10
- package/src/maps/GridLayerDesigner.tsx +5 -3
- package/src/maps/HoverContent.tsx +40 -16
- package/src/maps/Layer.ts +28 -10
- package/src/maps/LayerFactory.ts +0 -8
- package/src/maps/LayerLegendComponent.ts +2 -4
- package/src/maps/LayerSwitcherComponent.tsx +6 -2
- package/src/maps/LeafletMapComponent.tsx +3 -1
- package/src/maps/LegendComponent.tsx +10 -1
- package/src/maps/MWaterServerLayer.ts +3 -3
- package/src/maps/MapComponent.ts +3 -3
- package/src/maps/MapDesign.ts +3 -0
- package/src/maps/MapDesignerComponent.tsx +165 -162
- package/src/maps/MapLayerViewDesignerComponent.ts +2 -2
- package/src/maps/MapUtils.ts +24 -0
- package/src/maps/MapViewComponent.tsx +11 -3
- package/src/maps/MarkersLayer.ts +44 -18
- package/src/maps/MarkersLayerDesign.ts +19 -16
- package/src/maps/PopupFilterJoinsUtils.ts +6 -2
- package/src/maps/RasterMapViewComponent.ts +9 -45
- package/src/maps/ServerMapDataSource.ts +2 -2
- package/src/maps/SwitchableTileUrlLayer.tsx +4 -10
- package/src/maps/TileUrlLayer.tsx +4 -10
- package/src/maps/VectorMapViewComponent.tsx +28 -55
- package/src/maps/maps.ts +3 -0
- package/src/quickfilter/QuickfiltersComponent.ts +13 -7
- package/src/quickfilter/QuickfiltersDesignComponent.tsx +56 -74
- package/src/richtext/ExprItemsHtmlConverter.ts +9 -5
- package/src/richtext/ExprItemsTranslator.ts +176 -0
- package/src/richtext/ItemsHtmlConverter.ts +33 -18
- package/src/wellknown.ts +33 -30
- package/src/widgets/ImageWidget.ts +10 -1
- package/src/widgets/ImageWidgetComponent.ts +3 -2
- package/src/widgets/{MapWidget.ts → MapWidget.tsx} +90 -101
- package/src/widgets/MarkdownWidget.ts +3 -0
- package/src/widgets/TOCWidget.tsx +281 -0
- package/src/widgets/Widget.ts +25 -5
- package/src/widgets/WidgetScopesViewComponent.ts +2 -1
- package/src/widgets/charts/Chart.ts +31 -12
- package/src/widgets/charts/ChartViewComponent.ts +13 -3
- package/src/widgets/charts/ChartWidget.ts +11 -1
- package/src/widgets/charts/ChartWidgetComponent.tsx +9 -1
- package/src/widgets/charts/calendar/CalendarChart.ts +29 -0
- package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +3 -1
- package/src/widgets/charts/imagemosaic/ImageMosaicChart.ts +9 -0
- package/src/widgets/charts/layered/LayeredChart.ts +71 -3
- package/src/widgets/charts/layered/LayeredChartCompiler.ts +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
|
@@ -4,8 +4,7 @@ import { JsonQLFilter } from "../JsonQLFilter";
|
|
|
4
4
|
import { MapDesign } from "./MapDesign";
|
|
5
5
|
import { MapDataSource } from "./MapDataSource";
|
|
6
6
|
import { MapScope } from "./MapUtils";
|
|
7
|
-
|
|
8
|
-
export declare function MapViewComponent(props: {
|
|
7
|
+
export interface MapViewComponentProps {
|
|
9
8
|
schema: Schema;
|
|
10
9
|
dataSource: DataSource;
|
|
11
10
|
mapDataSource: MapDataSource;
|
|
@@ -33,6 +32,12 @@ export declare function MapViewComponent(props: {
|
|
|
33
32
|
zoomLocked?: boolean;
|
|
34
33
|
/** Locale to use. Overrides map design locale */
|
|
35
34
|
locale?: string;
|
|
35
|
+
/** Translate function to use for display. TODO: implement this */
|
|
36
|
+
translate?: (input: string) => string;
|
|
37
|
+
/** Increment to force refresh */
|
|
38
|
+
refreshTrigger?: number;
|
|
36
39
|
/** Whether to disable interaction or not. Default false (implemented for printing to reduce number of tiles request) */
|
|
37
40
|
disableInteraction?: boolean;
|
|
38
|
-
}
|
|
41
|
+
}
|
|
42
|
+
/** Component that displays just the map */
|
|
43
|
+
export declare function MapViewComponent(props: MapViewComponentProps): React.JSX.Element;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Layer, { OnGridClickOptions, OnGridHoverOptions, VectorTileDef } from "./Layer";
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import Layer, { OnGridClickOptions, OnGridHoverOptions, VectorTileDef, LegendOptions } from "./Layer";
|
|
3
3
|
import { Schema, DataSource } from "@mwater/expressions";
|
|
4
4
|
import { OnGridClickResults, OnGridHoverResults } from "./maps";
|
|
5
5
|
import { JsonQLFilter } from "../index";
|
|
6
6
|
import { JsonQLQuery, JsonQLSelectQuery } from "@mwater/jsonql";
|
|
7
7
|
import { MarkersLayerDesign } from "./MarkersLayerDesign";
|
|
8
|
-
import LayerLegendComponent from "./LayerLegendComponent";
|
|
9
8
|
export default class MarkersLayer extends Layer<MarkersLayerDesign> {
|
|
10
9
|
/** Gets the type of layer definition */
|
|
11
10
|
getLayerDefinitionType(): "VectorTile";
|
|
@@ -35,7 +34,7 @@ export default class MarkersLayer extends Layer<MarkersLayerDesign> {
|
|
|
35
34
|
getBounds(design: MarkersLayerDesign, schema: Schema, dataSource: DataSource, filters: JsonQLFilter[], callback: any): void;
|
|
36
35
|
getMinZoom(design: MarkersLayerDesign): number | undefined;
|
|
37
36
|
getMaxZoom(design: MarkersLayerDesign): number;
|
|
38
|
-
getLegend(
|
|
37
|
+
getLegend(options: LegendOptions<MarkersLayerDesign>): ReactNode;
|
|
39
38
|
getFilterableTables(design: MarkersLayerDesign, schema: Schema): string[];
|
|
40
39
|
isEditable(): boolean;
|
|
41
40
|
createDesignerElement(options: {
|
|
@@ -47,6 +46,8 @@ export default class MarkersLayer extends Layer<MarkersLayerDesign> {
|
|
|
47
46
|
}): React.ReactElement<{}>;
|
|
48
47
|
cleanDesign(design: MarkersLayerDesign, schema: Schema): MarkersLayerDesign;
|
|
49
48
|
validateDesign(design: MarkersLayerDesign, schema: Schema): string | null;
|
|
49
|
+
/** Get strings to be translated */
|
|
50
|
+
getTranslatableStrings(design: MarkersLayerDesign, schema: Schema): string[];
|
|
50
51
|
}
|
|
51
52
|
/**
|
|
52
53
|
* Takes a base query that has any number of selects and where conditions. It must have a geometry
|
package/lib/maps/MarkersLayer.js
CHANGED
|
@@ -38,6 +38,8 @@ const LayerLegendComponent_1 = __importDefault(require("./LayerLegendComponent")
|
|
|
38
38
|
const PopupFilterJoinsUtils = __importStar(require("./PopupFilterJoinsUtils"));
|
|
39
39
|
const HoverContent_1 = __importDefault(require("./HoverContent"));
|
|
40
40
|
const layoutOptions_1 = require("../dashboards/layoutOptions");
|
|
41
|
+
const BlocksLayoutManager_1 = __importDefault(require("../layouts/blocks/BlocksLayoutManager"));
|
|
42
|
+
const DashboardUtils_1 = require("../dashboards/DashboardUtils");
|
|
41
43
|
class MarkersLayer extends Layer_1.default {
|
|
42
44
|
/** Gets the type of layer definition */
|
|
43
45
|
getLayerDefinitionType() {
|
|
@@ -453,7 +455,8 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
|
|
|
453
455
|
key: ev.data.id,
|
|
454
456
|
schema: hoverOptions.schema,
|
|
455
457
|
dataSource: hoverOptions.dataSource,
|
|
456
|
-
|
|
458
|
+
table,
|
|
459
|
+
items: hoverOptions.design.hoverOver.items,
|
|
457
460
|
filters: [
|
|
458
461
|
{
|
|
459
462
|
table,
|
|
@@ -466,7 +469,9 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
|
|
|
466
469
|
]
|
|
467
470
|
}
|
|
468
471
|
}
|
|
469
|
-
]
|
|
472
|
+
],
|
|
473
|
+
locale: hoverOptions.locale,
|
|
474
|
+
translate: hoverOptions.translate
|
|
470
475
|
});
|
|
471
476
|
}
|
|
472
477
|
return results;
|
|
@@ -555,10 +560,10 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
|
|
|
555
560
|
design: options.design,
|
|
556
561
|
scope: null,
|
|
557
562
|
filters,
|
|
558
|
-
onScopeChange: null,
|
|
559
|
-
onDesignChange: null,
|
|
560
563
|
width: options.width,
|
|
561
|
-
height: options.height
|
|
564
|
+
height: options.height,
|
|
565
|
+
locale: clickOptions.locale,
|
|
566
|
+
translate: clickOptions.translate
|
|
562
567
|
});
|
|
563
568
|
}
|
|
564
569
|
});
|
|
@@ -585,7 +590,8 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
|
|
|
585
590
|
}
|
|
586
591
|
// Get the legend to be optionally displayed on the map. Returns
|
|
587
592
|
// a React element
|
|
588
|
-
getLegend(
|
|
593
|
+
getLegend(options) {
|
|
594
|
+
const { design, schema, name, dataSource, locale, filters, translate } = options;
|
|
589
595
|
const _filters = filters.slice();
|
|
590
596
|
if (design.filter != null) {
|
|
591
597
|
const exprCompiler = new expressions_1.ExprCompiler(schema);
|
|
@@ -600,7 +606,7 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
|
|
|
600
606
|
defaultColor: design.color,
|
|
601
607
|
symbol: design.symbol || "font-awesome/circle",
|
|
602
608
|
markerSize: design.markerSize,
|
|
603
|
-
name,
|
|
609
|
+
name: translate(name),
|
|
604
610
|
filters: lodash_1.default.compact(_filters),
|
|
605
611
|
axis: axisBuilder.cleanAxis({
|
|
606
612
|
axis: design.axes.color || null,
|
|
@@ -703,6 +709,26 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
|
|
|
703
709
|
}
|
|
704
710
|
return null;
|
|
705
711
|
}
|
|
712
|
+
/** Get strings to be translated */
|
|
713
|
+
getTranslatableStrings(design, schema) {
|
|
714
|
+
const strings = [];
|
|
715
|
+
// Add strings from hoverOver items
|
|
716
|
+
if (design.hoverOver && design.hoverOver.items) {
|
|
717
|
+
for (const item of design.hoverOver.items) {
|
|
718
|
+
if (item.label) {
|
|
719
|
+
strings.push(item.label);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
// Add strings from popup items using a layout manager approach
|
|
724
|
+
if (design.popup && design.popup.items) {
|
|
725
|
+
const layoutManager = new BlocksLayoutManager_1.default();
|
|
726
|
+
const popupStrings = (0, DashboardUtils_1.getTranslatableStringsFromLayoutManager)(layoutManager, design.popup.items, schema);
|
|
727
|
+
strings.push(...popupStrings);
|
|
728
|
+
}
|
|
729
|
+
// Remove duplicates
|
|
730
|
+
return lodash_1.default.uniq(strings);
|
|
731
|
+
}
|
|
706
732
|
}
|
|
707
733
|
exports.default = MarkersLayer;
|
|
708
734
|
/**
|
|
@@ -1,43 +1,46 @@
|
|
|
1
1
|
import { Expr } from "@mwater/expressions";
|
|
2
2
|
import { Axis } from "../axes/Axis";
|
|
3
3
|
import { HoverOverItem } from "./maps";
|
|
4
|
+
import { LayoutBlock } from "../layouts/blocks/blockUtils";
|
|
5
|
+
import { PopupFilterJoins } from "./PopupFilterJoinsUtils";
|
|
4
6
|
/** Design for a markers layer */
|
|
5
7
|
export interface MarkersLayerDesign {
|
|
6
8
|
/** table to get data from */
|
|
7
9
|
table: string;
|
|
8
|
-
/**
|
|
10
|
+
/** Axes */
|
|
9
11
|
axes: {
|
|
10
|
-
/**
|
|
12
|
+
/** Where to place markers */
|
|
11
13
|
geometry: Axis;
|
|
12
|
-
/**
|
|
14
|
+
/** Color axis (to split into series based on a color) */
|
|
13
15
|
color?: Axis;
|
|
14
16
|
};
|
|
15
|
-
/**
|
|
17
|
+
/** Optional logical expression to filter by */
|
|
16
18
|
filter?: Expr;
|
|
17
|
-
/**
|
|
19
|
+
/** Color of layer (e.g. #FF8800). Color axis overrides */
|
|
18
20
|
color?: string;
|
|
19
|
-
/**
|
|
21
|
+
/** Symbol to use for layer. e.g. "font-awesome/bell". Will be converted on server to proper uri. */
|
|
20
22
|
symbol?: string;
|
|
21
|
-
/**
|
|
23
|
+
/** Size in pixels of the markers. Default 10. */
|
|
22
24
|
markerSize?: number;
|
|
23
|
-
/**
|
|
25
|
+
/** Size of the lines in pixels. Default 3 */
|
|
24
26
|
lineWidth?: number;
|
|
25
|
-
/**
|
|
27
|
+
/** Opacity of polygon fill (0-1). Default is 0.25 */
|
|
26
28
|
polygonFillOpacity?: number;
|
|
27
|
-
/**
|
|
29
|
+
/** Color of polygon borders (defaults to color of fill) */
|
|
28
30
|
polygonBorderColor?: string;
|
|
29
|
-
/**
|
|
31
|
+
/** Contains items: which is BlocksLayoutManager items. Will be displayed when the marker is clicked */
|
|
30
32
|
popup: {
|
|
31
|
-
items:
|
|
33
|
+
items: LayoutBlock;
|
|
32
34
|
};
|
|
35
|
+
/** Contains items to display when hovering over the layer */
|
|
33
36
|
hoverOver: {
|
|
34
37
|
items: HoverOverItem[];
|
|
35
38
|
};
|
|
36
|
-
/**
|
|
37
|
-
popupFilterJoins:
|
|
38
|
-
/**
|
|
39
|
+
/** Customizable filtering for popup */
|
|
40
|
+
popupFilterJoins: PopupFilterJoins;
|
|
41
|
+
/** Minimum zoom level */
|
|
39
42
|
minZoom?: number;
|
|
40
|
-
/**
|
|
43
|
+
/** Maximum zoom level */
|
|
41
44
|
maxZoom?: number;
|
|
42
45
|
/** @deprecated LEGACY sublayers array that contains above design */
|
|
43
46
|
sublayers?: any[];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Expr, Schema } from "@mwater/expressions";
|
|
2
2
|
import { JsonQLFilter } from "..";
|
|
3
3
|
/**
|
|
4
|
-
* Utilities for popup filter joins.
|
|
5
4
|
* Object keyed by table name that has expressions as values.
|
|
6
5
|
* Each value is an expression for its key's table that is a type `id` or `idTable` of the layer's table.
|
|
7
6
|
* This is used to filter the popup so that the rows are scoped to the item clicked on.
|
|
@@ -9,9 +8,13 @@ import { JsonQLFilter } from "..";
|
|
|
9
8
|
* However, it could also filter to only water points that are related to the water system by adding the following key-value:
|
|
10
9
|
* entities.water_point: { table: "entities.water_point", type: "field", column: "water_system" }
|
|
11
10
|
*/
|
|
12
|
-
export
|
|
11
|
+
export type PopupFilterJoins = {
|
|
13
12
|
[tableId: string]: Expr;
|
|
14
|
-
}
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Utilities for popup filter joins.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createPopupFilters(popupFilterJoins: PopupFilterJoins, schema: Schema, layerTable: any, rowId: any, useWithin?: boolean): JsonQLFilter[];
|
|
15
18
|
export declare function createDefaultPopupFilterJoins(table: any): {
|
|
16
19
|
[x: number]: {
|
|
17
20
|
table: any;
|
|
@@ -6,12 +6,6 @@ const expressions_1 = require("@mwater/expressions");
|
|
|
6
6
|
const expressions_2 = require("@mwater/expressions");
|
|
7
7
|
/**
|
|
8
8
|
* Utilities for popup filter joins.
|
|
9
|
-
* Object keyed by table name that has expressions as values.
|
|
10
|
-
* Each value is an expression for its key's table that is a type `id` or `idTable` of the layer's table.
|
|
11
|
-
* This is used to filter the popup so that the rows are scoped to the item clicked on.
|
|
12
|
-
* For example, if the map displays water systems, the popup will (by default) only be filtered by water systems, selecting only the row that was clicked on.
|
|
13
|
-
* However, it could also filter to only water points that are related to the water system by adding the following key-value:
|
|
14
|
-
* entities.water_point: { table: "entities.water_point", type: "field", column: "water_system" }
|
|
15
9
|
*/
|
|
16
10
|
function createPopupFilters(popupFilterJoins, schema, layerTable, rowId, useWithin = false) {
|
|
17
11
|
const exprUtils = new expressions_2.ExprUtils(schema);
|
|
@@ -3,39 +3,10 @@ import LeafletMapComponent from "./LeafletMapComponent";
|
|
|
3
3
|
import { Schema, DataSource } from "@mwater/expressions";
|
|
4
4
|
import ModalPopupComponent from "@mwater/react-library/lib/ModalPopupComponent";
|
|
5
5
|
import { JsonQLFilter } from "../JsonQLFilter";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import { MapScope } from "./MapUtils";
|
|
9
|
-
export interface RasterMapViewComponentProps {
|
|
10
|
-
schema: Schema;
|
|
11
|
-
dataSource: DataSource;
|
|
12
|
-
mapDataSource: MapDataSource;
|
|
13
|
-
design: MapDesign;
|
|
14
|
-
onDesignChange?: (design: MapDesign) => void;
|
|
15
|
-
/** Width in pixels */
|
|
16
|
-
width: number;
|
|
17
|
-
/** Height in pixels */
|
|
18
|
-
height: number;
|
|
19
|
-
/** Called with (tableId, rowId) when item is clicked */
|
|
20
|
-
onRowClick?: (tableId: string, rowId: any) => void;
|
|
21
|
-
/** Extra filters to apply to view */
|
|
22
|
-
extraFilters?: JsonQLFilter[];
|
|
23
|
-
/** scope of the map (when a layer self-selects a particular scope) */
|
|
24
|
-
scope?: MapScope;
|
|
25
|
-
/** called with (scope) as a scope to apply to self and filter to apply to other widgets. See WidgetScoper for details */
|
|
26
|
-
onScopeChange?: (scope: MapScope | null) => void;
|
|
27
|
-
/** Whether the map be draggable with mouse/touch or not. Default true */
|
|
28
|
-
dragging?: boolean;
|
|
29
|
-
/** Whether the map can be zoomed by touch-dragging with two fingers. Default true */
|
|
30
|
-
touchZoom?: boolean;
|
|
31
|
-
/** Whether the map can be zoomed by using the mouse wheel. Default true */
|
|
32
|
-
scrollWheelZoom?: boolean;
|
|
33
|
-
/** Whether changes to zoom level should be persisted. Default false */
|
|
34
|
-
zoomLocked?: boolean;
|
|
6
|
+
import { MapViewComponentProps } from "./MapViewComponent";
|
|
7
|
+
export interface RasterMapViewComponentProps extends MapViewComponentProps {
|
|
35
8
|
/** Called with underlying leaflet map component */
|
|
36
9
|
leafletMapRef?: (map: LeafletMapComponent | null) => void;
|
|
37
|
-
/** Whether to disable interaction or not. Default false (implemented for printing to reduce number of tiles request) */
|
|
38
|
-
disableInteraction?: boolean;
|
|
39
10
|
}
|
|
40
11
|
/** Component that displays just the map, using raster tile technology */
|
|
41
12
|
export default class RasterMapViewComponent extends React.Component<RasterMapViewComponentProps, {
|
|
@@ -59,6 +30,7 @@ export default class RasterMapViewComponent extends React.Component<RasterMapVie
|
|
|
59
30
|
filters: JsonQLFilter[];
|
|
60
31
|
dataSource: DataSource;
|
|
61
32
|
locale: any;
|
|
33
|
+
translate: (input: string) => string;
|
|
62
34
|
onHide: () => void;
|
|
63
35
|
zoom: null;
|
|
64
36
|
}>;
|
|
@@ -104,13 +104,16 @@ class RasterMapViewComponent extends react_1.default.Component {
|
|
|
104
104
|
// Clean design (prevent ever displaying invalid/legacy designs)
|
|
105
105
|
const design = layer.cleanDesign(layerView.design, this.props.schema);
|
|
106
106
|
// Handle click of layer
|
|
107
|
+
// TODO not translated
|
|
107
108
|
const results = layer.onGridClick(ev, {
|
|
108
109
|
design,
|
|
109
110
|
schema: this.props.schema,
|
|
110
111
|
dataSource: this.props.dataSource,
|
|
111
112
|
layerDataSource: this.props.mapDataSource.getLayerDataSource(layerViewId),
|
|
112
113
|
scopeData: this.props.scope?.data?.layerViewId === layerViewId ? this.props.scope.data.data : undefined,
|
|
113
|
-
filters: this.getCompiledFilters()
|
|
114
|
+
filters: this.getCompiledFilters(),
|
|
115
|
+
locale: this.context,
|
|
116
|
+
translate: (input) => input
|
|
114
117
|
});
|
|
115
118
|
if (!results) {
|
|
116
119
|
return;
|
|
@@ -155,6 +158,7 @@ class RasterMapViewComponent extends react_1.default.Component {
|
|
|
155
158
|
filters: this.getCompiledFilters(),
|
|
156
159
|
dataSource: this.props.dataSource,
|
|
157
160
|
locale: this.context,
|
|
161
|
+
translate: this.props.translate ?? (() => ""),
|
|
158
162
|
onHide: () => this.setState({ legendHidden: true }),
|
|
159
163
|
zoom: null
|
|
160
164
|
});
|
|
@@ -230,7 +234,8 @@ class RasterMapViewComponent extends react_1.default.Component {
|
|
|
230
234
|
return R("div", { style: { width: this.props.width, height: this.props.height, position: "relative" } }, this.renderPopup(), R("div", { style: { position: "absolute", maxWidth: 250, top: 10, right: 10, zIndex: 999, userSelect: "none" } }, R("div", { style: { display: "flex", gap: 6, position: "relative", flexDirection: "column", alignItems: "right" } }, this.props.onDesignChange && this.props.design.showLayerSwitcher
|
|
231
235
|
? R(LayerSwitcherComponent_1.LayerSwitcherComponent, {
|
|
232
236
|
design: this.props.design,
|
|
233
|
-
onDesignChange: this.props.onDesignChange
|
|
237
|
+
onDesignChange: this.props.onDesignChange,
|
|
238
|
+
translate: this.props.translate ?? (() => "")
|
|
234
239
|
})
|
|
235
240
|
: undefined)), R(LeafletMapComponent_1.default, {
|
|
236
241
|
ref: (c) => {
|
|
@@ -118,7 +118,8 @@ class ServerLayerDataSource {
|
|
|
118
118
|
throw new Error("Error getting tiles token");
|
|
119
119
|
}
|
|
120
120
|
const { token, expires } = await response.json();
|
|
121
|
-
|
|
121
|
+
// Client isn't necessary, but allows tracking of usage easier
|
|
122
|
+
return { url: this.options.apiUrl + `vector_tiles/tiles/{z}/{x}/{y}?token=${token}&client=${this.options.client ?? ""}`, expires };
|
|
122
123
|
}
|
|
123
124
|
// Gets widget data source for a popup widget
|
|
124
125
|
getPopupWidgetDataSource(design, widgetId) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Layer from "./Layer";
|
|
1
|
+
import Layer, { LegendOptions } from "./Layer";
|
|
2
2
|
import { Schema, DataSource } from "@mwater/expressions";
|
|
3
3
|
import { JsonQLFilter } from "../index";
|
|
4
|
-
import React from "react";
|
|
4
|
+
import React, { ReactNode } from "react";
|
|
5
5
|
/**
|
|
6
6
|
* Layer that is composed of multiple tile urls that can be switched between
|
|
7
7
|
* Loads legend from the server as well
|
|
@@ -39,7 +39,7 @@ export default class SwitchableTileUrlLayer extends Layer<SwitchableTileUrlLayer
|
|
|
39
39
|
getTileUrl(design: SwitchableTileUrlLayerDesign, filters: JsonQLFilter[]): string | null;
|
|
40
40
|
/** Gets the utf grid url for definition type "TileUrl" */
|
|
41
41
|
getUtfGridUrl(design: SwitchableTileUrlLayerDesign, filters: JsonQLFilter[]): string | null;
|
|
42
|
-
getLegend(
|
|
42
|
+
getLegend(options: LegendOptions<SwitchableTileUrlLayerDesign>): ReactNode;
|
|
43
43
|
/** True if layer can be edited */
|
|
44
44
|
isEditable(): boolean;
|
|
45
45
|
createDesignerElement(options: {
|
|
@@ -35,7 +35,8 @@ class SwitchableTileUrlLayer extends Layer_1.default {
|
|
|
35
35
|
}
|
|
36
36
|
return option.utfGridUrl || null;
|
|
37
37
|
}
|
|
38
|
-
getLegend(
|
|
38
|
+
getLegend(options) {
|
|
39
|
+
const { design, name } = options;
|
|
39
40
|
// Find active option
|
|
40
41
|
const option = design.options.find((d) => d.id === design.activeOption);
|
|
41
42
|
if (!option || !option.legendUrl) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Layer from "./Layer";
|
|
3
|
-
import {
|
|
4
|
-
import { JsonQLFilter } from "../JsonQLFilter";
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import Layer, { LegendOptions } from "./Layer";
|
|
3
|
+
import { Schema } from "@mwater/expressions";
|
|
5
4
|
export interface TileUrlLayerDesign {
|
|
6
5
|
/** Url with {s}, {z}, {x}, {y} */
|
|
7
6
|
tileUrl: string;
|
|
@@ -22,7 +21,7 @@ export default class TileUrlLayer extends Layer<TileUrlLayerDesign> {
|
|
|
22
21
|
getMaxZoom(design: any): any;
|
|
23
22
|
isEditable(): boolean;
|
|
24
23
|
isIncomplete(design: any, schema: Schema): boolean;
|
|
25
|
-
getLegend(
|
|
24
|
+
getLegend(options: LegendOptions<TileUrlLayerDesign>): ReactNode;
|
|
26
25
|
createDesignerElement(options: any): React.CElement<TileUrlLayerDesignerComponentProps, TileUrlLayerDesignerComponent>;
|
|
27
26
|
cleanDesign(design: any, schema: Schema): any;
|
|
28
27
|
validateDesign(design: any, schema: Schema): string | null;
|
package/lib/maps/TileUrlLayer.js
CHANGED
|
@@ -45,7 +45,8 @@ class TileUrlLayer extends Layer_1.default {
|
|
|
45
45
|
isIncomplete(design, schema) {
|
|
46
46
|
return this.validateDesign(this.cleanDesign(design, schema), schema) != null;
|
|
47
47
|
}
|
|
48
|
-
getLegend(
|
|
48
|
+
getLegend(options) {
|
|
49
|
+
const { design } = options;
|
|
49
50
|
// Find active option
|
|
50
51
|
if (!design.legendUrl) {
|
|
51
52
|
return null;
|
|
@@ -1,44 +1,12 @@
|
|
|
1
|
-
import { DataSource, Schema } from "@mwater/expressions";
|
|
2
1
|
import React from "react";
|
|
3
|
-
import { JsonQLFilter } from "../JsonQLFilter";
|
|
4
|
-
import { MapDesign } from "./MapDesign";
|
|
5
|
-
import { MapDataSource } from "./MapDataSource";
|
|
6
|
-
import { MapScope } from "./MapUtils";
|
|
7
2
|
import "maplibre-gl/dist/maplibre-gl.css";
|
|
8
3
|
import "./VectorMapViewComponent.css";
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
schema: Schema;
|
|
12
|
-
dataSource: DataSource;
|
|
13
|
-
mapDataSource: MapDataSource;
|
|
14
|
-
design: MapDesign;
|
|
15
|
-
onDesignChange?: (design: MapDesign) => void;
|
|
16
|
-
/** Width in pixels */
|
|
17
|
-
width: number;
|
|
18
|
-
/** Height in pixels */
|
|
19
|
-
height: number;
|
|
20
|
-
/** Called with (tableId, rowId) when item is clicked */
|
|
21
|
-
onRowClick?: (tableId: string, rowId: any) => void;
|
|
22
|
-
/** Extra filters to apply to view */
|
|
23
|
-
extraFilters?: JsonQLFilter[];
|
|
24
|
-
/** scope of the map (when a layer self-selects a particular scope) */
|
|
25
|
-
scope?: MapScope;
|
|
26
|
-
/** called with (scope) as a scope to apply to self and filter to apply to other widgets. See WidgetScoper for details */
|
|
27
|
-
onScopeChange?: (scope: MapScope | null) => void;
|
|
28
|
-
/** Whether the map be draggable with mouse/touch or not. Default true */
|
|
29
|
-
dragging?: boolean;
|
|
30
|
-
/** Whether the map can be zoomed by touch-dragging with two fingers. Default true */
|
|
31
|
-
touchZoom?: boolean;
|
|
32
|
-
/** Whether the map can be zoomed by using the mouse wheel. Default true */
|
|
33
|
-
scrollWheelZoom?: boolean;
|
|
34
|
-
/** Whether changes to zoom level should be persisted. Default false */
|
|
35
|
-
zoomLocked?: boolean;
|
|
36
|
-
/** Locale to use. Overrides map design locale */
|
|
37
|
-
locale?: string;
|
|
38
|
-
/** Increment to force refresh */
|
|
39
|
-
refreshTrigger?: number;
|
|
4
|
+
import { MapViewComponentProps } from "./MapViewComponent";
|
|
5
|
+
export interface VectorMapViewComponentProps extends MapViewComponentProps {
|
|
40
6
|
/** Optional callback that gets updated MapLibre map each render. Used to allow
|
|
41
7
|
* external zooming/panning.
|
|
42
8
|
*/
|
|
43
9
|
onMapUpdate?: (map: maplibregl.Map) => void;
|
|
44
|
-
}
|
|
10
|
+
}
|
|
11
|
+
/** Component that displays just the map, using vector tile technology */
|
|
12
|
+
export declare function VectorMapViewComponent(props: VectorMapViewComponentProps): React.JSX.Element;
|
|
@@ -64,6 +64,10 @@ function VectorMapViewComponent(props) {
|
|
|
64
64
|
// State of legend
|
|
65
65
|
const initialLegendDisplay = props.design.initialLegendDisplay || "open";
|
|
66
66
|
const [legendHidden, setLegendHidden] = (0, react_1.useState)(initialLegendDisplay == "closed" || (props.width < 500 && initialLegendDisplay == "closedIfSmall"));
|
|
67
|
+
// Locale to use
|
|
68
|
+
const locale = props.locale || props.design.locale || "en";
|
|
69
|
+
// Translate function to use TODO
|
|
70
|
+
const translate = props.translate || ((input) => input);
|
|
67
71
|
// Last feature that mouse entered
|
|
68
72
|
const lastFeature = (0, react_2.useRef)();
|
|
69
73
|
// Load map
|
|
@@ -90,17 +94,19 @@ function VectorMapViewComponent(props) {
|
|
|
90
94
|
// Create layer
|
|
91
95
|
const layer = LayerFactory_1.default.createLayer(layerView.type);
|
|
92
96
|
// Clean design (prevent ever displaying invalid/legacy designs)
|
|
93
|
-
const
|
|
97
|
+
const layerDesign = layer.cleanDesign(layerView.design, props.schema);
|
|
94
98
|
// Handle click of layer
|
|
95
99
|
const results = layer.onGridHoverOver(ev, {
|
|
96
|
-
design:
|
|
100
|
+
design: layerDesign,
|
|
97
101
|
schema: props.schema,
|
|
98
102
|
dataSource: props.dataSource,
|
|
99
103
|
layerDataSource: props.mapDataSource.getLayerDataSource(layerViewId),
|
|
100
104
|
scopeData: props.scope && props.scope.data && props.scope.data.layerViewId == layerViewId
|
|
101
105
|
? props.scope.data.data
|
|
102
106
|
: undefined,
|
|
103
|
-
filters: getCompiledFilters()
|
|
107
|
+
filters: getCompiledFilters(),
|
|
108
|
+
locale: locale,
|
|
109
|
+
translate: translate
|
|
104
110
|
});
|
|
105
111
|
if (!results) {
|
|
106
112
|
setHoverContents(null);
|
|
@@ -127,7 +133,9 @@ function VectorMapViewComponent(props) {
|
|
|
127
133
|
scopeData: props.scope && props.scope.data && props.scope.data.layerViewId == layerViewId
|
|
128
134
|
? props.scope.data.data
|
|
129
135
|
: undefined,
|
|
130
|
-
filters: getCompiledFilters()
|
|
136
|
+
filters: getCompiledFilters(),
|
|
137
|
+
locale: locale,
|
|
138
|
+
translate: translate
|
|
131
139
|
});
|
|
132
140
|
if (!results) {
|
|
133
141
|
return;
|
|
@@ -391,7 +399,10 @@ function VectorMapViewComponent(props) {
|
|
|
391
399
|
props.mapDataSource.getBounds(props.design, getCompiledFilters(), (error, bounds) => {
|
|
392
400
|
setBusy(b => b - 1);
|
|
393
401
|
if (bounds) {
|
|
394
|
-
map.fitBounds([bounds.w, bounds.s, bounds.e, bounds.n], {
|
|
402
|
+
map.fitBounds([bounds.w, bounds.s, bounds.e, bounds.n], {
|
|
403
|
+
padding: 30,
|
|
404
|
+
duration: (props.design.animateAutoBounds ?? true) ? 2500 : 0
|
|
405
|
+
});
|
|
395
406
|
// Also record if editable as part of bounds
|
|
396
407
|
setBounds(bounds);
|
|
397
408
|
}
|
|
@@ -488,7 +499,7 @@ function VectorMapViewComponent(props) {
|
|
|
488
499
|
return react_1.default.createElement(HiddenLegend, { onShow: () => setLegendHidden(false) });
|
|
489
500
|
}
|
|
490
501
|
else {
|
|
491
|
-
return (react_1.default.createElement(LegendComponent_1.default, { schema: props.schema, layerViews: props.design.layerViews, filters: getCompiledFilters(), zoom: map ? map.getZoom() : null, dataSource: props.dataSource, locale:
|
|
502
|
+
return (react_1.default.createElement(LegendComponent_1.default, { schema: props.schema, layerViews: props.design.layerViews, filters: getCompiledFilters(), zoom: map ? map.getZoom() : null, dataSource: props.dataSource, locale: locale, translate: translate, onHide: () => setLegendHidden(true) }));
|
|
492
503
|
}
|
|
493
504
|
}
|
|
494
505
|
/** Render a spinner if loading */
|
|
@@ -518,14 +529,14 @@ function VectorMapViewComponent(props) {
|
|
|
518
529
|
border: "solid 1px #AAA",
|
|
519
530
|
maxWidth: 250
|
|
520
531
|
};
|
|
521
|
-
return react_1.default.createElement("div", { style: style }, hoverContents
|
|
532
|
+
return react_1.default.createElement("div", { style: style }, hoverContents);
|
|
522
533
|
};
|
|
523
534
|
// Overflow hidden because of problem of exceeding div
|
|
524
535
|
return (react_1.default.createElement("div", { style: { width: props.width, height: props.height, position: "relative" } },
|
|
525
536
|
renderPopup(),
|
|
526
537
|
react_1.default.createElement("div", { style: { position: "absolute", maxWidth: 250, top: 10, right: 10, zIndex: 999, userSelect: "none" } },
|
|
527
538
|
react_1.default.createElement("div", { style: { display: "flex", gap: 6, position: "relative", flexDirection: "column", alignItems: "right" } },
|
|
528
|
-
props.onDesignChange != null && props.design.showLayerSwitcher ? (react_1.default.createElement(LayerSwitcherComponent_1.LayerSwitcherComponent, { design: props.design, onDesignChange: props.onDesignChange })) : null,
|
|
539
|
+
props.onDesignChange != null && props.design.showLayerSwitcher ? (react_1.default.createElement(LayerSwitcherComponent_1.LayerSwitcherComponent, { design: props.design, onDesignChange: props.onDesignChange, translate: translate })) : null,
|
|
529
540
|
renderHoverContent())),
|
|
530
541
|
react_1.default.createElement("div", { style: { width: props.width, height: props.height }, ref: setMapDiv }),
|
|
531
542
|
renderLegend(),
|
package/lib/maps/maps.d.ts
CHANGED
|
@@ -28,8 +28,11 @@ export type OnGridHoverResults = {
|
|
|
28
28
|
scope?: any;
|
|
29
29
|
hoverOver?: React.ReactElement<{}>;
|
|
30
30
|
} | null;
|
|
31
|
+
/** Item in hover over */
|
|
31
32
|
export interface HoverOverItem {
|
|
32
33
|
id: string;
|
|
33
34
|
label: string;
|
|
34
35
|
value?: Expr;
|
|
36
|
+
/** See valueFormatter.ts */
|
|
37
|
+
format?: string;
|
|
35
38
|
}
|
|
@@ -21,6 +21,8 @@ export interface QuickfiltersComponentProps {
|
|
|
21
21
|
hideTopBorder?: boolean;
|
|
22
22
|
/** Called when user hides the quickfilter bar */
|
|
23
23
|
onHide?: () => void;
|
|
24
|
+
/** Translate function to use for display */
|
|
25
|
+
translate?: (input: string) => string;
|
|
24
26
|
}
|
|
25
27
|
/** Displays quick filters and allows their value to be modified */
|
|
26
28
|
export default class QuickfiltersComponent extends React.Component<QuickfiltersComponentProps> {
|
|
@@ -24,6 +24,8 @@ class QuickfiltersComponent extends react_1.default.Component {
|
|
|
24
24
|
}
|
|
25
25
|
let values = this.props.values || [];
|
|
26
26
|
let itemValue = values[index];
|
|
27
|
+
// Translate label
|
|
28
|
+
const label = this.props.translate?.(item.label) ?? item.label;
|
|
27
29
|
// Clean expression first
|
|
28
30
|
const expr = new expressions_2.ExprCleaner(this.props.schema).cleanExpr(item.expr);
|
|
29
31
|
// Do not render if nothing
|
|
@@ -73,7 +75,7 @@ class QuickfiltersComponent extends react_1.default.Component {
|
|
|
73
75
|
if (["enum", "enumset"].includes(type)) {
|
|
74
76
|
return R(EnumQuickfilterComponent, {
|
|
75
77
|
key: JSON.stringify(item),
|
|
76
|
-
label
|
|
78
|
+
label,
|
|
77
79
|
schema: this.props.schema,
|
|
78
80
|
options: new expressions_1.ExprUtils(this.props.schema).getExprEnumValues(expr),
|
|
79
81
|
value: itemValue,
|
|
@@ -85,7 +87,7 @@ class QuickfiltersComponent extends react_1.default.Component {
|
|
|
85
87
|
return R(TextQuickfilterComponent, {
|
|
86
88
|
key: JSON.stringify(item),
|
|
87
89
|
index,
|
|
88
|
-
label
|
|
90
|
+
label,
|
|
89
91
|
expr,
|
|
90
92
|
schema: this.props.schema,
|
|
91
93
|
quickfiltersDataSource: this.props.quickfiltersDataSource,
|
|
@@ -98,7 +100,7 @@ class QuickfiltersComponent extends react_1.default.Component {
|
|
|
98
100
|
if (["date", "datetime"].includes(type)) {
|
|
99
101
|
return R(DateQuickfilterComponent, {
|
|
100
102
|
key: JSON.stringify(item),
|
|
101
|
-
label
|
|
103
|
+
label,
|
|
102
104
|
expr,
|
|
103
105
|
schema: this.props.schema,
|
|
104
106
|
value: itemValue,
|
|
@@ -109,7 +111,7 @@ class QuickfiltersComponent extends react_1.default.Component {
|
|
|
109
111
|
return R(IdArrayQuickfilterComponent_1.default, {
|
|
110
112
|
key: JSON.stringify(item),
|
|
111
113
|
index,
|
|
112
|
-
label
|
|
114
|
+
label,
|
|
113
115
|
expr,
|
|
114
116
|
schema: this.props.schema,
|
|
115
117
|
dataSource: this.props.dataSource,
|
|
@@ -123,7 +125,7 @@ class QuickfiltersComponent extends react_1.default.Component {
|
|
|
123
125
|
return R(TextArrayQuickfilterComponent, {
|
|
124
126
|
key: JSON.stringify(item),
|
|
125
127
|
index,
|
|
126
|
-
label
|
|
128
|
+
label,
|
|
127
129
|
expr,
|
|
128
130
|
schema: this.props.schema,
|
|
129
131
|
quickfiltersDataSource: this.props.quickfiltersDataSource,
|
|
@@ -172,7 +174,7 @@ class EnumQuickfilterComponent extends react_1.default.Component {
|
|
|
172
174
|
};
|
|
173
175
|
renderSingleSelect(options) {
|
|
174
176
|
return R(react_select_1.default, {
|
|
175
|
-
placeholder:
|
|
177
|
+
placeholder: T `All`,
|
|
176
178
|
value: lodash_1.default.findWhere(options, { value: this.props.value }) || null,
|
|
177
179
|
options,
|
|
178
180
|
isClearable: true,
|
|
@@ -190,7 +192,7 @@ class EnumQuickfilterComponent extends react_1.default.Component {
|
|
|
190
192
|
}
|
|
191
193
|
renderMultiSelect(options) {
|
|
192
194
|
return R(react_select_1.default, {
|
|
193
|
-
placeholder:
|
|
195
|
+
placeholder: T `All`,
|
|
194
196
|
value: lodash_1.default.map(this.props.value, (v) => lodash_1.default.find(options, (o) => o.value === v)),
|
|
195
197
|
isClearable: true,
|
|
196
198
|
isMulti: true,
|
|
@@ -41,6 +41,6 @@ declare class QuickfilterDesignComponent extends React.Component<QuickfilterDesi
|
|
|
41
41
|
handleLabelChange: (ev: any) => void;
|
|
42
42
|
handleMergedChange: (merged: any) => void;
|
|
43
43
|
handleMultiChange: (multi: any) => void;
|
|
44
|
-
render(): React.
|
|
44
|
+
render(): React.JSX.Element;
|
|
45
45
|
}
|
|
46
46
|
export {};
|