You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by mg...@apache.org on 2015/08/07 10:43:36 UTC
isis git commit: ISIS-1007 Provide support for "are you sure" idiom,
eg using a @AreYouSure annotation on the action
Repository: isis
Updated Branches:
refs/heads/ISIS-1007-are-you-sure-semantics [created] f5f0fc631
ISIS-1007 Provide support for "are you sure" idiom, eg using a @AreYouSure annotation on the action
Add SemanticsOf#[NON_]IDEMPOTENT_ARE_YOU_SURE constants.
When used the action prompt for the action will show "Are you sure?" dialog after pressing the OK button
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/f5f0fc63
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/f5f0fc63
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/f5f0fc63
Branch: refs/heads/ISIS-1007-are-you-sure-semantics
Commit: f5f0fc6312c0db222231221a3cf85630e6b40d15
Parents: a930c1d
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Fri Aug 7 11:35:50 2015 +0300
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Fri Aug 7 11:43:15 2015 +0300
----------------------------------------------------------------------
.../isis/applib/annotation/ActionSemantics.java | 14 ++++++++--
.../isis/applib/annotation/SemanticsOf.java | 28 ++++++++++++++++++--
core/pom.xml | 8 +++---
.../actions/ActionParametersFormPanel.java | 21 ++++++++++++++-
.../viewer/wicket/ui/pages/PageAbstract.java | 4 +--
5 files changed, 64 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/f5f0fc63/core/applib/src/main/java/org/apache/isis/applib/annotation/ActionSemantics.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/ActionSemantics.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/ActionSemantics.java
index d5e21d7..0801922 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/ActionSemantics.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/ActionSemantics.java
@@ -55,10 +55,20 @@ public @interface ActionSemantics {
@Deprecated
IDEMPOTENT,
/**
- * @deprecated - see {@link SemanticsOf#IDEMPOTENT}
+ * @deprecated - see {@link SemanticsOf#NON_IDEMPOTENT}
+ */
+ @Deprecated
+ NON_IDEMPOTENT,
+ /**
+ * @deprecated - see {@link SemanticsOf#IDEMPOTENT_ARE_YOU_SURE}
+ */
+ @Deprecated
+ IDEMPOTENT_ARE_YOU_SURE,
+ /**
+ * @deprecated - see {@link SemanticsOf#NON_IDEMPOTENT_ARE_YOU_SURE}
*/
@Deprecated
- NON_IDEMPOTENT;
+ NON_IDEMPOTENT_ARE_YOU_SURE;
/**
* @deprecated - see {@link SemanticsOf#getFriendlyName()}
http://git-wip-us.apache.org/repos/asf/isis/blob/f5f0fc63/core/applib/src/main/java/org/apache/isis/applib/annotation/SemanticsOf.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/SemanticsOf.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/SemanticsOf.java
index 5cbe820..7a4a570 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/SemanticsOf.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/SemanticsOf.java
@@ -46,7 +46,27 @@ public enum SemanticsOf {
* <p>
* An example is increasing the quantity of a line item in an Order by 1.
*/
- NON_IDEMPOTENT;
+ NON_IDEMPOTENT,
+ /**
+ * Post-conditions are always the same, irrespective as to how many times called.
+ *
+ * <p>
+ * If supported the UI viewer will show a confirmation dialog before executing the action.
+ *
+ * <p>
+ * An example might be <tt>placeOrder()</tt>, that is a no-op if the order has already been placed.
+ */
+ IDEMPOTENT_ARE_YOU_SURE,
+ /**
+ * Neither safe nor idempotent; every invocation is likely to change the state of the object.
+ *
+ * <p>
+ * If supported the UI viewer will show a confirmation dialog before executing the action.
+ *
+ * <p>
+ * An example is increasing the quantity of a line item in an Order by 1.
+ */
+ NON_IDEMPOTENT_ARE_YOU_SURE;
public String getFriendlyName() {
return Enums.getFriendlyNameOf(this);
@@ -60,7 +80,7 @@ public enum SemanticsOf {
* Any of {@link #SAFE}, {@link #SAFE_AND_REQUEST_CACHEABLE} or (obviously) {@link #IDEMPOTENT}.
*/
public boolean isIdempotentInNature() {
- return isSafeInNature() || this == IDEMPOTENT;
+ return isSafeInNature() || this == IDEMPOTENT || this == IDEMPOTENT_ARE_YOU_SURE;
}
/**
@@ -88,7 +108,9 @@ public enum SemanticsOf {
if(semantics == SAFE_AND_REQUEST_CACHEABLE) return ActionSemantics.Of.SAFE_AND_REQUEST_CACHEABLE;
if(semantics == SAFE) return ActionSemantics.Of.SAFE;
if(semantics == IDEMPOTENT) return ActionSemantics.Of.IDEMPOTENT;
+ if(semantics == IDEMPOTENT_ARE_YOU_SURE) return ActionSemantics.Of.IDEMPOTENT_ARE_YOU_SURE;
if(semantics == NON_IDEMPOTENT) return ActionSemantics.Of.NON_IDEMPOTENT;
+ if(semantics == NON_IDEMPOTENT_ARE_YOU_SURE) return ActionSemantics.Of.NON_IDEMPOTENT_ARE_YOU_SURE;
// shouldn't happen
throw new IllegalArgumentException("Unrecognized of: " + semantics);
}
@@ -99,7 +121,9 @@ public enum SemanticsOf {
if(semantics == ActionSemantics.Of.SAFE_AND_REQUEST_CACHEABLE) return SAFE_AND_REQUEST_CACHEABLE;
if(semantics == ActionSemantics.Of.SAFE) return SAFE;
if(semantics == ActionSemantics.Of.IDEMPOTENT) return IDEMPOTENT;
+ if(semantics == ActionSemantics.Of.IDEMPOTENT_ARE_YOU_SURE) return IDEMPOTENT_ARE_YOU_SURE;
if(semantics == ActionSemantics.Of.NON_IDEMPOTENT) return NON_IDEMPOTENT;
+ if(semantics == ActionSemantics.Of.NON_IDEMPOTENT_ARE_YOU_SURE) return NON_IDEMPOTENT_ARE_YOU_SURE;
// shouldn't happen
throw new IllegalArgumentException("Unrecognized semantics: " + semantics);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/f5f0fc63/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 729b8b7..dfcabcd 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -131,11 +131,11 @@
<jetty.version>9.2.11.v20150529</jetty.version>
- <wicket.version>6.17.0</wicket.version>
- <wicketstuff.version>6.17.0</wicketstuff.version>
+ <wicket.version>6.20.0</wicket.version>
+ <wicketstuff.version>6.20.0</wicketstuff.version>
- <wicket-webjars.version>0.4.3</wicket-webjars.version>
- <wicket-bootstrap.version>0.9.7</wicket-bootstrap.version>
+ <wicket-webjars.version>0.4.6</wicket-webjars.version>
+ <wicket-bootstrap.version>0.9.12-SNAPSHOT</wicket-bootstrap.version>
<wicket-source.version>6.0.0.8</wicket-source.version>
<wicket-select2.version>2.2.3</wicket-select2.version>
http://git-wip-us.apache.org/repos/asf/isis/blob/f5f0fc63/core/viewer-wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersFormPanel.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersFormPanel.java b/core/viewer-wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersFormPanel.java
index 8416491..626c5f8 100644
--- a/core/viewer-wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersFormPanel.java
+++ b/core/viewer-wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersFormPanel.java
@@ -19,6 +19,8 @@
package org.apache.isis.viewer.wicket.ui.components.actions;
+import de.agilecoders.wicket.extensions.markup.html.bootstrap.confirmation.ConfirmationBehavior;
+
import java.util.List;
import com.google.common.collect.Lists;
import org.apache.wicket.Component;
@@ -29,6 +31,7 @@ import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.ResourceModel;
+import org.apache.isis.applib.annotation.ActionSemantics;
import org.apache.isis.core.commons.ensure.Ensure;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.version.ConcurrencyException;
@@ -182,7 +185,8 @@ public class ActionParametersFormPanel extends PanelAbstract<ActionModel> {
okButton.add(new JGrowlBehaviour());
setDefaultButton(okButton);
add(okButton);
-
+ applyAreYouSure(okButton);
+
AjaxButton cancelButton = new AjaxButton(ID_CANCEL_BUTTON, new ResourceModel("cancelLabel")) {
private static final long serialVersionUID = 1L;
@@ -204,6 +208,21 @@ public class ActionParametersFormPanel extends PanelAbstract<ActionModel> {
}
}
+ /**
+ * If the {@literal @}Action has "are you sure?" semantics then apply {@link ConfirmationBehavior}
+ * that will ask for confirmation before executing the Ajax request.
+ *
+ * @param button The button which action should be confirmed
+ */
+ private void applyAreYouSure(AjaxButton button) {
+ ActionModel actionModel = getActionModel();
+ final ObjectAction action = actionModel.getActionMemento().getAction();
+ ActionSemantics.Of semantics = action.getSemantics();
+ if (semantics == ActionSemantics.Of.IDEMPOTENT_ARE_YOU_SURE || semantics == ActionSemantics.Of.NON_IDEMPOTENT_ARE_YOU_SURE) {
+ button.add(new ConfirmationBehavior());
+ }
+ }
+
@Override
public void onUpdate(AjaxRequestTarget target, ScalarModelProvider provider) {
http://git-wip-us.apache.org/repos/asf/isis/blob/f5f0fc63/core/viewer-wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.java b/core/viewer-wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.java
index daf886e..60e273d 100644
--- a/core/viewer-wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.java
+++ b/core/viewer-wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.java
@@ -20,7 +20,7 @@
package org.apache.isis.viewer.wicket.ui.pages;
import de.agilecoders.wicket.core.Bootstrap;
-import de.agilecoders.wicket.core.markup.html.references.BootlintJavaScriptReference;
+import de.agilecoders.wicket.core.markup.html.references.BootlintHeaderItem;
import de.agilecoders.wicket.core.settings.IBootstrapSettings;
import de.agilecoders.wicket.core.settings.ITheme;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.icon.FontAwesomeCssReference;
@@ -271,7 +271,7 @@ public abstract class PageAbstract extends WebPage implements ActionPromptProvid
}
private void addBootLint(final IHeaderResponse response) {
- response.render(JavaScriptHeaderItem.forReference(BootlintJavaScriptReference.INSTANCE));
+ response.render(BootlintHeaderItem.INSTANCE);
}
private boolean isModernBrowser() {