feat: week numbers in schedule and week-wide assignment

Schedule table now shows ISO week number (W21) on the first
row of each week visible in the 14-day window (first row and
every Monday); other rows get a 4-space indent. Date column
widened from 16→18 to accommodate the prefix.

New W key in Schedule section opens the user picker in
week-assign mode, which assigns the selected user to all 7
days (Mon–Sun) of the ISO week containing the cursor. The +
key retains single-day assignment. The user picker header and
footer reflect which mode is active.
This commit is contained in:
Niklas Ye
2026-05-22 11:17:17 +02:00
parent 9a50770538
commit ffacbee429
3 changed files with 68 additions and 18 deletions
+15 -8
View File
@@ -144,9 +144,10 @@ type Model struct {
scheduleTable table.Model
// User picker (schedule assignment)
users []api.User
usersLoading bool
userPickerTable table.Model
users []api.User
usersLoading bool
userPickerTable table.Model
pickerAssignWeek bool
// User management section
userManageTable table.Model
@@ -328,7 +329,7 @@ func alertColumns(width int) []table.Column {
}
func scheduleColumns(width int) []table.Column {
dateW := 16
dateW := 18
onCallW := width - dateW - 6
if onCallW < 15 {
onCallW = 15
@@ -381,9 +382,15 @@ func scheduleRows(days []scheduleDay) []table.Row {
rows := make([]table.Row, len(days))
for i, d := range days {
dateStr := d.date.Format("2006-01-02")
label := d.date.Format("Jan 02 Mon")
showWeek := i == 0 || d.date.Weekday() == time.Monday
_, week := d.date.ISOWeek()
weekPrefix := " "
if showWeek {
weekPrefix = fmt.Sprintf("W%02d ", week)
}
label := weekPrefix + d.date.Format("Jan 02 Mon")
if dateStr == today {
label = "Today " + d.date.Format("Mon")
label = weekPrefix + "Today " + d.date.Format("Mon")
}
onCall := "—"
if d.entry != nil {
@@ -583,9 +590,9 @@ func fetchScheduleCmd(client *api.Client, from, to time.Time) tea.Cmd {
}
}
func assignScheduleCmd(client *api.Client, userID int64, date string, from, to time.Time) tea.Cmd {
func assignScheduleCmd(client *api.Client, userID int64, dates []string, from, to time.Time) tea.Cmd {
return func() tea.Msg {
if _, err := client.AssignSchedule(userID, []string{date}); err != nil {
if _, err := client.AssignSchedule(userID, dates); err != nil {
return scheduleActionErrMsg{err}
}
entries, err := client.GetSchedule(from.Format("2006-01-02"), to.Format("2006-01-02"))