Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eds semantic html without a separate selector #1194

Merged
merged 22 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d1ac8dc
added changes to publish semantic html of form from container[FormCon…
Apr 16, 2024
038043b
added test case to verify formDefinition api....
Apr 16, 2024
3d3bd99
added test case to verify formDefinition api....
Apr 16, 2024
f1063aa
updated the license header of body file...
Apr 22, 2024
ef14c68
added changes to publish semantic html of form from container[FormCon…
Apr 16, 2024
0e872ab
added test case to verify formDefinition api....
Apr 16, 2024
3aac04d
added test case to verify formDefinition api....
Apr 16, 2024
254b89a
updated the license header of body file...
Apr 22, 2024
60a299a
created a new version of page component.....
Apr 25, 2024
a73233c
Merge branch 'FormContainerEds' of https://github.com/adobe/aem-core-…
Apr 25, 2024
9d478c1
added a Utils file to move certain logic out of FormContainer sling m…
Apr 30, 2024
deb1ea7
added test cases for FormUtil class and getFormDef api..
Apr 30, 2024
d7e9474
made changes to remove style elements from container proxy...
May 2, 2024
1c50447
Merge branch 'dev' into FormContainerEds
May 2, 2024
8bd84d7
made changes to remove style elements from container proxy...
May 2, 2024
136b965
removed body html from v1 of page..
May 2, 2024
aca88b9
added README for page comp and bumped up minor version of the package…
May 2, 2024
04527a8
added java doc for the isEdgeDeliveryRequest api...
May 2, 2024
7873513
added test cases for v2 version of page component....
May 3, 2024
331b24e
added test cases for v2 version of page component....
May 3, 2024
c8fd6cb
merged dev branch to FormContainerEds....
May 7, 2024
3847748
made suggested review changes.......
May 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -15,6 +15,9 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package com.adobe.cq.forms.core.components.internal.models.v2.form;

import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Consumer;
Expand All @@ -32,6 +35,8 @@
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.adobe.aemds.guide.common.GuideContainer;
import com.adobe.aemds.guide.service.GuideSchemaType;
Expand All @@ -50,10 +55,12 @@
import com.adobe.cq.forms.core.components.models.form.ThankYouOption;
import com.adobe.cq.forms.core.components.util.AbstractContainerImpl;
import com.adobe.cq.forms.core.components.util.ComponentUtils;
import com.adobe.cq.forms.core.components.views.Views;
import com.day.cq.commons.LanguageUtil;
import com.day.cq.wcm.api.Page;
import com.day.cq.wcm.api.PageManager;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.ObjectMapper;

@Model(
adaptables = { SlingHttpServletRequest.class, Resource.class },
Expand All @@ -63,6 +70,7 @@
public class FormContainerImpl extends AbstractContainerImpl implements FormContainer {
protected static final String RESOURCE_TYPE = "core/fd/components/form/container/v2/container";

private static final Logger logger = LoggerFactory.getLogger(FormContainerImpl.class);
private static final String DOR_TYPE = "dorType";
private static final String DOR_TEMPLATE_REF = "dorTemplateRef";
private static final String DOR_TEMPLATE_TYPE = "dorTemplateType";
Expand Down Expand Up @@ -359,4 +367,33 @@
return FormContainer.super.getName();
}

@JsonIgnore
public String getFormDefinition() {
String result = null;

Check warning on line 372 in bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImpl.java

View check run for this annotation

Codecov / codecov/patch

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImpl.java#L372

Added line #L372 was not covered by tests
try {
deepprakash345 marked this conversation as resolved.
Show resolved Hide resolved
ObjectMapper mapper = new ObjectMapper();
Writer writer = new StringWriter();

Check warning on line 375 in bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImpl.java

View check run for this annotation

Codecov / codecov/patch

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImpl.java#L374-L375

Added lines #L374 - L375 were not covered by tests
// return publish view specific properties only for runtime
mapper.writerWithView(Views.Publish.class).writeValue(writer, this);
result = writer.toString();
} catch (IOException e) {
logger.error("Unable to generate json from resource");
}
return result;

Check warning on line 382 in bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImpl.java

View check run for this annotation

Codecov / codecov/patch

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImpl.java#L377-L382

Added lines #L377 - L382 were not covered by tests
}

@Override
@Nullable
@JsonIgnore
public Boolean isEdgeDeliveryRequest() {
deepprakash345 marked this conversation as resolved.
Show resolved Hide resolved
if (request != null) {
Object isEdgeDelivery = request.getAttribute("com.adobe.aem.wcm.franklin.internal.servlets.FranklinDeliveryServlet");
Boolean res = true;
if (isEdgeDelivery == null || isEdgeDelivery.equals(Boolean.FALSE)) {
res = false;
}
return res;
}
return false;

Check warning on line 397 in bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImpl.java

View check run for this annotation

Codecov / codecov/patch

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImpl.java#L397

Added line #L397 was not covered by tests
}
}
Expand Up @@ -363,4 +363,20 @@
return null;
}

@JsonIgnore
default String getFormDefinition() {
return null;

Check warning on line 368 in bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormContainer.java

View check run for this annotation

Codecov / codecov/patch

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormContainer.java#L368

Added line #L368 was not covered by tests
}

/**
* Returns whether this request is originating from edge delivery.
*
* @return whether this request is originating from edge delivery
* @since com.adobe.cq.forms.core.components.models.form 5.3.0
*/
@Nullable
@JsonIgnore
default Boolean isEdgeDeliveryRequest() {
return null;

Check warning on line 380 in bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormContainer.java

View check run for this annotation

Codecov / codecov/patch

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormContainer.java#L380

Added line #L380 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use boolean primitive and return false by default

deepprakash345 marked this conversation as resolved.
Show resolved Hide resolved
}
}
Expand Up @@ -230,6 +230,22 @@ void testGetThankYouMessage() throws Exception {
assertEquals("Thank you for submitting.", formContainer.getThankYouMessage());
}

@Test
void testGetIsEdgeDeliveryRequest() throws Exception {
deepprakash345 marked this conversation as resolved.
Show resolved Hide resolved
FormContainer formContainer = Utils.getComponentUnderTest(PATH_FORM_1, FormContainer.class, context);
MockSlingHttpServletRequest request = context.request();
request.setAttribute("com.adobe.aem.wcm.franklin.internal.servlets.FranklinDeliveryServlet", false);
assertFalse(formContainer.isEdgeDeliveryRequest());
}

@Test
void testGetIsEdgeDeliveryRequestTrue() throws Exception {
FormContainer formContainer = Utils.getComponentUnderTest(PATH_FORM_1, FormContainer.class, context);
MockSlingHttpServletRequest request = context.request();
request.setAttribute("com.adobe.aem.wcm.franklin.internal.servlets.FranklinDeliveryServlet", true);
assertTrue(formContainer.isEdgeDeliveryRequest());
}

@Test
void testGetThankYouOption() throws Exception {
FormContainer formContainer = Utils.getComponentUnderTest(PATH_FORM_1, FormContainer.class, context);
Expand Down
Expand Up @@ -4,4 +4,5 @@
jcr:title="Adaptive Form Container"
jcr:description="Add an Adaptive Form to a page."
sling:resourceSuperType="core/fd/components/form/container/v2/container"
cq:styleElements="[div,section,article,main,aside,header,footer]"
deepprakash345 marked this conversation as resolved.
Show resolved Hide resolved
componentGroup="Core Components Examples - Adaptive Form"/>
Expand Up @@ -13,9 +13,19 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->

<div class="form" data-sly-use.container="com.adobe.cq.forms.core.components.models.form.FormContainer" data-sly-test.isEdgeDeliveryRequest="${container.edgeDeliveryRequest}">
<div>
<div>
<pre>
<code>${container.formDefinition}</code>
</pre>
</div>
</div>
</div>
<sly data-sly-test="${!isEdgeDeliveryRequest}">
<sly data-sly-test="${wcmmode.edit}" data-sly-use.allowed="com.day.cq.wcm.foundation.AllowedComponentList"></sly>
<form data-sly-use.container="com.adobe.cq.forms.core.components.models.form.FormContainer"
data-sly-use.grid="com.day.cq.wcm.foundation.model.responsivegrid.ResponsiveGrid"
<form data-sly-use.grid="com.day.cq.wcm.foundation.model.responsivegrid.ResponsiveGrid"
deepprakash345 marked this conversation as resolved.
Show resolved Hide resolved
data-sly-use.templates="core/wcm/components/commons/v1/templates.html"
action="${container.metadata.action}"
id="${container.id}"
Expand Down Expand Up @@ -43,3 +53,4 @@
</div>
</form>
<div data-cmp-adaptiveform-container-loader="${container.id}"></div>
</sly>
@@ -0,0 +1,21 @@
<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2021 Adobe
deepprakash345 marked this conversation as resolved.
Show resolved Hide resolved
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->

<main>
<sly data-sly-use.templatedContainer="com.day.cq.wcm.foundation.TemplatedContainer"
data-sly-repeat.child="${templatedContainer.structureResources}"
data-sly-resource="${child.path @ resourceType=child.resourceType, decorationTagName='div'}"></sly>
deepprakash345 marked this conversation as resolved.
Show resolved Hide resolved
</main>