mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-01-30 20:20:59 -05:00
Move consistent icons
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
module ButtonsHelper
|
||||
def garden_plant_something_button(garden)
|
||||
button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf')
|
||||
link_to new_planting_path(garden_id: garden.id), class: "btn btn-default btn-xs btn-primary" do
|
||||
planting_icon + ' ' + t('buttons.plant_something_here')
|
||||
end
|
||||
end
|
||||
|
||||
def garden_mark_active_button(garden)
|
||||
@@ -41,39 +43,46 @@ module ButtonsHelper
|
||||
|
||||
link_to planting_path(planting, planting: { finished: 1 }),
|
||||
method: :put, class: 'btn btn-default btn-xs append-date' do
|
||||
render 'shared/glyphicon', icon: 'ok', title: 'buttons.mark_as_finished'
|
||||
finished_icon + ' ' + t('buttons.mark_as_finished')
|
||||
end
|
||||
end
|
||||
|
||||
def planting_harvest_button(planting)
|
||||
return unless planting.active? && can?(:create, Harvest) && can?(:edit, planting)
|
||||
|
||||
button(new_planting_harvest_path(planting), 'buttons.harvest', 'apple')
|
||||
link_to new_planting_harvest_path(planting), class: "btn btn-default btn-xs" do
|
||||
harvest_icon + ' ' + t('buttons.harvest')
|
||||
end
|
||||
end
|
||||
|
||||
def planting_save_seeds_button(planting)
|
||||
button(new_planting_seed_path(planting), 'buttons.save_seeds', 'heart') if can?(:edit, planting)
|
||||
return unless can?(:edit, planting)
|
||||
|
||||
link_to new_planting_seed_path(planting), class: "btn btn-default btn-xs" do
|
||||
seed_icon + ' ' + t('buttons.save_seeds')
|
||||
end
|
||||
end
|
||||
|
||||
# Generic buttons (works out which model)
|
||||
def add_photo_button(model)
|
||||
return unless can?(:edit, model) && can?(:create, Photo)
|
||||
|
||||
button(
|
||||
new_photo_path(id: model.id, type: model_type_for_photo(model)),
|
||||
'buttons.add_photo', 'camera'
|
||||
)
|
||||
link_to new_photo_path(id: model.id, type: model_type_for_photo(model)),
|
||||
class: "btn btn-default btn-xs" do
|
||||
photo_icon + ' ' + t('buttons.add_photo')
|
||||
end
|
||||
end
|
||||
|
||||
def edit_button(path)
|
||||
button(path, 'buttons.edit', 'pencil')
|
||||
link_to path, class: "btn btn-default btn-xs" do
|
||||
edit_icon + ' ' + t('buttons.edit')
|
||||
end
|
||||
end
|
||||
|
||||
def delete_button(model, message: 'are_you_sure')
|
||||
return unless can? :destroy, model
|
||||
|
||||
link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-default btn-xs' do
|
||||
render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete'
|
||||
delete_icon + ' ' + t('buttons.delete')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -83,9 +92,9 @@ module ButtonsHelper
|
||||
ActiveModel::Name.new(model.class).to_s.downcase
|
||||
end
|
||||
|
||||
def button(path, title, icon, size = 'btn-xs')
|
||||
def button(path, button_title, icon, size = 'btn-xs')
|
||||
link_to path, class: "btn btn-default #{size}" do
|
||||
render 'shared/glyphicon', icon: icon, title: title
|
||||
icon + ' ' + button_title
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,4 +14,20 @@ module IconsHelper
|
||||
def seed_icon
|
||||
icon('fas', 'heart')
|
||||
end
|
||||
|
||||
def finished_icon
|
||||
icon('fas', 'calendar')
|
||||
end
|
||||
|
||||
def edit_icon
|
||||
icon('far', 'edit')
|
||||
end
|
||||
|
||||
def delete_icon
|
||||
icon('fas', 'trash-alt')
|
||||
end
|
||||
|
||||
def photo_icon
|
||||
icon('fas', 'camera-retro')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
.garden-actions
|
||||
- if can?(:edit, garden)
|
||||
= garden_plant_something_button(garden) if garden.active
|
||||
.btn-group
|
||||
- if garden.active
|
||||
= garden_plant_something_button(garden)
|
||||
= garden_mark_inactive_button(garden)
|
||||
- else
|
||||
= garden_mark_active_button(garden)
|
||||
@@ -11,5 +11,4 @@
|
||||
= add_photo_button(garden)
|
||||
|
||||
- if can?(:destroy, garden)
|
||||
.pull-right
|
||||
= delete_button(garden, message: 'All plantings associated with this garden will also be deleted. Are you sure?')
|
||||
= delete_button(garden, message: 'All plantings associated with this garden will also be deleted. Are you sure?')
|
||||
|
||||
Reference in New Issue
Block a user