Skip to content

Commit

Permalink
#180 - Add admin field hint, help, and tooltip support
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Azzolini committed Jan 10, 2014
1 parent a5ec5ee commit 53ce888
Show file tree
Hide file tree
Showing 27 changed files with 102 additions and 7 deletions.
Expand Up @@ -17,6 +17,7 @@
package org.broadleafcommerce.openadmin.web.form.entity;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.broadleafcommerce.common.presentation.client.SupportedFieldType;


Expand Down Expand Up @@ -49,6 +50,9 @@ public class Field {
protected Boolean isFilterSortDisabled;
protected Boolean isDerived;
protected Boolean isLargeEntry;
protected String hint;
protected String tooltip;
protected String help;

/* ************ */
/* WITH METHODS */
Expand Down Expand Up @@ -143,11 +147,26 @@ public Field withDerived(Boolean isDerived) {
setDerived(isDerived);
return this;
}

public Field withLargeEntry(Boolean isLargeEntry) {
setLargeEntry(isLargeEntry);
return this;
}

public Field withHint(String hint) {
setHint(hint);
return this;
}

public Field withHelp(String help) {
setHelp(help);
return this;
}

public Field withTooltip(String tooltip) {
setTooltip(tooltip);
return this;
}

/* ************************ */
/* CUSTOM GETTERS / SETTERS */
Expand Down Expand Up @@ -348,5 +367,28 @@ public Boolean getIsLargeEntry() {
public void setLargeEntry(Boolean isLargeEntry) {
this.isLargeEntry = isLargeEntry;
}


public String getHint() {
return StringUtils.isBlank(hint) ? null : hint;
}

public void setHint(String hint) {
this.hint = hint;
}

public String getTooltip() {
return StringUtils.isBlank(tooltip) ? null : tooltip;
}

public void setTooltip(String tooltip) {
this.tooltip = tooltip;
}

public String getHelp() {
return StringUtils.isBlank(help) ? null : help;
}

public void setHelp(String help) {
this.help = help;
}
}
Expand Up @@ -483,7 +483,10 @@ protected void setEntityFormFields(EntityForm ef, List<Property> properties) {
.withReadOnly(fmd.getReadOnly())
.withTranslatable(fmd.getTranslatable())
.withAlternateOrdering((Boolean) fmd.getAdditionalMetadata().get(Field.ALTERNATE_ORDERING))
.withLargeEntry(fmd.isLargeEntry());
.withLargeEntry(fmd.isLargeEntry())
.withHint(fmd.getHint())
.withTooltip(fmd.getTooltip())
.withHelp(fmd.getHelpText());

if (StringUtils.isBlank(f.getFriendlyName())) {
f.setFriendlyName(f.getName());
Expand Down
Expand Up @@ -89,6 +89,12 @@ span.error {
color: inherit;
}

.field-tooltip {
color: #8EAA2B;
cursor: pointer;
padding: 0 3px;
}

input[type="search"] {
-webkit-appearance: none;
padding: 0px;
Expand All @@ -105,6 +111,7 @@ input[type="text"], input[type="password"], input[type="date"], input[type="date

.foreign-key-value-container,
.entity-form .custom.dropdown,
span.field-help,
.indented-form-value,
.entity-form input[type="text"], .entity-form input[type="password"], .entity-form input[type="date"], .entity-form input[type="datetime"], .entity-form input[type="email"], .entity-form input[type="number"], .entity-form input[type="search"], .entity-form input[type="tel"], .entity-form input[type="time"], .entity-form input[type="url"], .entity-form textarea {
margin: 7px 0 0px 0px;
Expand Down Expand Up @@ -136,11 +143,16 @@ fieldset div.field-box:last-child {
margin-bottom: 0;
}

span.field-help,
.indented-form-value {
display: block;
font-size: 12px;
}

span.field-help {
color: #555;
}

fieldset {
background-color: #FAFAFA;
margin: 0 0 25px 0;
Expand Down
Expand Up @@ -59,6 +59,9 @@
<div th:unless="${field.readOnly}" th:remove="tag">
<div th:substituteby="${'fields/' + #strings.toLowerCase(field.fieldType)}" />
</div>

<span th:if="${field.help}" class="field-help" th:text="#{${field.help}}" />

</div>
</fieldset>

Expand Down
@@ -0,0 +1,3 @@
<i th:if="${field.tooltip}"
class="has-tip tip-right field-tooltip icon-question"
th:attr="title=#{${field.tooltip}}" />
@@ -1,6 +1,7 @@
<blc_admin:admin_field_builder fieldBuilder="${field.fieldBuilder}">

<div class="field-label" th:if="${!field.required}" th:text="#{${field.friendlyName + '_Question'}}" />
<div class="field-label inline" th:if="${!field.required}" th:text="#{${field.friendlyName + '_Question'}}" />
<div th:substituteby="components/fieldTooltip" />

<div th:classappend="${field.styleClass}">

Expand Down
@@ -1,5 +1,6 @@
<div th:if="${field instanceof T(org.broadleafcommerce.openadmin.web.form.entity.ComboField)}">
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />

<select class="six" th:field="*{fields['__${field.name}__'].value}" th:if="${! #maps.isEmpty(field.options)}">
<option value="" th:text="#{Default_Select}" />
Expand Down
@@ -1,5 +1,7 @@
<div class="asset-selector-container">
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />

<span class="error" th:errors="*{fields['__${field.name}__'].value}" />
<a class="show-asset-freeform-url" href="#" th:text="'(' + #{Freeform_URL} + ')'" />
<br/>
Expand Down
@@ -1,4 +1,6 @@
<div class="field-label" th:text="#{asset_url_image_label}" />
<div th:substituteby="components/fieldTooltip" />

<img class="thumbnail"
th:if="*{fields['__${field.name}__'].value != null}"
blc:src="@{${cmsUrlPrefix} + *{fields['__${field.name}__'].value} + '?largeAdminThumbnail'}"
Expand Down
@@ -1,4 +1,5 @@
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />
<span class="error" th:errors="*{fields['__${field.name}__'].value}" />

<div class="custom-checkbox">
Expand Down
@@ -1,4 +1,5 @@
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />
<span class="error" th:errors="*{fields['__${field.name}__'].value}" />

<select class="six" th:field="*{fields['__${field.name}__'].value}"
Expand Down
@@ -1,4 +1,5 @@
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />
<span class="error" th:errors="*{fields['__${field.name}__'].value}" />
<br />

Expand Down
@@ -1,4 +1,5 @@
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />
<span class="error" th:errors="*{fields['__${field.name}__'].value}" />

<select class="six" th:field="*{fields['__${field.name}__'].value}">
Expand Down
@@ -1,4 +1,5 @@
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />
<span class="error" th:errors="*{fields['__${field.name}__'].value}" />

<select class="six" th:field="*{fields['__${field.name}__'].value}"
Expand Down
@@ -1,4 +1,5 @@
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />
<span class="error" th:errors="*{fields['__${field.name}__'].value}" />

<div class="datepicker-container">
Expand Down
@@ -1,3 +1,4 @@
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />
<span class="error" th:errors="*{fields['__${field.name}__'].value}" />
<input type="text" class="two" th:field="*{fields['__${field.name}__'].value}" />
@@ -1,4 +1,5 @@
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />
<span class="error" th:errors="*{fields['__${field.name}__'].value}" />
<select class="six" th:field="*{fields['__${field.name}__'].value}">
<option th:each="entry : *{fields['__${field.name}__'].options}"
Expand Down
@@ -1,4 +1,5 @@
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />
<div th:substituteby="components/fieldTranslation" />
<span class="error" th:errors="*{fields['__${field.name}__'].value}" />

Expand Down
@@ -1,4 +1,5 @@
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />
<div th:substituteby="components/fieldTranslation" />
<span class="error" th:errors="*{fields['__${field.name}__'].value}" />

Expand Down
@@ -1,3 +1,4 @@
<div class="field-label inline" th:text="#{${field.friendlyName}}" />
<div th:substituteby="components/fieldTooltip" />
<span class="error" th:errors="*{fields['__${field.name}__'].value}" />
<input type="text" class="four" th:field="*{fields['__${field.name}__'].value}" />
@@ -1,3 +1,4 @@
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />
<span class="error" th:errors="*{fields['__${field.name}__'].value}" />
<input type="text" class="two" th:field="*{fields['__${field.name}__'].value}" />
@@ -1,5 +1,8 @@
<div class="asset-selector-container">
<div class="field-label" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />
<br />

<input type="hidden" class="mediaItem" th:field="*{fields['__${field.name}__'].value}" />

<a th:if="*{fields['__${field.name}__'].media != null and !#strings.isEmpty(fields['__${field.name}__'].media.url)}"
Expand Down
@@ -1,3 +1,4 @@
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />
<span class="error" th:errors="*{fields['__${field.name}__'].value}" />
<input type="text" step=".01" class="two" th:field="*{fields['__${field.name}__'].value}" />
@@ -1,3 +1,4 @@
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />
<span class="error" th:errors="*{fields['__${field.name}__'].value}" />
<input type="password" class="twelve" th:field="*{fields['__${field.name}__'].value}" />
@@ -1,4 +1,5 @@
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />
<div class="twelve" style="margin-left: 20px; margin-bottom: 10px;" th:switch="*{fields['__${field.name}__'].fieldType}">

<span th:case="'MEDIA'" th:remove="tag">
Expand Down
@@ -1,7 +1,14 @@
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />
<div th:substituteby="components/fieldTranslation" />
<span class="error" th:errors="*{fields['__${field.name}__'].value}" />

<div th:if="*{fields['__${field.name}__'].isLargeEntry}" class="twelve indented-form-value">
<textarea class="autosize" style="width: 100%;" th:field="*{fields['__${field.name}__'].value}"/>
<textarea class="autosize" style="width: 100%;"
th:field="*{fields['__${field.name}__'].value}"
th:placeholder="${field.hint}" />
</div>
<input th:unless="*{fields['__${field.name}__'].isLargeEntry}" type="text" class="twelve" th:required="${field.required}" th:field="*{fields['__${field.name}__'].value}" />
<input th:unless="*{fields['__${field.name}__'].isLargeEntry}" type="text" class="twelve"
th:required="${field.required}"
th:placeholder="${field.hint}"
th:field="*{fields['__${field.name}__'].value}" />
@@ -1,4 +1,5 @@
<div class="field-label inline" th:text="#{${field.friendlyName}}" th:classappend="${field.required ? 'required' : ''}" />
<div th:substituteby="components/fieldTooltip" />
<span class="error" th:errors="*{fields['__${field.name}__'].value}" />
<div th:if="*{fields['__${field.name}__'].isLargeEntry}" class="twelve indented-form-value">
<textarea class="autosize" style="width: 100%;" th:field="*{fields['__${field.name}__'].value}"/>
Expand Down

0 comments on commit 53ce888

Please sign in to comment.