-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Feature: Liking project submissions with Hotwire #3929
Conversation
4693700
to
eacefe5
Compare
eacefe5
to
f3a109b
Compare
Because: * We are moving our React components to Hotwire This commit: * Add like view component to encapsulate the like button. * Add like singular resource route and controller - now with a proper delete route instead of reusing the create action. * Decorates submissions with current user likes when they are being fetched. This saves us from checking each one individually and hitting the database each time. * Adds a reusable sorting stimulus controller - can be used to automatically sort lists on page load or when a list item changes.
f3a109b
to
f3a5829
Compare
@@ -1,52 +1,47 @@ | |||
<%= turbo_frame_tag project_submission do %> | |||
<div data-test-id="submission-item" class="relative py-6 border-solid border-t border-gray-300 flex flex-col md:flex-row justify-between items-center"> | |||
<div id="<%= dom_id(project_submission) %>" data-id="<%= project_submission.id %>" data-sort-target="item" data-sort-code="<%= sort_by %>"> |
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.
Switched the turbo frame for a div because sortable.js cannot animate turbo frame elements.
@@ -1,5 +1,7 @@ | |||
module ProjectSubmissions | |||
class ItemComponent < ApplicationComponent | |||
CURRENT_USER_SORT_CODE = 10_000_000 # current user's submission should always be first |
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.
Bit of a workaround for now. After we get feature parity with the current submissions, we would be in a good place to revisit the design of submissions; and cleanly separate the users submission from the rest.
Because:
This commit: