diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/form/ReservedProperties.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/form/ReservedProperties.java index 34844e24b5..440555e8e6 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/form/ReservedProperties.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/form/ReservedProperties.java @@ -162,6 +162,7 @@ private ReservedProperties() { public static final String FD_ENABLE_AUTO_SAVE = "fd:enableAutoSave"; public static final String FD_AUTO_SAVE_STRATEGY_TYPE = "fd:autoSaveStrategyType"; public static final String FD_AUTO_SAVE_INTERVAL = "fd:autoSaveInterval"; + public static final String FD_DIALOG_LABEL = "fd:dialogLabel"; public static final String FD_XFA_SCRIPTS = "fd:xfaScripts"; diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/ScribbleImpl.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/ScribbleImpl.java new file mode 100644 index 0000000000..f2ee578b57 --- /dev/null +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/ScribbleImpl.java @@ -0,0 +1,73 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ Copyright 2025 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.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.ReservedProperties; +import com.adobe.cq.forms.core.components.models.form.Scribble; +import com.adobe.cq.forms.core.components.util.AbstractFieldImpl; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; + +@Model( + adaptables = { SlingHttpServletRequest.class, Resource.class }, + adapters = { Scribble.class, ComponentExporter.class }, + resourceType = "core/fd/components/form/scribble/v1/scribble") +@Exporter( + name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, + extensions = ExporterConstants.SLING_MODEL_EXTENSION) +public class ScribbleImpl extends AbstractFieldImpl implements Scribble { + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private String value; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = ReservedProperties.FD_DIALOG_LABEL) + @Default(values = Scribble.DEFAULT_DIALOG_LABEL) + protected String dialogLabel; + + @Override + public String getValue() { + return value; + } + + @JsonIgnore + public String getDialogLabel() { + return dialogLabel; + } + + @Override + public @NotNull Map getProperties() { + Map customProperties = super.getProperties(); + if (getDialogLabel() != null) + customProperties.put(ReservedProperties.FD_DIALOG_LABEL, getDialogLabel()); + return customProperties; + } + +} diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Scribble.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Scribble.java new file mode 100644 index 0000000000..82938af3c7 --- /dev/null +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Scribble.java @@ -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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + +package com.adobe.cq.forms.core.components.models.form; + +import org.osgi.annotation.versioning.ConsumerType; + +/** + * Defines the form Scribble Sling Model used for the Scribble component. + * + * @since com.adobe.cq.forms.core.components.models.form 5.11.0 + */ +@ConsumerType +public interface Scribble extends Field { + + String DEFAULT_DIALOG_LABEL = "Please sign here"; + + /** + * Returns the base64 encoded string of the scribble. + * + * @return Base64 encoded string representing the scribble + * @since com.adobe.cq.forms.core.components.models.form 5.11.0 + */ + String getValue(); + +} diff --git a/bundles/af-core/src/test/resources/form/scribble/exporter-scribble.json b/bundles/af-core/src/test/resources/form/scribble/exporter-scribble.json new file mode 100644 index 0000000000..853f822f58 --- /dev/null +++ b/bundles/af-core/src/test/resources/form/scribble/exporter-scribble.json @@ -0,0 +1,22 @@ +{ + "id": "scribble-178a5c65c2", + "fieldType": "text-input", + "name": "scribble1710484027357", + "value": "", + "type": "string", + "label": { + "value": "Scribble" + }, + "events": { + "custom:setProperty": [ + "$event.payload" + ] + }, + "properties": { + "fd:dor": { + "dorExclusion": false + }, + "fd:path": "/content/forms/af/scribbletest/jcr:content/guideContainer/scribble" + }, + ":type": "forms-components-examples/components/form/scribble" +} \ No newline at end of file diff --git a/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/scribble/.content.xml b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/scribble/.content.xml new file mode 100644 index 0000000000..7c7c367660 --- /dev/null +++ b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/scribble/.content.xml @@ -0,0 +1,7 @@ + + diff --git a/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/scribble/_cq_template.xml b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/scribble/_cq_template.xml new file mode 100644 index 0000000000..d660889a7c --- /dev/null +++ b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/scribble/_cq_template.xml @@ -0,0 +1,7 @@ + + diff --git a/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/scribble/.content.xml b/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/scribble/.content.xml new file mode 100644 index 0000000000..4fcce7df95 --- /dev/null +++ b/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/scribble/.content.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/scribble/.content.xml b/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/scribble/.content.xml new file mode 100644 index 0000000000..9d97f4c991 --- /dev/null +++ b/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/scribble/.content.xml @@ -0,0 +1,5 @@ + +