mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
This commit is contained in:
parent
225b1ef176
commit
415445863d
2 changed files with 46 additions and 9 deletions
|
|
@ -37,7 +37,8 @@ export const bindAssetEvent = (options: {
|
||||||
protyle: options.protyle,
|
protyle: options.protyle,
|
||||||
data: options.data,
|
data: options.data,
|
||||||
cellElements: options.cellElements,
|
cellElements: options.cellElements,
|
||||||
value
|
type: "addUpdate",
|
||||||
|
addUpdateValue: value
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -94,11 +95,13 @@ ${contentHTML}
|
||||||
</div>`;
|
</div>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateAssetCell = (options: {
|
export const updateAssetCell = (options: {
|
||||||
protyle: IProtyle,
|
protyle: IProtyle,
|
||||||
data: IAV,
|
data: IAV,
|
||||||
cellElements: HTMLElement[],
|
cellElements: HTMLElement[],
|
||||||
value?: IAVCellAssetValue[],
|
type: "replace" | "addUpdate" | "remove",
|
||||||
|
replaceValue?: IAVCellAssetValue[],
|
||||||
|
addUpdateValue?: IAVCellAssetValue[],
|
||||||
removeContent?: string
|
removeContent?: string
|
||||||
}) => {
|
}) => {
|
||||||
let cellIndex = 0;
|
let cellIndex = 0;
|
||||||
|
|
@ -128,7 +131,7 @@ const updateAssetCell = (options: {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const oldValue = Object.assign([], cellData.value.mAsset);
|
const oldValue = Object.assign([], cellData.value.mAsset);
|
||||||
if (options.removeContent) {
|
if (options.type === "remove") {
|
||||||
if (elementIndex === 0) {
|
if (elementIndex === 0) {
|
||||||
cellData.value.mAsset.find((oldItem, index) => {
|
cellData.value.mAsset.find((oldItem, index) => {
|
||||||
if (oldItem.content === options.removeContent) {
|
if (oldItem.content === options.removeContent) {
|
||||||
|
|
@ -140,9 +143,9 @@ const updateAssetCell = (options: {
|
||||||
} else {
|
} else {
|
||||||
cellData.value.mAsset = newValue;
|
cellData.value.mAsset = newValue;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (options.type === "addUpdate") {
|
||||||
if (elementIndex === 0) {
|
if (elementIndex === 0) {
|
||||||
options.value.forEach(newitem => {
|
options.addUpdateValue.forEach(newitem => {
|
||||||
if (!newitem.content) {
|
if (!newitem.content) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -164,6 +167,8 @@ const updateAssetCell = (options: {
|
||||||
} else {
|
} else {
|
||||||
cellData.value.mAsset = newValue;
|
cellData.value.mAsset = newValue;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
cellData.value.mAsset = options.replaceValue;
|
||||||
}
|
}
|
||||||
cellDoOperations.push({
|
cellDoOperations.push({
|
||||||
action: "updateAttrViewCell",
|
action: "updateAttrViewCell",
|
||||||
|
|
@ -208,7 +213,8 @@ export const editAssetItem = (protyle: IProtyle, data: IAV, cellElements: HTMLEl
|
||||||
protyle,
|
protyle,
|
||||||
data,
|
data,
|
||||||
cellElements,
|
cellElements,
|
||||||
value: [{
|
type: "addUpdate",
|
||||||
|
addUpdateValue: [{
|
||||||
content: linkAddress,
|
content: linkAddress,
|
||||||
name: textElement.value,
|
name: textElement.value,
|
||||||
type
|
type
|
||||||
|
|
@ -240,6 +246,7 @@ export const editAssetItem = (protyle: IProtyle, data: IAV, cellElements: HTMLEl
|
||||||
protyle,
|
protyle,
|
||||||
data,
|
data,
|
||||||
cellElements,
|
cellElements,
|
||||||
|
type: "remove",
|
||||||
removeContent: linkAddress
|
removeContent: linkAddress
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -273,7 +280,8 @@ export const addAssetLink = (protyle: IProtyle, data: IAV, cellElements: HTMLEle
|
||||||
protyle,
|
protyle,
|
||||||
data,
|
data,
|
||||||
cellElements,
|
cellElements,
|
||||||
value: [{
|
type: "addUpdate",
|
||||||
|
addUpdateValue: [{
|
||||||
type: "file",
|
type: "file",
|
||||||
name: textElements[1].value,
|
name: textElements[1].value,
|
||||||
content: textElements[0].value,
|
content: textElements[0].value,
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import {addSort, bindSortsEvent, getSortsHTML} from "./sort";
|
||||||
import {bindDateEvent, getDateHTML, setDateValue} from "./date";
|
import {bindDateEvent, getDateHTML, setDateValue} from "./date";
|
||||||
import {formatNumber} from "./number";
|
import {formatNumber} from "./number";
|
||||||
import {removeAttrViewColAnimation} from "./action";
|
import {removeAttrViewColAnimation} from "./action";
|
||||||
import {addAssetLink, bindAssetEvent, editAssetItem, getAssetHTML} from "./asset";
|
import {addAssetLink, bindAssetEvent, editAssetItem, getAssetHTML, updateAssetCell} from "./asset";
|
||||||
import {Constants} from "../../../constants";
|
import {Constants} from "../../../constants";
|
||||||
|
|
||||||
export const openMenuPanel = (options: {
|
export const openMenuPanel = (options: {
|
||||||
|
|
@ -227,6 +227,35 @@ export const openMenuPanel = (options: {
|
||||||
menuElement.innerHTML = getFiltersHTML(data.view);
|
menuElement.innerHTML = getFiltersHTML(data.view);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (type === "assets") {
|
||||||
|
const changeData = data.view.filters;
|
||||||
|
let targetFilter: IAVFilter;
|
||||||
|
changeData.find((filter, index: number) => {
|
||||||
|
if (filter.column === sourceId) {
|
||||||
|
targetFilter = changeData.splice(index, 1)[0];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
changeData.find((filter, index: number) => {
|
||||||
|
if (filter.column === targetId) {
|
||||||
|
if (isTop) {
|
||||||
|
changeData.splice(index, 0, targetFilter);
|
||||||
|
} else {
|
||||||
|
changeData.splice(index + 1, 0, targetFilter);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
updateAssetCell({
|
||||||
|
protyle:options.protyle,
|
||||||
|
data,
|
||||||
|
cellElements:options.cellElements,
|
||||||
|
type: "replace",
|
||||||
|
replaceValue
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
transaction(options.protyle, [{
|
transaction(options.protyle, [{
|
||||||
action: "sortAttrViewCol",
|
action: "sortAttrViewCol",
|
||||||
avID,
|
avID,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue