mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
This commit is contained in:
parent
c6e06b9f21
commit
64c2e6f102
1 changed files with 16 additions and 4 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import {transaction} from "../../wysiwyg/transaction";
|
import {transaction} from "../../wysiwyg/transaction";
|
||||||
import {fetchPost} from "../../../util/fetch";
|
import {fetchPost} from "../../../util/fetch";
|
||||||
import {addCol, bindEditEvent, duplicateCol, getColIconByType, getEditHTML, removeCol} from "./col";
|
import {addCol, bindEditEvent, duplicateCol, getColIconByType, getColNameByType, getEditHTML, removeCol} from "./col";
|
||||||
import {setPosition} from "../../../util/setPosition";
|
import {setPosition} from "../../../util/setPosition";
|
||||||
import {hasClosestByAttribute, hasClosestByClassName} from "../../util/hasClosest";
|
import {hasClosestByAttribute, hasClosestByClassName} from "../../util/hasClosest";
|
||||||
import {addColOptionOrCell, bindSelectEvent, getSelectHTML, removeCellOption, setColOption} from "./select";
|
import {addColOptionOrCell, bindSelectEvent, getSelectHTML, removeCellOption, setColOption} from "./select";
|
||||||
|
|
@ -874,13 +874,25 @@ export const openMenuPanel = (options: {
|
||||||
break;
|
break;
|
||||||
} else if (type === "updateColType") {
|
} else if (type === "updateColType") {
|
||||||
if (target.dataset.newType !== target.dataset.oldType) {
|
if (target.dataset.newType !== target.dataset.oldType) {
|
||||||
const name = (avPanelElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement).value;
|
const nameElement = avPanelElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement
|
||||||
data.view.columns.find((item: IAVColumn) => item.id === options.colId).type = target.dataset.newType as TAVCol;
|
const name = nameElement.value;
|
||||||
|
let newName = name;
|
||||||
|
data.view.columns.find((item: IAVColumn) => {
|
||||||
|
if (item.id === options.colId) {
|
||||||
|
item.type = target.dataset.newType as TAVCol;
|
||||||
|
if (getColNameByType(target.dataset.oldType as TAVCol) === name) {
|
||||||
|
newName = getColNameByType(target.dataset.newType as TAVCol);
|
||||||
|
item.name = newName;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
transaction(options.protyle, [{
|
transaction(options.protyle, [{
|
||||||
action: "updateAttrViewCol",
|
action: "updateAttrViewCol",
|
||||||
id: options.colId,
|
id: options.colId,
|
||||||
avID,
|
avID,
|
||||||
name,
|
name: newName,
|
||||||
type: target.dataset.newType as TAVCol,
|
type: target.dataset.newType as TAVCol,
|
||||||
}], [{
|
}], [{
|
||||||
action: "updateAttrViewCol",
|
action: "updateAttrViewCol",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue