Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
78880ff
Theme Editor POC CC Style Configs
Jul 21, 2024
bade26c
Fixed minor bug for base error class selector
Jul 21, 2024
0b5925c
Adding style config for hCaptcha and reCaptcha
Jul 22, 2024
773ce01
Updating style for Buttons
Jul 24, 2024
04357dc
Updating style for Footer
Jul 24, 2024
4d03588
Updated style for Checkbox
Jul 24, 2024
02adbca
Updating style for input components
Jul 24, 2024
67bb37d
Updating style for file input
Jul 24, 2024
4084bf8
Updating style for image
Jul 24, 2024
eff155f
Updating style for radio button
Jul 25, 2024
b4a3741
Updating style for switch
Jul 25, 2024
c08cc5c
Updating style for tnc
Jul 25, 2024
7209a63
Updating style for captcha
Jul 25, 2024
f199ed8
Updating style for email and accordion
Jul 25, 2024
0cfd99d
Updating style for wizard
Jul 29, 2024
e0f578a
Updating style for tabsontop
Jul 29, 2024
a142b82
Updating style for vertical tabs
Jul 29, 2024
36a2447
Updating style for panel container
Jul 29, 2024
6e62e32
Updating themeConfig of container
Jul 29, 2024
4b0b690
updating style for base
Jul 29, 2024
0326b4e
Updating ids for theme editor support
Oct 16, 2024
60ae7f0
Updating reference to core components
Oct 17, 2024
43baa18
Clientlib changes
Nov 4, 2024
7ebbe6e
Updating labels for UI
Nov 6, 2024
f6cbbc4
Removing GuideException
Nov 13, 2024
bb81631
Additions in CheckboxGroup style config
Nov 14, 2024
7e4fe2e
Updating VERTICAL and HORIZONTAL classes for checkbox and radiobutton
Nov 21, 2024
7254474
Updating errormessage div styles for components
Nov 21, 2024
4f03dae
Updating error and success states for components
Nov 22, 2024
7d82476
Additional style configs for new components
Oct 28, 2025
f15083f
Adding tests for coverage
Oct 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.adobe.cq.forms.core.components.internal.constants;

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2024 Adobe
~
~ 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.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

public class ThemeConstants {

public static final String RELATIVE_PATH_METADATA = "/metadata";
public static final String THEME_OVERRIDE = "themeOverride";
public static final String THEME_REF = "themeRef";
public static final String PROPERTY_CLIENTLIB_CATEGORY = "clientlibCategory";

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
import java.io.StringWriter;
import java.io.Writer;

import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.SlingObject;
Expand All @@ -28,6 +30,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.adobe.cq.forms.core.components.internal.constants.ThemeConstants;
import com.adobe.cq.forms.core.components.models.form.FormContainer;
import com.adobe.cq.forms.core.components.models.form.FormStructureParser;
import com.adobe.cq.forms.core.components.models.form.HtlUtil;
Expand Down Expand Up @@ -60,6 +63,36 @@ public String getClientLibRefFromFormContainer() {
return getPropertyFromFormContainer(resource, FormContainer.PN_CLIENT_LIB_REF);
}

@Override
public String getThemeClientLibRefFromFormContainer() {
String themeContentPath = null;
String themeClientLibRef = null;
if (request != null) {
themeContentPath = (String) request.getAttribute(ThemeConstants.THEME_OVERRIDE); // theme editor use-case
}
if (StringUtils.isBlank(themeContentPath)) {
if (request != null) {
themeContentPath = request.getParameter(ThemeConstants.THEME_OVERRIDE); // embed component use-case
}
if (StringUtils.isBlank(themeContentPath)) {
themeContentPath = getPropertyFromFormContainer(resource, ThemeConstants.THEME_REF); // normal including theme in form
// runtime
}
}
// get client library from theme content path
if (StringUtils.isNotBlank(themeContentPath)) {
Resource themeResource = resource.getResourceResolver().getResource(themeContentPath + ThemeConstants.RELATIVE_PATH_METADATA);
if (themeResource != null) {
ValueMap themeProps = themeResource.getValueMap();
themeClientLibRef = themeProps.get(ThemeConstants.PROPERTY_CLIENTLIB_CATEGORY, "");
} else {
logger.error("Invalid Theme Name {}", themeContentPath);
}
}

return themeClientLibRef;
}

@Override
public Boolean containsFormContainer() {
return containsFormContainer(resource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ public interface FormStructureParser {
*/
String getClientLibRefFromFormContainer();

/**
*
* @returns reference to the client lib of the theme from form container
*/
String getThemeClientLibRefFromFormContainer();

/**
* Checks if this resource contains a form container
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.junit.jupiter.api.extension.ExtendWith;

import com.adobe.cq.export.json.SlingModelFilter;
import com.adobe.cq.forms.core.components.internal.constants.ThemeConstants;
import com.adobe.cq.forms.core.components.internal.form.FormConstants;
import com.adobe.cq.forms.core.components.models.form.*;
import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext;
Expand Down Expand Up @@ -179,6 +180,67 @@ public void containsFormContainer_should_return_false() {
assertFalse(result);
}

@Test
void testGetThemeClientLibRefFromFormContainer() {
String path = CONTENT_ROOT + "/myTestPage";
FormStructureParser formStructureParser = getFormStructureParserUnderTest(path);
String themeClientLibRef = formStructureParser.getThemeClientLibRefFromFormContainer();
assertEquals("fdtheme.test-theme", themeClientLibRef);
}

@Test
void testGetThemeClientLibRefWithRequestAttribute() {
String path = CONTENT_ROOT + "/myTestPage";
context.currentResource(path);
MockSlingHttpServletRequest request = context.request();
request.setAttribute(ThemeConstants.THEME_OVERRIDE, "/content/dam/formsanddocuments-themes/test-theme");
FormStructureParser formStructureParser = request.adaptTo(FormStructureParser.class);
String themeClientLibRef = formStructureParser.getThemeClientLibRefFromFormContainer();
assertEquals("fdtheme.test-theme", themeClientLibRef);
}

@Test
void testGetThemeClientLibRefWithRequestParameter() {
String path = CONTENT_ROOT + "/myTestPage";
context.currentResource(path);
MockSlingHttpServletRequest request = context.request();
request.setParameterMap(Collections.singletonMap(ThemeConstants.THEME_OVERRIDE,
"/content/dam/formsanddocuments-themes/test-theme"));
FormStructureParser formStructureParser = request.adaptTo(FormStructureParser.class);
String themeClientLibRef = formStructureParser.getThemeClientLibRefFromFormContainer();
assertEquals("fdtheme.test-theme", themeClientLibRef);
}

@Test
void testGetThemeClientLibRefWithInvalidThemePath() {
String path = CONTENT_ROOT + "/myTestPage";
context.currentResource(path);
MockSlingHttpServletRequest request = context.request();
request.setAttribute(ThemeConstants.THEME_OVERRIDE, "/content/dam/formsanddocuments-themes/invalid-theme");
FormStructureParser formStructureParser = request.adaptTo(FormStructureParser.class);
String themeClientLibRef = formStructureParser.getThemeClientLibRefFromFormContainer();
assertNull(themeClientLibRef);
}

@Test
void testGetThemeClientLibRefWithNonExistentTheme() {
String path = CONTENT_ROOT + "/myTestPage";
context.currentResource(path);
MockSlingHttpServletRequest request = context.request();
request.setAttribute(ThemeConstants.THEME_OVERRIDE, "/content/dam/formsanddocuments-themes/non-existent");
FormStructureParser formStructureParser = request.adaptTo(FormStructureParser.class);
String themeClientLibRef = formStructureParser.getThemeClientLibRefFromFormContainer();
assertNull(themeClientLibRef);
}

@Test
void testGetThemeClientLibRefWithoutTheme() {
String path = FORM_CONTAINER_PATH + "/container1";
FormStructureParser formStructureParser = getFormStructureParserUnderTest(path);
String themeClientLibRef = formStructureParser.getThemeClientLibRefFromFormContainer();
assertNull(themeClientLibRef);
}

private FormStructureParser getFormStructureParserUnderTest(String resourcePath) {
context.currentResource(resourcePath);
MockSlingHttpServletRequest request = context.request();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"thankyouPage": "/a/b/c",
"thankyouMessage": "message",
"clientLibRef" : "abc",
"themeRef": "/content/dam/formsanddocuments-themes/test-theme",
"datepicker": {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType": "core/fd/components/form/datepicker/v1/datepicker",
Expand Down Expand Up @@ -88,5 +89,27 @@
}
}
}
},
"dam": {
"jcr:primaryType": "nt:unstructured",
"formsanddocuments-themes": {
"jcr:primaryType": "nt:unstructured",
"test-theme": {
"jcr:primaryType": "nt:unstructured",
"jcr:content": {
"jcr:primaryType": "dam:AssetContent",
"metadata": {
"jcr:primaryType": "nt:unstructured",
"clientlibCategory": "fdtheme.test-theme"
}
}
},
"invalid-theme": {
"jcr:primaryType": "nt:unstructured",
"jcr:content": {
"jcr:primaryType": "dam:AssetContent"
}
}
}
}
}
Loading