Gui improvements, ordering
This commit is contained in:
parent
6db0b64f4c
commit
42c077f6ab
28 changed files with 105 additions and 40 deletions
|
|
@ -8,6 +8,8 @@ class Element < ApplicationRecord
|
|||
|
||||
delegate :report, to: :page
|
||||
|
||||
after_validation :set_position
|
||||
|
||||
# Calculate actual conformity level:
|
||||
# - if a success_criterion has result :failed -> the confirmity_level
|
||||
# of that success_criterion is not reached.
|
||||
|
|
@ -30,4 +32,9 @@ class Element < ApplicationRecord
|
|||
def max_level
|
||||
@max_level ||= success_criteria.reject(&:not_applicable?).max(&:level)
|
||||
end
|
||||
|
||||
def set_position
|
||||
Rails.logger.debug("element: position #{position}")
|
||||
self.position ||= (page.elements.pluck(:position).max || 0) + 1
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,4 +3,11 @@ class Page < ApplicationRecord
|
|||
has_many :elements, dependent: :destroy
|
||||
|
||||
has_rich_text :comment
|
||||
|
||||
before_validation :set_position
|
||||
|
||||
private
|
||||
def set_position
|
||||
self.position ||= (report.pages.pluck(:position).max || 0) + 1
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ class SuccessCriterion < ApplicationRecord
|
|||
enum :result, %i[passed failed not_applicable]
|
||||
enum :level, %i[A AA AAA]
|
||||
|
||||
before_save :set_position
|
||||
|
||||
def level_value
|
||||
return nil unless level
|
||||
|
||||
|
|
@ -23,4 +25,10 @@ class SuccessCriterion < ApplicationRecord
|
|||
def header
|
||||
"HEADER"
|
||||
end
|
||||
|
||||
private
|
||||
def set_position
|
||||
self.position ||= (element.success_criteria.pluck(:position).max || 0) + 1
|
||||
Rails.logger.debug("set position: "+position.to_s)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue