feat: implement custom fields, gantt view, calendar view, and file encryption

- Custom Fields (FEAT-001):
  - CustomField and TaskCustomValue models with formula support
  - CRUD API for custom field management
  - Formula engine for calculated fields
  - Frontend: CustomFieldEditor, CustomFieldInput, ProjectSettings page
  - Task list API now includes custom_values
  - KanbanBoard displays custom field values

- Gantt View (FEAT-003):
  - TaskDependency model with FS/SS/FF/SF dependency types
  - Dependency CRUD API with cycle detection
  - start_date field added to tasks
  - GanttChart component with Frappe Gantt integration
  - Dependency type selector in UI

- Calendar View (FEAT-004):
  - CalendarView component with FullCalendar integration
  - Date range filtering API for tasks
  - Drag-and-drop date updates
  - View mode switching in Tasks page

- File Encryption (FEAT-010):
  - AES-256-GCM encryption service
  - EncryptionKey model with key rotation support
  - Admin API for key management
  - Encrypted upload/download for confidential projects

- Migrations: 011 (custom fields), 012 (encryption keys), 013 (task dependencies)
- Updated issues.md with completion status

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
beabigegg
2026-01-05 23:39:12 +08:00
parent 69b81d9241
commit 2d80a8384e
65 changed files with 11045 additions and 82 deletions

View File

@@ -0,0 +1,70 @@
"""Add custom fields and task custom values tables
Revision ID: 011
Revises: 010
Create Date: 2026-01-05
FEAT-001: Add custom fields feature for flexible task data extension.
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
revision: str = '011'
down_revision: Union[str, None] = '010'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# Create field_type_enum
field_type_enum = sa.Enum(
'text', 'number', 'dropdown', 'date', 'person', 'formula',
name='field_type_enum'
)
field_type_enum.create(op.get_bind(), checkfirst=True)
# Create pjctrl_custom_fields table
op.create_table(
'pjctrl_custom_fields',
sa.Column('id', sa.String(36), primary_key=True),
sa.Column('project_id', sa.String(36), sa.ForeignKey('pjctrl_projects.id', ondelete='CASCADE'), nullable=False),
sa.Column('name', sa.String(100), nullable=False),
sa.Column('field_type', field_type_enum, nullable=False),
sa.Column('options', sa.JSON, nullable=True),
sa.Column('formula', sa.Text, nullable=True),
sa.Column('is_required', sa.Boolean, default=False, nullable=False),
sa.Column('position', sa.Integer, default=0, nullable=False),
sa.Column('created_at', sa.DateTime, server_default=sa.func.now(), nullable=False),
sa.Column('updated_at', sa.DateTime, server_default=sa.func.now(), onupdate=sa.func.now(), nullable=False),
)
# Create indexes for custom_fields
op.create_index('ix_pjctrl_custom_fields_project_id', 'pjctrl_custom_fields', ['project_id'])
# Create pjctrl_task_custom_values table
op.create_table(
'pjctrl_task_custom_values',
sa.Column('id', sa.String(36), primary_key=True),
sa.Column('task_id', sa.String(36), sa.ForeignKey('pjctrl_tasks.id', ondelete='CASCADE'), nullable=False),
sa.Column('field_id', sa.String(36), sa.ForeignKey('pjctrl_custom_fields.id', ondelete='CASCADE'), nullable=False),
sa.Column('value', sa.Text, nullable=True),
sa.Column('updated_at', sa.DateTime, server_default=sa.func.now(), onupdate=sa.func.now(), nullable=False),
sa.UniqueConstraint('task_id', 'field_id', name='uq_task_field'),
)
# Create indexes for task_custom_values
op.create_index('ix_pjctrl_task_custom_values_task_id', 'pjctrl_task_custom_values', ['task_id'])
op.create_index('ix_pjctrl_task_custom_values_field_id', 'pjctrl_task_custom_values', ['field_id'])
def downgrade() -> None:
op.drop_index('ix_pjctrl_task_custom_values_field_id', table_name='pjctrl_task_custom_values')
op.drop_index('ix_pjctrl_task_custom_values_task_id', table_name='pjctrl_task_custom_values')
op.drop_table('pjctrl_task_custom_values')
op.drop_index('ix_pjctrl_custom_fields_project_id', table_name='pjctrl_custom_fields')
op.drop_table('pjctrl_custom_fields')
# Drop the enum type
sa.Enum(name='field_type_enum').drop(op.get_bind(), checkfirst=True)

View File

@@ -0,0 +1,48 @@
"""Encryption keys table and attachment encryption_key_id
Revision ID: 012
Revises: 011
Create Date: 2026-01-05
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers
revision = '012'
down_revision = '011'
branch_labels = None
depends_on = None
def upgrade():
# Create encryption_keys table
op.create_table(
'pjctrl_encryption_keys',
sa.Column('id', sa.String(36), primary_key=True),
sa.Column('key_data', sa.Text, nullable=False), # Encrypted key using Master Key
sa.Column('algorithm', sa.String(20), default='AES-256-GCM', nullable=False),
sa.Column('is_active', sa.Boolean, default=True, nullable=False),
sa.Column('created_at', sa.DateTime, server_default=sa.func.now(), nullable=False),
sa.Column('rotated_at', sa.DateTime, nullable=True),
)
op.create_index('idx_encryption_key_active', 'pjctrl_encryption_keys', ['is_active'])
# Add encryption_key_id column to attachments table
op.add_column(
'pjctrl_attachments',
sa.Column(
'encryption_key_id',
sa.String(36),
sa.ForeignKey('pjctrl_encryption_keys.id', ondelete='SET NULL'),
nullable=True
)
)
op.create_index('idx_attachment_encryption_key', 'pjctrl_attachments', ['encryption_key_id'])
def downgrade():
op.drop_index('idx_attachment_encryption_key', 'pjctrl_attachments')
op.drop_column('pjctrl_attachments', 'encryption_key_id')
op.drop_index('idx_encryption_key_active', 'pjctrl_encryption_keys')
op.drop_table('pjctrl_encryption_keys')

View File

@@ -0,0 +1,92 @@
"""Add start_date to tasks and create task dependencies table for Gantt view
Revision ID: 013
Revises: 012
Create Date: 2026-01-05
FEAT-003: Add Gantt view support with task dependencies and start dates.
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
revision: str = '013'
down_revision: Union[str, None] = '012'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# Add start_date column to pjctrl_tasks
op.add_column(
'pjctrl_tasks',
sa.Column('start_date', sa.DateTime, nullable=True)
)
# Create dependency_type_enum
dependency_type_enum = sa.Enum(
'FS', 'SS', 'FF', 'SF',
name='dependency_type_enum'
)
dependency_type_enum.create(op.get_bind(), checkfirst=True)
# Create pjctrl_task_dependencies table
op.create_table(
'pjctrl_task_dependencies',
sa.Column('id', sa.String(36), primary_key=True),
sa.Column(
'predecessor_id',
sa.String(36),
sa.ForeignKey('pjctrl_tasks.id', ondelete='CASCADE'),
nullable=False
),
sa.Column(
'successor_id',
sa.String(36),
sa.ForeignKey('pjctrl_tasks.id', ondelete='CASCADE'),
nullable=False
),
sa.Column(
'dependency_type',
dependency_type_enum,
default='FS',
nullable=False
),
sa.Column('lag_days', sa.Integer, default=0, nullable=False),
sa.Column('created_at', sa.DateTime, server_default=sa.func.now(), nullable=False),
# Unique constraint to prevent duplicate dependencies
sa.UniqueConstraint('predecessor_id', 'successor_id', name='uq_predecessor_successor'),
)
# Create indexes for efficient dependency lookups
op.create_index(
'ix_pjctrl_task_dependencies_predecessor_id',
'pjctrl_task_dependencies',
['predecessor_id']
)
op.create_index(
'ix_pjctrl_task_dependencies_successor_id',
'pjctrl_task_dependencies',
['successor_id']
)
def downgrade() -> None:
# Drop indexes
op.drop_index(
'ix_pjctrl_task_dependencies_successor_id',
table_name='pjctrl_task_dependencies'
)
op.drop_index(
'ix_pjctrl_task_dependencies_predecessor_id',
table_name='pjctrl_task_dependencies'
)
# Drop the table
op.drop_table('pjctrl_task_dependencies')
# Drop the enum type
sa.Enum(name='dependency_type_enum').drop(op.get_bind(), checkfirst=True)
# Remove start_date column from tasks
op.drop_column('pjctrl_tasks', 'start_date')