From c319c0b3e002f35523baec7df4d07b9d975dde7b Mon Sep 17 00:00:00 2001 From: seif Date: Mon, 18 Aug 2014 15:04:49 -0600 Subject: [PATCH] Make using a hint (or no results) text more flexible --- ui/lib/jquery.tokeninput.js | 4 ++-- ui/scripts/system.js | 16 ++++++++++++---- ui/scripts/ui/dialog.js | 18 ++---------------- ui/scripts/ui/widgets/detailView.js | 26 ++++++-------------------- 4 files changed, 22 insertions(+), 42 deletions(-) diff --git a/ui/lib/jquery.tokeninput.js b/ui/lib/jquery.tokeninput.js index 638ce68002d..182ed058fb5 100644 --- a/ui/lib/jquery.tokeninput.js +++ b/ui/lib/jquery.tokeninput.js @@ -21,8 +21,8 @@ var DEFAULT_SETTINGS = { jsonContainer: null, // Display settings - hintText: "Type in part of a storage tag", - noResultsText: "No storage tags found", + hintText: "Type in a search term", + noResultsText: "No results", searchingText: "Searching...", deleteText: "×", animateDropdown: true, diff --git a/ui/scripts/system.js b/ui/scripts/system.js index f0e97e50c98..fe51acb42f3 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -15197,7 +15197,9 @@ } args.response.success({ - data: tags + data: tags, + hintText: "Type in part of a host tag", + noResultsText: "No host tags found" }); }, error: function(XMLHttpResponse) { @@ -15790,7 +15792,9 @@ } args.response.success({ - data: tags + data: tags, + hintText: "Type in part of a host tag", + noResultsText: "No host tags found" }); }, error: function(XMLHttpResponse) { @@ -16970,7 +16974,9 @@ } args.response.success({ - data: tags + data: tags, + hintText: "Type in part of a storage tag", + noResultsText: "No storage tags found" }); }, error: function(XMLHttpResponse) { @@ -17329,7 +17335,9 @@ } args.response.success({ - data: tags + data: tags, + hintText: "Type in part of a storage tag", + noResultsText: "No storage tags found" }); }, error: function(XMLHttpResponse) { diff --git a/ui/scripts/ui/dialog.js b/ui/scripts/ui/dialog.js index 41cbef09ad1..6c77924123b 100644 --- a/ui/scripts/ui/dialog.js +++ b/ui/scripts/ui/dialog.js @@ -467,20 +467,6 @@ } else if (field.isTokenInput) { // jquery.tokeninput.js isAsync = true; - var hint= "Type in a search term"; - var noResults= "No results"; - - if (field.label === 'label.storage.tags') - { - hint = "Type in part of a storage tag"; - noResults = "No storage tags found"; - } - else if (field.label === 'label.host.tags') - { - hint = "Type in part of a host tag"; - noResults = "No host tags found"; - } - selectArgs = { context: args.context, response: { @@ -489,8 +475,8 @@ { theme: "facebook", preventDuplicates: true, - hintText: hint, - noResultsText: noResults + hintText: args.hintText, + noResultsText: args.noResultsText }); } } diff --git a/ui/scripts/ui/widgets/detailView.js b/ui/scripts/ui/widgets/detailView.js index 2d619771eb8..a2daa7e0d03 100644 --- a/ui/scripts/ui/widgets/detailView.js +++ b/ui/scripts/ui/widgets/detailView.js @@ -672,7 +672,7 @@ // Turn into form field var selectData = $value.data('detail-view-editable-select'); var isBoolean = $value.data('detail-view-editable-boolean'); - var isTokenInput = $value.data('detail-view-is-TokenInput'); + var isTokenInput = $value.data('detail-view-is-token-input'); var data = !isBoolean ? cloudStack.sanitizeReverse($value.html()) : $value.data('detail-view-boolean-value'); var rules = $value.data('validation-rules') ? $value.data('validation-rules') : {}; var isPassword = $value.data('detail-view-is-password'); @@ -734,20 +734,6 @@ isAsync = true; - var hint = "Type in a search term"; - var noResults = "No results"; - - if ($value.data('value_token').label === 'label.storage.tags') - { - hint = "Type in part of a storage tag"; - noResults= "No storage tags found"; - } - else if ($value.data('value_token').label === 'label.host.tags') - { - hint = "Type in part of a host tag"; - noResults = "No host tags found"; - } - selectArgs = { context: $detailView.data('view-args').context, response: { @@ -758,8 +744,8 @@ preventDuplicates: true, prePopulate: existing_tags, processPrePopulate: true, - hintText: hint, - noResultsText: noResults + hintText: args.hintText, + noResultsText: args.noResultsText }); } } @@ -773,7 +759,7 @@ $value.append($input); token_value = data; - $value.data('value_token').dataProvider(selectArgs); + $value.data('value-token').dataProvider(selectArgs); } else { // Text input $value.append( @@ -1129,8 +1115,8 @@ if (value.isTokenInput) { - $value.data('detail-view-is-TokenInput', true); - $value.data('value_token', value); + $value.data('detail-view-is-token-input', true); + $value.data('value-token', value); } }