Fix issues for  DSC-389

Also reformat some code to make it consistant within the file. (hence all the weird changes).
Hi Aaron,

These functions such as removeItem, toggleField, submitBulkEdit all specific to bulk editing.  Reformatting might not be enough, I wonder whether a BulkEdit prototype JS class is appropriate in this case.  Also, I noticed there are utility functions such as isInteger() down the track, such function would be useful to other freemarker templates as well; might be good to put into a .js of its own, and use requireJS to reference these functions.