Skip to content

Commit

Permalink
Fix/my nonprofit bug 02042024 (#545)
Browse files Browse the repository at this point in the history
* Solve google maps async load warning

* Prevent method call on nil object

* Solve event deprecation and missing target

* Fix seeds

* Add svg extension
  • Loading branch information
aliciapaz authored Apr 5, 2024
1 parent d4fb9e4 commit 87d7c9a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
2 changes: 2 additions & 0 deletions app/javascript/controllers/modal_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ export default class extends Controller {
}

displayAppliedIcon() {
if (this.appliedIcon === null) { return }

if (this.modalCheckboxes.some((check) => check.checked === true)) {
this.appliedIcon.classList.remove("hidden");
this.appliedIcon.classList.add("inline-block");
Expand Down
6 changes: 4 additions & 2 deletions app/javascript/controllers/places_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ export default class extends Controller {
})

function success (position) {
document.getElementById('search_lat').value = position.coords.latitude;
document.getElementById('search_lon').value = position.coords.longitude;
if (document.getElementById('search_lat') && document.getElementById('search_lon')) {
document.getElementById('search_lat').value = position.coords.latitude;
document.getElementById('search_lon').value = position.coords.longitude;
}
}

if(!navigator.geolocation) {
Expand Down
10 changes: 6 additions & 4 deletions app/javascript/packs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ ActiveStorage.start()
import "controllers"

window.initMap = function (...args) {
const event = document.createEvent("Events")
event.initEvent("google-maps-callback", true, true)
event.args = args
window.dispatchEvent(event)
const event = new CustomEvent("google-maps-callback", {
detail: args,
bubbles: true,
cancelable: true
});
window.dispatchEvent(event);
}

document.addEventListener("turbo:load", function (event) {
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbo-track': 'reload' %>
<%= stylesheet_pack_tag 'application', media: 'all', 'data-turbo-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbo-track': 'reload' %>
<%= javascript_include_tag 'https://maps.googleapis.com/maps/api/js?key='+Rails.application.credentials.dig(:google_api_key)+'&libraries=places&callback=initMap', 'data-turbolinks-eval': 'false' %>
<%= javascript_include_tag 'https://maps.googleapis.com/maps/api/js?key='+Rails.application.credentials.dig(:google_api_key)+'&loading=async&libraries=places&callback=initMap', 'data-turbolinks-eval': 'false' %>
<script>
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
Expand Down
10 changes: 4 additions & 6 deletions app/views/shared/_main_modal.html.erb
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
<div data-controller="main-modal" data-action="turbo:submit-end->main-modal#closeAfterSubmit">
<%# Backdrop %>
<div aria-hidden="true" class="fixed z-40 inset-0 bg-gray-500 bg-opacity-75 opacity-100" data-main-modal-target="backdrop"></div>

<div aria-hidden="true" class="fixed inset-0 z-40 bg-gray-500 bg-opacity-75 opacity-100" data-main-modal-target="backdrop"></div>
<%# Dialog %>
<div
role="dialog"
aria-modal="true"
class="fixed positioned-center z-40 w-11/12 max-w-sm pt-9 px-4 pb-4 rounded-lg overflow-y-auto bg-white md:px-8 md:pb-8"
class="overflow-y-auto fixed z-40 px-4 pt-9 pb-4 w-11/12 max-w-sm bg-white rounded-lg positioned-center md:px-8 md:pb-8"
data-main-modal-target="dialog">
<%# Close %>
<button
type="button"
data-action="click->main-modal#close"
class="absolute top-2 right-2 p-2 rounded-md text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">
class="absolute top-2 right-2 p-2 text-gray-400 rounded-md hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">
<span class="sr-only">Close</span>
<%= inline_svg_tag "x-icon", class: "w-3.5 h-3.5", aria_hidden: true %>
<%= inline_svg_tag "x-icon.svg", class: "w-3.5 h-3.5", aria_hidden: true %>
</button>

<%= yield %>
</div>
</div>
4 changes: 4 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
password_confirmation: "testing"
)
end
User.first.confirm

# Causes and Services
Rake::Task["populate:seed_causes_and_services"].invoke
Expand All @@ -44,6 +45,9 @@
# Populate organizations and locations
SpreadsheetParse.new.import("./lib/assets/GC_Dummy_Data_for_DB.xlsx")

# Create Organization Admin
OrganizationAdmin.find_or_create_by!(organization: Organization.first, user: User.first)

# Phone Number
PhoneNumber.find_or_create_by!(location: Location.first) do |phone|
phone.number = "222-333-4444"
Expand Down

0 comments on commit 87d7c9a

Please sign in to comment.