diff --git a/app/appearance/icons/ant/icon.js b/app/appearance/icons/ant/icon.js index e377d2d7d..96b19ac8d 100644 --- a/app/appearance/icons/ant/icon.js +++ b/app/appearance/icons/ant/icon.js @@ -1,5 +1,9 @@ document.body.insertAdjacentHTML('afterbegin', ` + + + + diff --git a/app/appearance/icons/ant/icon.json b/app/appearance/icons/ant/icon.json index 88aff836f..330897d63 100644 --- a/app/appearance/icons/ant/icon.json +++ b/app/appearance/icons/ant/icon.json @@ -2,5 +2,5 @@ "name": "ant", "author": "Vanessa", "url": "https://github.com/Vanessa219", - "version": "1.23.1" + "version": "1.24.0" } diff --git a/app/appearance/icons/index.html b/app/appearance/icons/index.html index 80222a668..447109532 100644 --- a/app/appearance/icons/index.html +++ b/app/appearance/icons/index.html @@ -28,6 +28,12 @@

SiYuan

+
+ + + + iconClock +
diff --git a/app/appearance/icons/material/icon.js b/app/appearance/icons/material/icon.js index 752c15c21..4bb6b75d8 100644 --- a/app/appearance/icons/material/icon.js +++ b/app/appearance/icons/material/icon.js @@ -1,5 +1,8 @@ document.body.insertAdjacentHTML('afterbegin', ` + + + diff --git a/app/appearance/icons/material/icon.json b/app/appearance/icons/material/icon.json index 3d8ce7088..2aac52867 100644 --- a/app/appearance/icons/material/icon.json +++ b/app/appearance/icons/material/icon.json @@ -2,5 +2,5 @@ "name": "material", "author": "Vanessa", "url": "https://github.com/Vanessa219", - "version": "1.23.1" + "version": "1.24.0" } diff --git a/app/src/protyle/render/av/addCol.ts b/app/src/protyle/render/av/addCol.ts index 3202914dd..43c2ed083 100644 --- a/app/src/protyle/render/av/addCol.ts +++ b/app/src/protyle/render/av/addCol.ts @@ -255,5 +255,55 @@ export const addCol = (protyle: IProtyle, blockElement: Element) => { }); } }); + menu.addItem({ + icon: "iconClock", + label: window.siyuan.languages.creationDate, + click() { + const id = Lute.NewNodeID(); + transaction(protyle, [{ + action: "addAttrViewCol", + name: window.siyuan.languages.creationDate, + avID, + type: "created", + id + }], [{ + action: "removeAttrViewCol", + id, + avID, + }]); + addAttrViewColAnimation({ + blockElement: blockElement, + protyle: protyle, + type: "created", + name: window.siyuan.languages.creationDate, + id + }); + } + }); + menu.addItem({ + icon: "iconClock", + label: window.siyuan.languages.modificationDate, + click() { + const id = Lute.NewNodeID(); + transaction(protyle, [{ + action: "addAttrViewCol", + name: window.siyuan.languages.modificationDate, + avID, + type: "updated", + id + }], [{ + action: "removeAttrViewCol", + id, + avID, + }]); + addAttrViewColAnimation({ + blockElement: blockElement, + protyle: protyle, + type: "updated", + name: window.siyuan.languages.modificationDate, + id + }); + } + }); return menu; }; diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts index 03b163e31..5d0f6afda 100644 --- a/app/src/protyle/render/av/cell.ts +++ b/app/src/protyle/render/av/cell.ts @@ -12,8 +12,8 @@ export const getCalcValue = (column: IAVColumn) => { } let resultCalc: any = column.calc.result.number; if (column.calc.operator === "Earliest" || column.calc.operator === "Latest" || - (column.calc.operator === "Range" && column.type === "date")) { - resultCalc = column.calc.result.date; + (column.calc.operator === "Range" && ["date", "created", "updated"].includes(column.type))) { + resultCalc = column.calc.result[column.type as "date"]; } let value = ""; switch (column.calc.operator) { @@ -101,10 +101,10 @@ export const genCellValue = (colType: TAVCol, value: string | any) => { color: "" }] }; - } else if (colType === "date" && value === "") { + } else if (["date", "created", "updated"].includes(colType) && value === "") { cellValue = { type: colType, - date: { + [colType]: { content: null, isNotEmpty: false, content2: null, @@ -119,10 +119,10 @@ export const genCellValue = (colType: TAVCol, value: string | any) => { type: colType, mSelect: value as IAVCellSelectValue[] }; - } else if (colType === "date") { + } else if (["date", "created", "updated"].includes(colType)) { cellValue = { type: colType, - date: value as IAVCellDateValue + [colType]: value as IAVCellDateValue }; } else if (colType === "mAsset") { cellValue = { @@ -309,7 +309,7 @@ export const openCalcMenu = (protyle: IProtyle, calcElement: HTMLElement) => { operator: "Range", label: window.siyuan.languages.calcOperatorRange }); - } else if (type === "date") { + } else if (["date", "created", "updated"].includes(type)) { calcItem({ menu, protyle, @@ -346,7 +346,7 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type if (!type) { type = cellElements[0].parentElement.parentElement.firstElementChild.querySelector(`[data-col-id="${cellElements[0].getAttribute("data-col-id")}"]`).getAttribute("data-dtype") as TAVCol; } - if (type === "template") { + if (type === "template" || type === "updated" || type === "created") { return; } if (type === "block" && (cellElements.length > 1 || !cellElements[0].getAttribute("data-detached"))) { diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts index ea0367d22..d63ed6eab 100644 --- a/app/src/protyle/render/av/col.ts +++ b/app/src/protyle/render/av/col.ts @@ -290,6 +290,9 @@ export const getColIconByType = (type: TAVCol) => { return "iconList"; case "date": return "iconCalendar"; + case "updated": + case "created": + return "iconClock"; case "url": return "iconLink"; case "mAsset": diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts index b7076d11a..657fab8ae 100644 --- a/app/src/protyle/render/av/render.ts +++ b/app/src/protyle/render/av/render.ts @@ -96,11 +96,19 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '${dayjs(cell.value.date.content2).format("YYYY-MM-DD HH:mm")}`; + if (dataValue && dataValue.hasEndDate && dataValue.isNotEmpty && dataValue.isNotEmpty2) { + text += `${dayjs(dataValue.content2).format("YYYY-MM-DD HH:mm")}`; + } + text += ""; + } else if (["created", "updated"].includes(cell.valueType)) { + text = ''; + const dataValue = cell.value ? cell.value[cell.valueType as "date"] : null; + if (dataValue && dataValue.content) { + text += dayjs(dataValue.content).format("YYYY-MM-DD HH:mm"); } text += ""; } else if (cell.valueType === "mAsset") { diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 02c98f529..54b09d781 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -65,6 +65,8 @@ type TAVCol = | "phone" | "mAsset" | "template" + | "created" + | "updated" type THintSource = "search" | "av" | "hint"; type TAVFilterOperator = "=" @@ -1078,6 +1080,8 @@ interface IAVCellValue { content: string } date?: IAVCellDateValue + created?: IAVCellDateValue + updated?: IAVCellDateValue } interface IAVCellDateValue {