From e83bfb6183242edcb20231a11ba2ba33c18a0d7b Mon Sep 17 00:00:00 2001 From: CorrectRoadH Date: Thu, 15 Aug 2024 10:45:11 +0800 Subject: [PATCH] feat: add action func for ysk card --- pkg/ysk/adapter.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/ysk/adapter.go b/pkg/ysk/adapter.go index 614428b..5fe82a1 100644 --- a/pkg/ysk/adapter.go +++ b/pkg/ysk/adapter.go @@ -75,6 +75,16 @@ func (yskCard YSKCard) WithList(params []YSKCardListItem) YSKCard { return yskCard } +// it will replace the old action by same side and style +func (YSKCard YSKCard) UpsertFooterAction(action YSKCardFooterAction) YSKCard { + for i, a := range YSKCard.Content.FooterActions { + if a.Side == action.Side && a.Style == action.Style { + YSKCard.Content.FooterActions[i] = action + } + } + return YSKCard +} + type YSKCardContent struct { TitleIcon YSKCardIcon `json:"titleIcon" gorm:"column:title_icon"` TitleText string `json:"titleText" gorm:"column:title_text"`