Skip to content

Commit

Permalink
Merge pull request #11 from div-yam/Preselect-project-launch-page
Browse files Browse the repository at this point in the history
Project is now preselected based on previously selected project when running new calculation
  • Loading branch information
RaphaelRobidas authored Jun 12, 2022
2 parents 4b2f35a + 533e59a commit e2d3d91
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions frontend/templates/frontend/launch.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@

function verify_form() {
$("#submit_button").addClass("is-loading");

//Adding the selected Project to localStorage on pressing Submit Button
choice = document.getElementById("calc_project");
localStorage.setItem("lastSelectedProject", choice.value);

data = $("#calcform").serializeArray(),

data.push({"name": "constraint_num", "value": constraint_num});
Expand Down Expand Up @@ -324,8 +329,7 @@
refresh_availabilities();
}

function project_selection_changed() {
choice = document.getElementById("calc_project");
function project_selection_changed(choice) {
field = document.getElementById("new_project_name_field");
if(choice.value == "New Project") {
field.style.display = "block";
Expand All @@ -343,6 +347,20 @@
}
}

function preselect_last_project() {
choice = document.getElementById("calc_project");
for(var i=0;i<choice.options.length;i++)
{
option = choice.options[i];
if(option.text == localStorage.getItem("lastSelectedProject") && option.text != "New Project")
{
option.setAttribute('selected', true);
project_selection_changed(option);
return;
}
}
}

function refresh_availabilities() {

full_options = document.querySelectorAll(".unavailable");
Expand Down Expand Up @@ -998,7 +1016,7 @@
<label class="label">Project</label>
<div class="control">
<div class="select" >
<select name="calc_project" onchange="project_selection_changed()" id="calc_project">
<select name="calc_project" onchange="project_selection_changed(this)" id="calc_project">
{% for proj in profile.project_set.all|dictsort:"name" %}
<option name="{{ proj }}">{{ proj }}</option>
{% endfor %}
Expand Down Expand Up @@ -1316,7 +1334,8 @@

$( document ).ready(function() {
{% if not ensemble and not structure %}
project_selection_changed();
preselect_last_project();
project_selection_changed(document.getElementById("calc_project"));
{% endif %}

refresh_presets();
Expand Down

0 comments on commit e2d3d91

Please sign in to comment.