You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2019/07/25 19:19:24 UTC
[sling-org-apache-sling-app-cms] branch dklco/form-framework
updated (65d808b -> 7b38bf0)
This is an automated email from the ASF dual-hosted git repository.
dklco pushed a change to branch dklco/form-framework
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git.
from 65d808b Fixing issue with the parent path for the policy query
new 150c5f5 Adding component annotation to textarea
new 87d298d Adding a class configuration for the alert
new 7b38bf0 Adding the ability to have components reload the page rather than reloading in context
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
api/src/main/java/org/apache/sling/cms/Component.java | 11 +++++++++--
.../sling/cms/core/internal/filters/EditIncludeFilter.java | 13 ++++++-------
.../sling/cms/core/internal/models/ComponentImpl.java | 10 ++++++++++
.../cms/reference/forms/impl/fields/TextareaHandler.java | 2 ++
.../apps/reference/components/forms/actions/sendemail.json | 3 ++-
.../reference/components/forms/actions/updateprofile.json | 3 ++-
.../apps/reference/components/forms/fields/selection.json | 3 ++-
.../apps/reference/components/forms/fields/textarea.json | 3 ++-
.../apps/reference/components/forms/fields/textfield.json | 3 ++-
.../jcr_root/apps/reference/components/forms/fieldset.json | 3 ++-
.../apps/reference/components/forms/form/config.json | 7 +++++++
.../jcr_root/apps/reference/components/forms/form/form.jsp | 12 +++++++++---
.../reference/components/forms/providers/userprofile.json | 3 ++-
ui/src/main/frontend/src/js/editor.js | 8 ++++++--
14 files changed, 63 insertions(+), 21 deletions(-)
[sling-org-apache-sling-app-cms] 01/03: Adding component annotation
to textarea
Posted by dk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dklco pushed a commit to branch dklco/form-framework
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git
commit 150c5f5cb4cd9f9a93c4484e5416294374918600
Author: Dan Klco <dk...@apache.org>
AuthorDate: Thu Jul 25 14:50:43 2019 -0400
Adding component annotation to textarea
---
.../apache/sling/cms/reference/forms/impl/fields/TextareaHandler.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/reference/src/main/java/org/apache/sling/cms/reference/forms/impl/fields/TextareaHandler.java b/reference/src/main/java/org/apache/sling/cms/reference/forms/impl/fields/TextareaHandler.java
index 26b0036..0b27346 100644
--- a/reference/src/main/java/org/apache/sling/cms/reference/forms/impl/fields/TextareaHandler.java
+++ b/reference/src/main/java/org/apache/sling/cms/reference/forms/impl/fields/TextareaHandler.java
@@ -23,9 +23,11 @@ import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.cms.reference.forms.FieldHandler;
import org.apache.sling.cms.reference.forms.FormException;
+import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@Component(service = FieldHandler.class)
public class TextareaHandler implements FieldHandler {
private static final Logger log = LoggerFactory.getLogger(TextareaHandler.class);
[sling-org-apache-sling-app-cms] 03/03: Adding the ability to have
components reload the page rather than reloading in context
Posted by dk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dklco pushed a commit to branch dklco/form-framework
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git
commit 7b38bf025df95dedd352418483b0b8dae72a7c8f
Author: Dan Klco <dk...@apache.org>
AuthorDate: Thu Jul 25 15:19:17 2019 -0400
Adding the ability to have components reload the page rather than
reloading in context
---
api/src/main/java/org/apache/sling/cms/Component.java | 11 +++++++++--
.../sling/cms/core/internal/filters/EditIncludeFilter.java | 13 ++++++-------
.../sling/cms/core/internal/models/ComponentImpl.java | 10 ++++++++++
.../apps/reference/components/forms/actions/sendemail.json | 3 ++-
.../reference/components/forms/actions/updateprofile.json | 3 ++-
.../apps/reference/components/forms/fields/selection.json | 3 ++-
.../apps/reference/components/forms/fields/textarea.json | 3 ++-
.../apps/reference/components/forms/fields/textfield.json | 3 ++-
.../jcr_root/apps/reference/components/forms/fieldset.json | 3 ++-
.../reference/components/forms/providers/userprofile.json | 3 ++-
ui/src/main/frontend/src/js/editor.js | 8 ++++++--
11 files changed, 45 insertions(+), 18 deletions(-)
diff --git a/api/src/main/java/org/apache/sling/cms/Component.java b/api/src/main/java/org/apache/sling/cms/Component.java
index c8cd9c4..bc92b22 100644
--- a/api/src/main/java/org/apache/sling/cms/Component.java
+++ b/api/src/main/java/org/apache/sling/cms/Component.java
@@ -61,15 +61,22 @@ public interface Component {
* @return the title
*/
String getTitle();
-
+
/**
- * True if the component is editable, false otherwise.
+ * True if the component is editable, false otherwise.
*
* @return the editable flag
*/
boolean isEditable();
/**
+ * Returns true if the the property reloadPage is set to true.
+ *
+ * @return true if page should be reloaded when the component is saved
+ */
+ boolean isReloadPage();
+
+ /**
* Returns true if the only component type on the component is the specified
* type.
*
diff --git a/core/src/main/java/org/apache/sling/cms/core/internal/filters/EditIncludeFilter.java b/core/src/main/java/org/apache/sling/cms/core/internal/filters/EditIncludeFilter.java
index 2527f10..6611291 100644
--- a/core/src/main/java/org/apache/sling/cms/core/internal/filters/EditIncludeFilter.java
+++ b/core/src/main/java/org/apache/sling/cms/core/internal/filters/EditIncludeFilter.java
@@ -118,10 +118,11 @@ public class EditIncludeFilter implements Filter {
String editPath = component.getEditPath();
String title = StringUtils.isNotEmpty(component.getTitle()) ? component.getTitle()
: StringUtils.substringAfterLast(resource.getResourceType(), "/");
- writer.write("<div class=\"sling-cms-component\" data-component=\"" + component.getResource().getPath()
- + "\" data-sling-cms-title=\"" + title + "\" data-sling-cms-resource-path=\"" + resource.getPath()
- + "\" data-sling-cms-resource-type=\"" + resource.getResourceType() + "\" data-sling-cms-edit=\""
- + editPath + "\"><div class=\"sling-cms-editor\">");
+ writer.write("<div class=\"sling-cms-component\" data-reload=\"" + component.isReloadPage()
+ + "\" data-component=\"" + component.getResource().getPath() + "\" data-sling-cms-title=\"" + title
+ + "\" data-sling-cms-resource-path=\"" + resource.getPath() + "\" data-sling-cms-resource-type=\""
+ + resource.getResourceType() + "\" data-sling-cms-edit=\"" + editPath
+ + "\"><div class=\"sling-cms-editor\">");
writer.write(
"<div class=\"level has-background-grey\"><div class=\"level-left\"><div class=\"field has-addons\">");
@@ -156,7 +157,6 @@ public class EditIncludeFilter implements Filter {
editPath = component.getEditPath();
}
-
if (StringUtils.isNotEmpty(editPath)) {
includeEnd = true;
writeEditorMarkup(resource, writer);
@@ -168,8 +168,7 @@ public class EditIncludeFilter implements Filter {
}
writer.write("<div class=\"sling-cms-component\" data-sling-cms-title=\""
+ (component != null ? component.getTitle() : "") + "\" data-sling-cms-resource-path=\""
- + resource.getPath() + "\" data-sling-cms-resource-type=\"" + resource.getResourceType()
- + "\">");
+ + resource.getPath() + "\" data-sling-cms-resource-type=\"" + resource.getResourceType() + "\">");
}
return includeEnd;
}
diff --git a/core/src/main/java/org/apache/sling/cms/core/internal/models/ComponentImpl.java b/core/src/main/java/org/apache/sling/cms/core/internal/models/ComponentImpl.java
index 9a76cab..26154d9 100644
--- a/core/src/main/java/org/apache/sling/cms/core/internal/models/ComponentImpl.java
+++ b/core/src/main/java/org/apache/sling/cms/core/internal/models/ComponentImpl.java
@@ -43,6 +43,11 @@ public class ComponentImpl implements Component {
@Default(booleanValues = true)
private boolean editable;
+ @Inject
+ @Optional
+ @Default(booleanValues = false)
+ private boolean reloadPage;
+
private Resource resource;
@Inject
@@ -161,6 +166,11 @@ public class ComponentImpl implements Component {
return editable;
}
+ @Override
+ public boolean isReloadPage() {
+ return reloadPage;
+ }
+
/**
* Returns true if the only component type on the component is the specified
* type.
diff --git a/reference/src/main/resources/jcr_root/apps/reference/components/forms/actions/sendemail.json b/reference/src/main/resources/jcr_root/apps/reference/components/forms/actions/sendemail.json
index 2f8e0ad..efe3d7b 100644
--- a/reference/src/main/resources/jcr_root/apps/reference/components/forms/actions/sendemail.json
+++ b/reference/src/main/resources/jcr_root/apps/reference/components/forms/actions/sendemail.json
@@ -1,5 +1,6 @@
{
"jcr:primaryType" : "sling:Component",
"jcr:title": "Email",
- "componentType": "Form Action"
+ "componentType": "Form Action",
+ "reloadPage": true
}
\ No newline at end of file
diff --git a/reference/src/main/resources/jcr_root/apps/reference/components/forms/actions/updateprofile.json b/reference/src/main/resources/jcr_root/apps/reference/components/forms/actions/updateprofile.json
index 8549c19..fc11fd1 100644
--- a/reference/src/main/resources/jcr_root/apps/reference/components/forms/actions/updateprofile.json
+++ b/reference/src/main/resources/jcr_root/apps/reference/components/forms/actions/updateprofile.json
@@ -1,5 +1,6 @@
{
"jcr:primaryType" : "sling:Component",
"jcr:title": "Update Profile",
- "componentType": "Form Action"
+ "componentType": "Form Action",
+ "reloadPage": true
}
\ No newline at end of file
diff --git a/reference/src/main/resources/jcr_root/apps/reference/components/forms/fields/selection.json b/reference/src/main/resources/jcr_root/apps/reference/components/forms/fields/selection.json
index d3f03c2..341d4a1 100644
--- a/reference/src/main/resources/jcr_root/apps/reference/components/forms/fields/selection.json
+++ b/reference/src/main/resources/jcr_root/apps/reference/components/forms/fields/selection.json
@@ -1,5 +1,6 @@
{
"jcr:primaryType" : "sling:Component",
"jcr:title": "Selection",
- "componentType": "Form Field"
+ "componentType": "Form Field",
+ "reloadPage": true
}
\ No newline at end of file
diff --git a/reference/src/main/resources/jcr_root/apps/reference/components/forms/fields/textarea.json b/reference/src/main/resources/jcr_root/apps/reference/components/forms/fields/textarea.json
index d9c86e4..0722adc 100644
--- a/reference/src/main/resources/jcr_root/apps/reference/components/forms/fields/textarea.json
+++ b/reference/src/main/resources/jcr_root/apps/reference/components/forms/fields/textarea.json
@@ -1,5 +1,6 @@
{
"jcr:primaryType" : "sling:Component",
"jcr:title": "Textarea",
- "componentType": "Form Field"
+ "componentType": "Form Field",
+ "reloadPage": true
}
\ No newline at end of file
diff --git a/reference/src/main/resources/jcr_root/apps/reference/components/forms/fields/textfield.json b/reference/src/main/resources/jcr_root/apps/reference/components/forms/fields/textfield.json
index c2976c7..7cb2186 100644
--- a/reference/src/main/resources/jcr_root/apps/reference/components/forms/fields/textfield.json
+++ b/reference/src/main/resources/jcr_root/apps/reference/components/forms/fields/textfield.json
@@ -1,5 +1,6 @@
{
"jcr:primaryType" : "sling:Component",
"jcr:title": "Text Field",
- "componentType": "Form Field"
+ "componentType": "Form Field",
+ "reloadPage": true
}
\ No newline at end of file
diff --git a/reference/src/main/resources/jcr_root/apps/reference/components/forms/fieldset.json b/reference/src/main/resources/jcr_root/apps/reference/components/forms/fieldset.json
index 5d40038..3926e8d 100644
--- a/reference/src/main/resources/jcr_root/apps/reference/components/forms/fieldset.json
+++ b/reference/src/main/resources/jcr_root/apps/reference/components/forms/fieldset.json
@@ -1,5 +1,6 @@
{
"jcr:primaryType" : "sling:Component",
"jcr:title": "Fieldset",
- "componentType": "Form Field"
+ "componentType": "Form Field",
+ "reloadPage": true
}
\ No newline at end of file
diff --git a/reference/src/main/resources/jcr_root/apps/reference/components/forms/providers/userprofile.json b/reference/src/main/resources/jcr_root/apps/reference/components/forms/providers/userprofile.json
index 3be98ba..eda95b0 100644
--- a/reference/src/main/resources/jcr_root/apps/reference/components/forms/providers/userprofile.json
+++ b/reference/src/main/resources/jcr_root/apps/reference/components/forms/providers/userprofile.json
@@ -1,5 +1,6 @@
{
"jcr:primaryType" : "sling:Component",
"jcr:title": "User Profile",
- "componentType": "Form Value Provider"
+ "componentType": "Form Value Provider",
+ "reloadPage": true
}
\ No newline at end of file
diff --git a/ui/src/main/frontend/src/js/editor.js b/ui/src/main/frontend/src/js/editor.js
index abd30b0..a21570f 100644
--- a/ui/src/main/frontend/src/js/editor.js
+++ b/ui/src/main/frontend/src/js/editor.js
@@ -80,14 +80,18 @@
}
},
reloadComponent: function (path, cb) {
- var component = document.querySelector('.sling-cms-component[data-sling-cms-resource-path="' + path + '"]');
+ var component = document.querySelector('.sling-cms-component[data-sling-cms-resource-path="' + path + '"]'),
+ reloadPage = component.dataset.reload === 'true';
while (!component && path.length > 1) {
var pathArr = path.split('\/');
pathArr.pop();
path = pathArr.join('/');
component = document.querySelector('.sling-cms-component[data-sling-cms-resource-path="' + path + '"]');
+ if(component.dataset.reload === 'true') {
+ reloadPage = true;
+ }
}
- if (!component) {
+ if (!component || reloadPage) {
CMSEditor.ui.hideModal();
window.top.location.reload();
}
[sling-org-apache-sling-app-cms] 02/03: Adding a class
configuration for the alert
Posted by dk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dklco pushed a commit to branch dklco/form-framework
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git
commit 87d298d6a3ed5ffcb7ddf7f08cef6f251febcbec
Author: Dan Klco <dk...@apache.org>
AuthorDate: Thu Jul 25 14:52:13 2019 -0400
Adding a class configuration for the alert
---
.../apps/reference/components/forms/form/config.json | 7 +++++++
.../jcr_root/apps/reference/components/forms/form/form.jsp | 12 +++++++++---
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/reference/src/main/resources/jcr_root/apps/reference/components/forms/form/config.json b/reference/src/main/resources/jcr_root/apps/reference/components/forms/form/config.json
index 18de6cb..9644259 100644
--- a/reference/src/main/resources/jcr_root/apps/reference/components/forms/form/config.json
+++ b/reference/src/main/resources/jcr_root/apps/reference/components/forms/form/config.json
@@ -15,6 +15,13 @@
"name": "submitClass",
"type": "text"
},
+ "alertClass": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "sling-cms/components/editor/fields/text",
+ "label": "Alert Class",
+ "name": "alertClass",
+ "type": "text"
+ },
"fieldClass": {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType": "sling-cms/components/editor/fields/text",
diff --git a/reference/src/main/resources/jcr_root/apps/reference/components/forms/form/form.jsp b/reference/src/main/resources/jcr_root/apps/reference/components/forms/form/form.jsp
index dc55367..c997126 100644
--- a/reference/src/main/resources/jcr_root/apps/reference/components/forms/form/form.jsp
+++ b/reference/src/main/resources/jcr_root/apps/reference/components/forms/form/form.jsp
@@ -21,13 +21,19 @@
<c:set var="formData" value="${sling:adaptTo(slingRequest,'org.apache.sling.cms.reference.forms.FormRequest').formData}" scope="request" />
<form class="${formConfig.formClass}" action="${resource.path}.allowpost.html" method="post" data-analytics-id="${sling:encode(properties.formId,'HTML_ATTR')}">
<c:if test="${param.message == 'success'}">
- ${properties.successMessage}
+ <div class="${formConfig.alertClass}">
+ ${properties.successMessage}
+ </div>
</c:if>
<c:if test="${param.error == 'actions'}">
- ${properties.actionsErrorMessage}
+ <div class="${formConfig.alertClass}">
+ ${properties.actionsErrorMessage}
+ </div>
</c:if>
<c:if test="${param.error == 'fields'}">
- ${properties.fieldsErrorMessage}
+ <div class="${formConfig.alertClass}">
+ ${properties.fieldsErrorMessage}
+ </div>
</c:if>
<c:set var="oldAvailableTypes" value="${availableTypes}" />