Multi-User Editing

Multi-User Editing

Donny85Donny85 Posts: 10Questions: 0Answers: 0
edited June 2013 in Editor
Hi,

I have a DataTable that allows users to update some pretty extensive content. As a result, a user could be editing an entry for quite some time. Which allows the potential for another user to open the same entry and update the same content. Are there any recommended ways to prevent two+ users from updating the same data at the same time?

Replies

  • allanallan Posts: 61,446Questions: 1Answers: 10,055 Site admin
    One possible method is to have a unique hash on each row (perhaps the last updated time stamp), and make that available in the data that is sent to the server as part of the edit (as a hidden field - the user would never see it). The server would then check to see if the hash is the same as the one that is in the database using the validation methods. If it is, the edit can take place, it if isn't, someone else has updated the row and the edit should be rejected with an error.

    Taking that a step further, another hidden field could be used to say "Someone has edited this record, click save again to overwrite their changes" - which might or might not be what you want. Certainly it will be slightly annoying for the user to need to reload the page and make their edits again.

    An alternative option is to 'lock' the rows while an edit is taking place. This could be done by sending an Ajax request tot he server whenever a row is requested to be edited - if no one else is editing it, the edit can continue placing a lock into the row, if there is already a lock in place, tell the user that the row is locked.

    This is probably a nicer user experience I think as they won't be able to make changes that might then be lost, although it can be a little bit of a pain if someone stops editing halfway through and doesn't cancel the edit (i.e. release the lock). There would need to be a timeout on the locks to stop this for disallowing all future edits.

    Regards,
    Allan
  • Donny85Donny85 Posts: 10Questions: 0Answers: 0
    Hi Allan,

    Thanks for the detailed response. I recently jumped back on the relevant project and implemented a solution. Each entry has an "isBeingEdited" field which is updated on form open/close. I've highlighted that closing is essential to prevent the need for a timed unlock. When the entry is already being edited, a pop up is displayed detailing who is currently editing.

    This pop up is currently just an editor.remove() with the submit method stripped out and a custom message. There's currently no method to easily pop up a custom pop up with say, title / message/ button text is there?
  • allanallan Posts: 61,446Questions: 1Answers: 10,055 Site admin
    Not really - using the `message()` and `buttons()` API methods you could create a messaging box, but there isn't a helper function to make those two calls in an easy to use wrapper function.

    That's a great idea for a future addition though - I'll look into adding that.

    Regards,
    Allan
This discussion has been closed.