Move the comment models to Backbone.js.

Review Request #3834 — Created Feb. 3, 2013 and submitted — Latest diff uploaded

Information

Review Board
master

Reviewers

Move the comment models to Backbone.js.

Previously, each comment implementation, though similar in
functionality, had lots of duplicate code.

Now there's a BaseComment model that takes care of all core comment
functionality, and subclasses that implement the support for the
specialized attributes they care about.

These objects validate their data when setting and before sending to the
server, to help us catch otherwise non-obvious problems. This is a
pattern I hope to make use of going forward, so that we can provide more
clear errors when we hit bugs.

All the other commenting code (blocks, dialogs) that deal with the
Comment objects had to be updated to make use of the newer-style
properties and events.

Unit tests were added to test the various bits of functionality.
All unit tests pass.

I tested the following with diff comments, screenshot comments, and
file attachment comments:

1) Creating new comments works (tested with and without existing drafts)
2) Editing an existing draft comment works.
3) Deleting a draft comment works.
4) Comments publish correctly.
5) The comment dialog dirty state behaves as expected in response to
   the presence of text in the field, and modifications to that text.