Skip to content

Commit 5795dc0

Browse files
hiding info icon as per extensions support
1 parent e447c0e commit 5795dc0

File tree

3 files changed

+23
-0
lines changed
  • bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v3/form
  • ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/fileinput/v3/fileinput

3 files changed

+23
-0
lines changed

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v3/form/FileInputImplV3.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ public String getDragDropText() {
7070

7171
@Override
7272
public List<String> getAcceptExtensions() {
73+
// adding . in front of the accept extensions
74+
if (acceptExtensions != null) {
75+
for (int i = 0; i < acceptExtensions.length; i++) {
76+
acceptExtensions[i] = "." + acceptExtensions[i];
77+
}
78+
}
7379
return Optional.ofNullable(acceptExtensions)
7480
.map(Arrays::asList)
7581
.orElse(Collections.emptyList());

ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/fileinput/v3/fileinput/_cq_dialog/.content.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
jcr:primaryType="nt:unstructured"
104104
sling:resourceType="fd/af/authoring/components/granite/form/formsmultifield"
105105
fieldLabel="Allowed file types"
106+
fieldDescription="This field got disabled as the allowed file extensions are specified."
106107
defaultValue="">
107108
<field
108109
name="./accept"

ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/fileinput/v3/fileinput/clientlibs/editor/js/editDialog.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
let mimeTypeWrapper = dialog.find(FILEINPUT_MIMETYPE);
2525
let mimeTypeField = mimeTypeWrapper.find("coral-multifield");
2626
let extensionsField = dialog.find(FILEINPUT_EXTENSIONS + " coral-multifield");
27+
let mimeTypeFieldInfoIcon = mimeTypeWrapper.find('coral-icon.coral-Form-fieldinfo');
2728

2829
function updateMimeTypeState() {
2930
let hasExtensions = extensionsField.find('coral-multifield-item').length > 0;
@@ -44,11 +45,26 @@
4445
if (hasExtensions) {
4546
// Keep first item, remove others
4647
let firstItem = mimeTypeField.find('coral-multifield-item').first();
48+
49+
// If no first item exists, create one
50+
if (firstItem.length === 0) {
51+
// Click the add button to create a new item
52+
mimeTypeField.find('button[coral-multifield-add]').click();
53+
firstItem = mimeTypeField.find('coral-multifield-item').first();
54+
}
55+
4756
mimeTypeField.find('coral-multifield-item:not(:first)').remove();
4857

4958
// Set value of first item to */*
5059
firstItem.find('input').val('*/*');
5160
}
61+
62+
if(mimeTypeFieldInfoIcon.length > 0) {
63+
// show the info icon
64+
mimeTypeFieldInfoIcon.css({
65+
'display': hasExtensions ? '' : 'none'
66+
});
67+
}
5268
}
5369

5470
// Watch for changes in both fields

0 commit comments

Comments
 (0)