vaadin / collaboration-engine

The simplest way to build real-time collaboration into web apps
https://vaadin.com/collaboration
Other
3 stars 1 forks source link

Highlight handler but for the whole form being edited #68

Open MatthewVaadin opened 2 years ago

MatthewVaadin commented 2 years ago

Is your feature request related to a use case? Please describe. I want to be able to respond to a user editing a form. This could be to make the fields read-only when another user is editing the form and to make them writable once the other user is finished.

Describe the solution you'd like A clear and concise description of what you want to happen. If you have an idea for new API to the product, describe the API and how you think it should work. Currently the FormManager API allows me to programmatically highlight a field being edited and to respond to another user doing the same. This feature could work in a very similar way. Here is a possible API:

public class FormManager extends AbstractCollaborationManager
    implements HasExpirationTimeout {
    ...
    public void edit(boolean edit) {
        ...
    }

    public void setEditHandler(EditHandler handler) {
        ...
    }
    ...
}

public interface EditHandler {
    interface EditContext extends Serializable {
        UserInfo getUser();
    }

    Registration handleEdit(EditContext context);
}

Describe alternatives you've considered Using the highlight handler to check whenever any field is being edited and respond to that. However, you can't track when a user has no fields highlighted, but is still editing the form.

Legioth commented 2 years ago

To me, this looks like tracking overall presence, but with slightly custom logic for when the user would be marked as present and not. That's something that's already supported using PresenceManager, which makes me wonder whether the use case would be common enough to justify also creating a dedicated API for it?