Skip to content
Snippets Groups Projects
Commit fad4b277 authored by Karl Prieb's avatar Karl Prieb
Browse files

create roomlist

parent 57b54ea2
No related branches found
No related tags found
No related merge requests found
...@@ -10,11 +10,12 @@ this.roomTypesCommon = class { ...@@ -10,11 +10,12 @@ this.roomTypesCommon = class {
@param identifier An identifier to the room type. If a real room, MUST BE the same of `db.rocketchat_room.t` field, if not, can be null @param identifier An identifier to the room type. If a real room, MUST BE the same of `db.rocketchat_room.t` field, if not, can be null
@param order Order number of the type @param order Order number of the type
@param config @param config
template: template name to render on sideNav
icon: icon class icon: icon class
label: i18n label
route: route:
name: route name name: route name
action: route action function action: route action function
identifier: room type identifier
*/ */
add(identifier = Random.id(), order, config) { add(identifier = Random.id(), order, config) {
...@@ -29,7 +30,7 @@ this.roomTypesCommon = class { ...@@ -29,7 +30,7 @@ this.roomTypesCommon = class {
identifier, identifier,
order order
}); });
this.roomTypes[identifier] = config; this.roomTypes[identifier] = {...config, identifier};
if (config.route && config.route.path && config.route.name && config.route.action) { if (config.route && config.route.path && config.route.name && config.route.action) {
const routeConfig = { const routeConfig = {
name: config.route.name, name: config.route.name,
......
/* globals openRoom */ /* globals openRoom */
RocketChat.roomTypes.add(null, 0, { RocketChat.roomTypes.add(null, 0, {
template: 'starredRooms', icon: 'icon-star',
icon: 'icon-star' label: 'Favorites'
}); });
RocketChat.roomTypes.add('c', 10, { RocketChat.roomTypes.add('c', 10, {
template: 'channels',
icon: 'icon-hash', icon: 'icon-hash',
label: 'Channels',
route: { route: {
name: 'channel', name: 'channel',
path: '/channel/:name', path: '/channel/:name',
...@@ -37,8 +37,8 @@ RocketChat.roomTypes.add('c', 10, { ...@@ -37,8 +37,8 @@ RocketChat.roomTypes.add('c', 10, {
}); });
RocketChat.roomTypes.add('d', 20, { RocketChat.roomTypes.add('d', 20, {
template: 'directMessages',
icon: 'icon-at', icon: 'icon-at',
label: 'Direct_Messages',
route: { route: {
name: 'direct', name: 'direct',
path: '/direct/:username', path: '/direct/:username',
...@@ -94,8 +94,8 @@ RocketChat.roomTypes.add('d', 20, { ...@@ -94,8 +94,8 @@ RocketChat.roomTypes.add('d', 20, {
}); });
RocketChat.roomTypes.add('p', 30, { RocketChat.roomTypes.add('p', 30, {
template: 'privateGroups',
icon: 'icon-lock', icon: 'icon-lock',
label: 'Private_Groups',
route: { route: {
name: 'group', name: 'group',
path: '/group/:name', path: '/group/:name',
......
/* globals openRoom, LivechatInquiry */ /* globals openRoom, LivechatInquiry */
RocketChat.roomTypes.add('l', 5, { RocketChat.roomTypes.add('l', 5, {
template: 'livechat',
icon: 'icon-chat-empty', icon: 'icon-chat-empty',
label: 'Livechat',
route: { route: {
name: 'live', name: 'live',
path: '/live/:code(\\d+)', path: '/live/:code(\\d+)',
......
<template name="roomList">
{{#with rooms}}
<h3 class="add-room background-transparent-darker-hover">
{{_ ../label}} <span class="room-count-small">({{count}})</span>
</h3>
<ul>
{{#each room in this}}
{{> chatRoomItem room }}
{{else}}
<p class="empty">{{_ "No_channels_yet" }}</p>
{{/each}}
</ul>
<button class="more more-channels background-transparent-darker-hover">{{_ "More_channels"}}...</button>
{{/with}}
</template>
Template.roomList.helpers({
rooms() {
const query = {
t: { $in: [this.identifier]},
open: true
};
if (RocketChat.settings.get('Favorite_Rooms')) {
query.f = { $ne: true };
}
if (Meteor.user() && Meteor.user().settings && Meteor.user().settings.preferences && Meteor.user().settings.preferences.unreadRoomsMode) {
query.$or = [
{ alert: { $ne: true } },
{ hideUnreadStatus: true }
];
}
return ChatSubscription.find(query, { sort: { 't': 1, 'name': 1 }});
},
favoritesCount() {
return ChatSubscription.find({ f: true }).count();
}
});
Template.roomList.events({
'click .more-channels'() {
SideNav.setFlex('listChannelsFlex');
return SideNav.openFlex();
}
});
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
<div class="wrapper"> <div class="wrapper">
{{> unreadRooms }} {{> unreadRooms }}
{{#each roomType}} {{#each room in roomType}}
{{#if canShowRoomType}} {{#if canShowRoomType}}
{{> Template.dynamic template=templateName }} {{> roomList type=room.type identifier=room.identifier label=room.label }}
{{/if}} {{/if}}
{{/each}} {{/each}}
......
...@@ -36,6 +36,7 @@ Package.onUse(function(api) { ...@@ -36,6 +36,7 @@ Package.onUse(function(api) {
api.addFiles('client/toolbar.html', 'client'); api.addFiles('client/toolbar.html', 'client');
api.addFiles('client/unreadRooms.html', 'client'); api.addFiles('client/unreadRooms.html', 'client');
api.addFiles('client/userStatus.html', 'client'); api.addFiles('client/userStatus.html', 'client');
api.addFiles('client/roomList.html', 'client');
api.addFiles('client/accountBox.js', 'client'); api.addFiles('client/accountBox.js', 'client');
api.addFiles('client/combined.js', 'client'); api.addFiles('client/combined.js', 'client');
...@@ -53,4 +54,5 @@ Package.onUse(function(api) { ...@@ -53,4 +54,5 @@ Package.onUse(function(api) {
api.addFiles('client/starredRooms.js', 'client'); api.addFiles('client/starredRooms.js', 'client');
api.addFiles('client/toolbar.js', 'client'); api.addFiles('client/toolbar.js', 'client');
api.addFiles('client/unreadRooms.js', 'client'); api.addFiles('client/unreadRooms.js', 'client');
api.addFiles('client/roomList.js', 'client');
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment