From 763b798bba314b4fb302bb3275fb613dfaadb8ba Mon Sep 17 00:00:00 2001 From: Rishi Mehta <69448117+rismehta@users.noreply.github.com> Date: Mon, 30 Sep 2024 15:07:14 +0530 Subject: [PATCH 01/10] GH actions (#1428) * GH actions * Dummy change * dummy * change * Fix error * Fix error * fix error * Fix error * fix regex * Fix code * dummy change * Dummy change * Fix errors --- .github/workflows/exporter-validate-pr.yml | 12 +- .../internal/form/FormConstants.java | 1 + .../internal/models/v1/form/PasswordImpl.java | 90 +++++++++++ .../components/models/form/FieldType.java | 1 + .../core/components/models/form/Password.java | 32 ++++ .../components/adaptive-form/password.less | 3 + .../components/form/password/.content.xml | 7 + .../components/form/password/_cq_template.xml | 5 + .../.content.xml | 2 +- .../fd/components/form/password/.content.xml | 3 + .../components/form/password/v1/.content.xml | 4 + .../form/password/v1/password/.content.xml | 8 + .../form/password/v1/password/README.md | 91 +++++++++++ .../password/_cq_design_dialog/.content.xml | 78 ++++++++++ .../v1/password/_cq_dialog/.content.xml | 142 ++++++++++++++++++ .../password/v1/password/_cq_template.xml | 5 + .../v1/password/clientlibs/.content.xml | 3 + .../password/clientlibs/editor/.content.xml | 5 + .../v1/password/clientlibs/editor/js.txt | 18 +++ .../clientlibs/editor/js/editDialog.js | 39 +++++ .../v1/password/clientlibs/site/.content.xml | 6 + .../v1/password/clientlibs/site/css.txt | 18 +++ .../clientlibs/site/css/passwordview.css | 15 ++ .../v1/password/clientlibs/site/js.txt | 19 +++ .../clientlibs/site/js/passwordview.js | 87 +++++++++++ .../site/js/togglepasswordvisibility.js | 28 ++++ .../form/password/v1/password/password.html | 58 +++++++ .../form/password/v1/password/password.js | 34 +++++ 28 files changed, 807 insertions(+), 7 deletions(-) create mode 100644 bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PasswordImpl.java create mode 100644 bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Password.java create mode 100644 examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/clientlibs/forms-clientlib-site/styles/components/adaptive-form/password.less create mode 100644 examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/password/.content.xml create mode 100644 examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/password/_cq_template.xml create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/.content.xml create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/.content.xml create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/.content.xml create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/README.md create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/_cq_design_dialog/.content.xml create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/_cq_dialog/.content.xml create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/_cq_template.xml create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/.content.xml create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/editor/.content.xml create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/editor/js.txt create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/editor/js/editDialog.js create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/.content.xml create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/css.txt create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/css/passwordview.css create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/js.txt create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/js/passwordview.js create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/js/togglepasswordvisibility.js create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/password.html create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/password.js diff --git a/.github/workflows/exporter-validate-pr.yml b/.github/workflows/exporter-validate-pr.yml index 8f3ac2c5b8..e8251f62af 100644 --- a/.github/workflows/exporter-validate-pr.yml +++ b/.github/workflows/exporter-validate-pr.yml @@ -34,8 +34,8 @@ jobs: head_file=$(git show ${{ github.head_ref }}:$file) # Compare the JSON keys - base_keys=$(echo "$base_file" | jq -r 'paths | map(tostring) | join(".")' | sed 's/\./\\./g') - head_keys=$(echo "$head_file" | jq -r 'paths | map(tostring) | join(".")' | sed 's/\./\\./g') + base_keys=$(echo "$base_file" | jq -r 'paths | map(tostring) | join(".")') + head_keys=$(echo "$head_file" | jq -r 'paths | map(tostring) | join(".")') # Check for removed keys removed_keys=$(comm -23 <(echo "$base_keys" | sort) <(echo "$head_keys" | sort)) @@ -45,11 +45,11 @@ jobs: echo "$removed_keys" exit 1 fi - + # Check for changed values for key in $base_keys; do - base_value=$(echo "$base_file" | jq -r --arg key "$key" '.[$key]') - head_value=$(echo "$head_file" | jq -r --arg key "$key" '.[$key]') + base_value=$(echo "$base_file" | jq -r ".$key") + head_value=$(echo "$head_file" | jq -r ".$key") if [ "$base_value" != "$head_value" ]; then echo "Backward incompatibility change detected in $file. The value of key '$key' was changed from '$base_value' to '$head_value'." @@ -59,4 +59,4 @@ jobs: done echo "All exporter JSON files have only additions. No backward incompatibility changes detected." - shell: bash \ No newline at end of file + shell: bash 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 09986f6e91..0939f9a7be 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 @@ -139,4 +139,5 @@ private FormConstants() { /* The resource type for the pre-selected the linked panel */ public final static String RT_FD_FORM_REVIEW_DATASOURCE_V1 = RT_FD_FORM_PREFIX + "review/v1/datasource"; + public static final String RT_FD_FORM_PASSWORD_V1 = RT_FD_FORM_PREFIX + "password/v1/password"; } diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PasswordImpl.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PasswordImpl.java new file mode 100644 index 0000000000..b8d2de195e --- /dev/null +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PasswordImpl.java @@ -0,0 +1,90 @@ +/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +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.ValueMapValue; + +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.Password; +import com.adobe.cq.forms.core.components.util.AbstractFieldImpl; + +@Model( + adaptables = { SlingHttpServletRequest.class, Resource.class }, + adapters = { Password.class, ComponentExporter.class }, + resourceType = { FormConstants.RT_FD_FORM_PASSWORD_V1 }) +@Exporter( + name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, + extensions = ExporterConstants.SLING_MODEL_EXTENSION) +public class PasswordImpl extends AbstractFieldImpl implements Password { + + @ValueMapValue + @Default(values = "") + private String validationPattern; + + @Override + public String getFieldType() { + return super.getFieldType(); + } + + @Override + public Integer getMinLength() { + return minLength; + } + + @Override + public Integer getMaxLength() { + return maxLength; + } + + @Override + public Long getMinimum() { + return minimum; + } + + @Override + public Long getMaximum() { + return maximum; + } + + @Override + public Long getExclusiveMaximum() { + return exclusiveMaximum; + } + + @Override + public Long getExclusiveMinimum() { + return exclusiveMinimum; + } + + @Override + public String getFormat() { + return displayFormat; + } + + @Override + public String getValidationPattern() { + return validationPattern; + } + +} diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FieldType.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FieldType.java index 58fb6fb702..9eff634a66 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FieldType.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FieldType.java @@ -36,6 +36,7 @@ public enum FieldType { FORM("form"), CHECKBOX_GROUP("checkbox-group"), IMAGE("image"), + TELEPHONE("tel"), PASSWORD("password"), RANGE("range"), diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Password.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Password.java new file mode 100644 index 0000000000..0f8bea8956 --- /dev/null +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Password.java @@ -0,0 +1,32 @@ +/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + +package com.adobe.cq.forms.core.components.models.form; + +import org.osgi.annotation.versioning.ConsumerType; + +@ConsumerType +public interface Password extends Field, StringConstraint, NumberConstraint { + + /** + * Returns the validation pattern (regex) for the password field. + * + * @return the validation pattern + * @since com.adobe.cq.forms.core.components.models.form 1.0.0 + */ + String getValidationPattern(); + +} diff --git a/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/clientlibs/forms-clientlib-site/styles/components/adaptive-form/password.less b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/clientlibs/forms-clientlib-site/styles/components/adaptive-form/password.less new file mode 100644 index 0000000000..070e26a5da --- /dev/null +++ b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/clientlibs/forms-clientlib-site/styles/components/adaptive-form/password.less @@ -0,0 +1,3 @@ +.cmp-adaptiveform-password { + .inputMixin(); + } \ No newline at end of file diff --git a/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/password/.content.xml b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/password/.content.xml new file mode 100644 index 0000000000..acb1cd0182 --- /dev/null +++ b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/password/.content.xml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/password/_cq_template.xml b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/password/_cq_template.xml new file mode 100644 index 0000000000..fd92ff415e --- /dev/null +++ b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/password/_cq_template.xml @@ -0,0 +1,5 @@ + + \ No newline at end of file diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-all/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-all/.content.xml index 4c0c770f99..e7ad284122 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-all/.content.xml +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-all/.content.xml @@ -5,4 +5,4 @@ cssProcessor="[default:none,min:none]" jsProcessor="[default:none,min:none]" categories="[core.forms.components.runtime.all]" - embed="[core.forms.components.runtime.base,core.forms.components.container.v2.runtime,core.forms.components.datePicker.v1.runtime,core.forms.components.textinput.v1.runtime,core.forms.components.numberinput.v1.runtime,core.forms.components.panelcontainer.v1.runtime,core.forms.components.radiobutton.v1.runtime,core.forms.components.text.v1.runtime,core.forms.components.checkboxgroup.v1.runtime,core.forms.components.button.v1.runtime,core.forms.components.image.v1.runtime,core.forms.components.dropdown.v1.runtime,core.forms.components.fileinput.v3.runtime,core.forms.components.accordion.v1.runtime,core.forms.components.tabs.v1.runtime,core.forms.components.wizard.v1.runtime,core.forms.components.verticaltabs.v1.runtime,core.forms.components.recaptcha.v1.runtime,core.forms.components.checkbox.v1.runtime,core.forms.components.fragment.v1.runtime,core.forms.components.switch.v1.runtime,core.forms.components.termsandconditions.v1.runtime, core.forms.components.hcaptcha.v1.runtime,core.forms.components.review.v1.runtime]"/> + embed="[core.forms.components.runtime.base,core.forms.components.container.v2.runtime,core.forms.components.datePicker.v1.runtime,core.forms.components.textinput.v1.runtime,core.forms.components.numberinput.v1.runtime,core.forms.components.panelcontainer.v1.runtime,core.forms.components.radiobutton.v1.runtime,core.forms.components.text.v1.runtime,core.forms.components.checkboxgroup.v1.runtime,core.forms.components.button.v1.runtime,core.forms.components.image.v1.runtime,core.forms.components.dropdown.v1.runtime,core.forms.components.fileinput.v3.runtime,core.forms.components.accordion.v1.runtime,core.forms.components.tabs.v1.runtime,core.forms.components.wizard.v1.runtime,core.forms.components.verticaltabs.v1.runtime,core.forms.components.recaptcha.v1.runtime,core.forms.components.checkbox.v1.runtime,core.forms.components.fragment.v1.runtime,core.forms.components.switch.v1.runtime,core.forms.components.termsandconditions.v1.runtime, core.forms.components.hcaptcha.v1.runtime,core.forms.components.review.v1.runtime, core.forms.components.password.v1.runtime]"/> diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/.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/password/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/.content.xml new file mode 100644 index 0000000000..12d179732b --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/.content.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/.content.xml new file mode 100644 index 0000000000..b568963358 --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/.content.xml @@ -0,0 +1,8 @@ + + \ No newline at end of file diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/README.md b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/README.md new file mode 100644 index 0000000000..87d7552110 --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/README.md @@ -0,0 +1,91 @@ + +Adaptive Form Password (v1) +==== +Adaptive Form Password field component written in HTL. + +## Features + +* Provides the following type of input: + * password + +* Custom constraint messages for the above types +* Styles +* Allows replacing this component with other component (as mentioned below). + +### Use Object +The Form Password component uses the `com.adobe.cq.forms.core.components.models.form.Password` Sling Model for its Use-object. + +### Edit Dialog Properties +The following properties are written to JCR for this Form Password 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 + +## Client Libraries +The component provides a `core.forms.components.password.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.password.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-password + ELEMENT cmp-adaptiveform-password__label + ELEMENT cmp-adaptiveform-password__label-container + ELEMENT cmp-adaptiveform-password__widget + ELEMENT cmp-adaptiveform-password__questionmark + ELEMENT cmp-adaptiveform-password__shortdescription + ELEMENT cmp-adaptiveform-password__longdescription + ELEMENT cmp-adaptiveform-password__errormessage +``` + +### Note +By placing the class names `cmp-adaptiveform-password__label` and `cmp-adaptiveform-password__questionmark` within the `cmp-adaptiveform-password__label-container` class, you create a logical grouping of the label and question mark elements. This approach simplifies the process of maintaining a consistent styling for both elements. + +## Replace feature: +We support replace feature that allows replacing Reset Button component to any of the below components: + +* Button +* Date Picker +* Email Input +* Number Input +* Reset Button +* Submit Button +* Telephone Input +* Text Box + +## JavaScript Data Attribute Bindings + +The following attributes must be added for the initialization of the password component in the form view: + 1. `data-cmp-is="adaptiveFormPassword"` + 2. `data-cmp-adaptiveformcontainer-path="${formstructparser.formContainerPath}"` + + +The following are optional attributes that can be added to the component in the form view: +1. `data-cmp-valid` having a boolean value to indicate whether the field is currently valid or not +2. `data-cmp-required` having a boolean value to indicate whether the field is currently required or not +3. `data-cmp-readonly` having a boolean value to indicate whether the field is currently readonly or not +4. `data-cmp-active` having a boolean value to indicate whether the field is currently active or not +5. `data-cmp-visible` having a boolean value to indicate whether the field is currently visible or not +6. `data-cmp-enabled` having a boolean value to indicate whether the field is currently enabled or not \ No newline at end of file diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/_cq_design_dialog/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/_cq_design_dialog/.content.xml new file mode 100644 index 0000000000..79e8649b56 --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/_cq_design_dialog/.content.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/_cq_dialog/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/_cq_dialog/.content.xml new file mode 100644 index 0000000000..b63ed7380a --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/_cq_dialog/.content.xml @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/_cq_template.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/_cq_template.xml new file mode 100644 index 0000000000..fed340a46b --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/_cq_template.xml @@ -0,0 +1,5 @@ + + diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/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/password/v1/password/clientlibs/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/editor/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/editor/.content.xml new file mode 100644 index 0000000000..9db59eb5c7 --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/editor/.content.xml @@ -0,0 +1,5 @@ + + diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/editor/js.txt b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/editor/js.txt new file mode 100644 index 0000000000..dd642eaed7 --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/editor/js.txt @@ -0,0 +1,18 @@ +############################################################################### +# 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. +############################################################################### + +#base=js +editDialog.js \ No newline at end of file diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/editor/js/editDialog.js b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/editor/js/editDialog.js new file mode 100644 index 0000000000..66e54543a5 --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/editor/js/editDialog.js @@ -0,0 +1,39 @@ +/******************************************************************************* + * 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. + ******************************************************************************/ +(function($) { + "use strict"; + + var EDIT_DIALOG = ".cmp-adaptiveform-password__editdialog", + PASSWORD_MAXLENGTH = EDIT_DIALOG + " .cmp-adaptiveform-password__maxlength", + PASSWORD_MINLENGTH = EDIT_DIALOG + " .cmp-adaptiveform-password__minlength", + BASE_PLACEHOLDER = EDIT_DIALOG + " .cmp-adaptiveform-base__placeholder", + PASSWORD_VALUE = EDIT_DIALOG + " .cmp-adaptiveform-password__value", + PASSWORD_RICHTEXTVALUE = EDIT_DIALOG + " .cmp-adaptiveform-password__richtextvalue", + PASSWORD_VALIDATIONPATTERN = EDIT_DIALOG + " .cmp-adaptiveform-password__validationpattern", + PASSWORD_VALIDATIONFORMAT = EDIT_DIALOG + " .cmp-adaptiveform-password__validationformat", + Utils = window.CQ.FormsCoreComponents.Utils.v1; + + function handleValidationPatternDropDown(dialog) { + Utils.handlePatternDropDown(dialog,PASSWORD_VALIDATIONPATTERN,PASSWORD_VALIDATIONFORMAT); + } + + function handleValidationFormat(dialog){ + Utils.handlePatternFormat(dialog,PASSWORD_VALIDATIONPATTERN,PASSWORD_VALIDATIONFORMAT); + } + + Utils.initializeEditDialog(EDIT_DIALOG)(handleValidationPatternDropDown,handleValidationFormat); + +})(jQuery); diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/.content.xml new file mode 100644 index 0000000000..27631c55e6 --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/.content.xml @@ -0,0 +1,6 @@ + + diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/css.txt b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/css.txt new file mode 100644 index 0000000000..768068f910 --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/css.txt @@ -0,0 +1,18 @@ +############################################################################### +# 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. +############################################################################### + +#base=css +passwordview.css \ No newline at end of file diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/css/passwordview.css b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/css/passwordview.css new file mode 100644 index 0000000000..229055b840 --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/css/passwordview.css @@ -0,0 +1,15 @@ +/******************************************************************************* + * 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. + ******************************************************************************/ \ No newline at end of file diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/js.txt b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/js.txt new file mode 100644 index 0000000000..78e5ac68f6 --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/js.txt @@ -0,0 +1,19 @@ +############################################################################### +# 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. +############################################################################### + +#base=js +passwordview.js +togglepasswordvisibility.js diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/js/passwordview.js b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/js/passwordview.js new file mode 100644 index 0000000000..40fcd8cf56 --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/js/passwordview.js @@ -0,0 +1,87 @@ +/******************************************************************************* + * 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. + ******************************************************************************/ +(function() { + + "use strict"; + class Password extends FormView.FormFieldBase { + + static NS = FormView.Constants.NS; + /** + * Each FormField has a data attribute class that is prefixed along with the global namespace to + * distinguish between them. If a component wants to put a data-attribute X, the attribute in HTML would be + * data-{NS}-{IS}-x="" + * @type {string} + */ + static IS = "adaptiveFormPassword"; + static bemBlock = 'cmp-adaptiveform-password' + static selectors = { + self: "[data-" + this.NS + '-is="' + this.IS + '"]', + widget: `.${Password.bemBlock}__widget`, + label: `.${Password.bemBlock}__label`, + description: `.${Password.bemBlock}__longdescription`, + qm: `.${Password.bemBlock}__questionmark`, + errorDiv: `.${Password.bemBlock}__errormessage`, + tooltipDiv: `.${Password.bemBlock}__shortdescription` + }; + + constructor(params) { + super(params); + } + + getWidget() { + return this.element.querySelector(Password.selectors.widget); + } + + getDescription() { + return this.element.querySelector(Password.selectors.description); + } + + getLabel() { + return this.element.querySelector(Password.selectors.label); + } + + getErrorDiv() { + return this.element.querySelector(Password.selectors.errorDiv); + } + + getTooltipDiv() { + return this.element.querySelector(Password.selectors.tooltipDiv); + } + + getQuestionMarkDiv() { + return this.element.querySelector(Password.selectors.qm); + } + + setModel(model) { + super.setModel(model); + if (this.widget.value !== '') { + this._model.value = this.widget.value; + } + this.widget.addEventListener('blur', (e) => { + this._model.value = e.target.value; + this.setInactive(); + }); + this.widget.addEventListener('focus', (e) => { + this.setActive(); + }); + } + } + + FormView.Utils.setupField(({element, formContainer}) => { + return new Password({element, formContainer}) + }, Password.selectors.self); + +})(); diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/js/togglepasswordvisibility.js b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/js/togglepasswordvisibility.js new file mode 100644 index 0000000000..4117df083d --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/js/togglepasswordvisibility.js @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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. + ******************************************************************************/ + +$(document).ready(function() { + $(document).on('click', '.ssnField .fisheye', function() { + var type = $(".ssnField").find("input").attr("type"); + if (type == "text") { + $(".ssnField").find("input").attr("type", "password"); + } + + if (type == "password") { + $(".ssnField").find("input").attr("type", "text"); + } + }); + }); diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/password.html b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/password.html new file mode 100644 index 0000000000..7a70e20574 --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/password.html @@ -0,0 +1,58 @@ + +
+ +
+
+
+
+
+ + +
+
+
+
+
+ \ No newline at end of file diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/password.js b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/password.js new file mode 100644 index 0000000000..dc33ea8b81 --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/password.js @@ -0,0 +1,34 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + +use(function () { + + var clientlibsArr = ['core.forms.components.base.v1.editor']; + 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" + var errorMessagePath = "core/fd/components/af-commons/v1/fieldTemplates/errorMessage.html"; + + return { + labelPath: labelPath, + shortDescriptionPath: shortDescriptionPath, + longDescriptionPath: longDescriptionPath, + questionMarkPath: questionMarkPath, + errorMessagePath: errorMessagePath, + clientlibs: clientlibsArr + } +}); \ No newline at end of file From d1d22826d3d811b117aa3dc5d7cfccc581edbc7d Mon Sep 17 00:00:00 2001 From: Sushil Kumar <88363275+kum-sushil@users.noreply.github.com> Date: Fri, 23 Feb 2024 15:44:17 +0530 Subject: [PATCH 02/10] AF Password Component| Updated license year and few code comments block update --- .../adobe/cq/forms/core/components/models/form/Password.java | 2 +- .../apps/core/fd/components/form/password/v1/password/README.md | 2 +- .../form/password/v1/password/clientlibs/editor/js.txt | 2 +- .../form/password/v1/password/clientlibs/site/css.txt | 2 +- .../components/form/password/v1/password/clientlibs/site/js.txt | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Password.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Password.java index 0f8bea8956..62ee8a5c02 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Password.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Password.java @@ -25,7 +25,7 @@ public interface Password extends Field, StringConstraint, NumberConstraint { * Returns the validation pattern (regex) for the password field. * * @return the validation pattern - * @since com.adobe.cq.forms.core.components.models.form 1.0.0 + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 */ String getValidationPattern(); diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/README.md b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/README.md index 87d7552110..3deb0fa3dc 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/README.md +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/README.md @@ -1,5 +1,5 @@ -
+ dir="auto" aria-label="password"/>
-
- \ No newline at end of file + \ No newline at end of file From 7f41331331459351e48f967305c6e02cc8a4613b Mon Sep 17 00:00:00 2001 From: Sushil Kumar <88363275+kum-sushil@users.noreply.github.com> Date: Mon, 4 Mar 2024 12:58:59 +0530 Subject: [PATCH 04/10] AF Password|Test Cases and html updates supporting responsiveness --- .../internal/models/v1/form/PasswordImpl.java | 8 +- .../core/components/models/form/Password.java | 5 + .../models/v1/form/PasswordImplTest.java | 181 ++++++++++++++++++ .../exporter-password-customized.json | 41 ++++ .../password/exporter-password-datalayer.json | 38 ++++ .../resources/form/password/test-content.json | 121 ++++++++++++ .../site/js/togglepasswordvisibility.js | 4 +- .../form/password/v1/password/password.html | 30 +-- 8 files changed, 409 insertions(+), 19 deletions(-) create mode 100644 bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PasswordImplTest.java create mode 100644 bundles/af-core/src/test/resources/form/password/exporter-password-customized.json create mode 100644 bundles/af-core/src/test/resources/form/password/exporter-password-datalayer.json create mode 100644 bundles/af-core/src/test/resources/form/password/test-content.json diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PasswordImpl.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PasswordImpl.java index b8d2de195e..48aef529db 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PasswordImpl.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PasswordImpl.java @@ -16,11 +16,13 @@ package com.adobe.cq.forms.core.components.internal.models.v1.form; +import javax.annotation.Nullable; + 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 com.adobe.cq.export.json.ComponentExporter; @@ -38,8 +40,8 @@ extensions = ExporterConstants.SLING_MODEL_EXTENSION) public class PasswordImpl extends AbstractFieldImpl implements Password { - @ValueMapValue - @Default(values = "") + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) + @Nullable private String validationPattern; @Override diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Password.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Password.java index 62ee8a5c02..9d78a1148a 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Password.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Password.java @@ -18,6 +18,11 @@ import org.osgi.annotation.versioning.ConsumerType; +/** + * Interface for {@code Password} Sling Model used for the {@code /apps/core/fd/components/form/password/v1/password} component. + * + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ @ConsumerType public interface Password extends Field, StringConstraint, NumberConstraint { diff --git a/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PasswordImplTest.java b/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PasswordImplTest.java new file mode 100644 index 0000000000..01b30e648d --- /dev/null +++ b/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PasswordImplTest.java @@ -0,0 +1,181 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import org.apache.commons.lang3.reflect.FieldUtils; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.adobe.cq.forms.core.Utils; +import com.adobe.cq.forms.core.components.datalayer.FormComponentData; +import com.adobe.cq.forms.core.components.models.form.FieldType; +import com.adobe.cq.forms.core.components.models.form.Password; +import com.adobe.cq.forms.core.components.models.form.TextInput; +import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext; +import io.wcm.testing.mock.aem.junit5.AemContext; +import io.wcm.testing.mock.aem.junit5.AemContextExtension; + +import static org.junit.Assert.assertEquals; + +@ExtendWith(AemContextExtension.class) +public class PasswordImplTest { + + private static final String BASE = "/form/password"; + private static final String CONTENT_ROOT = "/content"; + private static final String PATH_PASSWORD_DATALAYER = CONTENT_ROOT + "/password-datalayer"; + private static final String PATH_PASSWORD_CUSTOMIZED = CONTENT_ROOT + "/password-customized"; + + private final AemContext context = FormsCoreComponentTestContext.newAemContext(); + + @BeforeEach + void setUp() { + context.load().json(BASE + FormsCoreComponentTestContext.TEST_CONTENT_JSON, CONTENT_ROOT); + } + + @Test + void testFieldType() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals(FieldType.PASSWORD.getValue(), password.getFieldType()); + } + + @Test + void testGetLabel() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals("pwd", password.getLabel().getValue()); + } + + @Test + void testPlaceholder() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals("Enter valid password", password.getPlaceHolder()); + } + + @Test + void testGetName() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals("password", password.getName()); + + } + + @Test + void testDorProperties() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals(true, password.getDorProperties().get("dorExclusion")); + assertEquals("4", password.getDorProperties().get("dorColspan")); + assertEquals("Text1", password.getDorProperties().get("dorBindRef")); + + } + + @Test + void testGetDescription() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals("password field", password.getDescription()); + } + + @Test + void testGetRequired() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals(true, password.isRequired()); + } + + @Test + void testGetValidationPattern() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals("/^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/", password.getValidationPattern()); + + } + + @Test + void testIsEnabled() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals(true, password.isEnabled()); + } + + @Test + void testIsEnabledForCustomized() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals(true, password.isEnabled()); + } + + @Test + void testIsReadOnly() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals(false, password.isReadOnly()); + } + + @Test + void testIsReadOnlyForCustomized() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals(false, password.isReadOnly()); + } + + @Test + void testMinLength() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals(5, password.getMinLength().intValue()); + } + + @Test + void testMaxLength() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals(10, password.getMaxLength().intValue()); + } + + @Test + void testGetExclusiveMinimum() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals(8, password.getExclusiveMinimum().intValue()); + } + + @Test + void testGetExclusiveMaximum() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals(16, password.getExclusiveMaximum().intValue()); + } + + @Test + void testGetMinimum() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals(1, password.getMinimum().intValue()); + } + + @Test + void testGetMaximum() { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals(6, password.getMaximum().intValue()); + } + + @Test + void testGetDisplayFormat() throws Exception { + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_CUSTOMIZED, Password.class, context); + assertEquals("password", password.getFormat()); + } + + @Test + void testDataLayerProperties() throws IllegalAccessException { + TextInput textInput = Utils.getComponentUnderTest(PATH_PASSWORD_DATALAYER, TextInput.class, context); + FieldUtils.writeField(textInput, "dataLayerEnabled", true, true); + FormComponentData dataObject = (FormComponentData) textInput.getData(); + assert (dataObject != null); + assert (dataObject.getId()).equals("password-1c7bc238a6"); + assert (dataObject.getType()).equals("core/fd/components/form/password/v1/password"); + assert (dataObject.getTitle()).equals("Full Name"); + assert (dataObject.getFieldType()).equals("password"); + assert (dataObject.getDescription()).equals("Enter Full Name"); + } +} diff --git a/bundles/af-core/src/test/resources/form/password/exporter-password-customized.json b/bundles/af-core/src/test/resources/form/password/exporter-password-customized.json new file mode 100644 index 0000000000..0222bd54e2 --- /dev/null +++ b/bundles/af-core/src/test/resources/form/password/exporter-password-customized.json @@ -0,0 +1,41 @@ +{ + "id": "password-477c777f4e", + "fieldType": "password", + "name": "password1708629052628", + "visible": true, + "description": "

long desc

\r\n", + "tooltip": "

short desc

\r\n", + "type": "string", + "required": true, + "enabled": true, + "constraintMessages": { + "required": "Password is required", + "minLength": "min chars", + "maxLength": "max chars", + "pattern": "Invalid pwd" + }, + "readOnly": false, + "minLength": 5, + "maxLength": 10, + "validationPattern": "/^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/", + "label": { + "value": "Password", + "visible": true + }, + "properties": { + "afs:layout": { + "tooltipVisible": false + }, + "fd:dor": { + "dorExclusion": false + }, + "fd:path": "/content/password-customized" + }, + "events": { + "custom:setProperty": [ + "$event.payload" + ] + }, + "placeholder": "Enter valid password", + ":type": "core/fd/components/form/password/v1/password" +} \ No newline at end of file diff --git a/bundles/af-core/src/test/resources/form/password/exporter-password-datalayer.json b/bundles/af-core/src/test/resources/form/password/exporter-password-datalayer.json new file mode 100644 index 0000000000..ab723a1dd2 --- /dev/null +++ b/bundles/af-core/src/test/resources/form/password/exporter-password-datalayer.json @@ -0,0 +1,38 @@ +{ + "id": "password-1c7bc238a6", + "fieldType": "password", + "name": "Full Name", + "visible": true, + "description": "Enter Full Name", + "tooltip": "Full Name", + "type": "string", + "required": true, + "enabled": true, + "readOnly": false, + "label": { + "value": "Full Name" + }, + "events": { + "custom:setProperty": [ + "$event.payload" + ] + }, + "properties": { + "afs:layout": { + "tooltipVisible": false + }, + "fd:dor": { + "dorExclusion": false + }, + "fd:path": "/content/password-datalayer" + }, + ":type": "core/fd/components/form/password/v1/password", + "dataLayer": { + "password-1c7bc238a6": { + "dc:title": "Full Name", + "dc:description": "Enter Full Name", + "@type": "core/fd/components/form/password/v1/password", + "fieldType": "password" + } + } +} \ No newline at end of file diff --git a/bundles/af-core/src/test/resources/form/password/test-content.json b/bundles/af-core/src/test/resources/form/password/test-content.json new file mode 100644 index 0000000000..31c2c2f1e2 --- /dev/null +++ b/bundles/af-core/src/test/resources/form/password/test-content.json @@ -0,0 +1,121 @@ +{ + "password" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/password/v1/password", + "name" : "abc", + "jcr:title" : "def", + "fieldType": "password" + }, + "password-customized" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/password/v1/password", + "name" : "password", + "jcr:title" : "pwd", + "hideTitle" : false, + "dorExclusion": true, + "dorColspan": "4", + "dorBindRef": "Text1", + "description" : "password field", + "visible" : false, + "readOnly": false, + "enabled": true, + "required": true, + "minLength": 5, + "maxLength": 10, + "maximum" : 6, + "minimum" : 1, + "exclusiveMinimum":8, + "exclusiveMaximum":16, + "displayFormat" : "password", + "assistPriority" : "custom", + "dataRef" : "a.b", + "custom" : "Custom screen reader text", + "typeMessage" : "incorrect type", + "tooltip": "test-short-description", + "placeholder": "Enter valid password", + "validationPattern": "/^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/", + "default" : "password", + "fieldType": "password", + "label": { + "value": "Password", + "visible": true + } + }, + "password-format" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/password/v1/password", + "name" : "abc", + "jcr:title" : "def", + "hideTitle" : false, + "description" : "dummy", + "visible" : false, + "assistPriority" : "custom", + "dataRef" : "a.b", + "custom" : "Custom screen reader text", + "typeMessage" : "incorrect type", + "tooltip": "test-short-description", + "default" : "abc", + "fieldType": "password", + "readOnly": false, + "enabled": true, + "displayFormat" : "password" + }, + "password-datalayer" : { + "sling:resourceType" : "core/fd/components/form/password/v1/password", + "id": "password-1c7bc238a6", + "fieldType": "password", + "name": "Full Name", + "jcr:title" : "Full Name", + "visible": true, + "description": "Enter Full Name", + "tooltip": "Full Name", + "type": "string", + "required": true, + "enabled": true, + "readOnly": false, + "label": { + "value": "Full Name" + }, + "events": { + "custom:setProperty": [ + "$event.payload" + ] + }, + "properties": { + "afs:layout": { + "tooltipVisible": false + }, + "fd:dor": { + "dorExclusion": false + }, + "fd:path": "/content/forms/af/af2/jcr:content/guideContainer/password" + }, + ":type": "forms-components-examples/components/form/password" + }, + "password_unboundFormElement" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/password/v1/password", + "name" : "abc", + "jcr:title" : "def", + "fieldType": "password", + "unboundFormElement": true, + "dataRef": "$.h" + }, + "password-blank-dataref" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/password/v1/password", + "name" : "abc", + "jcr:title" : "def", + "fieldType": "password", + "dataRef": "" + }, + "password-blank-validationExpression" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/password/v1/password", + "name" : "abc", + "jcr:title" : "def", + "fieldType": "password", + "validationExpression": "" + } + } + \ No newline at end of file diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/js/togglepasswordvisibility.js b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/js/togglepasswordvisibility.js index 7b8e434f79..cdbb748860 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/js/togglepasswordvisibility.js +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/js/togglepasswordvisibility.js @@ -15,8 +15,8 @@ ******************************************************************************/ (function() { "use strict"; - let togglePasswordButton = document.querySelector('.cmp-adaptiveform-password .fisheye'); - let passwordInput = document.querySelector('input.cmp-adaptiveform-password__widget'); + const togglePasswordButton = document.querySelector('.cmp-adaptiveform-password__input-wrapper .eyeicon'); + const passwordInput = document.querySelector('.cmp-adaptiveform-password__input-wrapper input.cmp-adaptiveform-password__widget'); if(togglePasswordButton && passwordInput){ togglePasswordButton.addEventListener('click', function () { if (passwordInput.type === 'password') { diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/password.html b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/password.html index d237c078f2..612bbe648f 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/password.html +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/password.html @@ -35,20 +35,22 @@
- - +
+ + +
From 252299c2b11e7c1b6123675169c15620083cf765 Mon Sep 17 00:00:00 2001 From: Sushil Kumar <88363275+kum-sushil@users.noreply.github.com> Date: Mon, 4 Mar 2024 17:32:22 +0530 Subject: [PATCH 05/10] AF Password| Test case updates --- .../internal/models/v1/form/PasswordImplTest.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PasswordImplTest.java b/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PasswordImplTest.java index 01b30e648d..2ccc2f4803 100644 --- a/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PasswordImplTest.java +++ b/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PasswordImplTest.java @@ -25,7 +25,6 @@ import com.adobe.cq.forms.core.components.datalayer.FormComponentData; import com.adobe.cq.forms.core.components.models.form.FieldType; import com.adobe.cq.forms.core.components.models.form.Password; -import com.adobe.cq.forms.core.components.models.form.TextInput; import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext; import io.wcm.testing.mock.aem.junit5.AemContext; import io.wcm.testing.mock.aem.junit5.AemContextExtension; @@ -168,9 +167,9 @@ void testGetDisplayFormat() throws Exception { @Test void testDataLayerProperties() throws IllegalAccessException { - TextInput textInput = Utils.getComponentUnderTest(PATH_PASSWORD_DATALAYER, TextInput.class, context); - FieldUtils.writeField(textInput, "dataLayerEnabled", true, true); - FormComponentData dataObject = (FormComponentData) textInput.getData(); + Password password = Utils.getComponentUnderTest(PATH_PASSWORD_DATALAYER, Password.class, context); + FieldUtils.writeField(password, "dataLayerEnabled", true, true); + FormComponentData dataObject = (FormComponentData) password.getData(); assert (dataObject != null); assert (dataObject.getId()).equals("password-1c7bc238a6"); assert (dataObject.getType()).equals("core/fd/components/form/password/v1/password"); From 78f00719ba3fb4c98bdc7db88e817e393b1252ba Mon Sep 17 00:00:00 2001 From: Sushil Kumar <88363275+kum-sushil@users.noreply.github.com> Date: Mon, 11 Mar 2024 19:29:30 +0530 Subject: [PATCH 06/10] AF Password | PR review comments Updates --- .../adaptive-form/password/.content.xml | 221 +++++++++++++++++ .../samples/password/.content.xml | 6 + .../samples/password/basic/.content.xml | 23 ++ .../samples/password/.content.xml | 3 + .../samples/password/basic/.content.xml | 234 ++++++++++++++++++ .../form/password/v1/password/.content.xml | 4 +- .../form/password/v1/password/README.md | 9 +- .../password/_cq_design_dialog/.content.xml | 32 +-- .../v1/password/_cq_dialog/.content.xml | 4 +- .../clientlibs/site/css/passwordview.css | 31 ++- .../v1/password/clientlibs/site/js.txt | 1 - .../clientlibs/site/js/passwordview.js | 22 +- .../site/js/togglepasswordvisibility.js | 29 --- .../form/password/v1/password/password.html | 2 +- ui.frontend/src/constants.js | 12 + .../libs/commons/formsConstants.js | 1 + .../specs/password/password.authoring.spec.js | 177 +++++++++++++ .../specs/password/password.runtime.spec.js | 162 ++++++++++++ 18 files changed, 903 insertions(+), 70 deletions(-) create mode 100644 examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/password/.content.xml create mode 100644 it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/password/.content.xml create mode 100644 it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/password/basic/.content.xml create mode 100644 it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/password/.content.xml create mode 100644 it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/password/basic/.content.xml delete mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/clientlibs/site/js/togglepasswordvisibility.js create mode 100644 ui.tests/test-module/specs/password/password.authoring.spec.js create mode 100644 ui.tests/test-module/specs/password/password.runtime.spec.js diff --git a/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/password/.content.xml b/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/password/.content.xml new file mode 100644 index 0000000000..0237cad9c1 --- /dev/null +++ b/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/password/.content.xml @@ -0,0 +1,221 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/password/.content.xml b/it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/password/.content.xml new file mode 100644 index 0000000000..d738d26849 --- /dev/null +++ b/it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/password/.content.xml @@ -0,0 +1,6 @@ + + diff --git a/it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/password/basic/.content.xml b/it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/password/basic/.content.xml new file mode 100644 index 0000000000..ef1113d23c --- /dev/null +++ b/it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/password/basic/.content.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/password/.content.xml b/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/password/.content.xml new file mode 100644 index 0000000000..a0ac99e384 --- /dev/null +++ b/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/password/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/password/basic/.content.xml b/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/password/basic/.content.xml new file mode 100644 index 0000000000..d86fa760a4 --- /dev/null +++ b/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/password/basic/.content.xml @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/.content.xml index b568963358..a2530d42b7 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/.content.xml +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/password/v1/password/.content.xml @@ -1,7 +1,7 @@