Files
TimeTracker/docs/implementation-notes/DELETION_AND_STATUS_IMPROVEMENTS.md
T
Dries Peeters 29f7186ee8 docs: Reorganize documentation structure for better navigation
Complete reorganization of project documentation to improve discoverability,
navigation, and maintainability. All documentation has been restructured into
a clear, role-based hierarchy.

## Major Changes

### New Directory Structure
- Created `docs/api/` for API documentation
- Created `docs/admin/` with subdirectories:
  - `admin/configuration/` - Configuration guides
  - `admin/deployment/` - Deployment guides
  - `admin/security/` - Security documentation
  - `admin/monitoring/` - Monitoring and analytics
- Created `docs/development/` for developer documentation
- Created `docs/guides/` for user-facing guides
- Created `docs/reports/` for analysis reports and summaries
- Created `docs/changelog/` for detailed changelog entries (ready for future use)

### File Organization

#### Moved from Root Directory (40+ files)
- Implementation notes → `docs/implementation-notes/`
- Test reports → `docs/testing/`
- Analysis reports → `docs/reports/`
- User guides → `docs/guides/`

#### Reorganized within docs/
- API documentation → `docs/api/`
- Administrator documentation → `docs/admin/` (with subdirectories)
- Developer documentation → `docs/development/`
- Security documentation → `docs/admin/security/`
- Telemetry documentation → `docs/admin/monitoring/`

### Documentation Updates

#### docs/README.md
- Complete rewrite with improved navigation
- Added visual documentation map
- Organized by role (Users, Administrators, Developers)
- Better categorization and quick links
- Updated all internal links to new structure

#### README.md (root)
- Updated all documentation links to reflect new structure
- Fixed 8 broken links

#### app/templates/main/help.html
- Enhanced "Where can I get additional help?" section
- Added links to new documentation structure
- Added documentation index link
- Added admin documentation link for administrators
- Improved footer with organized documentation links
- Added "Complete Documentation" section with role-based links

### New Index Files
- Created README.md files for all new directories:
  - `docs/api/README.md`
  - `docs/guides/README.md`
  - `docs/reports/README.md`
  - `docs/development/README.md`
  - `docs/admin/README.md`

### Cleanup
- Removed empty `docs/security/` directory (moved to `admin/security/`)
- Removed empty `docs/telemetry/` directory (moved to `admin/monitoring/`)
- Root directory now only contains: README.md, CHANGELOG.md, LICENSE

## Results

**Before:**
- 45+ markdown files cluttering root directory
- Documentation scattered across root and docs/
- Difficult to find relevant documentation
- No clear organization structure

**After:**
- 3 files in root directory (README, CHANGELOG, LICENSE)
- Clear directory structure organized by purpose and audience
- Easy navigation with role-based organization
- All documentation properly categorized
- Improved discoverability

## Benefits

1. Better Organization - Documentation grouped by purpose and audience
2. Easier Navigation - Role-based sections (Users, Admins, Developers)
3. Improved Discoverability - Clear structure with README files in each directory
4. Cleaner Root - Only essential files at project root
5. Maintainability - Easier to add and organize new documentation

## Files Changed

- 40+ files moved from root to appropriate docs/ subdirectories
- 15+ files reorganized within docs/
- 3 major documentation files updated (docs/README.md, README.md, help.html)
- 5 new README index files created
- 2 empty directories removed

All internal links have been updated to reflect the new structure.
2025-12-14 07:56:07 +01:00

7.3 KiB

Deletion and Status Management Improvements

Summary

This document describes the improvements made to the deletion handling and status management for projects, tasks, and clients in the TimeTracker application.

Changes Made

1. Task Deletion Improvements

Previous Behavior:

  • Tasks used bulk checkboxes for selection
  • Bulk delete button appeared when tasks were selected
  • Users had to select multiple tasks to delete them

New Behavior:

  • Individual delete button for each task in the list view
  • Consistent with project and client deletion patterns
  • Immediate confirmation dialog when clicking delete
  • Better UX with per-row actions

Files Modified:

  • app/templates/tasks/list.html - Updated to remove bulk checkboxes and add individual delete buttons
  • Added confirmDeleteTask() JavaScript function for deletion confirmation
  • Removed bulk delete form and modal

Features:

  • Prevents deletion of tasks with time entries (with informative message)
  • Permission check (only admin or task creator can delete)
  • Uses window.showConfirm() for consistent UI

2. Project Status: Inactive Support

Previous Behavior:

  • Projects had only two statuses: 'active' and 'archived'
  • No middle ground for temporarily pausing a project

New Behavior:

  • Projects now support three statuses: 'active', 'inactive', and 'archived'
  • Inactive status allows projects to be temporarily paused without archiving
  • Clear visual distinction with warning color badge

Files Modified:

  • app/models/project.py - Added deactivate() and activate() methods
  • app/routes/projects.py - Added /projects/<id>/deactivate and /projects/<id>/activate routes
  • templates/projects/list.html - Updated to show inactive status and action buttons

New Routes:

  • POST /projects/<id>/deactivate - Mark project as inactive
  • POST /projects/<id>/activate - Reactivate an inactive project

