updates: fixes for imdb manual add and manual add dates
Local Docker Build (Dev) / build-dev (push) Successful in 5s
Local Docker Build (Dev) / build-dev (push) Successful in 5s
This commit is contained in:
@@ -1077,6 +1077,7 @@ function showEnhancedEditModal(mediaType, options, currentDateadded, currentSour
|
||||
|
||||
// Build enhanced edit form with date options
|
||||
let formHtml = `
|
||||
<form id="edit-form-enhanced" onsubmit="handleEnhancedEditSubmit(event); return false;">
|
||||
<input type="hidden" id="edit-imdb-id" value="${options.imdb_id}">
|
||||
<input type="hidden" id="edit-media-type" value="${mediaType}">
|
||||
${mediaType === 'episode' ? `
|
||||
@@ -1136,8 +1137,9 @@ function showEnhancedEditModal(mediaType, options, currentDateadded, currentSour
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="button" class="btn btn-secondary" onclick="closeModal()">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary" onclick="handleEnhancedEditSubmit(event)">Save Changes</button>
|
||||
<button type="submit" class="btn btn-primary">Save Changes</button>
|
||||
</div>
|
||||
</form>
|
||||
`;
|
||||
|
||||
modalBody.innerHTML = formHtml;
|
||||
@@ -1220,6 +1222,8 @@ function updateEditDateFromOption(optionIndex, option) {
|
||||
async function handleEnhancedEditSubmit(event) {
|
||||
event.preventDefault();
|
||||
|
||||
console.log('🔍 Enhanced Edit Submit called');
|
||||
|
||||
const modal = document.getElementById('edit-modal');
|
||||
const options = JSON.parse(modal.dataset.options);
|
||||
const imdbId = options.imdb_id;
|
||||
@@ -1227,7 +1231,17 @@ async function handleEnhancedEditSubmit(event) {
|
||||
const dateadded = document.getElementById('edit-dateadded').value;
|
||||
const source = document.getElementById('edit-source').value;
|
||||
|
||||
console.log('🔍 Form values:', {
|
||||
imdbId,
|
||||
mediaType,
|
||||
dateadded,
|
||||
dateaddedType: typeof dateadded,
|
||||
dateaddedLength: dateadded ? dateadded.length : 0,
|
||||
source
|
||||
});
|
||||
|
||||
if (!dateadded) {
|
||||
console.log('❌ Date field is empty!');
|
||||
showToast('Please enter a date', 'warning');
|
||||
return;
|
||||
}
|
||||
@@ -1236,15 +1250,19 @@ async function handleEnhancedEditSubmit(event) {
|
||||
let isoDateadded = null;
|
||||
try {
|
||||
isoDateadded = new Date(dateadded).toISOString();
|
||||
console.log('✅ Converted to ISO:', isoDateadded);
|
||||
} catch (e) {
|
||||
console.error('❌ Date conversion error:', e);
|
||||
showToast('Invalid date format', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (mediaType === 'movie') {
|
||||
console.log('📤 Calling updateMovieDate with:', { imdbId, isoDateadded, source });
|
||||
await updateMovieDate(imdbId, isoDateadded, source);
|
||||
} else {
|
||||
console.log('📤 Calling updateEpisodeDate with:', { imdbId, season: options.season, episode: options.episode, isoDateadded, source });
|
||||
await updateEpisodeDate(imdbId, options.season, options.episode, isoDateadded, source);
|
||||
}
|
||||
|
||||
@@ -1281,6 +1299,8 @@ function closeModal() {
|
||||
async function handleEditSubmit(event) {
|
||||
event.preventDefault();
|
||||
|
||||
console.log('🔍 Basic Edit Submit called (OLD HANDLER)');
|
||||
|
||||
const imdbId = document.getElementById('edit-imdb-id').value;
|
||||
const mediaType = document.getElementById('edit-media-type').value;
|
||||
const season = document.getElementById('edit-season').value;
|
||||
@@ -1288,13 +1308,26 @@ async function handleEditSubmit(event) {
|
||||
const dateadded = document.getElementById('edit-dateadded').value;
|
||||
const source = document.getElementById('edit-source').value;
|
||||
|
||||
console.log('🔍 OLD Form values:', {
|
||||
imdbId,
|
||||
mediaType,
|
||||
dateadded,
|
||||
dateaddedType: typeof dateadded,
|
||||
dateaddedLength: dateadded ? dateadded.length : 0,
|
||||
source
|
||||
});
|
||||
|
||||
// Convert datetime-local to ISO string
|
||||
const isoDateadded = dateadded ? new Date(dateadded).toISOString() : null;
|
||||
|
||||
console.log('🔍 OLD isoDateadded:', isoDateadded);
|
||||
|
||||
try {
|
||||
if (mediaType === 'movie') {
|
||||
console.log('📤 OLD calling updateMovieDate with:', { imdbId, isoDateadded, source });
|
||||
await updateMovieDate(imdbId, isoDateadded, source);
|
||||
} else {
|
||||
console.log('📤 OLD calling updateEpisodeDate');
|
||||
await updateEpisodeDate(imdbId, parseInt(season), parseInt(episode), isoDateadded, source);
|
||||
}
|
||||
|
||||
@@ -1306,15 +1339,29 @@ async function handleEditSubmit(event) {
|
||||
|
||||
// Update functions
|
||||
async function updateMovieDate(imdbId, dateadded, source) {
|
||||
console.log('🔍 updateMovieDate called with:', {
|
||||
imdbId,
|
||||
dateadded,
|
||||
dateaddedType: typeof dateadded,
|
||||
dateaddedValue: dateadded,
|
||||
source
|
||||
});
|
||||
|
||||
try {
|
||||
const result = await apiCall(`/api/movies/${imdbId}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
const payload = {
|
||||
dateadded: dateadded,
|
||||
source: source
|
||||
})
|
||||
};
|
||||
|
||||
console.log('📤 Sending API request with payload:', JSON.stringify(payload));
|
||||
|
||||
const result = await apiCall(`/api/movies/${imdbId}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
|
||||
console.log('✅ API response:', result);
|
||||
|
||||
showToast(result.message, 'success');
|
||||
|
||||
// Refresh current view
|
||||
|
||||
Reference in New Issue
Block a user