From 69548597f78a2f5163706831f40d99e6b2d6a5ce Mon Sep 17 00:00:00 2001 From: Edward Modecki-Mellett Date: Wed, 4 Jan 2017 15:26:15 -0500 Subject: [PATCH] Adding display of fieldLabel and fieldDescription to Touch UI inner fields. --- .gitignore | 4 +- pom.xml | 4 +- .../multicomposite/readonly/readonly.jsp | 11 ++ .../granite/multicomposite/render.jsp | 24 +++- .../clientlibs/multicomposite-touchui/css.txt | 2 +- .../css/Multicomposite.less | 115 ++++++++++++++++++ .../css/Mutlicomposite.css | 79 ------------ .../multicompositeaddon/Multicomposite.java | 26 +++- 8 files changed, 176 insertions(+), 89 deletions(-) create mode 100644 src/main/content/jcr_root/etc/clientlibs/multicomposite-touchui/css/Multicomposite.less delete mode 100644 src/main/content/jcr_root/etc/clientlibs/multicomposite-touchui/css/Mutlicomposite.css diff --git a/.gitignore b/.gitignore index b6b7b69..4fac44e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ .classpath .groovy .settings/ -target/ \ No newline at end of file +target/ +nb-configuration.xml + diff --git a/pom.xml b/pom.xml index 0db13e7..c26410f 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 4.0.0 multicomposite-addon bundle - 2.1.3 + 2.1.4-SNAPSHOT AEM Multicomposite Addon Adds multicomposite field to AEM @@ -22,7 +22,7 @@ ${maven.build.timestamp} admin - + sonatype-nexus-staging diff --git a/src/main/content/jcr_root/apps/multicomposite/granite/multicomposite/readonly/readonly.jsp b/src/main/content/jcr_root/apps/multicomposite/granite/multicomposite/readonly/readonly.jsp index c73e463..978fc09 100644 --- a/src/main/content/jcr_root/apps/multicomposite/granite/multicomposite/readonly/readonly.jsp +++ b/src/main/content/jcr_root/apps/multicomposite/granite/multicomposite/readonly/readonly.jsp @@ -16,6 +16,17 @@
+ + + + + + +
diff --git a/src/main/content/jcr_root/apps/multicomposite/granite/multicomposite/render.jsp b/src/main/content/jcr_root/apps/multicomposite/granite/multicomposite/render.jsp index d6654c5..4d0af5d 100644 --- a/src/main/content/jcr_root/apps/multicomposite/granite/multicomposite/render.jsp +++ b/src/main/content/jcr_root/apps/multicomposite/granite/multicomposite/render.jsp @@ -9,11 +9,22 @@
    -
  1. +
  2. + + + + + + + @@ -31,6 +42,17 @@
    + + + + + + + diff --git a/src/main/content/jcr_root/etc/clientlibs/multicomposite-touchui/css.txt b/src/main/content/jcr_root/etc/clientlibs/multicomposite-touchui/css.txt index 0649dae..21aab42 100644 --- a/src/main/content/jcr_root/etc/clientlibs/multicomposite-touchui/css.txt +++ b/src/main/content/jcr_root/etc/clientlibs/multicomposite-touchui/css.txt @@ -1,3 +1,3 @@ #base=css -Mutlicomposite.css \ No newline at end of file +Multicomposite.less \ No newline at end of file diff --git a/src/main/content/jcr_root/etc/clientlibs/multicomposite-touchui/css/Multicomposite.less b/src/main/content/jcr_root/etc/clientlibs/multicomposite-touchui/css/Multicomposite.less new file mode 100644 index 0000000..791b1fd --- /dev/null +++ b/src/main/content/jcr_root/etc/clientlibs/multicomposite-touchui/css/Multicomposite.less @@ -0,0 +1,115 @@ +/* Multicompositefield.form.styl */ + +.coral-Form--vertical .coral-Form-field.coral-Multicompositefield { + display: block; +} + +/* Multicompositefield.dark.styl */ + +.coral--dark .coral-Multicompositefield, +.coral--dark.coral-Multicompositefield { + border-color: #434343; + background-color: #484848; +} + +.coral-Form-field.coral-Multifield.coral-Multicompositefield { + .coral-Multicompositefield-add { + margin-top: .625rem; + } + + .coral-Multicompositefield-remove { + position: absolute; + top: 0; + right: 2.375rem; + margin-top: 0.5rem; + } + + .coral-Multicompositefield-move { + cursor: url("coralui2/resources/shared/cursors/Cur_Hand_11_11.cur"),move; + cursor: -webkit-grab; + cursor: -moz-grab; + position: absolute; + top: 0; + right: 0; + margin-top: 0.5rem; + } + + .coral-Multicompositefield-move:active { + cursor: url("coralui2/resources/shared/cursors/Cur_Fist_11_11.cur"),default !important; + cursor: -webkit-grabbing !important; + cursor: -moz-grabbing !important; + } + + .coral-Multicompositefield-input { + position: relative; + margin-top: .5rem; + padding-right: 0; + margin-right: 0; + } + + .coral-Multicompositefield-input:first-child { + margin-top: 0; + } + + .coral-Multicompositefield-input > :first-child { + width: 100%; + } + + .coral-Multicompositefield-input:only-child .coral-Multicompositefield-move { + display: none; + } + + .coral-Multicompositefield-input.is-dragging { + opacity: .9; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=90)"; + filter: alpha(opacity=90); + position: absolute; + top: 0; + left: 0; + z-index: 10000; + } + + .coral-Multicompositefield-input.is-dragging:first-child + .coral-Multicompositefield-input { + margin-top: 0; + } + + .coral-Multicompositefield-input + .coral-Multicompositefield-input { + margin-top: .625rem; + } + + .coral-Multicompositefield-input--dragAfter { + position: relative; + top: 3rem; + } + + .multicompositefield-list { + li { + padding-top: 1rem; + &:not(:first-child) { + border-top: 1px solid #3c3c3c; + margin-top: 1rem; + } + } + } + + .multicompositefield-item { + padding-top: 1rem; + .coral-Form-fieldlabel { + min-height: auto; + margin-top: 0.2rem; + line-height: 1.0625rem; + } + + .multicompositefield-field { + position: relative; + } + + .coral-Form-fieldinfo { + float: right; + margin-top: 0.5rem; + &:after { + clear: both; + } + } + } +} diff --git a/src/main/content/jcr_root/etc/clientlibs/multicomposite-touchui/css/Mutlicomposite.css b/src/main/content/jcr_root/etc/clientlibs/multicomposite-touchui/css/Mutlicomposite.css deleted file mode 100644 index f3e9d0b..0000000 --- a/src/main/content/jcr_root/etc/clientlibs/multicomposite-touchui/css/Mutlicomposite.css +++ /dev/null @@ -1,79 +0,0 @@ -.coral-Multicompositefield-add { - margin-top: .625rem; -} - -.coral-Multicompositefield-remove { - position: absolute; - top: 0; - right: 2.375rem; -} - -.coral-Multicompositefield-move { - cursor: url("coralui2/resources/shared/cursors/Cur_Hand_11_11.cur"),move; - cursor: -webkit-grab; - cursor: -moz-grab; - position: absolute; - top: 0; - right: 0; -} - -.coral-Multicompositefield-move:active { - cursor: url("coralui2/resources/shared/cursors/Cur_Fist_11_11.cur"),default !important; - cursor: -webkit-grabbing !important; - cursor: -moz-grabbing !important; -} - -.coral-Multicompositefield-input { - position: relative; - margin-top: .5rem; - padding-right: 4.75rem; -} - -.coral-Multicompositefield-input:first-child { - margin-top: 0; -} - -.coral-Multicompositefield-input > :first-child { - width: 100%; -} - -.coral-Multicompositefield-input:only-child .coral-Multicompositefield-move { - display: none; -} - -.coral-Multicompositefield-input.is-dragging { - opacity: .9; - -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=90)"; - filter: alpha(opacity=90); - position: absolute; - top: 0; - left: 0; - z-index: 10000; -} - -.coral-Multicompositefield-input.is-dragging:first-child + .coral-Multicompositefield-input { - margin-top: 0; -} - -.coral-Multicompositefield-input + .coral-Multicompositefield-input { - margin-top: .625rem; -} - -.coral-Multicompositefield-input--dragAfter { - position: relative; - top: 3rem; -} - -/* Multicompositefield.form.styl */ - -.coral-Form--vertical .coral-Form-field.coral-Multicompositefield { - display: block; -} - -/* Multicompositefield.dark.styl */ - -.coral--dark .coral-Multicompositefield, -.coral--dark.coral-Multicompositefield { - border-color: #434343; - background-color: #484848; -} diff --git a/src/main/java/com/citytechinc/aem/multicompositeaddon/Multicomposite.java b/src/main/java/com/citytechinc/aem/multicompositeaddon/Multicomposite.java index 25ae1cc..d9b4d84 100644 --- a/src/main/java/com/citytechinc/aem/multicompositeaddon/Multicomposite.java +++ b/src/main/java/com/citytechinc/aem/multicompositeaddon/Multicomposite.java @@ -34,7 +34,7 @@ public Multicomposite(ComponentHelper component, I18n i18n, SlingHttpServletRequ Config config = component.getConfig(); attributes = buildAttributes(config, component.consumeTag()); readOnlyAttributes = buildReadOnlyAttributes(component); - fields = buildFields(config); + fields = buildFields(component); parentContentPath = (String) request.getAttribute("multiParentContentPath"); name = StringUtils.isNotEmpty((String) request.getAttribute("multiPath")) ? (String) request @@ -75,12 +75,12 @@ private String buildReadOnlyAttributes(ComponentHelper component) { return attrBuilder.build(); } - private List buildFields(Config config) { + private List buildFields(ComponentHelper component) { List fields = new ArrayList(); - Resource fieldsResource = config.getChild("fields"); + Resource fieldsResource = component.getConfig().getChild("fields"); if (fieldsResource != null && !ResourceUtil.isNonExistingResource(fieldsResource)) { for (Resource fieldResource : fieldsResource.getChildren()) { - fields.add(new SubField(fieldResource)); + fields.add(new SubField(fieldResource, component)); } } return fields; @@ -137,12 +137,20 @@ public String getFieldLabel() { public class SubField { private final String name; + private final String fieldLabel; + private final String fieldDescription; private final String resourceType; private final String path; - public SubField(final Resource component) { + public SubField(final Resource component, final ComponentHelper helper) { ValueMap valueMap = component.adaptTo(ValueMap.class); this.name = valueMap.get("name", ""); + this.fieldLabel = helper.getXss().encodeForHTML(i18n.getVar(valueMap.get("fieldLabel", ""))); + this.fieldDescription = helper.getXss().encodeForHTMLAttr( + i18n.getVar( + valueMap.get("fieldDescription", "") + ) + ); this.path = component.getPath(); this.resourceType = component.getResourceType(); } @@ -155,6 +163,14 @@ public String getName() { return name; } + public String getFieldLabel() { + return fieldLabel; + } + + public String getFieldDescription() { + return fieldDescription; + } + public String getResourceType() { return resourceType; }