🎨 Add template type column to Attribute View https://github.com/siyuan-note/siyuan/issues/8766

This commit is contained in:
Daniel 2023-10-01 17:36:22 +08:00
parent b833087cb6
commit b2f5ab5700
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017
2 changed files with 11 additions and 11 deletions

View File

@ -143,7 +143,7 @@ func (value *Value) String() string {
} }
return strings.Join(ret, " ") return strings.Join(ret, " ")
case KeyTypeTemplate: case KeyTypeTemplate:
return value.Template.RenderedContent return value.Template.content
default: default:
return "" return ""
} }
@ -351,11 +351,11 @@ type ValueAsset struct {
} }
type ValueTemplate struct { type ValueTemplate struct {
RenderedContent string `json:"renderedContent"` content string `json:"content"`
} }
func (t *ValueTemplate) Render(blockID string, r func(blockID string) string) { func (t *ValueTemplate) Render(blockID string, r func(blockID string) string) {
t.RenderedContent = r(blockID) t.content = r(blockID)
} }
// View 描述了视图的结构。 // View 描述了视图的结构。

View File

@ -523,7 +523,7 @@ func (table *Table) calcColTemplate(col *TableColumn, colIndex int) {
case CalcOperatorCountValues: case CalcOperatorCountValues:
countValues := 0 countValues := 0
for _, row := range table.Rows { for _, row := range table.Rows {
if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Template && "" != row.Cells[colIndex].Value.Template.RenderedContent { if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Template && "" != row.Cells[colIndex].Value.Template.content {
countValues++ countValues++
} }
} }
@ -532,9 +532,9 @@ func (table *Table) calcColTemplate(col *TableColumn, colIndex int) {
countUniqueValues := 0 countUniqueValues := 0
uniqueValues := map[string]bool{} uniqueValues := map[string]bool{}
for _, row := range table.Rows { for _, row := range table.Rows {
if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Template && "" != row.Cells[colIndex].Value.Template.RenderedContent { if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Template && "" != row.Cells[colIndex].Value.Template.content {
if !uniqueValues[row.Cells[colIndex].Value.Template.RenderedContent] { if !uniqueValues[row.Cells[colIndex].Value.Template.content] {
uniqueValues[row.Cells[colIndex].Value.Template.RenderedContent] = true uniqueValues[row.Cells[colIndex].Value.Template.content] = true
countUniqueValues++ countUniqueValues++
} }
} }
@ -543,7 +543,7 @@ func (table *Table) calcColTemplate(col *TableColumn, colIndex int) {
case CalcOperatorCountEmpty: case CalcOperatorCountEmpty:
countEmpty := 0 countEmpty := 0
for _, row := range table.Rows { for _, row := range table.Rows {
if nil == row.Cells[colIndex] || nil == row.Cells[colIndex].Value || nil == row.Cells[colIndex].Value.Template || "" == row.Cells[colIndex].Value.Template.RenderedContent { if nil == row.Cells[colIndex] || nil == row.Cells[colIndex].Value || nil == row.Cells[colIndex].Value.Template || "" == row.Cells[colIndex].Value.Template.content {
countEmpty++ countEmpty++
} }
} }
@ -551,7 +551,7 @@ func (table *Table) calcColTemplate(col *TableColumn, colIndex int) {
case CalcOperatorCountNotEmpty: case CalcOperatorCountNotEmpty:
countNotEmpty := 0 countNotEmpty := 0
for _, row := range table.Rows { for _, row := range table.Rows {
if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Template && "" != row.Cells[colIndex].Value.Template.RenderedContent { if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Template && "" != row.Cells[colIndex].Value.Template.content {
countNotEmpty++ countNotEmpty++
} }
} }
@ -559,7 +559,7 @@ func (table *Table) calcColTemplate(col *TableColumn, colIndex int) {
case CalcOperatorPercentEmpty: case CalcOperatorPercentEmpty:
countEmpty := 0 countEmpty := 0
for _, row := range table.Rows { for _, row := range table.Rows {
if nil == row.Cells[colIndex] || nil == row.Cells[colIndex].Value || nil == row.Cells[colIndex].Value.Template || "" == row.Cells[colIndex].Value.Template.RenderedContent { if nil == row.Cells[colIndex] || nil == row.Cells[colIndex].Value || nil == row.Cells[colIndex].Value.Template || "" == row.Cells[colIndex].Value.Template.content {
countEmpty++ countEmpty++
} }
} }
@ -569,7 +569,7 @@ func (table *Table) calcColTemplate(col *TableColumn, colIndex int) {
case CalcOperatorPercentNotEmpty: case CalcOperatorPercentNotEmpty:
countNotEmpty := 0 countNotEmpty := 0
for _, row := range table.Rows { for _, row := range table.Rows {
if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Template && "" != row.Cells[colIndex].Value.Template.RenderedContent { if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Template && "" != row.Cells[colIndex].Value.Template.content {
countNotEmpty++ countNotEmpty++
} }
} }