Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PM - Update fixed checkbox when environment variable changes #3842

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
var 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/)) {
var 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
Loading