Skip to content

Commit

Permalink
Remove initializeExternalTypeSelector and associated inline JS
Browse files Browse the repository at this point in the history
  • Loading branch information
smellsblue committed Jun 28, 2024
1 parent 9e164d5 commit 59038ab
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 29 deletions.
9 changes: 8 additions & 1 deletion app/javascript/stockaid/donations.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ $(document).on("change", "#donor-selector", function(event) {
case "new":
var content = tmpl("new-donor-template", {});
$("#new-donor-fields").html(content).show();
return initializeExternalTypeSelector();

$("#external-type").select2({
placeholder: "Select a type",
theme: "bootstrap",
width: "100%"
});

return;
default:
content = tmpl("existing-donor-template", option.data());
return $("#existing-donor-fields").html(content).show();
Expand Down
17 changes: 7 additions & 10 deletions app/javascript/stockaid/external_type_select2.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
expose("initializeExternalTypeSelector", () => $(document).ready(() => $("#external-type").select2({
placeholder: "Select a type",
theme: "bootstrap",
width: "100%"
})));
$(document).on("turbolinks:load", () => {
$("#external-type").select2({
placeholder: "Select a type",
theme: "bootstrap",
width: "100%"
});
});
4 changes: 0 additions & 4 deletions app/views/donors/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
<% content_for :content_size, "col-sm-9 col-md-10" %>
<% content_for :content do %>
<%= javascript_tag do %>
initializeExternalTypeSelector();
<% end %>
<%= form_for @donor, data: { guarded: true } do |f| %>
<div class="row">
<%= render partial: "donors/donor_fields", locals: { donor: @donor, fields: f } %>
Expand Down
2 changes: 0 additions & 2 deletions app/views/donors/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<% content_for :content do %>
<%= javascript_tag do %>
initializeExternalTypeSelector();

function onExternalIdChange() {
var value = $(this).val();
$("#save_and_export").prop("disabled", value != "");
Expand Down
4 changes: 0 additions & 4 deletions app/views/organizations/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
<% content_for :content_size, "col-sm-9 col-md-10" %>
<% content_for :content do %>
<%= javascript_tag do %>
initializeExternalTypeSelector();
<% end %>
<%= form_for @organization, data: { guarded: true } do |f| %>
<fieldset id="organization_info">
<% if current_user.can_update_organization_external_and_admin_details? %>
Expand Down
2 changes: 0 additions & 2 deletions app/views/organizations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<% content_for :content do %>
<%= javascript_tag do %>
initializeExternalTypeSelector();

function onExternalIdChange() {
var value = $(this).val();
$("#save_and_export").prop("disabled", value != "");
Expand Down
4 changes: 0 additions & 4 deletions app/views/vendors/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
<% content_for :content_size, "col-sm-9 col-md-10" %>
<% content_for :content do %>
<%= javascript_tag do %>
initializeExternalTypeSelector();
<% end %>
<%= form_for @vendor, data: { guarded: true } do |f| %>
<%= render partial: "vendors/vendor_form", locals: { fields: f } %>
<%= f.submit "Save", class: "btn btn-primary" %>
Expand Down
2 changes: 0 additions & 2 deletions app/views/vendors/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<% content_for :content do %>
<%= javascript_tag do %>
initializeExternalTypeSelector();

function onExternalIdChange() {
var value = $(this).val();
$("#save_and_export").prop("disabled", value != "");
Expand Down

0 comments on commit 59038ab

Please sign in to comment.