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 ++++++++++++++++++++++++++++------------- view/tpl/acl_selector.tpl | 6 +-- view/tpl/attach_edit.tpl | 8 ++-- view/tpl/chatroom_new.tpl | 6 +-- view/tpl/cloud_actionspanel.tpl | 1 + view/tpl/jot.tpl | 9 +++-- 6 files changed, 75 insertions(+), 41 deletions(-) (limited to 'view') 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 diff --git a/view/tpl/acl_selector.tpl b/view/tpl/acl_selector.tpl index 60fae0a29..ddeb25a39 100755 --- a/view/tpl/acl_selector.tpl +++ b/view/tpl/acl_selector.tpl @@ -1,3 +1,4 @@ +
- +
diff --git a/view/tpl/attach_edit.tpl b/view/tpl/attach_edit.tpl index 965fb4819..1098049bf 100644 --- a/view/tpl/attach_edit.tpl +++ b/view/tpl/attach_edit.tpl @@ -1,4 +1,4 @@ -
+ @@ -16,15 +16,13 @@
- -
- {{$aclselect}} -
+{{$aclselect}} diff --git a/view/tpl/jot.tpl b/view/tpl/jot.tpl index 490349a04..a207989fb 100755 --- a/view/tpl/jot.tpl +++ b/view/tpl/jot.tpl @@ -1,4 +1,4 @@ -
+ {{$mimeselect}} {{$layoutselect}} {{if $id_select}} @@ -23,7 +23,6 @@ - {{if $showacl}}{{$acl}}{{/if}} {{if $webpage}}
@@ -166,11 +165,11 @@ {{/if}} {{if $showacl}} - {{/if}} - +
@@ -184,6 +183,8 @@ +{{if $showacl}}{{$acl}}{{/if}} + {{if $feature_expire}}
- + {{* album renaming is not supported atm.
@@ -88,8 +88,6 @@
{{/if}} - {{$edit.aclselect}} -
@@ -102,6 +100,7 @@
+ {{$edit.aclselect}}
diff --git a/view/tpl/photos_upload.tpl b/view/tpl/photos_upload.tpl index 6b98a8ac4..90cd0e84a 100755 --- a/view/tpl/photos_upload.tpl +++ b/view/tpl/photos_upload.tpl @@ -1,6 +1,6 @@
-
+
@@ -14,9 +14,6 @@ {{/foreach}}
- - {{$aclselect}} - {{if $default}}
@@ -59,5 +56,6 @@ {{/if}}
+ {{$aclselect}}
-- cgit v1.2.3 From 0340160ba71f73ef3dab1141d75f30d85144cc44 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 4 Aug 2016 10:36:45 +0200 Subject: multi acl: port /cloud and /filestorage --- view/js/main.js | 2 -- view/js/mod_filestorage.js | 15 +-------------- view/tpl/attach_edit.tpl | 6 +++--- view/tpl/cloud_actionspanel.tpl | 3 +-- 4 files changed, 5 insertions(+), 21 deletions(-) (limited to 'view') diff --git a/view/js/main.js b/view/js/main.js index a3fade0ea..21157bdfe 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1015,8 +1015,6 @@ function filestorage(event, nick, id) { $('#cloud-index-' + last_filestorage_id).removeClass('cloud-index-active'); $('#perms-panel-' + last_filestorage_id).hide().html(''); $('#file-edit-' + id).spin('tiny'); - // What for do we need this here? - delete acl; $.get('filestorage/' + nick + '/' + id + '/edit', function(data) { $('#cloud-index-' + id).addClass('cloud-index-active'); $('#perms-panel-' + id).html(data).show(); diff --git a/view/js/mod_filestorage.js b/view/js/mod_filestorage.js index c0620c928..4f58af9d5 100644 --- a/view/js/mod_filestorage.js +++ b/view/js/mod_filestorage.js @@ -1,17 +1,4 @@ /** * JavaScript used by mod/filestorage */ -$(document).ready(function() { - $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() { - var selstr; - $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() { - selstr = $(this).text(); - $('#jot-perms-icon').removeClass('fa-unlock').addClass('fa-lock'); - $('#jot-public').hide(); - }); - if(selstr === null) { - $('#jot-perms-icon').removeClass('fa-lock').addClass('fa-unlock'); - $('#jot-public').show(); - } - }).trigger('change'); -}); \ No newline at end of file + diff --git a/view/tpl/attach_edit.tpl b/view/tpl/attach_edit.tpl index 1098049bf..1d58004e5 100644 --- a/view/tpl/attach_edit.tpl +++ b/view/tpl/attach_edit.tpl @@ -1,4 +1,4 @@ -
+ @@ -16,10 +16,10 @@
- -
diff --git a/view/tpl/cloud_actionspanel.tpl b/view/tpl/cloud_actionspanel.tpl index 2c07f5ea7..0884cd0b4 100644 --- a/view/tpl/cloud_actionspanel.tpl +++ b/view/tpl/cloud_actionspanel.tpl @@ -9,10 +9,9 @@
{{if $quota.limit || $quota.used}}{{/if}} - + -
-- cgit v1.2.3 From b49cfb2efd05a46a830238e5dff703086ffc59c4 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 4 Aug 2016 10:46:50 +0200 Subject: multi acl: port /chat --- view/tpl/chatroom_new.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'view') diff --git a/view/tpl/chatroom_new.tpl b/view/tpl/chatroom_new.tpl index 94f694e41..1b7e0501a 100644 --- a/view/tpl/chatroom_new.tpl +++ b/view/tpl/chatroom_new.tpl @@ -1,5 +1,5 @@
-
+ {{include file="field_input.tpl" field=$name}} {{include file="field_input.tpl" field=$chat_expire}}
-- cgit v1.2.3 From 120e9a1e4c816eb629bc00dcf2324a26825479e0 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 4 Aug 2016 11:23:43 +0200 Subject: multi acl: port /webpages and /mitem --- view/tpl/mitemedit.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'view') diff --git a/view/tpl/mitemedit.tpl b/view/tpl/mitemedit.tpl index 865c587ec..a06203244 100644 --- a/view/tpl/mitemedit.tpl +++ b/view/tpl/mitemedit.tpl @@ -5,7 +5,7 @@
{{/if}} - {{$aclselect}}
+ {{$aclselect}}
{{if $header}} -- cgit v1.2.3 From 036b72757c0dd24cb468e5d02f717de9dffe67cb Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 4 Aug 2016 12:09:06 +0200 Subject: multi acl: port /wiki --- view/tpl/wiki.tpl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'view') diff --git a/view/tpl/wiki.tpl b/view/tpl/wiki.tpl index d9a4f8be3..c346bed60 100644 --- a/view/tpl/wiki.tpl +++ b/view/tpl/wiki.tpl @@ -29,7 +29,7 @@
-
+
+
-
-
{{$acl}}
-
-
+ {{$acl}} +
+