feat: document versioning, templates, ZIP backup/restore, and Open/Edit workflow
Backend:
- schema.js: add document_templates, template_versions, document_versions tables;
migrate documents with template_id/template_version_id columns;
auto-seed Version 1 for all 190 existing documents
- templateController.js (NEW): full CRUD + file upload/download for templates
and template versions
- templates.js route (NEW): /api/templates endpoints
- documentController.js: add getDocumentVersions, uploadDocumentVersion,
downloadDocumentVersion; uploadDocument now seeds Version 1 on creation
- documents.js: wire GET /:id/versions, POST /:id/upload-version
- backupController.js: upgrade backup to ZIP archive (DB + student files +
template files + SHA-256 manifest); restore handles ZIP and legacy .db;
safety backup taken before every restore
- package.json: add archiver + unzipper dependencies
Frontend:
- template_model.dart (NEW): DocumentTemplateModel + TemplateVersionModel entities
- document_version_model.dart (NEW): DocumentVersionModel entity
- template_repository.dart (NEW): Dio-based template API client
- document_repository.dart: add getDocumentVersions, uploadDocumentVersion,
downloadDocumentVersion methods
- document_preview_modal.dart: add Open / Open With (Windows rundll32
OpenAs_RunDLL / Android chooser) / Edit (download-temp -> open -> upload
prompt) / Upload New Version (FilePicker) / Version History actions
- document_version_history_sheet.dart (NEW): draggable bottom sheet listing
all document versions with per-version Preview + Download
- file_folder_card.dart: add Open With, Edit, Upload New Version, Version
History items to context menu
- documents_screen.dart: wire open_with, edit, upload_version, version_history,
restore action cases; import version history sheet
Bugfix:
- student_profile_modal.dart: remove enrollment.status access that caused
NoSuchMethodError (enrollments table has no status column)