mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-31 12:09:17 +08:00
Fix step table renaming [SCI-8216]
This commit is contained in:
parent
0beb64511d
commit
ee7abc2912
2 changed files with 16 additions and 15 deletions
|
@ -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
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
Loading…
Reference in a new issue