Side-nav CoffeeScript to JavaScript (#6264)
* Coffeescript to javascript * fix 'cannot find property of undefined' * Update channels.js * Update combined.js * Update directMessages.js * Update privateGroups.js * Update unreadRooms.jspull/6266/head^2
parent
813d0872f5
commit
fc39e64b3d
@ -1,70 +0,0 @@ |
||||
Template.accountBox.helpers |
||||
myUserInfo: -> |
||||
visualStatus = "online" |
||||
username = Meteor.user()?.username |
||||
switch Session.get('user_' + username + '_status') |
||||
when "away" |
||||
visualStatus = t("away") |
||||
when "busy" |
||||
visualStatus = t("busy") |
||||
when "offline" |
||||
visualStatus = t("invisible") |
||||
return { |
||||
name: Session.get('user_' + username + '_name') |
||||
status: Session.get('user_' + username + '_status') |
||||
visualStatus: visualStatus |
||||
_id: Meteor.userId() |
||||
username: username |
||||
} |
||||
|
||||
showAdminOption: -> |
||||
return RocketChat.authz.hasAtLeastOnePermission( ['view-statistics', 'view-room-administration', 'view-user-administration', 'view-privileged-setting' ]) or RocketChat.AdminBox.getOptions().length > 0 |
||||
|
||||
registeredMenus: -> |
||||
return AccountBox.getItems() |
||||
|
||||
Template.accountBox.events |
||||
'click .options .status': (event) -> |
||||
event.preventDefault() |
||||
AccountBox.setStatus(event.currentTarget.dataset.status) |
||||
RocketChat.callbacks.run('userStatusManuallySet', event.currentTarget.dataset.status) |
||||
|
||||
'click .account-box': (event) -> |
||||
AccountBox.toggle() |
||||
|
||||
'click #logout': (event) -> |
||||
event.preventDefault() |
||||
user = Meteor.user() |
||||
Meteor.logout -> |
||||
RocketChat.callbacks.run 'afterLogoutCleanUp', user |
||||
Meteor.call('logoutCleanUp', user) |
||||
FlowRouter.go 'home' |
||||
|
||||
'click #avatar': (event) -> |
||||
FlowRouter.go 'changeAvatar' |
||||
|
||||
'click #account': (event) -> |
||||
SideNav.setFlex "accountFlex" |
||||
SideNav.openFlex() |
||||
FlowRouter.go 'account' |
||||
|
||||
'click #admin': -> |
||||
SideNav.setFlex "adminFlex" |
||||
SideNav.openFlex() |
||||
FlowRouter.go 'admin-info' |
||||
|
||||
'click .account-link': (event) -> |
||||
event.stopPropagation(); |
||||
event.preventDefault(); |
||||
AccountBox.openFlex() |
||||
|
||||
'click .account-box-item': -> |
||||
if @href |
||||
FlowRouter.go @href |
||||
|
||||
if @sideNav? |
||||
SideNav.setFlex @sideNav |
||||
SideNav.openFlex() |
||||
|
||||
Template.accountBox.onRendered -> |
||||
AccountBox.init() |
||||
@ -0,0 +1,89 @@ |
||||
Template.accountBox.helpers({ |
||||
myUserInfo() { |
||||
let visualStatus = 'online'; |
||||
const username = Meteor.user() && Meteor.user().username; |
||||
switch (Session.get('user_' + username + '_status')) { |
||||
case 'away': |
||||
visualStatus = t('away'); |
||||
break; |
||||
case 'busy': |
||||
visualStatus = t('busy'); |
||||
break; |
||||
case 'offline': |
||||
visualStatus = t('invisible'); |
||||
break; |
||||
} |
||||
return { |
||||
name: Session.get('user_' + username + '_name'), |
||||
status: Session.get('user_' + username + '_status'), |
||||
visualStatus: visualStatus, |
||||
_id: Meteor.userId(), |
||||
username: username |
||||
}; |
||||
}, |
||||
|
||||
showAdminOption() { |
||||
return RocketChat.authz.hasAtLeastOnePermission(['view-statistics', 'view-room-administration', 'view-user-administration', 'view-privileged-setting' ]) || (RocketChat.AdminBox.getOptions().length > 0); |
||||
}, |
||||
|
||||
registeredMenus() { |
||||
return AccountBox.getItems(); |
||||
} |
||||
}); |
||||
|
||||
Template.accountBox.events({ |
||||
'click .options .status'(event) { |
||||
event.preventDefault(); |
||||
AccountBox.setStatus(event.currentTarget.dataset.status); |
||||
return RocketChat.callbacks.run('userStatusManuallySet', event.currentTarget.dataset.status); |
||||
}, |
||||
|
||||
'click .account-box'() { |
||||
return AccountBox.toggle(); |
||||
}, |
||||
|
||||
'click #logout'(event) { |
||||
event.preventDefault(); |
||||
const user = Meteor.user(); |
||||
return Meteor.logout(function() { |
||||
RocketChat.callbacks.run('afterLogoutCleanUp', user); |
||||
Meteor.call('logoutCleanUp', user); |
||||
return FlowRouter.go('home'); |
||||
}); |
||||
}, |
||||
|
||||
'click #avatar'() { |
||||
return FlowRouter.go('changeAvatar'); |
||||
}, |
||||
|
||||
'click #account'() { |
||||
SideNav.setFlex('accountFlex'); |
||||
SideNav.openFlex(); |
||||
return FlowRouter.go('account'); |
||||
}, |
||||
|
||||
'click #admin'() { |
||||
SideNav.setFlex('adminFlex'); |
||||
SideNav.openFlex(); |
||||
return FlowRouter.go('admin-info'); |
||||
}, |
||||
|
||||
'click .account-link'(event) { |
||||
event.stopPropagation(); |
||||
event.preventDefault(); |
||||
return AccountBox.openFlex(); |
||||
}, |
||||
|
||||
'click .account-box-item'() { |
||||
if (this.href) { |
||||
FlowRouter.go(this.href); |
||||
} |
||||
|
||||
if (this.sideNav != null) { |
||||
SideNav.setFlex(this.sideNav); |
||||
return SideNav.openFlex(); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
Template.accountBox.onRendered(() => AccountBox.init()); |
||||
@ -1,22 +0,0 @@ |
||||
Template.channels.helpers |
||||
isActive: -> |
||||
return 'active' if ChatSubscription.findOne({ t: { $in: ['c']}, f: { $ne: true }, open: true, rid: Session.get('openedRoom') }, { fields: { _id: 1 } })? |
||||
|
||||
rooms: -> |
||||
query = |
||||
t: { $in: ['c']}, |
||||
open: true |
||||
|
||||
if RocketChat.settings.get 'Favorite_Rooms' |
||||
query.f = { $ne: true } |
||||
|
||||
if Meteor.user()?.settings?.preferences?.unreadRoomsMode |
||||
query.alert = |
||||
$ne: true |
||||
|
||||
return ChatSubscription.find query, { sort: 't': 1, 'name': 1 } |
||||
|
||||
Template.channels.events |
||||
'click .more-channels': -> |
||||
SideNav.setFlex "listChannelsFlex" |
||||
SideNav.openFlex() |
||||
@ -0,0 +1,35 @@ |
||||
|
||||
|
||||
Template.channels.helpers({ |
||||
isActive() { |
||||
if (ChatSubscription.findOne({ t: { $in: ['c']}, f: { $ne: true }, open: true, rid: Session.get('openedRoom') }, { fields: { _id: 1 } }) !== null) { |
||||
return 'active'; |
||||
} |
||||
}, |
||||
|
||||
rooms() { |
||||
const query = { |
||||
t: { $in: ['c']}, |
||||
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.alert = |
||||
{$ne: true}; |
||||
} |
||||
|
||||
return ChatSubscription.find( |
||||
query, { sort: { 't': 1, 'name': 1 }}); |
||||
} |
||||
}); |
||||
|
||||
Template.channels.events({ |
||||
'click .more-channels'() { |
||||
SideNav.setFlex('listChannelsFlex'); |
||||
return SideNav.openFlex(); |
||||
} |
||||
}); |
||||
@ -1,22 +0,0 @@ |
||||
Template.combined.helpers |
||||
isActive: -> |
||||
return 'active' if ChatSubscription.findOne({ t: { $in: ['c', 'p']}, f: { $ne: true }, open: true, rid: Session.get('openedRoom') }, { fields: { _id: 1 } })? |
||||
|
||||
rooms: -> |
||||
query = |
||||
t: { $in: ['c', 'p']}, |
||||
open: true |
||||
|
||||
if RocketChat.settings.get 'Favorite_Rooms' |
||||
query.f = { $ne: true } |
||||
|
||||
if Meteor.user()?.settings?.preferences?.unreadRoomsMode |
||||
query.alert = |
||||
$ne: true |
||||
|
||||
return ChatSubscription.find query, { sort: 'name': 1 } |
||||
|
||||
Template.combined.events |
||||
'click .more-channels': -> |
||||
SideNav.setFlex "listCombinedFlex" |
||||
SideNav.openFlex() |
||||
@ -0,0 +1,30 @@ |
||||
Template.combined.helpers({ |
||||
isActive() { |
||||
if (ChatSubscription.findOne({ t: { $in: ['c', 'p']}, f: { $ne: true }, open: true, rid: Session.get('openedRoom') }, { fields: { _id: 1 } })) { |
||||
return 'active'; |
||||
} |
||||
}, |
||||
|
||||
rooms() { |
||||
const query = { |
||||
t: { $in: ['c', 'p']}, |
||||
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.alert = {$ne: true}; |
||||
} |
||||
|
||||
return ChatSubscription.find(query, { sort: { 'name': 1 }}); |
||||
}}); |
||||
|
||||
Template.combined.events({ |
||||
'click .more-channels'() { |
||||
SideNav.setFlex('listCombinedFlex'); |
||||
return SideNav.openFlex(); |
||||
} |
||||
}); |
||||
@ -1,12 +0,0 @@ |
||||
Template.directMessages.helpers |
||||
isActive: -> |
||||
return 'active' if ChatSubscription.findOne({ t: { $in: ['d']}, f: { $ne: true }, open: true, rid: Session.get('openedRoom') }, { fields: { _id: 1 } })? |
||||
|
||||
rooms: -> |
||||
query = { t: { $in: ['d']}, f: { $ne: true }, open: true } |
||||
|
||||
if Meteor.user()?.settings?.preferences?.unreadRoomsMode |
||||
query.alert = |
||||
$ne: true |
||||
|
||||
return ChatSubscription.find query, { sort: 't': 1, 'name': 1 } |
||||
@ -0,0 +1,18 @@ |
||||
Template.directMessages.helpers({ |
||||
isActive() { |
||||
if (ChatSubscription.findOne({ t: { $in: ['d']}, f: { $ne: true }, open: true, rid: Session.get('openedRoom') }, { fields: { _id: 1 } })) { |
||||
return 'active'; |
||||
} |
||||
}, |
||||
|
||||
rooms() { |
||||
const query = { t: { $in: ['d']}, f: { $ne: true }, open: true }; |
||||
|
||||
if (Meteor.user() && Meteor.user().settings && Meteor.user().settings.preferences && Meteor.user().settings.preferences.unreadRoomsMode) { |
||||
query.alert = |
||||
{$ne: true}; |
||||
} |
||||
|
||||
return ChatSubscription.find(query, { sort: { 't': 1, 'name': 1 }}); |
||||
} |
||||
}); |
||||
@ -1,23 +0,0 @@ |
||||
Template.privateGroups.helpers |
||||
isActive: -> |
||||
return 'active' if ChatSubscription.findOne({ t: { $in: ['p']}, f: { $ne: true }, open: true, rid: Session.get('openedRoom') }, { fields: { _id: 1 } })? |
||||
|
||||
rooms: -> |
||||
query = { t: { $in: ['p']}, f: { $ne: true }, open: true } |
||||
|
||||
if Meteor.user()?.settings?.preferences?.unreadRoomsMode |
||||
query.alert = |
||||
$ne: true |
||||
|
||||
return ChatSubscription.find query, { sort: 't': 1, 'name': 1 } |
||||
|
||||
total: -> |
||||
return ChatSubscription.find({ t: { $in: ['p']}, f: { $ne: true } }).count() |
||||
|
||||
totalOpen: -> |
||||
return ChatSubscription.find({ t: { $in: ['p']}, f: { $ne: true }, open: true }).count() |
||||
|
||||
Template.privateGroups.events |
||||
'click .more-groups': -> |
||||
SideNav.setFlex "listPrivateGroupsFlex" |
||||
SideNav.openFlex() |
||||
@ -0,0 +1,33 @@ |
||||
Template.privateGroups.helpers({ |
||||
isActive() { |
||||
if (ChatSubscription.findOne({ t: { $in: ['p']}, f: { $ne: true }, open: true, rid: Session.get('openedRoom') }, { fields: { _id: 1 } })) { |
||||
return 'active'; |
||||
} |
||||
}, |
||||
|
||||
rooms() { |
||||
const query = { t: { $in: ['p']}, f: { $ne: true }, open: true }; |
||||
|
||||
if (Meteor.user() && Meteor.user().settings && Meteor.user().settings.preferences && Meteor.user().settings.preferences.unreadRoomsMode) { |
||||
query.alert = |
||||
{$ne: true}; |
||||
} |
||||
|
||||
return ChatSubscription.find(query, { sort: { 't': 1, 'name': 1 }}); |
||||
}, |
||||
|
||||
total() { |
||||
return ChatSubscription.find({ t: { $in: ['p']}, f: { $ne: true } }).count(); |
||||
}, |
||||
|
||||
totalOpen() { |
||||
return ChatSubscription.find({ t: { $in: ['p']}, f: { $ne: true }, open: true }).count(); |
||||
} |
||||
}); |
||||
|
||||
Template.privateGroups.events({ |
||||
'click .more-groups'() { |
||||
SideNav.setFlex('listPrivateGroupsFlex'); |
||||
return SideNav.openFlex(); |
||||
} |
||||
}); |
||||
@ -1,14 +0,0 @@ |
||||
Template.starredRooms.helpers |
||||
isActive: -> |
||||
return 'active' if ChatSubscription.findOne({ f: true, rid: Session.get('openedRoom') }, { fields: { _id: 1 } })? |
||||
|
||||
rooms: -> |
||||
query = { f: true, open: true } |
||||
|
||||
if Meteor.user()?.settings?.preferences?.unreadRoomsMode |
||||
query.alert = |
||||
$ne: true |
||||
|
||||
return ChatSubscription.find query, { sort: 't': 1, 'name': 1 } |
||||
total: -> |
||||
return ChatSubscription.find({ f: true }).count() |
||||
@ -0,0 +1,22 @@ |
||||
Template.starredRooms.helpers({ |
||||
isActive() { |
||||
if (ChatSubscription.findOne({ f: true, rid: Session.get('openedRoom') }, { fields: { _id: 1 } })) { |
||||
return 'active'; |
||||
} |
||||
}, |
||||
|
||||
rooms() { |
||||
const query = { f: true, open: true }; |
||||
|
||||
if (Meteor.user().settings && Meteor.user().settings.preferences && Meteor.user().settings.preferences.unreadRoomsMode) { |
||||
query.alert = |
||||
{$ne: true}; |
||||
} |
||||
|
||||
return ChatSubscription.find(query, { sort: { 't': 1, 'name': 1 } |
||||
}); |
||||
}, |
||||
total() { |
||||
return ChatSubscription.find({ f: true }).count(); |
||||
} |
||||
}); |
||||
@ -1,14 +0,0 @@ |
||||
Template.unreadRooms.helpers |
||||
hasUnread: -> |
||||
return 'has-unread' if Meteor.user()?.settings?.preferences?.unreadRoomsMode and Template.instance().unreadRooms.count() > 0 |
||||
|
||||
rooms: -> |
||||
return Template.instance().unreadRooms |
||||
|
||||
Template.unreadRooms.onCreated -> |
||||
@autorun => |
||||
query = |
||||
alert: true |
||||
open: true |
||||
|
||||
@unreadRooms = ChatSubscription.find query, { sort: 't': 1, 'name': 1 } |
||||
@ -0,0 +1,22 @@ |
||||
Template.unreadRooms.helpers({ |
||||
hasUnread() { |
||||
if ((Meteor.user() && Meteor.user().settings && Meteor.user().settings.preferences && Meteor.user().settings.preferences.unreadRoomsMode) && (Template.instance().unreadRooms.count() > 0)) { |
||||
return 'has-unread'; |
||||
} |
||||
}, |
||||
|
||||
rooms() { |
||||
return Template.instance().unreadRooms; |
||||
} |
||||
}); |
||||
|
||||
Template.unreadRooms.onCreated(function() { |
||||
return this.autorun(() => { |
||||
const query = { |
||||
alert: true, |
||||
open: true |
||||
}; |
||||
|
||||
return this.unreadRooms = ChatSubscription.find(query, { sort: { 't': 1, 'name': 1 }}); |
||||
}); |
||||
}); |
||||
Loading…
Reference in new issue