-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds new options to the Survey model to configure visibility of surveys
Allow them to be shown on maps or stops—or neither. And restrict the list of stops and routes.
- Loading branch information
1 parent
5acc84e
commit 4f664ef
Showing
5 changed files
with
111 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,27 @@ | ||
<%= form_with model: @survey, url: admin_study_surveys_path(@study) do |f| %> | ||
<% url = @survey.persisted? ? admin_study_survey_path(@study, @survey) : admin_study_surveys_path(@study) %> | ||
<%= form_with model: @survey, url: url do |f| %> | ||
<div class="space-y-4"> | ||
<%= render Forms::ErrorsComponent.new(errors: @survey.errors.full_messages) %> | ||
<%= render Forms::TextFieldComponent.new(form: f, method: :name, autofocus: true) %> | ||
<%= render Forms::CheckboxComponent.new(form: f, method: :available) %> | ||
<%= render Forms::CheckboxComponent.new(form: f, method: :show_on_map) %> | ||
<%= render Forms::CheckboxComponent.new(form: f, method: :show_on_stops) %> | ||
|
||
<div> | ||
<%= render Forms::TextFieldComponent.new(form: f, method: :visible_stop_list) %> | ||
<div class='text-gray-500 text-sm'> | ||
Optional, comma separated list of stop IDs that this survey should be visible on. When blank, it implies visibility on all stops. | ||
</div> | ||
</div> | ||
|
||
<div> | ||
<%= render Forms::TextFieldComponent.new(form: f, method: :visible_route_list) %> | ||
<div class='text-gray-500 text-sm'> | ||
Optional, comma separated list of route IDs that this survey should be visible on. When blank, it implies visibility on all routes. | ||
</div> | ||
</div> | ||
|
||
<%= render Forms::ButtonBarComponent.new(f) %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,70 @@ | ||
<% title @survey.name %> | ||
<% back_link "Back to Study", admin_study_path(@survey.study) %> | ||
<%= render 'admins/survey_tabs' %> | ||
|
||
<div class="space-y-4"> | ||
<div> | ||
<%= 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' %> | ||
<div class='flex flex-col md:flex-row-reverse space-y-4 md:space-y-0 md:gap-x-2'> | ||
<div class='md:w-72 bg-neutral-50 rounded-md p-2'> | ||
<div class='flex mb-2'> | ||
<h2 class="h2">Settings</h2> | ||
<div class='flex-1 text-right text-sm self-center'> | ||
<%= link_to "Edit", edit_admin_study_survey_path(@survey.study, @survey), class: "oba-btn oba-btn--sm" %> | ||
</div> | ||
</div> | ||
|
||
<div class='text-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 }, | ||
] | ||
) %> | ||
</div> | ||
</div> | ||
|
||
<% 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 %> | ||
<div | ||
class="flex flex-col gap-y-4" | ||
data-controller="sortable" | ||
data-sortable-resource-name-value="question" | ||
data-sortable-response-kind-value="json" | ||
data-sortable-animation-value="150" | ||
data-sortable-handle-value=".handle"> | ||
<% @survey.questions.each do |sq| %> | ||
<div | ||
data-sortable-update-url="<%= admin_study_survey_question_path(@survey.study, @survey, sq) %>" | ||
class="border bg-slate-50 p-2"> | ||
<div class="flex"> | ||
<div class="handle self-center cursor-move"> | ||
<%= render("icons/grip_vertical_solid", classes: "w-4 h-4 fill-gray-500") %> | ||
</div> | ||
<div class="flex-1"> | ||
<h3 class="h3">Q<%= sq.position %>: <%= sq.content.type.titleize %></h3> | ||
</div> | ||
<div> | ||
<%= link_to "Edit", edit_admin_study_survey_question_path(@survey.study, @survey, sq), class: "link text-sm" %> | ||
<div class="space-y-4 flex-1"> | ||
<div class='flex gap-x-2'> | ||
<%= 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' %> | ||
</div> | ||
|
||
<% 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 %> | ||
<div | ||
class="flex flex-col gap-y-4" | ||
data-controller="sortable" | ||
data-sortable-resource-name-value="question" | ||
data-sortable-response-kind-value="json" | ||
data-sortable-animation-value="150" | ||
data-sortable-handle-value=".handle"> | ||
<% @survey.questions.each do |sq| %> | ||
<div | ||
data-sortable-update-url="<%= admin_study_survey_question_path(@survey.study, @survey, sq) %>" | ||
class="border bg-slate-50 p-2"> | ||
<div class="flex"> | ||
<div class="handle self-center cursor-move"> | ||
<%= render("icons/grip_vertical_solid", classes: "w-4 h-4 fill-gray-500") %> | ||
</div> | ||
<div class="flex-1"> | ||
<h3 class="h3">Q<%= sq.position %>: <%= sq.content.type.titleize %></h3> | ||
</div> | ||
<div> | ||
<%= link_to "Edit", edit_admin_study_survey_question_path(@survey.study, @survey, sq), class: "link text-sm" %> | ||
</div> | ||
</div> | ||
<%= render partial_for_field_preview(sq), question: sq %> | ||
</div> | ||
<%= render partial_for_field_preview(sq), question: sq %> | ||
</div> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters