Skip to content

Commit

Permalink
update fixed checkbox when environment variable changes (#3842)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashton22305 authored Oct 9, 2024
1 parent 7af67d2 commit eb9ce2e
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions apps/dashboard/app/javascript/launcher_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit eb9ce2e

Please sign in to comment.