diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/form/FormConstants.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/form/FormConstants.java
index 01bbc23604..6ecdd327c3 100644
--- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/form/FormConstants.java
+++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/form/FormConstants.java
@@ -108,6 +108,9 @@ private FormConstants() {
public static final String RT_FD_FRAGMENT_CONTAINER_V1 = RT_FD_FORM_PREFIX + "fragmentcontainer/v1/fragmentcontainer";
+ /** The resource type for terms and conditions v1 */
+ public static final String RT_FD_FORM_TERMS_AND_CONDITIONS_V1 = RT_FD_FORM_PREFIX + "termsandconditions/v1/termsandconditions";
+
public static final String FORM_FIELD_TYPE = "form";
public static final String REQ_ATTR_FORMCONTAINER_PATH = "formContainerPath";
diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TermsAndConditionsImpl.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TermsAndConditionsImpl.java
new file mode 100644
index 0000000000..63a81cc98c
--- /dev/null
+++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TermsAndConditionsImpl.java
@@ -0,0 +1,107 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ Copyright 2023 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.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+package com.adobe.cq.forms.core.components.internal.models.v1.form;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.models.annotations.Default;
+import org.apache.sling.models.annotations.Exporter;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
+import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
+import org.jetbrains.annotations.NotNull;
+
+import com.adobe.cq.export.json.ComponentExporter;
+import com.adobe.cq.export.json.ExporterConstants;
+import com.adobe.cq.forms.core.components.internal.form.FormConstants;
+import com.adobe.cq.forms.core.components.models.form.FieldType;
+import com.adobe.cq.forms.core.components.models.form.TermsAndConditions;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+@Model(
+ adaptables = { SlingHttpServletRequest.class, Resource.class },
+ adapters = { TermsAndConditions.class,
+ ComponentExporter.class },
+ resourceType = { FormConstants.RT_FD_FORM_TERMS_AND_CONDITIONS_V1 })
+
+@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
+public class TermsAndConditionsImpl extends PanelImpl implements TermsAndConditions {
+
+ private static final String CUSTOM_TNC_PROPERTY = "fd:tnc";
+
+ private static final String FIELD_TYPE = "fieldType";
+
+ @JsonIgnore
+ @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
+ @Default(booleanValues = true)
+ private boolean showApprovalOption;
+
+ @JsonIgnore
+ @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
+ @Default(booleanValues = false)
+ private boolean showLink;
+
+ @JsonIgnore
+ @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
+ @Default(booleanValues = false)
+ private boolean showAsPopup;
+
+ @Override
+ public boolean isShowApprovalOption() {
+ return showApprovalOption;
+ }
+
+ @Override
+ public boolean isShowLink() {
+ return showLink;
+ }
+
+ @Override
+ public boolean isShowAsPopup() {
+ return showAsPopup;
+ }
+
+ @Override
+ public @NotNull String getId() {
+ return super.getId();
+ }
+
+ @Override
+ public @NotNull Map getProperties() {
+ Map properties = super.getProperties();
+ if (resource.getValueMap().containsKey(CUSTOM_TNC_PROPERTY)) {
+ properties.put(CUSTOM_TNC_PROPERTY, true);
+ }
+ return properties;
+ }
+
+ @Override
+ protected List getFilteredChildrenResources() {
+ List childResources = getFilteredChildrenResources(resource);
+ // the tnc component will either have links or consent text based upon showLink value
+ if (showLink) {
+ childResources.removeIf(child -> FieldType.PLAIN_TEXT.getValue().equals(child.getValueMap().get(FIELD_TYPE)));
+
+ } else {
+ childResources.removeIf(child -> FieldType.CHECKBOX_GROUP.getValue().equals(child.getValueMap().get(FIELD_TYPE)));
+ }
+ return childResources;
+ }
+}
diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/TermsAndConditions.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/TermsAndConditions.java
new file mode 100644
index 0000000000..957877b9b2
--- /dev/null
+++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/TermsAndConditions.java
@@ -0,0 +1,50 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ Copyright 2023 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.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+package com.adobe.cq.forms.core.components.models.form;
+
+import org.osgi.annotation.versioning.ConsumerType;
+
+/**
+ * Defines the form {@code TermsAndConditions} Sling Model used for the
+ * {@code /apps/core/fd/components/form/termsandconditions/v1/termsandconditions} component.
+ *
+ * @since com.adobe.cq.forms.core.components.models.form 4.7.0
+ */
+@ConsumerType
+public interface TermsAndConditions extends Container, ContainerConstraint {
+
+ String FD_TERMS_AND_CONDITIONS = "fd:tnc";
+
+ /**
+ *
+ * @return {@code true} if approval checkbox should be shown, otherwise {@code false}
+ */
+ boolean isShowApprovalOption();
+
+ /**
+ *
+ * @return {@code true} if links to external Terms & Conditions pages are to be shown, otherwise
+ * {@code false if consent text is to be shown}
+ */
+ boolean isShowLink();
+
+ /**
+ *
+ * @return @return {@code true} if the content is to be shown as pop-up , otherwise {@code false}
+ */
+ boolean isShowAsPopup();
+}
diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java
index ff809fcbdc..1aacc8966b 100644
--- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java
+++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java
@@ -34,7 +34,7 @@
* version, is bound to this proxy component resource type.
*
+
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/.content.xml
new file mode 100644
index 0000000000..491392d539
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/.content.xml
@@ -0,0 +1,3 @@
+
+
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/.content.xml
new file mode 100644
index 0000000000..5e25fbe65e
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/.content.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/.content.xml
new file mode 100644
index 0000000000..b18110bf47
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/.content.xml
@@ -0,0 +1,24 @@
+
+
+
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/README.md b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/README.md
new file mode 100644
index 0000000000..94fee3b1f4
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/README.md
@@ -0,0 +1,85 @@
+
+Adaptive Form Terms and Conditions (v1)
+====
+Adaptive Form Terms and Components field component written in HTL.
+
+## Features
+
+* It is composed of Text Field, CheckBox and CheckBox Groups
+* Allows to author a Terms & Conditions component with either links or Texts.
+* Comes with some OOTB behaviour like
+ * Approval Checkbox is not enabled if the text-area is scrollable and user has not scrolled to the bottom
+ * Approval Checkbox is not enabled if TnC uses Links and user has not visited all the links
+
+### Use Object
+The Form Text component uses the `com.adobe.cq.forms.core.components.models.form.TermsAndConditions` Sling Model for its Use-object.
+
+### Edit Dialog Properties
+The following properties are written to JCR for this Form Text component and are expected to be available as `Resource` properties:
+
+1. `./jcr:title` - defines the label to use for this field
+2. `./hideTitle` - if set to `true`, the label of this field will be hidden
+3. `./name` - defines the name of the field, which will be submitted with the form data
+4. `./default` - defines the default value of the field
+5. `./description` - defines a help message that can be rendered in the field as a hint for the user
+6. `./required` - if set to `true`, this field will be marked as required, not allowing the form to be submitted until the field has a value
+7. `./requiredMessage` - defines the message displayed as tooltip when submitting the form if the value is left empty
+8. `./readOnly` - if set to `true`, the filed will be read only
+9. `./showApprovalOption` - whether to show the approval checkbox or not
+10. `./showLink` - whether to show links instead of Text Content
+11. `./showAsPopup` - whether to show the TNC content as a Modal
+
+## Client Libraries
+The component provides a `core.forms.components.termsandconditions.v1.runtime` client library category that contains the Javascript runtime for the component.
+It should be added to a relevant site client library using the `embed` property.
+
+It also provides a `core.forms.components.termsandconditions.v1.editor` editor client library category that includes
+JavaScript handling for dialog interaction. It is already included by its edit dialog.
+
+## BEM Description
+```
+BLOCK cmp-adaptiveform-termsandcondition
+ ELEMENT cmp-adaptiveform-termsandcondition__label-container
+ ELEMENT cmp-adaptiveform-termsandcondition__label
+ ELEMENT cmp-adaptiveform-termsandcondition__questionmark
+ ELEMENT cmp-adaptiveform-termsandcondition__content-container
+ MODIFIER cmp-adaptiveform-termsandcondition__content-container--modal
+ ELEMENT cmp-adaptiveform-termsandcondition__body
+ ELEMENT cmp-adaptiveform-termsandcondition__header
+ ELEMENT cmp-adaptiveform-termsandcondition__close-button
+ ELEMENT cmp-adaptiveform-termsandcondition__content
+ ELEMENT cmp-adaptiveform-termsandcondition__text
+ ELEMENT cmp-adaptiveform-termsandcondition__text .cmp-adaptiveform-text
+ ELEMENT cmp-adaptiveform-termsandcondition__text-intersect
+ ELEMENT cmp-adaptiveform-termsandcondition__link
+ ELEMENT cmp-adaptiveform-termsandcondition__link .cmp-adaptiveform-checkboxgroup
+ ELEMENT cmp-adaptiveform-termsandcondition__approvalcheckbox
+ ELEMENT cmp-adaptiveform-termsandcondition__approvalcheckbox .cmp-adaptiveform-checkbox
+ ELEMENT cmp-adaptiveform-termsandcondition__shortdescription
+ ELEMENT cmp-adaptiveform-termsandcondition__longdescription
+ ELEMENT cmp-adaptiveform-termsandcondition__errormessage
+```
+
+
+
+## JavaScript Data Attribute Bindings
+
+The following attributes must be added for the initialization of the text-input component in the form view:
+1. `data-cmp-is="adaptiveFormTermsAndConditions"`
+2. `data-cmp-adaptiveformcontainer-path="${formstructparser.formContainerPath}"`
+3. `data-cmp-visible` having a boolean value to indicate whether the field is currently visible or not
+4. `data-cmp-enabled` having a boolean value to indicate whether the field is currently enabled or not
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/_cq_dialog/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/_cq_dialog/.content.xml
new file mode 100644
index 0000000000..1ef3889e56
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/_cq_dialog/.content.xml
@@ -0,0 +1,169 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/_cq_editConfig.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/_cq_editConfig.xml
new file mode 100755
index 0000000000..5eb7044978
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/_cq_editConfig.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/_cq_template.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/_cq_template.xml
new file mode 100644
index 0000000000..95a10387e4
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/_cq_template.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/.content.xml
new file mode 100644
index 0000000000..491392d539
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/.content.xml
@@ -0,0 +1,3 @@
+
+
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/editor/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/editor/.content.xml
new file mode 100644
index 0000000000..0c6786f297
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/editor/.content.xml
@@ -0,0 +1,5 @@
+
+
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/editor/css.txt b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/editor/css.txt
new file mode 100644
index 0000000000..e31d85b9c6
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/editor/css.txt
@@ -0,0 +1,18 @@
+###############################################################################
+# Copyright 2023 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.
+###############################################################################
+
+#base=css
+termsandconditions.css
\ No newline at end of file
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/editor/css/termsandconditions.css b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/editor/css/termsandconditions.css
new file mode 100644
index 0000000000..84f90bfe93
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/editor/css/termsandconditions.css
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright 2023 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.
+ ******************************************************************************/
+
+.coral-Form-fieldwrapper.cmp-adaptiveform-termsandconditions__showAsLink {
+ display: flex;
+}
+.coral-Form-fieldwrapper.cmp-adaptiveform-termsandconditions__showAsLink label {
+ padding-right: 10px;
+}
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/editor/js.txt b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/editor/js.txt
new file mode 100644
index 0000000000..f135f85471
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/editor/js.txt
@@ -0,0 +1,18 @@
+###############################################################################
+# Copyright 2023 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.
+###############################################################################
+
+#base=js
+termsandconditions.js
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/editor/js/termsandconditions.js b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/editor/js/termsandconditions.js
new file mode 100644
index 0000000000..59bb65f88f
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/editor/js/termsandconditions.js
@@ -0,0 +1,61 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ Copyright 2023 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.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+/* global jQuery */
+(function($) {
+ "use strict";
+
+ const Utils = window.CQ.FormsCoreComponents.Utils.v1,
+ EDIT_DIALOG = ".cmp-adaptiveform-termsandconditions__editdialog";
+
+ /**
+ * Automatically enables approvalOption is shoAsPopup is selected
+ * @param dialog
+ */
+ function handleToggleOfApprovalOptions(dialog) {
+ const approvalOption = dialog.find('.cmp-adaptiveform-termsandconditions__showapprovaloption[name="./showApprovalOption"]')[0];
+ const showAsPopupWidget = dialog.find('.cmp-adaptiveform-termsandconditions__showaspopup[name="./showAsPopup"]')[0];
+ let showAsPopup = dialog.find('.cmp-adaptiveform-termsandconditions__showaspopup[name="./showAsPopup"]')[0]['checked'];
+ function toggleApprovalOption(show) {
+ if (show) {
+ approvalOption.readOnly=false;
+ approvalOption.style.opacity = "1";
+ } else {
+ approvalOption.readOnly=true;
+ approvalOption.style.opacity = "0.5"
+ }
+ }
+ if (showAsPopup) {
+ if (!approvalOption.checked) {
+ approvalOption['checked']=true;
+ }
+ toggleApprovalOption(false);
+ }
+ showAsPopupWidget.addEventListener('click', function() {
+ showAsPopup = !showAsPopup;
+ if (showAsPopup) {
+ if (!approvalOption.checked) {
+ approvalOption.click();
+ }
+ toggleApprovalOption(false);
+ } else {
+ toggleApprovalOption(true);
+ }
+ })
+ }
+
+ Utils.initializeEditDialog(EDIT_DIALOG)(handleToggleOfApprovalOptions);
+
+})(jQuery);
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/runtime/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/runtime/.content.xml
new file mode 100644
index 0000000000..124dfb0e20
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/runtime/.content.xml
@@ -0,0 +1,5 @@
+
+
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/runtime/css.txt b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/runtime/css.txt
new file mode 100644
index 0000000000..468a1dcd56
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/runtime/css.txt
@@ -0,0 +1,18 @@
+###############################################################################
+# Copyright 2023 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.
+###############################################################################
+
+#base=css
+termsandconditions.css
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/runtime/css/termsandconditions.css b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/runtime/css/termsandconditions.css
new file mode 100644
index 0000000000..6cde69339f
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/runtime/css/termsandconditions.css
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright 2023 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.
+ ******************************************************************************/
+
+.cmp-adaptiveform-termsandcondition{
+
+}
+
+.cmp-adaptiveform-termsandcondition__label {
+
+}
+
+.cmp-adaptiveform-termsandcondition__content-container {
+
+}
+
+.cmp-adaptiveform-termsandcondition__content-container--modal {
+
+}
+.cmp-adaptiveform-termsandcondition__content-container--modal .cmp-adaptiveform-termsandcondition__body{
+
+}
+.cmp-adaptiveform-termsandcondition__content-container--modal .cmp-adaptiveform-termsandcondition__header{
+
+}
+.cmp-adaptiveform-termsandcondition__content-container--modal .cmp-adaptiveform-termsandcondition__header h3{
+
+}
+
+
+.cmp-adaptiveform-termsandcondition__content-container--modal .cmp-adaptiveform-termsandcondition__close-button {
+
+}
+
+.cmp-adaptiveform-termsandcondition__content-container--modal .cmp-adaptiveform-termsandcondition__content {
+
+}
+
+.cmp-adaptiveform-termsandcondition__text {
+
+}
+
+.cmp-adaptiveform-termsandcondition__link {
+
+}
+
+.cmp-adaptiveform-termsandcondition__approvalcheckbox .cmp-adaptiveform-checkbox__label{
+ cursor:pointer;
+}
+
+.cmp-adaptiveform-termsandcondition__approvalcheckbox {
+
+}
+
+
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/runtime/js.txt b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/runtime/js.txt
new file mode 100644
index 0000000000..6aa7350c9e
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/runtime/js.txt
@@ -0,0 +1,18 @@
+###############################################################################
+# Copyright 2023 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.
+###############################################################################
+
+#base=js
+termsandconditionsview.js
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/runtime/js/termsandconditionsview.js b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/runtime/js/termsandconditionsview.js
new file mode 100644
index 0000000000..632f5c6aeb
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/clientlibs/runtime/js/termsandconditionsview.js
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright 2023 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.
+ ******************************************************************************/
+
+(function () {
+
+ class TermsAndConditions extends FormView.FormPanel {
+ static NS = FormView.Constants.NS;
+ static IS = "adaptiveFormTermsAndConditions";
+ static bemBlock = 'cmp-adaptiveform-termsandcondition';
+ static selectors = {
+ self: "[data-" + this.NS + '-is="' + this.IS + '"]',
+ label: `.${TermsAndConditions.bemBlock}__label`,
+ description: `.${TermsAndConditions.bemBlock}__longdescription`,
+ qm: `.${TermsAndConditions.bemBlock}__questionmark`,
+ tooltipDiv: `.${TermsAndConditions.bemBlock}__shortdescription`,
+ tncContentWrapper: `.${TermsAndConditions.bemBlock}__content-container`,
+ closePopupButton: `.${TermsAndConditions.bemBlock}__close-button`
+ };
+
+ constructor(params) {
+ super(params);
+ this.#handleScroll()
+ }
+
+ addChild(childView) {
+ super.addChild(childView);
+ if (childView.getModel()._jsonModel.fieldType === 'checkbox-group') {
+ this.#addLinkClickListener(childView);
+ }
+ if (childView.getModel()._jsonModel.fieldType === 'checkbox') {
+ this.#handlePopup(childView);
+ }
+ }
+
+ #addLinkClickListener(childView) {
+ childView.getWidgets().querySelectorAll('label').forEach((item) => {
+ const checkboxInput = item.querySelector('input');
+ item.querySelector('a').addEventListener('click', (e) => {
+ checkboxInput.click();
+ })
+ })
+ }
+
+ #handleScroll() {
+ const intersection = this.element.querySelector('.cmp-adaptiveform-termsandcondition__text-intersect');
+ if (intersection) {
+ const self = this;
+ const io = new IntersectionObserver(onIntersection, {
+ threshold: [1],
+ })
+ function onIntersection ([{isIntersecting}]) {
+ if (isIntersecting) {
+ self.children.filter(c => c.getModel()._jsonModel.fieldType === 'checkbox').forEach(cb => cb.updateEnabled(true))
+ io.unobserve(intersection);
+ }
+ }
+ io.observe(intersection)
+ }
+ }
+
+ #handlePopup(approvalCheckbox) {
+ const closePopUpBtn = this.getClosePopupButton();
+ if (closePopUpBtn) {
+ closePopUpBtn.addEventListener('click', () => {
+ this.toggleAttribute(this.getContentDivWrapper(), false, 'data-cmp-visible', false);
+ })
+
+ approvalCheckbox.label.addEventListener('click', () => {
+ const contentDiv = this.getContentDivWrapper();
+ if (contentDiv) {
+ this.toggleAttribute(this.getContentDivWrapper(), true, 'data-cmp-visible', false);
+ }
+ })
+ }
+ }
+
+ getContentDivWrapper() {
+ return this.element.querySelector(TermsAndConditions.selectors.tncContentWrapper);
+ }
+
+ getClosePopupButton() {
+ return this.element.querySelector(TermsAndConditions.selectors.closePopupButton);
+ }
+
+ getWidget() {
+ return null;
+ }
+
+ getDescription() {
+ return this.element.querySelector(TermsAndConditions.selectors.description);
+ }
+
+ getLabel() {
+ return null;
+ }
+
+ getErrorDiv() {
+ return null;
+ }
+
+ getTooltipDiv() {
+ return this.element.querySelector(TermsAndConditions.selectors.tooltipDiv);
+ }
+
+ getQuestionMarkDiv() {
+ return this.element.querySelector(TermsAndConditions.selectors.qm);
+ }
+ }
+
+ FormView.Utils.setupField(({element, formContainer}) => {
+ return new TermsAndConditions({element, formContainer})
+ }, TermsAndConditions.selectors.self);
+})();
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/termsandconditions.html b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/termsandconditions.html
new file mode 100644
index 0000000000..01d0522030
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/termsandconditions.html
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${"Please review the terms and conditions" @ i18n, context='html'}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/termsandconditions.js b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/termsandconditions.js
new file mode 100644
index 0000000000..e7bcebd928
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/termsandconditions.js
@@ -0,0 +1,29 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ Copyright 2023 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.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+use(function () {
+
+ var labelPath = 'core/fd/components/af-commons/v1/fieldTemplates/label.html';
+ var shortDescriptionPath = "core/fd/components/af-commons/v1/fieldTemplates/shortDescription.html";
+ var longDescriptionPath = "core/fd/components/af-commons/v1/fieldTemplates/longDescription.html";
+ var questionMarkPath = "core/fd/components/af-commons/v1/fieldTemplates/questionMark.html";
+ return {
+ labelPath: labelPath,
+ shortDescriptionPath: shortDescriptionPath,
+ longDescriptionPath: longDescriptionPath,
+ questionMarkPath: questionMarkPath
+ }
+});
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/.content.xml
new file mode 100644
index 0000000000..3977155bee
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/.content.xml
@@ -0,0 +1,18 @@
+
+
+
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/v1/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/v1/.content.xml
new file mode 100644
index 0000000000..69774ca1cc
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/v1/.content.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/v1/toggleablelink/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/v1/toggleablelink/.content.xml
new file mode 100644
index 0000000000..0d0d725d7c
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/v1/toggleablelink/.content.xml
@@ -0,0 +1,24 @@
+
+
+
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/v1/toggleablelink/_cq_dialog/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/v1/toggleablelink/_cq_dialog/.content.xml
new file mode 100644
index 0000000000..9bbce859e2
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/v1/toggleablelink/_cq_dialog/.content.xml
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/v1/toggleablelink/_cq_template.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/v1/toggleablelink/_cq_template.xml
new file mode 100644
index 0000000000..dbdb9ae264
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/v1/toggleablelink/_cq_template.xml
@@ -0,0 +1,8 @@
+
+
diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/v1/toggleablelink/widget.html b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/v1/toggleablelink/widget.html
new file mode 100644
index 0000000000..052452aecc
--- /dev/null
+++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/toggleablelink/v1/toggleablelink/widget.html
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/ui.frontend/src/index.js b/ui.frontend/src/index.js
index 99eed1aac0..5adb293738 100644
--- a/ui.frontend/src/index.js
+++ b/ui.frontend/src/index.js
@@ -15,7 +15,7 @@
******************************************************************************/
import Utils from "./utils.js";
import LanguageUtils from "./LanguageUtils.js";
-import {createFormInstance, FileObject, extractFileInfo, Click, Change, Submit, Blur, AddItem, RemoveItem} from "@aemforms/af-core";
+import {createFormInstance, FileObject, extractFileInfo, Click, Change, Submit, Blur, AddItem, RemoveItem, CustomEvent} from "@aemforms/af-core";
import {FormField, FormContainer, FormFieldBase, FormPanel, FormTabs} from "./view/index.js";
import {Constants} from "./constants.js";
import GuideBridge from "./GuideBridge.js";
@@ -47,7 +47,7 @@ window.guideBridge = new GuideBridge();
* @property {string} RemoveItem - The action for removing an item.
*/
const Actions = {
- Click, Change, Submit, Blur, AddItem, RemoveItem
+ Click, Change, Submit, Blur, AddItem, RemoveItem, CustomEvent
}
/**
diff --git a/ui.tests/test-module/libs/commons/formsConstants.js b/ui.tests/test-module/libs/commons/formsConstants.js
index a54b572f16..b5f6c015bf 100644
--- a/ui.tests/test-module/libs/commons/formsConstants.js
+++ b/ui.tests/test-module/libs/commons/formsConstants.js
@@ -46,6 +46,7 @@ var formsConstants = {
"checkbox": "/apps/forms-components-examples/components/form/checkbox",
"fragment": "/apps/forms-components-examples/components/form/fragment",
"fragmentcontainer": "/apps/forms-components-examples/components/form/fragmentcontainer",
+ "termsandconditions": "/apps/forms-components-examples/components/form/termsandconditions"
}
},
resourceType : {
diff --git a/ui.tests/test-module/specs/termsandconditions/tnc.authoring.spec.js b/ui.tests/test-module/specs/termsandconditions/tnc.authoring.spec.js
new file mode 100644
index 0000000000..e18919fb8b
--- /dev/null
+++ b/ui.tests/test-module/specs/termsandconditions/tnc.authoring.spec.js
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2022 Adobe Systems Incorporated
+ *
+ * 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.
+ */
+
+
+const sitesSelectors = require('../../libs/commons/sitesSelectors'),
+ afConstants = require('../../libs/commons/formsConstants');
+
+/**
+ * Testing Terms and Conditions with Sites Editor
+ */
+describe('Page - Authoring', function () {
+
+
+ const dropTnCInSites = function() {
+ const dataPath = "/content/core-components-examples/library/adaptive-form/termsandconditions/jcr:content/root/responsivegrid/demo/component/guideContainer/*",
+ responsiveGridDropZoneSelector = sitesSelectors.overlays.overlay.component + "[data-path='" + dataPath + "']";
+ cy.selectLayer("Edit");
+ cy.insertComponent(responsiveGridDropZoneSelector, "Adaptive Form Terms And Conditions", afConstants.components.forms.resourceType.termsandconditions);
+ cy.get('body').click( 0,0);
+ };
+
+ const dropTncInContainer = function() {
+ const dataPath = "/content/forms/af/core-components-it/blank/jcr:content/guideContainer/*",
+ responsiveGridDropZoneSelector = sitesSelectors.overlays.overlay.component + "[data-path='" + dataPath + "']";
+ cy.selectLayer("Edit");
+ cy.insertComponent(responsiveGridDropZoneSelector, "Adaptive Form Terms And Conditions", afConstants.components.forms.resourceType.termsandconditions);
+ cy.get('body').click(0, 0);
+ }
+
+ const testTncBehaviour = function (tncEditPathSelector, tncDrop, isSites) {
+ if (isSites) {
+ dropTnCInSites();
+ } else {
+ dropTncInContainer();
+ }
+ cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + tncEditPathSelector);
+ cy.invokeEditableAction("[data-action='CONFIGURE']"); // this line is causing frame busting which is causing cypress to fail
+ cy.get("[name='./name']")
+ .should("exist");
+
+ cy.get("coral-checkbox[name='./showApprovalOption']")
+ .should('have.attr', 'checked');
+
+ cy.get("input[name='./showApprovalOption']")
+ .click().then(e => {
+ cy.get("input[name='./showAsPopup']").click()
+ .then(e => {
+ cy.get("coral-checkbox[name='./showApprovalOption']")
+ .should('have.attr', 'checked');
+ })
+ });
+
+ cy.get('.cmp-adaptiveform-base__istitlerichtext').should('be.visible').click();
+ cy.get("div[name='richTextTitle']").should('be.visible');
+
+ cy.get('.cq-dialog-cancel').click();
+ cy.deleteComponentByPath(tncDrop);
+ }
+
+ // ***** //
+
+ context('Open Forms Editor', function() {
+ const pagePath = "/content/forms/af/core-components-it/blank",
+ tncEditPath = pagePath + afConstants.FORM_EDITOR_FORM_CONTAINER_SUFFIX + "/termsandconditions",
+ tncEditPathSelector = "[data-path='" + tncEditPath + "']",
+ tncDrop = pagePath + afConstants.FORM_EDITOR_FORM_CONTAINER_SUFFIX + "/" + afConstants.components.forms.resourceType.termsandconditions.split("/").pop();
+
+ beforeEach(function () {
+ // this is done since cypress session results in 403 sometimes
+ cy.openAuthoring(pagePath);
+ });
+
+ it('insert TnC in form container', function () {
+ dropTncInContainer();
+ cy.deleteComponentByPath(tncDrop);
+ });
+
+ it('Test TnC authoring behaviour', function() {
+ testTncBehaviour(tncEditPathSelector, tncDrop, false);
+ });
+ })
+
+ context('Open Sites Editor', function() {
+ const pagePath = "/content/core-components-examples/library/adaptive-form/termsandconditions",
+ tncEditPath = pagePath + afConstants.RESPONSIVE_GRID_DEMO_SUFFIX + "/guideContainer/termsandconditions",
+ tncDrop = pagePath + afConstants.RESPONSIVE_GRID_DEMO_SUFFIX + '/guideContainer/' + afConstants.components.forms.resourceType.termsandconditions.split("/").pop(),
+ tncEditPathSelector = "[data-path='" + tncEditPath + "']";
+
+ beforeEach(function () {
+ // this is done since cypress session results in 403 sometimes
+ cy.openAuthoring(pagePath);
+ });
+
+ it('insert aem forms TnC', function () {
+ dropTnCInSites();
+ cy.deleteComponentByPath(tncDrop);
+ });
+
+ it('Test TnC authoring behaviour', function() {
+ testTncBehaviour(tncEditPathSelector, tncDrop, true);
+ });
+ })
+});
diff --git a/ui.tests/test-module/specs/termsandconditions/tnc.runtime.spec.js b/ui.tests/test-module/specs/termsandconditions/tnc.runtime.spec.js
new file mode 100644
index 0000000000..017b060a3f
--- /dev/null
+++ b/ui.tests/test-module/specs/termsandconditions/tnc.runtime.spec.js
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright 2022 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.
+ ******************************************************************************/
+describe("Form Runtime with Terms and Conditions", () => {
+
+ const pagePath = "content/forms/af/core-components-it/samples/termsandconditions/basic.html",
+ externalPagePathSubmit="content/forms/af/core-components-it/samples/termsandconditions/submissiontest.html"
+ const bemBlock = 'cmp-adaptiveform-termsandcondition'
+ const IS = "adaptiveFormTermsAndConditions"
+ const selectors = {
+ tnc : `[data-cmp-is="${IS}"]`
+ }
+
+ let formContainer = null
+
+ beforeEach(() => {
+ cy.previewForm(pagePath).then(p => {
+ formContainer = p;
+ })
+ });
+
+ const checkHTML = (id, state, view, count) => {
+ const visible = state.visible;
+ const passVisibleCheck = `${visible === true ? "" : "not."}be.visible`;
+ cy.get(`#${id}`)
+ .should(passVisibleCheck)
+ .invoke('attr', 'data-cmp-visible')
+ .should('eq', visible.toString());
+ cy.get(`#${id}`)
+ .invoke('attr', 'data-cmp-enabled')
+ .should('eq', state.enabled.toString());
+ expect(state.items.length, "model has children equal to count").to.equal(2);
+ expect(view.children.length, "tab has children equal to count").to.equal(2); // this is because at any given point, either links are shown or text content is shown
+ return cy.get(`#${id}`);
+ };
+
+ it(" should get model and view initialized properly and parent child relationship is set ", () => {
+ expect(formContainer, "formcontainer is initialized").to.not.be.null;
+ const fields = formContainer.getAllFields();
+ Object.entries(fields).forEach(([id, field]) => {
+ expect(field.getId()).to.equal(id);
+ expect(formContainer._model.getElement(id), `model and view are in sync`).to.equal(field.getModel());
+ });
+ });
+
+ it(" model's changes are reflected in the html ", () => {
+ const tncId = formContainer._model.items[0].id
+ const model = formContainer._model.getElement(tncId)
+ const tabView = formContainer.getAllFields()[tncId];
+ const count = 2;
+ checkHTML(model.id, model.getState(), tabView, count).then(() => {
+ model.visible = false;
+ return checkHTML(model.id, model.getState(), tabView, count);
+ }).then(() => {
+ model.enable = false;
+ return checkHTML(model.id, model.getState(), tabView, count);
+ });
+ });
+
+
+ it("OOTB behaviour -> should enable approval checkbox only if links visited", () => {
+ const tncWithLinksID = formContainer._model.items[1].id;
+ const model = formContainer._model.getElement(tncWithLinksID)
+ expect(model.getState().items[0].enabled).to.equal(false);
+ cy.get(`#${tncWithLinksID}`).get('a').click()
+ .then(() => {
+ expect(model.getState().items[0].enabled).to.equal(true);
+ })
+
+ });
+
+ it("OOTB behaviour -> should have show popup", () => {
+ const tncWithPopup = formContainer._model.items[2].id;
+ const model = formContainer._model.getElement(tncWithPopup)
+ cy.get(`#${tncWithPopup} .cmp-adaptiveform-termsandcondition__content-container`)
+ .should('have.class', 'cmp-adaptiveform-termsandcondition__content-container--modal')
+ .invoke('attr', 'data-cmp-visible').should('eq', 'false')
+ expect(model.getState().items[1].enabled).to.equal(false);
+ cy.get(`#${tncWithPopup} .cmp-adaptiveform-checkbox__widget-container label`).click()
+ .then(() => {
+ // this test will also verify scrollDone scenario
+ cy.get(`#${tncWithPopup} .cmp-adaptiveform-checkbox`).invoke('attr', 'data-cmp-enabled')
+ .should('eq', 'true')
+
+ cy.get(`#${tncWithPopup} .cmp-adaptiveform-termsandcondition__content-container`)
+ .invoke('attr', 'data-cmp-visible').should('not.exist');
+ cy.get(`#${tncWithPopup} .cmp-adaptiveform-termsandcondition__close-button`).click()
+ .then(() => {
+ cy.get(`#${tncWithPopup} .cmp-adaptiveform-termsandcondition__content-container`)
+ .invoke('attr', 'data-cmp-visible').should('eq', 'false', );
+ })
+ })
+ });
+})
+