diff --git a/dashboard-ui/bower_components/emby-webcomponents/paperdialoghelper/paperdialoghelper.js b/dashboard-ui/bower_components/emby-webcomponents/paperdialoghelper/paperdialoghelper.js index 8831e5474c..8835931352 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/paperdialoghelper/paperdialoghelper.js +++ b/dashboard-ui/bower_components/emby-webcomponents/paperdialoghelper/paperdialoghelper.js @@ -165,6 +165,13 @@ } }; + // too buggy in IE, not even worth it + if (browser.msie) { + dlg.animationConfig = null; + dlg.entryAnimation = null; + dlg.exitAnimation = null; + } + dlg.classList.add('paperDialog'); dlg.classList.add('scrollY'); diff --git a/dashboard-ui/components/filterdialog/filterdialog.js b/dashboard-ui/components/filterdialog/filterdialog.js index f0d77bb8e7..9d82063e5b 100644 --- a/dashboard-ui/components/filterdialog/filterdialog.js +++ b/dashboard-ui/components/filterdialog/filterdialog.js @@ -1,4 +1,4 @@ -define(['paperdialoghelper', 'events', 'paper-checkbox', 'jqmcollapsible', 'css!components/filterdialog/style', 'paper-radio-button', 'paper-radio-group'], function (paperDialogHelper, events) { +define(['paperdialoghelper', 'events', 'browser', 'paper-checkbox', 'jqmcollapsible', 'css!components/filterdialog/style', 'paper-radio-button', 'paper-radio-group'], function (paperDialogHelper, events, browser) { function renderOptions(context, selector, cssClass, items, isCheckedFn) { @@ -84,9 +84,9 @@ if (options.mode == 'livetvchannels') { - $('.chkFavorite', context).checked(query.IsFavorite == true); - $('.chkLikes', context).checked(query.IsLiked == true); - $('.chkDislikes', context).checked(query.IsDisliked == true); + context.querySelector('.chkFavorite').checked = query.IsFavorite == true; + context.querySelector('.chkLikes').checked = query.IsLiked == true; + context.querySelector('.chkDislikes').checked = query.IsDisliked == true; } else { $('.chkStandardFilter', context).each(function () { @@ -95,7 +95,6 @@ var filterName = this.getAttribute('data-filter'); this.checked = filters.indexOf(',' + filterName) != -1; - }); } @@ -107,15 +106,15 @@ this.checked = filters.indexOf(',' + filterName) != -1; }); - $('.chk3DFilter', context).checked(query.Is3D == true); - $('.chkHDFilter', context).checked(query.IsHD == true); - $('.chkSDFilter', context).checked(query.IsHD == false); + context.querySelector('.chk3DFilter').checked = query.Is3D == true; + context.querySelector('.chkHDFilter').checked = query.IsHD == true; + context.querySelector('.chkSDFilter').checked = query.IsHD == true; - $('#chkSubtitle', context).checked(query.HasSubtitles == true); - $('#chkTrailer', context).checked(query.HasTrailer == true); - $('#chkThemeSong', context).checked(query.HasThemeSong == true); - $('#chkThemeVideo', context).checked(query.HasThemeVideo == true); - $('#chkSpecialFeature', context).checked(query.HasSpecialFeature == true); + context.querySelector('#chkSubtitle').checked = query.HasSubtitles == true; + context.querySelector('#chkTrailer').checked = query.HasTrailer == true; + context.querySelector('#chkThemeSong').checked = query.HasThemeSong == true; + context.querySelector('#chkThemeVideo').checked = query.HasThemeVideo == true; + context.querySelector('#chkSpecialFeature').checked = query.HasSpecialFeature == true; $('#chkSpecialEpisode', context).checked(query.ParentIndexNumber == 0); $('#chkMissingEpisode', context).checked(query.IsMissing == true); @@ -513,7 +512,8 @@ modal: false, enableHistory: false, entryAnimationDuration: 160, - exitAnimationDuration: 200 + exitAnimationDuration: 200, + autoFocus: false }); dlg.classList.add('ui-body-a'); @@ -522,28 +522,34 @@ dlg.classList.add('formDialog'); dlg.classList.add('filterDialog'); - var html = ''; - - html += Globalize.translateDocument(template); - - dlg.innerHTML = html; + dlg.innerHTML = Globalize.translateDocument(template); setVisibility(dlg, options); document.body.appendChild(dlg); // needed for jqm collapsibles - $(dlg.querySelector('.filterDialogContent')).trigger('create'); + $(dlg.querySelectorAll('div[data-role="collapsible"]')).collapsible({}); paperDialogHelper.open(dlg); dlg.addEventListener('iron-overlay-closed', resolve); - updateFilterControls(dlg, options); - bindEvents(self, dlg, options); + var onTimeout = function () { + updateFilterControls(dlg, options); + bindEvents(self, dlg, options); - if (enableDynamicFilters(options.mode)) { - dlg.classList.add('dynamicFilterDialog'); - loadDynamicFilters(dlg, Dashboard.getCurrentUserId(), options.query); + if (enableDynamicFilters(options.mode)) { + dlg.classList.add('dynamicFilterDialog'); + loadDynamicFilters(dlg, Dashboard.getCurrentUserId(), options.query); + } + }; + + // In browsers without native web components (FF/IE), there are some quirks with the checkboxes appearing incorrectly with no visible checkmark + // Applying a delay after setting innerHTML seems to resolve this + if (browser.animate) { + onTimeout(); + } else { + setTimeout(onTimeout, 100); } } diff --git a/dashboard-ui/components/metadataeditor/metadataeditor.js b/dashboard-ui/components/metadataeditor/metadataeditor.js index 6eb4ef6f39..0db81a2718 100644 --- a/dashboard-ui/components/metadataeditor/metadataeditor.js +++ b/dashboard-ui/components/metadataeditor/metadataeditor.js @@ -1,12 +1,14 @@ -define(['paperdialoghelper', 'paper-checkbox', 'paper-dialog', 'paper-input', 'paper-item-body', 'paper-icon-item', 'paper-textarea'], function (paperDialogHelper) { +define(['paperdialoghelper', 'paper-checkbox', 'paper-dialog', 'paper-input', 'paper-item-body', 'paper-icon-item', 'paper-textarea', 'paper-fab'], function (paperDialogHelper) { - var currentDialog; + var currentContext; var metadataEditorInfo; var currentItem; function closeDialog(isSubmitted) { - paperDialogHelper.close(currentDialog); + if (currentContext.tagName == 'PAPER-DIALOG') { + paperDialogHelper.close(currentContext); + } } function submitUpdatedItem(form, item) { @@ -259,6 +261,148 @@ }); } + function showRefreshMenu(context, button) { + + var items = []; + + items.push({ + name: Globalize.translate('ButtonLocalRefresh'), + id: 'local', + ironIcon: 'refresh' + }); + + items.push({ + name: Globalize.translate('ButtonAddMissingData'), + id: 'missing', + ironIcon: 'refresh' + }); + + items.push({ + name: Globalize.translate('ButtonFullRefresh'), + id: 'full', + ironIcon: 'refresh' + }); + + require(['actionsheet'], function (actionsheet) { + + actionsheet.show({ + items: items, + positionTo: button, + callback: function (id) { + + if (id) { + + Dashboard.showLoadingMsg(); + // For now this is a hack + setTimeout(function () { + Dashboard.hideLoadingMsg(); + }, 5000); + } + + switch (id) { + + case 'local': + ApiClient.refreshItem(currentItem.Id, { + Recursive: true, + ImageRefreshMode: 'None', + MetadataRefreshMode: 'ValidationOnly', + ReplaceAllImages: false, + ReplaceAllMetadata: false + }); + break; + case 'missing': + ApiClient.refreshItem(currentItem.Id, { + Recursive: true, + ImageRefreshMode: 'FullRefresh', + MetadataRefreshMode: 'FullRefresh', + ReplaceAllImages: false, + ReplaceAllMetadata: false + }); + break; + case 'full': + ApiClient.refreshItem(currentItem.Id, { + Recursive: true, + ImageRefreshMode: 'FullRefresh', + MetadataRefreshMode: 'FullRefresh', + ReplaceAllImages: false, + ReplaceAllMetadata: true + }); + break; + default: + break; + } + } + }); + + }); + + } + + function showMoreMenu(context, button) { + + var items = []; + + items.push({ + name: Globalize.translate('ButtonIdentify'), + id: 'identify', + ironIcon: 'info' + }); + + items.push({ + name: Globalize.translate('ButtonRefresh'), + id: 'refresh', + ironIcon: 'refresh' + }); + + require(['actionsheet'], function (actionsheet) { + + actionsheet.show({ + items: items, + positionTo: button, + callback: function (id) { + + switch (id) { + + case 'identify': + LibraryBrowser.identifyItem(currentItem.Id); + break; + case 'refresh': + showRefreshMenu(context, button); + break; + default: + break; + } + } + }); + + }); + + } + + function onWebSocketMessageReceived(e, data) { + + var msg = data; + + if (msg.MessageType === "LibraryChanged") { + + if (msg.Data.ItemsUpdated.indexOf(currentItem.Id) != -1) { + + console.log('Item updated - reloading metadata'); + reload(currentContext, currentItem.Id); + } + } + } + + function bindItemChanged(context) { + + Events.on(ApiClient, "websocketmessage", onWebSocketMessageReceived); + } + + function unbindItemChanged(context) { + + Events.off(ApiClient, "websocketmessage", onWebSocketMessageReceived); + } + function init(context) { $('.btnCancel', context).on('click', function () { @@ -266,6 +410,11 @@ closeDialog(false); }); + context.querySelector('.btnMore').addEventListener('click', function (e) { + + showMoreMenu(context, e.target); + }); + context.querySelector('.btnHeaderSave').addEventListener('click', function (e) { context.querySelector('.btnSave').click(); @@ -300,6 +449,11 @@ editPerson(context, {}, -1); }); + + // For now this is only supported in dialog mode because we have a way of knowing when it closes + if (currentContext.tagName == 'PAPER-DIALOG') { + bindItemChanged(context); + } } function getItem(itemId) { @@ -1074,16 +1228,43 @@ paperDialogHelper.open(dlg); dlg.addEventListener('iron-overlay-closed', function () { + bindItemChanged(context); resolve(); }); - currentDialog = dlg; + currentContext = dlg; init(dlg); reload(dlg, itemId); } + xhr.send(); + }); + }, + + embed: function (elem, itemId) { + return new Promise(function (resolve, reject) { + + Dashboard.showLoadingMsg(); + + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'components/metadataeditor/metadataeditor.template.html', true); + + xhr.onload = function (e) { + + var template = this.response; + + elem.innerHTML = Globalize.translateDocument(template); + + elem.querySelector('.btnCancel').classList.add('hide'); + + currentContext = elem; + + init(elem); + reload(elem, itemId); + } + xhr.send(); }); } diff --git a/dashboard-ui/components/metadataeditor/metadataeditor.template.html b/dashboard-ui/components/metadataeditor/metadataeditor.template.html index b505070181..39ee379a58 100644 --- a/dashboard-ui/components/metadataeditor/metadataeditor.template.html +++ b/dashboard-ui/components/metadataeditor/metadataeditor.template.html @@ -3,10 +3,13 @@