diff --git a/src/main/archetype/all/pom.xml b/src/main/archetype/all/pom.xml index d67ca5d97..7ef4d3822 100644 --- a/src/main/archetype/all/pom.xml +++ b/src/main/archetype/all/pom.xml @@ -181,7 +181,7 @@ #end #end -#if ( ($includeForms == "y" or $includeFormsenrollment == "y" or $includeFormscommunications == "y" or $includeFormsheadless == "y") and $aemVersion == "cloud" ) +#if ( ($includeForms == "y" or $includeFormsenrollment == "y" or $includeFormscommunications == "y" or $includeFormsheadless == "y") and $aemVersion != "cloud" ) com.adobe.aem core-forms-components-apps @@ -397,7 +397,7 @@ zip #end -#if ( ($includeForms == "y" or $includeFormsenrollment == "y" or $includeFormscommunications == "y" or $includeFormsheadless == "y") and $aemVersion == "cloud" ) +#if ( ($includeForms == "y" or $includeFormsenrollment == "y" or $includeFormscommunications == "y" or $includeFormsheadless == "y") and $aemVersion != "cloud" ) com.adobe.aem diff --git a/src/main/archetype/core/pom.xml b/src/main/archetype/core/pom.xml index 451803854..6e4cb603e 100644 --- a/src/main/archetype/core/pom.xml +++ b/src/main/archetype/core/pom.xml @@ -207,16 +207,18 @@ Import-Package: javax.annotation;version=0.0.0,* #end #end -#if ( ($includeForms == "y" or $includeFormsenrollment == "y" or $includeFormscommunications == "y" or $includeFormsheadless == "y") and $aemVersion == "cloud" ) +#if ($includeForms == "y" or $includeFormsenrollment == "y" or $includeFormscommunications == "y" or $includeFormsheadless == "y") com.adobe.aem aem-forms-sdk-api + #if ($aemVersion != "cloud") com.adobe.aem core-forms-components-core + #end #end diff --git a/src/main/archetype/ui.apps/pom.xml b/src/main/archetype/ui.apps/pom.xml index ea506854e..010c6a04d 100644 --- a/src/main/archetype/ui.apps/pom.xml +++ b/src/main/archetype/ui.apps/pom.xml @@ -84,7 +84,7 @@ core-cif-components-apps #end -#if ( ($includeForms == "y" or $includeFormsenrollment == "y" or $includeFormscommunications == "y" or $includeFormsheadless == "y") and $aemVersion == "cloud" ) +#if ( ($includeForms == "y" or $includeFormsenrollment == "y" or $includeFormscommunications == "y" or $includeFormsheadless == "y") and $aemVersion != "cloud" ) com.adobe.aem core-forms-components-apps @@ -334,21 +334,23 @@ Require-Capability: osgi.extender;filter:="(&(osgi.extender=sling.scripting)(ver #end #end -#if ( ($includeForms == "y" or $includeFormsenrollment == "y" or $includeFormscommunications == "y" or $includeFormsheadless == "y") and $aemVersion == "cloud") +#if ($includeForms == "y" or $includeFormsenrollment == "y" or $includeFormscommunications == "y" or $includeFormsheadless == "y") com.adobe.aem aem-forms-sdk-api - - com.adobe.aem - core-forms-components-apps - zip - - - com.adobe.aem - core-forms-components-core - + #if ($aemVersion != "cloud") + + com.adobe.aem + core-forms-components-apps + zip + + + com.adobe.aem + core-forms-components-core + + #end #end diff --git a/src/main/archetype/ui.content/src/main/content/jcr_root/conf/__appId__/settings/wcm/templates/blank-af-v2/.content.xml b/src/main/archetype/ui.content/src/main/content/jcr_root/conf/__appId__/settings/wcm/templates/blank-af-v2/.content.xml index f3576e87c..e71212dee 100644 --- a/src/main/archetype/ui.content/src/main/content/jcr_root/conf/__appId__/settings/wcm/templates/blank-af-v2/.content.xml +++ b/src/main/archetype/ui.content/src/main/content/jcr_root/conf/__appId__/settings/wcm/templates/blank-af-v2/.content.xml @@ -6,6 +6,6 @@ cq:lastModifiedBy="admin" cq:templateType="/conf/${appId}/settings/wcm/template-types/af-page-v2" jcr:primaryType="cq:PageContent" - jcr:title="${appId} - Blank With Core Components" + jcr:title="Blank With Core Components" status="enabled"/> diff --git a/src/main/archetype/ui.frontend.react.forms.af/src/Form.tsx b/src/main/archetype/ui.frontend.react.forms.af/src/Form.tsx index ee9d47c45..cd1a3b3a2 100644 --- a/src/main/archetype/ui.frontend.react.forms.af/src/Form.tsx +++ b/src/main/archetype/ui.frontend.react.forms.af/src/Form.tsx @@ -6,6 +6,24 @@ import ReactDOM from "react-dom"; //@ts-ignore import {Provider as Spectrum3Provider, defaultTheme} from '@adobe/react-spectrum' +const base64url = (s: any) => { + var to64url = btoa(s); + // Replace non-url compatible chars with base64url standard chars and remove leading = + return to64url.replace(/\+/g, '_').replace(/\//g, '-').replace(/=+${symbol_dollar}/g, ''); +} + + +export const getId = () => { + let id = "" + if (!process.env.FORMPATH) { + debugger; + const parent = document.querySelector(".cmp-formcontainer") + id = parent.getAttribute("data-form-id") + } else { + id = base64url(process.env.FORMPATH) + } + return id; +} const getForm = async (id: string) => { const resp = await fetch(`/adobe/forms/af/v1/${symbol_dollar}{id}`) @@ -14,12 +32,14 @@ const getForm = async (id: string) => { } const Form = (props: any) => { - const {id} = props; const [form, setForm] = useState("") const [state, setState] = useEditorEvents() const fetchForm = async () => { - const json:any = await getForm(id); - setForm(JSON.stringify(json.afModelDefinition)) + let id = getId(); + if (id) { + const json:any = await getForm(id); + setForm(JSON.stringify(json.afModelDefinition)) + } } useEffect(() => { fetchForm() @@ -27,8 +47,8 @@ const Form = (props: any) => { if (form != "") { const element = document.querySelector(".cmp-formcontainer__content") const retVal = ( - - ) + + ) return ReactDOM.createPortal(retVal, element) } return null diff --git a/src/main/archetype/ui.frontend.react.forms.af/src/index.tsx b/src/main/archetype/ui.frontend.react.forms.af/src/index.tsx index 5b4fc9645..cb7aa22de 100644 --- a/src/main/archetype/ui.frontend.react.forms.af/src/index.tsx +++ b/src/main/archetype/ui.frontend.react.forms.af/src/index.tsx @@ -3,25 +3,6 @@ import ReactDOM from 'react-dom'; // @ts-ignore import AForm from './Form' -const base64url = (s: any) => { - var to64url = btoa(s); - // Replace non-url compatible chars with base64url standard chars and remove leading = - return to64url.replace(/\+/g, '_').replace(/\//g, '-').replace(/=+${symbol_dollar}/g, ''); -} - - -const getId = () => { - let id = "" - if (!process.env.FORMPATH) { - const parent = document.querySelector(".cmp-formcontainer") - id = parent.getAttribute("data-form-id") - } else { - id = base64url(process.env.FORMPATH) - } - return id; -} - - window.onload = async () => { let div = document.getElementById("form-app"); if (!div) { @@ -30,7 +11,7 @@ window.onload = async () => { document.body.appendChild(div) } ReactDOM.render( - , + , div ); }; \ No newline at end of file diff --git a/src/main/archetype/ui.frontend.react.forms.af/webpack.common.js b/src/main/archetype/ui.frontend.react.forms.af/webpack.common.js index 3f78f1612..4c94d3158 100644 --- a/src/main/archetype/ui.frontend.react.forms.af/webpack.common.js +++ b/src/main/archetype/ui.frontend.react.forms.af/webpack.common.js @@ -40,6 +40,6 @@ module.exports = { filename: '[name].js', path: path.resolve(__dirname, 'dist'), clean: true, - //sourceMapFilename: `forms-react-components/resources/[name].map[ext]` uncomment for debugging + //sourceMapFilename: `clientlib-forms-react/resources/[name].map[ext]` // uncomment for debugging } };