From c50bfa07ca3a456d69d73988f42e58e3282879e9 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 3 Aug 2016 21:16:57 +0200 Subject: multiple acl work --- view/js/acl.js | 86 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 60 insertions(+), 26 deletions(-) (limited to 'view/js/acl.js') diff --git a/view/js/acl.js b/view/js/acl.js index 79699c589..33895d260 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -1,15 +1,17 @@ -function ACL(backend_url, preset) { +function ACL(backend_url) { that = this; that.url = backend_url; that.kp_timer = null; - if (preset === undefined) preset = []; - that.allow_cid = (preset[0] || []); - that.allow_gid = (preset[1] || []); - that.deny_cid = (preset[2] || []); - that.deny_gid = (preset[3] || []); + that.self = []; + + that.allow_cid = []; + that.allow_gid = []; + that.deny_cid = []; + that.deny_gid = []; + that.group_uids = []; that.info = $("#acl-info"); @@ -21,11 +23,8 @@ function ACL(backend_url, preset) { 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(); + //that.on_submit(); /*events*/ @@ -47,32 +46,59 @@ function ACL(backend_url, preset) { } }); + + //$(document).on('click', '.acl-submit', that.get_form_id_and_submit); + //$(document).on('click', '.acl-select', that.get_form_id_and_submit); + + $(document).on('focus', '.acl-form', that.get_form_data); + $(document).on('click', '.acl-form', that.get_form_data); + $(document).on('click','.acl-button-show',that.on_button_show); $(document).on('click','.acl-button-hide',that.on_button_hide); + $(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.on_submit(); }); } // no longer called only on submit - call to update whenever a change occurs to the acl list. +ACL.prototype.get_form_data = function(event) { +//event.preventDefault() + + that.form_id = $(this).data('formid'); + + console.log(event); + + that.allow_cid = ($(this).data('allow_cid') || []); + that.allow_gid = ($(this).data('allow_gid') || []); + that.deny_cid = ($(this).data('deny_cid') || []); + that.deny_gid = ($(this).data('deny_gid') || []); + + that.update_view(); + that.on_submit(); +} ACL.prototype.on_submit = function() { - aclfields = $("#acl-fields").html(""); + + + //console.log(that.form_id); + $('.acl-field').remove(); $(that.allow_gid).each(function(i,v) { - aclfields.append(""); + $('#' + that.form_id).append(""); }); $(that.allow_cid).each(function(i,v) { - aclfields.append(""); + $('#' + that.form_id).append(""); }); $(that.deny_gid).each(function(i,v) { - aclfields.append(""); + $('#' + that.form_id).append(""); }); $(that.deny_cid).each(function(i,v) { - aclfields.append(""); + $('#' + that.form_id).append(""); }); //areYouSure jquery plugin: recheck the form here @@ -101,6 +127,7 @@ ACL.prototype.on_onlyme = function(event) { that.deny_cid = []; that.deny_gid = []; + that.update_view(event.target.value); that.on_submit(); @@ -126,14 +153,14 @@ 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]]; + if(that.allow_cid.length === 0 && that.allow_gid.length === 0 && that.deny_cid.length === 0 && that.deny_gid.length === 0) { + that.allow_cid = [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.allow_cid = (that.allow_cid || []); + that.allow_gid = (that.allow_gid || []); + that.deny_cid = (that.deny_cid || []); + that.deny_gid = (that.deny_gid || []); that.update_view(event.target.value); that.on_submit(); @@ -239,14 +266,21 @@ ACL.prototype.set_deny = function(itemid) { that.update_view(); }; -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_select = function(set) { + that.showall.prop('selected', set === 'public'); + that.onlyme.prop('selected', set === 'onlyme'); + that.showlimited.prop('selected', set === 'limited'); }; ACL.prototype.update_view = function(value) { + console.log(that.form_id); + + console.log(that.allow_cid); + console.log(that.allow_gid); + console.log(that.deny_cid); + console.log(that.deny_gid); + 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 -- cgit v1.2.3 From df27a48e727ee319e3b9ff1f94024d1cf100f350 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 3 Aug 2016 22:50:37 +0200 Subject: multiple acl: store new data in update_view() --- view/js/acl.js | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'view/js/acl.js') diff --git a/view/js/acl.js b/view/js/acl.js index 33895d260..0006bcfca 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -46,10 +46,6 @@ function ACL(backend_url) { } }); - - //$(document).on('click', '.acl-submit', that.get_form_id_and_submit); - //$(document).on('click', '.acl-select', that.get_form_id_and_submit); - $(document).on('focus', '.acl-form', that.get_form_data); $(document).on('click', '.acl-form', that.get_form_data); @@ -66,11 +62,13 @@ function ACL(backend_url) { }); } -// no longer called only on submit - call to update whenever a change occurs to the acl list. + ACL.prototype.get_form_data = function(event) { //event.preventDefault() - that.form_id = $(this).data('formid'); + form_id = $(this).data('formid'); + + that.form_id = $('#' + form_id); console.log(event); @@ -83,22 +81,22 @@ ACL.prototype.get_form_data = function(event) { that.on_submit(); } +// no longer called only on submit - call to update whenever a change occurs to the acl list. ACL.prototype.on_submit = function() { - - //console.log(that.form_id); $('.acl-field').remove(); + $(that.allow_gid).each(function(i,v) { - $('#' + that.form_id).append(""); + that.form_id.append(""); }); $(that.allow_cid).each(function(i,v) { - $('#' + that.form_id).append(""); + that.form_id.append(""); }); $(that.deny_gid).each(function(i,v) { - $('#' + that.form_id).append(""); + that.form_id.append(""); }); $(that.deny_cid).each(function(i,v) { - $('#' + that.form_id).append(""); + that.form_id.append(""); }); //areYouSure jquery plugin: recheck the form here @@ -273,13 +271,19 @@ ACL.prototype.update_select = function(set) { }; ACL.prototype.update_view = function(value) { - + if(that.form_id) { console.log(that.form_id); - console.log(that.allow_cid); - console.log(that.allow_gid); - console.log(that.deny_cid); - console.log(that.deny_gid); + that.form_id.data('allow_cid', that.allow_cid); + that.form_id.data('allow_gid', that.allow_gid); + that.form_id.data('deny_cid', that.deny_cid); + that.form_id.data('deny_gid', that.deny_gid); + + console.log(that.form_id.data('allow_cid')); + console.log(that.form_id.data('allow_gid')); + console.log(that.form_id.data('deny_cid')); + console.log(that.form_id.data('deny_gid')); + } 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 @@ -293,8 +297,8 @@ ACL.prototype.update_view = function(value) { } // 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 + 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 !== 'limited') { + that.list.hide(); //hide acl-list that.info.hide(); //show acl-info that.update_select('onlyme'); -- cgit v1.2.3 From 908e15bc9041f757217ba8d3635a8d83a5544c46 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 3 Aug 2016 23:57:41 +0200 Subject: multi acl: port events --- view/js/acl.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'view/js/acl.js') diff --git a/view/js/acl.js b/view/js/acl.js index 0006bcfca..175462250 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -64,13 +64,12 @@ function ACL(backend_url) { ACL.prototype.get_form_data = function(event) { -//event.preventDefault() - form_id = $(this).data('formid'); + form_id = $(this).data('form_id'); that.form_id = $('#' + form_id); - console.log(event); + console.log(form_id); that.allow_cid = ($(this).data('allow_cid') || []); that.allow_gid = ($(this).data('allow_gid') || []); -- cgit v1.2.3 From 7e5428c69703e16f011e362a9865fe50d4841ddb Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 4 Aug 2016 21:26:30 +0200 Subject: multi acl: provide a acl-form-trigger class which comes handy in certain situations --- view/js/acl.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'view/js/acl.js') diff --git a/view/js/acl.js b/view/js/acl.js index 175462250..9b08571ae 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -48,6 +48,7 @@ function ACL(backend_url) { $(document).on('focus', '.acl-form', that.get_form_data); $(document).on('click', '.acl-form', that.get_form_data); + $(document).on('click', '.acl-form-trigger', that.get_form_data); $(document).on('click','.acl-button-show',that.on_button_show); $(document).on('click','.acl-button-hide',that.on_button_hide); @@ -71,10 +72,10 @@ ACL.prototype.get_form_data = function(event) { console.log(form_id); - that.allow_cid = ($(this).data('allow_cid') || []); - that.allow_gid = ($(this).data('allow_gid') || []); - that.deny_cid = ($(this).data('deny_cid') || []); - that.deny_gid = ($(this).data('deny_gid') || []); + that.allow_cid = (that.form_id.data('allow_cid') || []); + that.allow_gid = (that.form_id.data('allow_gid') || []); + that.deny_cid = (that.form_id.data('deny_cid') || []); + that.deny_gid = (that.form_id.data('deny_gid') || []); that.update_view(); that.on_submit(); -- cgit v1.2.3 From bed0a5773fe2300979969b46ef633f28ab84bf43 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 5 Aug 2016 13:20:03 +0200 Subject: multi acl: port /rpost --- view/js/acl.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'view/js/acl.js') diff --git a/view/js/acl.js b/view/js/acl.js index 9b08571ae..9b9f0eba3 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -53,8 +53,6 @@ function ACL(backend_url) { $(document).on('click','.acl-button-show',that.on_button_show); $(document).on('click','.acl-button-hide',that.on_button_hide); - $(document).on('click','.acl-button-hide',that.on_button_hide); - $("#acl-search").keypress(that.on_search); /* startup! */ @@ -64,7 +62,7 @@ function ACL(backend_url) { } -ACL.prototype.get_form_data = function(event) { +ACL.prototype.get_form_data = function(event, form_id) { form_id = $(this).data('form_id'); @@ -401,5 +399,5 @@ ACL.prototype.populate = function(data) { $(el).attr('src', $(el).data("src")); $(el).removeAttr("data-src"); }); - that.update_view(); + //that.update_view(); }; -- cgit v1.2.3 From e7e73e6fd1f2e6d7e9a31ad11aad9f3020c94bbf Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 5 Aug 2016 13:37:47 +0200 Subject: multi acl: port /thing --- view/js/acl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'view/js/acl.js') diff --git a/view/js/acl.js b/view/js/acl.js index 9b9f0eba3..a1af5f4f0 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -62,7 +62,7 @@ function ACL(backend_url) { } -ACL.prototype.get_form_data = function(event, form_id) { +ACL.prototype.get_form_data = function(event) { form_id = $(this).data('form_id'); -- cgit v1.2.3 From b2298d44a4126ba0b7f0355733bb1125c656bac1 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 5 Aug 2016 14:45:06 +0200 Subject: multi acl: port /settings --- view/js/acl.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'view/js/acl.js') diff --git a/view/js/acl.js b/view/js/acl.js index a1af5f4f0..2ba7ea46a 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -97,8 +97,6 @@ ACL.prototype.on_submit = function() { that.form_id.append(""); }); - //areYouSure jquery plugin: recheck the form here - $('form').trigger('checkform.areYouSure'); }; ACL.prototype.search = function() { -- cgit v1.2.3 From 316b090433b7e415fd3c8ac6230f2df0277cdf8c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 5 Aug 2016 14:53:46 +0200 Subject: remove some logging --- view/js/acl.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'view/js/acl.js') diff --git a/view/js/acl.js b/view/js/acl.js index 2ba7ea46a..b36fa97a1 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -65,11 +65,8 @@ function ACL(backend_url) { ACL.prototype.get_form_data = function(event) { form_id = $(this).data('form_id'); - that.form_id = $('#' + form_id); - console.log(form_id); - that.allow_cid = (that.form_id.data('allow_cid') || []); that.allow_gid = (that.form_id.data('allow_gid') || []); that.deny_cid = (that.form_id.data('deny_cid') || []); @@ -77,6 +74,7 @@ ACL.prototype.get_form_data = function(event) { that.update_view(); that.on_submit(); + } // no longer called only on submit - call to update whenever a change occurs to the acl list. @@ -268,17 +266,10 @@ ACL.prototype.update_select = function(set) { ACL.prototype.update_view = function(value) { if(that.form_id) { - console.log(that.form_id); - that.form_id.data('allow_cid', that.allow_cid); that.form_id.data('allow_gid', that.allow_gid); that.form_id.data('deny_cid', that.deny_cid); that.form_id.data('deny_gid', that.deny_gid); - - console.log(that.form_id.data('allow_cid')); - console.log(that.form_id.data('allow_gid')); - console.log(that.form_id.data('deny_cid')); - console.log(that.form_id.data('deny_gid')); } if (that.allow_gid.length === 0 && that.allow_cid.length === 0 && that.deny_gid.length === 0 && that.deny_cid.length === 0) { -- cgit v1.2.3 From e67f5bc6bbb77d53867d7c03bda8410c59360dbe Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 5 Aug 2016 15:19:17 +0200 Subject: Revert "remove some logging" This reverts commit 316b090433b7e415fd3c8ac6230f2df0277cdf8c. --- view/js/acl.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'view/js/acl.js') diff --git a/view/js/acl.js b/view/js/acl.js index b36fa97a1..2ba7ea46a 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -65,8 +65,11 @@ function ACL(backend_url) { ACL.prototype.get_form_data = function(event) { form_id = $(this).data('form_id'); + that.form_id = $('#' + form_id); + console.log(form_id); + that.allow_cid = (that.form_id.data('allow_cid') || []); that.allow_gid = (that.form_id.data('allow_gid') || []); that.deny_cid = (that.form_id.data('deny_cid') || []); @@ -74,7 +77,6 @@ ACL.prototype.get_form_data = function(event) { that.update_view(); that.on_submit(); - } // no longer called only on submit - call to update whenever a change occurs to the acl list. @@ -266,10 +268,17 @@ ACL.prototype.update_select = function(set) { ACL.prototype.update_view = function(value) { if(that.form_id) { + console.log(that.form_id); + that.form_id.data('allow_cid', that.allow_cid); that.form_id.data('allow_gid', that.allow_gid); that.form_id.data('deny_cid', that.deny_cid); that.form_id.data('deny_gid', that.deny_gid); + + console.log(that.form_id.data('allow_cid')); + console.log(that.form_id.data('allow_gid')); + console.log(that.form_id.data('deny_cid')); + console.log(that.form_id.data('deny_gid')); } if (that.allow_gid.length === 0 && that.allow_cid.length === 0 && that.deny_gid.length === 0 && that.deny_cid.length === 0) { -- cgit v1.2.3 From 531baa8fc4c29c10afdf52fc88174b8b6fd69700 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 5 Aug 2016 16:05:21 +0200 Subject: Revert "Revert "remove some logging"" This reverts commit e67f5bc6bbb77d53867d7c03bda8410c59360dbe. --- view/js/acl.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'view/js/acl.js') diff --git a/view/js/acl.js b/view/js/acl.js index 2ba7ea46a..b36fa97a1 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -65,11 +65,8 @@ function ACL(backend_url) { ACL.prototype.get_form_data = function(event) { form_id = $(this).data('form_id'); - that.form_id = $('#' + form_id); - console.log(form_id); - that.allow_cid = (that.form_id.data('allow_cid') || []); that.allow_gid = (that.form_id.data('allow_gid') || []); that.deny_cid = (that.form_id.data('deny_cid') || []); @@ -77,6 +74,7 @@ ACL.prototype.get_form_data = function(event) { that.update_view(); that.on_submit(); + } // no longer called only on submit - call to update whenever a change occurs to the acl list. @@ -268,17 +266,10 @@ ACL.prototype.update_select = function(set) { ACL.prototype.update_view = function(value) { if(that.form_id) { - console.log(that.form_id); - that.form_id.data('allow_cid', that.allow_cid); that.form_id.data('allow_gid', that.allow_gid); that.form_id.data('deny_cid', that.deny_cid); that.form_id.data('deny_gid', that.deny_gid); - - console.log(that.form_id.data('allow_cid')); - console.log(that.form_id.data('allow_gid')); - console.log(that.form_id.data('deny_cid')); - console.log(that.form_id.data('deny_gid')); } if (that.allow_gid.length === 0 && that.allow_cid.length === 0 && that.deny_gid.length === 0 && that.deny_cid.length === 0) { -- cgit v1.2.3