Skip to content

Commit 7e10b11

Browse files
committed
Merge branch 'master' of github.com:huboard/huboard-web
2 parents 15a93d8 + c47e231 commit 7e10b11

9 files changed

Lines changed: 130 additions & 36 deletions

File tree

ember-app/app/models/board.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var Board = Ember.Object.extend({
2424
return _.union.apply(_,[this.other_labels]
2525
.concat(this.linkedRepos.map(function (r){return r.other_labels; })));
2626

27-
}.property("linkedRepos.@each.issues.length", "issues.length"),
27+
}.property("linkedRepos.@each.issues.[]", "issues.[]"),
2828
filterLabels: function () {
2929
var labels = this.get("combinedLabels");
3030

@@ -35,21 +35,21 @@ var Board = Ember.Object.extend({
3535
}).value().sort(function (a,b){
3636
return a.name.localeCompare(b.name);
3737
});
38-
}.property(),
38+
}.property("combinedLabels", "combinedLabels.[]"),
3939
filterMilestones: function () {
4040
return _.chain(this.get("combinedMilestones"))
4141
.map(function (g) {
4242
return _.first(g);
4343
})
4444
.value();
45-
}.property("combinedMilestones"),
45+
}.property("combinedMilestones.[]"),
4646
combinedMilestones: function(){
4747
var milestones = _.union.apply(_,[this.milestones]
4848
.concat(this.linkedRepos.map(function (r){return r.milestones; })));
4949
return _.chain(milestones)
5050
.groupBy(function(l){return l.title.toLocaleLowerCase(); })
5151
.value();
52-
}.property("milestones.length","linkedRepos.@each.milestones.length"),
52+
}.property("milestones.[]","linkedRepos.@each.milestones.[]"),
5353
combinedAssignees: function(){
5454
var assignees = this.get("assignees");
5555
var linked = this.get("linkedRepos").map(function(repo){

ember-app/app/services/filter-groups.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ var FilterGroups = Ember.Service.extend({
1212
setGroups: function(model){
1313
var self = this;
1414
this.get("groups").forEach(function(group){
15-
self.get(group).create(model);
15+
var group = self.get(group);
16+
group.set('model', model);
17+
group.create(model);
1618
});
1719
this.set("created", true);
1820
},

ember-app/app/services/filter_groups/board.js

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,59 @@
11
import Ember from 'ember';
22

3+
function attr(modelProp, map) {
4+
return Ember.computed("model." + modelProp, "model." + modelProp + ".[]", {
5+
get: function(key){
6+
var model = this.get('model');
7+
8+
var filters = this.get("model." + modelProp).map(map);
9+
10+
filters.insertAt(0, Ember.Object.create({
11+
name: model.get('repo.name'),
12+
queryParam: "repo",
13+
mode:0,
14+
color: "7965cc",
15+
condition:function(i){
16+
return i.repo.name === model.get('repo.name');
17+
}
18+
}));
19+
if(this._filters){
20+
this._filters.forEach(function(f){
21+
var newOne = filters.findBy('name', f.name);
22+
if(newOne){
23+
newOne.set('mode', f.mode);
24+
}
25+
});
26+
}
27+
this._filters = filters;
28+
29+
return filters;
30+
},
31+
set: function(key, value){
32+
this.set("model." + key, value);
33+
return value;
34+
}
35+
});
36+
}
37+
338
var BoardFilters = Ember.Service.extend({
439
filters: [],
540
strategy: "inclusive",
641

742
create: function(model){
843
var owner = model.get("full_name").split("/")[0];
944

10-
this.set("filters", model.get("link_labels").map(function(l){
11-
var name = owner === l.user ? l.repo : l.user + "/" + l.repo;
45+
this.set("filters", attr("linkedRepos", function(l){
46+
var name = owner === l.repo.owner.login ? l.repo.name : l.repo.full_name;
1247
return Ember.Object.create({
1348
name: name,
1449
queryParam: "repo",
1550
mode:0,
16-
color: l.color,
51+
color: l.repo.color,
1752
condition:function(i){
18-
return i.repo.name === l.repo && i.repo.owner.login === l.user;
53+
return i.repo.name === l.repo.name && i.repo.owner.login === l.repo.owner.login;
1954
}
2055
});
2156
}));
22-
this.get("filters").insertAt(0, Ember.Object.create({
23-
name: model.get('repo.name'),
24-
queryParam: "repo",
25-
mode:0,
26-
color: "7965cc",
27-
condition:function(i){
28-
return i.repo.name === model.get('repo.name');
29-
}
30-
}));
3157

3258
return this.get("filters");
3359
}

ember-app/app/services/filter_groups/label.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
11
import Ember from 'ember';
22

3+
function attr(modelProp, map) {
4+
return Ember.computed("model." + modelProp, "model." + modelProp + ".[]", {
5+
get: function(key){
6+
7+
var filters = this.get("model." + modelProp).map(map);
8+
9+
if(this._filters){
10+
this._filters.forEach(function(f){
11+
var newOne = filters.findBy('name', f.name);
12+
if(newOne){
13+
newOne.set('mode', f.mode);
14+
}
15+
});
16+
}
17+
this._filters = filters;
18+
19+
return filters;
20+
},
21+
set: function(key, value){
22+
this.set("model." + key, value);
23+
return value;
24+
}
25+
});
26+
}
27+
328
var LabelFilters = Ember.Service.extend({
429
filters: [],
530
strategy: "grouping",
631

732
create: function(model){
8-
this.set("filters", model.get("filterLabels").map(function(l){
33+
this.set("filters", attr("filterLabels", function(l){
934
return Ember.Object.create({
1035
name: l.name,
1136
queryParam: "label",

ember-app/app/services/filter_groups/member.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var MemberFilters = Ember.Service.extend({
1616
},
1717

1818
filters : function () {
19-
return this.get("avatars").map(function(a){
19+
var filters = this.get("avatars").map(function(a){
2020
return Ember.Object.create({
2121
name: a.login,
2222
avatar : a,
@@ -26,6 +26,16 @@ var MemberFilters = Ember.Service.extend({
2626
}
2727
});
2828
});
29+
if(this._filters){
30+
this._filters.forEach(function(f){
31+
var newOne = filters.findBy('name', f.name);
32+
if(newOne){
33+
newOne.set('mode', f.mode);
34+
}
35+
});
36+
}
37+
this._filters = filters;
38+
return filters;
2939
}.property("avatars"),
3040

3141
avatars : function () {

ember-app/app/services/filter_groups/milestone.js

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,50 @@
11
import Ember from 'ember';
22

3+
function attr(modelProp, map) {
4+
return Ember.computed("model." + modelProp, {
5+
get: function(key){
6+
var filters = this.get("model." + modelProp).map(map);
7+
filters.insertAt(0, Ember.Object.create({
8+
name: 'No milestone',
9+
queryParam: "milestone",
10+
mode:0,
11+
condition:function(i){
12+
return i.milestone == null;
13+
}
14+
}));
15+
if(this._filters){
16+
this._filters.forEach(function(f){
17+
var newOne = filters.findBy('name', f.name);
18+
if(newOne){
19+
newOne.set('mode', f.mode);
20+
}
21+
});
22+
}
23+
this._filters = filters;
24+
return filters;
25+
},
26+
set: function(key, value){
27+
this.set("model." + key, value);
28+
return value;
29+
}
30+
});
31+
}
32+
333
var MilestoneFilters = Ember.Service.extend({
434
filters: [],
535
strategy: "inclusive",
636

737
create: function(model){
8-
this.set("filters", model.get("filterMilestones").map(function(m){
9-
return Ember.Object.create({
38+
this.set("filters", attr("filterMilestones", function(m){
39+
return Ember.Object.create({
1040
name: m.title,
1141
queryParam: "milestone",
1242
mode:0,
1343
condition:function(i){
14-
return i.milestone && i.milestone.title.toLocaleLowerCase() === m.title.toLocaleLowerCase();
44+
return i.milestone && i.milestone.title.toLocaleLowerCase() === m.title.toLocaleLowerCase();
1545
}
16-
});
17-
}));
18-
this.get("filters").insertAt(0, Ember.Object.create({
19-
name: 'No milestone',
20-
queryParam: "milestone",
21-
mode:0,
22-
condition:function(i){
23-
return i.milestone == null;
24-
}
46+
});
2547
}));
26-
2748
return this.get("filters");
2849
}
2950
});

ember-app/app/services/filters.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import Ember from "ember";
22

3+
function attr(group) {
4+
return Ember.computed('filterGroups.' + group + ".filters", {
5+
get: function(key){
6+
return this.get('filterGroups.' + group + ".filters");
7+
}
8+
});
9+
}
10+
311
var FiltersService = Ember.Service.extend({
412
//filterGroups requires setGroups(model) before it yields
513
//anything meaningful to the FiltersService
@@ -11,7 +19,8 @@ var FiltersService = Ember.Service.extend({
1119
if (!this.get("filterGroups.created")){ return; }
1220
key = key.replace("Filters", "");
1321
if (this.get("filterGroups." + key + ".filters")){
14-
return this.get("filterGroups." + key + ".filters");
22+
this.set(key+ "Filters", attr(key));
23+
return this.get(key + "Filters");
1524
}
1625
},
1726

ember-app/app/views/issue/create.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ var IssuesCreateView = ModalView.extend(KeyPressHandlingMixin, {
3333
return false;
3434
},
3535
focusTitleField: function(){
36-
Ember.run.schedule("afterRender", this, "focusTextbox");
36+
Ember.run.schedule("afterRender", this, "focusTextbox");
3737
}.on("init"),
3838
focusTextbox: function(){
39-
var input = this.$("input");
39+
var input = this.$("input").first();
4040
input.focus();
4141
}
4242
});

lib/bridge/github/board.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def linked?(user, repo)
4747
def linked(user, repo)
4848
label = link_labels.find{|l| l['user'] == user && l['repo'] == repo}
4949
board = Board.new(user, repo, @connection_factory).meta
50+
board[:repo][:color] = label['color']
5051
board[:issues] = board[:issues].map {|i| i.merge({ color: label['color'] })}
5152
board
5253
end

0 commit comments

Comments
 (0)