From fd6b95920a62324bd85af674cb44f2e385140dd5 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Mon, 20 Jan 2014 12:16:30 -0600 Subject: [PATCH] Add permissions editor --- lib/channel-new.js | 2 +- templates/channel.jade | 2 ++ templates/channeloptions.jade | 3 +++ www/assets/js/callbacks.js | 3 +-- www/assets/js/util.js | 50 +++++++++++++++++++++++------------ 5 files changed, 40 insertions(+), 20 deletions(-) diff --git a/lib/channel-new.js b/lib/channel-new.js index f4417eac..b696aa43 100644 --- a/lib/channel-new.js +++ b/lib/channel-new.js @@ -2329,7 +2329,7 @@ Channel.prototype.handleMoveFilter = function (user, data) { /** * Handles a user message to change the channel permissions */ -Channel.prototype.handleUpdatePermissions = function (user, perms) { +Channel.prototype.handleSetPermissions = function (user, perms) { if (user.rank < 3) { user.kick("Attempted setPermissions as a non-admin"); return; diff --git a/templates/channel.jade b/templates/channel.jade index 90c8af6e..08fe7d5a 100644 --- a/templates/channel.jade +++ b/templates/channel.jade @@ -177,6 +177,7 @@ html(lang="en") li: a(href="#cs-motdeditor", data-toggle="tab", tabindex="-1") Edit MOTD li: a(href="#cs-csseditor", data-toggle="tab", tabindex="-1") Edit CSS li: a(href="#cs-jseditor", data-toggle="tab", tabindex="-1") Edit Javascript + li: a(href="#cs-permedit", data-toggle="tab", tabindex="-1") Edit Permissions li: a(href="#cs-chanranks", data-toggle="tab", tabindex="-1", onclick="javascript:socket.emit('requestChannelRanks')") Edit moderators li: a(href="#cs-banlist", data-toggle="tab", tabindex="-1", onclick="javascript:socket.emit('requestBanlist')") Ban list .modal-body @@ -192,6 +193,7 @@ html(lang="en") mixin chanranks() mixin chatfilters() mixin chanlog() + mixin permeditor() .modal-footer button.btn.btn-default(type="button", data-dismiss="modal") Close include footer diff --git a/templates/channeloptions.jade b/templates/channeloptions.jade index 98dea0ff..6089753f 100644 --- a/templates/channeloptions.jade +++ b/templates/channeloptions.jade @@ -162,3 +162,6 @@ mixin chanlog input#filter_joinquit(type="checkbox") pre#chanlog_contents(style="max-height: 400px; overflow-y: scroll") button.btn.btn-default#chanlog_refresh Refresh + +mixin permeditor + #cs-permedit.tab-pane diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index 555f22e5..b1dcb8eb 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -300,8 +300,7 @@ Callbacks = { setPermissions: function(perms) { CHANNEL.perms = perms; - if(CLIENT.rank >= Rank.Admin) - genPermissionsEditor(); + genPermissionsEditor(); handlePermissionChange(); }, diff --git a/www/assets/js/util.js b/www/assets/js/util.js index 668e27eb..10117bbc 100644 --- a/www/assets/js/util.js +++ b/www/assets/js/util.js @@ -1370,33 +1370,36 @@ function chatOnly() { // TODO fix function genPermissionsEditor() { - $("#permedit").html(""); + $("#cs-permedit").html(""); var form = $("
").addClass("form-horizontal") .attr("action", "javascript:void(0)") - .appendTo($("#permedit")); - var fs = $("
").appendTo(form); + .appendTo($("#cs-permedit")); function makeOption(text, key, permset, defval) { - var group = $("
").addClass("control-group") - .appendTo(fs); - $("