remove nested form from library create dialog

This commit is contained in:
dkanada 2019-05-07 12:58:16 -07:00
parent b41ae5f483
commit a5bad54c51
2 changed files with 30 additions and 34 deletions

View File

@ -1,10 +1,7 @@
define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionseditor/libraryoptionseditor", "emby-toggle", "emby-input", "emby-select", "paper-icon-button-light", "listViewStyle", "formDialogStyle", "emby-button", "flexStyles"], function(loading, dialogHelper, dom, $, libraryoptionseditor) { define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionseditor/libraryoptionseditor", "emby-toggle", "emby-input", "emby-select", "paper-icon-button-light", "listViewStyle", "formDialogStyle", "emby-button", "flexStyles"], function(loading, dialogHelper, dom, $, libraryoptionseditor) {
"use strict"; "use strict";
function onSubmit(e) { function onAddLibrary() {
e.preventDefault();
e.stopPropagation();
if (isCreating) return false; if (isCreating) return false;
if (pathInfos.length == 0) { if (pathInfos.length == 0) {
@ -20,10 +17,9 @@ define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionsed
isCreating = true; isCreating = true;
loading.show(); loading.show();
var form = this; var dlg = dom.parentWithClass(this, "dlg-librarycreator");
var dlg = $(form).parents(".dialog")[0]; var name = $("#txtValue", dlg).val();
var name = $("#txtValue", form).val(); var type = $("#selectCollectionType", dlg).val();
var type = $("#selectCollectionType", form).val();
if (type == "mixed") type = null; if (type == "mixed") type = null;
var libraryOptions = libraryoptionseditor.getLibraryOptions(dlg.querySelector(".libraryOptions")); var libraryOptions = libraryoptionseditor.getLibraryOptions(dlg.querySelector(".libraryOptions"));
libraryOptions.PathInfos = pathInfos; libraryOptions.PathInfos = pathInfos;
@ -73,7 +69,7 @@ define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionsed
}); });
page.querySelector(".btnAddFolder").addEventListener("click", onAddButtonClick); page.querySelector(".btnAddFolder").addEventListener("click", onAddButtonClick);
page.querySelector("form").addEventListener("submit", onSubmit); page.querySelector(".btnSubmit").addEventListener("click", onAddLibrary);
page.querySelector(".folderList").addEventListener("click", onRemoveClick); page.querySelector(".folderList").addEventListener("click", onRemoveClick);
page.querySelector(".chkAdvanced").addEventListener("change", onToggleAdvancedChange); page.querySelector(".chkAdvanced").addEventListener("change", onToggleAdvancedChange);
} }
@ -111,10 +107,10 @@ define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionsed
function addMediaLocation(page, path, networkSharePath) { function addMediaLocation(page, path, networkSharePath) {
var pathLower = path.toLowerCase(); var pathLower = path.toLowerCase();
var path = pathInfos.filter(function(p) { var pathFilter = pathInfos.filter(function(p) {
return p.Path.toLowerCase() == pathLower; return p.Path.toLowerCase() == pathLower;
}); });
if (path.length === 0) { if (!pathFilter.length) {
var pathInfo = { var pathInfo = {
Path: path Path: path
}; };

View File

@ -5,39 +5,39 @@
<div class="formDialogContent scrollY" style="padding-top:2em;"> <div class="formDialogContent scrollY" style="padding-top:2em;">
<div class="dialogContentInner dialog-content-centered"> <div class="dialogContentInner dialog-content-centered">
<form style="margin:auto;"> <div class="inputContainer" style="text-align:right;">
<div class="inputContainer" style="text-align:right;"> <label style="width:auto;">
<label style="width:auto;"> <input is="emby-toggle" type="checkbox" class="chkAdvanced noautofocus" />
<input is="emby-toggle" type="checkbox" class="chkAdvanced noautofocus" /> <span>${ShowAdvancedSettings}</span>
<span>${ShowAdvancedSettings}</span> </label>
</label> </div>
</div>
<div id="fldCollectionType" class="selectContainer"> <div id="fldCollectionType" class="selectContainer">
<select is="emby-select" id="selectCollectionType" data-mini="true" required="required" label="${LabelContentType}"></select> <select is="emby-select" id="selectCollectionType" data-mini="true" required="required" label="${LabelContentType}"></select>
<div class="collectionTypeFieldDescription fieldDescription"> <div class="collectionTypeFieldDescription fieldDescription">
</div>
</div> </div>
</div>
<div class="inputContainer"> <div class="inputContainer">
<input is="emby-input" type="text" id="txtValue" required="required" label="${LabelDisplayName}" /> <input is="emby-input" type="text" id="txtValue" required="required" label="${LabelDisplayName}" />
</div> </div>
<div class="folders">
<div style="display: flex; align-items: center;"> <div style="display: flex; align-items: center;">
<h1 style="margin: .5em 0;">${HeadersFolders}</h1> <h1 style="margin: .5em 0;">${HeadersFolders}</h1>
<button is="emby-button" type="button" class="fab btnAddFolder submit" style="margin-left:1em;" title="${ButtonAdd}"> <button is="emby-button" type="button" class="fab btnAddFolder submit" style="margin-left:1em;" title="${ButtonAdd}">
<i class="md-icon">add</i> <i class="md-icon">add</i>
</button> </button>
<div class="paperList folderList hide" style="margin-bottom:2em;"></div>
</div> </div>
<div class="paperList folderList hide" style="margin-bottom:2em;"></div>
</div>
<div class="libraryOptions"></div> <div class="libraryOptions"></div>
<div class="formDialogFooter">
<button is="emby-button" type="submit" class="raised button-submit block formDialogFooterItem">
<span>${ButtonOk}</span>
</button>
</div>
</form>
</div> </div>
</div> </div>
<div class="formDialogFooter">
<button is="emby-button" type="button" class="raised btnSubmit button-submit block formDialogFooterItem">
<span>${ButtonOk}</span>
</button>
</div>