consistent updated display

This commit is contained in:
Torsten 2022-12-26 20:58:34 +02:00
parent ba022b5259
commit cbaf858b1c
7 changed files with 53 additions and 43 deletions

View File

@ -19,16 +19,8 @@ module Merged
Section.where(page_id: id).order(index: :asc)
end
def section_update
last = Time.now
last_section = nil
sections.each do |section|
if( section.updated_at < last )
last = section.updated_at
last_section = section
end
end
last_section
def sections_update
last_update_for( sections )
end
def template_style

View File

@ -15,6 +15,10 @@ module Merged
Card.where(section_id: id).order(index: :asc)
end
def cards_update
last_update_for( cards )
end
def template_style
SectionStyle.find_by_template( template )
end

View File

@ -12,6 +12,18 @@ module Merged
fields :options , :updated_at , :updated_by
def last_update_for(elements)
last = Time.now
last_section = nil
elements.each do |section|
if( section.updated_at < last )
last = section.updated_at
last_section = section
end
end
last_section
end
def edit_save( editor )
self.updated_at = Time.now
self.updated_by = editor

View File

@ -24,6 +24,12 @@
%h3.mt-4.text-lg.font-bold Image
= yellow_button("Change Image" , merged.images_path(card_id: card.id) )
= red_button("Remove image", merged.card_set_image_path( card.id , image: "") )
.basis-full.mt-3
Updated at:
= distance_of_time_in_words_to_now(card.updated_at)
.basis-full.mb-3
Updated by:
= card.updated_by
.basis-96
%h3.mt-4.text-lg.font-bold Image

View File

@ -7,30 +7,11 @@
%table.min-w-full.divide-y.divide-gray-200.text-sm
%thead.bg-gray-100
%tr
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
.flex.items-center.gap-2
Index
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
.flex.items-center.gap-2
Name
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
.flex.items-center.gap-2
Sections
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
.flex.items-center.gap-2
Updated
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
.flex.items-center.gap-2
Edited by
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
.flex.items-center.gap-2
Sections at
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
.flex.items-center.gap-2
Sections by
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
.flex.items-center.gap-2
Actions
-["Index", "Name","Sections" ,"Updated" ,"Edited by" ,
"Sections at", "Sections by","Actions"].each do |header|
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
.flex.items-center.gap-2
= header
%tbody.divide-y.divide-gray-200
- @pages.each do |page|
%tr{id: page.name}
@ -44,9 +25,9 @@
= distance_of_time_in_words_to_now(page.updated_at)
%td.whitespace-nowrap.px-4.py-2.text-gray-700
=page.updated_by
- s = page.section_update
- s = page.sections_update
%td.whitespace-nowrap.px-4.py-2.text-gray-700
=s.updated_at.to_date
=distance_of_time_in_words_to_now(s.updated_at)
%td.whitespace-nowrap.px-4.py-2.text-gray-700
=s.updated_by
%td.whitespace-nowrap.px-4.py-2

View File

@ -9,7 +9,7 @@
-@page.sections.each do |section |
.flex.gap-10.p-4{class: (section.index%2)==1 ? 'bg-cyan-50' : 'bg-red-50' , id: "section_#{section.id}"}
.basis-60
.basis-72
%h3.mt-4.text-lg.font-bold Section #{section.index} : #{section.header}
.flex.flex-wrap
= yellow_button("Edit" , merged.section_path(section.id) )
@ -24,13 +24,22 @@
%path{:d => "M15.75 17.25L12 21m0 0l-3.75-3.75M12 21V3", "stroke-linecap" => "round", "stroke-linejoin" => "round"}
.basis-full.mt-3
Updated at:
= section.updated_at.to_date
= distance_of_time_in_words_to_now(section.updated_at)
.basis-full.mb-3
Updated by:
= section.updated_by
- if section.has_cards?
- card = section.cards_update
.basis-full
Cards updated at:
= distance_of_time_in_words_to_now(card.updated_at)
.basis-full.mb-3
Cards updated by:
= card.updated_by
.basis-full.mb-3
= form_tag( merged.section_path(section.id) , {method: :delete } ) do
=submit_button( "Delete" , true)
.basis-72
%h3.mt-4.text-lg.font-bold Template
= link_to(merged.section_select_template_path(section.id)) do
@ -53,12 +62,12 @@
= image_for( section , "h-40")
-else
%p No image
.basis-52.grow
.basis-96
%h3.mt-4.text-lg.font-bold Options
- section.options.each do|name , value|
%p
= name
= value
.grid.grid-cols-2.gap-3.mx-10
- section.options.each do|name , value|
.font-bold.mt-1= name.camelcase
.font-xl= value
.grid.grid-cols-2.gap-2.m-8
.relative.block
%p

View File

@ -12,6 +12,12 @@
= section_preview(@section , class: "w-full object-contain my-4")
= yellow_button( "Change Template" , merged.section_select_template_path(@section.id))
= green_button( "New Section" , merged.new_page_section_path(@section.page.id , template: @section.template) )
.basis-full.mt-3
Updated at:
= distance_of_time_in_words_to_now(@section.updated_at)
.basis-full.mb-3
Updated by:
= @section.updated_by
.basis-96
%h3.mt-4.text-lg.font-bold Image