Use `{{outlets}}` instead of `{{render}}` in the application template

This commit is contained in:
Robin Ward 2016-10-26 13:02:58 -04:00
parent 3ff563e510
commit eeee5f4c08
5 changed files with 28 additions and 20 deletions

View File

@ -6,7 +6,10 @@ export default htmlHelper((user, args) => {
if (!user) { return; }
const name = escapeExpression(user.get('name'));
const currentUser = args.hash.currentUser;
let currentUser = args.currentUser;
if (!currentUser && args.hash) {
currentUser = args.hash.currentUser;
}
if (currentUser && user.get('admin') && currentUser.get('staff')) {
return iconHTML('shield', { label: I18n.t('user.admin', { user: name }) });

View File

@ -63,7 +63,9 @@ export default {
app.register('screen-track:main', screenTrack, { instantiate: false });
inject(app, 'screenTrack', 'component', 'route');
inject(app, 'currentUser', 'component', 'route', 'controller');
if (currentUser) {
inject(app, 'currentUser', 'component', 'route', 'controller');
}
app.register('location:discourse-location', DiscourseLocation);

View File

@ -20,14 +20,7 @@ function unlessReadOnly(method, message) {
const ApplicationRoute = Discourse.Route.extend(OpenComposer, {
siteTitle: setting('title'),
_handleLogout() {
if (this.currentUser) {
this.currentUser.destroySession().then(() => logout(this.siteSettings, this.keyValueStore));
}
},
actions: {
toggleAnonymous() {
ajax("/users/toggle-anon", {method: 'POST'}).then(() => {
window.location.reload();
@ -179,6 +172,14 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, {
});
},
renderTemplate() {
this.render('application');
this.render('user-card', { into: 'application', outlet: 'user-card' });
this.render('modal', { into: 'application', outlet: 'modal' });
this.render('topic-entrance', { into: 'application', outlet: 'topic-entrance' });
this.render('composer', { into: 'application', outlet: 'composer' });
},
handleShowLogin() {
if (this.siteSettings.enable_sso) {
const returnPath = encodeURIComponent(window.location.pathname);
@ -198,7 +199,6 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, {
},
_autoLogin(modal, modalClass, notAuto) {
const methods = findAll(this.siteSettings,
this.container.lookup('capabilities:main'),
this.site.isMobileDevice);
@ -212,6 +212,11 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, {
}
},
_handleLogout() {
if (this.currentUser) {
this.currentUser.destroySession().then(() => logout(this.siteSettings, this.keyValueStore));
}
},
});
RSVP.EventTarget.mixin(ApplicationRoute);

View File

@ -15,7 +15,7 @@
{{create-topics-notice}}
</div>
{{outlet}}
{{render "user-card"}}
{{outlet "user-card"}}
</div>
{{plugin-outlet "above-footer"}}
@ -24,6 +24,6 @@
{{/if}}
{{plugin-outlet "below-footer"}}
{{render "modal"}}
{{render "topic-entrance"}}
{{render "composer"}}
{{outlet "modal"}}
{{outlet "topic-entrance"}}
{{outlet "composer"}}

View File

@ -1,8 +1,6 @@
export default Em.View.extend({
// No rendering!
render: Em.K,
_hideModal: function() {
export default Ember.View.extend({
didInsertElement() {
this._super();
$('#discourse-modal').modal('hide');
}.on('didInsertElement')
}
});