Skip to content

Commit 43f0f45

Browse files
authored
fix: Fix the display of encoded special characters in titles - MEED-9880 - Meeds-io/meeds#3745 (#1968)
This change will fix the display of encoded special characters in titles. Resolves: Meeds-io/meeds#3745
1 parent 32c9e8c commit 43f0f45

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

portlets/src/main/webapp/vue-app/rules/components/drawers/ProgramDrawer.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ export default {
582582
if (this.program?.id) {
583583
this.$programService.updateProgram(this.programToSave)
584584
.then(() => this.$translationService.saveTranslations('program', this.program.id, 'title', this.programTitleTranslations))
585-
.then(() => this.$translationService.saveTranslations('program', this.program.id, 'description', this.programDescriptionTranslations))
585+
.then(() => this.$translationService.saveRichTranslations('program', this.program.id, 'description', this.programDescriptionTranslations))
586586
.then(() => {
587587
if (this.deleteCover) {
588588
return this.$programService.deleteProgramCover(this.program.id)
@@ -622,7 +622,7 @@ export default {
622622
this.originalProgram = program;
623623
return this.$translationService.saveTranslations('program', this.originalProgram.id, 'title', this.programTitleTranslations);
624624
})
625-
.then(() => this.$translationService.saveTranslations('program', this.originalProgram.id, 'description', this.programDescriptionTranslations))
625+
.then(() => this.$translationService.saveRichTranslations('program', this.originalProgram.id, 'description', this.programDescriptionTranslations))
626626
.then(() => {
627627
this.$root.$emit('alert-message-html', `
628628
<div class="text-start">

portlets/src/main/webapp/vue-app/rules/components/drawers/RuleContentFormDrawer.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ export default {
650650
this.saving = true;
651651
if (this.rule.id) {
652652
this.$translationService.saveTranslations('rule', this.rule.id, 'title', this.ruleTitleTranslations)
653-
.then(() => this.$translationService.saveTranslations('rule', this.rule.id, 'description', this.ruleDescriptionTranslations))
653+
.then(() => this.$translationService.saveRichTranslations('rule', this.rule.id, 'description', this.ruleDescriptionTranslations))
654654
.then(() => this.$refs?.rulePublishInput?.saveAttachments())
655655
.then(() => this.$ruleService.updateRule(this.ruleToSave))
656656
.then(rule => {
@@ -692,7 +692,7 @@ export default {
692692
this.$root.$emit('rule-created-event', rule);
693693
return this.$translationService.saveTranslations('rule', this.originalRule.id, 'title', this.ruleTitleTranslations);
694694
})
695-
.then(() => this.$translationService.saveTranslations('rule', this.originalRule.id, 'description', this.ruleDescriptionTranslations))
695+
.then(() => this.$translationService.saveRichTranslations('rule', this.originalRule.id, 'description', this.ruleDescriptionTranslations))
696696
.then(() => {
697697
this.metadataObjectId = String(this.originalRule.id);
698698
return this.$nextTick();

services/src/main/java/io/meeds/gamification/service/injection/ProgramImportService.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,23 +228,26 @@ protected void saveNames(RuleDescriptor d, RuleDTO ruleDTO) {
228228
ruleDTO.getId(),
229229
RuleTranslationPlugin.RULE_TITLE_FIELD_NAME,
230230
d.getNames(),
231-
d.getAppendEmoji());
231+
d.getAppendEmoji(),
232+
false);
232233
}
233234

234235
protected void saveDescriptions(RuleDescriptor d, RuleDTO ruleDTO) {
235236
programTranslationImportService.saveTranslationLabels(RuleTranslationPlugin.RULE_OBJECT_TYPE,
236237
ruleDTO.getId(),
237238
RuleTranslationPlugin.RULE_DESCRIPTION_FIELD_NAME,
238239
d.getDescriptions(),
239-
null);
240+
null,
241+
true);
240242
}
241243

242244
protected void saveProgramNames(ProgramDescriptor d, ProgramDTO programDTO) {
243245
programTranslationImportService.saveTranslationLabels(ProgramTranslationPlugin.PROGRAM_OBJECT_TYPE,
244246
programDTO.getId(),
245247
ProgramTranslationPlugin.PROGRAM_TITLE_FIELD_NAME,
246248
d.getNames(),
247-
d.getAppendEmoji());
249+
d.getAppendEmoji(),
250+
false);
248251
}
249252

250253
protected void saveProgramDescriptions(ProgramDescriptor d, ProgramDTO programDTO) {

services/src/main/java/io/meeds/gamification/service/injection/ProgramTranslationImportService.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,17 @@ public void saveTranslationLabels(String objectType,
7575
long objectId,
7676
String fieldName,
7777
Map<String, String> labels,
78-
String appendEmoji) {
78+
String appendEmoji,
79+
boolean isRichText) {
7980
// Make Heavy processing made at the end or import process
8081
postImportProcessors.computeIfAbsent(objectType, k -> new ArrayList<>())
8182
.add(() -> saveTranslationLabelsForAllLanguages(objectType,
8283
objectId,
8384
fieldName,
8485
labels,
8586
appendEmoji,
86-
getI18NLabel(labels.get("en"), Locale.ENGLISH)));
87+
getI18NLabel(labels.get("en"), Locale.ENGLISH),
88+
isRichText));
8789
}
8890

8991
public void postImport(String objectType) {
@@ -126,9 +128,10 @@ private void saveProgramDescriptionTranslationLabelsForAllLanguages(long objectI
126128
.forEach(config -> translations.put(config.getLocale(),
127129
getProgramDescriptionLabel(descriptions, config.getLocale())));
128130
translationService.saveTranslationLabels(ProgramTranslationPlugin.PROGRAM_OBJECT_TYPE,
129-
objectId,
131+
objectId == 0 ? null : String.valueOf(objectId),
130132
ProgramTranslationPlugin.PROGRAM_DESCRIPTION_FIELD_NAME,
131-
translations);
133+
translations,
134+
true);
132135
}
133136

134137
@SneakyThrows
@@ -138,7 +141,8 @@ private void saveTranslationLabelsForAllLanguages(String objectType,
138141
String fieldName,
139142
Map<String, String> labels,
140143
String appendEmoji,
141-
String defaultLabel) {
144+
String defaultLabel,
145+
boolean isRichText) {
142146
String i18nKey = labels.get("en");
143147
Map<Locale, String> translations = new HashMap<>();
144148
localeConfigService.getLocalConfigs()
@@ -152,7 +156,7 @@ private void saveTranslationLabelsForAllLanguages(String objectType,
152156
: getI18NLabel(i18nKey,
153157
config.getLocale(),
154158
defaultLabel)));
155-
translationService.saveTranslationLabels(objectType, objectId, fieldName, translations);
159+
translationService.saveTranslationLabels(objectType, objectId == 0 ? null : String.valueOf(objectId), fieldName, translations, isRichText);
156160
}
157161

158162
private String getI18NLabel(String label, Locale locale, String defaultLabel) {

0 commit comments

Comments
 (0)