feat(views): create default 4 default view for projects

This commit is contained in:
kolaente 2024-03-14 09:41:55 +01:00
parent 2fa3e2c2f5
commit e4b1a5d2db
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 49 additions and 0 deletions

View File

@ -789,6 +789,11 @@ func CreateProject(s *xorm.Session, project *Project, auth web.Auth, createBackl
}
}
err = CreateDefaultViewsForProject(s, project, auth)
if err != nil {
return
}
return events.Dispatch(&ProjectCreatedEvent{
Project: project,
Doer: doer,

View File

@ -206,3 +206,47 @@ func GetProjectViewByID(s *xorm.Session, id int64) (view *ProjectView, err error
return
}
func CreateDefaultViewsForProject(s *xorm.Session, project *Project, a web.Auth) (err error) {
list := &ProjectView{
ProjectID: project.ID,
Title: "List",
ViewKind: ProjectViewKindList,
Position: 100,
}
err = list.Create(s, a)
if err != nil {
return
}
gantt := &ProjectView{
ProjectID: project.ID,
Title: "Gantt",
ViewKind: ProjectViewKindGantt,
Position: 200,
}
err = gantt.Create(s, a)
if err != nil {
return
}
table := &ProjectView{
ProjectID: project.ID,
Title: "Table",
ViewKind: ProjectViewKindTable,
Position: 300,
}
err = table.Create(s, a)
if err != nil {
return
}
kanban := &ProjectView{
ProjectID: project.ID,
Title: "Kanban",
ViewKind: ProjectViewKindKanban,
Position: 400,
}
err = kanban.Create(s, a)
return
}