Skip to content

Commit

Permalink
fixed #56 - Error on Open saved search with condition for relations f…
Browse files Browse the repository at this point in the history
…ield
  • Loading branch information
Christian Fasching committed Sep 2, 2019
1 parent 34d5fe8 commit 7c33727
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 33 deletions.
23 changes: 19 additions & 4 deletions src/Resources/public/js/searchConfig/resultPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,27 @@ pimcore.bundle.advancedObjectSearch.searchConfig.resultPanel = Class.create(pimc
}
},

getLayout: function () {
getLayout: function (initialFilter) {

this.initialFilter = initialFilter;

if (this.layout == null) {
this.layout = new Ext.Panel({
border: false,
layout: "fit",
listeners: {
activate: function () {
if (this.getSaveDataCallback) {

var classId = null;
if(this.initialFilter) {
classId = this.initialFilter.classId;
} else if(this.getSaveDataCallback) {
var saveData = this.getSaveDataCallback(true);
this.updateGrid(saveData.classId);
classId = saveData.classId;
}

if(classId) {
this.updateGrid(classId);
}
}.bind(this)
}
Expand Down Expand Up @@ -329,7 +339,12 @@ pimcore.bundle.advancedObjectSearch.searchConfig.resultPanel = Class.create(pimc

var proxy = this.store.getProxy();

proxy.extraParams.filter = this.getSaveDataCallback();
if(this.initialFilter) {
proxy.extraParams.filter = Ext.encode(this.initialFilter);
this.initialFilter = null;
} else {
proxy.extraParams.filter = this.getSaveDataCallback();
}

if(this.extensionBag) {
this.extensionBag.addCustomFilter();
Expand Down
30 changes: 1 addition & 29 deletions src/Resources/public/js/searchConfigPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,7 @@ pimcore.bundle.advancedObjectSearch.searchConfigPanel = Class.create(pimcore.ele

// open result panel for saved searches
if(this.data.classId && data.conditions && data.conditions.filters) {
// count conditions
this.filterCount = 0;
this.loadedFilterCount = 0;
this.countFilter(data.conditions.filters);

// wait for the conditions to load, after that the filters are ready
// for the grid view, otherwise wrong results will be displayed
var listener = function() {
this.loadedFilterCount++;

if(this.filterCount === this.loadedFilterCount) {
this.conditionPanel.getPanel().un("condition:loaded", listener);
this.tab.setActiveItem(this.resultPanel.getLayout());
}
}.bind(this);

this.conditionPanel.getPanel().on("condition:loaded", listener);
this.tab.setActiveItem(this.resultPanel.getLayout(data));
}

this.tab.on("destroy", function () {
Expand All @@ -66,18 +50,6 @@ pimcore.bundle.advancedObjectSearch.searchConfigPanel = Class.create(pimcore.ele
pimcore.layout.refresh();
},

countFilter: function(filters) {
for(var i = 0; i < filters.length; i++) {
var filter = filters[i];

if(filter.fieldname === "~~group~~") {
this.countFilter(filter.filterEntryData);
} else {
this.filterCount++;
}
}
},

getTabId: function() {
if(!this.tabId) {
if(this.data && this.data.id) {
Expand Down

0 comments on commit 7c33727

Please sign in to comment.