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
9d4c47ee87
commit
0d5320f08b
3 changed files with 8 additions and 48 deletions
|
@ -164,7 +164,7 @@ export const bindGroupsNumber = (options: {
|
|||
export const getGroupsHTML = (columns: IAVColumn[], view: IAVView) => {
|
||||
let html = "";
|
||||
let column: IAVColumn;
|
||||
if (view.group && view.group.field) {
|
||||
if (view.group && view.group.field && view.groups) {
|
||||
let groupHTML = "";
|
||||
column = columns.find(item => item.id === view.group.field);
|
||||
if (view.groups.length > 0) {
|
||||
|
|
|
@ -93,45 +93,6 @@ func syncAttrViewTableColWidth(operation *Operation) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSetAttrViewHideEmptyGroup(operation *Operation) (ret *TxErr) {
|
||||
if err := setAttrViewHideEmptyGroup(operation.AvID, operation.BlockID, operation.Data.(bool)); nil != err {
|
||||
return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func setAttrViewHideEmptyGroup(avID, blockID string, hidden bool) (err error) {
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
view, err := getAttrViewViewByBlockID(attrView, blockID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if nil == view.Group {
|
||||
return
|
||||
}
|
||||
|
||||
view.Group.HideEmpty = hidden
|
||||
for _, group := range view.Groups {
|
||||
if hidden {
|
||||
group.GroupHidden = true
|
||||
} else {
|
||||
group.GroupHidden = false
|
||||
}
|
||||
}
|
||||
|
||||
err = av.SaveAttributeView(attrView)
|
||||
if err != nil {
|
||||
logging.LogErrorf("save attribute view [%s] failed: %s", avID, err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tx *Transaction) doHideAttrViewGroup(operation *Operation) (ret *TxErr) {
|
||||
if err := HideAttributeViewGroup(operation.AvID, operation.BlockID, operation.ID, operation.Data.(bool)); nil != err {
|
||||
return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}
|
||||
|
@ -198,16 +159,17 @@ func SetAttributeViewGroup(avID, blockID string, group *av.ViewGroup) (err error
|
|||
return err
|
||||
}
|
||||
|
||||
if nil == view.Group {
|
||||
view.Group = group
|
||||
} else {
|
||||
if err = copier.Copy(view.Group, group); nil != err {
|
||||
return
|
||||
view.Group = group
|
||||
for _, g := range view.Groups {
|
||||
if group.HideEmpty {
|
||||
g.GroupHidden = true
|
||||
} else {
|
||||
g.GroupHidden = false
|
||||
}
|
||||
}
|
||||
|
||||
genAttrViewViewGroups(view, attrView)
|
||||
return err
|
||||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSetAttrViewCardAspectRatio(operation *Operation) (ret *TxErr) {
|
||||
|
|
|
@ -301,8 +301,6 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
|||
ret = tx.doSetAttrViewGroup(op)
|
||||
case "hideAttrViewGroup":
|
||||
ret = tx.doHideAttrViewGroup(op)
|
||||
case "setAttrViewHideEmptyGroup":
|
||||
ret = tx.doSetAttrViewHideEmptyGroup(op)
|
||||
case "syncAttrViewTableColWidth":
|
||||
ret = tx.doSyncAttrViewTableColWidth(op)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue