Fix step table renaming [SCI-8216]

This commit is contained in:
Oleksii Kriuchykhin 2023-03-28 16:03:45 +02:00
parent 0beb64511d
commit ee7abc2912
2 changed files with 16 additions and 15 deletions

View file

@ -27,7 +27,7 @@ module StepElements
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
@table.assign_attributes(table_params.except(:metadata)) @table.assign_attributes(table_params.except(:metadata))
begin begin
@table.metadata = JSON.parse(table_params[:metadata]) @table.metadata = JSON.parse(table_params[:metadata]) if table_params[:metadata].present?
rescue JSON::ParserError rescue JSON::ParserError
@table.metadata = {} @table.metadata = {}
end end

View file

@ -156,24 +156,25 @@
updateTable() { updateTable() {
if (this.editingTable == false) return; 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.update();
this.editingTable = false; this.editingTable = false;
}, },
update() { 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) this.$emit('update', this.element)
}, },
loadTableData() { loadTableData() {