From c6d3869f8e61700faef12096375e2b5534e4d72f Mon Sep 17 00:00:00 2001 From: barshatr Date: Mon, 20 Jun 2022 16:12:21 +0530 Subject: [PATCH 1/3] CQ-4343453 Exclude forms core components if cloud --- src/main/archetype/all/pom.xml | 4 ++-- src/main/archetype/ui.apps/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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/ui.apps/pom.xml b/src/main/archetype/ui.apps/pom.xml index ea506854e..cfe059b3e 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,7 +334,7 @@ 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") and $aemVersion != "cloud") com.adobe.aem From 714ce0d6154494e23f4a65d07f56ef8724fcec28 Mon Sep 17 00:00:00 2001 From: barshatr Date: Mon, 20 Jun 2022 18:14:14 +0530 Subject: [PATCH 2/3] CQ-4343453 include sdk api for cloud --- src/main/archetype/core/pom.xml | 4 +++- src/main/archetype/ui.apps/pom.xml | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) 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 cfe059b3e..010c6a04d 100644 --- a/src/main/archetype/ui.apps/pom.xml +++ b/src/main/archetype/ui.apps/pom.xml @@ -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 From f967c1b22455023e05d184a23d604524a2df7fb5 Mon Sep 17 00:00:00 2001 From: barshatr Date: Tue, 21 Jun 2022 16:18:39 +0530 Subject: [PATCH 3/3] CQ-4343453 minor changes --- .../wcm/templates/blank-af-v2/.content.xml | 2 +- .../ui.frontend.react.forms.af/src/Form.tsx | 30 +++++++++++++++---- .../ui.frontend.react.forms.af/src/index.tsx | 21 +------------ .../webpack.common.js | 2 +- 4 files changed, 28 insertions(+), 27 deletions(-) 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 } };