From d07c926480b06cfea36f76a6289a56ce7ef137fd Mon Sep 17 00:00:00 2001 From: Min Khant Kyaw Date: Tue, 16 Sep 2025 16:43:08 +0630 Subject: [PATCH 1/2] Add invocation for community types creation in seeds file --- db/seeds.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/seeds.rb b/db/seeds.rb index 854987e2..66bad6fe 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -12,3 +12,6 @@ # Run the domain_block import rake task Rake::Task['domain_block:import'].invoke + +# Run default community types +Rake::Task['community_types:create'].invoke \ No newline at end of file From 73530504de58f8be47003213f4c6eab21ed1d67d Mon Sep 17 00:00:00 2001 From: Min Khant Kyaw Date: Wed, 17 Sep 2025 13:14:21 +0630 Subject: [PATCH 2/2] Add toggle functionality for modal button visibility based on input value --- app/javascript/lib/datatable.js | 51 ++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/app/javascript/lib/datatable.js b/app/javascript/lib/datatable.js index a86a7001..76ac55ab 100644 --- a/app/javascript/lib/datatable.js +++ b/app/javascript/lib/datatable.js @@ -141,10 +141,29 @@ jQuery(function() { nestedFields.find('input[type="text"]').val(''); } + // Add this function to handle modal button visibility + function toggleModalButtons(inputValue) { + const closeButton = document.querySelector('#maxCharsModal .btn-secondary'); + const crossButton = document.querySelector('#maxCharsModal .close'); + + if (inputValue && inputValue.trim() !== '') { + // Show buttons when input has value + if (closeButton) closeButton.style.display = 'block'; + if (crossButton) crossButton.style.display = 'block'; + } else { + // Hide buttons when input is empty + if (closeButton) closeButton.style.display = 'none'; + if (crossButton) crossButton.style.display = 'none'; + } + } + window.handleEditClick = function(element) { var maxCharsValue = element.getAttribute('data-optional-value'); var maxCharsInput = document.getElementById('max_chars_value'); maxCharsInput.value = maxCharsValue || ''; + + // Toggle buttons based on initial value + toggleModalButtons(maxCharsValue); }; function updateSetting(checkbox) { @@ -155,6 +174,36 @@ jQuery(function() { sendPatchRequest(`/server_settings/${settingId}`, data); } + // Update the existing modal show event handler + $('#maxCharsModal').on('show.bs.modal', function() { + const maxCharsInput = document.getElementById('max_chars_value'); + + // Initially hide buttons if no value + toggleModalButtons(maxCharsInput ? maxCharsInput.value : ''); + + // Add event listener for input changes + if (maxCharsInput) { + maxCharsInput.addEventListener('input', function() { + toggleModalButtons(this.value); + }); + + // Also listen for keyup to catch all changes + maxCharsInput.addEventListener('keyup', function() { + toggleModalButtons(this.value); + }); + } + }); + + // Reset button visibility when modal is hidden + $('#maxCharsModal').on('hidden.bs.modal', function() { + const closeButton = document.querySelector('#maxCharsModal .btn-secondary'); + const crossButton = document.querySelector('#maxCharsModal .close'); + + // Reset to visible state for next time + if (closeButton) closeButton.style.display = 'block'; + if (crossButton) crossButton.style.display = 'block'; + }); + function showModalIfNeeded(checkbox) { const settingName = checkbox.getAttribute('data-setting-name').toLowerCase(); @@ -180,7 +229,7 @@ jQuery(function() { if (saveMaxCharsButton) { saveMaxCharsButton.addEventListener('click', function() { const maxCharsInput = document.getElementById('max_chars_value'); - const newValue = maxCharsInput ? maxCharsInput.value : ''; + const newValue = maxCharsInput ? maxCharsInput.value || '500' : ''; const settingElement = Array.from(document.querySelectorAll('.setting-input')) .find(el => el.getAttribute('data-setting-name').toLowerCase() === 'long posts and markdown');