diff --git a/dashboard-ui/components/medialibraryeditor/medialibraryeditor.js b/dashboard-ui/components/medialibraryeditor/medialibraryeditor.js new file mode 100644 index 0000000000..6da4a152ff --- /dev/null +++ b/dashboard-ui/components/medialibraryeditor/medialibraryeditor.js @@ -0,0 +1,114 @@ +define([], function () { + + var currentDeferred; + var hasChanges; + var currentOptions; + + function onSubmit() { + + var form = this; + var dlg = $(form).parents('paper-dialog')[0]; + + ApiClient.addVirtualFolder($('#txtValue', form).val(), $('#selectCollectionType', form).val(), currentOptions.refresh).done(function () { + + hasChanges = true; + PaperDialogHelper.close(dlg); + + }).fail(function () { + + Dashboard.showError(Globalize.translate('DefaultErrorMessage')); + }); + + return false; + } + + function getCollectionTypeOptionsHtml(collectionTypeOptions) { + + return collectionTypeOptions.filter(function (i) { + + return i.isSelectable !== false; + + }).map(function (i) { + + return ''; + + }).join(""); + } + + function initEditor(page, collectionTypeOptions) { + + $('#selectCollectionType', page).html(getCollectionTypeOptionsHtml(collectionTypeOptions)).val(''); + + $('form', page).off('submit', onSubmit).on('submit', onSubmit); + } + + function onDialogClosed() { + + $(this).remove(); + Dashboard.hideLoadingMsg(); + currentDeferred.resolveWith(null, [hasChanges]); + } + + function editor() { + + var self = this; + + self.show = function (options) { + + var deferred = DeferredBuilder.Deferred(); + + currentOptions = options; + currentDeferred = deferred; + hasChanges = false; + + require(['components/paperdialoghelper'], function () { + + HttpClient.send({ + + type: 'GET', + url: 'components/medialibraryeditor/medialibraryeditor.template.html' + + }).done(function (template) { + + var dlg = PaperDialogHelper.createDialog({ + size: 'small', + theme: 'a' + }); + + var html = ''; + html += '

'; + html += ''; + + var title = Globalize.translate('ButtonAddMediaLibrary'); + + html += '
' + title + '
'; + html += '

'; + + html += '
'; + html += Globalize.translateDocument(template); + html += '
'; + + dlg.innerHTML = html; + document.body.appendChild(dlg); + + var editorContent = dlg.querySelector('.editorContent'); + initEditor(editorContent, options.collectionTypeOptions); + + $(dlg).on('iron-overlay-closed', onDialogClosed); + + PaperDialogHelper.openWithHash(dlg, 'medialibraryeditor'); + + $('.btnCloseDialog', dlg).on('click', function () { + + PaperDialogHelper.close(dlg); + }); + }); + + }); + + return deferred.promise(); + }; + } + + return editor; +}); \ No newline at end of file diff --git a/dashboard-ui/components/medialibraryeditor/medialibraryeditor.template.html b/dashboard-ui/components/medialibraryeditor/medialibraryeditor.template.html new file mode 100644 index 0000000000..b7347dc14c --- /dev/null +++ b/dashboard-ui/components/medialibraryeditor/medialibraryeditor.template.html @@ -0,0 +1,21 @@ +
+
+
+ + +
+
+
+

+ +

+
+
+ +
+
\ No newline at end of file diff --git a/dashboard-ui/css/card.css b/dashboard-ui/css/card.css index a411e009cb..ca787fb0d4 100644 --- a/dashboard-ui/css/card.css +++ b/dashboard-ui/css/card.css @@ -308,6 +308,10 @@ background-position: center center; } +.ui-body-b .iconCardImage { + color: #fff; +} + .iconCardImage { display: flex; align-items: center; diff --git a/dashboard-ui/library.html b/dashboard-ui/library.html index 7385ffad83..a490fa5887 100644 --- a/dashboard-ui/library.html +++ b/dashboard-ui/library.html @@ -4,7 +4,7 @@ ${TitleMediaLibrary} -
+
@@ -26,37 +26,6 @@
-
diff --git a/dashboard-ui/scripts/medialibrarypage.js b/dashboard-ui/scripts/medialibrarypage.js index 8689de943d..a0e02867c6 100644 --- a/dashboard-ui/scripts/medialibrarypage.js +++ b/dashboard-ui/scripts/medialibrarypage.js @@ -74,63 +74,44 @@ reloadLibrary(page); } - function getTextValue(header, label, initialValue, showCollectionType, callback) { - - var page = $.mobile.activePage; - - var popup = $('#popupEnterText', page); - - $('h3', popup).html(header); - $('#lblValue', popup).html(label); - $('#txtValue', popup).val(initialValue); - - if (showCollectionType) { - $('#fldCollectionType', popup).show(); - $('#selectCollectionType', popup).attr('required', 'required'); - } else { - $('#fldCollectionType', popup).hide(); - $('#selectCollectionType', popup).removeAttr('required'); - } - - $('#selectCollectionType', popup).html(getCollectionTypeOptionsHtml()).val(''); - - popup.on("popupafterclose", function () { - $(this).off("popupafterclose").off("click"); - $('#textEntryForm', this).off("submit"); - }).popup("open"); - - $('#textEntryForm', popup).on('submit', function () { - - if (callback) { - - if (showCollectionType) { - - var collectionType = $('#selectCollectionType', popup).val(); - - // The server expects an empty value for mixed - if (collectionType == 'mixed') { - collectionType = ''; - } - - callback($('#txtValue', popup).val(), collectionType); - } else { - callback($('#txtValue', popup).val()); - } - - } - - return false; - }); - } - function addVirtualFolder(page) { - getTextValue(Globalize.translate('HeaderAddMediaFolder'), Globalize.translate('LabelName'), "", true, function (name, type) { + //$('#textEntryForm', popup).on('submit', function () { - var refreshAfterChange = shouldRefreshLibraryAfterChanges(); + // if (callback) { - ApiClient.addVirtualFolder(name, type, refreshAfterChange).done(processOperationResult); + // if (showCollectionType) { + // var collectionType = $('#selectCollectionType', popup).val(); + + // // The server expects an empty value for mixed + // if (collectionType == 'mixed') { + // collectionType = ''; + // } + + // callback($('#txtValue', popup).val(), collectionType); + // } else { + // callback($('#txtValue', popup).val()); + // } + + // } + + // return false; + //}); + + require(['medialibraryeditor'], function (medialibraryeditor) { + + new medialibraryeditor().show({ + + collectionTypeOptions: getCollectionTypeOptions(), + refresh: shouldRefreshLibraryAfterChanges() + + }).done(function (hasChanges) { + + if (hasChanges) { + reloadLibrary(page); + } + }); }); } @@ -280,19 +261,6 @@ Dashboard.hideLoadingMsg(); } - function getCollectionTypeOptionsHtml() { - - return getCollectionTypeOptions().filter(function (i) { - - return i.isSelectable !== false; - - }).map(function (i) { - - return ''; - - }).join(""); - } - function getCollectionTypeOptions() { return [ @@ -347,7 +315,7 @@ var html = ''; - html += '
'; + html += '
'; html += '
'; html += '
'; diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 903c326c1a..bfa08d15b2 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -2062,6 +2062,7 @@ var AppInfo = {}; directorybrowser: 'components/directorybrowser/directorybrowser', collectioneditor: 'components/collectioneditor/collectioneditor', playlisteditor: 'components/playlisteditor/playlisteditor', + medialibraryeditor: 'components/medialibraryeditor/medialibraryeditor', howler: 'bower_components/howler.js/howler.min', dragula: 'bower_components/dragula.js/dist/dragula.min' }; diff --git a/dashboard-ui/wizardlibrary.html b/dashboard-ui/wizardlibrary.html index 3f527e1302..4c297af607 100644 --- a/dashboard-ui/wizardlibrary.html +++ b/dashboard-ui/wizardlibrary.html @@ -4,7 +4,7 @@ Emby -
+
@@ -19,38 +19,7 @@
- - +