Commit a3459eae by Albert St. Aubin

Updated learner profile to only use the tab panel view when there is accomplishments.

TNL-5283
parent eb6bb036
...@@ -100,10 +100,10 @@ define(['underscore', 'URI', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers' ...@@ -100,10 +100,10 @@ define(['underscore', 'URI', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers'
expect(learnerProfileView.$('.wrapper-profile-section-two').length).toBe(0); expect(learnerProfileView.$('.wrapper-profile-section-two').length).toBe(0);
}; };
var expectTabbedViewToBeHidden = function(requests, tabbedViewView) { var expectTabbedViewToBeUndefined = function(requests, tabbedViewView) {
// Unrelated initial request, no badge request // Unrelated initial request, no badge request
expect(requests.length).toBe(1); expect(requests.length).toBe(1);
expect(tabbedViewView.$el.find('.page-content-nav').is(':visible')).toBe(false); expect(tabbedViewView).toBe(undefined);
}; };
var expectTabbedViewToBeShown = function(tabbedViewView) { var expectTabbedViewToBeShown = function(tabbedViewView) {
...@@ -228,10 +228,17 @@ define(['underscore', 'URI', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers' ...@@ -228,10 +228,17 @@ define(['underscore', 'URI', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers'
expectLimitedProfileSectionsAndFieldsToBeRendered: expectLimitedProfileSectionsAndFieldsToBeRendered, expectLimitedProfileSectionsAndFieldsToBeRendered: expectLimitedProfileSectionsAndFieldsToBeRendered,
expectProfileSectionsAndFieldsToBeRendered: expectProfileSectionsAndFieldsToBeRendered, expectProfileSectionsAndFieldsToBeRendered: expectProfileSectionsAndFieldsToBeRendered,
expectProfileSectionsNotToBeRendered: expectProfileSectionsNotToBeRendered, expectProfileSectionsNotToBeRendered: expectProfileSectionsNotToBeRendered,
expectTabbedViewToBeHidden: expectTabbedViewToBeHidden, expectTabbedViewToBeShown: expectTabbedViewToBeShown, expectTabbedViewToBeUndefined: expectTabbedViewToBeUndefined,
expectBadgesDisplayed: expectBadgesDisplayed, expectBadgesHidden: expectBadgesHidden, expectTabbedViewToBeShown: expectTabbedViewToBeShown,
expectBadgeLoadingErrorIsRendered: expectBadgeLoadingErrorIsRendered, breakBadgeLoading: breakBadgeLoading, expectBadgesDisplayed: expectBadgesDisplayed,
firstPageBadges: firstPageBadges, secondPageBadges: secondPageBadges, thirdPageBadges: thirdPageBadges, expectBadgesHidden: expectBadgesHidden,
emptyBadges: emptyBadges, expectPage: expectPage, makeBadge: makeBadge expectBadgeLoadingErrorIsRendered: expectBadgeLoadingErrorIsRendered,
breakBadgeLoading: breakBadgeLoading,
firstPageBadges: firstPageBadges,
secondPageBadges: secondPageBadges,
thirdPageBadges: thirdPageBadges,
emptyBadges: emptyBadges,
expectPage: expectPage,
makeBadge: makeBadge
}; };
}); });
...@@ -72,7 +72,7 @@ define(['backbone', 'jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helper ...@@ -72,7 +72,7 @@ define(['backbone', 'jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helper
tabbedView = context.learnerProfileView.tabbedView, tabbedView = context.learnerProfileView.tabbedView,
learnerProfileView = context.learnerProfileView; learnerProfileView = context.learnerProfileView;
LearnerProfileHelpers.expectTabbedViewToBeHidden(requests, tabbedView); LearnerProfileHelpers.expectTabbedViewToBeUndefined(requests, tabbedView);
LearnerProfileHelpers.expectBadgesHidden(learnerProfileView); LearnerProfileHelpers.expectBadgesHidden(learnerProfileView);
}); });
...@@ -83,7 +83,7 @@ define(['backbone', 'jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helper ...@@ -83,7 +83,7 @@ define(['backbone', 'jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helper
tabbedView = context.learnerProfileView.tabbedView, tabbedView = context.learnerProfileView.tabbedView,
learnerProfileView = context.learnerProfileView; learnerProfileView = context.learnerProfileView;
LearnerProfileHelpers.expectTabbedViewToBeHidden(requests, tabbedView); LearnerProfileHelpers.expectTabbedViewToBeUndefined(requests, tabbedView);
LearnerProfileHelpers.expectBadgesHidden(learnerProfileView); LearnerProfileHelpers.expectBadgesHidden(learnerProfileView);
}); });
......
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
}, },
render: function() { render: function() {
var self = this; var tabs,
self = this;
this.sectionTwoView = new SectionTwoTab({ this.sectionTwoView = new SectionTwoTab({
viewList: this.options.sectionTwoFieldViews, viewList: this.options.sectionTwoFieldViews,
...@@ -47,10 +48,6 @@ ...@@ -47,10 +48,6 @@
ownProfile: this.options.ownProfile ownProfile: this.options.ownProfile
}); });
var tabs = [
{view: this.sectionTwoView, title: gettext('About Me'), url: 'about_me'}
];
HtmlUtils.setHtml(this.$el, HtmlUtils.template(learnerProfileTemplate)({ HtmlUtils.setHtml(this.$el, HtmlUtils.template(learnerProfileTemplate)({
username: self.options.accountSettingsModel.get('username'), username: self.options.accountSettingsModel.get('username'),
ownProfile: self.options.ownProfile, ownProfile: self.options.ownProfile,
...@@ -59,17 +56,22 @@ ...@@ -59,17 +56,22 @@
this.renderFields(); this.renderFields();
if (this.showFullProfile() && (this.options.accountSettingsModel.get('accomplishments_shared'))) { if (this.showFullProfile() && (this.options.accountSettingsModel.get('accomplishments_shared'))) {
tabs.push({ tabs = [
{view: this.sectionTwoView, title: gettext('About Me'), url: 'about_me'},
{
view: this.options.badgeListContainer, view: this.options.badgeListContainer,
title: gettext('Accomplishments'), title: gettext('Accomplishments'),
url: 'accomplishments' url: 'accomplishments'
}); }
];
// Build the accomplishments Tab and fill with data
this.options.badgeListContainer.collection.fetch().done(function() { this.options.badgeListContainer.collection.fetch().done(function() {
self.options.badgeListContainer.render(); self.options.badgeListContainer.render();
}).error(function() { }).error(function() {
self.options.badgeListContainer.renderError(); self.options.badgeListContainer.renderError();
}); });
}
this.tabbedView = new TabbedView({ this.tabbedView = new TabbedView({
tabs: tabs, tabs: tabs,
router: this.router, router: this.router,
...@@ -77,12 +79,6 @@ ...@@ -77,12 +79,6 @@
}); });
this.tabbedView.render(); this.tabbedView.render();
if (tabs.length === 1) {
// If the tab is unambiguous, don't display the tab interface.
this.tabbedView.$el.find('.page-content-nav').hide();
}
this.$el.find('.account-settings-container').append(this.tabbedView.el); this.$el.find('.account-settings-container').append(this.tabbedView.el);
if (this.firstRender) { if (this.firstRender) {
...@@ -96,8 +92,9 @@ ...@@ -96,8 +92,9 @@
Backbone.history.stop(); Backbone.history.stop();
Backbone.history.start(); Backbone.history.start();
} }
} else {
this.$el.find('.account-settings-container').append(this.sectionTwoView.render().el);
}
return this; return this;
}, },
......
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