-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1388 from adobe/devMaster9Sep
Dev master9 sep
- Loading branch information
Showing
51 changed files
with
1,426 additions
and
983 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...src/main/content/jcr_root/apps/forms-core-components-it/components/container/.content.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"/> |
5 changes: 5 additions & 0 deletions
5
.../main/content/jcr_root/apps/forms-core-components-it/components/container/v1/.content.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?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" | ||
jcr:primaryType="nt:unstructured"> | ||
<container/> | ||
</jcr:root> |
9 changes: 9 additions & 0 deletions
9
...ent/jcr_root/apps/forms-core-components-it/components/container/v1/container/.content.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
cq:icon="form" | ||
cq:isContainer="{Boolean}true" | ||
jcr:description="Container allowing to construct adaptive forms" | ||
jcr:primaryType="cq:Component" | ||
jcr:title="Adaptive Form Container (loader)" | ||
sling:resourceSuperType="core/fd/components/form/container/v2/container" | ||
componentGroup=".core-wcm"/> |
19 changes: 19 additions & 0 deletions
19
..._root/apps/forms-core-components-it/components/container/v1/container/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!-- | ||
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. | ||
--> | ||
Adaptive Form Container (loader) | ||
==== | ||
Adaptive Form container extending OOTB form container | ||
and additionally added support for loader icon during submit |
8 changes: 8 additions & 0 deletions
8
...apps/forms-core-components-it/components/container/v1/container/_cq_template/.content.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:fd="http://www.adobe.com/aemfd/fd/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="Form Container" | ||
fd:version="2.1" | ||
fieldType="form"> | ||
<cq:responsive jcr:primaryType="nt:unstructured"/> | ||
</jcr:root> |
3 changes: 3 additions & 0 deletions
3
...t/apps/forms-core-components-it/components/container/v1/container/clientlibs/.content.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"/> |
7 changes: 7 additions & 0 deletions
7
...s/forms-core-components-it/components/container/v1/container/clientlibs/site/.content.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" | ||
jcr:primaryType="cq:ClientLibraryFolder" | ||
allowProxy="{Boolean}true" | ||
categories="[core.forms.components.it.container.v1.runtime]" | ||
jsProcessor="[default:none,min:none]" | ||
dependencies="[core.forms.components.runtime.base]"/> |
18 changes: 18 additions & 0 deletions
18
...t/apps/forms-core-components-it/components/container/v1/container/clientlibs/site/css.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
############################################################################### | ||
# 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. | ||
############################################################################### | ||
|
||
#base=css | ||
formcontainerview.css |
22 changes: 22 additions & 0 deletions
22
...components-it/components/container/v1/container/clientlibs/site/css/formcontainerview.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/******************************************************************************* | ||
* 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. | ||
******************************************************************************/ | ||
|
||
form:not(.cmp-adaptiveform-container--edit) [data-cmp-visible="false"] { | ||
display: none !important; | ||
} | ||
.cmp-adaptiveform-container--loading{ | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...ot/apps/forms-core-components-it/components/container/v1/container/clientlibs/site/js.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
############################################################################### | ||
# 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. | ||
############################################################################### | ||
|
||
#base=js | ||
formcontainerview.js |
167 changes: 167 additions & 0 deletions
167
...e-components-it/components/container/v1/container/clientlibs/site/js/formcontainerview.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
/******************************************************************************* | ||
* 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. | ||
******************************************************************************/ | ||
|
||
(function() { | ||
|
||
"use strict"; | ||
class FormContainerV2 extends FormView.FormContainer { | ||
static NS = FormView.Constants.NS; | ||
static IS = "adaptiveFormContainer"; | ||
static bemBlock = 'cmp-adaptiveform-container'; | ||
static selectors = { | ||
self: "[data-" + this.NS + '-is="' + this.IS + '"]', | ||
}; | ||
static loadingClass = `${FormContainerV2.bemBlock}--loading`; | ||
constructor(params) { | ||
super(params); | ||
let self = this; | ||
// Function to add the loading class | ||
const addLoadingClass = (formId) => { | ||
const formContainer = document.querySelector(`[data-cmp-adaptiveform-container-loader='${formId}']`); | ||
if (formContainer) { | ||
formContainer.classList.add('cmp-adaptiveform-container--loading'); | ||
} | ||
}; | ||
// Function to remove the loading class | ||
const removeLoadingClass = (formId) => { | ||
const formContainer = document.querySelector(`[data-cmp-adaptiveform-container-loader='${formId}']`); | ||
if (formContainer) { | ||
formContainer.classList.remove('cmp-adaptiveform-container--loading'); | ||
} | ||
}; | ||
this._model.subscribe((action) => { | ||
addLoadingClass(action.target.id); | ||
}, "submit"); | ||
this._model.subscribe((action) => { | ||
removeLoadingClass(self.getModel().id); | ||
let state = action.target.getState(); | ||
// execute the handler only if there are no rules configured on submitSuccess event. | ||
if (!state.events.submitSuccess || state.events.submitSuccess.length === 0) { | ||
const globals = { | ||
form: self.getModel().getRuleNode(), | ||
event: { | ||
type: action.type, | ||
payload: action.payload, | ||
} | ||
}; | ||
FormView.customFunctions.defaultSubmitSuccessHandler(globals); | ||
} | ||
}, "submitSuccess"); | ||
this._model.subscribe((action) => { | ||
removeLoadingClass(self.getModel().id); | ||
let state = action.target.getState(); | ||
// execute the handler only if there are no rules configured on submitError event. | ||
if (!state.events.submitError || state.events.submitError.length === 0) { | ||
let defaultSubmissionError = FormView.LanguageUtils.getTranslatedString(self.getLang(), "InternalFormSubmissionError"); | ||
const globals = { | ||
form: self.getModel().getRuleNode(), | ||
event: { | ||
type: action.type, | ||
payload: action.payload, | ||
} | ||
}; | ||
FormView.customFunctions.defaultSubmitErrorHandler(defaultSubmissionError, globals); | ||
} | ||
}, "submitError"); | ||
this._model.subscribe((action) => { | ||
let state = action.target.getState(); | ||
// execute the handler only if there are no rules configured on custom:saveSuccess event. | ||
if (!state.events['custom:saveSuccess'] || state.events['custom:saveSuccess'].length === 0) { | ||
console.log("Draft id = " + action?.payload?.body?.draftId); | ||
window.alert("Draft has been saved successfully"); | ||
} | ||
}, "saveSuccess"); | ||
this._model.subscribe((action) => { | ||
let state = action.target.getState(); | ||
// execute the handler only if there are no rules configured on custom:saveError event. | ||
if (!state.events['custom:saveError'] || state.events['custom:saveError'].length === 0) { | ||
window.alert("Issue while saving draft"); | ||
} | ||
}, "saveError"); | ||
this.#setupAutoSave(self.getModel()); | ||
} | ||
|
||
/** | ||
* Register time based auto save | ||
* @param formModel. | ||
*/ | ||
#setupAutoSave(formModel) { | ||
const autoSaveProperties = formModel?.properties?.['fd:autoSave']; | ||
const enableAutoSave = autoSaveProperties?.['fd:enableAutoSave']; | ||
if (enableAutoSave) { | ||
const autoSaveStrategyType = autoSaveProperties['fd:autoSaveStrategyType']; | ||
const autoSaveInterval = autoSaveProperties['fd:autoSaveInterval']; | ||
const saveEndPoint = FormView.Utils.getContextPath() + '/adobe/forms/af/save/' + formModel.id; | ||
if (autoSaveStrategyType === 'time' && autoSaveInterval) { | ||
console.log("Registering time based auto save"); | ||
setInterval(() => { | ||
formModel.dispatch(new FormView.Actions.Save({ | ||
'action': saveEndPoint | ||
})); | ||
}, parseInt(autoSaveInterval) * 1000); | ||
} | ||
} | ||
} | ||
} | ||
|
||
async function onDocumentReady() { | ||
const startTime = new Date().getTime(); | ||
let elements = document.querySelectorAll(FormContainerV2.selectors.self); | ||
for (let i = 0; i < elements.length; i++) { | ||
let loaderToAdd = document.querySelector("[data-cmp-adaptiveform-container-loader='"+ elements[i].id + "']"); | ||
if(loaderToAdd){ | ||
loaderToAdd.classList.add(FormContainerV2.loadingClass); | ||
} | ||
console.debug("Form loading started", elements[i].id); | ||
} | ||
function onInit(e) { | ||
let formContainer = e.detail; | ||
let formEl = formContainer.getFormElement(); | ||
setTimeout(() => { | ||
let loaderToRemove = document.querySelector("[data-cmp-adaptiveform-container-loader='"+ formEl.id + "']"); | ||
if(loaderToRemove){ | ||
loaderToRemove.classList.remove(FormContainerV2.loadingClass); | ||
} | ||
const timeTaken = new Date().getTime() - startTime; | ||
console.debug("Form loading complete", formEl.id, timeTaken); | ||
}, 10); | ||
} | ||
document.addEventListener(FormView.Constants.FORM_CONTAINER_INITIALISED, onInit); | ||
await FormView.Utils.setupFormContainer(async ({ | ||
_formJson, _prefillData, _path, _element | ||
}) => { | ||
let formContainer = new FormContainerV2({_formJson, _prefillData, _path, _element}); | ||
// before initializing the form container load all the locale specific json resources | ||
// for runtime | ||
const formLanguage = formContainer.getLang(); | ||
const aemLangUrl = `/etc.clientlibs/core/fd/af-clientlibs/core-forms-components-runtime-all/resources/i18n/${formLanguage}.json`; | ||
await FormView.LanguageUtils.loadLang(formLanguage, aemLangUrl, true); | ||
formContainer.subscribe(); | ||
return formContainer; | ||
}, FormContainerV2.selectors.self, FormContainerV2.IS); | ||
} | ||
|
||
// This is to ensure that the there is no WCM Mode cookie when Form Container is rendered. | ||
// max-age=0 ensures that the cookie is deleted. | ||
document.cookie="wcmmode=disabled; max-age=0; path=/"; | ||
|
||
if (document.readyState !== "loading") { | ||
onDocumentReady(); | ||
} else { | ||
document.addEventListener("DOMContentLoaded", onDocumentReady); | ||
} | ||
|
||
})(); |
Binary file added
BIN
+19.1 KB
...s-it/components/container/v1/container/clientlibs/site/resources/busy-state.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
.../main/content/jcr_root/content/forms/af/core-components-it/samples/container/.content.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" | ||
jcr:mixinTypes="[rep:AccessControllable]" | ||
jcr:primaryType="sling:Folder" | ||
hidden="true"/> |
Oops, something went wrong.