track last edit
This commit is contained in:
parent
178c0ba9d2
commit
b9c6b12131
@ -31,7 +31,7 @@ module Merged
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@card.delete_and_reset_index
|
@card.delete_and_reset_index(current_member.email)
|
||||||
redirect_to section_cards_url(@card.section.id) , notice: "#{@card.header} removed"
|
redirect_to section_cards_url(@card.section.id) , notice: "#{@card.header} removed"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ module Merged
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@page.delete_save!
|
@page.delete_save!(current_member.email)
|
||||||
redirect_to pages_url, notice: "Page #{@page.name} was removed."
|
redirect_to pages_url, notice: "Page #{@page.name} was removed."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ module Merged
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@section.delete_and_reset_index
|
@section.delete_and_reset_index(current_member.email)
|
||||||
redirect_to page_sections_url(@section.page.id) , notice: "Section #{@section.header} removed"
|
redirect_to page_sections_url(@section.page.id) , notice: "Section #{@section.header} removed"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -68,6 +68,38 @@ module Merged
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def last_change_digit
|
||||||
|
last = ChangeSet.current.last
|
||||||
|
puts "digit in #{last}"
|
||||||
|
return 10 unless last
|
||||||
|
last = (Time.now - last).to_i
|
||||||
|
puts "digit minus #{last}"
|
||||||
|
return 10 if ( last >= 600 )
|
||||||
|
digit = last / 60
|
||||||
|
puts "digit ret #{digit}"
|
||||||
|
digit
|
||||||
|
end
|
||||||
|
|
||||||
|
def last_change_class
|
||||||
|
digit = last_change_digit
|
||||||
|
return button_classes if digit > 9
|
||||||
|
digit = 9 - digit
|
||||||
|
reds = { "1" => "bg-red-100","2" => "bg-red-200","3" => "bg-red-100",
|
||||||
|
"4" => "bg-red-400","5" => "bg-red-500","6" => "bg-red-600",
|
||||||
|
"7" => "bg-red-700","8" => "bg-red-600","9" => "bg-red-900"}
|
||||||
|
|
||||||
|
clazz = reds[digit.to_s].to_s
|
||||||
|
clazz += " " + "text-white" if digit > 7
|
||||||
|
button_classes + " " + clazz
|
||||||
|
end
|
||||||
|
|
||||||
|
def last_change_text
|
||||||
|
digit = last_change_digit
|
||||||
|
return "no change" if digit > 9
|
||||||
|
"#{digit} min. by #{ChangeSet.current.last_editor}"
|
||||||
|
end
|
||||||
|
|
||||||
def button_classes
|
def button_classes
|
||||||
"mr-3 inline-block rounded-lg px-4 py-3 text-md font-medium border border-gray-400"
|
"mr-3 inline-block rounded-lg px-4 py-3 text-md font-medium border border-gray-400"
|
||||||
end
|
end
|
||||||
|
@ -5,11 +5,11 @@ module Merged
|
|||||||
def edit_save( editor )
|
def edit_save( editor )
|
||||||
self.updated_at = Time.now
|
self.updated_at = Time.now
|
||||||
self.updated_by = editor
|
self.updated_by = editor
|
||||||
edit_save!
|
edit_save!(editor)
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit_save!
|
def edit_save!(editor)
|
||||||
ChangeSet.current.edit(self.class.name , self.change_name)
|
ChangeSet.current.edit(self.class.name , self.change_name, editor)
|
||||||
save!()
|
save!()
|
||||||
self.class.save_all
|
self.class.save_all
|
||||||
end
|
end
|
||||||
@ -17,17 +17,17 @@ module Merged
|
|||||||
def add_save( editor )
|
def add_save( editor )
|
||||||
self.updated_at = Time.now
|
self.updated_at = Time.now
|
||||||
self.updated_by = editor
|
self.updated_by = editor
|
||||||
add_save!
|
add_save!(editor)
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_save!
|
def add_save!(editor)
|
||||||
ChangeSet.current.add(self.class.name , self.change_name)
|
ChangeSet.current.add(self.class.name , self.change_name, editor)
|
||||||
save!()
|
save!()
|
||||||
self.class.save_all
|
self.class.save_all
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_save!
|
def delete_save!(editor)
|
||||||
ChangeSet.current.delete(self.class.name , self.change_name)
|
ChangeSet.current.delete(self.class.name , self.change_name,editor)
|
||||||
self.class.delete(self.id)
|
self.class.delete(self.id)
|
||||||
self.class.save_all
|
self.class.save_all
|
||||||
end
|
end
|
||||||
|
@ -38,8 +38,8 @@ module Merged
|
|||||||
CardStyle.find_by_template( self.template )
|
CardStyle.find_by_template( self.template )
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_and_reset_index
|
def delete_and_reset_index(editor)
|
||||||
delete_save!
|
delete_save!(editor)
|
||||||
section.reset_index
|
section.reset_index
|
||||||
Section.find(section_id).reset_index
|
Section.find(section_id).reset_index
|
||||||
Card.save_all
|
Card.save_all
|
||||||
|
@ -5,7 +5,7 @@ module Merged
|
|||||||
def self.current
|
def self.current
|
||||||
@@current ||= ChangeSet.new
|
@@current ||= ChangeSet.new
|
||||||
end
|
end
|
||||||
attr_reader :adds , :edits , :deletes
|
attr_reader :adds , :edits , :deletes , :last , :last_editor
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
zero
|
zero
|
||||||
@ -16,16 +16,26 @@ module Merged
|
|||||||
@adds = Set.new
|
@adds = Set.new
|
||||||
@edits = Set.new
|
@edits = Set.new
|
||||||
@deletes = Set.new
|
@deletes = Set.new
|
||||||
|
@last = nil
|
||||||
|
@last_editor = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def add( type , text)
|
def touch(editor)
|
||||||
|
@last = Time.now
|
||||||
|
@last_editor = editor
|
||||||
|
end
|
||||||
|
|
||||||
|
def add( type , text , editor)
|
||||||
|
touch(editor)
|
||||||
@adds << [typed(type) , text ]
|
@adds << [typed(type) , text ]
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit( type , text)
|
def edit( type , text, editor)
|
||||||
|
touch(editor)
|
||||||
@edits << [typed(type) , text ]
|
@edits << [typed(type) , text ]
|
||||||
end
|
end
|
||||||
def delete( type , text)
|
def delete( type , text, editor)
|
||||||
|
touch(editor)
|
||||||
@deletes << [typed(type) , text ]
|
@deletes << [typed(type) , text ]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ module Merged
|
|||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
File.delete self.full_filename
|
File.delete self.full_filename
|
||||||
delete_save!
|
delete_save!(current_member.email)
|
||||||
end
|
end
|
||||||
|
|
||||||
def asset_name
|
def asset_name
|
||||||
|
@ -51,9 +51,9 @@ module Merged
|
|||||||
sections.each_with_index{|section, index| section.index = index + 1}
|
sections.each_with_index{|section, index| section.index = index + 1}
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete
|
def delete(editor)
|
||||||
sections.each {|section| section.delete }
|
sections.each {|section| section.delete(editor) }
|
||||||
delete_save!
|
delete_save!(editor)
|
||||||
end
|
end
|
||||||
|
|
||||||
def save(editor)
|
def save(editor)
|
||||||
|
@ -37,15 +37,6 @@ module Merged
|
|||||||
! card_template.blank?
|
! card_template.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_card(card)
|
|
||||||
from_index = card.index
|
|
||||||
@cards.delete_at(from_index)
|
|
||||||
@content["cards"].delete_at(from_index)
|
|
||||||
@cards.each_with_index do |card, index|
|
|
||||||
card.set_index(index)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def move_up
|
def move_up
|
||||||
swap_index_with(next_section)
|
swap_index_with(next_section)
|
||||||
end
|
end
|
||||||
@ -71,13 +62,13 @@ module Merged
|
|||||||
cards.each_with_index{|card, index| card.index = index + 1}
|
cards.each_with_index{|card, index| card.index = index + 1}
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete
|
def delete(editor)
|
||||||
cards.each {|card| card.delete_save! }
|
cards.each {|card| card.delete_save!(editor) }
|
||||||
delete_save!()
|
delete_save!(editor)
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_and_reset_index
|
def delete_and_reset_index(editor)
|
||||||
delete
|
delete(editor)
|
||||||
Page.find(page_id).reset_index
|
Page.find(page_id).reset_index
|
||||||
Section.save_all
|
Section.save_all
|
||||||
end
|
end
|
||||||
|
@ -17,3 +17,5 @@
|
|||||||
%a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => merged.changes_index_path}
|
%a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => merged.changes_index_path}
|
||||||
Changes
|
Changes
|
||||||
= yield :merged_menu
|
= yield :merged_menu
|
||||||
|
|
||||||
|
%button.my-3{class: last_change_class}= last_change_text
|
||||||
|
@ -8,20 +8,20 @@ module Merged
|
|||||||
|
|
||||||
def test_deletes
|
def test_deletes
|
||||||
id = first.id
|
id = first.id
|
||||||
first.delete_save!
|
first.delete_save!("random")
|
||||||
assert_raises(ActiveHash::RecordNotFound) {Card.find(id) }
|
assert_raises(ActiveHash::RecordNotFound) {Card.find(id) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_delete_index
|
def test_delete_index
|
||||||
section = first.section
|
section = first.section
|
||||||
index = first.index
|
index = first.index
|
||||||
first.delete_and_reset_index
|
first.delete_and_reset_index("me")
|
||||||
assert_equal index , section.cards.first.index
|
assert_equal index , section.cards.first.index
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_adds
|
def test_adds
|
||||||
card = Card.first.section.new_card
|
card = Card.first.section.new_card
|
||||||
card.add_save!
|
card.add_save!("me me")
|
||||||
assert_equal "NEW" , card.header
|
assert_equal "NEW" , card.header
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -12,17 +12,17 @@ module Merged
|
|||||||
class ChangeSetTest < ActiveSupport::TestCase
|
class ChangeSetTest < ActiveSupport::TestCase
|
||||||
include Zero
|
include Zero
|
||||||
def test_has_add
|
def test_has_add
|
||||||
change.add("Section" , "name")
|
change.add("Section" , "name" , "you")
|
||||||
assert_equal "name", change.added("Section").first.last
|
assert_equal "name", change.added("Section").first.last
|
||||||
assert_equal :Section, change.added("Section").first.first
|
assert_equal :Section, change.added("Section").first.first
|
||||||
end
|
end
|
||||||
def test_has_edit
|
def test_has_edit
|
||||||
change.edit("Section" , "name")
|
change.edit("Section" , "name" , "me")
|
||||||
assert_equal "name", change.edited("Section").first.last
|
assert_equal "name", change.edited("Section").first.last
|
||||||
assert_equal :Section, change.edited("Section").first.first
|
assert_equal :Section, change.edited("Section").first.first
|
||||||
end
|
end
|
||||||
def test_has_delete
|
def test_has_delete
|
||||||
change.delete("Section" , "name")
|
change.delete("Section" , "name", "him")
|
||||||
assert_equal "name", change.deleted("Section").first.last
|
assert_equal "name", change.deleted("Section").first.last
|
||||||
assert_equal :Section, change.deleted("Section").first.first
|
assert_equal :Section, change.deleted("Section").first.first
|
||||||
end
|
end
|
||||||
@ -69,19 +69,19 @@ module Merged
|
|||||||
|
|
||||||
def test_page_delete
|
def test_page_delete
|
||||||
studios = Page.first
|
studios = Page.first
|
||||||
studios.delete_save!
|
studios.delete_save!("random")
|
||||||
assert_equal "studios" , change.deleted("Page").first.last
|
assert_equal "studios" , change.deleted("Page").first.last
|
||||||
assert_nil change.edited("Page").first
|
assert_nil change.edited("Page").first
|
||||||
end
|
end
|
||||||
def test_section_delete
|
def test_section_delete
|
||||||
studios = Section.first
|
studios = Section.first
|
||||||
studios.delete_save!()
|
studios.delete_save!("me")
|
||||||
assert_equal "studios:Studios" , change.deleted("Section").first.last
|
assert_equal "studios:Studios" , change.deleted("Section").first.last
|
||||||
assert_nil change.edited("Section").first
|
assert_nil change.edited("Section").first
|
||||||
end
|
end
|
||||||
def test_card_delete
|
def test_card_delete
|
||||||
studios = Card.first
|
studios = Card.first
|
||||||
studios.delete_save!()
|
studios.delete_save!("you")
|
||||||
assert_equal "studios:Standard" , change.deleted("Card").first.last
|
assert_equal "studios:Standard" , change.deleted("Card").first.last
|
||||||
assert_nil change.edited("Card").first
|
assert_nil change.edited("Card").first
|
||||||
end
|
end
|
||||||
|
@ -28,18 +28,18 @@ module Merged
|
|||||||
|
|
||||||
def test_deletes
|
def test_deletes
|
||||||
id = index.id
|
id = index.id
|
||||||
index.delete
|
index.delete("you")
|
||||||
assert_raises(ActiveHash::RecordNotFound){Page.find(id) }
|
assert_raises(ActiveHash::RecordNotFound){Page.find(id) }
|
||||||
end
|
end
|
||||||
def test_destroys
|
def test_destroys
|
||||||
id = index.id
|
id = index.id
|
||||||
index.delete
|
index.delete("you")
|
||||||
Section.reload
|
Section.reload
|
||||||
assert_raises(ActiveHash::RecordNotFound){Page.find(id) }
|
assert_raises(ActiveHash::RecordNotFound){Page.find(id) }
|
||||||
end
|
end
|
||||||
def test_destroys_sections
|
def test_destroys_sections
|
||||||
id = index.sections.first.id
|
id = index.sections.first.id
|
||||||
index.delete
|
index.delete("you")
|
||||||
Section.reload
|
Section.reload
|
||||||
assert_raises(ActiveHash::RecordNotFound){Page.find(id) }
|
assert_raises(ActiveHash::RecordNotFound){Page.find(id) }
|
||||||
end
|
end
|
||||||
|
@ -19,14 +19,14 @@ module Merged
|
|||||||
|
|
||||||
def test_deletes
|
def test_deletes
|
||||||
last_id = last.id
|
last_id = last.id
|
||||||
last.delete
|
last.delete("you")
|
||||||
assert_raises(ActiveHash::RecordNotFound){Section.find(last_id) }
|
assert_raises(ActiveHash::RecordNotFound){Section.find(last_id) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_delete_index_section
|
def test_delete_index_section
|
||||||
eleven = Section.find 11
|
eleven = Section.find 11
|
||||||
page = eleven.page
|
page = eleven.page
|
||||||
eleven.delete
|
eleven.delete("you")
|
||||||
assert_equal eleven.index + 1 , page.sections.second.index
|
assert_equal eleven.index + 1 , page.sections.second.index
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -34,19 +34,19 @@ module Merged
|
|||||||
eleven = Section.find 11
|
eleven = Section.find 11
|
||||||
page = eleven.page
|
page = eleven.page
|
||||||
index = eleven.index
|
index = eleven.index
|
||||||
eleven.delete_and_reset_index
|
eleven.delete_and_reset_index("you")
|
||||||
assert_equal index , page.sections.second.index
|
assert_equal index , page.sections.second.index
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroys
|
def test_destroys
|
||||||
last_id = last.id
|
last_id = last.id
|
||||||
last.delete
|
last.delete("you")
|
||||||
Section.reload
|
Section.reload
|
||||||
assert_raises(ActiveHash::RecordNotFound){Section.find(last_id) }
|
assert_raises(ActiveHash::RecordNotFound){Section.find(last_id) }
|
||||||
end
|
end
|
||||||
def test_destroys_cards
|
def test_destroys_cards
|
||||||
card_id = last.cards.first.id
|
card_id = last.cards.first.id
|
||||||
last.delete
|
last.delete("you")
|
||||||
Section.reload
|
Section.reload
|
||||||
assert_raises(ActiveHash::RecordNotFound){Card.find(card_id) }
|
assert_raises(ActiveHash::RecordNotFound){Card.find(card_id) }
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user