From 5a242021e36ca6a059a63768899bc32d5af16050 Mon Sep 17 00:00:00 2001 From: Anton Date: Thu, 16 Mar 2023 12:02:20 +0100 Subject: [PATCH] Fix handson table metadata issue [SCI-8138] --- .../javascripts/results/result_tables.js.erb | 20 ++++++++++++------- .../vue/protocol/step_elements/table.vue | 20 ++++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/results/result_tables.js.erb b/app/assets/javascripts/results/result_tables.js.erb index e51954a78..60c88ce47 100644 --- a/app/assets/javascripts/results/result_tables.js.erb +++ b/app/assets/javascripts/results/result_tables.js.erb @@ -39,13 +39,19 @@ var metadata = $('.hot-metadata'); var data = JSON.stringify({data: hot.getData()}); contents.attr('value', data); - metadata.attr('value', JSON.stringify({cells: hot.getCellsMeta().map((x) => { - return { - col: x.col, - row: x.row, - className: x.className || '' - } - })})) + metadata.attr('value', JSON.stringify({cells: hot.getCellsMeta().map( + (x) => { + if (x) { + return { + col: x.col, + row: x.row, + className: x.className || '' + } + } else { + return null + } + }).filter(e => { return e !== null}) + })) return true; }); } diff --git a/app/javascript/vue/protocol/step_elements/table.vue b/app/javascript/vue/protocol/step_elements/table.vue index 60f8d9195..f4ab3d3f0 100644 --- a/app/javascript/vue/protocol/step_elements/table.vue +++ b/app/javascript/vue/protocol/step_elements/table.vue @@ -158,13 +158,19 @@ let tableData = JSON.stringify({data: this.tableObject.getData()}); this.element.attributes.orderable.contents = tableData; - this.element.attributes.orderable.metadata = {cells: this.tableObject.getCellsMeta().map((x) => { - return { - col: x.col, - row: x.row, - className: x.className || '' - } - })}; + this.element.attributes.orderable.metadata = {cells: this.tableObject.getCellsMeta().map( + (x) => { + if (x) { + return { + col: x.col, + row: x.row, + className: x.className || '' + } + } else { + return null + } + }).filter(e => { return e !== null}) + }; this.update(); this.editingTable = false; },