mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-01 06:18:49 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
8462ae8b0b
3 changed files with 64 additions and 6 deletions
|
|
@ -40,9 +40,10 @@ type AttributeView struct {
|
|||
Columns []*Column `json:"columns"` // 表格列名
|
||||
Rows []*Row `json:"rows"` // 表格行记录
|
||||
|
||||
Type AttributeViewType `json:"type"` // 属性视图类型
|
||||
Filters []*AttributeViewFilter `json:"filters"` // 过滤规则
|
||||
Sorts []*AttributeViewSort `json:"sorts"` // 排序规则
|
||||
Type AttributeViewType `json:"type"` // 属性视图类型
|
||||
Filters []*AttributeViewFilter `json:"filters"` // 过滤规则
|
||||
Sorts []*AttributeViewSort `json:"sorts"` // 排序规则
|
||||
Calculates []*AttributeViewCalc `json:"calculates"` // 计算规则
|
||||
}
|
||||
|
||||
// AttributeViewType 描述了属性视图的类型。
|
||||
|
|
@ -98,6 +99,18 @@ const (
|
|||
FilterOperatorIsRelativeToToday FilterOperator = "Is relative to today"
|
||||
)
|
||||
|
||||
type AttributeViewCalc struct {
|
||||
Column string `json:"column"`
|
||||
Operator CalcOperator `json:"operator"`
|
||||
}
|
||||
|
||||
type CalcOperator string
|
||||
|
||||
const (
|
||||
CalcOperatorNone FilterOperator = ""
|
||||
CalcOperatorCountAll FilterOperator = "Count all"
|
||||
)
|
||||
|
||||
type AttributeViewSort struct {
|
||||
Column string `json:"column"` // 列 ID
|
||||
Order SortOrder `json:"order"` // 排序顺序
|
||||
|
|
@ -300,3 +313,7 @@ func (av *AttributeView) FilterRows() {
|
|||
av.Rows = rows
|
||||
}
|
||||
}
|
||||
|
||||
func (av *AttributeView) CalcCols() {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -558,6 +558,6 @@ func addAttributeViewBlock(blockID, previousRowID, avID string, tree *parse.Tree
|
|||
}
|
||||
|
||||
const (
|
||||
NodeAttrNameAVs = "avs"
|
||||
NodeAttrNamePrefixAvCol = "av-col-"
|
||||
NodeAttrNameAVs = "custom-avs"
|
||||
NodeAttrNamePrefixAvCol = "custom-av-col-"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package model
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/siyuan-note/siyuan/kernel/av"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
|
@ -1188,7 +1189,47 @@ func refreshDynamicRefTexts(updatedDefNodes map[string]*ast.Node, updatedTrees m
|
|||
}
|
||||
}
|
||||
|
||||
// TODO 2. 更新属性视图主键内容
|
||||
// 2. 更新属性视图主键内容
|
||||
for _, updatedDefNode := range updatedDefNodes {
|
||||
avs := updatedDefNode.IALAttr(NodeAttrNameAVs)
|
||||
if "" == avs {
|
||||
continue
|
||||
}
|
||||
|
||||
avIDs := strings.Split(avs, ",")
|
||||
for _, avID := range avIDs {
|
||||
attrView, parseErr := av.ParseAttributeView(avID)
|
||||
if nil != parseErr {
|
||||
continue
|
||||
}
|
||||
|
||||
changedAv := false
|
||||
for _, row := range attrView.Rows {
|
||||
blockCell := row.GetBlockCell()
|
||||
if nil == blockCell || nil == blockCell.Value || nil == blockCell.Value.Block {
|
||||
continue
|
||||
}
|
||||
|
||||
if blockCell.Value.Block.ID == updatedDefNode.ID {
|
||||
newContent := getNodeRefText(updatedDefNode)
|
||||
if newContent != blockCell.Value.Block.Content {
|
||||
blockCell.Value.Block.Content = newContent
|
||||
changedAv = true
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
if changedAv {
|
||||
av.SaveAttributeView(attrView)
|
||||
|
||||
evt := util.NewCmdResult("refreshAttributeView", 0, util.PushModeBroadcast)
|
||||
evt.Data = map[string]interface{}{
|
||||
"id": avID,
|
||||
}
|
||||
util.PushEvent(evt)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 保存变更
|
||||
for _, tree := range changedRefTree {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue