mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-31 03:59:51 +08:00
Fix saving of big tables on steps [SCI-8216]
This commit is contained in:
parent
e3a0f3c55f
commit
0beb64511d
2 changed files with 12 additions and 7 deletions
|
@ -25,7 +25,13 @@ module StepElements
|
|||
|
||||
def update
|
||||
ActiveRecord::Base.transaction do
|
||||
@table.update!(table_params)
|
||||
@table.assign_attributes(table_params.except(:metadata))
|
||||
begin
|
||||
@table.metadata = JSON.parse(table_params[:metadata])
|
||||
rescue JSON::ParserError
|
||||
@table.metadata = {}
|
||||
end
|
||||
@table.save!
|
||||
log_step_activity(:table_edited, { table_name: @table.name })
|
||||
end
|
||||
|
||||
|
@ -61,7 +67,7 @@ module StepElements
|
|||
private
|
||||
|
||||
def table_params
|
||||
params.permit(:name, :contents, metadata: {})
|
||||
params.permit(:name, :contents, :metadata)
|
||||
end
|
||||
|
||||
def load_table
|
||||
|
|
|
@ -156,9 +156,8 @@
|
|||
updateTable() {
|
||||
if (this.editingTable == false) return;
|
||||
|
||||
let tableData = JSON.stringify({data: this.tableObject.getData()});
|
||||
this.element.attributes.orderable.contents = tableData;
|
||||
this.element.attributes.orderable.metadata = {cells: this.tableObject.getCellsMeta().map(
|
||||
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 {
|
||||
|
@ -169,8 +168,8 @@
|
|||
} else {
|
||||
return null
|
||||
}
|
||||
}).filter(e => { return e !== null})
|
||||
};
|
||||
}).filter(e => { return e !== null })
|
||||
});
|
||||
this.update();
|
||||
this.editingTable = false;
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue