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

FORMS-16342 adding xfa data model in CC #1474

Draft
wants to merge 13 commits into
base: dev
Choose a base branch
from
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -436,4 +436,4 @@ workflows:
branches:
ignore: /.*/
tags:
only: /^core-forms-components-reactor-\d+\.\d+\.\d+$/
only: /^core-forms-components-reactor-\d+\.\d+\.\d+-\w+$/
2 changes: 1 addition & 1 deletion all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-parent</artifactId>
<version>3.0.100-SNAPSHOT</version>
<version>3.0.100-xfaB003-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion bundles/af-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-parent</artifactId>
<version>3.0.100-SNAPSHOT</version>
<version>3.0.100-xfaB003-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

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

import java.io.IOException;
import java.math.BigDecimal;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.*;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -68,9 +58,12 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.node.ArrayNode;

public class AbstractFormComponentImpl extends AbstractComponentImpl implements FormComponent {
@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = ReservedProperties.PN_DATAREF)
Expand Down Expand Up @@ -298,6 +291,10 @@ protected boolean getEditMode() {
if (rulesProperties.size() > 0) {
properties.put(CUSTOM_RULE_PROPERTY_WRAPPER, rulesProperties);
}
List<String> disabledScripts = getDisabledXFAScripts();
if (disabledScripts.size() > 0) {
properties.put("fd:disabledXfaScripts", disabledScripts);
}
return properties;
}

Expand Down Expand Up @@ -550,4 +547,24 @@ public Map<String, Object> getDorProperties() {
return customDorProperties;
}

private List<String> getDisabledXFAScripts() {
Set<String> disabledScripts = new HashSet<>();
String xfaScripts = resource.getValueMap().get("fd:xfaScripts", "");
if (StringUtils.isNotEmpty(xfaScripts)) {
// read string xfaScripts to jsonNode
ObjectMapper mapper = new ObjectMapper();
try {
ArrayNode node = (ArrayNode) mapper.readTree(xfaScripts);
// iterate through the array node and add the elements which have disabled property set to true
for (JsonNode jsonNode : node) {
if (jsonNode.has("disabled") && jsonNode.get("disabled").asBoolean()) {
disabledScripts.add(jsonNode.get("activity").asText());
}
}
} catch (IOException e) {
logger.error("Error while parsing xfaScripts {} {}", e, resource.getPath());
}
}
return new ArrayList<>(disabledScripts);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ public String[] getEnumNames() {
String[] enumName = map.values().toArray(new String[0]);
return Arrays.stream(enumName)
.map(p -> {
return this.translate(ReservedProperties.PN_ENUM_NAMES, p);
String value = this.translate(ReservedProperties.PN_ENUM_NAMES, p);
if (value == null) {
value = "";
}
return value;
})
.toArray(String[]::new);
}
Expand Down
2 changes: 1 addition & 1 deletion bundles/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-parent</artifactId>
<version>3.0.100-SNAPSHOT</version>
<version>3.0.100-xfaB003-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion examples/all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-parent</artifactId>
<version>3.0.100-SNAPSHOT</version>
<version>3.0.100-xfaB003-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion examples/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-parent</artifactId>
<version>3.0.100-SNAPSHOT</version>
<version>3.0.100-xfaB003-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-parent</artifactId>
<version>3.0.100-SNAPSHOT</version>
<version>3.0.100-xfaB003-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion examples/ui.apps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-parent</artifactId>
<version>3.0.100-SNAPSHOT</version>
<version>3.0.100-xfaB003-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion examples/ui.content/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-parent</artifactId>
<version>3.0.100-SNAPSHOT</version>
<version>3.0.100-xfaB003-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion it/apps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-parent</artifactId>
<version>3.0.100-SNAPSHOT</version>
<version>3.0.100-xfaB003-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion it/config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-parent</artifactId>
<version>3.0.100-SNAPSHOT</version>
<version>3.0.100-xfaB003-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion it/content/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-parent</artifactId>
<version>3.0.100-SNAPSHOT</version>
<version>3.0.100-xfaB003-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion it/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-parent</artifactId>
<version>3.0.100-SNAPSHOT</version>
<version>3.0.100-xfaB003-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion jsdocs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-parent</artifactId>
<version>3.0.100-SNAPSHOT</version>
<version>3.0.100-xfaB003-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-parent</artifactId>
<packaging>pom</packaging>
<version>3.0.100-SNAPSHOT</version>
<version>3.0.100-xfaB003-SNAPSHOT</version>

<name>AEM Forms Core Components - Parent</name>
<description>Parent POM for AEM Forms Core Components</description>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-parent</artifactId>
<version>3.0.100-SNAPSHOT</version>
<version>3.0.100-xfaB003-SNAPSHOT</version>
<relativePath>parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion ui.af.apps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-parent</artifactId>
<version>3.0.100-SNAPSHOT</version>
<version>3.0.100-xfaB003-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<!-- ====================================================================== -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
handler="CQ.FormsCoreComponents.editorhooks.viewQualifiedName"
icon="viewSOMExpression"
text="View Qualified Name"/>
<viewXFAScripts
jcr:primaryType="nt:unstructured"
condition="CQ.FormsCoreComponents.editorhooks.hasXfaScripts"
handler="CQ.FormsCoreComponents.editorhooks.viewXfaScripts"
icon="code"
text="View XFA Scripts"/>
</cq:actionConfigs>
<cq:inplaceEditing
jcr:primaryType="cq:InplaceEditingConfig"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
handler="CQ.FormsCoreComponents.editorhooks.viewQualifiedName"
icon="viewSOMExpression"
text="View Qualified Name"/>
<viewXFAScripts
jcr:primaryType="nt:unstructured"
condition="CQ.FormsCoreComponents.editorhooks.hasXfaScripts"
handler="CQ.FormsCoreComponents.editorhooks.viewXfaScripts"
icon="code"
text="View XFA Scripts"/>
</cq:actionConfigs>
<cq:inplaceEditing
jcr:primaryType="cq:InplaceEditingConfig"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,21 @@
Utils = window.CQ.FormsCoreComponents.Utils.v1;

var JSON_SCHEMA = 'jsonschema',
NONE = "none",
NONE = 'none',
FORM_DATA_MODEL = "formdatamodel",
FORM_TEMPLATE = 'formtemplates',
CONNECTOR = "connector",
SCHEMA_REF = "input[name='./schemaRef']",
XDP_REF = "input[name='./xdpRef']",
SCHEMA_TYPE = "input[name='./schemaType']",
SCHEMA_CONTAINER = ".cmp-adaptiveform-container__schemaselectorcontainer",
FDM_CONTAINER = ".cmp-adaptiveform-container__fdmselectorcontainer",
CONNECTOR_CONTAINER = ".cmp-adaptiveform-container__marketoselectorcontainer",
FORM_TEMPLATE_CONTAINER = ".cmp-adaptiveform-container__formtemplateselectorcontainer",
SCHEMA_DROPDOWN_SELECTOR = ".cmp-adaptiveform-container__schemaselector",
FDM_DROPDOWN_SELECTOR = ".cmp-adaptiveform-container__fdmselector",
CONNECTOR_DROPDOWN_SELECTOR = ".cmp-adaptiveform-container__marketoselector",
FORM_TEMPLATE_DROPDOWN_SELECTOR = ".cmp-adaptiveform-container__formtemplateselector",
FORM_MODEL_SELECTOR = ".cmp-adaptiveform-container__selectformmodel",
FM_AF_ROOT = "/content/forms/af/",
FM_DAM_ROOT ="/content/dam/formsanddocuments/",
Expand Down Expand Up @@ -113,9 +117,19 @@
if (isForm()){
var afAssetPath = getAfAssetMetadataPath();
DAM_SCHEMA_TYPE = "[name='" + afAssetPath + "/formmodel']";
DAM_SCHEMA_REF = "[name='" + afAssetPath + "/schemaRef']";
addFormParameter(afAssetPath + '/formmodel', schemaType);
addFormParameter(afAssetPath + '/schemaRef');
if(schemaType == JSON_SCHEMA){
DAM_SCHEMA_REF = "[name='" + afAssetPath + "/schemaRef']";
addFormParameter(afAssetPath + '/schemaRef');
} else if(schemaType == FORM_TEMPLATE){
DAM_SCHEMA_REF = "[name='" + afAssetPath + "/xdpRef']";
addFormParameter(afAssetPath + '/xdpRef');
// we don't want user to change the data model if form template has been selected
dialog.find('coral-selectlist-item[value="none"]').remove();
dialog.find('coral-selectlist-item[value="jsonschema"]').remove();
dialog.find('coral-selectlist-item[value="formdatamodel"]').remove();
dialog.find('coral-selectlist-item[value="connector"]').remove();
}
}
document.body.appendChild(formModelChangeConfirmationDialog);
prefillSchema(schemaType, dialog);
Expand All @@ -133,6 +147,10 @@

function prefillSchema(schemaType, dialog){
var schemaRef = dialog.find(SCHEMA_REF);
// for formtemplates we don't have schemaRef instead xdpRef
if(schemaType == FORM_TEMPLATE){
schemaRef = dialog.find(XDP_REF);
}
if(schemaRef.length > 0){
schemaRef = schemaRef[0].value;
configuredFormModel = schemaRef;
Expand All @@ -143,6 +161,8 @@
$(FDM_DROPDOWN_SELECTOR).val(schemaRef);
} else if (schemaType == CONNECTOR) {
$(CONNECTOR_DROPDOWN_SELECTOR).val(schemaRef);
} else if (schemaType == FORM_TEMPLATE) {
$(FORM_TEMPLATE_DROPDOWN_SELECTOR).val(schemaRef);
}
}
};
Expand Down Expand Up @@ -192,6 +212,21 @@
}
};

function formTemplateSelectorOnChanged(dialog) {
var selectedSchema = dialog.find(FORM_TEMPLATE_DROPDOWN_SELECTOR);
if(selectedSchema.length > 0) {
selectedSchema = selectedSchema[0].value;
setElementValue(dialog, SCHEMA_REF, selectedSchema);
setElementValue(dialog, DAM_SCHEMA_REF, selectedSchema);
isSchemaChanged = true;
if (configuredFormModel) {
confirmFormModelChange(selectedSchema, $(FORM_TEMPLATE_DROPDOWN_SELECTOR));
} else {
toBeConfiguredFormModel = selectedSchema;
}
}
};

function setElementValue(dialog, elementRef, value){
var element = dialog.find(elementRef);
if(element.length > 0){
Expand Down Expand Up @@ -225,20 +260,29 @@
function hideContainersExcept(selectedSchemaType) {
if (selectedSchemaType == JSON_SCHEMA) {
$(FDM_CONTAINER).hide();
$(FORM_TEMPLATE_CONTAINER).hide();
$(CONNECTOR_CONTAINER).hide();
$(SCHEMA_CONTAINER).show();
} else if (selectedSchemaType == FORM_DATA_MODEL) {
$(SCHEMA_CONTAINER).hide();
$(FORM_TEMPLATE_CONTAINER).hide();
$(CONNECTOR_CONTAINER).hide();
$(FDM_CONTAINER).show();
} else if (selectedSchemaType == CONNECTOR) {
$(SCHEMA_CONTAINER).hide();
$(FDM_CONTAINER).hide();
$(FORM_TEMPLATE_CONTAINER).hide();
$(CONNECTOR_CONTAINER).show();
} else if (selectedSchemaType == 'none') {
} else if (selectedSchemaType == FORM_TEMPLATE) {
$(FDM_CONTAINER).hide();
$(CONNECTOR_CONTAINER).hide();
$(SCHEMA_CONTAINER).hide();
$(FORM_TEMPLATE_CONTAINER).show();
} else if (selectedSchemaType == NONE) {
$(FDM_CONTAINER).hide();
$(SCHEMA_CONTAINER).hide();
$(CONNECTOR_CONTAINER).hide();
$(FORM_TEMPLATE_CONTAINER).hide();
}
};

Expand Down Expand Up @@ -266,7 +310,8 @@
var formModelSelector = dialog.find(FORM_MODEL_SELECTOR)[0],
schemaSelector = dialog.find(SCHEMA_DROPDOWN_SELECTOR)[0],
fdmSelector = dialog.find(FDM_DROPDOWN_SELECTOR)[0],
connectorSelector = dialog.find(CONNECTOR_DROPDOWN_SELECTOR)[0];
connectorSelector = dialog.find(CONNECTOR_DROPDOWN_SELECTOR)[0],
formTemplateSelector = dialog.find(FORM_TEMPLATE_DROPDOWN_SELECTOR)[0];
if (formModelSelector) {
formModelSelector.on("change", function() {
selectFormModelOnChanged(dialog);
Expand All @@ -287,6 +332,11 @@
connectorSelectorOnChanged(dialog);
});
};
if(formTemplateSelector) {
formTemplateSelector.on("change", function() {
formTemplateSelectorOnChanged(dialog);
});
}
selectFormModelOnLoad(dialog);
}

Expand Down
Loading