From 6818dda16078dd68b55917881efe562da0fbc15d Mon Sep 17 00:00:00 2001 From: Rishi Mehta Date: Mon, 23 Sep 2024 19:18:08 +0530 Subject: [PATCH 1/9] initial check in --- .../models/v1/form/FileInputImpl.java | 21 +++-- .../models/form/BaseConstraint.java | 2 +- .../models/form/FileConstraint.java | 13 +++ .../components/models/form/package-info.java | 2 +- .../v1/fileinput/_cq_dialog/.content.xml | 14 +++ ui.frontend/package-lock.json | 89 +++++++++++++------ ui.frontend/package.json | 2 +- 7 files changed, 110 insertions(+), 33 deletions(-) diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileInputImpl.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileInputImpl.java index 4e059e97b0..1a2e967e4e 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileInputImpl.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileInputImpl.java @@ -72,12 +72,23 @@ public Integer getMaxItems() { @Override public Type getType() { - // file upload does not work for type string in core component, hence default it to file - if (!isMultiple()) { - return Type.FILE; - } else { - return Type.FILE_ARRAY; + Type superType = super.getType(); + if (superType == null) { + return isMultiple() ? Type.FILE_ARRAY : Type.FILE; } + if (isMultiple() && superType == Type.STRING) { + return Type.STRING_ARRAY; + } + return superType; + } + + @Override + public String getFormat() { + Type type = getType(); + if (type == Type.STRING || type == Type.STRING_ARRAY) { + return "data-url"; + } + return null; } @Override diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/BaseConstraint.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/BaseConstraint.java index 0bc56bfffb..f9127314a3 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/BaseConstraint.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/BaseConstraint.java @@ -35,7 +35,7 @@ public interface BaseConstraint { * * @since com.adobe.cq.forms.core.components.models.form 0.0.1 */ - public enum Type { + public enum type { STRING("string"), STRING_ARRAY("string[]"), NUMBER("number"), diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FileConstraint.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FileConstraint.java index 68e87b9150..7c0ece5245 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FileConstraint.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FileConstraint.java @@ -21,6 +21,8 @@ import org.osgi.annotation.versioning.ProviderType; +import com.fasterxml.jackson.annotation.JsonInclude; + /** * Interface for constraints applicable to file attachments * @@ -54,4 +56,15 @@ default String getMaxFileSize() { default List getAccept() { return DEFAULT_ACCEPT; } + + /** + * The constraint is + * applicable for file attachment field. If the type is {@code String}, the format will always be {@code dataurl}. + * + * @since com.adobe.cq.forms.core.components.models.form 5.7.4 + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + default String getFormat() { + return null; + } } diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java index c06f9a92e7..b0e57e0089 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java @@ -35,7 +35,7 @@ *

*/ -@Version("5.6.4") +@Version("5.7.4") package com.adobe.cq.forms.core.components.models.form; import org.osgi.annotation.versioning.Version; diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/fileinput/v1/fileinput/_cq_dialog/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/fileinput/v1/fileinput/_cq_dialog/.content.xml index 2c7a32c4ac..27e6db3219 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/fileinput/v1/fileinput/_cq_dialog/.content.xml +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/fileinput/v1/fileinput/_cq_dialog/.content.xml @@ -63,6 +63,20 @@ fieldLabel="Button title" name="./buttonText"> + + + + + + diff --git a/ui.frontend/package-lock.json b/ui.frontend/package-lock.json index 3fba3bd590..946f88b971 100644 --- a/ui.frontend/package-lock.json +++ b/ui.frontend/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "Apache-2.0", "dependencies": { - "@aemforms/af-core": "^0.22.104", + "@aemforms/af-core": "file:///Users/rismehta/af2-web-runtime/packages/forms-next-core", "@aemforms/af-custom-functions": "1.0.10", "@aemforms/af-formatters": "^0.22.104" }, @@ -26,6 +26,41 @@ "webpack-merge": "^5.8.0" } }, + "../../af2-web-runtime/packages/forms-next-core": { + "name": "@aemforms/af-core", + "version": "0.22.106", + "license": "Adobe Proprietary", + "dependencies": { + "@adobe/json-formula": "0.1.50", + "@aemforms/af-formatters": "^0.22.106" + }, + "devDependencies": { + "@babel/preset-env": "^7.20.2", + "@types/jest": "29.2.4", + "@types/lodash": "^4.14.171", + "@typescript-eslint/eslint-plugin": "^4.28.2", + "@typescript-eslint/parser": "^4.28.2", + "babel-jest": "^29.4.1", + "blob-polyfill": "^7.0.20220408", + "eslint": "^7.30.0", + "eslint-config-standard": "^16.0.3", + "eslint-plugin-import": "^2.23.4", + "eslint-plugin-jest": "^24.3.6", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^5.1.0", + "form-data": "^4.0.0", + "jest": "29.3", + "jest-environment-jsdom": "^29.3.1", + "jest-junit": "^12.2.0", + "nock": "^13.1.3", + "node-fetch": "^2.6.1", + "parse-multipart-data": "^1.5.0", + "ts-jest": "29.0", + "typedoc": "0.22.11", + "typedoc-plugin-markdown": "3.11.13", + "typescript": "^4.3.5" + } + }, "../../af2-web-runtime/packages/forms-next-formatters": { "name": "@aemforms/af-formatters", "version": "0.22.75", @@ -52,22 +87,9 @@ "typedoc-plugin-markdown": "3.11.13" } }, - "node_modules/@adobe/json-formula": { - "version": "0.1.50", - "resolved": "https://registry.npmjs.org/@adobe/json-formula/-/json-formula-0.1.50.tgz", - "integrity": "sha512-dmlLYfbty8NPVIdxvI9cJ+ZdXsrRCFrCdmL1+aR2auEzXJ86rD0bm1qu+S4NOpFiZLKIyx0zvUTykms40vNjsA==", - "engines": { - "node": ">=16.0.0" - } - }, "node_modules/@aemforms/af-core": { - "version": "0.22.105", - "resolved": "https://registry.npmjs.org/@aemforms/af-core/-/af-core-0.22.105.tgz", - "integrity": "sha512-epfqV/bUq31h0RwHYJpfgJ6HzPkGTxbiUnqJmZAPXO7QgFzJhbpu/XFDz7pTJfRCBgNhGbOi/30nR9IPeZBUYg==", - "dependencies": { - "@adobe/json-formula": "0.1.50", - "@aemforms/af-formatters": "^0.22.105" - } + "resolved": "../../af2-web-runtime/packages/forms-next-core", + "link": true }, "node_modules/@aemforms/af-custom-functions": { "version": "1.0.10", @@ -11070,18 +11092,35 @@ } }, "dependencies": { - "@adobe/json-formula": { - "version": "0.1.50", - "resolved": "https://registry.npmjs.org/@adobe/json-formula/-/json-formula-0.1.50.tgz", - "integrity": "sha512-dmlLYfbty8NPVIdxvI9cJ+ZdXsrRCFrCdmL1+aR2auEzXJ86rD0bm1qu+S4NOpFiZLKIyx0zvUTykms40vNjsA==" - }, "@aemforms/af-core": { - "version": "0.22.105", - "resolved": "https://registry.npmjs.org/@aemforms/af-core/-/af-core-0.22.105.tgz", - "integrity": "sha512-epfqV/bUq31h0RwHYJpfgJ6HzPkGTxbiUnqJmZAPXO7QgFzJhbpu/XFDz7pTJfRCBgNhGbOi/30nR9IPeZBUYg==", + "version": "file:../../af2-web-runtime/packages/forms-next-core", "requires": { "@adobe/json-formula": "0.1.50", - "@aemforms/af-formatters": "^0.22.105" + "@aemforms/af-formatters": "^0.22.106", + "@babel/preset-env": "^7.20.2", + "@types/jest": "29.2.4", + "@types/lodash": "^4.14.171", + "@typescript-eslint/eslint-plugin": "^4.28.2", + "@typescript-eslint/parser": "^4.28.2", + "babel-jest": "^29.4.1", + "blob-polyfill": "^7.0.20220408", + "eslint": "^7.30.0", + "eslint-config-standard": "^16.0.3", + "eslint-plugin-import": "^2.23.4", + "eslint-plugin-jest": "^24.3.6", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^5.1.0", + "form-data": "^4.0.0", + "jest": "29.3", + "jest-environment-jsdom": "^29.3.1", + "jest-junit": "^12.2.0", + "nock": "^13.1.3", + "node-fetch": "^2.6.1", + "parse-multipart-data": "^1.5.0", + "ts-jest": "29.0", + "typedoc": "0.22.11", + "typedoc-plugin-markdown": "3.11.13", + "typescript": "^4.3.5" } }, "@aemforms/af-custom-functions": { diff --git a/ui.frontend/package.json b/ui.frontend/package.json index 3ed09dfea5..4fe9ec92ed 100644 --- a/ui.frontend/package.json +++ b/ui.frontend/package.json @@ -23,7 +23,7 @@ "webpack-merge": "^5.8.0" }, "dependencies": { - "@aemforms/af-core": "^0.22.104", + "@aemforms/af-core": "file:///Users/rismehta/af2-web-runtime/packages/forms-next-core", "@aemforms/af-formatters": "^0.22.104", "@aemforms/af-custom-functions": "1.0.10" } From 8caaca268312e1dede5fa66724640395c194966e Mon Sep 17 00:00:00 2001 From: Rishi Mehta Date: Wed, 25 Sep 2024 11:47:26 +0530 Subject: [PATCH 2/9] Adding test collateral --- .../models/v1/form/FileInputImpl.java | 2 +- .../models/form/BaseConstraint.java | 2 +- .../models/form/FileConstraint.java | 2 +- .../page-fileinputv3/customfooterlibs.html | 2 +- .../fileinput/fileinputstring/.content.xml | 7 + .../fileinputstring/basic/.content.xml | 23 +++ .../fileinput/fileinputstring/.content.xml | 5 + .../fileinputstring/basic/.content.xml | 89 ++++++++ .../specs/fileinput/fileinput.authoring.cy.js | 1 + .../fileinput/fileinputstring.runtime.cy.js | 192 ++++++++++++++++++ 10 files changed, 321 insertions(+), 4 deletions(-) create mode 100755 it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/fileinput/fileinputstring/.content.xml create mode 100755 it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/fileinput/fileinputstring/basic/.content.xml create mode 100644 it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/fileinput/fileinputstring/.content.xml create mode 100644 it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/fileinput/fileinputstring/basic/.content.xml create mode 100644 ui.tests/test-module/specs/fileinput/fileinputstring.runtime.cy.js diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileInputImpl.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileInputImpl.java index 1a2e967e4e..ae08989c33 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileInputImpl.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FileInputImpl.java @@ -73,7 +73,7 @@ public Integer getMaxItems() { @Override public Type getType() { Type superType = super.getType(); - if (superType == null) { + if (superType == null || superType == Type.FILE) { return isMultiple() ? Type.FILE_ARRAY : Type.FILE; } if (isMultiple() && superType == Type.STRING) { diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/BaseConstraint.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/BaseConstraint.java index f9127314a3..0bc56bfffb 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/BaseConstraint.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/BaseConstraint.java @@ -35,7 +35,7 @@ public interface BaseConstraint { * * @since com.adobe.cq.forms.core.components.models.form 0.0.1 */ - public enum type { + public enum Type { STRING("string"), STRING_ARRAY("string[]"), NUMBER("number"), diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FileConstraint.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FileConstraint.java index 7c0ece5245..9b53a9632c 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FileConstraint.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FileConstraint.java @@ -59,7 +59,7 @@ default List getAccept() { /** * The constraint is - * applicable for file attachment field. If the type is {@code String}, the format will always be {@code dataurl}. + * applicable for file attachment field. If the type is {@code String}, the format will always be {@code data-url}. * * @since com.adobe.cq.forms.core.components.models.form 5.7.4 */ diff --git a/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/page-fileinputv3/customfooterlibs.html b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/page-fileinputv3/customfooterlibs.html index 4e75eebfc8..303e22ea40 100644 --- a/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/page-fileinputv3/customfooterlibs.html +++ b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/page-fileinputv3/customfooterlibs.html @@ -20,7 +20,7 @@ - + diff --git a/it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/fileinput/fileinputstring/.content.xml b/it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/fileinput/fileinputstring/.content.xml new file mode 100755 index 0000000000..7256712059 --- /dev/null +++ b/it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/fileinput/fileinputstring/.content.xml @@ -0,0 +1,7 @@ + + diff --git a/it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/fileinput/fileinputstring/basic/.content.xml b/it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/fileinput/fileinputstring/basic/.content.xml new file mode 100755 index 0000000000..d69958e530 --- /dev/null +++ b/it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/fileinput/fileinputstring/basic/.content.xml @@ -0,0 +1,23 @@ + + + + + + \ No newline at end of file diff --git a/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/fileinput/fileinputstring/.content.xml b/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/fileinput/fileinputstring/.content.xml new file mode 100644 index 0000000000..bbf62ed22c --- /dev/null +++ b/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/fileinput/fileinputstring/.content.xml @@ -0,0 +1,5 @@ + +