diff --git a/app/controllers/step_elements/tables_controller.rb b/app/controllers/step_elements/tables_controller.rb index 1a81b1bd4..428bd3bf1 100644 --- a/app/controllers/step_elements/tables_controller.rb +++ b/app/controllers/step_elements/tables_controller.rb @@ -27,7 +27,7 @@ module StepElements ActiveRecord::Base.transaction do @table.assign_attributes(table_params.except(:metadata)) begin - @table.metadata = JSON.parse(table_params[:metadata]) + @table.metadata = JSON.parse(table_params[:metadata]) if table_params[:metadata].present? rescue JSON::ParserError @table.metadata = {} end diff --git a/app/javascript/vue/protocol/step_elements/table.vue b/app/javascript/vue/protocol/step_elements/table.vue index 47a1636e9..86a7e61da 100644 --- a/app/javascript/vue/protocol/step_elements/table.vue +++ b/app/javascript/vue/protocol/step_elements/table.vue @@ -156,24 +156,25 @@ updateTable() { if (this.editingTable == false) return; - 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 }) - }); this.update(); this.editingTable = false; }, 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 }) + }); this.$emit('update', this.element) }, loadTableData() {