-
Notifications
You must be signed in to change notification settings - Fork 45
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
Star Rating component PR #1100
base: master
Are you sure you want to change the base?
Star Rating component PR #1100
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
~ 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. | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ | ||
|
||
package com.adobe.cq.forms.core.components.internal.models.v1.form; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
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 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.models.form.StarRating; | ||
import com.adobe.cq.forms.core.components.util.AbstractBaseImpl; | ||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
|
||
@Model( | ||
adaptables = { SlingHttpServletRequest.class, Resource.class }, | ||
adapters = { StarRating.class, ComponentExporter.class }, | ||
resourceType = StarRatingImpl.STAR_RESOURCE_TYPE) | ||
@Exporter( | ||
name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, | ||
extensions = ExporterConstants.SLING_MODEL_EXTENSION) | ||
public class StarRatingImpl extends AbstractBaseImpl implements StarRating { | ||
|
||
public static final String STAR_RESOURCE_TYPE = "forms-components-examples/components/form/starrating"; | ||
|
||
@ValueMapValue(name = "starnumber", injectionStrategy = InjectionStrategy.OPTIONAL) | ||
private int starnumber = 5; | ||
|
||
public Object[] getRatingList() { | ||
List<String> ls = new ArrayList<>(); | ||
|
||
for (int i = 0; i < starnumber; i++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will the start rating start from '0'? |
||
ls.add(String.valueOf(i)); // Convert integer to string | ||
} | ||
return ls.toArray(); | ||
} | ||
|
||
@Override | ||
@JsonIgnore | ||
public @NotNull String getExportedType() { | ||
return resource.getResourceType(); | ||
} | ||
|
||
public int getStarNumber() { | ||
return starnumber; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
~ Copyright 2022 Adobe | ||
~ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update year in header |
||
~ 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 StarRating extends Field {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?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:primaryType="cq:Component" | ||
jcr:title="Adaptive Form Star Rating" | ||
jcr:description="Add stars to get feedback from user." | ||
sling:resourceSuperType="core/fd/components/form/starrating/v1/starrating" | ||
cq:icon="star" | ||
componentGroup="Core Components Examples - Adaptive Form"/> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?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="Star Rating" | ||
starnumber="5" | ||
fieldType="number-input" | ||
type="number"/> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
~ Copyright 2022 Adobe | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update year in header |
||
~ | ||
~ 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. | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--> | ||
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" | ||
jcr:primaryType="sling:Folder" /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
~ Copyright 2022 Adobe | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update year in header |
||
~ | ||
~ 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. | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--> | ||
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" | ||
jcr:primaryType="nt:unstructured"> | ||
</jcr:root> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?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:primaryType="cq:Component" | ||
jcr:title="Adaptive Form Star Rating" | ||
jcr:description="Add stars to get feedback from user." | ||
sling:resourceSuperType="core/fd/components/form/base/v1/base" | ||
cq:icon="star" | ||
componentGroup="Core Components Examples - Adaptive Form"/> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
~ Copyright 2022 Adobe | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update year in header |
||
~ | ||
~ 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. | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--> | ||
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:granite="http://www.adobe.com/jcr/granite/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="nt:unstructured" | ||
jcr:title="Adaptive Form Star Rating field" | ||
sling:resourceType="cq/gui/components/authoring/dialog" | ||
extraClientlibs="[core.forms.components.starrating.v1.editor]" | ||
helpPath="https://www.adobe.com/go/aem_af_cmp_starrating_v1" | ||
trackingFeature="core-components:adaptiveform-starrating:v1"> | ||
<content jcr:primaryType="nt:unstructured" | ||
granite:class="cmp-adaptiveform-starrating__editdialog" | ||
sling:resourceType="granite/ui/components/coral/foundation/container"> | ||
<items jcr:primaryType="nt:unstructured"> | ||
<tabs jcr:primaryType="nt:unstructured" | ||
sling:resourceType="granite/ui/components/coral/foundation/tabs" | ||
maximized="{Boolean}true"> | ||
<items jcr:primaryType="nt:unstructured"> | ||
<basic jcr:primaryType="nt:unstructured" | ||
jcr:title="Basic" | ||
sling:resourceType="granite/ui/components/coral/foundation/container" | ||
active="{Boolean}true" | ||
selected="{Boolean}true"> | ||
<items jcr:primaryType="nt:unstructured"> | ||
<columns | ||
jcr:primaryType="nt:unstructured" | ||
sling:resourceType="granite/ui/components/coral/foundation/fixedcolumns" | ||
margin="{Boolean}true"> | ||
<items jcr:primaryType="nt:unstructured"> | ||
<column | ||
jcr:primaryType="nt:unstructured" | ||
sling:resourceType="granite/ui/components/coral/foundation/container"> | ||
<items jcr:primaryType="nt:unstructured"> | ||
<placeholder jcr:primaryType="nt:unstructured" | ||
sling:hideResource="{Boolean}true"/> | ||
<enums jcr:primaryType="nt:unstructured" | ||
sling:resourceType="granite/ui/components/coral/foundation/include" | ||
path="core/fd/components/form/base/v1/base/cq:dialog/content/items/tabs/items/basic/items/columns/items/column/items/enums" | ||
sling:orderBefore="bindref" | ||
sling:hideResource="{Boolean}true"/> | ||
|
||
<column jcr:primaryType="nt:unstructured" | ||
sling:resourceType="granite/ui/components/coral/foundation/container"> | ||
<items jcr:primaryType="nt:unstructured"> | ||
<title jcr:primaryType="nt:unstructured" | ||
sling:orderAfter="Hide Title" | ||
sling:resourceType="granite/ui/components/coral/foundation/form/numberfield" | ||
fieldLabel="Number of Stars" | ||
name="./starnumber" | ||
min="1" | ||
max="10" | ||
value="5"/> | ||
</items> | ||
</column> | ||
|
||
</items> | ||
</column> | ||
</items> | ||
</columns> | ||
</items> | ||
</basic> | ||
<validation jcr:primaryType="nt:unstructured" | ||
jcr:title="Validation" | ||
sling:resourceType="granite/ui/components/coral/foundation/container"> | ||
<items jcr:primaryType="nt:unstructured"/> | ||
</validation> | ||
<patterns jcr:primaryType="nt:unstructured" | ||
sling:hideResource="{Boolean}true"/> | ||
<help jcr:primaryType="nt:unstructured" | ||
jcr:title="Help Content" | ||
sling:resourceType="granite/ui/components/coral/foundation/container"> | ||
<items jcr:primaryType="nt:unstructured"/> | ||
</help> | ||
<accessibility jcr:primaryType="nt:unstructured" | ||
jcr:title="Accessibility" | ||
sling:resourceType="granite/ui/components/coral/foundation/container"> | ||
<items jcr:primaryType="nt:unstructured"> | ||
<columns | ||
jcr:primaryType="nt:unstructured" | ||
sling:resourceType="granite/ui/components/coral/foundation/fixedcolumns" | ||
margin="{Boolean}true"> | ||
<items jcr:primaryType="nt:unstructured"> | ||
<column | ||
jcr:primaryType="nt:unstructured" | ||
sling:resourceType="granite/ui/components/coral/foundation/container"> | ||
<items jcr:primaryType="nt:unstructured"> | ||
<assistPriority | ||
jcr:primaryType="nt:unstructured" | ||
sling:hideResource="{Boolean}true"/> | ||
<assistPriorityCustom | ||
jcr:primaryType="nt:unstructured" | ||
sling:orderBefore="customText" | ||
sling:resourceType="granite/ui/components/coral/foundation/form/select" | ||
granite:class="cmp-adaptiveform-starrating__assistprioritycustom" | ||
fieldLabel="Text for screen readers" | ||
name="./assistPriority" | ||
value=""> | ||
<items jcr:primaryType="nt:unstructured"> | ||
<empty | ||
jcr:primaryType="nt:unstructured" | ||
text="" | ||
value=""/> | ||
<customText | ||
jcr:primaryType="nt:unstructured" | ||
text="Custom text" | ||
value="custom"/> | ||
<caption | ||
jcr:primaryType="nt:unstructured" | ||
text="Title" | ||
value="caption"/> | ||
</items> | ||
</assistPriorityCustom> | ||
<customText | ||
jcr:primaryType="nt:unstructured" | ||
sling:resourceType="granite/ui/components/coral/foundation/form/multifield" | ||
wrapperClass="cmp-adaptiveform-starrating__customtext" | ||
fieldLabel="Custom text"> | ||
<granite:data | ||
jcr:primaryType="nt:unstructured" | ||
wrapper-class="custom-text-wrapper"/> | ||
<field | ||
jcr:primaryType="nt:unstructured" | ||
sling:resourceType="granite/ui/components/coral/foundation/form/textfield" | ||
name="./custom"/> | ||
</customText> | ||
</items> | ||
</column> | ||
</items> | ||
</columns> | ||
</items> | ||
</accessibility> | ||
</items> | ||
</tabs> | ||
</items> | ||
</content> | ||
</jcr:root> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update year in header