From 8705cbdc0e632368beff0a5536a3adcd502f1281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=C5=BE=20Jerman?= Date: Mon, 16 May 2022 12:55:21 +0200 Subject: [PATCH] Fix resource translations not removed when deleting field hint/description --- compose/types/module_field.go | 57 +++++++++++++++++------------------ 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/compose/types/module_field.go b/compose/types/module_field.go index 0012ed1f3..dba389ad4 100644 --- a/compose/types/module_field.go +++ b/compose/types/module_field.go @@ -254,54 +254,53 @@ func (m *ModuleField) encodeTranslationsExpressionValidatorValidatorIDError() (o func (f *ModuleField) encodeTranslationsMetaDescriptionView() (out locale.ResourceTranslationSet) { out = locale.ResourceTranslationSet{} - if v := f.getOptionKey("description", "view"); v != nil { - aux := cast.ToString(v) - - out = append(out, &locale.ResourceTranslation{ - Resource: f.ResourceTranslation(), - Key: LocaleKeyModuleFieldMetaDescriptionView.Path, - Msg: aux, - }) + t := &locale.ResourceTranslation{ + Resource: f.ResourceTranslation(), + Key: LocaleKeyModuleFieldMetaDescriptionView.Path, } + if v := f.getOptionKey("description", "view"); v != nil { + t.Msg = cast.ToString(v) + } + out = append(out, t) return out } func (f *ModuleField) encodeTranslationsMetaDescriptionEdit() (out locale.ResourceTranslationSet) { out = locale.ResourceTranslationSet{} - if v := f.getOptionKey("description", "edit"); v != nil { - aux := cast.ToString(v) - out = append(out, &locale.ResourceTranslation{ - Resource: f.ResourceTranslation(), - Key: LocaleKeyModuleFieldMetaDescriptionEdit.Path, - Msg: aux, - }) + t := &locale.ResourceTranslation{ + Resource: f.ResourceTranslation(), + Key: LocaleKeyModuleFieldMetaDescriptionEdit.Path, } + if v := f.getOptionKey("description", "edit"); v != nil { + t.Msg = cast.ToString(v) + } + out = append(out, t) return out } func (f *ModuleField) encodeTranslationsMetaHintView() (out locale.ResourceTranslationSet) { out = locale.ResourceTranslationSet{} - if v := f.getOptionKey("hint", "view"); v != nil { - aux := cast.ToString(v) - out = append(out, &locale.ResourceTranslation{ - Resource: f.ResourceTranslation(), - Key: LocaleKeyModuleFieldMetaHintView.Path, - Msg: aux, - }) + t := &locale.ResourceTranslation{ + Resource: f.ResourceTranslation(), + Key: LocaleKeyModuleFieldMetaHintView.Path, } + if v := f.getOptionKey("hint", "view"); v != nil { + t.Msg = cast.ToString(v) + } + out = append(out, t) return out } func (f *ModuleField) encodeTranslationsMetaHintEdit() (out locale.ResourceTranslationSet) { out = locale.ResourceTranslationSet{} - if v := f.getOptionKey("hint", "edit"); v != nil { - aux := cast.ToString(v) - out = append(out, &locale.ResourceTranslation{ - Resource: f.ResourceTranslation(), - Key: LocaleKeyModuleFieldMetaHintEdit.Path, - Msg: aux, - }) + t := &locale.ResourceTranslation{ + Resource: f.ResourceTranslation(), + Key: LocaleKeyModuleFieldMetaHintEdit.Path, } + if v := f.getOptionKey("hint", "edit"); v != nil { + t.Msg = cast.ToString(v) + } + out = append(out, t) return out }