File tree 5 files changed +28
-2
lines changed
main/java/com/adobe/cq/forms/core/components
test/java/com/adobe/cq/forms/core/components/internal/models/v2/form
ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container
5 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -373,4 +373,10 @@ public String getName() {
373
373
return FormContainer .super .getName ();
374
374
}
375
375
376
+ @ JsonIgnore
377
+ @ Override
378
+ public AutoSaveConfiguration getAutoSaveConfig () {
379
+ return autoSaveConfig ;
380
+ }
381
+
376
382
}
Original file line number Diff line number Diff line change @@ -362,4 +362,9 @@ default void visit(Consumer<ComponentExporter> callback) throws Exception {}
362
362
default String getParentPagePath () {
363
363
return null ;
364
364
}
365
+
366
+ @ JsonIgnore
367
+ default AutoSaveConfiguration getAutoSaveConfig () {
368
+ return null ;
369
+ }
365
370
}
Original file line number Diff line number Diff line change @@ -75,6 +75,8 @@ public class FormContainerImplTest {
75
75
private static final String CONTENT_ROOT = CONTENT_PAGE_ROOT + "/jcr:content" ;
76
76
private static final String CONTENT_DAM_ROOT = "/content/dam/formsanddocuments/demo" ;
77
77
private static final String PATH_FORM_1 = CONTENT_ROOT + "/formcontainerv2" ;
78
+
79
+ private static final String PATH_FORM_WITH_AUTO_SAVE = CONTENT_ROOT + "/formcontainerv2WithAutoSave" ;
78
80
private static final String PATH_FORM_1_WITHOUT_REDIRECT = CONTENT_ROOT + "/formcontainerv2WithoutRedirect" ;
79
81
private static final String CONTENT_FORM_WITHOUT_PREFILL_ROOT = "/content/forms/af/formWithoutPrefill" ;
80
82
private static final String PATH_FORM_WITHOUT_PREFILL = CONTENT_FORM_WITHOUT_PREFILL_ROOT + "/formcontainerv2WithoutPrefill" ;
@@ -477,4 +479,12 @@ public void testGetLanguageDirection() throws Exception {
477
479
assertEquals ("ltr" , formContainer .getLanguageDirection ());
478
480
}
479
481
482
+ @ Test
483
+ public void testGetAutoSaveProperties () throws Exception {
484
+ context .load ().json (BASE + "/test-content-auto-save.json" , PATH_FORM_WITH_AUTO_SAVE );
485
+ FormContainer formContainer = Utils .getComponentUnderTest (PATH_FORM_WITH_AUTO_SAVE ,
486
+ FormContainer .class , context );
487
+ assertNotNull (formContainer .getAutoSaveConfig ());
488
+ }
489
+
480
490
}
Original file line number Diff line number Diff line change 81
81
*/
82
82
#setupAutoSave( formModel ) {
83
83
const autoSaveProperties = formModel ?. properties ?. [ 'fd:autoSave' ] ;
84
- const enableAutoSave = autoSaveProperties ?. [ 'fd:enableAutoSave' ] ;
84
+ const enableAutoSave = this . #getAutoSaveAttribute ( ) ;
85
85
if ( enableAutoSave ) {
86
86
const autoSaveStrategyType = autoSaveProperties [ 'fd:autoSaveStrategyType' ] ;
87
87
const autoSaveInterval = autoSaveProperties [ 'fd:autoSaveInterval' ] ;
96
96
}
97
97
}
98
98
}
99
+
100
+ #getAutoSaveAttribute( ) {
101
+ return this . getFormElement ( ) ?. getAttribute ( 'data-cmp-auto-save' ) === 'true' ;
102
+ }
99
103
}
100
104
101
105
async function onDocumentReady ( ) {
Original file line number Diff line number Diff line change 36
36
data-sly-use.templates ="core/wcm/components/commons/v1/templates.html "
37
37
action ="${container.metadata.action} "
38
38
id ="${container.id} "
39
+ data-cmp-auto-save ="${wcmmode.disabled && container.autoSaveConfig && container.autoSaveConfig.enableAutoSave ? 'true' : 'false'} "
39
40
data-cmp-is ="adaptiveFormContainer "
40
41
data-cmp-context-path ="${request.contextPath} "
41
42
data-cmp-page-lang ="${container.containingPageLang} "
61
62
</ div >
62
63
</ form >
63
64
< div data-cmp-adaptiveform-container-loader ="${container.id} "> </ div >
64
- </ sly >
65
+ </ sly >
You can’t perform that action at this time.
0 commit comments