settings acp refactor for dedicated routes

v1.18.x
psychobunny 11 years ago
parent 9b17ec9f26
commit 117b8dece4

@ -17,6 +17,8 @@ define('forum/admin/settings', ['uploader', 'sounds'], function(uploader, sounds
return; return;
} }
setupPills();
// Populate the fields on the page from the config // Populate the fields on the page from the config
var fields = $('#content [data-field]'), var fields = $('#content [data-field]'),
numFields = fields.length, numFields = fields.length,
@ -91,12 +93,6 @@ define('forum/admin/settings', ['uploader', 'sounds'], function(uploader, sounds
handleUploads(); handleUploads();
$('#settings-tab a').off('click').on('click', function (e) {
e.preventDefault();
$(this).tab('show');
return false;
});
$('button[data-action="email.test"]').off('click').on('click', function() { $('button[data-action="email.test"]').off('click').on('click', function() {
socket.emit('admin.email.test', function(err) { socket.emit('admin.email.test', function(err) {
app.alert({ app.alert({
@ -131,6 +127,14 @@ define('forum/admin/settings', ['uploader', 'sounds'], function(uploader, sounds
socket.emit('admin.config.remove', key); socket.emit('admin.config.remove', key);
}; };
function setupPills() {
$('.settings.nav-pills li').removeClass('active');
var slug = window.location.href.split('/');
slug = slug[slug.length-1];
$('.settings.nav-pills [data-pill="' + slug + '"]').addClass('active');
}
function saveField(field, callback) { function saveField(field, callback) {
field = $(field); field = $(field);
var key = field.attr('data-field'), var key = field.attr('data-field'),

@ -203,7 +203,7 @@ adminController.languages.get = function(req, res, next) {
}; };
adminController.settings.get = function(req, res, next) { adminController.settings.get = function(req, res, next) {
res.render('admin/settings', { res.render('admin/settings/' + req.params.term, {
'csrf': req.csrfToken() 'csrf': req.csrfToken()
}); });
}; };

@ -39,12 +39,14 @@ function addRoutes(router, middleware, controllers) {
//main //main
router.get('/index', controllers.admin.home); router.get('/index', controllers.admin.home);
router.get('/plugins', controllers.admin.plugins.get); router.get('/plugins', controllers.admin.plugins.get);
router.get('/settings', middleware.applyCSRF, controllers.admin.settings.get);
router.get('/themes', controllers.admin.themes.get); router.get('/themes', controllers.admin.themes.get);
router.get('/languages', controllers.admin.languages.get); router.get('/languages', controllers.admin.languages.get);
router.get('/groups', controllers.admin.groups.get); router.get('/groups', controllers.admin.groups.get);
router.get('/sounds', controllers.admin.sounds.get); router.get('/sounds', controllers.admin.sounds.get);
//settings
router.get('/settings/:term', middleware.applyCSRF, controllers.admin.settings.get);
//user //user
router.get('/users', controllers.admin.users.search); router.get('/users', controllers.admin.users.search);
router.get('/users/search', controllers.admin.users.search); router.get('/users/search', controllers.admin.users.search);

@ -60,7 +60,7 @@
<a href="{relative_path}/admin/index"><i class="fa fa-home" title="Home"></i><span class="visible-xs-inline"> Home</span></a> <a href="{relative_path}/admin/index"><i class="fa fa-home" title="Home"></i><span class="visible-xs-inline"> Home</span></a>
</li> </li>
<li> <li>
<a href="{relative_path}/admin/settings"><i class="fa fa-cogs" title="Settings"></i><span class="visible-xs-inline"> Settings</span></a> <a href="{relative_path}/admin/settings/general"><i class="fa fa-cogs" title="Settings"></i><span class="visible-xs-inline"> Settings</span></a>
</li> </li>
<li> <li>
<a href="{relative_path}/" target="_top"><i class="fa fa-book" title="Forum"></i><span class="visible-xs-inline"> Forum</span></a> <a href="{relative_path}/" target="_top"><i class="fa fa-book" title="Forum"></i><span class="visible-xs-inline"> Forum</span></a>
@ -101,7 +101,7 @@
<li><a href="{relative_path}/admin/tags"><i class="fa fa-fw fa-tags"></i> Tags</a></li> <li><a href="{relative_path}/admin/tags"><i class="fa fa-fw fa-tags"></i> Tags</a></li>
<li><a href="{relative_path}/admin/users/latest"><i class="fa fa-fw fa-user"></i> Users</a></li> <li><a href="{relative_path}/admin/users/latest"><i class="fa fa-fw fa-user"></i> Users</a></li>
<li><a href="{relative_path}/admin/groups"><i class="fa fa-fw fa-group"></i> Groups</a></li> <li><a href="{relative_path}/admin/groups"><i class="fa fa-fw fa-group"></i> Groups</a></li>
<li><a href="{relative_path}/admin/settings"><i class="fa fa-fw fa-cogs"></i> General Settings</a></li> <li><a href="{relative_path}/admin/settings/general"><i class="fa fa-fw fa-cogs"></i> Settings</a></li>
<li><a href="{relative_path}/admin/themes"><i class="fa fa-fw fa-th"></i> Themes</a></li> <li><a href="{relative_path}/admin/themes"><i class="fa fa-fw fa-th"></i> Themes</a></li>
<li><a href="{relative_path}/admin/plugins"><i class="fa fa-fw fa-code-fork"></i> Plugins</a></li> <li><a href="{relative_path}/admin/plugins"><i class="fa fa-fw fa-code-fork"></i> Plugins</a></li>
<li><a href="{relative_path}/admin/languages"><i class="fa fa-fw fa-language"></i> Languages</a></li> <li><a href="{relative_path}/admin/languages"><i class="fa fa-fw fa-language"></i> Languages</a></li>

@ -1,73 +0,0 @@
<h1><i class="fa fa-cogs"></i> Settings</h1>
<hr />
<ul id="settings-tab" class="nav nav-tabs">
<li class="active"><a href="#general" data-toggle="tab">General</a></li>
<li><a href="#reputation" data-toggle="tab">Reputation</a></li>
<li><a href="#email" data-toggle="tab">Email</a></li>
<li><a href="#user" data-toggle="tab">User</a></li>
<li><a href="#post" data-toggle="tab">Post</a></li>
<li><a href="#pagination" data-toggle="tab">Pagination</a></li>
<li><a href="#tags" data-toggle="tab">Tags</a></li>
<li><a href="#web-crawler" data-toggle="tab">Web Crawler</a></li>
<li><a href="#sockets" data-toggle="tab">Sockets</a></li>
<li><a href="#advanced" data-toggle="tab">Advanced</a></li>
</ul>
<div class="tab-content">
<!-- IMPORT admin/settings/general.tpl -->
<!-- IMPORT admin/settings/email.tpl -->
<!-- IMPORT admin/settings/user.tpl -->
<!-- IMPORT admin/settings/post.tpl -->
<!-- IMPORT admin/settings/pagination.tpl -->
<!-- IMPORT admin/settings/tags.tpl -->
<!-- IMPORT admin/settings/web-crawler.tpl -->
<!-- IMPORT admin/settings/sockets.tpl -->
<!-- IMPORT admin/settings/advanced.tpl -->
<!-- This was not moved into a partial because I am removing it soon (@julianlam) -->
<!-- ^ Heh, when did I add this... this section is still here apparently. (@julianlam July 2014) -->
<div class="tab-pane" id="reputation">
<form>
<div class="alert alert-warning">
<div class="checkbox">
<label>
<input type="checkbox" data-field="reputation:disabled"> <strong>Disable Reputation System</strong>
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" data-field="downvote:disabled"> <strong>Disable Down Voting</trong>
</label>
</div>
</div>
<div class="alert alert-warning">
<h3>Privilege Thresholds</h3>
<p>Use <strong>privilege thresholds</strong> to manage how much reputation a user must gain to receive moderator access.</p><br />
<strong>Manage Thread</strong><br /> <input type="text" class="form-control" value="1000" data-field="privileges:manage_topic"><br />
<strong>Manage Content</strong><br /> <input type="text" class="form-control" value="1000" data-field="privileges:manage_content"><br />
<div class="checkbox">
<label>
<input type="checkbox" data-field="privileges:disabled"> <strong>Disable Privilege Threshold System</strong>
</label>
</div>
</div>
<div class="alert alert-warning">
<h3>Activity Thresholds</h3>
<strong>Minimum reputation to downvote posts</strong><br /> <input type="text" class="form-control" data-field="privileges:downvote"><br />
<strong>Minimum reputation to flag posts</strong><br /> <input type="text" class="form-control" data-field="privileges:flag"><br />
</div>
</form>
</div>
</div>
<span class="hidden" id="csrf" data-csrf="{csrf}"></span>
<button class="btn btn-primary" id="save">Save</button>
<script>
require(['forum/admin/settings'], function(Settings) {
Settings.prepare();
});
</script>

@ -1,4 +1,5 @@
<div class="tab-pane active" id="advanced"> <!-- IMPORT admin/settings/header.tpl -->
<div class="alert alert-warning"> <div class="alert alert-warning">
<form> <form>
<div class="checkbox"> <div class="checkbox">
@ -27,4 +28,5 @@
</div> </div>
</form> </form>
</div> </div>
</div>
<!-- IMPORT admin/settings/footer.tpl -->

@ -1,4 +1,5 @@
<div class="tab-pane" id="email"> <!-- IMPORT admin/settings/header.tpl -->
<form> <form>
<div class="alert alert-warning"> <div class="alert alert-warning">
<div> <div>
@ -26,4 +27,5 @@
</div> </div>
</div> </div>
</form> </form>
</div>
<!-- IMPORT admin/settings/footer.tpl -->

@ -0,0 +1,9 @@
<span class="hidden" id="csrf" data-csrf="{csrf}"></span>
<button class="btn btn-primary" id="save">Save</button>
<script>
require(['forum/admin/settings'], function(Settings) {
Settings.prepare();
});
</script>

@ -1,4 +1,5 @@
<div class="tab-pane active" id="general"> <!-- IMPORT admin/settings/header.tpl -->
<div class="alert alert-warning"> <div class="alert alert-warning">
<form> <form>
<label>Site Title</label> <label>Site Title</label>
@ -48,4 +49,5 @@
</div> </div>
</form> </form>
</div> </div>
</div>
<!-- IMPORT admin/settings/footer.tpl -->

@ -0,0 +1,17 @@
<h1><i class="fa fa-cogs"></i> Settings</h1>
<hr />
<ul class="nav nav-pills settings">
<li data-pill="general"><a href="{relative_path}/admin/settings/general">General</a></li>
<li data-pill="reputation"><a href="{relative_path}/admin/settings/reputation">Reputation</a></li>
<li data-pill="email"><a href="{relative_path}/admin/settings/email">Email</a></li>
<li data-pill="user"><a href="{relative_path}/admin/settings/user">User</a></li>
<li data-pill="post"><a href="{relative_path}/admin/settings/post">Post</a></li>
<li data-pill="pagination"><a href="{relative_path}/admin/settings/pagination">Pagination</a></li>
<li data-pill="tags"><a href="{relative_path}/admin/settings/tags">Tags</a></li>
<li data-pill="web-crawler"><a href="{relative_path}/admin/settings/web-crawler">Web Crawler</a></li>
<li data-pill="sockets"><a href="{relative_path}/admin/settings/sockets">Sockets</a></li>
<li data-pill="advanced"><a href="{relative_path}/admin/settings/advanced">Advanced</a></li>
</ul>
<br />

@ -1,4 +1,5 @@
<div class="tab-pane" id="pagination"> <!-- IMPORT admin/settings/header.tpl -->
<form> <form>
<div class="alert alert-warning"> <div class="alert alert-warning">
<div class="checkbox"> <div class="checkbox">
@ -13,4 +14,5 @@
<strong>Initial Number of Topics to Load (Unread, Recent, Popular etc.)</strong><br /> <input type="text" class="form-control" value="20" data-field="topicsPerList"><br /> <strong>Initial Number of Topics to Load (Unread, Recent, Popular etc.)</strong><br /> <input type="text" class="form-control" value="20" data-field="topicsPerList"><br />
</div> </div>
</form> </form>
</div>
<!-- IMPORT admin/settings/footer.tpl -->

@ -1,4 +1,5 @@
<div class="tab-pane" id="post"> <!-- IMPORT admin/settings/header.tpl -->
<form> <form>
<div class="alert alert-warning"> <div class="alert alert-warning">
<div class="form-group"> <div class="form-group">
@ -58,4 +59,5 @@
</div> </div>
</div> </div>
</form> </form>
</div>
<!-- IMPORT admin/settings/footer.tpl -->

@ -0,0 +1,36 @@
<!-- IMPORT admin/settings/header.tpl -->
<form>
<div class="alert alert-warning">
<div class="checkbox">
<label>
<input type="checkbox" data-field="reputation:disabled"> <strong>Disable Reputation System</strong>
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" data-field="downvote:disabled"> <strong>Disable Down Voting</trong>
</label>
</div>
</div>
<div class="alert alert-warning">
<h3>Privilege Thresholds</h3>
<p>Use <strong>privilege thresholds</strong> to manage how much reputation a user must gain to receive moderator access.</p><br />
<strong>Manage Thread</strong><br /> <input type="text" class="form-control" value="1000" data-field="privileges:manage_topic"><br />
<strong>Manage Content</strong><br /> <input type="text" class="form-control" value="1000" data-field="privileges:manage_content"><br />
<div class="checkbox">
<label>
<input type="checkbox" data-field="privileges:disabled"> <strong>Disable Privilege Threshold System</strong>
</label>
</div>
</div>
<div class="alert alert-warning">
<h3>Activity Thresholds</h3>
<strong>Minimum reputation to downvote posts</strong><br /> <input type="text" class="form-control" data-field="privileges:downvote"><br />
<strong>Minimum reputation to flag posts</strong><br /> <input type="text" class="form-control" data-field="privileges:flag"><br />
</div>
</form>
<!-- IMPORT admin/settings/footer.tpl -->

@ -1,4 +1,5 @@
<div class="tab-pane" id="sockets"> <!-- IMPORT admin/settings/header.tpl -->
<form> <form>
<div class="alert alert-warning"> <div class="alert alert-warning">
<div class="form-group"> <div class="form-group">
@ -18,4 +19,5 @@
</div> </div>
</div> </div>
</form> </form>
</div>
<!-- IMPORT admin/settings/footer.tpl -->

@ -1,4 +1,5 @@
<div class="tab-pane" id="tags"> <!-- IMPORT admin/settings/header.tpl -->
<form> <form>
<div class="alert alert-warning"> <div class="alert alert-warning">
<strong>Tags per Topic</strong><br /> <input type="text" class="form-control" value="5" data-field="tagsPerTopic"><br /> <strong>Tags per Topic</strong><br /> <input type="text" class="form-control" value="5" data-field="tagsPerTopic"><br />
@ -6,4 +7,5 @@
<strong>Maximum Tag Length</strong><br /> <input type="text" class="form-control" value="15" data-field="maximumTagLength"><br /> <strong>Maximum Tag Length</strong><br /> <input type="text" class="form-control" value="15" data-field="maximumTagLength"><br />
</div> </div>
</form> </form>
</div>
<!-- IMPORT admin/settings/footer.tpl -->

@ -1,4 +1,5 @@
<div class="tab-pane" id="user"> <!-- IMPORT admin/settings/header.tpl -->
<form role="form"> <form role="form">
<div class="alert alert-warning"> <div class="alert alert-warning">
<div class="checkbox"> <div class="checkbox">
@ -114,4 +115,5 @@
</div> </div>
</div> </div>
</form> </form>
</div>
<!-- IMPORT admin/settings/footer.tpl -->

@ -1,4 +1,5 @@
<div class="tab-pane" id="web-crawler"> <!-- IMPORT admin/settings/header.tpl -->
<form> <form>
<div class="alert alert-warning"> <div class="alert alert-warning">
<strong>Custom Robots.txt <small>Leave blank for default</small></strong><br /> <strong>Custom Robots.txt <small>Leave blank for default</small></strong><br />
@ -20,4 +21,5 @@
</div> </div>
</div> </div>
</form> </form>
</div>
<!-- IMPORT admin/settings/footer.tpl -->
Loading…
Cancel
Save