mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-18 13:38:24 -04:00
DRY up gardens and plantings helper
This commit is contained in:
@@ -81,4 +81,15 @@ module ApplicationHelper
|
||||
model_name = model.model_name.human(count: size)
|
||||
"#{size} #{model_name}"
|
||||
end
|
||||
|
||||
def show_inactive_tickbox_path(type, owner, show_all)
|
||||
all = show_all ? '' : 1
|
||||
if owner
|
||||
plantings_by_owner_path(owner: owner.slug, all: all) if type == 'plantings'
|
||||
gardens_by_owner_path(owner: owner.slug, all: all) if type == 'gardens'
|
||||
else
|
||||
plantings_path(all: all) if type == 'plantings'
|
||||
gardens_path(all: all) if type == 'gardens'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,12 +10,7 @@ module GardensHelper
|
||||
end
|
||||
|
||||
def gardens_active_tickbox_path(owner, show_all)
|
||||
all = show_all ? '' : 1
|
||||
if owner
|
||||
gardens_by_owner_path(owner: owner.slug, all: all)
|
||||
else
|
||||
gardens_path(all: all)
|
||||
end
|
||||
show_inactive_tickbox_path('gardens', owner, show_all)
|
||||
end
|
||||
|
||||
def display_garden_name(garden)
|
||||
|
||||
@@ -42,12 +42,7 @@ module PlantingsHelper
|
||||
end
|
||||
|
||||
def plantings_active_tickbox_path(owner, show_all)
|
||||
all = show_all ? '' : 1
|
||||
if owner
|
||||
plantings_by_owner_path(owner: owner.slug, all: all)
|
||||
else
|
||||
plantings_path(all: all)
|
||||
end
|
||||
show_inactive_tickbox_path('plantings', owner, show_all)
|
||||
end
|
||||
|
||||
def plantings_title(owner, crop)
|
||||
|
||||
Reference in New Issue
Block a user