mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 07:30:12 +01: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) => {
|
export const getGroupsHTML = (columns: IAVColumn[], view: IAVView) => {
|
||||||
let html = "";
|
let html = "";
|
||||||
let column: IAVColumn;
|
let column: IAVColumn;
|
||||||
if (view.group && view.group.field) {
|
if (view.group && view.group.field && view.groups) {
|
||||||
let groupHTML = "";
|
let groupHTML = "";
|
||||||
column = columns.find(item => item.id === view.group.field);
|
column = columns.find(item => item.id === view.group.field);
|
||||||
if (view.groups.length > 0) {
|
if (view.groups.length > 0) {
|
||||||
|
|
|
||||||
|
|
@ -93,45 +93,6 @@ func syncAttrViewTableColWidth(operation *Operation) (err error) {
|
||||||
return
|
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) {
|
func (tx *Transaction) doHideAttrViewGroup(operation *Operation) (ret *TxErr) {
|
||||||
if err := HideAttributeViewGroup(operation.AvID, operation.BlockID, operation.ID, operation.Data.(bool)); nil != err {
|
if err := HideAttributeViewGroup(operation.AvID, operation.BlockID, operation.ID, operation.Data.(bool)); nil != err {
|
||||||
return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if nil == view.Group {
|
view.Group = group
|
||||||
view.Group = group
|
for _, g := range view.Groups {
|
||||||
} else {
|
if group.HideEmpty {
|
||||||
if err = copier.Copy(view.Group, group); nil != err {
|
g.GroupHidden = true
|
||||||
return
|
} else {
|
||||||
|
g.GroupHidden = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
genAttrViewViewGroups(view, attrView)
|
genAttrViewViewGroups(view, attrView)
|
||||||
return err
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tx *Transaction) doSetAttrViewCardAspectRatio(operation *Operation) (ret *TxErr) {
|
func (tx *Transaction) doSetAttrViewCardAspectRatio(operation *Operation) (ret *TxErr) {
|
||||||
|
|
|
||||||
|
|
@ -301,8 +301,6 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
||||||
ret = tx.doSetAttrViewGroup(op)
|
ret = tx.doSetAttrViewGroup(op)
|
||||||
case "hideAttrViewGroup":
|
case "hideAttrViewGroup":
|
||||||
ret = tx.doHideAttrViewGroup(op)
|
ret = tx.doHideAttrViewGroup(op)
|
||||||
case "setAttrViewHideEmptyGroup":
|
|
||||||
ret = tx.doSetAttrViewHideEmptyGroup(op)
|
|
||||||
case "syncAttrViewTableColWidth":
|
case "syncAttrViewTableColWidth":
|
||||||
ret = tx.doSyncAttrViewTableColWidth(op)
|
ret = tx.doSyncAttrViewTableColWidth(op)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue