Skip to content

Commit

Permalink
hide some processes if not picker role
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Mar 7, 2019
1 parent 342d8a8 commit d7dc1e6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import de.metas.handlingunits.picking.PickingCandidate;
import de.metas.process.IProcessPrecondition;
import de.metas.process.ProcessPreconditionsResolution;
import de.metas.ui.web.pickingV2.PickingConstantsV2;
import de.metas.ui.web.pickingV2.productsToPick.ProductsToPickRow;
import de.metas.ui.web.pickingV2.productsToPick.ProductsToPickView;
import de.metas.ui.web.process.adprocess.ViewBasedProcessTemplate;
Expand Down Expand Up @@ -42,6 +43,16 @@ public abstract class ProductsToPickViewBasedProcess extends ViewBasedProcessTem
@Override
protected abstract ProcessPreconditionsResolution checkPreconditionsApplicable();

protected final boolean isPickerProfile()
{
return getViewProfileId() == null;
}

protected final boolean isReviewProfile()
{
return PickingConstantsV2.PROFILE_ID_ProductsToPickView_Review.equals(getViewProfileId());
}

@Override
protected final ProductsToPickView getView()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public class ProductsToPick_4EyesReview_ProcessAll extends ProductsToPickViewBas
@Override
protected ProcessPreconditionsResolution checkPreconditionsApplicable()
{
if (!isPickerProfile())
{
return ProcessPreconditionsResolution.rejectWithInternalReason("only picker shall be allowed to process");
}

if (!getView().isApproved())
{
return ProcessPreconditionsResolution.rejectWithInternalReason("not all rows were approved");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public class ProductsToPick_PickSelected extends ProductsToPickViewBasedProcess
@Override
protected ProcessPreconditionsResolution checkPreconditionsApplicable()
{
if (!isPickerProfile())
{
return ProcessPreconditionsResolution.rejectWithInternalReason("only picker shall pick");
}

final List<ProductsToPickRow> selectedRows = getSelectedRows();
if (selectedRows.isEmpty())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ProductsToPick_Request4EyesReview extends ProductsToPickViewBasedPr
@Override
protected ProcessPreconditionsResolution checkPreconditionsApplicable()
{
if (PickingConstantsV2.PROFILE_ID_ProductsToPickView_Review.equals(getViewProfileId()))
if (isReviewProfile())
{
return ProcessPreconditionsResolution.rejectWithInternalReason("already reviewing");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public class ProductsToPick_SetPackingInstructions extends ProductsToPickViewBas
@Override
protected ProcessPreconditionsResolution checkPreconditionsApplicable()
{
if (!isPickerProfile())
{
return ProcessPreconditionsResolution.rejectWithInternalReason("only picker shall pack");
}

if (!streamRowsEligibleForPacking().findAny().isPresent())
{
return ProcessPreconditionsResolution.rejectWithInternalReason("no eligible rows were selected");
Expand Down

0 comments on commit d7dc1e6

Please sign in to comment.