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 {unicode2Emoji} from "../../../emoji";
|
||||||
import {getColIconByType} from "./col";
|
import {getColIconByType} from "./col";
|
||||||
import {escapeHtml} from "../../../util/escape";
|
import {escapeHtml} from "../../../util/escape";
|
||||||
import {transaction} from "../../wysiwyg/transaction";
|
|
||||||
import {setPosition} from "../../../util/setPosition";
|
import {setPosition} from "../../../util/setPosition";
|
||||||
import {getFieldsByData} from "./view";
|
import {getFieldsByData} from "./view";
|
||||||
|
import {fetchSyncPost} from "../../../util/fetch";
|
||||||
|
|
||||||
export const setGroupMethod = (options: {
|
export const setGroupMethod = async (options: {
|
||||||
protyle: IProtyle;
|
protyle: IProtyle;
|
||||||
fieldId: string;
|
fieldId: string;
|
||||||
data: IAV;
|
data: IAV;
|
||||||
menuElement: HTMLElement,
|
menuElement: HTMLElement,
|
||||||
blockElement: Element,
|
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 column: IAVColumn = getFieldsByData(options.data).find(item => item.id === options.fieldId);
|
||||||
const data = {
|
const data = column ? {
|
||||||
field: options.fieldId,
|
field: options.fieldId,
|
||||||
method: column.type === "number" ? 1 : (["date", "updated", "created"].includes(column.type) ? 2 : 0),
|
method: column.type === "number" ? 1 : (["date", "updated", "created"].includes(column.type) ? 2 : 0),
|
||||||
order: 0,
|
order: 0,
|
||||||
|
@ -23,24 +23,13 @@ export const setGroupMethod = (options: {
|
||||||
numEnd: 1000,
|
numEnd: 1000,
|
||||||
numStep: 100,
|
numStep: 100,
|
||||||
} : null
|
} : null
|
||||||
};
|
} : {field: null, method: null, order: null, range: null};
|
||||||
transaction(options.protyle, [{
|
const response = await fetchSyncPost("/api/av/setAttrViewGroup", {
|
||||||
action: "setAttrViewGroup",
|
|
||||||
avID: options.data.id,
|
|
||||||
blockID,
|
blockID,
|
||||||
data
|
avID: options.blockElement.getAttribute("data-av-id"),
|
||||||
}], [{
|
group: data
|
||||||
action: "setAttrViewGroup",
|
});
|
||||||
avID: options.data.id,
|
options.data.view = response.data.view;
|
||||||
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;
|
|
||||||
options.menuElement.innerHTML = getGroupsHTML(getFieldsByData(options.data), options.data.view);
|
options.menuElement.innerHTML = getGroupsHTML(getFieldsByData(options.data), options.data.view);
|
||||||
// bindGroupsEvent(options.protyle, options.menuElement, options.data, blockID);
|
// bindGroupsEvent(options.protyle, options.menuElement, options.data, blockID);
|
||||||
const tabRect = options.blockElement.querySelector(".av__views").getBoundingClientRect();
|
const tabRect = options.blockElement.querySelector(".av__views").getBoundingClientRect();
|
||||||
|
@ -141,7 +130,7 @@ export const getGroupsHTML = (columns: IAVColumn[], view: IAVView) => {
|
||||||
<button class="b3-menu__item">
|
<button class="b3-menu__item">
|
||||||
<span class="fn__flex-center">${window.siyuan.languages.hideEmptyGroup}</span>
|
<span class="fn__flex-center">${window.siyuan.languages.hideEmptyGroup}</span>
|
||||||
<span class="fn__space fn__flex-1"></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>
|
</button>
|
||||||
${groupHTML}
|
${groupHTML}
|
||||||
<button class="b3-menu__separator"></button>
|
<button class="b3-menu__separator"></button>
|
||||||
|
|
|
@ -1441,7 +1441,7 @@ export const openMenuPanel = (options: {
|
||||||
target,
|
target,
|
||||||
protyle: options.protyle,
|
protyle: options.protyle,
|
||||||
nodeElement: options.blockElement,
|
nodeElement: options.blockElement,
|
||||||
data: data
|
data
|
||||||
});
|
});
|
||||||
fields = getFieldsByData(data);
|
fields = getFieldsByData(data);
|
||||||
event.preventDefault();
|
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
|
numEnd: number // 数字范围结束值 1000
|
||||||
numStep: number // 数字范围步长 100
|
numStep: number // 数字范围步长 100
|
||||||
}
|
}
|
||||||
|
hideEmpty?: boolean
|
||||||
order?: number // 升序: 0(默认), 降序: 1, 手动排序: 2
|
order?: number // 升序: 0(默认), 降序: 1, 手动排序: 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue