Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Number stepper component #1099

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -59,6 +59,9 @@ private FormConstants() {
/** The resource type for number input v1 */
public static final String RT_FD_FORM_NUMBER_INPUT_V1 = RT_FD_FORM_PREFIX + "numberinput/v1/numberinput";

/** The resource type for number input v1 */
public static final String RT_FD_FORM_NUMBER_STEPPER_V1 = RT_FD_FORM_PREFIX + "numberstepper/v1/numberstepper";

/** The resource type for drop down v1 */
public static final String RT_FD_FORM_DROP_DOWN_V1 = RT_FD_FORM_PREFIX + "dropdown/v1/dropdown";

Expand Down
@@ -0,0 +1,46 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ 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.Exporter;
import org.apache.sling.models.annotations.Model;

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.NumberStepper;
import com.adobe.cq.forms.core.components.internal.models.v1.form.NumberStepperImpl;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;

@Model(
adaptables = { SlingHttpServletRequest.class, Resource.class },
adapters = { NumberStepper.class,
ComponentExporter.class },
resourceType = { FormConstants.RT_FD_FORM_NUMBER_STEPPER_V1 })
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class NumberStepperImpl extends NumberInputImpl implements NumberStepper {

@ValueMapValue(name = "step", injectionStrategy = InjectionStrategy.OPTIONAL)
private Integer step;

@Override
public Integer getStep() {
return step;
}
}
@@ -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;

/**
* Defines the {@code Switch} Sling Model used for the {@code /apps/core/fd/components/form/switch} component.
*
* @since com.adobe.cq.forms.core.components.models 4.7.0
*/
@ConsumerType
public interface NumberStepper extends NumberInput {

default Integer getStep() {
return null;
}
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:description="Add a field to capture numeric input"
jcr:primaryType="cq:Component"
jcr:title="Adaptive Form Numeric Stepper"
sling:resourceSuperType="core/fd/components/form/numberstepper/v1/numberstepper"
componentGroup="Core Components Examples - Adaptive Form"/>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0"
jcr:primaryType="nt:unstructured"
jcr:title="Number Stepper"
fieldType="number-stepper"/>
@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:fd="http://www.adobe.com/aemfd/fd/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Page">
<jcr:content
cq:lastModified="{Date}2020-07-15T13:25:39.732+02:00"
cq:lastModifiedBy="admin"
cq:tags="[]"
cq:template="/conf/core-components-examples/settings/wcm/templates/content-page"
jcr:description="Number Stepper"
jcr:primaryType="cq:PageContent"
jcr:title="Number Stepper"
sling:resourceType="forms-components-examples/components/page">
<root
jcr:primaryType="nt:unstructured"
sling:resourceType="wcm/foundation/components/responsivegrid">
<responsivegrid
jcr:primaryType="nt:unstructured"
sling:resourceType="wcm/foundation/components/responsivegrid">
<text_1740702241
cq:styleIds="[1644862132301]"
jcr:created="{Date}2019-02-15T19:05:53.032+01:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2019-02-15T19:09:39.787+01:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="core/wcm/components/text/v2/text"
text="&lt;h1>Number Stepper&lt;sub>v1&lt;/sub>&lt;/h1>"
textIsRich="true"/>
<text
cq:styleIds="[1544762734201]"
jcr:created="{Date}2018-12-06T19:11:23.947+01:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2020-07-15T13:25:39.729+02:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="core/wcm/components/text/v2/text"
text="&lt;p>A Number Stepper component in an Adaptive form is a type of form field that allows users to input numerical values. The component is typically represented by a text field with a up and down arrow for incrementing and decrementing the number.&lt;/p>&lt;p>It can also be used with attributes like min, max, step, value, and more. These attributes can be used to set the minimum and maximum values allowed in the field, the step interval for incrementing or decrementing the number, and the default value of the field.&lt;/p>&lt;p>This component can be used to gather numerical data like age, quantity, and more. and can also be used to perform mathematical operations like addition and subtraction. This component can also be used to validate the numerical data entered by the user.&lt;/p>&lt;p>For accessibility, it is important to specify 'label' that describes the purpose of the number input field, and what kind of input is expected.&lt;/p>
"
textIsRich="true"/>
<teaser
cq:styleIds="[1550165685463]"
jcr:created="{Date}2019-02-14T16:41:54.952+01:00"
jcr:createdBy="admin"
jcr:description="&lt;p>GitHub&lt;/p>&#xd;&#xa;"
jcr:lastModified="{Date}2019-02-14T16:49:57.290+01:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
jcr:title="Technical Documentation"
sling:resourceType="core-components-examples/components/teaser"
actionsEnabled="false"
descriptionFromPage="false"
fileReference="/content/dam/core-components-examples/library/github-logo.svg"
linkURL="https://github.com/adobe/aem-core-forms-components/tree/master/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/numberstepper/v1/numberstepper"
textIsRich="true"
titleFromPage="false"/>
<title_865328580
cq:styleIds="[1544759664489]"
jcr:created="{Date}2018-12-06T19:22:23.729+01:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2018-12-06T19:23:25.116+01:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
jcr:title="Examples"
sling:resourceType="core/wcm/components/title/v2/title"
type="h2"/>
<title_290384408
cq:styleIds="[1544759676459]"
jcr:created="{Date}2018-12-06T19:22:48.620+01:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2019-05-22T11:01:40.926+03:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
jcr:title="Standard"
sling:resourceType="core/wcm/components/title/v2/title"
type="h3"/>
<text_1337506761
jcr:created="{Date}2018-12-06T19:23:41.968+01:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2019-05-22T11:26:32.604+03:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="core/wcm/components/text/v2/text"
text="&lt;p>Simple Number Stepper with an &quot;up&quot; and &quot;down&quot; arrow for incrementing and decrementing the number&lt;/p>"
textIsRich="true"/>
<demo
jcr:created="{Date}2018-12-07T12:55:03.496+01:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2018-12-07T12:55:03.496+01:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="forms-components-examples/components/demo">
<component
jcr:primaryType="nt:unstructured"
sling:resourceType="forms-components-examples/components/demo/component">
<guideContainer
fd:version="2.1"
fieldType="form"
jcr:primaryType="nt:unstructured"
sling:resourceType="forms-components-examples/components/form/container">
<container
jcr:primaryType="nt:unstructured"
sling:resourceType="forms-components-examples/components/demo/component">
<numberinput_demo
jcr:title="Number Input"
fieldType="number-input"
jcr:created="{Date}2019-03-06T14:11:01.819+01:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2019-05-21T18:59:35.605+03:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
description="&lt;p>This is a long description.&lt;/p>"
tooltip="&lt;p>This is a short description.&lt;/p>"
tooltipVisible="true"
sling:resourceType="forms-components-examples/components/form/numberstepper"/>
</container>
</guideContainer>
</component>
<info
jcr:primaryType="nt:unstructured"
sling:resourceType="core-components-examples/components/tabs">
<properties
cq:panelTitle="Properties"
jcr:primaryType="nt:unstructured"
sling:resourceType="core-components-examples/components/demo/properties"
reference="../../component/guideContainer/container"/>
<markup
cq:panelTitle="Markup"
jcr:primaryType="nt:unstructured"
sling:resourceType="core-components-examples/components/demo/markup"
reference="../../component/guideContainer/container"/>
<json
cq:panelTitle="JSON"
jcr:primaryType="nt:unstructured"
sling:resourceType="core-components-examples/components/demo/json"
reference="../../component/guideContainer/container"/>
</info>
</demo>
</responsivegrid>
</root>
</jcr:content>
</jcr:root>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"
jcr:mixinTypes="[rep:AccessControllable]"
jcr:primaryType="sling:Folder"
hidden="true"/>