Skip to content

Commit

Permalink
Merge pull request #562 from scireum/meg/placeHoldMe
Browse files Browse the repository at this point in the history
Don't show placeholder in tokenfield if token is present
  • Loading branch information
andyHa authored Jan 31, 2019
2 parents 7e79256 + c9bc9c6 commit 8274673
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 @@ -643,6 +643,8 @@
} else {
token.label = suggestions.getTokenForValue(token.value).label;
}

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

Expand All @@ -658,6 +660,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 8274673

Please sign in to comment.