Merge pull request #2285 from urbanrotnik/ur-sci-4154-export-and-import

Export/Import for new column types [SCI-4153]
This commit is contained in:
Urban Rotnik 2020-01-10 11:31:23 +01:00 committed by GitHub
commit 92f432b86a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 31 additions and 5 deletions

View file

@ -58,4 +58,6 @@ class RepositoryAssetValue < ApplicationRecord
value.asset.post_process_file(team)
value
end
alias export_formatted formatted
end

View file

@ -14,8 +14,12 @@ class RepositoryChecklistValue < ApplicationRecord
SORTABLE_COLUMN_NAME = 'repository_checklist_items.data'
SORTABLE_VALUE_INCLUDE = { repository_checklist_value: :repository_checklist_items }.freeze
def formatted
repository_checklist_items.pluck(:data).join(' | ')
def formatted(separator: ' | ')
repository_checklist_items.pluck(:data).join(separator)
end
def export_formatted
formatted(separator: "\n")
end
def data

View file

@ -20,4 +20,6 @@ class RepositoryDateRangeValue < RepositoryDateTimeRangeValueBase
value.end_time = Time.zone.parse(data[:end_time])
value
end
alias export_formatted formatted
end

View file

@ -20,4 +20,6 @@ class RepositoryDateTimeRangeValue < RepositoryDateTimeRangeValueBase
value.end_time = Time.zone.parse(data[:end_time])
value
end
alias export_formatted formatted
end

View file

@ -10,7 +10,7 @@ class RepositoryDateTimeRangeValueBase < ApplicationRecord
has_one :repository_cell, as: :value, dependent: :destroy, inverse_of: :repository_date_time_value
accepts_nested_attributes_for :repository_cell
validates :repository_cell, :start_time, :end_time, presence: true
validates :repository_cell, :start_time, :end_time, :type, presence: true
SORTABLE_COLUMN_NAME = 'repository_date_time_values.start_time'
SORTABLE_VALUE_INCLUDE = :repository_date_time_range_value

View file

@ -15,4 +15,6 @@ class RepositoryDateTimeValue < RepositoryDateTimeValueBase
value.data = Time.zone.parse(payload)
value
end
alias export_formatted formatted
end

View file

@ -10,7 +10,7 @@ class RepositoryDateTimeValueBase < ApplicationRecord
has_one :repository_cell, as: :value, dependent: :destroy, inverse_of: :repository_date_time_value
accepts_nested_attributes_for :repository_cell
validates :repository_cell, :data, presence: true
validates :repository_cell, :data, :type, presence: true
SORTABLE_COLUMN_NAME = 'repository_date_time_values.data'
SORTABLE_VALUE_INCLUDE = :repository_date_time_value

View file

@ -15,4 +15,6 @@ class RepositoryDateValue < RepositoryDateTimeValueBase
value.data = Time.zone.parse(payload)
value
end
alias export_formatted formatted
end

View file

@ -47,4 +47,6 @@ class RepositoryListValue < ApplicationRecord
.find(payload)
value
end
alias export_formatted formatted
end

View file

@ -32,4 +32,6 @@ class RepositoryNumberValue < ApplicationRecord
value.data = payload.to_f
value
end
alias export_formatted formatted
end

View file

@ -42,4 +42,6 @@ class RepositoryStatusValue < ApplicationRecord
.find(payload)
value
end
alias export_formatted formatted
end

View file

@ -33,4 +33,6 @@ class RepositoryTextValue < ApplicationRecord
value.data = payload
value
end
alias export_formatted formatted
end

View file

@ -21,4 +21,6 @@ class RepositoryTimeRangeValue < RepositoryDateTimeRangeValueBase
value.end_time = Time.zone.parse(data[:end_time])
value
end
alias export_formatted formatted
end

View file

@ -15,4 +15,6 @@ class RepositoryTimeValue < RepositoryDateTimeValueBase
value.data = Time.zone.parse(payload)
value
end
alias export_formatted formatted
end

View file

@ -66,7 +66,7 @@ module RepositoryZipExport
handle_file_name_func.call(cell.value.asset)
else
SmartAnnotations::TagToText.new(
user, team, cell.value.formatted
user, team, cell.value.export_formatted
).text
end
end