fix : change product list in root
This commit is contained in:
@@ -22,10 +22,9 @@ class SegmentationLogic extends GetxController {
|
||||
RxnString searchedValue = RxnString();
|
||||
|
||||
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
TextEditingController weightController = TextEditingController();
|
||||
RxBool isSaleSubmitButtonEnabled = false.obs;
|
||||
TextEditingController weightController = TextEditingController(text: '0');
|
||||
RxBool isSubmitButtonEnabled = false.obs;
|
||||
|
||||
RxList<ProductModel> rolesProductsModel = RxList<ProductModel>();
|
||||
Rxn<ProductModel> selectedProduct = Rxn<ProductModel>();
|
||||
Rxn<SegmentationModel> selectedSegment = Rxn<SegmentationModel>();
|
||||
|
||||
@@ -36,6 +35,7 @@ class SegmentationLogic extends GetxController {
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
routesName = ['قطعهبندی'].toList();
|
||||
once(rootLogic.rolesProductsModel, (callback) => selectedProduct.value = callback.first);
|
||||
getAllSegmentation();
|
||||
}
|
||||
|
||||
@@ -61,6 +61,11 @@ class SegmentationLogic extends GetxController {
|
||||
(callback) => getAllSegmentation(),
|
||||
time: Duration(milliseconds: timeDebounce),
|
||||
);
|
||||
ever(selectedSegment, (_) {
|
||||
validateForm();
|
||||
});
|
||||
|
||||
weightController.addListener(() => validateForm());
|
||||
}
|
||||
|
||||
void setEditData(SegmentationModel item) {
|
||||
@@ -69,13 +74,23 @@ class SegmentationLogic extends GetxController {
|
||||
}
|
||||
|
||||
void clearForm() {
|
||||
weightController.clear();
|
||||
isSaleSubmitButtonEnabled.value = false;
|
||||
weightController.text = '0';
|
||||
isSubmitButtonEnabled.value = false;
|
||||
selectedProduct.value = null;
|
||||
selectedSegment.value = null;
|
||||
formKey.currentState?.reset();
|
||||
}
|
||||
|
||||
void validateForm() {
|
||||
isSubmitButtonEnabled = RxBool(
|
||||
selectedProduct.value != null &&
|
||||
selectedSegment.value != null &&
|
||||
weightController.text.isNotEmpty &&
|
||||
int.tryParse(weightController.text) != null &&
|
||||
int.tryParse(weightController.text)! > 0,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getAllSegmentation([bool isLoadingMore = false]) async {
|
||||
if (isLoadingMore) {
|
||||
isLoadingMoreAllocationsMade.value = true;
|
||||
@@ -134,22 +149,6 @@ class SegmentationLogic extends GetxController {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getRolesProducts() async {
|
||||
safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getRolesProducts(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
rolesProductsModel.value = result;
|
||||
|
||||
selectedProduct.value = rolesProductsModel.first;
|
||||
}
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> editSegment() async {
|
||||
var res = true;
|
||||
safeCall(
|
||||
|
||||
Reference in New Issue
Block a user