868cb0e49e
Milestone data layer: - lib/data/models/milestone.dart: Milestone model with progress fields (total, completed, pct) from backend progress endpoint - lib/data/api/milestones_api.dart: CRUD client for /api/projects/:id/milestones - lib/data/repositories/milestones_repository.dart: thin repository wrapper - lib/providers/milestones_provider.dart: FutureProvider.family keyed by project ID — lazily fetched per project when expanded - api_client_provider.dart: registers milestonesApiProvider and milestonesRepositoryProvider Projects tab redesign (project_list_screen.dart): - Each project is now an ExpansionTile showing open task count in subtitle - Expanding a project fetches its milestones and groups tasks under milestone headers with inline progress bar (completed/total count) - Tasks show status icon, due date with overdue highlighting, priority dot - 'No milestone' section at bottom for unassigned tasks - Tapping a task navigates to the task editor - Long-press on project title opens archive/complete/delete bottom sheet - 'New task' button at bottom of each expanded project section Bump version to 26.03.02+1 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
72 lines
1.9 KiB
Dart
72 lines
1.9 KiB
Dart
import 'package:dio/dio.dart';
|
|
|
|
import '../models/milestone.dart';
|
|
import 'api_client.dart';
|
|
|
|
class MilestonesApi {
|
|
final Dio _dio;
|
|
const MilestonesApi(this._dio);
|
|
|
|
Future<List<Milestone>> getAll(int projectId, {String? status}) async {
|
|
try {
|
|
final response = await _dio.get(
|
|
'/api/projects/$projectId/milestones',
|
|
queryParameters: status != null ? {'status': status} : null,
|
|
);
|
|
final data = response.data as Map<String, dynamic>;
|
|
final list = data['milestones'] as List<dynamic>;
|
|
return list
|
|
.map((e) => Milestone.fromJson(e as Map<String, dynamic>))
|
|
.toList();
|
|
} on DioException catch (e) {
|
|
throw dioToApp(e);
|
|
}
|
|
}
|
|
|
|
Future<Milestone> create(
|
|
int projectId, {
|
|
required String title,
|
|
String? description,
|
|
int orderIndex = 0,
|
|
}) async {
|
|
try {
|
|
final response = await _dio.post(
|
|
'/api/projects/$projectId/milestones',
|
|
data: {
|
|
'title': title,
|
|
if (description != null && description.isNotEmpty)
|
|
'description': description,
|
|
'order_index': orderIndex,
|
|
},
|
|
);
|
|
return Milestone.fromJson(response.data as Map<String, dynamic>);
|
|
} on DioException catch (e) {
|
|
throw dioToApp(e);
|
|
}
|
|
}
|
|
|
|
Future<Milestone> update(
|
|
int projectId,
|
|
int milestoneId,
|
|
Map<String, dynamic> fields,
|
|
) async {
|
|
try {
|
|
final response = await _dio.patch(
|
|
'/api/projects/$projectId/milestones/$milestoneId',
|
|
data: fields,
|
|
);
|
|
return Milestone.fromJson(response.data as Map<String, dynamic>);
|
|
} on DioException catch (e) {
|
|
throw dioToApp(e);
|
|
}
|
|
}
|
|
|
|
Future<void> delete(int projectId, int milestoneId) async {
|
|
try {
|
|
await _dio.delete('/api/projects/$projectId/milestones/$milestoneId');
|
|
} on DioException catch (e) {
|
|
throw dioToApp(e);
|
|
}
|
|
}
|
|
}
|