mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 22:45:46 +01:00
closes #6703
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
"parent-category-none": "(None)",
|
"parent-category-none": "(None)",
|
||||||
"copy-settings": "Copy Settings From",
|
"copy-settings": "Copy Settings From",
|
||||||
"optional-clone-settings": "(Optional) Clone Settings From Category",
|
"optional-clone-settings": "(Optional) Clone Settings From Category",
|
||||||
|
"clone-children": "Clone Children Categories And Settings",
|
||||||
"purge": "Purge Category",
|
"purge": "Purge Category",
|
||||||
|
|
||||||
"enable": "Enable",
|
"enable": "Enable",
|
||||||
|
|||||||
@@ -78,12 +78,25 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
|
|||||||
var formData = modal.find('form').serializeObject();
|
var formData = modal.find('form').serializeObject();
|
||||||
formData.description = '';
|
formData.description = '';
|
||||||
formData.icon = 'fa-comments';
|
formData.icon = 'fa-comments';
|
||||||
|
formData.uid = app.user.uid;
|
||||||
|
|
||||||
Categories.create(formData);
|
Categories.create(formData);
|
||||||
modal.modal('hide');
|
modal.modal('hide');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('#cloneChildren').on('change', function () {
|
||||||
|
var check = $(this);
|
||||||
|
var parentSelect = $('#parentCid');
|
||||||
|
|
||||||
|
if (check.prop('checked')) {
|
||||||
|
parentSelect.attr('disabled', 'disabled');
|
||||||
|
parentSelect.val('');
|
||||||
|
} else {
|
||||||
|
parentSelect.removeAttr('disabled');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
modal.find('form').on('submit', submit);
|
modal.find('form').on('submit', submit);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -84,10 +84,24 @@ module.exports = function (Categories) {
|
|||||||
], next);
|
], next);
|
||||||
},
|
},
|
||||||
function (results, next) {
|
function (results, next) {
|
||||||
if (data.cloneFromCid && parseInt(data.cloneFromCid, 10)) {
|
async.series([
|
||||||
return Categories.copySettingsFrom(data.cloneFromCid, category.cid, !data.parentCid, next);
|
function (next) {
|
||||||
}
|
if (data.cloneFromCid && parseInt(data.cloneFromCid, 10)) {
|
||||||
next(null, category);
|
return Categories.copySettingsFrom(data.cloneFromCid, category.cid, !data.parentCid, next);
|
||||||
|
}
|
||||||
|
|
||||||
|
next();
|
||||||
|
},
|
||||||
|
function (next) {
|
||||||
|
if (data.cloneChildren) {
|
||||||
|
return duplicateCategoriesChildren(category.cid, data.cloneFromCid, data.uid, next);
|
||||||
|
}
|
||||||
|
|
||||||
|
next();
|
||||||
|
},
|
||||||
|
], function (err) {
|
||||||
|
next(err, category);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
function (category, next) {
|
function (category, next) {
|
||||||
plugins.fireHook('action:category.create', { category: category });
|
plugins.fireHook('action:category.create', { category: category });
|
||||||
@@ -96,6 +110,25 @@ module.exports = function (Categories) {
|
|||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function duplicateCategoriesChildren(parentCid, cid, uid, callback) {
|
||||||
|
Categories.getChildren([cid], uid, function (err, children) {
|
||||||
|
if (err || !children.length) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
children = children[0];
|
||||||
|
|
||||||
|
children.forEach(function (child) {
|
||||||
|
child.parentCid = parentCid;
|
||||||
|
child.cloneFromCid = child.cid;
|
||||||
|
child.cloneChildren = true;
|
||||||
|
child.uid = uid;
|
||||||
|
});
|
||||||
|
|
||||||
|
async.each(children, Categories.create, callback);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Categories.assignColours = function () {
|
Categories.assignColours = function () {
|
||||||
var backgrounds = ['#AB4642', '#DC9656', '#F7CA88', '#A1B56C', '#86C1B9', '#7CAFC2', '#BA8BAF', '#A16946'];
|
var backgrounds = ['#AB4642', '#DC9656', '#F7CA88', '#A1B56C', '#86C1B9', '#7CAFC2', '#BA8BAF', '#A16946'];
|
||||||
var text = ['#fff', '#fff', '#333', '#fff', '#333', '#fff', '#fff', '#fff'];
|
var text = ['#fff', '#fff', '#333', '#fff', '#333', '#fff', '#fff', '#fff'];
|
||||||
|
|||||||
@@ -21,5 +21,10 @@
|
|||||||
<option value="{categories.cid}">{categories.name}</option>
|
<option value="{categories.cid}">{categories.name}</option>
|
||||||
<!-- END categories -->
|
<!-- END categories -->
|
||||||
</select>
|
</select>
|
||||||
|
<label>
|
||||||
|
<input id="cloneChildren" name="cloneChildren" type="checkbox">
|
||||||
|
<strong>[[admin/manage/categories:clone-children]]</strong>
|
||||||
|
</label>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
Reference in New Issue
Block a user