[Bps-public-commit] RT-Extension-FeaturedTickets branch, master, updated. ad06d2c9cfce8af01096fc1e658c7b0664be505f
Craig Kaiser
craig at bestpractical.com
Mon Mar 19 15:17:58 EDT 2018
The branch, master has been updated
via ad06d2c9cfce8af01096fc1e658c7b0664be505f (commit)
from b0580ace39093a8e249dd46f5ccbddb61331fe8e (commit)
Summary of changes:
html/NoAuth/Featured/index.html | 182 +++++++++++++++++++++++++++++++---------
1 file changed, 141 insertions(+), 41 deletions(-)
- Log -----------------------------------------------------------------
commit ad06d2c9cfce8af01096fc1e658c7b0664be505f
Author: craig Kaiser <craig at bestpractical.com>
Date: Mon Mar 19 15:17:00 2018 -0400
Pop-up option for details on featured ticket
diff --git a/html/NoAuth/Featured/index.html b/html/NoAuth/Featured/index.html
index ce05e7b..2d70093 100644
--- a/html/NoAuth/Featured/index.html
+++ b/html/NoAuth/Featured/index.html
@@ -1,3 +1,5 @@
+% use JSON qw(encode_json);
+
<!doctype html>
<html lang="en">
<head>
@@ -25,6 +27,44 @@
<script src="http://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7/html5shiv.js"></script>
<![endif]-->
<!-- Add google analytics tags here -->
+ <style>
+ .modal {
+ display: none; /* Hidden by default */
+ position: fixed; /* Stay in place */
+ z-index: 1; /* Sit on top */
+ left: 0;
+ top: 0;
+ width: 100%; /* Full width */
+ height: 100%; /* Full height */
+ overflow: auto; /* Enable scroll if needed */
+ background-color: rgb(0,0,0); /* Fallback color */
+ background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
+ }
+
+ /* Modal Content/Box */
+ .modal-content {
+ background-color: #fefefe;
+ margin: 15% auto; /* 15% from the top and centered */
+ padding: 20px;
+ border: 1px solid #888;
+ width: 80%; /* Could be more or less, depending on screen size */
+ }
+
+ /* The Close Button */
+ .close {
+ color: #aaa;
+ float: right;
+ font-size: 28px;
+ font-weight: bold;
+ }
+
+ .close:hover,
+ .close:focus {
+ color: black;
+ text-decoration: none;
+ cursor: pointer;
+ }
+ </style>
</head>
<body>
@@ -38,6 +78,61 @@
Sponsor a feature or fix
</h1>
</div>
+
+<!-- The Modal -->
+<div id="myModal" class="modal">
+ <!-- Modal content -->
+ <div class="modal-content">
+ <div id='sponsor-subject'></div>
+ <div id='sponsor-details'></div>
+ <div id='sponsor-goal'></div>
+
+ <div>
+ <p>I Want To Contribute</p>
+ <form action="/NoAuth/Featured">
+ <input placeholder="Name" name="Name" type="text">
+ <input placeholder="Email" type="email" name="Email" required>
+ <input placeholder="Contribution Amount" name="Amount">
+ <input name="ticket_id" id='ticket_id' type="hidden">
+ <input type="submit" name="Sponsor" value="Submit">
+ </form>
+ </div>
+ </div>
+</div>
+
+<script>
+ // Get the modal
+ var modal = document.getElementById('myModal');
+
+ // Get the button that opens the modal
+ var btn = document.getElementById("myBtn");
+
+ // Get the <span> element that closes the modal
+ var span = document.getElementsByClassName("close")[0];
+
+ function detailsClicked( args ) {
+ var subject = document.getElementById('sponsor-subject');
+ var details = document.getElementById('sponsor-details');
+ var goal = document.getElementById('sponsor-goal');
+ var ticket_id = document.getElementById('ticket_id');
+
+ subject.innerHTML = args['Subject'];
+ details.innerHTML = args['Details'];
+ goal.innerHTML = args['Goal'];
+
+ ticket_id.value = args['ticket_id'];
+
+ modal.style.display = "block";
+ }
+
+ // When the user clicks anywhere outside of the modal, close it
+ window.onclick = function(event) {
+ if (event.target == modal) {
+ modal.style.display = "none";
+ }
+ }
+</script>
+
<div class="l-content">
<div class="pricing-tables pure-g">
% while ( my $ticket = $tickets->Next ) {
@@ -55,9 +150,8 @@
<li>Funded!</li>
% }
</ul>
- <form action="/NoAuth/Featured/Details.html">
- <button type="submit" class="button-choose pure-button" name="ticket_id" value="<% $ticket->Id %>">Details</button>
- </form>
+% my $args = {'ticket_id' => $ticket->Id, 'Subject' => $ticket->Subject, 'Goal' => $ticket->FirstCustomFieldValue('Goal'), 'Details' => $ticket->FirstCustomFieldValue('Details') };
+ <button onclick="detailsClicked(<% encode_json( $args ) %>)" type="submit" class="button-choose pure-button" value="<% $ticket->Id %>" name="ticket_id">Details</button>
</div>
</div>
%}
@@ -133,54 +227,60 @@ if( $ARGS{Email} ){
my $parent_ticket = RT::Ticket->new(RT->SystemUser);
($ret, $msg) = $parent_ticket->Load( $ARGS{ticket_id} );
- # THIS RETURN WILL CAUSE WHITESCREEN IF INVALID ID WITH ARGS
- return ($ret, $msg) unless $ret;
- my $sponsors = RT::CustomRole->new(RT->SystemUser);
- ($ret, $msg) = $sponsors->Load( 'Sponsors' );
- return ($ret, $msg) unless $ret;
+ # If ticket fails to load, just load the page - bogus id
+ if ( $ret ) {
- my $user = RT::User->new(RT->SystemUser);
- ($ret, $msg) = $user->LoadByEmail($ARGS{Email});
+ my $sponsors = RT::CustomRole->new(RT->SystemUser);
+ ($ret, $msg) = $sponsors->Load( 'Sponsors' );
+ return ($ret, $msg) unless $ret;
- if ( !$ret ) {
- my ($ret, $msg) = $user->Create(
- RealName => $ARGS{Name},
- EmailAddress => $ARGS{Email},
- );
- return ($ret, $msg) unless $ret;
- }
+ my $user = RT::User->new(RT->SystemUser);
+ ($ret, $msg) = $user->LoadByEmail($ARGS{Email});
- if ( $ARGS{Amount} > 0 ) {
- ($ret, $msg) = $ticket->Create(
- Subject => $ARGS{Name} . " Sponsor Ticket For ". $parent_ticket->Subject,
- Queue => $queue->Name,
- DependedOnBy => $ARGS{ticket_id},
- 'CustomField-' . $ticket->LoadCustomFieldByIdentifier('Amount')->Id => $ARGS{Amount},
- );
- RT::Logger->error('Could Not Create Linked Ticket') unless $ret;
+ if ( !$ret ) {
+ my ($ret, $msg) = $user->Create(
+ RealName => $ARGS{Name},
+ EmailAddress => $ARGS{Email},
+ );
+ return ($ret, $msg) unless $ret;
+ }
- ($ret, $msg) = $ticket->AddWatcher( Type => $sponsors->GroupType, PrincipalId => $user->id );
- RT::Logger->error('Couldn\'t Add user as new sponsor') unless $ret;
- }
+ if ( $ARGS{Amount} > 0 ) {
+ ($ret, $msg) = $ticket->Create(
+ Subject => $ARGS{Name} . " Sponsor Ticket For: \"". $parent_ticket->Subject ."\"",
+ Queue => $queue->Name,
+ DependedOnBy => $ARGS{ticket_id},
+ 'CustomField-' . $ticket->LoadCustomFieldByIdentifier('Amount')->Id => $ARGS{Amount},
+ );
+ RT::Logger->error('Could Not Create Linked Ticket') unless $ret;
- ($ret, $msg) = $parent_ticket->AddWatcher( Type => $sponsors->GroupType, PrincipalId => $user->id );
- RT::Logger->debug('Couldn\'t Add user as new sponsor') unless $ret;
+ ($ret, $msg) = $ticket->AddWatcher( Type => $sponsors->GroupType, PrincipalId => $user->id );
+ RT::Logger->error('Couldn\'t Add user as new sponsor') unless $ret;
+ }
- my $new_amount = $ARGS{Amount} + $parent_ticket->FirstCustomFieldValue('Amount');
+ ($ret, $msg) = $parent_ticket->AddWatcher( Type => $sponsors->GroupType, PrincipalId => $user->id );
+ RT::Logger->debug('Couldn\'t Add user as new sponsor') unless $ret;
- ($ret, $msg) = $parent_ticket->AddCustomFieldValue( Field => $parent_ticket->LoadCustomFieldByIdentifier('Amount')->Id, Value => $new_amount );
- RT::Logger->error('Could Not Set Parent Ticket New Amount Value') unless $ret;
+ my $new_amount = $ARGS{Amount} + $parent_ticket->FirstCustomFieldValue('Amount');
- if ( $new_amount >= $parent_ticket->FirstCustomFieldValue('Goal') ) {
- ($ret, $msg) = $parent_ticket->AddCustomFieldValue( Field => $parent_ticket->LoadCustomFieldByIdentifier('Funded')->Id, Value => 'Funded' );
- RT::Logger->error('Funded Value Updated') unless $ret;
- }
+ ($ret, $msg) = $parent_ticket->AddCustomFieldValue( Field => $parent_ticket->LoadCustomFieldByIdentifier('Amount')->Id, Value => $new_amount );
+ RT::Logger->error('Could Not Set Parent Ticket New Amount Value') unless $ret;
+
+ if ( $new_amount >= $parent_ticket->FirstCustomFieldValue('Goal') ) {
+ ($ret, $msg) = $parent_ticket->AddCustomFieldValue( Field => $parent_ticket->LoadCustomFieldByIdentifier('Funded')->Id, Value => 'Funded' );
+ RT::Logger->error('Failed To Updated Funded Custom Field') unless $ret;
+ }
- ($ret, $msg) = $parent_ticket->Comment(
- Content => 'New sponsor ' . $ARGS{Email} . ', has committed $' . $ARGS{Amount},
- );
- RT::Logger->error('Could not comment on Ticket') unless $ret;
+ ($ret, $msg) = $parent_ticket->Comment(
+ Content => 'New sponsor ' . $ARGS{Email} . ', has committed $' . $ARGS{Amount},
+ );
+ RT::Logger->error('Could not comment on Ticket') unless $ret;
+ }
}
</%init>
+
+<%args>
+$ticket_id => undef
+</%args>
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list