Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: show/hide widgets features cannot handle complex input fields like Image or FileUpload #1745

Conversation

alberndt
Copy link

@alberndt alberndt commented Feb 6, 2019

Currently the show/hide-widgets features works only for simple dialog fields. More complex dialog fields of Coral UI using a wrapper DIV (e.g. Image, FileUpload), and the jQuery selector of show/hide-widgets will hide the field, but never unhides it.

This is because the css-class is assigned to the wrapper DIV, while the "showhidetargetvalue" is rendered at the main input field. I extended the jQuery selector to unhide also dialog-field, when they contain an input-element with showhidetargetvalue.

The following cq:dialog is an example, that works after the fix (and not before).

{
  "image": {
    "useHTML5": true,
    "mimeTypes": [
      "image"
    ],
    "name": "./file",
    "fieldLabel": "Image",
    "allowUpload": false,
    "sling:resourceType": "granite/ui/components/foundation/form/fileupload",
    "uploadUrl": "${suffix.path}"
  },
  "altText": {
    "name": "./altText",
    "fieldLabel": "ALT Text",
    "sling:resourceType": "granite/ui/components/foundation/form/textfield"
  },
  "enableSmallImage": {
    "cq-dialog-showhide-target": ".dch-small-image-widget",
    "name": "./enableSmallImage",
    "text": "Enable alternative Image for small screens",
    "sling:resourceType": "granite/ui/components/foundation/form/checkbox",
    "cq-dialog-checkbox-showhide": ""
  },
  "imageSmall": {
    "useHTML5": true,
    "showhidetargetvalue": true,
    "mimeTypes": [
      "image"
    ],
    "name": "./imageSmall/file",
    "class": "dch-small-image-widget",
    "fieldLabel": "Alternative Image (small screens)",
    "allowUpload": false,
    "sling:resourceType": "granite/ui/components/foundation/form/fileupload",
    "uploadUrl": "${suffix.path}"
  },
  "altTextSmall": {
    "showhidetargetvalue": true,
    "name": "./imageSmall/altText",
    "class": "dch-small-image-widget",
    "fieldLabel": "ALT Text (small screens)",
    "sling:resourceType": "granite/ui/components/foundation/form/textfield"
  }
}

Alexander Berndt added 2 commits February 6, 2019 14:43
…class is added the a wrapper-div, while the unhide-attribute is stored at the input-field. So the hide/unhide configuration is distributed in two different dom-nodes.
…class is added the a wrapper-div, while the unhide-attribute is stored at the input-field. So the hide/unhide configuration is distributed in two different dom-nodes.
@justinedelson justinedelson added this to the 4.0.0 milestone Feb 12, 2019
@justinedelson justinedelson merged commit 38b4155 into Adobe-Consulting-Services:master Feb 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants