Skip to content

Commit

Permalink
hound cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
Tooyosi committed Oct 7, 2024
1 parent 0eedef7 commit b03e84d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
37 changes: 24 additions & 13 deletions app/assets/javascripts/views/forms/form.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
document.addEventListener("DOMContentLoaded", function () {
const form = document.querySelector("form");
const prefix = 'reducer';
const is_reducer_form = form?.id.includes(prefix);

const toggle_input = function(value){
const is_subject = value.includes('subject');
let hidden_input_id = is_subject ? 'user_reducer_keys' : 'subject_reducer_keys';
let visible_input_id = hidden_input_id.includes('user_reducer_keys') ? 'subject_reducer_keys' : 'user_reducer_keys';

document.getElementById(hidden_input_id)?.classList.remove('hidden');

document.getElementById(visible_input_id)?.classList.add('hidden');
var form = document.querySelector("form");
var prefix = 'reducer';
var is_reducer_form = false
if(form){
is_reducer_form = form.id.includes(prefix);
}


var toggle_input = function(value){
var is_subject = value.includes('subject');
var hidden_input_id = is_subject ? 'user_reducer_keys' : 'subject_reducer_keys';
var visible_input_id = hidden_input_id.includes('user_reducer_keys') ? 'subject_reducer_keys' : 'user_reducer_keys';

var hidden_input = document.getElementById(hidden_input_id);

if(hidden_input){
hidden_input.classList.remove('hidden');
};

var visible_input = document.getElementById(visible_input_id);
if(visible_input){
visible_input.classList.add('hidden');
};
};

if (is_reducer_form) {
const reducer_topic = document.getElementById("reducer_topic");
var reducer_topic = document.getElementById("reducer_topic");

toggle_input(reducer_topic.value);

Expand Down
1 change: 0 additions & 1 deletion app/controllers/reducers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,5 @@ def remove_unwanted_config_key(param_object)
elsif
param_object[:user_reducer_keys] = nil
end
@reducer.save if @reducer
end
end
2 changes: 1 addition & 1 deletion config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
Rails.application.config.assets.precompile += %w( views/forms/form.js )
Rails.application.config.assets.precompile += %w[views/forms/form.js]

0 comments on commit b03e84d

Please sign in to comment.