mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
accf89a5ca
4 changed files with 43 additions and 52 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) {
|
||||
|
|
|
@ -44,6 +44,33 @@ import (
|
|||
"github.com/xrash/smetrics"
|
||||
)
|
||||
|
||||
func (tx *Transaction) doRemoveAttrViewGroup(operation *Operation) (ret *TxErr) {
|
||||
if err := removeAttributeViewGroup(operation.AvID, operation.BlockID); nil != err {
|
||||
return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func removeAttributeViewGroup(avID, blockID string) (err error) {
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
view, err := getAttrViewViewByBlockID(attrView, blockID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
view.Group, view.Groups, view.GroupUpdated = nil, nil, 0
|
||||
err = av.SaveAttributeView(attrView)
|
||||
if err != nil {
|
||||
logging.LogErrorf("save attribute view [%s] failed: %s", avID, err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSyncAttrViewTableColWidth(operation *Operation) (ret *TxErr) {
|
||||
err := syncAttrViewTableColWidth(operation)
|
||||
if err != nil {
|
||||
|
@ -93,53 +120,14 @@ 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 {
|
||||
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
|
||||
}
|
||||
|
||||
func HideAttributeViewGroup(avID, blockID, groupID string, hidden bool) (err error) {
|
||||
func hideAttributeViewGroup(avID, blockID, groupID string, hidden bool) (err error) {
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -198,16 +186,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) {
|
||||
|
|
|
@ -274,8 +274,10 @@ func CheckAuth(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
// 放过静态资源请求
|
||||
if strings.HasPrefix(c.Request.RequestURI, "/appearance/") || strings.HasPrefix(c.Request.RequestURI, "/stage/") {
|
||||
// 放过 /appearance/
|
||||
if strings.HasPrefix(c.Request.RequestURI, "/appearance/") ||
|
||||
strings.HasPrefix(c.Request.RequestURI, "/stage/build/export/") ||
|
||||
strings.HasPrefix(c.Request.RequestURI, "/stage/protyle/") {
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
|
|
|
@ -301,10 +301,10 @@ 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)
|
||||
case "removeAttrViewGroup":
|
||||
ret = tx.doRemoveAttrViewGroup(op)
|
||||
}
|
||||
|
||||
if nil != ret {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue