Skip to content

Commit

Permalink
Merge pull request #1455 from StochSS/hotfix-file-select-locations
Browse files Browse the repository at this point in the history
HOTFIX: File Select Location
  • Loading branch information
briandrawert authored May 1, 2023
2 parents ace3b6f + 94b027c commit bcb8872
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions client/pages/project-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<option>${path}</option>`;
});
locations.unshift(`<option value="">Select a location</option>`);
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();
}
Expand Down
4 changes: 2 additions & 2 deletions client/views/jstree-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,11 +781,11 @@ module.exports = View.extend({
});
locations.unshift(`<option value="">Select a location</option>`);
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) => {
Expand Down

0 comments on commit bcb8872

Please sign in to comment.