You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2021/05/12 15:03:13 UTC
[isis] branch master updated: ISIS-2665: action ordering fix
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 29547db ISIS-2665: action ordering fix
29547db is described below
commit 29547db9a1603569569aaca0e16a445ee57017ab
Author: Andi Huber <ah...@apache.org>
AuthorDate: Wed May 12 17:02:54 2021 +0200
ISIS-2665: action ordering fix
---
.../isis/core/metamodel/spec/feature/ObjectAction.java | 10 +++++-----
.../viewer/wicket/model/models/EntityCollectionModel.java | 5 +++++
.../model/models/EntityCollectionModelParented.java | 15 +++++++++++++++
3 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectAction.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectAction.java
index 505b3df..0be1b23 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectAction.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectAction.java
@@ -353,7 +353,7 @@ public interface ObjectAction extends ObjectMember {
.filter(ObjectAction.Predicates.isNotInAnyLayoutGroup(spec))
.filter(ObjectAction.Predicates.dynamicallyVisible(adapter,
InteractionInitiatedBy.USER, Where.ANYWHERE))
- .filter(ObjectAction.Predicates.excludeWizardActions(spec));
+ .filter(ObjectAction.Predicates.isNotWizard(spec));
}
public static Stream<ObjectAction> findForAssociation(
@@ -364,7 +364,7 @@ public interface ObjectAction extends ObjectMember {
return spec.streamRuntimeActions(MixedIn.INCLUDED)
.filter(ObjectAction.Predicates.isSameLayoutGroup(association))
- .filter(ObjectAction.Predicates.excludeWizardActions(spec))
+ .filter(ObjectAction.Predicates.isNotWizard(spec))
.sorted(Comparators.byMemberOrderSequence(false));
}
@@ -500,11 +500,11 @@ public interface ObjectAction extends ObjectMember {
};
}
- private static Predicate<ObjectAction> excludeWizardActions(final ObjectSpecification objectSpecification) {
- return wizardActions(objectSpecification).negate();
+ private static Predicate<ObjectAction> isNotWizard(final ObjectSpecification objectSpecification) {
+ return isWizard(objectSpecification).negate();
}
- private static Predicate<ObjectAction> wizardActions(final ObjectSpecification objectSpecification) {
+ private static Predicate<ObjectAction> isWizard(final ObjectSpecification objectSpecification) {
return (ObjectAction input) -> {
if (objectSpecification == null) {
return false;
diff --git a/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityCollectionModel.java b/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityCollectionModel.java
index 40a0424..7f02606 100644
--- a/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityCollectionModel.java
+++ b/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityCollectionModel.java
@@ -112,6 +112,9 @@ extends
* Returns all actions that are associated with this collection,
* and hence should be rendered close to this collection's UI representation.
* Typically at the top bar of the UI collection panel.
+ * <p>
+ * Order matters, that is the order of returned actions corresponds to the order of
+ * rendered (action) buttons.
*/
default Can<ObjectAction> getAssociatedActions() {
return Can.empty();
@@ -121,6 +124,8 @@ extends
* Returns all actions that are targets for the multi-select UI feature.
* That typically means, their first parameter is a non-scalar type with an
* element type that corresponds to the element type of this collection.
+ * <p>
+ * Order does not matter.
*/
default Can<ObjectAction> getActionsWithChoicesFrom() {
return Can.empty();
diff --git a/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityCollectionModelParented.java b/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityCollectionModelParented.java
index 888326e..bfca18f 100644
--- a/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityCollectionModelParented.java
+++ b/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityCollectionModelParented.java
@@ -28,7 +28,9 @@ import org.apache.isis.applib.layout.component.CollectionLayoutData;
import org.apache.isis.applib.services.bookmark.Bookmark;
import org.apache.isis.commons.collections.Can;
import org.apache.isis.commons.internal.base._NullSafe;
+import org.apache.isis.commons.internal.compare._Comparators;
import org.apache.isis.commons.internal.exceptions._Exceptions;
+import org.apache.isis.core.metamodel.facets.members.layout.order.LayoutOrderFacet;
import org.apache.isis.core.metamodel.interactions.managed.ManagedCollection;
import org.apache.isis.core.metamodel.spec.ManagedObject;
import org.apache.isis.core.metamodel.spec.feature.MixedIn;
@@ -103,6 +105,7 @@ implements
val associatedActions = managedCollection.getOwner().getSpecification()
.streamRuntimeActions(MixedIn.INCLUDED)
.filter(ObjectAction.Predicates.associatedWith(collection))
+ .sorted(this::deweyOrderCompare)
.collect(Can.toCan());
return associatedActions;
}
@@ -179,5 +182,17 @@ implements
return entityModel.memento();
}
+ // -- ACTION ORDER
+
+ private int deweyOrderCompare(ObjectAction a, ObjectAction b) {
+ val seqA = a.lookupFacet(LayoutOrderFacet.class)
+ .map(LayoutOrderFacet::getSequence)
+ .orElse("1");
+ val seqB = b.lookupFacet(LayoutOrderFacet.class)
+ .map(LayoutOrderFacet::getSequence)
+ .orElse("1");
+ return _Comparators.deweyOrderCompare(seqA, seqB);
+ }
+
}