[Rt-commit] rt 10/10: Prompt to automatically grant OwnDashboard rights on granting ModifySelf

sunnavy sunnavy at bestpractical.com
Fri Jul 9 16:45:34 EDT 2021


This is an automated email from the git hooks/post-receive script.

sunnavy pushed a commit to branch 5.0/use-dashboard-for-homepage-select-ui
in repository rt.

commit aed6117f96de3f310883522f16900adc1b34e1c0
Author: sunnavy <sunnavy at bestpractical.com>
AuthorDate: Sat Jul 10 03:39:31 2021 +0800

    Prompt to automatically grant OwnDashboard rights on granting ModifySelf
    
    Previously users can customize homepage with just "ModifySelf", this
    change can ease admin work by granting related rights all together.
---
 share/html/Admin/Elements/EditRights | 50 ++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/share/html/Admin/Elements/EditRights b/share/html/Admin/Elements/EditRights
index e60afa5343..d87e44b731 100644
--- a/share/html/Admin/Elements/EditRights
+++ b/share/html/Admin/Elements/EditRights
@@ -180,6 +180,29 @@ if ($anchor =~ /AddPrincipal/) {
               }
           }
       }
+
+    var auto_set_own_dashboards;
+    jQuery('input[value="ModifySelf"]').change(function() {
+        var form = jQuery(this).closest('form');
+        if ( jQuery(this).is(':checked') ) {
+            if ( form.find('input[value$="OwnDashboard"]:visible:not(:checked)').length ) {
+                jQuery('#grant-own-dashboard-rights-modal').modal('show');
+            }
+        }
+        else {
+            if ( auto_set_own_dashboards ) {
+                form.find('input[value$="OwnDashboard"]:visible:checked').prop('checked', false);
+                auto_set_own_dashboards = false;
+            }
+        }
+    });
+
+    jQuery('#grant-own-dashboard-rights-confirm').click(function() {
+        var form = jQuery(this).closest('form');
+        form.find('input[value$="OwnDashboard"]:visible:not(:checked)').prop('checked', true);
+        jQuery('#grant-own-dashboard-rights-modal').modal('hide');
+        auto_set_own_dashboards = true;
+    });
   });
 </script>
 
@@ -297,3 +320,30 @@ if ( $AddPrincipal ) {
     </div>
   </div>
 </div>
+
+<div class="modal" id="grant-own-dashboard-rights-modal">
+  <div class="modal-dialog" role="document">
+    <div class="modal-content">
+      <div class="modal-header">
+        <h5 class="modal-title"><&|/l&>Grant OwnDashboard rights too?</&></h5>
+        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+          <span aria-hidden="true">×</span>
+        </button>
+      </div>
+      <div class="modal-body">
+        <p>
+          <&|/l&>Users need these rights to fully customize their own "RT at a glance":</&>
+        </p>
+        <ul class="list-group-compact">
+%       for my $item ( qw/Create Delete Modify See/ ) {
+          <li class="list-group-item"><% $item %>OwnDashboard</li>
+%       }
+        </ul>
+      </div>
+      <div class="modal-footer">
+        <button type="button" class="btn btn-primary button" data-dismiss="modal"><&|/l&>Cancel</&></button>
+        <button type="button" class="btn btn-primary button" id="grant-own-dashboard-rights-confirm"><&|/l&>Yes</&></button>
+      </div>
+    </div>
+  </div>
+</div>

-- 
To stop receiving notification emails like this one, please contact
sysadmin at bestpractical.com.


More information about the rt-commit mailing list