-
Notifications
You must be signed in to change notification settings - Fork 46
Add Review page functionality #207
Changes from 4 commits
d37f222
a72b666
c7543f1
02e0f47
5068734
a392c9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,16 @@ var _ = require('underscore'); | |
var Backbone = require('backbone'); | ||
Backbone.$ = $; | ||
|
||
var comments = require('../../collections/comment-collection'); | ||
|
||
var MainEvents = require('../../events/main-events'); | ||
var PreambleHeadView = require('../header/preamble-head-view'); | ||
var CommentEvents = require('../../events/comment-events'); | ||
var comments = require('../../collections/comment-collection'); | ||
|
||
var CommentReviewView = Backbone.View.extend({ | ||
events: { | ||
'click .edit-comment': 'editComment', | ||
'click .preview-button': 'preview', | ||
'change .agree': 'toggleSubmit', | ||
'click .submit-button': 'submit' | ||
}, | ||
|
||
|
@@ -27,19 +29,41 @@ var CommentReviewView = Backbone.View.extend({ | |
|
||
this.previewLoading = false; | ||
|
||
this.listenTo(CommentEvents, 'read:proposal', this.handleRead); | ||
|
||
this.render(); | ||
}, | ||
|
||
findElms: function() { | ||
this.$status = this.$el.find('.status'); | ||
}, | ||
|
||
handleRead: function() { | ||
var section = this.docId + '-preamble-' + this.docId + '-I'; | ||
var options = {id: section, section: section, mode: 'read'}; | ||
|
||
$('#content-body').removeClass('comment-review-wrapper').addClass('preamble-wrapper'); | ||
|
||
MainEvents.trigger('section:open', section, options, 'preamble-section'); | ||
}, | ||
|
||
editComment: function(e) { | ||
var section = $(e.target).closest('li').data('section'); | ||
var options = {id: section, section: section, mode: 'write'}; | ||
|
||
$('#content-body').removeClass('comment-review-wrapper').addClass('preamble-wrapper'); | ||
|
||
MainEvents.trigger('section:open', section, options, 'preamble-section'); | ||
CommentEvents.trigger('comment:writeTabOpen'); | ||
}, | ||
|
||
render: function() { | ||
var commentData = comments.toJSON({docId: this.docId}); | ||
var html = this.template({ | ||
comments: commentData, | ||
previewLoading: this.previewLoading | ||
}); | ||
|
||
this.$content.html(html); | ||
this.findElms(); | ||
|
||
|
@@ -72,6 +96,10 @@ var CommentReviewView = Backbone.View.extend({ | |
this.render(); | ||
}, | ||
|
||
toggleSubmit: function() { | ||
$('.submit-button').prop('disabled', function(i, v) { return !v; }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Procedural updates like this might not mix well with the template rendering we're doing elsewhere in this view. AFAICT, If a user requests a comment download, then checks the "I agree" box, and then the download finishes, we're going to re-render the entire section, which will disable the submit button again. We could roll this update into the template, or only use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. If we were to update it template-side, would it be inline JS or something else..? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, I've been handling logic in templates with gross backbone template js, like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made a separate issue for this: #214 so we can merge this PR for demo. |
||
}, | ||
|
||
submit: function() { | ||
var prefix = window.APP_PREFIX || '/'; | ||
var $xhr = $.ajax({ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to add the
preamble-wrapper
class here? I don't see references to it in the less or js. Maybe we can drop that class altogether. Also, if we moved thecomment-review-wrapper
class from thediv
to the childsection
, would we have to remove the class at all?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't double check that
.preamble-wrapper
was being used, but.comment-review-wrapper
does need to be on the same element as#content-body
to resize the width of the content area.