diff --git a/public/js/pimcore/object/helpers/gridTabAbstract.js b/public/js/pimcore/object/helpers/gridTabAbstract.js index b30e99ea8d..f06b65493a 100644 --- a/public/js/pimcore/object/helpers/gridTabAbstract.js +++ b/public/js/pimcore/object/helpers/gridTabAbstract.js @@ -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", @@ -296,6 +335,7 @@ pimcore.object.helpers.gridTabAbstract = Class.create({ this.languageInfo, "-", this.toolbarFilterInfo, this.clearFilterButton, "->", + this.selectObjectType, "-", this.checkboxOnlyDirectChildren, "-", this.exportButton, "-", this.columnConfigButton, diff --git a/src/Helper/GridHelperService.php b/src/Helper/GridHelperService.php index 7311da8d55..28103086f9 100644 --- a/src/Helper/GridHelperService.php +++ b/src/Helper/GridHelperService.php @@ -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); diff --git a/translations/admin.en.yaml b/translations/admin.en.yaml index f52f4b4981..f65f0be866 100644 --- a/translations/admin.en.yaml +++ b/translations/admin.en.yaml @@ -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'