Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N°1681 - Add new triggers for attachment creation and removal #534

Open
wants to merge 8 commits into
base: support/3.2
Choose a base branch
from

Conversation

accognet
Copy link
Contributor

@accognet accognet commented Aug 3, 2023

Create a new trigger "on object's attachment creation"

@accognet accognet added the internal Work made by Combodo label Aug 3, 2023
@accognet accognet self-assigned this Aug 3, 2023
Copy link
Contributor

@Molkobain Molkobain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed IRL with Anne-Catherine, several things to change:

Point 1
Hacking the standard "Trigger on update" with JS to remove the "Attachment" class from proposed value doesn't seem like a good option.

Instead we would rather improve the \AttributeClass class to add a class_exclusion_list like we do for \AttributeClassAttCodeSet with attribute_definition_exclusion_list. Check with @rquetiez or @eespie , they can guide you.

Point 2
The way it is currently done, you can't limit the trigger to attachments of a specific class only, which is most likely something we'll want to do.

Point 3
Because of the previous points, you can't rely on the ComputeValues method and the fact it derived from the standard TriggerOnObjectUpdate, you'll need to call your trigger when attachments are finalized. We might want to add an event for that actually, check with Eric.

@Molkobain Molkobain changed the title N°1681 - Notification on Attachment creation N°1681 - Add new trigger for attachment creation Aug 22, 2023
@Hipska
Copy link
Contributor

Hipska commented Aug 30, 2023

May I ask why the existing triggers aren’t sufficient?

@accognet
Copy link
Contributor Author

It does but to get an attachment creation notification, we need to create an "on object update" trigger on the attachment with the temp_id field. It's not really logical.

@Molkobain
Copy link
Contributor

During the technical review, we'll need to discuss the possible impacts of adding the class_exclusion_list property on the existing AttributeClass attribute:

  • Can it be omitted in an AttributeClass instantiation (existing customizations using that type of attribute)
  • Create the corresponding Designer ticket
  • ...

@@ -3736,7 +3736,7 @@ class AttributeClass extends AttributeString

public static function ListExpectedParams()
{
return array_merge(parent::ListExpectedParams(), array("class_category", "more_values"));
return array_merge(parent::ListExpectedParams(), array('class_category', 'more_values', 'class_exclusion_list'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed during technical review: We'll actually remove it from expected params as it would force any AttributeClass usage to provide it, which would lead to regression on any module / custos using it.

We'll just add a comment to inform that this option exists.

@Molkobain Molkobain changed the title N°1681 - Add new trigger for attachment creation N°1681 - Add new triggers for attachment creation and removal Sep 3, 2024
@accognet accognet changed the base branch from support/3.1 to support/3.2 September 30, 2024 08:54
@accognet accognet force-pushed the feature/1681-Notification_on_Attachment branch from b71d2f1 to bfbf85c Compare October 1, 2024 09:11
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeClass("target_class", array("class_category" => "bizmodel", "more_values" => "User,UserExternal,UserInternal,UserLDAP,UserLocal", "sql" => "target_class", "default_value" => null, "is_null_allowed" => false, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeClass("target_class",
array("class_category" => "bizmodel", "more_values" => "User,UserExternal,UserInternal,UserLDAP,UserLocal", "sql" => "target_class", "default_value" => null, "is_null_allowed" => false, "depends_on" => array(), "class_exclusion_list" => "Attachment")));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note: Since there is no TriggerOnAttachmentCreate actually, I know of some iTop instances that use a TriggerOnObject with a target class Attachment.
Your implementation will make this impossible in the future, so you are forcing these people to migrate. At least this should be documented, as it may be a breaking change for some iTop instances?

I assume that in such a case (Triggers with target class Attachment already exist) the setup will not break, but there will be a warning in the DB tools? Have you checked this?

Copy link
Contributor

@rquetiez rquetiez Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One effect for the end-user (verified) is that, when opening the form to edit the trigger, the "class" value is reset and prevents the user from modifying the trigger (mandatory field).

In order to preserve this constraint, a solution would be to migrate automatically the existing triggers at setup time (ModuleInstaller). Could be implemented in the form of a helper in ModuleInstallerAPI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Work made by Combodo
Projects
Status: Pending functional review
Development

Successfully merging this pull request may close these issues.

5 participants