Skip to content

Commit

Permalink
Add 'Need info' field'
Browse files Browse the repository at this point in the history
  • Loading branch information
mounirlamouri committed Nov 18, 2012
1 parent ed96501 commit 6406525
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/bzhome.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ $(document).ready(function() {
var reviewlist = new ReviewList;
var feedbacklist = new FeedbackList;
var superreviewlist = new SuperReviewList;
var needinfoList = new NeedInfoList;
});

var bzhome = {
Expand Down
41 changes: 38 additions & 3 deletions app/reviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ $(function() {
window.SuperReviews = Reviews.extend({
localStorage: new Store("bzhome-superreviews")
});

window.NeedInfos = Reviews.extend({
localStorage: new Store("bzhome-needinfo")
});

window.reviews = new Reviews;
window.feedbacks = new Feedbacks;
window.superReviews = new SuperReviews;
window.needInfos = new NeedInfos;

window.ReviewRow = Backbone.View.extend({
tagName: "div",
Expand All @@ -45,6 +50,16 @@ $(function() {
}
});

window.NeedInfoRow = Backbone.View.extend({
tagName: "div",
className: "needinfo-item",
template: Handlebars.compile($("#needinfo-item").html()),
render: function() {
$(this.el).html(this.template(this.model.toJSON()));
return this;
}
});

window.ReviewList = Backbone.View.extend({
el: $("#reviews"),

Expand All @@ -65,6 +80,9 @@ $(function() {
case "superreview":
collection = this.collection = superReviews;
break;
case "needinfo":
collection = this.collection = needInfos;
break;
default:
console.error("unknown type '" + this.type + "'!");
}
Expand All @@ -90,6 +108,10 @@ $(function() {
case "superreview":
items = requests.superReviews;
break;
case "needinfo":
items = requests.needInfos;
console.log(requests);
break;
default:
console.error("unknown type '" + type + "'!");
}
Expand All @@ -106,9 +128,16 @@ $(function() {
},

addReview: function(review) {
var view = new ReviewRow({
model: review
});
var view;
if (this.type == 'needinfo') {
view = new NeedInfoRow({
model: review
});
} else {
view = new ReviewRow({
model: review
});
}
this.list.append(view.render().el);
}
});
Expand All @@ -124,4 +153,10 @@ $(function() {
list: $("#superreviews-list"),
type: "superreview"
});

window.NeedInfoList = ReviewList.extend({
el: $("#needinfo"),
list: $("#needinfo-list"),
type: "needinfo"
});
});
22 changes: 19 additions & 3 deletions app/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ User.prototype.requests = function(callback) {
var name = this.username.replace(/@.+/, ""), // can't get full email if not logged in
superReviews = [],
reviews = [],
feedbacks = [];
feedbacks = [],
needInfos = [];

this.client.searchBugs({
'field0-0-0': 'flag.requestee',
'type0-0-0': 'equals',
'value0-0-0': this.username,
include_fields: 'id,summary,status,resolution,last_change_time,attachments'
include_fields: 'id,summary,status,resolution,last_change_time,attachments,flags'
},
function(err, bugs) {
if (err) {
Expand Down Expand Up @@ -94,12 +95,27 @@ User.prototype.requests = function(callback) {
}
});
});

if (bug.flags) {
bug.flags.forEach(function(flag) {
if (flag.requestee && flag.requestee.name == name
&& flag.status == '?' && flag.name == 'needinfo') {
needInfos.push({
flag: flag,
attachment: null,
bug: bug,
time: null
});
}
});
}
});

superReviews.sort(utils.byTime);
reviews.sort(utils.byTime);
feedbacks.sort(utils.byTime);
// Sorting for needinfo is pointless because there is no time information.

callback(null, { superReviews: superReviews, reviews: reviews, feedbacks: feedbacks });
callback(null, { superReviews: superReviews, reviews: reviews, feedbacks: feedbacks, needInfos: needInfos });
});
}
20 changes: 20 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@
<span class="timeago" title="{{attachment.last_change_time}}"></span>
</div>
</script>

<script id="needinfo-item" type="text/html">
<div class="review-attachment">
<a class="review-link" href={{show_bug bug.id}} target=_blank title="{{> bug_tooltip}}">
{{bug.id}}: {{bug.summary}}
</a>
</div>
<div class="suffix">by {{flag.setter.name}}</div>
</script>


<script id="search-item" type="text/html">
<div id="search-{{idify name}}" class="search-item">
Expand Down Expand Up @@ -310,6 +320,16 @@
</div>
</section>

<section id="needinfo">
<div class="header">Need info <span class="count"></span></div>
<div class="content">
<div id="needinfo-list">

</div>
</div>
</section>


<section id="searches">
<div class="header">Searches</div>
<div class="content">
Expand Down
4 changes: 2 additions & 2 deletions index.less
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ section {
}
}

#superreviews, #reviews, #feedbacks {
#superreviews, #reviews, #feedbacks, #needinfo {
margin-bottom: 1.4em;

.review-item {
.review-item, .needinfo-item {
margin-bottom: 1em;

.review-attachment {
Expand Down

0 comments on commit 6406525

Please sign in to comment.