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'
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
expect(requests.length).toBe(1);
expect(tabbedViewView.$el.find('.page-content-nav').is(':visible')).toBe(false);
expect(tabbedViewView).toBe(undefined);
};
var expectTabbedViewToBeShown = function(tabbedViewView) {
......@@ -228,10 +228,17 @@ define(['underscore', 'URI', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers'
expectLimitedProfileSectionsAndFieldsToBeRendered: expectLimitedProfileSectionsAndFieldsToBeRendered,
expectProfileSectionsAndFieldsToBeRendered: expectProfileSectionsAndFieldsToBeRendered,
expectProfileSectionsNotToBeRendered: expectProfileSectionsNotToBeRendered,
expectTabbedViewToBeHidden: expectTabbedViewToBeHidden, expectTabbedViewToBeShown: expectTabbedViewToBeShown,
expectBadgesDisplayed: expectBadgesDisplayed, expectBadgesHidden: expectBadgesHidden,
expectBadgeLoadingErrorIsRendered: expectBadgeLoadingErrorIsRendered, breakBadgeLoading: breakBadgeLoading,
firstPageBadges: firstPageBadges, secondPageBadges: secondPageBadges, thirdPageBadges: thirdPageBadges,
emptyBadges: emptyBadges, expectPage: expectPage, makeBadge: makeBadge
expectTabbedViewToBeUndefined: expectTabbedViewToBeUndefined,
expectTabbedViewToBeShown: expectTabbedViewToBeShown,
expectBadgesDisplayed: expectBadgesDisplayed,
expectBadgesHidden: expectBadgesHidden,
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
tabbedView = context.learnerProfileView.tabbedView,
learnerProfileView = context.learnerProfileView;
LearnerProfileHelpers.expectTabbedViewToBeHidden(requests, tabbedView);
LearnerProfileHelpers.expectTabbedViewToBeUndefined(requests, tabbedView);
LearnerProfileHelpers.expectBadgesHidden(learnerProfileView);
});
......@@ -83,7 +83,7 @@ define(['backbone', 'jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helper
tabbedView = context.learnerProfileView.tabbedView,
learnerProfileView = context.learnerProfileView;
LearnerProfileHelpers.expectTabbedViewToBeHidden(requests, tabbedView);
LearnerProfileHelpers.expectTabbedViewToBeUndefined(requests, tabbedView);
LearnerProfileHelpers.expectBadgesHidden(learnerProfileView);
});
......
......@@ -39,7 +39,8 @@
},
render: function() {
var self = this;
var tabs,
self = this;
this.sectionTwoView = new SectionTwoTab({
viewList: this.options.sectionTwoFieldViews,
......@@ -47,10 +48,6 @@
ownProfile: this.options.ownProfile
});
var tabs = [
{view: this.sectionTwoView, title: gettext('About Me'), url: 'about_me'}
];
HtmlUtils.setHtml(this.$el, HtmlUtils.template(learnerProfileTemplate)({
username: self.options.accountSettingsModel.get('username'),
ownProfile: self.options.ownProfile,
......@@ -59,45 +56,45 @@
this.renderFields();
if (this.showFullProfile() && (this.options.accountSettingsModel.get('accomplishments_shared'))) {
tabs.push({
view: this.options.badgeListContainer,
title: gettext('Accomplishments'),
url: 'accomplishments'
});
tabs = [
{view: this.sectionTwoView, title: gettext('About Me'), url: 'about_me'},
{
view: this.options.badgeListContainer,
title: gettext('Accomplishments'),
url: 'accomplishments'
}
];
// Build the accomplishments Tab and fill with data
this.options.badgeListContainer.collection.fetch().done(function() {
self.options.badgeListContainer.render();
}).error(function() {
self.options.badgeListContainer.renderError();
});
}
this.tabbedView = new TabbedView({
tabs: tabs,
router: this.router,
viewLabel: gettext('Profile')
});
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.tabbedView = new TabbedView({
tabs: tabs,
router: this.router,
viewLabel: gettext('Profile')
});
if (this.firstRender) {
this.router.on('route:loadTab', _.bind(this.setActiveTab, this));
Backbone.history.start();
this.firstRender = false;
// Load from history.
this.router.navigate((Backbone.history.getFragment() || 'about_me'), {trigger: true});
this.tabbedView.render();
this.$el.find('.account-settings-container').append(this.tabbedView.el);
if (this.firstRender) {
this.router.on('route:loadTab', _.bind(this.setActiveTab, this));
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 {
// Restart the router so the tab will be brought up anew.
Backbone.history.stop();
Backbone.history.start();
this.$el.find('.account-settings-container').append(this.sectionTwoView.render().el);
}
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