@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,225 @@
|
|
|
1
|
+
import _ from "lodash"
|
|
2
|
+
import { Schema, LocalizedString, ExprUtils } from "@mwater/expressions"
|
|
3
|
+
import { CustomTablesetDesign, CustomTable } from "@mwater/common/lib/tables/custom_tablesets"
|
|
4
|
+
import { Partition as AccountingSystemPartitionType } from "@mwater/common/lib/accounting/accountingTypes"
|
|
5
|
+
import { useState, useEffect, useMemo } from "react"
|
|
6
|
+
import React from "react"
|
|
7
|
+
import { OptionListComponent } from "../UIComponents"
|
|
8
|
+
import { TextInput } from "@mwater/react-library/lib/bootstrap"
|
|
9
|
+
|
|
10
|
+
export interface MWaterAccountingSystemListComponentProps {
|
|
11
|
+
apiUrl: string
|
|
12
|
+
schema: Schema
|
|
13
|
+
client?: string
|
|
14
|
+
/** User id (not currently used but good for consistency) */
|
|
15
|
+
user?: string
|
|
16
|
+
/** Called with table selected, e.g. "custom.accounting:123.accounts" */
|
|
17
|
+
onChange: (tableId: string | null) => void
|
|
18
|
+
/** Current list of extra table wildcards, e.g. ["accounting:123.*"] */
|
|
19
|
+
extraTables: string[]
|
|
20
|
+
/** Called to request loading tables for an accounting system, e.g. "accounting:123.*" */
|
|
21
|
+
onExtraTableAdd: (wildcardTableId: string) => void
|
|
22
|
+
/** Called to request unloading tables for an accounting system */
|
|
23
|
+
onExtraTableRemove: (wildcardTableId: string) => void
|
|
24
|
+
/** e.g. "en" */
|
|
25
|
+
locale?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function MWaterAccountingSystemListComponent(props: MWaterAccountingSystemListComponentProps) {
|
|
29
|
+
const {
|
|
30
|
+
apiUrl,
|
|
31
|
+
schema,
|
|
32
|
+
client,
|
|
33
|
+
onChange,
|
|
34
|
+
extraTables,
|
|
35
|
+
onExtraTableAdd,
|
|
36
|
+
onExtraTableRemove,
|
|
37
|
+
locale
|
|
38
|
+
} = props
|
|
39
|
+
|
|
40
|
+
const [rawAccountingSystems, setRawAccountingSystems] = useState<AccountingSystemPartitionType[]>()
|
|
41
|
+
const [accountingTablesetDesign, setAccountingTablesetDesign] = useState<CustomTablesetDesign>()
|
|
42
|
+
const [search, setSearch] = useState<string>("")
|
|
43
|
+
// Stores the fully qualified table ID that we want to select after its system is loaded
|
|
44
|
+
const [targetSelection, setTargetSelection] = useState<string>()
|
|
45
|
+
|
|
46
|
+
// Fetch accounting systems (partitions) and the main accounting tableset design
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
// Fetch rows from the 'custom.accounting.partitions' table
|
|
49
|
+
fetch(`${apiUrl}custom/accounting/partitions?client=${client || ""}`)
|
|
50
|
+
.then((response) => {
|
|
51
|
+
if (!response.ok) {
|
|
52
|
+
console.error(`Error fetching accounting system partitions: ${response.status} ${response.statusText}`)
|
|
53
|
+
return [] // Return empty array on error
|
|
54
|
+
}
|
|
55
|
+
return response.json()
|
|
56
|
+
})
|
|
57
|
+
.then((systems: AccountingSystemPartitionType[]) => {
|
|
58
|
+
setRawAccountingSystems(systems)
|
|
59
|
+
})
|
|
60
|
+
.catch(error => {
|
|
61
|
+
console.error("Failed to load accounting systems:", error)
|
|
62
|
+
setRawAccountingSystems([])
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
// Fetch the design of the 'custom.accounting' tableset
|
|
66
|
+
const filter = encodeURIComponent(JSON.stringify({ code: "accounting" }))
|
|
67
|
+
fetch(`${apiUrl}custom_tablesets?filter=${filter}&client=${client || ""}`)
|
|
68
|
+
.then((response) => {
|
|
69
|
+
if (!response.ok) {
|
|
70
|
+
console.error(`Error fetching accounting tableset design: ${response.status} ${response.statusText}`)
|
|
71
|
+
return null
|
|
72
|
+
}
|
|
73
|
+
return response.json()
|
|
74
|
+
})
|
|
75
|
+
.then((tablesets: { design: CustomTablesetDesign }[] | null) => {
|
|
76
|
+
if (tablesets && tablesets.length > 0 && tablesets[0].design) {
|
|
77
|
+
setAccountingTablesetDesign(tablesets[0].design)
|
|
78
|
+
} else {
|
|
79
|
+
console.error("Accounting tableset design not found or invalid structure.")
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
.catch(error => {
|
|
83
|
+
console.error("Failed to load accounting tableset design:", error)
|
|
84
|
+
})
|
|
85
|
+
}, [apiUrl, client])
|
|
86
|
+
|
|
87
|
+
const sortedAccountingSystems = useMemo(() => {
|
|
88
|
+
if (!rawAccountingSystems) {
|
|
89
|
+
return undefined
|
|
90
|
+
}
|
|
91
|
+
return _.sortByAll(
|
|
92
|
+
rawAccountingSystems,
|
|
93
|
+
[
|
|
94
|
+
(sys: AccountingSystemPartitionType) => {
|
|
95
|
+
const wildcard = `custom.accounting:${String(sys._partition)}.*`
|
|
96
|
+
return !extraTables.includes(wildcard) // false (0) for included, true (1) for not
|
|
97
|
+
},
|
|
98
|
+
(sys: AccountingSystemPartitionType) => sys.name
|
|
99
|
+
]
|
|
100
|
+
)
|
|
101
|
+
}, [rawAccountingSystems, extraTables])
|
|
102
|
+
|
|
103
|
+
// Effect to handle selecting a table once its accounting system's tables are loaded into the schema
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (targetSelection && schema.getTable(targetSelection)) {
|
|
106
|
+
onChange(targetSelection)
|
|
107
|
+
setTargetSelection(undefined) // Clear the target selection
|
|
108
|
+
}
|
|
109
|
+
}, [targetSelection, schema, onChange])
|
|
110
|
+
|
|
111
|
+
const handleSelectTable = (partitionId: string | number, table: CustomTable) => {
|
|
112
|
+
const qualifiedTableId = `custom.accounting:${String(partitionId)}.${table.id}`
|
|
113
|
+
const accountingSystemWildcard = `custom.accounting:${String(partitionId)}.*`
|
|
114
|
+
|
|
115
|
+
if (!extraTables.includes(accountingSystemWildcard)) {
|
|
116
|
+
onExtraTableAdd(accountingSystemWildcard)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (schema.getTable(qualifiedTableId)) {
|
|
120
|
+
onChange(qualifiedTableId)
|
|
121
|
+
} else {
|
|
122
|
+
// If not yet in schema, ensure add request is made and set for future selection
|
|
123
|
+
if (!extraTables.includes(accountingSystemWildcard)) {
|
|
124
|
+
onExtraTableAdd(accountingSystemWildcard)
|
|
125
|
+
}
|
|
126
|
+
setTargetSelection(qualifiedTableId)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const handleRemoveAccountingSystem = (partitionId: string | number) => {
|
|
131
|
+
const accountingSystemWildcard = `custom.accounting:${String(partitionId)}.*`
|
|
132
|
+
if (confirm(T`Remove this accounting system? Some widgets may not work correctly.`)) {
|
|
133
|
+
onExtraTableRemove(accountingSystemWildcard)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (!sortedAccountingSystems || !accountingTablesetDesign) {
|
|
138
|
+
return (
|
|
139
|
+
<div>
|
|
140
|
+
<i className="fa fa-spin fa-spinner" /> {T`Loading accounting data...`}
|
|
141
|
+
</div>
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const filteredSystems = sortedAccountingSystems.filter(system => {
|
|
146
|
+
if (search === "") {
|
|
147
|
+
return true
|
|
148
|
+
}
|
|
149
|
+
const systemName = ExprUtils.localizeString(system.name, locale) || ""
|
|
150
|
+
if (systemName.toLowerCase().includes(search.toLowerCase())) {
|
|
151
|
+
return true
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return accountingTablesetDesign.tables.some(t =>
|
|
155
|
+
!t.deprecated && (ExprUtils.localizeString(t.name, locale) || "").toLowerCase().includes(search.toLowerCase())
|
|
156
|
+
)
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
const renderSingleAccountingSystem = (system: AccountingSystemPartitionType) => {
|
|
160
|
+
const systemName = ExprUtils.localizeString(system.name, locale) || T`Unnamed System (${system._partition})`
|
|
161
|
+
const accountingSystemWildcard = `custom.accounting:${String(system._partition)}.*`
|
|
162
|
+
const isIncluded = extraTables.includes(accountingSystemWildcard)
|
|
163
|
+
|
|
164
|
+
const tablesForThisSystem = accountingTablesetDesign.tables
|
|
165
|
+
.filter(t => !t.deprecated)
|
|
166
|
+
.filter(t => t.id != "partitions" && t.id != "roles")
|
|
167
|
+
.filter(t => {
|
|
168
|
+
if (search === "") {
|
|
169
|
+
return true
|
|
170
|
+
}
|
|
171
|
+
if ((ExprUtils.localizeString(system.name, locale) || "").toLowerCase().includes(search.toLowerCase())) {
|
|
172
|
+
return true
|
|
173
|
+
}
|
|
174
|
+
return (ExprUtils.localizeString(t.name, locale) || "").toLowerCase().includes(search.toLowerCase())
|
|
175
|
+
})
|
|
176
|
+
.map(t => ({
|
|
177
|
+
name: ExprUtils.localizeString(t.name, locale)!,
|
|
178
|
+
onClick: () => handleSelectTable(system._partition, t)
|
|
179
|
+
}))
|
|
180
|
+
|
|
181
|
+
if (search !== "" && !(ExprUtils.localizeString(system.name, locale) || "").toLowerCase().includes(search.toLowerCase()) && tablesForThisSystem.length === 0) {
|
|
182
|
+
return null
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<div key={system._partition} className="mt-3">
|
|
187
|
+
<div className="d-flex justify-content-between align-items-center">
|
|
188
|
+
<h4 className="text-muted mb-1">{systemName}</h4>
|
|
189
|
+
{isIncluded && (
|
|
190
|
+
<button
|
|
191
|
+
className="btn btn-sm btn-link"
|
|
192
|
+
type="button"
|
|
193
|
+
onClick={() => handleRemoveAccountingSystem(system._partition)}
|
|
194
|
+
title={T`Remove this accounting system`}
|
|
195
|
+
>
|
|
196
|
+
<i className="fa fa-times" />
|
|
197
|
+
</button>
|
|
198
|
+
)}
|
|
199
|
+
</div>
|
|
200
|
+
<OptionListComponent items={tablesForThisSystem} />
|
|
201
|
+
</div>
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<div>
|
|
207
|
+
<TextInput
|
|
208
|
+
value={search}
|
|
209
|
+
onChange={setSearch}
|
|
210
|
+
placeholder={T`Search accounting systems or tables...`}
|
|
211
|
+
/>
|
|
212
|
+
{targetSelection && !schema.getTable(targetSelection) && (
|
|
213
|
+
<div className="alert alert-info my-2">
|
|
214
|
+
<i className="fa fa-spinner fa-spin me-2" />
|
|
215
|
+
{T`Loading tables for selected accounting system...`}
|
|
216
|
+
</div>
|
|
217
|
+
)}
|
|
218
|
+
{filteredSystems.length > 0
|
|
219
|
+
? filteredSystems.map(system => renderSingleAccountingSystem(system))
|
|
220
|
+
: (sortedAccountingSystems.length > 0 && search !== "" && <p>{T`No accounting systems or tables match your search.`}</p>)
|
|
221
|
+
}
|
|
222
|
+
{sortedAccountingSystems.length === 0 && !targetSelection && <p>{T`No accounting systems found.`}</p>}
|
|
223
|
+
</div>
|
|
224
|
+
)
|
|
225
|
+
}
|
|
@@ -2,7 +2,7 @@ import _ from "lodash"
|
|
|
2
2
|
import { Schema, LocalizedString, Table, ExprUtils } from "@mwater/expressions"
|
|
3
3
|
import { useState, useEffect } from "react"
|
|
4
4
|
import React from "react"
|
|
5
|
-
import { OptionListComponent } from "
|
|
5
|
+
import { OptionListComponent } from "../UIComponents"
|
|
6
6
|
import { TextInput } from "@mwater/react-library/lib/bootstrap"
|
|
7
7
|
|
|
8
8
|
/** Searchable list of asset system tables */
|
|
@@ -84,7 +84,7 @@ export const MWaterAssetSystemsListComponent = (props: {
|
|
|
84
84
|
const renderAssetSystems = () => {
|
|
85
85
|
const items = systems
|
|
86
86
|
.map((m) => {
|
|
87
|
-
const alreadyIncluded = props.extraTables.some((t) => t == `
|
|
87
|
+
const alreadyIncluded = props.extraTables.some((t) => t == `assets:${m.sid}`)
|
|
88
88
|
return {
|
|
89
89
|
name: ExprUtils.localizeString(m.design.name, props.locale) || "",
|
|
90
90
|
onClick: () => selectTable(m),
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import _ from "lodash"
|
|
2
|
+
import { Schema, ExprUtils } from "@mwater/expressions"
|
|
3
|
+
import { useState, useEffect } from "react"
|
|
4
|
+
import React from "react"
|
|
5
|
+
import { OptionListComponent } from "../UIComponents"
|
|
6
|
+
import { TextInput } from "@mwater/react-library/lib/bootstrap"
|
|
7
|
+
|
|
8
|
+
interface MWaterCalculatedDataSourcesListComponentProps {
|
|
9
|
+
apiUrl: string
|
|
10
|
+
schema: Schema
|
|
11
|
+
client?: string
|
|
12
|
+
user?: string
|
|
13
|
+
onChange: (tableId: string | null) => void
|
|
14
|
+
extraTables: string[]
|
|
15
|
+
onExtraTableAdd: (tableId: string) => void
|
|
16
|
+
onExtraTableRemove: (tableId: string) => void
|
|
17
|
+
locale?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A list of calculated data sources that can be selected.
|
|
22
|
+
*/
|
|
23
|
+
export const MWaterCalculatedDataSourcesListComponent = (props: MWaterCalculatedDataSourcesListComponentProps) => {
|
|
24
|
+
const [calculatedSources, setCalculatedSources] = useState<CalculatedSource[]>()
|
|
25
|
+
const [search, setSearch] = useState<string | null>("")
|
|
26
|
+
const [extraTableNeeded, setExtraTableNeeded] = useState<string>()
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
fetch(`${props.apiUrl}calculated_data_sources?client=${props.client || ""}`)
|
|
30
|
+
.then((response) => response.json())
|
|
31
|
+
.then((body: CalculatedSource[]) => {
|
|
32
|
+
// Filter out calculated data sources that have never been calculated
|
|
33
|
+
const calculatedSources = body.filter((s) => s.last_calculated)
|
|
34
|
+
|
|
35
|
+
setCalculatedSources(
|
|
36
|
+
_.sortByAll(calculatedSources, [
|
|
37
|
+
(s) => (props.extraTables.some((t) => t == `calculated:${s._sid}`) ? 0 : 1),
|
|
38
|
+
(s) => ExprUtils.localizeString(s.name, props.locale)
|
|
39
|
+
])
|
|
40
|
+
)
|
|
41
|
+
})
|
|
42
|
+
}, [])
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (extraTableNeeded && props.schema.getTable(extraTableNeeded)) {
|
|
46
|
+
props.onChange(extraTableNeeded)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
const selectTable = (source: CalculatedSource) => {
|
|
51
|
+
const qualifiedTableId = `calculated:${source._sid}`
|
|
52
|
+
|
|
53
|
+
if (props.schema.getTable(qualifiedTableId)) {
|
|
54
|
+
props.onChange(qualifiedTableId)
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
setExtraTableNeeded(qualifiedTableId)
|
|
59
|
+
props.onExtraTableAdd(qualifiedTableId)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const handleRemove = (source: CalculatedSource) => {
|
|
63
|
+
const match = props.extraTables.find((t) => t == `calculated:${source._sid}`)
|
|
64
|
+
if (match) {
|
|
65
|
+
if (confirm(T`Remove this table? Some widgets may not work correctly.`)) {
|
|
66
|
+
props.onChange(null)
|
|
67
|
+
props.onExtraTableRemove(match)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!calculatedSources || extraTableNeeded) {
|
|
73
|
+
return (
|
|
74
|
+
<div>
|
|
75
|
+
<i className="fa fa-spin fa-spinner" /> {T`Loading...`}
|
|
76
|
+
</div>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const renderCalculatedSources = () => {
|
|
81
|
+
const items = calculatedSources
|
|
82
|
+
.map((s) => {
|
|
83
|
+
const alreadyIncluded = props.extraTables.some((t) => t == `calculated:${s._sid}`)
|
|
84
|
+
return {
|
|
85
|
+
name: ExprUtils.localizeString(s.name, props.locale) || "",
|
|
86
|
+
desc: s.description ? ExprUtils.localizeString(s.description, props.locale) || "" : undefined,
|
|
87
|
+
onClick: () => selectTable(s),
|
|
88
|
+
onRemove: alreadyIncluded ? handleRemove.bind(null, s) : undefined
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
.filter((item) => !search || item.name.toLowerCase().includes(search.toLowerCase()))
|
|
92
|
+
|
|
93
|
+
return <OptionListComponent items={items} />
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<div>
|
|
98
|
+
<TextInput value={search} onChange={setSearch} placeholder={T`Search...`} searchIcon />
|
|
99
|
+
<br/>
|
|
100
|
+
{renderCalculatedSources()}
|
|
101
|
+
</div>
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface CalculatedSource {
|
|
106
|
+
_id: string
|
|
107
|
+
_sid: number
|
|
108
|
+
name: { _base: string; [code: string]: string }
|
|
109
|
+
description?: { _base: string; [code: string]: string }
|
|
110
|
+
last_calculated?: string
|
|
111
|
+
}
|