An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Restore prefilling database dates https://github.com/siyuan-note/siyuan/issues/18402
Daniel6150ac6a3317
diff --git a/app/src/protyle/render/av/batchEdit.ts b/app/src/protyle/render/av/batchEdit.tsindex 32b75d7767..24a8563f72 100644--- a/app/src/protyle/render/av/batchEdit.ts+++ b/app/src/protyle/render/av/batchEdit.ts@@ -138,5 +138,6 @@ export const openAVFieldEditor = (options: {destroyCallback: destroy,keepMenuOpen: true,positionByMenu: true,+ requireExplicitChange: true,});};diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.tsindex c954ee4931..be31f4e4d9 100644--- a/app/src/protyle/render/av/cell.ts+++ b/app/src/protyle/render/av/cell.ts@@ -427,6 +427,7 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], typedestroyCallback?: () => void;keepMenuOpen?: boolean;positionByMenu?: boolean;+ requireExplicitChange?: boolean;}) => {if (cellElements.length === 0 || (cellElements.length === 1 && !cellElements[0])) {options?.destroyCallback?.();@@ -488,6 +489,7 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], typedata: options?.data,destroyCallback: options?.destroyCallback,keepMenuOpen: options?.keepMenuOpen,+ requireExplicitChange: options?.requireExplicitChange,});} else if (type === "mAsset") {openMenuPanel({diff --git a/app/src/protyle/render/av/date.ts b/app/src/protyle/render/av/date.tsindex 30c20e0219..167465d8d0 100644--- a/app/src/protyle/render/av/date.ts+++ b/app/src/protyle/render/av/date.ts@@ -1,6 +1,7 @@import * as dayjs from "dayjs";import {genCellValueByElement, updateCellsValue} from "./cell";import {getFieldsByData} from "./view";+import {shouldSubmitDateEdit} from "./dateSubmit";export const getDateHTML = (cellElements: HTMLElement[]) => {const cellValue = genCellValueByElement("date", cellElements[0]).date;@@ -55,7 +56,8 @@ export const bindDateEvent = (options: {data: IAV,menuElement: HTMLElement,blockElement: Element,- cellElements: HTMLElement[]+ cellElements: HTMLElement[],+ requireExplicitChange?: boolean,}) => {const inputElements: NodeListOf<HTMLInputElement> = options.menuElement.querySelectorAll("input");let dirty = false;@@ -132,7 +134,7 @@ export const bindDateEvent = (options: {};const submit = () => {- if (!dirty) {+ if (!shouldSubmitDateEdit(dirty, options.requireExplicitChange === true)) {return;}const dateStr1 = buildDateStr(0);diff --git a/app/src/protyle/render/av/dateSubmit.ts b/app/src/protyle/render/av/dateSubmit.tsnew file mode 100644index 0000000000..8db8a064f2--- /dev/null+++ b/app/src/protyle/render/av/dateSubmit.ts@@ -0,0 +1,3 @@+export const shouldSubmitDateEdit = (dirty: boolean, requireExplicitChange: boolean) => {+ return dirty || !requireExplicitChange;+};diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.tsindex 03cc9ca7a3..da4a206955 100644--- a/app/src/protyle/render/av/openMenuPanel.ts+++ b/app/src/protyle/render/av/openMenuPanel.ts@@ -94,6 +94,7 @@ export const openMenuPanel = (options: {destroyCallback?: () => void,keepMenuOpen?: boolean,filterOperation?: IAVFilterOperation,+ requireExplicitChange?: boolean,}) => {let avPanelElement = document.querySelector(".av__panel");if (avPanelElement) {@@ -235,7 +236,8 @@ export const openMenuPanel = (options: {data,menuElement,cellElements: options.cellElements,- blockElement: options.blockElement+ blockElement: options.blockElement,+ requireExplicitChange: options.requireExplicitChange,});} else if (options.type === "asset") {bindAssetEvent({diff --git a/app/tests/dateSubmit.test.ts b/app/tests/dateSubmit.test.tsnew file mode 100644index 0000000000..34424f003a--- /dev/null+++ b/app/tests/dateSubmit.test.ts@@ -0,0 +1,12 @@+import assert from "node:assert/strict";+import test from "node:test";+import {shouldSubmitDateEdit} from "../src/protyle/render/av/dateSubmit";++test("submits the prefilled date for a regular cell", () => {+ assert.equal(shouldSubmitDateEdit(false, false), true);+});++test("requires a change when batch editing dates", () => {+ assert.equal(shouldSubmitDateEdit(false, true), false);+ assert.equal(shouldSubmitDateEdit(true, true), true);+});