Skip to content

Commit

Permalink
Don't show placeholder in tokenfield if token is present
Browse files Browse the repository at this point in the history
Dynamically adds and removes placeholders from the tokenfield, since the underlying lib will always show it
  • Loading branch information
Marc Egenrieder committed Jan 31, 2019
1 parent acce4db commit c9bc9c6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

<div id="@id" class="multiselect">
<w:textfield id="@apply('%s-input',id)" name="@apply('%s-input', name)" span="@span" smallSpan="@smallSpan"
value="" label="@label" help="@help" adminOnly="@adminOnly" readonly="@readonly" required="@required"
placeholder="@i18n('template.html.selects.selection')"/>
value="" label="@label" help="@help" adminOnly="@adminOnly" readonly="@readonly" required="@required"/>
</div>

<select id="@id-suggestions-select" style="display: none" multiple="multiple">
Expand All @@ -41,6 +40,7 @@
noMatchesText: '@i18n("template.html.selects.noMatches")',
readonly: @readonly,
maxItems: @maxItems,
placeholder: '@i18n('template.html.selects.selection')',
allowCustomEntries: !@strict,
serviceUri: '@serviceUri',
type: '@type'
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/default/taglib/w/multiSelect.html.pasta
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

<div id="@id" class="multiselect">
<w:textfield id="@apply('%s-input',id)" name="@apply('%s-input', name)" span="@span" smallSpan="@smallSpan"
value="" label="@label" help="@help" adminOnly="@adminOnly" readonly="@readonly" required="@required"
placeholder="@i18n('template.html.selects.selection')"/>
value="" label="@label" help="@help" adminOnly="@adminOnly" readonly="@readonly" required="@required"/>
</div>

<select id="@id-suggestions-select" style="display: none" multiple="multiple">
Expand All @@ -38,6 +37,7 @@
name: '@name',
noMatchesText : '@i18n("template.html.selects.noMatches")',
readonly: @readonly,
placeholder: '@i18n('template.html.selects.selection')',
maxItems: @maxItems,
allowCustomEntries: @allowCustomEntries
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,8 @@
} else {
token.label = suggestions.getTokenForValue(token.value).label;
}

tokenfield.getTokenfieldInputField()[0].placeholder = '';
return true;
});

Expand All @@ -662,6 +664,16 @@

tokenfield.appendTokens(suggestions.getInitialSelection());

if (!tokenfield.hasTokens()) {
tokenfield.getTokenfieldInputField()[0].placeholder = args.placeholder;
}

tokenfield.on('onRemovedToken', function () {
if (!tokenfield.hasTokens()) {
tokenfield.getTokenfieldInputField()[0].placeholder = args.placeholder;
}
});

if (!args.readonly) {
var noMatchesToken = {label: args.noMatchesText, type: 'basic'};

Expand Down

0 comments on commit c9bc9c6

Please sign in to comment.