fix(views): assign default position when creating new project views

When creating a new view without specifying a position, it defaulted to
0, causing it to always sort before all other views. Apply
calculateDefaultPosition to assign a unique position based on the view
ID, consistent with how projects, tasks, and buckets handle this.

Fixes go-vikunja/vikunja#2319
This commit is contained in:
kolaente 2026-03-02 08:34:42 +01:00
parent a7e4a4f4af
commit 23d84e7811
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
1 changed files with 6 additions and 0 deletions

View File

@ -306,6 +306,12 @@ func createProjectView(s *xorm.Session, p *ProjectView, a web.Auth, createBacklo
return
}
p.Position = calculateDefaultPosition(p.ID, p.Position)
_, err = s.Where("id = ?", p.ID).Update(p)
if err != nil {
return
}
if p.ViewKind == ProjectViewKindKanban && createBacklogBucket && p.BucketConfigurationMode == BucketConfigurationModeManual {
// Create default buckets for kanban view
backlog := &Bucket{