Skip to content

Commit

Permalink
[DataObject] Add objects or variant filtering dropdown in grid tab (#465
Browse files Browse the repository at this point in the history
)

* 464 fix filtering objects and added to toolbar a select option

* added translations for select in grid view

* Update src/Helper/GridHelperService.php

Co-authored-by: JiaJia Ji <[email protected]>

* Update translations/admin.en.yaml

Co-authored-by: JiaJia Ji <[email protected]>

* hidden visibility if class does not "allow inheritance"

* fixed filtered list based on what type of objects you want show

* Update public/js/pimcore/object/helpers/gridTabAbstract.js

Co-authored-by: Sebastian Blank <[email protected]>

* Update label of select

Co-authored-by: JiaJia Ji <[email protected]>

* removing old code

Co-authored-by: JiaJia Ji <[email protected]>

* refactoring set objects

---------

Co-authored-by: JiaJia Ji <[email protected]>
Co-authored-by: Sebastian Blank <[email protected]>
  • Loading branch information
3 people authored Mar 22, 2024
1 parent c0eb487 commit d4fc52d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
40 changes: 40 additions & 0 deletions public/js/pimcore/object/helpers/gridTabAbstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,45 @@ pimcore.object.helpers.gridTabAbstract = Class.create({

this.store.getProxy().setExtraParam("query", this.searchFilter);

var selectObjectOptions = Ext.create('Ext.data.Store', {
fields: ['name', 'value'],
data: [
[t("all_types"), "all_objects"],
[t("only_object"), "only_objects"],
[t("only_variant"), "only_variant_objects"],
]
});

this.selectObjectType = new Ext.form.ComboBox({
fieldLabel: t('select_objects_type'),
name: 'objects_type',
labelWidth: 120,
xtype: "combo",
displayField:'name',
valueField: "value",
hidden: !this.element.data.general.allowInheritance,
store: selectObjectOptions,
editable: false,
width : 300,
triggerAction: 'all',
value: 'all_objects',
listeners: {
change: function(comboBox,selected){
this.grid.getStore().setRemoteFilter(false);
this.grid.filters.clearFilters();
this.grid.getStore().clearFilter();

this.store.getProxy().setExtraParam("filter_by_object_type", selected);

this.pagingtoolbar.moveFirst();

this.grid.getStore().setRemoteFilter(true);

this.saveColumnConfigButton.show();
}.bind(this)
}
});

this.checkboxOnlyDirectChildren = new Ext.form.Checkbox({
name: "onlyDirectChildren",
style: "margin-bottom: 5px; margin-left: 5px",
Expand Down Expand Up @@ -296,6 +335,7 @@ pimcore.object.helpers.gridTabAbstract = Class.create({
this.languageInfo, "-",
this.toolbarFilterInfo,
this.clearFilterButton, "->",
this.selectObjectType, "-",
this.checkboxOnlyDirectChildren, "-",
this.exportButton, "-",
this.columnConfigButton,
Expand Down
15 changes: 12 additions & 3 deletions src/Helper/GridHelperService.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,19 @@ public function prepareListingForGrid(array $requestParams, string $requestedLan
}
}

if ($class->getShowVariants()) {
$list->setObjectTypes([DataObject::OBJECT_TYPE_OBJECT, DataObject::OBJECT_TYPE_VARIANT]);
if ($class->getAllowVariants()) {
if ($class->getShowVariants()) {
$list->setObjectTypes([DataObject::OBJECT_TYPE_OBJECT, DataObject::OBJECT_TYPE_VARIANT]);
}
if (isset($requestParams['filter_by_object_type'])){
if ($requestParams['filter_by_object_type'] === "only_objects") {
$list->setObjectTypes([DataObject::OBJECT_TYPE_OBJECT]);
} elseif($requestParams['filter_by_object_type'] === "only_variant_objects") {
$list->setObjectTypes([DataObject::OBJECT_TYPE_VARIANT]);
}
}
}

$this->addGridFeatureJoins($list, $featureJoins, $class, $featureAndSlugFilters);
$this->addSlugJoins($list, $slugJoins, $featureAndSlugFilters);

Expand Down
3 changes: 3 additions & 0 deletions translations/admin.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@ system_columns: 'System columns'
columns: Columns
children_grid: 'Children Grid'
only_children: 'just direct children'
only_object: 'just objects'
only_variant: 'just variants object'
select_objects_type: "Type to show"
cut: Cut
paste_cut_element: 'Paste cut-out element'
memorize_tabs: 'Memorize open tabs'
Expand Down

0 comments on commit d4fc52d

Please sign in to comment.