Skip to content

Commit

Permalink
Merge pull request #168 from sparc-request/jl-move-fulfillment-buttons
Browse files Browse the repository at this point in the history
Jl move fulfillment buttons
  • Loading branch information
jleonardw9 committed May 13, 2016
2 parents 5d08349 + 5c74029 commit 1f6a4e2
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 55 deletions.
22 changes: 1 addition & 21 deletions app/assets/javascripts/study_level_activities.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,6 @@ $ ->
type: "DELETE"
url: "/line_items/#{line_item_id}"

$(document).on 'click', '.otf_fulfillments', ->
selected_row = $(this).parents("tr")
fulfillments_row = $("#fulfillments_row") #already displayed
span = $(this).children('.glyphicon')
line_item_id = $(this).parents("table.study_level_activities").bootstrapTable("getData")[selected_row.data("index")].id
fulfillments_already_displayed = fulfillments_row.attr('data-line_item_id') == "#{line_item_id}"

fulfillments_row.prev('tr').first().find('.glyphicon-chevron-down').removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-right").parents(".otf_fulfillments").attr('data-original-title', 'View Fulfillment Buttons')
fulfillments_row.remove()
unless fulfillments_already_displayed
span.removeClass("glyphicon-chevron-right").addClass("glyphicon-refresh")
$(this).parents("tr").after("<tr id='fulfillments_row'></tr>")
line_item_id = $(this).data('line-item-id')
$.ajax
type: 'GET'
url: "/fulfillments/#{line_item_id}"
else
$(this).attr('data-original-title', 'View Fulfillment Buttons')
span.removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-right")

# Fulfillment Bindings

$(document).on 'click', '.otf_fulfillment_new', ->
Expand All @@ -65,7 +45,7 @@ $ ->
url: "/fulfillments/new"
data: data

$(document).on 'click', '.otf_fulfillment_list', ->
$(document).on 'click', '.otf-fulfillment-list', ->
line_item_id = $(this).data('line-item-id')
data = line_item_id: line_item_id
$.ajax
Expand Down
4 changes: 2 additions & 2 deletions app/assets/stylesheets/study_level_activities.sass
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
td.wrap
word-break: break-all

.otf_fulfillment_new
margin-right: 10px
.center-block
text-align: center
4 changes: 0 additions & 4 deletions app/controllers/fulfillments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ def index
end
end

def show
@line_item = LineItem.find(params[:id])
end

def new
@line_item = LineItem.find(params[:line_item_id])
@clinical_providers = ClinicalProvider.where(organization_id: @line_item.protocol.sub_service_request.organization_id)
Expand Down
6 changes: 2 additions & 4 deletions app/helpers/study_level_activities_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ def sla_options_buttons line_item
raw content_tag(:div, button + ul, class: 'btn-group overflow_webkit_button')
end

def fulfillments_drop_button line_item_id
content_tag(:button, class: 'btn btn-primary btn-sm otf_fulfillments list', title: t(:fulfillment)[:view], type: "button", aria: {label: "Fulfillments List"}, data: {line_item_id: line_item_id, toggle: "tooltip", animation: 'false'}) do
content_tag(:span, '', class: "glyphicon glyphicon-chevron-right", aria: {hidden: "true"})
end
def fulfillments_drop_button line_item
button = raw content_tag(:button, 'List', id: "list-#{line_item.id}", type: 'button', class: 'btn btn-success otf-fulfillment-list', title: 'List', type: "button", aria: {label: "List Fulfillments"}, data: {line_item_id: line_item.id})
end

def fulfillment_components_dropdown components=Array.new
Expand Down
1 change: 1 addition & 0 deletions app/views/fulfillments/create.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ if $("#modal_errors > .alert.alert-danger > p").length == 0
$("#fulfillments_row").prev('tr').find('.qty_rem').text("<%= @line_item.quantity_remaining %>")
$("#fulfillments_row").prev('tr').find('.last_fulfillment').text("<%= format_date(@line_item.last_fulfillment) %>")
$("#modal_place").modal 'hide'
$("#list-<%= @line_item.id %>").trigger('click')
2 changes: 0 additions & 2 deletions app/views/fulfillments/index.js.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
$("#fulfillments_row").attr('data-line_item_id', "<%= @line_item.id %>")
$("#fulfillments_row").html("<%= escape_javascript(render(:partial =>'study_level_activities/fulfillment_buttons', locals: {line_item: @line_item})) %>");
$("#fulfillments_row").prev("tr").first().find(".otf_fulfillments > .glyphicon").removeClass("glyphicon-refresh").addClass("glyphicon-chevron-down").parents("button").attr('data-original-title', 'Hide Fulfillment Buttons')
$("#modal_area").html("<%= escape_javascript(render(:partial =>'study_level_activities/fulfillments_table', locals: {line_item: @line_item, header_text: 'Fulfillments List'})) %>");
$("#modal_place").modal 'show'
$("#fulfillments-table").bootstrapTable()
3 changes: 0 additions & 3 deletions app/views/fulfillments/show.js.coffee

This file was deleted.

1 change: 1 addition & 0 deletions app/views/fulfillments/update.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ if $("#modal_errors > .alert.alert-danger > p").length == 0
$("#fulfillments_row").prev('tr').find('.qty_rem').text("<%= @line_item.quantity_remaining %>")
$("#fulfillments_row").prev('tr').find('.last_fulfillment').text("<%= format_date(@line_item.last_fulfillment) %>")
$("#modal_place").modal 'hide'
$("#list-<%= @line_item.id %>").trigger('click')
2 changes: 1 addition & 1 deletion app/views/line_items/_study_level_activity.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ json.date_started format_date(line_item.started_at)
json.service_components sla_components_select(line_item.id, line_item.components.with_deleted)
json.last_fulfillment format_date(line_item.last_fulfillment)
json.options sla_options_buttons(line_item)
json.fulfillments_button fulfillments_drop_button(line_item.id)
json.fulfillments_button fulfillments_drop_button(line_item)

This file was deleted.

11 changes: 9 additions & 2 deletions app/views/study_level_activities/_fulfillments_table.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
%button.close{type: 'button', data: {dismiss: 'modal'}}
%span{aria: {hidden:'true'}} &times;
%span.sr-only= t(:actions)[:close]
%h4.modal-title.text-center= header_text
%h4.modal-title.text-center
= header_text
.modal-body
%td{colspan: 11}
.bootstrap-table-dropdown-overflow
Expand All @@ -23,4 +24,10 @@
%th{data: {class: 'components', align: "center", field: "components"}}
= t(:fulfillment)[:components]
%th{data: {class: 'options', align: "center", field: "options"}}
= t(:actions)[:actions]
= t(:actions)[:actions]
.modal-footer
.center-block
%button.btn.btn-default{type: 'button', data: {dismiss: 'modal'}}
= t(:actions)[:close]
%button.btn.btn-success.otf_fulfillment_new{type: "button", "aria-label" => "Add Fulfillment", data: {line_item_id: line_item.id}}
= t(:fulfillment)[:add_fulfillment]
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ en:

fulfillment:
object: "Fulfillment"
add_fulfillment: "Add"
add_fulfillment: "Add Fulfillment"
list_fulfillments: "List"
components: "Fulfillment Components"
edit: "Edit Fulfillment"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
it 'should list the fulfillments' do
given_i_have_fulfillments
and_i_have_opened_up_fulfillments
click_button "List"
wait_for_ajax
expect(page).to have_content('Fulfillments List')
end
end
Expand All @@ -17,7 +15,7 @@
given_i_have_fulfillments
count = @line_item.fulfillments.count
and_i_have_opened_up_fulfillments
click_button "Add"
click_button "Add Fulfillment"
wait_for_ajax
when_i_fill_out_the_fulfillment_form
expect(page).to have_content('Fulfillment Created')
Expand All @@ -43,7 +41,7 @@ def and_i_have_opened_up_fulfillments
wait_for_ajax
click_link "Study Level Activities"
wait_for_ajax
first('.otf_fulfillments.list').click
first('.otf-fulfillment-list').click
wait_for_ajax
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ def when_i_open_up_a_new_line_item_note
end

def when_i_open_up_a_new_fulfillment_note
first('.otf_fulfillments.list').click
wait_for_ajax
click_button 'List'
first('.otf-fulfillment-list').click
wait_for_ajax
first("#fulfillments-table .available-actions-button").click
wait_for_ajax
Expand Down

0 comments on commit 1f6a4e2

Please sign in to comment.