diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index b7e4fb248..536b0c688 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -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 diff --git a/app/views/timeline/_photos.html.haml b/app/views/timeline/_photos.html.haml new file mode 100644 index 000000000..12cddb1a2 --- /dev/null +++ b/app/views/timeline/_photos.html.haml @@ -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) \ No newline at end of file diff --git a/app/views/timeline/index.html.haml b/app/views/timeline/index.html.haml index 8c3a0c0a4..d6e293691 100644 --- a/app/views/timeline/index.html.haml +++ b/app/views/timeline/index.html.haml @@ -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