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

Gifts index #10

Merged
merged 12 commits into from
Jul 3, 2024
Merged

Gifts index #10

merged 12 commits into from
Jul 3, 2024

Conversation

brunoLombardo
Copy link
Collaborator

completed gifts index page

.rubocop.yml Outdated
@@ -7,6 +7,7 @@ AllCops:
- "node_modules/**/*"
- "db/schema.rb"
- "vendor/bundle/**/*"
- "db/migrate/20240621174351_create_active_storage_tables.active_storage.rb"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are going to ignore it, ignore all of the migrations folder

Comment on lines 2 to 3
before_action :classes_filter, :load_filters_and_categories, only: [:index]
def index
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a line break between before actions and methods

Comment on lines 8 to 13
scope :get_gifts_from_categories, lambda { |categories, order|
with_attached_image.includes(:supplier)
.joins(:gift_categorizations)
.where(gift_categorizations: { category_id: categories })
.order(order).distinct
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a weird scope for the following reasons:

  • The name should be something like with_categories, so that we can read it like Gift.with_categories(ids)
  • It does too many things: it should only do what the name says, join it with categories and filter by category id. Let's remove the includes and the with_attached_image scope. Remember that you can chain scopes, so we can do
Gift.with_categories(ids).with_attached_image.includes(:supplier).order(order).distinct

selected_categories
end
query = Gift.get_gifts_from_categories(query_categories, selected_order)
@query_count = query.count
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is weid. Maybe gifts_count?

Comment on lines 7 to 18
connect(){
if (this.checkBoxTarget.checked) {
this.labelTarget.classList.add(this.backgroundClass)
this.labelTarget.classList.add(this.textClass)
}
}
check() {
if (this.checkBoxTarget.checked) {
this.labelTarget.classList.add(this.backgroundClass)
this.labelTarget.classList.add(this.textClass)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add some space in between methods

Comment on lines 5 to 6
static targets = [ "checkBox", "label" ]
static classes = [ "background", 'text' ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// Connects to data-controller="style-labels"
export default class extends Controller {
static targets = [ "checkBox", "label" ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@JorgeLeites JorgeLeites left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@JorgeLeites JorgeLeites merged commit 9354bb7 into main Jul 3, 2024
1 check passed
@JorgeLeites JorgeLeites deleted the gifts_index branch July 3, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants