Skip to content

Commit

Permalink
request access UI, improvements going through steps and back
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Oct 11, 2022
1 parent bc47ec9 commit 619795b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ default boolean onBackPerformed(AjaxRequestTarget target) {

/**
* @return flag whether default "next" button action should be executed.
* If true, default behaviour of back button will be executed as well
* If true, default behaviour of next button will be executed as well
* If false, only code in this method will be executed
*/
default boolean onNextPerformed(AjaxRequestTarget target) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,20 @@ public class PageRequestAccess extends PageSelf {
private static final String ID_MAIN_FORM = "mainForm";
private static final String ID_WIZARD = "wizard";

private WizardModel model;

public PageRequestAccess() {
this(new PageParameters());
}

public PageRequestAccess(PageParameters parameters) {
this(parameters,null);
}

public PageRequestAccess(PageParameters parameters, WizardModel model) {
super(parameters);

this.model = model;
}

@Override
Expand All @@ -62,15 +71,14 @@ protected void onInitialize() {
initLayout();
}

private WizardPanel getWizard() {
return (WizardPanel) get(createComponentPath(ID_MAIN_FORM, ID_WIZARD));
}

private void initLayout() {
Form mainForm = new Form(ID_MAIN_FORM);
add(mainForm);

WizardPanel wizard = new WizardPanel(ID_WIZARD, new WizardModel(createSteps()));
if (model == null) {
model = new WizardModel(createSteps());
}
WizardPanel wizard = new WizardPanel(ID_WIZARD, model);
wizard.setOutputMarkupId(true);
mainForm.add(wizard);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected void onBeforeRender() {
PageParameters params = new PageParameters();
params.set(WizardModel.PARAM_STEP, PersonOfInterestPanel.STEP_ID);

throw new RestartResponseException(new PageRequestAccess(params));
throw new RestartResponseException(new PageRequestAccess(params, getWizard()));
}

super.onBeforeRender();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected void onBeforeRender() {
PageParameters params = new PageParameters();
params.set(WizardModel.PARAM_STEP, RelationPanel.STEP_ID);

throw new RestartResponseException(new PageRequestAccess(params));
throw new RestartResponseException(new PageRequestAccess(params, getWizard()));
}

ListGroupMenu menu = menuModel.getObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.Containerable;

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
Expand Down Expand Up @@ -143,6 +145,10 @@ protected PrismContainerValueWrapper load() {
// create whole wrapper, instead of only the concrete container value wrapper
PrismObjectWrapper<UserType> userWrapper = userWrapperFactory.createObjectWrapper(user.asPrismObject(), ItemStatus.ADDED, context);
PrismContainerWrapper<AssignmentType> assignmentWrapper = userWrapper.findContainer(UserType.F_ASSIGNMENT);
if (assignmentWrapper == null) {
return null;
}

PrismContainerValueWrapper<AssignmentType> valueWrapper = assignmentWrapper.getValues().iterator().next();
// todo this should be done automatically by wrappers - if parent ADDED child should probably have ADDED status as well...
valueWrapper.setStatus(ValueStatus.ADDED);
Expand Down Expand Up @@ -177,7 +183,12 @@ private void initLayout() {

@Override
protected DisplayNamePanel<AssignmentType> createDisplayNamePanel(String displayNamePanelId) {
DisplayNamePanel panel = super.createDisplayNamePanel(displayNamePanelId);
DisplayNamePanel panel;
if (getModelObject() == null) {
panel = new DisplayNamePanel(displayNamePanelId, Model.of((Containerable) null));
} else {
panel = super.createDisplayNamePanel(displayNamePanelId);
}
panel.add(new VisibleBehaviour(() -> false));
return panel;
}
Expand All @@ -194,7 +205,11 @@ protected ItemVisibility getBasicTabVisibity(ItemWrapper<?, ?> itemWrapper) {
};
extension.add(new VisibleBehaviour(() -> {
try {
PrismContainerWrapper cw = assignmentExtension.getObject().findItem(ItemPath.create(AssignmentType.F_EXTENSION));
PrismContainerValueWrapper<AssignmentType> wrapper = assignmentExtension.getObject();
if (wrapper == null) {
return false;
}
PrismContainerWrapper cw = wrapper.findItem(ItemPath.create(AssignmentType.F_EXTENSION));
if (cw == null || cw.isEmpty()) {
return false;
}
Expand Down Expand Up @@ -315,7 +330,12 @@ public Component getContent() {
protected void savePerformed(AjaxRequestTarget target, IModel<ShoppingCartItem> model) {
try {
// this is just a nasty "pre-save" code to handle assignment extension via wrappers -> apply it to our assignment stored in request access
PrismObjectWrapper<UserType> wrapper = assignmentExtension.getObject().getParent().findObjectWrapper();
PrismContainerValueWrapper<AssignmentType> containerValueWrapper = assignmentExtension.getObject();
if (containerValueWrapper == null){
return;
}

PrismObjectWrapper<UserType> wrapper = containerValueWrapper.getParent().findObjectWrapper();
if (wrapper.getObjectDelta().isEmpty()) {
return;
}
Expand Down

0 comments on commit 619795b

Please sign in to comment.