Skip to content

Commit

Permalink
fix: .map(Number) creates problems if preselect is not an id but a st…
Browse files Browse the repository at this point in the history
…ring

this is checking if filterGroups in fieldConfig contains 'relation' and only then maps to Number. This could still cause an issue, if a field contains ids and strings. 
I couldn't find a usecase for this, but something to think about.
Another solution would be to cast the key in FilterGroupHelper->getGroupValuesForFilterGroup to string and we can remove the map function altogether. Function is only used in the pimcore_ecommerceframework_index_getvaluesforfilterfield route and therefor should not cause other problems
  • Loading branch information
MercuryKojo authored Oct 16, 2024
1 parent 245c9a7 commit 19da0dd
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ pimcore.object.tags.indexFieldSelection = Class.create(pimcore.object.tags.selec
load: function(store) {
if(this.data) {
if(this.preSelectCombobox.rendered) {
this.preSelectCombobox.setValue(this.data.preSelect?.split(',').map(Number));
this.preSelectCombobox.setValue(this.fieldConfig.filterGroups?.includes('relation') ? this.data.preSelect?.split(',').map(Number) : this.data.preSelect?.split(','));
} else {
this.preSelectCombobox.addListener("afterRender", function() {
this.preSelectCombobox.setValue(this.data.preSelect?.split(',').map(Number));
this.preSelectCombobox.setValue(this.fieldConfig.filterGroups?.includes('relation') ? this.data.preSelect?.split(',').map(Number) : this.data.preSelect?.split(','));
}.bind(this));
}
}
Expand Down Expand Up @@ -239,10 +239,10 @@ pimcore.object.tags.indexFieldSelection = Class.create(pimcore.object.tags.selec

if(this.fieldConfig.multiPreSelect == 'local_single' || this.fieldConfig.multiPreSelect == 'local_multi') {
if(this.preSelectCombobox.rendered) {
this.preSelectCombobox.setValue(this.data.preSelect?.split(',').map(Number));
this.preSelectCombobox.setValue(this.fieldConfig.filterGroups?.includes('relation') ? this.data.preSelect?.split(',').map(Number) : this.data.preSelect?.split(','));
} else {
this.preSelectCombobox.addListener("afterRender", function() {
this.preSelectCombobox.setValue(this.data.preSelect?.split(',').map(Number));
this.preSelectCombobox.setValue(this.fieldConfig.filterGroups?.includes('relation') ? this.data.preSelect?.split(',').map(Number) : this.data.preSelect?.split(','));
}.bind(this));
}
}
Expand Down

0 comments on commit 19da0dd

Please sign in to comment.