From 1df4b18c952fa55b4498e30b6f2553e682c7fa57 Mon Sep 17 00:00:00 2001 From: Mikael Moilanen Date: Thu, 31 Oct 2024 17:57:53 +0200 Subject: [PATCH 1/5] Fix budget table column cell alignment --- frontend/src/views/Project/BudgetTable.tsx | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/frontend/src/views/Project/BudgetTable.tsx b/frontend/src/views/Project/BudgetTable.tsx index 08b4b495..ca104ea8 100644 --- a/frontend/src/views/Project/BudgetTable.tsx +++ b/frontend/src/views/Project/BudgetTable.tsx @@ -166,7 +166,15 @@ export const BudgetTable = forwardRef(function BudgetTable(props: Props, ref) { return !budget ? null : ( <> -
+ {!props.actualsLoading ? ( - data.year === year)?.total ?? null} - /> + + data.year === year)?.total ?? null + } + /> + ) : ( Date: Fri, 1 Nov 2024 12:30:28 +0200 Subject: [PATCH 2/5] Tweak finances chart ui --- .../components/Charts/FinancesBarChart.tsx | 58 ++++++++++++++++--- .../src/components/Charts/ProgressBar.tsx | 6 +- frontend/src/components/Charts/utils.ts | 7 ++- .../views/Project/ProjectFinancesCharts.tsx | 1 + shared/src/language/fi.ts | 4 +- 5 files changed, 59 insertions(+), 17 deletions(-) diff --git a/frontend/src/components/Charts/FinancesBarChart.tsx b/frontend/src/components/Charts/FinancesBarChart.tsx index 45f02be4..51e3c04a 100644 --- a/frontend/src/components/Charts/FinancesBarChart.tsx +++ b/frontend/src/components/Charts/FinancesBarChart.tsx @@ -2,14 +2,17 @@ import { css } from '@mui/material'; import { BarLabel, BarPlot, + ChartsLegend, ChartsReferenceLine, ChartsXAxis, ChartsYAxis, + DefaultChartsLegend, ResponsiveChartContainer, useDrawingArea, useYScale, } from '@mui/x-charts'; import { ScaleLinear } from 'd3-scale'; +import { translate } from 'ol/transform'; import { useTranslations } from '@frontend/stores/lang'; @@ -59,12 +62,27 @@ export function FinancesBarChart({ colors, barData, dataLabels, totalAmount, yAx function getTickInterval() { if (!yAxisScale) return 'auto'; - return [0, yAxisScale.min / 2, yAxisScale.min, yAxisScale.max / 2, yAxisScale.max]; + + if (yAxisScale.min == 0) { + return [0, yAxisScale.max / 2, yAxisScale.max]; + } + if (yAxisScale.max == 0) { + return [0, yAxisScale.min / 2, yAxisScale.min]; + } + + const interval = Math.max(Math.abs(yAxisScale.max), Math.abs(yAxisScale.min)) / 2; + return [ + 0, + yAxisScale.min, + yAxisScale.min + interval, + yAxisScale.max - interval, + yAxisScale.max, + ]; } return ( {refValue && ( - + <> + + { + const { width } = useDrawingArea(); + + return ( + + + + {tr('financesChart.averageLineLabel')} + + + ); + }, + }} + /> + )} 0 ? Math.max(Math.abs(minDatasetYValue) / 2, maxDatasetYValue) : 0, - min: - minDatasetYValue < 0 ? Math.min(Math.abs(maxDatasetYValue) / -2, minDatasetYValue * 1.5) : 0, + max: maxDatasetYValue > 0 ? maxAbsoluteValue : 0, + min: minDatasetYValue < 0 ? maxAbsoluteValue * -1 : 0, }; } diff --git a/frontend/src/views/Project/ProjectFinancesCharts.tsx b/frontend/src/views/Project/ProjectFinancesCharts.tsx index fcc00cb1..0019a8ba 100644 --- a/frontend/src/views/Project/ProjectFinancesCharts.tsx +++ b/frontend/src/views/Project/ProjectFinancesCharts.tsx @@ -43,6 +43,7 @@ export function ProjectFinancesCharts(props: Props) { startYear: props.startYear, endYear: props.endYear, }); + const budget = trpc.project.getBudget.useQuery( { projectId: props.projectId }, { enabled: Boolean(monthlyActuals.data) }, diff --git a/shared/src/language/fi.ts b/shared/src/language/fi.ts index 208e0846..eb9b1e3d 100644 --- a/shared/src/language/fi.ts +++ b/shared/src/language/fi.ts @@ -620,10 +620,10 @@ export const fi = { 'dataTable.noData': 'Ei hakutuloksia.', 'financesChart.averageLineLabel': 'Talousarvio/kuukausi', 'financesChart.totalLabel': 'Yhteensä', - 'financesChart.noTotalLabel': 'Ei kuluja tänä vuonna', + 'financesChart.noTotalLabel': 'Ei kuluja tänä vuonna.', 'financesChart.totalsErrorLabel': 'Virhe haettaessa toteumatietoja', 'financesChart.amountLabel': 'Talousarvio', - 'financesChart.noAmountLabel': 'Talousarvio puuttuu', + 'financesChart.noAmountLabel': 'Talousarvio puuttuu.', 'financesChart.loading': 'Ladataan toteumia...', 'itemInfoBox.dateRange': 'Aikaväli', 'itemInfoBox.lifecycleState': 'Elinkaaritila', From 9f23aeb65ae1d81deda7d0c7efa34a3b32cfbc03 Mon Sep 17 00:00:00 2001 From: Mikael Moilanen Date: Fri, 1 Nov 2024 12:34:04 +0200 Subject: [PATCH 3/5] Add white higlight color to project object draw --- frontend/src/components/Map/styles.ts | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/Map/styles.ts b/frontend/src/components/Map/styles.ts index 30283c6c..4fb10a94 100644 --- a/frontend/src/components/Map/styles.ts +++ b/frontend/src/components/Map/styles.ts @@ -521,15 +521,25 @@ const _PROJ_OBJ_DRAW_FILL = _PROJ_OBJ_FILL; const _PROJ_OBJ_DRAW_STROKE = _PROJ_OBJ_STROKE; const _PROJ_OBJ_DRAW_STROKE_WIDTH = 2; -export const PROJ_OBJ_DRAW_STYLE = new Style({ - fill: new Fill({ - color: _PROJ_OBJ_DRAW_FILL, +export const PROJ_OBJ_DRAW_STYLE = [ + new Style({ + fill: new Fill({ + color: _PROJ_OBJ_DRAW_FILL, + }), + stroke: new Stroke({ + color: _PROJ_OBJ_DRAW_STROKE, + width: _PROJ_OBJ_DRAW_STROKE_WIDTH, + }), + zIndex: 1, }), - stroke: new Stroke({ - color: _PROJ_OBJ_DRAW_STROKE, - width: _PROJ_OBJ_DRAW_STROKE_WIDTH, + new Style({ + stroke: new Stroke({ + color: _DEFAULT_HIGHLIGHT_STROKE, + width: _PROJECT_STROKE_WIDTH + 4, + }), + zIndex: 0, }), -}); +]; export function getStyleWithPointIcon(styleLike: StyleLike, isFaded: boolean): StyleFunction { return function (feature: FeatureLike, resolution: number) { From 8d18253962098399de2c5665799839c8d34028b2 Mon Sep 17 00:00:00 2001 From: Mikael Moilanen Date: Fri, 1 Nov 2024 12:46:53 +0200 Subject: [PATCH 4/5] Fix max toolbar tooltips and remove icons from editing geoms while copying a geom --- frontend/src/components/Map/MapToolbar.tsx | 6 ++++-- frontend/src/components/Map/MapWrapper.tsx | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/Map/MapToolbar.tsx b/frontend/src/components/Map/MapToolbar.tsx index d0f1807f..2fb5a4b2 100644 --- a/frontend/src/components/Map/MapToolbar.tsx +++ b/frontend/src/components/Map/MapToolbar.tsx @@ -12,7 +12,7 @@ import { } from '@mui/icons-material'; import { Box, Divider, IconButton, Tooltip } from '@mui/material'; import { useState } from 'react'; -import { useParams } from 'react-router'; +import { useLocation, useParams } from 'react-router'; import { useTranslations } from '@frontend/stores/lang'; @@ -140,6 +140,8 @@ export function MapToolbar(props: Props) { const tr = useTranslations(); const [selectedTool, setSelectedTool] = useState(null); const { projectObjectId } = useParams() as { projectObjectId?: string }; + const { pathname } = useLocation(); + const isProjectObjectView = projectObjectId || pathname.includes('uusi-kohde'); function handleToolClick(tool: ToolType | null) { if (tool === 'copyFromSelection' || tool === 'deleteAllFeatures') { @@ -164,7 +166,7 @@ export function MapToolbar(props: Props) { : typeof tool.tooltip === 'object' ? tr( tool.tooltip[props.geometryExists ? 'existing' : 'new'][ - projectObjectId ? 'projectObject' : 'project' + isProjectObjectView ? 'projectObject' : 'project' ], ) : tr(tool.tooltip) diff --git a/frontend/src/components/Map/MapWrapper.tsx b/frontend/src/components/Map/MapWrapper.tsx index 90418186..37427c68 100644 --- a/frontend/src/components/Map/MapWrapper.tsx +++ b/frontend/src/components/Map/MapWrapper.tsx @@ -365,9 +365,12 @@ export const MapWrapper = forwardRef(function MapWrapper< function copySelectionToDrawSource() { const drawFeatureIds = drawSource.getFeatures().map((feature) => olUtil.getUid(feature)); const selectionFeatures = selectionSource.getFeatures(); - const featuresToCopy = selectionFeatures.filter( - (feature) => !drawFeatureIds.includes(olUtil.getUid(feature)), - ); + const featuresToCopy = selectionFeatures + .filter((feature) => !drawFeatureIds.includes(olUtil.getUid(feature))) + .map((feature) => { + feature.setProperties({ editing: true }); + return feature; + }); drawSource.addFeatures(featuresToCopy); selectionSource.clear(); drawFinished(); From 6b16e94488f3eff9595b35fd6b5b7105fea03928 Mon Sep 17 00:00:00 2001 From: Mikael Moilanen Date: Fri, 1 Nov 2024 12:59:25 +0200 Subject: [PATCH 5/5] Add activity ids to tasks --- frontend/src/views/Task/TaskRow.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/Task/TaskRow.tsx b/frontend/src/views/Task/TaskRow.tsx index 78681f11..be7f11dc 100644 --- a/frontend/src/views/Task/TaskRow.tsx +++ b/frontend/src/views/Task/TaskRow.tsx @@ -12,10 +12,18 @@ interface Props { export function TaskRow(props: Readonly) { const tr = useTranslations(); + + function getActivityDescription() { + if (!props.task.activityId && !props.task.description) { + return tr('task.noActivityDescription'); + } + return `${props.task.activityId ?? ''} ${props.task.description ?? ''}`; + } + return ( <> - {props.task.description ?? tr('task.noActivityDescription')} + {getActivityDescription()} {formatCurrency(props.task.total)}