|
|
|
@ -5,45 +5,45 @@
|
|
|
|
|
function addPermission(permcode, permdesc) {
|
|
|
|
|
permcode = permcode.trim().toUpperCase();
|
|
|
|
|
if (permcode == "") {
|
|
|
|
|
return false;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if ($("#permslist div[data-permcode=" + permcode + "]").length) {
|
|
|
|
|
$("#permslist .list-group-item[data-permcode=" + permcode + "]").animate({
|
|
|
|
|
backgroundColor: "#ff0000",
|
|
|
|
|
}, 500, "linear", function () {
|
|
|
|
|
$("#permslist .list-group-item[data-permcode=" + permcode + "]").animate({
|
|
|
|
|
backgroundColor: "#ffffff",
|
|
|
|
|
}, 500);
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
$("#permslist .list-group-item[data-permcode=" + permcode + "]").animate({
|
|
|
|
|
backgroundColor: "#ff0000",
|
|
|
|
|
}, 500, "linear", function () {
|
|
|
|
|
$("#permslist .list-group-item[data-permcode=" + permcode + "]").animate({
|
|
|
|
|
backgroundColor: "#ffffff",
|
|
|
|
|
}, 500);
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (typeof permdesc == "undefined") {
|
|
|
|
|
$.post("action.php", {
|
|
|
|
|
action: 'autocomplete_permission',
|
|
|
|
|
q: $("#perms-box").val()
|
|
|
|
|
}, function (resp) {
|
|
|
|
|
if (resp.length === 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (resp.length === 1) {
|
|
|
|
|
permdesc = resp[0].info;
|
|
|
|
|
} else {
|
|
|
|
|
for (var i = 0; i < resp.length; i++) {
|
|
|
|
|
if (resp[i].name == permcode) {
|
|
|
|
|
permdesc = resp[i].info;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (typeof permdesc == "undefined") {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$('#permslist').append("<div class=\"list-group-item\" data-permcode=\"" + permcode + "\">" + permcode + "<div class=\"btn btn-danger btn-sm pull-right rmperm\"><i class=\"fa fa-trash-o\"></i></div><input type=\"hidden\" name=\"permissions[]\" value=\"" + permcode + "\" /> <p class=\"small\">" + permdesc + "</p></div>");
|
|
|
|
|
$("#perms-box").val("");
|
|
|
|
|
}, "json");
|
|
|
|
|
$.post("action.php", {
|
|
|
|
|
action: 'autocomplete_permission',
|
|
|
|
|
q: $("#perms-box").val()
|
|
|
|
|
}, function (resp) {
|
|
|
|
|
if (resp.length === 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (resp.length === 1) {
|
|
|
|
|
permdesc = resp[0].info;
|
|
|
|
|
} else {
|
|
|
|
|
for (var i = 0; i < resp.length; i++) {
|
|
|
|
|
if (resp[i].name == permcode) {
|
|
|
|
|
permdesc = resp[i].info;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (typeof permdesc == "undefined") {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$('#permslist').append("<div class=\"list-group-item\" data-permcode=\"" + permcode + "\">" + permcode + "<div class=\"btn btn-danger btn-sm pull-right rmperm\"><i class=\"fa fa-trash-o\"></i></div><input type=\"hidden\" name=\"permissions[]\" value=\"" + permcode + "\" /> <p class=\"small\">" + permdesc + "</p></div>");
|
|
|
|
|
$("#perms-box").val("");
|
|
|
|
|
}, "json");
|
|
|
|
|
} else {
|
|
|
|
|
$('#permslist').append("<div class=\"list-group-item\" data-permcode=\"" + permcode + "\">" + permcode + "<div class=\"btn btn-danger btn-sm pull-right rmperm\"><i class=\"fa fa-trash-o\"></i></div><input type=\"hidden\" name=\"permissions[]\" value=\"" + permcode + "\" /> <p class=\"small\">" + permdesc + "</p></div>");
|
|
|
|
|
$("#perms-box").val("");
|
|
|
|
|
$('#permslist').append("<div class=\"list-group-item\" data-permcode=\"" + permcode + "\">" + permcode + "<div class=\"btn btn-danger btn-sm pull-right rmperm\"><i class=\"fa fa-trash-o\"></i></div><input type=\"hidden\" name=\"permissions[]\" value=\"" + permcode + "\" /> <p class=\"small\">" + permdesc + "</p></div>");
|
|
|
|
|
$("#perms-box").val("");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -54,30 +54,30 @@ function removePermission(permcode) {
|
|
|
|
|
var options = {
|
|
|
|
|
url: "action.php",
|
|
|
|
|
ajaxSettings: {
|
|
|
|
|
dataType: "json",
|
|
|
|
|
method: "GET",
|
|
|
|
|
data: {
|
|
|
|
|
action: "autocomplete_user"
|
|
|
|
|
}
|
|
|
|
|
dataType: "json",
|
|
|
|
|
method: "GET",
|
|
|
|
|
data: {
|
|
|
|
|
action: "autocomplete_user"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
preparePostData: function (data) {
|
|
|
|
|
data.q = $("#user-box").val();
|
|
|
|
|
return data;
|
|
|
|
|
data.q = $("#user-box").val();
|
|
|
|
|
return data;
|
|
|
|
|
},
|
|
|
|
|
getValue: function (element) {
|
|
|
|
|
return element.username;
|
|
|
|
|
return element.username;
|
|
|
|
|
},
|
|
|
|
|
template: {
|
|
|
|
|
type: "custom",
|
|
|
|
|
method: function (value, item) {
|
|
|
|
|
return item.name + " <i class=\"small\">" + item.username + "</i>";
|
|
|
|
|
}
|
|
|
|
|
type: "custom",
|
|
|
|
|
method: function (value, item) {
|
|
|
|
|
return item.name + " <i class=\"small\">" + item.username + "</i>";
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
list: {
|
|
|
|
|
onClickEvent: function () {
|
|
|
|
|
var value = $("#user-box").getSelectedItemData().username;
|
|
|
|
|
document.location.href = "app.php?page=permissions&user=" + value;
|
|
|
|
|
}
|
|
|
|
|
onClickEvent: function () {
|
|
|
|
|
var value = $("#user-box").getSelectedItemData().username;
|
|
|
|
|
document.location.href = "app.php?page=permissions&user=" + value;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
requestDelay: 500
|
|
|
|
|
};
|
|
|
|
@ -85,31 +85,31 @@ var options = {
|
|
|
|
|
$("#perms-box").easyAutocomplete({
|
|
|
|
|
url: "action.php",
|
|
|
|
|
ajaxSettings: {
|
|
|
|
|
dataType: "json",
|
|
|
|
|
method: "GET",
|
|
|
|
|
data: {
|
|
|
|
|
action: "autocomplete_permission"
|
|
|
|
|
}
|
|
|
|
|
dataType: "json",
|
|
|
|
|
method: "GET",
|
|
|
|
|
data: {
|
|
|
|
|
action: "autocomplete_permission"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
preparePostData: function (data) {
|
|
|
|
|
data.q = $("#perms-box").val();
|
|
|
|
|
return data;
|
|
|
|
|
data.q = $("#perms-box").val();
|
|
|
|
|
return data;
|
|
|
|
|
},
|
|
|
|
|
getValue: function (element) {
|
|
|
|
|
return element.name;
|
|
|
|
|
return element.name;
|
|
|
|
|
},
|
|
|
|
|
template: {
|
|
|
|
|
type: "custom",
|
|
|
|
|
method: function (value, item) {
|
|
|
|
|
return item.name + " <i class=\"small\">" + item.info + "</i>";
|
|
|
|
|
}
|
|
|
|
|
type: "custom",
|
|
|
|
|
method: function (value, item) {
|
|
|
|
|
return item.name + " <i class=\"small\">" + item.info + "</i>";
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
list: {
|
|
|
|
|
onClickEvent: function () {
|
|
|
|
|
var permcode = $("#perms-box").getSelectedItemData().name;
|
|
|
|
|
var permdesc = $("#perms-box").getSelectedItemData().info;
|
|
|
|
|
addPermission(permcode, permdesc);
|
|
|
|
|
}
|
|
|
|
|
onClickEvent: function () {
|
|
|
|
|
var permcode = $("#perms-box").getSelectedItemData().name;
|
|
|
|
|
var permdesc = $("#perms-box").getSelectedItemData().info;
|
|
|
|
|
addPermission(permcode, permdesc);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
requestDelay: 500
|
|
|
|
|
});
|
|
|
|
@ -118,7 +118,7 @@ $("#user-box").easyAutocomplete(options);
|
|
|
|
|
|
|
|
|
|
$("#user-box").keyup(function (e) {
|
|
|
|
|
if (e.keyCode == 13) {
|
|
|
|
|
$("#selectuserbtn").click();
|
|
|
|
|
$("#selectuserbtn").click();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -128,15 +128,15 @@ $("#selectuserbtn").click(function () {
|
|
|
|
|
|
|
|
|
|
$("#perms-box").keyup(function (event) {
|
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
|
$("#addpermbtn").click();
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
return false;
|
|
|
|
|
$("#addpermbtn").click();
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
$("#perms-box").keydown(function (event) {
|
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
return false;
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|