Skip to content

Commit

Permalink
Merge pull request #416 from sparc-request/jw_epic_queue_bootstrap
Browse files Browse the repository at this point in the history
Jw epic queue bootstrap
  • Loading branch information
jwiel86 committed May 26, 2016
2 parents 5b5bbef + f13d7be commit 952899a
Show file tree
Hide file tree
Showing 17 changed files with 237 additions and 139 deletions.
8 changes: 5 additions & 3 deletions app/assets/javascripts/dashboard/epic_queues.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

$(document).ready ->
$(document).on 'click', '.delete-eq', ->

$('.epic-queue-table').bootstrapTable()

$(document).on 'click', '.delete-epic-queue-button', ->
if confirm(I18n['epic_queues']['confirm'])
eq_id = $(this).data('eq-id')
protocol_id = $(this).data('protocol-id')
eq_id = $(this).data('epic-queue-id')
$.ajax
type: 'DELETE'
url: "/dashboard/epic_queues/#{eq_id}.js"
Original file line number Diff line number Diff line change
Expand Up @@ -18,62 +18,11 @@
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Place all the styles related to the portal/epic_queues controller here.
// Place all the styles related to the notifications controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
.epic-queue-table {
table-layout: fixed;
width: 100%;
border-collapse: collapse;
font-family: arial;
margin:10px 0pt 15px;
text-align: left;
tr {
height: 40px;
}
tr.even {
background-color: #90B9CD !important;
color: white;
}
tr.odd {
background-color: white;
}
th {
border-right: 1px solid white;
padding: 4px 8px;
}
td {
border-right: 1px solid black;
padding: 4px 8px;
}
td.last, th.last {
border-right: none;
}
td.eq-protocol, th.eq-protocol {
width: 40%;
}
td.eq-protocol-PIs, th.eq-protocol-PIs {
width: 25%;
}
td.eq-date, th.eq-date {
width: 20%;
}
td.eq-status, th.eq-status {
width: 10%;
}
td.eq-delete, th.eq-delete {
width: 5%;
}
ul.eq-protocol-PIs-list {
list-style-type: none;
}
}

a.delete-eq {
width: 34px;
height: 34px;
background: url(/assets/dashboard/delete_red.png) no-repeat;
display: block;
}
#epic-queue-btn a
text-decoration: none
color: white
15 changes: 14 additions & 1 deletion app/controllers/dashboard/epic_queues_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@
class Dashboard::EpicQueuesController < Dashboard::BaseController

before_filter :get_epic_queue, only: [:destroy]
before_filter :authorize_overlord

def index
respond_to do |format|
format.html do
format.json do
@epic_queues = EpicQueue.all

render
end
format.html do
render
end
end
end

Expand All @@ -44,6 +48,15 @@ def destroy

private

# Check to see if user has rights to view epic queues
def authorize_overlord
unless QUEUE_EPIC_EDIT_LDAP_UIDS.include?(@user.ldap_uid)
@epic_queues = nil
@epic_queue = nil
render partial: 'service_requests/authorization_error', locals: { error: 'You do not have access to view the Epic Queues', in_dashboard: false }
end
end

def get_epic_queue
@epic_queue = EpicQueue.find(params[:id])
end
Expand Down
12 changes: 12 additions & 0 deletions app/helpers/dashboard/epic_queues_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ def format_protocol(protocol)
"#{protocol.type.capitalize}: #{protocol.id} - #{protocol.short_title}"
end

def format_pis(protocol)
protocol.principal_investigators.map(&:full_name).each do |pi|
"#{pi}"
end
end

def epic_queue_delete_button(epic_queue)
content_tag(:button,
raw(content_tag(:span, '', class: 'glyphicon glyphicon-remove', aria: { hidden: 'true' })),
type: 'button', data: { epic_queue_id: epic_queue.id, permission: 'true' }, class: "btn btn-danger actions-button delete-epic-queue-button")
end

