@@ -19,12 +19,18 @@ import (
1919)
2020
2121type (
22- // ProjectsConfig is used to identify the type of board that is being created
23- ProjectsConfig struct {
22+ // BoardConfig is used to identify the type of board that is being created
23+ BoardConfig struct {
2424 BoardType BoardType
2525 Translation string
2626 }
2727
28+ // CardConfig is used to identify the type of board card that is being used
29+ CardConfig struct {
30+ CardType CardType
31+ Translation string
32+ }
33+
2834 // Type is used to identify the type of project in question and ownership
2935 Type uint8
3036)
@@ -91,6 +97,7 @@ type Project struct {
9197 CreatorID int64 `xorm:"NOT NULL"`
9298 IsClosed bool `xorm:"INDEX"`
9399 BoardType BoardType
100+ CardType CardType
94101 Type Type
95102
96103 RenderedContent string `xorm:"-"`
@@ -145,15 +152,23 @@ func init() {
145152 db .RegisterModel (new (Project ))
146153}
147154
148- // GetProjectsConfig retrieves the types of configurations projects could have
149- func GetProjectsConfig () []ProjectsConfig {
150- return []ProjectsConfig {
155+ // GetBoardConfig retrieves the types of configurations project boards could have
156+ func GetBoardConfig () []BoardConfig {
157+ return []BoardConfig {
151158 {BoardTypeNone , "repo.projects.type.none" },
152159 {BoardTypeBasicKanban , "repo.projects.type.basic_kanban" },
153160 {BoardTypeBugTriage , "repo.projects.type.bug_triage" },
154161 }
155162}
156163
164+ // GetCardConfig retrieves the types of configurations project board cards could have
165+ func GetCardConfig () []CardConfig {
166+ return []CardConfig {
167+ {CardTypeTextOnly , "repo.projects.card_type.text_only" },
168+ {CardTypeImagesAndText , "repo.projects.card_type.images_and_text" },
169+ }
170+ }
171+
157172// IsTypeValid checks if a project type is valid
158173func IsTypeValid (p Type ) bool {
159174 switch p {
@@ -237,6 +252,10 @@ func NewProject(p *Project) error {
237252 p .BoardType = BoardTypeNone
238253 }
239254
255+ if ! IsCardTypeValid (p .CardType ) {
256+ p .CardType = CardTypeTextOnly
257+ }
258+
240259 if ! IsTypeValid (p .Type ) {
241260 return util .NewInvalidArgumentErrorf ("project type is not valid" )
242261 }
@@ -280,9 +299,14 @@ func GetProjectByID(ctx context.Context, id int64) (*Project, error) {
280299
281300// UpdateProject updates project properties
282301func UpdateProject (ctx context.Context , p * Project ) error {
302+ if ! IsCardTypeValid (p .CardType ) {
303+ p .CardType = CardTypeTextOnly
304+ }
305+
283306 _ , err := db .GetEngine (ctx ).ID (p .ID ).Cols (
284307 "title" ,
285308 "description" ,
309+ "card_type" ,
286310 ).Update (p )
287311 return err
288312}
0 commit comments