mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Database grouping by field https://github.com/siyuan-note/siyuan/issues/10964
This commit is contained in:
parent
526bd76c4c
commit
49cc87381c
4 changed files with 29 additions and 20 deletions
|
|
@ -79,26 +79,27 @@ func GetKeyBlockValue(blockKeyValues []*KeyValues) (ret *Value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KeyType 描述了属性视图属性字段的类型。
|
||||||
type KeyType string
|
type KeyType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
KeyTypeBlock KeyType = "block"
|
KeyTypeBlock KeyType = "block" // 主键
|
||||||
KeyTypeText KeyType = "text"
|
KeyTypeText KeyType = "text" // 文本
|
||||||
KeyTypeNumber KeyType = "number"
|
KeyTypeNumber KeyType = "number" // 数字
|
||||||
KeyTypeDate KeyType = "date"
|
KeyTypeDate KeyType = "date" // 日期
|
||||||
KeyTypeSelect KeyType = "select"
|
KeyTypeSelect KeyType = "select" // 单选
|
||||||
KeyTypeMSelect KeyType = "mSelect"
|
KeyTypeMSelect KeyType = "mSelect" // 多选
|
||||||
KeyTypeURL KeyType = "url"
|
KeyTypeURL KeyType = "url" // URL
|
||||||
KeyTypeEmail KeyType = "email"
|
KeyTypeEmail KeyType = "email" // Email
|
||||||
KeyTypePhone KeyType = "phone"
|
KeyTypePhone KeyType = "phone" // 电话
|
||||||
KeyTypeMAsset KeyType = "mAsset"
|
KeyTypeMAsset KeyType = "mAsset" // 资源
|
||||||
KeyTypeTemplate KeyType = "template"
|
KeyTypeTemplate KeyType = "template" // 模板
|
||||||
KeyTypeCreated KeyType = "created"
|
KeyTypeCreated KeyType = "created" // 创建时间
|
||||||
KeyTypeUpdated KeyType = "updated"
|
KeyTypeUpdated KeyType = "updated" // 更新时间
|
||||||
KeyTypeCheckbox KeyType = "checkbox"
|
KeyTypeCheckbox KeyType = "checkbox" // 复选框
|
||||||
KeyTypeRelation KeyType = "relation"
|
KeyTypeRelation KeyType = "relation" // 关联
|
||||||
KeyTypeRollup KeyType = "rollup"
|
KeyTypeRollup KeyType = "rollup" // 汇总
|
||||||
KeyTypeLineNumber KeyType = "lineNumber"
|
KeyTypeLineNumber KeyType = "lineNumber" // 行号
|
||||||
)
|
)
|
||||||
|
|
||||||
// Key 描述了属性视图属性字段的基础结构。
|
// Key 描述了属性视图属性字段的基础结构。
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ func Sort(viewable Viewable, attrView *AttributeView) {
|
||||||
val := items[i].GetValues()[fieldIndexSort.Index]
|
val := items[i].GetValues()[fieldIndexSort.Index]
|
||||||
if KeyTypeCheckbox == val.Type {
|
if KeyTypeCheckbox == val.Type {
|
||||||
if block := item.GetBlockValue(); nil != block && block.IsEdited() {
|
if block := item.GetBlockValue(); nil != block && block.IsEdited() {
|
||||||
// 如果主键编辑过,则勾选框也算作编辑过,参与排序 https://github.com/siyuan-note/siyuan/issues/11016
|
// 如果主键编辑过,则复选框也算作编辑过,参与排序 https://github.com/siyuan-note/siyuan/issues/11016
|
||||||
editedValItems[item.GetID()] = true
|
editedValItems[item.GetID()] = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ func (value *Value) IsEdited() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
if KeyTypeCheckbox == value.Type {
|
if KeyTypeCheckbox == value.Type {
|
||||||
// 勾选框不会为空,即使勾选框未勾选,也不算是空,所以不能用下面的 IsEmpty 判断,这里使用更新时间判断是否编辑过 https://github.com/siyuan-note/siyuan/issues/11016
|
// 复选框不会为空,即使复选框未勾选,也不算是空,所以不能用下面的 IsEmpty 判断,这里使用更新时间判断是否编辑过 https://github.com/siyuan-note/siyuan/issues/11016
|
||||||
return value.CreatedAt != value.UpdatedAt
|
return value.CreatedAt != value.UpdatedAt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -289,7 +289,7 @@ func (value *Value) IsEmpty() bool {
|
||||||
if nil == value.Checkbox {
|
if nil == value.Checkbox {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false // 勾选框不会为空
|
return false // 复选框不会为空
|
||||||
case KeyTypeRelation:
|
case KeyTypeRelation:
|
||||||
return 1 > len(value.Relation.Contents)
|
return 1 > len(value.Relation.Contents)
|
||||||
case KeyTypeRollup:
|
case KeyTypeRollup:
|
||||||
|
|
|
||||||
|
|
@ -1598,6 +1598,14 @@ func genAttrViewViewGroups(view *av.View, attrView *av.AttributeView) {
|
||||||
groupItemsMap[groupName] = append(groupItemsMap[groupName], item)
|
groupItemsMap[groupName] = append(groupItemsMap[groupName], item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if av.KeyTypeSelect == groupKey.Type || av.KeyTypeMSelect == groupKey.Type {
|
||||||
|
for _, o := range groupKey.Options {
|
||||||
|
if _, ok := groupItemsMap[o.Name]; !ok {
|
||||||
|
groupItemsMap[o.Name] = []av.Item{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for name, groupItems := range groupItemsMap {
|
for name, groupItems := range groupItemsMap {
|
||||||
var v *av.View
|
var v *av.View
|
||||||
switch view.LayoutType {
|
switch view.LayoutType {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue