- <%= link_to "New Text Field", new_admin_study_survey_question_path(@survey.study, @survey, content: 'text'), class: 'oba-btn' %>
- <%= link_to "New Label", new_admin_study_survey_question_path(@survey.study, @survey, content: 'label'), class: 'oba-btn' %>
- <%= link_to "New Radio List", new_admin_study_survey_question_path(@survey.study, @survey, content: 'radio'), class: 'oba-btn' %>
- <%= link_to "New Checkbox List", new_admin_study_survey_question_path(@survey.study, @survey, content: 'checkbox'), class: 'oba-btn' %>
- <%= link_to "New External Survey", new_admin_study_survey_question_path(@survey.study, @survey, content: 'external_survey'), class: 'oba-btn' %>
+
+
+
+
Settings
+
+ <%= link_to "Edit", edit_admin_study_survey_path(@survey.study, @survey), class: "oba-btn oba-btn--sm" %>
+
+
+
+
+ <%= render Data::DataListComponent.new(
+ [
+ { name: "Name", value: @survey.name },
+ { name: "Show on Map", value: @survey.show_on_map? ? "Yes" : "No" },
+ { name: "Show on Stops", value: @survey.show_on_stops? ? "Yes" : "No" },
+ { name: "Visible stop list", value: @survey.visible_stop_list },
+ { name: "Visible route list", value: @survey.visible_route_list },
+ ]
+ ) %>
+
- <% if @survey.questions.blank? %>
- <%= render Containers::EmptyStateComponent.new(
- title: "No Survey Questions",
- description: "Add survey questions to this survey to collect data from participants."
- ) %>
- <% else %>
-
- <% @survey.questions.each do |sq| %>
-
-
-
- <%= render("icons/grip_vertical_solid", classes: "w-4 h-4 fill-gray-500") %>
-
-
-
Q<%= sq.position %>: <%= sq.content.type.titleize %>
-
-
- <%= link_to "Edit", edit_admin_study_survey_question_path(@survey.study, @survey, sq), class: "link text-sm" %>
+
+
+ <%= link_to "New Text Field", new_admin_study_survey_question_path(@survey.study, @survey, content: 'text'), class: 'oba-btn' %>
+ <%= link_to "New Label", new_admin_study_survey_question_path(@survey.study, @survey, content: 'label'), class: 'oba-btn' %>
+ <%= link_to "New Radio List", new_admin_study_survey_question_path(@survey.study, @survey, content: 'radio'), class: 'oba-btn' %>
+ <%= link_to "New Checkbox List", new_admin_study_survey_question_path(@survey.study, @survey, content: 'checkbox'), class: 'oba-btn' %>
+ <%= link_to "New External Survey", new_admin_study_survey_question_path(@survey.study, @survey, content: 'external_survey'), class: 'oba-btn' %>
+
+
+ <% if @survey.questions.blank? %>
+ <%= render Containers::EmptyStateComponent.new(
+ title: "No Survey Questions",
+ description: "Add survey questions to this survey to collect data from participants."
+ ) %>
+ <% else %>
+
+ <% @survey.questions.each do |sq| %>
+
+
+
+ <%= render("icons/grip_vertical_solid", classes: "w-4 h-4 fill-gray-500") %>
+
+
+
Q<%= sq.position %>: <%= sq.content.type.titleize %>
+
+
+ <%= link_to "Edit", edit_admin_study_survey_question_path(@survey.study, @survey, sq), class: "link text-sm" %>
+
+ <%= render partial_for_field_preview(sq), question: sq %>
- <%= render partial_for_field_preview(sq), question: sq %>
-
- <% end %>
-
- <% end %>
-
+ <% end %>
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/api/v1/surveys/index.json.jbuilder b/app/views/api/v1/surveys/index.json.jbuilder
index 487b46f..0f55577 100644
--- a/app/views/api/v1/surveys/index.json.jbuilder
+++ b/app/views/api/v1/surveys/index.json.jbuilder
@@ -1,6 +1,18 @@
json.surveys do
json.array! @surveys do |survey|
- json.extract! survey, :id, :name, :created_at
+ json.extract! survey, :id, :name, :created_at, :updated_at, :show_on_map, :show_on_stops
+
+ if survey.visible_stop_list.blank?
+ json.visible_stop_list nil
+ else
+ json.visible_stop_list survey.visible_stop_list&.split(',')&.map(&:strip)
+ end
+
+ if survey.visible_route_list.blank?
+ json.visible_route_list nil
+ else
+ json.visible_route_list survey.visible_route_list&.split(',')&.map(&:strip)
+ end
json.study do
json.extract! survey.study, :id, :name, :description
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index dd73ae8..e35a703 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -39,13 +39,15 @@
<% end %>
-
-
- <% if @back_link_title.present? && @back_link_path.present? %>
- <%= render Navigation::BackLinkComponent.new(title: @back_link_title, link: @back_link_path) %>
- <% end %>
-
<%= @title %>
-
+
+ <% if @back_link_title.present? && @back_link_path.present? %>
+ <%= render Navigation::BackLinkComponent.new(title: @back_link_title, link: @back_link_path) %>
+ <% end %>
+ <%= @title %>
+
+ <% if defined?(@sub_tabs) && @sub_tabs.count > 0 %>
+ <%= render Navigation::TabsComponent.new(@sub_tabs) %>
+ <% end %>
diff --git a/spec/components/data/data_list_component_spec.rb b/spec/components/data/data_list_component_spec.rb
new file mode 100644
index 0000000..1de896d
--- /dev/null
+++ b/spec/components/data/data_list_component_spec.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+RSpec.describe Data::DataListComponent, type: :component do
+ it "renders something useful" do
+ expect(
+ render_inline(described_class.new([{ name: "Hello world", value: "Foo bar" }])).to_html
+ ).to include(
+ "Hello world"
+ )
+ end
+end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index f3c3bc1..c39d9ed 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -10,6 +10,7 @@
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!
+require "view_component/test_helpers"
Rails.root.glob('spec/support/**/*.rb').sort.each { |f| require f }
@@ -30,6 +31,7 @@
config.infer_spec_type_from_file_location!
config.filter_rails_from_backtrace!
+ config.include ViewComponent::TestHelpers, type: :component
config.include ApiHelper, type: :request
config.include RequestHelper, type: :request
config.include ModelsHelper