This commit is contained in:
+50
-1
@@ -828,7 +828,7 @@ function showEnhancedEditModal(mediaType, options, currentDateadded, currentSour
|
||||
|
||||
<div class="form-group">
|
||||
<label for="edit-source">Source:</label>
|
||||
<select id="edit-source" required>
|
||||
<select id="edit-source" required onchange="handleSourceDropdownChange()">
|
||||
<option value="manual">Manual</option>
|
||||
<option value="airdate">Air Date</option>
|
||||
<option value="digital_release">Digital Release</option>
|
||||
@@ -846,6 +846,9 @@ function showEnhancedEditModal(mediaType, options, currentDateadded, currentSour
|
||||
|
||||
modalBody.innerHTML = formHtml;
|
||||
|
||||
// Store options globally for dropdown sync
|
||||
window.currentEditOptions = options;
|
||||
|
||||
// Set current values
|
||||
if (currentDateadded && currentDateadded !== '-') {
|
||||
try {
|
||||
@@ -1052,6 +1055,52 @@ async function updateEpisodeDate(imdbId, season, episode, dateadded, source) {
|
||||
}
|
||||
}
|
||||
|
||||
// Source dropdown sync function
|
||||
function handleSourceDropdownChange() {
|
||||
const selectedSource = document.getElementById('edit-source').value;
|
||||
const options = window.currentEditOptions;
|
||||
|
||||
if (!options || !options.options) {
|
||||
console.error('No options available for source sync');
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the option that matches the selected source
|
||||
const matchingOption = options.options.find(option => option.source === selectedSource);
|
||||
|
||||
if (matchingOption) {
|
||||
// Found matching option - select its radio button and update date
|
||||
const optionIndex = options.options.indexOf(matchingOption);
|
||||
const radioButton = document.querySelector(`input[name="edit-date-option"][value="${optionIndex}"]`);
|
||||
|
||||
if (radioButton) {
|
||||
radioButton.checked = true;
|
||||
// Update the date field using the existing function
|
||||
updateEditDateFromOption(optionIndex, matchingOption);
|
||||
}
|
||||
} else {
|
||||
// No matching option found - show "not available" message
|
||||
const dateInput = document.getElementById('edit-dateadded');
|
||||
if (dateInput) {
|
||||
dateInput.value = '';
|
||||
|
||||
// Show toast notification
|
||||
const sourceLabel = selectedSource.replace(/[_:]/g, ' ').replace(/\b\w/g, l => l.toUpperCase());
|
||||
showToast(`${sourceLabel} date not available for this item`, 'warning');
|
||||
}
|
||||
|
||||
// Clear any selected radio buttons since this source isn't available
|
||||
const radioButtons = document.querySelectorAll('input[name="edit-date-option"]');
|
||||
radioButtons.forEach(radio => radio.checked = false);
|
||||
|
||||
// Add visual feedback to the date input
|
||||
const dateInput = document.getElementById('edit-dateadded');
|
||||
if (dateInput) {
|
||||
dateInput.placeholder = 'Date not available for this source';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Utility functions
|
||||
function debounce(func, wait) {
|
||||
let timeout;
|
||||
|
||||
Reference in New Issue
Block a user