계정 정보 다이얼로그 추가 및 전체 목록 페치 개선
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user