mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-12 17:05:51 +01:00
closes #6449
This commit is contained in:
@@ -7,7 +7,8 @@ define('admin/manage/category', [
|
||||
'autocomplete',
|
||||
'translator',
|
||||
'categorySelector',
|
||||
], function (uploader, iconSelect, colorpicker, autocomplete, translator, categorySelector) {
|
||||
'benchpress',
|
||||
], function (uploader, iconSelect, colorpicker, autocomplete, translator, categorySelector, Benchpress) {
|
||||
var Category = {};
|
||||
var modified_categories = {};
|
||||
|
||||
@@ -80,20 +81,54 @@ define('admin/manage/category', [
|
||||
$('.purge').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
bootbox.confirm(translator.compile(
|
||||
'admin/manage/categories:alert.confirm-purge',
|
||||
$('form.category').find('input[data-name="name"]').val()
|
||||
), function (confirm) {
|
||||
if (!confirm) {
|
||||
return;
|
||||
Benchpress.parse('admin/partials/categories/purge', {
|
||||
name: ajaxify.data.category.name,
|
||||
topic_count: ajaxify.data.category.topic_count,
|
||||
}, function (html) {
|
||||
var modal = bootbox.dialog({
|
||||
title: '[[admin/manage/categories:purge]]',
|
||||
message: html,
|
||||
size: 'large',
|
||||
buttons: {
|
||||
save: {
|
||||
label: '[[modules:bootbox.confirm]]',
|
||||
className: 'btn-primary',
|
||||
callback: function () {
|
||||
modal.find('.modal-footer button').prop('disabled', true);
|
||||
|
||||
var intervalId = setInterval(function () {
|
||||
socket.emit('categories.getTopicCount', ajaxify.data.category.cid, function (err, count) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
|
||||
var percent = 0;
|
||||
if (ajaxify.data.category.topic_count > 0) {
|
||||
percent = Math.max(0, (1 - (count / ajaxify.data.category.topic_count))) * 100;
|
||||
}
|
||||
|
||||
modal.find('.progress-bar').css({ width: percent + '%' });
|
||||
});
|
||||
}, 1000);
|
||||
|
||||
socket.emit('admin.categories.purge', ajaxify.data.category.cid, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
if (intervalId) {
|
||||
clearInterval(intervalId);
|
||||
}
|
||||
modal.modal('hide');
|
||||
app.alertSuccess('[[admin/manage/categories:alert.purge-success]]');
|
||||
ajaxify.go('admin/manage/categories');
|
||||
});
|
||||
|
||||
return false;
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
8
src/views/admin/partials/categories/purge.tpl
Normal file
8
src/views/admin/partials/categories/purge.tpl
Normal file
@@ -0,0 +1,8 @@
|
||||
<form type="form">
|
||||
[[admin/manage/categories:alert.confirm-purge, {name}]]
|
||||
<hr/>
|
||||
<div class="progress">
|
||||
<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="{topic_count}" style="width: 0%;">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
Reference in New Issue
Block a user