From c9bc9c6837a357da5ab39ea98524ccfd6160deb4 Mon Sep 17 00:00:00 2001 From: Marc Egenrieder Date: Thu, 31 Jan 2019 18:28:56 +0100 Subject: [PATCH] Don't show placeholder in tokenfield if token is present Dynamically adds and removes placeholders from the tokenfield, since the underlying lib will always show it --- .../taglib/w/autocompleteMultiSelect.html.pasta | 4 ++-- .../default/taglib/w/multiSelect.html.pasta | 4 ++-- .../templates/wondergem/page-script.html.pasta | 12 ++++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/resources/default/taglib/w/autocompleteMultiSelect.html.pasta b/src/main/resources/default/taglib/w/autocompleteMultiSelect.html.pasta index 8bf4526c8..3a327bc29 100644 --- a/src/main/resources/default/taglib/w/autocompleteMultiSelect.html.pasta +++ b/src/main/resources/default/taglib/w/autocompleteMultiSelect.html.pasta @@ -21,8 +21,7 @@
+ value="" label="@label" help="@help" adminOnly="@adminOnly" readonly="@readonly" required="@required"/>
@@ -38,6 +37,7 @@ name: '@name', noMatchesText : '@i18n("template.html.selects.noMatches")', readonly: @readonly, + placeholder: '@i18n('template.html.selects.selection')', maxItems: @maxItems, allowCustomEntries: @allowCustomEntries }); diff --git a/src/main/resources/default/templates/wondergem/page-script.html.pasta b/src/main/resources/default/templates/wondergem/page-script.html.pasta index 21af15751..fe45c53e2 100644 --- a/src/main/resources/default/templates/wondergem/page-script.html.pasta +++ b/src/main/resources/default/templates/wondergem/page-script.html.pasta @@ -647,6 +647,8 @@ } else { token.label = suggestions.getTokenForValue(token.value).label; } + + tokenfield.getTokenfieldInputField()[0].placeholder = ''; return true; }); @@ -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'};