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