From 94b027cc0557551adbd19b48fbefccfb124111b3 Mon Sep 17 00:00:00 2001 From: Bryan Rumsey Date: Thu, 27 Apr 2023 11:30:53 -0400 Subject: [PATCH] Fixed location select list for file select modal. --- client/pages/project-manager.js | 18 +++++++++--------- client/views/jstree-view.js | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/pages/project-manager.js b/client/pages/project-manager.js index 234669747..9f0024368 100644 --- a/client/pages/project-manager.js +++ b/client/pages/project-manager.js @@ -89,42 +89,42 @@ let ProjectManager = PageView.extend({ let self = this let mdlListEP = path.join(app.getApiPath(), 'project/add-existing-model') + "?path=" + self.model.directory; app.getXHR(mdlListEP, { - always: function (err, response, body) { + always: (err, response, body) => { let modal = $(modals.importModelHtml(body.files)).modal(); let okBtn = document.querySelector('#importModelModal .ok-model-btn'); let select = document.querySelector('#importModelModal #modelFileSelect'); let location = document.querySelector('#importModelModal #modelPathSelect'); - select.addEventListener("change", function (e) { + select.addEventListener("change", (e) => { okBtn.disabled = e.target.value && body.paths[e.target.value].length >= 2; if(body.paths[e.target.value].length >= 2) { - var locations = body.paths[e.target.value].map(function (path) { + var locations = body.paths[e.target.value].map((path) => { return ``; }); locations.unshift(``); locations = locations.join(" "); - $("#modelPathInput").find('option').remove().end().append(locations); + $(location).find('option').remove().end().append(locations); $("#location-container").css("display", "block"); }else{ $("#location-container").css("display", "none"); - $("#modelPathInput").find('option').remove().end(); + $(location).find('option').remove().end(); } }); - location.addEventListener("change", function (e) { + location.addEventListener("change", (e) => { okBtn.disabled = !Boolean(e.target.value); }); - okBtn.addEventListener("click", function (e) { + okBtn.addEventListener("click", (e) => { modal.modal('hide'); let mdlPath = body.paths[select.value].length < 2 ? body.paths[select.value][0] : location.value; let queryString = "?path=" + self.model.directory + "&mdlPath=" + mdlPath; let endpoint = path.join(app.getApiPath(), 'project/add-existing-model') + queryString app.postXHR(endpoint, null, { - success: function (err, response, body) { + success: (err, response, body) => { if(document.querySelector("#successModal")) { document.querySelector("#successModal").remove(); } let successModal = $(modals.successHtml(body.message)).modal(); }, - error: function (err, response, body) { + error: (err, response, body) => { if(document.querySelector("#errorModal")) { document.querySelector("#errorModal").remove(); } diff --git a/client/views/jstree-view.js b/client/views/jstree-view.js index a11020125..287a03e25 100644 --- a/client/views/jstree-view.js +++ b/client/views/jstree-view.js @@ -781,11 +781,11 @@ module.exports = View.extend({ }); locations.unshift(``); locations = locations.join(" "); - $("#modelPathSelect").find('option').remove().end().append(locations); + $(location).find('option').remove().end().append(locations); $("#location-container").css("display", "block"); }else{ $("#location-container").css("display", "none"); - $("#modelPathSelect").find('option').remove().end(); + $(location).find('option').remove().end(); } }); location.addEventListener("change", (e) => {