move transfer button, hide delete button better
All checks were successful
Release / meta (push) Successful in 28s
Release / linux-build (push) Successful in 54s
Release / web-build (push) Successful in 4m48s
Release / android-build (push) Successful in 15m12s
Release / release-master (push) Successful in 31s
Release / release-dev (push) Successful in 34s

This commit is contained in:
2026-01-06 12:04:34 +00:00
parent 06bed86a49
commit 5b94ab263b
2 changed files with 86 additions and 51 deletions

View File

@@ -744,57 +744,92 @@ Future<void> showTractionDetails(
); );
}, },
), ),
if (auth.isElevated || canDeleteAsOwner) ...[ const SizedBox(height: 16),
const SizedBox(height: 16), FilledButton.icon(
FilledButton.tonal( onPressed: () {
style: FilledButton.styleFrom( Navigator.of(ctx).pop();
backgroundColor: navContext.push(
Theme.of(context).colorScheme.errorContainer, Uri(
foregroundColor: path: '/traction',
Theme.of(context).colorScheme.onErrorContainer, queryParameters: {
), 'selection': 'single',
onPressed: () async { 'transferFromLocoId': loco.id.toString(),
final confirmed = await showDialog<bool>(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('Delete loco?'),
content: const Text(
'This will permanently delete this loco. Are you sure?',
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(false),
child: const Text('Cancel'),
),
FilledButton(
onPressed: () => Navigator.of(context).pop(true),
style: FilledButton.styleFrom(
backgroundColor:
Theme.of(context).colorScheme.error,
),
child: const Text('Delete'),
),
],
);
}, },
); ).toString(),
if (confirmed != true) return; extra: {
try { 'selection': 'single',
await data.adminDeleteLoco(locoId: loco.id); 'transferFromLocoId': loco.id,
messenger.showSnackBar( },
const SnackBar(content: Text('Loco deleted')), );
); },
await onActionComplete?.call(); icon: const Icon(Icons.swap_horiz),
if (!context.mounted) return; label: const Text('Transfer allocations'),
Navigator.of(ctx).pop(); ),
} catch (e) { if (auth.isElevated || canDeleteAsOwner) ...[
messenger.showSnackBar( const SizedBox(height: 8),
SnackBar(content: Text('Failed to delete loco: $e')), ExpansionTile(
); tilePadding: EdgeInsets.zero,
} childrenPadding: EdgeInsets.zero,
}, title: Text(
child: const Text('Delete loco'), 'More',
style: Theme.of(context).textTheme.titleSmall,
),
children: [
FilledButton.tonal(
style: FilledButton.styleFrom(
backgroundColor:
Theme.of(context).colorScheme.errorContainer,
foregroundColor:
Theme.of(context).colorScheme.onErrorContainer,
),
onPressed: () async {
final confirmed = await showDialog<bool>(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('Delete loco?'),
content: const Text(
'This will permanently delete this loco. Are you sure?',
),
actions: [
TextButton(
onPressed: () =>
Navigator.of(context).pop(false),
child: const Text('Cancel'),
),
FilledButton(
onPressed: () =>
Navigator.of(context).pop(true),
style: FilledButton.styleFrom(
backgroundColor:
Theme.of(context).colorScheme.error,
),
child: const Text('Delete'),
),
],
);
},
);
if (confirmed != true) return;
try {
await data.adminDeleteLoco(locoId: loco.id);
messenger.showSnackBar(
const SnackBar(content: Text('Loco deleted')),
);
await onActionComplete?.call();
if (!context.mounted) return;
Navigator.of(ctx).pop();
} catch (e) {
messenger.showSnackBar(
SnackBar(
content: Text('Failed to delete loco: $e')),
);
}
},
child: const Text('Delete loco'),
),
const SizedBox(height: 8),
],
), ),
], ],
], ],

View File

@@ -472,7 +472,7 @@ extension DataServiceTraction on DataService {
}) async { }) async {
try { try {
await api.post('/loco/alloc/transfer', { await api.post('/loco/alloc/transfer', {
'loco_id': fromLocoId, 'from_loco_id': fromLocoId,
'to_loco_id': toLocoId, 'to_loco_id': toLocoId,
}); });
} catch (e) { } catch (e) {