From bd0ccab1061ec533ea9184855b5844c87bac3b00 Mon Sep 17 00:00:00 2001
From: srosse <stephane.rosse@frentix.com>
Date: Thu, 3 Sep 2020 14:38:04 +0200
Subject: [PATCH] OO-4894: edit user life cycle body template in text area

---
 ...AdminLifecycleConfigurationController.java | 31 +++++++++++--------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/src/main/java/org/olat/user/ui/admin/lifecycle/UserAdminLifecycleConfigurationController.java b/src/main/java/org/olat/user/ui/admin/lifecycle/UserAdminLifecycleConfigurationController.java
index ea64d3eafca..350684d2fab 100644
--- a/src/main/java/org/olat/user/ui/admin/lifecycle/UserAdminLifecycleConfigurationController.java
+++ b/src/main/java/org/olat/user/ui/admin/lifecycle/UserAdminLifecycleConfigurationController.java
@@ -91,7 +91,6 @@ public class UserAdminLifecycleConfigurationController extends FormBasicControll
 		formLayout.add(buttonsLayout);
 		uifactory.addFormSubmitButton("save", buttonsLayout);
 	}
-	
 
 	protected void initDeactivationForm(FormItemContainer formLayout) {
 		String[] onValues = new String[] { translate("enabled") };
@@ -115,8 +114,8 @@ public class UserAdminLifecycleConfigurationController extends FormBasicControll
 		initDays(numberOfDayBeforeDeactivationMailEl);
 		
 		// subject + content mail
-		TranslationBundle beforeBundleSubject = initForm("mail.before.deactivation.subject.label", "mail.before.deactivation.subject", formLayout);
-		TranslationBundle beforeBundle = initForm("mail.before.deactivation.body.label", "mail.before.deactivation.body", formLayout);
+		TranslationBundle beforeBundleSubject = initForm("mail.before.deactivation.subject.label", "mail.before.deactivation.subject", false, formLayout);
+		TranslationBundle beforeBundle = initForm("mail.before.deactivation.body.label", "mail.before.deactivation.body", true, formLayout);
 		mailBeforeDeactivationBundles = new TranslationBundles(beforeBundleSubject, beforeBundle);
 
 		// enable mail after
@@ -125,8 +124,8 @@ public class UserAdminLifecycleConfigurationController extends FormBasicControll
 		enableMailAfterDeactivationEl.select(onKeys[0], userModule.isMailAfterDeactivation());
 
 		// subject + content mail
-		TranslationBundle afterBundleSubject = initForm("mail.after.deactivation.subject.label", "mail.after.deactivation.subject", formLayout);
-		TranslationBundle afterBundle = initForm("mail.after.deactivation.body.label", "mail.after.deactivation.body", formLayout);
+		TranslationBundle afterBundleSubject = initForm("mail.after.deactivation.subject.label", "mail.after.deactivation.subject", false, formLayout);
+		TranslationBundle afterBundle = initForm("mail.after.deactivation.body.label", "mail.after.deactivation.body", true, formLayout);
 		mailAfterDeactivationBundles = new TranslationBundles(afterBundleSubject, afterBundle);
 	}
 
@@ -151,8 +150,8 @@ public class UserAdminLifecycleConfigurationController extends FormBasicControll
 		initDays(numberOfDayBeforeDeletionMailEl);
 		
 		// subject + content mail
-		TranslationBundle beforeBundleSubject = initForm("mail.before.deletion.subject.label", "mail.before.deletion.subject", formLayout);
-		TranslationBundle beforeBundle = initForm("mail.before.deletion.body.label", "mail.before.deletion.body", formLayout);
+		TranslationBundle beforeBundleSubject = initForm("mail.before.deletion.subject.label", "mail.before.deletion.subject", false, formLayout);
+		TranslationBundle beforeBundle = initForm("mail.before.deletion.body.label", "mail.before.deletion.body", true, formLayout);
 		mailBeforeDeletionBundles = new TranslationBundles(beforeBundleSubject, beforeBundle);
 		
 		// enable mail after
@@ -161,17 +160,17 @@ public class UserAdminLifecycleConfigurationController extends FormBasicControll
 		enableMailAfterDeletionEl.select(onKeys[0], userModule.isMailAfterDeletion());
 		
 		// subject + content mail
-		TranslationBundle afterBundleSubject = initForm("mail.after.deletion.subject.label", "mail.after.deletion.subject", formLayout);
-		TranslationBundle afterBundle = initForm("mail.after.deletion.body.label", "mail.after.deletion.body", formLayout);
+		TranslationBundle afterBundleSubject = initForm("mail.after.deletion.subject.label", "mail.after.deletion.subject", false, formLayout);
+		TranslationBundle afterBundle = initForm("mail.after.deletion.body.label", "mail.after.deletion.body", true, formLayout);
 		mailAfterDeletionBundles = new TranslationBundles(afterBundleSubject, afterBundle);
 		
 	}
 	
-	private TranslationBundle initForm(String labelI18nKey, String textI18nKey, FormItemContainer formLayout) {
+	private TranslationBundle initForm(String labelI18nKey, String textI18nKey, boolean textArea, FormItemContainer formLayout) {
 		String text = translate(textI18nKey);
 		StaticTextElement viewEl = uifactory.addStaticTextElement("view." + counter++, labelI18nKey, text, formLayout);
 		FormLink translationLink = uifactory.addFormLink("translate." + counter++, "translation.edit", null, formLayout, Link.LINK);
-		TranslationBundle bundle = new TranslationBundle(textI18nKey, labelI18nKey, viewEl, translationLink);
+		TranslationBundle bundle = new TranslationBundle(textI18nKey, labelI18nKey, viewEl, translationLink, textArea);
 		translationLink.setUserObject(bundle);
 		return bundle;
 	}
@@ -274,7 +273,7 @@ public class UserAdminLifecycleConfigurationController extends FormBasicControll
 		if(guardModalController(translatorCtrl)) return;
 		
 		translatorCtrl = new SingleKeyTranslatorController(ureq, getWindowControl(), bundle.getI18nKey(),
-				UserAdminLifecycleConfigurationController.class);
+				UserAdminLifecycleConfigurationController.class, bundle.isTextArea());
 		translatorCtrl.setUserObject(bundle);
 		listenTo(translatorCtrl);
 
@@ -290,12 +289,14 @@ public class UserAdminLifecycleConfigurationController extends FormBasicControll
 	
 	private static class TranslationBundle {
 		
+		private final boolean textArea;
 		private final String i18nKey;
 		private final String labelI18nKey;
 		private final StaticTextElement viewEl;
 		private final FormLink translationLink;
 		
-		public TranslationBundle(String i18nKey, String labelI18nKey, StaticTextElement viewEl, FormLink translationLink) {
+		public TranslationBundle(String i18nKey, String labelI18nKey, StaticTextElement viewEl, FormLink translationLink, boolean textArea) {
+			this.textArea = textArea;
 			this.i18nKey = i18nKey;
 			this.viewEl = viewEl;
 			this.labelI18nKey = labelI18nKey;
@@ -305,6 +306,10 @@ public class UserAdminLifecycleConfigurationController extends FormBasicControll
 		public StaticTextElement getViewEl() {
 			return viewEl;
 		}
+		
+		public boolean isTextArea() {
+			return textArea;
+		}
 
 		public String getI18nKey() {
 			return i18nKey;
-- 
GitLab