계정 정보 다이얼로그 추가 및 전체 목록 페치 개선

This commit is contained in:
JiWoong Sul
2025-10-22 01:05:47 +09:00
parent 6b58effc83
commit f4dc83d441
44 changed files with 1636 additions and 362 deletions

View File

@@ -520,6 +520,17 @@ class _InboundPageState extends State<InboundPage> {
style: theme.textTheme.small,
),
const SizedBox(width: 12),
ShadButton.ghost(
size: ShadButtonSize.sm,
onPressed: currentPage <= 1
? null
: () => _goToPage(1),
child: const Icon(
lucide.LucideIcons.chevronsLeft,
size: 16,
),
),
const SizedBox(width: 8),
ShadButton.ghost(
size: ShadButtonSize.sm,
onPressed: currentPage <= 1
@@ -541,6 +552,17 @@ class _InboundPageState extends State<InboundPage> {
size: 16,
),
),
const SizedBox(width: 8),
ShadButton.ghost(
size: ShadButtonSize.sm,
onPressed: currentPage >= totalPages
? null
: () => _goToPage(totalPages),
child: const Icon(
lucide.LucideIcons.chevronsRight,
size: 16,
),
),
],
),
],
@@ -1060,7 +1082,11 @@ class _InboundPageState extends State<InboundPage> {
}
void _goToPage(int page) {
final target = page < 1 ? 1 : page;
final totalItems = _result?.total ?? _filteredRecords.length;
final totalPages = _calculateTotalPages(totalItems);
final int target = page < 1
? 1
: (page > totalPages ? totalPages : page);
if (target == _currentPage) {
return;
}

View File

@@ -18,6 +18,7 @@ import 'package:superport_v2/features/inventory/shared/widgets/customer_multi_se
import 'package:superport_v2/features/inventory/shared/widgets/warehouse_select_field.dart';
import 'package:superport_v2/core/config/environment.dart';
import 'package:superport_v2/core/network/failure.dart';
import 'package:superport_v2/core/common/utils/pagination_utils.dart';
import 'package:superport_v2/core/permissions/permission_manager.dart';
import 'package:superport_v2/core/permissions/permission_resources.dart';
import 'package:superport_v2/features/inventory/outbound/presentation/controllers/outbound_controller.dart';
@@ -163,17 +164,16 @@ class _OutboundPageState extends State<OutboundPage> {
try {
final repository = getIt<CustomerRepository>();
final result = await repository.list(
page: 1,
pageSize: 100,
isActive: true,
final customers = await fetchAllPaginatedItems<Customer>(
request: (page, pageSize) =>
repository.list(page: page, pageSize: pageSize, isActive: true),
);
if (!mounted) {
return;
}
final seen = <String>{CustomerFilterOption.all.cacheKey};
final options = <CustomerFilterOption>[CustomerFilterOption.all];
for (final customer in result.items) {
for (final customer in customers) {
final option = CustomerFilterOption.fromCustomer(customer);
if (seen.add(option.cacheKey)) {
options.add(option);
@@ -620,6 +620,17 @@ class _OutboundPageState extends State<OutboundPage> {
style: theme.textTheme.small,
),
const SizedBox(width: 12),
ShadButton.ghost(
size: ShadButtonSize.sm,
onPressed: currentPage <= 1
? null
: () => _goToPage(1),
child: const Icon(
lucide.LucideIcons.chevronsLeft,
size: 16,
),
),
const SizedBox(width: 8),
ShadButton.ghost(
size: ShadButtonSize.sm,
onPressed: currentPage <= 1
@@ -641,6 +652,17 @@ class _OutboundPageState extends State<OutboundPage> {
size: 16,
),
),
const SizedBox(width: 8),
ShadButton.ghost(
size: ShadButtonSize.sm,
onPressed: currentPage >= totalPages
? null
: () => _goToPage(totalPages),
child: const Icon(
lucide.LucideIcons.chevronsRight,
size: 16,
),
),
],
),
],
@@ -1172,7 +1194,9 @@ class _OutboundPageState extends State<OutboundPage> {
}
void _goToPage(int page) {
final target = page < 1 ? 1 : page;
final totalItems = _result?.total ?? _filteredRecords.length;
final totalPages = _calculateTotalPages(totalItems);
final int target = page < 1 ? 1 : (page > totalPages ? totalPages : page);
if (target == _currentPage) {
return;
}

View File

@@ -567,6 +567,17 @@ class _RentalPageState extends State<RentalPage> {
style: theme.textTheme.small,
),
const SizedBox(width: 12),
ShadButton.ghost(
size: ShadButtonSize.sm,
onPressed: currentPage <= 1
? null
: () => _goToPage(1),
child: const Icon(
lucide.LucideIcons.chevronsLeft,
size: 16,
),
),
const SizedBox(width: 8),
ShadButton.ghost(
size: ShadButtonSize.sm,
onPressed: currentPage <= 1
@@ -588,6 +599,17 @@ class _RentalPageState extends State<RentalPage> {
size: 16,
),
),
const SizedBox(width: 8),
ShadButton.ghost(
size: ShadButtonSize.sm,
onPressed: currentPage >= totalPages
? null
: () => _goToPage(totalPages),
child: const Icon(
lucide.LucideIcons.chevronsRight,
size: 16,
),
),
],
),
],
@@ -1106,7 +1128,11 @@ class _RentalPageState extends State<RentalPage> {
}
void _goToPage(int page) {
final target = page < 1 ? 1 : page;
final totalItems = _result?.total ?? _filteredRecords.length;
final totalPages = _calculateTotalPages(totalItems);
final int target = page < 1
? 1
: (page > totalPages ? totalPages : page);
if (target == _currentPage) {
return;
}

View File

@@ -5,6 +5,7 @@ import 'package:get_it/get_it.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:superport_v2/core/network/failure.dart';
import 'package:superport_v2/core/common/utils/pagination_utils.dart';
import 'package:superport_v2/features/masters/warehouse/domain/entities/warehouse.dart';
import 'package:superport_v2/features/masters/warehouse/domain/repositories/warehouse_repository.dart';
@@ -120,13 +121,15 @@ class _InventoryWarehouseSelectFieldState
_error = null;
});
try {
final result = await repository.list(
page: 1,
pageSize: 100,
isActive: true,
includeZipcode: false,
final warehouses = await fetchAllPaginatedItems<Warehouse>(
request: (page, pageSize) => repository.list(
page: page,
pageSize: pageSize,
isActive: true,
includeZipcode: false,
),
);
final options = result.items
final options = warehouses
.map(InventoryWarehouseOption.fromWarehouse)
.toList(growable: false);
setState(() {
@@ -296,35 +299,29 @@ class _InventoryWarehouseSelectFieldState
}
void _setSelection(InventoryWarehouseOption? option, {bool notify = true}) {
if (option != null &&
option.id != -1 &&
!_initialOptions.any((item) => item.id == option.id)) {
_initialOptions.add(option);
setState(() {
if (option != null &&
option.id != -1 &&
!_initialOptions.any((item) => item.id == option.id)) {
_initialOptions.add(option);
}
_selected = option;
if (option == null) {
_applyControllerText('');
} else if (option.id == -1) {
_applyControllerText(widget.allLabel);
} else {
_applyControllerText(_displayLabel(option));
}
});
if (!notify) {
return;
}
_selected = option;
_isApplyingText = true;
if (option == null) {
_controller.clear();
if (notify) {
widget.onChanged(null);
}
} else if (option.id == -1) {
_controller
..text = widget.allLabel
..selection = TextSelection.collapsed(offset: widget.allLabel.length);
if (notify) {
widget.onChanged(null);
}
if (option == null || option.id == -1) {
widget.onChanged(null);
} else {
final label = _displayLabel(option);
_controller
..text = label
..selection = TextSelection.collapsed(offset: label.length);
if (notify) {
widget.onChanged(option);
}
widget.onChanged(option);
}
_isApplyingText = false;
}
String _displayLabel(InventoryWarehouseOption option) {
@@ -387,6 +384,7 @@ class _InventoryWarehouseSelectFieldState
}
},
fieldViewBuilder: (context, textController, focusNode, onFieldSubmitted) {
assert(identical(textController, _controller));
final placeholder = widget.placeholder ?? const Text('창고 선택');
return Stack(
alignment: Alignment.centerRight,
@@ -454,4 +452,11 @@ class _InventoryWarehouseSelectFieldState
},
);
}
void _applyControllerText(String value) {
_isApplyingText = true;
_controller.text = value;
_controller.selection = TextSelection.collapsed(offset: value.length);
_isApplyingText = false;
}
}