This commit is contained in:
parent
65042ab834
commit
f1993e13e3
5 changed files with 25 additions and 69 deletions
|
@ -34,69 +34,24 @@ export const duplicateCol = (options: {
|
|||
newColData.id = Lute.NewNodeID();
|
||||
const newUpdated = dayjs().format("YYYYMMDDHHmmss");
|
||||
const blockId = options.blockElement.getAttribute("data-node-id");
|
||||
if (["select", "mSelect", "rollup"].includes(newColData.type)) {
|
||||
fetchPost("/api/av/renderAttributeView", {
|
||||
id: options.data.id,
|
||||
viewID: options.viewID
|
||||
}, (response) => {
|
||||
const data = response.data as IAV;
|
||||
let colOptions;
|
||||
data.view.columns.find((item) => {
|
||||
if (item.id === options.colId) {
|
||||
colOptions = item.options;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
transaction(options.protyle, [{
|
||||
action: "addAttrViewCol",
|
||||
name: newColData.name,
|
||||
avID: options.data.id,
|
||||
type: newColData.type,
|
||||
data: newColData.icon,
|
||||
previousID: options.colId,
|
||||
id: newColData.id
|
||||
}, {
|
||||
action: "updateAttrViewColOptions",
|
||||
id: newColData.id,
|
||||
avID: options.data.id,
|
||||
data: colOptions
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
id: blockId,
|
||||
data: newUpdated,
|
||||
}], [{
|
||||
action: "removeAttrViewCol",
|
||||
id: newColData.id,
|
||||
avID: options.data.id,
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
id: blockId,
|
||||
data: options.blockElement.getAttribute("updated")
|
||||
}]);
|
||||
});
|
||||
} else {
|
||||
transaction(options.protyle, [{
|
||||
action: "addAttrViewCol",
|
||||
name: newColData.name,
|
||||
avID: options.data.id,
|
||||
type: newColData.type,
|
||||
data: newColData.icon,
|
||||
id: newColData.id,
|
||||
previousID: options.colId,
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
id: blockId,
|
||||
data: newUpdated,
|
||||
}], [{
|
||||
action: "removeAttrViewCol",
|
||||
id: newColData.id,
|
||||
avID: options.data.id,
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
id: blockId,
|
||||
data: options.blockElement.getAttribute("updated")
|
||||
}]);
|
||||
}
|
||||
transaction(options.protyle, [{
|
||||
action: "duplicateAttrViewKey",
|
||||
keyID:newColData.id,
|
||||
nextID:options.colId,
|
||||
avID: options.data.id,
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
id: blockId,
|
||||
data: newUpdated,
|
||||
}], [{
|
||||
action: "removeAttrViewCol",
|
||||
id: newColData.id,
|
||||
avID: options.data.id,
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
id: blockId,
|
||||
data: options.blockElement.getAttribute("updated")
|
||||
}]);
|
||||
addAttrViewColAnimation({
|
||||
blockElement: options.blockElement,
|
||||
protyle: options.protyle,
|
||||
|
|
|
@ -20,4 +20,4 @@ export const processClonePHElement = (item:Element) => {
|
|||
phElement.setAttribute("data-content", Lute.UnEscapeHTMLStr(phElement.getAttribute("data-content")));
|
||||
}
|
||||
return item;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -767,7 +767,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
|
|||
"setAttrViewSorts", "setAttrViewColCalc", "removeAttrViewCol", "updateAttrViewColNumberFormat", "removeAttrViewBlock",
|
||||
"replaceAttrViewBlock", "updateAttrViewColTemplate", "setAttrViewColPin", "addAttrViewView", "setAttrViewColIcon",
|
||||
"removeAttrViewView", "setAttrViewViewName", "setAttrViewViewIcon", "duplicateAttrViewView", "sortAttrViewView",
|
||||
"updateAttrViewColRelation", "setAttrViewPageSize", "updateAttrViewColRollup", "sortAttrViewKey"].includes(operation.action)) {
|
||||
"updateAttrViewColRelation", "setAttrViewPageSize", "updateAttrViewColRollup", "sortAttrViewKey", "duplicateAttrViewKey"].includes(operation.action)) {
|
||||
refreshAV(protyle, operation);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ export const openSearch = async (options: {
|
|||
const exitDialog = window.siyuan.dialogs.find((item) => {
|
||||
// 再次打开
|
||||
if (item.element.querySelector("#searchList")) {
|
||||
const searchElement = item.element.querySelector(".b3-dialog__body")
|
||||
const searchElement = item.element.querySelector(".b3-dialog__body");
|
||||
const cloneData = JSON.parse(JSON.stringify(item.data)) as Config.IUILayoutTabSearchConfig;
|
||||
const selectText = getSelection().rangeCount > 0 ? getSelection().getRangeAt(0).toString() : undefined;
|
||||
if (selectText) {
|
||||
|
@ -71,12 +71,12 @@ export const openSearch = async (options: {
|
|||
updateConfig(searchElement, cloneData, item.data, item.editors.edit);
|
||||
} else if (options.hotkey === Constants.DIALOG_SEARCH) {
|
||||
cloneData.hasReplace = false;
|
||||
const toPath = item.editors.edit.protyle.path
|
||||
const toPath = item.editors.edit.protyle.path;
|
||||
fetchPost("/api/filetree/getHPathsByPaths", {paths: [toPath]}, (response) => {
|
||||
cloneData.idPath = [pathPosix().join(item.editors.edit.protyle.notebookId, toPath)];
|
||||
cloneData.hPath = response.data[0];
|
||||
item.data.idPath = cloneData.idPath
|
||||
item.data.hPath = cloneData.hPath
|
||||
item.data.idPath = cloneData.idPath;
|
||||
item.data.hPath = cloneData.hPath;
|
||||
updateConfig(searchElement, cloneData, item.data, item.editors.edit);
|
||||
});
|
||||
}
|
||||
|
|
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
@ -33,6 +33,7 @@ type TOperation =
|
|||
| "updateAttrViewColOption"
|
||||
| "setAttrViewName"
|
||||
| "doUpdateUpdated"
|
||||
| "duplicateAttrViewKey"
|
||||
| "setAttrViewColIcon"
|
||||
| "setAttrViewFilters"
|
||||
| "setAttrViewSorts"
|
||||
|
|
Loading…
Add table
Reference in a new issue