@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
|
@@ -41,7 +41,8 @@ class TextWidget extends Widget_1.default {
|
|
|
41
41
|
height: options.height,
|
|
42
42
|
singleRowTable: options.singleRowTable,
|
|
43
43
|
namedStrings: options.namedStrings,
|
|
44
|
-
ref: options.widgetRef
|
|
44
|
+
ref: options.widgetRef,
|
|
45
|
+
refreshKey: options.refreshKey
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
48
|
// Get the data that the widget needs. This will be called on the server, typically.
|
|
@@ -189,6 +190,9 @@ class TextWidget extends Widget_1.default {
|
|
|
189
190
|
}
|
|
190
191
|
// Get a list of table ids that can be filtered on
|
|
191
192
|
getFilterableTables(design, schema) {
|
|
193
|
+
if (!design) {
|
|
194
|
+
return [];
|
|
195
|
+
}
|
|
192
196
|
const exprItems = this.getExprItems(design.items);
|
|
193
197
|
let filterableTables = lodash_1.default.map(exprItems, (exprItem) => exprItem.expr?.table);
|
|
194
198
|
filterableTables = lodash_1.default.uniq(lodash_1.default.compact(filterableTables));
|
|
@@ -17,17 +17,29 @@ export interface TextWidgetComponentProps {
|
|
|
17
17
|
/** Table that is filtered to have one row */
|
|
18
18
|
singleRowTable?: string;
|
|
19
19
|
namedStrings?: any;
|
|
20
|
+
/** A key that changes when the widget should be refreshed */
|
|
21
|
+
refreshKey?: any;
|
|
20
22
|
}
|
|
21
23
|
export default class TextWidgetComponent extends AsyncLoadComponent<TextWidgetComponentProps, {
|
|
22
24
|
loading: boolean;
|
|
23
25
|
exprValues: any;
|
|
24
26
|
error: any;
|
|
25
27
|
cacheExpiry: any;
|
|
28
|
+
editModalOpen: boolean;
|
|
26
29
|
}> {
|
|
27
30
|
divComp: HTMLElement | null;
|
|
28
|
-
constructor(props:
|
|
31
|
+
constructor(props: TextWidgetComponentProps);
|
|
29
32
|
isLoadNeeded(newProps: any, oldProps: any): boolean;
|
|
30
|
-
load(props:
|
|
33
|
+
load(props: TextWidgetComponentProps, prevProps: TextWidgetComponentProps, callback: any): void;
|
|
31
34
|
scrollToTOCEntry(entryId: any): void;
|
|
32
|
-
|
|
35
|
+
handleEditClick: () => void;
|
|
36
|
+
handleEditModalClose: () => void;
|
|
37
|
+
handleBackgroundColorChange: (color: string | null) => void;
|
|
38
|
+
handleSpacingChange: (spacing: number | null) => void;
|
|
39
|
+
handleBorderColorChange: (color: string | null) => void;
|
|
40
|
+
handleBorderThicknessChange: (thickness: number | null) => void;
|
|
41
|
+
handleBorderRadiusChange: (radius: number | null) => void;
|
|
42
|
+
renderEditModal(): React.JSX.Element | null;
|
|
43
|
+
renderTextComponent(): React.JSX.Element;
|
|
44
|
+
render(): React.JSX.Element;
|
|
33
45
|
}
|
|
@@ -4,11 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
|
-
const R = react_1.default.createElement;
|
|
8
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
8
|
const TextComponent_1 = __importDefault(require("./TextComponent"));
|
|
10
9
|
const TextWidget_1 = __importDefault(require("./TextWidget"));
|
|
11
10
|
const AsyncLoadComponent_1 = __importDefault(require("@mwater/react-library/lib/AsyncLoadComponent"));
|
|
11
|
+
const DropdownWidgetComponent_1 = __importDefault(require("../DropdownWidgetComponent"));
|
|
12
|
+
const ActionCancelModalComponent_1 = __importDefault(require("@mwater/react-library/lib/ActionCancelModalComponent"));
|
|
13
|
+
const bootstrap_1 = require("@mwater/react-library/lib/bootstrap");
|
|
14
|
+
const ColorComponent_1 = __importDefault(require("../../ColorComponent"));
|
|
15
|
+
const bootstrap_2 = require("@mwater/react-library/lib/bootstrap");
|
|
12
16
|
// Widget which displays styled text with embedded expressions
|
|
13
17
|
class TextWidgetComponent extends AsyncLoadComponent_1.default {
|
|
14
18
|
divComp;
|
|
@@ -19,7 +23,8 @@ class TextWidgetComponent extends AsyncLoadComponent_1.default {
|
|
|
19
23
|
// Map of expression id to expression value
|
|
20
24
|
exprValues: {},
|
|
21
25
|
error: null,
|
|
22
|
-
cacheExpiry: props.dataSource.getCacheExpiry()
|
|
26
|
+
cacheExpiry: props.dataSource.getCacheExpiry(),
|
|
27
|
+
editModalOpen: false
|
|
23
28
|
};
|
|
24
29
|
}
|
|
25
30
|
// Override to determine if a load is needed. Not called on mounting
|
|
@@ -42,7 +47,8 @@ class TextWidgetComponent extends AsyncLoadComponent_1.default {
|
|
|
42
47
|
// Reload if filters or expressions have changed or cache expiry
|
|
43
48
|
return (!lodash_1.default.isEqual(newProps.filters, oldProps.filters) ||
|
|
44
49
|
!lodash_1.default.isEqual(getExprItems(newProps.design.items), getExprItems(oldProps.design.items)) ||
|
|
45
|
-
newProps.dataSource.getCacheExpiry() !== this.state.cacheExpiry
|
|
50
|
+
newProps.dataSource.getCacheExpiry() !== this.state.cacheExpiry ||
|
|
51
|
+
newProps.refreshKey !== oldProps.refreshKey);
|
|
46
52
|
}
|
|
47
53
|
// Call callback with state changes
|
|
48
54
|
load(props, prevProps, callback) {
|
|
@@ -65,24 +71,75 @@ class TextWidgetComponent extends AsyncLoadComponent_1.default {
|
|
|
65
71
|
return entry.scrollIntoView(true);
|
|
66
72
|
}
|
|
67
73
|
}
|
|
68
|
-
|
|
74
|
+
handleEditClick = () => {
|
|
75
|
+
this.setState({ editModalOpen: true });
|
|
76
|
+
};
|
|
77
|
+
handleEditModalClose = () => {
|
|
78
|
+
this.setState({ editModalOpen: false });
|
|
79
|
+
};
|
|
80
|
+
handleBackgroundColorChange = (color) => {
|
|
81
|
+
const newDesign = { ...this.props.design, backgroundColor: color };
|
|
82
|
+
this.props.onDesignChange(newDesign);
|
|
83
|
+
};
|
|
84
|
+
handleSpacingChange = (spacing) => {
|
|
85
|
+
const newDesign = { ...this.props.design, padding: spacing ?? undefined };
|
|
86
|
+
this.props.onDesignChange(newDesign);
|
|
87
|
+
};
|
|
88
|
+
handleBorderColorChange = (color) => {
|
|
89
|
+
const newDesign = { ...this.props.design, borderColor: color };
|
|
90
|
+
this.props.onDesignChange(newDesign);
|
|
91
|
+
};
|
|
92
|
+
handleBorderThicknessChange = (thickness) => {
|
|
93
|
+
const newDesign = { ...this.props.design, borderThickness: thickness };
|
|
94
|
+
this.props.onDesignChange(newDesign);
|
|
95
|
+
};
|
|
96
|
+
handleBorderRadiusChange = (radius) => {
|
|
97
|
+
const newDesign = { ...this.props.design, borderRadius: radius };
|
|
98
|
+
this.props.onDesignChange(newDesign);
|
|
99
|
+
};
|
|
100
|
+
renderEditModal() {
|
|
101
|
+
if (!this.state.editModalOpen) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const spacingOptions = [0, 5, 10, 15, 20, 25, 30, 35, 40].map(value => ({ value, label: `${value}px` }));
|
|
105
|
+
const borderThicknessOptions = [0, 1, 2, 3, 4, 5].map(value => ({ value, label: value === 0 ? "None" : `${value}px` }));
|
|
106
|
+
return (react_1.default.createElement(ActionCancelModalComponent_1.default, { title: "Edit Text Widget", onCancel: this.handleEditModalClose, onAction: this.handleEditModalClose },
|
|
107
|
+
react_1.default.createElement(bootstrap_1.FormGroup, { label: "Background Color" },
|
|
108
|
+
react_1.default.createElement(ColorComponent_1.default, { color: this.props.design.backgroundColor || null, onChange: this.handleBackgroundColorChange }),
|
|
109
|
+
react_1.default.createElement("div", { className: "text-muted" }, "Choose a background color for the text widget")),
|
|
110
|
+
react_1.default.createElement(bootstrap_1.FormGroup, { label: "Padding" },
|
|
111
|
+
react_1.default.createElement(bootstrap_2.Select, { value: this.props.design.padding ?? 0, onChange: this.handleSpacingChange, options: spacingOptions }),
|
|
112
|
+
react_1.default.createElement("div", { className: "text-muted" }, "Choose extra padding for the text widget")),
|
|
113
|
+
react_1.default.createElement(bootstrap_1.FormGroup, { label: "Border Thickness", help: "Choose the border thickness for the text widget" },
|
|
114
|
+
react_1.default.createElement(bootstrap_2.Select, { value: this.props.design.borderThickness ?? 0, onChange: this.handleBorderThicknessChange, options: borderThicknessOptions })),
|
|
115
|
+
this.props.design.borderThickness &&
|
|
116
|
+
react_1.default.createElement(bootstrap_1.FormGroup, { label: "Border Color", help: "Choose the border color for the text widget" },
|
|
117
|
+
react_1.default.createElement(ColorComponent_1.default, { color: this.props.design.borderColor || null, onChange: this.handleBorderColorChange })),
|
|
118
|
+
this.props.design.borderThickness &&
|
|
119
|
+
react_1.default.createElement(bootstrap_1.FormGroup, { label: "Border Radius", help: "Choose the border radius for the text widget" },
|
|
120
|
+
react_1.default.createElement(bootstrap_2.Select, { value: this.props.design.borderRadius ?? 0, onChange: this.handleBorderRadiusChange, options: spacingOptions }))));
|
|
121
|
+
}
|
|
122
|
+
renderTextComponent() {
|
|
69
123
|
// If loading, don't display old values
|
|
70
124
|
const exprValues = !this.state.loading ? this.state.exprValues : {};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
design
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
125
|
+
const padding = this.props.design.padding ?? 0;
|
|
126
|
+
return (react_1.default.createElement(TextComponent_1.default, { design: this.props.design, onDesignChange: this.props.onDesignChange, schema: this.props.schema, dataSource: this.props.dataSource, exprValues: exprValues, width: this.props.width ? this.props.width - padding * 2 : undefined, height: this.props.height ? this.props.height - padding * 2 : undefined, singleRowTable: this.props.singleRowTable, namedStrings: this.props.namedStrings }));
|
|
127
|
+
}
|
|
128
|
+
render() {
|
|
129
|
+
const borderStyle = this.props.design.borderThickness && this.props.design.borderColor
|
|
130
|
+
? `${this.props.design.borderThickness}px solid ${this.props.design.borderColor}`
|
|
131
|
+
: undefined;
|
|
132
|
+
return (react_1.default.createElement("div", { style: {
|
|
133
|
+
backgroundColor: this.props.design.backgroundColor ?? undefined,
|
|
134
|
+
padding: this.props.design.padding != null ? `${this.props.design.padding}px` : undefined,
|
|
135
|
+
border: borderStyle,
|
|
136
|
+
borderRadius: this.props.design.borderRadius != null ? `${this.props.design.borderRadius}px` : undefined
|
|
137
|
+
}, ref: comp => this.divComp = comp },
|
|
138
|
+
this.props.onDesignChange ? (react_1.default.createElement(DropdownWidgetComponent_1.default, { dropdownItems: [{
|
|
139
|
+
label: "Edit",
|
|
140
|
+
onClick: this.handleEditClick
|
|
141
|
+
}] }, this.renderTextComponent())) : (this.renderTextComponent()),
|
|
142
|
+
this.renderEditModal()));
|
|
86
143
|
}
|
|
87
144
|
}
|
|
88
145
|
exports.default = TextWidgetComponent;
|
|
@@ -1,6 +1,20 @@
|
|
|
1
|
+
import { HtmlItemExpr } from "../../richtext/ExprItemsHtmlConverter";
|
|
2
|
+
import { HtmlItem } from "../../richtext/ItemsHtmlConverter";
|
|
1
3
|
export interface TextWidgetDesign {
|
|
2
4
|
/** Text widget stores its content as array of items. See ItemsHtmlConverter TODO */
|
|
3
|
-
items:
|
|
5
|
+
items: (HtmlItem | HtmlItemExpr)[];
|
|
4
6
|
/** "title" for title block. default is "default" */
|
|
5
|
-
style?: "title" | "default";
|
|
7
|
+
style?: "title" | "default" | "header" | "footer";
|
|
8
|
+
/** Background color of the text widget (optional) */
|
|
9
|
+
backgroundColor?: string | null;
|
|
10
|
+
/** Extra padding for the text widget */
|
|
11
|
+
padding?: number;
|
|
12
|
+
/** Border color of the text widget (optional) */
|
|
13
|
+
borderColor?: string | null;
|
|
14
|
+
/** Border thickness of the text widget (optional) */
|
|
15
|
+
borderThickness?: number | null;
|
|
16
|
+
/** Border radius of the text widget (optional) */
|
|
17
|
+
borderRadius?: number | null;
|
|
6
18
|
}
|
|
19
|
+
/** Returns true if the text widget design is empty. */
|
|
20
|
+
export declare function isEmptyTextWidgetDesign(design: TextWidgetDesign | undefined): boolean;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEmptyTextWidgetDesign = void 0;
|
|
4
|
+
/** Returns true if the text widget design is empty. */
|
|
5
|
+
function isEmptyTextWidgetDesign(design) {
|
|
6
|
+
return design == null || design.items.length === 0;
|
|
7
|
+
}
|
|
8
|
+
exports.isEmptyTextWidgetDesign = isEmptyTextWidgetDesign;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mwater/visualization",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "Visualization library",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"async": "^1.2.1",
|
|
30
30
|
"async-latest": "^1.0.0",
|
|
31
31
|
"backbone": "~1.1.2",
|
|
32
|
-
"billboard.js": "^3.
|
|
32
|
+
"billboard.js": "^3.13.0",
|
|
33
33
|
"canonical-json": "0.0.4",
|
|
34
34
|
"classnames": "^2.3.1",
|
|
35
35
|
"color": "^3.2.1",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"maplibre-gl": "^3.3.1",
|
|
55
55
|
"markdown-it": "^12.0.4",
|
|
56
56
|
"moment": "^2.29.1",
|
|
57
|
+
"p-queue": "^8.0.1",
|
|
57
58
|
"pako": "^1.0.11",
|
|
58
59
|
"prop-types": "^15.7.2",
|
|
59
60
|
"querystring": "^0.2.0",
|
|
@@ -70,7 +71,7 @@
|
|
|
70
71
|
"react-linkify": "^0.2.2",
|
|
71
72
|
"react-motion": "^0.5.2",
|
|
72
73
|
"react-onclickout": "^2.0.4",
|
|
73
|
-
"react-select": "^5.
|
|
74
|
+
"react-select": "^5.8.0",
|
|
74
75
|
"save-svg-as-png": "^1.4.17",
|
|
75
76
|
"shallowequal": "^0.2.2",
|
|
76
77
|
"update-object": "^1.0.0",
|
|
@@ -94,7 +95,6 @@
|
|
|
94
95
|
"@types/react-color": "^2.17.6",
|
|
95
96
|
"@types/react-datepicker": "^1.8.0",
|
|
96
97
|
"@types/react-dropzone": "^5.1.0",
|
|
97
|
-
"@types/react-select": "^3.0.27",
|
|
98
98
|
"@types/uuid": "^3.4.10",
|
|
99
99
|
"build-library": "github:mWater/build-library",
|
|
100
100
|
"chai": "~2.0.0",
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import React, { CSSProperties, useContext } from "react"
|
|
2
|
+
import ReactDOM from "react-dom"
|
|
3
|
+
import ClickOutHandler from "react-onclickout"
|
|
4
|
+
import { ColorState, SketchPicker, SwatchesPicker } from "react-color"
|
|
5
|
+
import { CustomColorsContext } from "./CustomColorsContext"
|
|
6
|
+
|
|
7
|
+
export interface ColorComponentProps {
|
|
8
|
+
color: string | null | undefined
|
|
9
|
+
onChange: (value: string | null) => void
|
|
10
|
+
disableReset?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface ColorComponentState {
|
|
14
|
+
open: boolean
|
|
15
|
+
advanced: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Simple color well with popup
|
|
19
|
+
export default class ColorComponent extends React.Component<ColorComponentProps, ColorComponentState> {
|
|
20
|
+
constructor(props: ColorComponentProps) {
|
|
21
|
+
super(props)
|
|
22
|
+
this.state = { open: false, advanced: false }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
handleClick = () => {
|
|
26
|
+
return this.setState({ open: !this.state.open, advanced: false })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
handleColor = (color: ColorState) => {
|
|
30
|
+
return this.props.onChange(color.hex)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
handleReset = () => {
|
|
34
|
+
this.setState({ open: false })
|
|
35
|
+
return this.props.onChange(null)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
handleTransparent = () => {
|
|
39
|
+
this.setState({ open: false })
|
|
40
|
+
return this.props.onChange("transparent")
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
handleAdvanced = () => {
|
|
44
|
+
return this.setState({ advanced: !this.state.advanced })
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
renderPopup() {
|
|
48
|
+
if (!this.state.open || !this.colorWellRef) return null
|
|
49
|
+
|
|
50
|
+
const rect = this.colorWellRef.getBoundingClientRect()
|
|
51
|
+
|
|
52
|
+
const popupPosition: CSSProperties = {
|
|
53
|
+
position: "fixed",
|
|
54
|
+
top: `${rect.bottom + window.scrollY}px`,
|
|
55
|
+
left: `${rect.left + window.scrollX}px`,
|
|
56
|
+
zIndex: 1070,
|
|
57
|
+
backgroundColor: "white",
|
|
58
|
+
border: "solid 1px #DDD",
|
|
59
|
+
borderRadius: 3
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return ReactDOM.createPortal(
|
|
63
|
+
<ClickOutHandler onClickOut={() => this.setState({ open: false })}>
|
|
64
|
+
<div style={popupPosition}>
|
|
65
|
+
{!this.props.disableReset && (
|
|
66
|
+
<button type="button" className="btn btn-link btn-sm" onClick={this.handleReset}>
|
|
67
|
+
<i className="fa fa-undo" />
|
|
68
|
+
{" Reset Color"}
|
|
69
|
+
</button>
|
|
70
|
+
)}
|
|
71
|
+
<button type="button" className="btn btn-link btn-sm" onClick={this.handleAdvanced}>
|
|
72
|
+
{this.state.advanced ? "Basic" : "Advanced"}
|
|
73
|
+
</button>
|
|
74
|
+
|
|
75
|
+
<CustomColors
|
|
76
|
+
color={this.props.color}
|
|
77
|
+
onChange={this.props.onChange}
|
|
78
|
+
/>
|
|
79
|
+
{this.state.advanced ? (
|
|
80
|
+
<SketchPicker
|
|
81
|
+
color={this.props.color || undefined}
|
|
82
|
+
disableAlpha={true}
|
|
83
|
+
onChangeComplete={this.handleColor}
|
|
84
|
+
/>
|
|
85
|
+
) : (
|
|
86
|
+
<SwatchesPicker
|
|
87
|
+
color={this.props.color || undefined}
|
|
88
|
+
onChangeComplete={this.handleColor}
|
|
89
|
+
/>
|
|
90
|
+
)}
|
|
91
|
+
</div>
|
|
92
|
+
</ClickOutHandler>,
|
|
93
|
+
document.body
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
colorWellRef: HTMLDivElement | null = null
|
|
98
|
+
|
|
99
|
+
render() {
|
|
100
|
+
const style: CSSProperties = {
|
|
101
|
+
height: 20,
|
|
102
|
+
width: 20,
|
|
103
|
+
border: "solid 2px #888",
|
|
104
|
+
borderRadius: 4,
|
|
105
|
+
backgroundColor: this.props.color || undefined,
|
|
106
|
+
cursor: "pointer",
|
|
107
|
+
display: "inline-block"
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!this.props.color) {
|
|
111
|
+
// http://lea.verou.me/css3patterns/#diagonal-stripes
|
|
112
|
+
style.backgroundColor = "#AAA"
|
|
113
|
+
style.backgroundImage =
|
|
114
|
+
"repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(255,255,255,.7) 2px, rgba(255,255,255,.7) 4px)"
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<div style={{ position: "relative", display: "inline-block" }}>
|
|
119
|
+
<div
|
|
120
|
+
style={style}
|
|
121
|
+
onClick={this.handleClick}
|
|
122
|
+
ref={ref => this.colorWellRef = ref}
|
|
123
|
+
/>
|
|
124
|
+
{this.renderPopup()}
|
|
125
|
+
</div>
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Custom colors component for the color picker that allows the user to select from a set of custom colors
|
|
132
|
+
* that are defined in CSS variables.
|
|
133
|
+
* @param props
|
|
134
|
+
* @returns
|
|
135
|
+
*/
|
|
136
|
+
function CustomColors(props: {
|
|
137
|
+
color: string | null | undefined
|
|
138
|
+
onChange: (value: string | null) => void
|
|
139
|
+
}) {
|
|
140
|
+
const customColors = useContext(CustomColorsContext)
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(5, 42px)', gap: 8, margin: 5, marginLeft: 16 }}>
|
|
144
|
+
{customColors?.customColors.filter(color => color != null).map((color) => {
|
|
145
|
+
const isSelected = props.color === color
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<div
|
|
149
|
+
key={color}
|
|
150
|
+
title={color}
|
|
151
|
+
tabIndex={0}
|
|
152
|
+
onClick={() => props.onChange(color)}
|
|
153
|
+
style={{
|
|
154
|
+
background: color,
|
|
155
|
+
height: '24px',
|
|
156
|
+
width: '40px',
|
|
157
|
+
cursor: 'pointer',
|
|
158
|
+
position: 'relative',
|
|
159
|
+
outline: 'none',
|
|
160
|
+
marginBottom: '1px',
|
|
161
|
+
overflow: 'hidden',
|
|
162
|
+
boxShadow: isSelected ? `${color} 0 0 4px` : 'none'
|
|
163
|
+
}}
|
|
164
|
+
>
|
|
165
|
+
{isSelected && (
|
|
166
|
+
<div style={{ color: '#FFFFFF', marginLeft: '8px' }}>
|
|
167
|
+
<svg viewBox="0 0 24 24" style={{ fill: 'currentcolor', width: '24px', height: '24px' }}>
|
|
168
|
+
<path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path>
|
|
169
|
+
</svg>
|
|
170
|
+
</div>
|
|
171
|
+
)}
|
|
172
|
+
</div>
|
|
173
|
+
)
|
|
174
|
+
})}
|
|
175
|
+
</div>
|
|
176
|
+
)
|
|
177
|
+
}
|
|
@@ -27,12 +27,18 @@ function generateSequentialSet(set: any, number: any, reversed: any) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export default class ColorSchemeFactory {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Creates a color scheme
|
|
32
|
+
* @param options
|
|
33
|
+
* @param options.type - type of the color scheme
|
|
34
|
+
* @param options.number - number of colors to be generated
|
|
35
|
+
* @param options.reversed - true to reversed
|
|
36
|
+
*/
|
|
37
|
+
static createColorScheme(options: {
|
|
38
|
+
type: string
|
|
39
|
+
number: number
|
|
40
|
+
reversed: boolean
|
|
41
|
+
}): string[] {
|
|
36
42
|
switch (options.type) {
|
|
37
43
|
case "schemeAccent":
|
|
38
44
|
return generateCategoricalSet(brewer.schemeAccent, options.number, options.reversed)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import _ from "lodash"
|
|
2
|
-
import PropTypes from "prop-types"
|
|
3
2
|
import React from "react"
|
|
4
3
|
const R = React.createElement
|
|
5
|
-
import { FilterExprComponent } from "@mwater/expressions-ui"
|
|
4
|
+
import { FilterExprComponent, LocaleContext } from "@mwater/expressions-ui"
|
|
6
5
|
import { DataSource, Expr, ExprCleaner, Schema } from "@mwater/expressions"
|
|
7
6
|
import { ExprUtils } from "@mwater/expressions"
|
|
8
7
|
|
|
@@ -20,7 +19,7 @@ export interface FiltersDesignerComponentProps {
|
|
|
20
19
|
// Designer for filters of multiple tables. Used for maps and dashboards
|
|
21
20
|
// Filters are in format mwater-expression filter expression indexed by table. e.g. { sometable: logical expression, etc. }
|
|
22
21
|
export default class FiltersDesignerComponent extends React.Component<FiltersDesignerComponentProps> {
|
|
23
|
-
static
|
|
22
|
+
static contextType = LocaleContext
|
|
24
23
|
|
|
25
24
|
handleFilterChange = (table: any, expr: any) => {
|
|
26
25
|
// Clean filter
|
|
@@ -33,7 +32,7 @@ export default class FiltersDesignerComponent extends React.Component<FiltersDes
|
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
renderFilterableTable = (table: any) => {
|
|
36
|
-
const name = ExprUtils.localizeString(this.props.schema.getTable(table)!.name, this.context
|
|
35
|
+
const name = ExprUtils.localizeString(this.props.schema.getTable(table)!.name, this.context)
|
|
37
36
|
|
|
38
37
|
return R(
|
|
39
38
|
"div",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Expr, LiteralType } from "@mwater/expressions"
|
|
2
|
+
|
|
3
|
+
/** Global filters apply to multiple tables at once if a certain column is present. User-interface to set them
|
|
4
|
+
* is application-specific and the default (non-mWater) dashboard applies them but does not allow editing. */
|
|
5
|
+
export interface GlobalFilter {
|
|
6
|
+
/** id of column to filter */
|
|
7
|
+
columnId: string
|
|
8
|
+
|
|
9
|
+
/** type of column to filter (to ensure that consistent) */
|
|
10
|
+
columnType: LiteralType
|
|
11
|
+
|
|
12
|
+
/** op of expression for filtering */
|
|
13
|
+
op: string
|
|
14
|
+
|
|
15
|
+
/** array of expressions to use for filtering. field expression for column will be injected as expression 0 in the resulting filter expression */
|
|
16
|
+
exprs: Expr[]
|
|
17
|
+
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import React from "react"
|
|
2
|
-
import
|
|
2
|
+
import { LocaleContext } from "@mwater/expressions-ui/lib/contexts"
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
getChildContext() {
|
|
11
|
-
return { locale: this.props.locale }
|
|
12
|
-
}
|
|
4
|
+
export interface LocaleContextProps {
|
|
5
|
+
locale: string
|
|
6
|
+
children: React.ReactNode
|
|
7
|
+
}
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
/** Adds the locale to the context */
|
|
10
|
+
const LocaleContextInjector: React.FC<LocaleContextProps> = ({ locale, children }) => {
|
|
11
|
+
return (
|
|
12
|
+
<LocaleContext.Provider value={locale}>
|
|
13
|
+
{children}
|
|
14
|
+
</LocaleContext.Provider>
|
|
15
|
+
)
|
|
17
16
|
}
|
|
17
|
+
|
|
18
|
+
export default LocaleContextInjector
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import $ from "jquery"
|
|
2
|
-
import PropTypes from "prop-types"
|
|
3
2
|
import _ from "lodash"
|
|
4
3
|
import React from "react"
|
|
5
4
|
const R = React.createElement
|
|
@@ -11,6 +10,7 @@ import { ExprUtils, Schema } from "@mwater/expressions"
|
|
|
11
10
|
import * as ui from "./UIComponents"
|
|
12
11
|
import * as formUtils from "@mwater/forms/lib/formUtils" // TODO requireing this directly because of bizarre backbone issue
|
|
13
12
|
import { Form, FormDesign } from "@mwater/forms"
|
|
13
|
+
import { LocaleContext } from "@mwater/expressions-ui/lib/contexts"
|
|
14
14
|
|
|
15
15
|
export interface MWaterAddRelatedFormComponentProps {
|
|
16
16
|
/** Entities table id */
|
|
@@ -115,7 +115,7 @@ class AddRelatedFormModalComponent extends React.Component<
|
|
|
115
115
|
AddRelatedFormModalComponentProps,
|
|
116
116
|
AddRelatedFormModalComponentState
|
|
117
117
|
> {
|
|
118
|
-
static
|
|
118
|
+
static contextType = LocaleContext
|
|
119
119
|
|
|
120
120
|
constructor(props: any) {
|
|
121
121
|
super(props)
|
|
@@ -149,7 +149,7 @@ class AddRelatedFormModalComponent extends React.Component<
|
|
|
149
149
|
|
|
150
150
|
// Get _id, name, and description
|
|
151
151
|
const items = _.map(forms, (form) => ({
|
|
152
|
-
name: ExprUtils.localizeString(form.design.name, this.context
|
|
152
|
+
name: ExprUtils.localizeString(form.design.name, this.context),
|
|
153
153
|
desc: `Modified ${moment(form.modified!.on, moment.ISO_8601).format("ll")}`,
|
|
154
154
|
onClick: this.props.onSelect.bind(null, "responses:" + form._id)
|
|
155
155
|
}))
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import $ from "jquery"
|
|
2
|
-
import PropTypes from "prop-types"
|
|
3
2
|
import _ from "lodash"
|
|
4
3
|
import React from "react"
|
|
5
4
|
const R = React.createElement
|
|
6
5
|
|
|
7
6
|
import querystring from "querystring"
|
|
8
7
|
import { ExprUtils, Schema } from "@mwater/expressions"
|
|
8
|
+
import { LocaleContext } from "@mwater/expressions-ui/lib/contexts"
|
|
9
9
|
|
|
10
10
|
export interface MWaterAddRelatedIndicatorComponentProps {
|
|
11
11
|
table: string
|
|
@@ -30,7 +30,7 @@ export default class MWaterAddRelatedIndicatorComponent extends React.Component<
|
|
|
30
30
|
MWaterAddRelatedIndicatorComponentProps,
|
|
31
31
|
MWaterAddRelatedIndicatorComponentState
|
|
32
32
|
> {
|
|
33
|
-
static
|
|
33
|
+
static contextType = LocaleContext
|
|
34
34
|
|
|
35
35
|
constructor(props: any) {
|
|
36
36
|
super(props)
|
|
@@ -69,7 +69,7 @@ export default class MWaterAddRelatedIndicatorComponent extends React.Component<
|
|
|
69
69
|
indicators,
|
|
70
70
|
[
|
|
71
71
|
(indicator) => (indicator.design.recommended ? 0 : 1),
|
|
72
|
-
(indicator) => ExprUtils.localizeString(indicator.design.name, this.context
|
|
72
|
+
(indicator) => ExprUtils.localizeString(indicator.design.name, this.context)
|
|
73
73
|
],
|
|
74
74
|
["asc", "asc"]
|
|
75
75
|
)
|
|
@@ -112,7 +112,7 @@ export default class MWaterAddRelatedIndicatorComponent extends React.Component<
|
|
|
112
112
|
// Filter by search
|
|
113
113
|
if (this.props.filter) {
|
|
114
114
|
indicators = _.filter(indicators, (indicator) =>
|
|
115
|
-
filterMatches(this.props.filter, ExprUtils.localizeString(indicator.design.name, this.context
|
|
115
|
+
filterMatches(this.props.filter, ExprUtils.localizeString(indicator.design.name, this.context))
|
|
116
116
|
)
|
|
117
117
|
}
|
|
118
118
|
|
|
@@ -134,8 +134,8 @@ export default class MWaterAddRelatedIndicatorComponent extends React.Component<
|
|
|
134
134
|
"div",
|
|
135
135
|
{ style: { paddingLeft: 10 } },
|
|
136
136
|
_.map(indicators, (indicator) => {
|
|
137
|
-
const name = ExprUtils.localizeString(indicator.design.name, this.context
|
|
138
|
-
const desc = ExprUtils.localizeString(indicator.design.desc, this.context
|
|
137
|
+
const name = ExprUtils.localizeString(indicator.design.name, this.context)
|
|
138
|
+
const desc = ExprUtils.localizeString(indicator.design.desc, this.context)
|
|
139
139
|
|
|
140
140
|
// If added, put special message
|
|
141
141
|
if (this.props.schema.getTable(`indicator_values:${indicator._id}`)) {
|