diff --git a/apps/dashboard/app/javascript/launcher_edit.js b/apps/dashboard/app/javascript/launcher_edit.js index 013a2c3d58..728d543865 100644 --- a/apps/dashboard/app/javascript/launcher_edit.js +++ b/apps/dashboard/app/javascript/launcher_edit.js @@ -166,16 +166,38 @@ function addInProgressField(event) { function updateAutoEnvironmentVariable(event) { const aev_name = event.target.value; const labelString = event.target.dataset.labelString; + const idString = `launcher_auto_environment_variable_${aev_name}`; + const nameString = `launcher[auto_environment_variable_${aev_name}]`; var input_field = event.target.parentElement.children[2].children[1]; input_field.removeAttribute('readonly'); - input_field.id = `launcher_auto_environment_variable_${aev_name}`; - input_field.name = `launcher[auto_environment_variable_${aev_name}]`; + input_field.id = idString; + input_field.name = nameString; if (labelString.match(/Environment( |\s)Variable/)) { const label_field = event.target.parentElement.children[2].children[0]; label_field.innerHTML = `Environment Variable: ${aev_name}`; } + + // Update the checkbox so that environment variables can be fixed when created + let fixedBoxGroup = event.target.parentElement.children[3].children[0].children[0]; + + let checkbox = fixedBoxGroup.children[0]; + checkbox.id = `${idString}_fixed`; + checkbox.name = `launcher[auto_environment_variable_${aev_name}_fixed]`; + checkbox.setAttribute('data-fixed-toggler', idString); + + // Update hidden field if attribute is already fixed, otherwise just update label + let labelIndex = 2; + if(fixedBoxGroup.children.length == 3) { + let hiddenField = fixedBoxGroup.children[1]; + hiddenField.name = nameString; + } else { + labelIndex = 1; + } + + let fixedLabel = fixedBoxGroup.children[labelIndex]; + fixedLabel.setAttribute('for', `${idString}_fixed`); } function fixExcludeBasedOnSelect(selectElement) {