WIP add user modal

v1.18.x
Julian Lam 7 years ago
parent cd4d0049e6
commit b2b57d49bf

@ -134,5 +134,7 @@
"edited": "Edited", "edited": "Edited",
"disabled": "Disabled", "disabled": "Disabled",
"select": "Select" "select": "Select",
"user-search-prompt": "Type something here to find users..."
} }

@ -21,6 +21,8 @@
"chat.three_months": "3 Months", "chat.three_months": "3 Months",
"chat.delete_message_confirm": "Are you sure you wish to delete this message?", "chat.delete_message_confirm": "Are you sure you wish to delete this message?",
"chat.add-users-to-room": "Add users to room", "chat.add-users-to-room": "Add users to room",
"chat.retrieving-users": "Retrieving users...",
"chat.manage-room": "Manage Chat Room",
"chat.confirm-chat-with-dnd-user": "This user has set their status to DnD(Do not disturb). Do you still want to chat with them?", "chat.confirm-chat-with-dnd-user": "This user has set their status to DnD(Do not disturb). Do you still want to chat with them?",
"chat.rename-room": "Rename room", "chat.rename-room": "Rename room",
"chat.rename-placeholder": "Enter your room name here", "chat.rename-placeholder": "Enter your room name here",

@ -48,7 +48,15 @@ define('forum/chats', [
Chats.addEventListeners = function () { Chats.addEventListeners = function () {
Chats.addSendHandlers(ajaxify.data.roomId, $('.chat-input'), $('.expanded-chat button[data-action="send"]')); Chats.addSendHandlers(ajaxify.data.roomId, $('.chat-input'), $('.expanded-chat button[data-action="send"]'));
Chats.addPopoutHandler();
Chats.addActionHandlers(components.get('chat/messages'), ajaxify.data.roomId);
Chats.addMemberHandler(ajaxify.data.roomId, components.get('chat/controls').find('[data-action="members"]'));
Chats.addRenameHandler(ajaxify.data.roomId, components.get('chat/controls').find('[data-action="rename"]'));
Chats.addScrollHandler(ajaxify.data.roomId, ajaxify.data.uid, $('.chat-content'));
Chats.addCharactersLeftHandler($('[component="chat/main-wrapper"]'));
};
Chats.addPopoutHandler = function () {
$('[data-action="pop-out"]').on('click', function () { $('[data-action="pop-out"]').on('click', function () {
var text = components.get('chat/input').val(); var text = components.get('chat/input').val();
var roomId = ajaxify.data.roomId; var roomId = ajaxify.data.roomId;
@ -66,11 +74,6 @@ define('forum/chats', [
components.get('chat/input').val(text); components.get('chat/input').val(text);
}); });
}); });
Chats.addActionHandlers(components.get('chat/messages'), ajaxify.data.roomId);
Chats.addRenameHandler(ajaxify.data.roomId, components.get('expanded-chat/controls').find('[data-action="rename"]'));
Chats.addScrollHandler(ajaxify.data.roomId, ajaxify.data.uid, $('.chat-content'));
Chats.addCharactersLeftHandler($('[component="chat/main-wrapper"]'));
}; };
Chats.addScrollHandler = function (roomId, uid, el) { Chats.addScrollHandler = function (roomId, uid, el) {
@ -170,6 +173,39 @@ define('forum/chats', [
}); });
}; };
Chats.addMemberHandler = function (roomId, buttonEl) {
var modal;
buttonEl.on('click', function () {
Benchpress.parse('partials/modals/manage_room', {}, function (html) {
translator.translate(html, function (html) {
modal = bootbox.dialog({
title: '[[modules:chat.manage-room]]',
message: html,
});
modal.attr('component', 'chat/manage-modal');
socket.emit('modules.chats.getUsersInRoom', { roomId: roomId }, function (err, users) {
var listEl = modal.find('.list-group');
if (err) {
return translator.translate('[[error:invalid-data]]', function (translated) {
listEl.find('li').text(translated);
});
}
Benchpress.parse('partials/modals/manage_room_users', {
users: users,
}, function (html) {
listEl.html(html);
});
});
});
});
});
};
Chats.addRenameHandler = function (roomId, buttonEl, roomName) { Chats.addRenameHandler = function (roomId, buttonEl, roomName) {
var modal; var modal;

@ -167,6 +167,14 @@ SocketModules.chats.loadRoom = function (socket, data, callback) {
], callback); ], callback);
}; };
SocketModules.chats.getUsersInRoom = function (socket, data, callback) {
if (!data || !data.roomId) {
return callback(new Error('[[error:invalid-data]]'));
}
Messaging.getUsersInRoom(data.roomId, 0, -1, callback);
};
SocketModules.chats.addUserToRoom = function (socket, data, callback) { SocketModules.chats.addUserToRoom = function (socket, data, callback) {
if (!data || !data.roomId || !data.username) { if (!data || !data.roomId || !data.username) {
return callback(new Error('[[error:invalid-data]]')); return callback(new Error('[[error:invalid-data]]'));

Loading…
Cancel
Save