mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
feat: #7501
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
"parent-category": "Parent Category",
|
"parent-category": "Parent Category",
|
||||||
"optional-parent-category": "(Optional) Parent Category",
|
"optional-parent-category": "(Optional) Parent Category",
|
||||||
"parent-category-none": "(None)",
|
"parent-category-none": "(None)",
|
||||||
|
"copy-parent": "Copy Parent",
|
||||||
"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",
|
"clone-children": "Clone Children Categories And Settings",
|
||||||
|
|||||||
@@ -4,11 +4,9 @@ define('admin/manage/category', [
|
|||||||
'uploader',
|
'uploader',
|
||||||
'iconSelect',
|
'iconSelect',
|
||||||
'admin/modules/colorpicker',
|
'admin/modules/colorpicker',
|
||||||
'autocomplete',
|
|
||||||
'translator',
|
|
||||||
'categorySelector',
|
'categorySelector',
|
||||||
'benchpress',
|
'benchpress',
|
||||||
], function (uploader, iconSelect, colorpicker, autocomplete, translator, categorySelector, Benchpress) {
|
], function (uploader, iconSelect, colorpicker, categorySelector, Benchpress) {
|
||||||
var Category = {};
|
var Category = {};
|
||||||
var modified_categories = {};
|
var modified_categories = {};
|
||||||
|
|
||||||
@@ -126,13 +124,46 @@ define('admin/manage/category', [
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('.copy-settings').on('click', function () {
|
$('.copy-settings').on('click', function () {
|
||||||
categorySelector.modal(function (cid) {
|
Benchpress.parse('admin/partials/categories/copy-settings', {
|
||||||
socket.emit('admin.categories.copySettingsFrom', { fromCid: cid, toCid: ajaxify.data.category.cid }, function (err) {
|
categories: ajaxify.data.allCategories,
|
||||||
if (err) {
|
}, function (html) {
|
||||||
return app.alertError(err.message);
|
var selectedCid;
|
||||||
|
var modal = bootbox.dialog({
|
||||||
|
title: '[[modules:composer.select_category]]',
|
||||||
|
message: html,
|
||||||
|
buttons: {
|
||||||
|
save: {
|
||||||
|
label: '[[modules:bootbox.confirm]]',
|
||||||
|
className: 'btn-primary',
|
||||||
|
callback: function () {
|
||||||
|
if (!selectedCid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.emit('admin.categories.copySettingsFrom', {
|
||||||
|
fromCid: selectedCid,
|
||||||
|
toCid: ajaxify.data.category.cid,
|
||||||
|
copyParent: modal.find('#copyParent').prop('checked'),
|
||||||
|
}, function (err) {
|
||||||
|
if (err) {
|
||||||
|
return app.alertError(err.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
modal.modal('hide');
|
||||||
|
app.alertSuccess('[[admin/manage/categories:alert.copy-success]]');
|
||||||
|
ajaxify.refresh();
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
modal.find('.modal-footer button').prop('disabled', true);
|
||||||
|
categorySelector.init(modal.find('[component="category-selector"]'), function (selectedCategory) {
|
||||||
|
selectedCid = selectedCategory && selectedCategory.cid;
|
||||||
|
if (selectedCid) {
|
||||||
|
modal.find('.modal-footer button').prop('disabled', false);
|
||||||
}
|
}
|
||||||
app.alertSuccess('[[admin/manage/categories:alert.copy-success]]');
|
|
||||||
ajaxify.refresh();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ function copyPrivilegesToChildrenRecursive(parentCid, category, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Categories.copySettingsFrom = function (socket, data, callback) {
|
Categories.copySettingsFrom = function (socket, data, callback) {
|
||||||
categories.copySettingsFrom(data.fromCid, data.toCid, true, callback);
|
categories.copySettingsFrom(data.fromCid, data.toCid, data.copyParent, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
Categories.copyPrivilegesFrom = function (socket, data, callback) {
|
Categories.copyPrivilegesFrom = function (socket, data, callback) {
|
||||||
|
|||||||
7
src/views/admin/partials/categories/copy-settings.tpl
Normal file
7
src/views/admin/partials/categories/copy-settings.tpl
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<!-- IMPORT admin/partials/categories/select-category.tpl -->
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="copyParent">
|
||||||
|
<input id="copyParent" name="copyParent" type="checkbox">
|
||||||
|
<strong>[[admin/manage/categories:copy-parent]]</strong>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
@@ -549,7 +549,7 @@ describe('Categories', function () {
|
|||||||
},
|
},
|
||||||
function (category, next) {
|
function (category, next) {
|
||||||
child1Cid = category.cid;
|
child1Cid = category.cid;
|
||||||
socketCategories.copySettingsFrom({ uid: adminUid }, { fromCid: parentCid, toCid: child1Cid }, next);
|
socketCategories.copySettingsFrom({ uid: adminUid }, { fromCid: parentCid, toCid: child1Cid, copyParent: true }, next);
|
||||||
},
|
},
|
||||||
function (destinationCategory, next) {
|
function (destinationCategory, next) {
|
||||||
Categories.getCategoryField(child1Cid, 'description', next);
|
Categories.getCategoryField(child1Cid, 'description', next);
|
||||||
|
|||||||
Reference in New Issue
Block a user