Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wth - (SPARCDashboard, SPARCRequest & Data) Admin Rate Label Change a… #1442

Merged
merged 2 commits into from
Aug 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good idea. At some point we should streamline our tooltips to do this using a global JS function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. The only reason I came across this was because tooltips and x-editable fields don't play nicely. Reason being the data: { toggle: 'tooltip' } part

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
4 changes: 2 additions & 2 deletions app/models/available_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ def disabled_status?
end

def self.statuses
@statuses ||= PermissibleValue.get_hash('status')
@statuses ||= PermissibleValue.order(:sort_order).get_hash('status')
end

def self.defaults
@defaults ||= PermissibleValue.get_key_list('status', true)
@defaults ||= PermissibleValue.order(:sort_order).get_key_list('status', true)
end

def humanize
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