feat: decouple views from projects #2217

Merged
konrad merged 97 commits from feature/decouple-views-from-projects into main 2024-03-19 19:16:14 +00:00
2 changed files with 49 additions and 0 deletions
Showing only changes of commit e4b1a5d2db - Show all commits

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
}