Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Side-nav CoffeeScript to JavaScript II #6266

Merged
merged 3 commits into from
Mar 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 0 additions & 122 deletions packages/rocketchat-ui-sidenav/client/chatRoomItem.coffee

This file was deleted.

158 changes: 158 additions & 0 deletions packages/rocketchat-ui-sidenav/client/chatRoomItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/* globals KonchatNotification, menu */

Template.chatRoomItem.helpers({

alert() {
if ((FlowRouter.getParam('_id') !== this.rid) || !document.hasFocus()) {
return this.alert;
}
},

unread() {
if (((FlowRouter.getParam('_id') !== this.rid) || !document.hasFocus()) && (this.unread > 0)) {
return this.unread;
}
},

userStatus() {
const userStatus = RocketChat.roomTypes.getUserStatus(this.t, this.rid);
return `status-${userStatus || 'offline'}`;
},

name() {
return this.name;
},

roomIcon() {
return RocketChat.roomTypes.getIcon(this.t);
},

active() {
if (Session.get('openedRoom') === this.rid) {
return 'active';
}
},

canLeave() {
const roomData = Session.get('roomData' + this.rid);

if (!roomData) { return false; }

if (((roomData.cl != null) && !roomData.cl) || (roomData.t === 'd')) {
return false;
} else {
return true;
}
},

route() {
return RocketChat.roomTypes.getRouteLink(this.t, this);
},

archived() {
return this.archived ? 'archived' : undefined;
}
});

Template.chatRoomItem.rendered = function() {
if (!(FlowRouter.getParam('_id') && (FlowRouter.getParam('_id') === this.data.rid)) && !this.data.ls && (this.data.alert === true)) {
return KonchatNotification.newRoom(this.data.rid);
}
};

Template.chatRoomItem.events({

'click .open-room'() {
return menu.close();
},

'click .hide-room'(e) {
e.stopPropagation();
e.preventDefault();

const { rid } = this;
const { name } = this;

const warnText = (() => {
switch (this.t) {
case 'c': return 'Hide_Room_Warning';
case 'p': return 'Hide_Group_Warning';
case 'd': return 'Hide_Private_Warning';
}
})();

return swal({
title: t('Are_you_sure'),
text: warnText ? t(warnText, name) : '',
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#DD6B55',
confirmButtonText: t('Yes_hide_it'),
cancelButtonText: t('Cancel'),
closeOnConfirm: true,
html: false
}, function() {
if (['channel', 'group', 'direct'].includes(FlowRouter.getRouteName()) && (Session.get('openedRoom') === rid)) {
FlowRouter.go('home');
}

return Meteor.call('hideRoom', rid, function(err) {
if (err) {
return handleError(err);
} else if (rid === Session.get('openedRoom')) {
return Session.delete('openedRoom');
}
});
});
},

'click .leave-room'(e) {
e.stopPropagation();
e.preventDefault();

const { rid } = this;
const { name } = this;

const warnText = (() => {
switch (false) {
case this.t !== 'c': return 'Leave_Room_Warning';
case this.t !== 'p': return 'Leave_Group_Warning';
case this.t !== 'd': return 'Leave_Private_Warning';
}
})();
return swal({
title: t('Are_you_sure'),
text: t(warnText, name),
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#DD6B55',
confirmButtonText: t('Yes_leave_it'),
cancelButtonText: t('Cancel'),
closeOnConfirm: false,
html: false
}, function(isConfirm) {
if (isConfirm) {
return Meteor.call('leaveRoom', rid, function(err) {
if (err) {
return swal({
title: t('Warning'),
text: handleError(err, false),
type: 'warning',
html: false
});

} else {
swal.close();
if (['channel', 'group', 'direct'].includes(FlowRouter.getRouteName()) && (Session.get('openedRoom') === rid)) {
FlowRouter.go('home');
}

return RoomManager.close(rid);
}
});
} else {
return swal.close();
}
});
}
});
95 changes: 0 additions & 95 deletions packages/rocketchat-ui-sidenav/client/listChannelsFlex.coffee

This file was deleted.

Loading