def format_epic_queue_date(protocol)
date = protocol.last_epic_push_time
if date.present?
Expand Down
53 changes: 20 additions & 33 deletions app/views/dashboard/epic_queues/_epic_queue_list.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,23 @@
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
-# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%div
%table.epic-queue-table
%colgroup
%col
%col
%col
%col
%col.last
%thead
%tr{class: "even"}
%th{class: "eq-protocol", align: "left"}= t(:epic_queues)[:protocol]
%th{class: "eq-protocol-PIs", align: "left"}= t(:epic_queues)[:PIs]
%th{class: "eq-date", align: "left"}= t(:epic_queues)[:date]
%th{class: "eq-status", align: "left"}= t(:epic_queues)[:status]
%th.last{class: "eq-delete", align: "center"}= t(:epic_queues)[:delete]
%tbody
- row_index = 1
- @epic_queues.each do |eq|
- protocol = eq.protocol
%tr.epic-queue-protocol{class: row_index % 2 == 0 ? "even" : "odd"}
- row_index += 1
%td{class: "eq-protocol", align: "left"}
= format_protocol(protocol)
%td{class: "eq-protocol-PIs", align: "left"}
%ul{class: "eq-protocol-PIs-list"}
- protocol.principal_investigators.map(&:full_name).each do |pi|
%li{class: "#{protocol.id}-PI"}= pi
%td{class: "eq-date", align: "left"}
= format_epic_queue_date(protocol)
%td{class: "eq-status", align: "left"}
= format_status(protocol)
%td.last{class: "eq-delete", align: "center"}
%a{class: "delete-eq", title: "Delete Epic Queue", href: "javascript:void(0)", data: {eq_id: eq.id, protocol_id: protocol.id}}
.panel.panel-default#epic-queue-panel
.panel-heading
%h4.panel-title
= t(:dashboard)[:epic_queues][:header]
.panel-body
.bootstrap-table-dropdown-overflow
#epic-queues-custom-toolbar
%table.epic-queue-table{ data: { toggle: 'table', search: 'true', 'show-columns' => 'true', 'show-refresh' => 'true', 'show-toggle' => 'true', url: dashboard_epic_queues_path, striped: 'true', toolbar: '#epic-queues-custom-toolbar' } }
%thead.primary-header
%tr
%th{data: { field: "protocol", align: "left", sortable: 'true' } }
= t(:epic_queues)[:protocol]
%th{data: { field: "pis", align: "left", sortable: 'true' } }
= t(:epic_queues)[:PIs]
%th{data: { field: "date", align: "left", sortable: 'true' } }
= t(:epic_queues)[:date]
%th{data: { field: "status", align: "left", sortable: 'true' } }
= t(:epic_queues)[:status]
%th.last{data: { field: "delete", align: "center" } }
= t(:epic_queues)[:delete]
2 changes: 1 addition & 1 deletion app/views/dashboard/epic_queues/destroy.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

