Refactor MessagesDialog component to improve parameter interpolation and description formatting

- Enhanced the description formatting logic to ensure proper interpolation of parameters in both title and description fields.
- Updated the handling of monetary values to ensure they are correctly converted to numbers before formatting.
- Improved comments for clarity on the interpolation process and effects handling.
This commit is contained in:
Torsten Schulz (local)
2026-01-09 14:44:20 +01:00
parent d0a2b122b2
commit 36f0bd8eb9

View File

@@ -172,9 +172,12 @@ export default {
if (value && value.title && value.description) {
// Parameter aus effects extrahieren und formatieren
const formattedParams = this.formatParams(params);
// Zuerst Description interpolieren (für {amount} etc.), dann Effects hinzufügen
let description = this.interpolateString(value.description, formattedParams);
description = this.formatDescriptionWithEffects(description, value.effects || [], formattedParams);
return {
title: this.interpolateString(value.title, formattedParams),
description: this.formatDescriptionWithEffects(value.description, value.effects || [], formattedParams)
description: description
};
}
@@ -212,6 +215,10 @@ export default {
const title = this.$t(titleKey, formattedParams);
let description = this.$t(descKey, formattedParams);
// Stelle sicher, dass auch hier die Parameter interpoliert werden (für {amount} etc.)
// Vue i18n interpoliert bereits, aber wir müssen sicherstellen, dass formatParams korrekt formatiert
description = this.interpolateString(description, formattedParams);
// Füge Effect-Details hinzu, falls vorhanden
if (value && value.effects) {
description = this.formatDescriptionWithEffects(description, value.effects, formattedParams);
@@ -234,10 +241,10 @@ export default {
// Geldbeträge formatieren
if (params.amount !== undefined && params.amount !== null) {
formatted.amount = this.formatMoney(params.amount);
formatted.amount = this.formatMoney(Number(params.amount));
}
if (params.absolute !== undefined && params.absolute !== null) {
formatted.amount = this.formatMoney(params.absolute);
formatted.amount = this.formatMoney(Number(params.absolute));
}
if (params.percent !== undefined && params.percent !== null) {
formatted.percent = `${params.percent > 0 ? '+' : ''}${params.percent.toFixed(1)}%`;