Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Merge pull request #207 from xtine/add-review-functionality
Browse files Browse the repository at this point in the history
Add Review page functionality
  • Loading branch information
cmc333333 committed Apr 8, 2016
2 parents a39e3f0 + a392c9c commit 0f99613
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 11 deletions.
17 changes: 15 additions & 2 deletions regulations/static/regulations/css/less/module/comment.less
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,11 @@ a.comment-index-review {
line-height: 18px;
text-transform: inherit;
width: 425px;

&:hover {
cursor: pointer;
text-decoration: underline;
}
}

.details {
Expand Down Expand Up @@ -373,13 +378,21 @@ a.comment-index-review {
}

.submit-button {
background: @grey;
background: @pacific;
border-radius: 3px;
color: #000;
color: #FFF;
font-size: 17px;
font-weight: bold;
height: auto;
padding: 12px 30px;

&:disabled, &:disabled:hover {
background: @grey;
color: #000;
}
&:hover {
background-color: @pacific_hover;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
},

Expand All @@ -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');

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();

Expand Down Expand Up @@ -72,6 +96,10 @@ var CommentReviewView = Backbone.View.extend({
this.render();
},

toggleSubmit: function() {
$('.submit-button').prop('disabled', function(i, v) { return !v; });
},

submit: function() {
var prefix = window.APP_PREFIX || '/';
var $xhr = $.ajax({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ var PreambleHeadView = Backbone.View.extend({
},

readProposal: function() {
if ($('#preamble-write').is(':visible')) {
// yeah... need a better way to manage this. - xtine
if ($('#preamble-write').is(':visible') || $('#comment-review').length) {
this.readTabOpen();

CommentEvents.trigger('read:proposal');
Expand Down
4 changes: 3 additions & 1 deletion regulations/templates/regulations/comment-review-chrome.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
class="drawer-toggle-icon" alt="Table of Contents toggle" /></a></li>
{% endblock %}

{% block wayfinding %}{% endblock %}

{% block header-secondary %}
{% include "regulations/preamble-header.html" %}
{% endblock %}
Expand Down Expand Up @@ -56,7 +58,7 @@ <h3>You are submitting an official comment to Regulations.gov.</h3>
<div class="comments">
<ul>
<% _.each(comments, function(comment, index) { %>
<li>
<li data-section="<%= comment.id %>">
<h4><%= comment.label %></h4>
<div class="comment-content">
<%= comment.comment %>
Expand Down
6 changes: 1 addition & 5 deletions regulations/templates/regulations/preamble-chrome.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
</li>
{% endblock %}

{% block wayfinding %}
<span class="subpart">{{doc_number}}</span>
<span id="active-title"></span>
{% endblock %}

{% block wayfinding %}{% endblock %}

{% block header-secondary %}
{% include "regulations/preamble-header.html" %}
Expand Down

0 comments on commit 0f99613

Please sign in to comment.