$("#epic-queue-container").replace_html('<%= escape_javascript(render(:partial => "epic_queue_list")).html_safe %>'
$('.epic-queue-table').bootstrapTable('refresh', silent: 'true')
9 changes: 0 additions & 9 deletions app/views/dashboard/epic_queues/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,5 @@
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
-# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.admin-right-dashboard
.user-information-body
%p
= @user.full_name
|
= @user.email
.admin-buttons
=link_to "Return to Dashboard", dashboard_root_path, :class => 'return_link'
%br
#epic-queue-container
= render :partial => 'epic_queue_list'
7 changes: 7 additions & 0 deletions app/views/dashboard/epic_queues/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
json.(@epic_queues) do |eq|
json.protocol format_protocol(eq.protocol)
json.pis format_pis(eq.protocol)
json.date format_epic_queue_date(eq.protocol)
json.status format_status(eq.protocol)
json.delete epic_queue_delete_button(eq)
end
2 changes: 1 addition & 1 deletion app/views/dashboard/notifications/_notifications.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
-# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.col-xs-12.tabs{role: 'tabpanel'}
.col-xs-2#notification_tabs{data: {selected: "inbox"}}
= render partial: "dashboard/notifications/dropdown", locals: { sub_service_request: sub_service_request, user: user, admin: admin }
= render partial: "dashboard/notifications/dropdown", locals: { sub_service_request: sub_service_request, user: user}
%hr
%button.btn.btn-primary.btn-block.notification_nav#notifications_inbox
%span.pull-left
Expand Down
3 changes: 3 additions & 0 deletions app/views/layouts/dashboard/_dashboard_header.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
= show_welcome_message(user)
%ul.nav.navbar-nav.navbar-right
%li
- if QUEUE_EPIC_EDIT_LDAP_UIDS.include?(user.ldap_uid)
%button.btn.btn-info.navbar-btn#epic-queue-btn{ type: 'button'}
= link_to t(:dashboard)[:navbar][:epic_queue], dashboard_epic_queues_path
%button.btn.btn-danger.navbar-btn#messages-btn{ type: 'button'}
= t(:dashboard)[:navbar][:messages]
%span.badge
Expand Down
3 changes: 2 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ en:
# EPIC QUEUES #
#################
epic_queues:

header: "Epic Queues"
##################
# FULFILLMENTS #
##################
Expand Down Expand Up @@ -354,6 +354,7 @@ en:
##########
navbar:
logged_in_as: "Logged in as "
epic_queue: "View Epic Queue"
messages: "Messages"

###########
Expand Down
32 changes: 25 additions & 7 deletions spec/controllers/dashboard/epic_queues/delete_destroy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,34 @@
allow(EpicQueue).to receive(:find).
with(@epic_queue.id.to_s).
and_return(@epic_queue)

log_in_dashboard_identity(obj: build_stubbed(:identity))
xhr :delete, :destroy, id: @epic_queue.id
end

it "should delete EpicQueue from params[:id]" do
expect(@epic_queue).to have_received(:destroy)
describe "for overlord users" do
before(:each) do
log_in_dashboard_identity(obj: build(:identity, ldap_uid: 'jug2'))
xhr :delete, :destroy, id: @epic_queue.id
end

it "should delete EpicQueue from params[:id]" do
expect(@epic_queue).to have_received(:destroy)
end

it { is_expected.to render_template "dashboard/epic_queues/destroy"}
it { is_expected.to respond_with :ok }
end

it { is_expected.to render_template "dashboard/epic_queues/destroy"}
it { is_expected.to respond_with :ok }
describe "for creepy hacker doods" do
before(:each) do
log_in_dashboard_identity(obj: build_stubbed(:identity))
xhr :delete, :destroy, id: @epic_queue.id
end

it "should not delete the EpicQueue from params[:id]" do
expect(@epic_queue).to_not have_received(:destroy)
end

it { is_expected.to_not render_template "dashboard/epic_queues/destroy"}
it { is_expected.to respond_with 200 }
end
end
end
32 changes: 25 additions & 7 deletions spec/controllers/dashboard/epic_queues/get_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,34 @@
before(:each) do
@all_epic_queues = instance_double(ActiveRecord::Relation)
allow(EpicQueue).to receive(:all).and_return(@all_epic_queues)

log_in_dashboard_identity(obj: build_stubbed(:identity))
get :index
end

it "should put all EpicQueues in @epic_queues" do
expect(assigns(:epic_queues)).to eq(@all_epic_queues)
describe "for overlord users" do
before(:each) do
log_in_dashboard_identity(obj: build(:identity, ldap_uid: 'jug2'))
get :index, format: :json
end

it "should put all EpicQueues in @epic_queues" do
expect(assigns(:epic_queues)).to eq(@all_epic_queues)
end

it { is_expected.to render_template "dashboard/epic_queues/index" }
it { is_expected.to respond_with 200 }
end

it { is_expected.to render_template "dashboard/epic_queues/index" }
it { is_expected.to respond_with :ok }
describe "for creepy hacker doods" do
before(:each) do
log_in_dashboard_identity(obj: build_stubbed(:identity))
get :index, format: :json
end

it "should put all EpicQueues in @epic_queues" do
expect(assigns(:epic_queues)).to_not eq(@all_epic_queues)
end

it { is_expected.to_not render_template "dashboard/epic_queues/index" }
it { is_expected.to respond_with 200 }
end
end
end

0 comments on commit 952899a

Please sign in to comment.