An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Support displaying field names in calendar views
Daniel127da1ac0491
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20240208172514-9dsv6na.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20240208172514-9dsv6na.syindex 38963ba264..9e50a50581 100644--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20240208172514-9dsv6na.sy+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20240208172514-9dsv6na.sy@@ -7,7 +7,7 @@"id": "20240208172514-9dsv6na","title": "Database","type": "doc",- "updated": "20261024164212"+ "updated": "20261025011511"},"Children": [{@@ -773,7 +773,7 @@"HeadingLevel": 3,"Properties": {"id": "20260920225154-tz8a00o",- "updated": "20260929123717"+ "updated": "20261025011205"},"Children": [{@@ -802,7 +802,7 @@"ListData": {},"Properties": {"id": "20260920225154-qqxdh7e",- "updated": "20260929123717"+ "updated": "20261025011205"},"Children": [{@@ -1046,6 +1046,52 @@]}]+ },+ {+ "ID": "20261025011205-dbums56",+ "Type": "NodeListItem",+ "Properties": {+ "id": "20261025011205-dbums56",+ "updated": "20261025011205"+ },+ "Children": [+ {+ "ID": "20261025011205-5ibctn0",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20261025011205-5ibctn0",+ "updated": "20261025011205"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "Field names: Open the view settings and enable "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Layout"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Display field name"+ },+ {+ "Type": "NodeText",+ "Data": ". Field names appear beside non-primary field values; the primary key remains the entry title. This option is off by default and saved per calendar view. Turn it off to show only values"+ }+ ]+ }+ ],+ "ListData": {+ "BulletChar": 42,+ "Marker": "Kg=="+ }}]},@@ -1055,7 +1101,7 @@"HeadingLevel": 3,"Properties": {"id": "20260613162855-cdeorum",- "updated": "20261024161058"+ "updated": "20261025011511"},"Children": [{@@ -1084,7 +1130,7 @@"ListData": {},"Properties": {"id": "20260613162855-y67hk0x",- "updated": "20261024161058"+ "updated": "20261025011511"},"Children": [{@@ -1157,7 +1203,7 @@},"Properties": {"id": "20260613162855-i1ifv63",- "updated": "20260613162855"+ "updated": "20261025011511"},"Children": [{@@ -1165,7 +1211,7 @@"Type": "NodeParagraph","Properties": {"id": "20260613162855-q8b0pyo",- "updated": "20260613162855"+ "updated": "20261025011511"},"Children": [{@@ -1176,6 +1222,28 @@{"Type": "NodeText","Data": ": Each card displays a summary of the content block bound to the primary key, along with the values of fields selected in that view"+ },+ {+ "Type": "NodeText",+ "Data": ". Open the view settings and enable "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Layout"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Display field name"+ },+ {+ "Type": "NodeText",+ "Data": " to show field names beside their values. This option is saved per view; turn it off to hide the names"}]}@@ -1316,7 +1384,7 @@"HeadingLevel": 3,"Properties": {"id": "20260613162855-sxaxx5x",- "updated": "20260927112821"+ "updated": "20261025011511"},"Children": [{@@ -1345,7 +1413,7 @@"ListData": {},"Properties": {"id": "20260613162855-9yfcx0f",- "updated": "20260613162855"+ "updated": "20261025011511"},"Children": [{@@ -1390,7 +1458,7 @@},"Properties": {"id": "20260613162855-39vgry3",- "updated": "20260613162855"+ "updated": "20261025011511"},"Children": [{@@ -1398,7 +1466,7 @@"Type": "NodeParagraph","Properties": {"id": "20260613162855-0c304fq",- "updated": "20260613162855"+ "updated": "20261025011511"},"Children": [{@@ -1409,6 +1477,28 @@{"Type": "NodeText","Data": ": Each entry is rendered as a card showing a summary of the primary key block's content and the selected field values, making it ideal for quick browsing and content-first viewing"+ },+ {+ "Type": "NodeText",+ "Data": ". Open the view settings and enable "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Layout"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Display field name"+ },+ {+ "Type": "NodeText",+ "Data": " to show field names beside their values. This option is saved per view; turn it off to hide the names"}]}diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20240208113259-nykkvaq.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20240208113259-nykkvaq.syindex daa3ebc31d..b0fb60bd99 100644--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20240208113259-nykkvaq.sy+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20240208113259-nykkvaq.sy@@ -7,7 +7,7 @@"id": "20240208113259-nykkvaq","title": "数据库","type": "doc",- "updated": "20261024164212"+ "updated": "20261025011511"},"Children": [{@@ -773,7 +773,7 @@"HeadingLevel": 3,"Properties": {"id": "20260920225154-xtg5hn3",- "updated": "20260929123717"+ "updated": "20261025011205"},"Children": [{@@ -802,7 +802,7 @@"ListData": {},"Properties": {"id": "20260920225154-09h9ysf",- "updated": "20260929123717"+ "updated": "20261025011205"},"Children": [{@@ -1046,6 +1046,52 @@]}]+ },+ {+ "ID": "20261025011205-rre2xnb",+ "Type": "NodeListItem",+ "Properties": {+ "id": "20261025011205-rre2xnb",+ "updated": "20261025011205"+ },+ "Children": [+ {+ "ID": "20261025011205-601x92p",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20261025011205-601x92p",+ "updated": "20261025011205"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "字段名称:在视图设置中开启 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "布局"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "显示字段名称"+ },+ {+ "Type": "NodeText",+ "Data": ",即可在非主键字段值旁显示字段名称,主键仍作为条目标题。该选项默认关闭,按日历视图保存,关闭后恢复为只显示字段值"+ }+ ]+ }+ ],+ "ListData": {+ "BulletChar": 42,+ "Marker": "Kg=="+ }}]},@@ -1055,7 +1101,7 @@"HeadingLevel": 3,"Properties": {"id": "20260613162748-v93usth",- "updated": "20261024161058"+ "updated": "20261025011511"},"Children": [{@@ -1084,7 +1130,7 @@"ListData": {},"Properties": {"id": "20260613162748-zeeswbq",- "updated": "20261024161058"+ "updated": "20261025011511"},"Children": [{@@ -1157,7 +1203,7 @@},"Properties": {"id": "20260613162748-cfi3bs0",- "updated": "20260613162748"+ "updated": "20261025011511"},"Children": [{@@ -1165,7 +1211,7 @@"Type": "NodeParagraph","Properties": {"id": "20260613162748-7cpchiq",- "updated": "20260613162748"+ "updated": "20261025011511"},"Children": [{@@ -1176,6 +1222,28 @@{"Type": "NodeText","Data": ":每张卡片展示主键所绑定块的内容摘要,以及该视图中所选字段的值"+ },+ {+ "Type": "NodeText",+ "Data": "。在视图设置中开启 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "布局"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "显示字段名称"+ },+ {+ "Type": "NodeText",+ "Data": ",可在字段值旁显示字段名称;该选项按视图保存,关闭后隐藏字段名称"}]}@@ -1316,7 +1384,7 @@"HeadingLevel": 3,"Properties": {"id": "20260613162748-amp8zb3",- "updated": "20260927112821"+ "updated": "20261025011511"},"Children": [{@@ -1345,7 +1413,7 @@"ListData": {},"Properties": {"id": "20260613162748-2p2jtiq",- "updated": "20260613162748"+ "updated": "20261025011511"},"Children": [{@@ -1390,7 +1458,7 @@},"Properties": {"id": "20260613162748-2hkin4f",- "updated": "20260613162748"+ "updated": "20261025011511"},"Children": [{@@ -1398,7 +1466,7 @@"Type": "NodeParagraph","Properties": {"id": "20260613162748-fuiujj7",- "updated": "20260613162748"+ "updated": "20261025011511"},"Children": [{@@ -1409,6 +1477,28 @@{"Type": "NodeText","Data": ":每条记录渲染为一张卡片,卡片中展示主键块的内容摘要和所选字段值,适合快速浏览和以内容为主的查看方式"+ },+ {+ "Type": "NodeText",+ "Data": "。在视图设置中开启 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "布局"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "显示字段名称"+ },+ {+ "Type": "NodeText",+ "Data": ",可在字段值旁显示字段名称;该选项按视图保存,关闭后隐藏字段名称"}]}diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20240208171522-y7dxcno.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20240208171522-y7dxcno.syindex f059acefe7..eaccd2651a 100644--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20240208171522-y7dxcno.sy+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20240208171522-y7dxcno.sy@@ -7,7 +7,7 @@"id": "20240208171522-y7dxcno","title": "資料庫","type": "doc",- "updated": "20261024164212"+ "updated": "20261025011511"},"Children": [{@@ -773,7 +773,7 @@"HeadingLevel": 3,"Properties": {"id": "20260920225154-xknvq29",- "updated": "20260929123717"+ "updated": "20261025011205"},"Children": [{@@ -802,7 +802,7 @@"ListData": {},"Properties": {"id": "20260920225154-mpwyzfe",- "updated": "20260929123717"+ "updated": "20261025011205"},"Children": [{@@ -1046,6 +1046,52 @@]}]+ },+ {+ "ID": "20261025011205-hpy47l0",+ "Type": "NodeListItem",+ "Properties": {+ "id": "20261025011205-hpy47l0",+ "updated": "20261025011205"+ },+ "Children": [+ {+ "ID": "20261025011205-9vepwg6",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20261025011205-9vepwg6",+ "updated": "20261025011205"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "欄位名稱:在檢視設定中開啟 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "佈局"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "顯示欄位名稱"+ },+ {+ "Type": "NodeText",+ "Data": ",即可在非主鍵欄位值旁顯示欄位名稱,主鍵仍作為項目標題。此選項預設關閉,依日曆檢視儲存,關閉後恢復為僅顯示欄位值"+ }+ ]+ }+ ],+ "ListData": {+ "BulletChar": 42,+ "Marker": "Kg=="+ }}]},@@ -1055,7 +1101,7 @@"HeadingLevel": 3,"Properties": {"id": "20260613164228-rrw0f53",- "updated": "20261024161058"+ "updated": "20261025011511"},"Children": [{@@ -1084,7 +1130,7 @@"ListData": {},"Properties": {"id": "20260613164228-hqf3wj5",- "updated": "20261024161058"+ "updated": "20261025011511"},"Children": [{@@ -1157,7 +1203,7 @@},"Properties": {"id": "20260613164228-yv431bq",- "updated": "20260613164228"+ "updated": "20261025011511"},"Children": [{@@ -1165,7 +1211,7 @@"Type": "NodeParagraph","Properties": {"id": "20260613164228-cosafjo",- "updated": "20260730184353"+ "updated": "20261025011511"},"Children": [{@@ -1176,6 +1222,28 @@{"Type": "NodeText","Data": ":每張卡片展示主鍵所繫結區塊的內容摘要,以及該視圖中所選字段的值"+ },+ {+ "Type": "NodeText",+ "Data": "。在視圖設定中開啟 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "佈局"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "顯示欄位名稱"+ },+ {+ "Type": "NodeText",+ "Data": ",可在欄位值旁顯示欄位名稱;此選項依視圖儲存,關閉後隱藏欄位名稱"}]}@@ -1316,7 +1384,7 @@"HeadingLevel": 3,"Properties": {"id": "20260613164228-jqu76ou",- "updated": "20260927112821"+ "updated": "20261025011511"},"Children": [{@@ -1345,7 +1413,7 @@"ListData": {},"Properties": {"id": "20260613164228-cgmduwb",- "updated": "20260613164228"+ "updated": "20261025011511"},"Children": [{@@ -1390,7 +1458,7 @@},"Properties": {"id": "20260613164228-imp49ba",- "updated": "20260613164228"+ "updated": "20261025011511"},"Children": [{@@ -1398,7 +1466,7 @@"Type": "NodeParagraph","Properties": {"id": "20260613164228-4efi1s4",- "updated": "20260730184353"+ "updated": "20261025011511"},"Children": [{@@ -1409,6 +1477,28 @@{"Type": "NodeText","Data": ":每條記錄渲染為一張卡片,卡片中展示主鍵區塊的內容摘要和所選字段值,適合快速瀏覽和以內容為主的檢視方式"+ },+ {+ "Type": "NodeText",+ "Data": "。在視圖設定中開啟 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "佈局"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "顯示欄位名稱"+ },+ {+ "Type": "NodeText",+ "Data": ",可在欄位值旁顯示欄位名稱;此選項依視圖儲存,關閉後隱藏欄位名稱"}]}diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-3eaevtp.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-3eaevtp.syindex cdbec7d9a2..d6b34cc622 100644--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-3eaevtp.sy+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-3eaevtp.sy@@ -8,7 +8,7 @@"id": "20240530101000-3eaevtp","title": "データベース","type": "doc",- "updated": "20261024164212"+ "updated": "20261025011511"},"Children": [{@@ -774,7 +774,7 @@"HeadingLevel": 3,"Properties": {"id": "20260920225154-vntgfc2",- "updated": "20260929123717"+ "updated": "20261025011205"},"Children": [{@@ -803,7 +803,7 @@"ListData": {},"Properties": {"id": "20260920225154-wh2lupo",- "updated": "20260929123717"+ "updated": "20261025011205"},"Children": [{@@ -1047,6 +1047,52 @@]}]+ },+ {+ "ID": "20261025011205-or11gjy",+ "Type": "NodeListItem",+ "Properties": {+ "id": "20261025011205-or11gjy",+ "updated": "20261025011205"+ },+ "Children": [+ {+ "ID": "20261025011205-1vqd168",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20261025011205-1vqd168",+ "updated": "20261025011205"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "フィールド名:ビュー設定で "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "レイアウト"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "フィールド名を表示"+ },+ {+ "Type": "NodeText",+ "Data": " を有効にすると、主キー以外の値の横にフィールド名を表示します。主キーは引き続きエントリのタイトルになります。初期状態では無効で、カレンダービューごとに保存されます。無効にすると値だけの表示に戻ります"+ }+ ]+ }+ ],+ "ListData": {+ "BulletChar": 42,+ "Marker": "Kg=="+ }}]},@@ -1056,7 +1102,7 @@"HeadingLevel": 3,"Properties": {"id": "20260613164213-x497lrs",- "updated": "20261024161058"+ "updated": "20261025011511"},"Children": [{@@ -1085,7 +1131,7 @@"ListData": {},"Properties": {"id": "20260613164213-kvig09h",- "updated": "20261024161058"+ "updated": "20261025011511"},"Children": [{@@ -1158,7 +1204,7 @@},"Properties": {"id": "20260613164213-9h3zw60",- "updated": "20260613164213"+ "updated": "20261025011511"},"Children": [{@@ -1166,7 +1212,7 @@"Type": "NodeParagraph","Properties": {"id": "20260613164213-nkkuyiq",- "updated": "20260613164213"+ "updated": "20261025011511"},"Children": [{@@ -1177,6 +1223,28 @@{"Type": "NodeText","Data": ":各カードには主キーにバインドされたコンテンツブロックの概要と、そのビューで選択したフィールドの値が表示されます"+ },+ {+ "Type": "NodeText",+ "Data": "。ビュー設定で "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "レイアウト"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "フィールド名を表示"+ },+ {+ "Type": "NodeText",+ "Data": " を有効にすると、値の横にフィールド名を表示します。この設定はビューごとに保存され、無効にするとフィールド名を非表示にできます"}]}@@ -1317,7 +1385,7 @@"HeadingLevel": 3,"Properties": {"id": "20260613164213-zanxpx0",- "updated": "20260927112821"+ "updated": "20261025011511"},"Children": [{@@ -1346,7 +1414,7 @@"ListData": {},"Properties": {"id": "20260613164213-5bpycoo",- "updated": "20260613164213"+ "updated": "20261025011511"},"Children": [{@@ -1391,7 +1459,7 @@},"Properties": {"id": "20260613164213-gwzs1xh",- "updated": "20260613164213"+ "updated": "20261025011511"},"Children": [{@@ -1399,7 +1467,7 @@"Type": "NodeParagraph","Properties": {"id": "20260613164213-2ltygil",- "updated": "20260613164213"+ "updated": "20261025011511"},"Children": [{@@ -1410,6 +1478,28 @@{"Type": "NodeText","Data": ":各エントリがカードとしてレンダリングされ、主キーブロックのコンテンツ概要と選択したフィールド値が表示されます。クイックブラウジングやコンテンツファーストの閲覧に最適"+ },+ {+ "Type": "NodeText",+ "Data": "。ビュー設定で "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "レイアウト"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "フィールド名を表示"+ },+ {+ "Type": "NodeText",+ "Data": " を有効にすると、値の横にフィールド名を表示します。この設定はビューごとに保存され、無効にするとフィールド名を非表示にできます"}]}diff --git a/app/src/assets/scss/business/_av-calendar.scss b/app/src/assets/scss/business/_av-calendar.scssindex 9e236e5b6d..a9daec84a8 100644--- a/app/src/assets/scss/business/_av-calendar.scss+++ b/app/src/assets/scss/business/_av-calendar.scss@@ -258,6 +258,22 @@pointer-events: none;}+ .av__calendar-field-row {+ display: flex;+ align-items: center;+ gap: 4px;++ > .av__calendar-field {+ flex: 1;+ }+ }++ .av__calendar-field-name {+ max-width: 40%;+ flex-shrink: 0;+ white-space: nowrap;+ }+.av__calendar-field {display: flex;align-items: center;diff --git a/app/src/protyle/render/av/calendar/render.test.ts b/app/src/protyle/render/av/calendar/render.test.tsindex 410c966b9c..bd30389cf8 100644--- a/app/src/protyle/render/av/calendar/render.test.ts+++ b/app/src/protyle/render/av/calendar/render.test.ts@@ -8,6 +8,8 @@ import {transpileModule, ModuleKind, ScriptTarget} from "typescript";import * as dates from "./date";import {cellValueIsEmpty, createEmptyAVValue} from "../cellValue";import {getConditionalBackground} from "../conditionalColor";+import {DOMFixture} from "../testDOM";+import {escapeAttr, escapeHtml} from "../../../../util/escape";const search = {bindAvSearch() {}, captureAvSearchSelection() {}, deferAvSearchRender: () => false};@@ -84,7 +86,7 @@ test("calendar refreshes the current view after composition and captures the latassert.equal(bound.selection, selection);});-test("calendar omits empty fields while preserving zero, unchecked boxes and rendered values", async () => {+test("calendar field names preserve titles, empty fields, zero, unchecked boxes and rendered values in month and week views", async () => {const start = new Date(2026, 8, 1).getTime();const range = {start, end: dates.addCalendarDays(start, 7), timeZone: "UTC"};const types: TAVCol[] = ["text", "number", "phone", "url", "email", "template", "select", "mSelect", "relation", "rollup", "mAsset", "date"];@@ -96,20 +98,22 @@ test("calendar omits empty fields while preserving zero, unchecked boxes and ren{...createEmptyAVValue("rendered", "text"), renderedContent: "Rendered", hasRenderTemplate: true},{...createEmptyAVValue("blank-rendered", "text"), text: {content: "Source"}, renderedContent: "", hasRenderTemplate: true},createEmptyAVValue("primary", "block"),+ {...createEmptyAVValue("hidden", "text"), text: {content: "Hidden value"}},);let html = "";const complete = new Error("rendered");const api = {} as typeof import("./render");+ const state = {anchor: start, mode: "week", rowLimit: 3, expandedWeeks: new Set()};const modules: Record<string, unknown> = {"./date": dates,- "./state": {getCalendarState: () => ({anchor: start, mode: "week", rowLimit: 3}), getCalendarRequestRange: () => range},+ "./state": {getCalendarState: () => state, getCalendarRequestRange: () => range},"./settings": {isCalendarDateColumn: () => true},"../cellValue": {cellValueIsEmpty},"../conditionalColor": {getConditionalBackground},"../cell": {renderCell: () => "<span></span>"},"../render": {genTabHeaderHTML: () => ""},"../search": search,- "../../../../util/escape": {escapeAttr: String, escapeHtml: String},+ "../../../../util/escape": {escapeAttr, escapeHtml},"../../../../constants": {Constants: {}},"../virtualScroll": {getAVSelectedItemIDs: (): string[] => []},"../container": {replaceAVContainer: (_block: unknown, value: string) => { html = value; throw complete; }},@@ -120,19 +124,38 @@ test("calendar omits empty fields while preserving zero, unchecked boxes and renexports: api, require: (name: string) => name === "./capabilities" || name === "../capabilities" ? capabilities : (modules[name] || {}),window: {siyuan: {config: {lang: "en"}, languages: {}}}, document: {activeElement: null},});- await assert.rejects(api.renderCalendar({querySelector: (): null => null, removeAttribute() {}} as unknown as HTMLElement,- {disabled: true, options: {}} as IProtyle, {viewID: "calendar", view: {- calendar: {dateKeyID: "date"}, calendarRange: range,- columns: values.map(value => ({id: value.keyID, type: value.type, name: value.keyID})),- rows: [{id: "row", cells: values.map(value => ({value})), conditionalColors: {background: {content: "", color: "3"}}}],- }} as unknown as IAV), error => error === complete);- for (const type of types) {- assert.doesNotMatch(html, new RegExp(`data-field-id="empty-${type}"`));- }- assert.doesNotMatch(html, /data-field-id="blank-rendered"/);- assert.match(html, /--b3-av-calendar-background:var\(--b3-font-background3\)/);- for (const key of ["primary", "date", "zero", "unchecked", "rendered"]) {- assert.match(html, new RegExp(`data-field-id="${key}"`));+ for (const mode of ["month", "week"]) {+ state.mode = mode;+ for (const displayFieldName of [undefined, false, true]) {+ await assert.rejects(api.renderCalendar({querySelector: (): null => null, removeAttribute() {}} as unknown as HTMLElement,+ {disabled: true, options: {}} as IProtyle, {viewID: "calendar", view: {+ calendar: {dateKeyID: "date", displayFieldName}, calendarRange: range,+ columns: values.map(value => ({id: value.keyID, type: value.type, name: `Name ${value.keyID} <&>`, hidden: value.keyID === "hidden"})),+ rows: [{id: "row", cells: values.map(value => ({value})), conditionalColors: {background: {content: "", color: "3"}}}],+ }} as unknown as IAV), error => error === complete);+ for (const type of types) {+ assert.doesNotMatch(html, new RegExp(`data-field-id="empty-${type}"`));+ }+ assert.doesNotMatch(html, /data-field-id="blank-rendered"/);+ assert.doesNotMatch(html, /data-field-id="hidden"/);+ assert.match(html, /--b3-av-calendar-background:var\(--b3-font-background3\)/);+ for (const key of ["primary", "date", "zero", "unchecked", "rendered"]) {+ assert.match(html, new RegExp(`data-field-id="${key}"`));+ }+ const document = new DOMFixture();+ document.body.innerHTML = html;+ const labels = document.body.querySelectorAll(".av__calendar-field-name");+ assert.equal(labels.length, displayFieldName ? 4 : 0);+ assert.equal(document.body.querySelector('[data-field-id="primary"]').parentElement.classList.contains("av__calendar-field-row"), false);+ if (displayFieldName) {+ assert.deepEqual(labels.map(label => label.textContent), ["date", "zero", "unchecked", "rendered"].map(key => `Name ${key} <&>`));+ assert.equal(labels[1].getAttribute("title"), "Name zero <&>");+ assert.equal(labels[1].children.length, 0);+ const checkbox = document.body.querySelector('[data-field-id="unchecked"]');+ assert.equal(checkbox.getAttribute("role"), "checkbox");+ assert.equal(checkbox.getAttribute("aria-checked"), "false");+ }+ }}});diff --git a/app/src/protyle/render/av/calendar/render.ts b/app/src/protyle/render/av/calendar/render.tsindex d850aa93fe..851bd46386 100644--- a/app/src/protyle/render/av/calendar/render.ts+++ b/app/src/protyle/render/av/calendar/render.ts@@ -98,7 +98,9 @@ const getEventHTML = (segment: ICalendarSegment, view: IAVTable, editable: booleconst checkClass = field.type === "checkbox" ? (cell.value?.checkbox?.checked ? " av__cell-check" : " av__cell-uncheck") : "";const checkbox = field.type === "checkbox" && !field.renderTemplate?.trim() ?` role="checkbox" tabindex="${editable ? "0" : "-1"}" aria-checked="${!!cell.value.checkbox?.checked}" aria-disabled="${!editable}" aria-label="${escapeAttr(field.name)}"` : "";- return `<div class="av__calendar-field${checkClass}"${checkbox} data-field-id="${field.id}" data-col-id="${field.id}" data-dtype="${field.type}" data-align="${field.align || ""}" data-wrap="${field.wrap}"${field.renderTemplate?.trim() ? ' data-render-template="true"' : ""} title="${escapeAttr(field.name)}">${renderCell(cell.value, event.rowIndex || 0, view.showIcon, "calendar", field.options, field.dateFormat, field.renderTemplate, false)}</div>`;+ const value = `<div class="av__calendar-field${checkClass}"${checkbox} data-field-id="${field.id}" data-col-id="${field.id}" data-dtype="${field.type}" data-align="${field.align || ""}" data-wrap="${field.wrap}"${field.renderTemplate?.trim() ? ' data-render-template="true"' : ""} title="${escapeAttr(field.name)}">${renderCell(cell.value, event.rowIndex || 0, view.showIcon, "calendar", field.options, field.dateFormat, field.renderTemplate, false)}</div>`;+ return view.calendar.displayFieldName && field.type !== "block" ?+ `<div class="av__calendar-field-row"><span class="av__calendar-field-name fn__ellipsis" title="${escapeAttr(field.name)}">${escapeHtml(field.name)}</span>${value}</div>` : value;}).join("");return `<div class="av__calendar-item${starts ? " av__calendar-item--start" : ""}${ends ? " av__calendar-item--end" : ""}" role="button" tabindex="0" data-calendar-item="${event.row.id}" data-id="${event.row.id}" title="${escapeAttr(title)}" style="grid-column:${segment.column + 1}/span ${segment.span};grid-row:${segment.lane + 1};${background ? `--b3-av-calendar-background:${background}` : ""}">${drag && starts ? `<span class="av__calendar-resize av__calendar-resize--start" data-calendar-resize="start" title="${window.siyuan.languages.calendarResizeStart}"></span>` : ""}diff --git a/app/src/protyle/render/av/calendar/settings.test.ts b/app/src/protyle/render/av/calendar/settings.test.tsindex 1a475f5134..c9b7e72fe9 100644--- a/app/src/protyle/render/av/calendar/settings.test.ts+++ b/app/src/protyle/render/av/calendar/settings.test.ts@@ -66,7 +66,7 @@ test("calendar layout submenus filter choices, mark selection and preserve undo"const {methods, transactions, menus} = setup();const current = data();const view = current.view as IAVTable;- view.calendar = {dateKeyID: "date", colorKeyID: "color", weekStart: 1};+ view.calendar = {dateKeyID: "date", colorKeyID: "color", weekStart: 1, displayFieldName: true};view.columns = [{id: "date", type: "date", name: "Date"}, {id: "created", type: "created", name: "Created"},{id: "updated", type: "updated", name: "Updated"}, {id: "color", type: "select", name: "Color"},{id: "text", type: "text", name: "Text"}] as IAVColumn[];@@ -89,6 +89,8 @@ test("calendar layout submenus filter choices, mark selection and preserve undo"assert.equal(transactions.length, 1);assert.equal(settingsOf(transactions[0].do[0])[key], key === "weekStart" ? 0 : "");assert.equal(settingsOf(transactions[0].undo[0])[key], key === "weekStart" ? 1 : "date");+ assert.equal(settingsOf(transactions[0].do[0]).displayFieldName, true);+ assert.equal(settingsOf(transactions[0].undo[0]).displayFieldName, true);assert.equal(refreshed, 1);}});diff --git a/app/src/protyle/render/av/layout.test.ts b/app/src/protyle/render/av/layout.test.tsnew file mode 100644index 0000000000..d061f66acf--- /dev/null+++ b/app/src/protyle/render/av/layout.test.ts@@ -0,0 +1,77 @@+import * as assert from "node:assert/strict";+import {readFileSync} from "node:fs";+import {join} from "node:path";+import {test} from "node:test";+import {runInNewContext} from "node:vm";+import {ModuleKind, ScriptTarget, transpileModule} from "typescript";+import {DOMFixture} from "./testDOM";+import * as capabilities from "./capabilities";++const setup = () => {+ const api = {} as typeof import("./layout");+ const transactions: Array<{perform: IOperation[]; undo: IOperation[]}> = [];+ let calendarBindings = 0;+ const modules: Record<string, unknown> = {+ "./capabilities": capabilities,+ "./calendar/settings": {getCalendarSettingsHTML: () => "", bindCalendarSettings() { calendarBindings++; }},+ "./viewType": {isTableLikeView: (type: TAVView) => type === "table" || type === "list"},+ "../../wysiwyg/transaction": {transaction: (_protyle: IProtyle, perform: IOperation[], undo: IOperation[]) => {+ transactions.push({perform, undo});+ }},+ "../../../constants": {Constants: {CUSTOM_SY_AV_VIEW: "custom-sy-av-view"}},+ "../../../util/setPosition": {setPosition() {}},+ "./gallery/style": {getCardWidth: () => 240, getCardAspectRatioValue: () => 1, getCardAspectRatioLabel: () => "1:1"},+ "./gallery/cardLayout": {CARD_LAYOUT_COMPACT: 1},+ };+ runInNewContext(transpileModule(readFileSync(join(__dirname, "layout.ts"), "utf8"), {+ compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2022},+ }).outputText, {exports: api, require: (name: string) => modules[name] || {},+ window: {siyuan: {languages: {displayFieldName: "Display field names"}}}});+ return {api, transactions, getCalendarBindings: () => calendarBindings};+};++test("field name switches persist per view and restore previous values for calendar, gallery and kanban", () => {+ for (const type of ["calendar", "gallery", "kanban"] as const) {+ for (const previous of [undefined, false, true]) {+ const fixture = setup();+ const document = new DOMFixture();+ const menu = document.createElement("div");+ const block = document.createElement("div");+ block.setAttribute("data-av-id", "database");+ block.setAttribute("data-node-id", "carrier");+ block.innerHTML = '<div class="av__views"></div>';+ const view = {calendar: {displayFieldName: previous}, displayFieldName: previous, coverFrom: 0,+ fields: [] as IAVGallery["fields"], pageSize: 20};+ const data = {viewID: "selected-view", viewType: type, view} as unknown as IAV;+ menu.innerHTML = fixture.api.getLayoutHTML(data);+ const selector = '.b3-switch[data-type="toggle-gallery-name"]';+ const input = menu.querySelector(selector);+ assert.ok(input, type);+ assert.equal(input.hasAttribute("checked"), !!previous);+ fixture.api.bindLayoutEvent({data, protyle: {} as IProtyle, menuElement: menu as unknown as HTMLElement,+ blockElement: block as unknown as Element});+ (input as unknown as HTMLInputElement).checked = !previous;+ input.dispatch("change");+ assert.equal(fixture.transactions.length, 1);+ const {perform, undo} = fixture.transactions[0];+ for (const [operations, expected] of [[perform, !previous], [undo, !!previous]] as const) {+ assert.equal(operations.length, 1);+ assert.equal(operations[0].action, "setAttrViewDisplayFieldName");+ assert.equal(operations[0].data, expected);+ assert.equal(operations[0].viewID, "selected-view");+ assert.equal(operations[0].avID, "database");+ assert.equal(operations[0].blockID, "carrier");+ }+ assert.equal(type === "calendar" ? view.calendar.displayFieldName : view.displayFieldName, !previous);+ assert.equal(menu.querySelector(selector).hasAttribute("checked"), !previous);+ assert.equal(fixture.getCalendarBindings(), type === "calendar" ? 2 : 0);+ }+ }+});++test("table and list layouts keep their existing field name presentation", () => {+ const {api} = setup();+ for (const viewType of ["table", "list"] as const) {+ assert.doesNotMatch(api.getLayoutHTML({viewType, view: {}} as IAV), /toggle-gallery-name/);+ }+});diff --git a/app/src/protyle/render/av/layout.ts b/app/src/protyle/render/av/layout.tsindex a91a88f77d..6a2a47061a 100644--- a/app/src/protyle/render/av/layout.ts+++ b/app/src/protyle/render/av/layout.ts@@ -172,7 +172,11 @@ export const getLayoutHTML = (data: IAV) => {</label>`;}if (data.viewType === "calendar") {- return html + getCalendarSettingsHTML(data.view as IAVTable, true) + "</div>";+ return html + `<label class="b3-menu__item">+ <span class="fn__flex-center">${window.siyuan.languages.displayFieldName}</span>+ <span class="fn__space fn__flex-1"></span>+ <input data-type="toggle-gallery-name" type="checkbox" class="b3-switch b3-switch--menu" ${(data.view as IAVTable).calendar.displayFieldName ? "checked" : ""}>+</label>` + getCalendarSettingsHTML(data.view as IAVTable, true) + "</div>";}return html + `<button class="b3-menu__item" data-type="set-page-size" data-size="${view.pageSize}"><span class="fn__flex-center">${window.siyuan.languages.entryNum}</span>@@ -286,6 +290,28 @@ export const bindLayoutEvent = (options: {});options.data.view.wrapField = checked;});+ const toggleNameElement = options.menuElement.querySelector('.b3-switch[data-type="toggle-gallery-name"]') as HTMLInputElement;+ toggleNameElement?.addEventListener("change", () => {+ const checked = toggleNameElement.checked;+ const view = options.data.viewType === "calendar" ? (options.data.view as IAVTable).calendar :+ options.data.view as IAVGallery | IAVKanban;+ const previous = !!view.displayFieldName;+ transaction(options.protyle, [{+ action: "setAttrViewDisplayFieldName",+ avID,+ blockID,+ data: checked,+ viewID+ }], [{+ action: "setAttrViewDisplayFieldName",+ avID,+ blockID,+ data: previous,+ viewID+ }]);+ view.displayFieldName = checked;+ rerender();+ });if (options.data.viewType === "calendar") {bindCalendarSettings({...options, onChange: rerender});return;@@ -363,25 +389,6 @@ export const bindLayoutEvent = (options: {}]);(options.data.view as IAVGallery).fitImage = checked;});- const toggleNameElement = options.menuElement.querySelector('.b3-switch[data-type="toggle-gallery-name"]') as HTMLInputElement;- toggleNameElement.addEventListener("change", () => {- const checked = toggleNameElement.checked;- transaction(options.protyle, [{- action: "setAttrViewDisplayFieldName",- avID,- blockID,- data: checked,- viewID- }], [{- action: "setAttrViewDisplayFieldName",- avID,- blockID,- data: !checked,- viewID- }]);- (options.data.view as IAVGallery | IAVKanban).displayFieldName = checked;- rerender();- });const toggleEmptyElement = options.menuElement.querySelector('.b3-switch[data-type="toggle-gallery-empty"]') as HTMLInputElement;toggleEmptyElement.addEventListener("change", () => {const checked = toggleEmptyElement.checked;diff --git a/app/src/types/api/index.d.ts b/app/src/types/api/index.d.tsindex 402becbdc6..19caedf1e5 100644--- a/app/src/types/api/index.d.ts+++ b/app/src/types/api/index.d.ts@@ -294,9 +294,9 @@ export type AVCalendarRange = { "end": number; "start": number; "timeZone": striexport type AVCalendarRangeInput = { "end": number; "start": number; "timeZone": string; };-export type AVCalendarSettings = { "colorKeyID": string; "dateKeyID": string; "rowLimit"?: number; "weekStart": number; };+export type AVCalendarSettings = { "colorKeyID": string; "dateKeyID": string; "displayFieldName"?: boolean; "rowLimit"?: number; "weekStart": number; };-export type AVCalendarSettingsInput = { "colorKeyID": string; "dateKeyID": string; "rowLimit"?: number; "weekStart": number; };+export type AVCalendarSettingsInput = { "colorKeyID": string; "dateKeyID": string; "displayFieldName"?: boolean; "rowLimit"?: number; "weekStart": number; };export type AVCalendarUndatedData = { "rows": Array<AVTableRow | null> | null; "total": number; };diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex bf2f5e63eb..a79618dd43 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -1269,6 +1269,8 @@ interface IAVCalendarSettings {weekStart: number;/** 月视图折叠前的条目行数:3、5、10 或 -1(全部);省略或 0 使用 3,周视图显示全部,不影响查询范围。 */rowLimit?: number;+ /** 在日历条目中显示非主键字段的名称,默认关闭;按视图保存,支持撤销和重做。 */+ displayFieldName?: boolean;}/**diff --git a/app/tests/avCalendarFieldNames.test.js b/app/tests/avCalendarFieldNames.test.jsnew file mode 100644index 0000000000..994c8fb1f3--- /dev/null+++ b/app/tests/avCalendarFieldNames.test.js@@ -0,0 +1,126 @@+const assert = require("node:assert/strict");+const {mkdtempSync, readFileSync, rmSync} = require("node:fs");+const path = require("node:path");+const os = require("node:os");+const {runInNewContext} = require("node:vm");+const {transpileModule, ModuleKind, ScriptTarget} = require("typescript");+const sass = require("sass");++const calendarItem = mobile => {+ const api = {};+ const source = readFileSync(path.join(__dirname, "../src/protyle/render/av/calendar/render.ts"), "utf8");+ const escape = value => String(value).replaceAll("&", "&").replaceAll("<", "<").replaceAll('"', """);+ const modules = {+ "../../../../util/escape": {escapeAttr: escape, escapeHtml: escape},+ "../../../../util/functions": {isMobile: () => mobile},+ "./date": {getCalendarDate: value => value.date, isCalendarDateEditable: () => true},+ "../conditionalColor": {getConditionalBackground: () => ""},+ "../cellValue": {cellValueIsEmpty: () => false},+ "../cell": {renderCell: value => `<span class="av__celltext">${escape(value.text?.content ?? value.number?.content ?? "[ ]")}</span>`},+ };+ runInNewContext(transpileModule(source, {+ compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2022},+ }).outputText + "\nexports.getEventHTML = getEventHTML;", {+ exports: api, require: name => modules[name] || {}, window: {siyuan: {config: {lang: "en"}, languages: {}}},+ });+ const values = [+ {keyID: "primary", type: "block", block: {content: "Entry title"}, text: {content: "Entry title"}},+ {keyID: "amount", type: "number", number: {content: 0}},+ {keyID: "note", type: "text", text: {content: "A_long_value_that_wraps_without_expanding_the_calendar_column"}},+ {keyID: "check", type: "checkbox", checkbox: {checked: false}},+ ];+ const row = {id: "item", cells: values.map(value => ({value}))};+ const view = {calendar: {displayFieldName: true}, columns: values.map(value => ({+ id: value.keyID, type: value.type, name: "A very long field name that must remain bounded", wrap: value.keyID === "note",+ }))};+ const date = {value: {type: "date", date: {isNotTime: true}}};+ return api.getEventHTML({event: {row, date}, starts: true, ends: true, column: 0, span: 1, lane: 0}, view, true);+};++const browserCases = (css, item) => {+ const check = require("node:assert/strict");+ document.head.innerHTML = "<style></style>";+ document.head.firstElementChild.textContent = css;+ for (const size of [16, 28]) {+ document.body.style.fontSize = size + "px";+ document.body.innerHTML = `<div class="av" data-av-type="calendar"><div class="av__calendar-events">${item}</div></div>`;+ const card = document.querySelector(".av__calendar-item");+ const content = document.querySelector(".av__calendar-item-content");+ const primary = document.querySelector('[data-field-id="primary"]');+ check.equal(primary.parentElement, content, "the primary key remains an unlabeled title");+ const rows = document.querySelectorAll(".av__calendar-field-row");+ check.equal(rows.length, 3);+ for (const row of rows) {+ const label = row.firstElementChild;+ const value = row.lastElementChild;+ const bounds = row.getBoundingClientRect();+ const nameBounds = label.getBoundingClientRect();+ const valueBounds = value.getBoundingClientRect();+ check.ok(bounds.width > 0);+ check.ok(nameBounds.width <= bounds.width * 0.4 + 1, "long names leave space for their values");+ check.ok(valueBounds.width > 0);+ check.ok(valueBounds.right <= bounds.right + 1, "values stay inside their event");+ check.ok(label.scrollWidth > label.clientWidth, "long field names truncate");+ check.equal(getComputedStyle(label).textOverflow, "ellipsis");+ }+ check.ok(content.scrollWidth <= content.clientWidth + 1, "field labels do not expand the event");+ const amount = document.querySelector('[data-field-id="amount"]');+ check.equal(amount.textContent, "0");+ check.equal(getComputedStyle(amount.firstElementChild).whiteSpace, "nowrap");+ const note = document.querySelector('[data-field-id="note"]');+ check.equal(getComputedStyle(note.firstElementChild).whiteSpace, "pre-wrap");+ check.ok(note.getBoundingClientRect().height > amount.getBoundingClientRect().height, "wrapped values retain multiple lines");+ const checkbox = document.querySelector('[data-field-id="check"]');+ check.equal(getComputedStyle(checkbox).pointerEvents, "auto");+ check.equal(checkbox.getAttribute("aria-checked"), "false");+ check.ok(checkbox.getAttribute("aria-label").length > 0);+ check.ok(card.getBoundingClientRect().right <= document.body.getBoundingClientRect().right + 1);+ }+ return "Calendar field name layout passed";+};++if (process.versions.electron && process.type === "browser") {+ const {app, BrowserWindow} = require("electron");+ app.setPath("userData", process.argv[2]);+ app.whenReady().then(async () => {+ const win = new BrowserWindow({show: false, webPreferences: {nodeIntegration: true, contextIsolation: false, offscreen: true}});+ try {+ for (const name of ["base", "mobile"]) {+ const styles = sass.compile(path.join(__dirname, `../src/assets/scss/${name}.scss`), {logger: sass.Logger.silent}).css;+ for (const theme of ["daylight", "midnight"]) {+ const css = readFileSync(path.join(__dirname, `../appearance/themes/${theme}/theme.css`), "utf8") + styles;+ for (const width of [1280, 840, 420]) {+ win.setSize(width, 900);+ await win.loadURL("data:text/html,<html><body></body></html>");+ const result = await win.webContents.executeJavaScript(+ `(() => { try { return (${browserCases.toString()})(${JSON.stringify(css)}, ${JSON.stringify(calendarItem(name === "mobile"))}); } catch (error) { return error.stack; } })()`);+ assert.equal(result, "Calendar field name layout passed", `${name}/${theme}/${width}`);+ }+ }+ }+ console.log("Calendar field name layout passed");+ app.exit(0);+ } catch (error) {+ console.error(error);+ app.exit(1);+ }+ }).catch(error => { console.error(error); app.exit(1); });+} else {+ require("node:test").test("calendar field names fit desktop and mobile events in both themes at narrow widths and large editor fonts", {+ skip: process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY,+ timeout: 60000,+ }, async () => {+ const profile = mkdtempSync(path.join(os.tmpdir(), "siyuan-calendar-fields-"));+ const env = {...process.env};+ delete env.ELECTRON_RUN_AS_NODE;+ try {+ const {stdout} = await require("node:util").promisify(require("node:child_process").execFile)(+ require("electron"), [__filename, profile], {env, windowsHide: true, timeout: 55000});+ assert.match(stdout, /Calendar field name layout passed/);+ } finally {+ assert.equal(path.dirname(path.resolve(profile)), path.resolve(os.tmpdir()));+ assert.ok(path.basename(profile).startsWith("siyuan-calendar-fields-"));+ rmSync(profile, {recursive: true, force: true, maxRetries: 5, retryDelay: 100});+ }+ });+}diff --git a/kernel/api/av_contract_calendar.go b/kernel/api/av_contract_calendar.goindex e9da30dffd..1f24b4452c 100644--- a/kernel/api/av_contract_calendar.go+++ b/kernel/api/av_contract_calendar.go@@ -24,7 +24,7 @@ func toContractAVCalendarSettings(value *av.CalendarSettings) *apicontract.AVCalreturn nil}return &apicontract.AVCalendarSettings{DateKeyID: value.DateKeyID, ColorKeyID: value.ColorKeyID,- WeekStart: value.WeekStart, RowLimit: value.RowLimit}+ WeekStart: value.WeekStart, RowLimit: value.RowLimit, DisplayFieldName: value.DisplayFieldName}}func toContractAVLayoutCalendar(value *av.LayoutCalendar) *apicontract.AVLayoutCalendar {diff --git a/kernel/api/contract_av_calendar_test.go b/kernel/api/contract_av_calendar_test.goindex e3a4a34de3..e5ada888bc 100644--- a/kernel/api/contract_av_calendar_test.go+++ b/kernel/api/contract_av_calendar_test.go@@ -126,6 +126,36 @@ func TestAVContractCalendarTemplateDate(t *testing.T) {}}+func TestAVContractCalendarFieldNames(t *testing.T) {+ fixture := setupAttributeViewContextFilterAPITest(t)+ database := fixture.attrView+ view := database.Views[0]+ view.LayoutType = av.LayoutTypeCalendar+ view.Calendar = &av.LayoutCalendar{LayoutTable: view.Table, Settings: av.CalendarSettings{WeekStart: 1}}+ view.Table = nil+ for _, enabled := range []bool{false, true} {+ view.Calendar.Settings.DisplayFieldName = enabled+ if err := av.SaveAttributeView(database); err != nil {+ t.Fatal(err)+ }+ assertAVContractJSONEqual(t, view.Calendar, toContractAVLayoutCalendar(view.Calendar))+ path := "/api/av/renderAttributeView"+ response := callAttributeViewContextFilterAPI(t, path, map[string]any{+ "id": database.ID, "viewID": view.ID,+ }, renderAttributeView)+ requireAPIContract(t, http.MethodPost, path, response)+ var result struct {+ Code int+ Data struct{ View *av.Table }+ }+ decodeAttributeViewContextFilterAPIResponse(t, response, &result)+ if result.Code != 0 || result.Data.View == nil || result.Data.View.Calendar == nil ||+ result.Data.View.Calendar.DisplayFieldName != enabled {+ t.Fatalf("calendar field name setting lost: %s", response.Body.String())+ }+ }+}+func TestAVContractCalendarLegacyRowIDs(t *testing.T) {for _, test := range []struct {name stringdiff --git a/kernel/apicontract/av_calendar.go b/kernel/apicontract/av_calendar.goindex 0390ef1752..143ac354ad 100644--- a/kernel/apicontract/av_calendar.go+++ b/kernel/apicontract/av_calendar.go@@ -1,6 +1,6 @@package apicontract-// AVCalendarSettings 是 setAttrViewCalendar 事务的完整设置数据,也是日历布局的持久化字段设置。+// AVCalendarSettings 是 setAttrViewCalendar 事务的完整设置数据,也是日历布局的持久化字段和显示设置。// 月周模式和当前浏览日期由各编辑器独立维护,不写入共享设置。// 切换布局保留其他布局及分组设置;日历渲染不应用分组。type AVCalendarSettings struct {@@ -19,6 +19,8 @@ type AVCalendarSettings struct {// 月视图折叠前显示的条目行数,可选 3、5、10;-1 表示全部,省略或 0 按 3 行显示。// 仅控制客户端折叠,不限制查询结果;周视图始终显示全部条目。RowLimit int `json:"rowLimit,omitempty" api:"optional"`+ // 是否在日历条目中显示非主键字段的名称;省略时关闭,按视图保存,支持撤销和重做。+ DisplayFieldName bool `json:"displayFieldName,omitempty" api:"optional"`}// AVCalendarRange 是本次渲染的毫秒时间戳半开区间 [start, end),不持久化。diff --git a/kernel/apicontract/schema.json b/kernel/apicontract/schema.jsonindex fa97391698..00f84e17cb 100644--- a/kernel/apicontract/schema.json+++ b/kernel/apicontract/schema.json@@ -7537,6 +7537,9 @@"dateKeyID": {"type": "string"},+ "displayFieldName": {+ "type": "boolean"+ },"rowLimit": {"type": "integer"},@@ -7560,6 +7563,9 @@"dateKeyID": {"type": "string"},+ "displayFieldName": {+ "type": "boolean"+ },"rowLimit": {"type": "integer"},diff --git a/kernel/av/layout_calendar.go b/kernel/av/layout_calendar.goindex 0f7c1067a5..b2c3edc464 100644--- a/kernel/av/layout_calendar.go+++ b/kernel/av/layout_calendar.go@@ -13,12 +13,13 @@ import (_ "time/tzdata")-// CalendarSettings 保存日历的字段绑定;浏览日期和月周切换由各编辑器独立维护。+// CalendarSettings 保存日历的字段绑定和显示设置;浏览日期和月周切换由各编辑器独立维护。type CalendarSettings struct {- DateKeyID string `json:"dateKeyID"`- ColorKeyID string `json:"colorKeyID"`- WeekStart int `json:"weekStart"`- RowLimit int `json:"rowLimit,omitempty"`+ DateKeyID string `json:"dateKeyID"`+ ColorKeyID string `json:"colorKeyID"`+ WeekStart int `json:"weekStart"`+ RowLimit int `json:"rowLimit,omitempty"`+ DisplayFieldName bool `json:"displayFieldName,omitempty"`}// ValidRowLimit 保留旧设置的零值默认值,负一表示展开全部条目行。diff --git a/kernel/av/layout_calendar_test.go b/kernel/av/layout_calendar_test.goindex 9cd9c60a87..71d620c0f3 100644--- a/kernel/av/layout_calendar_test.go+++ b/kernel/av/layout_calendar_test.go@@ -102,6 +102,24 @@ func TestCalendarTemplateAllLanguages(t *testing.T) {}}+func TestCalendarDisplayFieldNameCompatibility(t *testing.T) {+ var settings CalendarSettings+ if err := json.Unmarshal([]byte(`{"dateKeyID":"date","colorKeyID":"","weekStart":1}`), &settings); err != nil {+ t.Fatal(err)+ }+ if settings.DisplayFieldName {+ t.Fatal("existing calendars must keep field names hidden")+ }+ for _, enabled := range []bool{true, false} {+ settings.DisplayFieldName = enabled+ data, err := json.Marshal(settings)+ var actual CalendarSettings+ if err != nil || json.Unmarshal(data, &actual) != nil || actual != settings {+ t.Fatalf("field name setting round trip: %s", data)+ }+ }+}+func TestCalendarRowLimitCompatibility(t *testing.T) {var settings CalendarSettingsif err := json.Unmarshal([]byte(`{"dateKeyID":"date","colorKeyID":"","weekStart":1}`), &settings); err != nil {diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex 27c5a976b7..b59fa340b4 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -1781,8 +1781,10 @@ func setAttrViewDisplayFieldName(operation *Operation) (err error) {}switch view.LayoutType {- case av.LayoutTypeTable, av.LayoutTypeList, av.LayoutTypeCalendar:+ case av.LayoutTypeTable, av.LayoutTypeList:return+ case av.LayoutTypeCalendar:+ view.Calendar.Settings.DisplayFieldName = operation.Data.(bool)case av.LayoutTypeGallery:view.Gallery.DisplayFieldName = operation.Data.(bool)case av.LayoutTypeKanban:diff --git a/kernel/model/attribute_view_calendar_fts5_test.go b/kernel/model/attribute_view_calendar_fts5_test.goindex cff32664f9..352d8e149a 100644--- a/kernel/model/attribute_view_calendar_fts5_test.go+++ b/kernel/model/attribute_view_calendar_fts5_test.go@@ -31,6 +31,8 @@ func TestAttributeViewCalendarDateUndoAndEncryptedReplay(t *testing.T) {if err := changeAttrViewLayout(original, original.Views[0], av.LayoutTypeCalendar); err != nil {t.Fatal(err)}+ otherView := av.NewCalendarView()+ original.Views = append(original.Views, otherView)boxID := ""plainPath := filepath.Join(util.DataDir, "storage", "av", original.ID+".json")if encrypted {@@ -58,9 +60,15 @@ func TestAttributeViewCalendarDateUndoAndEncryptedReplay(t *testing.T) {settings := original.Views[0].Calendar.SettingsnextSettings := settingsnextSettings.RowLimit = 5+ nextSettings.DisplayFieldName = true+ beforeDisplaySettings := nextSettings+ beforeDisplaySettings.DisplayFieldName = falsesetRows := func(value av.CalendarSettings) *Operation {return &Operation{Action: "setAttrViewCalendar", AvID: original.ID, ViewID: original.Views[0].ID, Data: value}}+ setNames := func(enabled bool) *Operation {+ return &Operation{Action: "setAttrViewDisplayFieldName", AvID: original.ID, ViewID: original.Views[0].ID, Data: enabled}+ }key, _ := original.GetKeyValues(settings.DateKeyID)value := key.Values[0]before := *value.Date@@ -71,8 +79,8 @@ func TestAttributeViewCalendarDateUndoAndEncryptedReplay(t *testing.T) {return &Operation{Action: "updateAttrViewCell", AvID: original.ID, KeyID: key.Key.ID,RowID: value.BlockID, ID: value.ID, Data: map[string]any{"type": "date", "date": date}}}- tx := &Transaction{DoOperations: []*Operation{operation(after), setRows(nextSettings)},- UndoOperations: []*Operation{operation(before), setRows(settings)}, fromAPI: true}+ tx := &Transaction{DoOperations: []*Operation{operation(after), setRows(beforeDisplaySettings), setNames(true)},+ UndoOperations: []*Operation{operation(before), setRows(settings), setNames(false)}, fromAPI: true}if err := PerformTxSync(tx); err != nil {t.Fatal(err)}@@ -95,6 +103,10 @@ func TestAttributeViewCalendarDateUndoAndEncryptedReplay(t *testing.T) {if !reflect.DeepEqual(actual, replay.expected) || stored.Views[0].Calendar.Settings != replay.settings {t.Fatalf("date replay: actual=%+v expected=%+v settings=%+v", actual, replay.expected, stored.Views[0].Calendar.Settings)}+ if stored.Views[len(stored.Views)-1].ID != otherView.ID ||+ stored.Views[len(stored.Views)-1].Calendar.Settings.DisplayFieldName {+ t.Fatal("field name setting changed another calendar view")+ }}if encrypted {path := filepath.Join(util.DataDir, boxID, "storage", "av", original.ID+".json")