From d9ebdc05bb34929183c0b1914d6ff9239ee3c3d2 Mon Sep 17 00:00:00 2001 From: SenorSmartyPants Date: Tue, 15 Feb 2022 23:54:44 -0600 Subject: [PATCH] Add option to season image downloader to pick from series images --- .../imageDownloader/imageDownloader.js | 37 +++++++++++++------ .../imageDownloader.template.html | 4 ++ src/components/imageeditor/imageeditor.js | 8 +++- src/strings/en-us.json | 1 + 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/components/imageDownloader/imageDownloader.js b/src/components/imageDownloader/imageDownloader.js index 1fb32a0864..01ff77013a 100644 --- a/src/components/imageDownloader/imageDownloader.js +++ b/src/components/imageDownloader/imageDownloader.js @@ -31,11 +31,16 @@ import template from './imageDownloader.template.html'; let browsableImageStartIndex = 0; let browsableImageType = 'Primary'; let selectedProvider; + let browsableParentId; - function getBaseRemoteOptions() { + function getBaseRemoteOptions(page) { const options = {}; - options.itemId = currentItemId; + if (page.querySelector('#chkShowParentImages').checked && browsableParentId) { + options.itemId = browsableParentId; + } else { + options.itemId = currentItemId; + } return options; } @@ -43,7 +48,7 @@ import template from './imageDownloader.template.html'; function reloadBrowsableImages(page, apiClient) { loading.show(); - const options = getBaseRemoteOptions(); + const options = getBaseRemoteOptions(page); options.type = browsableImageType; options.startIndex = browsableImageStartIndex; @@ -135,7 +140,7 @@ import template from './imageDownloader.template.html'; } function downloadRemoteImage(page, apiClient, url, type, provider) { - const options = getBaseRemoteOptions(); + const options = getBaseRemoteOptions(page); options.Type = type; options.ImageUrl = url; @@ -273,26 +278,31 @@ import template from './imageDownloader.template.html'; return html; } + function reloadBrowsableImagesFirstPage(page, apiClient) { + browsableImageStartIndex = 0; + reloadBrowsableImages(page, apiClient); + } + function initEditor(page, apiClient) { page.querySelector('#selectBrowsableImageType').addEventListener('change', function () { browsableImageType = this.value; - browsableImageStartIndex = 0; selectedProvider = null; - reloadBrowsableImages(page, apiClient); + reloadBrowsableImagesFirstPage(page, apiClient); }); page.querySelector('#selectImageProvider').addEventListener('change', function () { - browsableImageStartIndex = 0; selectedProvider = this.value; - reloadBrowsableImages(page, apiClient); + reloadBrowsableImagesFirstPage(page, apiClient); }); page.querySelector('#chkAllLanguages').addEventListener('change', function () { - browsableImageStartIndex = 0; + reloadBrowsableImagesFirstPage(page, apiClient); + }); - reloadBrowsableImages(page, apiClient); + page.querySelector('#chkShowParentImages').addEventListener('change', function () { + reloadBrowsableImagesFirstPage(page, apiClient); }); page.addEventListener('click', function (e) { @@ -336,6 +346,10 @@ import template from './imageDownloader.template.html'; scrollHelper.centerFocus.on(dlg, false); } + if (browsableParentId) { + dlg.querySelector('#lblShowParentImages').classList.remove('hide'); + } + // Has to be assigned a z-index after the call to .open() dlg.addEventListener('close', onDialogClosed); @@ -366,7 +380,7 @@ import template from './imageDownloader.template.html'; } } -export function show(itemId, serverId, itemType, imageType) { +export function show(itemId, serverId, itemType, imageType, parentId) { return new Promise(function (resolve, reject) { currentResolve = resolve; currentReject = reject; @@ -374,6 +388,7 @@ export function show(itemId, serverId, itemType, imageType) { browsableImageStartIndex = 0; browsableImageType = imageType || 'Primary'; selectedProvider = null; + browsableParentId = parentId; showEditor(itemId, serverId, itemType); }); } diff --git a/src/components/imageDownloader/imageDownloader.template.html b/src/components/imageDownloader/imageDownloader.template.html index b88ea73923..aede7a6933 100644 --- a/src/components/imageDownloader/imageDownloader.template.html +++ b/src/components/imageDownloader/imageDownloader.template.html @@ -39,6 +39,10 @@ ${AllLanguages} +
diff --git a/src/components/imageeditor/imageeditor.js b/src/components/imageeditor/imageeditor.js index 7f5be72f61..5682f3e95b 100644 --- a/src/components/imageeditor/imageeditor.js +++ b/src/components/imageeditor/imageeditor.js @@ -280,7 +280,13 @@ import template from './imageeditor.template.html'; function showImageDownloader(page, imageType) { import('../imageDownloader/imageDownloader').then((ImageDownloader) => { - ImageDownloader.show(currentItem.Id, currentItem.ServerId, currentItem.Type, imageType).then(function () { + ImageDownloader.show( + currentItem.Id, + currentItem.ServerId, + currentItem.Type, + imageType, + currentItem.Type == 'Season' ? currentItem.ParentId : null + ).then(function () { hasChanges = true; reload(page); }); diff --git a/src/strings/en-us.json b/src/strings/en-us.json index f1144e8f40..dea02e3506 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -1384,6 +1384,7 @@ "ShowIndicatorsFor": "Show indicators for:", "ShowLess": "Show less", "ShowMore": "Show more", + "ShowParentImages": "Show series images", "Shows": "Shows", "ShowTitle": "Show the title", "ShowYear": "Show the year",