-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feedback edit #149
Merged
Merged
Feedback edit #149
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9ee1df6
Add `textarea-autogrow` Stimulus component
JoshDevHub 31e909b
Change overall_rating to report in 5 step increments
JoshDevHub 2fd6d0d
Create and style turbo frame edit form
JoshDevHub 9dd45ed
Situationally force full page load for edit form
JoshDevHub 3e04944
Merge branch 'main' into feedback-edit
JoshDevHub 712e748
Add content for showing who the feedback is for in edit template
JoshDevHub File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is merged, but out of curiousity, what is the difference between using the |
||
</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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have to use this instead of the
turbo_frame_tag
helper because of some compatibility issues with ViewComponent. See this documentation