mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 18:56:15 +01:00
wrapping up basic blocking UCP for #6463
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
"followers": "Followers",
|
"followers": "Followers",
|
||||||
"following": "Following",
|
"following": "Following",
|
||||||
"blocks": "Blocks",
|
"blocks": "Blocks",
|
||||||
|
"block_toggle": "Toggle Block",
|
||||||
"aboutme": "About me",
|
"aboutme": "About me",
|
||||||
"signature": "Signature",
|
"signature": "Signature",
|
||||||
"birthday": "Birthday",
|
"birthday": "Birthday",
|
||||||
|
|||||||
@@ -1,12 +1,37 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('forum/account/blocks', ['forum/account/header'], function (header) {
|
define('forum/account/blocks', ['forum/account/header', 'autocomplete'], function (header, autocomplete) {
|
||||||
var Blocks = {};
|
var Blocks = {};
|
||||||
|
|
||||||
Blocks.init = function () {
|
Blocks.init = function () {
|
||||||
header.init();
|
header.init();
|
||||||
|
|
||||||
console.log('derpp');
|
autocomplete.user($('#user-search'), function (ev, ui) {
|
||||||
|
app.parseAndTranslate('account/blocks', 'edit', {
|
||||||
|
edit: [ui.item.user],
|
||||||
|
}, function (html) {
|
||||||
|
$('.block-edit').html(html);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.block-edit').on('click', '[data-action="toggle"]', function () {
|
||||||
|
var uid = parseInt(this.getAttribute('data-uid'), 10);
|
||||||
|
socket.emit('user.toggleBlock', {
|
||||||
|
uid: uid,
|
||||||
|
}, Blocks.refreshList);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Blocks.refreshList = function () {
|
||||||
|
$.get(config.relative_path + '/api/' + ajaxify.currentPage)
|
||||||
|
.done(function (payload) {
|
||||||
|
app.parseAndTranslate('account/blocks', 'users', payload, function (html) {
|
||||||
|
$('#users-container').html(html);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.fail(function () {
|
||||||
|
ajaxify.go(ajaxify.currentPage);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return Blocks;
|
return Blocks;
|
||||||
|
|||||||
@@ -200,4 +200,13 @@ module.exports = function (SocketUser) {
|
|||||||
},
|
},
|
||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SocketUser.toggleBlock = function (socket, data, callback) {
|
||||||
|
async.waterfall([
|
||||||
|
async.apply(user.blocks.is, data.uid, socket.uid),
|
||||||
|
function (is, next) {
|
||||||
|
user.blocks[is ? 'remove' : 'add'](data.uid, socket.uid, next);
|
||||||
|
},
|
||||||
|
], callback);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user