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,45 +56,45 @@ ...@@ -59,45 +56,45 @@
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.options.badgeListContainer, {view: this.sectionTwoView, title: gettext('About Me'), url: 'about_me'},
title: gettext('Accomplishments'), {
url: 'accomplishments' view: this.options.badgeListContainer,
}); title: gettext('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({
tabs: tabs,
router: this.router,
viewLabel: gettext('Profile')
});
this.tabbedView.render();
if (tabs.length === 1) { this.tabbedView = new TabbedView({
// If the tab is unambiguous, don't display the tab interface. tabs: tabs,
this.tabbedView.$el.find('.page-content-nav').hide(); router: this.router,
} viewLabel: gettext('Profile')
});
this.$el.find('.account-settings-container').append(this.tabbedView.el);
if (this.firstRender) { this.tabbedView.render();
this.router.on('route:loadTab', _.bind(this.setActiveTab, this)); this.$el.find('.account-settings-container').append(this.tabbedView.el);
Backbone.history.start();
this.firstRender = false; if (this.firstRender) {
// Load from history. this.router.on('route:loadTab', _.bind(this.setActiveTab, this));
this.router.navigate((Backbone.history.getFragment() || 'about_me'), {trigger: true}); Backbone.history.start();
this.firstRender = false;
// Load from history.
this.router.navigate((Backbone.history.getFragment() || 'about_me'), {trigger: true});
} else {
// Restart the router so the tab will be brought up anew.
Backbone.history.stop();
Backbone.history.start();
}
} else { } else {
// Restart the router so the tab will be brought up anew. this.$el.find('.account-settings-container').append(this.sectionTwoView.render().el);
Backbone.history.stop();
Backbone.history.start();
} }
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