mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
This commit is contained in:
parent
4eba1176be
commit
492621e131
4 changed files with 54 additions and 26 deletions
|
|
@ -765,7 +765,12 @@ export const openMenuPanel = (options: {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
} else if (type === "goSearchRollupCol") {
|
} else if (type === "goSearchRollupCol") {
|
||||||
goSearchRollupCol(avID, target);
|
goSearchRollupCol({
|
||||||
|
target,
|
||||||
|
data,
|
||||||
|
protyle: options.protyle,
|
||||||
|
colId: menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id")
|
||||||
|
});
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -4,27 +4,44 @@ import {upDownHint} from "../../../util/upDownHint";
|
||||||
import {fetchPost} from "../../../util/fetch";
|
import {fetchPost} from "../../../util/fetch";
|
||||||
import {escapeHtml} from "../../../util/escape";
|
import {escapeHtml} from "../../../util/escape";
|
||||||
import {transaction} from "../../wysiwyg/transaction";
|
import {transaction} from "../../wysiwyg/transaction";
|
||||||
import {updateCellsValue} from "./cell";
|
import {genIconHTML} from "../util";
|
||||||
import {updateAttrViewCellAnimation} from "./action";
|
import {unicode2Emoji} from "../../../emoji";
|
||||||
import {focusBlock} from "../../util/selection";
|
import {getColIconByType} from "./col";
|
||||||
|
|
||||||
|
const updateCol = (protyle: IProtyle, data: IAV, colId: string, itemElement: HTMLElement) => {
|
||||||
|
const colData = data.view.columns.find((item) => {
|
||||||
|
if (item.id === colId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
transaction(protyle, [{
|
||||||
|
action: "updateAttrViewColRollup",
|
||||||
|
id: colId,
|
||||||
|
avID: data.id,
|
||||||
|
parentID: itemElement.dataset.colId,
|
||||||
|
// keyID: "",
|
||||||
|
// data: "",
|
||||||
|
}], [{
|
||||||
|
action: "updateAttrViewColRollup",
|
||||||
|
// operation.AvID 汇总列所在 av
|
||||||
|
// operation.ID 汇总列 ID
|
||||||
|
// operation.ParentID 汇总列基于的关联列 ID
|
||||||
|
// operation.KeyID 目标列 ID
|
||||||
|
// operation.Data 计算方式
|
||||||
|
}])
|
||||||
|
}
|
||||||
|
|
||||||
const genSearchList = (element: Element, keyword: string, avId: string, cb?: () => void) => {
|
const genSearchList = (element: Element, keyword: string, avId: string, cb?: () => void) => {
|
||||||
fetchPost("/api/av/searchAttributeViewNonRelationKey", {keyword}, (response) => {
|
fetchPost("/api/av/searchAttributeViewNonRelationKey", {
|
||||||
|
avID: avId,
|
||||||
|
keyword
|
||||||
|
}, (response) => {
|
||||||
let html = "";
|
let html = "";
|
||||||
response.data.results.forEach((item: {
|
response.data.nonRelationKeys.forEach((item: IAVColumn, index: number) => {
|
||||||
avID: string
|
html += `<div class="b3-list-item b3-list-item--narrow${index === 0 ? " b3-list-item--focus" : ""}" data-col-id="${item.id}">
|
||||||
avName: string
|
${item.icon ? unicode2Emoji(item.icon, "b3-list-item__graphic", true) : `<svg class="b3-list-item__graphic"><use xlink:href="#${getColIconByType(item.type)}"></use></svg>`}
|
||||||
blockID: string
|
${genIconHTML()}
|
||||||
hPath: string
|
<span class="b3-list-item__text">${escapeHtml(item.name || window.siyuan.languages.title)}</span>
|
||||||
}, index: number) => {
|
|
||||||
html += `<div class="b3-list-item b3-list-item--narrow${index === 0 ? " b3-list-item--focus" : ""}" data-av-id="${item.avID}" data-block-id="${item.blockID}">
|
|
||||||
<div class="b3-list-item--two fn__flex-1">
|
|
||||||
<div class="b3-list-item__first">
|
|
||||||
<span class="b3-list-item__text">${escapeHtml(item.avName || window.siyuan.languages.title)}</span>
|
|
||||||
</div>
|
|
||||||
<div class="b3-list-item__meta b3-list-item__showall">${escapeHtml(item.hPath)}</div>
|
|
||||||
</div>
|
|
||||||
<svg aria-label="${window.siyuan.languages.thisDatabase}" style="margin: 0 0 0 4px" class="b3-list-item__hinticon ariaLabel${item.avID === avId ? "" : " fn__none"}"><use xlink:href="#iconInfo"></use></svg>
|
|
||||||
</div>`;
|
</div>`;
|
||||||
});
|
});
|
||||||
element.innerHTML = html;
|
element.innerHTML = html;
|
||||||
|
|
@ -34,7 +51,12 @@ const genSearchList = (element: Element, keyword: string, avId: string, cb?: ()
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const goSearchRollupCol = (avId: string, target: HTMLElement) => {
|
export const goSearchRollupCol = (options: {
|
||||||
|
target: HTMLElement,
|
||||||
|
data: IAV,
|
||||||
|
protyle: IProtyle,
|
||||||
|
colId: string
|
||||||
|
}) => {
|
||||||
window.siyuan.menus.menu.remove();
|
window.siyuan.menus.menu.remove();
|
||||||
const menu = new Menu();
|
const menu = new Menu();
|
||||||
menu.addItem({
|
menu.addItem({
|
||||||
|
|
@ -61,24 +83,24 @@ export const goSearchRollupCol = (avId: string, target: HTMLElement) => {
|
||||||
if (event.key === "Enter") {
|
if (event.key === "Enter") {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
// setDatabase(avId, target, listElement.querySelector(".b3-list-item--focus"));
|
updateCol(options.protyle, options.data, options.colId, listElement.querySelector(".b3-list-item--focus"));
|
||||||
window.siyuan.menus.menu.remove();
|
window.siyuan.menus.menu.remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
inputElement.addEventListener("input", (event) => {
|
inputElement.addEventListener("input", (event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
genSearchList(listElement, inputElement.value, avId);
|
genSearchList(listElement, inputElement.value, options.data.id);
|
||||||
});
|
});
|
||||||
element.lastElementChild.addEventListener("click", (event) => {
|
element.lastElementChild.addEventListener("click", (event) => {
|
||||||
const listItemElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item");
|
const listItemElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item");
|
||||||
if (listItemElement) {
|
if (listItemElement) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
// setDatabase(avId, target, listItemElement);
|
updateCol(options.protyle, options.data, options.colId, listItemElement);
|
||||||
window.siyuan.menus.menu.remove();
|
window.siyuan.menus.menu.remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
genSearchList(listElement, "", avId, () => {
|
genSearchList(listElement, "", options.data.id, () => {
|
||||||
const rect = target.getBoundingClientRect();
|
const rect = options.target.getBoundingClientRect();
|
||||||
menu.open({
|
menu.open({
|
||||||
x: rect.left,
|
x: rect.left,
|
||||||
y: rect.bottom,
|
y: rect.bottom,
|
||||||
|
|
|
||||||
|
|
@ -724,7 +724,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
|
||||||
"setAttrViewSorts", "setAttrViewColCalc", "removeAttrViewCol", "updateAttrViewColNumberFormat", "removeAttrViewBlock",
|
"setAttrViewSorts", "setAttrViewColCalc", "removeAttrViewCol", "updateAttrViewColNumberFormat", "removeAttrViewBlock",
|
||||||
"replaceAttrViewBlock", "updateAttrViewColTemplate", "setAttrViewColPin", "addAttrViewView",
|
"replaceAttrViewBlock", "updateAttrViewColTemplate", "setAttrViewColPin", "addAttrViewView",
|
||||||
"removeAttrViewView", "setAttrViewViewName", "setAttrViewViewIcon", "duplicateAttrViewView", "sortAttrViewView",
|
"removeAttrViewView", "setAttrViewViewName", "setAttrViewViewIcon", "duplicateAttrViewView", "sortAttrViewView",
|
||||||
"updateAttrViewColRelation", "setAttrViewPageSize"].includes(operation.action)) {
|
"updateAttrViewColRelation", "setAttrViewPageSize", "updateAttrViewColRollup"].includes(operation.action)) {
|
||||||
refreshAV(protyle, operation, isUndo);
|
refreshAV(protyle, operation, isUndo);
|
||||||
} else if (operation.action === "doUpdateUpdated") {
|
} else if (operation.action === "doUpdateUpdated") {
|
||||||
updateElements.forEach(item => {
|
updateElements.forEach(item => {
|
||||||
|
|
|
||||||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -50,6 +50,7 @@ type TOperation =
|
||||||
| "sortAttrViewView"
|
| "sortAttrViewView"
|
||||||
| "setAttrViewPageSize"
|
| "setAttrViewPageSize"
|
||||||
| "updateAttrViewColRelation"
|
| "updateAttrViewColRelation"
|
||||||
|
| "updateAttrViewColRollup"
|
||||||
type TBazaarType = "templates" | "icons" | "widgets" | "themes" | "plugins"
|
type TBazaarType = "templates" | "icons" | "widgets" | "themes" | "plugins"
|
||||||
type TCardType = "doc" | "notebook" | "all"
|
type TCardType = "doc" | "notebook" | "all"
|
||||||
type TEventBus = "ws-main" | "sync-start" | "sync-end" | "sync-fail" |
|
type TEventBus = "ws-main" | "sync-start" | "sync-end" | "sync-fail" |
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue