Skip to content

Commit

Permalink
Merge pull request #1117 from senid231/improve-report-custom-cdr-admi…
Browse files Browse the repository at this point in the history
…n-ui

Improve report custom cdr admin UI
  • Loading branch information
dmitry-sinina authored Feb 23, 2022
2 parents 78fdaa4 + 720d9dc commit 0cb87eb
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/admin/reports/custom_cdrs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def create
form do |f|
f.semantic_errors *f.object.errors.attribute_names
f.inputs do
f.input :date_start, as: :date_time_picker
f.input :date_start, as: :date_time_picker, wrapper_html: { class: 'datetime_preset_pair', data: { show_time: 'true' } }
f.input :date_end, as: :date_time_picker
f.contractor_input :customer_id, label: 'Customer', path_params: { q: { customer_eq: true } }
f.input :filter
Expand All @@ -64,7 +64,7 @@ def create
end

filter :id
# boolean_filter :completed
boolean_filter :completed
filter :date_start, as: :date_time_range
filter :date_end, as: :date_time_range
filter :created_at, as: :date_time_range
Expand Down
23 changes: 22 additions & 1 deletion app/admin/reports/custom_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
div class: :report_sidebar_info do
attributes_table_for assigns[:custom_cdr] do
row :id
row :completed
row :date_start
row :date_end
row :filter
Expand All @@ -39,11 +40,31 @@
end
end

assoc_filter_columns = Report::CustomData::CDR_COLUMNS - %i[destination_id dialpeer_id]
assoc_filter_columns = Report::CustomData::CDR_COLUMNS - %i[destination_id dialpeer_id customer_id vendor_id vendor_acc_id customer_acc_id]
assoc_filter_columns.each do |key|
filter key.to_s[0..-4].to_sym,
if: proc { @custom_cdr.group_by_include? key },
input_html: { class: 'chosen' }

contractor_filter :customer_id_eq,
label: 'Customer',
path_params: { q: { customer_eq: true } },
if: proc { @custom_cdr.group_by_include?(:customer_id) }

contractor_filter :vendor_id_eq,
label: 'Vendor',
path_params: { q: { vendor_eq: true } },
if: proc { @custom_cdr.group_by_include?(:vendor_id) }

account_filter :customer_acc_id_eq,
label: 'Customer Acc',
path_params: { q: { contractor_customer_eq: true } },
if: proc { @custom_cdr.group_by_include?(:customer_acc_id) }

account_filter :vendor_acc_id_eq,
label: 'Vendor Acc',
path_params: { q: { contractor_vendor_eq: true } },
if: proc { @custom_cdr.group_by_include?(:vendor_acc_id) }
end

controller do
Expand Down
20 changes: 20 additions & 0 deletions spec/features/reports/custom_cdrs/new_custom_cdr_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@

include_examples :creates_custom_cdr_report

context 'with set range date_start date_end' do
let(:fill_form!) do
fill_in_chosen 'Group by', with: 'customer_id', no_search: true
within_form_for { click_link 'Set range' }
within('.block_timerange') { click_on_text 'This Week' }
end
let(:expected_service_params) do
{
date_start: Time.zone.now.beginning_of_week,
date_end: Time.zone.now.next_week,
group_by: %w[customer_id],
filter: nil,
customer: nil,
send_to: nil
}
end

include_examples :creates_custom_cdr_report
end

context 'with customer' do
let(:fill_form!) do
super()
Expand Down

0 comments on commit 0cb87eb

Please sign in to comment.