From 19cad569b39283a64732382dd483cbe9213363bf Mon Sep 17 00:00:00 2001 From: Soufiane Date: Tue, 16 May 2023 11:19:56 +0200 Subject: [PATCH] Cache the values of formulas of HOT tables in meta data [SCI-8173] (#5406) --- .../vue/protocol/step_elements/table.vue | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/app/javascript/vue/protocol/step_elements/table.vue b/app/javascript/vue/protocol/step_elements/table.vue index 15f18e0cf..3c92349f5 100644 --- a/app/javascript/vue/protocol/step_elements/table.vue +++ b/app/javascript/vue/protocol/step_elements/table.vue @@ -162,18 +162,23 @@ update() { this.element.attributes.orderable.contents = JSON.stringify({ data: this.tableObject.getData() }); this.element.attributes.orderable.metadata = JSON.stringify({ - 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 }) + cells: this.tableObject + .getCellsMeta() + .filter(e => !!e) + .map((x) => { + const {row, col} = x; + const plugins = this.tableObject.plugin; + const cellId = plugins.utils.translateCellCoords({row, col}); + const calculated = plugins.matrix.getItem(cellId)?.value || + this.tableObject.getDataAtCell(row, col) || + null; + return { + row: row, + col: col, + className: x.className || '', + calculated: calculated + } + }) }); this.$emit('update', this.element) this.ajax_update_url()