Skip to content
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

Merged
merged 1 commit into from
Jul 11, 2023

Conversation

KevinMulhern
Copy link
Member

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.

@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-3929 July 8, 2023 17:02 Inactive
@KevinMulhern KevinMulhern force-pushed the feature/like-submissions-with-hotwire branch from 4693700 to eacefe5 Compare July 10, 2023 00:01
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-3929 July 10, 2023 00:07 Inactive
@KevinMulhern KevinMulhern force-pushed the feature/like-submissions-with-hotwire branch from eacefe5 to f3a109b Compare July 10, 2023 18:10
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-3929 July 10, 2023 18:10 Inactive
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.
@KevinMulhern KevinMulhern force-pushed the feature/like-submissions-with-hotwire branch from f3a109b to f3a5829 Compare July 10, 2023 18:37
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-3929 July 10, 2023 18:37 Inactive
@KevinMulhern KevinMulhern self-assigned this Jul 10, 2023
@KevinMulhern KevinMulhern added the Type: Enhancement Involves a new feature or enhancement request label Jul 10, 2023
@@ -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 %>">
Copy link
Member Author

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
Copy link
Member Author

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.

@KevinMulhern KevinMulhern marked this pull request as ready for review July 10, 2023 18:48
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-3929 July 11, 2023 19:37 Inactive
@KevinMulhern KevinMulhern merged commit 0302b1c into main Jul 11, 2023
2 checks passed
@KevinMulhern KevinMulhern deleted the feature/like-submissions-with-hotwire branch July 11, 2023 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Involves a new feature or enhancement request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants