Gui improvements and ideas
This commit is contained in:
parent
3f4c7d17bf
commit
2ae0b55e42
54 changed files with 639 additions and 237 deletions
|
|
@ -1,4 +1,18 @@
|
|||
class ChecklistEntry < ApplicationRecord
|
||||
belongs_to :checklist
|
||||
belongs_to :check
|
||||
|
||||
before_validation :set_position
|
||||
after_validation :normalize_positions
|
||||
|
||||
def set_position
|
||||
self.position ||= checklist.checklist_entries.maximum(:position).to_i + 1
|
||||
end
|
||||
|
||||
def normalize_positions
|
||||
checklist.checklist_entries.where.not(id:).find_by(position:)&.update_attribute(:position, position_was)
|
||||
# checklist.checklist_entries.order(:position).each_with_index do |entry, index|
|
||||
# entry.update_column(:position, index + 1) if entry.position != index + 1
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue