mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 07:25:46 +01:00
closes #5722
This commit is contained in:
@@ -66,8 +66,8 @@
|
||||
"nodebb-plugin-spam-be-gone": "0.5.0",
|
||||
"nodebb-rewards-essentials": "0.0.9",
|
||||
"nodebb-theme-lavender": "4.0.1",
|
||||
"nodebb-theme-persona": "5.0.4",
|
||||
"nodebb-theme-vanilla": "6.0.3",
|
||||
"nodebb-theme-persona": "5.0.5",
|
||||
"nodebb-theme-vanilla": "6.0.4",
|
||||
"nodebb-widget-essentials": "3.0.0",
|
||||
"nodemailer": "2.6.4",
|
||||
"nodemailer-sendmail-transport": "1.0.0",
|
||||
|
||||
@@ -131,5 +131,6 @@
|
||||
"cookies.accept": "Got it!",
|
||||
"cookies.learn_more": "Learn More",
|
||||
|
||||
"edited": "Edited"
|
||||
"edited": "Edited",
|
||||
"disabled": "Disabled"
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
"thread_tools.unlock": "Unlock Topic",
|
||||
"thread_tools.move": "Move Topic",
|
||||
"thread_tools.move_all": "Move All",
|
||||
"thread_tools.select_category": "Select Category",
|
||||
"thread_tools.fork": "Fork Topic",
|
||||
"thread_tools.delete": "Delete Topic",
|
||||
"thread_tools.delete-posts": "Delete Posts",
|
||||
@@ -86,7 +87,6 @@
|
||||
"post_purge_confirm": "Are you sure you want to purge this post?",
|
||||
|
||||
"load_categories": "Loading Categories",
|
||||
"disabled_categories_note": "Disabled Categories are greyed out",
|
||||
"confirm_move": "Move",
|
||||
"confirm_fork": "Fork",
|
||||
|
||||
|
||||
@@ -297,25 +297,11 @@ define('admin/manage/category', [
|
||||
};
|
||||
|
||||
Category.launchParentSelector = function () {
|
||||
socket.emit('categories.get', function (err, categories) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
categories = categories.filter(function (category) {
|
||||
var categories = ajaxify.data.allCategories.filter(function (category) {
|
||||
return category && !category.disabled && parseInt(category.cid, 10) !== parseInt(ajaxify.data.category.cid, 10);
|
||||
});
|
||||
|
||||
templates.parse('partials/category_list', {
|
||||
categories: categories,
|
||||
}, function (html) {
|
||||
var modal = bootbox.dialog({
|
||||
message: html,
|
||||
title: '[[admin/manage/categories:alert.set-parent-category]]',
|
||||
});
|
||||
|
||||
modal.find('li[data-cid]').on('click', function () {
|
||||
var parentCid = $(this).attr('data-cid');
|
||||
selectCategoryModal(categories, function (parentCid) {
|
||||
var payload = {};
|
||||
|
||||
payload[ajaxify.data.category.cid] = {
|
||||
@@ -326,20 +312,17 @@ define('admin/manage/category', [
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
var parent = categories.filter(function (category) {
|
||||
var parent = ajaxify.data.allCategories.filter(function (category) {
|
||||
return category && parseInt(category.cid, 10) === parseInt(parentCid, 10);
|
||||
});
|
||||
parent = parent[0];
|
||||
|
||||
modal.modal('hide');
|
||||
$('button[data-action="removeParent"]').parent().removeClass('hide');
|
||||
$('button[data-action="setParent"]').addClass('hide');
|
||||
var buttonHtml = '<i class="fa ' + parent.icon + '"></i> ' + parent.name;
|
||||
$('button[data-action="changeParent"]').html(buttonHtml).parent().removeClass('hide');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Category.addUserToPrivilegeTable = function () {
|
||||
@@ -418,12 +401,11 @@ define('admin/manage/category', [
|
||||
});
|
||||
};
|
||||
|
||||
function selectCategoryModal(callback) {
|
||||
socket.emit('admin.categories.getNames', function (err, categories) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
function selectCategoryModal(categories, callback) {
|
||||
if (typeof categories === 'function') {
|
||||
callback = categories;
|
||||
categories = ajaxify.data.allCategories;
|
||||
}
|
||||
|
||||
templates.parse('admin/partials/categories/select-category', {
|
||||
categories: categories,
|
||||
}, function (html) {
|
||||
@@ -450,7 +432,6 @@ define('admin/manage/category', [
|
||||
modal.find('form').on('submit', submit);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return Category;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
define('forum/topic/move', function () {
|
||||
var Move = {};
|
||||
var modal;
|
||||
var selectedEl;
|
||||
var selectedCategory;
|
||||
|
||||
Move.init = function (tids, currentCid, onComplete) {
|
||||
Move.tids = tids;
|
||||
@@ -31,8 +31,17 @@ define('forum/topic/move', function () {
|
||||
modal.find('.modal-header h3').translateText('[[topic:move_topics]]');
|
||||
}
|
||||
|
||||
modal.on('click', '.category-list li[data-cid]', function () {
|
||||
selectCategory($(this));
|
||||
modal.find('#select-cid').on('change', function () {
|
||||
var cid = $(this).val();
|
||||
var optionEl = $(this).find('option[value="' + cid + '"]');
|
||||
|
||||
var selectedCategory = {
|
||||
cid: cid,
|
||||
name: optionEl.attr('data-name'),
|
||||
text: optionEl.text(),
|
||||
icon: optionEl.attr('data-icon'),
|
||||
};
|
||||
selectCategory(selectedCategory);
|
||||
});
|
||||
|
||||
modal.find('#move_thread_commit').on('click', onCommitClicked);
|
||||
@@ -42,60 +51,25 @@ define('forum/topic/move', function () {
|
||||
}
|
||||
|
||||
function parseModal(categories, callback) {
|
||||
templates.parse('partials/move_thread_modal', { categories: [] }, function (html) {
|
||||
require(['translator'], function (translator) {
|
||||
translator.translate(html, function (html) {
|
||||
app.parseAndTranslate('partials/move_thread_modal', { categories: categories }, function (html) {
|
||||
modal = $(html);
|
||||
categories.forEach(function (category) {
|
||||
if (!category.link) {
|
||||
buildRecursive(modal.find('.category-list'), category, '');
|
||||
}
|
||||
});
|
||||
|
||||
callback();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function buildRecursive(parentEl, category, level) {
|
||||
var categoryEl = $('<li/>');
|
||||
|
||||
if (category.bgColor) {
|
||||
categoryEl.css('background-color', category.bgColor);
|
||||
}
|
||||
if (category.color) {
|
||||
categoryEl.css('color', category.color);
|
||||
}
|
||||
categoryEl.toggleClass('disabled', !!category.disabled);
|
||||
categoryEl.attr('data-cid', category.cid);
|
||||
categoryEl.attr('data-icon', category.icon);
|
||||
categoryEl.attr('data-name', category.name);
|
||||
categoryEl.html('<i class="fa fa-fw ' + category.icon + '"></i> ' + category.name);
|
||||
|
||||
parentEl.append(level);
|
||||
parentEl.append(categoryEl);
|
||||
parentEl.append('<br/>');
|
||||
|
||||
var indent = ' ';
|
||||
category.children.forEach(function (childCategory) {
|
||||
if (!childCategory.link) {
|
||||
buildRecursive(parentEl, childCategory, indent + level);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function selectCategory(category) {
|
||||
modal.find('#confirm-category-name').html(category.html());
|
||||
modal.find('#confirm-category-name').text(category.name);
|
||||
modal.find('#move-confirm').removeClass('hide');
|
||||
|
||||
selectedEl = category;
|
||||
selectedCategory = category;
|
||||
modal.find('#move_thread_commit').prop('disabled', false);
|
||||
}
|
||||
|
||||
function onCommitClicked() {
|
||||
var commitEl = modal.find('#move_thread_commit');
|
||||
|
||||
if (!commitEl.prop('disabled') && selectedEl.attr('data-cid')) {
|
||||
if (!commitEl.prop('disabled') && selectedCategory && selectedCategory.cid) {
|
||||
commitEl.prop('disabled', true);
|
||||
|
||||
moveTopics();
|
||||
@@ -105,7 +79,7 @@ define('forum/topic/move', function () {
|
||||
function moveTopics() {
|
||||
socket.emit(Move.moveAll ? 'topics.moveAll' : 'topics.move', {
|
||||
tids: Move.tids,
|
||||
cid: selectedEl.attr('data-cid'),
|
||||
cid: selectedCategory.cid,
|
||||
currentCid: Move.currentCid,
|
||||
}, function (err) {
|
||||
modal.modal('hide');
|
||||
@@ -114,7 +88,7 @@ define('forum/topic/move', function () {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
app.alertSuccess('[[topic:topic_move_success, ' + selectedEl.attr('data-name') + ']] <i class="fa fa-fw ' + selectedEl.attr('data-icon') + '"></i>');
|
||||
app.alertSuccess('[[topic:topic_move_success, ' + selectedCategory.name + ']] <i class="fa fa-fw ' + selectedCategory.icon + '"></i>');
|
||||
if (typeof Move.onComplete === 'function') {
|
||||
Move.onComplete();
|
||||
}
|
||||
|
||||
@@ -315,6 +315,17 @@ Categories.getTree = function (categories, parentCid) {
|
||||
};
|
||||
|
||||
Categories.buildForSelect = function (uid, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
Categories.getCategoriesByPrivilege('cid:0:children', uid, 'read', next);
|
||||
},
|
||||
function (categories, next) {
|
||||
Categories.buildForSelectCategories(categories, next);
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
Categories.buildForSelectCategories = function (categories, callback) {
|
||||
function recursive(category, categoriesData, level) {
|
||||
if (category.link) {
|
||||
return;
|
||||
@@ -329,11 +340,7 @@ Categories.buildForSelect = function (uid, callback) {
|
||||
recursive(child, categoriesData, ' ' + level);
|
||||
});
|
||||
}
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
Categories.getCategoriesByPrivilege('cid:0:children', uid, 'read', next);
|
||||
},
|
||||
function (categories, next) {
|
||||
|
||||
var categoriesData = [];
|
||||
|
||||
categories = categories.filter(function (category) {
|
||||
@@ -343,9 +350,7 @@ Categories.buildForSelect = function (uid, callback) {
|
||||
categories.forEach(function (category) {
|
||||
recursive(category, categoriesData, '');
|
||||
});
|
||||
next(null, categoriesData);
|
||||
},
|
||||
], callback);
|
||||
callback(null, categoriesData);
|
||||
};
|
||||
|
||||
Categories.getIgnorers = function (cid, start, stop, callback) {
|
||||
|
||||
@@ -160,12 +160,12 @@ SocketCategories.getMoveCategories = function (socket, data, callback) {
|
||||
function (next) {
|
||||
db.getSortedSetRange('cid:0:children', 0, -1, next);
|
||||
},
|
||||
function (cids, next) {
|
||||
privileges.categories.filterCids('read', cids, socket.uid, next);
|
||||
},
|
||||
function (cids, next) {
|
||||
categories.getCategories(cids, socket.uid, next);
|
||||
},
|
||||
function (categoriesData, next) {
|
||||
categories.buildForSelectCategories(categoriesData, next);
|
||||
},
|
||||
], next);
|
||||
},
|
||||
}, next);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<label for="select-cid">[[admin/manage/categories:select-category]]</label>
|
||||
<select class="form-control" name="select-cid" id="select-cid">
|
||||
<!-- BEGIN categories -->
|
||||
<option value="{categories.cid}">{categories.name}</option>
|
||||
<option value="{categories.cid}">{categories.text}</option>
|
||||
<!-- END categories -->
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
<div class="modal fade" id="setParent" tabindex="-1" role="dialog" aria-labelledby="setParentLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span>
|
||||
<span class="sr-only">[[global:buttons.close]]</span>
|
||||
</button>
|
||||
<h4 class="modal-title" id="setParentLabel">
|
||||
[[admin/manage/categories:set-parent-category]]
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- IMPORT partials/category_list.tpl -->
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">
|
||||
[[global:buttons.close]]
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user