mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
This commit is contained in:
parent
684286fc8a
commit
c339d1b9bc
3 changed files with 13 additions and 23 deletions
|
@ -1,20 +1,20 @@
|
|||
import {unicode2Emoji} from "../../../emoji";
|
||||
import {getColIconByType} from "./col";
|
||||
import {escapeHtml} from "../../../util/escape";
|
||||
import {transaction} from "../../wysiwyg/transaction";
|
||||
import {setPosition} from "../../../util/setPosition";
|
||||
import {getFieldsByData} from "./view";
|
||||
import {fetchSyncPost} from "../../../util/fetch";
|
||||
|
||||
export const setGroupMethod = (options: {
|
||||
export const setGroupMethod = async (options: {
|
||||
protyle: IProtyle;
|
||||
fieldId: string;
|
||||
data: IAV;
|
||||
menuElement: HTMLElement,
|
||||
blockElement: Element,
|
||||
}) => {
|
||||
const blockID = options.blockElement.getAttribute("data-block-id");
|
||||
const blockID = options.blockElement.getAttribute("data-node-id");
|
||||
const column: IAVColumn = getFieldsByData(options.data).find(item => item.id === options.fieldId);
|
||||
const data = {
|
||||
const data = column ? {
|
||||
field: options.fieldId,
|
||||
method: column.type === "number" ? 1 : (["date", "updated", "created"].includes(column.type) ? 2 : 0),
|
||||
order: 0,
|
||||
|
@ -23,24 +23,13 @@ export const setGroupMethod = (options: {
|
|||
numEnd: 1000,
|
||||
numStep: 100,
|
||||
} : null
|
||||
};
|
||||
transaction(options.protyle, [{
|
||||
action: "setAttrViewGroup",
|
||||
avID: options.data.id,
|
||||
} : {field: null, method: null, order: null, range: null};
|
||||
const response = await fetchSyncPost("/api/av/setAttrViewGroup", {
|
||||
blockID,
|
||||
data
|
||||
}], [{
|
||||
action: "setAttrViewGroup",
|
||||
avID: options.data.id,
|
||||
blockID,
|
||||
data: {
|
||||
field: options.data.view.group?.field || "",
|
||||
method: options.data.view.group?.method || "",
|
||||
order: options.data.view.group?.order || "",
|
||||
range: options.data.view.group?.range || ""
|
||||
}
|
||||
}]);
|
||||
options.data.view.group = data;
|
||||
avID: options.blockElement.getAttribute("data-av-id"),
|
||||
group: data
|
||||
});
|
||||
options.data.view = response.data.view;
|
||||
options.menuElement.innerHTML = getGroupsHTML(getFieldsByData(options.data), options.data.view);
|
||||
// bindGroupsEvent(options.protyle, options.menuElement, options.data, blockID);
|
||||
const tabRect = options.blockElement.querySelector(".av__views").getBoundingClientRect();
|
||||
|
@ -141,7 +130,7 @@ export const getGroupsHTML = (columns: IAVColumn[], view: IAVView) => {
|
|||
<button class="b3-menu__item">
|
||||
<span class="fn__flex-center">${window.siyuan.languages.hideEmptyGroup}</span>
|
||||
<span class="fn__space fn__flex-1"></span>
|
||||
<input type="checkbox" class="b3-switch b3-switch--menu">
|
||||
<input type="checkbox" class="b3-switch b3-switch--menu"${view.group.hideEmpty ? " checked" : ""}>
|
||||
</button>
|
||||
${groupHTML}
|
||||
<button class="b3-menu__separator"></button>
|
||||
|
|
|
@ -1441,7 +1441,7 @@ export const openMenuPanel = (options: {
|
|||
target,
|
||||
protyle: options.protyle,
|
||||
nodeElement: options.blockElement,
|
||||
data: data
|
||||
data
|
||||
});
|
||||
fields = getFieldsByData(data);
|
||||
event.preventDefault();
|
||||
|
|
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
@ -898,6 +898,7 @@ interface IAVGroup {
|
|||
numEnd: number // 数字范围结束值 1000
|
||||
numStep: number // 数字范围步长 100
|
||||
}
|
||||
hideEmpty?: boolean
|
||||
order?: number // 升序: 0(默认), 降序: 1, 手动排序: 2
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue