Commit 2398824b by Bill DeRusha

Add Full Country & Language Names to Teams [TNL-2891]

parent 117bc4a9
...@@ -9,13 +9,25 @@ define([ ...@@ -9,13 +9,25 @@ define([
return { return {
name: "team " + i, name: "team " + i,
id: "id " + i, id: "id " + i,
language: "English", language: languages[i%4][0],
country: "Sealand", country: countries[i%4][0],
is_active: true, is_active: true,
membership: [] membership: []
}; };
}); });
}; },
countries = [
['', ''],
['US', 'United States'],
['CA', 'Canada'],
['MX', 'Mexico']
],
languages = [
['', ''],
['en', 'English'],
['es', 'Spanish'],
['fr', 'French']
];
beforeEach(function () { beforeEach(function () {
setFixtures('<div class="teams-container"></div>'); setFixtures('<div class="teams-container"></div>');
...@@ -33,7 +45,10 @@ define([ ...@@ -33,7 +45,10 @@ define([
teamsView = new TeamsView({ teamsView = new TeamsView({
el: '.teams-container', el: '.teams-container',
collection: teamCollection, collection: teamCollection,
teamParams: {} teamParams: {
countries: countries,
languages: languages
}
}).render(); }).render();
}); });
...@@ -43,9 +58,10 @@ define([ ...@@ -43,9 +58,10 @@ define([
expect(teamsView.$('.teams-paging-header').text()).toMatch('Showing 1-5 out of 6 total'); expect(teamsView.$('.teams-paging-header').text()).toMatch('Showing 1-5 out of 6 total');
_.each(initialTeams, function (team, index) { _.each(initialTeams, function (team, index) {
var currentCard = teamCards.eq(index); var currentCard = teamCards.eq(index);
expect(currentCard.text()).toMatch(team.name); expect(currentCard.text()).toMatch(team.name);
expect(currentCard.text()).toMatch(team.language); expect(currentCard.text()).toMatch(_.object(languages)[team.language]);
expect(currentCard.text()).toMatch(team.country); expect(currentCard.text()).toMatch(_.object(countries)[team.country]);
}); });
expect(footerEl.text()).toMatch('1\\s+out of\\s+\/\\s+2'); expect(footerEl.text()).toMatch('1\\s+out of\\s+\/\\s+2');
expect(footerEl).not.toHaveClass('hidden'); expect(footerEl).not.toHaveClass('hidden');
......
...@@ -47,11 +47,16 @@ ...@@ -47,11 +47,16 @@
TeamCountryLanguageView = Backbone.View.extend({ TeamCountryLanguageView = Backbone.View.extend({
template: _.template(teamCountryLanguageTemplate), template: _.template(teamCountryLanguageTemplate),
initialize: function (options) {
this.countries = options.countries;
this.languages = options.languages;
},
render: function() { render: function() {
// this.$el should be the card meta div // this.$el should be the card meta div
this.$el.append(this.template({ this.$el.append(this.template({
country: this.model.get('country'), country: this.countries[this.model.get('country')],
language: this.model.get('language') language: this.languages[this.model.get('language')]
})); }));
} }
}); });
...@@ -62,7 +67,11 @@ ...@@ -62,7 +67,11 @@
// TODO: show last activity detail view // TODO: show last activity detail view
this.detailViews = [ this.detailViews = [
new TeamMembershipView({model: this.model, maxTeamSize: this.maxTeamSize}), new TeamMembershipView({model: this.model, maxTeamSize: this.maxTeamSize}),
new TeamCountryLanguageView({model: this.model}) new TeamCountryLanguageView({
model: this.model,
countries: this.countries,
languages: this.languages
})
]; ];
}, },
......
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
this.itemViewClass = TeamCardView.extend({ this.itemViewClass = TeamCardView.extend({
router: options.router, router: options.router,
topic: options.topic, topic: options.topic,
maxTeamSize: options.maxTeamSize maxTeamSize: options.maxTeamSize,
countries: this.selectorOptionsArrayToHashWithBlank(options.teamParams.countries),
languages: this.selectorOptionsArrayToHashWithBlank(options.teamParams.languages),
}); });
PaginatedView.prototype.initialize.call(this); PaginatedView.prototype.initialize.call(this);
this.teamParams = options.teamParams; this.teamParams = options.teamParams;
...@@ -29,6 +31,20 @@ ...@@ -29,6 +31,20 @@
this.$el.append(teamActionsView.$el); this.$el.append(teamActionsView.$el);
teamActionsView.render(); teamActionsView.render();
return this; return this;
},
/**
* Convert a 2d array to an object equivalent with an additional blank element
*
* @param {Array.<Array.<string>>} Two dimensional options array
* @returns {Object} Hash version of the input array
* @example selectorOptionsArrayToHashWithBlank([["a", "alpha"],["b","beta"]])
* // returns {"a":"alpha", "b":"beta", "":""}
*/
selectorOptionsArrayToHashWithBlank: function (options) {
var map = _.object(options);
map[""] = "";
return map;
} }
}); });
return TeamsView; return TeamsView;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment