Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2024-04-15 16:37:03 +08:00
commit 3699129d7a
5 changed files with 42 additions and 13 deletions

View file

@ -119,13 +119,19 @@ func (value *Value) Compare(other *Value, attrView *AttributeView) int {
return 0
}
case KeyTypeSelect, KeyTypeMSelect:
if 0 < len(value.MSelect) && 0 < len(other.MSelect) {
v1 := value.MSelect[0].Content
v2 := other.MSelect[0].Content
if v1 == v2 {
return 0
if nil != value.MSelect && nil != other.MSelect {
var v1 string
for _, v := range value.MSelect {
v1 += v.Content
break
}
var v2 string
for _, v := range other.MSelect {
v2 += v.Content
break
}
// 按设置的选项顺序排序
key, _ := attrView.GetKey(value.KeyID)
if nil != key {
optionSort := map[string]int{}

View file

@ -179,6 +179,14 @@ func (table *Table) SortRows(attrView *AttributeView) {
for i, row := range table.Rows {
for _, colIndexSort := range colIndexSorts {
val := table.Rows[i].Cells[colIndexSort.Index].Value
if KeyTypeCheckbox == val.Type {
if block := row.GetBlockValue(); nil != block && block.IsEdited() {
// 如果主键编辑过,则勾选框也算作编辑过,参与排序 https://github.com/siyuan-note/siyuan/issues/11016
editedValRows[row.ID] = true
break
}
}
if val.IsEdited() {
// 如果该行某列的值已经编辑过,则该行可参与排序
editedValRows[row.ID] = true
@ -213,13 +221,17 @@ func (table *Table) SortRows(attrView *AttributeView) {
sorted := true
for _, colIndexSort := range colIndexSorts {
val1 := editedRows[i].Cells[colIndexSort.Index].Value
if nil == val1 {
return colIndexSort.Order == SortOrderAsc
}
val2 := editedRows[j].Cells[colIndexSort.Index].Value
if nil == val2 {
return colIndexSort.Order != SortOrderAsc
if nil == val1 || val1.IsEmpty() {
if nil != val2 && !val2.IsEmpty() {
return false
}
sorted = false
continue
} else {
if nil == val2 || val2.IsEmpty() {
return true
}
}
result := val1.Compare(val2, attrView)

View file

@ -208,6 +208,11 @@ func (value *Value) IsEdited() bool {
return true
}
if KeyTypeCheckbox == value.Type {
// 勾选框不会为空,即使勾选框未勾选,也不算是空,所以不能用下面的 IsEmpty 判断,这里使用更新时间判断是否编辑过 https://github.com/siyuan-note/siyuan/issues/11016
return value.CreatedAt != value.UpdatedAt
}
if !value.IsEmpty() {
return true
}
@ -279,7 +284,7 @@ func (value *Value) IsEmpty() bool {
if nil == value.Checkbox {
return true
}
return !value.Checkbox.Checked
return false // 勾选框不会为空
case KeyTypeRelation:
return 1 > len(value.Relation.Contents)
case KeyTypeRollup:

View file

@ -197,6 +197,12 @@ func getNodeRefText0(node *ast.Node) string {
return "Video..."
case ast.NodeAudio:
return "Audio..."
case ast.NodeAttributeView:
ret, _ := av.GetAttributeViewName(node.AttributeViewID)
if "" == ret {
ret = "Database " + Conf.language(105)
}
return ret
}
if ast.NodeDocument != node.Type && node.IsContainerBlock() {

View file

@ -458,7 +458,7 @@ func genTreeID(tree *parse.Tree) {
if "" == n.IALAttr("id") && (ast.NodeParagraph == n.Type || ast.NodeList == n.Type || ast.NodeListItem == n.Type || ast.NodeBlockquote == n.Type ||
ast.NodeMathBlock == n.Type || ast.NodeCodeBlock == n.Type || ast.NodeHeading == n.Type || ast.NodeTable == n.Type || ast.NodeThematicBreak == n.Type ||
ast.NodeYamlFrontMatter == n.Type || ast.NodeBlockQueryEmbed == n.Type || ast.NodeSuperBlock == n.Type ||
ast.NodeYamlFrontMatter == n.Type || ast.NodeBlockQueryEmbed == n.Type || ast.NodeSuperBlock == n.Type || ast.NodeAttributeView == n.Type ||
ast.NodeHTMLBlock == n.Type || ast.NodeIFrame == n.Type || ast.NodeWidget == n.Type || ast.NodeAudio == n.Type || ast.NodeVideo == n.Type) {
n.ID = ast.NewNodeID()
n.KramdownIAL = [][]string{{"id", n.ID}}