Skip to content

Commit

Permalink
Keep sidenav for admin pages in embedded layout
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Apr 27, 2019
1 parent 48cf697 commit 21c2b32
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 29 deletions.
8 changes: 3 additions & 5 deletions app/ui-admin/client/adminFlex.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
<aside class="sidebar-light sidebar--medium" role="navigation">
<header class="sidebar-flex__header">
<h1 class="sidebar-flex__title">{{_ "Administration"}}</h1>
{{#unless embeddedVersion}}
<button class="sidebar-flex__close-button" data-action="close">
{{> icon block="sidebar-flex__close-icon" icon="cross"}}
</button>
{{/unless}}
<button class="sidebar-flex__close-button" data-action="close">
{{> icon block="sidebar-flex__close-icon" icon="cross"}}
</button>
</header>
<div class="rooms-list {{#if embeddedVersion}}rooms-list--embedded{{/if}}" aria-label="{{_ "Administration"}}">
<ul class="rooms-list__list">
Expand Down
19 changes: 11 additions & 8 deletions app/ui-admin/client/adminFlex.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import _ from 'underscore';
import s from 'underscore.string';
import { ReactiveVar } from 'meteor/reactive-var';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { settings } from '../../settings';
import { CachedCollection } from '../../ui-cached-collection';
import { SideNav, AdminBox, Layout } from '../../ui-utils';
import { t } from '../../utils';
import _ from 'underscore';
import s from 'underscore.string';
import { menu } from '../../ui-utils/client';

Template.adminFlex.onCreated(function() {
this.isEmbedded = Layout.isEmbedded();
this.settingsFilter = new ReactiveVar('');
if (settings.cachedCollectionPrivate == null) {
settings.cachedCollectionPrivate = new CachedCollection({
Expand All @@ -25,10 +27,6 @@ const label = function() {
return TAPi18n.__(this.i18nLabel || this._id);
};

// Template.adminFlex.onRendered(function() {
// $(this.find('.rooms-list')).perfectScrollbar();
// });

Template.adminFlex.helpers({
groups() {
const filter = Template.instance().settingsFilter.get();
Expand Down Expand Up @@ -77,12 +75,17 @@ Template.adminFlex.helpers({
};
},
embeddedVersion() {
return Layout.isEmbedded();
return this.isEmbedded;
},
});

Template.adminFlex.events({
'click [data-action="close"]'() {
'click [data-action="close"]'(e, instance) {
if (instance.isEmbedded) {
menu.close();
return;
}

SideNav.closeFlex();
},
'keyup [name=settings-search]'(e, t) {
Expand Down
4 changes: 1 addition & 3 deletions app/ui-master/client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ Template.main.onCreated(function() {

Template.main.helpers({
removeSidenav() {
const { center } = this;
const centerTemplate = (center || typeof center === 'function' ? center() : center);
return Layout.isEmbedded() && !/^admin/.test(centerTemplate);
return Layout.isEmbedded() && !/^\/admin/.test(FlowRouter.current().route.path);
},
siteName() {
return settings.get('Site_Name');
Expand Down
16 changes: 5 additions & 11 deletions app/ui-utils/client/lib/SideNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,10 @@ export const SideNav = new class {
}, 500);
}
closeFlex(callback = null) {
let subscription;
if (!roomTypes.getTypes().filter(function(i) {
return i.route;
}).map(function(i) {
return i.route.name;
}).includes(FlowRouter.current().route.name)) {
subscription = Subscriptions.findOne({
rid: Session.get('openedRoom'),
});
if (subscription != null) {
const routesNamesForRooms = roomTypes.getTypes().filter((i) => i.route).map((i) => i.route.name);
if (!routesNamesForRooms.includes(FlowRouter.current().route.name)) {
const subscription = Subscriptions.findOne({ rid: Session.get('openedRoom') });
if (subscription) {
roomTypes.openRouteLink(subscription.t, subscription, FlowRouter.current().queryParams);
} else {
FlowRouter.go('home');
Expand All @@ -59,7 +53,7 @@ export const SideNav = new class {
if (this.animating === true) {
return;
}
return this.toggleFlex(-1, callback);
this.toggleFlex(-1, callback);
}
flexStatus() {
return this.flexNav.opened;
Expand Down
3 changes: 1 addition & 2 deletions client/routes/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';
import { Session } from 'meteor/session';
import { KonchatNotification } from '../../app/ui';
import { Layout } from '../../app/ui-utils/client';

Blaze.registerHelper('pathFor', function(path, kw) {
return FlowRouter.path(path, kw.hash, Layout.isEmbedded ? { layout: 'embedded' } : {});
return FlowRouter.path(path, kw.hash);
});

BlazeLayout.setRoot('body');
Expand Down

0 comments on commit 21c2b32

Please sign in to comment.