Skip to content

Commit

Permalink
Use our form builder everywhere by default
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Jul 26, 2024
1 parent 208e00e commit a7b4351
Show file tree
Hide file tree
Showing 22 changed files with 22 additions and 21 deletions.
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class ApplicationController < ActionController::Base
# See https://github.com/heartcombo/devise/wiki/How-To:-%5BRedirect-back-to-current-page-after-sign-in,-sign-out,-sign-up,-update%5D
before_action :store_user_location!, if: :storable_location?

default_form_builder FormBuilders::Tailwind

sig { void }
def authenticate_active_admin_user!
authenticate_user!
Expand Down
1 change: 0 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ def pa_button_to(name, path = nil, options = {}, &block)
end
form_with(
url: url_for(path),
builder: FormBuilders::Tailwind,
class: options.delete(:form_class),
method: options.delete(:method),
data: options.delete(:data)
Expand Down
2 changes: 1 addition & 1 deletion app/views/alerts/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</div>

<div class="pb-12 border-b text-light-grey">
<%= form_with model: [:profile, @alert], builder: FormBuilders::Tailwind, class: "mt-5" do |f| %>
<%= form_with model: [:profile, @alert], class: "mt-5" do |f| %>
<%= f.label :radius_meters, "Alert distance" %>
<div class="flex flex-col gap-4 mt-2" x-data="{radius_meters: <%= j(@alert.radius_meters) %>}">
<%= f.select :radius_meters,
Expand Down
2 changes: 1 addition & 1 deletion app/views/alerts/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= render HeadingComponent.new(tag: :h2).with_content("Create new alert") %>
<%= form_with model: [:profile, @alert], builder: FormBuilders::Tailwind, class: "mt-12" do |f| %>
<%= form_with model: [:profile, @alert], class: "mt-12" do |f| %>
<div>
<%= f.label :address, "Enter a street address" %>
<%= f.street_address_field :address, class: "mt-2 block w-full" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/api_keys/non_commercials/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<section class="mt-8">
<%# TODO: Add errors on all fields in the form %>
<%= form_with builder: FormBuilders::Tailwind do |f| %>
<%= form_with do |f| %>
<div>
<%= f.label :organisation, "Organisation", class: "block mb-3" %>
<%= f.text_field :organisation, class: "block w-full" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/api_keys/paid/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<section class="mt-8">
<%# TODO: Add errors on all fields in the form %>
<%= form_with builder: FormBuilders::Tailwind do |f| %>
<%= form_with do |f| %>
<%# TODO: How to style fieldset and legend? %>
<fieldset>
<legend class="text-xl font-bold text-navy">Company</legend>
Expand Down
2 changes: 1 addition & 1 deletion app/views/applications/_address_search_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<%# Right now the styling is quite different from the other forms %>
<%# TODO: Reuse at least some of the styling from the default form builder %>
<div class="px-6 py-10 sm:py-16 bg-navy sm:px-28">
<%= form_with url: address_applications_path(anchor: "results"), method: :get, builder: FormBuilders::Tailwind, class: "gap-4 flex flex-col items-center" do |form| %>
<%= form_with url: address_applications_path(anchor: "results"), method: :get, class: "gap-4 flex flex-col items-center" do |form| %>
<%# Not using a heading here so that we don't mess up the heading order on different pages. %>
<%# TODO: There's probably something simpler and more sensible we should do here %>
<div class="max-w-xl text-3xl font-bold leading-tight text-center text-white sm:text-4xl font-display sm:leading-tight">
Expand Down
2 changes: 1 addition & 1 deletion app/views/applications/_create_alert_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= image_tag "bookmark.svg", alt: "", class: "mt-2 sm:mt-0" %>
<div class="flex flex-col gap-4 sm:flex-row sm:justify-between grow sm:items-center">
<p class="text-xl font-bold text-navy">Save this search as an email alert</p>
<%= form_with model: [:profile, alert], builder: FormBuilders::Tailwind do |f| %>
<%= form_with model: [:profile, alert] do |f| %>
<%= f.hidden_field :address %>
<%= f.hidden_field :radius_meters %>
<%= f.button "Save" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/applications/_create_alert_form_bigger.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
It only takes a moment.
</p>
<% else %>
<%= form_with model: [:profile, alert], builder: FormBuilders::Tailwind do |f| %>
<%= form_with model: [:profile, alert] do |f| %>
<p class="mt-2 mb-8 text-xl text-navy">
Save your search for applications within <%= meters_in_words(alert.radius_meters) %> of <%= alert.address %>?
</p>
Expand Down
2 changes: 1 addition & 1 deletion app/views/applications/search.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<%# TODO: This page needs a proper design %>

<%= form_with url: search_applications_path, method: :get, builder: FormBuilders::Tailwind, class: "my-24" do |f| %>
<%= form_with url: search_applications_path, method: :get, class: "my-24" do |f| %>
<%= f.text_field :q, value: @q, class: "block w-full", size: 50, autofocus: @applications.nil?, placeholder: "Tree work" %>
<div class="mt-5">
<%= f.button "Search" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/comments/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= form_with model: [application, comment], builder: FormBuilders::Tailwind do |f| %>
<%= form_with model: [application, comment] do |f| %>
<div>
<%= f.label :text, "Your comment" %>
<%= f.text_area :text,
Expand Down
2 changes: 1 addition & 1 deletion app/views/comments/preview.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</div>

<div class="mt-4">
<%= form_with(url: publish_application_comment_path(@comment), builder: FormBuilders::Tailwind) do %>
<%= form_with(url: publish_application_comment_path(@comment)) do %>
<%= render ButtonWithSideTextComponent.new(tag: :button, size: "xl", type: :primary) do |c| %>
Publish
<% c.with_side_text do %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/contact_messages/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= form_with model: contact_message, builder: FormBuilders::Tailwind do |f| %>
<%= form_with model: contact_message do |f| %>
<% if current_user.nil? %>
<div>
<%= f.label :name, "Your name", class: "block mb-3" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/confirmations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Resend confirmation instructions
<% end %>

<%= form_with model: resource, url: confirmation_path(resource_name), builder: FormBuilders::Tailwind do |f| %>
<%= form_with model: resource, url: confirmation_path(resource_name) do |f| %>
<div>
<%= f.label :email, class: "block" %>
<%= f.email_field :email, class: "mt-1 block w-full", autocomplete: "email", autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/passwords/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="max-w-lg mx-auto">
<%= render HeadingComponent.new(tag: :h1, extra_classes: "my-20 text-center").with_content("Create your new password") %>

<%= form_with model: resource, url: password_path(resource_name), method: :put, builder: FormBuilders::Tailwind do |f| %>
<%= form_with model: resource, url: password_path(resource_name), method: :put do |f| %>
<%= f.hidden_field :reset_password_token %>

<div class="flex flex-col items-center">
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/passwords/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<%= render HeadingComponent.new(tag: :h1, extra_classes: "my-20 text-center") do %>
Let's get you to create a new password. First we need to confirm you're you
<% end %>
<%= form_with model: resource, url: password_path(resource_name), builder: FormBuilders::Tailwind do |f| %>
<%= form_with model: resource, url: password_path(resource_name) do |f| %>
<div class="flex flex-col items-center">
<div class="w-full">
<%= f.label :email, class: "block" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/registrations/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= render HeadingComponent.new(tag: :h2, extra_classes: "pb-10").with_content("Edit your account") %>

<%= form_with model: resource, url: registration_path(resource_name), method: :put, builder: FormBuilders::Tailwind, class: "border-b border-light-grey pb-8" do |f| %>
<%= form_with model: resource, url: registration_path(resource_name), method: :put, class: "border-b border-light-grey pb-8" do |f| %>
<%# TODO: What actually goes here and is it needed on other devise forms? %>
<%= render "devise/shared/error_messages", resource: %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/registrations/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="max-w-lg mx-auto">
<%= render HeadingComponent.new(tag: :h1, extra_classes: "mt-20 mb-12 text-center").with_content("Create an account") %>

<%= form_with model: resource, url: registration_path(resource_name), builder: FormBuilders::Tailwind do |f| %>
<%= form_with model: resource, url: registration_path(resource_name) do |f| %>
<div>
<%= f.label :name, "Your full name", class: "block" %>
<%= f.text_field :name, class: "mt-1 block w-full", autofocus: true, autocomplete: "name", placeholder: "e.g. Jane Citizen" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/sessions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<%= render HeadingComponent.new(tag: :h1, extra_classes: "mt-20 mb-12 text-center") do %>
Sign in to Planning&nbsp;Alerts
<% end %>
<%= form_with model: resource, url: session_path(resource_name), builder: FormBuilders::Tailwind do |f| %>
<%= form_with model: resource, url: session_path(resource_name) do |f| %>
<%# TODO: Add error display and styling %>
<div class="flex flex-col items-center">
<div class="w-full">
Expand Down
2 changes: 1 addition & 1 deletion app/views/reports/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
you think the comment should be removed.
</p>

<%= form_with model: [@comment, @report], builder: FormBuilders::Tailwind, class: "mt-12" do |f| %>
<%= form_with model: [@comment, @report], class: "mt-12" do |f| %>
<div>
<%= f.label :details, "Why should the comment below be removed?" %>
<%= f.text_area :details, class: "block w-full mt-4", rows: 8 %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/activations/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="max-w-lg mx-auto">
<%= render HeadingComponent.new(tag: :h1, extra_classes: "my-20 text-center").with_content("Activate your account") %>

<%= form_with model: @user, url: users_activation_path, method: :put, builder: FormBuilders::Tailwind do |f| %>
<%= form_with model: @user, url: users_activation_path, method: :put do |f| %>
<%= f.hidden_field :reset_password_token %>

<div class="flex flex-col items-center">
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/activations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Activate your account
<% end %>

<%= form_with model: @user, url: users_activation_path, builder: FormBuilders::Tailwind do |f| %>
<%= form_with model: @user, url: users_activation_path do |f| %>
<div>
<%= f.label :email, class: "block" %>
<%= f.email_field :email, class: "mt-1 block w-full", autocomplete: "email", autofocus: true %>
Expand Down

0 comments on commit a7b4351

Please sign in to comment.