Commit Graph

754 Commits

Author SHA1 Message Date
Dries Peeters
e21a350ec6 version bump 2025-12-29 20:36:18 +01:00
Dries Peeters
66ca9589bb Fix project template tasks creation and editing
- Fix tasks not being created when projects are created from templates
  * Remove invalid status parameter from task creation (TaskService doesn't accept it)
  * Fix estimated_hours conversion from string to float/None
  * Add proper error handling for task creation failures
  * Refresh template from database before reading tasks

- Fix missing tasks section in template edit form
  * Add tasks section to edit template form with full CRUD functionality
  * Display existing tasks when editing templates
  * Allow adding, editing, and removing tasks in templates

- Fix tasks not being saved when creating/editing templates
  * Fix JavaScript form handling to properly collect tasks from form
  * Create tasks input field on page load and update on submit
  * Add capture phase event listener to ensure tasks are set before form submission
  * Ensure tasks are always saved as a list (never None)

- Fix [object Object] error in toast notifications
  * Add safeguards to ensure flash messages are always strings
  * Add object-to-string conversion in toast notification system

- Improve error handling and validation
  * Add validation to ensure tasks is always a list
  * Improve JSON parsing with better error handling
  * Add safeguards for flash message handling
2025-12-29 20:33:56 +01:00
Dries Peeters
e8bf502153 Fix: Handle None values in stock item form fields
Convert None database values to empty strings in template to prevent 'None' text from appearing in form fields. This fixes an issue where users had to manually delete 'None' from URL and other optional fields before saving.

Updated fields: image_url, description, category, barcode, and notes to use 'or' filter for proper None handling.
2025-12-29 19:50:33 +01:00
Dries Peeters
090344aa5d Fix JSON serialization error when editing stock items
Convert Supplier objects to dictionaries before passing to template to
prevent 'Object of type Supplier is not JSON serializable' error.

The template uses tojson filter to serialize suppliers for JavaScript,
but SQLAlchemy model objects are not directly JSON serializable. By
converting suppliers to dictionaries using to_dict() method before
rendering, the serialization now works correctly.

Fixes issue where editing stock items resulted in 500 server error.
Affects both new_stock_item and edit_stock_item routes.
2025-12-29 17:01:31 +01:00
Dries Peeters
5e61ed382a Validate and simplify integration setup pages
- Remove confusing trello_token field from Trello setup (replaced with api_secret)
- Add required field indicators (*) and HTML validation for all OAuth credentials
- Add backend validation for required fields (Client ID, API Key, API Secret)
- Improve GitLab instance URL validation with proper defaults and URL format checking
- Enhance help text for Microsoft integrations (Outlook, Teams) tenant_id field
- Clarify when fields are required vs optional with better placeholder text
- Ensure setup pages only show necessary fields for each integration type

All integration setup pages now have:
- Clear required field indicators
- Proper validation (frontend and backend)
- Simplified, intuitive forms
- Better help text and instructions
- No unnecessary or confusing fields
2025-12-29 16:53:54 +01:00
Dries Peeters
53c58ec43e feat: comprehensive integration setup and configuration system
Enhanced all integrations with complete setup procedures, authentication flows,
and comprehensive configuration management.

Base Connector Enhancements:
- Extended get_config_schema() with sections, sync settings, and validation
- Added validate_config() with type checking and constraints
- Added helper methods: get_sync_settings(), get_field_mappings(), get_status_mappings()

Integration Configuration Schemas:
- All integrations now have complete config schemas with organized sections
- Support for sync direction (Import/Export/Bidirectional)
- Sync scheduling options (Manual/Hourly/Daily/Weekly)
- Data mapping configuration (status mappings, field mappings)
- Field types: string, number, boolean, select, array, json, url, text, password
- Comprehensive help text and descriptions for all fields

Enhanced Integrations:
- Jira: JQL queries, status mapping, project auto-creation
- GitHub: Repository selection, issue state filtering, webhook security
- GitLab: Project selection, issue filtering, webhook configuration
- Slack: Channel selection, notification triggers
- Asana: Workspace/project selection, completion status sync
- Trello: Board selection, list-to-status mapping
- Microsoft Teams: Channel configuration, notification settings
- QuickBooks: Customer/item/account mappings, sandbox mode
- Xero: Contact/item/account mappings
- Google Calendar: Event formatting, date range controls
- Outlook Calendar: Event formatting, date range controls
- CalDAV: Server discovery, SSL verification, lookback/lookahead

UI Enhancements:
- Section-based configuration display
- Support for all field types (select, array, number, json, boolean)
- Improved help text and descriptions
- Better visual organization and validation

Route Enhancements:
- Config schema passed to template
- Form processing for all field types
- Proper default value handling
- Validation error messages

This provides a complete, user-friendly integration setup experience with
one-button OAuth connections, configurable sync settings, and data translation
capabilities.
2025-12-29 16:35:06 +01:00
Dries Peeters
764f65639d Version Bump 2025-12-29 16:09:01 +01:00
Dries Peeters
bd16c664ac feat: Enhance integrations management with config UI and improved status display
- Add integration-specific configuration support via get_config_schema()
  - Dynamic form generation for config fields (string, boolean, text, JSON, url)
  - Save integration config to database (jira_url, jql, realm_id, etc.)
  - Support for all field types with validation and help text

- Improve connection status visualization
  - Enhanced status badges (Connected/Not Connected, Sync OK/Error)
  - Display last sync timestamp and error messages
  - Grid layout for better information hierarchy
  - Clear visual feedback for connection health

- Enhance sync operations
  - Update last_sync_at, last_sync_status, and last_error fields
  - Log sync events with metadata to IntegrationEvent table
  - Better error handling and user feedback

- Clean up integrations list page
  - Remove duplicate 'Your Active Integrations' table section
  - Keep only card-based view with all necessary information
  - Simplified, cleaner interface

- Fix f-string syntax errors in QuickBooks connector
  - Extract string replacements outside f-string expressions
  - Fix lines 382 and 444 that prevented connector registration

- Update navigation and admin dashboard
  - Move integrations link from admin menu to Tools & Data menu
  - Update admin dashboard shortcut to new integrations route

All integrations now have full configuration UI support, better status
feedback, and improved user experience.
2025-12-29 16:03:46 +01:00
Dries Peeters
0c310736c1 Remove legacy UI enable/disable settings system
Remove both system-wide and per-user UI feature enable/disable settings
in favor of the centralized ModuleRegistry system for module management.

Changes:
- Remove ui_allow_* columns from Settings model and database (migration 093)
- Remove ui_show_* preference assignments from user settings route
- Remove UI Customization section from user settings template
- Remove UI Features section from admin settings template
- Update admin modules template to use ModuleRegistry instead of settings flags
- Remove settings_flag and user_flag attributes from ModuleDefinition
- Update ModuleRegistry.is_enabled() to only check dependencies and default_enabled
- Update dashboard template to use is_module_enabled() helper
- Update admin route docstring to reflect module management changes

Module visibility is now controlled exclusively via the admin module
management interface (/admin/modules), eliminating the need for separate
system-wide and per-user UI preference systems.
2025-12-29 15:51:59 +01:00
Dries Peeters
083dd9f1f2 feat: Implement comprehensive module system with visibility controls
- Add centralized module registry system (ModuleRegistry) for managing
  module metadata, dependencies, and visibility across the application
- Create module helper utilities with decorators (@module_enabled) and
  helper functions for route protection and template access
- Add database migration (092) to add missing module visibility flags
  to settings and users tables for granular control
- Extend Settings and User models with additional module visibility
  flags for CRM, Finance, Tools, and Advanced features
- Implement admin module management UI for system-wide module
  enable/disable controls
- Add module checks to routes (calendar, contacts, deals, expenses,
  invoices, leads, custom_reports) to enforce visibility rules
- Update scheduled report service and report templates to respect
  module visibility settings
- Bump version to 4.8.0 in setup.py
- Add comprehensive documentation for module integration planning
  and implementation analysis
2025-12-29 14:13:32 +01:00
Dries Peeters
4cd05bb82a Fix company logo not visible in invoice template editor
The company logo was visible in the preview but not in the editor when
loading saved invoice templates. This was caused by Konva Image nodes
losing their image data after JSON deserialization.

Changes:
- Enhanced logo detection to use multiple methods (className, constructor,
  instanceof) for robustness after deserialization
- Check all Image nodes, not just those with name='logo', in case the
  name attribute is lost during serialization
- Detect Image nodes that should be logos (have dimensions but no image data)
- Improved error handling and logging for debugging
- Applied fix to both invoice and quote PDF layout templates

The logo images are now properly restored from LOGO_URL when loading
saved designs, making them visible in the editor as well as the preview.
2025-12-29 14:12:20 +01:00
Dries Peeters
ff19b67046 Fix PDF layout designer logo issues and dropdown menu behavior
- Fix logo becoming invisible after resize in designer by reloading images from URL when loading saved designs

- Fix logo size not being preserved by converting scale changes to width/height during resize

- Fix logo resizing for invoice PDF layouts with proper transformend event handling

- Fix PDF templates dropdown closing parent admin menu by keeping ancestor dropdowns open

- Fix JavaScript syntax error with Jinja2 template in logo rendering

- Fix logo display in preview with proper URL embedding
2025-12-29 14:05:52 +01:00
Dries Peeters
89717dc089 Fix log_event() calls in inventory routes to use keyword arguments
Fixed all log_event() calls in app/routes/inventory.py that were incorrectly
passing dictionaries as positional arguments. The log_event() function signature
requires the event name as the first positional argument and all other data as
keyword arguments (via **kwargs).

Changed 19 calls from:
  log_event('event_name', {'key': value})  # Wrong

To:
  log_event('event_name', key=value)  # Correct

This resolves the error 'log_event() takes 1 positional argument but 2 were
given' that occurred when creating or editing stock items and other inventory
operations.

Affected operations:
- Stock item create/update/delete
- Warehouse create/update/delete
- Stock movements, transfers, and adjustments
- Stock reservations
- Supplier create/update/delete
- Purchase order operations
2025-12-29 12:57:05 +01:00
Dries Peeters
e2d7e21447 feat(api): implement and enhance search API endpoints
- Fix syntax error in existing /api/search endpoint (missing parenthesis in tasks query)
- Enhance /api/search endpoint with types filter, improved error handling, and response metadata
- Add new /api/v1/search endpoint with token-based authentication
  - Requires read:projects scope
  - Respects user permissions (non-admin users see only their own time entries)
  - Supports filtering by entity type (project, task, client, entry)
  - Includes OpenAPI documentation
- Add comprehensive test suite for both endpoints
  - Tests for legacy /api/search (session-based auth)
  - Tests for /api/v1/search (token-based auth)
  - Covers authentication, authorization, filtering, and search functionality
- Update API documentation in docs/api/REST_API.md
  - Add search endpoint documentation with examples
  - Include parameter descriptions and response formats
- Add search endpoint to /api/v1/info endpoint listing

This addresses the HIGH PRIORITY requirement to implement the search API
endpoint that was referenced but may not have been fully functional.

Resolves: Search API endpoint (/api/search) referenced but may not exist
2025-12-29 12:40:38 +01:00
Dries Peeters
95a35d2cd0 fix: Complete integration implementations and improve error handling
HIGH PRIORITY FIXES:
- GitHub: Fix webhook signature verification to use raw request body bytes
  * GitHub signs the raw body, not parsed JSON, so signature verification was failing
  * Added security checks to reject webhooks when secret configured but signature missing
  * Updated route handler to pass raw body for proper signature verification

- QuickBooks: Complete customer/account mapping implementation
  * Implemented automatic customer lookup by DisplayName in QuickBooks
  * Implemented automatic item lookup by Name for invoice items
  * Implemented automatic expense account discovery with fallback
  * Auto-saves discovered mappings for future use
  * Added validation to ensure required mappings exist before creating invoices
  * Improved API request handling with proper error messages and timeout handling

IMPROVEMENTS:
- CalDAV: Enhance bidirectional sync functionality
  * Improved update handling to use existing event hrefs correctly
  * Better error handling for HTTP errors (404, etc.)
  * Enhanced event creation vs update logic

- Integrations: Add comprehensive error handling across all integrations
  * GitHub: Network errors, authentication failures, database errors, timeout handling
  * QuickBooks: API errors, validation errors, timeout handling, connection errors
  * CalDAV: HTTP errors, connection errors, timeout handling
  * Jira & Slack: Improved error handling in webhook handlers
  * All integrations now properly handle timeouts, connection errors, auth failures
  * Detailed error messages and appropriate logging levels
  * Proper database transaction rollback on errors

TECHNICAL CHANGES:
- Updated BaseConnector.handle_webhook() to accept optional raw_body parameter
- Updated all webhook handlers (GitHub, Jira, Slack) for consistency
- Improved QuickBooks API request method with better error handling
- Enhanced CalDAV client create_or_update_event() to handle existing hrefs
2025-12-29 12:40:27 +01:00
Dries Peeters
33ad9a0c26 feat: Complete offline sync, form auto-save, browser fallbacks, and smart notifications
- Offline sync: Implement task and project sync functionality
  * Add syncTasks() and syncProjects() methods with full CRUD support
  * Implement saveTaskOffline(), saveProjectOffline() helper methods
  * Add createTaskOffline() and createProjectOffline() public API methods
  * Update markAsSynced() to handle tasks and projects correctly
  * Support both create and update operations for offline entities

- Enhanced UI: Complete form auto-save initialization
  * Add comprehensive error handling and validation
  * Implement storage quota error handling with fallback
  * Improve indicator with error states and better visual feedback
  * Add beforeunload handler to save state on page unload
  * Prevent duplicate initialization with proper tracking
  * Add CSRF token handling and form method detection
  * Use passive event listeners for better performance

- Error handling: Implement browser fallbacks for older browsers
  * Add polyfillFetch() using XMLHttpRequest for fetch API fallback
  * Implement polyfillLocalStorage() with in-memory storage
  * Add sessionStorage fallback support
  * Initialize fallbacks early in error handler setup

- Smart notifications: Complete check methods with error handling
  * Enhance checkIdleTime() with duplicate prevention and better event handling
  * Improve checkDeadlines() with validation, rate limiting, and error handling
  * Enhance checkDailySummary() with once-per-day sending and better formatting
  * Add comprehensive error handling to startBackgroundTasks()
  * Implement proper network error handling and response validation

All implementations include proper error handling, edge case coverage,
performance optimizations, and browser compatibility considerations.
2025-12-29 12:32:09 +01:00
Dries Peeters
92893b188d fix: complete backend implementations and integration improvements
This commit addresses multiple incomplete implementations identified in the
codebase analysis, focusing on security, functionality, and error handling.

Backend Fixes:
- Issues module: Implement proper permission filtering for non-admin users
  - Users can only see issues for projects they have access to
  - Added permission checks to view_issue and edit_issue routes
  - Statistics now respect user permissions

- Push notifications: Implement proper subscription storage
  - Created PushSubscription model for browser push notification subscriptions
  - Updated routes to use new model with proper CRUD operations
  - Added support for multiple subscriptions per user
  - Added endpoint to list user subscriptions

Integration Improvements:
- GitHub: Implement webhook signature verification
  - Added HMAC SHA-256 signature verification using webhook secret
  - Uses constant-time comparison to prevent timing attacks
  - Added webhook_secret field to config schema

- QuickBooks: Implement customer and account mapping
  - Added support for customer mappings (client → QuickBooks customer)
  - Added support for item mappings (invoice items → QuickBooks items)
  - Added support for account mappings (expense categories → accounts)
  - Added default expense account configuration
  - Improved error handling and logging

- Xero: Add customer and account mapping support
  - Added contact mappings (client → Xero Contact ID)
  - Added item mappings (invoice items → Xero item codes)
  - Added account mappings (expense categories → Xero account codes)
  - Added default expense account configuration

- CalDAV: Implement bidirectional sync
  - Added TimeTracker to Calendar sync direction
  - Implemented iCalendar event generation from time entries
  - Added create_or_update_event method to CalDAVClient
  - Supports bidirectional sync (both directions simultaneously)
  - Improved error handling for event creation/updates

- Trello: Implement bidirectional sync
  - Added TimeTracker to Trello sync direction
  - Implemented task to card creation and updates
  - Automatic board creation for projects if needed
  - Maps task status to Trello lists
  - Supports bidirectional sync

- Exception handling: Improve error logging in integrations
  - Replaced silent pass statements with proper error logging
  - Added debug logging for non-critical failures (user info fetch)
  - Improved error visibility for debugging
  - Affected: Google Calendar, Outlook Calendar, Microsoft Teams, Asana, GitLab

All changes include proper error handling, logging, and follow existing code
patterns. Database migration required for push_subscriptions table.
2025-12-29 12:31:52 +01:00
Dries Peeters
ff2b8be015 Bump Version 2025-12-29 08:02:19 +01:00
Dries Peeters
d3f7fb8998 docs: Add troubleshooting for PostgreSQL init and ADMIN_USERNAMES behavior
Addresses user deployment issues:
1. PostgreSQL database tables not being created automatically
2. Authentication issues when using multiple admin usernames

Documentation improvements:
- Added comprehensive troubleshooting sections for PostgreSQL database initialization
- Clarified that only the first username in ADMIN_USERNAMES is auto-created during initialization
- Documented that additional admin usernames must self-register or be created manually
- Added step-by-step solutions for both issues

Code improvements:
- Fixed whitespace handling in ADMIN_USERNAMES parsing (strip whitespace from all usernames)
- Fixed whitespace handling in all database initialization scripts to properly strip the first admin username
- Ensured consistent behavior across all initialization paths

Files updated:
- All Docker setup documentation files
- Configuration documentation
- README and env.example
- Database initialization scripts
- Config parsing logic
2025-12-29 08:00:26 +01:00
Dries Peeters
df9b06c228 fix: Improve CalDAV integration error handling and feature completeness
Fix multiple issues with CalDAV calendar integration:

Error Handling & User Experience:
- Fix 'Integration not found' error after saving CalDAV configuration
- Improve error handling in view_integration route to gracefully handle missing/invalid credentials
- Add connector error display in integration view template with helpful links
- Fix 'Test Connection' button always showing errors by improving credential validation
- Add better error messages for SSL, timeout, and connection errors with actionable guidance

Sync Improvements:
- Fix sync returning 0 items with no feedback - now provides detailed messages
- Add support for DURATION-based events (not just DTEND)
- Improve sync result messages to distinguish between 'no events found' vs 'all events already imported'
- Add synced_items field for compatibility with scheduled sync tasks
- Better handling of duplicate UID race conditions during import

CalDAV Client Enhancements:
- Improve XML parsing error handling with clear error messages
- Handle empty responses gracefully (return empty multistatus for no events)
- Add time range validation in fetch_events
- Better error handling in calendar discovery with step-by-step error messages
- Improve iCalendar parsing with better error logging

Configuration & Setup:
- Add auto_sync configuration option in CalDAV setup form
- Add URL validation for server_url and calendar_url
- Ensure credentials are properly saved and integration marked as active
- Improve CalDAV setup route to handle missing credentials during initial setup

Logging & Debugging:
- Add comprehensive logging throughout sync process
- Log calendar discovery steps and event fetch operations
- Better error context in logs for troubleshooting

This addresses user-reported issues where:
- Users couldn't click on integration after saving
- Test Connection always failed with generic errors
- Sync showed 0 items with no explanation
- Credentials weren't being saved properly
2025-12-29 08:00:08 +01:00
Dries Peeters
5d5ebc98d0 Version Bump 2025-12-20 17:43:18 +01:00
Dries Peeters
443a797e2d feat: Add CalDAV calendar integration for Zimbra and other CalDAV servers
Implement comprehensive CalDAV calendar integration to import calendar events
as time entries from CalDAV-compatible servers (Zimbra, Nextcloud, ownCloud).

Features:
- CalDAV client with calendar discovery and event fetching
- Automatic calendar discovery from server URL
- Import calendar events (VEVENT) as time entries
- Project matching from event titles with fallback to default project
- Idempotent sync using IntegrationExternalEventLink to prevent duplicates
- Per-user integration setup (similar to Google Calendar)
- Support for both server URL (with discovery) and direct calendar URL
- SSL certificate verification toggle for self-signed certificates
- Configurable lookback period for event import

Components:
- CalDAVCalendarConnector: Main integration connector with sync logic
- CalDAVClient: Low-level CalDAV client using PROPFIND/REPORT requests
- IntegrationExternalEventLink: Model for tracking imported events (idempotency)
- Setup UI: User-friendly form for configuration
- Comprehensive validation and error handling
- Full test coverage (unit, integration, route tests)
- Documentation: Setup guide and troubleshooting

Technical details:
- Uses icalendar library for parsing VEVENT components
- Handles timezone conversion (CalDAV UTC to app local timezone)
- Skips all-day events (only imports timed events)
- Stores credentials securely (password in access_token, username in extra_data)
- Automatic calendar discovery on first sync if only server URL provided

Migration:
- Adds integration_external_event_links table for sync tracking
- Unique constraint on (integration_id, external_uid) prevents duplicates

Documentation:
- CALDAV_INTEGRATION.md: Complete feature documentation
- CALDAV_QUICK_SETUP.md: Step-by-step setup guide with examples

Closes feature request for CalDAV/Zimbra integration.
2025-12-20 17:28:48 +01:00
Dries Peeters
00f467843b feat: add project time entries overview + day-group invoice selection
- Add per-project time entries overview page with date range filter and chronological grouping.

- Add navigation links from project view/dashboard.

- Group unbilled invoice time entry selection by day and sort chronologically.
2025-12-20 08:54:45 +01:00
Dries Peeters
a89ecd4b31 Fix project creation 500 when logging client name
Project.client is a backward-compat property that returns a string, so accessing project.client.name raised AttributeError during /projects/create activity logging.

- Use Project.client_obj.name (fallback to Project.client) when building activity/audit-style descriptions
- Fix similar usages in reports/exports/invoice/unpaid-hours flows
- Add regression test covering POST /projects/create
2025-12-20 08:35:10 +01:00
Dries Peeters
f6264f2473 Merge pull request #356 from DRYTRIX/rc/v4.6.0
Rc/v4.6.0
v4.6.0
2025-12-14 08:02:29 +01:00
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
Dries Peeters
9291d5c705 docs: Add comprehensive CHANGELOG and update release documentation
- Create CHANGELOG.md with complete release history (v4.2.0 through v4.6.0)
- Document all recent features, bug fixes, and improvements from git commits
- Add release dates and detailed change descriptions for each version
- Update README.md to reference CHANGELOG.md in navigation and documentation sections
- Add 'What's New' section highlighting latest releases (v4.5.0, v4.5.1, v4.6.0)
- Follow Keep a Changelog format for consistency

This ensures all recent commits and version releases are properly documented
for users and contributors to track application changes over time.
2025-12-14 07:31:02 +01:00
Dries Peeters
7791e6ada0 feat: Add comprehensive issue/bug tracking system
Implement a complete issue management system with client portal integration
and internal admin interface for tracking and resolving client-reported issues.

Features:
- New Issue model with full lifecycle management (open, in_progress, resolved, closed, cancelled)
- Priority levels (low, medium, high, urgent) with visual indicators
- Issue linking to projects and tasks
- Create tasks directly from issues
- Client portal integration for issue reporting and viewing
- Internal admin routes for issue management, filtering, and assignment
- Comprehensive templates for both client and admin views
- Status filtering and search functionality
- Issue assignment to internal users
- Automatic timestamp tracking (created, updated, resolved, closed)

Client Portal:
- Clients can report new issues with project association
- View all issues with status filtering
- View individual issue details
- Submit issues with optional submitter name/email

Admin Interface:
- List all issues with advanced filtering (status, priority, client, project, assignee, search)
- View, edit, and delete issues
- Link issues to existing tasks
- Create tasks from issues
- Update issue status, priority, and assignment
- Issue statistics dashboard

Technical:
- Added Issue model with relationships to Client, Project, Task, and User
- New issues blueprint for internal management
- Extended client_portal routes with issue endpoints
- Updated model imports and relationships
- Added navigation links in base templates
- Version bump to 4.6.0
- Code cleanup in docker scripts and schema verification
2025-12-14 07:25:42 +01:00
Dries Peeters
a4271b18e6 Merge pull request #355 from DRYTRIX/RC
Rc
v4.5.1
2025-12-13 19:09:14 +01:00
Dries Peeters
6c6ae8cfdf Merge pull request #354 from DRYTRIX/develop
perf: optimize task listing and improve version management
2025-12-13 19:08:50 +01:00
Dries Peeters
8324636e2b perf: optimize task listing and improve version management
- Bump version to 4.5.1
- Refactor version retrieval: make get_version_from_setup() public and add multiple path fallbacks for better reliability in production and development environments
- Optimize task listing performance:
  * Replace joinedload with selectinload to avoid cartesian product issues
  * Implement optimized pagination that avoids expensive count queries when possible
  * Move AJAX request check earlier to skip unnecessary filter data loading
  * Add query limits to filter dropdowns (projects: 500, users: 200)
  * Optimize permission checks by checking is_admin first (no DB query)
- Update API info endpoint and context processor to use centralized version retrieval
- Maintain backward compatibility with _get_version_from_setup alias
2025-12-13 19:06:19 +01:00
Dries Peeters
b7d7547ac5 Merge pull request #353 from DRYTRIX/RC
Rc
v4.5.0
2025-12-12 22:37:52 +01:00
Dries Peeters
2450e03a84 Merge pull request #352 from DRYTRIX/develop
Develop
2025-12-12 22:36:19 +01:00
Dries Peeters
2230d5b909 feat: Add quick task creation from Start Timer modal
Add ability to create tasks directly from the Start Timer UI without
navigating through deep menus or loading all tasks upfront.

Features:
- Convert task dropdown to combobox (input + datalist) for autocomplete
- Allow free-text input to create new tasks on-the-fly
- Auto-create tasks with sensible defaults when timer is started:
  * Assigned to current user
  * Medium priority
  * No due date
  * Todo status
- New AJAX endpoint /api/tasks/create for inline task creation
- Preserve task selection when reloading task list after creation

Implementation details:
- Task combobox shows existing tasks as suggestions via datalist
- When user types a new task name, it's automatically created before
  starting the timer
- JavaScript handles task creation asynchronously with proper error handling
- Form submission includes the newly created task_id

Tests:
- Add integration test for inline task creation endpoint
- Add smoke test for full timer start flow with new task creation

This significantly improves workflow efficiency by eliminating the need
to navigate through multiple screens to create and start a timer for
a new task.
2025-12-12 22:35:38 +01:00
Dries Peeters
a83aabb006 feat: Add user filter and flexible column layout to Kanban board
- Add 'Assigned To' filter dropdown to filter tasks by assigned user
  - Enables users to view their personal todo landscape
  - Filter works in combination with existing project filter
  - Shows all active users sorted by display name

- Replace fixed grid layout with flexible flexbox layout
  - Columns now expand evenly to fill available horizontal space
  - Added min-width constraint to prevent columns from becoming too narrow
  - Maintains horizontal scrolling on smaller screens for better mobile UX

This improves the Kanban board usability by allowing users to focus on
their assigned tasks and provides a better visual layout that adapts
to the number of columns and screen size.
2025-12-12 22:24:19 +01:00
Dries Peeters
bde61c7f5d Fix permission and role management bugs
Fix multiple permission and role-related issues:

1. Gantt chart access: Replace is_admin check with view_projects permission
   - Users with custom roles having view_projects permission can now access
     Gantt charts, not just admins
   - Updated app/routes/gantt.py to check permissions properly

2. Task view filtering: Replace is_admin check with view_all_tasks permission
   - Users with custom roles having view_all_tasks permission can now see
     all tasks in the Tasks view, not just admins
   - Updated app/services/task_service.py to accept has_view_all_tasks parameter
   - Updated app/routes/tasks.py list_tasks and export_tasks to use permission check

3. Role assignment security: Prevent privilege escalation
   - Added is_super_admin property to User model
   - Only super_admins can assign super_admin role to users
   - Only super_admins can remove admin role from themselves or others
   - Prevents admins from escalating privileges or removing admin access
   - Updated app/routes/permissions.py manage_user_roles with validation

4. Version display consistency: Ensure consistent version display
   - Added APP_VERSION environment variable to docker-compose.example.yml
   - Ensures version is displayed consistently when using pre-built images

All changes maintain backward compatibility and follow the existing
permission system architecture.
2025-12-12 22:18:30 +01:00
Dries Peeters
88656c3d34 feat: Advanced Report Builder with iterative generation and email distribution
Implement comprehensive enhancements to the Report Builder system with support
for iterative report generation, flexible email distribution, and improved
error handling.

Features:
- Add iterative report generation: generate one report per custom field value
- Add email distribution modes: mapping, template, and single recipient modes
- Add recipient email templates with {value} placeholder support
- Enhance scheduled reports with better error handling and validation
- Add fix endpoint for invalid scheduled reports
- Improve report builder UI with iterative generation options
- Add comprehensive management views for report schemes

Fixes:
- Fix template errors in iterative report view (dict access issues)
- Fix empty report builder when editing saved reports
- Fix PWA install toast notification handling
- Fix migration revision ID length issue (shortened to fit 32 char limit)
- Add idempotent migration checks to prevent duplicate column errors
- Improve error handling in scheduled reports list view

Database Changes:
- Add iterative_report_generation and iterative_custom_field_name to saved_report_views
- Add email_distribution_mode and recipient_email_template to report_email_schedules
- Migration 090_report_builder_iteration (idempotent)

UI/UX Improvements:
- Display iterative generation status in saved views list
- Show distribution mode and template in scheduled reports
- Add error badges and fix buttons for invalid schedules
- Improve report builder form loading for saved configurations

Technical:
- Enhance ScheduledReportService with recipient resolution logic
- Add validation for report configurations
- Improve error handling and logging throughout
- Update templates to use safe dictionary access patterns
2025-12-12 22:11:57 +01:00
Dries Peeters
a582e2af62 feat: improve error handling, performance logging, and PWA install UI
- Add session state clearing (expunge_all) after rollbacks in custom field
  definition error handlers to prevent stale session state
- Add graceful error handling for missing link_templates table with proper
  rollback and session cleanup, preventing app crashes when migrations
  haven't been run
- Add detailed performance logging to TaskService.list_tasks method to track
  timing of each query step for performance monitoring
- Improve PWA install prompt UI with better toast integration, dismiss button,
  and proper DOM manipulation using requestAnimationFrame
- Bump version to 4.5.0
2025-12-12 21:49:26 +01:00
Dries Peeters
717142bdd7 Merge pull request #348 from DRYTRIX/RC
Rc
v4.4.1
2025-12-08 21:18:39 +01:00
Dries Peeters
f203c789e4 Merge pull request #347 from DRYTRIX/develop
Develop
2025-12-08 21:16:49 +01:00
Dries Peeters
8a78975497 Enhance custom reports and scheduled reports functionality
- Add edit functionality for saved report views in custom reports builder
- Implement saved views list page with management capabilities
- Enhance scheduled reports service with improved error handling and email support
- Add email template for scheduled report delivery
- Update report templates with improved UI and functionality
- Fix PostgreSQL sequences for roles and permissions tables
- Update permission system migration with additional changes
- Improve base template with enhanced navigation and styling
2025-12-08 21:16:06 +01:00
Dries Peeters
98fefd5ec1 fix: handle missing custom_field_definitions table gracefully (fixes #344)
- Updated CustomFieldDefinition model methods to catch ProgrammingError
  when table doesn't exist (migration not run yet)
- Methods now return empty list/None instead of raising 500 errors
- Added transaction rollback to prevent subsequent query failures
- Prevents database errors when visiting Time Entries, Projects, or Clients
  pages before migration 084_add_custom_field_definitions is applied

The fix ensures the application continues to work even if the migration
hasn't been run, with appropriate warning logs suggesting to run
'flask db upgrade'.
2025-12-05 07:50:35 +01:00
Dries Peeters
3c2e144f5c Fix dashboard cache invalidation when editing timer entries (#342)
- Add cache invalidation to update_entry API endpoint
- Add cache invalidation to edit_timer route
- Add cache invalidation to delete_entry API endpoint
- Add cache invalidation to delete_timer route
- Add cache invalidation to create_entry API endpoint

The dashboard caches data for 5 minutes, but the cache was not being
invalidated when time entries were modified. This caused the 'Recent
Entries' table to show stale duration values until the cache expired
or the browser tab was refreshed.

Now the dashboard cache is immediately invalidated whenever a time
entry is created, updated, or deleted, ensuring users see the latest
data without waiting for cache expiration.
2025-12-05 07:44:57 +01:00
Dries Peeters
5f3cd98533 Fix dashboard cache invalidation when editing timer entries (#342)
- Add cache invalidation to update_entry API endpoint
- Add cache invalidation to edit_timer route
- Add cache invalidation to delete_entry API endpoint
- Add cache invalidation to delete_timer route
- Add cache invalidation to create_entry API endpoint

The dashboard caches data for 5 minutes, but the cache was not being
invalidated when time entries were modified. This caused the 'Recent
Entries' table to show stale duration values until the cache expired
or the browser tab was refreshed.

Now the dashboard cache is immediately invalidated whenever a time
entry is created, updated, or deleted, ensuring users see the latest
data without waiting for cache expiration.
2025-12-05 07:15:37 +01:00
Dries Peeters
ea5f83eef4 Merge pull request #340 from DRYTRIX/RC
Rc
v4.4.0
2025-12-03 09:17:58 +01:00
Dries Peeters
e4b932a148 Merge pull request #339 from DRYTRIX/develop
Update setup.py
2025-12-03 09:17:36 +01:00
Dries Peeters
c64af6dd3a Update setup.py 2025-12-03 09:16:59 +01:00
Dries Peeters
11e27e39ab Merge pull request #338 from DRYTRIX/RC
Rc
2025-12-03 09:16:03 +01:00
Dries Peeters
9b227cb694 Merge pull request #337 from DRYTRIX/develop
Develop
2025-12-03 09:15:41 +01:00
Dries Peeters
4e57f08c03 Add salesman-based report splitting and email distribution
- Add SalesmanEmailMapping model to map salesman initials to email addresses
  - Support for direct email addresses, email patterns, and domain-based patterns
  - Admin interface for managing email mappings

- Add UnpaidHoursService for querying and grouping unpaid time entries
  - Filter by client custom fields (e.g., salesman)
  - Group unpaid hours by salesman for report generation

- Add salesman report routes and API endpoints
  - CRUD operations for email mappings
  - Generate and send reports split by salesman
  - Preview email addresses for salesman initials

- Enhance scheduled reports with salesman splitting
  - Add split_by_salesman and salesman_field_name to report schedules
  - Automatically split reports by salesman and send to mapped emails

- Add UI components for salesman report management
  - Admin dashboard integration
  - Report builder with salesman splitting options
  - Email mapping management interface

- Add email template for unpaid hours reports

- Add database migrations:
  - 087: Create salesman_email_mappings table
  - 088: Add salesman splitting fields to report_email_schedules
2025-12-03 08:59:48 +01:00