diff --git a/src/AdvancedObjectSearchBundle.php b/src/AdvancedObjectSearchBundle.php index 0e6c5fc..6b9539c 100644 --- a/src/AdvancedObjectSearchBundle.php +++ b/src/AdvancedObjectSearchBundle.php @@ -116,6 +116,7 @@ public function getJsPaths() '/bundles/advancedobjectsearch/js/searchConfigPanel.js', '/bundles/advancedobjectsearch/js/searchConfig/conditionPanelContainerBuilder.js', '/bundles/advancedobjectsearch/js/searchConfig/conditionPanel.js', + '/bundles/advancedobjectsearch/js/searchConfig/resultAbstractPanel.js', '/bundles/advancedobjectsearch/js/searchConfig/resultPanel.js', '/bundles/advancedobjectsearch/js/searchConfig/resultExtension.js', '/bundles/advancedobjectsearch/js/searchConfig/conditionAbstractPanel.js', diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index ec24919..06260d9 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -185,7 +185,7 @@ public function getBatchJobsAction(Request $request, Service $service) //get ID list from ES Service $data = json_decode($request->get("filter"), true); - $results = $service->doFilter($data['classId'], $data['conditions']['filters'], $data['conditions']['fulltextSearchTerm'], null, 9999); + $results = $service->doFilter($data['classId'], $data['conditions']['filters'] ?? [], $data['conditions']['fulltextSearchTerm'] ?? [], null, 9999); $ids = $service->extractIdsFromResult($results); @@ -219,20 +219,21 @@ public function getExportJobsAction(Request $request, Service $service) { $request->setLocale($request->get("language")); } - //get ID list from ES Service $data = json_decode($request->get("filter"), true); - //TODO eventually add ID filter for preselected export + if (empty($ids = $request->get('ids', false))) { + $results = $service->doFilter( + $data['classId'], + $data['conditions']['filters'], + $data['conditions']['fulltextSearchTerm'], + 0, + 9999 // elastic search cannot export more results than 9999 in one request + ); - $results = $service->doFilter( - $data['classId'], - $data['conditions']['filters'], - $data['conditions']['fulltextSearchTerm'], - 0, - 9999 // elastic search cannot export more results than 9999 in one request - ); + //get ID list from ES Service + $ids = $service->extractIdsFromResult($results); + } - $ids = $service->extractIdsFromResult($results); $jobs = array_chunk($ids, 20); $fileHandle = uniqid("export-"); @@ -386,7 +387,7 @@ public function loadSearchAction(Request $request) { $helperColumns = []; foreach ($config["gridConfig"]["columns"] as &$column) { - if(!$column["isOperator"]) { + if(!($column["isOperator"] ?? false)) { $fieldDefinition = $classDefinition->getFieldDefinition($column['key']); if($fieldDefinition) { $width = isset($column["layout"]["width"]) ? $column["layout"]["width"] : null; diff --git a/src/Resources/public/js/searchConfig/resultAbstractPanel.js b/src/Resources/public/js/searchConfig/resultAbstractPanel.js new file mode 100644 index 0000000..00e1777 --- /dev/null +++ b/src/Resources/public/js/searchConfig/resultAbstractPanel.js @@ -0,0 +1,49 @@ +/** + * Pimcore + * + * This source file is available under two different licenses: + * - GNU General Public License version 3 (GPLv3) + * - Pimcore Enterprise License (PEL) + * Full copyright and license information is available in + * LICENSE.md which is distributed with this source code. + * + * @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) + * @license http://www.pimcore.org/license GPLv3 and PEL + */ + + +pimcore.registerNS("pimcore.bundle.advancedObjectSearch.searchConfig.resultAbstractPanel"); +pimcore.bundle.advancedObjectSearch.searchConfig.resultAbstractPanel = Class.create(pimcore.object.helpers.gridTabAbstract, { + systemColumns: ["id", "fullpath", "type", "subtype", "filename", "classname", "creationDate", "modificationDate"], + noBatchColumns: [], + batchAppendColumns: [], + batchRemoveColumns: [], + exportPrepareUrl: "/admin/bundle/advanced-object-search/admin/get-export-jobs", + batchPrepareUrl: "/admin/bundle/advanced-object-search/admin/get-batch-jobs", + + getSaveDataCallback: null, + gridConfigData: {}, + + portletMode: false, + + fieldObject: {}, + + getLayout: function (initialFilter) { + }, + + updateGrid: function (classId) { + }, + + createGrid: function (fromConfig, response, settings, save) { + } +}); + +/** + * https://github.com/pimcore/advanced-object-search/issues/64 + * TODO pimcore.object.helpers.gridcolumnconfig for BC reasons, to be removed with next major version + */ +if (pimcore.object.helpers.gridcolumnconfig) { + pimcore.bundle.advancedObjectSearch.searchConfig.resultAbstractPanel.addMethods(pimcore.object.helpers.gridcolumnconfig); +} else { + pimcore.bundle.advancedObjectSearch.searchConfig.resultAbstractPanel.addMethods(pimcore.element.helpers.gridColumnConfig); +} diff --git a/src/Resources/public/js/searchConfig/resultPanel.js b/src/Resources/public/js/searchConfig/resultPanel.js index 18e564e..6574b1a 100644 --- a/src/Resources/public/js/searchConfig/resultPanel.js +++ b/src/Resources/public/js/searchConfig/resultPanel.js @@ -13,21 +13,12 @@ pimcore.registerNS("pimcore.bundle.advancedObjectSearch.searchConfig.resultPanel"); -pimcore.bundle.advancedObjectSearch.searchConfig.resultPanel = Class.create(pimcore.object.helpers.gridTabAbstract, { - systemColumns: ["id", "fullpath", "type", "subtype", "filename", "classname", "creationDate", "modificationDate"], - noBatchColumns: [], - batchAppendColumns: [], - batchRemoveColumns: [], +pimcore.bundle.advancedObjectSearch.searchConfig.resultPanel = Class.create(pimcore.bundle.advancedObjectSearch.searchConfig.resultAbstractPanel, { - getSaveDataCallback: null, - gridConfigData: {}, - - portletMode: false, - - fieldObject: {}, initialize: function (getSaveDataCallback, gridConfigData, portletMode) { this.getSaveDataCallback = getSaveDataCallback; this.settings = {}; + this.element = {}; this.gridPageSize = 25; if (gridConfigData) { @@ -260,26 +251,19 @@ pimcore.bundle.advancedObjectSearch.searchConfig.resultPanel = Class.create(pimc }); plugins.push(this.cellEditing); - tbar = tbar.concat(['->', "-", { - text: t("export_csv"), - iconCls: "pimcore_icon_export", - handler: function () { - - Ext.MessageBox.show({ - title: t('warning'), - msg: t('csv_object_export_warning'), - buttons: Ext.Msg.OKCANCEL, - fn: function (btn) { - if (btn == 'ok') { - this.exportResultPrepare(); - } - }.bind(this), - icon: Ext.MessageBox.WARNING - }); + var exportButtons = this.getExportButtons(); + var firstButton = exportButtons.pop(); + this.exportButton = new Ext.SplitButton({ + text: firstButton.text, + iconCls: firstButton.iconCls, + handler: firstButton.handler, + menu: exportButtons, + }); - }.bind(this) - }, "-", this.columnConfigButton + tbar = tbar.concat(['->', "-", + this.exportButton, "-", + this.columnConfigButton ]); tbars = [{ @@ -460,7 +444,7 @@ pimcore.bundle.advancedObjectSearch.searchConfig.resultPanel = Class.create(pimc }, - exportResultPrepare: function () { + exportPrepare: function (settings, exportType) { var jobs = []; var fields = this.getGridConfig().columns; @@ -494,9 +478,7 @@ pimcore.bundle.advancedObjectSearch.searchConfig.resultPanel = Class.create(pimc var fieldKeys = Object.keys(fields); if (rdata.success && rdata.jobs) { - var exportType = {}; - exportType.downloadUrl = "/admin/object-helper/download-csv-file"; - this.exportProcess(rdata.jobs, rdata.fileHandle, fieldKeys, true, {}, exportType); + this.exportProcess(rdata.jobs, rdata.fileHandle, fieldKeys, true, settings, exportType); } }.bind(this) @@ -604,16 +586,22 @@ pimcore.bundle.advancedObjectSearch.searchConfig.resultPanel = Class.create(pimc } else { return this.gridConfigData; } - } + }, -}); + getExportButtons: function () { + var buttons = []; + pimcore.globalmanager.get("pimcore.object.gridexport").forEach(function (exportType) { + buttons.push({ + text: t(exportType.text), + iconCls: exportType.icon || "pimcore_icon_export", + handler: function () { + pimcore.helpers.exportWarning(exportType, function (settings) { + this.exportPrepare(settings, exportType); + }.bind(this)); + }.bind(this), + }) + }.bind(this)); -/** - * https://github.com/pimcore/advanced-object-search/issues/64 - * TODO pimcore.object.helpers.gridcolumnconfig for BC reasons, to be removed with next major version - */ -if (pimcore.object.helpers.gridcolumnconfig) { - pimcore.bundle.advancedObjectSearch.searchConfig.resultPanel.addMethods(pimcore.object.helpers.gridcolumnconfig); -} else { - pimcore.bundle.advancedObjectSearch.searchConfig.resultPanel.addMethods(pimcore.element.helpers.gridColumnConfig); -} + return buttons; + } +});