-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WC-2758] combobox: load initial data on database source #1393
Conversation
ffb845b
to
7caddff
Compare
if (this.lazyLoading && this.ds && this.attributeId) { | ||
const filterCondition = datasourceFilter("containsExact", attributeValue, this.attributeId); | ||
this.ds?.setFilter(filterCondition); | ||
this.ds.setLimit(this.attributeId.length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this.attributeId.length
return and why do we set it is limit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basically it returns 1. because only works for single selection. database multi selection don't have attributes set.
set limit to 1 will fetch the datasource, because on lazy load, initial limit is 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@r0b1n you are correct. this is string length,
updated to hardcode: 1
const obj = this.options.getAll().find(option => { | ||
return _valuesIsEqual(targetAttribute.value, this.values.get(option)); | ||
}); | ||
if (obj) { | ||
this.currentId = obj; | ||
} else { | ||
if (targetAttribute.value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks redundant as we already checked that it is true at line 72.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -69,13 +69,17 @@ export class DatabaseSingleSelectionSelector< | |||
if (this.lastSetValue === null || !_valuesIsEqual(this.lastSetValue, targetAttribute.value)) { | |||
if (ds.status === "available") { | |||
this.lastSetValue = this._attr.value; | |||
if (!_valuesIsEqual(this.values.getEmptyValue(), targetAttribute.value)) { | |||
if (targetAttribute.value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this check gone? I guess this will run the code even if the value is equals to "empty value", which seems incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty value is default value. initially we did a hack by setting default value to $currentObject/attribute.
this is no longer applicable.
attribute value checks is sufficient.
d7a4a4f
to
710ef88
Compare
710ef88
to
276eefb
Compare
continue on #1408 |
Pull request type
Bug fix (non-breaking change which fixes an issue)
Description
Issue: combobox database source, with lazy load, don't have object data on initial load.
this cause combobox to not be able to render caption on initial load.
fix: load single object based on stored value attribute data on initial render.
method: use database filter. set limit to 1.
risk: because this is using literal filter (not object guid retrieval), data could be duplicate,
but because the data used is the stored value attribute, this should already be unique (otherwise, model failed)
this method is not needed on multi select, because database multi select cannot store attribute value.