From d5675c0c337e9ac71e05c189147f54a0f54807ca Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Fri, 10 Jan 2020 12:56:57 +0100 Subject: [PATCH] Add smart annotations to repository text value --- app/helpers/repository_datatable_helper.rb | 8 ++++---- .../repository_text_value_serializer.rb | 9 ++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/helpers/repository_datatable_helper.rb b/app/helpers/repository_datatable_helper.rb index a96e8d103..cdaf226db 100644 --- a/app/helpers/repository_datatable_helper.rb +++ b/app/helpers/repository_datatable_helper.rb @@ -6,7 +6,7 @@ module RepositoryDatatableHelper def prepare_row_columns(repository_rows, repository, columns_mappings, - _team, + team, assigned_rows) parsed_records = [] includes_json = { repository_cells: Extends::REPOSITORY_SEARCH_INCLUDES } @@ -36,7 +36,7 @@ module RepositoryDatatableHelper # Add custom columns record.repository_cells.each do |cell| row[columns_mappings[cell.repository_column.id]] = - display_cell_value(cell) + display_cell_value(cell, team) end parsed_records << row end @@ -66,8 +66,8 @@ module RepositoryDatatableHelper Constants::REPOSITORY_TABLE_DEFAULT_STATE['columns'].to_json end - def display_cell_value(cell) + def display_cell_value(cell, team) "RepositoryDatatable::#{cell.repository_column.data_type}Serializer" - .constantize.new(cell.value).serializable_hash + .constantize.new(cell.value, scope: { team: team, user: current_user }).serializable_hash end end diff --git a/app/serializers/repository_datatable/repository_text_value_serializer.rb b/app/serializers/repository_datatable/repository_text_value_serializer.rb index c10c5ac17..60a788f97 100644 --- a/app/serializers/repository_datatable/repository_text_value_serializer.rb +++ b/app/serializers/repository_datatable/repository_text_value_serializer.rb @@ -2,8 +2,15 @@ module RepositoryDatatable class RepositoryTextValueSerializer < RepositoryBaseValueSerializer + include InputSanitizeHelper + include ActionView::Helpers::TextHelper + include ApplicationHelper + def value - object.data + @user = scope[:user] + custom_auto_link(object.data, + simple_format: true, + team: scope[:team]) end end end