diff --git a/src/components/medialibraryeditor/medialibraryeditor.js b/src/components/medialibraryeditor/medialibraryeditor.js index a1ee53f72b..8336f9e175 100644 --- a/src/components/medialibraryeditor/medialibraryeditor.js +++ b/src/components/medialibraryeditor/medialibraryeditor.js @@ -1,22 +1,22 @@ -define(["jQuery", "loading", "dialogHelper", "dom", "components/libraryoptionseditor/libraryoptionseditor", "emby-button", "listViewStyle", "paper-icon-button-light", "formDialogStyle", "emby-toggle", "flexStyles"], function(jQuery, loading, dialogHelper, dom, libraryoptionseditor) { +define(["jQuery", "loading", "dialogHelper", "dom", "components/libraryoptionseditor/libraryoptionseditor", "emby-button", "listViewStyle", "paper-icon-button-light", "formDialogStyle", "emby-toggle", "flexStyles"], function (jQuery, loading, dialogHelper, dom, libraryoptionseditor) { "use strict"; function onEditLibrary() { - if (isCreating) return false; + if (isCreating) { + return false; + } isCreating = true; loading.show(); - var dlg = dom.parentWithClass(this, "dlg-libraryeditor"); var libraryOptions = libraryoptionseditor.getLibraryOptions(dlg.querySelector(".libraryOptions")); libraryOptions = Object.assign(currentOptions.library.LibraryOptions || {}, libraryOptions); - - ApiClient.updateVirtualFolderOptions(currentOptions.library.ItemId, libraryOptions).then(function() { + ApiClient.updateVirtualFolderOptions(currentOptions.library.ItemId, libraryOptions).then(function () { hasChanges = true; isCreating = false; loading.hide(); dialogHelper.close(dlg); - }, function() { + }, function () { isCreating = false; loading.hide(); }); @@ -26,11 +26,11 @@ define(["jQuery", "loading", "dialogHelper", "dom", "components/libraryoptionsed function addMediaLocation(page, path, networkSharePath) { var virtualFolder = currentOptions.library; var refreshAfterChange = currentOptions.refresh; - ApiClient.addMediaPath(virtualFolder.Name, path, networkSharePath, refreshAfterChange).then(function() { + ApiClient.addMediaPath(virtualFolder.Name, path, networkSharePath, refreshAfterChange).then(function () { hasChanges = true; refreshLibraryFromServer(page); - }, function() { - require(["toast"], function(toast) { + }, function () { + require(["toast"], function (toast) { toast(Globalize.translate("ErrorAddingMediaPathToVirtualFolder")); }); }); @@ -41,11 +41,11 @@ define(["jQuery", "loading", "dialogHelper", "dom", "components/libraryoptionsed ApiClient.updateMediaPath(virtualFolder.Name, { Path: path, NetworkPath: networkSharePath - }).then(function() { + }).then(function () { hasChanges = true; refreshLibraryFromServer(page); - }, function() { - require(["toast"], function(toast) { + }, function () { + require(["toast"], function (toast) { toast(Globalize.translate("ErrorAddingMediaPathToVirtualFolder")); }); }); @@ -54,19 +54,20 @@ define(["jQuery", "loading", "dialogHelper", "dom", "components/libraryoptionsed function onRemoveClick(btnRemovePath, location) { var button = btnRemovePath; var virtualFolder = currentOptions.library; - require(["confirm"], function(confirm) { + + require(["confirm"], function (confirm) { confirm({ title: Globalize.translate("HeaderRemoveMediaLocation"), text: Globalize.translate("MessageConfirmRemoveMediaLocation"), confirmText: Globalize.translate("ButtonDelete"), primary: "delete" - }).then(function() { + }).then(function () { var refreshAfterChange = currentOptions.refresh; - ApiClient.removeMediaPath(virtualFolder.Name, location, refreshAfterChange).then(function() { + ApiClient.removeMediaPath(virtualFolder.Name, location, refreshAfterChange).then(function () { hasChanges = true; refreshLibraryFromServer(dom.parentWithClass(button, "dlg-libraryeditor")); - }, function() { - require(["toast"], function(toast) { + }, function () { + require(["toast"], function (toast) { toast(Globalize.translate("DefaultErrorMessage")); }); }); @@ -76,13 +77,19 @@ define(["jQuery", "loading", "dialogHelper", "dom", "components/libraryoptionsed function onListItemClick(e) { var listItem = dom.parentWithClass(e.target, "listItem"); + if (listItem) { var index = parseInt(listItem.getAttribute("data-index")); var pathInfos = (currentOptions.library.LibraryOptions || {}).PathInfos || []; var pathInfo = null == index ? {} : pathInfos[index] || {}; var originalPath = pathInfo.Path || (null == index ? null : currentOptions.library.Locations[index]); var btnRemovePath = dom.parentWithClass(e.target, "btnRemovePath"); - if (btnRemovePath) return void onRemoveClick(btnRemovePath, originalPath); + + if (btnRemovePath) { + onRemoveClick(btnRemovePath, originalPath); + return; + } + showDirectoryBrowser(dom.parentWithClass(listItem, "dlg-libraryeditor"), originalPath, pathInfo.NetworkPath); } } @@ -94,9 +101,11 @@ define(["jQuery", "loading", "dialogHelper", "dom", "components/libraryoptionsed html += '