mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
This commit is contained in:
@@ -132,5 +132,6 @@
|
|||||||
"cookies.learn_more": "Learn More",
|
"cookies.learn_more": "Learn More",
|
||||||
|
|
||||||
"edited": "Edited",
|
"edited": "Edited",
|
||||||
"disabled": "Disabled"
|
"disabled": "Disabled",
|
||||||
|
"select": "Select"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,6 @@
|
|||||||
"move_post": "Move Post",
|
"move_post": "Move Post",
|
||||||
"post_moved": "Post moved!",
|
"post_moved": "Post moved!",
|
||||||
"fork_topic": "Fork Topic",
|
"fork_topic": "Fork Topic",
|
||||||
"topic_will_be_moved_to": "This topic will be moved to the category",
|
|
||||||
"fork_topic_instruction": "Click the posts you want to fork",
|
"fork_topic_instruction": "Click the posts you want to fork",
|
||||||
"fork_no_pids": "No posts selected!",
|
"fork_no_pids": "No posts selected!",
|
||||||
"fork_pid_count": "%1 post(s) selected",
|
"fork_pid_count": "%1 post(s) selected",
|
||||||
|
|||||||
@@ -232,6 +232,11 @@ body {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.category-dropdown-menu {
|
||||||
|
max-height: 600px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.table-reordering {
|
.table-reordering {
|
||||||
tr:hover {
|
tr:hover {
|
||||||
cursor: move;
|
cursor: move;
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ define('admin/manage/category', [
|
|||||||
'admin/modules/colorpicker',
|
'admin/modules/colorpicker',
|
||||||
'autocomplete',
|
'autocomplete',
|
||||||
'translator',
|
'translator',
|
||||||
], function (uploader, iconSelect, colorpicker, autocomplete, translator) {
|
'categorySelector',
|
||||||
|
], function (uploader, iconSelect, colorpicker, autocomplete, translator, categorySelector) {
|
||||||
var Category = {};
|
var Category = {};
|
||||||
var modified_categories = {};
|
var modified_categories = {};
|
||||||
|
|
||||||
@@ -411,21 +412,24 @@ define('admin/manage/category', [
|
|||||||
}, function (html) {
|
}, function (html) {
|
||||||
translator.translate(html, function (html) {
|
translator.translate(html, function (html) {
|
||||||
var modal = bootbox.dialog({
|
var modal = bootbox.dialog({
|
||||||
title: 'Select a Category',
|
title: '[[modules:composer.select_category]]',
|
||||||
message: html,
|
message: html,
|
||||||
buttons: {
|
buttons: {
|
||||||
save: {
|
save: {
|
||||||
label: 'Copy',
|
label: '[[global:select]]',
|
||||||
className: 'btn-primary',
|
className: 'btn-primary',
|
||||||
callback: submit,
|
callback: submit,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
categorySelector.init(modal.find('[component="category-selector"]'));
|
||||||
function submit() {
|
function submit(ev) {
|
||||||
var formData = modal.find('form').serializeObject();
|
ev.preventDefault();
|
||||||
callback(formData['select-cid']);
|
var selectedCategory = categorySelector.getSelectedCategory();
|
||||||
modal.modal('hide');
|
if (selectedCategory) {
|
||||||
|
callback(selectedCategory.cid);
|
||||||
|
modal.modal('hide');
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/topic/move', function () {
|
define('forum/topic/move', ['categorySelector'], function (categorySelector) {
|
||||||
var Move = {};
|
var Move = {};
|
||||||
var modal;
|
var modal;
|
||||||
var selectedCategory;
|
var selectedCategory;
|
||||||
@@ -31,18 +31,7 @@ define('forum/topic/move', function () {
|
|||||||
modal.find('.modal-header h3').translateText('[[topic:move_topics]]');
|
modal.find('.modal-header h3').translateText('[[topic:move_topics]]');
|
||||||
}
|
}
|
||||||
|
|
||||||
modal.find('#select-cid').on('change', function () {
|
categorySelector.init(modal.find('[component="category-selector"]'), onCategorySelected);
|
||||||
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);
|
modal.find('#move_thread_commit').on('click', onCommitClicked);
|
||||||
|
|
||||||
@@ -58,10 +47,7 @@ define('forum/topic/move', function () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectCategory(category) {
|
function onCategorySelected(category) {
|
||||||
modal.find('#confirm-category-name').text(category.name);
|
|
||||||
modal.find('#move-confirm').removeClass('hide');
|
|
||||||
|
|
||||||
selectedCategory = category;
|
selectedCategory = category;
|
||||||
modal.find('#move_thread_commit').prop('disabled', false);
|
modal.find('#move_thread_commit').prop('disabled', false);
|
||||||
}
|
}
|
||||||
@@ -88,7 +74,7 @@ define('forum/topic/move', function () {
|
|||||||
return app.alertError(err.message);
|
return app.alertError(err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.alertSuccess('[[topic:topic_move_success, ' + selectedCategory.name + ']] <i class="fa fa-fw ' + selectedCategory.icon + '"></i>');
|
app.alertSuccess('[[topic:topic_move_success, ' + selectedCategory.name + ']]');
|
||||||
if (typeof Move.onComplete === 'function') {
|
if (typeof Move.onComplete === 'function') {
|
||||||
Move.onComplete();
|
Move.onComplete();
|
||||||
}
|
}
|
||||||
|
|||||||
33
public/src/modules/categorySelector.js
Normal file
33
public/src/modules/categorySelector.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
define('categorySelector', function () {
|
||||||
|
var categorySelector = {};
|
||||||
|
var selectedCategory;
|
||||||
|
var el;
|
||||||
|
categorySelector.init = function (_el, callback) {
|
||||||
|
callback = callback || function () {};
|
||||||
|
el = _el;
|
||||||
|
el.on('click', '[data-cid]', function () {
|
||||||
|
var categoryEl = $(this);
|
||||||
|
categorySelector.selectCategory(categoryEl.attr('data-cid'));
|
||||||
|
callback(selectedCategory);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
categorySelector.getSelectedCategory = function () {
|
||||||
|
return selectedCategory;
|
||||||
|
};
|
||||||
|
|
||||||
|
categorySelector.selectCategory = function (cid) {
|
||||||
|
var categoryEl = el.find('[data-cid="' + cid + '"]');
|
||||||
|
selectedCategory = {
|
||||||
|
cid: cid,
|
||||||
|
name: categoryEl.attr('data-name'),
|
||||||
|
};
|
||||||
|
el.find('[component="category-selector-selected"]').html(categoryEl.find('[component="category-markup"]').html());
|
||||||
|
};
|
||||||
|
|
||||||
|
return categorySelector;
|
||||||
|
});
|
||||||
|
|
||||||
@@ -314,10 +314,10 @@ Categories.getTree = function (categories, parentCid) {
|
|||||||
return tree;
|
return tree;
|
||||||
};
|
};
|
||||||
|
|
||||||
Categories.buildForSelect = function (uid, callback) {
|
Categories.buildForSelect = function (uid, privilege, callback) {
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
Categories.getCategoriesByPrivilege('cid:0:children', uid, 'read', next);
|
Categories.getCategoriesByPrivilege('cid:0:children', uid, privilege, next);
|
||||||
},
|
},
|
||||||
function (categories, next) {
|
function (categories, next) {
|
||||||
Categories.buildForSelectCategories(categories, next);
|
Categories.buildForSelectCategories(categories, next);
|
||||||
@@ -333,6 +333,7 @@ Categories.buildForSelectCategories = function (categories, callback) {
|
|||||||
|
|
||||||
var bullet = level ? '• ' : '';
|
var bullet = level ? '• ' : '';
|
||||||
category.value = category.cid;
|
category.value = category.cid;
|
||||||
|
category.level = level;
|
||||||
category.text = level + bullet + category.name;
|
category.text = level + bullet + category.name;
|
||||||
categoriesData.push(category);
|
categoriesData.push(category);
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ categoriesController.get = function (req, res, callback) {
|
|||||||
async.parallel({
|
async.parallel({
|
||||||
category: async.apply(categories.getCategories, [req.params.category_id], req.user.uid),
|
category: async.apply(categories.getCategories, [req.params.category_id], req.user.uid),
|
||||||
privileges: async.apply(privileges.categories.list, req.params.category_id),
|
privileges: async.apply(privileges.categories.list, req.params.category_id),
|
||||||
allCategories: async.apply(categories.buildForSelect, req.uid),
|
allCategories: async.apply(categories.buildForSelect, req.uid, 'read'),
|
||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
function (data, next) {
|
function (data, next) {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ modsController.flags.list = function (req, res, next) {
|
|||||||
async.parallel({
|
async.parallel({
|
||||||
flags: async.apply(flags.list, filters, req.uid),
|
flags: async.apply(flags.list, filters, req.uid),
|
||||||
analytics: async.apply(analytics.getDailyStatsForSet, 'analytics:flags', Date.now(), 30),
|
analytics: async.apply(analytics.getDailyStatsForSet, 'analytics:flags', Date.now(), 30),
|
||||||
categories: async.apply(categories.buildForSelect, req.uid),
|
categories: async.apply(categories.buildForSelect, req.uid, 'read'),
|
||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
function (data) {
|
function (data) {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ searchController.search = function (req, res, next) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
categories: async.apply(categories.buildForSelect, req.uid),
|
categories: async.apply(categories.buildForSelect, req.uid, 'read'),
|
||||||
search: async.apply(search.search, data),
|
search: async.apply(search.search, data),
|
||||||
}, function (err, results) {
|
}, function (err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ module.exports = function (Meta) {
|
|||||||
'public/src/modules/sort.js',
|
'public/src/modules/sort.js',
|
||||||
'public/src/modules/navigator.js',
|
'public/src/modules/navigator.js',
|
||||||
'public/src/modules/topicSelect.js',
|
'public/src/modules/topicSelect.js',
|
||||||
|
'public/src/modules/categorySelector.js',
|
||||||
'public/src/modules/share.js',
|
'public/src/modules/share.js',
|
||||||
'public/src/modules/search.js',
|
'public/src/modules/search.js',
|
||||||
'public/src/modules/alerts.js',
|
'public/src/modules/alerts.js',
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
<form type="form">
|
<form type="form">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="select-cid">[[admin/manage/categories:select-category]]</label>
|
<div component="category-selector" class="btn-group">
|
||||||
<select class="form-control" name="select-cid" id="select-cid">
|
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
||||||
<!-- BEGIN categories -->
|
<span component="category-selector-selected">[[topic:thread_tools.select_category]]</span> <span class="caret"></span>
|
||||||
<option value="{categories.cid}">{categories.text}</option>
|
</button>
|
||||||
<!-- END categories -->
|
<ul class="dropdown-menu category-dropdown-menu" role="menu">
|
||||||
</select>
|
<!-- BEGIN categories -->
|
||||||
|
<li role="presentation" class="category" data-cid="{categories.cid}" data-name="{categories.name}">
|
||||||
|
<a role="menu-item">{categories.level}<span component="category-markup"><!-- IF categories.icon --><span class="fa-stack"><i style="color: {categories.bgColor};" class="fa fa-circle fa-stack-2x"></i><i style="color: {categories.color};" class="fa fa-stack-1x fa-fw {categories.icon}"></i></span><!-- ENDIF categories.icon --> {categories.name}</span></a>
|
||||||
|
</li>
|
||||||
|
<!-- END categories -->
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
Reference in New Issue
Block a user