From 97f5a7e9fcc092e8422a95ef3061e6b433d68745 Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Thu, 11 Jun 2020 16:10:38 +0200 Subject: [PATCH] Fix smart annotation in inventory on edit --- .../javascripts/repositories/renderers/edit_renderers.js | 2 +- .../javascripts/repositories/renderers/view_renderers.js | 3 ++- .../repository_text_value_serializer.rb | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/repositories/renderers/edit_renderers.js b/app/assets/javascripts/repositories/renderers/edit_renderers.js index 3bb608bbe..067499ff5 100644 --- a/app/assets/javascripts/repositories/renderers/edit_renderers.js +++ b/app/assets/javascripts/repositories/renderers/edit_renderers.js @@ -27,7 +27,7 @@ $.fn.dataTable.render.editRepositoryAssetValue = function(formId, columnId, cell $.fn.dataTable.render.editRepositoryTextValue = function(formId, columnId, cell) { let $cell = $(cell.node()); - let text = $cell.text(); + let text = $cell.find('.text-value').data('edit-value'); $cell.html(`
diff --git a/app/assets/javascripts/repositories/renderers/view_renderers.js b/app/assets/javascripts/repositories/renderers/view_renderers.js index cfca42aeb..8d23fce1f 100644 --- a/app/assets/javascripts/repositories/renderers/view_renderers.js +++ b/app/assets/javascripts/repositories/renderers/view_renderers.js @@ -26,7 +26,8 @@ $.fn.dataTable.render.defaultRepositoryAssetValue = function() { }; $.fn.dataTable.render.RepositoryTextValue = function(data) { - return data.value; + var text = $(`${data.value.view}`); + return text.prop('outerHTML'); }; $.fn.dataTable.render.defaultRepositoryTextValue = function() { diff --git a/app/serializers/repository_datatable/repository_text_value_serializer.rb b/app/serializers/repository_datatable/repository_text_value_serializer.rb index 60a788f97..c505abbc2 100644 --- a/app/serializers/repository_datatable/repository_text_value_serializer.rb +++ b/app/serializers/repository_datatable/repository_text_value_serializer.rb @@ -8,9 +8,10 @@ module RepositoryDatatable def value @user = scope[:user] - custom_auto_link(object.data, - simple_format: true, - team: scope[:team]) + { + view: custom_auto_link(object.data, simple_format: true, team: scope[:team]), + edit: sanitize_input(object.data) + } end end end