Api: SearchMixin improvements to work with Et2LinkSearch more efficiently

Moving handling of missing options to overridable method so Et2LinkSearch can use its more efficient method
This commit is contained in:
nathan 2023-07-25 09:38:11 -06:00
parent 06af22a46c
commit 2a5d0062dd

View File

@ -591,6 +591,23 @@ export const Et2WithSearchMixin = <T extends Constructor<LitElement>>(superclass
continue; continue;
} }
this._missingOption(newValueElement);
}
}
}
/**
* Some [part of a] value is missing from the available options, but should be there, so find and add it.
*
* This is used when not all options are sent to the client (search, link list). Ideally we want to send
* the options for the current value, but sometimes this is not the best option so here we search or create
* the option as needed. These are not free entries, but need to match some list somewhere.
*
* @param {string} newValueElement
* @protected
*/
protected _missingOption(newValueElement : string)
{
// Given a value we need to search for - this will add in all matches, including the one needed // Given a value we need to search for - this will add in all matches, including the one needed
this.remoteSearch(newValueElement, this.searchOptions).then((result : SelectOption[]) => this.remoteSearch(newValueElement, this.searchOptions).then((result : SelectOption[]) =>
{ {
@ -601,8 +618,6 @@ export const Et2WithSearchMixin = <T extends Constructor<LitElement>>(superclass
} }
}); });
} }
}
}
protected fix_bad_value() protected fix_bad_value()
{ {