mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
This commit is contained in:
parent
fb85f7d36e
commit
04b1c80ac9
5 changed files with 82 additions and 8 deletions
|
|
@ -53,6 +53,9 @@ ctrl+p 搜索: 202
|
||||||
.block__popover: 205
|
.block__popover: 205
|
||||||
.block__popover--top: 206
|
.block__popover--top: 206
|
||||||
|
|
||||||
|
// 需小于 .b3-menu
|
||||||
|
.av__panel: 209
|
||||||
|
|
||||||
// 需大于 .block__popover
|
// 需大于 .block__popover
|
||||||
.b3-menu: 210
|
.b3-menu: 210
|
||||||
|
|
||||||
|
|
@ -78,8 +81,6 @@ progressLoading: 400
|
||||||
#windowControls: 502
|
#windowControls: 502
|
||||||
|
|
||||||
.b3-snackbar: 503
|
.b3-snackbar: 503
|
||||||
|
|
||||||
.av__panel: 504
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
html {
|
html {
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&__panel {
|
&__panel {
|
||||||
z-index: 504;
|
z-index: 209;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
.b3-menu {
|
.b3-menu {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import {fetchPost} from "../../../util/fetch";
|
||||||
import {addCol} from "./addCol";
|
import {addCol} from "./addCol";
|
||||||
import {getColIconByType} from "./col";
|
import {getColIconByType} from "./col";
|
||||||
import {setPosition} from "../../../util/setPosition";
|
import {setPosition} from "../../../util/setPosition";
|
||||||
|
import {Menu} from "../../../plugin/Menu";
|
||||||
|
|
||||||
export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type: "properties" | "config" | "sorts" = "config") => {
|
export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type: "properties" | "config" | "sorts" = "config") => {
|
||||||
let avPanelElement = document.querySelector(".av__panel");
|
let avPanelElement = document.querySelector(".av__panel");
|
||||||
|
|
@ -57,11 +58,26 @@ export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
} else if (type === "removeSorts") {
|
} else if (type === "removeSorts") {
|
||||||
// TODO
|
transaction(protyle, [{
|
||||||
|
action: "setAttrView",
|
||||||
|
id: avId,
|
||||||
|
data: {
|
||||||
|
sorts: []
|
||||||
|
}
|
||||||
|
}], [{
|
||||||
|
action: "setAttrView",
|
||||||
|
id: avId,
|
||||||
|
data: {
|
||||||
|
sorts: data.sorts
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
data.sorts = [];
|
||||||
|
menuElement.innerHTML = getSortsHTML(data);
|
||||||
|
setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
} else if (type === "addSort") {
|
} else if (type === "addSort") {
|
||||||
// TODO
|
addSort({data, rect: target.getBoundingClientRect(), menuElement, tabRect, avId, protyle});
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
} else if (type === "removeSort") {
|
} else if (type === "removeSort") {
|
||||||
|
|
@ -306,3 +322,56 @@ ${hideHTML}
|
||||||
<span class="b3-menu__label">${window.siyuan.languages.new}</span>
|
<span class="b3-menu__label">${window.siyuan.languages.new}</span>
|
||||||
</button>`;
|
</button>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const addSort = (options: {
|
||||||
|
data: IAV,
|
||||||
|
rect: DOMRect,
|
||||||
|
menuElement: HTMLElement,
|
||||||
|
tabRect: DOMRect,
|
||||||
|
avId: string,
|
||||||
|
protyle: IProtyle
|
||||||
|
}) => {
|
||||||
|
const menu = new Menu("av-add-sort");
|
||||||
|
options.data.columns.forEach((column) => {
|
||||||
|
let hasSort = false;
|
||||||
|
options.data.sorts.find((sort) => {
|
||||||
|
if (sort.column === column.id) {
|
||||||
|
hasSort = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!hasSort) {
|
||||||
|
menu.addItem({
|
||||||
|
label: column.name,
|
||||||
|
icon: getColIconByType(column.type),
|
||||||
|
click: () => {
|
||||||
|
const oldSorts = Object.assign([], options.data.sorts);
|
||||||
|
options.data.sorts.push({
|
||||||
|
column: column.id,
|
||||||
|
order: "ASC",
|
||||||
|
});
|
||||||
|
transaction(options.protyle, [{
|
||||||
|
action: "setAttrView",
|
||||||
|
id: options.avId,
|
||||||
|
data: {
|
||||||
|
sorts: options.data.sorts
|
||||||
|
}
|
||||||
|
}], [{
|
||||||
|
action: "setAttrView",
|
||||||
|
id: options.avId,
|
||||||
|
data: {
|
||||||
|
sorts: oldSorts
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
options.menuElement.innerHTML = getSortsHTML(options.data);
|
||||||
|
setPosition(options.menuElement, options.tabRect.right - options.menuElement.clientWidth, options.tabRect.bottom, options.tabRect.height);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
menu.open({
|
||||||
|
x: options.rect.left,
|
||||||
|
y: options.rect.bottom,
|
||||||
|
h: options.rect.height,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export const avRender = (element: Element, cb?: () => void) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fetchPost("/api/av/renderAttributeView", {id: e.getAttribute("data-av-id")}, (response) => {
|
fetchPost("/api/av/renderAttributeView", {id: e.getAttribute("data-av-id")}, (response) => {
|
||||||
const data = response.data.av;
|
const data = response.data.av as IAV;
|
||||||
// header
|
// header
|
||||||
let tableHTML = '<div class="av__row av__row--header"><div class="av__firstcol"><svg style="height: 42px"><use xlink:href="#iconUncheck"></use></svg></div>';
|
let tableHTML = '<div class="av__row av__row--header"><div class="av__firstcol"><svg style="height: 42px"><use xlink:href="#iconUncheck"></use></svg></div>';
|
||||||
let index = 0;
|
let index = 0;
|
||||||
|
|
@ -89,7 +89,7 @@ ${cell.color ? `color:${cell.color};` : ""}"><span class="av__celltext">${text}<
|
||||||
<div class="layout-tab-bar fn__flex">
|
<div class="layout-tab-bar fn__flex">
|
||||||
<div class="item item--focus">
|
<div class="item item--focus">
|
||||||
<svg class="item__graphic"><use xlink:href="#iconTable"></use></svg>
|
<svg class="item__graphic"><use xlink:href="#iconTable"></use></svg>
|
||||||
<span class="item__text">Table</span>
|
<span class="item__text">${data.type}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="fn__flex-1"></div>
|
<div class="fn__flex-1"></div>
|
||||||
<span data-type="av-filter" class="block__icon block__icon--show b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.filter}">
|
<span data-type="av-filter" class="block__icon block__icon--show b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.filter}">
|
||||||
|
|
@ -105,7 +105,7 @@ ${cell.color ? `color:${cell.color};` : ""}"><span class="av__celltext">${text}<
|
||||||
</span>
|
</span>
|
||||||
<div class="fn__space"></div>
|
<div class="fn__space"></div>
|
||||||
</div>
|
</div>
|
||||||
<div contenteditable="true" class="av__title" data-tip="${window.siyuan.languages.title}">${data.title || ""}</div>
|
<div contenteditable="true" class="av__title" data-tip="${window.siyuan.languages.title}">${data.name || ""}</div>
|
||||||
<div class="av__counter fn__none"></div>
|
<div class="av__counter fn__none"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="av__scroll">
|
<div class="av__scroll">
|
||||||
|
|
|
||||||
4
app/src/types/index.d.ts
vendored
4
app/src/types/index.d.ts
vendored
|
|
@ -29,6 +29,7 @@ type TOperation =
|
||||||
| "setAttrViewColHidden"
|
| "setAttrViewColHidden"
|
||||||
| "setAttrViewColWrap"
|
| "setAttrViewColWrap"
|
||||||
| "setAttrViewColWidth"
|
| "setAttrViewColWidth"
|
||||||
|
| "setAttrView"
|
||||||
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" |
|
type TEventBus = "ws-main" |
|
||||||
|
|
@ -827,6 +828,9 @@ interface IAV {
|
||||||
columns: IAVColumn[],
|
columns: IAVColumn[],
|
||||||
filters: [],
|
filters: [],
|
||||||
sorts: IAVSort[],
|
sorts: IAVSort[],
|
||||||
|
name: string,
|
||||||
|
type: "table"
|
||||||
|
rows: IAVRow[],
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IAVSort {
|
interface IAVSort {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue