From 0cea6d31a44df88def2f0fb1203157aaf93f1412 Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Wed, 23 Feb 2022 12:06:29 +0200 Subject: [PATCH 1/2] admin UI report custom cdrs - fix date_start/date_end form inputs fill via set range --- app/admin/reports/custom_cdrs.rb | 2 +- .../custom_cdrs/new_custom_cdr_spec.rb | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/admin/reports/custom_cdrs.rb b/app/admin/reports/custom_cdrs.rb index 12000028c..f53f94384 100644 --- a/app/admin/reports/custom_cdrs.rb +++ b/app/admin/reports/custom_cdrs.rb @@ -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 diff --git a/spec/features/reports/custom_cdrs/new_custom_cdr_spec.rb b/spec/features/reports/custom_cdrs/new_custom_cdr_spec.rb index 73f02991b..ac5032f8f 100644 --- a/spec/features/reports/custom_cdrs/new_custom_cdr_spec.rb +++ b/spec/features/reports/custom_cdrs/new_custom_cdr_spec.rb @@ -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() From 720d9dcab82f519047c55aad06bb0c7d6fcedf75 Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Wed, 23 Feb 2022 12:22:40 +0200 Subject: [PATCH 2/2] admin UI report custom cdrs - fix filters on custom items index add filter completed to custom cdrs index and to custom cdr sidebar on custom items --- app/admin/reports/custom_cdrs.rb | 2 +- app/admin/reports/custom_data.rb | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/admin/reports/custom_cdrs.rb b/app/admin/reports/custom_cdrs.rb index f53f94384..f345c4a6c 100644 --- a/app/admin/reports/custom_cdrs.rb +++ b/app/admin/reports/custom_cdrs.rb @@ -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 diff --git a/app/admin/reports/custom_data.rb b/app/admin/reports/custom_data.rb index 3261dde57..b51605569 100644 --- a/app/admin/reports/custom_data.rb +++ b/app/admin/reports/custom_data.rb @@ -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 @@ -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