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

Feature Request: adding Moving and Moved events to FormService #667

Closed
inetzo opened this issue Nov 2, 2021 · 1 comment
Closed

Feature Request: adding Moving and Moved events to FormService #667

inetzo opened this issue Nov 2, 2021 · 1 comment

Comments

@inetzo
Copy link

inetzo commented Nov 2, 2021

It would be nice to have Moving and Moved events on the FormService when a Form is moved in or moved to another folder.

We've extend the Forms folders the manage the permissions of the form inside them. A the moment we use the FormService.Saved event to track changes but this is not a particular event for when a form is moved.

@AndyButland
Copy link

We'll introduce these in 8.10.0 and 9.2.0. However as we don't have a "move" operation on the IFormService, instead there'll be additional data available in the FormEventArgs and FolderEventArgs dictionary property called AdditionalData.

This will be updated in the documentation when the RCs for these minors are released, but I'll also reference it here:

When a form or folder is moved there is no specific service event. However information available in the AdditionalData dictionary available on the FormEventArgs or FolderEventArgs can be used to determine whether the item was moved, and if so, where from:

    public class TestSiteComposer : IUserComposer
    {
        public void Compose(Composition composition)
        {
            composition.Components().Append<TestSiteComponent>();
        }
    }

    public class TestSiteComponent : IComponent
    {
        private readonly IFormService _formService;
        public TestSiteComponent(IFormService formService)
        {
            _formService = formService;
        }

        public void Initialize()
        {
            _formService.Updating += FormService_Updating;
            _formService.Updated += FormService_Updated;
        }

        private void FormService_Updated(object sender, FormEventArgs e) =>
            Current.Logger.Info(
                typeof(TestSiteComponent),
                $"Form updated. New parent: {e.Form.FolderId}. Old parent: {e.AdditionalData["MovedFromFolderId"]}");

        private void FolderService_Updated(object sender, FolderEventArgs e) =>
            Current.Logger.Info(
                typeof(TestSiteComponent),
                $"Folder updated. New parent: {e.Folder.ParentId}. Old parent: {e.AdditionalData["MovedFromFolderId"]}");

        public void Terminate()
        {
            _formService.Updating -= FormService_Updating;
            _formService.Updated -= FormService_Updated;
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants