Skip to content

Commit

Permalink
Merge pull request #928 from adobe/adobe/devToMaster
Browse files Browse the repository at this point in the history
Adobe/dev to master
  • Loading branch information
rismehta authored Oct 16, 2023
2 parents d82c48a + decce62 commit 4fd7884
Show file tree
Hide file tree
Showing 196 changed files with 6,837 additions and 297 deletions.
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ jobs:
# update readme.md
sed -i -E "s/(\| $LAST_VERSION\s*\|) [0-9]+\.[0-9]+\.[0-9]+ \s*\| /| $NEW_VERSION | $WCM_CORE_COMPONENTS_VERSION | /g" README.md
# Check if package-lock.json is modified
if [[ $(git status --porcelain | grep "package-lock.json") ]]; then
# Discard the changes to package-lock.json (if needed)
git checkout -- '**/package-lock.json'
fi
git add VERSIONS.md README.md
git commit -m "Update VERSIONS.md and README.md to include version ${NEW_VERSION}"
git push origin $RELEASE_BRANCH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ private FormConstants() {
/** The resource type for checkbox v1 */
public static final String RT_FD_FORM_CHECKBOX_V1 = RT_FD_FORM_PREFIX + "checkbox/v1/checkbox";

/** The resource type for switch v1 */
public static final String RT_FD_FORM_SWITCH_V1 = RT_FD_FORM_PREFIX + "switch/v1/switch";

/** The resource type for date picker v1 */
public static final String RT_FD_FORM_DATE_PICKER_V1 = RT_FD_FORM_PREFIX + "datepicker/v1/datepicker";

Expand Down Expand Up @@ -108,6 +111,9 @@ private FormConstants() {

public static final String RT_FD_FRAGMENT_CONTAINER_V1 = RT_FD_FORM_PREFIX + "fragmentcontainer/v1/fragmentcontainer";

/** The resource type for terms and conditions v1 */
public static final String RT_FD_FORM_TERMS_AND_CONDITIONS_V1 = RT_FD_FORM_PREFIX + "termsandconditions/v1/termsandconditions";

public static final String FORM_FIELD_TYPE = "form";

public static final String REQ_ATTR_FORMCONTAINER_PATH = "formContainerPath";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2022 Adobe
~ Copyright 2023 Adobe
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand All @@ -15,25 +15,16 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package com.adobe.cq.forms.core.components.internal.models.v1.form;

import java.util.Map;

import javax.annotation.Nullable;
import javax.annotation.PostConstruct;

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.internal.form.FormConstants;
import com.adobe.cq.forms.core.components.models.form.CheckBox;
import com.adobe.cq.forms.core.components.util.AbstractOptionsFieldImpl;
import com.adobe.cq.forms.core.components.util.ComponentUtils;
import com.adobe.cq.forms.core.components.util.AbstractCheckboxImpl;

@Model(
adaptables = { SlingHttpServletRequest.class, Resource.class },
Expand All @@ -42,54 +33,4 @@
@Exporter(
name = ExporterConstants.SLING_MODEL_EXPORTER_NAME,
extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class CheckBoxImpl extends AbstractOptionsFieldImpl implements CheckBox {

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "orientation")
@Nullable
protected String orientationJcr;
private Orientation orientation;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
private String checkedValue;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
private String uncheckedValue;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
private Boolean enableUncheckedValue;

@PostConstruct
private void initCheckBoxModel() {
orientation = Orientation.fromString(orientationJcr);
if (!Type.BOOLEAN.equals(type)) {
if (Boolean.TRUE.equals(enableUncheckedValue)) {
enums = new String[] { checkedValue, uncheckedValue };
} else {
enums = new String[] { checkedValue };
}
}
}

@Override
public @NotNull Map<String, Object> getCustomLayoutProperties() {
Map<String, Object> customLayoutProperties = super.getCustomLayoutProperties();
if (orientation != null) {
customLayoutProperties.put("orientation", orientation);
}
return customLayoutProperties;
}

@Override
public Orientation getOrientation() {
return orientation;
}

@Override
public Object[] getEnums() {
if (enums == null) {
return null;
} else {
return ComponentUtils.coerce(type, enums);
}
}
}
public class CheckBoxImpl extends AbstractCheckboxImpl implements CheckBox {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2023 Adobe
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package com.adobe.cq.forms.core.components.internal.models.v1.form;

import javax.annotation.PostConstruct;

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.Switch;
import com.adobe.cq.forms.core.components.util.AbstractCheckboxImpl;

@Model(
adaptables = { SlingHttpServletRequest.class, Resource.class },
adapters = { Switch.class,
ComponentExporter.class },
resourceType = { FormConstants.RT_FD_FORM_SWITCH_V1 })
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class SwitchImpl extends AbstractCheckboxImpl implements Switch {
@PostConstruct
public void initSwitchModel() {
if (enumNames != null) {
String[] enumNameArray = enumNames;
enumNames = Boolean.TRUE.equals(enableUncheckedValue) ? new String[] { enumNameArray[0], enumNameArray[1] }
: new String[] { enumNameArray[0] };
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2023 Adobe
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

package com.adobe.cq.forms.core.components.internal.models.v1.form;

import java.util.List;
import java.util.Map;

import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Default;
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.jetbrains.annotations.NotNull;

import com.adobe.cq.export.json.ComponentExporter;
import com.adobe.cq.export.json.ExporterConstants;
import com.adobe.cq.forms.core.components.internal.form.FormConstants;
import com.adobe.cq.forms.core.components.models.form.FieldType;
import com.adobe.cq.forms.core.components.models.form.TermsAndConditions;
import com.fasterxml.jackson.annotation.JsonIgnore;

@Model(
adaptables = { SlingHttpServletRequest.class, Resource.class },
adapters = { TermsAndConditions.class,
ComponentExporter.class },
resourceType = { FormConstants.RT_FD_FORM_TERMS_AND_CONDITIONS_V1 })

@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class TermsAndConditionsImpl extends PanelImpl implements TermsAndConditions {

private static final String CUSTOM_TNC_PROPERTY = "fd:tnc";

private static final String FIELD_TYPE = "fieldType";

@JsonIgnore
@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
@Default(booleanValues = true)
private boolean showApprovalOption;

@JsonIgnore
@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
@Default(booleanValues = false)
private boolean showLink;

@JsonIgnore
@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
@Default(booleanValues = false)
private boolean showAsPopup;

@Override
public boolean isShowApprovalOption() {
return showApprovalOption;
}

@Override
public boolean isShowLink() {
return showLink;
}

@Override
public boolean isShowAsPopup() {
return showAsPopup;
}

@Override
public @NotNull String getId() {
return super.getId();
}

@Override
public @NotNull Map<String, Object> getProperties() {
Map<String, Object> properties = super.getProperties();
if (resource.getValueMap().containsKey(CUSTOM_TNC_PROPERTY)) {
properties.put(CUSTOM_TNC_PROPERTY, true);
}
return properties;
}

@Override
protected List<Resource> getFilteredChildrenResources() {
List<Resource> childResources = getFilteredChildrenResources(resource);
// the tnc component will either have links or consent text based upon showLink value
if (showLink) {
childResources.removeIf(child -> FieldType.PLAIN_TEXT.getValue().equals(child.getValueMap().get(FIELD_TYPE)));

} else {
childResources.removeIf(child -> FieldType.CHECKBOX_GROUP.getValue().equals(child.getValueMap().get(FIELD_TYPE)));
}
return childResources;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,10 @@
/**
* Interface for a label
*
* @since com.adobe.cq.forms.core.components.models.form 0.0.1
* @since com.adobe.cq.forms.core.components.models.form 4.6.0
*/
@ConsumerType
public interface Label {

/**
* Returns {@code true} if label is rich text, otherwise {@code false}.
*
* @return {@code true} if label is rich text, otherwise {@code false}
* @since com.adobe.cq.forms.core.components.models.form 0.0.1
*/
@Nullable
default Boolean isRichText() {
return null;
}
public interface Label extends TextContent {

/**
* Returns {@code true} if label should be visible, otherwise {@code false}.
Expand All @@ -48,15 +37,4 @@ default Boolean isVisible() {
return null;
}

/**
* Returns the value of this label.
*
* @return the value of this label
* @since com.adobe.cq.forms.core.components.models.form 0.0.1
*/
@Nullable
default String getValue() {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.osgi.annotation.versioning.ProviderType;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
Expand Down Expand Up @@ -57,5 +58,17 @@ default boolean isEnforceEnum() {
* @return the list of enum names
* @since com.adobe.cq.forms.core.components.models.form 0.0.1
*/
@Deprecated
@JsonIgnore
String[] getEnumNames();

/**
* Returns a list of RichText to be displayed to the end user.
* The length of enum and enumNames array must match
*
* @return the list of enum names
* @since com.adobe.cq.forms.core.components.models.form 4.6.0
*/
@JsonProperty("enumNames")
TextContent[] getEnumNamesAsTextContent();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2023 Adobe
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package com.adobe.cq.forms.core.components.models.form;

import org.osgi.annotation.versioning.ConsumerType;

/**
* Defines the {@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 Switch extends CheckBox {}
Loading

0 comments on commit 4fd7884

Please sign in to comment.