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

[Draft] FORMS-16201 Register auto save in publish(disabled) mode only #1415

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,10 @@ public String getName() {
return FormContainer.super.getName();
}

@JsonIgnore
@Override
public AutoSaveConfiguration getAutoSaveConfig() {
return autoSaveConfig;
}
girotraapankaj marked this conversation as resolved.
Show resolved Hide resolved

}
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,9 @@
default String getParentPagePath() {
return null;
}

@JsonIgnore
default AutoSaveConfiguration getAutoSaveConfig() {
return null;

Check warning on line 368 in bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormContainer.java

View check run for this annotation

Codecov / codecov/patch

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormContainer.java#L368

Added line #L368 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public class FormContainerImplTest {
private static final String CONTENT_ROOT = CONTENT_PAGE_ROOT + "/jcr:content";
private static final String CONTENT_DAM_ROOT = "/content/dam/formsanddocuments/demo";
private static final String PATH_FORM_1 = CONTENT_ROOT + "/formcontainerv2";

private static final String PATH_FORM_WITH_AUTO_SAVE = CONTENT_ROOT + "/formcontainerv2WithAutoSave";
private static final String PATH_FORM_WITHOUT_FIELDTYPE = CONTENT_ROOT + "/formcontainerv2-without-fieldtype";
private static final String PATH_FORM_1_WITHOUT_REDIRECT = CONTENT_ROOT + "/formcontainerv2WithoutRedirect";
private static final String CONTENT_FORM_WITHOUT_PREFILL_ROOT = "/content/forms/af/formWithoutPrefill";
Expand Down Expand Up @@ -480,6 +482,13 @@ public void testGetLanguageDirection() throws Exception {
}

@Test
public void testGetAutoSaveProperties() throws Exception {
context.load().json(BASE + "/test-content-auto-save.json", PATH_FORM_WITH_AUTO_SAVE);
FormContainer formContainer = Utils.getComponentUnderTest(PATH_FORM_WITH_AUTO_SAVE,
FormContainer.class, context);
assertNotNull(formContainer.getAutoSaveConfig());
}

void testNoFieldType() {
FormContainer formContainer = Utils.getComponentUnderTest(PATH_FORM_WITHOUT_FIELDTYPE, FormContainer.class, context);
assertEquals(FieldType.FORM.getValue(), formContainer.getFieldType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
*/
#setupAutoSave(formModel) {
const autoSaveProperties = formModel?.properties?.['fd:autoSave'];
const enableAutoSave = autoSaveProperties?.['fd:enableAutoSave'];
const enableAutoSave = this.#getAutoSaveAttribute();
if (enableAutoSave) {
const autoSaveStrategyType = autoSaveProperties['fd:autoSaveStrategyType'];
const autoSaveInterval = autoSaveProperties['fd:autoSaveInterval'];
Expand All @@ -96,6 +96,10 @@
}
}
}

#getAutoSaveAttribute() {
return this.getFormElement()?.getAttribute('data-cmp-auto-save') === 'true';
}
}

async function onDocumentReady() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
data-sly-use.templates="core/wcm/components/commons/v1/templates.html"
action="${container.metadata.action}"
id="${container.id}"
data-cmp-auto-save="${wcmmode.disabled && container.autoSaveConfig && container.autoSaveConfig.enableAutoSave ? 'true' : 'false'}"
data-cmp-is="adaptiveFormContainer"
data-cmp-context-path="${request.contextPath}"
data-cmp-page-lang="${container.containingPageLang}"
Expand All @@ -61,4 +62,4 @@
</div>
</form>
<div data-cmp-adaptiveform-container-loader="${container.id}"></div>
</sly>
</sly>
Loading