mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02: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
|
||||
}
|
||||
|
||||
// KeyType 描述了属性视图属性字段的类型。
|
||||
type KeyType string
|
||||
|
||||
const (
|
||||
KeyTypeBlock KeyType = "block"
|
||||
KeyTypeText KeyType = "text"
|
||||
KeyTypeNumber KeyType = "number"
|
||||
KeyTypeDate KeyType = "date"
|
||||
KeyTypeSelect KeyType = "select"
|
||||
KeyTypeMSelect KeyType = "mSelect"
|
||||
KeyTypeURL KeyType = "url"
|
||||
KeyTypeEmail KeyType = "email"
|
||||
KeyTypePhone KeyType = "phone"
|
||||
KeyTypeMAsset KeyType = "mAsset"
|
||||
KeyTypeTemplate KeyType = "template"
|
||||
KeyTypeCreated KeyType = "created"
|
||||
KeyTypeUpdated KeyType = "updated"
|
||||
KeyTypeCheckbox KeyType = "checkbox"
|
||||
KeyTypeRelation KeyType = "relation"
|
||||
KeyTypeRollup KeyType = "rollup"
|
||||
KeyTypeLineNumber KeyType = "lineNumber"
|
||||
KeyTypeBlock KeyType = "block" // 主键
|
||||
KeyTypeText KeyType = "text" // 文本
|
||||
KeyTypeNumber KeyType = "number" // 数字
|
||||
KeyTypeDate KeyType = "date" // 日期
|
||||
KeyTypeSelect KeyType = "select" // 单选
|
||||
KeyTypeMSelect KeyType = "mSelect" // 多选
|
||||
KeyTypeURL KeyType = "url" // URL
|
||||
KeyTypeEmail KeyType = "email" // Email
|
||||
KeyTypePhone KeyType = "phone" // 电话
|
||||
KeyTypeMAsset KeyType = "mAsset" // 资源
|
||||
KeyTypeTemplate KeyType = "template" // 模板
|
||||
KeyTypeCreated KeyType = "created" // 创建时间
|
||||
KeyTypeUpdated KeyType = "updated" // 更新时间
|
||||
KeyTypeCheckbox KeyType = "checkbox" // 复选框
|
||||
KeyTypeRelation KeyType = "relation" // 关联
|
||||
KeyTypeRollup KeyType = "rollup" // 汇总
|
||||
KeyTypeLineNumber KeyType = "lineNumber" // 行号
|
||||
)
|
||||
|
||||
// Key 描述了属性视图属性字段的基础结构。
|
||||
|
|
|
@ -67,7 +67,7 @@ func Sort(viewable Viewable, attrView *AttributeView) {
|
|||
val := items[i].GetValues()[fieldIndexSort.Index]
|
||||
if KeyTypeCheckbox == val.Type {
|
||||
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
|
||||
break
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ func (value *Value) IsEdited() bool {
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@ func (value *Value) IsEmpty() bool {
|
|||
if nil == value.Checkbox {
|
||||
return true
|
||||
}
|
||||
return false // 勾选框不会为空
|
||||
return false // 复选框不会为空
|
||||
case KeyTypeRelation:
|
||||
return 1 > len(value.Relation.Contents)
|
||||
case KeyTypeRollup:
|
||||
|
|
|
@ -1598,6 +1598,14 @@ func genAttrViewViewGroups(view *av.View, attrView *av.AttributeView) {
|
|||
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 {
|
||||
var v *av.View
|
||||
switch view.LayoutType {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue