Store office suite choice in a single config option

Previously it was three boolean options, which were supposed to be mutually
exclusive, which had to be taken care of manually.

Also previously there was only indirect indication of the choice "none", which
is brittle, too.

Signed-off-by: Pablo Zmdl <pablo@nextcloud.com>
This commit is contained in:
Pablo Zmdl
2026-07-09 13:15:02 +02:00
parent 4285168457
commit fd4e0ddcb2
8 changed files with 121 additions and 115 deletions
+7 -54
View File
@@ -1,6 +1,7 @@
document.addEventListener("DOMContentLoaded", function () {
const optionsForm = document.getElementById('options-form');
// Don't run if the expected form isn't present.
if (document.getElementById('options-form') === null) {
if (optionsForm === null) {
return;
}
@@ -20,14 +21,8 @@ document.addEventListener("DOMContentLoaded", function () {
const communityContainersCheckboxes = document.querySelectorAll("#community-form input[type='checkbox']");
// Office suite radio buttons
const collaboraRadio = document.getElementById('office-collabora');
const onlyofficeRadio = document.getElementById('office-onlyoffice');
const euroofficeRadio = document.getElementById('office-eurooffice');
const noneRadio = document.getElementById('office-none');
const collaboraHidden = document.getElementById('collabora');
const onlyofficeHidden = document.getElementById('onlyoffice');
const euroofficeHidden = document.getElementById('eurooffice');
let initialOfficeSelection = null;
const officeSuiteChoiceList = optionsForm.elements['office_suite_choice'];
const initialOfficeSelection = document.getElementById('initial-office-suite')?.value ?? '';
optionsContainersCheckboxes.forEach(checkbox => {
initialStateOptionsContainers[checkbox.id] = checkbox.checked; // Use checked property to capture actual initial state
@@ -37,19 +32,6 @@ document.addEventListener("DOMContentLoaded", function () {
initialStateCommunityContainers[checkbox.id] = checkbox.checked; // Use checked property to capture actual initial state
});
// Store initial office suite selection
if (collaboraRadio && onlyofficeRadio && euroofficeRadio && noneRadio) {
if (collaboraRadio.checked) {
initialOfficeSelection = 'collabora';
} else if (onlyofficeRadio.checked) {
initialOfficeSelection = 'onlyoffice';
} else if (euroofficeRadio.checked) {
initialOfficeSelection = 'eurooffice';
} else {
initialOfficeSelection = 'none';
}
}
// Function to compare current states to initial states
function checkForOptionContainerChanges() {
let hasChanges = false;
@@ -60,32 +42,8 @@ document.addEventListener("DOMContentLoaded", function () {
}
});
// Check office suite changes and sync to hidden inputs
if (collaboraRadio && onlyofficeRadio && euroofficeRadio && noneRadio && collaboraHidden && onlyofficeHidden && euroofficeHidden) {
let currentOfficeSelection = null;
if (collaboraRadio.checked) {
currentOfficeSelection = 'collabora';
collaboraHidden.value = 'on';
onlyofficeHidden.value = '';
euroofficeHidden.value = '';
} else if (onlyofficeRadio.checked) {
currentOfficeSelection = 'onlyoffice';
collaboraHidden.value = '';
onlyofficeHidden.value = 'on';
euroofficeHidden.value = '';
} else if (euroofficeRadio.checked) {
currentOfficeSelection = 'eurooffice';
collaboraHidden.value = '';
onlyofficeHidden.value = '';
euroofficeHidden.value = 'on';
} else {
currentOfficeSelection = 'none';
collaboraHidden.value = '';
onlyofficeHidden.value = '';
euroofficeHidden.value = '';
}
if (currentOfficeSelection !== initialOfficeSelection) {
if (officeSuiteChoiceList) {
if (officeSuiteChoiceList.value !== initialOfficeSelection) {
hasChanges = true;
}
}
@@ -156,12 +114,7 @@ document.addEventListener("DOMContentLoaded", function () {
handleTalkVisibility(); // Ensure talk-recording is correctly initialized
// Add event listeners for office suite radio buttons
if (collaboraRadio && onlyofficeRadio && euroofficeRadio && noneRadio) {
collaboraRadio.addEventListener('change', checkForOptionContainerChanges);
onlyofficeRadio.addEventListener('change', checkForOptionContainerChanges);
euroofficeRadio.addEventListener('change', checkForOptionContainerChanges);
noneRadio.addEventListener('change', checkForOptionContainerChanges);
}
officeSuiteChoiceList?.forEach((elem) => elem.addEventListener('change', checkForOptionContainerChanges));
// Initial call to check for changes
checkForOptionContainerChanges();
+1 -3
View File
@@ -153,9 +153,7 @@ $app->get('/containers', function (Request $request, Response $response, array $
'backup_times' => $configurationManager->getBackupTimes(),
'current_channel' => $dockerActionManager->GetCurrentChannel(),
'is_clamav_enabled' => $configurationManager->isClamavEnabled,
'is_onlyoffice_enabled' => $configurationManager->isOnlyofficeEnabled,
'is_eurooffice_enabled' => $configurationManager->isEuroofficeEnabled,
'is_collabora_enabled' => $configurationManager->isCollaboraEnabled,
'office_suite' => $configurationManager->getOfficeSuiteString(),
'is_talk_enabled' => $configurationManager->isTalkEnabled,
'borg_restore_password' => $configurationManager->borgRestorePassword,
'daily_backup_time' => $configurationManager->getDailyBackupTime(),