What is the easiest way to add a custom button to toolbar, with access to content item? I already check : Toolbar item for delete - for 2sxc module But because delete is not possible with already defined buttons, I like to make my own button.
Asked
Active
Viewed 91 times
2 Answers
0
As of now there is no official way to do this. It's easy, but since not official, it could break one day.
Basically all the buttons are provided from here: https://github.com/2sic/2sxc/blob/master/src/inpage/2sxc._actions.js
As you can see, there is a function $2sxc._actions.create
which will get all the actions possible for something, based on what that something is. So you could either
- Overwrite the _actions.create
- in your module-specific 2sxc-object - the one given by $2sxc(moduleid) - you could change the actions (but this would be tricky in terms of timing)
- change the
- setup which contains all the buttons after the toolbars are built, to add yours
- build an "official" way to add buttons and sync it with the core team to get it into the client-api
- develop the delete function yourself, the main issue here is that often you'll get a "failed-because-in-use", in which case you would have to ask the user if they want to force-delete-it, and if yes, send the second webapi-call with force-delete. You can see how this is done in the normal EAV-entities-management, as that is implemented there using a toastr

iJungleBoy
- 5,325
- 1
- 9
- 21
0
Update: 2sxc 8.6 beta is out, and it supports adding custom buttons to the toolbar. Read about the API, JSON definitions in the wiki. I'll try to blog about specific step-by-step in a few weeks...

iJungleBoy
- 5,325
- 1
- 9
- 21