Add actionable push notifications and fix recurring task completion
Features: - Add task action buttons to push notifications (complete, view, cancel, etc.) - Add button types logic for different task states (overdue, in_progress, etc.) - Implement Chain of Responsibility pattern for task categorization - Add comprehensive kanban categorization documentation Fixes: - Reset recurring task status to Pending after completion so tasks appear in correct kanban column (was staying in "In Progress") - Fix PostgreSQL EXTRACT function error in overdue notifications query - Update seed data to properly set next_due_date for recurring tasks Admin: - Add tasks list to residence detail page - Fix task edit page to properly handle all fields 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -169,7 +169,6 @@ func (h *AdminTaskHandler) Update(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Residence not found"})
|
||||
return
|
||||
}
|
||||
task.ResidenceID = *req.ResidenceID
|
||||
}
|
||||
// Verify created_by if changing
|
||||
if req.CreatedByID != nil {
|
||||
@@ -178,7 +177,6 @@ func (h *AdminTaskHandler) Update(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Created by user not found"})
|
||||
return
|
||||
}
|
||||
task.CreatedByID = *req.CreatedByID
|
||||
}
|
||||
// Verify assigned_to if changing
|
||||
if req.AssignedToID != nil {
|
||||
@@ -187,57 +185,68 @@ func (h *AdminTaskHandler) Update(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Assigned to user not found"})
|
||||
return
|
||||
}
|
||||
task.AssignedToID = req.AssignedToID
|
||||
}
|
||||
|
||||
// Build update map with only the fields that were provided
|
||||
updates := make(map[string]interface{})
|
||||
if req.ResidenceID != nil {
|
||||
updates["residence_id"] = *req.ResidenceID
|
||||
}
|
||||
if req.CreatedByID != nil {
|
||||
updates["created_by_id"] = *req.CreatedByID
|
||||
}
|
||||
if req.AssignedToID != nil {
|
||||
updates["assigned_to_id"] = *req.AssignedToID
|
||||
}
|
||||
if req.Title != nil {
|
||||
task.Title = *req.Title
|
||||
updates["title"] = *req.Title
|
||||
}
|
||||
if req.Description != nil {
|
||||
task.Description = *req.Description
|
||||
updates["description"] = *req.Description
|
||||
}
|
||||
if req.CategoryID != nil {
|
||||
task.CategoryID = req.CategoryID
|
||||
updates["category_id"] = *req.CategoryID
|
||||
}
|
||||
if req.PriorityID != nil {
|
||||
task.PriorityID = req.PriorityID
|
||||
updates["priority_id"] = *req.PriorityID
|
||||
}
|
||||
if req.StatusID != nil {
|
||||
task.StatusID = req.StatusID
|
||||
updates["status_id"] = *req.StatusID
|
||||
}
|
||||
if req.FrequencyID != nil {
|
||||
task.FrequencyID = req.FrequencyID
|
||||
updates["frequency_id"] = *req.FrequencyID
|
||||
}
|
||||
if req.DueDate != nil {
|
||||
if dueDate, err := time.Parse("2006-01-02", *req.DueDate); err == nil {
|
||||
task.DueDate = &dueDate
|
||||
updates["due_date"] = dueDate
|
||||
}
|
||||
}
|
||||
if req.EstimatedCost != nil {
|
||||
d := decimal.NewFromFloat(*req.EstimatedCost)
|
||||
task.EstimatedCost = &d
|
||||
updates["estimated_cost"] = decimal.NewFromFloat(*req.EstimatedCost)
|
||||
}
|
||||
if req.ActualCost != nil {
|
||||
d := decimal.NewFromFloat(*req.ActualCost)
|
||||
task.ActualCost = &d
|
||||
updates["actual_cost"] = decimal.NewFromFloat(*req.ActualCost)
|
||||
}
|
||||
if req.ContractorID != nil {
|
||||
task.ContractorID = req.ContractorID
|
||||
updates["contractor_id"] = *req.ContractorID
|
||||
}
|
||||
if req.ParentTaskID != nil {
|
||||
task.ParentTaskID = req.ParentTaskID
|
||||
updates["parent_task_id"] = *req.ParentTaskID
|
||||
}
|
||||
if req.IsCancelled != nil {
|
||||
task.IsCancelled = *req.IsCancelled
|
||||
updates["is_cancelled"] = *req.IsCancelled
|
||||
}
|
||||
if req.IsArchived != nil {
|
||||
task.IsArchived = *req.IsArchived
|
||||
updates["is_archived"] = *req.IsArchived
|
||||
}
|
||||
|
||||
if err := h.db.Save(&task).Error; err != nil {
|
||||
// Use Updates with map to only update specified fields
|
||||
if err := h.db.Model(&task).Updates(updates).Error; err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to update task"})
|
||||
return
|
||||
}
|
||||
|
||||
// Reload with preloads for response
|
||||
h.db.Preload("Residence").Preload("CreatedBy").Preload("Category").Preload("Priority").Preload("Status").First(&task, id)
|
||||
c.JSON(http.StatusOK, h.toTaskResponse(&task))
|
||||
}
|
||||
@@ -320,7 +329,7 @@ func (h *AdminTaskHandler) Delete(c *gin.Context) {
|
||||
// Soft delete - archive and cancel
|
||||
task.IsArchived = true
|
||||
task.IsCancelled = true
|
||||
if err := h.db.Save(&task).Error; err != nil {
|
||||
if err := h.db.Omit("Residence", "CreatedBy", "AssignedTo", "Category", "Priority", "Status", "Frequency", "ParentTask", "Completions").Save(&task).Error; err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to delete task"})
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user