-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor big file into smaller files * Store artefact status * Add UI for artefact sign off * Add artefact status chip on artefact cards * Add frontend functionality to change artefact status * Return updated artefact on patch endpoint * Pass correct artefact status value * fix order of returned artefacts
- Loading branch information
Showing
14 changed files
with
289 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
import '../models/artefact.dart'; | ||
import 'dio.dart'; | ||
|
||
part 'artefact_notifier.g.dart'; | ||
|
||
@riverpod | ||
class ArtefactNotifier extends _$ArtefactNotifier { | ||
@override | ||
Future<Artefact> build(int artefactId) async { | ||
final dio = ref.watch(dioProvider); | ||
|
||
final response = await dio.get('/v1/artefacts/$artefactId'); | ||
final artefact = Artefact.fromJson(response.data); | ||
return artefact; | ||
} | ||
|
||
Future<void> changeStatus(ArtefactStatus newStatus) async { | ||
final dio = ref.watch(dioProvider); | ||
|
||
final response = await dio.patch( | ||
'/v1/artefacts/$artefactId', | ||
data: {'status': newStatus.toJson()}, | ||
); | ||
|
||
state = AsyncData(Artefact.fromJson(response.data)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
frontend/lib/ui/artefact_dialog/artefact_signoff_button.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:yaru_widgets/yaru_widgets.dart'; | ||
|
||
import '../../models/artefact.dart'; | ||
import '../../providers/artefact_notifier.dart'; | ||
|
||
class ArtefactSignoffButton extends ConsumerWidget { | ||
const ArtefactSignoffButton({super.key, required this.artefact}); | ||
|
||
final Artefact artefact; | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final fontStyle = Theme.of(context).textTheme.titleMedium; | ||
|
||
return YaruPopupMenuButton( | ||
child: Text( | ||
artefact.status.name, | ||
style: fontStyle?.apply(color: artefact.status.color), | ||
), | ||
itemBuilder: (_) => ArtefactStatus.values | ||
.map( | ||
(status) => PopupMenuItem( | ||
value: status, | ||
onTap: () => ref | ||
.read(artefactNotifierProvider(artefact.id).notifier) | ||
.changeStatus(status), | ||
child: Text( | ||
status.name, | ||
style: fontStyle?.apply(color: status.color), | ||
), | ||
), | ||
) | ||
.toList(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:intersperse/intersperse.dart'; | ||
|
||
import '../../models/artefact.dart'; | ||
import '../spacing.dart'; | ||
import 'artefact_status_chip.dart'; | ||
|
||
class ArtefactCard extends ConsumerWidget { | ||
const ArtefactCard({Key? key, required this.artefact}) : super(key: key); | ||
|
||
final Artefact artefact; | ||
static const double width = 320; | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
return GestureDetector( | ||
onTap: () { | ||
final currentRoute = GoRouterState.of(context).fullPath; | ||
context.go('$currentRoute/${artefact.id}'); | ||
}, | ||
child: Card( | ||
margin: const EdgeInsets.all(0), | ||
elevation: 0, | ||
shape: RoundedRectangleBorder( | ||
side: BorderSide(color: Theme.of(context).colorScheme.outline), | ||
borderRadius: BorderRadius.circular(2.25), | ||
), | ||
child: Container( | ||
width: width, | ||
height: 180, | ||
padding: const EdgeInsets.all(Spacing.level4), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Text( | ||
artefact.name, | ||
style: Theme.of(context).textTheme.titleLarge, | ||
), | ||
const SizedBox(height: Spacing.level2), | ||
...artefact.details.entries | ||
.map<Widget>( | ||
(detail) => Text('${detail.key}: ${detail.value}'), | ||
) | ||
.intersperse(const SizedBox(height: Spacing.level2)), | ||
const Spacer(), | ||
ArtefactStatusChip(status: artefact.status), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import '../../models/artefact.dart'; | ||
|
||
class ArtefactStatusChip extends StatelessWidget { | ||
const ArtefactStatusChip({super.key, required this.status}); | ||
|
||
final ArtefactStatus status; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final fontStyle = Theme.of(context).textTheme.labelMedium; | ||
return Chip( | ||
label: Text( | ||
status.name, | ||
style: fontStyle?.apply(color: status.color), | ||
), | ||
shape: const StadiumBorder(), | ||
); | ||
} | ||
} |
Oops, something went wrong.