diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 5b3a9c5..fed9ee3 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -29,6 +29,10 @@ $weight-bold: 400; @import "checkmark-icon"; @import './demo'; +.field_with_errors input { + border-color: $red; +} + .is-logo { font-family: $family-sans-serif; color: $grey; @@ -124,6 +128,10 @@ Colours .backend-logo { white-space: nowrap; + img { + height: 30px; + vertical-align: text-bottom; + } } .features .columns { @@ -137,13 +145,6 @@ Colours margin-top: 3em; } -.tag-line { - img { - height: 30px; - vertical-align: text-bottom; - } -} - .call-to-action { margin-top: 2em; } diff --git a/app/controllers/forms_controller.rb b/app/controllers/forms_controller.rb index 22b7850..8b1495c 100644 --- a/app/controllers/forms_controller.rb +++ b/app/controllers/forms_controller.rb @@ -5,7 +5,7 @@ class FormsController < ApplicationController layout 'submission', only: [:form] def new - @form = current_user.forms.build + @form = current_user.forms.build(backend_name: 'google_sheets') end def show @@ -40,13 +40,12 @@ class FormsController < ApplicationController end def form - @form = Form.find_by!(token: params[:id]) end private def form_params - params.require(:form).permit(:title, :thank_you_url) + params.require(:form).permit(:title, :thank_you_url, :backend_name, :airtable_table, :airtable_api_key, :airtable_app_key) end end diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 38aa7c6..5aee77c 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -12,6 +12,7 @@ require('burger_menu'); require('tinyforms'); require('demo'); require('backend_typed'); +require('tabs'); // Uncomment to copy all static images under ../images to the output folder and reference // them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>) diff --git a/app/javascript/tabs.js b/app/javascript/tabs.js new file mode 100644 index 0000000..3ece03b --- /dev/null +++ b/app/javascript/tabs.js @@ -0,0 +1,16 @@ +document.addEventListener("turbolinks:load", function () { + const tabLinks = document.querySelectorAll('.tabs a[data-target]'); + tabLinks.forEach(el => { + el.addEventListener('click', (e) => { + e.preventDefault(); + // hide alll + tabLinks.forEach(link => { + link.closest('li').classList.remove('is-active'); + document.getElementById(link.dataset.target).classList.add('is-hidden') + }); + const target = document.getElementById(el.dataset.target); + target.classList.remove('is-hidden'); + el.closest('li').classList.add('is-active'); + }, true); + }); +}); diff --git a/app/models/form.rb b/app/models/form.rb index b4bcd37..6ad6d99 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -68,5 +68,6 @@ class Form < ApplicationRecord def insert_defaults self.backend_name ||= airtable_app_key.present? ? 'airtable' : 'google_sheets' + self.title ||= airtable_table end end diff --git a/app/views/forms/new.html.erb b/app/views/forms/new.html.erb index ac8f1aa..397d969 100644 --- a/app/views/forms/new.html.erb +++ b/app/views/forms/new.html.erb @@ -2,10 +2,87 @@
-
-

Create a new form

+
+

Create a new form

- <%= render 'form', form: @form %> + + +
+ <%= form_for @form, local: true do |f| %> + <%= f.hidden_field :backend_name, value: 'google_sheets' %> +
+ +
+ <%= f.text_field :title, class: 'input', placeholder: '', autocomplete: 'off' %> +
+

Give your document a name.

+
+ +
+
+ <%= f.submit class: 'button is-primary' %> +
+
+ <% end %> +
+ +
+

+ To connect a new online form with an Airtable document please first create the document on Airtable. +

+ <%= form_for @form, local: true do |f| %> + <%= f.hidden_field :backend_name, value: 'airtable' %> +
+ +
+ <%= f.text_field :airtable_table, class: 'input', placeholder: 'Table 1', autocomplete: 'off' %> +
+

The name of the table in your Airtable base. Your Airtable can have multiple tables/sheets. Which one do you want to use?

+
+ +
+ +
+ <%= f.text_field :airtable_api_key, class: 'input', placeholder: '', autocomplete: 'off' %> +
+

Your Airtable account API Key. You find this one on your Airtable account page.

+
+ +
+ +
+ <%= f.text_field :airtable_app_key, class: 'input', placeholder: '', autocomplete: 'off' %> +
+

The application key of your Airtable document. You find this one on the API page of your Airtable base.

+
+ +
+
+ <%= f.submit class: 'button is-primary' %> +
+
+ <% end %> +
+ +
+

+ Do you need help? <%= link_to 'Let us know!', help_url %>. +