Binding in templates
There are special classes/attributes that need to be defined for given elements to be used as action buttons. However, there is already flexible template component which can handle it all:
templates/modules/common/components/actions.twig
- for table
templates/modules/common/components/table-cells/actions.html.twig
- for accordion
templates/modules/common/components/accordion/actions.twig
All there is todo is just including the actions component with selection of actions that should be available:
Update/Delete action
trash
is responsible for removing the recordedit
turnscontenteditable
on elements by defaultsave
triggers update
note
By default all entries in the system are soft deleted
which means that these can be reverted in case of missclick.
All entities which support soft-delete logic implement the SoftDeletableEntityInterface
.
important
The edit
action is also needed to make the special actions work as it toggles
the visibility of actions
Special actions
fontawesome
is special action which allows selecting fontawesome icon from list
important
fontawesome
action requires fontawesome-input
class to be added to the element which should contain the fontawesome icon name
lock
will togglelockMechanism
on given entry (more about this in the other guide)copy
allows to copy content of given selector into the clipboard,edit with tinymce
allows to turn the given element into the container fully editable via tinymce
important
edit with tinymce
action requires the target element to have 2 classes:
edit-record-with-tiny-mce transform-to-tiny-mce
warning
Like it's written in the specification, chrome should be used to work with this project while for example copy
seems to be breaking in Firefox.
Specially handled actions
toggle-boolval
simply turns thebool
value of entity, it consists of given html attributes: (does not require defining logic in js)
dialog
allows to create the dialog which is then prefilled by template content returned on backend
append form
allows appending form on view
warning
- the forms appended via
append-form
should not be submitted separately - these should only be responsible for adding fields.
remove
- this is an additional way of removing entities from the database (this solution does not require defining logic in js)
edit via prefilled modal
- allows editing state of DB entry via modal
warning
Some actions were used only once, thus it's possible that might malfunction in some untested cases. This regards for example: edit via prefilled modal