mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-22 00:06:09 +01:00
🎨 Card view supports displaying field names https://github.com/siyuan-note/siyuan/issues/15180
This commit is contained in:
parent
78c3479fc3
commit
692665f100
4 changed files with 36 additions and 0 deletions
|
|
@ -29,6 +29,7 @@ type LayoutGallery struct {
|
|||
CardAspectRatio CardAspectRatio `json:"cardAspectRatio"` // 卡片宽高比
|
||||
CardSize CardSize `json:"cardSize"` // 卡片大小,0:小卡片,1:中卡片,2:大卡片
|
||||
FitImage bool `json:"fitImage"` // 是否适应封面图片大小
|
||||
DisplayFieldName bool `json:"displayFieldName"` // 是否显示字段名称
|
||||
|
||||
CardFields []*ViewGalleryCardField `json:"fields"` // 卡片字段
|
||||
|
||||
|
|
@ -94,6 +95,7 @@ type Gallery struct {
|
|||
CardAspectRatio CardAspectRatio `json:"cardAspectRatio"` // 卡片宽高比
|
||||
CardSize CardSize `json:"cardSize"` // 卡片大小
|
||||
FitImage bool `json:"fitImage"` // 是否适应封面图片大小
|
||||
DisplayFieldName bool `json:"displayFieldName"` // 是否显示字段名称
|
||||
Fields []*GalleryField `json:"fields"` // 卡片字段
|
||||
Cards []*GalleryCard `json:"cards"` // 卡片
|
||||
CardCount int `json:"cardCount"` // 总卡片数
|
||||
|
|
|
|||
|
|
@ -514,6 +514,36 @@ func setAttrViewFitImage(operation *Operation) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSetAttrViewDisplayFieldName(operation *Operation) (ret *TxErr) {
|
||||
err := setAttrViewDisplayFieldName(operation)
|
||||
if err != nil {
|
||||
return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func setAttrViewDisplayFieldName(operation *Operation) (err error) {
|
||||
attrView, err := av.ParseAttributeView(operation.AvID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
view, err := getAttrViewViewByBlockID(attrView, operation.BlockID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
return
|
||||
case av.LayoutTypeGallery:
|
||||
view.Gallery.DisplayFieldName = operation.Data.(bool)
|
||||
}
|
||||
|
||||
err = av.SaveAttributeView(attrView)
|
||||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSetAttrViewCardSize(operation *Operation) (ret *TxErr) {
|
||||
err := setAttrViewCardSize(operation)
|
||||
if err != nil {
|
||||
|
|
@ -2503,6 +2533,7 @@ func (tx *Transaction) doDuplicateAttrViewView(operation *Operation) (ret *TxErr
|
|||
view.Gallery.CoverFromAssetKeyID = masterView.Gallery.CoverFromAssetKeyID
|
||||
view.Gallery.CardSize = masterView.Gallery.CardSize
|
||||
view.Gallery.FitImage = masterView.Gallery.FitImage
|
||||
view.Gallery.DisplayFieldName = masterView.Gallery.DisplayFieldName
|
||||
view.Gallery.ShowIcon = masterView.Gallery.ShowIcon
|
||||
view.Gallery.WrapField = masterView.Gallery.WrapField
|
||||
}
|
||||
|
|
|
|||
|
|
@ -289,6 +289,8 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
|||
ret = tx.doSetAttrViewCardSize(op)
|
||||
case "setAttrViewFitImage":
|
||||
ret = tx.doSetAttrViewFitImage(op)
|
||||
case "setDisplayFieldName":
|
||||
ret = tx.doSetAttrViewDisplayFieldName(op)
|
||||
case "setAttrViewShowIcon":
|
||||
ret = tx.doSetAttrViewShowIcon(op)
|
||||
case "setAttrViewWrapField":
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ func RenderAttributeViewGallery(attrView *av.AttributeView, view *av.View, query
|
|||
CardAspectRatio: view.Gallery.CardAspectRatio,
|
||||
CardSize: view.Gallery.CardSize,
|
||||
FitImage: view.Gallery.FitImage,
|
||||
DisplayFieldName: view.Gallery.DisplayFieldName,
|
||||
Fields: []*av.GalleryField{},
|
||||
Cards: []*av.GalleryCard{},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue