Skip to content

Commit

Permalink
sprint: add edit item action
Browse files Browse the repository at this point in the history
  • Loading branch information
sstasi95 committed Feb 11, 2025
1 parent d26a7e2 commit 5173d43
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/src/screens/sprint_detail/base_sprint_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:azure_devops/src/widgets/app_base_page.dart';
import 'package:azure_devops/src/widgets/app_page.dart';
import 'package:azure_devops/src/widgets/board_widget.dart';
import 'package:azure_devops/src/widgets/filter_menu.dart';
import 'package:azure_devops/src/widgets/popup_menu.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';

Expand Down
38 changes: 30 additions & 8 deletions lib/src/screens/sprint_detail/controller_sprint_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class _SprintDetailController with FilterMixin {
Set<WorkItemType> typesFilter = {};
List<WorkItemType> allWorkItemTypes = [];

Set<String> get _allowedTypes => _data?.sprint.types?.toSet() ?? {};
Set<String> get _allowedTypes => _data?.sprint.types?.toSet() ?? {'Task', 'Bug', 'User Story'};

SprintDetailWithItems? _data;

Expand Down Expand Up @@ -59,13 +59,8 @@ class _SprintDetailController with FilterMixin {
}
}

Future<void> goToDetail(WorkItem item) async {
await AppRouter.goToWorkItemDetail(project: args.project, id: item.id);
await init();
}

Future<void> addNewItem() async {
final sprint = sprintWithItems.value?.data?.sprint;
final sprint = _data?.sprint;

final areaPath = sprint?.teamDefaultArea;
if (areaPath == null) return;
Expand All @@ -79,13 +74,40 @@ class _SprintDetailController with FilterMixin {
project: args.project,
isAreaVisible: false,
isIterationVisible: false,
allowedTypes: {'Task', 'Bug', 'User Story'},
allowedTypes: _allowedTypes,
);

await AppRouter.goToCreateOrEditWorkItem(args: addItemArgs);
await init();
}

Future<void> goToDetail(WorkItem item) async {
await AppRouter.goToWorkItemDetail(project: args.project, id: item.id);
await init();
}

Future<void> editItem(WorkItem item) async {
final sprint = _data?.sprint;

final areaPath = sprint?.teamDefaultArea;
if (areaPath == null) return;

final iterationPath = sprint?.path;
if (iterationPath == null) return;

final editItemArgs = CreateOrEditWorkItemArgs(
project: args.project,
area: areaPath,
iteration: iterationPath,
id: item.id,
isAreaVisible: false,
isIterationVisible: false,
allowedTypes: _allowedTypes,
);
await AppRouter.goToCreateOrEditWorkItem(args: editItemArgs);
await init();
}

Future<void> _fillTypesFilter() async {
final types = await api.getWorkItemTypes();
if (types.isError) return;
Expand Down
3 changes: 3 additions & 0 deletions lib/src/screens/sprint_detail/screen_sprint_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class _SprintDetailScreen extends StatelessWidget {
tabController: DefaultTabController.of(ctx),
columnItems: ctrl.columnItems,
onTapItem: ctrl.goToDetail,
actions: (item) => [
PopupItem(text: 'Edit', onTap: () => ctrl.editItem(item)),
],
),
),
),
Expand Down

0 comments on commit 5173d43

Please sign in to comment.