Skip to content

Commit

Permalink
MID-7976 replaces viewtoggle panel with more generic toggle panel, up…
Browse files Browse the repository at this point in the history
…dated behavior of shopping cart step
  • Loading branch information
1azyman committed Jun 17, 2022
1 parent e351771 commit 5c3805f
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ default IModel<List<Badge>> getTitleBadges() {
}

default VisibleEnableBehaviour getStepsBehaviour() {
return VisibleEnableBehaviour.ALWAYS_INVISIBLE;
return VisibleEnableBehaviour.ALWAYS_VISIBLE_ENABLED;
}

default VisibleEnableBehaviour getHeaderBehaviour() {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ protected void openConflictPerformed(AjaxRequestTarget target) {
protected void submitPerformed(AjaxRequestTarget target) {
}

//todo use configuration to populate this
private IModel<List> createValidityOptions() {
return new LoadableModel<>(false) {

Expand Down Expand Up @@ -227,7 +226,7 @@ private List<ValidityPredefinedValueType> getValidityPeriods() {

CheckoutValidityConfigurationType validityConfig = config.getValidityConfiguration();
List<ValidityPredefinedValueType> values = validityConfig.getPredefinedValue();
return values != null ? values : DEFAULT_VALIDITY_PERIODS;
return values != null && !values.isEmpty() ? values : DEFAULT_VALIDITY_PERIODS;
}

private CheckoutType getCheckoutConfiguration() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected List<Toggle<ConflictState>> load() {
List<Toggle<ConflictState>> list = new ArrayList<>();

for (ConflictState cs : ConflictState.values()) {
Toggle<ConflictState> t = new Toggle<>(null, cs.name());
Toggle<ConflictState> t = new Toggle<>(null, getString(cs));
if (cs == ConflictState.UNRESOLVED) {
t.setActive(true);
t.setBadge("2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
<div wicket:id="viewToggle"/>
<ul wicket:id="menu"/>
</div>
<div class="flex-grow-1" wicket:id="tilesTable"/>
<wicket:remove>
<!-- todo mt-2 added because search panel now uses *-sm classes and it doesn't match rest of the layout -->
</wicket:remove>
<div class="flex-grow-1 mt-2" wicket:id="tilesTable"/>
</div>
</wicket:panel>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import java.util.stream.Collectors;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.api.component.result.Toast;

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
Expand All @@ -30,6 +28,7 @@
import org.apache.wicket.model.Model;
import org.apache.wicket.util.string.Strings;

import com.evolveum.midpoint.gui.api.component.result.Toast;
import com.evolveum.midpoint.gui.api.component.wizard.Badge;
import com.evolveum.midpoint.gui.api.component.wizard.WizardStepPanel;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
Expand All @@ -38,7 +37,10 @@
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.gui.impl.component.search.Search;
import com.evolveum.midpoint.gui.impl.component.search.SearchFactory;
import com.evolveum.midpoint.gui.impl.component.tile.*;
import com.evolveum.midpoint.gui.impl.component.tile.CatalogTile;
import com.evolveum.midpoint.gui.impl.component.tile.CatalogTilePanel;
import com.evolveum.midpoint.gui.impl.component.tile.TileTablePanel;
import com.evolveum.midpoint.gui.impl.component.tile.ViewToggle;
import com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.query.ObjectQuery;
Expand Down Expand Up @@ -201,11 +203,34 @@ protected IModel<Search> createSearchModel() {
};
add(tilesTable);

ViewTogglePanel viewToggle = new ViewTogglePanel(ID_VIEW_TOGGLE, tilesTable.getViewToggleModel()) {
IModel<List<Toggle<ViewToggle>>> items = new LoadableModel<>(false) {

@Override
protected List<Toggle<ViewToggle>> load() {
ViewToggle toggle = tilesTable.getViewToggleModel().getObject();
List<Toggle<ViewToggle>> list = new ArrayList<>();

Toggle asList = new Toggle("fa-solid fa-table-list", null);
asList.setActive(ViewToggle.TABLE == toggle);
asList.setValue(ViewToggle.TABLE);
list.add(asList);

Toggle asTile = new Toggle("fa-solid fa-table-cells", null);
asTile.setActive(ViewToggle.TILE == toggle);
asTile.setValue(ViewToggle.TILE);
list.add(asTile);

return list;
}
};

TogglePanel<ViewToggle> viewToggle = new TogglePanel<>(ID_VIEW_TOGGLE, items) {

@Override
protected void onTogglePerformed(AjaxRequestTarget target, ViewToggle newState) {
super.onTogglePerformed(target, newState);
protected void itemSelected(AjaxRequestTarget target, IModel<Toggle<ViewToggle>> item) {
super.itemSelected(target, item);

tilesTable.getViewToggleModel().setObject(item.getObject().getValue());
target.add(RoleCatalogPanel.this);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ private ContainerDelta handleAssignmentDeltas(ObjectDelta<UserType> focusDelta,
return delta;
}

// todo this doesn't work properly first time loading conflict numbers - model is evaluated before computeConflicts...
@Override
public IModel<List<Badge>> getTitleBadges() {
return () -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<wicket:container wicket:id="buttons">
<button type="button" class="btn btn-default d-flex align-items-baseline gap-1" data-toggle="button" wicket:id="button">
<button type="button" class="btn btn-default" data-toggle="button" wicket:id="button">
<wicket:container wicket:id="content"/>
</button>
</wicket:container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ public class TogglePanel<O extends Serializable> extends BasePanel<List<Toggle<O
private static final String ID_LABEL = "label";
private static final String ID_BADGE = "badge";

private boolean multipleActive;

public TogglePanel(String id, IModel<List<Toggle<O>>> model) {
super(id, model);
public TogglePanel(String id, IModel<List<Toggle<O>>> items) {
super(id, items);

initLayout();
}
Expand Down Expand Up @@ -92,23 +90,13 @@ protected Component createButtonContent(String id, IModel<Toggle<O>> model) {
return defaultButtonContent;
}

public boolean isMultipleActive() {
return multipleActive;
}

public void setMultipleActive(boolean multipleActive) {
this.multipleActive = multipleActive;
}

protected void itemSelected(AjaxRequestTarget target, IModel<Toggle<O>> item) {
Toggle<O> toggle = item.getObject();

boolean wasActiveBefore = toggle.isActive();

if (!multipleActive) {
List<Toggle<O>> list = getModelObject();
list.forEach(t -> t.setActive(false));
}
List<Toggle<O>> list = getModelObject();
list.forEach(t -> t.setActive(false));

toggle.setActive(!wasActiveBefore);

Expand Down

0 comments on commit 5c3805f

Please sign in to comment.