From c713bbebbc6b3d5451202a81d0474a79a2198ab4 Mon Sep 17 00:00:00 2001 From: GiuseppeS Date: Wed, 14 Apr 2021 12:25:09 +0200 Subject: [PATCH] Fix su creazione collo involontaria in DialogScanOrCreateUL --- .../DialogScanOrCreateLUView.java | 4 +++- .../DialogScanOrCreateLUViewModel.java | 17 +++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/scan_or_create_lu/DialogScanOrCreateLUView.java b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/scan_or_create_lu/DialogScanOrCreateLUView.java index 2619dfb2..e2e05f48 100644 --- a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/scan_or_create_lu/DialogScanOrCreateLUView.java +++ b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/scan_or_create_lu/DialogScanOrCreateLUView.java @@ -46,6 +46,7 @@ public class DialogScanOrCreateLUView extends BaseDialogFragment implements Dial private boolean mShouldCheckResiduo; private boolean mShouldCheckIfExistDoc; + private boolean mEnableCreation; private final BindableBoolean basketEnabled = new BindableBoolean(); private final BindableBoolean creationEnabled = new BindableBoolean(); @@ -71,6 +72,7 @@ public class DialogScanOrCreateLUView extends BaseDialogFragment implements Dial this.basketEnabled.set(enableBasket); this.creationEnabled.set(enableCreation); + mEnableCreation = enableCreation; mOnComplete = onComplete; } @@ -95,7 +97,7 @@ public class DialogScanOrCreateLUView extends BaseDialogFragment implements Dial getDialog().setCanceledOnTouchOutside(false); getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); - this.mViewModel.init(mShouldCheckResiduo, mShouldCheckIfExistDoc); + this.mViewModel.init(mShouldCheckResiduo, mShouldCheckIfExistDoc, mEnableCreation); mBindings.createNewLuButton.setOnClickListener(v -> { this.mViewModel.createNewLU(); diff --git a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/scan_or_create_lu/DialogScanOrCreateLUViewModel.java b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/scan_or_create_lu/DialogScanOrCreateLUViewModel.java index 99f663ed..66c40b54 100644 --- a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/scan_or_create_lu/DialogScanOrCreateLUViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/scan_or_create_lu/DialogScanOrCreateLUViewModel.java @@ -29,6 +29,7 @@ public class DialogScanOrCreateLUViewModel { private boolean mShouldCheckResiduo = false; private boolean mShouldCheckIfExistDoc = true; + private boolean mEnableCreation = false; private Listener mListener; @@ -40,9 +41,10 @@ public class DialogScanOrCreateLUViewModel { } - public void init(boolean checkResiduo, boolean shouldCheckIfExistDoc) { + public void init(boolean checkResiduo, boolean shouldCheckIfExistDoc, boolean enableCreation) { this.mShouldCheckResiduo = checkResiduo; this.mShouldCheckIfExistDoc = shouldCheckIfExistDoc; + this.mEnableCreation = enableCreation; } public void createNewLU() { @@ -94,11 +96,14 @@ public class DialogScanOrCreateLUViewModel { this.mColliMagazzinoRESTConsumer.getBySSCC(barcodeScanDTO.getStringValue(), mShouldCheckResiduo, false, mtbColt -> { if (mtbColt == null) { - this.mColliMagazzinoRESTConsumer.createColloFromEtichettaAnonima(barcodeScanDTO, GestioneEnum.LAVORAZIONE, createdMtbColt -> { - onComplete.run(); - this.sendOnLUOpened(createdMtbColt, true); - }, this::sendError); - + if(mEnableCreation) { + this.mColliMagazzinoRESTConsumer.createColloFromEtichettaAnonima(barcodeScanDTO, GestioneEnum.LAVORAZIONE, createdMtbColt -> { + onComplete.run(); + this.sendOnLUOpened(createdMtbColt, true); + }, this::sendError); + } else { + this.sendError(new NoLUFoundException()); + } } else { if (mtbColt.getCodDtip() != null && mShouldCheckIfExistDoc) { this.sendError(new AlreadyAttachedDocumentToLUException());