feat: implement alias strategy for receipt import with user-scoped and global fallback, enhance validation and normalization, and update UI components
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
This commit is contained in:
@@ -31,7 +31,11 @@ class _UserAliasesScreenState extends ConsumerState<UserAliasesScreen> {
|
||||
final aliases = await ref.read(adminRepositoryProvider).listReceiptAliases();
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_aliases = aliases;
|
||||
_aliases = [...aliases]
|
||||
..sort((a, b) {
|
||||
if (a.isGlobal != b.isGlobal) return a.isGlobal ? 1 : -1;
|
||||
return a.receiptName.compareTo(b.receiptName);
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
@@ -118,7 +122,7 @@ class _UserAliasesScreenState extends ConsumerState<UserAliasesScreen> {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Alias skapas automatiskt när du sparar kvittorader i inventariet.',
|
||||
'Alias skapas när du väljer att lära in dem under kvittoimporten.',
|
||||
style: theme.textTheme.bodySmall?.copyWith(color: theme.colorScheme.onSurfaceVariant),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
@@ -135,23 +139,41 @@ class _UserAliasesScreenState extends ConsumerState<UserAliasesScreen> {
|
||||
final alias = _aliases[i];
|
||||
return ListTile(
|
||||
leading: Icon(
|
||||
Icons.link_outlined,
|
||||
alias.isGlobal ? Icons.public_outlined : Icons.link_outlined,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
title: Text(
|
||||
alias.receiptName,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(fontWeight: FontWeight.w500),
|
||||
),
|
||||
subtitle: Text(
|
||||
'→ ${alias.displayProductName}',
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.delete_outline),
|
||||
tooltip: 'Ta bort alias',
|
||||
color: theme.colorScheme.error,
|
||||
onPressed: () => _delete(alias),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'→ ${alias.displayProductName}',
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Chip(
|
||||
visualDensity: VisualDensity.compact,
|
||||
label: Text(alias.isGlobal ? 'Global fallback' : 'Privat alias'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
trailing: alias.isPrivate
|
||||
? IconButton(
|
||||
icon: const Icon(Icons.delete_outline),
|
||||
tooltip: 'Ta bort alias',
|
||||
color: theme.colorScheme.error,
|
||||
onPressed: () => _delete(alias),
|
||||
)
|
||||
: null,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user