This commit is contained in:
+1
-49
@@ -828,7 +828,7 @@ function showEnhancedEditModal(mediaType, options, currentDateadded, currentSour
|
|||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="edit-source">Source:</label>
|
<label for="edit-source">Source:</label>
|
||||||
<select id="edit-source" required onchange="handleSourceDropdownChange()">
|
<select id="edit-source" required>
|
||||||
<option value="manual">Manual</option>
|
<option value="manual">Manual</option>
|
||||||
<option value="airdate">Air Date</option>
|
<option value="airdate">Air Date</option>
|
||||||
<option value="digital_release">Digital Release</option>
|
<option value="digital_release">Digital Release</option>
|
||||||
@@ -846,8 +846,6 @@ function showEnhancedEditModal(mediaType, options, currentDateadded, currentSour
|
|||||||
|
|
||||||
modalBody.innerHTML = formHtml;
|
modalBody.innerHTML = formHtml;
|
||||||
|
|
||||||
// Store options globally for dropdown sync
|
|
||||||
window.currentEditOptions = options;
|
|
||||||
|
|
||||||
// Set current values
|
// Set current values
|
||||||
if (currentDateadded && currentDateadded !== '-') {
|
if (currentDateadded && currentDateadded !== '-') {
|
||||||
@@ -1055,52 +1053,6 @@ 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
|
// Utility functions
|
||||||
function debounce(func, wait) {
|
function debounce(func, wait) {
|
||||||
let timeout;
|
let timeout;
|
||||||
|
|||||||
Reference in New Issue
Block a user