[Bps-public-commit] rt-extension-rightsdebugger branch, master, updated. 2e47852fa5f36cf2b9ec088eb6694fe399aa866d
Shawn Moore
shawn at bestpractical.com
Thu Feb 2 17:37:09 EST 2017
The branch, master has been updated
via 2e47852fa5f36cf2b9ec088eb6694fe399aa866d (commit)
from a845de52dff2231b732fac14d988b71250389553 (commit)
Summary of changes:
META.yml | 1 +
html/Admin/RightsDebugger/index.html | 10 ++++++++++
html/Helpers/RightsDebugger/Search | 12 ++++++++++++
lib/RT/Extension/RightsDebugger.pm | 2 ++
static/js/rights-debugger.js | 18 ++++++++++++++++++
5 files changed, 43 insertions(+)
create mode 100644 html/Helpers/RightsDebugger/Search
create mode 100644 static/js/rights-debugger.js
- Log -----------------------------------------------------------------
commit 2e47852fa5f36cf2b9ec088eb6694fe399aa866d
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Feb 2 22:36:42 2017 +0000
Add search form that on keystroke posts to AJAX helper
diff --git a/META.yml b/META.yml
index 2c98179..ceab63c 100644
--- a/META.yml
+++ b/META.yml
@@ -18,6 +18,7 @@ no_index:
directory:
- html
- inc
+ - static
requires:
perl: 5.10.1
resources:
diff --git a/html/Admin/RightsDebugger/index.html b/html/Admin/RightsDebugger/index.html
index 6ece378..c75b2ae 100644
--- a/html/Admin/RightsDebugger/index.html
+++ b/html/Admin/RightsDebugger/index.html
@@ -1,6 +1,16 @@
<& /Admin/Elements/Header, Title => loc("Rights Debugger") &>
<& /Elements/Tabs &>
+<form action="<%RT->Config->Get('WebPath')%>/Helpers/RightsDebugger/Search" id="rights-debugger">
+ <div class="search">
+ <input type="text" name="principal" placeholder="Principal">
+ <input type="text" name="object" placeholder="Object">
+ <input type="text" name="right" placeholder="Right">
+ </div>
+ <div class="results">
+ </div>
+</form>
+
<%INIT>
unless ($session{'CurrentUser'}->HasRight( Object=> RT->System, Right => 'SuperUser')) {
Abort(loc('This feature is only available to system administrators.'));
diff --git a/html/Helpers/RightsDebugger/Search b/html/Helpers/RightsDebugger/Search
new file mode 100644
index 0000000..ecd2ae5
--- /dev/null
+++ b/html/Helpers/RightsDebugger/Search
@@ -0,0 +1,12 @@
+<%ARGS>
+$Principal => ''
+$Object => ''
+$Right => ''
+</%ARGS>
+<%INIT>
+my @results;
+
+$r->content_type('application/json; charset=utf-8');
+$m->out(JSON({ results => \@results }));
+$m->abort;
+</%INIT>
diff --git a/lib/RT/Extension/RightsDebugger.pm b/lib/RT/Extension/RightsDebugger.pm
index cacb400..5029405 100644
--- a/lib/RT/Extension/RightsDebugger.pm
+++ b/lib/RT/Extension/RightsDebugger.pm
@@ -4,6 +4,8 @@ use warnings;
our $VERSION = '0.01';
+RT->AddJavaScript("rights-debugger.js");
+
=head1 NAME
RT-Extension-RightsDebugger -
diff --git a/static/js/rights-debugger.js b/static/js/rights-debugger.js
new file mode 100644
index 0000000..5e15ba0
--- /dev/null
+++ b/static/js/rights-debugger.js
@@ -0,0 +1,18 @@
+jQuery(function () {
+ var form = jQuery('form#rights-debugger');
+ var refreshResults = function () {
+ jQuery.ajax({
+ url: form.attr('action'),
+ data: form.serializeArray(),
+ timeout: 30000, /* 30 seconds */
+ success: function (response) {
+ },
+ error: function (xhr, reason) {
+ }
+ });
+ };
+
+ form.find('.search input').on('input', function () {
+ refreshResults();
+ });
+});
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list