-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add `textarea-autogrow` Stimulus component * Change overall_rating to report in 5 step increments * Create and style turbo frame edit form * Situationally force full page load for edit form Certain pages need this because the turbo frame wouldn't make for a good user experience. * Add content for showing who the feedback is for in edit template
- Loading branch information
1 parent
3d1428c
commit 1797634
Showing
10 changed files
with
65 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
<div class="p-2 border shadow-lg rounded-lg max-w-prose mx-auto flex-1"> | ||
<div class="flex justify-between items-center"> | ||
<%= heading(class: "text-lg") %> | ||
<%= render Feedback::EditButtonComponent.new(feedback:, current_user: user) %> | ||
</div> | ||
<div> | ||
<% if feedback.completed? %> | ||
<div class="p-2"> | ||
<p><span class="font-bold">Rating:</span> <%= feedback.overall_rating %>/10</p> | ||
</div> | ||
<%= render Feedback::QuestionComponent.with_collection(questions) %> | ||
<% else %> | ||
<p class="p-4">Awaiting completion of feedback.</p> | ||
<% end %> | ||
</div> | ||
<%= tag.turbo_frame(id: dom_id(feedback)) do %> | ||
<div class="flex justify-between items-center"> | ||
<%= heading(class: "text-lg") %> | ||
<%= render Feedback::EditButtonComponent.new(feedback:, current_user: user) %> | ||
</div> | ||
<div> | ||
<% if feedback.completed? %> | ||
<div class="p-2"> | ||
<p><span class="font-bold">Rating:</span> <%= feedback.overall_rating %>/5</p> | ||
</div> | ||
<%= render Feedback::QuestionComponent.with_collection(questions) %> | ||
<% else %> | ||
<p class="p-4">Awaiting completion of feedback.</p> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</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
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
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,33 +1,38 @@ | ||
<h1 class="text-2xl font-bold mb-4 text-center">Edit Feedback</h1> | ||
|
||
<%= form_with model: @feedback, local: true, html: { class: 'max-w-prose mx-auto px-4' } do |form| %> | ||
<% if @feedback.errors.any? %> | ||
<dl class="text-center mb-2"> | ||
<dl class="font-bold">For</dl> | ||
<dt><%= @feedback.receiver.email %></dt> | ||
</dl> | ||
|
||
<div class="mb-4"> | ||
<h2 class="text-red-700 text-lg"> | ||
Please fix <%= pluralize(@feedback.errors.count, "error") %> | ||
</h2> | ||
<%= turbo_frame_tag @feedback, target: "_top" do %> | ||
<ul> | ||
<% @feedback.errors.each do |error| %> | ||
<li><%= error.full_message %></li> | ||
<% end %> | ||
</ul> | ||
<%= form_with model: @feedback, local: true, html: { class: 'max-w-prose mx-auto px-4' } do |form| %> | ||
<p class="font-bold mb-2">Rating:</p> | ||
<div class="flex gap-x-2 mb-4"> | ||
<% (1..5).each do |n| %> | ||
<div class="flex flex-col text-center"> | ||
<%= form.radio_button :overall_rating, n, class: "radio radio-primary" %> | ||
<%= form.label :overall_rating, n %> | ||
</div> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
|
||
<div> | ||
<%= form.label "overall_rating", class: "label label-text text-lg " %> | ||
<%= form.number_field :overall_rating, class: "input input-bordered input-sm", min: 0, max: 10 %> | ||
</div> | ||
<% @feedback.data['feedback'].each_with_index do |object, index| %> | ||
<div class="form-control mb-4"> | ||
<%= form.label "data[feedback][#{index}][answer]", object['question'], class: "font-bold mb-2" %> | ||
<%= form.text_area "data[feedback][#{index}][answer]", | ||
value: object['answer'], | ||
required: object['required'], | ||
class: "textarea textarea-bordered", | ||
data: { controller: 'textarea-autogrow'}, | ||
rows: '1' | ||
%> | ||
</div> | ||
<% end %> | ||
|
||
<% @feedback.data['feedback'].each_with_index do |object, index| %> | ||
<div class="form-control mb-4"> | ||
<%= form.label "data[feedback][#{index}][answer]", object['question'], class: "label label-text text-lg" %> | ||
<%= form.text_area "data[feedback][#{index}][answer]", value: object['answer'], required: object['required'], class: "textarea textarea-bordered" %> | ||
<div class="form-control"> | ||
<%= form.submit "Update Feedback", class: "btn btn-primary btn-wide mx-auto" %> | ||
</div> | ||
<% end %> | ||
|
||
<div class="form-control"> | ||
<%= form.submit "Update Feedback", class: "btn btn-primary btn-wide mx-auto" %> | ||
</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
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