Skip to content

Commit

Permalink
Merge pull request #106 from OneBusAway/survey
Browse files Browse the repository at this point in the history
WIP - Survey Features
  • Loading branch information
aaronbrethorst authored Jul 1, 2024
2 parents 406cd4e + 66f695d commit b33d4b3
Show file tree
Hide file tree
Showing 87 changed files with 1,207 additions and 101 deletions.
7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ AllCops:
- 'gemfiles/vendor/bundle/**/*'
- 'vendor/**/*'
SuggestExtensions: false
NewCops: enable

Naming/PredicateName:
Enabled: false

Style/OpenStructUse:
Enabled: false

Layout/LineLength:
Max: 140
Expand Down
64 changes: 19 additions & 45 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,38 @@ source "https://rubygems.org"

ruby "3.3.0"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.1.3", ">= 7.1.3.2"

# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"

# Use postgresql as the database for Active Record
gem "pg", "~> 1.1"

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", ">= 5.0"

# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails"

# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"

# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"

# Use Tailwind CSS [https://github.com/rails/tailwindcss-rails]
gem "tailwindcss-rails"

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"
gem 'rest-client', '~> 2.1'

# Use Redis adapter to run Action Cable in production
gem "redis", ">= 4.0.1"

# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
gem "bcrypt", "~> 3.1.7"

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false

gem 'feedjira', '~> 3.2', '>= 3.2.3'
gem 'haml', '~> 6.3'
gem "importmap-rails"
gem "jbuilder", '~>2.12'
gem 'jsonb_accessor', '~> 1.4'
gem 'mailgun-ruby', '~>1.2.14'
gem "pg", "~> 1.1"
gem 'positioning', '~> 0.2.2'
gem 'pr_geohash', '~>1.0.0'
gem "puma", ">= 5.0"
gem "rails", "~> 7.1.3", ">= 7.1.3.2"
gem "redis", ">= 4.0.1"
gem 'rest-client', '~> 2.1'
gem 'ruby-protocol-buffers', '~>1.6.1' # https://github.com/codekitchen/ruby-protocol-buffers
gem "sentry-rails"
gem "sentry-ruby"
gem 'sidekiq', '~>7.2.4'
gem "sprockets-rails"
gem "stimulus-rails"
gem 'store_model', '~> 3.0', '>= 3.0.2'
gem 'stripe', '~>11.3'
gem "tailwindcss-rails"
gem "turbo-rails"
gem 'varint', '~>0.1.1' # needed for protobuf
gem 'view_component', '~> 3.12', '>= 3.12.1'

# Protocol Buffers
# https://github.com/codekitchen/ruby-protocol-buffers
gem 'ruby-protocol-buffers', '~>1.6.1'
gem 'varint', '~>0.1.1'

gem 'sidekiq', '~>7.2.4'

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug"
gem 'factory_bot_rails', '~>6.4.3'
gem "rspec-rails", '~>6.1.2'
gem 'rubocop', require: false
gem 'rubocop-rails', require: false
Expand All @@ -80,6 +53,7 @@ end
group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem 'rails-controller-testing'
gem "selenium-webdriver"
gem 'simplecov'
gem "vcr", '~>6.2.0'
Expand Down
25 changes: 24 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ GEM
domain_name (0.6.20240107)
drb (2.2.1)
erubi (1.13.0)
factory_bot (6.4.6)
activesupport (>= 5.0.0)
factory_bot_rails (6.4.3)
factory_bot (~> 6.4)
railties (>= 5.0.0)
feedjira (3.2.3)
loofah (>= 2.3.1, < 3)
sax-machine (>= 1.0, < 2)
Expand Down Expand Up @@ -136,6 +141,10 @@ GEM
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
json (2.7.2)
jsonb_accessor (1.4)
activerecord (>= 6.1)
activesupport (>= 6.1)
pg (>= 0.18.1)
language_server-protocol (3.17.0.3)
loofah (2.22.0)
crass (~> 1.0.2)
Expand Down Expand Up @@ -185,6 +194,9 @@ GEM
ast (~> 2.4.1)
racc
pg (1.5.6)
positioning (0.2.2)
activerecord (>= 6.1)
activesupport (>= 6.1)
pr_geohash (1.0.0)
psych (5.1.2)
stringio
Expand Down Expand Up @@ -214,6 +226,10 @@ GEM
activesupport (= 7.1.3.4)
bundler (>= 1.15.0)
railties (= 7.1.3.4)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
activesupport (>= 5.0.1.rc1)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
Expand Down Expand Up @@ -317,6 +333,8 @@ GEM
sprockets (>= 3.0.0)
stimulus-rails (1.3.3)
railties (>= 6.0.0)
store_model (3.0.2)
activerecord (>= 5.2)
stringio (3.1.1)
stripe (11.7.0)
strscan (3.1.0)
Expand Down Expand Up @@ -380,15 +398,19 @@ DEPENDENCIES
bootsnap
capybara
debug
factory_bot_rails (~> 6.4.3)
feedjira (~> 3.2, >= 3.2.3)
haml (~> 6.3)
importmap-rails
jbuilder
jbuilder (~> 2.12)
jsonb_accessor (~> 1.4)
mailgun-ruby (~> 1.2.14)
pg (~> 1.1)
positioning (~> 0.2.2)
pr_geohash (~> 1.0.0)
puma (>= 5.0)
rails (~> 7.1.3, >= 7.1.3.2)
rails-controller-testing
redis (>= 4.0.1)
rest-client (~> 2.1)
rspec-rails (~> 6.1.2)
Expand All @@ -402,6 +424,7 @@ DEPENDENCIES
simplecov
sprockets-rails
stimulus-rails
store_model (~> 3.0, >= 3.0.2)
stripe (~> 11.3)
tailwindcss-rails
turbo-rails
Expand Down
7 changes: 5 additions & 2 deletions app/assets/stylesheets/application.tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@

@layer components {
.link {
@apply text-blue-600 hover:underline;
@apply text-blue-600 hover:underline fill-blue-600;
}

.oba-td {
@apply whitespace-nowrap pr-3 py-4 text-sm text-gray-500;
}

.oba-btn {
@apply rounded-md bg-gray-100 px-3 py-2 text-sm text-gray-700 font-semibold shadow-sm hover:bg-gray-50 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand;
@apply bg-gradient-to-b from-slate-50 to-slate-100;
@apply text-sm text-gray-700 font-semibold;
@apply border border-gray-300/70 hover:border-gray-400/50;
@apply rounded-md px-3 py-2 shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand;
}

.oba-btn--primary {
Expand Down
6 changes: 6 additions & 0 deletions app/components/admin/side_tabs_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
active: @current_path == admin_path
) %>

<% @context.with_tab(
title: "Studies",
path: admin_studies_path,
active: @current_path == admin_studies_path
) %>

<% @context.with_tab(
title: "Alert Feed",
path: admin_alerts_path,
Expand Down
14 changes: 10 additions & 4 deletions app/components/containers/empty_state_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<div class="relative block w-full rounded-lg border-2 border-dashed border-gray-300 p-12 text-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true" stroke-width="1.5" stroke="currentColor" class="mx-auto h-16 h-16 text-gray-400">
<path stroke-linecap="round" stroke-linejoin="round" d="M14.857 17.082a23.848 23.848 0 0 0 5.454-1.31A8.967 8.967 0 0 1 18 9.75V9A6 6 0 0 0 6 9v.75a8.967 8.967 0 0 1-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 0 1-5.714 0m5.714 0a3 3 0 1 1-5.714 0M3.124 7.5A8.969 8.969 0 0 1 5.292 3m13.416 0a8.969 8.969 0 0 1 2.168 4.5" />
</svg>
<div class="relative block w-full rounded-lg border-2 border-dashed border-gray-300 p-12 text-center fill-gray-900">
<div class="text-center mx-auto">
<% if @icon %>
<%= @icon %>
<% else %>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true" stroke-width="1.5" stroke="currentColor" class="h-16 h-16 text-gray-400">
<path stroke-linecap="round" stroke-linejoin="round" d="M14.857 17.082a23.848 23.848 0 0 0 5.454-1.31A8.967 8.967 0 0 1 18 9.75V9A6 6 0 0 0 6 9v.75a8.967 8.967 0 0 1-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 0 1-5.714 0m5.714 0a3 3 0 1 1-5.714 0M3.124 7.5A8.969 8.969 0 0 1 5.292 3m13.416 0a8.969 8.969 0 0 1 2.168 4.5" />
</svg>
<% end %>
</div>

<span class="mt-2 block text-sm font-semibold text-gray-900"><%= @title %></span>
<span class="mt-2 block text-sm text-gray-900"><%= @description %></span>
Expand Down
3 changes: 2 additions & 1 deletion app/components/containers/empty_state_component.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# frozen_string_literal: true

class Containers::EmptyStateComponent < ViewComponent::Base
def initialize(title:, description:)
def initialize(title:, description:, icon: nil)
super()
@title = title
@description = description
@icon = icon
end
end
4 changes: 2 additions & 2 deletions app/components/containers/side_tabs_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class Containers::SideTabsComponent < ViewComponent::Base
class: class_names(
"group flex gap-x-3 rounded-md p-2 pl-3 text-sm leading-6 font-semibold",
{
"bg-gray-50 text-brand-tertiary": active,
"text-gray-700 hover:text-brand-tertiary hover:bg-gray-50": !active
'bg-gray-50 text-brand-tertiary': active,
'text-gray-700 hover:text-brand-tertiary hover:bg-gray-50': !active
}
)
)
Expand Down
4 changes: 4 additions & 0 deletions app/components/forms/button_bar_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="text-right space-x-2">
<%= link_to "Cancel", :back, class: "oba-btn" %>
<%= @form.submit class: 'oba-btn--primary' %>
</div>
8 changes: 8 additions & 0 deletions app/components/forms/button_bar_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

class Forms::ButtonBarComponent < ViewComponent::Base
def initialize(form)
super()
@form = form
end
end
8 changes: 8 additions & 0 deletions app/components/forms/errors_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="bg-red-50 border border-red-200 rounded-md p-2">
<h3 class="h3">Errors</h3>
<ul class="list-disc list-inside pl-4">
<% @errors.each do |error| %>
<li><%= error %></li>
<% end %>
</ul>
</div>
12 changes: 12 additions & 0 deletions app/components/forms/errors_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

class Forms::ErrorsComponent < ViewComponent::Base
def initialize(errors:)
super()
@errors = errors
end

def render?
@errors.any?
end
end
12 changes: 12 additions & 0 deletions app/components/navigation/back_link_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%= link_to @link, class: 'link text-sm font-medium' do %>
<div class="flex">
<div class="flex-none self-center">
<svg xmlns="http://www.w3.org/2000/svg" class="w-4" viewBox="0 0 24 24">
<path d="M20 11H7.41l5.3-5.29a1 1 0 0 0-1.42-1.42l-7 7a1 1 0 0 0 0 1.42l7 7a1 1 0 0 0 1.42-1.42L7.41 13H20a1 1 0 0 0 0-2z"/>
</svg>
</div>
<div>
<%= @title %>
</div>
</div>
<% end %>
9 changes: 9 additions & 0 deletions app/components/navigation/back_link_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class Navigation::BackLinkComponent < ViewComponent::Base
def initialize(title:, link:)
super()
@title = title
@link = link
end
end
33 changes: 33 additions & 0 deletions app/components/questions/options_builder_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<div data-controller="options-builder">
<div class="flex gap-x-2 mt-4 mb-2">
<h3 class="h3">Options:</h3>

<div class="flex-1">
<button
type="button"
class="oba-btn--sm oba-btn--primary"
data-action="click->options-builder#addField">
Add Option
</button>
</div>
</div>

<div
class="p-2 border bg-slate-50 space-y-4"
data-options-builder-target="fields">
</div>

<template data-options-builder-target="template">
<div class="flex gap-x-2">
<label class="block text-sm font-medium leading-6 text-gray-900 self-center">Option:</label>
<div class="flex-1">
<%= text_field_tag(
"question[content_attributes][options][]",
"",
id: nil,
class: "block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-brand sm:text-sm sm:leading-6"
) %>
</div>
</div>
</template>
</div>
4 changes: 4 additions & 0 deletions app/components/questions/options_builder_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

class Questions::OptionsBuilderComponent < ViewComponent::Base
end
Loading

0 comments on commit b33d4b3

Please sign in to comment.