Skip to content

Commit

Permalink
Added possibility to "ui_dropdown" component to delete user text in s…
Browse files Browse the repository at this point in the history
…earch box (#816)

* Update ui_dropdown.js - Added option msg.resetSearch 

to send it to frontend dropdown via emitOptions.resetSearch

* Update ui-component-ctrl.js - process msg.resetSearch

If resetSearch is present in msg, clear user searchTerm input in dropdown select ui component.

* Update ui_dropdown.html - Added info about resetSearch

Added information about msg.resetSearch (delete user search term)
  • Loading branch information
DanielsNoJack authored Aug 28, 2023
1 parent f4da205 commit b15badc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions nodes/locales/en-US/ui_dropdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<p>The configured value of the selected item will be returned as <code>msg.payload</code>.</p>
<p>Setting <code>msg.payload</code> to one of the item values will preset the choice in the dropdown.
If using the multi-select option then the payload should be an array of values.</p>
<p>Optionally user search term can deleted if set the <code>msg.resetSearch</code> property is present and true.</p>
<p>Optionally the <b>Topic</b> field can be used to set the <code>msg.topic</code> property.</p>
<p>The Options may be configured by inputting <code>msg.options</code> containing an array.
If just text then the value will be the same as the label, otherwise you can specify both by
Expand Down
4 changes: 3 additions & 1 deletion nodes/ui_dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ module.exports = function(RED) {
node.error("ERR: Invalid Options", msg);
}
}

if (msg.hasOwnProperty("resetSearch") && msg.resetSearch) {
emitOptions.resetSearch = true;
}
if (msg.hasOwnProperty("payload")) {
if (node.multiple) {
if (typeof msg.payload === "string") {
Expand Down
4 changes: 4 additions & 0 deletions src/components/ui-component/ui-component-ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@ angular.module('ui').controller('uiComponentController', ['$scope', 'UiEvents',

// may add additional input processing for other controls
var processDropDownInput = function (msg) {
// If resetSearch is present, clear user searchTerm input
if (msg && msg.resetSearch) {
me.searchTerm = "";
}
// options should have the correct format see beforeEmit in ui-dropdown.js
if (msg && msg.isOptionsValid) {
me.item.options = msg.newOptions;
Expand Down

0 comments on commit b15badc

Please sign in to comment.