Skip to content

Commit

Permalink
wth - (SPARCDashboard, SPARCRequest & Data) Admin Rate Label Change a…
Browse files Browse the repository at this point in the history
…nd Visual Cue

Background: Currently, the admin rate is an attribute on Line Item level. When an admin user set an admin rate on a service in a request, and then add the same service in SPARCFulfillment (which was not pushed from SPARCRequest), SPARCFulfillment considers it as a service with the normal rate rather than admin rate.

Please:

1). Make the format of the "Non-clinical Service" "Your Cost" editable field consistent with the other ones in SPARCDashboard Admin Edit Section “Clinical Services” Tab (see 2nd screenshot attached);

2). Add a visual cue (such as "(Modified)" sign or "M" icon with "Modified Rate" tooltip next to the cost in green color) for admin rate (SPARCRequest & SPARCDashboard).

The corresponding SPARCFulfillment story can be found here: https://www.pivotaltracker.com/story/show/156286625

[#156275541]

Story - https://www.pivotaltracker.com/story/show/156275541

fixed specs and yml

fix specs

fix specs
  • Loading branch information
wtholt committed Jul 30, 2018
1 parent abf1b77 commit c9cafc0
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ $ ->
url: "/dashboard/line_items/#{line_item_id}/edit"
data: data

$(document).on 'change', '.your-cost-edit', ->
row_index = $(this).parents('tr').data('index')
line_item_id = $(this).parents('table.study_level_activities').bootstrapTable('getData')[row_index].id
data = 'line_item': 'displayed_cost' : $(this).val().replace('$', '')
$.ajax
type: 'PATCH'
url: "/dashboard/line_items/#{line_item_id}"
data: data

$(document).on 'click', '.otf_delete', ->
row_index = $(this).parents('tr').data('index')
line_item_id = $(this).parents('table.study_level_activities').bootstrapTable('getData')[row_index].id
Expand Down Expand Up @@ -105,3 +96,12 @@ $ ->
$.ajax
type: 'DELETE'
url: "/dashboard/fulfillments/#{fulfillment_id}"

$(document).on 'load-success.bs.table', '.study_level_activities', ->
setup_xeditable_fields()

$('body').tooltip(
selector: '[data-title]'
delay: {show: 500}
)

14 changes: 14 additions & 0 deletions app/assets/javascripts/service_calendar.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,20 @@ $(document).ready ->
$('#sub_service_request_header').html(data['header'])
$('.selectpicker').selectpicker()

$('.your-cost').editable
display: (value) ->
# display field as currency, edit as quantity
$(this).text("$" + parseFloat(value).toFixed(2))
params: (params) ->
{
line_item:
displayed_cost: params.value
service_request_id: getSRId()
}
success: (response, newValue) ->
$('.study_level_activities').bootstrapTable('refresh', silent: true)


$('.edit-subject-count').editable
params: (params) ->
{
Expand Down
4 changes: 3 additions & 1 deletion app/helpers/dashboard/study_level_activities_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def sla_service_rate_display line_item
end

def sla_your_cost_field line_item
raw( text_field(:line_item, :service, class: 'your-cost-edit', value: number_with_precision(Service.cents_to_dollars(line_item.applicable_rate), precision: 2)) )
link_to 'javascript:void(0);', class: [("your-cost editable"), ('text-danger' if line_item.admin_rates.present?)], data: { url: dashboard_line_item_path(line_item), title: line_item.admin_rates.present? ? t(:dashboard)[:study_level_activities][:tooltips][:modified_rate] : t(:dashboard)[:study_level_activities][:tooltips][:admin_rate] }do
number_with_precision(Service.cents_to_dollars(line_item.applicable_rate), precision: 2)
end
end

def sla_options_buttons line_item
Expand Down
2 changes: 2 additions & 0 deletions config/locales/dashboard.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ en:
cost: "Cost:"
tooltips:
add_non_clinical_services: "Add Non-clinical services related to selected organization"
modified_rate: 'Modified Rate'
admin_rate: 'Admin Rate'

##########################
# SUB SERVICE REQUESTS #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,14 @@

context 'your cost' do
before :each do
find('.edit-your-cost.editable', match: :first).click
find('.your-cost.editable', match: :first).click
find('.editable-input input').set(100)
find('.editable-submit').click
wait_for_javascript_to_finish
end

it 'updates your cost' do
expect(page).to have_css('.edit-your-cost', text: '$100.00')
end

it 'should update header total cost' do
expect(page).to have_css('.display_cost', text: '$1,001.00')
expect(page).to have_css('.your-cost', text: '$100.00')
end
end
end
Expand All @@ -160,24 +156,6 @@
expect(page).to have_css('.display_cost', text: '$11.00')
end
end

context 'your cost' do
before :each do
find('.edit-your-cost.editable', match: :first).click
find('.editable-input input').set('a number')
find('.editable-submit').click
wait_for_javascript_to_finish
end

it 'should throw error' do
expect(page).to have_selector('.editable-error-block', visible: true)
expect(page).to have_content('Displayed Cost must be a number')
end

it 'should not update header total' do
expect(page).to have_css('.display_cost', text: '$11.00')
end
end
end
end

Expand Down

0 comments on commit c9cafc0

Please sign in to comment.