aboutsummaryrefslogtreecommitdiffstats
path: root/view/js/acl.js
diff options
context:
space:
mode:
authorWave <wave72@users.noreply.github.com>2016-07-22 10:55:02 +0200
committerGitHub <noreply@github.com>2016-07-22 10:55:02 +0200
commit744ad84714fe0f7a3d90250a4ff02dc4327b9061 (patch)
tree595fb74ec9ea0bc7130d18bd7993d719a222d343 /view/js/acl.js
parentc38c79d71c8ef70ef649f83e322f1984b75ee2dd (diff)
parent7d897a3f03bd57ed556433eb84a41963ba44e02e (diff)
downloadvolse-hubzilla-744ad84714fe0f7a3d90250a4ff02dc4327b9061.tar.gz
volse-hubzilla-744ad84714fe0f7a3d90250a4ff02dc4327b9061.tar.bz2
volse-hubzilla-744ad84714fe0f7a3d90250a4ff02dc4327b9061.zip
Merge pull request #6 from redmatrix/dev
Dev
Diffstat (limited to 'view/js/acl.js')
-rw-r--r--view/js/acl.js149
1 files changed, 110 insertions, 39 deletions
diff --git a/view/js/acl.js b/view/js/acl.js
index 65f1009ed..79699c589 100644
--- a/view/js/acl.js
+++ b/view/js/acl.js
@@ -11,28 +11,50 @@ function ACL(backend_url, preset) {
that.deny_cid = (preset[2] || []);
that.deny_gid = (preset[3] || []);
that.group_uids = [];
- that.nw = 4; //items per row. should be calulated from #acl-list.width
+ that.info = $("#acl-info");
+ that.list = $("#acl-list");
that.list_content = $("#acl-list-content");
- that.item_tpl = unescape($(".acl-list-item[rel=acl-template]").html());
- that.showall = $("#acl-showall");
+ that.item_tpl = unescape($(".acl-list-item[rel=acl-template]").html());
+ that.showall = $("#acl-showall");
+ that.onlyme = $("#acl-onlyme");
+ that.showlimited = $("#acl-showlimited");
+ that.acl_select = $("#acl-select");
+
+ that.preset = preset;
+ that.self = [];
// set the initial ACL lists in case the enclosing form gets submitted before the ajax loader completes.
that.on_submit();
- if (preset.length === 0) that.showall.removeClass("btn-default").addClass("btn-warning");
-
/*events*/
$(document).ready(function() {
- that.showall.click(that.on_showall);
- $(document).on('click','.acl-button-show',that.on_button_show);
- $(document).on('click','.acl-button-hide',that.on_button_hide);
- $("#acl-search").keypress(that.on_search);
-
- /* startup! */
- that.get(0,15000);
- that.on_submit();
+
+ that.acl_select.change(function(event) {
+ var option = that.acl_select.val();
+
+ if(option == 'public') { // public
+ that.on_showall(event);
+ }
+
+ if(option == 'onlyme') { // limited to one self
+ that.on_onlyme(event);
+ }
+
+ if(option == 'limited') { // limited to custom selection
+ that.on_showlimited(event);
+ }
+ });
+
+ $(document).on('click','.acl-button-show',that.on_button_show);
+ $(document).on('click','.acl-button-hide',that.on_button_hide);
+
+ $("#acl-search").keypress(that.on_search);
+
+ /* startup! */
+ that.get(0,15000);
+ that.on_submit();
});
}
@@ -70,26 +92,55 @@ ACL.prototype.on_search = function(event) {
that.kp_timer = setTimeout( that.search, 1000);
};
-ACL.prototype.on_showall = function(event) {
- event.preventDefault();
+ACL.prototype.on_onlyme = function(event) {
+ // preventDefault() isn't called here as we want state changes from update_view() to be applied to the radiobutton
event.stopPropagation();
- if (that.showall.hasClass("btn-warning")) {
- return false;
- }
- that.showall.removeClass("btn-default").addClass("btn-warning");
+ that.allow_cid = [that.self[0]];
+ that.allow_gid = [];
+ that.deny_cid = [];
+ that.deny_gid = [];
+
+ that.update_view(event.target.value);
+ that.on_submit();
+
+ return true; // return true so that state changes from update_view() will be applied
+};
+
+ACL.prototype.on_showall = function(event) {
+ // preventDefault() isn't called here as we want state changes from update_view() to be applied to the radiobutton
+ event.stopPropagation();
that.allow_cid = [];
that.allow_gid = [];
that.deny_cid = [];
that.deny_gid = [];
- that.update_view();
+ that.update_view(event.target.value);
that.on_submit();
- return false;
+ return true; // return true so that state changes from update_view() will be applied
};
+ACL.prototype.on_showlimited = function(event) {
+ // preventDefault() isn't called here as we want state changes from update_view() to be applied to the radiobutton
+ event.stopPropagation();
+
+ if(that.preset[0].length === 0 && that.preset[1].length === 0 && that.preset[2].length === 0 && that.preset[3].length === 0) {
+ that.preset[0] = [that.self[0]];
+ }
+
+ that.allow_cid = (that.preset[0] || []);
+ that.allow_gid = (that.preset[1] || []);
+ that.deny_cid = (that.preset[2] || []);
+ that.deny_gid = (that.preset[3] || []);
+
+ that.update_view(event.target.value);
+ that.on_submit();
+
+ return true; // return true so that state changes from update_view() will be applied
+}
+
ACL.prototype.on_selectall = function(event) {
event.preventDefault();
event.stopPropagation();
@@ -188,24 +239,45 @@ ACL.prototype.set_deny = function(itemid) {
that.update_view();
};
-ACL.prototype.update_view = function() {
- if (that.allow_gid.length === 0 && that.allow_cid.length === 0 &&
- that.deny_gid.length === 0 && that.deny_cid.length === 0) {
- that.showall.removeClass("btn-default").addClass("btn-warning");
- /* jot acl */
- $('#jot-perms-icon').removeClass('icon-lock').addClass('icon-unlock');
- $('#jot-public').show();
- $('.profile-jot-net input').attr('disabled', false);
- if(typeof editor !== 'undefined' && editor !== false) {
- $('#profile-jot-desc').html(ispublic);
- }
- } else {
- that.showall.removeClass("btn-warning").addClass("btn-default");
+ACL.prototype.update_select = function(preset) {
+ that.showall.prop('selected', preset === 'public');
+ that.onlyme.prop('selected', preset === 'onlyme');
+ that.showlimited.prop('selected', preset === 'limited');
+};
+
+ACL.prototype.update_view = function(value) {
+
+ if (that.allow_gid.length === 0 && that.allow_cid.length === 0 && that.deny_gid.length === 0 && that.deny_cid.length === 0) {
+ that.list.hide(); //hide acl-list
+ that.info.show(); //show acl-info
+ that.update_select('public');
+
+ /* jot acl */
+ $('#jot-perms-icon, #dialog-perms-icon').removeClass('fa-lock').addClass('fa-unlock');
+ $('.profile-jot-net input').attr('disabled', false);
+
+ }
+
+ // if value != 'onlyme' we should fall through this one
+ else if (that.allow_gid.length === 0 && that.allow_cid.length === 1 && that.allow_cid[0] === that.self[0] && that.deny_gid.length === 0 && that.deny_cid.length === 0 && value === 'onlyme') {
+ that.list.hide(); //hide acl-list if
+ that.info.hide(); //show acl-info
+ that.update_select('onlyme');
+
/* jot acl */
- $('#jot-perms-icon').removeClass('icon-unlock').addClass('icon-lock');
- $('#jot-public').hide();
+ $('#jot-perms-icon, #dialog-perms-icon').removeClass('fa-unlock').addClass('fa-lock');
$('.profile-jot-net input').attr('disabled', 'disabled');
- $('#profile-jot-desc').html('&nbsp;');
+ }
+
+ else {
+ that.list.show(); //show acl-list
+ that.info.hide(); //hide acl-info
+ that.update_select('limited');
+
+ /* jot acl */
+ $('#jot-perms-icon, #dialog-perms-icon').removeClass('fa-unlock').addClass('fa-lock');
+ $('.profile-jot-net input').attr('disabled', 'disabled');
+
}
$("#acl-list-content .acl-list-item").each(function() {
$(this).removeClass("groupshow grouphide");
@@ -278,12 +350,11 @@ ACL.prototype.get = function(start, count, search) {
};
ACL.prototype.populate = function(data) {
- var height = Math.ceil(data.items.length / that.nw) * 42;
- that.list_content.height(height);
$(data.items).each(function(){
html = "<div class='acl-list-item {4} {7} {5}' title='{6}' id='{2}{3}'>"+that.item_tpl+"</div>";
html = html.format(this.photo, this.name, this.type, this.xid, '', this.self, this.link, this.taggable);
if (this.uids !== undefined) that.group_uids[this.xid] = this.uids;
+ if (this.self === 'abook-self') that.self[0] = this.xid;
//console.log(html);
that.list_content.append(html);
});