JS actions handling
Update
Update is handled via DataProcessor
definition of makeUpdateData
.
Example:
$baseElement
- is the element having given classeseditable-parent save-parent
and is also a parent element ofedit
andsave
action,url
- that's the backend action called to perform the update logic,ajaxData
- is the standard ajax data object containing values of fields that are to be updated (or eventually can transfer some additional data as well)grup
is a special type of data sent to backend, contains information about the entity so with this it's also possible to update the relational field via ajaxCall
success/fail message
- are the messages that are going to be shown by default if no message is going to be returned to the backend,
Create
Create is handled via DataProcessor
definition of makeCreateData
.
The structure is the same as in the makeUpdateData, however additional thing actually in this method is a callback (available remove/update as well)
callback
allows adding additional logic which should be called after the response from the backend is initially processed(which is after the template is being reloaded/rebuilt)
Remove
Create is handled via DataProcessor
definition of makeRemoveData
.
This action structure is the same as both one above - nothing new to describe here additionally
important
This 3 methods (makeRemoveData
, makeCreateData
, makeUpdateData
) are required for actions called by using the logic present in: templates/modules/common/components/actions.twig
Copy
Copy is a special action that was prepared explicitly for passwords
module, is handled via DataProcessor
definition of makeCopyData
.
This action structure is the same as both one above - nothing new to describe here additionally
caution
Like mentioned, the copy
logic was explicitly created for passwords
module, like always the best intent was to create a flexible logic
reusable in other cases, however since this had only one particular usage and might've never been used afterwards means that it might
require additional adaptation.
Edit with prefilled modal
This action can be used to edit the entity via dialog/modal. Each of the called repositories names need to be defined in:
src/assets/scripts/core/ui/Actions/EditViaModalPrefilledWithEntityDataAction.ts
Like for example:
Calling dialog
With this action it's possible to call dialog with rendered template.
Definition of dialog logic must be added to: src/assets/scripts/core/ui/Dialogs/LogicLoader/DialogLogic.ts
.
important
- This logic MUST be defined and should contain the js initializers. This is required due to the fact that backend returns only a template and thus no logic is bound to its element. The callback is called directly after the dialog is filled with template.
- The name of the method must be equal to the method name provided in the template via
data-dialog-name="myIssueCardAddRecords"