Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/self-dashbo…
Browse files Browse the repository at this point in the history
…ard-configuration
  • Loading branch information
Kateryna Honchar committed Aug 4, 2022
2 parents 4a9c1e4 + da65c1d commit 1e06d27
Show file tree
Hide file tree
Showing 50 changed files with 801 additions and 332 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void initLayout() {
AjaxIconButton exit = new AjaxIconButton(
buttons.newChildId(),
Model.of("fa fa-right-from-bracket"),
getPageBase().createStringResource("ResourceWizard.exit")) {
getExitLabel()) {
@Override
public void onClick(AjaxRequestTarget target) {
onExitPerformed(target);
Expand All @@ -70,6 +70,10 @@ public void onClick(AjaxRequestTarget target) {
add(buttons);
}

protected IModel<String> getExitLabel() {
return getPageBase().createStringResource("WizardPanel.exit");
}

protected void onExitPerformed(AjaxRequestTarget target) {
getPageBase().navigateToNext(PageResources.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ <h5 class="text-secondary mb-5" wicket:id="subText"/>
<wicket:message key="WizardHeader.back"/>
</a>
<a class="btn btn-outline-primary" wicket:id="exit">
<i class="fas fa-arrow-left mr-2"></i>
<i class="fas fa-right-from-bracket mr-2"></i>
<wicket:message key="WizardPanel.exit"/>
</a>
<a class="btn btn-success" wicket:id="finish">
<i class="fas fa-flag-checkered ml-2"/>
<wicket:message key="WizardPanel.finish"/>
</a>
<a class="btn btn-success" wicket:id="next">
<wicket:message key="WizardHeader.next"/>
<span wicket:id="nextLabel"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;


/**
* @author lskublik
*/
Expand All @@ -30,6 +29,8 @@ public class BasicWizardStepPanel<T> extends WizardStepPanel<T> {
private static final String ID_SUBTEXT = "subText";
private static final String ID_BACK = "back";
private static final String ID_EXIT = "exit";

private static final String ID_FINISH = "finish";
private static final String ID_NEXT = "next";
private static final String ID_NEXT_LABEL = "nextLabel";

Expand Down Expand Up @@ -82,6 +83,24 @@ public void onClick(AjaxRequestTarget target) {
WebComponentUtil.addDisabledClassBehavior(exit);
add(exit);

AjaxSubmitButton finish = new AjaxSubmitButton(ID_FINISH) {

@Override
public void onSubmit(AjaxRequestTarget target) {
onFinishPerformed(target);
}

@Override
protected void onError(AjaxRequestTarget target) {
updateFeedbackPanels(target);
}
};
finish.add(new VisibleBehaviour(() -> isFinishVisible()));
finish.setOutputMarkupId(true);
finish.setOutputMarkupPlaceholderTag(true);
WebComponentUtil.addDisabledClassBehavior(finish);
add(finish);

AjaxSubmitButton next = new AjaxSubmitButton(ID_NEXT) {

@Override
Expand All @@ -104,6 +123,15 @@ protected void onError(AjaxRequestTarget target) {
next.add(nextLabel);
}

@Override
public VisibleEnableBehaviour getNextBehaviour() {
return new VisibleEnableBehaviour(() -> !isFinishVisible());
}

private boolean isFinishVisible() {
return getWizard().getNextPanel() == null;
}

private VisibleBehaviour getExitVisibility() {
return new VisibleBehaviour(() -> isExitButtonVisible());
}
Expand Down Expand Up @@ -142,17 +170,23 @@ protected IModel<String> getSubTextModel() {
}

public boolean onNextPerformed(AjaxRequestTarget target) {
getWizard().next();
target.add(getWizard().getPanel());
WizardModel model = getWizard();
if (model.hasNext()) {
model.next();
target.add(model.getPanel());
}

return false;
}

protected void onFinishPerformed(AjaxRequestTarget target) {
}

public boolean onBackPerformed(AjaxRequestTarget target) {
int index = getWizard().getActiveStepIndex();
if (index > 0) {
getWizard().previous();
target.add(getWizard().getPanel());
WizardModel model = getWizard();
if (model.hasPrevious()) {
model.previous();
target.add(model.getPanel());
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ public void init(Page page) {
String stepId = getStepIdFromParams(page);
if (stepId != null) {
setActiveStepById(stepId);
} else {
for (int i = 0; i < steps.size(); i++) {
WizardStep step = steps.get(i);

if (BooleanUtils.isTrue(step.isStepVisible().getObject())) {
activeStepIndex = i;
break;
}
}
}

fireActiveStepChanged(getActiveStep());
Expand Down Expand Up @@ -113,17 +122,13 @@ public void setActiveStepById(String id) {
WizardStep step = steps.get(i);

if (Objects.equals(id, step.getStepId()) && BooleanUtils.isTrue(step.isStepVisible().getObject())) {
setActiveStepIndex(i);
activeStepIndex = i;
break;
}
}
}

public int getActiveStepIndex() {
return activeStepIndex;
}

public int getActiveStepVisibleIndex() {
int index = 0;
for (int i = 0; i < activeStepIndex; i++) {
if (BooleanUtils.isTrue(steps.get(i).isStepVisible().getObject())) {
Expand All @@ -133,27 +138,70 @@ public int getActiveStepVisibleIndex() {
return index;
}

private void setActiveStepIndex(int activeStepIndex) {
if (activeStepIndex < 0) {
return;
public boolean hasNext() {
return findNextStep() != null;
}

private WizardStep findNextStep() {
for (int i = activeStepIndex + 1; i < steps.size(); i++) {
if (i >= steps.size()) {
return null;
}

if (BooleanUtils.isTrue(steps.get(i).isStepVisible().getObject())) {
return steps.get(i);
}
}
if (activeStepIndex >= steps.size()) {

return null;
}

public void next() {
int index = activeStepIndex;

WizardStep next = findNextStep();
if (next == null) {
return;
}

this.activeStepIndex = activeStepIndex;
activeStepIndex = steps.indexOf(next);

if (index != activeStepIndex) {
fireActiveStepChanged(getActiveStep());
}
}

public boolean hasPrevious() {
return findPreviousStep() != null;
}

public void next() {
setActiveStepIndex(activeStepIndex + 1);
private WizardStep findPreviousStep() {
for (int i = activeStepIndex - 1; i >= 0; i--) {
if (i < 0) {
return null;
}

fireActiveStepChanged(getActiveStep());
if (BooleanUtils.isTrue(steps.get(i).isStepVisible().getObject())) {
return steps.get(i);
}
}

return null;
}

public void previous() {
setActiveStepIndex(activeStepIndex - 1);
int index = activeStepIndex;

fireActiveStepChanged(getActiveStep());
WizardStep previous = findPreviousStep();
if (previous == null) {
return;
}

activeStepIndex = steps.indexOf(previous);

if (index != activeStepIndex) {
fireActiveStepChanged(getActiveStep());
}
}

public WizardStep getNextPanel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private void initLayout() {
protected void populateItem(ListItem<IModel<String>> listItem) {
WizardHeaderStepPanel step = new WizardHeaderStepPanel(ID_STEP, listItem.getIndex(), listItem.getModelObject());
// todo fix, if steps are invisible index might shift?
step.add(AttributeAppender.append("class", () -> wizardModel.getActiveStepVisibleIndex() == listItem.getIndex() ? "active" : null));
step.add(AttributeAppender.append("class", () -> wizardModel.getActiveStepIndex() == listItem.getIndex() ? "active" : null));
listItem.add(step);

WebMarkupContainer line = new WebMarkupContainer(ID_LINE);
Expand All @@ -144,7 +144,7 @@ protected void onBackPerformed(AjaxRequestTarget target) {
return;
}

if (wizardModel.getActiveStepIndex() == 0) {
if (!wizardModel.hasPrevious()) {
getPageBase().redirectBack();
} else {
wizardModel.previous();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class WrapperContext {
@Experimental
private Map<String, LookupTableType> lookupTableCache = new HashMap();

private GuiObjectDetailsPageType detailsPageTypeConfiguration;
private List<ContainerPanelConfigurationType> detailsPageTypeConfiguration;
private Collection<VirtualContainersSpecificationType> virtualContainers = new ArrayList<>();

public WrapperContext(Task task, OperationResult result) {
Expand Down Expand Up @@ -215,7 +215,7 @@ public Collection<VirtualContainersSpecificationType> getVirtualContainers() {
if (detailsPageTypeConfiguration == null) {
return virtualContainers;
}
List<ContainerPanelConfigurationType> containerPanelConfigurationTypes = detailsPageTypeConfiguration.getPanel();
List<ContainerPanelConfigurationType> containerPanelConfigurationTypes = detailsPageTypeConfiguration;
if (containerPanelConfigurationTypes.isEmpty()) {
return virtualContainers;
}
Expand Down Expand Up @@ -246,11 +246,7 @@ public VirtualContainersSpecificationType findVirtualContainerConfiguration(Item
return null;
}

public GuiObjectDetailsPageType getDetailsPageTypeConfiguration() {
return detailsPageTypeConfiguration;
}

public void setDetailsPageTypeConfiguration(GuiObjectDetailsPageType detailsPageTypeConfiguration) {
public void setDetailsPageTypeConfiguration(List<ContainerPanelConfigurationType> detailsPageTypeConfiguration) {
this.detailsPageTypeConfiguration = detailsPageTypeConfiguration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4601,8 +4601,8 @@ public static <T> List<T> sortDropDownChoices(IModel<? extends List<? extends T>
return sortedList;
}

public static IChoiceRenderer<QName> getRelationChoicesRenderer(PageBase pageBase) {
return new IChoiceRenderer<QName>() {
public static IChoiceRenderer<QName> getRelationChoicesRenderer() {
return new IChoiceRenderer<>() {

private static final long serialVersionUID = 1L;

Expand All @@ -4621,8 +4621,9 @@ public Object getDisplayValue(QName object) {
DisplayType display = def.getDisplay();
if (display != null) {
PolyStringType label = display.getLabel();

if (PolyStringUtils.isNotEmpty(label)) {
return pageBase.createStringResource(label).getString();
return getTranslatedPolyString(label);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import com.evolveum.midpoint.gui.api.factory.wrapper.PrismObjectWrapperFactory;
Expand Down Expand Up @@ -70,7 +71,7 @@ protected PrismObjectWrapper<O> load() {
OperationResult result = task.getResult();
WrapperContext ctx = new WrapperContext(task, result);
ctx.setCreateIfEmpty(true);
ctx.setDetailsPageTypeConfiguration(detailsPageConfigurationModel.getObject());
ctx.setDetailsPageTypeConfiguration(getPanelConfigurations());
if (isReadonly()) {
ctx.setReadOnly(isReadonly());
}
Expand Down Expand Up @@ -110,6 +111,13 @@ protected O load() {
};
}

private List<ContainerPanelConfigurationType> getPanelConfigurations() {
GuiObjectDetailsPageType detailsPage = detailsPageConfigurationModel.getObject();
if (detailsPage == null) {
return Collections.emptyList();
}
return detailsPage.getPanel();
}
private void loadParentOrgs(PrismObject<O> object) {
Task task = getModelServiceLocator().createSimpleTask(OPERATION_LOAD_PARENT_ORG);
OperationResult subResult = task.getResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
*/
package com.evolveum.midpoint.gui.impl.page.admin.focus.component;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import javax.xml.namespace.QName;

Expand Down Expand Up @@ -473,12 +470,12 @@ public WebMarkupContainer createPanel(String panelId) {
}

private ContainerPanelConfigurationType getBasicShadowPanelConfiguration(ShadowType shadowType) {
GuiShadowDetailsPageType detailsPageType = findShadowDetailsPageConfiguration(shadowType);
if (detailsPageType == null) {
List<ContainerPanelConfigurationType> panelConfigs = findShadowDetailsPageConfiguration(shadowType);
if (panelConfigs.isEmpty()) {
return null;
}

List<ContainerPanelConfigurationType> basicPanelConfig = detailsPageType.getPanel().stream().filter(p -> p.getIdentifier().equals("shadowBasic")).collect(Collectors.toList());
List<ContainerPanelConfigurationType> basicPanelConfig = panelConfigs.stream().filter(p -> p.getIdentifier().equals("shadowBasic")).collect(Collectors.toList());
if (basicPanelConfig.size() == 1) {
return basicPanelConfig.get(0);
}
Expand All @@ -487,8 +484,12 @@ private ContainerPanelConfigurationType getBasicShadowPanelConfiguration(ShadowT
return null;
}

private GuiShadowDetailsPageType findShadowDetailsPageConfiguration(ShadowType shadowType) {
return getPageBase().getCompiledGuiProfile().findShadowDetailsConfiguration(createResourceShadowCoordinates(shadowType));
private List<ContainerPanelConfigurationType> findShadowDetailsPageConfiguration(ShadowType shadowType) {
GuiShadowDetailsPageType shadowDetailsPage = getPageBase().getCompiledGuiProfile().findShadowDetailsConfiguration(createResourceShadowCoordinates(shadowType));
if (shadowDetailsPage == null) {
return Collections.emptyList();
}
return shadowDetailsPage.getPanel();
}

private ResourceShadowCoordinates createResourceShadowCoordinates(ShadowType shadow) {
Expand Down

0 comments on commit 1e06d27

Please sign in to comment.