mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-26 16:53:12 +08:00
SCI-4601 fix the associations, minor styling changes
This commit is contained in:
parent
f089e4abc8
commit
76232f0298
3 changed files with 8 additions and 4 deletions
|
@ -7,7 +7,7 @@ class RepositoryDateTimeRangeValueBase < ApplicationRecord
|
|||
inverse_of: :created_repository_date_time_values
|
||||
belongs_to :last_modified_by, foreign_key: :last_modified_by_id, class_name: 'User', optional: true,
|
||||
inverse_of: :modified_repository_date_time_values
|
||||
has_one :repository_cell, as: :value, dependent: :destroy, inverse_of: :repository_date_time_value
|
||||
has_one :repository_cell, as: :value, dependent: :destroy, inverse_of: :value
|
||||
accepts_nested_attributes_for :repository_cell
|
||||
|
||||
validates :repository_cell, :start_time, :end_time, :type, presence: true
|
||||
|
|
|
@ -10,4 +10,8 @@ class RepositoryStatusItem < ApplicationRecord
|
|||
belongs_to :last_modified_by, foreign_key: 'last_modified_by_id', class_name: 'User', optional: true,
|
||||
inverse_of: :modified_repository_status_types
|
||||
has_many :repository_status_values, inverse_of: :repository_status_item, dependent: :destroy
|
||||
|
||||
def data
|
||||
"#{icon} #{status}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,12 +31,12 @@ class RepositoryStatusValue < ApplicationRecord
|
|||
|
||||
def snapshot!(cell_snapshot)
|
||||
value_snapshot = dup
|
||||
list_item = cell_snapshot.repository_column
|
||||
status_item = cell_snapshot.repository_column
|
||||
.repository_status_items
|
||||
.find { |item| item.data == repository_status_item.data }
|
||||
value_snapshot.assign_attributes(
|
||||
repository_cell: cell_snapshot,
|
||||
repository_status_item: list_item,
|
||||
repository_status_item: status_item,
|
||||
created_at: created_at,
|
||||
updated_at: updated_at
|
||||
)
|
||||
|
@ -46,7 +46,7 @@ class RepositoryStatusValue < ApplicationRecord
|
|||
def data
|
||||
return nil unless repository_status_item
|
||||
|
||||
"#{repository_status_item.icon} #{repository_status_item.status}"
|
||||
repository_status_item.data
|
||||
end
|
||||
|
||||
def self.new_with_payload(payload, attributes)
|
||||
|
|
Loading…
Reference in a new issue