Further DRYing

This commit is contained in:
Brenda Wallace
2019-07-08 09:31:50 +12:00
parent 933c78b4e5
commit e26c6d52a4
3 changed files with 41 additions and 41 deletions

View File

@@ -60,40 +60,12 @@
%h2 Activity
.list-group
- @activity.each do |event|
.list-group-item.list-group-item-action.flex-column.align-items-start.active{:href => "#!"}
.list-group-item.list-group-item-action.flex-column.align-items-start{:href => "#!"}
.d-flex.w-100.justify-content-between
%h5
= icon_for_model(event.event_type)
= event_description(event)
- if event.event_type == 'photo'
- photo = resolve_model(event)
.media
= link_to(image_tag(photo.fullsize_url, width: 150, class: 'rounded'), photo)
.media-body
%p
%ul.associations
- photo.plantings.each do |planting|
%li
= planting_icon
= link_to t('photos.show.planting', planting: planting.to_s, owner: planting.owner.to_s), planting_path(planting)
- photo.harvests.each do |harvest|
%li
= harvest_icon
= link_to t('photos.show.harvest', crop: harvest.crop.name, owner: harvest.owner.to_s), harvest_path(harvest)
- photo.gardens.each do |garden|
%li
= garden_icon
= link_to t('photos.show.garden', garden: garden.to_s, owner: garden.owner.to_s), garden_path(garden)
- photo.seeds.each do |seed|
%li
= seed_icon
= link_to t('photos.show.seed', seed: seed.to_s, owner: seed.owner.to_s), seed_path(seed)
- else
= link_to event.event_type, event
= render 'timeline/photos', photo: resolve_model(event) if event.event_type == 'photo'
%small
- if event.event_at.present?
#{time_ago_in_words(event.event_at)} ago

View File

@@ -0,0 +1,24 @@
.media
= link_to(image_tag(photo.fullsize_url, width: 150, class: 'rounded'), photo)
.media-body
%p
%ul.associations
- photo.plantings.each do |planting|
%li
= planting_icon
= link_to t('photos.show.planting', planting: planting.to_s, owner: planting.owner.to_s), planting_path(planting)
- photo.harvests.each do |harvest|
%li
= harvest_icon
= link_to t('photos.show.harvest', crop: harvest.crop.name, owner: harvest.owner.to_s), harvest_path(harvest)
- photo.gardens.each do |garden|
%li
= garden_icon
= link_to t('photos.show.garden', garden: garden.to_s, owner: garden.owner.to_s), garden_path(garden)
- photo.seeds.each do |seed|
%li
= seed_icon
= link_to t('photos.show.seed', seed: seed.to_s, owner: seed.owner.to_s), seed_path(seed)

View File

@@ -7,18 +7,22 @@
= page_entries_info @seeds
= will_paginate @seeds
.list-group-item.list-group-item-action.flex-column.align-items-start.active{:href => "#!"}
.list-group
- @timeline.each do |event|
.d-flex.justify-content-between
%h5
- owner = Member.find(event.owner_id)
= render 'members/tiny', member: owner
= icon_for_model(event.event_type)
= link_to owner, owner
= event_description(event)
%small= time_ago_in_words event.event_at
- if event.crop_id.present?
= render 'crops/thumbnail', crop: Crop.find(event.crop_id)
.list-group-item.list-group-item-action.flex-column.align-items-start{:href => "#!"}
.d-flex.w-100.justify-content-between
%h5
= icon_for_model(event.event_type)
- owner = Member.find(event.owner_id)
= link_to owner, owner
= event_description(event)
= render 'timeline/photos', photo: resolve_model(event) if event.event_type == 'photo'
%small
- if event.event_at.present?
#{time_ago_in_words(event.event_at)} ago
- else
unknown date
.pagination
= page_entries_info @seeds
= will_paginate @seeds