v1.18.x
Barış Soner Uşaklı 6 years ago
parent b52dba5c92
commit 2ee2cd528f

@ -17,6 +17,7 @@
"parent-category": "Parent Category",
"optional-parent-category": "(Optional) Parent Category",
"parent-category-none": "(None)",
"copy-parent": "Copy Parent",
"copy-settings": "Copy Settings From",
"optional-clone-settings": "(Optional) Clone Settings From Category",
"clone-children": "Clone Children Categories And Settings",

@ -4,11 +4,9 @@ define('admin/manage/category', [
'uploader',
'iconSelect',
'admin/modules/colorpicker',
'autocomplete',
'translator',
'categorySelector',
'benchpress',
], function (uploader, iconSelect, colorpicker, autocomplete, translator, categorySelector, Benchpress) {
], function (uploader, iconSelect, colorpicker, categorySelector, Benchpress) {
var Category = {};
var modified_categories = {};
@ -126,13 +124,46 @@ define('admin/manage/category', [
});
$('.copy-settings').on('click', function () {
categorySelector.modal(function (cid) {
socket.emit('admin.categories.copySettingsFrom', { fromCid: cid, toCid: ajaxify.data.category.cid }, function (err) {
if (err) {
return app.alertError(err.message);
Benchpress.parse('admin/partials/categories/copy-settings', {
categories: ajaxify.data.allCategories,
}, function (html) {
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;

@ -130,7 +130,7 @@ function copyPrivilegesToChildrenRecursive(parentCid, category, 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) {

@ -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) {
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) {
Categories.getCategoryField(child1Cid, 'description', next);

Loading…
Cancel
Save