Skip to content

Commit

Permalink
[#2] Add remove feed functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisros committed Jan 6, 2018
1 parent d29e05a commit 4c0087a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
21 changes: 21 additions & 0 deletions Controller/AdminInterfaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
26 changes: 25 additions & 1 deletion Resources/public/js/pimcore/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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");
}

});
1 change: 0 additions & 1 deletion Resources/public/js/pimcore/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
});
Expand Down
3 changes: 2 additions & 1 deletion Resources/translations/admin.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
feedbuilder_enter_the_name_of_the_new_feed: 'Add the new name of the feed'
feedbuilder_delete_successfully: 'Feed succesfully removed'

0 comments on commit 4c0087a

Please sign in to comment.