Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added possibility to "ui_dropdown" component to delete user text in search box #816

Merged
merged 4 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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