mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
This commit is contained in:
parent
10f408513d
commit
fadd3c2120
5 changed files with 41 additions and 3 deletions
|
@ -320,7 +320,7 @@ export const renderGallery = async (options: {
|
|||
protyle: options.protyle,
|
||||
blockElement: options.blockElement,
|
||||
});
|
||||
if (options.data.view.hideAttrViewName) {
|
||||
if (view.hideAttrViewName) {
|
||||
options.blockElement.querySelector(".av__gallery").classList.add("av__gallery--top");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -182,15 +182,27 @@ export const getGroupsHTML = (columns: IAVColumn[], view: IAVView) => {
|
|||
let groupHTML = "";
|
||||
column = columns.find(item => item.id === view.group.field);
|
||||
if (view.groups?.length > 0) {
|
||||
groupHTML = '<button class="b3-menu__separator"></button>';
|
||||
const disabledDrag = ["created", "date", "created", "updated"].includes(column.type);
|
||||
let showCount = 0
|
||||
view.groups.forEach(item => {
|
||||
if (!item.groupHidden) {
|
||||
showCount++;
|
||||
}
|
||||
groupHTML += `<button class="b3-menu__item" draggable="${disabledDrag ? "false" : "true"}" data-id="${item.id}">
|
||||
${disabledDrag ? "" : '<svg class="b3-menu__icon fn__grab"><use xlink:href="#iconDrag"></use></svg>'}
|
||||
<div class="b3-menu__label fn__flex">${item.name || ""}</div>
|
||||
<svg class="b3-menu__action b3-menu__action--show" data-type="hideGroup" data-id="${item.id}"><use xlink:href="#iconEye${item.groupHidden === 0 ? "" : "off"}"></use></svg>
|
||||
</button>`;
|
||||
});
|
||||
groupHTML = `<button class="b3-menu__separator"></button>
|
||||
<button class="b3-menu__item" data-type="nobg">
|
||||
<span class="b3-menu__label"></span>
|
||||
<span class="block__icon" data-type="hideGroups">
|
||||
${window.siyuan.languages[showCount === view.groups.length? "hideAll" : "showAll"]}
|
||||
<span class="fn__space"></span>
|
||||
<svg><use xlink:href="#iconEye${showCount === view.groups.length? "off" : ""}"></use></svg>
|
||||
</span>
|
||||
</button>` + groupHTML;
|
||||
}
|
||||
html = `<button class="b3-menu__item${["date", "updated", "created"].includes(column.type) ? "" : " fn__none"}" data-type="goGroupsDate">
|
||||
<span class="b3-menu__label">${window.siyuan.languages.date}</span>
|
||||
|
|
|
@ -1578,6 +1578,31 @@ export const openMenuPanel = (options: {
|
|||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "hideGroups") {
|
||||
window.siyuan.menus.menu.remove();
|
||||
const useElement = target.querySelector("use");
|
||||
const isShow = useElement.getAttribute("xlink:href") === "#iconEyeoff";
|
||||
target.innerHTML = `${window.siyuan.languages[isShow ? "showAll" : "hideAll"]}
|
||||
<span class="fn__space"></span>
|
||||
<svg><use xlink:href="#iconEye${isShow ? "" : "off"}"></use></svg>`;
|
||||
data.view.groups.forEach((item) => {
|
||||
item.groupHidden = isShow ? 2 : 0;
|
||||
target.parentElement.querySelector(`.b3-menu__item[data-id="${item.id}"] .b3-menu__action use`)?.setAttribute("xlink:href", `iconEye${isShow ? "" : "off"}`);
|
||||
});
|
||||
transaction(options.protyle, [{
|
||||
action: "hideAttrViewAllGroups",
|
||||
avID: data.id,
|
||||
blockID,
|
||||
data: isShow,
|
||||
}], [{
|
||||
action: "hideAttrViewAllGroups",
|
||||
avID: data.id,
|
||||
blockID,
|
||||
data: !isShow
|
||||
}]);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "removeGroups") {
|
||||
window.siyuan.menus.menu.remove();
|
||||
transaction(options.protyle, [{
|
||||
|
|
|
@ -864,7 +864,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
|
|||
"duplicateAttrViewKey", "setAttrViewViewDesc", "setAttrViewCoverFrom", "setAttrViewCoverFromAssetKeyID",
|
||||
"setAttrViewBlockView", "setAttrViewCardSize", "setAttrViewCardAspectRatio", "hideAttrViewName", "setAttrViewShowIcon",
|
||||
"setAttrViewWrapField", "setAttrViewGroup", "removeAttrViewGroup", "hideAttrViewGroup", "sortAttrViewGroup",
|
||||
"foldAttrViewGroup"].includes(operation.action)) {
|
||||
"foldAttrViewGroup", "hideAttrViewAllGroups"].includes(operation.action)) {
|
||||
if (!isUndo) {
|
||||
// 撤销 transaction 会进行推送,需使用推送来进行刷新最新数据 https://github.com/siyuan-note/siyuan/issues/13607
|
||||
refreshAV(protyle, operation);
|
||||
|
|
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
@ -65,6 +65,7 @@ type TOperation =
|
|||
| "setAttrViewBlockView"
|
||||
| "setAttrViewGroup"
|
||||
| "removeAttrViewGroup"
|
||||
| "hideAttrViewAllGroups"
|
||||
| "syncAttrViewTableColWidth"
|
||||
| "hideAttrViewGroup"
|
||||
| "sortAttrViewGroup"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue