From 9296f0eb4fdc9d481a59d0ebfa641a3a34d82236 Mon Sep 17 00:00:00 2001 From: Urban Rotnik Date: Fri, 10 Jan 2020 09:29:20 +0100 Subject: [PATCH] Add extra format for exports --- app/models/repository_asset_value.rb | 2 ++ app/models/repository_checklist_value.rb | 8 ++++++-- app/models/repository_date_range_value.rb | 2 ++ app/models/repository_date_time_range_value.rb | 2 ++ app/models/repository_date_time_value.rb | 2 ++ app/models/repository_date_value.rb | 2 ++ app/models/repository_list_value.rb | 2 ++ app/models/repository_number_value.rb | 2 ++ app/models/repository_status_value.rb | 2 ++ app/models/repository_text_value.rb | 2 ++ app/models/repository_time_range_value.rb | 2 ++ app/models/repository_time_value.rb | 2 ++ app/services/repository_zip_export.rb | 2 +- 13 files changed, 29 insertions(+), 3 deletions(-) diff --git a/app/models/repository_asset_value.rb b/app/models/repository_asset_value.rb index 49ee94d3e..d5a7d956e 100644 --- a/app/models/repository_asset_value.rb +++ b/app/models/repository_asset_value.rb @@ -58,4 +58,6 @@ class RepositoryAssetValue < ApplicationRecord value.asset.post_process_file(team) value end + + alias export_formatted formatted end diff --git a/app/models/repository_checklist_value.rb b/app/models/repository_checklist_value.rb index 98daaf1b6..aa113b18c 100644 --- a/app/models/repository_checklist_value.rb +++ b/app/models/repository_checklist_value.rb @@ -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 diff --git a/app/models/repository_date_range_value.rb b/app/models/repository_date_range_value.rb index e1429a24c..06aeed0a0 100644 --- a/app/models/repository_date_range_value.rb +++ b/app/models/repository_date_range_value.rb @@ -20,4 +20,6 @@ class RepositoryDateRangeValue < RepositoryDateTimeRangeValueBase value.end_time = Time.zone.parse(data[:end_time]) value end + + alias export_formatted formatted end diff --git a/app/models/repository_date_time_range_value.rb b/app/models/repository_date_time_range_value.rb index 716eae496..5e0587c19 100644 --- a/app/models/repository_date_time_range_value.rb +++ b/app/models/repository_date_time_range_value.rb @@ -20,4 +20,6 @@ class RepositoryDateTimeRangeValue < RepositoryDateTimeRangeValueBase value.end_time = Time.zone.parse(data[:end_time]) value end + + alias export_formatted formatted end diff --git a/app/models/repository_date_time_value.rb b/app/models/repository_date_time_value.rb index f1e42f7ec..6955eef75 100644 --- a/app/models/repository_date_time_value.rb +++ b/app/models/repository_date_time_value.rb @@ -15,4 +15,6 @@ class RepositoryDateTimeValue < RepositoryDateTimeValueBase value.data = Time.zone.parse(payload) value end + + alias export_formatted formatted end diff --git a/app/models/repository_date_value.rb b/app/models/repository_date_value.rb index 3e9eb30fb..6791f8295 100644 --- a/app/models/repository_date_value.rb +++ b/app/models/repository_date_value.rb @@ -15,4 +15,6 @@ class RepositoryDateValue < RepositoryDateTimeValueBase value.data = Time.zone.parse(payload) value end + + alias export_formatted formatted end diff --git a/app/models/repository_list_value.rb b/app/models/repository_list_value.rb index 1ef154bef..84cca6c24 100644 --- a/app/models/repository_list_value.rb +++ b/app/models/repository_list_value.rb @@ -47,4 +47,6 @@ class RepositoryListValue < ApplicationRecord .find(payload) value end + + alias export_formatted formatted end diff --git a/app/models/repository_number_value.rb b/app/models/repository_number_value.rb index ff3244c4c..5b53a32b9 100644 --- a/app/models/repository_number_value.rb +++ b/app/models/repository_number_value.rb @@ -32,4 +32,6 @@ class RepositoryNumberValue < ApplicationRecord value.data = payload.to_f value end + + alias export_formatted formatted end diff --git a/app/models/repository_status_value.rb b/app/models/repository_status_value.rb index e26994707..d374c6ba0 100644 --- a/app/models/repository_status_value.rb +++ b/app/models/repository_status_value.rb @@ -42,4 +42,6 @@ class RepositoryStatusValue < ApplicationRecord .find(payload) value end + + alias export_formatted formatted end diff --git a/app/models/repository_text_value.rb b/app/models/repository_text_value.rb index 61eb31857..2afd75ed7 100644 --- a/app/models/repository_text_value.rb +++ b/app/models/repository_text_value.rb @@ -33,4 +33,6 @@ class RepositoryTextValue < ApplicationRecord value.data = payload value end + + alias export_formatted formatted end diff --git a/app/models/repository_time_range_value.rb b/app/models/repository_time_range_value.rb index 9224fad90..ddb64b7cb 100644 --- a/app/models/repository_time_range_value.rb +++ b/app/models/repository_time_range_value.rb @@ -21,4 +21,6 @@ class RepositoryTimeRangeValue < RepositoryDateTimeRangeValueBase value.end_time = Time.zone.parse(data[:end_time]) value end + + alias export_formatted formatted end diff --git a/app/models/repository_time_value.rb b/app/models/repository_time_value.rb index 835621622..95665e1d4 100644 --- a/app/models/repository_time_value.rb +++ b/app/models/repository_time_value.rb @@ -15,4 +15,6 @@ class RepositoryTimeValue < RepositoryDateTimeValueBase value.data = Time.zone.parse(payload) value end + + alias export_formatted formatted end diff --git a/app/services/repository_zip_export.rb b/app/services/repository_zip_export.rb index 1c862ede6..9dd54c591 100644 --- a/app/services/repository_zip_export.rb +++ b/app/services/repository_zip_export.rb @@ -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