Skip to content

Commit

Permalink
refactor sorting helper
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriyAndriyovuch committed Sep 24, 2023
1 parent 97628d6 commit 6eb2a76
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions app/helpers/account/sort_helper.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
module Account::SortHelper
def products_criterias
def base_criterias
[
[I18n.t("sort.id_asc"), "id asc"],
[I18n.t("sort.id_desc"), "id desc"],
[I18n.t("sort.id_desc"), "id desc"]
]
end

def products_criterias
base_criterias | [
[I18n.t("sort.title_asc"), "title asc"],
[I18n.t("sort.title_desc"), "title desc"]
]
end

def calculators_criterias
[
[I18n.t("sort.id_asc"), "id asc"],
[I18n.t("sort.id_desc"), "id desc"],
base_criterias | [
[I18n.t("sort.name_asc"), "name asc"],
[I18n.t("sort.name_desc"), "name desc"],
[I18n.t("sort.slug_asc"), "slug asc"],
Expand All @@ -20,9 +23,7 @@ def calculators_criterias
end

def users_criterias
[
[I18n.t("sort.id_asc"), "id asc"],
[I18n.t("sort.id_desc"), "id desc"],
base_criterias | [
[I18n.t("sort.email_asc"), "email asc"],
[I18n.t("sort.email_desc"), "email desc"],
[I18n.t("sort.last_sign_in_at_asc"), "last_sign_in_at asc"],
Expand All @@ -31,9 +32,7 @@ def users_criterias
end

def categories_criterias
[
[I18n.t("sort.id_asc"), "id asc"],
[I18n.t("sort.id_desc"), "id desc"],
base_criterias | [
[I18n.t("sort.name_asc"), "name asc"],
[I18n.t("sort.name_desc"), "name desc"],
[I18n.t("sort.priority_asc"), "priority asc"],
Expand Down

0 comments on commit 6eb2a76

Please sign in to comment.