mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-05 16:28:49 +01:00
This commit is contained in:
parent
3719459179
commit
70bf718b41
5 changed files with 30 additions and 18 deletions
|
|
@ -10,10 +10,13 @@ export const setGroupMethod = (options: {
|
|||
fieldId: string;
|
||||
data: IAV;
|
||||
menuElement: HTMLElement,
|
||||
blockElement: HTMLElement,
|
||||
blockElement: Element,
|
||||
}) => {
|
||||
const blockID = options.blockElement.getAttribute("data-block-id");
|
||||
transaction(options.protyle, [{
|
||||
action: "setAttrViewGroup",
|
||||
avID: options.data.id,
|
||||
blockID,
|
||||
data: {
|
||||
field: options.fieldId,
|
||||
method: null,
|
||||
|
|
@ -22,31 +25,33 @@ export const setGroupMethod = (options: {
|
|||
}
|
||||
}], [{
|
||||
action: "setAttrViewGroup",
|
||||
avID: options.data.id,
|
||||
blockID,
|
||||
data: {
|
||||
field: options.data.view.groups?.field || "",
|
||||
field: options.data.view.group?.field || "",
|
||||
method: null,
|
||||
order: null,
|
||||
range: null
|
||||
}
|
||||
}]);
|
||||
if (!options.data.view.groups) {
|
||||
options.data.view.groups = {
|
||||
if (!options.data.view.group) {
|
||||
options.data.view.group = {
|
||||
field: options.fieldId
|
||||
};
|
||||
} else {
|
||||
options.data.view.groups.field = options.fieldId;
|
||||
options.data.view.group.field = options.fieldId;
|
||||
}
|
||||
options.menuElement.innerHTML = getGroupsHTML(getFieldsByData(options.data), options.data.view.groups);
|
||||
options.menuElement.innerHTML = getGroupsHTML(getFieldsByData(options.data), options.data.view.group);
|
||||
// bindGroupsEvent(options.protyle, options.menuElement, options.data, blockID);
|
||||
const tabRect = options.blockElement.querySelector(".av__views").getBoundingClientRect();
|
||||
setPosition(options.menuElement, tabRect.right - options.menuElement.clientWidth, tabRect.bottom, tabRect.height);
|
||||
};
|
||||
|
||||
export const getGroupsMethodHTML = (columns: IAVColumn[], groups: IAVGroups) => {
|
||||
export const getGroupsMethodHTML = (columns: IAVColumn[], group: IAVGroup) => {
|
||||
const selectHTML = '<svg class="b3-menu__checked"><use xlink:href="#iconSelect"></use></svg>';
|
||||
let html = `<button class="b3-menu__item" data-type="setGroupMethod">
|
||||
<div class="b3-menu__label">${window.siyuan.languages.calcOperatorNone}</div>
|
||||
${groups ? "" : selectHTML}
|
||||
${group ? "" : selectHTML}
|
||||
</button>`;
|
||||
columns.forEach(item => {
|
||||
html += `<button class="b3-menu__item" data-id="${item.id}" data-type="setGroupMethod">
|
||||
|
|
@ -54,7 +59,7 @@ export const getGroupsMethodHTML = (columns: IAVColumn[], groups: IAVGroups) =>
|
|||
${item.icon ? unicode2Emoji(item.icon, "b3-menu__icon", true) : `<svg class="b3-menu__icon"><use xlink:href="#${getColIconByType(item.type)}"></use></svg>`}
|
||||
${escapeHtml(item.name) || " "}
|
||||
</div>
|
||||
${groups?.field === item.id ? selectHTML : ""}
|
||||
${group?.field === item.id ? selectHTML : ""}
|
||||
</button>`;
|
||||
});
|
||||
return `<div class="b3-menu__items">
|
||||
|
|
@ -69,9 +74,9 @@ ${html}
|
|||
</div>`;
|
||||
};
|
||||
|
||||
export const getGroupsHTML = (columns: IAVColumn[], groups: IAVGroups) => {
|
||||
export const getGroupsHTML = (columns: IAVColumn[], group: IAVGroup) => {
|
||||
let html = "";
|
||||
if (groups) {
|
||||
if (group) {
|
||||
html = `<button class="b3-menu__separator"></button>
|
||||
<button class="b3-menu__item" data-type="removeGroups">
|
||||
<svg class="b3-menu__icon"><use xlink:href="#iconTrashcan"></use></svg>
|
||||
|
|
@ -88,7 +93,7 @@ export const getGroupsHTML = (columns: IAVColumn[], groups: IAVGroups) => {
|
|||
<button class="b3-menu__separator"></button>
|
||||
<button class="b3-menu__item" data-type="goGroupsMethod">
|
||||
<span class="b3-menu__label">${window.siyuan.languages.groupMethod}</span>
|
||||
<span class="b3-menu__accelerator">${groups ? columns.filter(item => item.id === groups.field)[0].name : ""}</span>
|
||||
<span class="b3-menu__accelerator">${group ? columns.filter(item => item.id === group.field)[0].name : ""}</span>
|
||||
<svg class="b3-menu__icon b3-menu__icon--small"><use xlink:href="#iconRight"></use></svg>
|
||||
</button>
|
||||
${html}
|
||||
|
|
|
|||
|
|
@ -577,7 +577,7 @@ export const openMenuPanel = (options: {
|
|||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "goGroups") {
|
||||
menuElement.innerHTML = getGroupsHTML(fields, data.view.groups);
|
||||
menuElement.innerHTML = getGroupsHTML(fields, data.view.group);
|
||||
bindGroupsEvent(options.protyle, menuElement, data, blockID);
|
||||
setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);
|
||||
window.siyuan.menus.menu.remove();
|
||||
|
|
@ -585,7 +585,7 @@ export const openMenuPanel = (options: {
|
|||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "goGroupsMethod") {
|
||||
menuElement.innerHTML = getGroupsMethodHTML(fields, data.view.groups);
|
||||
menuElement.innerHTML = getGroupsMethodHTML(fields, data.view.group);
|
||||
setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ export const getViewHTML = (data: IAV) => {
|
|||
<button class="b3-menu__item" data-type="goGroups">
|
||||
<svg class="b3-menu__icon"><use xlink:href="#iconGroups"></use></svg>
|
||||
<span class="b3-menu__label">${window.siyuan.languages.group}</span>
|
||||
<span class="b3-menu__accelerator">${data.view.groups ? fields.filter((item: IAVColumn) => item.id === data.view.groups.field)[0].name : ""}</span>
|
||||
<span class="b3-menu__accelerator">${data.view.group ? fields.filter((item: IAVColumn) => item.id === data.view.group.field)[0].name : ""}</span>
|
||||
<svg class="b3-menu__icon b3-menu__icon--small"><use xlink:href="#iconRight"></use></svg>
|
||||
</button>
|
||||
<button class="b3-menu__separator"></button>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@ import {getContenteditableElement} from "../wysiwyg/getBlock";
|
|||
import {getTypeByCellElement, updateCellsValue} from "../render/av/cell";
|
||||
import {scrollCenter} from "../../util/highlightById";
|
||||
|
||||
interface FileWithPath extends File {
|
||||
path: string;
|
||||
}
|
||||
|
||||
export class Upload {
|
||||
public element: HTMLElement;
|
||||
public isUploading: boolean;
|
||||
|
|
@ -265,7 +269,7 @@ export const uploadFiles = (protyle: IProtyle, files: FileList | DataTransferIte
|
|||
}
|
||||
if (0 === fileItem.size && "" === fileItem.type && -1 === fileItem.name.indexOf(".")) {
|
||||
// 文件夹
|
||||
uploadLocalFiles([fileItem.path], protyle, false);
|
||||
uploadLocalFiles([(fileItem as FileWithPath).path], protyle, false);
|
||||
} else {
|
||||
fileList.push(fileItem);
|
||||
}
|
||||
|
|
|
|||
7
app/src/types/index.d.ts
vendored
7
app/src/types/index.d.ts
vendored
|
|
@ -842,7 +842,8 @@ interface IAVView {
|
|||
wrapField: boolean;
|
||||
filters: IAVFilter[],
|
||||
sorts: IAVSort[],
|
||||
groups: IAVGroups
|
||||
groups: IAVView[]
|
||||
group: IAVGroup
|
||||
}
|
||||
|
||||
interface IAVTable extends IAVView {
|
||||
|
|
@ -877,8 +878,10 @@ interface relativeDate {
|
|||
direction: number; // 方向:-1: 前、0: 现在、1: 后
|
||||
}
|
||||
|
||||
interface IAVGroups {
|
||||
interface IAVGroup {
|
||||
field: string,
|
||||
method?: number
|
||||
order?: number
|
||||
}
|
||||
|
||||
interface IAVSort {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue