added back category creation, #2463

v1.18.x
Julian Lam 10 years ago
parent e340b9fffe
commit 202789fa8d

@ -47,23 +47,20 @@ define('admin/manage/categories', function() {
});
});
function showCreateCategoryModal() {
$('#new-category-modal').modal();
}
function createNewCategory() {
var category = {
name: $('#inputName').val(),
description: $('#inputDescription').val(),
icon: $('#new-category-modal i').attr('value'),
order: $('#active-categories').children().length + 1
};
$('button[data-action="create"]').on('click', Categories.create);
};
saveNew(category);
}
Categories.create = function() {
bootbox.prompt('Category Name', function(name) {
if (!name) {
return;
}
function saveNew(category) {
socket.emit('admin.categories.create', category, function(err, data) {
socket.emit('admin.categories.create', {
name: name,
description: '',
icon: 'fa-comments'
}, function(err, data) {
if(err) {
return app.alertError(err.message);
}
@ -76,13 +73,9 @@ define('admin/manage/categories', function() {
timeout: 2000
});
$('#new-category-modal').modal('hide');
ajaxify.refresh();
ajaxify.go('admin/manage/categories/' + data.cid);
});
}
$('#addNew').on('click', showCreateCategoryModal);
$('#create-category-btn').on('click', createNewCategory);
});
};
return Categories;

@ -1,5 +1,5 @@
<div class="row">
<div class="col-lg-12">
<div class="col-lg-9">
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-folder"></i> Categories</div>
<div class="panel-body">
@ -53,9 +53,7 @@
</table>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-folder"></i> Categories</div>
<div class="panel-body">
@ -110,6 +108,13 @@
</div>
</div>
</div>
<!-- IMPORT admin/partials/categories/new.tpl -->
<div class="col-lg-3 acp-sidebar">
<div class="panel panel-default">
<div class="panel-heading">Categories Control Panel</div>
<div class="panel-body">
<button type="button" class="btn btn-primary btn-block" data-action="create">Create New Category</button>
</div>
</div>
</div>
</div>

@ -1,41 +0,0 @@
<div id="new-category-modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="Add New Modal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>Create New Category</h3>
</div>
<div class="modal-body">
<div>
<form class='form-horizontal'>
<div class="control-group">
<label class="control-label" for="inputName">Name</label>
<div class="controls">
<input class="form-control" type="text" id="inputName" placeholder="Name" value="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputDescription">Description</label>
<div class="controls">
<input class="form-control" type="text" id="inputDescription" placeholder="Description" value="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputIcon">Icon</label>
<div class="controls">
<div class="icon">
<i data-name="icon" value="fa-pencil" class="fa fa-pencil fa-2x"></i>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="modal-footer">
<button type="button" id="create-category-btn" href="#" class="btn btn-primary btn-lg btn-block">Create</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
Loading…
Cancel
Save