Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #38 from mena-devs/enhance-invitations-views
Browse files Browse the repository at this point in the history
Enhance invitations views
  • Loading branch information
cnicolaou authored Mar 29, 2020
2 parents 9db38ea + 27d7b87 commit 9c75ce3
Show file tree
Hide file tree
Showing 16 changed files with 175 additions and 289 deletions.
2 changes: 1 addition & 1 deletion app/controllers/invitations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def update
# PATCH/PUT /invitations/1/resend
def resend
if current_user.admin? && @invitation.resend_invitation
redirect_to invitations_path, notice: 'Invitation was resent.'
redirect_to list_invitations_admin_path, notice: 'Invitation was resent.'
else
render :index
end
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,8 @@ def directory_letters
end
letters.join('').html_safe
end

def authorised_admin?
(user_signed_in? && current_user.admin?)
end
end
4 changes: 0 additions & 4 deletions app/helpers/jobs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ def authorised_job_owner?(job)
(user_signed_in? && job.user_id == current_user.id)
end

def authorised_admin?
(user_signed_in? && current_user.admin?)
end

def job_status(job)
status = 'Job '

Expand Down
2 changes: 1 addition & 1 deletion app/views/directory/users/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
<br/>
<% end %>

<% if user_signed_in? && current_user.admin? %>
<% if authorised_admin? %>

<div class="alert alert-info" role="alert">
<h4>Details for Admins</h4>
Expand Down
2 changes: 1 addition & 1 deletion app/views/invitations/_admin_invitation.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<tr>
<td><%= admin_invitation.invitee_name %></td>
<td><%= admin_invitation.invitee_email %></td>
<td><%= admin_invitation.location_name %></td>
<td><%= admin_invitation.aasm_state.humanize %></td>
<td><%= admin_invitation.retries %></td>
<td><%= admin_invitation.updated_at.strftime("%d %b %Y") %></td>
<td><%= link_to("Resend", resend_invitation_path(admin_invitation), class: "button button-3d button-mini button-rounded button-red", method: :put) %></td>
<td><%= link_to("View", admin_invitation, class: "button button-3d button-mini button-rounded button-green") %></td>
</tr>
3 changes: 1 addition & 2 deletions app/views/invitations/_admin_invitations_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
<tr>
<th>Name</th>
<th>Email</th>
<th>Location</th>
<th>State</th>
<th>Retries</th>
<th>Sent on</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
</tr>
</thead>

<tbody>
<%= render partial: "admin_invitation", collection: @admin_invitations %>
</tbody>

</table>
</div>
9 changes: 4 additions & 5 deletions app/views/invitations/_invitation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
<%= fa_icon("check", text: "me") %>
<% end %>
</td>
<td><%= invitation.location_name %></td>
<td><%= display_invitation_state(invitation) %></td>
<td><%= invitation.retries %></td>
<td><%= invitation.updated_at.strftime("%d %b %Y") %></td>
<% if current_user.admin %>
<td><%= link_to "Resend", resend_invitation_path(invitation), class: "button button-3d button-mini button-rounded button-red", method: :put %></td>

<% if authorised_admin? %>
<td><%= link_to("Resend", resend_invitation_path(invitation), class: "button button-3d button-mini button-rounded button-red", method: :put) %></td>
<% end %>
<td><%= link_to("View", invitation, class: "button button-3d button-mini button-rounded button-green") %></td>
</tr>
2 changes: 0 additions & 2 deletions app/views/invitations/admin_index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
<%= paginate @admin_invitations %>
</div>
<% end %>

</div>

</div>

</section><!-- #content end -->
122 changes: 51 additions & 71 deletions app/views/invitations/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,84 +1,64 @@
<!-- Document Wrapper
============================================= -->
<div id="wrapper" class="clearfix">
<!-- Page Title
============================================= -->
<section id="page-title">
<!-- Page Title
============================================= -->
<section id="page-title">

<div class="container clearfix">
<div class="col-md-8 col-xs-12">
<h1>Slack Group sent invitations</h1>
<span class='hidden-xs'>Invitations sent to contacts to join MENAdevs Slack Group</span>
</div>
<div class="container clearfix">
<div class="row clearfix">
<div class="col-md-8 col-xs-12 nopadding">
<h1>Slack Group invitations</h1>
<span class='hidden-xs'>Invitations sent to your contacts</span>
</div>

<div class="col-md-4 hidden-xs">
<%= link_to new_invitation_path, :class => "button button-3d notopmargin fright" do %>
<%= fa_icon("plus", :text => "Invite") %>
<% end %>
</div>
<div class="col-md-4 hidden-xs">
<%= link_to new_invitation_path, :class => "button button-3d notopmargin fright" do %>
<%= fa_icon("plus", :text => "New invitation") %>
<% end %>
</div>
</div>
</div>

</section><!-- #page-title end -->
</section><!-- #page-title end -->

<%= content_for :flash %>
<%= content_for :flash %>

<!-- Content
============================================= -->
<section id="content">
<!-- Content
============================================= -->
<section id="content">

<div class="content-wrap">
<div class="content-wrap">

<div class="container clearfix">

<div class="table-responsive">
<% if @invitations.blank? %>
<div class="container clearfix">

<div class="alert alert-info alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<i class="icon-warning-sign"></i>You have sent 0 invitations
</div>
<div class="table-responsive">
<% if @invitations.blank? %>

<% else %>
<table id="invitations-datatable" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Location</th>
<th>State</th>
<th>Retries</th>
<th>Sent on</th>
<% if current_user.admin %>
<th>&nbsp;</th>
<% end %>
</tr>
</thead>
<tbody>
<%= render partial: "invitation", collection: @invitations %>
<div class="alert alert-info alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<i class="icon-warning-sign"></i>You have sent 0 invitations
</div>

<%= paginate @invitations %>
</tbody>
</table>
<% end %>
</div>
<% else %>
<table id="invitations-datatable" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>State</th>
<% if authorised_admin? %>
<th>&nbsp;</th>
<% end %>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<%= render partial: "invitation", collection: @invitations %>
</tbody>
</table>
<% end %>
</div>
<div class="center">
<%= paginate @invitations %>
</div>
</div>
</section><!-- #content end -->
</div>

<!-- Bootstrap Data Table Plugin -->
<%= javascript_include_tag "components/bs-datatable.js", "data-turbolinks-track" => false %>
<%= stylesheet_link_tag('bs-datatable', media: 'all',
'data-turbolinks-track': false) %>

<script>

$(document).ready(function() {
$('#invitations-datatable').dataTable(
{
aaSorting: [[5, 'desc']]
}
);
});

</script>
</div>
</section><!-- #content end -->
Loading

0 comments on commit 9c75ce3

Please sign in to comment.