Fix confusion when connector checkboxes are disabled for private posts

- Saves connector checkbox state when disabling them
- Restores connector checkbox state when reenabling them
This commit is contained in:
Hypolite Petovan 2019-03-24 22:42:03 -04:00
parent 898f7e7e38
commit f17a6007e5
1 changed files with 47 additions and 36 deletions

View File

@ -225,30 +225,41 @@ ACL.prototype.is_show_all = function() {
this.deny_gid.length==0 && this.deny_cid.length==0); this.deny_gid.length==0 && this.deny_cid.length==0);
}; };
ACL.prototype.update_view = function(){ ACL.prototype.update_view = function () {
if (this.is_show_all()){ if (this.is_show_all()) {
this.showall.addClass("selected"); this.showall.addClass("selected");
/* jot acl */ /* jot acl */
$('#jot-perms-icon').removeClass('lock').addClass('unlock'); $('#jot-perms-icon').removeClass('lock').addClass('unlock');
$('#jot-public').show(); $('#jot-public').show();
$('.profile-jot-net input').attr('disabled', false); $('.profile-jot-net input[type=checkbox]').each(function() {
if(typeof editor != 'undefined' && editor != false) { // Restores checkbox state if it had been saved
$('#profile-jot-desc').html(ispublic); if ($(this).attr('data-checked') !== undefined) {
} $(this).prop('checked', $(this).attr('data-checked') === 'true');
}
});
$('.profile-jot-net input').attr('disabled', false);
if (typeof editor != 'undefined' && editor != false) {
$('#profile-jot-desc').html(ispublic);
}
} else { } else {
this.showall.removeClass("selected"); this.showall.removeClass("selected");
/* jot acl */ /* jot acl */
$('#jot-perms-icon').removeClass('unlock').addClass('lock'); $('#jot-perms-icon').removeClass('unlock').addClass('lock');
$('#jot-public').hide(); $('#jot-public').hide();
$('.profile-jot-net input').attr('disabled', 'disabled'); $('.profile-jot-net input[type=checkbox]').each(function() {
$('#profile-jot-desc').html(' '); // Saves current checkbox state
$(this)
.attr('data-checked', $(this).prop('checked'))
.prop('checked', false);
});
$('.profile-jot-net input').attr('disabled', 'disabled');
$('#profile-jot-desc').html(' ');
} }
$("#acl-list-content .acl-list-item").each(function(){
$(this).removeClass("groupshow grouphide");
});
$("#acl-list-content .acl-list-item").each(function(index, element){ $("#acl-list-content .acl-list-item").each(function (index, element) {
$(this).removeClass("groupshow grouphide");
itemid = $(element).attr('id'); itemid = $(element).attr('id');
type = itemid[0]; type = itemid[0];
id = parseInt(itemid.substr(1)); id = parseInt(itemid.substr(1));
@ -256,40 +267,40 @@ ACL.prototype.update_view = function(){
btshow = $(element).children(".acl-button-show").removeClass("selected"); btshow = $(element).children(".acl-button-show").removeClass("selected");
bthide = $(element).children(".acl-button-hide").removeClass("selected"); bthide = $(element).children(".acl-button-hide").removeClass("selected");
switch(type){ switch (type) {
case "g": case "g":
var uclass = ""; var uclass = "";
if (this.allow_gid.indexOf(id)>=0){ if (this.allow_gid.indexOf(id) >= 0) {
btshow.addClass("selected"); btshow.addClass("selected");
bthide.removeClass("selected"); bthide.removeClass("selected");
uclass="groupshow"; uclass = "groupshow";
} }
if (this.deny_gid.indexOf(id)>=0){ if (this.deny_gid.indexOf(id) >= 0) {
btshow.removeClass("selected"); btshow.removeClass("selected");
bthide.addClass("selected"); bthide.addClass("selected");
uclass="grouphide"; uclass = "grouphide";
} }
$(this.group_uids[id]).each(function(i,v) { $(this.group_uids[id]).each(function (i, v) {
if(uclass == "grouphide") if (uclass == "grouphide")
$("#c"+v).removeClass("groupshow"); $("#c" + v).removeClass("groupshow");
if(uclass != "") { if (uclass != "") {
var cls = $("#c"+v).attr('class'); var cls = $("#c" + v).attr('class');
if( cls == undefined) if (cls == undefined)
return true; return true;
var hiding = cls.indexOf('grouphide'); var hiding = cls.indexOf('grouphide');
if(hiding == -1) if (hiding == -1)
$("#c"+v).addClass(uclass); $("#c" + v).addClass(uclass);
} }
}); });
break; break;
case "c": case "c":
if (this.allow_cid.indexOf(id)>=0){ if (this.allow_cid.indexOf(id) >= 0) {
btshow.addClass("selected"); btshow.addClass("selected");
bthide.removeClass("selected"); bthide.removeClass("selected");
} }
if (this.deny_cid.indexOf(id)>=0){ if (this.deny_cid.indexOf(id) >= 0) {
btshow.removeClass("selected"); btshow.removeClass("selected");
bthide.addClass("selected"); bthide.addClass("selected");
} }
@ -297,7 +308,7 @@ ACL.prototype.update_view = function(){
}.bind(this)); }.bind(this));
} };
ACL.prototype.get = function(start,count, search){ ACL.prototype.get = function(start,count, search){
var postdata = { var postdata = {