mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-16 14:17:00 +08:00
Add previewable update_data! to repository checklist value [SCI-10582]
This commit is contained in:
parent
e1ecc9f584
commit
cf0799462a
1 changed files with 14 additions and 5 deletions
|
@ -1,6 +1,8 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class RepositoryChecklistValue < ApplicationRecord
|
class RepositoryChecklistValue < ApplicationRecord
|
||||||
|
attribute :current_repository_checklist_items
|
||||||
|
|
||||||
belongs_to :created_by, foreign_key: 'created_by_id', class_name: 'User',
|
belongs_to :created_by, foreign_key: 'created_by_id', class_name: 'User',
|
||||||
inverse_of: :created_repository_checklist_values
|
inverse_of: :created_repository_checklist_values
|
||||||
belongs_to :last_modified_by, foreign_key: 'last_modified_by_id', class_name: 'User',
|
belongs_to :last_modified_by, foreign_key: 'last_modified_by_id', class_name: 'User',
|
||||||
|
@ -78,11 +80,18 @@ class RepositoryChecklistValue < ApplicationRecord
|
||||||
|
|
||||||
self.last_modified_by = user
|
self.last_modified_by = user
|
||||||
|
|
||||||
self.repository_checklist_items = repository_cell.repository_column
|
if preview
|
||||||
.repository_checklist_items
|
self.current_repository_checklist_items = repository_checklist_items
|
||||||
.where(id: item_ids)
|
clear_current_repository_checklist_items_change
|
||||||
|
self.current_repository_checklist_items =
|
||||||
preview ? validate : save!
|
repository_cell.repository_column.repository_checklist_items.where(id: item_ids)
|
||||||
|
validate
|
||||||
|
else
|
||||||
|
self.repository_checklist_items = repository_cell.repository_column
|
||||||
|
.repository_checklist_items
|
||||||
|
.where(id: item_ids)
|
||||||
|
save!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def snapshot!(cell_snapshot)
|
def snapshot!(cell_snapshot)
|
||||||
|
|
Loading…
Reference in a new issue