mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-24 15:54:00 +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
|
def update
|
||||||
ActiveRecord::Base.transaction do
|
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 })
|
log_step_activity(:table_edited, { table_name: @table.name })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -61,7 +67,7 @@ module StepElements
|
||||||
private
|
private
|
||||||
|
|
||||||
def table_params
|
def table_params
|
||||||
params.permit(:name, :contents, metadata: {})
|
params.permit(:name, :contents, :metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_table
|
def load_table
|
||||||
|
|
|
@ -156,9 +156,8 @@
|
||||||
updateTable() {
|
updateTable() {
|
||||||
if (this.editingTable == false) return;
|
if (this.editingTable == false) return;
|
||||||
|
|
||||||
let tableData = JSON.stringify({data: this.tableObject.getData()});
|
this.element.attributes.orderable.contents = JSON.stringify({ data: this.tableObject.getData() });
|
||||||
this.element.attributes.orderable.contents = tableData;
|
this.element.attributes.orderable.metadata = JSON.stringify({ cells: this.tableObject.getCellsMeta().map(
|
||||||
this.element.attributes.orderable.metadata = {cells: this.tableObject.getCellsMeta().map(
|
|
||||||
(x) => {
|
(x) => {
|
||||||
if (x) {
|
if (x) {
|
||||||
return {
|
return {
|
||||||
|
@ -169,8 +168,8 @@
|
||||||
} else {
|
} else {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}).filter(e => { return e !== null})
|
}).filter(e => { return e !== null })
|
||||||
};
|
});
|
||||||
this.update();
|
this.update();
|
||||||
this.editingTable = false;
|
this.editingTable = false;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue