From 7c108323288e9fd46309bdbb26af5c7228531ed8 Mon Sep 17 00:00:00 2001 From: Rishi Mehta <69448117+rismehta@users.noreply.github.com> Date: Thu, 7 Jul 2022 16:03:08 +0530 Subject: [PATCH 001/494] @trivial Fixing content classification warnings (#87) --- .../components/formsportal/link/v1/link/_cq_dialog/.content.xml | 2 +- .../portallister/v1/portallister/_cq_dialog/.content.xml | 2 +- .../searchlister/v1/searchlister/_cq_dialog/.content.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/formsportal/link/v1/link/_cq_dialog/.content.xml b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/formsportal/link/v1/link/_cq_dialog/.content.xml index e0052c64a5..a074c4b45e 100644 --- a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/formsportal/link/v1/link/_cq_dialog/.content.xml +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/formsportal/link/v1/link/_cq_dialog/.content.xml @@ -141,7 +141,7 @@ diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/formsportal/searchlister/v1/searchlister/_cq_dialog/.content.xml b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/formsportal/searchlister/v1/searchlister/_cq_dialog/.content.xml index ea8d02554e..b588002515 100644 --- a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/formsportal/searchlister/v1/searchlister/_cq_dialog/.content.xml +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/formsportal/searchlister/v1/searchlister/_cq_dialog/.content.xml @@ -51,7 +51,7 @@ name="./title"/> From 65a752f50d5836338e82b2c117a03d178f3cd204 Mon Sep 17 00:00:00 2001 From: Ujjwal Gupta Date: Wed, 13 Jul 2022 15:09:02 +0530 Subject: [PATCH 002/494] CQ-4346124 Removing toggle dev bundle from it.content (#94) Co-authored-by: ujjgupta --- .circleci/ci/it-tests.js | 1 - it/content/pom.xml | 7 ---- ...om.adobe.granite.toggle.impl.dev-1.1.2.jar | Bin 11697 -> 0 bytes ui.tests/test-module/libs/support/commands.js | 33 ------------------ .../specs/aemformcontainer.spec.js | 7 ++-- 5 files changed, 4 insertions(+), 44 deletions(-) delete mode 100644 it/content/src/main/resources/com.adobe.granite.toggle.impl.dev-1.1.2.jar diff --git a/.circleci/ci/it-tests.js b/.circleci/ci/it-tests.js index 428c3f62e3..7e2f65e524 100644 --- a/.circleci/ci/it-tests.js +++ b/.circleci/ci/it-tests.js @@ -49,7 +49,6 @@ try { // Start CQ ci.sh(`./qp.sh -v start --id author --runmode author --port 4502 --qs-jar /home/circleci/cq/author/cq-quickstart.jar \ --bundle org.apache.sling:org.apache.sling.junit.core:1.0.23:jar \ - --install-file ${config.modules['core-forms-components-it-tests-content'].path}/src/main/resources/com.adobe.granite.toggle.impl.dev-1.1.2.jar \ --bundle com.adobe.cq:core.wcm.components.examples.all:${wcmVersion}:zip \ ${extras} \ ${ci.addQpFileDependency(config.modules['core-forms-components-apps'])} \ diff --git a/it/content/pom.xml b/it/content/pom.xml index 822f223657..bf58edffa4 100644 --- a/it/content/pom.xml +++ b/it/content/pom.xml @@ -178,12 +178,5 @@ zip provided - - com.adobe.granite.toggle - com.adobe.granite.toggle.impl.dev - 1.1.2 - system - ${project.basedir}/src/main/resources/com.adobe.granite.toggle.impl.dev-1.1.2.jar - diff --git a/it/content/src/main/resources/com.adobe.granite.toggle.impl.dev-1.1.2.jar b/it/content/src/main/resources/com.adobe.granite.toggle.impl.dev-1.1.2.jar deleted file mode 100644 index 30f5720a55366cfe9b88b5fb5454d4bd75c0f5f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11697 zcmb_?1yr0#vo;<)xO;GSm*DR15Znpwmcb>sLm;>X2n3hl7MuV<2Y1(?Kdgn#y}SGE z|J|B1=gge*K2`lzS9e!ET?*3R5NIIK(9j@`4tz==PXq=80z_6+MUYNXPK@EM9|Qy( zL_zu)^y3p?zdfe#mteGqC;kA-3d%`}i7Knm%ZdfYDcYqmBK0iBTq5cbDl3Ww|L;|YC4$kC5wHDWmD^Y7)(yg zfi4X)|KUujVy{d<#gcpkooRU2MtFFAqkViJ^g&mfX=%VvV>C>;JkvKv6NUN^6i9%y zEs?klst%BVyuL;OT=))ZTVmtB~6$&)&t939K2i#e%a)@lO`s^(1%Kn>EUfk$&F-+Ff zF99(Jd~L%y6Sn&3ivvP90~XGQrlo=-Nh$M;o1EB@0#Wz9q+H%kV(QA0QR_VZjQ6cYOJ*jMERI>eG(&}E*;IMj zS5t&f^7yIT5S-|w9WX4%99R9x9hLJOjU0Yp%DfZ=r3zs{B{XSdzSCX_WXe{*NCK>9 z8D=l|+IuZT60yg=2gQVKSm1#Z(`58JeE`u~Q$m9W&5&VF7Q%4yCN&d2a^T$Fk1Ja1 z0>E?~!^iGV@z&4Z95|_BeBCsy@JOJ8H)}j(=+M73C?~UaGCW3OAhPBY66>Li)=<86 z(MnGErZmKy?AkV(%}-12S?T-?xD$?n$7&;iAC}==_jqP5U(3?3J+FCf7&^y_gnOU3sE4@H75VoBW3FNbaO6`@oB8{L(sFEHJ# z?zLgw5ON}eimXIrd-&@$T0)(36qed13M$jO;?HkjIiH_1YYAlXeK|p$>(h*@-rplA zP~gbb!0gUd$z?fDRWcQxG07Xb$BQpBiSSB(b4K?`27`|K1pF~7qO55)d>>vh|Ka;1 zDlC6mgo^*?PH?lap4Za0o2^6f87>Dxd6(vr%GP>LWP&yUOH|B1e`jeMYhrG#O0R@%v^F#)x2vg+(5K0|}I* z76k87gT^Xgg_n#NOGc&=oafsEK)Ih1S@^fKwz?iHV$HQJEVNuq zegB5QC^iksp@8KAUq{Lp8|2mvUbPMymrV~K<{ao4_I!6S_Y8agYDO6uN0gUzSKiay z>xI$kS96TS&+9$?{8;Tehpb!(w|?UE?B^+Pc*>$;di*K@l?qNl;E*CT=Bug_Wb`~u zcXw$WF}0=C20@U91|eki?Uw#cGAs=0HU;_&>PO$x*}j$(Pj)SjQ5xDxB<^S>;WS?F z3ksVtY8^rjx2@e;-~@Z@$9|04!d(fuJWsy2H508hRb$m_!$Kgs>SW=Thg8#v;C)kD zN*v>#6m>l|XhlxT)`vW=AxHyzz*D@08t5=B0&%wnVi%$h zK|vly2v{uM_cEN0LeZ_|n``3ZFqF>oKQ=;Cq=1oz;Z!En3lx6mgU<>8jocH;&H5GIIy3veRcBUbhk9y{07BB zVy71^jEgW>!8cw(*a|r;uW5tCx*g6Ve8JT%be`n(Zj#I=|1h2-EV!g4x6Ea(BQ{vC zEV)t{@H4urXeEsI%*8~y4QL^yfY;f6VBjy=9o&m!Rb)R}e>3HZGB^bB+PZAqkrF z$Kxsqe(||3Z&~k9E>q_^-n3{k!ZzkIEQxnu)}GhU3=;$CR$QK$8PRWB{O*o*cO;G` z8T}2;HhC{BFFO5%;Jx7|9=t<8o=JDqH?-_l!?#`DJjYi=Y}zKXV^MRps?+2e9fC80 zc5|*oHuv*O!zlySu?gkP_^!Yfny_^GPut|pqj4@C%et^p2l?c&FlRAUNOGE6^fo>Q z-cZ)_-81nrwQ;39Sey|JA$4UkLfYg-`|_Dxk#VXVGaC7^V>A=oOySRK7y~`{80O6Y zqrr(`4ZtF_To(@O!B`t9&lFw8xM!Q*U(~Loa-$)r0S!ZXX=B=DBFxZO+GU;g@Y)gz z@x5$jA869VSJm~?1g{h^*WH_JP1r|UjVIoIRvCt2gUY!nD7^xF(Kz1TJ#|x21jE}I zjiV{#e4$GxJtU#$-kvhJ=CtjcK~#qEZ(`wgU{s_BdNmB zA&aHDbHdi{5~EDUEuI%0)XmB-I}PbWigVWcoh4^nKF6?9C8NsG6BH5bXE;l0_JEt$ybr(#xO}c}_N7H5roY)Z5+zaHiInenS zOACs@weZ#!7z@2KoQGm1qMAG;F){Z00O^7?@i{x2V`-Fi=usscFBjiCm6539K+UN#_K_hwfJCJQ!YqL}OlWi5~iEnd?a_yEG;(2MOHWmuGV zCMP??SX(AYZi-c!Yq9Ht$2;A)J~WY-?`#m94Sa_BXcWwmyd3;(6+2&M`5T^jQ|#4iu5)jA7OA6TqKu0~RsI2Ug|OS%NrQ+7++Wn-%5gS;02i;yl~050GLZBePJU20`3!M=Czgzd z*IDe5+^uJutZ^|4dI$J**MoL}u<`If^Btn{)@7J8agrZ!2p1n-7DC#9gL$$uPM`U)ltQnW&RHTSWHANZk(n7_=`PM~nU<9$VEIwxi74tbcIr30{%y zIcO3pm_bSUhIcp$f<8=~z?pV&GSE@QMc*;uh0nJU35O2aOl6~D!>&&9zbaZ=|ASmO0TqQ zyB-`P@lZwm$d!NgIm%Pl*_b#PI=S2byJF|Db+2drC#SP1W zF(Gvy@OI@MNx?|~kT8Tah)Jo*f#C6b)@55YX|}qZ1-1KxD9df&bE!jKC%2~g8AGki z2xJXHny4}Sd&n>2G_oTidS`vU;>Ue2Wf>fC^zDCrjEBf{ffq1@7I)51aW#~{L4L$l!@NR+R)K4Pi@u_RTb+#gM2WkBAR_9KEMC~wgm|$8jfVk zZezn*{ZgvleU`jni#?6c&{Y{n@#uJ2ANV{}On(54Ym# zBFsRlYC1Et&$Z~=F{x z8?4x!mq;CgO*rk)W5i8CQ^LJKCjf1Rsy#he&=Hc>YyOZ>q$r>e66TtRWSa@3Iu=P) z>S$3KVr_mko;-G{4NJADX|*Pup}8sX(#KeMP&2Jsp685s!>b}x*=t>-@@TY!6Zo0- zBH0Fq06l8lP~La4@M^MUxf|WO=h)I;w%u*>wp4Jq^W%nKf~t<#G>gM4tpeKKp|}qr z4Q-MWmc^6Tvwe`o=?pa%kz*lel}>Vs+)CnNDzq41O|$}_x;xMrIupcGZLgP7#=f!k z(u_BXW8vMPeLK6X3{{CzP|rel+(&cPu6srswEmH7y_mTGD%d~PD#CDQJBreAkXoTQ z4W}-i{P+#88Ka1LfEt|usO`x(kZ^}zFbwx&R3c60WdDcc01mXKJ|vvffuoN(aN}x+ z7^9ksl@4ASNr^6{VXHn{0a9GX>+ps;PP# zu(m&sa6W+kppB_Gf%98B2s)2c@S6r*Uk}Ah0)6EH=H23h1lBYAp-5K|mJ_JjLJWCT zZ^(86(+Oqi(jyCLofB^I`XCVO8tta6S=L;fen#VEY(sREcKXdws&M;y^3qqYvPf3s zU{Y-zkEz*^`W&p(hL0RSxR-NJ^t9BalWD6p3a}EHFl~mJGq2&Gr7i0sben3wff;d5 z5hRBD=;xHAw&_mk!IaxKItKG8y^SqS#ll$qavJSSrX-`GCi#0pPo52ahkN@g@#Tg#N|Rwr~AUbldRV*8+dL!ny4*$^WEBb=Hz zpAF=5H?w1OqNnmWX~{n@;V)goGgL+Q5>Y09AyTPiT30`(E!zh-)oA2WK#@}V+>%X{ zD*-p;e%MZOP(+F)f_7fCf7?jtHsw`L%I%^<$Y`xJi?_Q|R#Bd4l!>2O>gcKJn8+|9 zuY3X1OkT+OD9-+VJ>2BHC#LND1@L+j-OGOg6a^x`B5pxZohw3j8ljHIB6jqiU^kD2 zxtBkf5H^EvTi5Ttu(gBGLhmIIqlH+DYi4eOaFa;vkfumL?Cn9-CfA!u{{x@;qv*+u zw#C+b`_ZXUJk46a5xU)@vuCz1#7;euqOQp1g{rs5{MYYZY6B6sNSAK=D0w!w-ftKT z^Xo4rDcsa9UCj3ceb2m}b|YN+zJD-!3PSh!=DB(E#7@lVH<#yW1Y+z1=DIse-U3E^ z_#Yvw2gTns*u?E4wCS??oq-&-#AD=*s#jbn~?M8Z3}ux8VI%4ABQEC4vo**N7-)xa_=% z`la5mh?Vvl^EljHUi}TeBQpzfQO1Sv3^5%(n57+V-`4Qk6fxV$XPn1yvgZ?Vat~I7 zygjFAzR0-6d^~xRQTrU~>~ zxSrxXeRe8NOr8cPM3IodBk4I=Z+0I}O?xNs0Tjr_D+x3NdyC>mYk*mnxt{Fp*u9Dc z0k4W(=r67 zXMl@(o~_u>xOt0Y8QRRai2CDs!&gYy&DN6U-bK?I7Wkq9_pcN{dm&;ej<`rO?AaC{ zu_c#?W<}+#&L}O9*|{UnB- zoLgFh(3X^5ik9BjjIim}{t6Xe*^A}&Z`jzNxO>Ax(^{t`ASE1olkcO*ftu>uu_d-_ zZY*~lqoE+6RyXrY&AQqfqW+Cuv%pz`cQ8h2pfy>T25F-i0@)YTPDv@ZQg31~7R!&` zz_vbruC@shb-63Z<_Z!_q22mR-P9x;1y}Nrnz8;VHTyY01pm7L`StuSQ~$1yw}$T% z#0QlqDItOJO$VjRm}|;Fm|BDu^i@b>v@xoZ5F27+2eYB;GqYzXmfCEQHj!G|vs!x= z<652^TEap~M)I>WCjy&xd#ynE{9zuJM%oG_>(!H`jEl>Ki;Kz-0%KjhD( z1ZAJ0l3(>f)@i&-K^ds7X! z45(R(Q^W)D+F8YfWSM>rER+92 z(uRACCr*{cW4X}VyO%ZpEZ6k>B!T(TTyH!!D`~=EQH4EaauY(D$H;jBw#0)1jXUtY zl~{P6RNcyYsYNLOSGt)n2n&UsFr{D1Lu_YQZig#_d~e7UVc;Bbu)#_%H+`iAx?T=P zlg>(X!o63*wSBBWReI+Jgp=t-(c3L8B|t$=0)FOmfB-GHXZ}}Ky8J!)5-REy`G&OA zKz~-2l;`U_~F$0~TCzb1-p`Jof@ z!t6vu97s%C&ba5Kkg+8p-TDSnWwcp2zfU%@6sjsgw^CJ1s3;c+O{T42px1trQ&0^E zQ4JM?#o#;5kTj2@e*;TnCkKOzIga5h*zIc4L}GX-tn#IZV^O%DA?a)Fpgk+_Jcw#q10x)iO(E#KC&C=kx~1A-Kw>LbK)Jz}XsW zsA||^lo_=WJ^8!DCKJqRV+=Fa_l%kt*c4{27(5!05RIa1eu-7DQYq)SAor$Uta!rG z1FvDVkQGPB6BTzAD+r%cat0AYUI1UfSGvEzS8!ahmWB24Q%Ao+DyOOe70@~EM@ls(-5AY;Pfa)Q=rZR)%v+LUw}z5bUr#XJ+O6N4&?@n(xxexTs9%#A7Mg#i?KAW@mjG z`$MmIarDG$V#umPm+R|4@Wc#bH1xLBH(2+`GIZ~M_?w)PCSQf5- zd4??@(%V_BBPVMCdIRH|IO6bSD4lztZ~#s<$!S-6W4f7MAkt|vH#@>zEtwE|q#wElJU=p#%;j{9zzREm;uHq_LCVMPOh zjprTdF-OmX+$I>w^Eq3ZRA@88S0{{n^6EXFeRLEh!ypQitb@3e2qmeG7kQg1*OLN? zH+R>UtDRs?`;4aJsNfXpZt|JeG(e2ie;iHTWV+W;dbB?AKAqmJWtRV7*>^VJgrCV6 zZKzRkh%XrR1L2x1;Q^@+2diGtgd3zu67V(u!juibv;IS1uoZX{sg7hUJ}(s_4tHge zKEu8+W;SGBF!Wxf(Rc5QrJ=NP9)3cFYSy@&`Yz?bx^=Nb!a5!_N=*^h!4(O-WALfo<8%& zM1pmHb60~{Pe$6Pa+7=ft{WpQ%toZV>^0A%J>SdkSCs_MwpyQUMZTGE^5aH0c7hgv zjYS>>Wb%2p3b5NVXx@LiM+N%P|iDCiSp=p{g4?I zreJ4+FNV#Xd0IlH-#wBF=5bGLoBj3%1?{wh%RP*GIfAnQniEa%zP+wT=}BtWwN5c; zyfyWfSXZAJw_gW<@(P_GD31oi2`UXobIB-ww?0{o90{z$r&pw~Tof;h$ce2!<7-a{ zjhPKqEDHDtYmr03Y!}X^J~c$F(tVlSMSh??&AV$6s^5{g)SWmm?EyK<-6Z?<6LC3f z@NDzup(4=VYMNi>kmtj)oS(s&U0nIQiGw_^sDavV^f+raD5_XSP<(=XL&tk~XKwwI zYaoWj$;&-QuPwj&IZvEG9L>6;gzmghVLQ7AWMGX33y8Lj{?y~LE{Xm2Wh_;(GN#JMRXbFUz_<0P+4)DZ@vU#pmRW)ur*TL*!udos zZ{Stk5(5OpF@`bGgK^ZS3lSI~_a@FxsM;8`sacaUDAmE*#Q8JB196sW8T2XNZ#q(O zGrv8eSB(vEWs1R6CtB{PYaX}x&hFqEW{>)UH@CizG+9kEO$pnDc^kKGQ6$jiBWa+k z%3=3+PfXt)edKoaI!w{?lAHUP`(LuO9++(#jtBC(3H>pR2L(d|`E&2t?~P@Ty=Q-x zKbpxNJJEiIKJ7Sq>^%D+d=EeWfIjI%d#d3vNqpKw^Vpg6L-ZfU^oNGu`jnoce`o)G zANpgX%?}xRNJsxb|Jru*ci_i1n;(Mk;Dn#Re?=BQG+zC+Hy@j9eu&Ax(E3;Aeze^D zZ1-v3$s^zWLl*x}?f$vp=IJONdt9F0qCEDv{E*d$BJw}==|8{y<0u};_owE6j)%vq znjez>5FUSA0sIVmdJpkf%KnhAPhtN!tiQju`Pu5DmEVK+kxc#}NXSnH`^SC7&-kaL z_@8H7>3_xl7sG#Y-|_P(9!LHATl{(N;6nYC6!<&DBmMqEY<@%hN~!-H?$7=z_!I7T zD*o^AkJS4Q+4^7cztI`{&Py`XRA+7vqxs(hfLu8S5|-J X85E=;p&nJDKYWOvfq;0BKmPlF7uU6W diff --git a/ui.tests/test-module/libs/support/commands.js b/ui.tests/test-module/libs/support/commands.js index 2b8691af70..d71ad39d1b 100644 --- a/ui.tests/test-module/libs/support/commands.js +++ b/ui.tests/test-module/libs/support/commands.js @@ -157,12 +157,6 @@ Cypress.Commands.add("openAuthoring", (pagePath) => { cy.openSiteAuthoring(pagePath); }); -// Cypress command to open authoring page after configuring feature toggles -Cypress.Commands.add("openAuthoringWithFeatureToggles", (pagePath, toggles) => { - cy.enableToggles(toggles); - cy.openSiteAuthoring(pagePath); -}); - // Cypress command to open authoring page Cypress.Commands.add("openPage", (pagePath) => { const baseUrl = Cypress.env('crx.contextPath') ? Cypress.env('crx.contextPath') : ""; @@ -281,30 +275,3 @@ Cypress.Commands.add("insertComponent", (selector, componentString, componentTyp cy.get(insertComponentDialog_Selector).click({force: true}); // sometimes AEM popover is visible, hence adding force here }); -// enable toggles -Cypress.Commands.add("enableToggles", (toggles) => { - const baseUrl = (Cypress.env('crx.contextPath') ? Cypress.env('crx.contextPath') : "") + "/system/console/configMgr"; - cy.visit(baseUrl); - cy.get('table').contains('td', 'Adobe Granite Dynamic Toggle Provider').click(); - cy.get("span[id='enabledToggles1']").type(toggles[0]); - - let toggleIndex = 1; - let textAreaId = 3; - while (toggleIndex < toggles.length) { - cy.get("input[value='+']").first().click(); - cy.get("span[id='enabledToggles" + textAreaId++ + "']").type(toggles[toggleIndex++]); - } - - cy.get('button').contains( 'Save').click(); -}); - -// disable toggles -Cypress.Commands.add("disableToggles", () => { - const baseUrl = (Cypress.env('crx.contextPath') ? Cypress.env('crx.contextPath') : "") + "/system/console/configMgr"; - cy.visit(baseUrl); - cy.get('table').contains('td', 'Adobe Granite Dynamic Toggle Provider').click(); - cy.get("textarea[name='enabledToggles']").each(item => { - cy.get("input[value='-']").first().click(); - }); - cy.get('button').contains( 'Save').click(); -}); diff --git a/ui.tests/test-module/specs/aemformcontainer.spec.js b/ui.tests/test-module/specs/aemformcontainer.spec.js index 9e50d541dc..21d2d12840 100644 --- a/ui.tests/test-module/specs/aemformcontainer.spec.js +++ b/ui.tests/test-module/specs/aemformcontainer.spec.js @@ -91,13 +91,13 @@ describe('Page - Authoring', function () { }); }); +/* describe('Page - Authoring - Wizard', function () { context('Open Editor - Wizard', function () { beforeEach(function () { const baseUrl = Cypress.env('crx.contextPath') ? Cypress.env('crx.contextPath') : ""; cy.visit(baseUrl); cy.login(baseUrl); - //cy.enableToggles(["FT_CQ-4343036","FT_CQ-4339424"]); cy.openAuthoringWithFeatureToggles(pagePath,["FT_CQ-4343036","FT_CQ-4339424"]); }); @@ -108,7 +108,7 @@ describe('Page - Authoring - Wizard', function () { cy.get(wizardSelectors.wizardCancelButton).click(); }); - /*it('open toolbar, select wizard and create a Form', function() { + it('open toolbar, select wizard and create a Form', function() { cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + aemFormContainerEditPathSelector); cy.get("[data-action='createFormViaWizard']").should('be.visible'); cy.invokeEditableAction("[data-action='createFormViaWizard']"); @@ -125,7 +125,7 @@ describe('Page - Authoring - Wizard', function () { cy.invokeEditableAction("[data-action='CONFIGURE']"); cy.get("coral-taglist[name='./formRef']") .should("have.value", "/content/dam/formsanddocuments/" + formName); - });*/ + }); afterEach(function() { cy.disableToggles(); @@ -137,3 +137,4 @@ describe('Page - Authoring - Wizard', function () { }); }); }); +*/ From 9d3049d21109f8afa688b365fac684750ac4ebe2 Mon Sep 17 00:00:00 2001 From: Barshat Rai Date: Tue, 2 Aug 2022 14:40:26 +0530 Subject: [PATCH 003/494] Cloud profile build (#106) * fixing maven build for cloud profile * Updating Readme * minor styling update in the readme Co-authored-by: vdua --- README.md | 53 +++++++++++++++++++------- examples/all/pom.xml | 14 ------- examples/ui.apps/pom.xml | 75 ++++++++++++++++--------------------- examples/ui.content/pom.xml | 16 ++++---- it/content/pom.xml | 17 ++++++--- parent/pom.xml | 3 +- 6 files changed, 91 insertions(+), 87 deletions(-) diff --git a/README.md b/README.md index eae5303d35..90b603487d 100644 --- a/README.md +++ b/README.md @@ -47,23 +47,50 @@ For a list of requirements for previous versions, see [Historical System Require This project relies on the [AEM Sites Core Components](https://github.com/adobe/aem-core-wcm-components). They are typically installed as part of AEM. If you install AEM without sample content option you have to [deploy them manually](https://github.com/adobe/aem-core-wcm-components#installation) before using the AEM Forms Core Components. See the System Requirements above for version requirements. -## Installation +## Building -1. Clone this repository. -2. Run a `mvn clean install` in the root folder to install the artifacts to your local Maven repository. -3. Switch to the `all` project and run a `mvn clean install content-package:install`. +### Compliling the Core Components -### Easy install with the "all" package - -If you want to build all the modules yourself and get all the latest (yet) **unreleased** changes, just build and install all the modules with the following command at the root of the repository: +To compile your own version of the Core Components, you can build and install everything on your running AEM instance by issuing the following command in the top level folder of the project: +```shell +mvn clean install -PautoInstallPackage +``` +You can also install individual packages/bundles by issuing the following command in the top-level folder of the project: +```shell +mvn clean install -PautoInstallPackage -pl -am ``` -mvn clean install -PautoInstallAll,include-wcm-components-examples + +With AEM as a Cloud Service SDK, use the cloud profile as follows to deploy the components into `/libs` instead of `/apps`: +```shell +mvn clean install -PautoInstallPackage,cloud ``` -This installs everything by default to `localhost:4502` without any context path. You can also configure the install location with the following maven properties: -* `aem.host`: the name of the AEM instance -* `aem.port`: the port number of the AEM instance -* `aem.contextPath`: the context path of your AEM instance (if not `/`) + +Note that: + +* `-pl/-projects` option specifies the list of projects that you want to install +* `-am/-also-make` options specifies that dependencies should also be built + +For convenience, the following deployment profiles are provided when running the Maven install goal with `mvn install`: + +* `autoInstallAll`: Install everything to the AEM author instance. +* `autoInstallPackage`: Install the ui.content and ui.apps content packages to the AEM author instance. +* `autoInstallPackagePublish`: Install the ui.content and ui.apps content packages to the AEM publish instance. + +The hostname and port of the instance can be changed with the following user defined properties: + +* `aem.host` and `aem.port` for the author instance. +* `aem.publish.host` and `aem.publish.port` for the publish instance. + +### AEM as a Cloud Service SDK +When compiling and deploying to AEM as a Cloud Service SDK, you can use the `cloud` profile +(in conjunction with previously documented profiles) to generate cloud-ready artifacts +(with components located in `/libs` instead of `/apps`). +To allow recompilation of the HTL scripts, you should disable `aem-precompiled-scripts` bundle. + +Due to [FELIX-6365](https://issues.apache.org/jira/browse/FELIX-6365), +please only use `autoInstallPackage` and `autoInstallPackagePublish` when +working with the AEM as a Cloud Service SDK! ### UberJar @@ -102,7 +129,7 @@ to the `content-package-maven-plugin`. ## Using Pre-release versions In order to use components under pre-release: 1. Enable the pre-release channel. Instructions at https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/release-notes/prerelease.html?lang=en -2. Replace `core-forms-components-*` version with the desired pre-release version (e.g `1.0.4-PRERELEASE-20211223`) in your Cloud Manager / AEM Archetype project. This can be done by updating `x.y.z` in the top level pom.xml of archetype project. + 1. Replace `core-forms-components-*` version with the desired pre-release version (e.g `1.0.4-PRERELEASE-20211223`) in your Cloud Manager / AEM Archetype project. This can be done by updating `x.y.z` in the top level pom.xml of archetype project. Contents in the pre-release are contained in the `pre-release` branch. diff --git a/examples/all/pom.xml b/examples/all/pom.xml index 3d155577b0..628f841ac6 100644 --- a/examples/all/pom.xml +++ b/examples/all/pom.xml @@ -62,21 +62,7 @@ none true - /apps/core/forms/install - - - com.adobe.aem - core-forms-components-core - true - /apps/core/forms/install - - - - com.adobe.aem - core-forms-components-apps - true - com.adobe.aem core-forms-components-examples-apps diff --git a/examples/ui.apps/pom.xml b/examples/ui.apps/pom.xml index 12bd2270c5..4b6fc5f22b 100644 --- a/examples/ui.apps/pom.xml +++ b/examples/ui.apps/pom.xml @@ -58,9 +58,8 @@ - src/content/jcr_root + src/main/content/jcr_root - - **/js/** - - - org.apache.maven.plugins - maven-remote-resources-plugin - - - - process - - - ${project.build.directory}/vault-work - false - - - - - - com.day.jcr.vault - content-package-maven-plugin + org.apache.jackrabbit + filevault-package-maven-plugin true ${vault.package.group} - - overwrite - ${project.description} - ${buildNumber} - ${vault.package.company} - - ${basedir}/META-INF/vault/filter.xml + application adobe/cq60 @@ -130,6 +91,34 @@ + + com.day.jcr.vault + content-package-maven-plugin + + + + org.apache.sling + htl-maven-plugin + + + validate-htl-scripts + + validate + + generate-sources + + true + org.apache.sling.scripting.sightly + + cssClassName + decoration + decorationTagName + wcmmode + + + + + org.apache.rat apache-rat-plugin diff --git a/examples/ui.content/pom.xml b/examples/ui.content/pom.xml index e66a9f4181..db8bfd030d 100644 --- a/examples/ui.content/pom.xml +++ b/examples/ui.content/pom.xml @@ -104,18 +104,12 @@ - com.day.jcr.vault - content-package-maven-plugin + org.apache.jackrabbit + filevault-package-maven-plugin true ${vault.package.group} - - overwrite - ${project.description} - ${buildNumber} - ${vault.package.company} - - ${basedir}/META-INF/vault/filter.xml + content adobe/cq60 @@ -130,6 +124,10 @@ + + com.day.jcr.vault + content-package-maven-plugin + org.apache.rat apache-rat-plugin diff --git a/it/content/pom.xml b/it/content/pom.xml index bf58edffa4..fc323dc6f2 100644 --- a/it/content/pom.xml +++ b/it/content/pom.xml @@ -59,6 +59,17 @@ + src/main/content/jcr_root + + + + ${basedir}/src/main/content/META-INF + ../vault-work/META-INF + + org.apache.jackrabbit @@ -67,12 +78,6 @@ ${vault.package.group} content - - ${project.description} - ${buildNumber} - ${vault.package.company} - none - true diff --git a/parent/pom.xml b/parent/pom.xml index 922a89adf4..2e00b65e2c 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -459,11 +459,10 @@ com.day.jcr.vault content-package-maven-plugin - 0.0.24 + 1.0.4 ${quickstart.url}/crx/packmgr/service.jsp true - true From bb7681b9155993ab7caaa21eb6913a2174ea4937 Mon Sep 17 00:00:00 2001 From: Ujjwal Gupta Date: Wed, 3 Aug 2022 16:46:47 +0530 Subject: [PATCH 004/494] CQ-4346081 Moving embed feature to AEM Forms Container component v2 (#110) Co-authored-by: ujjgupta --- README.md | 2 +- .../models/v2/aemform/AEMFormImpl.java | 34 +++ .../models/v2/aemform/AEMFormImplTest.java | 62 +++++ .../test/resources/aemform/test-content.json | 15 ++ .../components/aemform/.content.xml | 2 +- .../library/core-content/aemform/.content.xml | 4 +- ui.apps/pom.xml | 3 +- .../aemform/v1/aemform/_cq_editConfig.xml | 6 - .../clientlibs/editorhook/js/EditListeners.js | 23 +- .../fd/components/aemform/v2/.content.xml | 20 ++ .../aemform/v2/aemform/.content.xml | 22 ++ .../components/aemform/v2/aemform/README.md | 55 +++++ .../v2/aemform/_cq_dialog/.content.xml | 229 ++++++++++++++++++ .../aemform/v2/aemform/_cq_editConfig.xml | 37 +++ .../aemform/v2/aemform/aemform.html | 54 +++++ .../v2/aemform/clientlibs/.content.xml | 18 ++ .../v2/aemform/clientlibs/editor/.content.xml | 20 ++ .../v2/aemform/clientlibs/editor/js.txt | 17 ++ .../clientlibs/editorhook/.content.xml | 21 ++ .../v2/aemform/clientlibs/editorhook/js.txt | 20 ++ .../clientlibs/editorhook/js/EditListeners.js | 58 +++++ .../clientlibs/editorhook/js/PreviewHook.js | 31 +++ .../clientlibs/editorhook/js/namespace.js | 22 ++ .../clientlibs/runtime/formapp/.content.xml | 21 ++ .../clientlibs/runtime/formapp/css.txt | 16 ++ .../aemform/clientlibs/runtime/formapp/js.txt | 16 ++ .../runtime/third-party/.content.xml | 18 ++ .../iframeContentResizer/.content.xml | 21 ++ .../third-party/iframeContentResizer/css.txt | 16 ++ .../third-party/iframeContentResizer/js.txt | 16 ++ .../third-party/iframeResizer/.content.xml | 21 ++ .../runtime/third-party/iframeResizer/js.txt | 16 ++ .../v2/aemform/clientlibs/site/.content.xml | 21 ++ .../v2/aemform/clientlibs/site/css.txt | 17 ++ .../aemform/v2/aemform/formcontainer.html | 40 +++ .../aemform/v2/aemform/formcontainer.js | 24 ++ .../components/aemform/v2/aemform/iframe.html | 30 +++ .../specs/aemformcontainer.spec.js | 4 - 38 files changed, 1035 insertions(+), 37 deletions(-) create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v2/aemform/AEMFormImpl.java create mode 100644 bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v2/aemform/AEMFormImplTest.java create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/README.md create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/_cq_dialog/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/_cq_editConfig.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/aemform.html create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editor/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editor/js.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/EditListeners.js create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/PreviewHook.js create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/namespace.js create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/formapp/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/formapp/css.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/formapp/js.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeContentResizer/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeContentResizer/css.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeContentResizer/js.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeResizer/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeResizer/js.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/site/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/site/css.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/formcontainer.html create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/formcontainer.js create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/iframe.html diff --git a/README.md b/README.md index 90b603487d..2006007edf 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ See [AEM Sites Core Components](https://docs.adobe.com/content/help/en/experienc ### Page Authoring Components -- [AEM Forms Container](ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v1/aemform) +- [AEM Forms Container](ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform) ### Forms And Communications Portal diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v2/aemform/AEMFormImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v2/aemform/AEMFormImpl.java new file mode 100644 index 0000000000..45a88b6c22 --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v2/aemform/AEMFormImpl.java @@ -0,0 +1,34 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v2.aemform; + +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.models.annotations.Exporter; +import org.apache.sling.models.annotations.Model; + +import com.adobe.cq.export.json.ComponentExporter; +import com.adobe.cq.export.json.ExporterConstants; +import com.adobe.cq.forms.core.components.models.aemform.AEMForm; + +@Model( + adaptables = SlingHttpServletRequest.class, + adapters = { AEMForm.class, + ComponentExporter.class }, + resourceType = AEMFormImpl.RESOURCE_TYPE) +@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION) +public class AEMFormImpl extends com.adobe.cq.forms.core.components.internal.models.v1.aemform.AEMFormImpl implements AEMForm { + public static final String RESOURCE_TYPE = "core/fd/components/aemform/v2/aemform"; +} diff --git a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v2/aemform/AEMFormImplTest.java b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v2/aemform/AEMFormImplTest.java new file mode 100644 index 0000000000..664792993e --- /dev/null +++ b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v2/aemform/AEMFormImplTest.java @@ -0,0 +1,62 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v2.aemform; + +import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mockito; + +import com.adobe.cq.forms.core.components.models.aemform.AEMForm; +import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext; +import io.wcm.testing.mock.aem.junit5.AemContext; +import io.wcm.testing.mock.aem.junit5.AemContextExtension; + +import static org.junit.Assert.assertEquals; + +@ExtendWith(AemContextExtension.class) +public class AEMFormImplTest { + private static final String BASE = "/aemform"; + private static final String CONTENT_ROOT = "/content"; + private static final String ROOT_PAGE = "/content/aemform"; + private static final String GRID = ROOT_PAGE + "/jcr:content/root/responsivegrid"; + private static final String FORM_1 = "/aemformv2-1"; + private static final String PATH_FORM_1 = GRID + FORM_1; + + private final AemContext context = FormsCoreComponentTestContext.newAemContext(); + + @BeforeEach + void setUp() { + context.load().json(BASE + FormsCoreComponentTestContext.TEST_CONTENT_JSON, CONTENT_ROOT); + } + + @Test + void testExportedType() { + AEMForm aemform = getAEMFormUnderTest(PATH_FORM_1); + assertEquals("core/fd/components/aemform/v2/aemform", aemform.getExportedType()); + AEMForm aemFormMock = Mockito.mock(AEMForm.class); + Mockito.when(aemFormMock.getExportedType()).thenCallRealMethod(); + Assertions.assertThrows(UnsupportedOperationException.class, aemFormMock::getExportedType); + } + + private AEMForm getAEMFormUnderTest(String resourcePath) { + context.currentResource(resourcePath); + MockSlingHttpServletRequest request = context.request(); + return request.adaptTo(AEMForm.class); + } +} diff --git a/bundles/core/src/test/resources/aemform/test-content.json b/bundles/core/src/test/resources/aemform/test-content.json index 17c177b1ab..fbe6dface4 100644 --- a/bundles/core/src/test/resources/aemform/test-content.json +++ b/bundles/core/src/test/resources/aemform/test-content.json @@ -33,6 +33,21 @@ "sling:resourceType": "core/fd/components/aemform/v1/aemform", "usePageLocale" : "true", "height" : "abc" + }, + "aemformv2-1" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType": "core/fd/components/aemform/v2/aemform", + "height": "100", + "thankyouPage": "/a/b/c", + "thankyouConfig": "page", + "formType": "adaptiveForm", + "formRef": "/content/forms/af/abc", + "themeRef": "/content/dam/formsanddocuments-themes/abc", + "submitType": "inline", + "cssClientlib": "abc.def", + "useiframe" : "true", + "usePageLocale" : "true", + "enableFocusOnFirstField" : true } } } diff --git a/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/aemform/.content.xml b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/aemform/.content.xml index 31851fab4d..0b9d4e7529 100644 --- a/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/aemform/.content.xml +++ b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/aemform/.content.xml @@ -3,5 +3,5 @@ jcr:description="AEM Forms Container Component for the Core Components Library" jcr:primaryType="cq:Component" jcr:title="AEM Forms Container" - sling:resourceSuperType="core/fd/components/aemform/v1/aemform" + sling:resourceSuperType="core/fd/components/aemform/v2/aemform" componentGroup="Core Components Examples"/> diff --git a/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/core-content/aemform/.content.xml b/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/core-content/aemform/.content.xml index 534cca2e38..18d31f59bb 100644 --- a/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/core-content/aemform/.content.xml +++ b/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/core-content/aemform/.content.xml @@ -24,7 +24,7 @@ jcr:lastModifiedBy="admin" jcr:primaryType="nt:unstructured" sling:resourceType="core/wcm/components/text/v2/text" - text="<h1>AEM Forms Container<sub>v1</sub></h1>" + text="<h1>AEM Forms Container<sub>v2</sub></h1>" textIsRich="true"/> + + + + diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/.content.xml b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/.content.xml new file mode 100644 index 0000000000..a77ddf167a --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/.content.xml @@ -0,0 +1,22 @@ + + + diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/README.md b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/README.md new file mode 100644 index 0000000000..2ff1c3d17a --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/README.md @@ -0,0 +1,55 @@ + +AEM Forms Container (v2) +==== +AEM Forms Container component written in HTL. + +## Features +* Customizable to use AEM Forms Theme +* AEM Forms Pages could be used inside iframe or non-iframe mode +* Customizable to enable/disable focus on the form +* Provides an action config to create an Adaptive Form on the fly. + +### Use Object +The AEM Forms Container component uses the `com.adobe.cq.forms.core.components.models.aemform.AEMForm` Sling model as its Use-object. + +### Edit Dialog Properties +The following properties are written to JCR for the AEM Form component and are expected to be available as `Resource` properties: + +1. `./useIframe` - specifies whether to use iframe as a container for the form or interactive communication. +2. `./thankyouPage` - specifies the thank you page to show on form submission. +3. `./thankyouMessage` - specifies the thank you message to show on form submission. +4. `./themeRef` - specifies the AEM Forms theme to use for the form or interactive communication. +5. `./enableFocusOnFirstField` - specifies whether to bring focus on the form or page containing the form or interactive communication. +6. `./submitType` - specifies a submit type for the form. It can be synchronous or asynchronous. +7. `./locale` - specifies the locale of the form or interactive communication. It could be sites page locale or a custom locale. +8. `./id` - specifies value for the component HTML ID attribute. + + +## BEM Description +``` +BLOCK cmp-aemform + ELEMENT cmp-aemform__iframecontent + ELEMENT cmp-aemform__content +``` + +## Information +* **Vendor**: Adobe +* **Version**: v2 +* **Compatibility**: AEM Forms as a cloud service +* **Status**: production-ready + +_If you were involved in the authoring of this component and are not credited above, please reach out to us on [GitHub](https://github.com/adobe/aem-core-forms-components)._ diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/_cq_dialog/.content.xml b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/_cq_dialog/.content.xml new file mode 100644 index 0000000000..abc685ca83 --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/_cq_dialog/.content.xml @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/_cq_editConfig.xml b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/_cq_editConfig.xml new file mode 100644 index 0000000000..8214dde8dc --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/_cq_editConfig.xml @@ -0,0 +1,37 @@ + + + + + + + + + diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/aemform.html b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/aemform.html new file mode 100644 index 0000000000..4ed1246665 --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/aemform.html @@ -0,0 +1,54 @@ + + + + + + + + + + + + + diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/.content.xml b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/.content.xml new file mode 100644 index 0000000000..74ee937feb --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/.content.xml @@ -0,0 +1,18 @@ + + + diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editor/.content.xml b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editor/.content.xml new file mode 100644 index 0000000000..3ffdd1113f --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editor/.content.xml @@ -0,0 +1,20 @@ + + + diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editor/js.txt b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editor/js.txt new file mode 100644 index 0000000000..d41ec0dd62 --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editor/js.txt @@ -0,0 +1,17 @@ +############################################################################### +# 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 diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/.content.xml b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/.content.xml new file mode 100644 index 0000000000..7045d143d9 --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/.content.xml @@ -0,0 +1,21 @@ + + + diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js.txt b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js.txt new file mode 100644 index 0000000000..93b263a97e --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js.txt @@ -0,0 +1,20 @@ +############################################################################### +# 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 +namespace.js +EditListeners.js +PreviewHook.js diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/EditListeners.js b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/EditListeners.js new file mode 100644 index 0000000000..2de9f75a1d --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/EditListeners.js @@ -0,0 +1,58 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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 (Granite, ns) { + ns.aemform.v2.constants = { + "AEM_FORM_SELECTOR" : "[data-form-page-path]", + "AEM_FORM_CONTAINER_SELECTOR" : ".cmp-aemform", + "AEM_FORM_WIZARD_LINK" : "/libs/fd/fm/base/content/commons/wizardspalink.html" + }; + + ns.aemform.v2.actions.openFormForEditing = function (editable) { + var htmlElement = $(ns.aemform.v2.constants.AEM_FORM_SELECTOR, editable.dom).addBack("[data-form-page-path]"), + formPath = htmlElement.attr("data-form-page-path"), + url = Granite.HTTP.externalize("/editor.html" + formPath + ".html"); + window.open(url); + }; + + ns.aemform.v2.actions.openCreateFormWizard = function (editable) { + $.ajax({ + url: Granite.HTTP.externalize(ns.aemform.v2.constants.AEM_FORM_WIZARD_LINK), + type: "GET", + success: function(data){ + var wizardURL = new URL($(data).get(0).href); + wizardURL.searchParams.append('embedAt', btoa(editable.path)); + wizardURL.searchParams.append('redirectUrl', btoa(window.location.href)); + window.open(Granite.HTTP.externalize(wizardURL.href), "_self"); + }, + error: function (error) { + console.log("Error: " + error); + } + }); + } + + ns.aemform.v2.actions.formExists = function (editable) { + return $(ns.aemform.v2.constants.AEM_FORM_SELECTOR, editable.dom).addBack(ns.aemform.v2.constants.AEM_FORM_SELECTOR).length > 0; + }; + + ns.aemform.v2.actions.aemFormExistsInPage = function () { + return Granite.author.ContentFrame.getDocument().find(ns.aemform.v2.constants.AEM_FORM_CONTAINER_SELECTOR).length > 0; + }; + + ns.aemform.v2.actions.featureEnabled = function (editable) { + return Granite.Toggles.isEnabled("FT_CQ-4343036"); + }; + +}(window.Granite, CQ.FormsCoreComponents)); diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/PreviewHook.js b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/PreviewHook.js new file mode 100644 index 0000000000..0af8d94161 --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/PreviewHook.js @@ -0,0 +1,31 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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 (channel, ns) { + + // once the layer is switched, check if AEM form component exists in the page + // if aem form component exists, then refresh the page, so that we can show the test data in wcmmode preview + channel.on("editor-frame-mode-changed.aemform", function () { + if (ns.aemform && ns.aemform.v2 && ns.aemform.v2.actions && ns.aemform.v2.actions.aemFormExistsInPage()) { + // check if the cookie is wcmmode preview + var wcModeCookie = $.cookie("wcmmode"); + if (wcModeCookie == "preview" || wcModeCookie == "edit") { + // reload the page + window.location.reload(); + } + } + }); + +}($(document), CQ.FormsCoreComponents)); diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/namespace.js b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/namespace.js new file mode 100644 index 0000000000..6460bad2eb --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/namespace.js @@ -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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +(function() { + window.CQ = window.CQ || {}; + window.CQ.FormsCoreComponents = window.CQ.FormsCoreComponents || {}; + window.CQ.FormsCoreComponents.aemform = window.CQ.FormsCoreComponents.aemform || {}; + window.CQ.FormsCoreComponents.aemform.v2 = window.CQ.FormsCoreComponents.aemform.v2 || {}; + window.CQ.FormsCoreComponents.aemform.v2.actions = {}; +})(); diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/formapp/.content.xml b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/formapp/.content.xml new file mode 100644 index 0000000000..367130e7da --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/formapp/.content.xml @@ -0,0 +1,21 @@ + + + diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/formapp/css.txt b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/formapp/css.txt new file mode 100644 index 0000000000..0ea67c2e1c --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/formapp/css.txt @@ -0,0 +1,16 @@ +############################################################################### +# 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 diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/formapp/js.txt b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/formapp/js.txt new file mode 100644 index 0000000000..76033e850b --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/formapp/js.txt @@ -0,0 +1,16 @@ +############################################################################### +# 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 diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/.content.xml b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/.content.xml new file mode 100644 index 0000000000..7b04808c1a --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/.content.xml @@ -0,0 +1,18 @@ + + + diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeContentResizer/.content.xml b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeContentResizer/.content.xml new file mode 100644 index 0000000000..8dec114854 --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeContentResizer/.content.xml @@ -0,0 +1,21 @@ + + + diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeContentResizer/css.txt b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeContentResizer/css.txt new file mode 100644 index 0000000000..0ea67c2e1c --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeContentResizer/css.txt @@ -0,0 +1,16 @@ +############################################################################### +# 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 diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeContentResizer/js.txt b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeContentResizer/js.txt new file mode 100644 index 0000000000..76033e850b --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeContentResizer/js.txt @@ -0,0 +1,16 @@ +############################################################################### +# 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 diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeResizer/.content.xml b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeResizer/.content.xml new file mode 100644 index 0000000000..3ea896ce07 --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeResizer/.content.xml @@ -0,0 +1,21 @@ + + + diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeResizer/js.txt b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeResizer/js.txt new file mode 100644 index 0000000000..76033e850b --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/runtime/third-party/iframeResizer/js.txt @@ -0,0 +1,16 @@ +############################################################################### +# 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 diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/site/.content.xml b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/site/.content.xml new file mode 100644 index 0000000000..60311beab5 --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/site/.content.xml @@ -0,0 +1,21 @@ + + + diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/site/css.txt b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/site/css.txt new file mode 100644 index 0000000000..2f2fd45de0 --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/site/css.txt @@ -0,0 +1,17 @@ +############################################################################### +# 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 diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/formcontainer.html b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/formcontainer.html new file mode 100644 index 0000000000..da3c9eddd9 --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/formcontainer.html @@ -0,0 +1,40 @@ + + + + + + +
+ ${'Select a form to embed.' @ i18n, locale=request.locale}
+ ${'Tap' @ i18n, locale=request.locale} + + ${'to embed an existing form or use ' @ i18n, locale=request.locale} + + ${'to create and embed a new form.' @ i18n, locale=request.locale} +
+
+
+ + + + + +
diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/formcontainer.js b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/formcontainer.js new file mode 100644 index 0000000000..eb2d5d8756 --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/formcontainer.js @@ -0,0 +1,24 @@ +/* + * 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. + */ +/** + * using property wcmmode and theme configured in af in aem. + */ +use(function () { + var property; + for (property in this) { + request.setAttribute(property, this[property]); + } +}); diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/iframe.html b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/iframe.html new file mode 100644 index 0000000000..7f56ea77c4 --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/iframe.html @@ -0,0 +1,30 @@ + + + + + + <sly data-sly-use.af="com.adobe.aemds.guide.common.AdaptiveForm" />${af.formTitle @ context='html'} + + + + + + + + + diff --git a/ui.tests/test-module/specs/aemformcontainer.spec.js b/ui.tests/test-module/specs/aemformcontainer.spec.js index 21d2d12840..224e8840a6 100644 --- a/ui.tests/test-module/specs/aemformcontainer.spec.js +++ b/ui.tests/test-module/specs/aemformcontainer.spec.js @@ -61,10 +61,6 @@ describe('Page - Authoring', function () { // click configure action on aem forms container component cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + aemFormContainerEditPathSelector); cy.invokeEditableAction("[data-action='CONFIGURE']"); // this line is causing frame busting which is causing cypress to fail - // check if adaptive form is selected by default - cy.get("[name='./formType']") - .should("be.visible") - .should("have.value", "adaptiveForm"); // check for dynamic operations performed using JS cy.get("[name='./thankyouConfig'][value='message']") .should("be.visible") From 062148c91f7180ca881a27a170737e294948dcbf Mon Sep 17 00:00:00 2001 From: Rishi Mehta Date: Wed, 3 Aug 2022 17:19:58 +0530 Subject: [PATCH 005/494] @releng [maven-scm] :prepare release core-forms-components-reactor-1.0.18 --- all/pom.xml | 4 ++-- bundles/core/pom.xml | 4 ++-- examples/all/pom.xml | 4 ++-- examples/pom.xml | 2 +- examples/ui.apps/pom.xml | 4 ++-- examples/ui.content/pom.xml | 4 ++-- it/content/pom.xml | 4 ++-- parent/pom.xml | 4 ++-- pom.xml | 4 ++-- ui.apps/pom.xml | 4 ++-- ui.tests/pom.xml | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/all/pom.xml b/all/pom.xml index 7430b0274c..8b354ab64d 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.17-SNAPSHOT + 1.0.18 ../parent/pom.xml @@ -39,7 +39,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.18 Adobe diff --git a/bundles/core/pom.xml b/bundles/core/pom.xml index a65b062ccb..9e2a17a4b6 100644 --- a/bundles/core/pom.xml +++ b/bundles/core/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.17-SNAPSHOT + 1.0.18 ../../parent/pom.xml @@ -38,7 +38,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.18 Adobe diff --git a/examples/all/pom.xml b/examples/all/pom.xml index 628f841ac6..89b1ebfb44 100644 --- a/examples/all/pom.xml +++ b/examples/all/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.17-SNAPSHOT + 1.0.18 ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.18 Adobe diff --git a/examples/pom.xml b/examples/pom.xml index e758c410d0..533f5cc2c7 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.17-SNAPSHOT + 1.0.18 ../parent/pom.xml diff --git a/examples/ui.apps/pom.xml b/examples/ui.apps/pom.xml index 4b6fc5f22b..ee3216dffc 100644 --- a/examples/ui.apps/pom.xml +++ b/examples/ui.apps/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.17-SNAPSHOT + 1.0.18 ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.18 Adobe diff --git a/examples/ui.content/pom.xml b/examples/ui.content/pom.xml index db8bfd030d..47da572b0a 100644 --- a/examples/ui.content/pom.xml +++ b/examples/ui.content/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.17-SNAPSHOT + 1.0.18 ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.18 Adobe diff --git a/it/content/pom.xml b/it/content/pom.xml index fc323dc6f2..c851ccb9b9 100644 --- a/it/content/pom.xml +++ b/it/content/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.17-SNAPSHOT + 1.0.18 ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.18 Adobe diff --git a/parent/pom.xml b/parent/pom.xml index 2e00b65e2c..e19ad0021e 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent pom - 1.0.17-SNAPSHOT + 1.0.18 AEM Forms Core Components - Parent Parent POM for AEM Forms Core Components @@ -31,7 +31,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.18 diff --git a/pom.xml b/pom.xml index c98f50732b..ba53c034f9 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.17-SNAPSHOT + 1.0.18 parent/pom.xml @@ -70,7 +70,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.18 diff --git a/ui.apps/pom.xml b/ui.apps/pom.xml index b45e3a00e4..19af1d7c95 100644 --- a/ui.apps/pom.xml +++ b/ui.apps/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.17-SNAPSHOT + 1.0.18 ../parent/pom.xml @@ -37,7 +37,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.18 Adobe diff --git a/ui.tests/pom.xml b/ui.tests/pom.xml index 30c184b9cb..fac019800d 100644 --- a/ui.tests/pom.xml +++ b/ui.tests/pom.xml @@ -24,7 +24,7 @@ com.adobe.aem core-forms-components-parent - 1.0.17-SNAPSHOT + 1.0.18 ../parent/pom.xml From 577c74270c08f8ef064928e2357874b5ce63d88c Mon Sep 17 00:00:00 2001 From: Rishi Mehta Date: Wed, 3 Aug 2022 17:19:59 +0530 Subject: [PATCH 006/494] @releng [maven-scm] :prepare for next development iteration --- all/pom.xml | 4 ++-- bundles/core/pom.xml | 4 ++-- examples/all/pom.xml | 4 ++-- examples/pom.xml | 2 +- examples/ui.apps/pom.xml | 4 ++-- examples/ui.content/pom.xml | 4 ++-- it/content/pom.xml | 4 ++-- parent/pom.xml | 4 ++-- pom.xml | 4 ++-- ui.apps/pom.xml | 4 ++-- ui.tests/pom.xml | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/all/pom.xml b/all/pom.xml index 8b354ab64d..e4dbb65dd3 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.18 + 1.0.19-SNAPSHOT ../parent/pom.xml @@ -39,7 +39,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.18 + HEAD Adobe diff --git a/bundles/core/pom.xml b/bundles/core/pom.xml index 9e2a17a4b6..14e2be4520 100644 --- a/bundles/core/pom.xml +++ b/bundles/core/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.18 + 1.0.19-SNAPSHOT ../../parent/pom.xml @@ -38,7 +38,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.18 + HEAD Adobe diff --git a/examples/all/pom.xml b/examples/all/pom.xml index 89b1ebfb44..a5fdd4d791 100644 --- a/examples/all/pom.xml +++ b/examples/all/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.18 + 1.0.19-SNAPSHOT ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.18 + HEAD Adobe diff --git a/examples/pom.xml b/examples/pom.xml index 533f5cc2c7..2eb005b68f 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.18 + 1.0.19-SNAPSHOT ../parent/pom.xml diff --git a/examples/ui.apps/pom.xml b/examples/ui.apps/pom.xml index ee3216dffc..f9316454f5 100644 --- a/examples/ui.apps/pom.xml +++ b/examples/ui.apps/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.18 + 1.0.19-SNAPSHOT ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.18 + HEAD Adobe diff --git a/examples/ui.content/pom.xml b/examples/ui.content/pom.xml index 47da572b0a..8e0c1c5763 100644 --- a/examples/ui.content/pom.xml +++ b/examples/ui.content/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.18 + 1.0.19-SNAPSHOT ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.18 + HEAD Adobe diff --git a/it/content/pom.xml b/it/content/pom.xml index c851ccb9b9..f194ca1892 100644 --- a/it/content/pom.xml +++ b/it/content/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.18 + 1.0.19-SNAPSHOT ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.18 + HEAD Adobe diff --git a/parent/pom.xml b/parent/pom.xml index e19ad0021e..2e4781d4de 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent pom - 1.0.18 + 1.0.19-SNAPSHOT AEM Forms Core Components - Parent Parent POM for AEM Forms Core Components @@ -31,7 +31,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.18 + HEAD diff --git a/pom.xml b/pom.xml index ba53c034f9..839b5d9aea 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.18 + 1.0.19-SNAPSHOT parent/pom.xml @@ -70,7 +70,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.18 + HEAD diff --git a/ui.apps/pom.xml b/ui.apps/pom.xml index 19af1d7c95..bd3954017d 100644 --- a/ui.apps/pom.xml +++ b/ui.apps/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.18 + 1.0.19-SNAPSHOT ../parent/pom.xml @@ -37,7 +37,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.18 + HEAD Adobe diff --git a/ui.tests/pom.xml b/ui.tests/pom.xml index fac019800d..0389ea30f5 100644 --- a/ui.tests/pom.xml +++ b/ui.tests/pom.xml @@ -24,7 +24,7 @@ com.adobe.aem core-forms-components-parent - 1.0.18 + 1.0.19-SNAPSHOT ../parent/pom.xml From b94360f306867cca8b47b8c5588893cdff9e74a4 Mon Sep 17 00:00:00 2001 From: Rishi Mehta Date: Wed, 3 Aug 2022 17:21:08 +0530 Subject: [PATCH 007/494] @trivial Updating released version in read me --- README.md | 2 +- VERSIONS.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2006007edf..623f5f5c4e 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ The latest version of the AEM Forms Core Components, require the below minimum s | Forms Core Components | WCM Core Components | AEM Forms as a cloud service | Java | Maven | | --------------------- | ------------------- | ---------------------------- | ----- | ------ | -| 1.0.16 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | +| 1.0.18 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | For a list of requirements for previous versions, see [Historical System Requirements](VERSIONS.md). diff --git a/VERSIONS.md b/VERSIONS.md index 8334b1527c..0c59df5b51 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -4,6 +4,7 @@ See below for a full list of minimum system requirements for historical versions | Forms Core Components | WCM Core Components | AEM Forms as a cloud service | Java | Maven | | --------------------- | ------------------- | ---------------------------- | ----- | ------ | +| 1.0.16 | 2.19.0 | Continual | 8, 11 | 3.3.9+ | | 1.0.14 | 2.19.0 | Continual | 8, 11 | 3.3.9+ | | 1.0.12 | 2.19.0 | Continual | 8, 11 | 3.3.9+ | | 1.0.10 | 2.19.0 | Continual | 8, 11 | 3.3.9+ | From cadfc270640435cef796051ec8b79bc695d9497f Mon Sep 17 00:00:00 2001 From: Ujjwal Gupta Date: Tue, 9 Aug 2022 21:53:05 +0530 Subject: [PATCH 008/494] CQ-4346953 Fix wizard redirect in Sites page for AEM in Unified Shell (#113) Co-authored-by: ujjgupta --- .../v2/aemform/clientlibs/editorhook/js/EditListeners.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/EditListeners.js b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/EditListeners.js index 2de9f75a1d..3d1f4eb5c5 100644 --- a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/EditListeners.js +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/EditListeners.js @@ -35,7 +35,7 @@ var wizardURL = new URL($(data).get(0).href); wizardURL.searchParams.append('embedAt', btoa(editable.path)); wizardURL.searchParams.append('redirectUrl', btoa(window.location.href)); - window.open(Granite.HTTP.externalize(wizardURL.href), "_self"); + window.open(Granite.HTTP.externalize(wizardURL.href), "_top"); }, error: function (error) { console.log("Error: " + error); From 0d71ee0dd0cbfe4ae81c6f0571319da71b916af7 Mon Sep 17 00:00:00 2001 From: Rishi Mehta Date: Tue, 9 Aug 2022 21:56:16 +0530 Subject: [PATCH 009/494] @releng [maven-scm] :prepare release core-forms-components-reactor-1.0.20 --- all/pom.xml | 4 ++-- bundles/core/pom.xml | 4 ++-- examples/all/pom.xml | 4 ++-- examples/pom.xml | 2 +- examples/ui.apps/pom.xml | 4 ++-- examples/ui.content/pom.xml | 4 ++-- it/content/pom.xml | 4 ++-- parent/pom.xml | 4 ++-- pom.xml | 4 ++-- ui.apps/pom.xml | 4 ++-- ui.tests/pom.xml | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/all/pom.xml b/all/pom.xml index e4dbb65dd3..97f0b3a3dc 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.19-SNAPSHOT + 1.0.20 ../parent/pom.xml @@ -39,7 +39,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.20 Adobe diff --git a/bundles/core/pom.xml b/bundles/core/pom.xml index 14e2be4520..e5655f9b24 100644 --- a/bundles/core/pom.xml +++ b/bundles/core/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.19-SNAPSHOT + 1.0.20 ../../parent/pom.xml @@ -38,7 +38,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.20 Adobe diff --git a/examples/all/pom.xml b/examples/all/pom.xml index a5fdd4d791..becb12537c 100644 --- a/examples/all/pom.xml +++ b/examples/all/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.19-SNAPSHOT + 1.0.20 ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.20 Adobe diff --git a/examples/pom.xml b/examples/pom.xml index 2eb005b68f..2e2a2d0e64 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.19-SNAPSHOT + 1.0.20 ../parent/pom.xml diff --git a/examples/ui.apps/pom.xml b/examples/ui.apps/pom.xml index f9316454f5..c43b139732 100644 --- a/examples/ui.apps/pom.xml +++ b/examples/ui.apps/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.19-SNAPSHOT + 1.0.20 ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.20 Adobe diff --git a/examples/ui.content/pom.xml b/examples/ui.content/pom.xml index 8e0c1c5763..06cca54c9c 100644 --- a/examples/ui.content/pom.xml +++ b/examples/ui.content/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.19-SNAPSHOT + 1.0.20 ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.20 Adobe diff --git a/it/content/pom.xml b/it/content/pom.xml index f194ca1892..b1514abfc0 100644 --- a/it/content/pom.xml +++ b/it/content/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.19-SNAPSHOT + 1.0.20 ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.20 Adobe diff --git a/parent/pom.xml b/parent/pom.xml index 2e4781d4de..89b400c384 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent pom - 1.0.19-SNAPSHOT + 1.0.20 AEM Forms Core Components - Parent Parent POM for AEM Forms Core Components @@ -31,7 +31,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.20 diff --git a/pom.xml b/pom.xml index 839b5d9aea..02446aebe7 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.19-SNAPSHOT + 1.0.20 parent/pom.xml @@ -70,7 +70,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.20 diff --git a/ui.apps/pom.xml b/ui.apps/pom.xml index bd3954017d..ab32223b74 100644 --- a/ui.apps/pom.xml +++ b/ui.apps/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.19-SNAPSHOT + 1.0.20 ../parent/pom.xml @@ -37,7 +37,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.20 Adobe diff --git a/ui.tests/pom.xml b/ui.tests/pom.xml index 0389ea30f5..45d4dd7e5d 100644 --- a/ui.tests/pom.xml +++ b/ui.tests/pom.xml @@ -24,7 +24,7 @@ com.adobe.aem core-forms-components-parent - 1.0.19-SNAPSHOT + 1.0.20 ../parent/pom.xml From a2456c3a261459abfd7873be2c798e88a88ca1b2 Mon Sep 17 00:00:00 2001 From: Rishi Mehta Date: Tue, 9 Aug 2022 21:56:17 +0530 Subject: [PATCH 010/494] @releng [maven-scm] :prepare for next development iteration --- all/pom.xml | 4 ++-- bundles/core/pom.xml | 4 ++-- examples/all/pom.xml | 4 ++-- examples/pom.xml | 2 +- examples/ui.apps/pom.xml | 4 ++-- examples/ui.content/pom.xml | 4 ++-- it/content/pom.xml | 4 ++-- parent/pom.xml | 4 ++-- pom.xml | 4 ++-- ui.apps/pom.xml | 4 ++-- ui.tests/pom.xml | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/all/pom.xml b/all/pom.xml index 97f0b3a3dc..01aba004ed 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.20 + 1.0.21-SNAPSHOT ../parent/pom.xml @@ -39,7 +39,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.20 + HEAD Adobe diff --git a/bundles/core/pom.xml b/bundles/core/pom.xml index e5655f9b24..1a1533fbc2 100644 --- a/bundles/core/pom.xml +++ b/bundles/core/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.20 + 1.0.21-SNAPSHOT ../../parent/pom.xml @@ -38,7 +38,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.20 + HEAD Adobe diff --git a/examples/all/pom.xml b/examples/all/pom.xml index becb12537c..5ec78d12c1 100644 --- a/examples/all/pom.xml +++ b/examples/all/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.20 + 1.0.21-SNAPSHOT ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.20 + HEAD Adobe diff --git a/examples/pom.xml b/examples/pom.xml index 2e2a2d0e64..f29ddbcbfe 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.20 + 1.0.21-SNAPSHOT ../parent/pom.xml diff --git a/examples/ui.apps/pom.xml b/examples/ui.apps/pom.xml index c43b139732..a2ecc73e83 100644 --- a/examples/ui.apps/pom.xml +++ b/examples/ui.apps/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.20 + 1.0.21-SNAPSHOT ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.20 + HEAD Adobe diff --git a/examples/ui.content/pom.xml b/examples/ui.content/pom.xml index 06cca54c9c..8bbfb93f89 100644 --- a/examples/ui.content/pom.xml +++ b/examples/ui.content/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.20 + 1.0.21-SNAPSHOT ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.20 + HEAD Adobe diff --git a/it/content/pom.xml b/it/content/pom.xml index b1514abfc0..87e4fddef0 100644 --- a/it/content/pom.xml +++ b/it/content/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.20 + 1.0.21-SNAPSHOT ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.20 + HEAD Adobe diff --git a/parent/pom.xml b/parent/pom.xml index 89b400c384..e073cb6545 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent pom - 1.0.20 + 1.0.21-SNAPSHOT AEM Forms Core Components - Parent Parent POM for AEM Forms Core Components @@ -31,7 +31,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.20 + HEAD diff --git a/pom.xml b/pom.xml index 02446aebe7..0256d89ed2 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.20 + 1.0.21-SNAPSHOT parent/pom.xml @@ -70,7 +70,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.20 + HEAD diff --git a/ui.apps/pom.xml b/ui.apps/pom.xml index ab32223b74..f43825c4aa 100644 --- a/ui.apps/pom.xml +++ b/ui.apps/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.20 + 1.0.21-SNAPSHOT ../parent/pom.xml @@ -37,7 +37,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.20 + HEAD Adobe diff --git a/ui.tests/pom.xml b/ui.tests/pom.xml index 45d4dd7e5d..31d2eadde1 100644 --- a/ui.tests/pom.xml +++ b/ui.tests/pom.xml @@ -24,7 +24,7 @@ com.adobe.aem core-forms-components-parent - 1.0.20 + 1.0.21-SNAPSHOT ../parent/pom.xml From 08d5e3193a15bcd687c817047c3a41f6893c8b80 Mon Sep 17 00:00:00 2001 From: Rishi Mehta Date: Tue, 9 Aug 2022 21:57:47 +0530 Subject: [PATCH 011/494] @trivial updating read me with new version --- README.md | 2 +- VERSIONS.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 623f5f5c4e..808a079744 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ The latest version of the AEM Forms Core Components, require the below minimum s | Forms Core Components | WCM Core Components | AEM Forms as a cloud service | Java | Maven | | --------------------- | ------------------- | ---------------------------- | ----- | ------ | -| 1.0.18 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | +| 1.0.20 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | For a list of requirements for previous versions, see [Historical System Requirements](VERSIONS.md). diff --git a/VERSIONS.md b/VERSIONS.md index 0c59df5b51..15e76948e9 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -4,6 +4,7 @@ See below for a full list of minimum system requirements for historical versions | Forms Core Components | WCM Core Components | AEM Forms as a cloud service | Java | Maven | | --------------------- | ------------------- | ---------------------------- | ----- | ------ | +| 1.0.18 | 2.19.0 | Continual | 8, 11 | 3.3.9+ | | 1.0.16 | 2.19.0 | Continual | 8, 11 | 3.3.9+ | | 1.0.14 | 2.19.0 | Continual | 8, 11 | 3.3.9+ | | 1.0.12 | 2.19.0 | Continual | 8, 11 | 3.3.9+ | From 5da00683d13b21cd58abbc575a0802dbabd227d6 Mon Sep 17 00:00:00 2001 From: Rishi Mehta Date: Tue, 9 Aug 2022 21:59:58 +0530 Subject: [PATCH 012/494] @trivial Fixing old version compatibility matrix --- VERSIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSIONS.md b/VERSIONS.md index 15e76948e9..c158275951 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -4,7 +4,7 @@ See below for a full list of minimum system requirements for historical versions | Forms Core Components | WCM Core Components | AEM Forms as a cloud service | Java | Maven | | --------------------- | ------------------- | ---------------------------- | ----- | ------ | -| 1.0.18 | 2.19.0 | Continual | 8, 11 | 3.3.9+ | +| 1.0.18 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | | 1.0.16 | 2.19.0 | Continual | 8, 11 | 3.3.9+ | | 1.0.14 | 2.19.0 | Continual | 8, 11 | 3.3.9+ | | 1.0.12 | 2.19.0 | Continual | 8, 11 | 3.3.9+ | From 10eea04ae864ea0292cfe2959babebd041cda581 Mon Sep 17 00:00:00 2001 From: Ujjwal Gupta Date: Thu, 11 Aug 2022 11:16:54 +0530 Subject: [PATCH 013/494] Revert: CQ-4346953 Fix wizard redirect in Sites page for AEM in Unified Shell (#114) Co-authored-by: ujjgupta --- .../v2/aemform/clientlibs/editorhook/js/EditListeners.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/EditListeners.js b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/EditListeners.js index 3d1f4eb5c5..2de9f75a1d 100644 --- a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/EditListeners.js +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/EditListeners.js @@ -35,7 +35,7 @@ var wizardURL = new URL($(data).get(0).href); wizardURL.searchParams.append('embedAt', btoa(editable.path)); wizardURL.searchParams.append('redirectUrl', btoa(window.location.href)); - window.open(Granite.HTTP.externalize(wizardURL.href), "_top"); + window.open(Granite.HTTP.externalize(wizardURL.href), "_self"); }, error: function (error) { console.log("Error: " + error); From 049f1511cf23ca514500503bbaa8ab2463749164 Mon Sep 17 00:00:00 2001 From: ujjgupta Date: Thu, 11 Aug 2022 12:05:49 +0530 Subject: [PATCH 014/494] @releng [maven-scm] :prepare release core-forms-components-reactor-1.0.22 --- all/pom.xml | 4 ++-- bundles/core/pom.xml | 4 ++-- examples/all/pom.xml | 4 ++-- examples/pom.xml | 2 +- examples/ui.apps/pom.xml | 4 ++-- examples/ui.content/pom.xml | 4 ++-- it/content/pom.xml | 4 ++-- parent/pom.xml | 4 ++-- pom.xml | 4 ++-- ui.apps/pom.xml | 4 ++-- ui.tests/pom.xml | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/all/pom.xml b/all/pom.xml index 01aba004ed..2529f3d5ce 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.21-SNAPSHOT + 1.0.22 ../parent/pom.xml @@ -39,7 +39,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.22 Adobe diff --git a/bundles/core/pom.xml b/bundles/core/pom.xml index 1a1533fbc2..9770c20e8f 100644 --- a/bundles/core/pom.xml +++ b/bundles/core/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.21-SNAPSHOT + 1.0.22 ../../parent/pom.xml @@ -38,7 +38,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.22 Adobe diff --git a/examples/all/pom.xml b/examples/all/pom.xml index 5ec78d12c1..ba6a2c8ce4 100644 --- a/examples/all/pom.xml +++ b/examples/all/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.21-SNAPSHOT + 1.0.22 ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.22 Adobe diff --git a/examples/pom.xml b/examples/pom.xml index f29ddbcbfe..9183580e5c 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.21-SNAPSHOT + 1.0.22 ../parent/pom.xml diff --git a/examples/ui.apps/pom.xml b/examples/ui.apps/pom.xml index a2ecc73e83..1104d20182 100644 --- a/examples/ui.apps/pom.xml +++ b/examples/ui.apps/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.21-SNAPSHOT + 1.0.22 ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.22 Adobe diff --git a/examples/ui.content/pom.xml b/examples/ui.content/pom.xml index 8bbfb93f89..f47c99f771 100644 --- a/examples/ui.content/pom.xml +++ b/examples/ui.content/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.21-SNAPSHOT + 1.0.22 ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.22 Adobe diff --git a/it/content/pom.xml b/it/content/pom.xml index 87e4fddef0..91571b0bd6 100644 --- a/it/content/pom.xml +++ b/it/content/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.21-SNAPSHOT + 1.0.22 ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.22 Adobe diff --git a/parent/pom.xml b/parent/pom.xml index e073cb6545..ccd0a2f10a 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent pom - 1.0.21-SNAPSHOT + 1.0.22 AEM Forms Core Components - Parent Parent POM for AEM Forms Core Components @@ -31,7 +31,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.22 diff --git a/pom.xml b/pom.xml index 0256d89ed2..cb9f675479 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.21-SNAPSHOT + 1.0.22 parent/pom.xml @@ -70,7 +70,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.22 diff --git a/ui.apps/pom.xml b/ui.apps/pom.xml index f43825c4aa..95bc89b22a 100644 --- a/ui.apps/pom.xml +++ b/ui.apps/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.21-SNAPSHOT + 1.0.22 ../parent/pom.xml @@ -37,7 +37,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.22 Adobe diff --git a/ui.tests/pom.xml b/ui.tests/pom.xml index 31d2eadde1..e05513cf27 100644 --- a/ui.tests/pom.xml +++ b/ui.tests/pom.xml @@ -24,7 +24,7 @@ com.adobe.aem core-forms-components-parent - 1.0.21-SNAPSHOT + 1.0.22 ../parent/pom.xml From 853ad9d0e419bc80b211f15019bac4bdc2677048 Mon Sep 17 00:00:00 2001 From: ujjgupta Date: Thu, 11 Aug 2022 12:05:50 +0530 Subject: [PATCH 015/494] @releng [maven-scm] :prepare for next development iteration --- all/pom.xml | 4 ++-- bundles/core/pom.xml | 4 ++-- examples/all/pom.xml | 4 ++-- examples/pom.xml | 2 +- examples/ui.apps/pom.xml | 4 ++-- examples/ui.content/pom.xml | 4 ++-- it/content/pom.xml | 4 ++-- parent/pom.xml | 4 ++-- pom.xml | 4 ++-- ui.apps/pom.xml | 4 ++-- ui.tests/pom.xml | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/all/pom.xml b/all/pom.xml index 2529f3d5ce..20c9802895 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.22 + 1.0.23-SNAPSHOT ../parent/pom.xml @@ -39,7 +39,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.22 + HEAD Adobe diff --git a/bundles/core/pom.xml b/bundles/core/pom.xml index 9770c20e8f..9144df398e 100644 --- a/bundles/core/pom.xml +++ b/bundles/core/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.22 + 1.0.23-SNAPSHOT ../../parent/pom.xml @@ -38,7 +38,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.22 + HEAD Adobe diff --git a/examples/all/pom.xml b/examples/all/pom.xml index ba6a2c8ce4..5b9f04ba1a 100644 --- a/examples/all/pom.xml +++ b/examples/all/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.22 + 1.0.23-SNAPSHOT ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.22 + HEAD Adobe diff --git a/examples/pom.xml b/examples/pom.xml index 9183580e5c..efcae0ba9f 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.22 + 1.0.23-SNAPSHOT ../parent/pom.xml diff --git a/examples/ui.apps/pom.xml b/examples/ui.apps/pom.xml index 1104d20182..da4fde93b0 100644 --- a/examples/ui.apps/pom.xml +++ b/examples/ui.apps/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.22 + 1.0.23-SNAPSHOT ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.22 + HEAD Adobe diff --git a/examples/ui.content/pom.xml b/examples/ui.content/pom.xml index f47c99f771..18da699e69 100644 --- a/examples/ui.content/pom.xml +++ b/examples/ui.content/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.22 + 1.0.23-SNAPSHOT ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.22 + HEAD Adobe diff --git a/it/content/pom.xml b/it/content/pom.xml index 91571b0bd6..15a9bd6f28 100644 --- a/it/content/pom.xml +++ b/it/content/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.22 + 1.0.23-SNAPSHOT ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.22 + HEAD Adobe diff --git a/parent/pom.xml b/parent/pom.xml index ccd0a2f10a..e1ba18c4a0 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent pom - 1.0.22 + 1.0.23-SNAPSHOT AEM Forms Core Components - Parent Parent POM for AEM Forms Core Components @@ -31,7 +31,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.22 + HEAD diff --git a/pom.xml b/pom.xml index cb9f675479..9e4a40ac78 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.22 + 1.0.23-SNAPSHOT parent/pom.xml @@ -70,7 +70,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.22 + HEAD diff --git a/ui.apps/pom.xml b/ui.apps/pom.xml index 95bc89b22a..b2e8d2e7b1 100644 --- a/ui.apps/pom.xml +++ b/ui.apps/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.22 + 1.0.23-SNAPSHOT ../parent/pom.xml @@ -37,7 +37,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.22 + HEAD Adobe diff --git a/ui.tests/pom.xml b/ui.tests/pom.xml index e05513cf27..fb97e66584 100644 --- a/ui.tests/pom.xml +++ b/ui.tests/pom.xml @@ -24,7 +24,7 @@ com.adobe.aem core-forms-components-parent - 1.0.22 + 1.0.23-SNAPSHOT ../parent/pom.xml From 3c2374a9b5f926a26d3d3e79b75ff3f24e9bb0ae Mon Sep 17 00:00:00 2001 From: ujjgupta Date: Thu, 11 Aug 2022 12:10:56 +0530 Subject: [PATCH 016/494] @trivial updating read me with new version --- README.md | 2 +- VERSIONS.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 808a079744..56a5e1c7c4 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ The latest version of the AEM Forms Core Components, require the below minimum s | Forms Core Components | WCM Core Components | AEM Forms as a cloud service | Java | Maven | | --------------------- | ------------------- | ---------------------------- | ----- | ------ | -| 1.0.20 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | +| 1.0.22 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | For a list of requirements for previous versions, see [Historical System Requirements](VERSIONS.md). diff --git a/VERSIONS.md b/VERSIONS.md index c158275951..ba8ed31ab4 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -4,6 +4,7 @@ See below for a full list of minimum system requirements for historical versions | Forms Core Components | WCM Core Components | AEM Forms as a cloud service | Java | Maven | | --------------------- | ------------------- | ---------------------------- | ----- | ------ | +| 1.0.20 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | | 1.0.18 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | | 1.0.16 | 2.19.0 | Continual | 8, 11 | 3.3.9+ | | 1.0.14 | 2.19.0 | Continual | 8, 11 | 3.3.9+ | From c61dfe5c09ae45f8124c17b21a129b279b9475ff Mon Sep 17 00:00:00 2001 From: ujjgupta Date: Thu, 11 Aug 2022 13:02:58 +0530 Subject: [PATCH 017/494] @trivial Removing commented out tests --- .../specs/aemformcontainer.spec.js | 48 ------------------- 1 file changed, 48 deletions(-) diff --git a/ui.tests/test-module/specs/aemformcontainer.spec.js b/ui.tests/test-module/specs/aemformcontainer.spec.js index 224e8840a6..834b222c25 100644 --- a/ui.tests/test-module/specs/aemformcontainer.spec.js +++ b/ui.tests/test-module/specs/aemformcontainer.spec.js @@ -86,51 +86,3 @@ describe('Page - Authoring', function () { }); }); }); - -/* -describe('Page - Authoring - Wizard', function () { - context('Open Editor - Wizard', function () { - beforeEach(function () { - const baseUrl = Cypress.env('crx.contextPath') ? Cypress.env('crx.contextPath') : ""; - cy.visit(baseUrl); - cy.login(baseUrl); - cy.openAuthoringWithFeatureToggles(pagePath,["FT_CQ-4343036","FT_CQ-4339424"]); - }); - - it('open toolbar, select wizard and click on Cancel', function(){ - cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + aemFormContainerEditPathSelector); - cy.get("[data-action='createFormViaWizard']").should('be.visible'); - cy.invokeEditableAction("[data-action='createFormViaWizard']"); - cy.get(wizardSelectors.wizardCancelButton).click(); - }); - - it('open toolbar, select wizard and create a Form', function() { - cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + aemFormContainerEditPathSelector); - cy.get("[data-action='createFormViaWizard']").should('be.visible'); - cy.invokeEditableAction("[data-action='createFormViaWizard']"); - - cy.get(wizardSelectors.basicTemplate).click(); - cy.get(wizardSelectors.wizardCreateButton).click(); - cy.get(wizardSelectors.modal.create).should('be.visible'); - const formName = 'testcreateform_' + new Date().getTime(); - cy.get(wizardSelectors.modal.title).type(formName); - cy.get(wizardSelectors.modal.createButton).click(); - - //check if created form is configured - cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + aemFormContainerEditPathSelector); - cy.invokeEditableAction("[data-action='CONFIGURE']"); - cy.get("coral-taglist[name='./formRef']") - .should("have.value", "/content/dam/formsanddocuments/" + formName); - }); - - afterEach(function() { - cy.disableToggles(); - }); - - after(function() { - // clean up the operations performed in the test - cy.enableOrDisableTutorials(true); - }); - }); -}); -*/ From 78267310a7a17bdbd404ce13c5b346577c105605 Mon Sep 17 00:00:00 2001 From: ujjgupta Date: Thu, 11 Aug 2022 13:07:02 +0530 Subject: [PATCH 018/494] Revert "@trivial Removing commented out tests" This reverts commit c61dfe5c09ae45f8124c17b21a129b279b9475ff. --- .../specs/aemformcontainer.spec.js | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/ui.tests/test-module/specs/aemformcontainer.spec.js b/ui.tests/test-module/specs/aemformcontainer.spec.js index 834b222c25..224e8840a6 100644 --- a/ui.tests/test-module/specs/aemformcontainer.spec.js +++ b/ui.tests/test-module/specs/aemformcontainer.spec.js @@ -86,3 +86,51 @@ describe('Page - Authoring', function () { }); }); }); + +/* +describe('Page - Authoring - Wizard', function () { + context('Open Editor - Wizard', function () { + beforeEach(function () { + const baseUrl = Cypress.env('crx.contextPath') ? Cypress.env('crx.contextPath') : ""; + cy.visit(baseUrl); + cy.login(baseUrl); + cy.openAuthoringWithFeatureToggles(pagePath,["FT_CQ-4343036","FT_CQ-4339424"]); + }); + + it('open toolbar, select wizard and click on Cancel', function(){ + cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + aemFormContainerEditPathSelector); + cy.get("[data-action='createFormViaWizard']").should('be.visible'); + cy.invokeEditableAction("[data-action='createFormViaWizard']"); + cy.get(wizardSelectors.wizardCancelButton).click(); + }); + + it('open toolbar, select wizard and create a Form', function() { + cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + aemFormContainerEditPathSelector); + cy.get("[data-action='createFormViaWizard']").should('be.visible'); + cy.invokeEditableAction("[data-action='createFormViaWizard']"); + + cy.get(wizardSelectors.basicTemplate).click(); + cy.get(wizardSelectors.wizardCreateButton).click(); + cy.get(wizardSelectors.modal.create).should('be.visible'); + const formName = 'testcreateform_' + new Date().getTime(); + cy.get(wizardSelectors.modal.title).type(formName); + cy.get(wizardSelectors.modal.createButton).click(); + + //check if created form is configured + cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + aemFormContainerEditPathSelector); + cy.invokeEditableAction("[data-action='CONFIGURE']"); + cy.get("coral-taglist[name='./formRef']") + .should("have.value", "/content/dam/formsanddocuments/" + formName); + }); + + afterEach(function() { + cy.disableToggles(); + }); + + after(function() { + // clean up the operations performed in the test + cy.enableOrDisableTutorials(true); + }); + }); +}); +*/ From ea0b04e167409f4af6e55ce1bbad19744f8d1fae Mon Sep 17 00:00:00 2001 From: ujjgupta Date: Thu, 11 Aug 2022 13:13:57 +0530 Subject: [PATCH 019/494] @releng [maven-scm] :prepare release core-forms-components-reactor-1.0.24 --- all/pom.xml | 4 ++-- bundles/core/pom.xml | 4 ++-- examples/all/pom.xml | 4 ++-- examples/pom.xml | 2 +- examples/ui.apps/pom.xml | 4 ++-- examples/ui.content/pom.xml | 4 ++-- it/content/pom.xml | 4 ++-- parent/pom.xml | 4 ++-- pom.xml | 4 ++-- ui.apps/pom.xml | 4 ++-- ui.tests/pom.xml | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/all/pom.xml b/all/pom.xml index 20c9802895..c482a1d533 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.23-SNAPSHOT + 1.0.24 ../parent/pom.xml @@ -39,7 +39,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.24 Adobe diff --git a/bundles/core/pom.xml b/bundles/core/pom.xml index 9144df398e..28bd06fab0 100644 --- a/bundles/core/pom.xml +++ b/bundles/core/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.23-SNAPSHOT + 1.0.24 ../../parent/pom.xml @@ -38,7 +38,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.24 Adobe diff --git a/examples/all/pom.xml b/examples/all/pom.xml index 5b9f04ba1a..debb4ab33c 100644 --- a/examples/all/pom.xml +++ b/examples/all/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.23-SNAPSHOT + 1.0.24 ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.24 Adobe diff --git a/examples/pom.xml b/examples/pom.xml index efcae0ba9f..7bd06717cd 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.23-SNAPSHOT + 1.0.24 ../parent/pom.xml diff --git a/examples/ui.apps/pom.xml b/examples/ui.apps/pom.xml index da4fde93b0..75a6a59ced 100644 --- a/examples/ui.apps/pom.xml +++ b/examples/ui.apps/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.23-SNAPSHOT + 1.0.24 ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.24 Adobe diff --git a/examples/ui.content/pom.xml b/examples/ui.content/pom.xml index 18da699e69..3ba649773d 100644 --- a/examples/ui.content/pom.xml +++ b/examples/ui.content/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.23-SNAPSHOT + 1.0.24 ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.24 Adobe diff --git a/it/content/pom.xml b/it/content/pom.xml index 15a9bd6f28..7679d1e7f6 100644 --- a/it/content/pom.xml +++ b/it/content/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.23-SNAPSHOT + 1.0.24 ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.24 Adobe diff --git a/parent/pom.xml b/parent/pom.xml index e1ba18c4a0..ed2484387c 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent pom - 1.0.23-SNAPSHOT + 1.0.24 AEM Forms Core Components - Parent Parent POM for AEM Forms Core Components @@ -31,7 +31,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.24 diff --git a/pom.xml b/pom.xml index 9e4a40ac78..6055a03f7c 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.23-SNAPSHOT + 1.0.24 parent/pom.xml @@ -70,7 +70,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.24 diff --git a/ui.apps/pom.xml b/ui.apps/pom.xml index b2e8d2e7b1..e8ea082a78 100644 --- a/ui.apps/pom.xml +++ b/ui.apps/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.23-SNAPSHOT + 1.0.24 ../parent/pom.xml @@ -37,7 +37,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.24 Adobe diff --git a/ui.tests/pom.xml b/ui.tests/pom.xml index fb97e66584..7713b97c2a 100644 --- a/ui.tests/pom.xml +++ b/ui.tests/pom.xml @@ -24,7 +24,7 @@ com.adobe.aem core-forms-components-parent - 1.0.23-SNAPSHOT + 1.0.24 ../parent/pom.xml From fa146c31e830b2841b274d4a5a428514b44dd4e9 Mon Sep 17 00:00:00 2001 From: ujjgupta Date: Thu, 11 Aug 2022 13:13:58 +0530 Subject: [PATCH 020/494] @releng [maven-scm] :prepare for next development iteration --- all/pom.xml | 4 ++-- bundles/core/pom.xml | 4 ++-- examples/all/pom.xml | 4 ++-- examples/pom.xml | 2 +- examples/ui.apps/pom.xml | 4 ++-- examples/ui.content/pom.xml | 4 ++-- it/content/pom.xml | 4 ++-- parent/pom.xml | 4 ++-- pom.xml | 4 ++-- ui.apps/pom.xml | 4 ++-- ui.tests/pom.xml | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/all/pom.xml b/all/pom.xml index c482a1d533..25eaee3597 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.24 + 1.0.25-SNAPSHOT ../parent/pom.xml @@ -39,7 +39,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.24 + HEAD Adobe diff --git a/bundles/core/pom.xml b/bundles/core/pom.xml index 28bd06fab0..0a8bf3e865 100644 --- a/bundles/core/pom.xml +++ b/bundles/core/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.24 + 1.0.25-SNAPSHOT ../../parent/pom.xml @@ -38,7 +38,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.24 + HEAD Adobe diff --git a/examples/all/pom.xml b/examples/all/pom.xml index debb4ab33c..3f5f346ba3 100644 --- a/examples/all/pom.xml +++ b/examples/all/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.24 + 1.0.25-SNAPSHOT ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.24 + HEAD Adobe diff --git a/examples/pom.xml b/examples/pom.xml index 7bd06717cd..6bc54b04f2 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.24 + 1.0.25-SNAPSHOT ../parent/pom.xml diff --git a/examples/ui.apps/pom.xml b/examples/ui.apps/pom.xml index 75a6a59ced..e73b4a1677 100644 --- a/examples/ui.apps/pom.xml +++ b/examples/ui.apps/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.24 + 1.0.25-SNAPSHOT ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.24 + HEAD Adobe diff --git a/examples/ui.content/pom.xml b/examples/ui.content/pom.xml index 3ba649773d..4c4140edcb 100644 --- a/examples/ui.content/pom.xml +++ b/examples/ui.content/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.24 + 1.0.25-SNAPSHOT ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.24 + HEAD Adobe diff --git a/it/content/pom.xml b/it/content/pom.xml index 7679d1e7f6..356a5c7097 100644 --- a/it/content/pom.xml +++ b/it/content/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.24 + 1.0.25-SNAPSHOT ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.24 + HEAD Adobe diff --git a/parent/pom.xml b/parent/pom.xml index ed2484387c..66c2bee7ff 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent pom - 1.0.24 + 1.0.25-SNAPSHOT AEM Forms Core Components - Parent Parent POM for AEM Forms Core Components @@ -31,7 +31,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.24 + HEAD diff --git a/pom.xml b/pom.xml index 6055a03f7c..e6a80d7e18 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.24 + 1.0.25-SNAPSHOT parent/pom.xml @@ -70,7 +70,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.24 + HEAD diff --git a/ui.apps/pom.xml b/ui.apps/pom.xml index e8ea082a78..2d8d48fc95 100644 --- a/ui.apps/pom.xml +++ b/ui.apps/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.24 + 1.0.25-SNAPSHOT ../parent/pom.xml @@ -37,7 +37,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.24 + HEAD Adobe diff --git a/ui.tests/pom.xml b/ui.tests/pom.xml index 7713b97c2a..db5227000b 100644 --- a/ui.tests/pom.xml +++ b/ui.tests/pom.xml @@ -24,7 +24,7 @@ com.adobe.aem core-forms-components-parent - 1.0.24 + 1.0.25-SNAPSHOT ../parent/pom.xml From 14a4ea9d33ce738df294590c45e3b709941ff289 Mon Sep 17 00:00:00 2001 From: ujjgupta Date: Thu, 11 Aug 2022 13:38:05 +0530 Subject: [PATCH 021/494] @trivial updating read me with new version --- README.md | 2 +- VERSIONS.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 56a5e1c7c4..68b81709e1 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ The latest version of the AEM Forms Core Components, require the below minimum s | Forms Core Components | WCM Core Components | AEM Forms as a cloud service | Java | Maven | | --------------------- | ------------------- | ---------------------------- | ----- | ------ | -| 1.0.22 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | +| 1.0.24 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | For a list of requirements for previous versions, see [Historical System Requirements](VERSIONS.md). diff --git a/VERSIONS.md b/VERSIONS.md index ba8ed31ab4..89f660488a 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -4,6 +4,7 @@ See below for a full list of minimum system requirements for historical versions | Forms Core Components | WCM Core Components | AEM Forms as a cloud service | Java | Maven | | --------------------- | ------------------- | ---------------------------- | ----- | ------ | +| 1.0.22 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | | 1.0.20 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | | 1.0.18 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | | 1.0.16 | 2.19.0 | Continual | 8, 11 | 3.3.9+ | From 50718216a763796dd4b392e6148bd27a516279ed Mon Sep 17 00:00:00 2001 From: Ujjwal Gupta Date: Wed, 24 Aug 2022 14:17:10 +0530 Subject: [PATCH 022/494] CQ-4347278 Fix wizard redirect in Sites page for AEM in Unified Shell (#124) --- .../v2/aemform/clientlibs/editorhook/js/EditListeners.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/EditListeners.js b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/EditListeners.js index 2de9f75a1d..3d1f4eb5c5 100644 --- a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/EditListeners.js +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/clientlibs/editorhook/js/EditListeners.js @@ -35,7 +35,7 @@ var wizardURL = new URL($(data).get(0).href); wizardURL.searchParams.append('embedAt', btoa(editable.path)); wizardURL.searchParams.append('redirectUrl', btoa(window.location.href)); - window.open(Granite.HTTP.externalize(wizardURL.href), "_self"); + window.open(Granite.HTTP.externalize(wizardURL.href), "_top"); }, error: function (error) { console.log("Error: " + error); From 4f30b36a993cabfc12d4608b8cbec4cdef0ec5db Mon Sep 17 00:00:00 2001 From: ujjgupta Date: Wed, 24 Aug 2022 14:35:58 +0530 Subject: [PATCH 023/494] @releng [maven-scm] :prepare release core-forms-components-reactor-1.0.26 --- all/pom.xml | 4 ++-- bundles/core/pom.xml | 4 ++-- examples/all/pom.xml | 4 ++-- examples/pom.xml | 2 +- examples/ui.apps/pom.xml | 4 ++-- examples/ui.content/pom.xml | 4 ++-- it/content/pom.xml | 4 ++-- parent/pom.xml | 4 ++-- pom.xml | 4 ++-- ui.apps/pom.xml | 4 ++-- ui.tests/pom.xml | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/all/pom.xml b/all/pom.xml index 25eaee3597..16d440c662 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.25-SNAPSHOT + 1.0.26 ../parent/pom.xml @@ -39,7 +39,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.26 Adobe diff --git a/bundles/core/pom.xml b/bundles/core/pom.xml index 0a8bf3e865..6a30371f77 100644 --- a/bundles/core/pom.xml +++ b/bundles/core/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.25-SNAPSHOT + 1.0.26 ../../parent/pom.xml @@ -38,7 +38,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.26 Adobe diff --git a/examples/all/pom.xml b/examples/all/pom.xml index 3f5f346ba3..eaf367ba4c 100644 --- a/examples/all/pom.xml +++ b/examples/all/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.25-SNAPSHOT + 1.0.26 ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.26 Adobe diff --git a/examples/pom.xml b/examples/pom.xml index 6bc54b04f2..36ee1d13d9 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.25-SNAPSHOT + 1.0.26 ../parent/pom.xml diff --git a/examples/ui.apps/pom.xml b/examples/ui.apps/pom.xml index e73b4a1677..0055d97efe 100644 --- a/examples/ui.apps/pom.xml +++ b/examples/ui.apps/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.25-SNAPSHOT + 1.0.26 ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.26 Adobe diff --git a/examples/ui.content/pom.xml b/examples/ui.content/pom.xml index 4c4140edcb..46e0d0e4c8 100644 --- a/examples/ui.content/pom.xml +++ b/examples/ui.content/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.25-SNAPSHOT + 1.0.26 ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.26 Adobe diff --git a/it/content/pom.xml b/it/content/pom.xml index 356a5c7097..521a7bdcdd 100644 --- a/it/content/pom.xml +++ b/it/content/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.25-SNAPSHOT + 1.0.26 ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.26 Adobe diff --git a/parent/pom.xml b/parent/pom.xml index 66c2bee7ff..07285ca381 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent pom - 1.0.25-SNAPSHOT + 1.0.26 AEM Forms Core Components - Parent Parent POM for AEM Forms Core Components @@ -31,7 +31,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.26 diff --git a/pom.xml b/pom.xml index e6a80d7e18..6929d15bd7 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.25-SNAPSHOT + 1.0.26 parent/pom.xml @@ -70,7 +70,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.26 diff --git a/ui.apps/pom.xml b/ui.apps/pom.xml index 2d8d48fc95..8b7c271c44 100644 --- a/ui.apps/pom.xml +++ b/ui.apps/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.25-SNAPSHOT + 1.0.26 ../parent/pom.xml @@ -37,7 +37,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - HEAD + core-forms-components-reactor-1.0.26 Adobe diff --git a/ui.tests/pom.xml b/ui.tests/pom.xml index db5227000b..8588747fa7 100644 --- a/ui.tests/pom.xml +++ b/ui.tests/pom.xml @@ -24,7 +24,7 @@ com.adobe.aem core-forms-components-parent - 1.0.25-SNAPSHOT + 1.0.26 ../parent/pom.xml From 979a3ec92392b6e3b9ddb361d8b99c6d5ced4d50 Mon Sep 17 00:00:00 2001 From: ujjgupta Date: Wed, 24 Aug 2022 14:35:59 +0530 Subject: [PATCH 024/494] @releng [maven-scm] :prepare for next development iteration --- all/pom.xml | 4 ++-- bundles/core/pom.xml | 4 ++-- examples/all/pom.xml | 4 ++-- examples/pom.xml | 2 +- examples/ui.apps/pom.xml | 4 ++-- examples/ui.content/pom.xml | 4 ++-- it/content/pom.xml | 4 ++-- parent/pom.xml | 4 ++-- pom.xml | 4 ++-- ui.apps/pom.xml | 4 ++-- ui.tests/pom.xml | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/all/pom.xml b/all/pom.xml index 16d440c662..32cefe2810 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.26 + 1.0.27-SNAPSHOT ../parent/pom.xml @@ -39,7 +39,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.26 + HEAD Adobe diff --git a/bundles/core/pom.xml b/bundles/core/pom.xml index 6a30371f77..31236849ad 100644 --- a/bundles/core/pom.xml +++ b/bundles/core/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.26 + 1.0.27-SNAPSHOT ../../parent/pom.xml @@ -38,7 +38,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.26 + HEAD Adobe diff --git a/examples/all/pom.xml b/examples/all/pom.xml index eaf367ba4c..bfded2c378 100644 --- a/examples/all/pom.xml +++ b/examples/all/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.26 + 1.0.27-SNAPSHOT ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.26 + HEAD Adobe diff --git a/examples/pom.xml b/examples/pom.xml index 36ee1d13d9..5528aa3f5e 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.26 + 1.0.27-SNAPSHOT ../parent/pom.xml diff --git a/examples/ui.apps/pom.xml b/examples/ui.apps/pom.xml index 0055d97efe..a1764c1cca 100644 --- a/examples/ui.apps/pom.xml +++ b/examples/ui.apps/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.26 + 1.0.27-SNAPSHOT ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.26 + HEAD Adobe diff --git a/examples/ui.content/pom.xml b/examples/ui.content/pom.xml index 46e0d0e4c8..c58d68faa9 100644 --- a/examples/ui.content/pom.xml +++ b/examples/ui.content/pom.xml @@ -18,7 +18,7 @@ com.adobe.aem core-forms-components-parent - 1.0.26 + 1.0.27-SNAPSHOT ../../parent/pom.xml @@ -33,7 +33,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.26 + HEAD Adobe diff --git a/it/content/pom.xml b/it/content/pom.xml index 521a7bdcdd..efe90677cd 100644 --- a/it/content/pom.xml +++ b/it/content/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.26 + 1.0.27-SNAPSHOT ../../parent/pom.xml @@ -34,7 +34,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.26 + HEAD Adobe diff --git a/parent/pom.xml b/parent/pom.xml index 07285ca381..ce53ad7f7b 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent pom - 1.0.26 + 1.0.27-SNAPSHOT AEM Forms Core Components - Parent Parent POM for AEM Forms Core Components @@ -31,7 +31,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.26 + HEAD diff --git a/pom.xml b/pom.xml index 6929d15bd7..c4173d373d 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ com.adobe.aem core-forms-components-parent - 1.0.26 + 1.0.27-SNAPSHOT parent/pom.xml @@ -70,7 +70,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.26 + HEAD diff --git a/ui.apps/pom.xml b/ui.apps/pom.xml index 8b7c271c44..7c458c514d 100644 --- a/ui.apps/pom.xml +++ b/ui.apps/pom.xml @@ -20,7 +20,7 @@ com.adobe.aem core-forms-components-parent - 1.0.26 + 1.0.27-SNAPSHOT ../parent/pom.xml @@ -37,7 +37,7 @@ scm:git:https://github.com/adobe/aem-core-forms-components scm:git:git@github.com:adobe/aem-core-forms-components.git https://github.com/adobe/aem-core-forms-components - core-forms-components-reactor-1.0.26 + HEAD Adobe diff --git a/ui.tests/pom.xml b/ui.tests/pom.xml index 8588747fa7..36e9ecc028 100644 --- a/ui.tests/pom.xml +++ b/ui.tests/pom.xml @@ -24,7 +24,7 @@ com.adobe.aem core-forms-components-parent - 1.0.26 + 1.0.27-SNAPSHOT ../parent/pom.xml From afe3e35a9976e5aa4654a5fe43c6b70788ed0362 Mon Sep 17 00:00:00 2001 From: ujjgupta Date: Wed, 24 Aug 2022 14:40:36 +0530 Subject: [PATCH 025/494] @trivial updating read me with new version --- README.md | 2 +- VERSIONS.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 68b81709e1..ca6f6aab8e 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ The latest version of the AEM Forms Core Components, require the below minimum s | Forms Core Components | WCM Core Components | AEM Forms as a cloud service | Java | Maven | | --------------------- | ------------------- | ---------------------------- | ----- | ------ | -| 1.0.24 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | +| 1.0.26 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | For a list of requirements for previous versions, see [Historical System Requirements](VERSIONS.md). diff --git a/VERSIONS.md b/VERSIONS.md index 89f660488a..1317c32954 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -4,6 +4,7 @@ See below for a full list of minimum system requirements for historical versions | Forms Core Components | WCM Core Components | AEM Forms as a cloud service | Java | Maven | | --------------------- | ------------------- | ---------------------------- | ----- | ------ | +| 1.0.24 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | | 1.0.22 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | | 1.0.20 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | | 1.0.18 | 2.20.2 | Continual | 8, 11 | 3.3.9+ | From 14531b2cf3fdb6b16cff8758663e8904776afc16 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Aug 2022 16:59:03 +0530 Subject: [PATCH 026/494] Bump core.wcm.components.core from 2.20.2 to 2.20.8 in /parent (#132) Bumps core.wcm.components.core from 2.20.2 to 2.20.8. --- updated-dependencies: - dependency-name: com.adobe.cq:core.wcm.components.core dependency-type: direct:production ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index ce53ad7f7b..db9553645e 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -87,7 +87,7 @@ 1.7.6 0.7.9 - 2.20.2 + 2.20.8 2.20.2 UTF-8 From b1ab2fecce17b7043da60faf9687080222654228 Mon Sep 17 00:00:00 2001 From: Nitin Gupta Date: Mon, 19 Sep 2022 11:03:15 +0530 Subject: [PATCH 027/494] Merge dev to master (#179) --- .circleci/ci/build.js | 2 +- .gitignore | 3 + README.md | 12 + all/pom.xml | 1 + bundles/core/pom.xml | 3 +- .../internal/form/FormConstants.java | 25 + .../form/FormStructureParserImpl.java | 51 + .../models/v1/form/AbstractBaseImpl.java | 472 - .../models/v1/form/CheckBoxGroupImpl.java | 51 + .../internal/models/v1/form/CheckBoxImpl.java | 70 + .../models/v1/form/DatePickerImpl.java | 78 + .../internal/models/v1/form/DropDownImpl.java | 58 + .../models/v1/form/FileInputImpl.java | 86 + .../models/v1/form/FormContainerImpl.java | 60 +- .../models/v1/form/NumberInputImpl.java | 92 + .../models/v1/form/PanelContainerImpl.java | 36 + .../internal/models/v1/form/PanelImpl.java | 52 + .../models/v1/form/TextInputImpl.java | 86 +- .../models/v2/form/FormContainerImpl.java | 68 +- .../core/components/models/form/Base.java | 148 +- .../models/form/BaseConstraint.java | 14 +- .../core/components/models/form/CheckBox.java | 91 + .../components/models/form/CheckBoxGroup.java | 29 + .../components/models/form/Container.java | 9 +- .../models/form/ContainerConstraint.java | 11 +- .../models/form/DateConstraint.java | 81 + .../components/models/form/DatePicker.java | 39 + .../core/components/models/form/DropDown.java | 37 + .../core/components/models/form/Field.java | 27 +- .../models/form/FileConstraint.java | 14 +- .../components/models/form/FileInput.java | 37 + .../components/models/form/FormContainer.java | 40 + .../models/form/FormStructureParser.java | 26 + .../models/form/FormatConstraint.java | 67 + .../models/form/NumberAndDateConstraint.java | 47 - .../models/form/NumberConstraint.java | 66 + .../components/models/form/NumberInput.java | 48 + .../models/form/OptionsConstraint.java | 4 +- .../core/components/models/form/Panel.java | 28 + .../models/form/StringConstraint.java | 2 +- .../components/models/form/TextInput.java | 37 +- .../components/models/form/package-info.java | 2 +- .../components/util/AbstractBaseImpl.java | 608 + .../util/AbstractComponentImpl.java | 190 + .../form => util}/AbstractContainerImpl.java | 52 +- .../v1/form => util}/AbstractFieldImpl.java | 107 +- .../util/AbstractOptionsFieldImpl.java | 82 + .../core/components/util/ComponentUtils.java | 58 + .../util/DefaultValueSerializer.java | 76 + .../models/v1/form => util}/LabelImpl.java | 9 +- .../core/components/util/package-info.java | 2 +- .../cq/forms/core/components/views/Views.java | 32 + .../core/components/views/package-info.java | 25 + .../java/com/adobe/cq/forms/core/Utils.java | 16 +- .../v1/form/AbstractContainerImplTest.java | 5 +- .../models/v1/form/BaseConstraintTest.java | 7 - .../models/v1/form/CheckBoxGroupImplTest.java | 318 + .../models/v1/form/CheckBoxImplTest.java | 275 + .../v1/form/ContainerConstraintTest.java | 8 +- .../models/v1/form/DatePickerImplTest.java | 237 + .../models/v1/form/DropDownImplTest.java | 313 + .../models/v1/form/FileConstraintTest.java | 6 +- .../models/v1/form/FileInputImplTest.java | 318 + .../v1/form/FormStructureParserImplTest.java | 83 + .../models/v1/form/NumberInputImplTest.java | 280 + .../v1/form/PanelContainerImplTest.java | 118 + .../models/v1/form/PanelImplTest.java | 119 + .../models/v1/form/TextInputImplTest.java | 164 +- .../models/v2/form/FormContainerImplTest.java | 78 +- .../form/checkbox/exporter-checkbox.json | 32 + .../resources/form/checkbox/test-content.json | 26 + .../checkboxgroup/exporter-checkboxgroup.json | 39 + .../form/checkboxgroup/test-content.json | 49 + .../exporter-datepicker-message.json | 42 + .../form/datepicker/exporter-datepicker.json | 40 + .../form/datepicker/test-content.json | 58 + .../form/dropdown/exporter-dropdown.json | 31 + .../exporter-multiselect-dropdown.json | 34 + .../resources/form/dropdown/test-content.json | 42 + .../form/fileinput/exporter-fileinput.json | 34 + .../exporter-multiselect-fileinput.json | 35 + .../form/fileinput/test-content.json | 41 + .../formcontainer/exporter-formcontainer.json | 21 +- .../exporter-formcontainerv2.json | 6 +- .../form/formcontainer/test-content.json | 13 +- .../test-lib-form-container.json | 11 + .../test-localization-content.json | 64 + .../form/formcontainer/test-page-content.json | 40 + .../form/formstructparser/test-content.json | 59 + .../numberinput/exporter-numberinput.json | 34 + .../form/numberinput/test-content.json | 24 + .../form/panel/exporter-array-panel.json | 42 + .../resources/form/panel/exporter-panel.json | 40 + .../form/panel/exporter-rules-panel.json | 46 + .../resources/form/panel/test-content.json | 70 + .../exporter-array-panelcontainer.json | 42 + .../exporter-panelcontainer.json | 40 + .../exporter-rules-panelcontainer.json | 46 + .../form/panelcontainer/test-content.json | 70 + .../exporter-multiline-textinput.json | 2 - .../textinput/exporter-textinput-format.json | 30 + .../form/textinput/exporter-textinput.json | 13 +- .../form/textinput/test-content.json | 47 +- examples/all/pom.xml | 30 + examples/ui.apps/pom.xml | 59 +- .../form/container/_cq_template.xml | 5 + .../components/form/datepicker/.content.xml | 7 + .../form/datepicker/_cq_template.xml | 5 + .../form/panelcontainer/.content.xml | 7 + .../form/panelcontainer/_cq_template.xml | 5 + .../form/textinput/_cq_template.xml | 5 + examples/ui.content/pom.xml | 59 +- .../adaptive-form/container/.content.xml | 1 + .../adaptive-form/panelcontainer/.content.xml | 130 + .../adaptive-form/textinput/.content.xml | 24 +- it/content/pom.xml | 7 + .../main/content/META-INF/vault/filter.xml | 6 +- .../af-blank-v2/policies/.content.xml | 25 - .../.content.xml | 0 .../settings/.content.xml | 0 .../settings/wcm/.content.xml | 0 .../settings/wcm/policies/.content.xml | 22 + .../settings/wcm/templates/.content.xml | 0 .../wcm/templates/af-blank-v2/.content.xml | 0 .../af-blank-v2/initial/.content.xml | 1 + .../af-blank-v2/policies/.content.xml | 14 + .../af-blank-v2/structure/.content.xml | 1 + .../wcm/templates/af-blank-v2/thumbnail.png | Bin .../dam/formsanddocuments/.content.xml | 3 +- .../core-components-it/.content.xml | 7 + .../blank/.content.xml | 4 +- .../core-components-it/samples/.content.xml | 7 + .../samples/datepicker/.content.xml | 7 + .../samples/datepicker/basic/.content.xml | 21 + .../samples/textinput/.content.xml | 7 + .../samples/textinput/basic/.content.xml | 21 + .../blank/.content.xml | 5 +- .../core-components-it/samples/.content.xml | 5 + .../samples/datepicker/.content.xml | 5 + .../samples/datepicker/basic/.content.xml | 32 + .../samples/textinput/.content.xml | 5 + .../samples/textinput/basic/.content.xml | 32 + ...om.adobe.granite.toggle.impl.dev-1.1.2.jar | Bin 0 -> 11697 bytes parent/aem-forms-sdk-api-2022.08.29.00.jar | Bin 0 -> 355934 bytes parent/pom.xml | 10 +- pom.xml | 1 + ui.apps/pom.xml | 9 +- .../.content.xml | 6 + .../core-forms-components-runtime-all/css.txt | 15 + .../core-forms-components-runtime-all/js.txt | 15 + .../v1/fieldTemplates/errorMessage.html | 3 + .../v1/base}/_cq_design_dialog/.content.xml | 2 +- .../form/base/v1/base/_cq_dialog/.content.xml | 147 +- .../form/base/v1/base/_cq_editConfig.xml | 16 + .../form/container/v2/container/.content.xml | 2 +- .../v2/container/_cq_dialog/.content.xml | 9 +- .../clientlibs/editorhook/.content.xml | 5 + .../v2/container/clientlibs/editorhook/js.txt | 18 + .../editorhook/js/ruleeditorhook.js | 53 + .../v2/container/clientlibs/site/.content.xml | 5 + .../v2/container/clientlibs/site/css.txt | 18 + .../clientlibs/site/css/formcontainerview.css | 19 + .../v2/container/clientlibs/site/js.txt | 18 + .../clientlibs/site/js/formcontainerview.js | 43 + .../container/v2/container/container.html | 3 +- .../components/form/datepicker/.content.xml | 3 + .../form/datepicker/v1/.content.xml | 5 + .../datepicker/v1/datepicker/.content.xml | 8 + .../v1/datepicker/_cq_dialog/.content.xml | 163 + .../datepicker/v1/datepicker/_cq_template.xml | 7 + .../v1/datepicker/clientlibs/.content.xml | 3 + .../datepicker/clientlibs/site/.content.xml | 5 + .../v1/datepicker/clientlibs/site/css.txt | 18 + .../clientlibs/site/css/datepickerview.css | 38 + .../v1/datepicker/clientlibs/site/js.txt | 18 + .../clientlibs/site/js/datepickerview.js | 68 + .../datepicker/v1/datepicker/datepicker.html | 42 + .../datepicker/v1/datepicker/datepicker.js | 31 + .../form/panelcontainer/.content.xml | 3 + .../form/panelcontainer/v1/.content.xml | 4 + .../v1/panelcontainer/.content.xml | 24 + .../v1/panelcontainer/README.md | 79 + .../_cq_design_dialog/.content.xml | 138 + .../v1/panelcontainer/_cq_dialog/.content.xml | 150 + .../v1/panelcontainer/_cq_template.xml | 5 + .../v1/panelcontainer/allowedcomponents.html | 21 + .../v1/panelcontainer/clientlibs/.content.xml | 3 + .../clientlibs/editor/.content.xml | 4 + .../panelcontainer/clientlibs/editor/js.txt | 18 + .../clientlibs/editor/js/panelcontainer.js | 96 + .../clientlibs/runtime/.content.xml | 5 + .../panelcontainer/clientlibs/runtime/js.txt | 18 + .../clientlibs/runtime/js/panelcontainer.js | 43 + .../v1/panelcontainer/new/.content.xml | 21 + .../v1/panelcontainer/panelcontainer.html | 24 + .../v1/panelcontainer/responsiveGrid.html | 27 + .../v1/panelcontainer/simple.html | 35 + .../form/textinput/v1/textinput/README.md | 1 + .../v1/textinput/_cq_dialog/.content.xml | 140 +- .../textinput/v1/textinput/_cq_template.xml | 5 + .../clientlibs/editor/js/editDialog.js | 23 +- .../v1/textinput/clientlibs/site/.content.xml | 5 + .../v1/textinput/clientlibs/site/css.txt | 18 + .../clientlibs/site/css/textinputview.css | 39 + .../v1/textinput/clientlibs/site/js.txt | 18 + .../clientlibs/site/js/textinputview.js | 76 + .../textinput/v1/textinput/textinput.html | 23 +- .../form/textinput/v1/textinput/textinput.js | 2 + .../page/v1/page/customfooterlibs.html | 20 + .../page/v1/page/customheaderlibs.html | 18 + ui.frontend/.babelrc | 2 + ui.frontend/__tests__/guidebridge.test.js | 42 + ui.frontend/__tests__/resources/form.json | 30 + ui.frontend/__tests__/utils.test.js | 30 + ui.frontend/clientlib-dev.config.js | 55 + ui.frontend/clientlib.config.js | 54 + ui.frontend/package-lock.json | 14289 ++++++++++++++++ ui.frontend/package.json | 37 + ui.frontend/pom.xml | 120 + ui.frontend/src/FormData.js | 40 + ui.frontend/src/GuideBridge.js | 155 + ui.frontend/src/Response.js | 57 + ui.frontend/src/constants.js | 93 + ui.frontend/src/index.js | 35 + ui.frontend/src/utils.js | 154 + ui.frontend/src/view/FormContainer.js | 94 + ui.frontend/src/view/FormField.js | 101 + ui.frontend/src/view/FormFieldBase.js | 152 + ui.frontend/src/view/FormPanel.js | 71 + ui.frontend/src/view/index.js | 20 + ui.frontend/webpack.common.js | 29 + ui.frontend/webpack.dev.js | 31 + ui.frontend/webpack.prod.js | 24 + .../libs/commons/formsConstants.js | 3 +- ui.tests/test-module/libs/support/commands.js | 22 +- ui.tests/test-module/libs/support/index.js | 11 + ui.tests/test-module/package.json | 4 +- .../datepicker/datepicker.runtime.spec.js | 80 + .../specs/draftsnsubmissionscomponent.spec.js | 5 - .../test-module/specs/formcontainer.spec.js | 7 +- .../specs/formsportallinkcomponent.spec.js | 4 - .../test-module/specs/panelcontainer.spec.js | 107 + .../specs/searchnlistercomponent.spec.js | 5 - ui.tests/test-module/specs/textinput.spec.js | 103 +- .../specs/textinput/textinput.runtime.spec.js | 84 + 245 files changed, 24431 insertions(+), 1284 deletions(-) create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/form/FormStructureParserImpl.java delete mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/AbstractBaseImpl.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxGroupImpl.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxImpl.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DatePickerImpl.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DropDownImpl.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileInputImpl.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/NumberInputImpl.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PanelContainerImpl.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PanelImpl.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/CheckBox.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/CheckBoxGroup.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/DateConstraint.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/DatePicker.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/DropDown.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FileInput.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormStructureParser.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormatConstraint.java delete mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/NumberAndDateConstraint.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/NumberConstraint.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/NumberInput.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/Panel.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractBaseImpl.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractComponentImpl.java rename bundles/core/src/main/java/com/adobe/cq/forms/core/components/{internal/models/v1/form => util}/AbstractContainerImpl.java (60%) rename bundles/core/src/main/java/com/adobe/cq/forms/core/components/{internal/models/v1/form => util}/AbstractFieldImpl.java (55%) create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractOptionsFieldImpl.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/DefaultValueSerializer.java rename bundles/core/src/main/java/com/adobe/cq/forms/core/components/{internal/models/v1/form => util}/LabelImpl.java (88%) create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/views/Views.java create mode 100644 bundles/core/src/main/java/com/adobe/cq/forms/core/components/views/package-info.java create mode 100644 bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxGroupImplTest.java create mode 100644 bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxImplTest.java create mode 100644 bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DatePickerImplTest.java create mode 100644 bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DropDownImplTest.java create mode 100644 bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileInputImplTest.java create mode 100644 bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FormStructureParserImplTest.java create mode 100644 bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/NumberInputImplTest.java create mode 100644 bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PanelContainerImplTest.java create mode 100644 bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PanelImplTest.java create mode 100644 bundles/core/src/test/resources/form/checkbox/exporter-checkbox.json create mode 100644 bundles/core/src/test/resources/form/checkbox/test-content.json create mode 100644 bundles/core/src/test/resources/form/checkboxgroup/exporter-checkboxgroup.json create mode 100644 bundles/core/src/test/resources/form/checkboxgroup/test-content.json create mode 100644 bundles/core/src/test/resources/form/datepicker/exporter-datepicker-message.json create mode 100644 bundles/core/src/test/resources/form/datepicker/exporter-datepicker.json create mode 100644 bundles/core/src/test/resources/form/datepicker/test-content.json create mode 100644 bundles/core/src/test/resources/form/dropdown/exporter-dropdown.json create mode 100644 bundles/core/src/test/resources/form/dropdown/exporter-multiselect-dropdown.json create mode 100644 bundles/core/src/test/resources/form/dropdown/test-content.json create mode 100644 bundles/core/src/test/resources/form/fileinput/exporter-fileinput.json create mode 100644 bundles/core/src/test/resources/form/fileinput/exporter-multiselect-fileinput.json create mode 100644 bundles/core/src/test/resources/form/fileinput/test-content.json create mode 100644 bundles/core/src/test/resources/form/formcontainer/test-lib-form-container.json create mode 100644 bundles/core/src/test/resources/form/formcontainer/test-localization-content.json create mode 100644 bundles/core/src/test/resources/form/formcontainer/test-page-content.json create mode 100644 bundles/core/src/test/resources/form/formstructparser/test-content.json create mode 100644 bundles/core/src/test/resources/form/numberinput/exporter-numberinput.json create mode 100644 bundles/core/src/test/resources/form/numberinput/test-content.json create mode 100644 bundles/core/src/test/resources/form/panel/exporter-array-panel.json create mode 100644 bundles/core/src/test/resources/form/panel/exporter-panel.json create mode 100644 bundles/core/src/test/resources/form/panel/exporter-rules-panel.json create mode 100644 bundles/core/src/test/resources/form/panel/test-content.json create mode 100644 bundles/core/src/test/resources/form/panelcontainer/exporter-array-panelcontainer.json create mode 100644 bundles/core/src/test/resources/form/panelcontainer/exporter-panelcontainer.json create mode 100644 bundles/core/src/test/resources/form/panelcontainer/exporter-rules-panelcontainer.json create mode 100644 bundles/core/src/test/resources/form/panelcontainer/test-content.json create mode 100644 bundles/core/src/test/resources/form/textinput/exporter-textinput-format.json create mode 100644 examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/container/_cq_template.xml create mode 100644 examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/datepicker/.content.xml create mode 100644 examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/datepicker/_cq_template.xml create mode 100644 examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/panelcontainer/.content.xml create mode 100644 examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/panelcontainer/_cq_template.xml create mode 100644 examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/textinput/_cq_template.xml create mode 100644 examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/panelcontainer/.content.xml delete mode 100755 it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/af-blank-v2/policies/.content.xml rename it/content/src/main/content/jcr_root/conf/{core-components-examples => core-components-it}/.content.xml (100%) rename it/content/src/main/content/jcr_root/conf/{core-components-examples => core-components-it}/settings/.content.xml (100%) rename it/content/src/main/content/jcr_root/conf/{core-components-examples => core-components-it}/settings/wcm/.content.xml (100%) create mode 100644 it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/policies/.content.xml rename it/content/src/main/content/jcr_root/conf/{core-components-examples => core-components-it}/settings/wcm/templates/.content.xml (100%) rename it/content/src/main/content/jcr_root/conf/{core-components-examples => core-components-it}/settings/wcm/templates/af-blank-v2/.content.xml (100%) rename it/content/src/main/content/jcr_root/conf/{core-components-examples => core-components-it}/settings/wcm/templates/af-blank-v2/initial/.content.xml (96%) create mode 100755 it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/templates/af-blank-v2/policies/.content.xml rename it/content/src/main/content/jcr_root/conf/{core-components-examples => core-components-it}/settings/wcm/templates/af-blank-v2/structure/.content.xml (97%) rename it/content/src/main/content/jcr_root/conf/{core-components-examples => core-components-it}/settings/wcm/templates/af-blank-v2/thumbnail.png (100%) create mode 100755 it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/.content.xml rename it/content/src/main/content/jcr_root/content/dam/formsanddocuments/{core-components-examples => core-components-it}/blank/.content.xml (92%) create mode 100755 it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/.content.xml create mode 100755 it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/datepicker/.content.xml create mode 100755 it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/datepicker/basic/.content.xml create mode 100755 it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/textinput/.content.xml create mode 100755 it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/textinput/basic/.content.xml rename it/content/src/main/content/jcr_root/content/forms/af/{core-components-examples => core-components-it}/blank/.content.xml (84%) create mode 100755 it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/.content.xml create mode 100755 it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/datepicker/.content.xml create mode 100755 it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/datepicker/basic/.content.xml create mode 100755 it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/textinput/.content.xml create mode 100755 it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/textinput/basic/.content.xml create mode 100644 it/content/src/main/resources/com.adobe.granite.toggle.impl.dev-1.1.2.jar create mode 100644 parent/aem-forms-sdk-api-2022.08.29.00.jar create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/clientlibs/core-forms-components-runtime-all/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/clientlibs/core-forms-components-runtime-all/css.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/clientlibs/core-forms-components-runtime-all/js.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/commons/v1/fieldTemplates/errorMessage.html rename ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/{textinput/v1/textinput => base/v1/base}/_cq_design_dialog/.content.xml (97%) create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/base/v1/base/_cq_editConfig.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/clientlibs/editorhook/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/clientlibs/editorhook/js.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/clientlibs/editorhook/js/ruleeditorhook.js create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/clientlibs/site/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/clientlibs/site/css.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/clientlibs/site/css/formcontainerview.css create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/clientlibs/site/js.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/clientlibs/site/js/formcontainerview.js create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/datepicker/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/datepicker/v1/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/datepicker/v1/datepicker/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/datepicker/v1/datepicker/_cq_dialog/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/datepicker/v1/datepicker/_cq_template.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/datepicker/v1/datepicker/clientlibs/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/datepicker/v1/datepicker/clientlibs/site/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/datepicker/v1/datepicker/clientlibs/site/css.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/datepicker/v1/datepicker/clientlibs/site/css/datepickerview.css create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/datepicker/v1/datepicker/clientlibs/site/js.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/datepicker/v1/datepicker/clientlibs/site/js/datepickerview.js create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/datepicker/v1/datepicker/datepicker.html create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/datepicker/v1/datepicker/datepicker.js create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/panelcontainer/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/panelcontainer/README.md create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/panelcontainer/_cq_design_dialog/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/panelcontainer/_cq_dialog/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/panelcontainer/_cq_template.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/panelcontainer/allowedcomponents.html create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/panelcontainer/clientlibs/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/panelcontainer/clientlibs/editor/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/panelcontainer/clientlibs/editor/js.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/panelcontainer/clientlibs/editor/js/panelcontainer.js create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/panelcontainer/clientlibs/runtime/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/panelcontainer/clientlibs/runtime/js.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/panelcontainer/clientlibs/runtime/js/panelcontainer.js create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/panelcontainer/new/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/panelcontainer/panelcontainer.html create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/panelcontainer/responsiveGrid.html create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/panelcontainer/v1/panelcontainer/simple.html create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/textinput/v1/textinput/_cq_template.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/textinput/v1/textinput/clientlibs/site/.content.xml create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/textinput/v1/textinput/clientlibs/site/css.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/textinput/v1/textinput/clientlibs/site/css/textinputview.css create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/textinput/v1/textinput/clientlibs/site/js.txt create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/textinput/v1/textinput/clientlibs/site/js/textinputview.js create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/page/v1/page/customfooterlibs.html create mode 100644 ui.apps/src/main/content/jcr_root/apps/core/fd/components/page/v1/page/customheaderlibs.html create mode 100644 ui.frontend/.babelrc create mode 100644 ui.frontend/__tests__/guidebridge.test.js create mode 100644 ui.frontend/__tests__/resources/form.json create mode 100644 ui.frontend/__tests__/utils.test.js create mode 100644 ui.frontend/clientlib-dev.config.js create mode 100644 ui.frontend/clientlib.config.js create mode 100644 ui.frontend/package-lock.json create mode 100644 ui.frontend/package.json create mode 100644 ui.frontend/pom.xml create mode 100644 ui.frontend/src/FormData.js create mode 100644 ui.frontend/src/GuideBridge.js create mode 100644 ui.frontend/src/Response.js create mode 100644 ui.frontend/src/constants.js create mode 100644 ui.frontend/src/index.js create mode 100644 ui.frontend/src/utils.js create mode 100644 ui.frontend/src/view/FormContainer.js create mode 100644 ui.frontend/src/view/FormField.js create mode 100644 ui.frontend/src/view/FormFieldBase.js create mode 100644 ui.frontend/src/view/FormPanel.js create mode 100644 ui.frontend/src/view/index.js create mode 100644 ui.frontend/webpack.common.js create mode 100644 ui.frontend/webpack.dev.js create mode 100644 ui.frontend/webpack.prod.js create mode 100644 ui.tests/test-module/specs/datepicker/datepicker.runtime.spec.js create mode 100644 ui.tests/test-module/specs/panelcontainer.spec.js create mode 100644 ui.tests/test-module/specs/textinput/textinput.runtime.spec.js diff --git a/.circleci/ci/build.js b/.circleci/ci/build.js index 0f68c268d4..aee2cca0d4 100644 --- a/.circleci/ci/build.js +++ b/.circleci/ci/build.js @@ -24,7 +24,7 @@ const configuration = ci.collectConfiguration(); console.log(configuration); ci.stage('Build Project'); -ci.sh('mvn -B clean install'); +ci.sh('mvn -B clean install -Pcloud'); ci.stage('Collect test results'); const testFolder = path.resolve(process.cwd(), 'test-results/junit'); diff --git a/.gitignore b/.gitignore index 2f27082dca..57f0b978e2 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,9 @@ .settings .DS_Store +# auto-generated clientlib +ui.apps/src/main/content/jcr_root/apps/core/fd/clientlibs/core-forms-components-runtime-base/** + # Ignore Maven stuff target/ pom.xml.tag diff --git a/README.md b/README.md index ca6f6aab8e..77bdbe5d6a 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,18 @@ The hostname and port of the instance can be changed with the following user def * `aem.host` and `aem.port` for the author instance. * `aem.publish.host` and `aem.publish.port` for the publish instance. +### Building and Installing examples + +We have a set of example proxy components to demonstrate how the existing components can be customized or +new components can be added. The `examples` module contains the code for all the components + +To build and install that, from the examples directory (or from the root directory), +run the following command + +```shell +mvn clean install -PautoInstallExamples,include-wcm-components-examples +``` + ### AEM as a Cloud Service SDK When compiling and deploying to AEM as a Cloud Service SDK, you can use the `cloud` profile (in conjunction with previously documented profiles) to generate cloud-ready artifacts diff --git a/all/pom.xml b/all/pom.xml index 32cefe2810..fe31715786 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -57,6 +57,7 @@ UTF-8 + ${project.basedir}/../parent diff --git a/bundles/core/pom.xml b/bundles/core/pom.xml index 31236849ad..39d51b082c 100644 --- a/bundles/core/pom.xml +++ b/bundles/core/pom.xml @@ -56,6 +56,7 @@ ${project.build.directory}/jacoco.exec ./eclipse-formatter.xml false + ${project.basedir}/../../parent @@ -437,9 +438,7 @@ - - com.adobe.aem aem-forms-sdk-api diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/form/FormConstants.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/form/FormConstants.java index e1d9301aab..8b7bbe675c 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/form/FormConstants.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/form/FormConstants.java @@ -31,8 +31,33 @@ private FormConstants() { /** The resource type for form container v1 */ public final static String RT_FD_FORM_CONTAINER_V1 = RT_FD_FORM_PREFIX + "container/v1/container"; + /** The resource type for form container v2 */ + public final static String RT_FD_FORM_CONTAINER_V2 = RT_FD_FORM_PREFIX + "container/v2/container"; + /** The resource type for text input v1 */ public static final String RT_FD_FORM_TEXT_V1 = RT_FD_FORM_PREFIX + "textinput/v1/textinput"; + /** The resource type for checkbox v1 */ + public static final String RT_FD_FORM_CHECKBOX_V1 = RT_FD_FORM_PREFIX + "checkbox/v1/checkbox"; + + /** The resource type for date picker v1 */ + public static final String RT_FD_FORM_DATE_PICKER_V1 = RT_FD_FORM_PREFIX + "datepicker/v1/datepicker"; + + /** The resource type for number input v1 */ + public static final String RT_FD_FORM_NUMBER_INPUT_V1 = RT_FD_FORM_PREFIX + "numberinput/v1/numberinput"; + + /** The resource type for drop down v1 */ + public static final String RT_FD_FORM_DROP_DOWN_V1 = RT_FD_FORM_PREFIX + "dropdown/v1/dropdown"; + + /** The resource type for file input v1 */ + public static final String RT_FD_FORM_FILE_INPUT_V1 = RT_FD_FORM_PREFIX + "fileinput/v1/fileinput"; + + /** The resource type for check box group v1 */ + public static final String RT_FD_FORM_CHECKBOX_GROUP_V1 = RT_FD_FORM_PREFIX + "checkboxgroup/v1/checkboxgroup"; + + /** The resource type for panel v1 */ + public static final String RT_FD_FORM_PANEL_V1 = RT_FD_FORM_PREFIX + "panel/v1/panel"; + + public static final String RT_FD_FORM_PANEL_CONTAINER_V1 = RT_FD_FORM_PREFIX + "panelcontainer/v1/panelcontainer"; /* The resource type prefix for the form container related datasources */ public final static String RT_FD_FORM_CONTAINER_DATASOURCE_V1 = RT_FD_FORM_PREFIX + "container/v1/datasource"; diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/form/FormStructureParserImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/form/FormStructureParserImpl.java new file mode 100644 index 0000000000..1cc0e74187 --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/form/FormStructureParserImpl.java @@ -0,0 +1,51 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.form; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.injectorspecific.SlingObject; + +import com.adobe.cq.forms.core.components.models.form.FormStructureParser; + +import static com.adobe.cq.forms.core.components.internal.form.FormConstants.RT_FD_FORM_CONTAINER_V2; + +@Model( + adaptables = Resource.class, + adapters = FormStructureParser.class) +public class FormStructureParserImpl implements FormStructureParser { + + @SlingObject + private Resource resource; + + @Override + public String getFormContainerPath() { + return getFormContainerPath(resource); + } + + private String getFormContainerPath(Resource resource) { + if (resource == null) { + return null; + } + + if (resource.isResourceType(RT_FD_FORM_CONTAINER_V2)) { + return resource.getPath(); + } + + return getFormContainerPath(resource.getParent()); + } + +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/AbstractBaseImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/AbstractBaseImpl.java deleted file mode 100644 index 0d654e20d1..0000000000 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/AbstractBaseImpl.java +++ /dev/null @@ -1,472 +0,0 @@ -/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ 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. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ -package com.adobe.cq.forms.core.components.internal.models.v1.form; - -import java.util.LinkedHashMap; -import java.util.Map; - -import javax.annotation.PostConstruct; - -import org.apache.commons.lang3.StringEscapeUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.sling.api.resource.Resource; -import org.apache.sling.api.resource.ValueMap; -import org.apache.sling.models.annotations.Default; -import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy; -import org.apache.sling.models.annotations.injectorspecific.SlingObject; -import org.apache.sling.models.annotations.injectorspecific.ValueMapValue; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import com.adobe.aemds.guide.utils.GuideUtils; -import com.adobe.cq.forms.core.components.models.form.Base; -import com.adobe.cq.forms.core.components.models.form.BaseConstraint; -import com.adobe.cq.forms.core.components.models.form.Label; -import com.adobe.cq.wcm.core.components.util.AbstractComponentImpl; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Abstract class which can be used as base class for {@link Base} implementations. - */ -public abstract class AbstractBaseImpl extends AbstractComponentImpl implements Base, BaseConstraint { - - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "longDescription") - @Nullable - protected String description; // long description as per current spec - - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "bindRef") - @Nullable - protected String dataRef; - - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) - @Nullable - protected String format; - - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) - @Nullable - protected String validationExpression; - - // using old jcr property names to allow easy conversion from foundation to core components - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "mandatory") - @Default(booleanValues = false) - protected boolean required; - - /** - * Defines the assist priority type. Possible values: {@code custom}, {@code description}, {@code label}, {@code name} - * - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 - */ - private enum AssistPriority { - CUSTOM("custom"), - DESCRIPTION("description"), - LABEL("label"), - NAME("name"); - - private String value; - - AssistPriority(String value) { - this.value = value; - } - - /** - * Given a {@link String} value, this method returns the enum's value that corresponds to the provided string - * representation - * - * @param value the string representation for which an enum value should be returned - * @return the corresponding enum value, if one was found - * @since com.adobe.cq.wcm.core.components.models.form 13.0.0 - */ - public static AssistPriority fromString(String value) { - for (AssistPriority type : AssistPriority.values()) { - if (StringUtils.equals(value, type.value)) { - return type; - } - } - return null; - } - - /** - * Returns the string value of this enum constant. - * - * @return the string value of this enum constant - * @since com.adobe.cq.wcm.core.components.models.form 13.0.0 - */ - public String getValue() { - return value; - } - - @Override - @JsonValue - public String toString() { - return value; - } - } - - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "assistPriority") - @Nullable - protected String assistPriorityJcr; - private AssistPriority assistPriority; - - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "custom") - @Nullable - protected String customAssistPriorityMsg; - - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) - @Nullable - protected String name; - - @ValueMapValue - @Default(values = "") - protected String value; - - @ValueMapValue - @Default(booleanValues = true) - protected boolean visible; - - @ValueMapValue - @Default(booleanValues = true) - protected boolean enabled; - - @SlingObject - private Resource resource; - - /** - * Holds the constraint messages - */ - private Map constraintMessages = null; - - @PostConstruct - private void initModel() { - assistPriority = AssistPriority.fromString(assistPriorityJcr); - } - - @JsonIgnore - protected abstract FieldType getDefaultFieldType(); - - /** - * Returns label of the form field - * - * @return label of the field - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 - */ - @Override - public Label getLabel() { - return new LabelImpl(resource, getName()); - } - - /** - * Returns the name of the form field - * - * @return name of the form field - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 - */ - @Override - public String getName() { - if (name == null) { - name = getDefaultName(); - } - return name; - } - - protected String getDefaultName() { - return StringEscapeUtils.escapeHtml4(GuideUtils.getGuideName(resource)); - } - - /** - * Returns the reference to the data model - * - * @return reference to the data model - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 - */ - @Override - @Nullable - public String getDataRef() { - return dataRef; - } - - @Override - @Nullable - public String getScreenReaderText() { - String screenReaderText = getName(); - if (AssistPriority.LABEL.equals(assistPriority)) { - Label label = getLabel(); - if (label != null) { - screenReaderText = label.getValue(); - } - } else if (AssistPriority.NAME.equals(assistPriority)) { - screenReaderText = getName(); - } else if (AssistPriority.DESCRIPTION.equals(assistPriority)) { - screenReaderText = getDescription(); - } else if (AssistPriority.CUSTOM.equals(assistPriority)) { - screenReaderText = customAssistPriorityMsg; - } - return screenReaderText; - } - - /** - * Returns the description of the field - * - * @return the description of the field - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 - */ - @Override - @Nullable - public String getDescription() { - return description; - } - - /** - * Returns the view type - * - * @return the view type - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 - */ - @Override - public String getFieldType() { - return getDefaultFieldType().getValue(); - } - - /** - * Returns {@code true} if form field should be visible, otherwise {@code false}. - * - * @return {@code true} if form field should be visible, otherwise {@code false} - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 - */ - @Override - public boolean isVisible() { - return visible; - } - - /** - * Returns {@code true} if form field should be enabled, otherwise {@code false}. - * - * @return {@code true} if form field should be enabled, otherwise {@code false} - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 - */ - @Override - public boolean isEnabled() { - return enabled; - } - - @Override - public @NotNull Map getConstraintsMessages() { - if (constraintMessages == null) { - constraintMessages = new LinkedHashMap<>(); - ConstraintMessages msgs = new ConstraintMessagesProvider(); - put(ConstraintType.TYPE, msgs.getTypeConstraintMessage()); - put(ConstraintType.REQUIRED, msgs.getRequiredConstraintMessage()); - if (this.getType().equals(Type.STRING)) { - put(ConstraintType.MIN_LENGTH, msgs.getMinLengthConstraintMessage()); - put(ConstraintType.MAX_LENGTH, msgs.getMaxLengthConstraintMessage()); - put(ConstraintType.PATTERN, msgs.getPatternConstraintMessage()); - put(ConstraintType.FORMAT, msgs.getFormatConstraintMessage()); - } - - if (this.getType().equals(Type.NUMBER)) { - put(ConstraintType.MINIMUM, msgs.getMinimumConstraintMessage()); - put(ConstraintType.MAXIMUM, msgs.getMaximumConstraintMessage()); - } - - // todo: add the following conditionally - put(ConstraintType.STEP, msgs.getStepConstraintMessage()); - put(ConstraintType.MIN_ITEMS, msgs.getMinItemsConstraintMessage()); - put(ConstraintType.MAX_ITEMS, msgs.getMaxItemsConstraintMessage()); - put(ConstraintType.ENFORCE_ENUM, msgs.getEnforceEnumConstraintMessage()); - put(ConstraintType.VALIDATION_EXPRESSION, msgs.getValidationExpressionConstraintMessage()); - put(ConstraintType.UNIQUE_ITEMS, msgs.getUniqueItemsConstraintMessage()); - } - return constraintMessages; - } - - /** - * Put non-blank named values in constraint messages map. - */ - private void put(ConstraintType name, String value) { - if (StringUtils.isNotBlank(value)) { - constraintMessages.put(name, value); - } - } - - /** - * Provides constraint messages configured for a form field - */ - private interface ConstraintMessages { - - String getTypeConstraintMessage(); - - String getRequiredConstraintMessage(); - - String getMinimumConstraintMessage(); - - String getMaximumConstraintMessage(); - - String getMinLengthConstraintMessage(); - - String getMaxLengthConstraintMessage(); - - String getStepConstraintMessage(); - - String getFormatConstraintMessage(); - - String getPatternConstraintMessage(); - - String getMinItemsConstraintMessage(); - - String getMaxItemsConstraintMessage(); - - String getUniqueItemsConstraintMessage(); - - String getEnforceEnumConstraintMessage(); - - String getValidationExpressionConstraintMessage(); - } - - private class ConstraintMessagesProvider implements ConstraintMessages { - - private static final String PN_TYPE_MESSAGE = "typeMessage"; - private static final String PN_REQUIRED_MESSAGE = "mandatoryMessage"; // reusing the same property name as in foundation - private static final String PN_MINIMUM_MESSAGE = "minimumMessage"; - private static final String PN_MAXIMUM_MESSAGE = "maximumMessage"; - private static final String PN_MINLENGTH_MESSAGE = "minLengthMessage"; - private static final String PN_MAXLENGTH_MESSAGE = "maxLengthMessage"; - private static final String PN_STEP_MESSAGE = "stepMessage"; - private static final String PN_FORMAT_MESSAGE = "formatMessage"; - private static final String PN_PATTERN_MESSAGE = "validatePictureClauseMessage"; // reusing the same property name as in foundation - private static final String PN_MINITEMS_MESSAGE = "minItemsMessage"; - private static final String PN_MAXITEMS_MESSAGE = "maxItemsMessage"; - private static final String PN_UNIQUEITEMS_MESSAGE = "uniqueItemsMessage"; - private static final String PN_ENFORCEENUM_MESSAGE = "enforceEnumMessage"; - private static final String PN_VALIDATIONEXPRESSION_MESSAGE = "validateExpMessage"; // reusing the same property name as in - // foundation - - private ValueMap properties = resource.getValueMap(); - - @Override - @Nullable - public String getTypeConstraintMessage() { - return properties.get(PN_TYPE_MESSAGE, String.class); - } - - @Override - @Nullable - public String getRequiredConstraintMessage() { - return properties.get(PN_REQUIRED_MESSAGE, String.class); - } - - @Override - @Nullable - public String getMinimumConstraintMessage() { - return properties.get(PN_MINIMUM_MESSAGE, String.class); - } - - @Override - @Nullable - public String getMaximumConstraintMessage() { - return properties.get(PN_MAXIMUM_MESSAGE, String.class); - } - - @Override - @Nullable - public String getMinLengthConstraintMessage() { - return properties.get(PN_MINLENGTH_MESSAGE, String.class); - } - - @Override - @Nullable - public String getMaxLengthConstraintMessage() { - return properties.get(PN_MAXLENGTH_MESSAGE, String.class); - } - - @Override - @Nullable - public String getStepConstraintMessage() { - return properties.get(PN_STEP_MESSAGE, String.class); - } - - @Override - @Nullable - public String getFormatConstraintMessage() { - return properties.get(PN_FORMAT_MESSAGE, String.class); - } - - @Override - @Nullable - public String getPatternConstraintMessage() { - return properties.get(PN_PATTERN_MESSAGE, String.class); - } - - @Override - @Nullable - public String getMinItemsConstraintMessage() { - return properties.get(PN_MINITEMS_MESSAGE, String.class); - } - - @Override - @Nullable - public String getMaxItemsConstraintMessage() { - return properties.get(PN_MAXITEMS_MESSAGE, String.class); - } - - @Override - @Nullable - public String getUniqueItemsConstraintMessage() { - return properties.get(PN_UNIQUEITEMS_MESSAGE, String.class); - } - - @Override - @Nullable - public String getEnforceEnumConstraintMessage() { - return properties.get(PN_ENFORCEENUM_MESSAGE, String.class); - } - - @Override - @Nullable - public String getValidationExpressionConstraintMessage() { - return properties.get(PN_VALIDATIONEXPRESSION_MESSAGE, String.class); - } - } - - @Override - public @NotNull String getExportedType() { - return resource.getResourceType(); - } - - @JsonIgnore - protected abstract Type getDefaultType(); - - @Override - public boolean isRequired() { - return required; - } - - @Override - public Type getType() { - return getDefaultType(); - } - - @Override - @Nullable - public String getFormat() { - return format; - } - - @Override - @Nullable - public String getValidationExpression() { - return validationExpression; - } -} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxGroupImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxGroupImpl.java new file mode 100644 index 0000000000..785633c395 --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxGroupImpl.java @@ -0,0 +1,51 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Exporter; +import org.apache.sling.models.annotations.Model; + +import com.adobe.cq.export.json.ComponentExporter; +import com.adobe.cq.export.json.ExporterConstants; +import com.adobe.cq.forms.core.components.internal.form.FormConstants; +import com.adobe.cq.forms.core.components.models.form.CheckBoxGroup; +import com.adobe.cq.forms.core.components.util.AbstractOptionsFieldImpl; + +@Model( + adaptables = { SlingHttpServletRequest.class, Resource.class }, + adapters = { CheckBoxGroup.class, + ComponentExporter.class }, + resourceType = { FormConstants.RT_FD_FORM_CHECKBOX_GROUP_V1 }) +@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION) +public class CheckBoxGroupImpl extends AbstractOptionsFieldImpl implements CheckBoxGroup { + + @Override + public Integer getMinItems() { + return minItems; + } + + @Override + public Integer getMaxItems() { + return maxItems; + } + + @Override + public Type getType() { + return super.getType(); // check box group always has type array // we always return boolean[], string[] or number[] + } +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxImpl.java new file mode 100644 index 0000000000..775aa1bb84 --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxImpl.java @@ -0,0 +1,70 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import java.util.Map; + +import javax.annotation.Nullable; +import javax.annotation.PostConstruct; + +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Exporter; +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy; +import org.apache.sling.models.annotations.injectorspecific.ValueMapValue; +import org.jetbrains.annotations.NotNull; + +import com.adobe.cq.export.json.ComponentExporter; +import com.adobe.cq.export.json.ExporterConstants; +import com.adobe.cq.forms.core.components.internal.form.FormConstants; +import com.adobe.cq.forms.core.components.models.form.CheckBox; +import com.adobe.cq.forms.core.components.util.AbstractOptionsFieldImpl; + +@Model( + adaptables = { SlingHttpServletRequest.class, Resource.class }, + adapters = { CheckBox.class, ComponentExporter.class }, + resourceType = { FormConstants.RT_FD_FORM_CHECKBOX_V1 }) +@Exporter( + name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, + extensions = ExporterConstants.SLING_MODEL_EXTENSION) +public class CheckBoxImpl extends AbstractOptionsFieldImpl implements CheckBox { + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "orientation") + @Nullable + protected String orientationJcr; + private Orientation orientation; + + @PostConstruct + private void initCheckBoxModel() { + orientation = Orientation.fromString(orientationJcr); + } + + @Override + public @NotNull Map getCustomProperties() { + Map customProperties = super.getCustomProperties(); + if (orientation != null) { + customProperties.put("orientation", orientation); + } + return customProperties; + } + + @Override + public Orientation getOrientation() { + return orientation; + } + +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DatePickerImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DatePickerImpl.java new file mode 100644 index 0000000000..15b474b3de --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DatePickerImpl.java @@ -0,0 +1,78 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import java.util.Date; +import java.util.Map; + +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Exporter; +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.injectorspecific.SlingObject; +import org.jetbrains.annotations.NotNull; + +import com.adobe.cq.export.json.ComponentExporter; +import com.adobe.cq.export.json.ExporterConstants; +import com.adobe.cq.forms.core.components.internal.form.FormConstants; +import com.adobe.cq.forms.core.components.models.form.DatePicker; +import com.adobe.cq.forms.core.components.util.AbstractFieldImpl; +import com.adobe.cq.forms.core.components.util.ComponentUtils; + +@Model( + adaptables = { SlingHttpServletRequest.class, Resource.class }, + adapters = { DatePicker.class, + ComponentExporter.class }, + resourceType = { FormConstants.RT_FD_FORM_DATE_PICKER_V1 }) +@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION) +public class DatePickerImpl extends AbstractFieldImpl implements DatePicker { + + @SlingObject + private Resource resource; + + @Override + public Date getMinimumDate() { + return ComponentUtils.clone(minimumDate); + } + + @Override + public Date getMaximumDate() { + return ComponentUtils.clone(maximumDate); + } + + @Override + public Date getExclusiveMaximumDate() { + return ComponentUtils.clone(exclusiveMaximumDate); + } + + @Override + public Date getExclusiveMinimumDate() { + return ComponentUtils.clone(exclusiveMinimumDate); + } + + public @NotNull Map getConstraintMessages() { + Map res = super.getConstraintMessages(); + String msg = getConstraintMessage(ConstraintType.MINIMUM); + if (msg != null) { + res.put(ConstraintType.MINIMUM, msg); + } + msg = getConstraintMessage(ConstraintType.MAXIMUM); + if (msg != null) { + res.put(ConstraintType.MAXIMUM, msg); + } + return res; + } +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DropDownImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DropDownImpl.java new file mode 100644 index 0000000000..7bde7773a7 --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DropDownImpl.java @@ -0,0 +1,58 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Default; +import org.apache.sling.models.annotations.Exporter; +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy; +import org.apache.sling.models.annotations.injectorspecific.ValueMapValue; + +import com.adobe.cq.export.json.ComponentExporter; +import com.adobe.cq.export.json.ExporterConstants; +import com.adobe.cq.forms.core.components.internal.form.FormConstants; +import com.adobe.cq.forms.core.components.models.form.DropDown; +import com.adobe.cq.forms.core.components.util.AbstractOptionsFieldImpl; + +@Model( + adaptables = { SlingHttpServletRequest.class, Resource.class }, + adapters = { DropDown.class, + ComponentExporter.class }, + resourceType = { FormConstants.RT_FD_FORM_DROP_DOWN_V1 }) +@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION) +public class DropDownImpl extends AbstractOptionsFieldImpl implements DropDown { + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "multiSelect") + @Default(booleanValues = false) + protected boolean multiSelect; + + @Override + public Integer getMinItems() { + return minItems; + } + + @Override + public Integer getMaxItems() { + return maxItems; + } + + @Override + public Boolean isMultiSelect() { + return multiSelect; + } +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileInputImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileInputImpl.java new file mode 100644 index 0000000000..317b9a0ece --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileInputImpl.java @@ -0,0 +1,86 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import java.util.Arrays; +import java.util.List; + +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Default; +import org.apache.sling.models.annotations.Exporter; +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy; +import org.apache.sling.models.annotations.injectorspecific.ValueMapValue; + +import com.adobe.cq.export.json.ComponentExporter; +import com.adobe.cq.export.json.ExporterConstants; +import com.adobe.cq.forms.core.components.internal.form.FormConstants; +import com.adobe.cq.forms.core.components.models.form.FileInput; +import com.adobe.cq.forms.core.components.util.AbstractFieldImpl; + +@Model( + adaptables = { SlingHttpServletRequest.class, Resource.class }, + adapters = { FileInput.class, + ComponentExporter.class }, + resourceType = { FormConstants.RT_FD_FORM_FILE_INPUT_V1 }) +@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION) +public class FileInputImpl extends AbstractFieldImpl implements FileInput { + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "multiSelection") + @Default(booleanValues = false) + protected boolean multiSelection; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "maxFileSize") + protected String maxFileSize; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "accept") + protected String[] accept; + + @Override + public Integer getMinItems() { + return minItems; + } + + @Override + public Integer getMaxItems() { + return maxItems; + } + + @Override + public Type getType() { + // if (isMultiple()) { + // return Type.ARRAY; + // } else { + return super.getType(); // we don't return array but rather type stored in JCR, for example, file[] + // } + } + + @Override + public Boolean isMultiple() { + return multiSelection; + } + + @Override + public String getMaxFileSize() { + return maxFileSize; + } + + @Override + public List getAccept() { + return Arrays.asList(accept); + } +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FormContainerImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FormContainerImpl.java index edc0267feb..0f2203b637 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FormContainerImpl.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FormContainerImpl.java @@ -17,23 +17,19 @@ import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.apache.sling.api.SlingHttpServletRequest; -import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Default; import org.apache.sling.models.annotations.Exporter; import org.apache.sling.models.annotations.Model; import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy; -import org.apache.sling.models.annotations.injectorspecific.OSGiService; -import org.apache.sling.models.annotations.injectorspecific.ScriptVariable; -import org.apache.sling.models.annotations.injectorspecific.Self; +import org.apache.sling.models.annotations.injectorspecific.SlingObject; import org.apache.sling.models.annotations.injectorspecific.ValueMapValue; -import org.apache.sling.models.factory.ModelFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; @@ -42,39 +38,27 @@ import com.adobe.cq.export.json.ComponentExporter; import com.adobe.cq.export.json.ContainerExporter; import com.adobe.cq.export.json.ExporterConstants; -import com.adobe.cq.export.json.SlingModelFilter; import com.adobe.cq.forms.core.components.internal.form.FormConstants; import com.adobe.cq.forms.core.components.models.form.FormContainer; import com.adobe.cq.forms.core.components.models.form.FormMetaData; +import com.adobe.cq.forms.core.components.util.AbstractComponentImpl; import com.adobe.cq.forms.core.components.util.ComponentUtils; -import com.adobe.cq.wcm.core.components.util.AbstractComponentImpl; import com.day.cq.dam.api.Asset; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @Model( - adaptables = SlingHttpServletRequest.class, + adaptables = { SlingHttpServletRequest.class, Resource.class }, adapters = { FormContainer.class, ContainerExporter.class, ComponentExporter.class }, resourceType = { FormConstants.RT_FD_FORM_CONTAINER_V1 }) @Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION) public class FormContainerImpl extends AbstractComponentImpl implements FormContainer { + // not extending from AbstractBase since v1 container does not have mandatory field injections private static final Logger logger = LoggerFactory.getLogger(FormContainerImpl.class); - @Self - private SlingHttpServletRequest request; - - @ScriptVariable - private SlingHttpServletResponse response; - - @OSGiService - private SlingModelFilter slingModelFilter; - - @OSGiService - private ModelFactory modelFactory; - - @ScriptVariable + @SlingObject private Resource resource; // @ScriptVariable @@ -104,8 +88,6 @@ public class FormContainerImpl extends AbstractComponentImpl implements FormCont @Default(values = "") protected String documentPath; - private List childrenModels; - // overriding since AF 2.0 specification does not have id but we need the API for rendering @Override @JsonIgnore @@ -113,14 +95,6 @@ public String getId() { return super.getId(); } - @Override - public List getItems() { - if (childrenModels == null) { - childrenModels = getChildrenModels(request, ComponentExporter.class); - } - return childrenModels; - } - @Override public FormMetaData getMetaData() { return new FormMetaDataImpl(resource); @@ -177,12 +151,18 @@ public String getEncodedCurrentPagePath() { } } + @Override + @JsonIgnore + public List getItems() { + return Collections.emptyList(); + } + @Override @JsonIgnore public Map getModel() { Map jsonMap = null; if (StringUtils.isNotEmpty(documentPath) - && this.request.getResourceResolver().getResource(documentPath) != null) { + && this.request != null && this.request.getResourceResolver().getResource(documentPath) != null) { // the json is coming from DAM final Resource assetResource = request.getResourceResolver().getResource(documentPath); if (assetResource != null) { @@ -201,22 +181,10 @@ public Map getModel() { } } } else { - FormContainer formContainer = modelFactory.getModelFromWrappedRequest(request, resource, FormContainer.class); + FormContainer formContainer = resource.adaptTo(FormContainer.class); ObjectMapper mapper = new ObjectMapper(); jsonMap = mapper.convertValue(formContainer, new TypeReference>() {}); } return jsonMap; } - - // todo: its similar to other container code, but could not find a better way to do this - protected List getChildrenModels(@NotNull SlingHttpServletRequest request, @NotNull Class modelClass) { - List models = new ArrayList<>(); - for (Resource child : slingModelFilter.filterChildResources(resource.getChildren())) { - T model = modelFactory.getModelFromWrappedRequest(request, child, modelClass); - if (model != null) { - models.add(model); - } - } - return models; - } } diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/NumberInputImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/NumberInputImpl.java new file mode 100644 index 0000000000..648ed4de66 --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/NumberInputImpl.java @@ -0,0 +1,92 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import java.util.Map; + +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Exporter; +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy; +import org.apache.sling.models.annotations.injectorspecific.ValueMapValue; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import com.adobe.cq.export.json.ComponentExporter; +import com.adobe.cq.export.json.ExporterConstants; +import com.adobe.cq.forms.core.components.internal.form.FormConstants; +import com.adobe.cq.forms.core.components.models.form.NumberInput; +import com.adobe.cq.forms.core.components.util.AbstractFieldImpl; + +@Model( + adaptables = { SlingHttpServletRequest.class, Resource.class }, + adapters = { NumberInput.class, + ComponentExporter.class }, + resourceType = { FormConstants.RT_FD_FORM_NUMBER_INPUT_V1 }) +@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION) +public class NumberInputImpl extends AbstractFieldImpl implements NumberInput { + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "leadDigits") + @Nullable + protected Integer leadDigits; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "fracDigits") + @Nullable + protected Integer fracDigits; + + @Override + public Long getMinimum() { + return minimum; + } + + @Override + public Long getMaximum() { + return maximum; + } + + @Override + public Long getExclusiveMaximum() { + return exclusiveMaximum; + } + + @Override + public Long getExclusiveMinimum() { + return exclusiveMinimum; + } + + @Override + public @Nullable Integer getLeadDigits() { + return leadDigits; + } + + @Override + public @Nullable Integer getFracDigits() { + return fracDigits; + } + + @Override + public @NotNull Map getCustomProperties() { + Map customProperties = super.getCustomProperties(); + if (leadDigits != null) { + customProperties.put("leadDigits", leadDigits); + } + if (fracDigits != null) { + customProperties.put("fracDigits", fracDigits); + } + return customProperties; + } +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PanelContainerImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PanelContainerImpl.java new file mode 100644 index 0000000000..a092446eb6 --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PanelContainerImpl.java @@ -0,0 +1,36 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Exporter; +import org.apache.sling.models.annotations.Model; + +import com.adobe.cq.export.json.ComponentExporter; +import com.adobe.cq.export.json.ExporterConstants; +import com.adobe.cq.forms.core.components.internal.form.FormConstants; +import com.adobe.cq.forms.core.components.models.form.Panel; + +@Model( + adaptables = { SlingHttpServletRequest.class, Resource.class }, + adapters = { Panel.class, + ComponentExporter.class }, + resourceType = { FormConstants.RT_FD_FORM_PANEL_CONTAINER_V1 }) +@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION) +public class PanelContainerImpl extends PanelImpl { + +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PanelImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PanelImpl.java new file mode 100644 index 0000000000..c641c606d3 --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PanelImpl.java @@ -0,0 +1,52 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Exporter; +import org.apache.sling.models.annotations.Model; + +import com.adobe.cq.export.json.ComponentExporter; +import com.adobe.cq.export.json.ExporterConstants; +import com.adobe.cq.forms.core.components.internal.form.FormConstants; +import com.adobe.cq.forms.core.components.models.form.Panel; +import com.adobe.cq.forms.core.components.util.AbstractContainerImpl; +import com.fasterxml.jackson.annotation.JsonIgnore; + +@Model( + adaptables = { SlingHttpServletRequest.class, Resource.class }, + adapters = { Panel.class, + ComponentExporter.class }, + resourceType = { FormConstants.RT_FD_FORM_PANEL_V1 }) +@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION) +public class PanelImpl extends AbstractContainerImpl implements Panel { + + @JsonIgnore + @Override + public boolean isRequired() { + return false; // overriding since base is defining isRequired, to avoid creating a new interface, added jsonIgnore here + } + + @Override + public Type getType() { + if (minItems != null && maxItems != null) { + return Type.ARRAY; + } else { + return Type.OBJECT; + } + } +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextInputImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextInputImpl.java index d43986d46d..3e63c50afd 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextInputImpl.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextInputImpl.java @@ -15,34 +15,33 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ package com.adobe.cq.forms.core.components.internal.models.v1.form; +import java.util.Date; + import javax.annotation.Nullable; import org.apache.sling.api.SlingHttpServletRequest; -import org.apache.sling.api.resource.ValueMap; +import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Default; import org.apache.sling.models.annotations.Exporter; import org.apache.sling.models.annotations.Model; import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy; -import org.apache.sling.models.annotations.injectorspecific.ScriptVariable; import org.apache.sling.models.annotations.injectorspecific.ValueMapValue; import com.adobe.cq.export.json.ComponentExporter; import com.adobe.cq.export.json.ExporterConstants; import com.adobe.cq.forms.core.components.internal.form.FormConstants; -import com.adobe.cq.forms.core.components.models.form.StringConstraint; import com.adobe.cq.forms.core.components.models.form.TextInput; +import com.adobe.cq.forms.core.components.util.AbstractFieldImpl; +import com.adobe.cq.forms.core.components.util.ComponentUtils; @Model( - adaptables = SlingHttpServletRequest.class, + adaptables = { SlingHttpServletRequest.class, Resource.class }, adapters = { TextInput.class, ComponentExporter.class }, resourceType = { FormConstants.RT_FD_FORM_TEXT_V1 }) @Exporter( name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION) -public class TextInputImpl extends AbstractFieldImpl implements TextInput, StringConstraint { - - @ScriptVariable - private ValueMap properties; +public class TextInputImpl extends AbstractFieldImpl implements TextInput { @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) @Default(booleanValues = false) @@ -50,23 +49,15 @@ public class TextInputImpl extends AbstractFieldImpl implements TextInput, Strin @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) @Nullable - protected Integer minLength; + protected String format; - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "maxChars") - @Nullable - protected Integer maxLength; - - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "validatePictureClause") + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "pattern") @Nullable protected String pattern; - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) - @Default(booleanValues = false) - protected boolean autocomplete; - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) @Nullable - protected String autofillFieldKeyword; + protected String autocomplete; @Override public boolean isMultiLine() { @@ -74,11 +65,11 @@ public boolean isMultiLine() { } @Override - public FieldType getDefaultFieldType() { + public String getFieldType() { if (isMultiLine()) { - return FieldType.MULTILINE_INPUT; + return FieldType.MULTILINE_INPUT.getValue(); } else { - return FieldType.TEXT_INPUT; + return super.getFieldType(); } } @@ -95,22 +86,61 @@ public Integer getMaxLength() { } @Override + @Nullable public String getPattern() { return pattern; } @Override - public Type getDefaultType() { - return Type.STRING; + public String getAutoComplete() { + return autocomplete; } @Override - public boolean isAutoComplete() { - return autocomplete; + @Nullable + public Long getMinimum() { + return minimum; + } + + @Override + @Nullable + public Long getMaximum() { + return maximum; + } + + @Override + public Long getExclusiveMaximum() { + return exclusiveMinimum; } @Override - public String getAutofillFieldKeyword() { - return autofillFieldKeyword; + public Long getExclusiveMinimum() { + return exclusiveMaximum; + } + + @Override + public Date getMinimumDate() { + return ComponentUtils.clone(minimumDate); + } + + @Override + public Date getMaximumDate() { + return ComponentUtils.clone(maximumDate); + } + + @Override + public Date getExclusiveMaximumDate() { + return ComponentUtils.clone(exclusiveMaximumDate); + } + + @Override + public Date getExclusiveMinimumDate() { + return ComponentUtils.clone(exclusiveMinimumDate); + } + + @Override + @Nullable + public String getFormat() { + return format; } } diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImpl.java index 9b358c21b7..6ef57af06e 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImpl.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImpl.java @@ -16,20 +16,84 @@ package com.adobe.cq.forms.core.components.internal.models.v2.form; import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Exporter; import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy; +import org.apache.sling.models.annotations.injectorspecific.ValueMapValue; +import org.jetbrains.annotations.Nullable; import com.adobe.cq.export.json.ComponentExporter; import com.adobe.cq.export.json.ContainerExporter; import com.adobe.cq.export.json.ExporterConstants; +import com.adobe.cq.forms.core.components.internal.models.v1.form.FormMetaDataImpl; import com.adobe.cq.forms.core.components.models.form.FormContainer; +import com.adobe.cq.forms.core.components.models.form.FormMetaData; +import com.adobe.cq.forms.core.components.util.AbstractContainerImpl; +import com.adobe.cq.forms.core.components.util.ComponentUtils; +import com.fasterxml.jackson.annotation.JsonIgnore; @Model( - adaptables = SlingHttpServletRequest.class, + adaptables = { SlingHttpServletRequest.class, Resource.class }, adapters = { FormContainer.class, ContainerExporter.class, ComponentExporter.class }, resourceType = { FormContainerImpl.RESOURCE_TYPE }) @Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION) -public class FormContainerImpl extends com.adobe.cq.forms.core.components.internal.models.v1.form.FormContainerImpl implements +public class FormContainerImpl extends AbstractContainerImpl implements FormContainer { protected static final String RESOURCE_TYPE = "core/fd/components/form/container/v2/container"; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) + @Nullable + private String thankyouMessage; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) + @Nullable + private String thankyouPage; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) + @Nullable + private String title; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) + @Nullable + private String data; + + @Override + @Nullable + public String getThankYouMessage() { + return thankyouMessage; + } + + @Override + @Nullable + public String getThankYouPage() { + return thankyouPage; + } + + @Override + public FormMetaData getMetaData() { + return new FormMetaDataImpl(resource); + } + + @Override + @Nullable + public String getTitle() { + return title; + } + + @Override + @Nullable + public String getFormData() { + return data; + } + + @Override + @JsonIgnore + public String getEncodedCurrentPagePath() { + if (getCurrentPage() != null) { + return ComponentUtils.getEncodedPath(getCurrentPage().getPath()); + } else { + return null; + } + } } diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/Base.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/Base.java index 8294e0b46a..63fc1c6fb2 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/Base.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/Base.java @@ -18,6 +18,8 @@ import java.util.Collections; import java.util.Map; +import javax.annotation.Nonnull; + import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -25,6 +27,8 @@ import com.adobe.cq.export.json.ComponentExporter; import com.adobe.cq.wcm.core.components.models.Component; +import com.day.cq.i18n.I18n; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonValue; @@ -37,6 +41,9 @@ @ConsumerType public interface Base extends Component { + public final String CUSTOM_PROPERTY_WRAPPER = "af:layout"; + public final String DATE_FORMATTER = "yyyy-MM-dd"; + /** * Defines the view type. Possible values: {@code text-input}, {@code multiline-input}, {@code number-input}, {@code date-input}, * {@code file-input}, {@code drop-down}, {@code radio-group} @@ -56,7 +63,8 @@ public enum FieldType { CHECKBOX("checkbox"), BUTTON("button"), PANEL("panel"), - CHECKBOX_GROUP("checkbox-goup"); + FORM("form"), + CHECKBOX_GROUP("checkbox-group"); private String value; @@ -85,7 +93,7 @@ public static FieldType fromString(String value) { * Returns the string value of this enum constant. * * @return the string value of this enum constant - * @since com.adobe.cq.wcm.core.components.models.form 13.0.0 + * @since com.adobe.cq.forms.core.components.models.form 0.0.1 */ public String getValue() { return value; @@ -160,6 +168,66 @@ public String getValue() { public String toString() { return value; } + + /** + * returns the name of the property which stores the value of the error message for the constraint + * + * @return string + */ + public String getMessageProperty() { + return value + "Message"; + } + } + + /** + * Defines the assist priority type. Possible values: {@code custom}, {@code description}, {@code label}, {@code name} + * + * @since com.adobe.cq.forms.core.components.models.form 0.0.1 + */ + public enum AssistPriority { + CUSTOM("custom"), + DESCRIPTION("description"), + LABEL("label"), + NAME("name"); + + private String value; + + AssistPriority(String value) { + this.value = value; + } + + /** + * Given a {@link String} value, this method returns the enum's value that corresponds to the provided string + * representation + * + * @param value the string representation for which an enum value should be returned + * @return the corresponding enum value, if one was found + * @since com.adobe.cq.wcm.core.components.models.form 13.0.0 + */ + public static AssistPriority fromString(String value) { + for (AssistPriority type : AssistPriority.values()) { + if (StringUtils.equals(value, type.value)) { + return type; + } + } + return null; + } + + /** + * Returns the string value of this enum constant. + * + * @return the string value of this enum constant + * @since com.adobe.cq.wcm.core.components.models.form 13.0.0 + */ + public String getValue() { + return value; + } + + @Override + @JsonValue + public String toString() { + return value; + } } /** @@ -207,9 +275,9 @@ default String getDescription() { } /** - * Returns the string to indicate the text to be read by screen readers + * Returns json formula rule to indicate the text to be read by screen readers based on the {@link AssistPriority} configured. * - * @return the screen reader text + * @return the screen reader text as json formula rule * @since com.adobe.cq.forms.core.components.models.form 0.0.1 */ @Nullable @@ -217,6 +285,19 @@ default String getScreenReaderText() { return null; } + /** + * Returns the string to indicate the text to be read by screen readers. This + * could be used on server side to compute initial rendition + * + * @return the screen reader text + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ + @Nullable + @JsonIgnore + default String getHtmlScreenReaderText() { + return null; + } + /** * Returns the field type * @@ -254,7 +335,7 @@ default boolean isEnabled() { */ @NotNull @JsonInclude(JsonInclude.Include.NON_EMPTY) - default Map getConstraintsMessages() { + default Map getConstraintMessages() { return Collections.emptyMap(); } @@ -278,4 +359,61 @@ default String getExportedType() { default Map getProperties() { return Collections.emptyMap(); } + + /** + * Returns the tool tip of the field + * + * @return the tool tip of the field + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ + @Nullable + default String getTooltip() { + return null; + } + + /** + * Returns {@code true} if tooltip should always be visible, otherwise {@code false}. + * + * @return {@code true} if tooltip should always be visible, otherwise {@code false} + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ + @JsonIgnore + default boolean isTooltipVisible() { + return false; + } + + /** + * Returns the rules defined for the component after filtering out invalid rules + * If no rules are defined, returns an empty map + * + * @return map containing the rules and their expressions + */ + @NotNull + @JsonInclude(Include.NON_EMPTY) + default Map getRules() { + return Collections.emptyMap(); + } + + /** + * Returns the events defined for the component after filtering out invalid rules + * + * @return map containing the events and their expressions + * If no rules are defined, returns an empty map + */ + @NotNull + @JsonInclude(Include.NON_EMPTY) + default Map getEvents() { + return Collections.emptyMap(); + } + + /** + * Sets i18n object + * + * @param i18n reference to the {@link I18n} object + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ + @JsonIgnore + default void setI18n(@Nonnull I18n i18n) { + // empty body + } } diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/BaseConstraint.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/BaseConstraint.java index 9ed8d0285a..22e48d5e43 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/BaseConstraint.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/BaseConstraint.java @@ -37,8 +37,11 @@ public interface BaseConstraint { */ public enum Type { STRING("string"), + STRING_ARRAY("string[]"), NUMBER("number"), + NUMBER_ARRAY("number[]"), BOOLEAN("boolean"), + BOOLEAN_ARRAY("boolean[]"), OBJECT("object"), ARRAY("array"), FILE("file"), @@ -104,17 +107,6 @@ default Type getType() { return Type.STRING; } - /** - * Returns the format of the form field as specified in the json schema specification(for example, date, binary etc) - * - * @return the format of the form field - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 - */ - @Nullable - default String getFormat() { - return null; - } - /** * Returns an expression returning boolean value indicating whether the value in the field is valid or not * diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/CheckBox.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/CheckBox.java new file mode 100644 index 0000000000..266a64faf9 --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/CheckBox.java @@ -0,0 +1,91 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.models.form; + +import org.apache.commons.lang3.StringUtils; +import org.osgi.annotation.versioning.ConsumerType; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines the form {@code CheckBox} Sling Model used for the {@code /apps/core/fd/components/form/checkbox/v1/checkbox} component. + * + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ +@ConsumerType +public interface CheckBox extends Field, OptionsConstraint { + + /** + * Defines the orientation for checkbox. Possible values: {@code horizontal}, {@code vertical} + * + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ + public enum Orientation { + HORIZONTAL("horizontal"), + VERTICAL("vertical"); + + private String value; + + Orientation(String value) { + this.value = value; + } + + /** + * Given a {@link String} value, this method returns the enum's value that corresponds to the provided string + * representation. If no representation is found, {@link #HORIZONTAL} will be returned. + * + * @param value the string representation for which an enum value should be returned + * @return the corresponding enum value, if one was found, or {@link #HORIZONTAL} + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ + public static Orientation fromString(String value) { + for (Orientation type : Orientation.values()) { + if (StringUtils.equals(value, type.value)) { + return type; + } + } + return HORIZONTAL; + } + + /** + * Returns the string value of this enum constant. + * + * @return the string value of this enum constant + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ + public String getValue() { + return value; + } + + @Override + @JsonValue + public String toString() { + return value; + } + } + + /** + * Returns the orientation of the checkbox component + * + * @return {@link Orientation}. + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ + @JsonIgnore + default Orientation getOrientation() { + return Orientation.HORIZONTAL; + } +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/CheckBoxGroup.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/CheckBoxGroup.java new file mode 100644 index 0000000000..a001048cab --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/CheckBoxGroup.java @@ -0,0 +1,29 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.models.form; + +import org.osgi.annotation.versioning.ConsumerType; + +/** + * Defines the form {@code CheckBoxGroup} Sling Model used for the {@code /apps/core/fd/components/form/checkboxgroup/v1/checkboxgroup} + * component. + * + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ +@ConsumerType +public interface CheckBoxGroup extends Field, OptionsConstraint, ContainerConstraint { + +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/Container.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/Container.java index 0891dc251a..603b67ba38 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/Container.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/Container.java @@ -34,7 +34,7 @@ * @since com.adobe.cq.forms.core.components.models.form 0.0.1 */ @ConsumerType -public interface Container extends ContainerExporter { +public interface Container extends Base, BaseConstraint, ContainerExporter { /** * Returns the list of items present inside the container as an array. @@ -56,6 +56,13 @@ public interface Container extends ContainerExporter { return Collections.emptyMap(); } + @JsonIgnore + @Override + default boolean isRequired() { + // explicitly setting null, since containers don't have required property + return false; + } + @NotNull @Override @JsonIgnore diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/ContainerConstraint.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/ContainerConstraint.java index 7a140dd3b8..0eeacf1723 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/ContainerConstraint.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/ContainerConstraint.java @@ -15,6 +15,7 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ package com.adobe.cq.forms.core.components.models.form; +import org.jetbrains.annotations.Nullable; import org.osgi.annotation.versioning.ConsumerType; /** @@ -30,8 +31,9 @@ public interface ContainerConstraint { * @return the minimum items * @since com.adobe.cq.forms.core.components.models.form 0.0.1 */ - default int getMinItems() { - return 1; + @Nullable + default Integer getMinItems() { + return null; } /** @@ -40,8 +42,9 @@ default int getMinItems() { * @return the maximum items * @since com.adobe.cq.forms.core.components.models.form 0.0.1 */ - default int getMaxItems() { - return -1; + @Nullable + default Integer getMaxItems() { + return null; } // todo: add initial items here diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/DateConstraint.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/DateConstraint.java new file mode 100644 index 0000000000..c984215eee --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/DateConstraint.java @@ -0,0 +1,81 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.models.form; + +import java.util.Date; + +import org.osgi.annotation.versioning.ConsumerType; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A interface which specifies the different form date type constraints + * + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ +@ConsumerType +public interface DateConstraint extends FormatConstraint { + + /** + * Returns the minimum value for the date. The constraint is applicable only for field with type date + * + * @return minimum date + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonProperty("minimum") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = Base.DATE_FORMATTER) + Date getMinimumDate(); + + /** + * Returns the maximum value for the date. The constraint is applicable only for field with type date + * + * @return maximum date + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonProperty("maximum") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = Base.DATE_FORMATTER) + Date getMaximumDate(); + + /** + * Returns the Maximum value (exclusive) that can be entered by the user. + * + * @return maximum value (exclusive) for the date + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonProperty("exclusiveMaximum") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = Base.DATE_FORMATTER) + Date getExclusiveMaximumDate(); + + /** + * Returns the minimum value (exclusive) that can be entered by the user. + * + * @return minimum value (exclusive) for the date + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonProperty("exclusiveMinimum") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = Base.DATE_FORMATTER) + Date getExclusiveMinimumDate(); + + default String getFormat() { + return Format.DATE.toString(); + } +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/DatePicker.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/DatePicker.java new file mode 100644 index 0000000000..c90b5ca6a8 --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/DatePicker.java @@ -0,0 +1,39 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.models.form; + +import org.osgi.annotation.versioning.ConsumerType; + +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * Defines the form {@code DatePicker} Sling Model used for the {@code /apps/core/fd/components/form/datepicker/v1/datepicker} component. + * + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ +@ConsumerType +public interface DatePicker extends Field, DateConstraint { + + /** + * @see Field#getDefault() + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = Base.DATE_FORMATTER) + @Override + default Object[] getDefault() { + return null; + } +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/DropDown.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/DropDown.java new file mode 100644 index 0000000000..3d753cb699 --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/DropDown.java @@ -0,0 +1,37 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.models.form; + +import org.osgi.annotation.versioning.ConsumerType; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * Defines the form {@code DropDown} Sling Model used for the {@code /apps/core/fd/components/form/dropdown/v1/dropdown} component. + * + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ +@ConsumerType +public interface DropDown extends Field, OptionsConstraint, ContainerConstraint { + + /** + * Returns {@code true} if multiple items can be selected in dropdown, {@code false} otherwise + * + * @return {@code true} if multiple selection is enabled, {@code false} otherwise + */ + @JsonIgnore + Boolean isMultiSelect(); +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/Field.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/Field.java index 74fc218d66..46775b3a63 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/Field.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/Field.java @@ -15,10 +15,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ package com.adobe.cq.forms.core.components.models.form; -import org.jetbrains.annotations.Nullable; import org.osgi.annotation.versioning.ConsumerType; -import com.fasterxml.jackson.annotation.JsonIgnore; +import com.adobe.cq.forms.core.components.util.DefaultValueSerializer; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; /** * Defines the form {@code Field} Sling Model used for form field component. @@ -88,28 +88,9 @@ default String getDataFormat() { * @return default value of the field * @since com.adobe.cq.forms.core.components.models.form 0.0.1 */ - Object getDefault(); - - /** - * Returns the short description of the field - * - * @return the short description of the field - * @since com.adobe.cq.forms.core.components.models.form 1.0.0 - */ - @JsonIgnore - @Nullable - default String getShortDescription() { + @JsonSerialize(using = DefaultValueSerializer.class) + default Object[] getDefault() { return null; } - /** - * Returns {@code true} if short description should always be visible, otherwise {@code false}. - * - * @return {@code true} if short description should always be visible, otherwise {@code false} - * @since com.adobe.cq.forms.core.components.models.form 1.0.0 - */ - @JsonIgnore - default boolean isShortDescriptionVisible() { - return false; - } } diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FileConstraint.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FileConstraint.java index 148ef426b3..72a4d0a133 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FileConstraint.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FileConstraint.java @@ -15,6 +15,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ package com.adobe.cq.forms.core.components.models.form; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + import org.osgi.annotation.versioning.ConsumerType; /** @@ -25,6 +29,10 @@ @ConsumerType public interface FileConstraint { + String DEFAULT_MAX_FILE_SIZE = "2MB"; + + List DEFAULT_ACCEPT = Collections.unmodifiableList(Arrays.asList("audio/*", "video/*", "image/*", "text/*", "application/pdf")); + /** * Returns the Maximum file size (in IEC specification) that a field can accept. The constraint is * applicable for file attachment field @@ -33,7 +41,7 @@ public interface FileConstraint { * @since com.adobe.cq.forms.core.components.models.form 0.0.1 */ default String getMaxFileSize() { - return "2MB"; + return DEFAULT_MAX_FILE_SIZE; } /** @@ -43,7 +51,7 @@ default String getMaxFileSize() { * @return the list of standard IANA media types * @since com.adobe.cq.forms.core.components.models.form 0.0.1 */ - default String[] getAccept() { - return new String[] { "audio/*", "video/*", "image/*", "text/*", "application/pdf" }; + default List getAccept() { + return DEFAULT_ACCEPT; } } diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FileInput.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FileInput.java new file mode 100644 index 0000000000..a2e3d080ce --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FileInput.java @@ -0,0 +1,37 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.models.form; + +import org.osgi.annotation.versioning.ConsumerType; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * Defines the form {@code FileInput} Sling Model used for the {@code /apps/core/fd/components/form/fileinput/v1/fileinput} component. + * + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ +@ConsumerType +public interface FileInput extends Field, FileConstraint, ContainerConstraint { + + /** + * Returns {@code true} if multiple files can be selected, {@code false} otherwise + * + * @return {@code true} if multiple files can be selected, {@code false} otherwise + */ + @JsonIgnore + Boolean isMultiple(); +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormContainer.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormContainer.java index 1a98ab8dbe..0a35904e19 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormContainer.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormContainer.java @@ -61,6 +61,46 @@ default String getId() { return null; } + @Override + default String getFieldType() { + return FieldType.FORM.getValue(); + } + + @JsonIgnore + @Override + default boolean isEnabled() { + // explicitly setting true, since form container does not have enabled property, but other containers like panel have enabled + return true; + } + + @Override + @JsonIgnore + default Label getLabel() { + // explicitly setting null, since form container does not have label, but other containers like panel have a label + return null; + } + + @JsonIgnore + @Override + default boolean isVisible() { + // explicitly setting true, since form container does not have visible property, but other containers like panel have visible + return true; + } + + @JsonIgnore + @Override + default String getName() { + // explicitly setting null, since form container does not have name property, but other containers like panel have a name + return null; + } + + @JsonIgnore + @Override + default BaseConstraint.Type getType() { + // explicitly setting null, since form container does not have type property, but other containers like panel have a type + return null; + } + /** * Returns the form title * diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormStructureParser.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormStructureParser.java new file mode 100644 index 0000000000..f6d4a13714 --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormStructureParser.java @@ -0,0 +1,26 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.models.form; + +public interface FormStructureParser { + + /** + * + * @returns the path of the form container in which the component is there + */ + String getFormContainerPath(); + +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormatConstraint.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormatConstraint.java new file mode 100644 index 0000000000..01d02f487d --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormatConstraint.java @@ -0,0 +1,67 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.models.form; + +import org.apache.commons.lang3.StringUtils; +import org.jetbrains.annotations.Nullable; + +import com.fasterxml.jackson.annotation.JsonValue; + +public interface FormatConstraint { + + public enum Format { + DATE("date"); + + private String value; + + Format(String value) { + this.value = value; + } + + public static Format fromString(String value) { + for (Format format : Format.values()) { + if (StringUtils.equals(value, format.value)) { + return format; + } + } + return null; + } + + /** + * Returns the string value of this enum constant. + * + * @return the string value of this enum constant + */ + public String getValue() { + return value; + } + + @Override + @JsonValue + public String toString() { + return value; + } + } + + /** + * Returns the format of the form field as specified in the json schema specification(for example, date, binary etc) + * + * @return the format of the form field + * @since com.adobe.cq.forms.core.components.models.form 0.0.1 + */ + @Nullable + String getFormat(); +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/NumberAndDateConstraint.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/NumberAndDateConstraint.java deleted file mode 100644 index e45e1d35ab..0000000000 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/NumberAndDateConstraint.java +++ /dev/null @@ -1,47 +0,0 @@ -/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ 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. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ - -package com.adobe.cq.forms.core.components.models.form; - -import org.osgi.annotation.versioning.ConsumerType; - -/** - * Interface for date and number constraints - * - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 - */ -@ConsumerType -public interface NumberAndDateConstraint extends BaseConstraint { - - /** - * Returns the minimum value that a user can enter in the Field. This constraint is applicable for - * Fields that have type number or type string and format date (i.e. Date Fields) - * - * @return the minimum value which could be Date serialized in ISO 8601 format or a number - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 - */ - Object getMinimum(); - - /** - * Returns the maximum value that a user can enter in the Field. This constraint is applicable for - * Fields that have type number or type string and format date (i.e. Date Fields) - * - * @return the maximum value which could be Date serialized in ISO 8601 format (string) or a number - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 - */ - Object getMaximum(); - -} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/NumberConstraint.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/NumberConstraint.java new file mode 100644 index 0000000000..9693e895d9 --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/NumberConstraint.java @@ -0,0 +1,66 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.models.form; + +import org.osgi.annotation.versioning.ConsumerType; + +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A interface which specifies the different form number type constraints + * + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ +@ConsumerType +public interface NumberConstraint { + + /** + * Returns the minimum value for the number. The constraint is applicable only for field with type number + * + * @return minimum value for the number + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + Long getMinimum(); + + /** + * Returns the maximum value for the number. The constraint is applicable only for field with type number + * + * @return maximum value for the number + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + Long getMaximum(); + + /** + * Returns the Maximum value (exclusive) that can be entered by the user. + * + * @return maximum value (exclusive) for the number + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + Long getExclusiveMaximum(); + + /** + * Returns the minimum value (exclusive) that can be entered by the user. + * + * @return minimum value (exclusive) for the number + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + Long getExclusiveMinimum(); + +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/NumberInput.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/NumberInput.java new file mode 100644 index 0000000000..600464d08c --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/NumberInput.java @@ -0,0 +1,48 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.models.form; + +import org.jetbrains.annotations.Nullable; +import org.osgi.annotation.versioning.ConsumerType; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * Defines the form {@code NumberInput} Sling Model used for the {@code /apps/core/fd/components/form/numberinput/v1/numberinput} component. + * + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ +@ConsumerType +public interface NumberInput extends Field, NumberConstraint { + + /** + * Returns the lead digits for float data type + * + * @return lead digits + */ + @Nullable + @JsonIgnore + Integer getLeadDigits(); + + /** + * Returns the fractional digits for float data type + * + * @return fractional digits + */ + @Nullable + @JsonIgnore + Integer getFracDigits(); +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/OptionsConstraint.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/OptionsConstraint.java index f10d57d38e..4d8a9de426 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/OptionsConstraint.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/OptionsConstraint.java @@ -48,7 +48,7 @@ default boolean isEnforceEnum() { * @since com.adobe.cq.forms.core.components.models.form 0.0.1 */ @JsonProperty("enum") - Object[] enums(); + Object[] getEnums(); /** * Returns a user friendly text to display for the possible options to be shown to the end user. @@ -57,5 +57,5 @@ default boolean isEnforceEnum() { * @return the list of enum names * @since com.adobe.cq.forms.core.components.models.form 0.0.1 */ - String[] enumNames(); + String[] getEnumNames(); } diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/Panel.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/Panel.java new file mode 100644 index 0000000000..d2bfbcdc8b --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/Panel.java @@ -0,0 +1,28 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.models.form; + +import org.osgi.annotation.versioning.ConsumerType; + +/** + * Defines the form {@code panel} Sling Model used for the {@code /apps/core/fd/components/form/panel/v1/panel} component. + * + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 + */ +@ConsumerType +public interface Panel extends Container, ContainerConstraint { + // todo +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/StringConstraint.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/StringConstraint.java index 62b1fac3cd..150a3b630d 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/StringConstraint.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/StringConstraint.java @@ -25,7 +25,7 @@ * @since com.adobe.cq.forms.core.components.models.form 0.0.1 */ @ConsumerType -public interface StringConstraint extends BaseConstraint { +public interface StringConstraint extends BaseConstraint, FormatConstraint { /** * Returns the minimum length of the data. The constraint is applicable only for field with type string diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/TextInput.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/TextInput.java index b799ce076d..9744adca59 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/TextInput.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/TextInput.java @@ -15,18 +15,18 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ package com.adobe.cq.forms.core.components.models.form; -import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.osgi.annotation.versioning.ConsumerType; import com.fasterxml.jackson.annotation.JsonIgnore; /** - * Defines the form {@code Text} Sling Model used for the {@code /apps/core/fd/components/form/textinput} component. + * Defines the form {@code Text} Sling Model used for the {@code /apps/core/fd/components/form/textinput/v1/textinput} component. * * @since com.adobe.cq.forms.core.components.models.form 0.0.1 */ @ConsumerType -public interface TextInput extends Field { +public interface TextInput extends Field, NumberConstraint, DateConstraint, StringConstraint { /** * Returns {@code true} if multi line, otherwise {@code false}. @@ -40,32 +40,25 @@ default boolean isMultiLine() { } /** - * @see Base#getFieldType() - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 - */ - @NotNull - @Override - default String getFieldType() { - return FieldType.TEXT_INPUT.getValue(); - } - - /** - * Returns {@code true} if autocomplete, otherwise {@code false}. + * Returns {@code "off"} if autocomplete if disabled, otherwise {@code "on"} or values listed @see + * here * - * @return {@code true} if autocomplete, otherwise {@code false} - * @since com.adobe.cq.forms.core.components.models.form 1.0.0 + * @since com.adobe.cq.forms.core.components.models.form 2.0.0 */ - default boolean isAutoComplete() { - return false; + @Nullable + default String getAutoComplete() { + return null; } /** - * The autofillFieldKeyword. + * Returns the format of the form field as specified in the json schema specification(for example, date, binary etc) * - * @return autofillFieldKeyword. - * @since com.adobe.cq.forms.core.components.models.form 1.0.0 + * @return the format of the form field + * @since com.adobe.cq.forms.core.components.models.form 0.0.1 */ - default String getAutofillFieldKeyword() { + @Nullable + default String getFormat() { return null; } + } diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java index ebebd7e93f..e5a00b85d9 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java @@ -34,7 +34,7 @@ * version, is bound to this proxy component resource type. *

*/ -@Version("1.1.0") +@Version("2.0.0") package com.adobe.cq.forms.core.components.models.form; import org.osgi.annotation.versioning.Version; diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractBaseImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractBaseImpl.java new file mode 100644 index 0000000000..ffaf2e9755 --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractBaseImpl.java @@ -0,0 +1,608 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.util; + +import java.util.AbstractMap; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import javax.annotation.Nonnull; +import javax.annotation.PostConstruct; + +import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.api.resource.ValueMap; +import org.apache.sling.models.annotations.Default; +import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy; +import org.apache.sling.models.annotations.injectorspecific.SlingObject; +import org.apache.sling.models.annotations.injectorspecific.ValueMapValue; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import com.adobe.aemds.guide.utils.GuideUtils; +import com.adobe.cq.forms.core.components.models.form.Base; +import com.adobe.cq.forms.core.components.models.form.BaseConstraint; +import com.adobe.cq.forms.core.components.models.form.Label; +import com.day.cq.i18n.I18n; +import com.day.cq.wcm.api.WCMMode; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * Abstract class which can be used as base class for {@link Base} implementations. + */ +public abstract class AbstractBaseImpl extends AbstractComponentImpl implements Base, BaseConstraint { + + protected I18n i18n = null; + private static final String PN_DESCRIPTION = "description"; + private static final String PN_TOOLTIP = "tooltip"; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = PN_DESCRIPTION) + @Nullable + protected String description; // long description as per current spec + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = PN_TOOLTIP) + @Nullable + protected String tooltip; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "tooltipVisible") + @Default(booleanValues = false) + protected boolean tooltipVisible; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "type") // needs to be implemented in dialog + @Nullable + protected String typeJcr; // todo: note this should never be array, we infer array types based on other metadata + private Type type; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "dataRef") + @Nullable + protected String dataRef; + + // mandatory property else adapt should fail for adaptive form components + @ValueMapValue(name = "fieldType") + protected String fieldTypeJcr; + private FieldType fieldType; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) + @Nullable + protected String validationExpression; + + // using old jcr property names to allow easy conversion from foundation to core components + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "required") + @Default(booleanValues = false) + protected boolean required; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "assistPriority") + @Nullable + protected String assistPriorityJcr; + private AssistPriority assistPriority; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "custom") + @Nullable + protected String customAssistPriorityMsg; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) + @Nullable + protected String name; + + @ValueMapValue + @Default(values = "") + protected String value; + + @ValueMapValue + @Default(booleanValues = true) + protected boolean visible; + + @ValueMapValue + @Default(booleanValues = true) + protected boolean enabled; + + /** Adding in base since it can also be used for fields and panels **/ + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) + protected Integer minItems; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) + protected Integer maxItems; + + /** End **/ + + @SlingObject + private Resource resource; + + /** + * Holds the constraint messages + */ + private Map constraintMessages = null; + + /** + * Predicate to check if a map entry is non empty + * return true if and only if + * 1) the value is not of type string and non empty or + * 2) the value is of type string[] and has more than 1 elements + */ + private final Predicate> isEntryNonEmpty = obj -> (obj.getValue() instanceof String && ((String) obj + .getValue()).length() > 0) + || (obj.getValue() instanceof String[] && ((String[]) obj.getValue()).length > 0); + + @PostConstruct + protected void initBaseModel() { + assistPriority = AssistPriority.fromString(assistPriorityJcr); + type = Type.fromString(typeJcr); + // first check if this is in the supported list of field type + fieldType = FieldType.fromString(fieldTypeJcr); + if (request != null && i18n == null) { + i18n = GuideUtils.getI18n(request, resource); + } + } + + @Override + public void setI18n(@Nonnull I18n i18n) { + this.i18n = i18n; + } + + /** + * Returns label of the form field + * + * @return label of the field + * @since com.adobe.cq.forms.core.components.models.form 0.0.1 + */ + @Override + public Label getLabel() { + return new LabelImpl(resource, getName(), i18n); + } + + /** + * Returns the name of the form field + * + * @return name of the form field + * @since com.adobe.cq.forms.core.components.models.form 0.0.1 + */ + @Override + public String getName() { + if (name == null) { + name = getDefaultName(); + } + return name; + } + + protected String getDefaultName() { + return StringEscapeUtils.escapeHtml4(GuideUtils.getGuideName(resource)); + } + + @Override + public @Nullable String getTooltip() { + return translate(PN_TOOLTIP, tooltip); + } + + @Override + public boolean isTooltipVisible() { + return tooltipVisible; + } + + @JsonIgnore + public @NotNull Map getCustomProperties() { + Map customProperties = new LinkedHashMap<>(); + if (tooltip != null) { + customProperties.put("tooltipVisible", tooltipVisible); + } + return customProperties; + } + + /** + * Returns the reference to the data model + * + * @return reference to the data model + * @since com.adobe.cq.forms.core.components.models.form 0.0.1 + */ + @Override + @Nullable + public String getDataRef() { + return dataRef; + } + + @Override + @Nullable + public String getScreenReaderText() { + // needs to be represented as json formula since labels, name, description can be dynamic, and hence + // screen reader text can be dynamic + String screenReaderText = null; // only if assist priority is set in JCR, we return screenReaderText to the client + if (AssistPriority.LABEL.equals(assistPriority)) { + Label label = getLabel(); + if (label != null) { + screenReaderText = "$label.$value"; + } + } else if (AssistPriority.NAME.equals(assistPriority)) { + screenReaderText = "$name"; + } else if (AssistPriority.DESCRIPTION.equals(assistPriority)) { + screenReaderText = "$description"; + } else if (AssistPriority.CUSTOM.equals(assistPriority)) { + screenReaderText = "'" + customAssistPriorityMsg + "'"; // json formula string literal + } + return screenReaderText; + } + + @Override + @Nullable + public String getHtmlScreenReaderText() { + // this can be used in sightly to compute initial html + String screenReaderText = getName(); + if (AssistPriority.LABEL.equals(assistPriority)) { + Label label = getLabel(); + if (label != null) { + screenReaderText = label.getValue(); + } + } else if (AssistPriority.NAME.equals(assistPriority)) { + screenReaderText = getName(); + } else if (AssistPriority.DESCRIPTION.equals(assistPriority)) { + screenReaderText = getDescription(); + } else if (AssistPriority.CUSTOM.equals(assistPriority)) { + screenReaderText = customAssistPriorityMsg; + } + return screenReaderText; + } + + /** + * Returns the description of the field + * + * @return the description of the field + * @since com.adobe.cq.forms.core.components.models.form 0.0.1 + */ + @Override + @Nullable + public String getDescription() { + return translate(PN_DESCRIPTION, description); + } + + /** + * Returns the view type + * + * @return the view type + * @since com.adobe.cq.forms.core.components.models.form 0.0.1 + */ + @Override + public String getFieldType() { + return fieldType.getValue(); + } + + /** + * Returns {@code true} if form field should be visible, otherwise {@code false}. + * + * @return {@code true} if form field should be visible, otherwise {@code false} + * @since com.adobe.cq.forms.core.components.models.form 0.0.1 + */ + @Override + public boolean isVisible() { + return visible; + } + + /** + * Returns {@code true} if form field should be enabled, otherwise {@code false}. + * + * @return {@code true} if form field should be enabled, otherwise {@code false} + * @since com.adobe.cq.forms.core.components.models.form 0.0.1 + */ + @Override + public boolean isEnabled() { + return enabled; + } + + protected String getConstraintMessage(ConstraintType type) { + String propName = type.getMessageProperty(); + ValueMap properties = resource.getValueMap(); + return translate(propName, properties.get(propName, String.class)); + } + + @Override + public @NotNull Map getConstraintMessages() { + if (constraintMessages == null) { + constraintMessages = new LinkedHashMap<>(); + ConstraintMessages msgs = new ConstraintMessagesProvider(); + putConstraintMessage(ConstraintType.TYPE, msgs.getTypeConstraintMessage()); + putConstraintMessage(ConstraintType.REQUIRED, msgs.getRequiredConstraintMessage()); + if (this.getType().equals(Type.STRING)) { + putConstraintMessage(ConstraintType.MIN_LENGTH, msgs.getMinLengthConstraintMessage()); + putConstraintMessage(ConstraintType.MAX_LENGTH, msgs.getMaxLengthConstraintMessage()); + putConstraintMessage(ConstraintType.PATTERN, msgs.getPatternConstraintMessage()); + putConstraintMessage(ConstraintType.FORMAT, msgs.getFormatConstraintMessage()); + } + + if (this.getType().equals(Type.NUMBER)) { + putConstraintMessage(ConstraintType.MINIMUM, msgs.getMinimumConstraintMessage()); + putConstraintMessage(ConstraintType.MAXIMUM, msgs.getMaximumConstraintMessage()); + } + + // todo: add the following conditionally + putConstraintMessage(ConstraintType.STEP, msgs.getStepConstraintMessage()); + putConstraintMessage(ConstraintType.MIN_ITEMS, msgs.getMinItemsConstraintMessage()); + putConstraintMessage(ConstraintType.MAX_ITEMS, msgs.getMaxItemsConstraintMessage()); + putConstraintMessage(ConstraintType.ENFORCE_ENUM, msgs.getEnforceEnumConstraintMessage()); + putConstraintMessage(ConstraintType.VALIDATION_EXPRESSION, msgs.getValidationExpressionConstraintMessage()); + putConstraintMessage(ConstraintType.UNIQUE_ITEMS, msgs.getUniqueItemsConstraintMessage()); + } + return constraintMessages; + } + + /** + * Put non-blank named values in constraint messages map. + */ + private void putConstraintMessage(ConstraintType name, String value) { + if (StringUtils.isNotBlank(value)) { + constraintMessages.put(name, value); + } + } + + /** + * Provides constraint messages configured for a form field + */ + private interface ConstraintMessages { + + String getTypeConstraintMessage(); + + String getRequiredConstraintMessage(); + + String getMinimumConstraintMessage(); + + String getMaximumConstraintMessage(); + + String getMinLengthConstraintMessage(); + + String getMaxLengthConstraintMessage(); + + String getStepConstraintMessage(); + + String getFormatConstraintMessage(); + + String getPatternConstraintMessage(); + + String getMinItemsConstraintMessage(); + + String getMaxItemsConstraintMessage(); + + String getUniqueItemsConstraintMessage(); + + String getEnforceEnumConstraintMessage(); + + String getValidationExpressionConstraintMessage(); + } + + private class ConstraintMessagesProvider implements ConstraintMessages { + + private static final String PN_TYPE_MESSAGE = "typeMessage"; + private static final String PN_REQUIRED_MESSAGE = "mandatoryMessage"; // reusing the same property name as in foundation + private static final String PN_MINIMUM_MESSAGE = "minimumMessage"; + private static final String PN_MAXIMUM_MESSAGE = "maximumMessage"; + private static final String PN_MINLENGTH_MESSAGE = "minLengthMessage"; + private static final String PN_MAXLENGTH_MESSAGE = "maxLengthMessage"; + private static final String PN_STEP_MESSAGE = "stepMessage"; + private static final String PN_FORMAT_MESSAGE = "formatMessage"; + private static final String PN_PATTERN_MESSAGE = "validatePictureClauseMessage"; // reusing the same property name as in foundation + private static final String PN_MINITEMS_MESSAGE = "minItemsMessage"; + private static final String PN_MAXITEMS_MESSAGE = "maxItemsMessage"; + private static final String PN_UNIQUEITEMS_MESSAGE = "uniqueItemsMessage"; + private static final String PN_ENFORCEENUM_MESSAGE = "enforceEnumMessage"; + private static final String PN_VALIDATIONEXPRESSION_MESSAGE = "validateExpMessage"; // reusing the same property name as in + // foundation + + private ValueMap properties = resource.getValueMap(); + + @Override + @Nullable + public String getTypeConstraintMessage() { + return translate(PN_TYPE_MESSAGE, properties.get(PN_TYPE_MESSAGE, String.class)); + } + + @Override + @Nullable + public String getRequiredConstraintMessage() { + return translate(PN_REQUIRED_MESSAGE, properties.get(PN_REQUIRED_MESSAGE, String.class)); + } + + @Override + @Nullable + public String getMinimumConstraintMessage() { + return translate(PN_MINIMUM_MESSAGE, properties.get(PN_MINIMUM_MESSAGE, String.class)); + } + + @Override + @Nullable + public String getMaximumConstraintMessage() { + return translate(PN_MAXIMUM_MESSAGE, properties.get(PN_MAXIMUM_MESSAGE, String.class)); + } + + @Override + @Nullable + public String getMinLengthConstraintMessage() { + return translate(PN_MINLENGTH_MESSAGE, properties.get(PN_MINLENGTH_MESSAGE, String.class)); + } + + @Override + @Nullable + public String getMaxLengthConstraintMessage() { + return translate(PN_MAXLENGTH_MESSAGE, properties.get(PN_MAXLENGTH_MESSAGE, String.class)); + } + + @Override + @Nullable + public String getStepConstraintMessage() { + return translate(PN_STEP_MESSAGE, properties.get(PN_STEP_MESSAGE, String.class)); + } + + @Override + @Nullable + public String getFormatConstraintMessage() { + return translate(PN_FORMAT_MESSAGE, properties.get(PN_FORMAT_MESSAGE, String.class)); + } + + @Override + @Nullable + public String getPatternConstraintMessage() { + return translate(PN_PATTERN_MESSAGE, properties.get(PN_PATTERN_MESSAGE, String.class)); + } + + @Override + @Nullable + public String getMinItemsConstraintMessage() { + return translate(PN_MINITEMS_MESSAGE, properties.get(PN_MINITEMS_MESSAGE, String.class)); + } + + @Override + @Nullable + public String getMaxItemsConstraintMessage() { + return translate(PN_MAXITEMS_MESSAGE, properties.get(PN_MAXITEMS_MESSAGE, String.class)); + } + + @Override + @Nullable + public String getUniqueItemsConstraintMessage() { + return translate(PN_UNIQUEITEMS_MESSAGE, properties.get(PN_UNIQUEITEMS_MESSAGE, String.class)); + } + + @Override + @Nullable + public String getEnforceEnumConstraintMessage() { + return translate(PN_ENFORCEENUM_MESSAGE, properties.get(PN_ENFORCEENUM_MESSAGE, String.class)); + } + + @Override + @Nullable + public String getValidationExpressionConstraintMessage() { + return translate(PN_VALIDATIONEXPRESSION_MESSAGE, properties.get(PN_VALIDATIONEXPRESSION_MESSAGE, String.class)); + } + } + + @Override + public @NotNull String getExportedType() { + return resource.getResourceType(); + } + + @Override + public Type getType() { + return type; + } + + @Override + @Nullable + public String getValidationExpression() { + return validationExpression; + } + + @Override + public @NotNull Map getProperties() { + Map customProperties = new LinkedHashMap<>(); + if (getCustomProperties().size() != 0) { + customProperties.put(CUSTOM_PROPERTY_WRAPPER, getCustomProperties()); + } + return customProperties; + } + + @Override + @NotNull + public Map getRules() { + String[] VALID_RULES = new String[] { "visible", "value", "enabled", "label", "required" }; + + Predicate> isRuleNameValid = obj -> Arrays.stream(VALID_RULES).anyMatch(validKey -> validKey.equals(obj + .getKey())); + + Predicate> isRuleValid = isEntryNonEmpty.and(isRuleNameValid); + + Resource ruleNode = resource.getChild("fd:rules"); + if (ruleNode != null) { + ValueMap ruleNodeProps = ruleNode.getValueMap(); + Map rules = ruleNodeProps.entrySet() + .stream() + .filter(isRuleValid) + .map(entry -> new AbstractMap.SimpleEntry<>(entry.getKey(), (String) entry.getValue())) + .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); + return rules; + } + return Collections.emptyMap(); + } + + /** + * Sanitizes the event entry by + * * removing invalid event names, + * * removing events where the handler is not of type string or string[] + * * converts all the event handlers into string[] for easy consumption + * * updates custom event key (as we cannot save custom:eventName in JCR) + * + * @param entry the event entry to manipulate + * @return the updated event entry + */ + private Stream> sanitizeEvent(Entry entry) { + String[] VALID_EVENTS = new String[] { "click", "submit", "initialize", "load", "change" }; + + Predicate> isEventNameValid = obj -> obj.getKey().startsWith("custom_") || + Arrays.stream(VALID_EVENTS).anyMatch(validKey -> validKey.equals(obj.getKey())); + Predicate> isEventValid = isEntryNonEmpty.and(isEventNameValid); + + Stream> updatedEntry; + Object eventValue = entry.getValue(); + String[] arrayEventValue; + String key = entry.getKey(); + if (key.startsWith("custom_")) { + key = "custom:" + key.substring("custom_".length()); + } + if (!isEventValid.test(entry)) { + updatedEntry = Stream.empty(); + } else { + if (eventValue instanceof String) { + arrayEventValue = new String[1]; + arrayEventValue[0] = (String) eventValue; + } else { + arrayEventValue = (String[]) eventValue; + } + updatedEntry = Stream.of(new AbstractMap.SimpleEntry<>(key, arrayEventValue)); + } + return updatedEntry; + } + + @Override + @NotNull + public Map getEvents() { + Resource eventNode = resource.getChild("fd:events"); + if (eventNode != null) { + ValueMap eventNodeProps = eventNode.getValueMap(); + Map events = eventNodeProps.entrySet() + .stream() + .flatMap(this::sanitizeEvent) + .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); + return events; + } + return Collections.emptyMap(); + } + + @Nullable + protected String translate(@NotNull String propertyName, @Nullable String propertyValue) { + // if author mode return the property value + boolean editMode = i18n == null; + if (request != null) { + editMode = WCMMode.fromRequest(request) == WCMMode.EDIT || WCMMode.fromRequest(request) == WCMMode.DESIGN; + } + if (editMode) { + return propertyValue; + } + if (StringUtils.isBlank(propertyValue)) { + return null; + } + return ComponentUtils.translate(propertyValue, propertyName, resource, i18n); + } +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractComponentImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractComponentImpl.java new file mode 100644 index 0000000000..025b673880 --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractComponentImpl.java @@ -0,0 +1,190 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.util; + +import java.util.Calendar; +import java.util.Optional; + +import org.apache.commons.lang3.StringUtils; +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy; +import org.apache.sling.models.annotations.injectorspecific.ScriptVariable; +import org.apache.sling.models.annotations.injectorspecific.Self; +import org.apache.sling.models.annotations.injectorspecific.SlingObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.osgi.annotation.versioning.ConsumerType; + +import com.adobe.cq.wcm.core.components.models.Component; +import com.adobe.cq.wcm.core.components.models.datalayer.ComponentData; +import com.adobe.cq.wcm.core.components.models.datalayer.builder.DataLayerBuilder; +import com.adobe.cq.wcm.core.components.util.ComponentUtils; +import com.adobe.cq.wcm.style.ComponentStyleInfo; +import com.day.cq.commons.jcr.JcrConstants; +import com.day.cq.wcm.api.Page; +import com.day.cq.wcm.api.components.ComponentContext; + +// this class is copied from WCM, since for forms adapting via slingRequest is optional + +/** + * Abstract class that can be used as a base class for {@link Component} implementations. + */ +@ConsumerType +public abstract class AbstractComponentImpl implements Component { + + /** + * The current request. + */ + @Self(injectionStrategy = InjectionStrategy.OPTIONAL) + protected SlingHttpServletRequest request; + + /** + * The current resource. + */ + @SlingObject + private Resource resource; + + /** + * The component. + */ + @ScriptVariable(injectionStrategy = InjectionStrategy.OPTIONAL) + @Nullable + protected com.day.cq.wcm.api.components.Component component; + + /** + * The component context. + */ + @ScriptVariable(injectionStrategy = InjectionStrategy.OPTIONAL) + @Nullable + protected ComponentContext componentContext; + + /** + * The current page. + */ + @ScriptVariable(injectionStrategy = InjectionStrategy.OPTIONAL) + @Nullable + private Page currentPage; + + /** + * The ID for this component. + */ + private String id; + + /** + * Flag indicating if the data layer is enabled. + */ + private Boolean dataLayerEnabled; + + /** + * The data layer component data. + */ + private ComponentData componentData; + + /** + * Getter for current page. + * + * @return The current {@link Page} + */ + protected Page getCurrentPage() { + return currentPage; + } + + /** + * Setter for current page. + * + * @param currentPage The {@link Page} to set + */ + protected void setCurrentPage(Page currentPage) { + this.currentPage = currentPage; + } + + @NotNull + @Override + public String getId() { + if (id == null) { + this.id = ComponentUtils.getId(this.resource, this.currentPage, null, this.componentContext); + } + return id; + } + + @NotNull + @Override + public String getExportedType() { + return resource.getResourceType(); + } + + /** + * See {@link Component#getData()} + * + * @return The component data + */ + @Override + @Nullable + public ComponentData getData() { + if (componentData == null) { + if (this.dataLayerEnabled == null) { + if (this.currentPage != null) { + // Check at page level to allow components embedded via containers in editable templates to inherit the setting + this.dataLayerEnabled = ComponentUtils.isDataLayerEnabled(this.currentPage.getContentResource()); + } else { + this.dataLayerEnabled = ComponentUtils.isDataLayerEnabled(this.resource); + } + } + if (this.dataLayerEnabled) { + componentData = getComponentData(); + } + } + return componentData; + } + + /** + * See {@link Component#getAppliedCssClasses()} + * + * @return The component styles/css class names + */ + @Override + @Nullable + public String getAppliedCssClasses() { + + return Optional.ofNullable(this.resource.adaptTo(ComponentStyleInfo.class)) + .map(ComponentStyleInfo::getAppliedCssClasses) + .filter(StringUtils::isNotBlank) + .orElse(null); // Returning null so sling model exporters don't return anything for this property if not configured + } + + /** + * Override this method to provide a different data model for your component. This will be called by + * {@link AbstractComponentImpl#getData()} in case the datalayer is activated. + * + * @return The component data. + */ + @NotNull + protected ComponentData getComponentData() { + return DataLayerBuilder.forComponent() + .withId(this::getId) + .withLastModifiedDate(() -> + // Note: this can be simplified in JDK 11 + Optional.ofNullable(resource.getValueMap().get(JcrConstants.JCR_LASTMODIFIED, Calendar.class)) + .map(Calendar::getTime) + .orElseGet(() -> Optional.ofNullable(resource.getValueMap().get(JcrConstants.JCR_CREATED, Calendar.class)) + .map(Calendar::getTime) + .orElse(null))) + .withType(() -> this.resource.getResourceType()) + .build(); + } + +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/AbstractContainerImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractContainerImpl.java similarity index 60% rename from bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/AbstractContainerImpl.java rename to bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractContainerImpl.java index 6c517c4de4..9791b0d2bc 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/AbstractContainerImpl.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractContainerImpl.java @@ -13,21 +13,20 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ -package com.adobe.cq.forms.core.components.internal.models.v1.form; +package com.adobe.cq.forms.core.components.util; import java.util.ArrayList; import java.util.List; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.resource.Resource; -import org.apache.sling.models.annotations.Default; -import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy; import org.apache.sling.models.annotations.injectorspecific.OSGiService; import org.apache.sling.models.annotations.injectorspecific.SlingObject; -import org.apache.sling.models.annotations.injectorspecific.ValueMapValue; import org.apache.sling.models.factory.ModelFactory; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import com.adobe.cq.export.json.ComponentExporter; import com.adobe.cq.export.json.SlingModelFilter; import com.adobe.cq.forms.core.components.models.form.Base; import com.adobe.cq.forms.core.components.models.form.Container; @@ -36,15 +35,7 @@ /** * Abstract class which can be used as base class for {@link Container} implementations. */ -public abstract class AbstractContainerImpl extends AbstractBaseImpl implements Base, Container, ContainerConstraint { - - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) - @Default(intValues = 0) - protected int minItems; - - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) - @Default(intValues = -1) - protected int maxItems; +public abstract class AbstractContainerImpl extends AbstractBaseImpl implements Container, ContainerConstraint { @OSGiService private SlingModelFilter slingModelFilter; @@ -53,24 +44,45 @@ public abstract class AbstractContainerImpl extends AbstractBaseImpl implements private ModelFactory modelFactory; @SlingObject - private Resource resource; + protected Resource resource; + + private List childrenModels; @Override - public int getMinItems() { + public Integer getMinItems() { return minItems; } @Override - public int getMaxItems() { + public Integer getMaxItems() { return maxItems; } - protected List getChildrenModels(@NotNull SlingHttpServletRequest request, @NotNull Class modelClass) { + @Override + public List getItems() { + if (childrenModels == null) { + childrenModels = getChildrenModels(request, ComponentExporter.class); + } + return childrenModels; + } + + protected List getChildrenModels(@Nullable SlingHttpServletRequest request, @NotNull Class modelClass) { List models = new ArrayList<>(); + for (Resource child : slingModelFilter.filterChildResources(resource.getChildren())) { - T model = modelFactory.getModelFromWrappedRequest(request, child, modelClass); - if (model != null) { - models.add(model); + if (!child.getName().startsWith("fd:")) { + T model = null; + if (request != null) { + model = modelFactory.getModelFromWrappedRequest(request, child, modelClass); + } else { + model = child.adaptTo(modelClass); + if (model instanceof Base && i18n != null) { + ((Base) model).setI18n(i18n); + } + } + if (model != null) { + models.add(model); + } } } return models; diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/AbstractFieldImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractFieldImpl.java similarity index 55% rename from bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/AbstractFieldImpl.java rename to bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractFieldImpl.java index 2e369e3d01..a367de7c32 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/AbstractFieldImpl.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractFieldImpl.java @@ -13,18 +13,20 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ -package com.adobe.cq.forms.core.components.internal.models.v1.form; +package com.adobe.cq.forms.core.components.util; -import java.util.LinkedHashMap; -import java.util.Map; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Default; import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy; import org.apache.sling.models.annotations.injectorspecific.SlingObject; import org.apache.sling.models.annotations.injectorspecific.ValueMapValue; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.adobe.cq.forms.core.components.models.form.Field; @@ -33,23 +35,26 @@ */ public abstract class AbstractFieldImpl extends AbstractBaseImpl implements Field { + private static final Logger logger = LoggerFactory.getLogger(AbstractFieldImpl.class); + private static final String PN_PLACEHOLDER = "placeholder"; + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) @Default(booleanValues = false) protected boolean readOnly; - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "_value") + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "default") @Nullable - protected Object defaultValue; + protected Object[] defaultValue; - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "placeholderText") + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = PN_PLACEHOLDER) @Nullable protected String placeholder; - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "displayPictureClause") + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "displayFormat") @Nullable protected String displayFormat; - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "editPictureClause") + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "editFormat") @Nullable protected String editFormat; @@ -57,13 +62,45 @@ public abstract class AbstractFieldImpl extends AbstractBaseImpl implements Fiel @Nullable protected String dataFormat; - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "minLength") @Nullable - protected String shortDescription; + protected Integer minLength; - @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "shortVisible") - @Default(booleanValues = false) - protected boolean shortDescriptionVisible; + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "maxLength") + @Nullable + protected Integer maxLength; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "maximum") + @Nullable + protected Long maximum; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "minimum") + @Nullable + protected Long minimum; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "minimumDate") + @Nullable + protected Date minimumDate; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "maximumDate") + @Nullable + protected Date maximumDate; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "exclusiveMinimum") + @Nullable + protected Long exclusiveMinimum; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "exclusiveMaximum") + @Nullable + protected Long exclusiveMaximum; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "exclusiveMinimumDate") + @Nullable + protected Date exclusiveMinimumDate; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "exclusiveMaximumDate") + @Nullable + protected Date exclusiveMaximumDate; @SlingObject private Resource resource; @@ -74,14 +111,30 @@ public boolean isReadOnly() { } @Override - public Object getDefault() { - return defaultValue; + public boolean isRequired() { + return required; + } + + @Override + public Object[] getDefault() { + if (defaultValue != null) { + return Arrays.stream(defaultValue) + .map(p -> { + if (p instanceof Calendar) { + return ((Calendar) p).getTime(); + } else { + return p; + } + }) + .toArray(); + } + return null; } @Override @Nullable public String getPlaceHolder() { - return placeholder; + return translate(PN_PLACEHOLDER, placeholder); } @Override @@ -101,24 +154,4 @@ public String getEditFormat() { public String getDataFormat() { return dataFormat; } - - @Override - public @Nullable String getShortDescription() { - return shortDescription; - } - - @Override - public boolean isShortDescriptionVisible() { - return shortDescriptionVisible; - } - - @Override - public @NotNull Map getProperties() { - Map customProperties = new LinkedHashMap<>(); - if (shortDescription != null) { - customProperties.put("shortDescription", shortDescription); - customProperties.put("shortDescriptionVisible", shortDescriptionVisible); - } - return customProperties; - } } diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractOptionsFieldImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractOptionsFieldImpl.java new file mode 100644 index 0000000000..d0d86b279b --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractOptionsFieldImpl.java @@ -0,0 +1,82 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.util; + +import java.util.Arrays; +import java.util.Objects; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.sling.models.annotations.Default; +import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy; +import org.apache.sling.models.annotations.injectorspecific.ValueMapValue; +import org.jetbrains.annotations.Nullable; + +import com.adobe.cq.forms.core.components.models.form.Field; +import com.adobe.cq.forms.core.components.models.form.OptionsConstraint; + +/** + * Abstract class which can be used as base class for options {@link Field} implementations. + */ +public abstract class AbstractOptionsFieldImpl extends AbstractFieldImpl implements OptionsConstraint { + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) + @Default(booleanValues = false) + private boolean enforceEnum; + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "enum") + @Nullable + private String[] enums; // todo: this needs to be thought through ? + + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "enumNames") + @Nullable + private String[] enumNames; + + @Override + public boolean isEnforceEnum() { + return enforceEnum; + } + + @Override + public Object[] getEnums() { + if (enums == null) { + return null; + } else { + // todo: we can only typecast to number or boolean if type is present in JCR, for array types, we need to store the type of each + // array element in JCR + // todo: and compute based on it (hence using typeJcr below) + // may expose internal representation of mutable object, hence cloning + if (Type.fromString(typeJcr).equals(Type.NUMBER) || Type.fromString(typeJcr).equals(Type.NUMBER_ARRAY)) { + return Arrays.stream(enums) + .filter(Objects::nonNull) + .map(Integer::parseInt) + .toArray(Integer[]::new); + } else if (Type.fromString(typeJcr).equals(Type.BOOLEAN) || Type.fromString(typeJcr).equals(Type.BOOLEAN_ARRAY)) { + return Arrays.stream(enums) + .filter(Objects::nonNull) + .map(Boolean::parseBoolean) + .toArray(Boolean[]::new); + } else { + return ArrayUtils.clone(enums); + } + } + } + + @Override + public String[] getEnumNames() { + // may expose internal representation of mutable object, hence cloning + return ArrayUtils.clone(enumNames); + } +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/ComponentUtils.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/ComponentUtils.java index 810232cb8e..2f4ce66907 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/ComponentUtils.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/ComponentUtils.java @@ -17,8 +17,16 @@ import java.nio.charset.StandardCharsets; import java.util.Base64; +import java.util.Date; +import java.util.Optional; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.api.resource.ValueMap; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import com.adobe.aemds.guide.utils.GuideUtils; +import com.day.cq.i18n.I18n; /** * Utility helper functions for components. @@ -42,4 +50,54 @@ public static String getEncodedPath(@NotNull String path) { return new String(Base64.getEncoder().encode(path.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8); } + /** + * Translates the given property as per the {@link I18n} object passed + * + * @param propertyValue value of the property (for example, in case of array type property, one needs to pass the value stored in array + * index) + * @param propertyName name of the property + * @param resource reference to the {@link Resource} + * @param i18n reference to the {@link I18n} object + * @return translated value + */ + @NotNull + public static String translate(@NotNull String propertyValue, @NotNull String propertyName, @NotNull Resource resource, + @Nullable I18n i18n) { + return translate(propertyValue, propertyName, resource.getValueMap(), i18n); + } + + /** + * Translates the given property as per the {@link I18n} object passed + * + * @param propertyValue value of the property (for example, in case of array type property, one needs to pass the value stored in array + * index) + * @param propertyName name of the property + * @param valueMap reference to the {@link ValueMap} + * @param i18n reference to the {@link I18n} object + * @return translated value + */ + @NotNull + public static String translate(@NotNull String propertyValue, @NotNull String propertyName, @NotNull ValueMap valueMap, + @Nullable I18n i18n) { + String translatedValue = propertyValue; + if (i18n != null) { + translatedValue = GuideUtils.translateOrReturnOriginal(propertyValue, propertyName, i18n, valueMap); + } + return translatedValue; + } + + /** + * Returns clone of the date object (mutable) provided as input + * + * @param date date + * @return clone of date object + */ + @NotNull + public static Date clone(@Nullable Date date) { + return Optional.ofNullable(date) + .map(Date::getTime) + .map(Date::new) + .orElse(null); + } + } diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/DefaultValueSerializer.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/DefaultValueSerializer.java new file mode 100644 index 0000000000..481fc1eda0 --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/DefaultValueSerializer.java @@ -0,0 +1,76 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.util; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +import com.adobe.cq.forms.core.components.models.form.Base; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +/** + * Jackson serializer for default value. This handles the use-case to support multiple value types for default field + */ +public class DefaultValueSerializer extends StdSerializer { + + private SimpleDateFormat formatter = new SimpleDateFormat(Base.DATE_FORMATTER); + + public DefaultValueSerializer() { + this(null); + } + + public DefaultValueSerializer(Class t) { + super(t); + } + + private void serialize(Object value, JsonGenerator gen) throws IOException { + if (value instanceof Boolean) { + gen.writeBoolean((Boolean) value); + } else if (value instanceof Long) { + gen.writeNumber((Long) value); + } else if (value instanceof Double) { + gen.writeNumber((Double) value); + } else if (value instanceof Integer) { + gen.writeNumber((Integer) value); + } else if (value instanceof String) { + gen.writeString((String) value); + } else if (value instanceof Date) { + gen.writeString(formatter.format(value)); + } else if (value instanceof Calendar) { + gen.writeString(formatter.format(((Calendar) value).getTime())); + } + } + + @Override + public void serialize( + Object[] value, JsonGenerator gen, SerializerProvider arg2) + throws IOException, JsonProcessingException { + if (value.length == 1) { + serialize(value[0], gen); + } else { + gen.writeStartArray(); + for (Object objValue : value) { + serialize(objValue, gen); + } + gen.writeEndArray(); + } + } +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/LabelImpl.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/LabelImpl.java similarity index 88% rename from bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/LabelImpl.java rename to bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/LabelImpl.java index 624945528d..c89e101e2e 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/LabelImpl.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/LabelImpl.java @@ -13,13 +13,14 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ -package com.adobe.cq.forms.core.components.internal.models.v1.form; +package com.adobe.cq.forms.core.components.util; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ValueMap; import com.adobe.cq.forms.core.components.models.form.Label; import com.day.cq.commons.jcr.JcrConstants; +import com.day.cq.i18n.I18n; public class LabelImpl implements Label { @@ -29,10 +30,12 @@ public class LabelImpl implements Label { private ValueMap properties; private String defaultTitle; + private I18n i18n; - public LabelImpl(Resource field, String defaultTitle) { + public LabelImpl(Resource field, String defaultTitle, I18n i18n) { this.properties = field.getValueMap(); this.defaultTitle = defaultTitle; + this.i18n = i18n; } /** @@ -65,6 +68,6 @@ public boolean isVisible() { */ @Override public String getValue() { - return properties.get(PN_TITLE, this.defaultTitle); + return ComponentUtils.translate(properties.get(PN_TITLE, this.defaultTitle), PN_TITLE, properties, i18n); } } diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/package-info.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/package-info.java index 0e2e244777..72e03b34d2 100644 --- a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/package-info.java +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/util/package-info.java @@ -18,7 +18,7 @@ * This package defines utility classes exposed by the Adobe Experience Manager Core Forms Components Bundle. *

*/ -@Version("1.0.0") +@Version("1.1.0") package com.adobe.cq.forms.core.components.util; import org.osgi.annotation.versioning.Version; \ No newline at end of file diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/views/Views.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/views/Views.java new file mode 100644 index 0000000000..9411d261ac --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/views/Views.java @@ -0,0 +1,32 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.views; + +public class Views { + + /** + * This view is used as the default view for serialising sling models to AF2.0 compliant schema + */ + public static class Publish {} + + /** + * Use this view for serialising the property required in control plane. + * It is a superset of properties in Publish view. + * Eg: DoR related properties of forms core components + */ + public static class Author extends Publish {} + +} diff --git a/bundles/core/src/main/java/com/adobe/cq/forms/core/components/views/package-info.java b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/views/package-info.java new file mode 100644 index 0000000000..ffdf14dc18 --- /dev/null +++ b/bundles/core/src/main/java/com/adobe/cq/forms/core/components/views/package-info.java @@ -0,0 +1,25 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/** + *

+ * This package defines the JSONViews exposed by the Adobe Experience Manager Forms Components Bundle for the form components. + * It is meant to be used by Jackson serialisation of Sling models of core components. + *

+ */ +@Version("1.0.0") +package com.adobe.cq.forms.core.components.views; + +import org.osgi.annotation.versioning.Version; diff --git a/bundles/core/src/test/java/com/adobe/cq/forms/core/Utils.java b/bundles/core/src/test/java/com/adobe/cq/forms/core/Utils.java index d41656a6ea..4f6e95db33 100644 --- a/bundles/core/src/test/java/com/adobe/cq/forms/core/Utils.java +++ b/bundles/core/src/test/java/com/adobe/cq/forms/core/Utils.java @@ -26,13 +26,15 @@ import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; +import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest; +import com.adobe.cq.forms.core.components.views.Views; import com.adobe.cq.wcm.core.components.internal.jackson.DefaultMethodSkippingModuleProvider; import com.adobe.cq.wcm.core.components.internal.jackson.PageModuleProvider; import com.fasterxml.jackson.databind.ObjectMapper; +import io.wcm.testing.mock.aem.junit5.AemContext; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; /** * Testing utilities. @@ -57,7 +59,7 @@ public static void testJSONExport(Object model, String expectedJsonResource) { DefaultMethodSkippingModuleProvider defaultMethodSkippingModuleProvider = new DefaultMethodSkippingModuleProvider(); mapper.registerModule(defaultMethodSkippingModuleProvider.getModule()); try { - mapper.writer().writeValue(writer, model); + mapper.writerWithView(Views.Publish.class).writeValue(writer, model); } catch (IOException e) { fail(String.format("Unable to generate JSON export for model %s: %s", model.getClass().getName(), e.getMessage())); @@ -142,4 +144,12 @@ private static Field getField(Class clazz, String field) { } } + public static T getComponentUnderTest(String resourcePath, Class clazz, AemContext context) { + context.currentResource(resourcePath); + MockSlingHttpServletRequest request = context.request(); + assertNotNull("resource adaptation should not be null", context.currentResource().adaptTo(clazz)); + assertNotNull("request adaptation should not be null", request.adaptTo(clazz)); + return request.adaptTo(clazz); + } + } diff --git a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/AbstractContainerImplTest.java b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/AbstractContainerImplTest.java index e48a891102..dd9215c42c 100644 --- a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/AbstractContainerImplTest.java +++ b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/AbstractContainerImplTest.java @@ -19,6 +19,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; +import com.adobe.cq.forms.core.components.util.AbstractContainerImpl; import io.wcm.testing.mock.aem.junit5.AemContextExtension; import static org.junit.Assert.assertEquals; @@ -30,14 +31,14 @@ public class AbstractContainerImplTest { void testGetMinItems() { AbstractContainerImpl abstractContainerMock = Mockito.mock(AbstractContainerImpl.class); Mockito.when(abstractContainerMock.getMinItems()).thenCallRealMethod(); - assertEquals(0, abstractContainerMock.getMinItems()); + assertEquals(null, abstractContainerMock.getMinItems()); } @Test void testGetMaxItems() { AbstractContainerImpl abstractContainerMock = Mockito.mock(AbstractContainerImpl.class); Mockito.when(abstractContainerMock.getMaxItems()).thenCallRealMethod(); - assertEquals(0, abstractContainerMock.getMaxItems()); + assertEquals(null, abstractContainerMock.getMaxItems()); } } diff --git a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/BaseConstraintTest.java b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/BaseConstraintTest.java index 709d2dcb9b..4584a8fe6a 100644 --- a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/BaseConstraintTest.java +++ b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/BaseConstraintTest.java @@ -33,13 +33,6 @@ void testGetType() { assertEquals(BaseConstraint.Type.STRING, baseConstraintMock.getType()); } - @Test - void testGetFormat() { - BaseConstraint baseConstraintMock = Mockito.mock(BaseConstraint.class); - Mockito.when(baseConstraintMock.getFormat()).thenCallRealMethod(); - assertEquals(null, baseConstraintMock.getFormat()); - } - @Test void testIsRequired() { BaseConstraint baseConstraintMock = Mockito.mock(BaseConstraint.class); diff --git a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxGroupImplTest.java b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxGroupImplTest.java new file mode 100644 index 0000000000..7346772245 --- /dev/null +++ b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxGroupImplTest.java @@ -0,0 +1,318 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import java.util.Collections; +import java.util.Map; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mockito; + +import com.adobe.cq.forms.core.Utils; +import com.adobe.cq.forms.core.components.internal.form.FormConstants; +import com.adobe.cq.forms.core.components.models.form.Base; +import com.adobe.cq.forms.core.components.models.form.BaseConstraint; +import com.adobe.cq.forms.core.components.models.form.CheckBoxGroup; +import com.adobe.cq.forms.core.components.models.form.Label; +import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext; +import com.adobe.cq.wcm.style.ComponentStyleInfo; +import io.wcm.testing.mock.aem.junit5.AemContext; +import io.wcm.testing.mock.aem.junit5.AemContextExtension; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; + +@ExtendWith(AemContextExtension.class) +public class CheckBoxGroupImplTest { + private static final String BASE = "/form/checkboxgroup"; + private static final String CONTENT_ROOT = "/content"; + private static final String PATH_CHECKBOX_GROUP = CONTENT_ROOT + "/checkboxgroup"; + + private final AemContext context = FormsCoreComponentTestContext.newAemContext(); + + @BeforeEach + void setUp() { + context.load().json(BASE + FormsCoreComponentTestContext.TEST_CONTENT_JSON, CONTENT_ROOT); + } + + @Test + void testExportedType() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals(FormConstants.RT_FD_FORM_CHECKBOX_GROUP_V1, checkboxGroup.getExportedType()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getExportedType()).thenCallRealMethod(); + assertEquals("", checkboxGroupMock.getExportedType()); + } + + @Test + void testFieldType() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals(Base.FieldType.CHECKBOX_GROUP.getValue(), checkboxGroup.getFieldType()); + } + + @Test + void testGetLabel() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals("def", checkboxGroup.getLabel().getValue()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getLabel()).thenCallRealMethod(); + assertEquals(null, checkboxGroupMock.getLabel()); + + Label labelMock = Mockito.mock(Label.class); + Mockito.when(labelMock.isRichText()).thenCallRealMethod(); + assertEquals(false, labelMock.isRichText()); + Mockito.when(labelMock.getValue()).thenCallRealMethod(); + assertEquals(null, labelMock.getValue()); + Mockito.when(labelMock.isVisible()).thenCallRealMethod(); + assertEquals(true, labelMock.isVisible()); + } + + @Test + void testGetName() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals("abc", checkboxGroup.getName()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getName()).thenCallRealMethod(); + assertEquals(null, checkboxGroupMock.getName()); + } + + @Test + void testGetDataRef() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals("a.b", checkboxGroup.getDataRef()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getDataRef()).thenCallRealMethod(); + assertEquals(null, checkboxGroupMock.getDataRef()); + } + + @Test + void testGetDescription() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals("dummy", checkboxGroup.getDescription()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getDescription()).thenCallRealMethod(); + assertEquals(null, checkboxGroupMock.getDescription()); + } + + @Test + void testGetScreenReaderText() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals("'Custom screen reader text'", checkboxGroup.getScreenReaderText()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getScreenReaderText()).thenCallRealMethod(); + assertEquals(null, checkboxGroupMock.getScreenReaderText()); + } + + @Test + void testIsVisible() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals(false, checkboxGroup.isVisible()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.isVisible()).thenCallRealMethod(); + assertEquals(true, checkboxGroupMock.isVisible()); + } + + @Test + void testIsEnabled() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals(true, checkboxGroup.isEnabled()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.isEnabled()).thenCallRealMethod(); + assertEquals(true, checkboxGroupMock.isEnabled()); + } + + @Test + void testIsReadOnly() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals(false, checkboxGroup.isReadOnly()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.isReadOnly()).thenCallRealMethod(); + assertEquals(false, checkboxGroupMock.isReadOnly()); + } + + @Test + void testGetPlaceHolder() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals(null, checkboxGroup.getPlaceHolder()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getPlaceHolder()).thenCallRealMethod(); + assertEquals(null, checkboxGroupMock.getPlaceHolder()); + } + + @Test + void testGetDisplayFormat() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals(null, checkboxGroup.getDisplayFormat()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getDisplayFormat()).thenCallRealMethod(); + assertEquals(null, checkboxGroupMock.getDisplayFormat()); + } + + @Test + void testGetEditFormat() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals(null, checkboxGroup.getEditFormat()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getEditFormat()).thenCallRealMethod(); + assertEquals(null, checkboxGroupMock.getEditFormat()); + } + + @Test + void testGetDataFormat() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals(null, checkboxGroup.getDataFormat()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getDataFormat()).thenCallRealMethod(); + assertEquals(null, checkboxGroupMock.getDataFormat()); + } + + @Test + void testGetTooltip() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals("test-short-description", checkboxGroup.getTooltip()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getTooltip()).thenCallRealMethod(); + assertEquals(null, checkboxGroupMock.getTooltip()); + } + + @Test + void testGetConstraintMessages() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + Map constraintsMessages = checkboxGroup.getConstraintMessages(); + assertEquals(constraintsMessages.get(Base.ConstraintType.TYPE), "incorrect type"); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getConstraintMessages()).thenCallRealMethod(); + assertEquals(Collections.emptyMap(), checkboxGroupMock.getConstraintMessages()); + } + + @Test + void testJSONExport() throws Exception { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + Utils.testJSONExport(checkboxGroup, Utils.getTestExporterJSONPath(BASE, PATH_CHECKBOX_GROUP)); + } + + @Test + void testGetProperties() throws Exception { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + Map properties = checkboxGroup.getProperties(); + assertFalse(properties.isEmpty()); + // get custom properties of "af:layout" + Map customProperties = (Map) properties.get(Base.CUSTOM_PROPERTY_WRAPPER); + assertFalse((boolean) customProperties.get("tooltipVisible")); + } + + @Test + void testGetProperties_should_return_empty_if_no_custom_properties() { + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getProperties()).thenCallRealMethod(); + assertTrue(checkboxGroupMock.getProperties().isEmpty()); + } + + @Test + void testGetShortDescription() { + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getTooltip()).thenCallRealMethod(); + assertEquals(null, checkboxGroupMock.getTooltip()); + } + + @Test + void testIsShortDescriptionVisible() { + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.isTooltipVisible()).thenCallRealMethod(); + assertEquals(false, checkboxGroupMock.isTooltipVisible()); + } + + @Test + void testGetEnum() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertArrayEquals(new Integer[] { 0, 1, 2 }, checkboxGroup.getEnums()); + } + + @Test + void testEnforceEnum() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals(true, checkboxGroup.isEnforceEnum()); + } + + @Test + void testGetDefault() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertArrayEquals(new Long[] { 0L, 1L }, checkboxGroup.getDefault()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getDefault()).thenCallRealMethod(); + assertEquals(null, checkboxGroupMock.getDefault()); + } + + @Test + void testGetType() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals(BaseConstraint.Type.NUMBER_ARRAY, checkboxGroup.getType()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getType()).thenCallRealMethod(); + assertEquals(BaseConstraint.Type.STRING, checkboxGroupMock.getType()); + } + + @Test + void testGetEnumNames() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertArrayEquals(new String[] { "m", "f", "o" }, checkboxGroup.getEnumNames()); + } + + @Test + void testGetMinItems() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals(1, checkboxGroup.getMinItems().intValue()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getMinItems()).thenCallRealMethod(); + assertEquals(null, checkboxGroupMock.getMinItems()); + } + + @Test + void testGetMaxItems() { + CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); + assertEquals(2, checkboxGroup.getMaxItems().intValue()); + CheckBoxGroup checkboxGroupMock = Mockito.mock(CheckBoxGroup.class); + Mockito.when(checkboxGroupMock.getMaxItems()).thenCallRealMethod(); + assertEquals(null, checkboxGroupMock.getMaxItems()); + } + + @Test + void testStyleSystemClasses() { + ComponentStyleInfo componentStyleInfoMock = mock(ComponentStyleInfo.class); + Resource resource = spy(context.resourceResolver().getResource(PATH_CHECKBOX_GROUP)); + Mockito.doReturn(componentStyleInfoMock).when(resource).adaptTo(ComponentStyleInfo.class); + MockSlingHttpServletRequest request = context.request(); + request.setResource(resource); + Mockito.doReturn("mystyle").when(componentStyleInfoMock).getAppliedCssClasses(); + CheckBoxGroup checkboxGroup = request.adaptTo(CheckBoxGroup.class); + String appliedCssClasses = checkboxGroup.getAppliedCssClasses(); + assertEquals("mystyle", appliedCssClasses); + } + + private CheckBoxGroup getCheckBoxGroupUnderTest(String resourcePath) { + context.currentResource(resourcePath); + MockSlingHttpServletRequest request = context.request(); + return request.adaptTo(CheckBoxGroup.class); + } +} diff --git a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxImplTest.java b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxImplTest.java new file mode 100644 index 0000000000..b249622971 --- /dev/null +++ b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxImplTest.java @@ -0,0 +1,275 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import java.util.Collections; +import java.util.Map; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mockito; + +import com.adobe.cq.forms.core.Utils; +import com.adobe.cq.forms.core.components.internal.form.FormConstants; +import com.adobe.cq.forms.core.components.models.form.Base; +import com.adobe.cq.forms.core.components.models.form.CheckBox; +import com.adobe.cq.forms.core.components.models.form.Label; +import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext; +import com.adobe.cq.wcm.style.ComponentStyleInfo; +import io.wcm.testing.mock.aem.junit5.AemContext; +import io.wcm.testing.mock.aem.junit5.AemContextExtension; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; + +@ExtendWith(AemContextExtension.class) +public class CheckBoxImplTest { + private static final String BASE = "/form/checkbox"; + private static final String CONTENT_ROOT = "/content"; + private static final String PATH_CHECKBOX = CONTENT_ROOT + "/checkbox"; + + private final AemContext context = FormsCoreComponentTestContext.newAemContext(); + + @BeforeEach + void setUp() { + context.load().json(BASE + FormsCoreComponentTestContext.TEST_CONTENT_JSON, CONTENT_ROOT); + } + + @Test + void testExportedType() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertEquals(FormConstants.RT_FD_FORM_CHECKBOX_V1, checkbox.getExportedType()); + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.getExportedType()).thenCallRealMethod(); + assertEquals("", checkboxMock.getExportedType()); + } + + @Test + void testFieldType() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertEquals(Base.FieldType.CHECKBOX.getValue(), checkbox.getFieldType()); + } + + @Test + void testGetLabel() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertEquals("def", checkbox.getLabel().getValue()); + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.getLabel()).thenCallRealMethod(); + assertEquals(null, checkboxMock.getLabel()); + + Label labelMock = Mockito.mock(Label.class); + Mockito.when(labelMock.isRichText()).thenCallRealMethod(); + assertEquals(false, labelMock.isRichText()); + Mockito.when(labelMock.getValue()).thenCallRealMethod(); + assertEquals(null, labelMock.getValue()); + Mockito.when(labelMock.isVisible()).thenCallRealMethod(); + assertEquals(true, labelMock.isVisible()); + } + + @Test + void testGetName() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertEquals("abc", checkbox.getName()); + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.getName()).thenCallRealMethod(); + assertEquals(null, checkboxMock.getName()); + } + + @Test + void testGetDataRef() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertEquals("a.b", checkbox.getDataRef()); + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.getDataRef()).thenCallRealMethod(); + assertEquals(null, checkboxMock.getDataRef()); + } + + @Test + void testGetDescription() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertEquals("dummy", checkbox.getDescription()); + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.getDescription()).thenCallRealMethod(); + assertEquals(null, checkboxMock.getDescription()); + } + + @Test + void testGetScreenReaderText() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertEquals("'Custom screen reader text'", checkbox.getScreenReaderText()); + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.getScreenReaderText()).thenCallRealMethod(); + assertEquals(null, checkboxMock.getScreenReaderText()); + } + + @Test + void testIsVisible() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertEquals(false, checkbox.isVisible()); + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.isVisible()).thenCallRealMethod(); + assertEquals(true, checkboxMock.isVisible()); + } + + @Test + void testIsEnabled() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertEquals(true, checkbox.isEnabled()); + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.isEnabled()).thenCallRealMethod(); + assertEquals(true, checkboxMock.isEnabled()); + } + + @Test + void testIsReadOnly() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertEquals(false, checkbox.isReadOnly()); + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.isReadOnly()).thenCallRealMethod(); + assertEquals(false, checkboxMock.isReadOnly()); + } + + @Test + void testGetPlaceHolder() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertEquals(null, checkbox.getPlaceHolder()); + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.getPlaceHolder()).thenCallRealMethod(); + assertEquals(null, checkboxMock.getPlaceHolder()); + } + + @Test + void testGetDisplayFormat() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertEquals(null, checkbox.getDisplayFormat()); + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.getDisplayFormat()).thenCallRealMethod(); + assertEquals(null, checkboxMock.getDisplayFormat()); + } + + @Test + void testGetEditFormat() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertEquals(null, checkbox.getEditFormat()); + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.getEditFormat()).thenCallRealMethod(); + assertEquals(null, checkboxMock.getEditFormat()); + } + + @Test + void testGetDataFormat() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertEquals(null, checkbox.getDataFormat()); + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.getDataFormat()).thenCallRealMethod(); + assertEquals(null, checkboxMock.getDataFormat()); + } + + @Test + void testGetTooltip() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertEquals("test-short-description", checkbox.getTooltip()); + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.getTooltip()).thenCallRealMethod(); + assertEquals(null, checkboxMock.getTooltip()); + } + + @Test + void testGetConstraintMessages() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + Map constraintsMessages = checkbox.getConstraintMessages(); + assertEquals(constraintsMessages.get(Base.ConstraintType.TYPE), "incorrect type"); + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.getConstraintMessages()).thenCallRealMethod(); + assertEquals(Collections.emptyMap(), checkboxMock.getConstraintMessages()); + } + + @Test + void testJSONExport() throws Exception { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + Utils.testJSONExport(checkbox, Utils.getTestExporterJSONPath(BASE, PATH_CHECKBOX)); + } + + @Test + void testGetProperties() throws Exception { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + Map properties = checkbox.getProperties(); + assertFalse(properties.isEmpty()); + // get custom properties of "af:layout" + Map customProperties = (Map) properties.get(Base.CUSTOM_PROPERTY_WRAPPER); + assertFalse((boolean) customProperties.get("tooltipVisible")); + } + + @Test + void testGetProperties_should_return_empty_if_no_custom_properties() { + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.getProperties()).thenCallRealMethod(); + assertTrue(checkboxMock.getProperties().isEmpty()); + } + + @Test + void testGetShortDescription() { + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.getTooltip()).thenCallRealMethod(); + assertEquals(null, checkboxMock.getTooltip()); + } + + @Test + void testIsShortDescriptionVisible() { + CheckBox checkboxMock = Mockito.mock(CheckBox.class); + Mockito.when(checkboxMock.isTooltipVisible()).thenCallRealMethod(); + assertEquals(false, checkboxMock.isTooltipVisible()); + } + + @Test + void testGetEnum() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertArrayEquals(new Boolean[] { true, false }, checkbox.getEnums()); + } + + @Test + void testGetEnumNames() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertArrayEquals(new String[] { "yes", "no" }, checkbox.getEnumNames()); + } + + @Test + void testStyleSystemClasses() { + ComponentStyleInfo componentStyleInfoMock = mock(ComponentStyleInfo.class); + Resource resource = spy(context.resourceResolver().getResource(PATH_CHECKBOX)); + Mockito.doReturn(componentStyleInfoMock).when(resource).adaptTo(ComponentStyleInfo.class); + MockSlingHttpServletRequest request = context.request(); + request.setResource(resource); + Mockito.doReturn("mystyle").when(componentStyleInfoMock).getAppliedCssClasses(); + CheckBox checkbox = request.adaptTo(CheckBox.class); + String appliedCssClasses = checkbox.getAppliedCssClasses(); + assertEquals("mystyle", appliedCssClasses); + } + + private CheckBox getCheckBoxUnderTest(String resourcePath) { + context.currentResource(resourcePath); + MockSlingHttpServletRequest request = context.request(); + return request.adaptTo(CheckBox.class); + } +} diff --git a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/ContainerConstraintTest.java b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/ContainerConstraintTest.java index fdec09466e..bb52458f99 100644 --- a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/ContainerConstraintTest.java +++ b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/ContainerConstraintTest.java @@ -27,16 +27,16 @@ @ExtendWith(AemContextExtension.class) public class ContainerConstraintTest { @Test - void testGetMaxFileSize() { + void testGetMinItems() { ContainerConstraint containerConstraintMock = Mockito.mock(ContainerConstraint.class); Mockito.when(containerConstraintMock.getMinItems()).thenCallRealMethod(); - assertEquals(1, containerConstraintMock.getMinItems()); + assertEquals(null, containerConstraintMock.getMinItems()); } @Test - void testGetAccept() { + void testGetMaxItems() { ContainerConstraint containerConstraintMock = Mockito.mock(ContainerConstraint.class); Mockito.when(containerConstraintMock.getMaxItems()).thenCallRealMethod(); - assertEquals(-1, containerConstraintMock.getMaxItems()); + assertEquals(null, containerConstraintMock.getMaxItems()); } } diff --git a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DatePickerImplTest.java b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DatePickerImplTest.java new file mode 100644 index 0000000000..ed200b524b --- /dev/null +++ b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DatePickerImplTest.java @@ -0,0 +1,237 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import java.util.Collections; +import java.util.Date; +import java.util.Map; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mockito; + +import com.adobe.cq.forms.core.Utils; +import com.adobe.cq.forms.core.components.internal.form.FormConstants; +import com.adobe.cq.forms.core.components.models.form.*; +import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext; +import io.wcm.testing.mock.aem.junit5.AemContext; +import io.wcm.testing.mock.aem.junit5.AemContextExtension; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; + +@ExtendWith(AemContextExtension.class) +public class DatePickerImplTest { + private static final String BASE = "/form/datepicker"; + private static final String CONTENT_ROOT = "/content"; + private static final String PATH_DATEPICKER = CONTENT_ROOT + "/datepicker"; + + private static final String PATH_DATEPICKER_MESSAGE = CONTENT_ROOT + "/datepicker-message"; + + private final AemContext context = FormsCoreComponentTestContext.newAemContext(); + + @BeforeEach + void setUp() { + context.load().json(BASE + FormsCoreComponentTestContext.TEST_CONTENT_JSON, CONTENT_ROOT); + } + + @Test + void testExportedType() { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + assertEquals(FormConstants.RT_FD_FORM_DATE_PICKER_V1, datePicker.getExportedType()); + DatePicker datePickerMock = Mockito.mock(DatePicker.class); + Mockito.when(datePickerMock.getExportedType()).thenCallRealMethod(); + assertEquals("", datePickerMock.getExportedType()); + } + + @Test + void testFieldType() { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + assertEquals(Base.FieldType.DATE_INPUT.getValue(), datePicker.getFieldType()); + } + + @Test + void testGetLabel() { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + assertEquals("def", datePicker.getLabel().getValue()); + DatePicker datePickerMock = Mockito.mock(DatePicker.class); + Mockito.when(datePickerMock.getLabel()).thenCallRealMethod(); + assertEquals(null, datePickerMock.getLabel()); + + Label labelMock = Mockito.mock(Label.class); + Mockito.when(labelMock.isRichText()).thenCallRealMethod(); + assertEquals(false, labelMock.isRichText()); + Mockito.when(labelMock.getValue()).thenCallRealMethod(); + assertEquals(null, labelMock.getValue()); + Mockito.when(labelMock.isVisible()).thenCallRealMethod(); + assertEquals(true, labelMock.isVisible()); + } + + @Test + void testGetName() { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + assertEquals("abc", datePicker.getName()); + DatePicker datePickerMock = Mockito.mock(DatePicker.class); + Mockito.when(datePickerMock.getName()).thenCallRealMethod(); + assertEquals(null, datePickerMock.getName()); + } + + @Test + void testGetDataRef() { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + assertEquals("a.b", datePicker.getDataRef()); + DatePicker datePickerMock = Mockito.mock(DatePicker.class); + Mockito.when(datePickerMock.getDataRef()).thenCallRealMethod(); + assertEquals(null, datePickerMock.getDataRef()); + } + + @Test + void testGetDescription() { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + assertEquals("dummy", datePicker.getDescription()); + DatePicker datePickerMock = Mockito.mock(DatePicker.class); + Mockito.when(datePickerMock.getDescription()).thenCallRealMethod(); + assertEquals(null, datePickerMock.getDescription()); + } + + @Test + void testGetScreenReaderText() { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + assertEquals("'Custom screen reader text'", datePicker.getScreenReaderText()); + DatePicker datePickerMock = Mockito.mock(DatePicker.class); + Mockito.when(datePickerMock.getScreenReaderText()).thenCallRealMethod(); + assertEquals(null, datePickerMock.getScreenReaderText()); + } + + @Test + void testIsVisible() { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + assertEquals(false, datePicker.isVisible()); + DatePicker datePickerMock = Mockito.mock(DatePicker.class); + Mockito.when(datePickerMock.isVisible()).thenCallRealMethod(); + assertEquals(true, datePickerMock.isVisible()); + } + + @Test + void testIsEnabled() { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + assertEquals(true, datePicker.isEnabled()); + DatePicker datePickerMock = Mockito.mock(DatePicker.class); + Mockito.when(datePickerMock.isEnabled()).thenCallRealMethod(); + assertEquals(true, datePickerMock.isEnabled()); + } + + @Test + void testGetMinimumDate() { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + assertEquals(new Date("Fri Feb 04 2022 05:30:00 GMT+0530"), datePicker.getMinimumDate()); + } + + @Test + void testGetDefault() { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + assertArrayEquals(new Object[] { new Date("Mon Feb 07 2022 05:30:00 GMT+0530") }, datePicker.getDefault()); + } + + @Test + void testIsReadOnly() { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + assertEquals(false, datePicker.isReadOnly()); + DatePicker datePickerMock = Mockito.mock(DatePicker.class); + Mockito.when(datePickerMock.isReadOnly()).thenCallRealMethod(); + assertEquals(false, datePickerMock.isReadOnly()); + } + + @Test + void testGetPlaceHolder() { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + assertEquals(null, datePicker.getPlaceHolder()); + DatePicker datePickerMock = Mockito.mock(DatePicker.class); + Mockito.when(datePickerMock.getPlaceHolder()).thenCallRealMethod(); + assertEquals(null, datePickerMock.getPlaceHolder()); + } + + @Test + void testGetDisplayFormat() { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + assertEquals(null, datePicker.getDisplayFormat()); + DatePicker datePickerMock = Mockito.mock(DatePicker.class); + Mockito.when(datePickerMock.getDisplayFormat()).thenCallRealMethod(); + assertEquals(null, datePickerMock.getDisplayFormat()); + } + + @Test + void testGetEditFormat() { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + assertEquals(null, datePicker.getEditFormat()); + DatePicker datePickerMock = Mockito.mock(DatePicker.class); + Mockito.when(datePickerMock.getEditFormat()).thenCallRealMethod(); + assertEquals(null, datePickerMock.getEditFormat()); + } + + @Test + void testGetDataFormat() { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + assertEquals(null, datePicker.getDataFormat()); + DatePicker datePickerMock = Mockito.mock(DatePicker.class); + Mockito.when(datePickerMock.getDataFormat()).thenCallRealMethod(); + assertEquals(null, datePickerMock.getDataFormat()); + } + + @Test + void testGetConstraintMessages() { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + Map constraintsMessages = datePicker.getConstraintMessages(); + assertEquals(constraintsMessages.get(Base.ConstraintType.TYPE), "incorrect type"); + DatePicker datePickerMock = Mockito.mock(DatePicker.class); + Mockito.when(datePickerMock.getConstraintMessages()).thenCallRealMethod(); + assertEquals(Collections.emptyMap(), datePickerMock.getConstraintMessages()); + } + + @Test + void testJSONExport() throws Exception { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER, DatePicker.class, context); + Utils.testJSONExport(datePicker, Utils.getTestExporterJSONPath(BASE, PATH_DATEPICKER)); + } + + @Test + void testJSONExportMessage() throws Exception { + DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER_MESSAGE, DatePicker.class, context); + Utils.testJSONExport(datePicker, Utils.getTestExporterJSONPath(BASE, PATH_DATEPICKER_MESSAGE)); + } + + @Test + void testGetProperties_should_return_empty_if_no_custom_properties() { + TextInput textInputMock = Mockito.mock(TextInput.class); + Mockito.when(textInputMock.getProperties()).thenCallRealMethod(); + assertTrue(textInputMock.getProperties().isEmpty()); + } + + @Test + void testGetShortDescription() { + DatePicker datePickerMock = Mockito.mock(DatePicker.class); + Mockito.when(datePickerMock.getTooltip()).thenCallRealMethod(); + assertEquals(null, datePickerMock.getTooltip()); + } + + @Test + void testIsShortDescriptionVisible() { + DatePicker datePickerMock = Mockito.mock(DatePicker.class); + Mockito.when(datePickerMock.isTooltipVisible()).thenCallRealMethod(); + assertEquals(false, datePickerMock.isTooltipVisible()); + } +} diff --git a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DropDownImplTest.java b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DropDownImplTest.java new file mode 100644 index 0000000000..1637d4f718 --- /dev/null +++ b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DropDownImplTest.java @@ -0,0 +1,313 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import java.util.Collections; +import java.util.Map; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mockito; + +import com.adobe.cq.forms.core.Utils; +import com.adobe.cq.forms.core.components.internal.form.FormConstants; +import com.adobe.cq.forms.core.components.models.form.*; +import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext; +import com.adobe.cq.wcm.style.ComponentStyleInfo; +import io.wcm.testing.mock.aem.junit5.AemContext; +import io.wcm.testing.mock.aem.junit5.AemContextExtension; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; + +@ExtendWith(AemContextExtension.class) +public class DropDownImplTest { + private static final String BASE = "/form/dropdown"; + private static final String CONTENT_ROOT = "/content"; + private static final String PATH_DROPDOWN = CONTENT_ROOT + "/dropdown"; + private static final String PATH_MULTISELECT_DROPDOWN = CONTENT_ROOT + "/multiselect-dropdown"; + + private final AemContext context = FormsCoreComponentTestContext.newAemContext(); + + @BeforeEach + void setUp() { + context.load().json(BASE + FormsCoreComponentTestContext.TEST_CONTENT_JSON, CONTENT_ROOT); + } + + @Test + void testExportedType() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertEquals(FormConstants.RT_FD_FORM_DROP_DOWN_V1, dropdown.getExportedType()); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.getExportedType()).thenCallRealMethod(); + assertEquals("", dropdownMock.getExportedType()); + } + + @Test + void testFieldType() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertEquals(Base.FieldType.DROP_DOWN.getValue(), dropdown.getFieldType()); + } + + @Test + void testGetLabel() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertEquals("def", dropdown.getLabel().getValue()); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.getLabel()).thenCallRealMethod(); + assertEquals(null, dropdownMock.getLabel()); + + Label labelMock = Mockito.mock(Label.class); + Mockito.when(labelMock.isRichText()).thenCallRealMethod(); + assertEquals(false, labelMock.isRichText()); + Mockito.when(labelMock.getValue()).thenCallRealMethod(); + assertEquals(null, labelMock.getValue()); + Mockito.when(labelMock.isVisible()).thenCallRealMethod(); + assertEquals(true, labelMock.isVisible()); + } + + @Test + void testGetName() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertEquals("abc", dropdown.getName()); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.getName()).thenCallRealMethod(); + assertEquals(null, dropdownMock.getName()); + } + + @Test + void testGetDataRef() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertEquals("a.b", dropdown.getDataRef()); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.getDataRef()).thenCallRealMethod(); + assertEquals(null, dropdownMock.getDataRef()); + } + + @Test + void testGetDescription() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertEquals("dummy", dropdown.getDescription()); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.getDescription()).thenCallRealMethod(); + assertEquals(null, dropdownMock.getDescription()); + } + + @Test + void testGetScreenReaderText() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertEquals("'Custom screen reader text'", dropdown.getScreenReaderText()); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.getScreenReaderText()).thenCallRealMethod(); + assertEquals(null, dropdownMock.getScreenReaderText()); + } + + @Test + void testIsVisible() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertEquals(false, dropdown.isVisible()); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.isVisible()).thenCallRealMethod(); + assertEquals(true, dropdownMock.isVisible()); + } + + @Test + void testIsEnabled() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertEquals(true, dropdown.isEnabled()); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.isEnabled()).thenCallRealMethod(); + assertEquals(true, dropdownMock.isEnabled()); + } + + @Test + void testIsReadOnly() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertEquals(false, dropdown.isReadOnly()); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.isReadOnly()).thenCallRealMethod(); + assertEquals(false, dropdownMock.isReadOnly()); + } + + @Test + void testGetPlaceHolder() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertEquals(null, dropdown.getPlaceHolder()); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.getPlaceHolder()).thenCallRealMethod(); + assertEquals(null, dropdownMock.getPlaceHolder()); + } + + @Test + void testGetDisplayFormat() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertEquals(null, dropdown.getDisplayFormat()); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.getDisplayFormat()).thenCallRealMethod(); + assertEquals(null, dropdownMock.getDisplayFormat()); + } + + @Test + void testGetEditFormat() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertEquals(null, dropdown.getEditFormat()); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.getEditFormat()).thenCallRealMethod(); + assertEquals(null, dropdownMock.getEditFormat()); + } + + @Test + void testGetDataFormat() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertEquals(null, dropdown.getDataFormat()); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.getDataFormat()).thenCallRealMethod(); + assertEquals(null, dropdownMock.getDataFormat()); + } + + @Test + void testGetTooltip() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertEquals("test-short-description", dropdown.getTooltip()); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.getTooltip()).thenCallRealMethod(); + assertEquals(null, dropdownMock.getTooltip()); + } + + @Test + void testGetConstraintMessages() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + Map constraintsMessages = dropdown.getConstraintMessages(); + assertEquals(constraintsMessages.get(Base.ConstraintType.TYPE), "incorrect type"); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.getConstraintMessages()).thenCallRealMethod(); + assertEquals(Collections.emptyMap(), dropdownMock.getConstraintMessages()); + } + + @Test + void testJSONExport() throws Exception { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + Utils.testJSONExport(dropdown, Utils.getTestExporterJSONPath(BASE, PATH_DROPDOWN)); + } + + @Test + void testMultiSelectJSONExport() throws Exception { + DropDown dropdown = Utils.getComponentUnderTest(PATH_MULTISELECT_DROPDOWN, DropDown.class, context); + Utils.testJSONExport(dropdown, Utils.getTestExporterJSONPath(BASE, PATH_MULTISELECT_DROPDOWN)); + } + + @Test + void testGetProperties() throws Exception { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + Map properties = dropdown.getProperties(); + assertFalse(properties.isEmpty()); + // get custom properties of "af:layout" + Map customProperties = (Map) properties.get(Base.CUSTOM_PROPERTY_WRAPPER); + assertFalse((boolean) customProperties.get("tooltipVisible")); + } + + @Test + void testGetProperties_should_return_empty_if_no_custom_properties() { + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.getProperties()).thenCallRealMethod(); + assertTrue(dropdownMock.getProperties().isEmpty()); + } + + @Test + void testGetShortDescription() { + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.getTooltip()).thenCallRealMethod(); + assertEquals(null, dropdownMock.getTooltip()); + } + + @Test + void testIsShortDescriptionVisible() { + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.isTooltipVisible()).thenCallRealMethod(); + assertEquals(false, dropdownMock.isTooltipVisible()); + } + + @Test + void testGetEnum() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertArrayEquals(new Integer[] { 0, 1, 2 }, dropdown.getEnums()); + } + + @Test + void testGetType() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertEquals(BaseConstraint.Type.NUMBER, dropdown.getType()); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.getType()).thenCallRealMethod(); + assertEquals(BaseConstraint.Type.STRING, dropdownMock.getType()); + } + + @Test + void testGetMultiSelectType() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_MULTISELECT_DROPDOWN, DropDown.class, context); + assertEquals(BaseConstraint.Type.NUMBER_ARRAY, dropdown.getType()); + } + + @Test + void testGetMultiSelectDefault() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_MULTISELECT_DROPDOWN, DropDown.class, context); + assertArrayEquals(new Long[] { 0L, 1L }, dropdown.getDefault()); + } + + @Test + void testGetMultiSelectMinItems() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_MULTISELECT_DROPDOWN, DropDown.class, context); + assertEquals(1, dropdown.getMinItems().intValue()); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.getMinItems()).thenCallRealMethod(); + assertEquals(null, dropdownMock.getMinItems()); + } + + @Test + void testGetMultiSelectMaxItems() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_MULTISELECT_DROPDOWN, DropDown.class, context); + assertEquals(2, dropdown.getMaxItems().intValue()); + DropDown dropdownMock = Mockito.mock(DropDown.class); + Mockito.when(dropdownMock.getMaxItems()).thenCallRealMethod(); + assertEquals(null, dropdownMock.getMaxItems()); + } + + @Test + void testGetEnumNames() { + DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN, DropDown.class, context); + assertArrayEquals(new String[] { "m", "f", "o" }, dropdown.getEnumNames()); + } + + @Test + void testStyleSystemClasses() { + ComponentStyleInfo componentStyleInfoMock = mock(ComponentStyleInfo.class); + Resource resource = spy(context.resourceResolver().getResource(PATH_DROPDOWN)); + Mockito.doReturn(componentStyleInfoMock).when(resource).adaptTo(ComponentStyleInfo.class); + MockSlingHttpServletRequest request = context.request(); + request.setResource(resource); + Mockito.doReturn("mystyle").when(componentStyleInfoMock).getAppliedCssClasses(); + DropDown dropdown = request.adaptTo(DropDown.class); + String appliedCssClasses = dropdown.getAppliedCssClasses(); + assertEquals("mystyle", appliedCssClasses); + } +} diff --git a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileConstraintTest.java b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileConstraintTest.java index 389dc44629..8ff181a6b7 100644 --- a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileConstraintTest.java +++ b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileConstraintTest.java @@ -22,7 +22,9 @@ import com.adobe.cq.forms.core.components.models.form.FileConstraint; import io.wcm.testing.mock.aem.junit5.AemContextExtension; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; @ExtendWith(AemContextExtension.class) public class FileConstraintTest { @@ -31,13 +33,13 @@ public class FileConstraintTest { void testGetMaxFileSize() { FileConstraint fileConstraintMock = Mockito.mock(FileConstraint.class); Mockito.when(fileConstraintMock.getMaxFileSize()).thenCallRealMethod(); - assertEquals("2MB", fileConstraintMock.getMaxFileSize()); + assertEquals(FileConstraint.DEFAULT_MAX_FILE_SIZE, fileConstraintMock.getMaxFileSize()); } @Test void testGetAccept() { FileConstraint fileConstraintMock = Mockito.mock(FileConstraint.class); Mockito.when(fileConstraintMock.getAccept()).thenCallRealMethod(); - assertEquals(new String[] { "audio/*", "video/*", "image/*", "text/*", "application/pdf" }, fileConstraintMock.getAccept()); + assertThat(FileConstraint.DEFAULT_ACCEPT, is(fileConstraintMock.getAccept())); } } diff --git a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileInputImplTest.java b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileInputImplTest.java new file mode 100644 index 0000000000..64a186a44c --- /dev/null +++ b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileInputImplTest.java @@ -0,0 +1,318 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mockito; + +import com.adobe.cq.forms.core.Utils; +import com.adobe.cq.forms.core.components.internal.form.FormConstants; +import com.adobe.cq.forms.core.components.models.form.Base; +import com.adobe.cq.forms.core.components.models.form.BaseConstraint; +import com.adobe.cq.forms.core.components.models.form.FileInput; +import com.adobe.cq.forms.core.components.models.form.Label; +import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext; +import com.adobe.cq.wcm.style.ComponentStyleInfo; +import io.wcm.testing.mock.aem.junit5.AemContext; +import io.wcm.testing.mock.aem.junit5.AemContextExtension; + +import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; + +@ExtendWith(AemContextExtension.class) +public class FileInputImplTest { + private static final String BASE = "/form/fileinput"; + private static final String CONTENT_ROOT = "/content"; + private static final String PATH_FILEINPUT = CONTENT_ROOT + "/fileinput"; + private static final String PATH_MULTISELECT_FILEINPUT = CONTENT_ROOT + "/multiselect-fileinput"; + + private final AemContext context = FormsCoreComponentTestContext.newAemContext(); + + @BeforeEach + void setUp() { + context.load().json(BASE + FormsCoreComponentTestContext.TEST_CONTENT_JSON, CONTENT_ROOT); + } + + @Test + void testExportedType() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertEquals(FormConstants.RT_FD_FORM_FILE_INPUT_V1, fileInput.getExportedType()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getExportedType()).thenCallRealMethod(); + assertEquals("", fileInputMock.getExportedType()); + } + + @Test + void testFieldType() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertEquals(Base.FieldType.FILE_INPUT.getValue(), fileInput.getFieldType()); + } + + @Test + void testGetLabel() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertEquals("def", fileInput.getLabel().getValue()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getLabel()).thenCallRealMethod(); + assertEquals(null, fileInputMock.getLabel()); + + Label labelMock = Mockito.mock(Label.class); + Mockito.when(labelMock.isRichText()).thenCallRealMethod(); + assertEquals(false, labelMock.isRichText()); + Mockito.when(labelMock.getValue()).thenCallRealMethod(); + assertEquals(null, labelMock.getValue()); + Mockito.when(labelMock.isVisible()).thenCallRealMethod(); + assertEquals(true, labelMock.isVisible()); + } + + @Test + void testGetName() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertEquals("abc", fileInput.getName()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getName()).thenCallRealMethod(); + assertEquals(null, fileInputMock.getName()); + } + + @Test + void testGetDataRef() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertEquals("a.b", fileInput.getDataRef()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getDataRef()).thenCallRealMethod(); + assertEquals(null, fileInputMock.getDataRef()); + } + + @Test + void testGetDescription() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertEquals("dummy", fileInput.getDescription()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getDescription()).thenCallRealMethod(); + assertEquals(null, fileInputMock.getDescription()); + } + + @Test + void testGetScreenReaderText() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertEquals("'Custom screen reader text'", fileInput.getScreenReaderText()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getScreenReaderText()).thenCallRealMethod(); + assertEquals(null, fileInputMock.getScreenReaderText()); + } + + @Test + void testIsVisible() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertEquals(false, fileInput.isVisible()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.isVisible()).thenCallRealMethod(); + assertEquals(true, fileInputMock.isVisible()); + } + + @Test + void testIsEnabled() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertEquals(true, fileInput.isEnabled()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.isEnabled()).thenCallRealMethod(); + assertEquals(true, fileInputMock.isEnabled()); + } + + @Test + void testIsReadOnly() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertEquals(false, fileInput.isReadOnly()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.isReadOnly()).thenCallRealMethod(); + assertEquals(false, fileInputMock.isReadOnly()); + } + + @Test + void testGetPlaceHolder() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertEquals(null, fileInput.getPlaceHolder()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getPlaceHolder()).thenCallRealMethod(); + assertEquals(null, fileInputMock.getPlaceHolder()); + } + + @Test + void testGetDisplayFormat() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertEquals(null, fileInput.getDisplayFormat()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getDisplayFormat()).thenCallRealMethod(); + assertEquals(null, fileInputMock.getDisplayFormat()); + } + + @Test + void testGetEditFormat() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertEquals(null, fileInput.getEditFormat()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getEditFormat()).thenCallRealMethod(); + assertEquals(null, fileInputMock.getEditFormat()); + } + + @Test + void testGetDataFormat() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertEquals(null, fileInput.getDataFormat()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getDataFormat()).thenCallRealMethod(); + assertEquals(null, fileInputMock.getDataFormat()); + } + + @Test + void testGetMaxFileSize() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertEquals("4MB", fileInput.getMaxFileSize()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getMaxFileSize()).thenCallRealMethod(); + assertEquals(FileInput.DEFAULT_MAX_FILE_SIZE, fileInputMock.getMaxFileSize()); + } + + @Test + void testGetAccept() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertThat(Arrays.asList("audio/*", "video/*", "image/*"), is(fileInput.getAccept())); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getAccept()).thenCallRealMethod(); + assertThat(FileInput.DEFAULT_ACCEPT, is(fileInputMock.getAccept())); + } + + @Test + void testGetTooltip() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertEquals("test-short-description", fileInput.getTooltip()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getTooltip()).thenCallRealMethod(); + assertEquals(null, fileInputMock.getTooltip()); + } + + @Test + void testGetConstraintMessages() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + Map constraintsMessages = fileInput.getConstraintMessages(); + assertEquals(constraintsMessages.get(Base.ConstraintType.TYPE), "incorrect type"); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getConstraintMessages()).thenCallRealMethod(); + assertEquals(Collections.emptyMap(), fileInputMock.getConstraintMessages()); + } + + @Test + void testJSONExport() throws Exception { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + Utils.testJSONExport(fileInput, Utils.getTestExporterJSONPath(BASE, PATH_FILEINPUT)); + } + + @Test + void testMultiSelectJSONExport() throws Exception { + FileInput fileInput = Utils.getComponentUnderTest(PATH_MULTISELECT_FILEINPUT, FileInput.class, context); + Utils.testJSONExport(fileInput, Utils.getTestExporterJSONPath(BASE, PATH_MULTISELECT_FILEINPUT)); + } + + @Test + void testGetProperties() throws Exception { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + Map properties = fileInput.getProperties(); + assertFalse(properties.isEmpty()); + // get custom properties of "af:layout" + Map customProperties = (Map) properties.get(Base.CUSTOM_PROPERTY_WRAPPER); + assertFalse((boolean) customProperties.get("tooltipVisible")); + } + + @Test + void testGetProperties_should_return_empty_if_no_custom_properties() { + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getProperties()).thenCallRealMethod(); + assertTrue(fileInputMock.getProperties().isEmpty()); + } + + @Test + void testGetShortDescription() { + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getTooltip()).thenCallRealMethod(); + assertEquals(null, fileInputMock.getTooltip()); + } + + @Test + void testIsShortDescriptionVisible() { + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.isTooltipVisible()).thenCallRealMethod(); + assertEquals(false, fileInputMock.isTooltipVisible()); + } + + @Test + void testGetType() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT, FileInput.class, context); + assertEquals(BaseConstraint.Type.FILE, fileInput.getType()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getType()).thenCallRealMethod(); + assertEquals(BaseConstraint.Type.STRING, fileInputMock.getType()); + } + + @Test + void testGetMultiSelectType() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_MULTISELECT_FILEINPUT, FileInput.class, context); + assertEquals(BaseConstraint.Type.FILE_ARRAY, fileInput.getType()); + } + + @Test + void testGetMultiSelectMinItems() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_MULTISELECT_FILEINPUT, FileInput.class, context); + assertEquals(1, fileInput.getMinItems().intValue()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getMinItems()).thenCallRealMethod(); + assertEquals(null, fileInputMock.getMinItems()); + } + + @Test + void testGetMultiSelectMaxItems() { + FileInput fileInput = Utils.getComponentUnderTest(PATH_MULTISELECT_FILEINPUT, FileInput.class, context); + assertEquals(2, fileInput.getMaxItems().intValue()); + FileInput fileInputMock = Mockito.mock(FileInput.class); + Mockito.when(fileInputMock.getMaxItems()).thenCallRealMethod(); + assertEquals(null, fileInputMock.getMaxItems()); + } + + @Test + void testStyleSystemClasses() { + ComponentStyleInfo componentStyleInfoMock = mock(ComponentStyleInfo.class); + Resource resource = spy(context.resourceResolver().getResource(PATH_FILEINPUT)); + Mockito.doReturn(componentStyleInfoMock).when(resource).adaptTo(ComponentStyleInfo.class); + MockSlingHttpServletRequest request = context.request(); + request.setResource(resource); + Mockito.doReturn("mystyle").when(componentStyleInfoMock).getAppliedCssClasses(); + FileInput fileInput = request.adaptTo(FileInput.class); + String appliedCssClasses = fileInput.getAppliedCssClasses(); + assertEquals("mystyle", appliedCssClasses); + } +} diff --git a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FormStructureParserImplTest.java b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FormStructureParserImplTest.java new file mode 100644 index 0000000000..ed5b1ae207 --- /dev/null +++ b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FormStructureParserImplTest.java @@ -0,0 +1,83 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.adobe.cq.forms.core.components.models.form.*; +import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext; +import io.wcm.testing.mock.aem.junit5.AemContext; +import io.wcm.testing.mock.aem.junit5.AemContextExtension; + +import static org.junit.Assert.*; + +@ExtendWith(AemContextExtension.class) +public class FormStructureParserImplTest { + private static final String BASE = "/form/formstructparser"; + private static final String CONTENT_ROOT = "/content/myTestPage"; + private static final String JCR_CONTENT_PATH = CONTENT_ROOT + "/jcr:content"; + + private static final String FORM_CONTAINER_PATH = JCR_CONTENT_PATH + "/formcontainerv2"; + + private final AemContext context = FormsCoreComponentTestContext.newAemContext(); + + @BeforeEach + void setUp() { + context.load().json(BASE + FormsCoreComponentTestContext.TEST_CONTENT_JSON, CONTENT_ROOT); + } + + @Test + void testFormContainerPath() { + String path = FORM_CONTAINER_PATH + "/datepicker"; + FormStructureParser formStructureParser = getFormStructureParserUnderTest(path); + assertEquals(FORM_CONTAINER_PATH, formStructureParser.getFormContainerPath()); + } + + @Test + void testFormContainerPathInsideContainers() { + String path = FORM_CONTAINER_PATH + "/container1"; + FormStructureParser formStructureParser = getFormStructureParserUnderTest(path); + assertEquals(FORM_CONTAINER_PATH, formStructureParser.getFormContainerPath()); + + formStructureParser = getFormStructureParserUnderTest(path + "/datepicker1"); + assertEquals(FORM_CONTAINER_PATH, formStructureParser.getFormContainerPath()); + + formStructureParser = getFormStructureParserUnderTest(path + "/container2"); + assertEquals(FORM_CONTAINER_PATH, formStructureParser.getFormContainerPath()); + + formStructureParser = getFormStructureParserUnderTest(path + "/container2/text"); + assertEquals(FORM_CONTAINER_PATH, formStructureParser.getFormContainerPath()); + } + + @Test + void testFormContainerPathForPathOutsideFormContainer() { + String path = JCR_CONTENT_PATH + "/container3"; + FormStructureParser formStructureParser = getFormStructureParserUnderTest(path); + assertNull(formStructureParser.getFormContainerPath()); + + formStructureParser = getFormStructureParserUnderTest(path + "/text1"); + assertNull(formStructureParser.getFormContainerPath()); + } + + private FormStructureParser getFormStructureParserUnderTest(String resourcePath) { + context.currentResource(resourcePath); + MockSlingHttpServletRequest request = context.request(); + return request.getResource().adaptTo(FormStructureParser.class); + } +} diff --git a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/NumberInputImplTest.java b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/NumberInputImplTest.java new file mode 100644 index 0000000000..aff9f9c116 --- /dev/null +++ b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/NumberInputImplTest.java @@ -0,0 +1,280 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import java.util.Collections; +import java.util.Map; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mockito; + +import com.adobe.cq.forms.core.Utils; +import com.adobe.cq.forms.core.components.internal.form.FormConstants; +import com.adobe.cq.forms.core.components.models.form.Base; +import com.adobe.cq.forms.core.components.models.form.Label; +import com.adobe.cq.forms.core.components.models.form.NumberInput; +import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext; +import com.adobe.cq.wcm.style.ComponentStyleInfo; +import io.wcm.testing.mock.aem.junit5.AemContext; +import io.wcm.testing.mock.aem.junit5.AemContextExtension; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; + +@ExtendWith(AemContextExtension.class) +public class NumberInputImplTest { + private static final String BASE = "/form/numberinput"; + private static final String CONTENT_ROOT = "/content"; + private static final String PATH_NUMBER_INPUT = CONTENT_ROOT + "/numberinput"; + + private final AemContext context = FormsCoreComponentTestContext.newAemContext(); + + @BeforeEach + void setUp() { + context.load().json(BASE + FormsCoreComponentTestContext.TEST_CONTENT_JSON, CONTENT_ROOT); + } + + @Test + void testExportedType() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals(FormConstants.RT_FD_FORM_NUMBER_INPUT_V1, numberInput.getExportedType()); + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.getExportedType()).thenCallRealMethod(); + assertEquals("", numberInputMock.getExportedType()); + } + + @Test + void testFieldType() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals(Base.FieldType.NUMBER_INPUT.getValue(), numberInput.getFieldType()); + } + + @Test + void testGetLabel() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals("def", numberInput.getLabel().getValue()); + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.getLabel()).thenCallRealMethod(); + assertEquals(null, numberInputMock.getLabel()); + + Label labelMock = Mockito.mock(Label.class); + Mockito.when(labelMock.isRichText()).thenCallRealMethod(); + assertEquals(false, labelMock.isRichText()); + Mockito.when(labelMock.getValue()).thenCallRealMethod(); + assertEquals(null, labelMock.getValue()); + Mockito.when(labelMock.isVisible()).thenCallRealMethod(); + assertEquals(true, labelMock.isVisible()); + } + + @Test + void testGetName() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals("abc", numberInput.getName()); + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.getName()).thenCallRealMethod(); + assertEquals(null, numberInputMock.getName()); + } + + @Test + void testGetDataRef() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals("a.b", numberInput.getDataRef()); + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.getDataRef()).thenCallRealMethod(); + assertEquals(null, numberInputMock.getDataRef()); + } + + @Test + void testGetDescription() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals("dummy", numberInput.getDescription()); + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.getDescription()).thenCallRealMethod(); + assertEquals(null, numberInputMock.getDescription()); + } + + @Test + void testGetScreenReaderText() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals("'Custom screen reader text'", numberInput.getScreenReaderText()); + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.getScreenReaderText()).thenCallRealMethod(); + assertEquals(null, numberInputMock.getScreenReaderText()); + } + + @Test + void testIsVisible() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals(false, numberInput.isVisible()); + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.isVisible()).thenCallRealMethod(); + assertEquals(true, numberInputMock.isVisible()); + } + + @Test + void testIsEnabled() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals(true, numberInput.isEnabled()); + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.isEnabled()).thenCallRealMethod(); + assertEquals(true, numberInputMock.isEnabled()); + } + + @Test + void testIsReadOnly() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals(false, numberInput.isReadOnly()); + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.isReadOnly()).thenCallRealMethod(); + assertEquals(false, numberInputMock.isReadOnly()); + } + + @Test + void testGetPlaceHolder() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals(null, numberInput.getPlaceHolder()); + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.getPlaceHolder()).thenCallRealMethod(); + assertEquals(null, numberInputMock.getPlaceHolder()); + } + + @Test + void testGetDisplayFormat() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals(null, numberInput.getDisplayFormat()); + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.getDisplayFormat()).thenCallRealMethod(); + assertEquals(null, numberInputMock.getDisplayFormat()); + } + + @Test + void testGetEditFormat() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals(null, numberInput.getEditFormat()); + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.getEditFormat()).thenCallRealMethod(); + assertEquals(null, numberInputMock.getEditFormat()); + } + + @Test + void testGetDataFormat() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals(null, numberInput.getDataFormat()); + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.getDataFormat()).thenCallRealMethod(); + assertEquals(null, numberInputMock.getDataFormat()); + } + + @Test + void testGetTooltip() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals("test-short-description", numberInput.getTooltip()); + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.getTooltip()).thenCallRealMethod(); + assertEquals(null, numberInputMock.getTooltip()); + } + + @Test + void testGetConstraintMessages() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + Map constraintsMessages = numberInput.getConstraintMessages(); + assertEquals(constraintsMessages.get(Base.ConstraintType.TYPE), "incorrect type"); + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.getConstraintMessages()).thenCallRealMethod(); + assertEquals(Collections.emptyMap(), numberInputMock.getConstraintMessages()); + } + + @Test + void testJSONExport() throws Exception { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + Utils.testJSONExport(numberInput, Utils.getTestExporterJSONPath(BASE, PATH_NUMBER_INPUT)); + } + + @Test + void testGetProperties() throws Exception { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + Map properties = numberInput.getProperties(); + assertFalse(properties.isEmpty()); + // get custom properties of "af:layout" + Map customProperties = (Map) properties.get(Base.CUSTOM_PROPERTY_WRAPPER); + assertFalse((boolean) customProperties.get("tooltipVisible")); + } + + @Test + void testGetProperties_should_return_empty_if_no_custom_properties() { + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.getProperties()).thenCallRealMethod(); + assertTrue(numberInputMock.getProperties().isEmpty()); + } + + @Test + void testGetShortDescription() { + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.getTooltip()).thenCallRealMethod(); + assertEquals(null, numberInputMock.getTooltip()); + } + + @Test + void testIsShortDescriptionVisible() { + NumberInput numberInputMock = Mockito.mock(NumberInput.class); + Mockito.when(numberInputMock.isTooltipVisible()).thenCallRealMethod(); + assertEquals(false, numberInputMock.isTooltipVisible()); + } + + @Test + void testGetMinimum() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals(10000L, numberInput.getMinimum().longValue()); + } + + @Test + void testGetMaximum() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals(2000000, numberInput.getMaximum().longValue()); + } + + @Test + void testGetExclusiveMinimum() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals(10002L, numberInput.getExclusiveMinimum().longValue()); + } + + @Test + void testGetExclusiveMaximum() { + NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT, NumberInput.class, context); + assertEquals(2000002, numberInput.getExclusiveMaximum().longValue()); + } + + @Test + void testStyleSystemClasses() { + ComponentStyleInfo componentStyleInfoMock = mock(ComponentStyleInfo.class); + Resource resource = spy(context.resourceResolver().getResource(PATH_NUMBER_INPUT)); + Mockito.doReturn(componentStyleInfoMock).when(resource).adaptTo(ComponentStyleInfo.class); + MockSlingHttpServletRequest request = context.request(); + request.setResource(resource); + Mockito.doReturn("mystyle").when(componentStyleInfoMock).getAppliedCssClasses(); + NumberInput numberInput = request.adaptTo(NumberInput.class); + String appliedCssClasses = numberInput.getAppliedCssClasses(); + assertEquals("mystyle", appliedCssClasses); + } +} diff --git a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PanelContainerImplTest.java b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PanelContainerImplTest.java new file mode 100644 index 0000000000..31fa9be48f --- /dev/null +++ b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PanelContainerImplTest.java @@ -0,0 +1,118 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + +import org.apache.sling.api.resource.Resource; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mockito; + +import com.adobe.cq.export.json.SlingModelFilter; +import com.adobe.cq.forms.core.Utils; +import com.adobe.cq.forms.core.components.internal.form.FormConstants; +import com.adobe.cq.forms.core.components.models.form.Panel; +import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext; +import com.day.cq.wcm.api.NameConstants; +import com.day.cq.wcm.msm.api.MSMNameConstants; +import io.wcm.testing.mock.aem.junit5.AemContext; +import io.wcm.testing.mock.aem.junit5.AemContextExtension; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +@ExtendWith(AemContextExtension.class) +public class PanelContainerImplTest { + private static final String BASE = "/form/panelcontainer"; + private static final String CONTENT_ROOT = "/content"; + private static final String PATH_PANEL = CONTENT_ROOT + "/panelcontainer"; + private static final String PATH_ARRAY_PANEL = CONTENT_ROOT + "/array-panelcontainer"; + private static final String PATH_RULES_PANEL = CONTENT_ROOT + "/rules-panelcontainer"; + private final AemContext context = FormsCoreComponentTestContext.newAemContext(); + + @BeforeEach + void setUp() { + context.load().json(BASE + FormsCoreComponentTestContext.TEST_CONTENT_JSON, CONTENT_ROOT); + context.registerService(SlingModelFilter.class, new SlingModelFilter() { + + private final Set IGNORED_NODE_NAMES = new HashSet() { + { + add(NameConstants.NN_RESPONSIVE_CONFIG); + add(MSMNameConstants.NT_LIVE_SYNC_CONFIG); + add("cq:annotations"); + } + }; + + @Override + public Map filterProperties(Map map) { + return map; + } + + @Override + public Iterable filterChildResources(Iterable childResources) { + return StreamSupport + .stream(childResources.spliterator(), false) + .filter(r -> !IGNORED_NODE_NAMES.contains(r.getName())) + .collect(Collectors.toList()); + } + }); + } + + @Test + void testExportedType() throws Exception { + Panel panel = Utils.getComponentUnderTest(PATH_PANEL, Panel.class, context); + assertEquals(FormConstants.RT_FD_FORM_PANEL_CONTAINER_V1, panel.getExportedType()); + Panel panelMock = Mockito.mock(Panel.class); + Mockito.when(panelMock.getExportedType()).thenCallRealMethod(); + assertEquals("", panelMock.getExportedType()); + } + + @Test + void testGetId() throws Exception { + Panel panel = Utils.getComponentUnderTest(PATH_PANEL, Panel.class, context); + assertNotNull(panel.getId()); + } + + @Test + void testGetName() throws Exception { + Panel panel = Utils.getComponentUnderTest(PATH_PANEL, Panel.class, context); + assertEquals("abc", panel.getName()); + } + + @Test + void testJSONExport() throws Exception { + Panel panel = Utils.getComponentUnderTest(PATH_PANEL, Panel.class, context); + Utils.testJSONExport(panel, Utils.getTestExporterJSONPath(BASE, PATH_PANEL)); + } + + @Test + void testArrayPanelJSONExport() throws Exception { + Panel panel = Utils.getComponentUnderTest(PATH_ARRAY_PANEL, Panel.class, context); + Utils.testJSONExport(panel, Utils.getTestExporterJSONPath(BASE, PATH_ARRAY_PANEL)); + } + + @Test + void testRulesPanelJSONExport() throws Exception { + Panel panel = Utils.getComponentUnderTest(PATH_RULES_PANEL, Panel.class, context); + Utils.testJSONExport(panel, Utils.getTestExporterJSONPath(BASE, PATH_RULES_PANEL)); + } +} diff --git a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PanelImplTest.java b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PanelImplTest.java new file mode 100644 index 0000000000..af79840d2e --- /dev/null +++ b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/PanelImplTest.java @@ -0,0 +1,119 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.internal.models.v1.form; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + +import org.apache.sling.api.resource.Resource; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mockito; + +import com.adobe.cq.export.json.SlingModelFilter; +import com.adobe.cq.forms.core.Utils; +import com.adobe.cq.forms.core.components.internal.form.FormConstants; +import com.adobe.cq.forms.core.components.models.form.Panel; +import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext; +import com.day.cq.wcm.api.NameConstants; +import com.day.cq.wcm.msm.api.MSMNameConstants; +import io.wcm.testing.mock.aem.junit5.AemContext; +import io.wcm.testing.mock.aem.junit5.AemContextExtension; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +@ExtendWith(AemContextExtension.class) +public class PanelImplTest { + private static final String BASE = "/form/panel"; + private static final String CONTENT_ROOT = "/content"; + private static final String PATH_PANEL = CONTENT_ROOT + "/panel"; + private static final String PATH_ARRAY_PANEL = CONTENT_ROOT + "/array-panel"; + private static final String PATH_RULES_PANEL = CONTENT_ROOT + "/rules-panel"; + private final AemContext context = FormsCoreComponentTestContext.newAemContext(); + + @BeforeEach + void setUp() { + context.load().json(BASE + FormsCoreComponentTestContext.TEST_CONTENT_JSON, CONTENT_ROOT); + context.registerService(SlingModelFilter.class, new SlingModelFilter() { + + private final Set IGNORED_NODE_NAMES = new HashSet() { + { + add(NameConstants.NN_RESPONSIVE_CONFIG); + add(MSMNameConstants.NT_LIVE_SYNC_CONFIG); + add("cq:annotations"); + } + }; + + @Override + public Map filterProperties(Map map) { + return map; + } + + @Override + public Iterable filterChildResources(Iterable childResources) { + return StreamSupport + .stream(childResources.spliterator(), false) + .filter(r -> !IGNORED_NODE_NAMES.contains(r.getName())) + .collect(Collectors.toList()); + } + }); + } + + @Test + void testExportedType() throws Exception { + Panel panel = Utils.getComponentUnderTest(PATH_PANEL, Panel.class, context); + assertEquals(FormConstants.RT_FD_FORM_PANEL_V1, panel.getExportedType()); + Panel panelMock = Mockito.mock(Panel.class); + Mockito.when(panelMock.getExportedType()).thenCallRealMethod(); + assertEquals("", panelMock.getExportedType()); + } + + @Test + void testGetId() throws Exception { + Panel panel = Utils.getComponentUnderTest(PATH_PANEL, Panel.class, context); + assertNotNull(panel.getId()); + } + + @Test + void testGetName() throws Exception { + Panel panel = Utils.getComponentUnderTest(PATH_PANEL, Panel.class, context); + ; + assertEquals("abc", panel.getName()); + } + + @Test + void testJSONExport() throws Exception { + Panel panel = Utils.getComponentUnderTest(PATH_PANEL, Panel.class, context); + Utils.testJSONExport(panel, Utils.getTestExporterJSONPath(BASE, PATH_PANEL)); + } + + @Test + void testArrayPanelJSONExport() throws Exception { + Panel panel = Utils.getComponentUnderTest(PATH_ARRAY_PANEL, Panel.class, context); + Utils.testJSONExport(panel, Utils.getTestExporterJSONPath(BASE, PATH_ARRAY_PANEL)); + } + + @Test + void testRulesPanelJSONExport() throws Exception { + Panel panel = Utils.getComponentUnderTest(PATH_RULES_PANEL, Panel.class, context); + Utils.testJSONExport(panel, Utils.getTestExporterJSONPath(BASE, PATH_RULES_PANEL)); + } +} diff --git a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextInputImplTest.java b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextInputImplTest.java index 0c96e36aca..673b3a06a1 100644 --- a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextInputImplTest.java +++ b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextInputImplTest.java @@ -27,9 +27,7 @@ import com.adobe.cq.forms.core.Utils; import com.adobe.cq.forms.core.components.internal.form.FormConstants; -import com.adobe.cq.forms.core.components.models.form.Base; -import com.adobe.cq.forms.core.components.models.form.Label; -import com.adobe.cq.forms.core.components.models.form.TextInput; +import com.adobe.cq.forms.core.components.models.form.*; import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext; import com.adobe.cq.wcm.style.ComponentStyleInfo; import io.wcm.testing.mock.aem.junit5.AemContext; @@ -38,6 +36,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -47,6 +46,9 @@ public class TextInputImplTest { private static final String CONTENT_ROOT = "/content"; private static final String PATH_TEXTINPUT_1 = CONTENT_ROOT + "/textinput"; private static final String PATH_TEXTINPUT_2 = CONTENT_ROOT + "/multiline-textinput"; + private static final String PATH_NUMBER_TEXTINPUT = CONTENT_ROOT + "/number-textinput"; + + private static final String PATH_FORMAT_TEXTINPUT = CONTENT_ROOT + "/textinput-format"; private final AemContext context = FormsCoreComponentTestContext.newAemContext(); @@ -57,7 +59,7 @@ void setUp() { @Test void testExportedType() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); assertEquals(FormConstants.RT_FD_FORM_TEXT_V1, textInput.getExportedType()); TextInput textInputMock = Mockito.mock(TextInput.class); Mockito.when(textInputMock.getExportedType()).thenCallRealMethod(); @@ -66,16 +68,13 @@ void testExportedType() { @Test void testFieldType() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); assertEquals(Base.FieldType.TEXT_INPUT.getValue(), textInput.getFieldType()); - TextInput textInputMock = Mockito.mock(TextInput.class); - Mockito.when(textInputMock.getFieldType()).thenCallRealMethod(); - assertEquals(Base.FieldType.TEXT_INPUT.getValue(), textInputMock.getFieldType()); } @Test void testGetLabel() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); assertEquals("def", textInput.getLabel().getValue()); TextInput textInputMock = Mockito.mock(TextInput.class); Mockito.when(textInputMock.getLabel()).thenCallRealMethod(); @@ -92,7 +91,7 @@ void testGetLabel() { @Test void testGetName() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); assertEquals("abc", textInput.getName()); TextInput textInputMock = Mockito.mock(TextInput.class); Mockito.when(textInputMock.getName()).thenCallRealMethod(); @@ -101,7 +100,7 @@ void testGetName() { @Test void testGetDataRef() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); assertEquals("a.b", textInput.getDataRef()); TextInput textInputMock = Mockito.mock(TextInput.class); Mockito.when(textInputMock.getDataRef()).thenCallRealMethod(); @@ -110,25 +109,49 @@ void testGetDataRef() { @Test void testGetDescription() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); assertEquals("dummy", textInput.getDescription()); TextInput textInputMock = Mockito.mock(TextInput.class); Mockito.when(textInputMock.getDescription()).thenCallRealMethod(); assertEquals(null, textInputMock.getDescription()); } + @Test + void testGetDefault() { + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); + assertArrayEquals(new String[] { "abc" }, textInput.getDefault()); + TextInput textInputMock = Mockito.mock(TextInput.class); + Mockito.when(textInputMock.getDefault()).thenCallRealMethod(); + assertEquals(null, textInputMock.getDefault()); + } + + @Test + void testGetNumberDefault() { + TextInput numberTextInput = Utils.getComponentUnderTest(PATH_NUMBER_TEXTINPUT, TextInput.class, context); + assertArrayEquals(new Long[] { 150L }, numberTextInput.getDefault()); + } + @Test void testGetScreenReaderText() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); - assertEquals("Custom screen reader text", textInput.getScreenReaderText()); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); + assertEquals("'Custom screen reader text'", textInput.getScreenReaderText()); TextInput textInputMock = Mockito.mock(TextInput.class); Mockito.when(textInputMock.getScreenReaderText()).thenCallRealMethod(); assertEquals(null, textInputMock.getScreenReaderText()); } + @Test + void testGetHtmlScreenReaderText() { + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); + assertEquals("Custom screen reader text", textInput.getHtmlScreenReaderText()); + TextInput textInputMock = Mockito.mock(TextInput.class); + Mockito.when(textInputMock.getHtmlScreenReaderText()).thenCallRealMethod(); + assertEquals(null, textInputMock.getHtmlScreenReaderText()); + } + @Test void testIsVisible() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); assertEquals(false, textInput.isVisible()); TextInput textInputMock = Mockito.mock(TextInput.class); Mockito.when(textInputMock.isVisible()).thenCallRealMethod(); @@ -137,7 +160,7 @@ void testIsVisible() { @Test void testIsEnabled() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); assertEquals(true, textInput.isEnabled()); TextInput textInputMock = Mockito.mock(TextInput.class); Mockito.when(textInputMock.isEnabled()).thenCallRealMethod(); @@ -146,7 +169,7 @@ void testIsEnabled() { @Test void testIsReadOnly() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); assertEquals(false, textInput.isReadOnly()); TextInput textInputMock = Mockito.mock(TextInput.class); Mockito.when(textInputMock.isReadOnly()).thenCallRealMethod(); @@ -155,7 +178,7 @@ void testIsReadOnly() { @Test void testIsMultiLine() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); assertEquals(false, textInput.isMultiLine()); TextInput textInputMock = Mockito.mock(TextInput.class); Mockito.when(textInputMock.isMultiLine()).thenCallRealMethod(); @@ -164,7 +187,7 @@ void testIsMultiLine() { @Test void testGetPlaceHolder() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); assertEquals(null, textInput.getPlaceHolder()); TextInput textInputMock = Mockito.mock(TextInput.class); Mockito.when(textInputMock.getPlaceHolder()).thenCallRealMethod(); @@ -173,7 +196,7 @@ void testGetPlaceHolder() { @Test void testGetDisplayFormat() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); assertEquals(null, textInput.getDisplayFormat()); TextInput textInputMock = Mockito.mock(TextInput.class); Mockito.when(textInputMock.getDisplayFormat()).thenCallRealMethod(); @@ -182,7 +205,7 @@ void testGetDisplayFormat() { @Test void testGetEditFormat() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); assertEquals(null, textInput.getEditFormat()); TextInput textInputMock = Mockito.mock(TextInput.class); Mockito.when(textInputMock.getEditFormat()).thenCallRealMethod(); @@ -191,42 +214,85 @@ void testGetEditFormat() { @Test void testGetDataFormat() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); assertEquals(null, textInput.getDataFormat()); TextInput textInputMock = Mockito.mock(TextInput.class); Mockito.when(textInputMock.getDataFormat()).thenCallRealMethod(); assertEquals(null, textInputMock.getDataFormat()); } + @Test + void testGetType() { + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); + assertEquals(BaseConstraint.Type.STRING, textInput.getType()); + TextInput textInputMock = Mockito.mock(TextInput.class); + Mockito.when(textInputMock.getType()).thenCallRealMethod(); + assertEquals(BaseConstraint.Type.STRING, textInputMock.getType()); + } + + @Test + void testGetNumberType() { + TextInput numberTextInput = Utils.getComponentUnderTest(PATH_NUMBER_TEXTINPUT, TextInput.class, context); + assertEquals(BaseConstraint.Type.NUMBER, numberTextInput.getType()); + } + + @Test + void testGetMaximum() { + TextInput numberTextInput = Utils.getComponentUnderTest(PATH_NUMBER_TEXTINPUT, TextInput.class, context); + assertEquals(100, numberTextInput.getMaximum().intValue()); + } + + @Test + void testGetMinimum() { + TextInput numberTextInput = Utils.getComponentUnderTest(PATH_NUMBER_TEXTINPUT, TextInput.class, context); + assertEquals(10, numberTextInput.getMinimum().intValue()); + } + + @Test + void testGetTooltip() { + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); + assertEquals("test-short-description", textInput.getTooltip()); + TextInput textInputMock = Mockito.mock(TextInput.class); + Mockito.when(textInputMock.getTooltip()).thenCallRealMethod(); + assertEquals(null, textInputMock.getTooltip()); + } + @Test void testGetConstraintMessages() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); - Map constraintsMessages = textInput.getConstraintsMessages(); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); + Map constraintsMessages = textInput.getConstraintMessages(); assertEquals(constraintsMessages.get(Base.ConstraintType.TYPE), "incorrect type"); TextInput textInputMock = Mockito.mock(TextInput.class); - Mockito.when(textInputMock.getConstraintsMessages()).thenCallRealMethod(); - assertEquals(Collections.emptyMap(), textInputMock.getConstraintsMessages()); + Mockito.when(textInputMock.getConstraintMessages()).thenCallRealMethod(); + assertEquals(Collections.emptyMap(), textInputMock.getConstraintMessages()); } @Test void testJSONExport() throws Exception { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); Utils.testJSONExport(textInput, Utils.getTestExporterJSONPath(BASE, PATH_TEXTINPUT_1)); } @Test void testMultiLineJSONExport() throws Exception { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_2); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_2, TextInput.class, context); Utils.testJSONExport(textInput, Utils.getTestExporterJSONPath(BASE, PATH_TEXTINPUT_2)); } + @Test + void testFormatJSONExport() throws Exception { + TextInput textInput = Utils.getComponentUnderTest(PATH_FORMAT_TEXTINPUT, TextInput.class, context); + Utils.testJSONExport(textInput, Utils.getTestExporterJSONPath(BASE, PATH_FORMAT_TEXTINPUT)); + } + @Test void testGetProperties() throws Exception { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); Map properties = textInput.getProperties(); assertFalse(properties.isEmpty()); - assertEquals("test-short-description", String.valueOf(properties.get("shortDescription"))); - assertFalse((boolean) properties.get("shortDescriptionVisible")); + // get custom properties of "af:layout" + Map customProperties = (Map) properties.get(Base.CUSTOM_PROPERTY_WRAPPER); + assertFalse((boolean) customProperties.get("tooltipVisible")); } @Test @@ -239,33 +305,25 @@ void testGetProperties_should_return_empty_if_no_custom_properties() { @Test void testGetShortDescription() { TextInput textInputMock = Mockito.mock(TextInput.class); - Mockito.when(textInputMock.getShortDescription()).thenCallRealMethod(); - assertEquals(null, textInputMock.getShortDescription()); + Mockito.when(textInputMock.getTooltip()).thenCallRealMethod(); + assertEquals(null, textInputMock.getTooltip()); } @Test void testIsShortDescriptionVisible() { TextInput textInputMock = Mockito.mock(TextInput.class); - Mockito.when(textInputMock.isShortDescriptionVisible()).thenCallRealMethod(); - assertEquals(false, textInputMock.isShortDescriptionVisible()); - } - - @Test - void testIsAutoComplete() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); - assertEquals(false, textInput.isAutoComplete()); - TextInput textInputMock = Mockito.mock(TextInput.class); - Mockito.when(textInputMock.isAutoComplete()).thenCallRealMethod(); - assertEquals(false, textInputMock.isAutoComplete()); + Mockito.when(textInputMock.isTooltipVisible()).thenCallRealMethod(); + assertEquals(false, textInputMock.isTooltipVisible()); } @Test - void testGetAutofillFieldKeyword() { - TextInput textInput = getTextInputUnderTest(PATH_TEXTINPUT_1); - assertEquals(null, textInput.getAutofillFieldKeyword()); + void testGetAutoComplete() { + TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_1, TextInput.class, context); + ; + assertEquals(null, textInput.getAutoComplete()); TextInput textInputMock = Mockito.mock(TextInput.class); - Mockito.when(textInputMock.getAutofillFieldKeyword()).thenCallRealMethod(); - assertEquals(null, textInputMock.getAutofillFieldKeyword()); + Mockito.when(textInputMock.getAutoComplete()).thenCallRealMethod(); + assertEquals(null, textInputMock.getAutoComplete()); } @Test @@ -276,14 +334,8 @@ void testStyleSystemClasses() { MockSlingHttpServletRequest request = context.request(); request.setResource(resource); Mockito.doReturn("mystyle").when(componentStyleInfoMock).getAppliedCssClasses(); - TextInput textInput = request.adaptTo(TextInput.class); + TextInput textInput = context.currentResource().adaptTo(TextInput.class); String appliedCssClasses = textInput.getAppliedCssClasses(); assertEquals("mystyle", appliedCssClasses); } - - private TextInput getTextInputUnderTest(String resourcePath) { - context.currentResource(resourcePath); - MockSlingHttpServletRequest request = context.request(); - return request.adaptTo(TextInput.class); - } } diff --git a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImplTest.java b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImplTest.java index 6d1b349ada..39cb26ff4e 100644 --- a/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImplTest.java +++ b/bundles/core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImplTest.java @@ -15,23 +15,33 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ package com.adobe.cq.forms.core.components.internal.models.v2.form; +import java.util.HashMap; import java.util.HashSet; +import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.StreamSupport; import org.apache.sling.api.resource.Resource; +import org.apache.sling.i18n.ResourceBundleProvider; +import org.apache.sling.testing.mock.sling.MockResourceBundle; +import org.apache.sling.testing.mock.sling.MockResourceBundleProvider; import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; +import com.adobe.aemds.guide.service.GuideLocalizationService; +import com.adobe.aemds.guide.utils.GuideConstants; import com.adobe.cq.export.json.SlingModelFilter; import com.adobe.cq.forms.core.Utils; import com.adobe.cq.forms.core.components.models.form.FormContainer; +import com.adobe.cq.forms.core.components.models.form.TextInput; import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext; +import com.day.cq.i18n.I18n; import com.day.cq.wcm.api.NameConstants; import com.day.cq.wcm.msm.api.MSMNameConstants; import io.wcm.testing.mock.aem.junit5.AemContext; @@ -43,14 +53,21 @@ @ExtendWith(AemContextExtension.class) public class FormContainerImplTest { private static final String BASE = "/form/formcontainer"; - private static final String CONTENT_ROOT = "/content"; + private static final String CONTENT_PAGE_ROOT = "/content/forms/af/demo"; + 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 LIB_FORM_CONTAINER = "/libs/core/fd/components/form/container/v2/container"; private final AemContext context = FormsCoreComponentTestContext.newAemContext(); @BeforeEach void setUp() { - context.load().json(BASE + FormsCoreComponentTestContext.TEST_CONTENT_JSON, CONTENT_ROOT); + context.load().json(BASE + "/test-localization-content.json", CONTENT_DAM_ROOT); // required for localization + context.load().json(BASE + "/test-page-content.json", CONTENT_PAGE_ROOT); // required for localization since we traverse the + // resource up to find page + context.load().json(BASE + "/test-lib-form-container.json", LIB_FORM_CONTAINER); // required since v2 container resource type should + // be v1 for localization to work context.registerService(SlingModelFilter.class, new SlingModelFilter() { private final Set IGNORED_NODE_NAMES = new HashSet() { @@ -78,7 +95,7 @@ public Iterable filterChildResources(Iterable childResources @Test void testExportedType() throws Exception { - FormContainer formContainer = getFormContainerUnderTest(PATH_FORM_1); + FormContainer formContainer = Utils.getComponentUnderTest(PATH_FORM_1, FormContainer.class, context); assertEquals("core/fd/components/form/container/v2/container", formContainer.getExportedType()); FormContainer formContainerMock = Mockito.mock(FormContainer.class); Mockito.when(formContainerMock.getExportedType()).thenCallRealMethod(); @@ -87,31 +104,76 @@ void testExportedType() throws Exception { @Test void testGetId() throws Exception { - FormContainer formContainer = getFormContainerUnderTest(PATH_FORM_1); + FormContainer formContainer = Utils.getComponentUnderTest(PATH_FORM_1, FormContainer.class, context); assertNotNull(formContainer.getId()); } @Test void testGetAction() throws Exception { - FormContainer formContainer = getFormContainerUnderTest(PATH_FORM_1); + FormContainer formContainer = Utils.getComponentUnderTest(PATH_FORM_1, FormContainer.class, context); assertEquals("/a/b", formContainer.getMetaData().getAction()); } @Test void testGetDataUrl() throws Exception { - FormContainer formContainer = getFormContainerUnderTest(PATH_FORM_1); + FormContainer formContainer = Utils.getComponentUnderTest(PATH_FORM_1, FormContainer.class, context); assertEquals("/c/d", formContainer.getMetaData().getDataUrl()); } + @Test + void testGetLocalizedValue() throws Exception { + FormContainer formContainer = getFormContainerWithLocaleUnderTest(PATH_FORM_1); + TextInput textInput = (TextInput) formContainer.getItems().stream() + .filter(Objects::nonNull) + .findFirst() + .orElse(null); + assertEquals("dummy 1", textInput.getDescription()); + } + + @Test + void testFormContainerWithI18nSetter() throws Exception { + FormContainer formContainer = Utils.getComponentUnderTest(PATH_FORM_1, FormContainer.class, context); + MockResourceBundleProvider bundleProvider = (MockResourceBundleProvider) context.getService(ResourceBundleProvider.class); + MockResourceBundle resourceBundle = (MockResourceBundle) bundleProvider.getResourceBundle( + "/content/dam/formsanddocuments/demo/jcr:content/dictionary", new Locale("de")); + resourceBundle.putAll(new HashMap() { + { + put("guideContainer##textinput##description##5648", "dummy 1"); + } + }); + I18n i18n = new I18n(resourceBundle); + formContainer.setI18n(i18n); + TextInput textInput = (TextInput) formContainer.getItems().stream() + .filter(Objects::nonNull) + .findFirst() + .orElse(null); + assertEquals("dummy", textInput.getDescription()); // just a dummy test to make sure i18n is set correctly in the resource hierarchy + } + @Test void testJSONExport() throws Exception { - FormContainer formContainer = getFormContainerUnderTest(PATH_FORM_1); + FormContainer formContainer = Utils.getComponentUnderTest(PATH_FORM_1, FormContainer.class, context); Utils.testJSONExport(formContainer, Utils.getTestExporterJSONPath(BASE, PATH_FORM_1)); } - private FormContainer getFormContainerUnderTest(String resourcePath) throws Exception { + private FormContainer getFormContainerWithLocaleUnderTest(String resourcePath) throws Exception { context.currentResource(resourcePath); + // added this since AF API expects this to be present + GuideLocalizationService guideLocalizationService = context.registerService(GuideLocalizationService.class, + Mockito.mock(GuideLocalizationService.class)); + Mockito.when(guideLocalizationService.getSupportedLocales()).thenReturn(new String[] { "en", "de" }); + MockResourceBundleProvider bundleProvider = (MockResourceBundleProvider) context.getService(ResourceBundleProvider.class); + MockResourceBundle resourceBundle = (MockResourceBundle) bundleProvider.getResourceBundle( + "/content/dam/formsanddocuments/demo/jcr:content/dictionary", new Locale("de")); + resourceBundle.putAll(new HashMap() { + { + put("guideContainer##textinput##description##5648", "dummy 1"); + } + }); MockSlingHttpServletRequest request = context.request(); + Map paramMap = new HashMap<>(); + paramMap.put(GuideConstants.AF_LANGUAGE_PARAMETER, "de"); + request.setParameterMap(paramMap); return request.adaptTo(FormContainer.class); } } diff --git a/bundles/core/src/test/resources/form/checkbox/exporter-checkbox.json b/bundles/core/src/test/resources/form/checkbox/exporter-checkbox.json new file mode 100644 index 0000000000..297dd3bfe3 --- /dev/null +++ b/bundles/core/src/test/resources/form/checkbox/exporter-checkbox.json @@ -0,0 +1,32 @@ +{ + "id": "checkbox-42948c9a6c", + "required": false, + "name": "abc", + "visible": false, + "enabled": true, + "readOnly": false, + "fieldType": "checkbox", + "description" : "dummy", + "tooltip": "test-short-description", + "properties": { + "af:layout" : { + "tooltipVisible": false, + "orientation" : "horizontal" + } + }, + "enforceEnum":false, + "enum" : [true, false], + "enumNames" : ["yes", "no"], + "label": { + "visible": true, + "value": "def", + "richText": false + }, + "dataRef":"a.b", + "screenReaderText": "'Custom screen reader text'", + "constraintMessages":{ + "type":"incorrect type" + }, + "type": "boolean", + ":type": "core/fd/components/form/checkbox/v1/checkbox" +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/checkbox/test-content.json b/bundles/core/src/test/resources/form/checkbox/test-content.json new file mode 100644 index 0000000000..4b2ea5c719 --- /dev/null +++ b/bundles/core/src/test/resources/form/checkbox/test-content.json @@ -0,0 +1,26 @@ +{ + "checkbox" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/checkbox/v1/checkbox", + "name" : "abc", + "jcr:title" : "def", + "hideTitle" : false, + "description" : "dummy", + "visible" : false, + "assistPriority" : "custom", + "dataRef" : "a.b", + "custom" : "Custom screen reader text", + "typeMessage" : "incorrect type", + "tooltip": "test-short-description", + "type" : "boolean", + "enum" : [true, false], + "fieldType": "checkbox", + "enumNames" : ["yes", "no"], + "fd:rules" : { + "jcr:primaryType": "nt:unstructured" + }, + "fd:events" : { + "jcr:primaryType": "nt:unstructured" + } + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/checkboxgroup/exporter-checkboxgroup.json b/bundles/core/src/test/resources/form/checkboxgroup/exporter-checkboxgroup.json new file mode 100644 index 0000000000..c7b30b2f4e --- /dev/null +++ b/bundles/core/src/test/resources/form/checkboxgroup/exporter-checkboxgroup.json @@ -0,0 +1,39 @@ +{ + "id": "checkboxgroup-93e681dfb9", + "required": false, + "name": "abc", + "visible": false, + "enabled": true, + "readOnly": false, + "fieldType": "checkbox-group", + "description" : "dummy", + "tooltip": "test-short-description", + "properties": { + "af:layout" : { + "tooltipVisible": false + } + }, + "enforceEnum":true, + "enum" : [0, 1, 2], + "enumNames" : ["m", "f", "o"], + "label": { + "visible": true, + "value": "def", + "richText": false + }, + "dataRef":"a.b", + "screenReaderText": "'Custom screen reader text'", + "constraintMessages":{ + "type":"incorrect type" + }, + "default" : [0, 1], + "type": "number[]", + "minItems" : 1, + "maxItems" : 2, + ":type": "core/fd/components/form/checkboxgroup/v1/checkboxgroup", + "events" : { + "change" : ["e1", "e2"], + "click": ["e1"], + "custom:event" : ["e2"] + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/checkboxgroup/test-content.json b/bundles/core/src/test/resources/form/checkboxgroup/test-content.json new file mode 100644 index 0000000000..feacf7d40f --- /dev/null +++ b/bundles/core/src/test/resources/form/checkboxgroup/test-content.json @@ -0,0 +1,49 @@ +{ + "checkboxgroup": { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType": "core/fd/components/form/checkboxgroup/v1/checkboxgroup", + "name": "abc", + "jcr:title": "def", + "hideTitle": false, + "description": "dummy", + "visible": false, + "assistPriority": "custom", + "dataRef": "a.b", + "custom": "Custom screen reader text", + "fieldType": "checkbox-group", + "typeMessage": "incorrect type", + "tooltip": "test-short-description", + "type": "number[]", + "multiSelect": true, + "default": [ + 0, + 1 + ], + "enum": [ + 0, + 1, + 2 + ], + "enforceEnum" : true, + "enumNames": [ + "m", + "f", + "o" + ], + "minItems": 1, + "maxItems": 2, + "fd:rules" : { + "xyz" : "abcd", + "visible" : 1, + "jcr:primaryType": "nt:unstructured" + }, + "fd:events" : { + "jcr:primaryType": "nt:unstructured", + "initialize" : 1, + "event1" : "invalid", + "change" : ["e1", "e2"], + "click": "e1", + "custom_event" : "e2" + } + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/datepicker/exporter-datepicker-message.json b/bundles/core/src/test/resources/form/datepicker/exporter-datepicker-message.json new file mode 100644 index 0000000000..536a486201 --- /dev/null +++ b/bundles/core/src/test/resources/form/datepicker/exporter-datepicker-message.json @@ -0,0 +1,42 @@ +{ + "id": "datepicker-fffa242824", + "required": false, + "name": "abc", + "visible": false, + "enabled": true, + "readOnly": false, + "fieldType": "date-input", + "description" : "dummy", + "tooltip": "test-short-description", + "properties": { + "af:layout" : { + "tooltipVisible": false + } + }, + "label": { + "visible": true, + "value": "def", + "richText": false + }, + "dataRef":"a.b", + "screenReaderText": "'Custom screen reader text'", + "constraintMessages":{ + "type":"incorrect type", + "minimum": "Date should be greater than 4th Feb 2022", + "maximum": "Date should be less than 9th Feb 2022" + }, + "type": "string", + "format": "date", + "minimum": "2022-02-04", + "exclusiveMinimum": "2022-02-05", + "exclusiveMaximum": "2022-02-08", + "maximum": "2022-02-09", + "default" : "2022-02-07", + ":type": "core/fd/components/form/datepicker/v1/datepicker", + "rules" : { + "visible" : "true()", + "value" : "false()", + "label" : "{value : 'some label'}", + "enabled" : "true()" + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/datepicker/exporter-datepicker.json b/bundles/core/src/test/resources/form/datepicker/exporter-datepicker.json new file mode 100644 index 0000000000..f57aed86b0 --- /dev/null +++ b/bundles/core/src/test/resources/form/datepicker/exporter-datepicker.json @@ -0,0 +1,40 @@ +{ + "id": "datepicker-00447787e6", + "required": false, + "name": "abc", + "visible": false, + "enabled": true, + "readOnly": false, + "fieldType": "date-input", + "description" : "dummy", + "tooltip": "test-short-description", + "properties": { + "af:layout" : { + "tooltipVisible": false + } + }, + "label": { + "visible": true, + "value": "def", + "richText": false + }, + "dataRef":"a.b", + "screenReaderText": "'Custom screen reader text'", + "constraintMessages":{ + "type":"incorrect type" + }, + "type": "string", + "format": "date", + "minimum": "2022-02-04", + "exclusiveMinimum": "2022-02-05", + "exclusiveMaximum": "2022-02-08", + "maximum": "2022-02-09", + "default" : "2022-02-07", + ":type": "core/fd/components/form/datepicker/v1/datepicker", + "rules" : { + "visible" : "true()", + "value" : "false()", + "label" : "{value : 'some label'}", + "enabled" : "true()" + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/datepicker/test-content.json b/bundles/core/src/test/resources/form/datepicker/test-content.json new file mode 100644 index 0000000000..2b174101ee --- /dev/null +++ b/bundles/core/src/test/resources/form/datepicker/test-content.json @@ -0,0 +1,58 @@ +{ + "datepicker" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/datepicker/v1/datepicker", + "name" : "abc", + "jcr:title" : "def", + "hideTitle" : false, + "description" : "dummy", + "visible" : false, + "assistPriority" : "custom", + "dataRef" : "a.b", + "fieldType": "date-input", + "custom" : "Custom screen reader text", + "typeMessage" : "incorrect type", + "tooltip": "test-short-description", + "minimumDate": "Fri Feb 04 2022 05:30:00 GMT+0530", + "exclusiveMinimumDate": "Sat Feb 05 2022 05:30:00 GMT+0530", + "exclusiveMaximumDate": "Tue Feb 08 2022 05:30:00 GMT+0530", + "maximumDate": "Wed Feb 09 2022 05:30:00 GMT+0530", + "default": "Mon Feb 07 2022 05:30:00 GMT+0530", + "fd:rules" : { + "jcr:primaryType": "nt:unstructured", + "visible" : "true()", + "value" : "false()", + "label" : "{value : 'some label'}", + "enabled" : "true()" + } + }, + "datepicker-message" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/datepicker/v1/datepicker", + "name" : "abc", + "jcr:title" : "def", + "hideTitle" : false, + "description" : "dummy", + "visible" : false, + "assistPriority" : "custom", + "dataRef" : "a.b", + "fieldType": "date-input", + "custom" : "Custom screen reader text", + "typeMessage" : "incorrect type", + "tooltip": "test-short-description", + "minimumDate": "Fri Feb 04 2022 05:30:00 GMT+0530", + "minimumMessage" : "Date should be greater than 4th Feb 2022", + "exclusiveMinimumDate": "Sat Feb 05 2022 05:30:00 GMT+0530", + "exclusiveMaximumDate": "Tue Feb 08 2022 05:30:00 GMT+0530", + "maximumDate": "Wed Feb 09 2022 05:30:00 GMT+0530", + "maximumMessage" : "Date should be less than 9th Feb 2022", + "default": "Mon Feb 07 2022 05:30:00 GMT+0530", + "fd:rules" : { + "jcr:primaryType": "nt:unstructured", + "visible" : "true()", + "value" : "false()", + "label" : "{value : 'some label'}", + "enabled" : "true()" + } + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/dropdown/exporter-dropdown.json b/bundles/core/src/test/resources/form/dropdown/exporter-dropdown.json new file mode 100644 index 0000000000..aa8bbd4dae --- /dev/null +++ b/bundles/core/src/test/resources/form/dropdown/exporter-dropdown.json @@ -0,0 +1,31 @@ +{ + "id": "dropdown-6fb0d7f4c0", + "required": false, + "name": "abc", + "visible": false, + "enabled": true, + "readOnly": false, + "fieldType": "drop-down", + "description" : "dummy", + "tooltip": "test-short-description", + "properties": { + "af:layout" : { + "tooltipVisible": false + } + }, + "enforceEnum":false, + "enum" : [0, 1, 2], + "enumNames" : ["m", "f", "o"], + "label": { + "visible": true, + "value": "def", + "richText": false + }, + "dataRef":"a.b", + "screenReaderText": "'Custom screen reader text'", + "constraintMessages":{ + "type":"incorrect type" + }, + "type": "number", + ":type": "core/fd/components/form/dropdown/v1/dropdown" +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/dropdown/exporter-multiselect-dropdown.json b/bundles/core/src/test/resources/form/dropdown/exporter-multiselect-dropdown.json new file mode 100644 index 0000000000..090cfc5366 --- /dev/null +++ b/bundles/core/src/test/resources/form/dropdown/exporter-multiselect-dropdown.json @@ -0,0 +1,34 @@ +{ + "id": "dropdown-c0d54fed4e", + "required": false, + "name": "abc", + "visible": false, + "enabled": true, + "readOnly": false, + "fieldType": "drop-down", + "description" : "dummy", + "tooltip": "test-short-description", + "properties": { + "af:layout" : { + "tooltipVisible": false + } + }, + "enforceEnum":false, + "enum" : [0, 1, 2], + "enumNames" : ["m", "f", "o"], + "label": { + "visible": true, + "value": "def", + "richText": false + }, + "dataRef":"a.b", + "screenReaderText": "'Custom screen reader text'", + "constraintMessages":{ + "type":"incorrect type" + }, + "default" : [0, 1], + "type": "number[]", + "minItems" : 1, + "maxItems" : 2, + ":type": "core/fd/components/form/dropdown/v1/dropdown" +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/dropdown/test-content.json b/bundles/core/src/test/resources/form/dropdown/test-content.json new file mode 100644 index 0000000000..54fc7506fa --- /dev/null +++ b/bundles/core/src/test/resources/form/dropdown/test-content.json @@ -0,0 +1,42 @@ +{ + "dropdown" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/dropdown/v1/dropdown", + "name" : "abc", + "jcr:title" : "def", + "hideTitle" : false, + "description" : "dummy", + "visible" : false, + "assistPriority" : "custom", + "dataRef" : "a.b", + "custom" : "Custom screen reader text", + "typeMessage" : "incorrect type", + "tooltip": "test-short-description", + "fieldType": "drop-down", + "type" : "number", + "enum" : [0, 1, 2], + "enumNames" : ["m", "f", "o"] + }, + "multiselect-dropdown" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/dropdown/v1/dropdown", + "name" : "abc", + "jcr:title" : "def", + "hideTitle" : false, + "description" : "dummy", + "visible" : false, + "assistPriority" : "custom", + "fieldType": "drop-down", + "dataRef" : "a.b", + "custom" : "Custom screen reader text", + "typeMessage" : "incorrect type", + "tooltip": "test-short-description", + "type" : "number[]", + "multiSelect" : true, + "default" : [0, 1], + "enum" : [0, 1, 2], + "enumNames" : ["m", "f", "o"], + "minItems" : 1, + "maxItems" : 2 + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/fileinput/exporter-fileinput.json b/bundles/core/src/test/resources/form/fileinput/exporter-fileinput.json new file mode 100644 index 0000000000..5633dfe200 --- /dev/null +++ b/bundles/core/src/test/resources/form/fileinput/exporter-fileinput.json @@ -0,0 +1,34 @@ +{ + "id": "fileinput-8857e83bbf", + "required": false, + "name": "abc", + "visible": false, + "enabled": true, + "readOnly": false, + "fieldType": "file-input", + "description" : "dummy", + "tooltip": "test-short-description", + "properties": { + "af:layout" : { + "tooltipVisible": false + } + }, + "label": { + "visible": true, + "value": "def", + "richText": false + }, + "maxFileSize": "4MB", + "dataRef":"a.b", + "screenReaderText": "'Custom screen reader text'", + "constraintMessages":{ + "type":"incorrect type" + }, + "type": "file", + "accept": [ + "audio/*", + "video/*", + "image/*" + ], + ":type": "core/fd/components/form/fileinput/v1/fileinput" +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/fileinput/exporter-multiselect-fileinput.json b/bundles/core/src/test/resources/form/fileinput/exporter-multiselect-fileinput.json new file mode 100644 index 0000000000..28f60cbc91 --- /dev/null +++ b/bundles/core/src/test/resources/form/fileinput/exporter-multiselect-fileinput.json @@ -0,0 +1,35 @@ +{ + "id": "fileinput-4573ac70ac", + "required": false, + "name": "abc", + "visible": false, + "enabled": true, + "readOnly": false, + "fieldType": "file-input", + "description" : "dummy", + "tooltip": "test-short-description", + "properties": { + "af:layout" : { + "tooltipVisible": false + } + }, + "label": { + "visible": true, + "value": "def", + "richText": false + }, + "dataRef":"a.b", + "screenReaderText": "'Custom screen reader text'", + "constraintMessages":{ + "type":"incorrect type" + }, + "type": "file[]", + "maxFileSize": "4GB", + "maxItems": 2, + "minItems": 1, + "accept": [ + "text/*", + "application/pdf" + ], + ":type": "core/fd/components/form/fileinput/v1/fileinput" +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/fileinput/test-content.json b/bundles/core/src/test/resources/form/fileinput/test-content.json new file mode 100644 index 0000000000..0b8994d4ea --- /dev/null +++ b/bundles/core/src/test/resources/form/fileinput/test-content.json @@ -0,0 +1,41 @@ +{ + "fileinput" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/fileinput/v1/fileinput", + "name" : "abc", + "jcr:title" : "def", + "hideTitle" : false, + "description" : "dummy", + "visible" : false, + "assistPriority" : "custom", + "dataRef" : "a.b", + "fieldType": "file-input", + "custom" : "Custom screen reader text", + "typeMessage" : "incorrect type", + "tooltip": "test-short-description", + "type" : "file", + "maxFileSize" : "4MB", + "accept" : ["audio/*", "video/*", "image/*"] + }, + "multiselect-fileinput" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/fileinput/v1/fileinput", + "fieldType": "file-input", + "name" : "abc", + "jcr:title" : "def", + "hideTitle" : false, + "description" : "dummy", + "visible" : false, + "assistPriority" : "custom", + "dataRef" : "a.b", + "custom" : "Custom screen reader text", + "typeMessage" : "incorrect type", + "tooltip": "test-short-description", + "type" : "file[]", + "multiSelection" : true, + "minItems" : 1, + "maxItems" : 2, + "maxFileSize" : "4GB", + "accept" : ["text/*", "application/pdf"] + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/formcontainer/exporter-formcontainer.json b/bundles/core/src/test/resources/form/formcontainer/exporter-formcontainer.json index 10a619c850..5d0c6ac901 100644 --- a/bundles/core/src/test/resources/form/formcontainer/exporter-formcontainer.json +++ b/bundles/core/src/test/resources/form/formcontainer/exporter-formcontainer.json @@ -1,25 +1,6 @@ { - "items": [ - { - "id": "textinput-2be05cc42b", - "required": false, - "name": "abc", - "visible": false, - "enabled": true, - "readOnly": false, - "fieldType": "text-input", - "autoComplete": false, - "label": { - "visible": true, - "richText": false, - "value": "def" - }, - "screenReaderText": "abc", - "type": "string", - ":type": "core/fd/components/form/textinput/v1/textinput" - } - ], ":type": "core/fd/components/form/container/v1/container", + "fieldType" : "form", "metadata": { "dataUrl": "/c/d", "action": "/a/b", diff --git a/bundles/core/src/test/resources/form/formcontainer/exporter-formcontainerv2.json b/bundles/core/src/test/resources/form/formcontainer/exporter-formcontainerv2.json index dddb2c8bd4..e422bfb76e 100644 --- a/bundles/core/src/test/resources/form/formcontainer/exporter-formcontainerv2.json +++ b/bundles/core/src/test/resources/form/formcontainer/exporter-formcontainerv2.json @@ -1,24 +1,24 @@ { "items": [ { - "id":"textinput-b00e1d53ed", + "id":"textinput-9a52c5fa93", + "description": "dummy", "required": false, "name": "abc", "visible": false, "enabled": true, "readOnly": false, - "autoComplete":false, "fieldType": "text-input", "label": { "visible": true, "richText": false, "value": "def" }, - "screenReaderText": "abc", "type": "string", ":type": "core/fd/components/form/textinput/v1/textinput" } ], + "fieldType" : "form", "metadata": { "action": "/a/b", "dataUrl": "/c/d", diff --git a/bundles/core/src/test/resources/form/formcontainer/test-content.json b/bundles/core/src/test/resources/form/formcontainer/test-content.json index afb035848a..682d30c16b 100644 --- a/bundles/core/src/test/resources/form/formcontainer/test-content.json +++ b/bundles/core/src/test/resources/form/formcontainer/test-content.json @@ -4,15 +4,6 @@ "sling:resourceType" : "core/fd/components/form/container/v1/container", "thankyouPage": "/a/b/c", "thankyouMessage": "message", - "textinput" : { - "jcr:primaryType": "nt:unstructured", - "sling:resourceType" : "core/fd/components/form/textinput/v1/textinput", - "name" : "abc", - "jcr:title" : "def", - "hideTitle" : false, - "description" : "dummy", - "visible" : false - }, "action": "/a/b", "dataUrl": "/c/d" }, @@ -21,6 +12,7 @@ "sling:resourceType" : "core/fd/components/form/container/v2/container", "thankyouPage": "/a/b/c", "thankyouMessage": "message", + "fieldType" : "form", "textinput" : { "jcr:primaryType": "nt:unstructured", "sling:resourceType" : "core/fd/components/form/textinput/v1/textinput", @@ -28,6 +20,8 @@ "jcr:title" : "def", "hideTitle" : false, "description" : "dummy", + "fieldType" : "text-input", + "fd:translationIds" : "{\"jcr:title\":\"guideContainer##textinput##jcr:title##5598\",\"placeholder\":\"guideContainer##textinput##description##5648\"}", "visible" : false }, "action": "/a/b", @@ -36,6 +30,7 @@ "formcontainerWithDocumentPath": { "jcr:primaryType": "nt:unstructured", "sling:resourceType" : "core/fd/components/form/container/v1/container", + "fieldType" : "form", "thankyouPage": "/a/b/c", "thankyouMessage": "message", "formModelDocumentPath" : "/content/dam/sample.json", diff --git a/bundles/core/src/test/resources/form/formcontainer/test-lib-form-container.json b/bundles/core/src/test/resources/form/formcontainer/test-lib-form-container.json new file mode 100644 index 0000000000..79e65ab872 --- /dev/null +++ b/bundles/core/src/test/resources/form/formcontainer/test-lib-form-container.json @@ -0,0 +1,11 @@ +{ + "jcr:primaryType": "cq:Component", + "jcr:createdBy": "admin", + "jcr:title": "Adaptive Form Container (v2)", + "cq:isContainer": true, + "jcr:created": "Mon Aug 01 2022 13:07:05 GMT+0530", + "sling:resourceSuperType": "core/fd/components/form/container/v1/container", + "jcr:description": "Container allowing to construct adaptive forms", + "cq:icon": "form", + "componentGroup": "Core Adaptive Form" +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/formcontainer/test-localization-content.json b/bundles/core/src/test/resources/form/formcontainer/test-localization-content.json new file mode 100644 index 0000000000..6e1ea6ae4d --- /dev/null +++ b/bundles/core/src/test/resources/form/formcontainer/test-localization-content.json @@ -0,0 +1,64 @@ +{ + "jcr:primaryType": "dam:Asset", + "jcr:createdBy": "admin", + "jcr:content": { + "jcr:primaryType": "dam:AssetContent", + "type": "guide", + "guide": "1", + "sling:resourceType": "fd/fm/af/render", + "dictionary": { + "jcr:primaryType": "nt:unstructured", + "de": { + "jcr:primaryType": "sling:OrderedFolder", + "jcr:mixinTypes": [ + "mix:language" + ], + "jcr:createdBy": "translation-job-service", + "jcr:language": "de", + "sling:basename": "/content/dam/formsanddocuments/demo/jcr:content/dictionary", + "jcr:created": "Fri Aug 05 2022 16:45:12 GMT+0530", + "temp": { + "jcr:primaryType": "nt:folder", + "jcr:mixinTypes": [ + "sling:Message" + ], + "jcr:createdBy": "translation-job-service", + "sling:message": "Adaptive Form V2 (IT)", + "sling:key": "jcr:title##6249", + "jcr:created": "Fri Aug 05 2022 16:45:12 GMT+0530" + }, + "temp1": { + "jcr:primaryType": "nt:folder", + "jcr:mixinTypes": [ + "sling:Message" + ], + "jcr:createdBy": "translation-job-service", + "sling:message": "def 1", + "sling:key": "guideContainer##textinput##jcr:title##5598", + "jcr:created": "Fri Aug 05 2022 16:45:12 GMT+0530" + }, + "temp2": { + "jcr:primaryType": "nt:folder", + "jcr:mixinTypes": [ + "sling:Message" + ], + "jcr:createdBy": "translation-job-service", + "sling:message": "dummy 1", + "sling:key": "guideContainer##textinput##description##5648", + "jcr:created": "Fri Aug 05 2022 16:45:12 GMT+0530" + } + } + }, + "metadata": { + "jcr:primaryType": "nt:unstructured", + "availableInMobileApp": false, + "author": "admin", + "allowedRenderFormat": "HTML", + "fd:version": "2.0", + "title": "Adaptive Form V2 (IT)", + "formmodel": "none", + "dorType": "none", + "hasCustomThumbnail": false + } + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/formcontainer/test-page-content.json b/bundles/core/src/test/resources/form/formcontainer/test-page-content.json new file mode 100644 index 0000000000..9f9d90e3a5 --- /dev/null +++ b/bundles/core/src/test/resources/form/formcontainer/test-page-content.json @@ -0,0 +1,40 @@ +{ + "jcr:primaryType": "cq:Page", + "jcr:createdBy": "admin", + "jcr:created": "Mon Aug 01 2022 14:37:23 GMT+0530", + "jcr:content": { + "jcr:primaryType": "cq:PageContent", + "jcr:createdBy": "admin", + "jcr:title": "Adaptive Form V2 (IT)", + "cq:template": "/conf/core-components-it/settings/wcm/templates/af-blank-v2", + "jcr:language": "en", + "jcr:created": "Mon Aug 01 2022 14:37:23 GMT+0530", + "cq:lastModified": "Tue Aug 23 2022 15:23:41 GMT+0530", + "cq:deviceGroups": [ + "mobile/groups/responsive" + ], + "sling:resourceType": "forms-components-examples/components/page", + "fd:translationIds": "{\"jcr:title\":\"jcr:title##6249\"}", + "cq:lastModifiedBy": "admin", + "formcontainerv2": { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/container/v2/container", + "thankyouPage": "/a/b/c", + "thankyouMessage": "message", + "fieldType" : "form", + "textinput" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/textinput/v1/textinput", + "name" : "abc", + "jcr:title" : "def", + "hideTitle" : false, + "description" : "dummy", + "fieldType" : "text-input", + "fd:translationIds" : "{\"jcr:title\":\"guideContainer##textinput##jcr:title##5598\",\"description\":\"guideContainer##textinput##description##5648\"}", + "visible" : false + }, + "action": "/a/b", + "dataUrl": "/c/d" + } + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/formstructparser/test-content.json b/bundles/core/src/test/resources/form/formstructparser/test-content.json new file mode 100644 index 0000000000..e8a86761dd --- /dev/null +++ b/bundles/core/src/test/resources/form/formstructparser/test-content.json @@ -0,0 +1,59 @@ +{ + "jcr:primaryType": "cq:Page", + "jcr:content": { + "sling:resourceType": "myTest/components/page", + "jcr:title": "Test", + "jcr:description": "Test", + "jcr:primaryType": "cq:PageContent", + "cq:template": "/conf/myTest/settings/wcm/templates/content-page", + "formcontainerv2": { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType": "core/fd/components/form/container/v2/container", + "fieldType" : "form", + "thankyouPage": "/a/b/c", + "thankyouMessage": "message", + "datepicker": { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType": "core/fd/components/form/datepicker/v1/datepicker", + "name": "abc", + "jcr:title": "def", + "hideTitle": false, + "description": "dummy", + "visible": false + }, + "container1": { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType": "wcm/foundation/components/responsivegrid", + "datepicker1": { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType": "core/fd/components/form/datepicker/v1/datepicker", + "name": "abc", + "jcr:title": "def", + "hideTitle": false, + "description": "dummy", + "visible": false + }, + "container2": { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType": "wcm/foundation/components/responsivegrid", + "text": { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType": "myTest/components/text", + "text": "abc" + } + } + }, + "action": "/a/b", + "dataUrl": "/c/d" + }, + "container3": { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType": "wcm/foundation/components/responsivegrid", + "text1": { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType": "myTest/components/text", + "text": "test" + } + } + } +} diff --git a/bundles/core/src/test/resources/form/numberinput/exporter-numberinput.json b/bundles/core/src/test/resources/form/numberinput/exporter-numberinput.json new file mode 100644 index 0000000000..f3b2f819c9 --- /dev/null +++ b/bundles/core/src/test/resources/form/numberinput/exporter-numberinput.json @@ -0,0 +1,34 @@ +{ + "id": "numberinput-4b399a633a", + "required": false, + "name": "abc", + "visible": false, + "enabled": true, + "readOnly": false, + "fieldType": "number-input", + "description" : "dummy", + "tooltip": "test-short-description", + "properties": { + "af:layout" : { + "tooltipVisible": false, + "leadDigits": 2, + "fracDigits" : 4 + } + }, + "maximum": 2000000, + "minimum": 10000, + "exclusiveMaximum": 2000002, + "exclusiveMinimum": 10002, + "label": { + "visible": true, + "value": "def", + "richText": false + }, + "dataRef":"a.b", + "screenReaderText": "'Custom screen reader text'", + "constraintMessages":{ + "type":"incorrect type" + }, + "type": "number", + ":type": "core/fd/components/form/numberinput/v1/numberinput" +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/numberinput/test-content.json b/bundles/core/src/test/resources/form/numberinput/test-content.json new file mode 100644 index 0000000000..46aee7a9c2 --- /dev/null +++ b/bundles/core/src/test/resources/form/numberinput/test-content.json @@ -0,0 +1,24 @@ +{ + "numberinput" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/numberinput/v1/numberinput", + "name" : "abc", + "jcr:title" : "def", + "hideTitle" : false, + "description" : "dummy", + "visible" : false, + "assistPriority" : "custom", + "dataRef" : "a.b", + "custom" : "Custom screen reader text", + "typeMessage" : "incorrect type", + "tooltip": "test-short-description", + "fieldType": "number-input", + "type" : "number", + "leadDigits" : 2, + "fracDigits" : 4, + "minimum" : 10000, + "maximum" : 2000000, + "exclusiveMinimum" : 10002, + "exclusiveMaximum" : 2000002 + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/panel/exporter-array-panel.json b/bundles/core/src/test/resources/form/panel/exporter-array-panel.json new file mode 100644 index 0000000000..4728e62267 --- /dev/null +++ b/bundles/core/src/test/resources/form/panel/exporter-array-panel.json @@ -0,0 +1,42 @@ +{ + "id": "panel-95130a1dba", + "items": [ + { + "id": "textinput-9670d145f5", + "description": "dummy", + "required": false, + "name": "abc", + "visible": false, + "enabled": true, + "readOnly": false, + "fieldType": "text-input", + "label": { + "visible": true, + "richText": false, + "value": "def" + }, + "type": "string", + ":type": "core/fd/components/form/textinput/v1/textinput" + } + ], + ":type": "core/fd/components/form/panel/v1/panel", + "fieldType" : "panel", + "tooltip" : "dependent names tooltip", + "description" : "dependent names description", + "type" : "array", + "minItems": 1, + "maxItems": 10, + "label" : { + "richText": false, + "value" : "dependent names", + "visible": true + }, + "visible": true, + "enabled": true, + "name": "abc", + "properties": { + "af:layout": { + "tooltipVisible": false + } + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/panel/exporter-panel.json b/bundles/core/src/test/resources/form/panel/exporter-panel.json new file mode 100644 index 0000000000..20febd313e --- /dev/null +++ b/bundles/core/src/test/resources/form/panel/exporter-panel.json @@ -0,0 +1,40 @@ +{ + "id": "panel-d29e24f4ca", + "items": [ + { + "id": "textinput-3a2afcbdfd", + "description": "dummy", + "required": false, + "name": "abc", + "visible": false, + "enabled": true, + "readOnly": false, + "fieldType": "text-input", + "label": { + "visible": true, + "richText": false, + "value": "def" + }, + "type": "string", + ":type": "core/fd/components/form/textinput/v1/textinput" + } + ], + ":type": "core/fd/components/form/panel/v1/panel", + "fieldType" : "panel", + "tooltip" : "dependent names tooltip", + "description" : "dependent names description", + "type" : "object", + "label" : { + "richText": false, + "value" : "dependent names", + "visible": true + }, + "visible": true, + "enabled": true, + "name": "abc", + "properties": { + "af:layout": { + "tooltipVisible": false + } + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/panel/exporter-rules-panel.json b/bundles/core/src/test/resources/form/panel/exporter-rules-panel.json new file mode 100644 index 0000000000..9419e3b3f6 --- /dev/null +++ b/bundles/core/src/test/resources/form/panel/exporter-rules-panel.json @@ -0,0 +1,46 @@ +{ + "id": "panel-81f441fcab", + "items": [ + { + "id": "textinput-bec585e910", + "description": "dummy", + "required": false, + "name": "abc", + "visible": false, + "enabled": true, + "readOnly": false, + "fieldType": "text-input", + "label": { + "visible": true, + "richText": false, + "value": "def" + }, + "type": "string", + ":type": "core/fd/components/form/textinput/v1/textinput" + } + ], + ":type": "core/fd/components/form/panel/v1/panel", + "fieldType" : "panel", + "tooltip" : "dependent names tooltip", + "description" : "dependent names description", + "type" : "object", + "label" : { + "richText": false, + "value" : "dependent names", + "visible": true + }, + "visible": true, + "enabled": true, + "name": "abc", + "properties": { + "af:layout": { + "tooltipVisible": false + } + }, + "rules" : { + "visible" : "some expression" + }, + "events" : { + "change" : ["some expression 2"] + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/panel/test-content.json b/bundles/core/src/test/resources/form/panel/test-content.json new file mode 100644 index 0000000000..f69ba219de --- /dev/null +++ b/bundles/core/src/test/resources/form/panel/test-content.json @@ -0,0 +1,70 @@ +{ + "panel": { + "name" : "abc", + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/panel/v1/panel", + "jcr:title": "dependent names", + "description" : "dependent names description", + "tooltip" : "dependent names tooltip", + "fieldType" : "panel", + "textinput" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/textinput/v1/textinput", + "name" : "abc", + "jcr:title" : "def", + "hideTitle" : false, + "description" : "dummy", + "fieldType" : "text-input", + "visible" : false + } + }, + "rules-panel": { + "name" : "abc", + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/panel/v1/panel", + "jcr:title": "dependent names", + "description" : "dependent names description", + "tooltip" : "dependent names tooltip", + "fieldType" : "panel", + "textinput" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/textinput/v1/textinput", + "name" : "abc", + "jcr:title" : "def", + "hideTitle" : false, + "fieldType" : "text-input", + "description" : "dummy", + "visible" : false + }, + "fd:rules" : { + "jcr:primaryType": "nt:unstructured", + "visible" : "some expression" + }, + "fd:events" : { + "jcr:primaryType": "nt:unstructured", + "change" : "some expression 2" + } + }, + "array-panel": { + "name" : "abc", + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/panel/v1/panel", + "type": "array", + "minItems": 1, + "maxItems": 10, + "jcr:title": "dependent names", + "description" : "dependent names description", + "tooltip" : "dependent names tooltip", + "fieldType" : "panel", + "textinput" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/textinput/v1/textinput", + "name" : "abc", + "jcr:title" : "def", + "hideTitle" : false, + "description" : "dummy", + "fieldType" : "text-input", + "visible" : false + } + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/panelcontainer/exporter-array-panelcontainer.json b/bundles/core/src/test/resources/form/panelcontainer/exporter-array-panelcontainer.json new file mode 100644 index 0000000000..792824dbf7 --- /dev/null +++ b/bundles/core/src/test/resources/form/panelcontainer/exporter-array-panelcontainer.json @@ -0,0 +1,42 @@ +{ + "id": "panelcontainer-c551a729ed", + "items": [ + { + "id": "textinput-fae1400d3e", + "description": "dummy", + "required": false, + "name": "abc", + "visible": false, + "enabled": true, + "readOnly": false, + "fieldType": "text-input", + "label": { + "visible": true, + "richText": false, + "value": "def" + }, + "type": "string", + ":type": "core/fd/components/form/textinput/v1/textinput" + } + ], + ":type": "core/fd/components/form/panelcontainer/v1/panelcontainer", + "fieldType" : "panel", + "tooltip" : "dependent names tooltip", + "description" : "dependent names description", + "type" : "array", + "minItems": 1, + "maxItems": 10, + "label" : { + "richText": false, + "value" : "dependent names", + "visible": true + }, + "visible": true, + "enabled": true, + "name": "abc", + "properties": { + "af:layout": { + "tooltipVisible": false + } + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/panelcontainer/exporter-panelcontainer.json b/bundles/core/src/test/resources/form/panelcontainer/exporter-panelcontainer.json new file mode 100644 index 0000000000..3215b3a32f --- /dev/null +++ b/bundles/core/src/test/resources/form/panelcontainer/exporter-panelcontainer.json @@ -0,0 +1,40 @@ +{ + "id": "panelcontainer-94f9ea9e7d", + "items": [ + { + "id": "textinput-6c994d85b4", + "description": "dummy", + "required": false, + "name": "abc", + "visible": false, + "enabled": true, + "readOnly": false, + "fieldType": "text-input", + "label": { + "visible": true, + "richText": false, + "value": "def" + }, + "type": "string", + ":type": "core/fd/components/form/textinput/v1/textinput" + } + ], + ":type": "core/fd/components/form/panelcontainer/v1/panelcontainer", + "fieldType" : "panel", + "tooltip" : "dependent names tooltip", + "description" : "dependent names description", + "type" : "object", + "label" : { + "richText": false, + "value" : "dependent names", + "visible": true + }, + "visible": true, + "enabled": true, + "name": "abc", + "properties": { + "af:layout": { + "tooltipVisible": false + } + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/panelcontainer/exporter-rules-panelcontainer.json b/bundles/core/src/test/resources/form/panelcontainer/exporter-rules-panelcontainer.json new file mode 100644 index 0000000000..8811cdf5d6 --- /dev/null +++ b/bundles/core/src/test/resources/form/panelcontainer/exporter-rules-panelcontainer.json @@ -0,0 +1,46 @@ +{ + "id": "panelcontainer-da2cf7dff5", + "items": [ + { + "id": "textinput-2d7a7460fa", + "description": "dummy", + "required": false, + "name": "abc", + "visible": false, + "enabled": true, + "readOnly": false, + "fieldType": "text-input", + "label": { + "visible": true, + "richText": false, + "value": "def" + }, + "type": "string", + ":type": "core/fd/components/form/textinput/v1/textinput" + } + ], + ":type": "core/fd/components/form/panelcontainer/v1/panelcontainer", + "fieldType" : "panel", + "tooltip" : "dependent names tooltip", + "description" : "dependent names description", + "type" : "object", + "label" : { + "richText": false, + "value" : "dependent names", + "visible": true + }, + "visible": true, + "enabled": true, + "name": "abc", + "properties": { + "af:layout": { + "tooltipVisible": false + } + }, + "rules" : { + "visible" : "some expression" + }, + "events" : { + "change" : ["some expression 2"] + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/panelcontainer/test-content.json b/bundles/core/src/test/resources/form/panelcontainer/test-content.json new file mode 100644 index 0000000000..5bb1c8f441 --- /dev/null +++ b/bundles/core/src/test/resources/form/panelcontainer/test-content.json @@ -0,0 +1,70 @@ +{ + "panelcontainer": { + "name" : "abc", + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/panelcontainer/v1/panelcontainer", + "jcr:title": "dependent names", + "description" : "dependent names description", + "tooltip" : "dependent names tooltip", + "fieldType" : "panel", + "textinput" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/textinput/v1/textinput", + "name" : "abc", + "jcr:title" : "def", + "hideTitle" : false, + "description" : "dummy", + "fieldType" : "text-input", + "visible" : false + } + }, + "rules-panelcontainer": { + "name" : "abc", + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/panelcontainer/v1/panelcontainer", + "jcr:title": "dependent names", + "description" : "dependent names description", + "tooltip" : "dependent names tooltip", + "fieldType" : "panel", + "textinput" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/textinput/v1/textinput", + "name" : "abc", + "jcr:title" : "def", + "hideTitle" : false, + "fieldType" : "text-input", + "description" : "dummy", + "visible" : false + }, + "fd:rules" : { + "jcr:primaryType": "nt:unstructured", + "visible" : "some expression" + }, + "fd:events" : { + "jcr:primaryType": "nt:unstructured", + "change" : "some expression 2" + } + }, + "array-panelcontainer": { + "name" : "abc", + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/panelcontainer/v1/panelcontainer", + "type": "array", + "minItems": 1, + "maxItems": 10, + "jcr:title": "dependent names", + "description" : "dependent names description", + "tooltip" : "dependent names tooltip", + "fieldType" : "panel", + "textinput" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/textinput/v1/textinput", + "name" : "abc", + "jcr:title" : "def", + "hideTitle" : false, + "description" : "dummy", + "fieldType" : "text-input", + "visible" : false + } + } +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/textinput/exporter-multiline-textinput.json b/bundles/core/src/test/resources/form/textinput/exporter-multiline-textinput.json index 82765265a7..340716b434 100644 --- a/bundles/core/src/test/resources/form/textinput/exporter-multiline-textinput.json +++ b/bundles/core/src/test/resources/form/textinput/exporter-multiline-textinput.json @@ -7,13 +7,11 @@ "readOnly": false, "fieldType": "multiline-input", "description" : "dummy", - "autoComplete": false, "label": { "visible": true, "value": "def", "richText": false }, - "screenReaderText": "abc", "type": "string", ":type": "core/fd/components/form/textinput/v1/textinput" } \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/textinput/exporter-textinput-format.json b/bundles/core/src/test/resources/form/textinput/exporter-textinput-format.json new file mode 100644 index 0000000000..873be16497 --- /dev/null +++ b/bundles/core/src/test/resources/form/textinput/exporter-textinput-format.json @@ -0,0 +1,30 @@ +{ + "id": "textinput-566534ba93", + "required": false, + "name": "abc", + "visible": false, + "enabled": true, + "readOnly": false, + "fieldType": "text-input", + "description" : "dummy", + "tooltip": "test-short-description", + "properties": { + "af:layout" : { + "tooltipVisible": false + } + }, + "default" : "abc", + "label": { + "visible": true, + "value": "def", + "richText": false + }, + "dataRef":"a.b", + "screenReaderText": "'Custom screen reader text'", + "constraintMessages":{ + "type":"incorrect type" + }, + "type": "string", + "format" : "email", + ":type": "core/fd/components/form/textinput/v1/textinput" +} \ No newline at end of file diff --git a/bundles/core/src/test/resources/form/textinput/exporter-textinput.json b/bundles/core/src/test/resources/form/textinput/exporter-textinput.json index e774681a3d..6a441318a0 100644 --- a/bundles/core/src/test/resources/form/textinput/exporter-textinput.json +++ b/bundles/core/src/test/resources/form/textinput/exporter-textinput.json @@ -7,20 +7,21 @@ "readOnly": false, "fieldType": "text-input", "description" : "dummy", - "autoComplete": false, + "tooltip": "test-short-description", "properties": { - "shortDescription": "test-short-description", - "shortDescriptionVisible": false + "af:layout" : { + "tooltipVisible": false + } }, + "default" : "abc", "label": { "visible": true, "value": "def", "richText": false }, "dataRef":"a.b", - - "screenReaderText": "Custom screen reader text", - "constraintsMessages":{ + "screenReaderText": "'Custom screen reader text'", + "constraintMessages":{ "type":"incorrect type" }, "type": "string", diff --git a/bundles/core/src/test/resources/form/textinput/test-content.json b/bundles/core/src/test/resources/form/textinput/test-content.json index 6d43904be3..5d35e1281a 100644 --- a/bundles/core/src/test/resources/form/textinput/test-content.json +++ b/bundles/core/src/test/resources/form/textinput/test-content.json @@ -5,22 +5,61 @@ "name" : "abc", "jcr:title" : "def", "hideTitle" : false, - "longDescription" : "dummy", + "description" : "dummy", "visible" : false, "assistPriority" : "custom", - "bindRef" : "a.b", + "dataRef" : "a.b", "custom" : "Custom screen reader text", "typeMessage" : "incorrect type", - "shortDescription": "test-short-description" + "tooltip": "test-short-description", + "default" : "abc", + "fieldType": "text-input" + }, + "number-textinput" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/textinput/v1/textinput", + "name" : "abc", + "type" : "number", + "jcr:title" : "def", + "hideTitle" : false, + "description" : "dummy", + "visible" : false, + "assistPriority" : "custom", + "dataRef" : "a.b", + "custom" : "Custom screen reader text", + "typeMessage" : "incorrect type", + "tooltip": "test-short-description", + "fieldType": "text-input", + "maximum" : 100, + "minimum" : 10, + "default" : 150 }, "multiline-textinput" : { "jcr:primaryType": "nt:unstructured", "sling:resourceType" : "core/fd/components/form/textinput/v1/textinput", "name" : "abc", "multiLine" : true, + "fieldType": "multiline-input", "jcr:title" : "def", "hideTitle" : false, - "longDescription" : "dummy", + "description" : "dummy", "visible" : false + }, + "textinput-format" : { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType" : "core/fd/components/form/textinput/v1/textinput", + "name" : "abc", + "jcr:title" : "def", + "hideTitle" : false, + "description" : "dummy", + "visible" : false, + "assistPriority" : "custom", + "dataRef" : "a.b", + "custom" : "Custom screen reader text", + "typeMessage" : "incorrect type", + "tooltip": "test-short-description", + "default" : "abc", + "fieldType": "text-input", + "format" : "email" } } \ No newline at end of file diff --git a/examples/all/pom.xml b/examples/all/pom.xml index bfded2c378..8077b5d689 100644 --- a/examples/all/pom.xml +++ b/examples/all/pom.xml @@ -47,6 +47,10 @@ + + ${project.basedir}/../../parent + + @@ -84,6 +88,32 @@
+ + autoInstallExamples + + false + + + + + com.day.jcr.vault + content-package-maven-plugin + + + install-package + + install + + + ${quickstart.url}/crx/packmgr/service.jsp + true + + + + + + + include-wcm-components-examples diff --git a/examples/ui.apps/pom.xml b/examples/ui.apps/pom.xml index a1764c1cca..a49f4c07ca 100644 --- a/examples/ui.apps/pom.xml +++ b/examples/ui.apps/pom.xml @@ -52,6 +52,7 @@ UTF-8 ${project.version} + ${project.basedir}/../../parent @@ -129,64 +130,6 @@
- - - - - - autoInstallPackage - - false - - - - - com.day.jcr.vault - content-package-maven-plugin - - - install-package - - install - - - ${quickstart.url}/crx/packmgr/service.jsp - true - - - - - - - - - autoInstallPackagePublish - - false - - - - - com.day.jcr.vault - content-package-maven-plugin - - - install-package-publish - - install - - - ${quickstart.url}/crx/packmgr/service.jsp - true - - - - - - - - - diff --git a/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/container/_cq_template.xml b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/container/_cq_template.xml new file mode 100644 index 0000000000..17dfd80520 --- /dev/null +++ b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/container/_cq_template.xml @@ -0,0 +1,5 @@ + + diff --git a/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/datepicker/.content.xml b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/datepicker/.content.xml new file mode 100644 index 0000000000..00c1c33f98 --- /dev/null +++ b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/datepicker/.content.xml @@ -0,0 +1,7 @@ + + diff --git a/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/datepicker/_cq_template.xml b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/datepicker/_cq_template.xml new file mode 100644 index 0000000000..9994a78289 --- /dev/null +++ b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/datepicker/_cq_template.xml @@ -0,0 +1,5 @@ + + diff --git a/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/panelcontainer/.content.xml b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/panelcontainer/.content.xml new file mode 100644 index 0000000000..1ef090cf54 --- /dev/null +++ b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/panelcontainer/.content.xml @@ -0,0 +1,7 @@ + + diff --git a/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/panelcontainer/_cq_template.xml b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/panelcontainer/_cq_template.xml new file mode 100644 index 0000000000..b352cfbbe3 --- /dev/null +++ b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/panelcontainer/_cq_template.xml @@ -0,0 +1,5 @@ + + diff --git a/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/textinput/_cq_template.xml b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/textinput/_cq_template.xml new file mode 100644 index 0000000000..870afe559e --- /dev/null +++ b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/textinput/_cq_template.xml @@ -0,0 +1,5 @@ + + diff --git a/examples/ui.content/pom.xml b/examples/ui.content/pom.xml index c58d68faa9..8cd86eaece 100644 --- a/examples/ui.content/pom.xml +++ b/examples/ui.content/pom.xml @@ -52,6 +52,7 @@ UTF-8 ${project.version} + ${project.basedir}/../../parent @@ -138,64 +139,6 @@
- - - - - - autoInstallPackage - - false - - - - - com.day.jcr.vault - content-package-maven-plugin - - - install-package - - install - - - ${quickstart.url}/crx/packmgr/service.jsp - true - - - - - - - - - autoInstallPackagePublish - - false - - - - - com.day.jcr.vault - content-package-maven-plugin - - - install-package-publish - - install - - - ${quickstart.url}/crx/packmgr/service.jsp - true - - - - - - - - - diff --git a/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/container/.content.xml b/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/container/.content.xml index 74a24c1181..a86f20eb7a 100644 --- a/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/container/.content.xml +++ b/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/container/.content.xml @@ -96,6 +96,7 @@ jcr:lastModified="{Date}2019-05-21T18:59:35.605+03:00" jcr:lastModifiedBy="admin" jcr:primaryType="nt:unstructured" + fieldType="form" thankYouMessage="Thank you for submitting the form" formModelDocumentPath="/content/dam/core-components-examples/library/forms-components/sample.json" sling:resourceType="forms-components-examples/components/form/container"/> diff --git a/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/panelcontainer/.content.xml b/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/panelcontainer/.content.xml new file mode 100644 index 0000000000..01e27d163b --- /dev/null +++ b/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/panelcontainer/.content.xml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/textinput/.content.xml b/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/textinput/.content.xml index 7a316e7352..26b2abf4e1 100644 --- a/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/textinput/.content.xml +++ b/examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/adaptive-form/textinput/.content.xml @@ -48,7 +48,7 @@ sling:resourceType="core-components-examples/components/teaser" actionsEnabled="false" descriptionFromPage="false" - linkURL="https://github.com/adobe/aem-core-forms-components/tree/master/ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v1/container" + linkURL="https://github.com/adobe/aem-core-forms-components/tree/master/ui.apps/src/main/content/jcr_root/apps/core/fd/components/form/textinput/v1/textinput" textIsRich="true" titleFromPage="false"/> - + + + zip provided + + com.adobe.granite.toggle + com.adobe.granite.toggle.impl.dev + 1.1.2 + system + ${project.basedir}/src/main/resources/com.adobe.granite.toggle.impl.dev-1.1.2.jar + diff --git a/it/content/src/main/content/META-INF/vault/filter.xml b/it/content/src/main/content/META-INF/vault/filter.xml index d00787bf79..b6802e5cc2 100644 --- a/it/content/src/main/content/META-INF/vault/filter.xml +++ b/it/content/src/main/content/META-INF/vault/filter.xml @@ -1,6 +1,6 @@ - - - + + + diff --git a/it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/af-blank-v2/policies/.content.xml b/it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/af-blank-v2/policies/.content.xml deleted file mode 100755 index 90d8fd22eb..0000000000 --- a/it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/af-blank-v2/policies/.content.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - diff --git a/it/content/src/main/content/jcr_root/conf/core-components-examples/.content.xml b/it/content/src/main/content/jcr_root/conf/core-components-it/.content.xml similarity index 100% rename from it/content/src/main/content/jcr_root/conf/core-components-examples/.content.xml rename to it/content/src/main/content/jcr_root/conf/core-components-it/.content.xml diff --git a/it/content/src/main/content/jcr_root/conf/core-components-examples/settings/.content.xml b/it/content/src/main/content/jcr_root/conf/core-components-it/settings/.content.xml similarity index 100% rename from it/content/src/main/content/jcr_root/conf/core-components-examples/settings/.content.xml rename to it/content/src/main/content/jcr_root/conf/core-components-it/settings/.content.xml diff --git a/it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/.content.xml b/it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/.content.xml similarity index 100% rename from it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/.content.xml rename to it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/.content.xml diff --git a/it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/policies/.content.xml b/it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/policies/.content.xml new file mode 100644 index 0000000000..b1ae4b549e --- /dev/null +++ b/it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/policies/.content.xml @@ -0,0 +1,22 @@ + + + + +
+ + + + + +
+
+
+
diff --git a/it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/.content.xml b/it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/templates/.content.xml similarity index 100% rename from it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/.content.xml rename to it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/templates/.content.xml diff --git a/it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/af-blank-v2/.content.xml b/it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/templates/af-blank-v2/.content.xml similarity index 100% rename from it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/af-blank-v2/.content.xml rename to it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/templates/af-blank-v2/.content.xml diff --git a/it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/af-blank-v2/initial/.content.xml b/it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/templates/af-blank-v2/initial/.content.xml similarity index 96% rename from it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/af-blank-v2/initial/.content.xml rename to it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/templates/af-blank-v2/initial/.content.xml index 04299a010f..7caf3e40bc 100755 --- a/it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/af-blank-v2/initial/.content.xml +++ b/it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/templates/af-blank-v2/initial/.content.xml @@ -9,6 +9,7 @@ diff --git a/it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/templates/af-blank-v2/policies/.content.xml b/it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/templates/af-blank-v2/policies/.content.xml new file mode 100755 index 0000000000..d600587911 --- /dev/null +++ b/it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/templates/af-blank-v2/policies/.content.xml @@ -0,0 +1,14 @@ + + + + + + + diff --git a/it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/af-blank-v2/structure/.content.xml b/it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/templates/af-blank-v2/structure/.content.xml similarity index 97% rename from it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/af-blank-v2/structure/.content.xml rename to it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/templates/af-blank-v2/structure/.content.xml index 27fefd7f50..4ead24751b 100755 --- a/it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/af-blank-v2/structure/.content.xml +++ b/it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/templates/af-blank-v2/structure/.content.xml @@ -12,6 +12,7 @@ diff --git a/it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/af-blank-v2/thumbnail.png b/it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/templates/af-blank-v2/thumbnail.png similarity index 100% rename from it/content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/af-blank-v2/thumbnail.png rename to it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/templates/af-blank-v2/thumbnail.png diff --git a/it/content/src/main/content/jcr_root/content/dam/formsanddocuments/.content.xml b/it/content/src/main/content/jcr_root/content/dam/formsanddocuments/.content.xml index bbf62ed22c..32ba4b074b 100755 --- a/it/content/src/main/content/jcr_root/content/dam/formsanddocuments/.content.xml +++ b/it/content/src/main/content/jcr_root/content/dam/formsanddocuments/.content.xml @@ -1,5 +1,4 @@