feat(views): create default 4 default view for projects
This commit is contained in:
parent
2fa3e2c2f5
commit
e4b1a5d2db
@ -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,
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user