From a18050fc2dd028e2b780cf4e69b99ab557c0a758 Mon Sep 17 00:00:00 2001
From: Markus Klein <markus.klein@typo3.org>
Date: Sun, 29 May 2016 15:59:38 +0200
Subject: [PATCH] [TASK] Automatically select the custom preset when values are
 changed

If the user changes a field in a custom preset in the Install Tool
the custom preset's radio box must be selected too.

Resolves: #76365
Releases: master, 7.6
Change-Id: Iee499d61574e88ef094d690bea7ff827aa7507dc
Reviewed-on: https://review.typo3.org/48394
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
---
 .../Partials/Action/Tool/Configuration/Context/Custom.html | 3 ++-
 .../Partials/Action/Tool/Configuration/Image/Custom.html   | 3 ++-
 .../Partials/Action/Tool/Configuration/Mail/Custom.html    | 7 ++++---
 .../sysext/install/Resources/Public/JavaScript/Install.js  | 5 +++++
 4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Context/Custom.html b/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Context/Custom.html
index 2a50e95b6714..7b9d137192ab 100644
--- a/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Context/Custom.html
+++ b/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Context/Custom.html
@@ -33,7 +33,8 @@
 						type="input"
 						name="install[values][{feature.name}][{preset.name}][{configurationKey}]"
 						value="{configurationValue}"
-						class="form-control"
+						class="form-control t3js-custom-preset"
+						data-radio="t3-install-tool-configuration-context-custom"
 					/>
 				</div>
 			</div>
diff --git a/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Image/Custom.html b/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Image/Custom.html
index 133d5063b78c..deda64cd5bd5 100644
--- a/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Image/Custom.html
+++ b/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Image/Custom.html
@@ -33,7 +33,8 @@
 						type="input"
 						name="install[values][{feature.name}][{preset.name}][{configurationKey}]"
 						value="{configurationValue}"
-						class="form-control"
+						class="form-control t3js-custom-preset"
+						data-radio="t3-install-tool-configuration-image-custom"
 					/>
 				</div>
 			</div>
diff --git a/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Mail/Custom.html b/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Mail/Custom.html
index 28fe86e1b019..9531c8256289 100644
--- a/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Mail/Custom.html
+++ b/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Mail/Custom.html
@@ -4,13 +4,13 @@
 			<input
 				type="radio"
 				class="t3-install-tool-configuration-radio"
-				id="t3-install-tool-configuration-charset-custom"
+				id="t3-install-tool-configuration-mail-custom"
 				name="install[values][{feature.name}][enable]"
 				value="{preset.name}"
 				{f:if(condition:'{preset.isActive}', then:'checked="checked"')}
 			/>
 			<label
-				for="t3-install-tool-configuration-charset-custom"
+				for="t3-install-tool-configuration-mail-custom"
 				class="t3-install-tool-configuration-radio-label"
 				>
 				<strong>
@@ -33,7 +33,8 @@
 						type="input"
 						name="install[values][{feature.name}][{preset.name}][{configurationKey}]"
 						value="{configurationValue}"
-						class="form-control"
+						class="form-control t3js-custom-preset"
+						data-radio="t3-install-tool-configuration-mail-custom"
 						/>
 				</div>
 			</div>
diff --git a/typo3/sysext/install/Resources/Public/JavaScript/Install.js b/typo3/sysext/install/Resources/Public/JavaScript/Install.js
index bfac527c1322..aad6583dbcfb 100644
--- a/typo3/sysext/install/Resources/Public/JavaScript/Install.js
+++ b/typo3/sysext/install/Resources/Public/JavaScript/Install.js
@@ -675,4 +675,9 @@ $(function() {
 			TYPO3.Install.Scrolling.handleButtonScrolling();
 		}, 50);
 	});
+
+	// automatically select the custom preset if a value in one of its input fields is changed
+	$('.t3js-custom-preset').on('change', function () {
+		$('#' + $(this).data('radio')).prop('checked', true);
+	});
 });
-- 
GitLab