Jasper Floor pushed to branch release/4.2 at cms-community / hippo-cms

Commits:
7de86c66 by Bert Leunis at 2017-06-29T14:42:47+02:00
CMS-10811 trigger validation again if necessary when the order of compounds has 
changed

(cherry picked from commit 8dfecae23613c0038117b7bc62f9a9dbce7381d3)

- - - - -
6f1a42ec by Jasper Floor at 2017-06-30T16:49:30+02:00
CMS-10811 Reintegrate bugfix/CMS-10811

- - - - -


2 changed files:

- 
editor/frontend/src/main/java/org/hippoecm/frontend/editor/editor/EditorForm.java
- 
editor/frontend/src/main/java/org/hippoecm/frontend/editor/plugins/field/NodeFieldPlugin.java


Changes:

=====================================
editor/frontend/src/main/java/org/hippoecm/frontend/editor/editor/EditorForm.java
=====================================
--- 
a/editor/frontend/src/main/java/org/hippoecm/frontend/editor/editor/EditorForm.java
+++ 
b/editor/frontend/src/main/java/org/hippoecm/frontend/editor/editor/EditorForm.java
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2008-2015 Hippo B.V. (http://www.onehippo.com)
+ *  Copyright 2008-2017 Hippo B.V. (http://www.onehippo.com)
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -115,7 +115,7 @@ public class EditorForm extends HippoForm<Node> implements 
IFeedbackMessageFilte
     }
 
     @Override
-    protected void onValidateModelObjects() {
+    public void onValidateModelObjects() {
         // HippoForm#process() has cleared old feedbacks, but in case
         // the validation is invoked from Ajax, they should be cleared again
         clearFeedbackMessages();


=====================================
editor/frontend/src/main/java/org/hippoecm/frontend/editor/plugins/field/NodeFieldPlugin.java
=====================================
--- 
a/editor/frontend/src/main/java/org/hippoecm/frontend/editor/plugins/field/NodeFieldPlugin.java
+++ 
b/editor/frontend/src/main/java/org/hippoecm/frontend/editor/plugins/field/NodeFieldPlugin.java
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2008-2015 Hippo B.V. (http://www.onehippo.com)
+ *  Copyright 2008-2017 Hippo B.V. (http://www.onehippo.com)
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -33,6 +33,8 @@ import org.apache.wicket.markup.html.panel.Fragment;
 import org.apache.wicket.markup.repeater.Item;
 import org.apache.wicket.model.IModel;
 import org.hippoecm.frontend.editor.TemplateEngineException;
+import org.hippoecm.frontend.editor.editor.EditorForm;
+import org.hippoecm.frontend.editor.editor.EditorPlugin;
 import org.hippoecm.frontend.editor.plugins.fieldhint.FieldHint;
 import org.hippoecm.frontend.model.AbstractProvider;
 import org.hippoecm.frontend.model.ChildNodeProvider;
@@ -294,4 +296,31 @@ public class NodeFieldPlugin extends 
AbstractFieldPlugin<Node, JcrNodeModel> {
             return new Label("add").setVisible(false);
         }
     }
+
+    @Override
+    public void onMoveItemUp(final JcrNodeModel model, final AjaxRequestTarget 
target) {
+        super.onMoveItemUp(model, target);
+        validateModelObjects();
+    }
+
+    @Override
+    public void onRemoveItem(final JcrNodeModel childModel, final 
AjaxRequestTarget target) {
+        super.onRemoveItem(childModel, target);
+        validateModelObjects();
+    }
+
+    /**
+     * If validation has already been done, trigger it again. This is useful 
when items in the form
+     * have moved to a different location or have been removed. After 
redrawing a possible error message
+     * is shown at the correct field.
+     */
+    private void validateModelObjects() {
+        final EditorPlugin editorPlugin = findParent(EditorPlugin.class);
+        if (editorPlugin != null && editorPlugin.getForm() instanceof 
EditorForm) {
+            final EditorForm editorForm = (EditorForm) editorPlugin.getForm();
+            if (editorForm.hasErrorMessage()) {
+                editorForm.onValidateModelObjects();
+            }
+        }
+    }
 }



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-cms/compare/b51f1ebea03bc6ad6b3eac733d57b12096ad9976...6f1a42eca25addc315b455e34bcb57a1ff62af1c
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to