Skip to content
Open
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
2 changes: 1 addition & 1 deletion public/js/pimcore/element/helpers/gridConfigDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ pimcore.element.helpers.gridConfigDialog = Class.create({

this.saveFilters = new Ext.form.field.Checkbox(
{
fieldLabel: "Save filters",
fieldLabel: t("save_filters"),
inputValue: true,
name: "saveFilters",
value: this.settings.saveFilters
Expand Down
16 changes: 14 additions & 2 deletions public/js/pimcore/object/folder/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,19 @@ pimcore.object.search = Class.create(pimcore.object.helpers.gridTabAbstract, {
let col = gridColumns[i];
if (col.filter) {
needGridFilter = true;
break;

if (this.filter) {
var filterValue = this.filter.find(filter => filter.property === col.dataIndex)?.value || null;
if(filterValue) {
if (typeof col.filter !== "object") {
col.filter = { type: col.filter };
}

col.filter.value = filterValue;
}
} else {
break;
}
}
}
}
Expand Down Expand Up @@ -340,11 +352,11 @@ pimcore.object.search = Class.create(pimcore.object.helpers.gridTabAbstract, {

if (this.filter) {
this.filter.forEach(filt => {
this.store.setFilters(new Ext.util.Filter(filt))
this.filterUpdateFunction(this.grid, this.toolbarFilterInfo, this.clearFilterButton);
});
}


this.grid.on("columnmove", function () {
this.saveColumnConfigButton.show()
}.bind(this));
Expand Down
12 changes: 11 additions & 1 deletion src/Model/GridConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class GridConfig extends AbstractModel

protected bool $setAsFavourite = false;

protected bool $saveFilters = false;
protected ?bool $saveFilters = null;

protected string $type = 'object';

Expand Down Expand Up @@ -199,6 +199,16 @@ public function setSetAsFavourite(bool $setAsFavourite): void

public function isSaveFilters(): bool
{
if ($this->saveFilters === null) {
$config = json_decode($this->getConfig());

if (isset($config->filter)) {
$this->saveFilters = (bool) $config->filter;
} else {
$this->saveFilters = false;
}
}

return $this->saveFilters;
}

Expand Down
6 changes: 6 additions & 0 deletions src/Model/GridConfig/Dao.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public function save(): int
}
}

if (!$gridconfigs['saveFilters']){
$configData = json_decode($data['config'], true);
unset($configData['filter']);
$data['config'] = json_encode($configData);
}

$lastInsertId = Helper::upsert($this->db, 'gridconfigs', $data, $this->getPrimaryKey('gridconfigs'));
if ($lastInsertId !== null && !$this->model->getId()) {
$this->model->setId((int) $lastInsertId);
Expand Down
1 change: 1 addition & 0 deletions translations/admin.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ restrict_to_locales: 'Restrict to locales'
predefined: Predefined
save_as_copy: 'Save as copy'
set_as_favourite: 'Set as favourite'
save_filters: Save filters
grid_configuration: 'Grid Configuration'
shared_users: 'Shared Users'
shared_roles: 'Shared Roles'
Expand Down