diff --git a/Controller/AdminInterfaceController.php b/Controller/AdminInterfaceController.php index 7874ef6..2d934bf 100644 --- a/Controller/AdminInterfaceController.php +++ b/Controller/AdminInterfaceController.php @@ -190,4 +190,25 @@ public function addAction(Request $request) // ExportProviderService::getProviders('Provider'); return $this->json(['success' => true, 'id'=>end(array_keys($arr['feeds']))]); } + + /** + * + * @Route("/delete") + * @param Request $request + * @return \Pimcore\Bundle\AdminBundle\HttpFoundation\JsonResponse + * @throws \Exception + */ + public function deleteAction(Request $request) + { + $current = FeedBuilderService::getConfig(); + $arr = $current->toArray(); + + unset($arr['feeds'][$request->get('id')]); + + $configFile = \Pimcore\Config::locateConfigFile(FeedBuilderService::LOCATION_FILE); + + File::putPhpFile($configFile, to_php_data_file_format($arr)); + + return $this->json(['success' => true]); + } } diff --git a/Resources/public/js/pimcore/item.js b/Resources/public/js/pimcore/item.js index 098b68a..d3c12d3 100644 --- a/Resources/public/js/pimcore/item.js +++ b/Resources/public/js/pimcore/item.js @@ -244,7 +244,7 @@ feedbuilder.panelitem = Class.create({ panelButtons.push('->',{ text: t("delete"), iconCls: "pimcore_icon_delete", - handler: this.save.bind(this) + handler: this.delete.bind(this) },{ text: t("save"), iconCls: "pimcore_icon_save_white", @@ -303,6 +303,30 @@ feedbuilder.panelitem = Class.create({ window.location.reload(); } }.bind(this));*/ + }, + delete: function() { + var allValues = this.form.getForm().getFieldValues(); + allValues.id = this.data.id; + allValues.title = this.data.text; + + Ext.Ajax.request({ + url: "/admin/feedbuilder/delete", + method: "post", + params: allValues, + success: this.deleteOnComplete.bind(this) + }); + + var id = "pimcore_feed_panel_" + this.data.id; + this.parentPanel.getEditPanel().remove( Ext.getCmp(id)); + + return {}; + }, + deleteOnComplete: function () { + this.parentPanel.tree.getStore().sync(); + this.parentPanel.tree.getStore().load(); + this.parentPanel.tree.getView().refresh(); + + pimcore.helpers.showNotification(t("delete"), t("feedbuilder_delete_successfully"), "delete"); } }); \ No newline at end of file diff --git a/Resources/public/js/pimcore/panel.js b/Resources/public/js/pimcore/panel.js index d1fb3a6..4f2f2fb 100644 --- a/Resources/public/js/pimcore/panel.js +++ b/Resources/public/js/pimcore/panel.js @@ -83,7 +83,6 @@ feedbuilder.panel = Class.create({ success: function (response) { var data = Ext.decode(response.responseText); - console.log(data); this.tree.getStore().load({ node: this.tree.getRootNode() }); diff --git a/Resources/translations/admin.en.yml b/Resources/translations/admin.en.yml index acd7ac1..7932a51 100644 --- a/Resources/translations/admin.en.yml +++ b/Resources/translations/admin.en.yml @@ -15,4 +15,5 @@ feedbuilder_form_type_export: 'Cronjob' feedbuilder_form_type_feed: 'Feed' feedbuilder_form_root: 'Root element' feedbuilder_title_create_new: 'Create new feed' -feedbuilder_enter_the_name_of_the_new_feed: 'Add the new name of the feed' \ No newline at end of file +feedbuilder_enter_the_name_of_the_new_feed: 'Add the new name of the feed' +feedbuilder_delete_successfully: 'Feed succesfully removed' \ No newline at end of file