@mwater/visualization 5.4.5 → 5.6.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/MWaterContextComponent.d.ts +1 -1
- package/lib/MWaterContextComponent.js +1 -1
- package/lib/MWaterGlobalFiltersComponent.d.ts +2 -2
- package/lib/MWaterGlobalFiltersComponent.js +11 -20
- package/lib/MWaterLoaderComponent.d.ts +5 -14
- package/lib/MWaterLoaderComponent.js +2 -11
- package/lib/UndoStack.d.ts +2 -1
- package/lib/UndoStack.js +12 -6
- package/lib/dashboards/DashboardComponent.js +7 -5
- package/lib/dashboards/DashboardDesign.d.ts +1 -1
- package/lib/dashboards/LayoutOptionsComponent.js +18 -11
- package/lib/dashboards/ServerDashboardDataSource.d.ts +10 -1
- package/lib/dashboards/ServerDashboardDataSource.js +29 -10
- package/lib/dashboards/SettingsModalComponent.js +1 -1
- package/lib/dashboards/layoutOptions.d.ts +5 -1
- package/lib/datagrids/DatagridComponent.js +23 -3
- package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -3
- package/lib/datagrids/DatagridDesignerComponent.js +108 -120
- package/lib/datagrids/DatagridViewComponent.js +3 -2
- package/lib/datagrids/ExprCellComponent.d.ts +1 -0
- package/lib/datagrids/ExprCellComponent.js +22 -20
- package/lib/datagrids/OrderBysDesignerComponent.d.ts +7 -7
- package/lib/datagrids/OrderBysDesignerComponent.js +19 -28
- package/lib/index.css +45 -2
- package/lib/index.d.ts +5 -5
- package/lib/index.js +2 -3
- package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +8 -1
- package/lib/layouts/blocks/BlocksDisplayComponent.js +46 -4
- package/lib/maps/BufferLayer.d.ts +18 -0
- package/lib/maps/BufferLayer.js +36 -14
- package/lib/maps/BufferLayerDesign.d.ts +1 -1
- package/lib/maps/BufferLayerDesignerComponent.js +2 -2
- package/lib/maps/ChoroplethLayer.d.ts +18 -0
- package/lib/maps/ChoroplethLayer.js +46 -25
- package/lib/maps/ChoroplethLayerDesign.d.ts +7 -3
- package/lib/maps/ChoroplethLayerDesigner.d.ts +10 -22
- package/lib/maps/ChoroplethLayerDesigner.js +58 -89
- package/lib/maps/DirectMapDataSource.js +17 -10
- package/lib/maps/EditHoverOver.d.ts +4 -3
- package/lib/maps/EditHoverOver.js +64 -35
- package/lib/maps/HoverContent.d.ts +10 -5
- package/lib/maps/HoverContent.js +7 -36
- package/lib/maps/Layer.d.ts +37 -0
- package/lib/maps/Layer.js +30 -4
- package/lib/maps/LeafletMapComponent.js +10 -19
- package/lib/maps/MWaterServerLayer.d.ts +2 -2
- package/lib/maps/MWaterServerLayer.js +6 -6
- package/lib/maps/MapComponent.js +0 -1
- package/lib/maps/MapLayerDataSource.d.ts +9 -0
- package/lib/maps/MapUtils.d.ts +19 -1
- package/lib/maps/MapUtils.js +80 -1
- package/lib/maps/MarkersLayer.d.ts +18 -0
- package/lib/maps/MarkersLayer.js +42 -26
- package/lib/maps/MarkersLayerDesign.d.ts +1 -1
- package/lib/maps/MarkersLayerDesignerComponent.d.ts +12 -28
- package/lib/maps/MarkersLayerDesignerComponent.js +81 -111
- package/lib/maps/RasterMapViewComponent.js +1 -1
- package/lib/maps/ServerMapDataSource.d.ts +9 -0
- package/lib/maps/ServerMapDataSource.js +29 -10
- package/lib/maps/VectorMapViewComponent.js +7 -15
- package/lib/maps/maps.d.ts +4 -2
- package/lib/maps/symbols/font-awesome/asterisk.png +0 -0
- package/lib/maps/symbols/font-awesome/ban.png +0 -0
- package/lib/maps/symbols/font-awesome/beer.png +0 -0
- package/lib/maps/symbols/font-awesome/bell.png +0 -0
- package/lib/maps/symbols/font-awesome/bolt.png +0 -0
- package/lib/maps/symbols/font-awesome/building.png +0 -0
- package/lib/maps/symbols/font-awesome/bullseye.png +0 -0
- package/lib/maps/symbols/font-awesome/bus.png +0 -0
- package/lib/maps/symbols/font-awesome/caret-up.png +0 -0
- package/lib/maps/symbols/font-awesome/certificate.png +0 -0
- package/lib/maps/symbols/font-awesome/check-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/check.png +0 -0
- package/lib/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
- package/lib/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
- package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/lib/maps/symbols/font-awesome/cloud.png +0 -0
- package/lib/maps/symbols/font-awesome/comment.png +0 -0
- package/lib/maps/symbols/font-awesome/crosshairs.png +0 -0
- package/lib/maps/symbols/font-awesome/dot-circle-o.png +0 -0
- package/lib/maps/symbols/font-awesome/exclamation-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
- package/lib/maps/symbols/font-awesome/female.png +0 -0
- package/lib/maps/symbols/font-awesome/file.png +0 -0
- package/lib/maps/symbols/font-awesome/flag.png +0 -0
- package/lib/maps/symbols/font-awesome/flask.png +0 -0
- package/lib/maps/symbols/font-awesome/h-square.png +0 -0
- package/lib/maps/symbols/font-awesome/home.png +0 -0
- package/lib/maps/symbols/font-awesome/info-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/male.png +0 -0
- package/lib/maps/symbols/font-awesome/medkit.png +0 -0
- package/lib/maps/symbols/font-awesome/mobile.png +0 -0
- package/lib/maps/symbols/font-awesome/plus-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/plus-square.png +0 -0
- package/lib/maps/symbols/font-awesome/plus.png +0 -0
- package/lib/maps/symbols/font-awesome/square.png +0 -0
- package/lib/maps/symbols/font-awesome/star.png +0 -0
- package/lib/maps/symbols/font-awesome/thumbs-down.png +0 -0
- package/lib/maps/symbols/font-awesome/thumbs-up.png +0 -0
- package/lib/maps/symbols/font-awesome/ticket.png +0 -0
- package/lib/maps/symbols/font-awesome/times-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/times.png +0 -0
- package/lib/maps/symbols/font-awesome/tint.png +0 -0
- package/lib/maps/symbols/font-awesome/tree.png +0 -0
- package/lib/maps/symbols/font-awesome/university.png +0 -0
- package/lib/maps/symbols/font-awesome/usd.png +0 -0
- package/lib/maps/symbols/font-awesome/user.png +0 -0
- package/lib/maps/symbols/font-awesome/users.png +0 -0
- package/lib/maps/symbols/font-awesome/wheelchair.png +0 -0
- package/lib/maps/symbols/sdf-ize.sh +93 -0
- package/lib/maps/vectorMaps.d.ts +1 -0
- package/lib/maps/vectorMaps.js +20 -36
- package/lib/mwater_table_selection/FormsListComponent.d.ts +33 -0
- package/lib/mwater_table_selection/FormsListComponent.js +141 -0
- package/lib/mwater_table_selection/IndicatorsListComponent.d.ts +49 -0
- package/lib/mwater_table_selection/IndicatorsListComponent.js +251 -0
- package/lib/mwater_table_selection/IssuesListComponent.d.ts +29 -0
- package/lib/mwater_table_selection/IssuesListComponent.js +123 -0
- package/lib/mwater_table_selection/MWaterAccountingSystemListComponent.d.ts +20 -0
- package/lib/mwater_table_selection/MWaterAccountingSystemListComponent.js +157 -0
- package/lib/mwater_table_selection/MWaterAssetSystemsListComponent.d.ts +17 -0
- package/lib/mwater_table_selection/MWaterAssetSystemsListComponent.js +79 -0
- package/lib/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.d.ts +18 -0
- package/lib/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.js +80 -0
- package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.d.ts +63 -0
- package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.js +461 -0
- package/lib/mwater_table_selection/MWaterCustomTablesetListComponent.d.ts +17 -0
- package/lib/mwater_table_selection/MWaterCustomTablesetListComponent.js +94 -0
- package/lib/mwater_table_selection/MWaterMetricsTableListComponent.d.ts +17 -0
- package/lib/mwater_table_selection/MWaterMetricsTableListComponent.js +80 -0
- package/lib/mwater_table_selection/MWaterTableSelectComponent.d.ts +32 -0
- package/lib/mwater_table_selection/MWaterTableSelectComponent.js +163 -0
- package/lib/mwater_table_selection/MWaterWorkflowsSelectComponent.d.ts +19 -0
- package/lib/mwater_table_selection/MWaterWorkflowsSelectComponent.js +111 -0
- package/lib/quickfilter/QuickfiltersComponent.d.ts +3 -102
- package/lib/quickfilter/QuickfiltersComponent.js +53 -110
- package/lib/quickfilter/TextLiteralComponent.d.ts +23 -47
- package/lib/quickfilter/TextLiteralComponent.js +85 -82
- package/lib/widgets/MapWidget.js +4 -2
- package/lib/widgets/charts/Chart.d.ts +11 -0
- package/lib/widgets/charts/Chart.js +15 -0
- package/lib/widgets/charts/ChartWidgetComponent.d.ts +1 -0
- package/lib/widgets/charts/ChartWidgetComponent.js +27 -1
- package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +1 -1
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +1 -1
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +5 -12
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +43 -57
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +113 -110
- package/lib/widgets/charts/layered/LayeredChartUtils.d.ts +2 -1
- package/lib/widgets/charts/layered/LayeredChartUtils.js +0 -2
- package/lib/widgets/charts/pivot/PivotChart.d.ts +2 -0
- package/lib/widgets/charts/pivot/PivotChart.js +156 -0
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +5 -20
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +31 -61
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +4 -0
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +4 -2
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.d.ts +5 -44
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +38 -63
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +7 -68
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.js +58 -106
- package/lib/widgets/charts/table/TableChart.d.ts +2 -0
- package/lib/widgets/charts/table/TableChart.js +172 -1
- package/lib/widgets/charts/table/TableChartDesignerComponent.d.ts +7 -17
- package/lib/widgets/charts/table/TableChartDesignerComponent.js +79 -95
- package/lib/widgets/charts/table/TableChartViewComponent.d.ts +1 -7
- package/lib/widgets/charts/table/TableChartViewComponent.js +19 -27
- package/lib/widgets/text/ExprItemEditorComponent.d.ts +3 -8
- package/lib/widgets/text/ExprItemEditorComponent.js +36 -33
- package/lib/widgets/text/ExprUpdateModalComponent.d.ts +1 -0
- package/package.json +4 -10
- package/src/MWaterContextComponent.tsx +2 -2
- package/src/{MWaterGlobalFiltersComponent.ts → MWaterGlobalFiltersComponent.tsx} +32 -33
- package/src/{MWaterLoaderComponent.ts → MWaterLoaderComponent.tsx} +18 -19
- package/src/UndoStack.ts +14 -6
- package/src/dashboards/DashboardComponent.tsx +7 -5
- package/src/dashboards/DashboardDesign.ts +1 -1
- package/src/dashboards/LayoutOptionsComponent.tsx +22 -10
- package/src/dashboards/ServerDashboardDataSource.ts +36 -13
- package/src/dashboards/SettingsModalComponent.tsx +1 -1
- package/src/dashboards/layoutOptions.tsx +5 -1
- package/src/datagrids/DatagridComponent.tsx +31 -3
- package/src/datagrids/DatagridDesignerComponent.tsx +241 -229
- package/src/datagrids/DatagridViewComponent.tsx +3 -2
- package/src/datagrids/ExprCellComponent.tsx +23 -20
- package/src/datagrids/OrderBysDesignerComponent.tsx +61 -70
- package/src/index.css +45 -2
- package/src/index.ts +5 -11
- package/src/layouts/blocks/BlocksDisplayComponent.tsx +60 -5
- package/src/maps/BufferLayer.ts +48 -20
- package/src/maps/BufferLayerDesign.ts +1 -1
- package/src/maps/BufferLayerDesignerComponent.tsx +2 -1
- package/src/maps/ChoroplethLayer.ts +70 -39
- package/src/maps/ChoroplethLayerDesign.ts +6 -2
- package/src/maps/ChoroplethLayerDesigner.tsx +171 -167
- package/src/maps/DirectMapDataSource.ts +21 -13
- package/src/maps/EditHoverOver.tsx +98 -54
- package/src/maps/HoverContent.tsx +17 -48
- package/src/maps/Layer.ts +42 -4
- package/src/maps/LeafletMapComponent.tsx +10 -19
- package/src/maps/MWaterServerLayer.ts +6 -6
- package/src/maps/MapComponent.ts +0 -1
- package/src/maps/MapLayerDataSource.ts +8 -0
- package/src/maps/MapUtils.ts +82 -3
- package/src/maps/MarkersLayer.ts +54 -27
- package/src/maps/MarkersLayerDesign.ts +1 -1
- package/src/maps/MarkersLayerDesignerComponent.tsx +360 -0
- package/src/maps/RasterMapViewComponent.ts +1 -1
- package/src/maps/ServerMapDataSource.ts +35 -12
- package/src/maps/VectorMapViewComponent.tsx +8 -19
- package/src/maps/maps.ts +4 -2
- package/src/maps/symbols/font-awesome/asterisk.png +0 -0
- package/src/maps/symbols/font-awesome/ban.png +0 -0
- package/src/maps/symbols/font-awesome/beer.png +0 -0
- package/src/maps/symbols/font-awesome/bell.png +0 -0
- package/src/maps/symbols/font-awesome/bolt.png +0 -0
- package/src/maps/symbols/font-awesome/building.png +0 -0
- package/src/maps/symbols/font-awesome/bullseye.png +0 -0
- package/src/maps/symbols/font-awesome/bus.png +0 -0
- package/src/maps/symbols/font-awesome/caret-up.png +0 -0
- package/src/maps/symbols/font-awesome/certificate.png +0 -0
- package/src/maps/symbols/font-awesome/check-circle.png +0 -0
- package/src/maps/symbols/font-awesome/check.png +0 -0
- package/src/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
- package/src/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
- package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/src/maps/symbols/font-awesome/cloud.png +0 -0
- package/src/maps/symbols/font-awesome/comment.png +0 -0
- package/src/maps/symbols/font-awesome/crosshairs.png +0 -0
- package/src/maps/symbols/font-awesome/dot-circle-o.png +0 -0
- package/src/maps/symbols/font-awesome/exclamation-circle.png +0 -0
- package/src/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
- package/src/maps/symbols/font-awesome/female.png +0 -0
- package/src/maps/symbols/font-awesome/file.png +0 -0
- package/src/maps/symbols/font-awesome/flag.png +0 -0
- package/src/maps/symbols/font-awesome/flask.png +0 -0
- package/src/maps/symbols/font-awesome/h-square.png +0 -0
- package/src/maps/symbols/font-awesome/home.png +0 -0
- package/src/maps/symbols/font-awesome/info-circle.png +0 -0
- package/src/maps/symbols/font-awesome/male.png +0 -0
- package/src/maps/symbols/font-awesome/medkit.png +0 -0
- package/src/maps/symbols/font-awesome/mobile.png +0 -0
- package/src/maps/symbols/font-awesome/plus-circle.png +0 -0
- package/src/maps/symbols/font-awesome/plus-square.png +0 -0
- package/src/maps/symbols/font-awesome/plus.png +0 -0
- package/src/maps/symbols/font-awesome/square.png +0 -0
- package/src/maps/symbols/font-awesome/star.png +0 -0
- package/src/maps/symbols/font-awesome/thumbs-down.png +0 -0
- package/src/maps/symbols/font-awesome/thumbs-up.png +0 -0
- package/src/maps/symbols/font-awesome/ticket.png +0 -0
- package/src/maps/symbols/font-awesome/times-circle.png +0 -0
- package/src/maps/symbols/font-awesome/times.png +0 -0
- package/src/maps/symbols/font-awesome/tint.png +0 -0
- package/src/maps/symbols/font-awesome/tree.png +0 -0
- package/src/maps/symbols/font-awesome/university.png +0 -0
- package/src/maps/symbols/font-awesome/usd.png +0 -0
- package/src/maps/symbols/font-awesome/user.png +0 -0
- package/src/maps/symbols/font-awesome/users.png +0 -0
- package/src/maps/symbols/font-awesome/wheelchair.png +0 -0
- package/src/maps/symbols/sdf-ize.sh +93 -0
- package/src/maps/vectorMaps.tsx +20 -44
- package/src/mwater_table_selection/FormsListComponent.tsx +188 -0
- package/src/mwater_table_selection/IndicatorsListComponent.tsx +411 -0
- package/src/mwater_table_selection/IssuesListComponent.tsx +167 -0
- package/src/mwater_table_selection/MWaterAccountingSystemListComponent.tsx +225 -0
- package/src/{MWaterAssetSystemsListComponent.tsx → mwater_table_selection/MWaterAssetSystemsListComponent.tsx} +2 -2
- package/src/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.tsx +111 -0
- package/src/mwater_table_selection/MWaterCompleteTableSelectComponent.tsx +713 -0
- package/src/{MWaterCustomTablesetListComponent.tsx → mwater_table_selection/MWaterCustomTablesetListComponent.tsx} +1 -1
- package/src/{MWaterMetricsTableListComponent.tsx → mwater_table_selection/MWaterMetricsTableListComponent.tsx} +1 -1
- package/src/{MWaterTableSelectComponent.tsx → mwater_table_selection/MWaterTableSelectComponent.tsx} +91 -90
- package/src/mwater_table_selection/MWaterWorkflowsSelectComponent.tsx +159 -0
- package/src/quickfilter/{QuickfiltersComponent.ts → QuickfiltersComponent.tsx} +165 -158
- package/src/quickfilter/TextLiteralComponent.tsx +197 -0
- package/src/widgets/MapWidget.tsx +9 -1
- package/src/widgets/charts/Chart.ts +17 -0
- package/src/widgets/charts/ChartWidgetComponent.tsx +36 -1
- package/src/widgets/charts/layered/LayeredChartDesign.ts +1 -1
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +23 -24
- package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +260 -211
- package/src/widgets/charts/layered/LayeredChartUtils.ts +7 -7
- package/src/widgets/charts/pivot/PivotChart.ts +191 -0
- package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +124 -129
- package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +4 -2
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +120 -149
- package/src/widgets/charts/pivot/SegmentDesignerComponent.tsx +178 -198
- package/src/widgets/charts/table/TableChart.ts +177 -1
- package/src/widgets/charts/table/TableChartDesignerComponent.tsx +422 -0
- package/src/widgets/charts/table/{TableChartViewComponent.ts → TableChartViewComponent.tsx} +65 -60
- package/src/widgets/text/ExprItemEditorComponent.tsx +83 -77
- package/src/widgets/text/ExprUpdateModalComponent.tsx +1 -0
- package/test/UndoStackTests.ts +52 -1
- package/.storybook/config.js +0 -7
- package/.storybook/head.html +0 -4
- package/.storybook/webpack.config.js +0 -15
- package/src/MWaterCompleteTableSelectComponent.tsx +0 -975
- package/src/maps/BingLayer.ts +0 -146
- package/src/maps/MarkersLayerDesignerComponent.ts +0 -374
- package/src/quickfilter/TextLiteralComponent.ts +0 -165
- package/src/widgets/charts/table/TableChartDesignerComponent.ts +0 -441
- package/stories/UpdateableComponent.js +0 -29
- package/stories/consoles.js +0 -202
- package/stories/dashboards.js +0 -217
- package/stories/datagridDesign.js +0 -114
- package/stories/datagrids.js +0 -69
- package/stories/dates.js +0 -80
- package/stories/exprcomponent.js +0 -43
- package/stories/index.js +0 -18
- package/stories/leaflet.js +0 -59
- package/stories/maps.js +0 -24
- package/stories/pivotChart.js +0 -235
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.IndicatorsListComponent = void 0;
|
|
30
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
31
|
+
const jquery_1 = __importDefault(require("jquery"));
|
|
32
|
+
const react_1 = __importDefault(require("react"));
|
|
33
|
+
const querystring_1 = __importDefault(require("querystring"));
|
|
34
|
+
const uiComponents = __importStar(require("../UIComponents"));
|
|
35
|
+
const expressions_1 = require("@mwater/expressions");
|
|
36
|
+
const ModalPopupComponent_1 = __importDefault(require("@mwater/react-library/lib/ModalPopupComponent"));
|
|
37
|
+
// Searchable list of indicators
|
|
38
|
+
class IndicatorsListComponent extends react_1.default.Component {
|
|
39
|
+
addIndicatorConfirmPopup;
|
|
40
|
+
constructor(props) {
|
|
41
|
+
super(props);
|
|
42
|
+
this.state = {
|
|
43
|
+
indicators: null,
|
|
44
|
+
search: ""
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
componentDidMount() {
|
|
48
|
+
// Get names and basic of forms
|
|
49
|
+
const query = {};
|
|
50
|
+
query.fields = JSON.stringify({ "design.name": 1, "design.desc": 1, "design.recommended": 1, deprecated: 1, "design.category": 1, "design.subcategory": 1, "design.code": 1, "design.organization": 1 });
|
|
51
|
+
query.client = this.props.client;
|
|
52
|
+
// Get list of all indicator names
|
|
53
|
+
return jquery_1.default.getJSON(this.props.apiUrl + "indicators?" + querystring_1.default.stringify(query), (indicators) => {
|
|
54
|
+
// Remove deprecated
|
|
55
|
+
indicators = lodash_1.default.filter(indicators, (indicator) => !indicator.deprecated);
|
|
56
|
+
// Sort by name
|
|
57
|
+
indicators = lodash_1.default.sortByOrder(indicators, [
|
|
58
|
+
(indicator) => ((this.props.extraTables || []).includes("indicator_values:" + indicator._id) ? 0 : 1),
|
|
59
|
+
(indicator) => (indicator.design.recommended ? 0 : 1),
|
|
60
|
+
(indicator) => expressions_1.ExprUtils.localizeString(indicator.design.name, T.locale)
|
|
61
|
+
], ["asc", "asc", "asc"]);
|
|
62
|
+
return this.setState({
|
|
63
|
+
indicators: indicators
|
|
64
|
+
});
|
|
65
|
+
}).fail((xhr) => {
|
|
66
|
+
return this.setState({ error: xhr.responseText });
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
handleTableRemove = (table) => {
|
|
70
|
+
if (confirm(T `Remove ${expressions_1.ExprUtils.localizeString(table.name, T.locale)}? Any widgets that depend on it will no longer work properly.`)) {
|
|
71
|
+
return this.props.onExtraTableRemove(table.id);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
searchRef = (comp) => {
|
|
75
|
+
// Focus
|
|
76
|
+
if (comp) {
|
|
77
|
+
return comp.focus();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
handleSelect = (tableId) => {
|
|
81
|
+
// Add table if not present
|
|
82
|
+
if (!this.props.schema.getTable(tableId)) {
|
|
83
|
+
this.props.onExtraTableAdd(tableId);
|
|
84
|
+
}
|
|
85
|
+
this.addIndicatorConfirmPopup.show(tableId);
|
|
86
|
+
};
|
|
87
|
+
handleOpenIndicator = (id) => {
|
|
88
|
+
this.handleSelect("indicator_values:" + id);
|
|
89
|
+
};
|
|
90
|
+
// Render a simplified version of IndicatorListComponent from mwater-portal
|
|
91
|
+
renderIndicatorList(indicators, searchText) {
|
|
92
|
+
// Filter indicators based on search text
|
|
93
|
+
let filteredIndicators = indicators;
|
|
94
|
+
if (searchText) {
|
|
95
|
+
const searchTerms = searchText.toLowerCase().split(" ");
|
|
96
|
+
filteredIndicators = indicators.filter(indicator => {
|
|
97
|
+
const searchFields = [
|
|
98
|
+
expressions_1.ExprUtils.localizeString(indicator.design.name, T.locale),
|
|
99
|
+
indicator.design.code,
|
|
100
|
+
indicator.design.organization,
|
|
101
|
+
indicator.design.category,
|
|
102
|
+
indicator.design.subcategory
|
|
103
|
+
];
|
|
104
|
+
return searchTerms.every(term => searchFields.some(field => field && field.toLowerCase().includes(term)));
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
// Split into recommended and all indicators
|
|
108
|
+
const recommendedIndicators = filteredIndicators.filter(indicator => indicator.design.recommended);
|
|
109
|
+
const otherIndicators = filteredIndicators.filter(indicator => !indicator.design.recommended);
|
|
110
|
+
// Group by category
|
|
111
|
+
const groupByCategory = (indicators) => {
|
|
112
|
+
const categories = {};
|
|
113
|
+
indicators.forEach(indicator => {
|
|
114
|
+
const category = indicator.design.category || T `Uncategorized`;
|
|
115
|
+
if (!categories[category]) {
|
|
116
|
+
categories[category] = [];
|
|
117
|
+
}
|
|
118
|
+
categories[category].push(indicator);
|
|
119
|
+
});
|
|
120
|
+
return categories;
|
|
121
|
+
};
|
|
122
|
+
const recommendedByCategory = groupByCategory(recommendedIndicators);
|
|
123
|
+
const otherByCategory = groupByCategory(otherIndicators);
|
|
124
|
+
return (react_1.default.createElement("div", null,
|
|
125
|
+
recommendedIndicators.length > 0 && (react_1.default.createElement("div", null,
|
|
126
|
+
react_1.default.createElement("h4", null, T `Recommended Indicators`),
|
|
127
|
+
lodash_1.default.map(recommendedByCategory, (categoryIndicators, category) => (react_1.default.createElement("div", { key: category },
|
|
128
|
+
react_1.default.createElement("h5", null, category),
|
|
129
|
+
react_1.default.createElement("table", { className: "table table-hover" },
|
|
130
|
+
react_1.default.createElement("tbody", null, lodash_1.default.map(categoryIndicators, indicator => (react_1.default.createElement("tr", { key: indicator._id, onClick: () => this.handleOpenIndicator(indicator._id) },
|
|
131
|
+
react_1.default.createElement("td", null,
|
|
132
|
+
react_1.default.createElement(IndicatorListItemComponent, { indicator: indicator, onClick: () => this.handleOpenIndicator(indicator._id) })))))))))))),
|
|
133
|
+
react_1.default.createElement("h4", null, T `All Indicators`),
|
|
134
|
+
lodash_1.default.map(otherByCategory, (categoryIndicators, category) => (react_1.default.createElement("div", { key: category },
|
|
135
|
+
react_1.default.createElement("h5", null, category),
|
|
136
|
+
react_1.default.createElement("table", { className: "table table-hover" },
|
|
137
|
+
react_1.default.createElement("tbody", null, lodash_1.default.map(categoryIndicators, indicator => (react_1.default.createElement("tr", { key: indicator._id, onClick: () => this.handleOpenIndicator(indicator._id) },
|
|
138
|
+
react_1.default.createElement("td", null,
|
|
139
|
+
react_1.default.createElement(IndicatorListItemComponent, { indicator: indicator, onClick: () => this.handleOpenIndicator(indicator._id) }))))))))))));
|
|
140
|
+
}
|
|
141
|
+
render() {
|
|
142
|
+
if (this.state.error) {
|
|
143
|
+
return react_1.default.createElement("div", { className: "alert alert-danger" }, this.state.error);
|
|
144
|
+
}
|
|
145
|
+
let tables = lodash_1.default.filter(this.props.schema.getTables(), (table) => table.id.match(/^indicator_values:/) && !table.deprecated);
|
|
146
|
+
tables = lodash_1.default.sortBy(tables, (t) => t.name.en);
|
|
147
|
+
return (react_1.default.createElement("div", null,
|
|
148
|
+
react_1.default.createElement(AddIndicatorConfirmPopupComponent, { schema: this.props.schema, onChange: this.props.onChange, onExtraTableAdd: this.props.onExtraTableAdd, ref: (c) => {
|
|
149
|
+
this.addIndicatorConfirmPopup = c;
|
|
150
|
+
} }),
|
|
151
|
+
react_1.default.createElement("label", null, T `Included Indicators:`),
|
|
152
|
+
tables.length > 0 ? (react_1.default.createElement(uiComponents.OptionListComponent, { items: lodash_1.default.map(tables, (table) => ({
|
|
153
|
+
name: expressions_1.ExprUtils.localizeString(table.name, T.locale),
|
|
154
|
+
desc: expressions_1.ExprUtils.localizeString(table.desc, T.locale),
|
|
155
|
+
onClick: () => this.handleSelect(table.id),
|
|
156
|
+
onRemove: () => this.handleTableRemove(table)
|
|
157
|
+
})) })) : (react_1.default.createElement("div", null, T `None`)),
|
|
158
|
+
react_1.default.createElement("br", null),
|
|
159
|
+
react_1.default.createElement("label", null, T `All Indicators:`),
|
|
160
|
+
!this.state.indicators || this.state.indicators.length === 0 ? (react_1.default.createElement("div", { className: "alert alert-info" },
|
|
161
|
+
react_1.default.createElement("i", { className: "fa fa-spinner fa-spin" }),
|
|
162
|
+
"\u00A0" + T `Loading...`)) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
163
|
+
react_1.default.createElement("input", { type: "text", className: "form-control form-control-sm", placeholder: T `Search...`, key: "search", ref: this.searchRef, style: { maxWidth: "20em", marginBottom: 10 }, value: this.state.search, onChange: (ev) => this.setState({ search: ev.target.value }) }),
|
|
164
|
+
this.renderIndicatorList(this.state.indicators, this.state.search)))));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
exports.IndicatorsListComponent = IndicatorsListComponent;
|
|
168
|
+
class AddIndicatorConfirmPopupComponent extends react_1.default.Component {
|
|
169
|
+
constructor(props) {
|
|
170
|
+
super(props);
|
|
171
|
+
this.state = {
|
|
172
|
+
visible: false,
|
|
173
|
+
indicatorTable: null
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
show(indicatorTable) {
|
|
177
|
+
return this.setState({ visible: true, indicatorTable });
|
|
178
|
+
}
|
|
179
|
+
renderContents() {
|
|
180
|
+
// Show loading if table not loaded
|
|
181
|
+
if (!this.props.schema.getTable(this.state.indicatorTable)) {
|
|
182
|
+
return (react_1.default.createElement("div", { className: "alert alert-info" },
|
|
183
|
+
react_1.default.createElement("i", { className: "fa fa-spinner fa-spin" }),
|
|
184
|
+
"\u00A0",
|
|
185
|
+
T `Loading...`));
|
|
186
|
+
}
|
|
187
|
+
// Find entity links
|
|
188
|
+
const entityColumns = lodash_1.default.filter(this.props.schema.getColumns(this.state.indicatorTable), (col) => col.join?.toTable?.match(/^entities\./));
|
|
189
|
+
return (react_1.default.createElement("div", null,
|
|
190
|
+
react_1.default.createElement("p", null, T `In general, it is better to get indicator values from the related site. Please select the site
|
|
191
|
+
below, then find the indicator values in the 'Related Indicators' section. Or click on 'Use Raw Indicator' if you
|
|
192
|
+
are certain that you want to use the raw indicator table`),
|
|
193
|
+
react_1.default.createElement(uiComponents.OptionListComponent, { items: lodash_1.default.map(entityColumns, (entityColumn) => ({
|
|
194
|
+
name: expressions_1.ExprUtils.localizeString(entityColumn.name, T.locale),
|
|
195
|
+
desc: expressions_1.ExprUtils.localizeString(entityColumn.desc, T.locale),
|
|
196
|
+
onClick: () => {
|
|
197
|
+
// Select table
|
|
198
|
+
this.props.onChange(entityColumn.join.toTable);
|
|
199
|
+
return this.setState({ visible: false });
|
|
200
|
+
}
|
|
201
|
+
})) }),
|
|
202
|
+
react_1.default.createElement("br", null),
|
|
203
|
+
react_1.default.createElement("div", null,
|
|
204
|
+
react_1.default.createElement("a", { className: "link-plain", onClick: this.props.onChange.bind(null, this.state.indicatorTable) }, T `Use Raw Indicator`))));
|
|
205
|
+
}
|
|
206
|
+
render() {
|
|
207
|
+
if (!this.state.visible) {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
return (react_1.default.createElement(ModalPopupComponent_1.default, { showCloseX: true, onClose: () => this.setState({ visible: false }), header: T `Add Indicator` }, this.renderContents()));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
// Single indicator item in a list
|
|
214
|
+
// Local port of the class found in mwater-portal
|
|
215
|
+
class IndicatorListItemComponent extends react_1.default.Component {
|
|
216
|
+
renderIcon() {
|
|
217
|
+
switch (this.props.indicator.type) {
|
|
218
|
+
case "expression":
|
|
219
|
+
// R 'i', className: "text-muted fa fa-fw fa-calculator"
|
|
220
|
+
return null;
|
|
221
|
+
case "response":
|
|
222
|
+
// R 'i', className: "text-muted fa fa-fw fa-list-alt"
|
|
223
|
+
return null;
|
|
224
|
+
case "set":
|
|
225
|
+
return (react_1.default.createElement("span", { className: "fa-stack", style: { paddingRight: 6 } },
|
|
226
|
+
react_1.default.createElement("i", { className: "fa fa-th-list fa-stack-1x text-muted" }),
|
|
227
|
+
react_1.default.createElement("i", { className: "fa fa-circle fa-stack-1x", style: { color: "white", paddingLeft: 15 } }),
|
|
228
|
+
react_1.default.createElement("i", { className: "fa fa-check-circle fa-stack-1x text-primary", style: { paddingLeft: 15 } })));
|
|
229
|
+
}
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
render() {
|
|
233
|
+
return (react_1.default.createElement("div", { onClick: this.props.onClick, style: { cursor: "pointer" } },
|
|
234
|
+
react_1.default.createElement("div", { key: "name", style: { fontWeight: "bold" } },
|
|
235
|
+
this.renderIcon(),
|
|
236
|
+
expressions_1.ExprUtils.localizeString(this.props.indicator.design.name, T.locale),
|
|
237
|
+
this.props.indicator.design.code ? ` (${this.props.indicator.design.code})` : undefined,
|
|
238
|
+
this.props.indicator.design.organization ? (react_1.default.createElement("span", { className: "text-muted" },
|
|
239
|
+
" ",
|
|
240
|
+
T `by ${this.props.indicator.design.organization}`)) : undefined),
|
|
241
|
+
react_1.default.createElement("div", { key: "desc", className: "text-muted" },
|
|
242
|
+
expressions_1.ExprUtils.localizeString(this.props.indicator.design.desc, T.locale),
|
|
243
|
+
this.props.indicator.design.category
|
|
244
|
+
? [
|
|
245
|
+
` (${this.props.indicator.design.category}`,
|
|
246
|
+
this.props.indicator.design.subcategory ? `/${this.props.indicator.design.subcategory}` : undefined,
|
|
247
|
+
`)`
|
|
248
|
+
]
|
|
249
|
+
: undefined)));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Schema } from "@mwater/expressions";
|
|
3
|
+
interface IssuesListComponentProps {
|
|
4
|
+
/** Url to hit api */
|
|
5
|
+
apiUrl: string;
|
|
6
|
+
/** Optional client */
|
|
7
|
+
client?: string;
|
|
8
|
+
schema: Schema;
|
|
9
|
+
/** User id */
|
|
10
|
+
user?: string;
|
|
11
|
+
/** Called with table selected */
|
|
12
|
+
onChange: any;
|
|
13
|
+
extraTables: any;
|
|
14
|
+
onExtraTableAdd: any;
|
|
15
|
+
onExtraTableRemove: any;
|
|
16
|
+
}
|
|
17
|
+
interface IssuesListComponentState {
|
|
18
|
+
error?: any;
|
|
19
|
+
search: any;
|
|
20
|
+
issueTypes: any[] | null;
|
|
21
|
+
}
|
|
22
|
+
export declare class IssuesListComponent extends React.Component<IssuesListComponentProps, IssuesListComponentState> {
|
|
23
|
+
constructor(props: any);
|
|
24
|
+
componentDidMount(): JQuery.jqXHR<any>;
|
|
25
|
+
handleTableRemove: (table: any) => any;
|
|
26
|
+
searchRef: (comp: any) => any;
|
|
27
|
+
render(): React.JSX.Element;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.IssuesListComponent = void 0;
|
|
30
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
31
|
+
const jquery_1 = __importDefault(require("jquery"));
|
|
32
|
+
const react_1 = __importDefault(require("react"));
|
|
33
|
+
const querystring_1 = __importDefault(require("querystring"));
|
|
34
|
+
const uiComponents = __importStar(require("../UIComponents"));
|
|
35
|
+
const expressions_1 = require("@mwater/expressions");
|
|
36
|
+
// Searchable list of issue types
|
|
37
|
+
class IssuesListComponent extends react_1.default.Component {
|
|
38
|
+
constructor(props) {
|
|
39
|
+
super(props);
|
|
40
|
+
this.state = {
|
|
41
|
+
issueTypes: null,
|
|
42
|
+
search: ""
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
componentDidMount() {
|
|
46
|
+
// Get names and basic of issueTypes
|
|
47
|
+
const query = {};
|
|
48
|
+
query.fields = JSON.stringify({ name: 1, desc: 1, roles: 1, created: 1, modified: 1 });
|
|
49
|
+
query.client = this.props.client;
|
|
50
|
+
// Get list of all issueType names
|
|
51
|
+
return jquery_1.default.getJSON(this.props.apiUrl + "issue_types?" + querystring_1.default.stringify(query), (issueTypes) => {
|
|
52
|
+
// Sort by modified.on desc but first by user
|
|
53
|
+
issueTypes = lodash_1.default.sortByOrder(issueTypes, [
|
|
54
|
+
(issueType) => ((this.props.extraTables || []).includes("issues:" + issueType._id) ? 0 : 1),
|
|
55
|
+
(issueType) => (issueType.created.by === this.props.user ? 0 : 1),
|
|
56
|
+
(issueType) => expressions_1.ExprUtils.localizeString(issueType.name, T.locale)
|
|
57
|
+
], ["asc", "asc", "asc"]);
|
|
58
|
+
return this.setState({
|
|
59
|
+
issueTypes: lodash_1.default.map(issueTypes, (issueType) => ({
|
|
60
|
+
id: issueType._id,
|
|
61
|
+
name: expressions_1.ExprUtils.localizeString(issueType.name, T.locale),
|
|
62
|
+
desc: expressions_1.ExprUtils.localizeString(issueType.desc, T.locale)
|
|
63
|
+
}))
|
|
64
|
+
});
|
|
65
|
+
}).fail((xhr) => {
|
|
66
|
+
return this.setState({ error: xhr.responseText });
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
handleTableRemove = (table) => {
|
|
70
|
+
if (confirm(T `Remove ${expressions_1.ExprUtils.localizeString(table.name, T.locale)}? Any widgets that depend on it will no longer work properly.`)) {
|
|
71
|
+
return this.props.onExtraTableRemove(table.id);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
searchRef = (comp) => {
|
|
75
|
+
// Focus
|
|
76
|
+
if (comp) {
|
|
77
|
+
return comp.focus();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
render() {
|
|
81
|
+
let issueTypes;
|
|
82
|
+
if (this.state.error) {
|
|
83
|
+
return react_1.default.createElement("div", { className: "alert alert-danger" }, this.state.error);
|
|
84
|
+
}
|
|
85
|
+
// Filter issueTypes
|
|
86
|
+
if (this.state.search) {
|
|
87
|
+
const escapeRegExp = (s) => s.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
88
|
+
const searchStringRegExp = new RegExp(escapeRegExp(this.state.search), "i");
|
|
89
|
+
issueTypes = lodash_1.default.filter(this.state.issueTypes || [], (issueType) => issueType.name.match(searchStringRegExp));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
;
|
|
93
|
+
({ issueTypes } = this.state);
|
|
94
|
+
}
|
|
95
|
+
// Remove if already included
|
|
96
|
+
issueTypes = lodash_1.default.filter(issueTypes || [], (f) => !(this.props.extraTables || []).includes(`issues:${f.id}`));
|
|
97
|
+
let tables = lodash_1.default.filter(this.props.schema.getTables(), (table) => (table.id.match(/^issues:/) || table.id.match(/^issue_events:/)) && !table.deprecated);
|
|
98
|
+
tables = lodash_1.default.sortBy(tables, (t) => t.name.en);
|
|
99
|
+
return (react_1.default.createElement("div", null,
|
|
100
|
+
react_1.default.createElement("label", null, T `Included Issues:`),
|
|
101
|
+
tables.length > 0 ? (react_1.default.createElement(uiComponents.OptionListComponent, { items: lodash_1.default.map(tables, (table) => {
|
|
102
|
+
return {
|
|
103
|
+
name: expressions_1.ExprUtils.localizeString(table.name, T.locale),
|
|
104
|
+
desc: expressions_1.ExprUtils.localizeString(table.desc, T.locale),
|
|
105
|
+
onClick: this.props.onChange.bind(null, table.id),
|
|
106
|
+
onRemove: this.handleTableRemove.bind(null, table)
|
|
107
|
+
};
|
|
108
|
+
}) })) : (react_1.default.createElement("div", null, T `None`)),
|
|
109
|
+
react_1.default.createElement("br", null),
|
|
110
|
+
react_1.default.createElement("label", null, T `All Issues:`),
|
|
111
|
+
!this.state.issueTypes || this.state.issueTypes.length === 0 ? (react_1.default.createElement("div", { className: "alert alert-info" },
|
|
112
|
+
react_1.default.createElement("i", { className: "fa fa-spinner fa-spin" }),
|
|
113
|
+
"\u00A0",
|
|
114
|
+
T `Loading...`)) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
115
|
+
react_1.default.createElement("input", { type: "text", className: "form-control form-control-sm", placeholder: T `Search...`, key: "search", ref: this.searchRef, style: { maxWidth: "20em", marginBottom: 10 }, value: this.state.search, onChange: (ev) => this.setState({ search: ev.target.value }) }),
|
|
116
|
+
react_1.default.createElement(uiComponents.OptionListComponent, { items: lodash_1.default.map(issueTypes, (issueType) => ({
|
|
117
|
+
name: issueType.name,
|
|
118
|
+
desc: issueType.desc,
|
|
119
|
+
onClick: this.props.onChange.bind(null, "issues:" + issueType.id)
|
|
120
|
+
})) })))));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.IssuesListComponent = IssuesListComponent;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Schema } from "@mwater/expressions";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export interface MWaterAccountingSystemListComponentProps {
|
|
4
|
+
apiUrl: string;
|
|
5
|
+
schema: Schema;
|
|
6
|
+
client?: string;
|
|
7
|
+
/** User id (not currently used but good for consistency) */
|
|
8
|
+
user?: string;
|
|
9
|
+
/** Called with table selected, e.g. "custom.accounting:123.accounts" */
|
|
10
|
+
onChange: (tableId: string | null) => void;
|
|
11
|
+
/** Current list of extra table wildcards, e.g. ["accounting:123.*"] */
|
|
12
|
+
extraTables: string[];
|
|
13
|
+
/** Called to request loading tables for an accounting system, e.g. "accounting:123.*" */
|
|
14
|
+
onExtraTableAdd: (wildcardTableId: string) => void;
|
|
15
|
+
/** Called to request unloading tables for an accounting system */
|
|
16
|
+
onExtraTableRemove: (wildcardTableId: string) => void;
|
|
17
|
+
/** e.g. "en" */
|
|
18
|
+
locale?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function MWaterAccountingSystemListComponent(props: MWaterAccountingSystemListComponentProps): React.JSX.Element;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MWaterAccountingSystemListComponent = MWaterAccountingSystemListComponent;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const expressions_1 = require("@mwater/expressions");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const react_2 = __importDefault(require("react"));
|
|
11
|
+
const UIComponents_1 = require("../UIComponents");
|
|
12
|
+
const bootstrap_1 = require("@mwater/react-library/lib/bootstrap");
|
|
13
|
+
function MWaterAccountingSystemListComponent(props) {
|
|
14
|
+
const { apiUrl, schema, client, onChange, extraTables, onExtraTableAdd, onExtraTableRemove, locale } = props;
|
|
15
|
+
const [rawAccountingSystems, setRawAccountingSystems] = (0, react_1.useState)();
|
|
16
|
+
const [accountingTablesetDesign, setAccountingTablesetDesign] = (0, react_1.useState)();
|
|
17
|
+
const [search, setSearch] = (0, react_1.useState)("");
|
|
18
|
+
// Stores the fully qualified table ID that we want to select after its system is loaded
|
|
19
|
+
const [targetSelection, setTargetSelection] = (0, react_1.useState)();
|
|
20
|
+
// Fetch accounting systems (partitions) and the main accounting tableset design
|
|
21
|
+
(0, react_1.useEffect)(() => {
|
|
22
|
+
// Fetch rows from the 'custom.accounting.partitions' table
|
|
23
|
+
fetch(`${apiUrl}custom/accounting/partitions?client=${client || ""}`)
|
|
24
|
+
.then((response) => {
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
console.error(`Error fetching accounting system partitions: ${response.status} ${response.statusText}`);
|
|
27
|
+
return []; // Return empty array on error
|
|
28
|
+
}
|
|
29
|
+
return response.json();
|
|
30
|
+
})
|
|
31
|
+
.then((systems) => {
|
|
32
|
+
setRawAccountingSystems(systems);
|
|
33
|
+
})
|
|
34
|
+
.catch(error => {
|
|
35
|
+
console.error("Failed to load accounting systems:", error);
|
|
36
|
+
setRawAccountingSystems([]);
|
|
37
|
+
});
|
|
38
|
+
// Fetch the design of the 'custom.accounting' tableset
|
|
39
|
+
const filter = encodeURIComponent(JSON.stringify({ code: "accounting" }));
|
|
40
|
+
fetch(`${apiUrl}custom_tablesets?filter=${filter}&client=${client || ""}`)
|
|
41
|
+
.then((response) => {
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
console.error(`Error fetching accounting tableset design: ${response.status} ${response.statusText}`);
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return response.json();
|
|
47
|
+
})
|
|
48
|
+
.then((tablesets) => {
|
|
49
|
+
if (tablesets && tablesets.length > 0 && tablesets[0].design) {
|
|
50
|
+
setAccountingTablesetDesign(tablesets[0].design);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
console.error("Accounting tableset design not found or invalid structure.");
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
.catch(error => {
|
|
57
|
+
console.error("Failed to load accounting tableset design:", error);
|
|
58
|
+
});
|
|
59
|
+
}, [apiUrl, client]);
|
|
60
|
+
const sortedAccountingSystems = (0, react_1.useMemo)(() => {
|
|
61
|
+
if (!rawAccountingSystems) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
return lodash_1.default.sortByAll(rawAccountingSystems, [
|
|
65
|
+
(sys) => {
|
|
66
|
+
const wildcard = `custom.accounting:${String(sys._partition)}.*`;
|
|
67
|
+
return !extraTables.includes(wildcard); // false (0) for included, true (1) for not
|
|
68
|
+
},
|
|
69
|
+
(sys) => sys.name
|
|
70
|
+
]);
|
|
71
|
+
}, [rawAccountingSystems, extraTables]);
|
|
72
|
+
// Effect to handle selecting a table once its accounting system's tables are loaded into the schema
|
|
73
|
+
(0, react_1.useEffect)(() => {
|
|
74
|
+
if (targetSelection && schema.getTable(targetSelection)) {
|
|
75
|
+
onChange(targetSelection);
|
|
76
|
+
setTargetSelection(undefined); // Clear the target selection
|
|
77
|
+
}
|
|
78
|
+
}, [targetSelection, schema, onChange]);
|
|
79
|
+
const handleSelectTable = (partitionId, table) => {
|
|
80
|
+
const qualifiedTableId = `custom.accounting:${String(partitionId)}.${table.id}`;
|
|
81
|
+
const accountingSystemWildcard = `custom.accounting:${String(partitionId)}.*`;
|
|
82
|
+
if (!extraTables.includes(accountingSystemWildcard)) {
|
|
83
|
+
onExtraTableAdd(accountingSystemWildcard);
|
|
84
|
+
}
|
|
85
|
+
if (schema.getTable(qualifiedTableId)) {
|
|
86
|
+
onChange(qualifiedTableId);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// If not yet in schema, ensure add request is made and set for future selection
|
|
90
|
+
if (!extraTables.includes(accountingSystemWildcard)) {
|
|
91
|
+
onExtraTableAdd(accountingSystemWildcard);
|
|
92
|
+
}
|
|
93
|
+
setTargetSelection(qualifiedTableId);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const handleRemoveAccountingSystem = (partitionId) => {
|
|
97
|
+
const accountingSystemWildcard = `custom.accounting:${String(partitionId)}.*`;
|
|
98
|
+
if (confirm(T `Remove this accounting system? Some widgets may not work correctly.`)) {
|
|
99
|
+
onExtraTableRemove(accountingSystemWildcard);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
if (!sortedAccountingSystems || !accountingTablesetDesign) {
|
|
103
|
+
return (react_2.default.createElement("div", null,
|
|
104
|
+
react_2.default.createElement("i", { className: "fa fa-spin fa-spinner" }),
|
|
105
|
+
" ",
|
|
106
|
+
T `Loading accounting data...`));
|
|
107
|
+
}
|
|
108
|
+
const filteredSystems = sortedAccountingSystems.filter(system => {
|
|
109
|
+
if (search === "") {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
const systemName = expressions_1.ExprUtils.localizeString(system.name, locale) || "";
|
|
113
|
+
if (systemName.toLowerCase().includes(search.toLowerCase())) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
return accountingTablesetDesign.tables.some(t => !t.deprecated && (expressions_1.ExprUtils.localizeString(t.name, locale) || "").toLowerCase().includes(search.toLowerCase()));
|
|
117
|
+
});
|
|
118
|
+
const renderSingleAccountingSystem = (system) => {
|
|
119
|
+
const systemName = expressions_1.ExprUtils.localizeString(system.name, locale) || T `Unnamed System (${system._partition})`;
|
|
120
|
+
const accountingSystemWildcard = `custom.accounting:${String(system._partition)}.*`;
|
|
121
|
+
const isIncluded = extraTables.includes(accountingSystemWildcard);
|
|
122
|
+
const tablesForThisSystem = accountingTablesetDesign.tables
|
|
123
|
+
.filter(t => !t.deprecated)
|
|
124
|
+
.filter(t => t.id != "partitions" && t.id != "roles")
|
|
125
|
+
.filter(t => {
|
|
126
|
+
if (search === "") {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
if ((expressions_1.ExprUtils.localizeString(system.name, locale) || "").toLowerCase().includes(search.toLowerCase())) {
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
return (expressions_1.ExprUtils.localizeString(t.name, locale) || "").toLowerCase().includes(search.toLowerCase());
|
|
133
|
+
})
|
|
134
|
+
.map(t => ({
|
|
135
|
+
name: expressions_1.ExprUtils.localizeString(t.name, locale),
|
|
136
|
+
onClick: () => handleSelectTable(system._partition, t)
|
|
137
|
+
}));
|
|
138
|
+
if (search !== "" && !(expressions_1.ExprUtils.localizeString(system.name, locale) || "").toLowerCase().includes(search.toLowerCase()) && tablesForThisSystem.length === 0) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
return (react_2.default.createElement("div", { key: system._partition, className: "mt-3" },
|
|
142
|
+
react_2.default.createElement("div", { className: "d-flex justify-content-between align-items-center" },
|
|
143
|
+
react_2.default.createElement("h4", { className: "text-muted mb-1" }, systemName),
|
|
144
|
+
isIncluded && (react_2.default.createElement("button", { className: "btn btn-sm btn-link", type: "button", onClick: () => handleRemoveAccountingSystem(system._partition), title: T `Remove this accounting system` },
|
|
145
|
+
react_2.default.createElement("i", { className: "fa fa-times" })))),
|
|
146
|
+
react_2.default.createElement(UIComponents_1.OptionListComponent, { items: tablesForThisSystem })));
|
|
147
|
+
};
|
|
148
|
+
return (react_2.default.createElement("div", null,
|
|
149
|
+
react_2.default.createElement(bootstrap_1.TextInput, { value: search, onChange: setSearch, placeholder: T `Search accounting systems or tables...` }),
|
|
150
|
+
targetSelection && !schema.getTable(targetSelection) && (react_2.default.createElement("div", { className: "alert alert-info my-2" },
|
|
151
|
+
react_2.default.createElement("i", { className: "fa fa-spinner fa-spin me-2" }),
|
|
152
|
+
T `Loading tables for selected accounting system...`)),
|
|
153
|
+
filteredSystems.length > 0
|
|
154
|
+
? filteredSystems.map(system => renderSingleAccountingSystem(system))
|
|
155
|
+
: (sortedAccountingSystems.length > 0 && search !== "" && react_2.default.createElement("p", null, T `No accounting systems or tables match your search.`)),
|
|
156
|
+
sortedAccountingSystems.length === 0 && !targetSelection && react_2.default.createElement("p", null, T `No accounting systems found.`)));
|
|
157
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Schema } from "@mwater/expressions";
|
|
2
|
+
import React from "react";
|
|
3
|
+
/** Searchable list of asset system tables */
|
|
4
|
+
export declare const MWaterAssetSystemsListComponent: (props: {
|
|
5
|
+
apiUrl: string;
|
|
6
|
+
schema: Schema;
|
|
7
|
+
client?: string;
|
|
8
|
+
/** User id */
|
|
9
|
+
user?: string;
|
|
10
|
+
/** Called with table selected */
|
|
11
|
+
onChange: (tableId: string | null) => void;
|
|
12
|
+
extraTables: string[];
|
|
13
|
+
onExtraTableAdd: (tableId: string) => void;
|
|
14
|
+
onExtraTableRemove: (tableId: string) => void;
|
|
15
|
+
/** e.g. "en" */
|
|
16
|
+
locale?: string;
|
|
17
|
+
}) => React.JSX.Element;
|