mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 08:00:13 +01:00
This commit is contained in:
parent
9aa9a67627
commit
96c5084af6
2 changed files with 23 additions and 9 deletions
|
|
@ -174,7 +174,7 @@ export const toggleUpdateRelationBtn = (menuItemsElement: HTMLElement, avId: str
|
||||||
const switchElement = switchItemElement.querySelector(".b3-switch") as HTMLInputElement;
|
const switchElement = switchItemElement.querySelector(".b3-switch") as HTMLInputElement;
|
||||||
const inputItemElement = switchItemElement.nextElementSibling;
|
const inputItemElement = switchItemElement.nextElementSibling;
|
||||||
const btnElement = inputItemElement.nextElementSibling;
|
const btnElement = inputItemElement.nextElementSibling;
|
||||||
const oldValue = JSON.parse(searchElement.dataset.oldValue) as IAVCellRelationValue;
|
const oldValue = JSON.parse(searchElement.dataset.oldValue) as IAVColumnRelation;
|
||||||
if (oldValue.avID) {
|
if (oldValue.avID) {
|
||||||
const inputElement = inputItemElement.querySelector("input") as HTMLInputElement;
|
const inputElement = inputItemElement.querySelector("input") as HTMLInputElement;
|
||||||
if (resetData) {
|
if (resetData) {
|
||||||
|
|
@ -323,7 +323,7 @@ ${html || genSelectItemHTML("empty")}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getRelationHTML = (data: IAV, cellElements?: HTMLElement[]) => {
|
export const getRelationHTML = (data: IAV, cellElements?: HTMLElement[]) => {
|
||||||
let colRelationData: IAVCellRelationValue;
|
let colRelationData: IAVColumnRelation;
|
||||||
data.view.columns.find(item => {
|
data.view.columns.find(item => {
|
||||||
if (item.id === cellElements[0].dataset.colId) {
|
if (item.id === cellElements[0].dataset.colId) {
|
||||||
colRelationData = item.relation;
|
colRelationData = item.relation;
|
||||||
|
|
@ -358,7 +358,19 @@ export const setRelationCell = (protyle: IProtyle, nodeElement: HTMLElement, tar
|
||||||
if (!nodeElement.contains(cellElements[0])) {
|
if (!nodeElement.contains(cellElements[0])) {
|
||||||
cellElements[0] = nodeElement.querySelector(`.av__row[data-id="${rowElement.dataset.id}"] .av__cell[data-col-id="${cellElements[0].dataset.colId}"]`) as HTMLElement;
|
cellElements[0] = nodeElement.querySelector(`.av__row[data-id="${rowElement.dataset.id}"] .av__cell[data-col-id="${cellElements[0].dataset.colId}"]`) as HTMLElement;
|
||||||
}
|
}
|
||||||
const newValue = genCellValueByElement("relation", cellElements[0]).relation;
|
const newValue:IAVCellRelationValue = {blockIDs: [], contents: []};
|
||||||
|
menuElement.querySelectorAll('[data-type="setRelationCell"]').forEach(item => {
|
||||||
|
const id = item.getAttribute("data-id");
|
||||||
|
newValue.blockIDs.push(id);
|
||||||
|
newValue.contents.push({
|
||||||
|
type: "block",
|
||||||
|
block: {
|
||||||
|
id,
|
||||||
|
content: item.querySelector(".b3-menu__label").textContent
|
||||||
|
},
|
||||||
|
isDetached: !item.querySelector(".popover__block")
|
||||||
|
});
|
||||||
|
});
|
||||||
if (target.classList.contains("b3-menu__item")) {
|
if (target.classList.contains("b3-menu__item")) {
|
||||||
const targetId = target.getAttribute("data-id");
|
const targetId = target.getAttribute("data-id");
|
||||||
const separatorElement = menuElement.querySelector(".b3-menu__separator");
|
const separatorElement = menuElement.querySelector(".b3-menu__separator");
|
||||||
|
|
|
||||||
14
app/src/types/index.d.ts
vendored
14
app/src/types/index.d.ts
vendored
|
|
@ -834,7 +834,7 @@ interface IAVColumn {
|
||||||
name: string,
|
name: string,
|
||||||
color: string,
|
color: string,
|
||||||
}[],
|
}[],
|
||||||
relation?: IAVCellRelationValue,
|
relation?: IAVColumnRelation,
|
||||||
rollup?: IAVCellRollupValue
|
rollup?: IAVCellRollupValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -886,10 +886,7 @@ interface IAVCellValue {
|
||||||
checkbox?: {
|
checkbox?: {
|
||||||
checked: boolean
|
checked: boolean
|
||||||
}
|
}
|
||||||
relation?: {
|
relation?: IAVCellRelationValue
|
||||||
blockIDs: string[]
|
|
||||||
contents?: IAVCellValue[]
|
|
||||||
}
|
|
||||||
rollup?: {
|
rollup?: {
|
||||||
contents?: IAVCellValue[]
|
contents?: IAVCellValue[]
|
||||||
}
|
}
|
||||||
|
|
@ -898,6 +895,11 @@ interface IAVCellValue {
|
||||||
updated?: IAVCellDateValue
|
updated?: IAVCellDateValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IAVCellRelationValue {
|
||||||
|
blockIDs: string[]
|
||||||
|
contents?: IAVCellValue[]
|
||||||
|
}
|
||||||
|
|
||||||
interface IAVCellDateValue {
|
interface IAVCellDateValue {
|
||||||
content?: number,
|
content?: number,
|
||||||
isNotEmpty?: boolean
|
isNotEmpty?: boolean
|
||||||
|
|
@ -919,7 +921,7 @@ interface IAVCellAssetValue {
|
||||||
type: "file" | "image"
|
type: "file" | "image"
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IAVCellRelationValue {
|
interface IAVColumnRelation {
|
||||||
avID?: string
|
avID?: string
|
||||||
backKeyID?: string
|
backKeyID?: string
|
||||||
isTwoWay?: boolean
|
isTwoWay?: boolean
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue