Hi,
Being relatively new to Angular etc, I thought I would check here before logging this as a bug. So I was looking at the line-items field type and noticed that there is a trigger when adding/removing a line, to allow custom code to hook into these events (ie on removal this gets sent: onLineItemRemove).
This gets tied up with Field Logic definitions and a custom Angular action (similar to the existing field logic), so theoretcally you can wait for a line to be deleted and then trigger an action that also deletes an entry in a remote table (for example). This is the (eventual) code that does this:
protected triggerLineActionEvents(lineActionEvent: LineActionEvent): void {
const fieldLogics = this.field?.logic || {} as FieldLogicMap;
if (emptyObject(fieldLogics)) {
return;
}
Object.keys(fieldLogics).forEach(logicKey => {
const fieldLogic = fieldLogics[logicKey] || null;
const onEvent = fieldLogic?.params?.triggerOnEvents?.[lineActionEvent];
if (isTrue(onEvent)) {
this.logic.runLogic(this.field, this.mode as ViewMode, this.record);
}
});
}
So as far as I can see you would add an entry in the ‘logic’ settings for the field, with params of
'triggerOnEvents'=>['onLineItemRemove'=>true]
which would trigger the events to run (great). However the this.runLogic has an additional parameter (triggeringStatus), which is then used to determine precisely which actions to run, in this case I would expect something like onLineItemRemove to be sent through so we can seperate the actions to run between onLineItemRemove/onLineItemAdd, the way it is I believe that all registered actions will run everytime.
Hopefully this is me reading this incorrectly, if not let me know and I will raise a bug.
Regards
Mark