Status Transitions:

  • Active → Inactive → Active (reactivate)
  • Active → Archived → Active (unarchive)
  • Inactive → Archived → Active (unarchive)
  • Inactive → Active (activate)

Visual Indicators:

  • Active: Green badge with check icon
  • Inactive: Yellow/Warning badge with pause icon
  • Archived: Gray badge with archive icon

3. Consistent Deletion Handling

Standardization: All three entities (tasks, projects, clients) now use the same deletion pattern:

  1. Individual delete button per item in list view
  2. Confirmation dialog using window.showConfirm()
  3. Permission checks (admin only for projects/clients, admin or creator for tasks)
  4. Prevention of deletion when dependencies exist (time entries, projects, etc.)
  5. Informative error messages when deletion is not allowed

Deleted Modals:

  • Removed Bootstrap modal from projects list
  • Now uses consistent window.showConfirm() pattern across all entities

4. Projects List Enhancements

Summary Cards:

  • Added 4-column layout showing:
    • Total Projects
    • Active Projects
    • Inactive Projects (new)
    • Archived Projects
    • Total Hours across all projects

Filter Options:

  • Added "Inactive" to status filter dropdown
  • Allows filtering projects by:
    • All statuses
    • Active only
    • Inactive only (new)
    • Archived only

Action Buttons: Each project row now shows contextual actions based on status:

For Active Projects:

  • View
  • Edit
  • Mark as Inactive (new)
  • Archive
  • Delete

For Inactive Projects:

  • View
  • Edit
  • Activate (new)
  • Archive
  • Delete

For Archived Projects:

  • View
  • Edit
  • Unarchive
  • Delete

5. JavaScript Improvements

New Functions:

  • confirmDeleteTask() - Task deletion with time entry check
  • confirmDeleteProject() - Project deletion with time entry check
  • confirmArchiveProject() - Archive confirmation
  • confirmUnarchiveProject() - Unarchive confirmation
  • confirmActivateProject() - Activate confirmation (new)
  • confirmDeactivateProject() - Deactivate confirmation (new)
  • submitProjectAction() - Generic form submission helper

Features:

  • Fallback to native confirm() if window.showConfirm() not available
  • Fallback to native alert() if window.showAlert() not available
  • CSRF token handling for all form submissions
  • Internationalization support via JSON data blocks

Testing

Test Coverage

New test file: tests/test_project_inactive_status.py

Tests Include:

  1. Project default status verification
  2. Deactivate functionality
  3. Activate from inactive functionality
  4. Archive from inactive functionality
  5. Complete status transition cycle
  6. Deactivate route endpoint
  7. Activate route endpoint
  8. Filter by inactive status
  9. Task list delete buttons verification

Running Tests

# Run all tests
pytest tests/test_project_inactive_status.py

# Run specific test class
pytest tests/test_project_inactive_status.py::TestProjectInactiveStatus

# Run with verbose output
pytest tests/test_project_inactive_status.py -v

Migration Notes

Database Schema

No database migration required!

The existing projects.status column is a VARCHAR(20) which already supports storing 'active', 'inactive', or 'archived' values. The changes are code-only.

Existing Data

All existing projects will continue to work:

  • Projects with status='active' remain active
  • Projects with status='archived' remain archived
  • No data migration needed

User Impact

Benefits

  1. Better Project Management:

    • Can temporarily pause projects without archiving them
    • Clear visual distinction between different project states
    • More granular control over project lifecycle
  2. Improved Task Deletion:

    • Faster deletion workflow (no checkbox selection needed)
    • Clearer action buttons in list view
    • Better mobile experience with individual action buttons
  3. Consistent UX:

    • All entities use the same deletion pattern
    • Consistent confirmation dialogs
    • Predictable behavior across the application

Breaking Changes

None. All changes are backward compatible:

  • Existing status values remain valid
  • Existing routes still work
  • No API changes

Future Enhancements

Potential future improvements:

  1. Bulk status changes (e.g., bulk activate/deactivate)
  2. Scheduled status transitions
  3. Status change history/audit log
  4. Dashboard widgets for status overview
  5. Notifications when projects become inactive

Internationalization

All new strings are translatable:

  • "Inactive" status label
  • "Mark as inactive" action
  • "Activate" action
  • Confirmation messages

Translation keys added to i18n-json-projects-list:

  • status_inactive
  • confirm_activate
  • confirm_deactivate

Technical Notes

Code Quality

  • All new code follows existing patterns
  • Proper error handling and flash messages
  • Permission checks for all admin actions
  • CSRF protection on all forms
  • Responsive design maintained

Performance

No performance impact:

  • No additional database queries
  • Existing indexes still apply
  • Client-side filtering uses same logic

Documentation Updates

Files updated:

  • This file (DELETION_AND_STATUS_IMPROVEMENTS.md)
  • Test documentation in tests/test_project_inactive_status.py

This implementation follows the user's preferences:

  • Database schema changes should use Alembic migrations (Memory ID: 8330340, 8329489)
  • All new features require unit tests (Memory ID: 9751130)
  • Documentation must be added for new features (Memory ID: 9751130)