Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2025-09-14 22:17:55 +08:00
parent 2d8f4a3030
commit 3211d331fa
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 80 additions and 2 deletions

View file

@ -24,6 +24,13 @@ import (
type LayoutKanban struct {
*BaseLayout
CoverFrom CoverFrom `json:"coverFrom"` // 封面来源01内容图2资源字段
CoverFromAssetKeyID string `json:"coverFromAssetKeyID,omitempty"` // 资源字段 IDCoverFrom 为 2 时有效
CardAspectRatio CardAspectRatio `json:"cardAspectRatio"` // 卡片宽高比
CardSize CardSize `json:"cardSize"` // 卡片大小0小卡片1中卡片2大卡片
FitImage bool `json:"fitImage"` // 是否适应封面图片大小
DisplayFieldName bool `json:"displayFieldName"` // 是否显示字段名称
Fields []*ViewKanbanField `json:"fields"` // 字段
}
@ -34,6 +41,9 @@ func NewLayoutKanban() *LayoutKanban {
ID: ast.NewNodeID(),
ShowIcon: true,
},
CoverFrom: CoverFromContentImage,
CardAspectRatio: CardAspectRatio16_9,
CardSize: CardSizeMedium,
}
}

View file

@ -667,6 +667,8 @@ func setAttrViewCardAspectRatio(operation *Operation) (err error) {
return
case av.LayoutTypeGallery:
view.Gallery.CardAspectRatio = av.CardAspectRatio(operation.Data.(float64))
case av.LayoutTypeKanban:
view.Kanban.CardAspectRatio = av.CardAspectRatio(operation.Data.(float64))
}
err = av.SaveAttributeView(attrView)
@ -707,7 +709,7 @@ func ChangeAttrViewLayout(blockID, avID string, layout av.LayoutType) (err error
switch newLayout {
case av.LayoutTypeTable:
if view.Name == av.GetAttributeViewI18n("gallery") {
if view.Name == av.GetAttributeViewI18n("gallery") || view.Name == av.GetAttributeViewI18n("kanban") {
view.Name = av.GetAttributeViewI18n("table")
}
@ -721,9 +723,13 @@ func ChangeAttrViewLayout(blockID, avID string, layout av.LayoutType) (err error
for _, field := range view.Gallery.CardFields {
view.Table.Columns = append(view.Table.Columns, &av.ViewTableColumn{BaseField: &av.BaseField{ID: field.ID}})
}
case av.LayoutTypeKanban:
for _, field := range view.Kanban.Fields {
view.Table.Columns = append(view.Table.Columns, &av.ViewTableColumn{BaseField: &av.BaseField{ID: field.ID}})
}
}
case av.LayoutTypeGallery:
if view.Name == av.GetAttributeViewI18n("table") {
if view.Name == av.GetAttributeViewI18n("table") || view.Name == av.GetAttributeViewI18n("kanban") {
view.Name = av.GetAttributeViewI18n("gallery")
}
@ -737,6 +743,30 @@ func ChangeAttrViewLayout(blockID, avID string, layout av.LayoutType) (err error
for _, col := range view.Table.Columns {
view.Gallery.CardFields = append(view.Gallery.CardFields, &av.ViewGalleryCardField{BaseField: &av.BaseField{ID: col.ID}})
}
case av.LayoutTypeKanban:
for _, field := range view.Kanban.Fields {
view.Gallery.CardFields = append(view.Gallery.CardFields, &av.ViewGalleryCardField{BaseField: &av.BaseField{ID: field.ID}})
}
}
case av.LayoutTypeKanban:
if view.Name == av.GetAttributeViewI18n("table") || view.Name == av.GetAttributeViewI18n("gallery") {
view.Name = av.GetAttributeViewI18n("kanban")
}
if nil != view.Kanban {
break
}
view.Kanban = av.NewLayoutKanban()
switch view.LayoutType {
case av.LayoutTypeTable:
for _, col := range view.Table.Columns {
view.Kanban.Fields = append(view.Kanban.Fields, &av.ViewKanbanField{BaseField: &av.BaseField{ID: col.ID}})
}
case av.LayoutTypeGallery:
for _, field := range view.Gallery.CardFields {
view.Kanban.Fields = append(view.Kanban.Fields, &av.ViewKanbanField{BaseField: &av.BaseField{ID: field.ID}})
}
}
}
@ -876,6 +906,8 @@ func setAttrViewFitImage(operation *Operation) (err error) {
return
case av.LayoutTypeGallery:
view.Gallery.FitImage = operation.Data.(bool)
case av.LayoutTypeKanban:
view.Kanban.FitImage = operation.Data.(bool)
}
err = av.SaveAttributeView(attrView)
@ -906,6 +938,8 @@ func setAttrViewDisplayFieldName(operation *Operation) (err error) {
return
case av.LayoutTypeGallery:
view.Gallery.DisplayFieldName = operation.Data.(bool)
case av.LayoutTypeKanban:
view.Kanban.DisplayFieldName = operation.Data.(bool)
}
err = av.SaveAttributeView(attrView)
@ -936,6 +970,8 @@ func setAttrViewCardSize(operation *Operation) (err error) {
return
case av.LayoutTypeGallery:
view.Gallery.CardSize = av.CardSize(operation.Data.(float64))
case av.LayoutTypeKanban:
view.Kanban.CardSize = av.CardSize(operation.Data.(float64))
}
err = av.SaveAttributeView(attrView)
@ -996,6 +1032,8 @@ func setAttrViewCoverFrom(operation *Operation) (err error) {
return
case av.LayoutTypeGallery:
view.Gallery.CoverFrom = av.CoverFrom(operation.Data.(float64))
case av.LayoutTypeKanban:
view.Kanban.CoverFrom = av.CoverFrom(operation.Data.(float64))
}
err = av.SaveAttributeView(attrView)
@ -2596,6 +2634,25 @@ func (tx *Transaction) doDuplicateAttrViewView(operation *Operation) (ret *TxErr
view.Gallery.DisplayFieldName = masterView.Gallery.DisplayFieldName
view.Gallery.ShowIcon = masterView.Gallery.ShowIcon
view.Gallery.WrapField = masterView.Gallery.WrapField
case av.LayoutTypeKanban:
for _, field := range masterView.Kanban.Fields {
view.Kanban.Fields = append(view.Kanban.Fields, &av.ViewKanbanField{
BaseField: &av.BaseField{
ID: field.ID,
Wrap: field.Wrap,
Hidden: field.Hidden,
Desc: field.Desc,
},
})
}
view.Kanban.CoverFrom = masterView.Kanban.CoverFrom
view.Kanban.CoverFromAssetKeyID = masterView.Kanban.CoverFromAssetKeyID
view.Kanban.CardSize = masterView.Kanban.CardSize
view.Kanban.FitImage = masterView.Kanban.FitImage
view.Kanban.DisplayFieldName = masterView.Kanban.DisplayFieldName
view.Kanban.ShowIcon = masterView.Kanban.ShowIcon
view.Kanban.WrapField = masterView.Kanban.WrapField
}
view.ItemIDs = masterView.ItemIDs

View file

@ -53,6 +53,17 @@ func RenderGroupView(attrView *av.AttributeView, view, groupView *av.View, query
groupView.Gallery.CardSize = view.Gallery.CardSize
groupView.Gallery.FitImage = view.Gallery.FitImage
groupView.Gallery.DisplayFieldName = view.Gallery.DisplayFieldName
case av.LayoutTypeKanban:
err = copier.CopyWithOption(&groupView.Kanban.Fields, &view.Kanban.Fields, copier.Option{DeepCopy: true})
groupView.Kanban.ShowIcon = view.Kanban.ShowIcon
groupView.Kanban.WrapField = view.Kanban.WrapField
groupView.Kanban.CoverFrom = view.Kanban.CoverFrom
groupView.Kanban.CoverFromAssetKeyID = view.Kanban.CoverFromAssetKeyID
groupView.Kanban.CardAspectRatio = view.Kanban.CardAspectRatio
groupView.Kanban.CardSize = view.Kanban.CardSize
groupView.Kanban.FitImage = view.Kanban.FitImage
groupView.Kanban.DisplayFieldName = view.Kanban.DisplayFieldName
}
if nil != err {
logging.LogErrorf("copy view fields [%s] to group [%s] failed: %s", view.ID, groupView.ID, err)