From 4af630967c5194c6266dc2db595ef2376ba534e8 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 5 Nov 2019 15:21:31 +0200 Subject: [PATCH 1/6] Extract partial --- .../account_activities/_search_form.html.haml | 36 ++++++++++++++++++ app/views/admin/account_activities/index.haml | 37 +------------------ .../locales/admin/account_activities.en.yml | 2 +- 3 files changed, 38 insertions(+), 37 deletions(-) create mode 100644 app/views/admin/account_activities/_search_form.html.haml diff --git a/app/views/admin/account_activities/_search_form.html.haml b/app/views/admin/account_activities/_search_form.html.haml new file mode 100644 index 000000000..d022542b1 --- /dev/null +++ b/app/views/admin/account_activities/_search_form.html.haml @@ -0,0 +1,36 @@ +.row + .col-md-12 + = search_form_for @q, url: [:admin, :account_activities], html: { style: 'margin-bottom: 0;' } do |f| + .row + .col-md-12 + .form-group + = f.label t(:registrar_name) + = f.select :account_registrar_id_in, Registrar.all.map { |x| [x, x.id] }, {}, class: 'form-control js-combobox', placeholder: t(:choose), multiple: true + .row + .col-md-6 + .form-group + = f.label t(:activity_type) + = f.select :activity_type_in, AccountActivity.types_for_select, {}, class: 'form-control js-combobox', placeholder: t(:choose), multiple: true + .col-md-6 + .form-group + = f.label t(:description) + = f.search_field :description_cont, class: 'form-control', placeholder: t(:description), autocomplete: 'off' + .row + .col-md-3 + .form-group + = f.label t(:receipt_date_from) + = f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_from) + .col-md-3 + .form-group + = f.label t(:receipt_date_until) + = f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_until) + .col-md-3 + .form-group + = label_tag t(:results_per_page) + = text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) + .col-md-3{style: 'padding-top: 25px;'} + %button.btn.btn-default.search +   + %span.glyphicon.glyphicon-search +   + = link_to(t('.reset_btn'), admin_account_activities_path, class: 'btn btn-default') diff --git a/app/views/admin/account_activities/index.haml b/app/views/admin/account_activities/index.haml index 1f201f255..df84b2757 100644 --- a/app/views/admin/account_activities/index.haml +++ b/app/views/admin/account_activities/index.haml @@ -2,43 +2,8 @@ = link_to(t(:export_csv), url_for(params.merge(format: 'csv')), class: 'btn btn-default') = render 'shared/title', name: t(:account_activities) += render 'search_form' -.row - .col-md-12 - = search_form_for @q, url: [:admin, :account_activities], html: { style: 'margin-bottom: 0;' } do |f| - .row - .col-md-12 - .form-group - = f.label t(:registrar_name) - = f.select :account_registrar_id_in, Registrar.all.map { |x| [x, x.id] }, {}, class: 'form-control js-combobox', placeholder: t(:choose), multiple: true - .row - .col-md-6 - .form-group - = f.label t(:activity_type) - = f.select :activity_type_in, AccountActivity.types_for_select, {}, class: 'form-control js-combobox', placeholder: t(:choose), multiple: true - .col-md-6 - .form-group - = f.label t(:description) - = f.search_field :description_cont, class: 'form-control', placeholder: t(:description), autocomplete: 'off' - .row - .col-md-3 - .form-group - = f.label t(:receipt_date_from) - = f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_from) - .col-md-3 - .form-group - = f.label t(:receipt_date_until) - = f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_until) - .col-md-3 - .form-group - = label_tag t(:results_per_page) - = text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) - .col-md-3{style: 'padding-top: 25px;'} - %button.btn.btn-default.search -   - %span.glyphicon.glyphicon-search -   - = link_to(t('.reset_btn'), admin_account_activities_path, class: 'btn btn-default') .row .col-md-3 .col-md-3 diff --git a/config/locales/admin/account_activities.en.yml b/config/locales/admin/account_activities.en.yml index 2e91e7a8f..2006f2f36 100644 --- a/config/locales/admin/account_activities.en.yml +++ b/config/locales/admin/account_activities.en.yml @@ -1,5 +1,5 @@ en: admin: account_activities: - index: + search_form: reset_btn: Reset From 8861b7c535eb46e42ec6196cdcd9a202cf616abb Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 5 Nov 2019 15:29:17 +0200 Subject: [PATCH 2/6] Convert HAML to ERB --- .../account_activities/_search_form.html.erb | 62 +++++++++++++++++++ .../account_activities/_search_form.html.haml | 36 ----------- 2 files changed, 62 insertions(+), 36 deletions(-) create mode 100644 app/views/admin/account_activities/_search_form.html.erb delete mode 100644 app/views/admin/account_activities/_search_form.html.haml diff --git a/app/views/admin/account_activities/_search_form.html.erb b/app/views/admin/account_activities/_search_form.html.erb new file mode 100644 index 000000000..ddd587bb2 --- /dev/null +++ b/app/views/admin/account_activities/_search_form.html.erb @@ -0,0 +1,62 @@ +
+
+ <%= search_form_for @q, url: [:admin, :account_activities], html: { style: 'margin-bottom: 0;' } do |f| %> +
+
+
+ <%= f.label t(:registrar_name) %> + <%= f.select :account_registrar_id_in, Registrar.all.map { |x| [x, x.id] }, {}, class: 'form-control js-combobox', placeholder: t(:choose), multiple: true %> +
+
+
+ +
+
+
+ <%= f.label t(:activity_type) %> + <%= f.select :activity_type_in, AccountActivity.types_for_select, {}, class: 'form-control js-combobox', placeholder: t(:choose), multiple: true %> +
+
+ +
+
+ <%= f.label t(:description) %> + <%= f.search_field :description_cont, class: 'form-control', placeholder: t(:description), autocomplete: 'off' %> +
+
+
+ +
+
+
+ <%= f.label t(:receipt_date_from) %> + <%= f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_from) %> +
+
+ +
+
+ <%= f.label t(:receipt_date_until) %> + <%= f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_until) %> +
+
+ +
+
+ <%= label_tag t(:results_per_page) %> + <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %> +
+
+ +
+ + <%= link_to(t('.reset_btn'), admin_account_activities_path, class: 'btn btn-default') %> +
+
+ <% end %> +
+
diff --git a/app/views/admin/account_activities/_search_form.html.haml b/app/views/admin/account_activities/_search_form.html.haml deleted file mode 100644 index d022542b1..000000000 --- a/app/views/admin/account_activities/_search_form.html.haml +++ /dev/null @@ -1,36 +0,0 @@ -.row - .col-md-12 - = search_form_for @q, url: [:admin, :account_activities], html: { style: 'margin-bottom: 0;' } do |f| - .row - .col-md-12 - .form-group - = f.label t(:registrar_name) - = f.select :account_registrar_id_in, Registrar.all.map { |x| [x, x.id] }, {}, class: 'form-control js-combobox', placeholder: t(:choose), multiple: true - .row - .col-md-6 - .form-group - = f.label t(:activity_type) - = f.select :activity_type_in, AccountActivity.types_for_select, {}, class: 'form-control js-combobox', placeholder: t(:choose), multiple: true - .col-md-6 - .form-group - = f.label t(:description) - = f.search_field :description_cont, class: 'form-control', placeholder: t(:description), autocomplete: 'off' - .row - .col-md-3 - .form-group - = f.label t(:receipt_date_from) - = f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_from) - .col-md-3 - .form-group - = f.label t(:receipt_date_until) - = f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_until) - .col-md-3 - .form-group - = label_tag t(:results_per_page) - = text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) - .col-md-3{style: 'padding-top: 25px;'} - %button.btn.btn-default.search -   - %span.glyphicon.glyphicon-search -   - = link_to(t('.reset_btn'), admin_account_activities_path, class: 'btn btn-default') From dc3bd6c093d6ca72b3d4832fb5b6d257df1135cb Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 5 Nov 2019 15:37:59 +0200 Subject: [PATCH 3/6] Group submit buttons in UI --- app/views/admin/account_activities/_search_form.html.erb | 9 ++++++--- app/views/admin/account_activities/index.haml | 3 --- config/locales/admin/account_activities.en.yml | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/views/admin/account_activities/_search_form.html.erb b/app/views/admin/account_activities/_search_form.html.erb index ddd587bb2..bf353a936 100644 --- a/app/views/admin/account_activities/_search_form.html.erb +++ b/app/views/admin/account_activities/_search_form.html.erb @@ -27,14 +27,14 @@
-
+
<%= f.label t(:receipt_date_from) %> <%= f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_from) %>
-
+
<%= f.label t(:receipt_date_until) %> <%= f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_until) %> @@ -48,12 +48,15 @@
-
+
+ <%= button_tag t('.download_btn'), + formaction: admin_account_activities_path(format: 'csv'), + class: 'btn btn-default' %> <%= link_to(t('.reset_btn'), admin_account_activities_path, class: 'btn btn-default') %>
diff --git a/app/views/admin/account_activities/index.haml b/app/views/admin/account_activities/index.haml index df84b2757..2e1d57dc6 100644 --- a/app/views/admin/account_activities/index.haml +++ b/app/views/admin/account_activities/index.haml @@ -1,6 +1,3 @@ -- content_for :actions do - = link_to(t(:export_csv), url_for(params.merge(format: 'csv')), class: 'btn btn-default') - = render 'shared/title', name: t(:account_activities) = render 'search_form' diff --git a/config/locales/admin/account_activities.en.yml b/config/locales/admin/account_activities.en.yml index 2006f2f36..e7cc80d65 100644 --- a/config/locales/admin/account_activities.en.yml +++ b/config/locales/admin/account_activities.en.yml @@ -2,4 +2,5 @@ en: admin: account_activities: search_form: + download_btn: Download CSV reset_btn: Reset From 4f1401a1a8f8c29a21591110efe050c562b2d106 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 5 Nov 2019 15:39:59 +0200 Subject: [PATCH 4/6] Convert HAML to ERB --- .../registrar/account_activities/index.haml | 61 ----------- .../account_activities/index.html.erb | 102 ++++++++++++++++++ 2 files changed, 102 insertions(+), 61 deletions(-) delete mode 100644 app/views/registrar/account_activities/index.haml create mode 100644 app/views/registrar/account_activities/index.html.erb diff --git a/app/views/registrar/account_activities/index.haml b/app/views/registrar/account_activities/index.haml deleted file mode 100644 index 3cc6b34e4..000000000 --- a/app/views/registrar/account_activities/index.haml +++ /dev/null @@ -1,61 +0,0 @@ -- content_for :actions do - = link_to(t(:back_to_billing), registrar_invoices_path, class: 'btn btn-default') - = link_to(t(:export_csv), url_for(params.merge(format: 'csv')), class: 'btn btn-default') - -= render 'shared/title', name: t(:account_activity) - -.row - .col-md-12 - = search_form_for @q, url: [:registrar, :account_activities], html: { style: 'margin-bottom: 0;' } do |f| - .row - .col-md-6 - .form-group - = f.label t(:activity_type) - = f.select :activity_type_in, AccountActivity.types_for_select, {}, class: 'form-control js-combobox', placeholder: t(:choose), multiple: true - .col-md-6 - .form-group - = f.label t(:description) - = f.search_field :description_cont, class: 'form-control', placeholder: t(:description), autocomplete: 'off' - .row - .col-md-3 - .form-group - = f.label t(:receipt_date_from) - = f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_from) - .col-md-3 - .form-group - = f.label t(:receipt_date_until) - = f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_until) - .col-md-6{style: 'padding-top: 25px;'} - %button.btn.btn-default -   - %span.glyphicon.glyphicon-search -   - = link_to(t('.reset_btn'), registrar_account_activities_path, class: 'btn btn-default') -%hr - -.row - .col-md-12 - .table-responsive - %table.table.table-hover.table-condensed - %thead - %tr - %th{class: 'col-xs-5'} - = sort_link(@q, 'description') - %th{class: 'col-xs-2'} - = sort_link(@q, 'activity_type') - %th{class: 'col-xs-3'} - = sort_link(@q, 'created_at', AccountActivity.human_attribute_name(:created_at)) - %th{class: 'col-xs-2'} - = sort_link(@q, 'sum') - %tbody - - @account_activities.each do |x| - %tr - %td= x.description.present? ? x.description : '-' - %td= x.activity_type ? t(x.activity_type) : '' - %td= l(x.created_at) - - c = x.sum > 0.0 ? 'text-success' : 'text-danger' - - s = x.sum > 0.0 ? "+#{x.sum} #{x.currency}" : "#{x.sum} #{x.currency}" - %td{class: c}= s -.row - .col-md-12 - = paginate @account_activities diff --git a/app/views/registrar/account_activities/index.html.erb b/app/views/registrar/account_activities/index.html.erb new file mode 100644 index 000000000..73e966b51 --- /dev/null +++ b/app/views/registrar/account_activities/index.html.erb @@ -0,0 +1,102 @@ +<% content_for :actions do %> + <%= link_to(t(:back_to_billing), registrar_invoices_path, class: 'btn btn-default') %> + <%= link_to(t(:export_csv), url_for(params.merge(format: 'csv')), class: 'btn btn-default') %> +<% end %> + +<%= render 'shared/title', name: t(:account_activity) %> + +
+
+ <%= search_form_for @q, url: [:registrar, :account_activities], html: { style: 'margin-bottom: 0;' } do |f| %> +
+
+
+ <%= f.label t(:activity_type) %> + <%= f.select :activity_type_in, AccountActivity.types_for_select, {}, class: 'form-control js-combobox', placeholder: t(:choose), multiple: true %> +
+
+
+
+ <%= f.label t(:description) %> + <%= f.search_field :description_cont, class: 'form-control', placeholder: t(:description), autocomplete: 'off' %> +
+
+
+
+
+
+ <%= f.label t(:receipt_date_from) %> + <%= f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_from) %> +
+
+
+
+ <%= f.label t(:receipt_date_until) %> + <%= f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_until) %> +
+
+
+ + <%= link_to(t('.reset_btn'), registrar_account_activities_path, class: 'btn btn-default') %> +
+
+ <% end %> +
+
+ +
+ +
+
+
+ + + + + + + + + + + <% @account_activities.each do |x| %> + + + + + <% c = x.sum > 0.0 ? 'text-success' : 'text-danger' %> + <% s = x.sum > 0.0 ? "+#{x.sum} #{x.currency}" : "#{x.sum} #{x.currency}" %> + + + <% end %> + +
+ <%= sort_link(@q, 'description') %> + + <%= sort_link(@q, 'activity_type') %> + + <%= sort_link(@q, 'created_at', AccountActivity.human_attribute_name(:created_at)) %> + + <%= sort_link(@q, 'sum') %> +
+ <%= x.description.present? ? x.description : '-' %> + + <%= x.activity_type ? t(x.activity_type) : '' %> + + <%= l(x.created_at) %> + + <%= s %> +
+
+
+
+ +
+
+ <%= paginate @account_activities %> +
+
From 3539c3f28c4529a80770443e615caab2caaf7dc6 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 5 Nov 2019 15:41:08 +0200 Subject: [PATCH 5/6] Extract partial --- .../account_activities/_search_form.html.erb | 46 +++++++++++++++++++ .../account_activities/index.html.erb | 43 +---------------- .../registrar/account_activities.en.yml | 2 +- 3 files changed, 48 insertions(+), 43 deletions(-) create mode 100644 app/views/registrar/account_activities/_search_form.html.erb diff --git a/app/views/registrar/account_activities/_search_form.html.erb b/app/views/registrar/account_activities/_search_form.html.erb new file mode 100644 index 000000000..b5041a04c --- /dev/null +++ b/app/views/registrar/account_activities/_search_form.html.erb @@ -0,0 +1,46 @@ +
+
+ <%= search_form_for @q, url: [:registrar, :account_activities], html: { style: 'margin-bottom: 0;' } do |f| %> +
+
+
+ <%= f.label t(:activity_type) %> + <%= f.select :activity_type_in, AccountActivity.types_for_select, {}, class: 'form-control js-combobox', placeholder: t(:choose), multiple: true %> +
+
+ +
+
+ <%= f.label t(:description) %> + <%= f.search_field :description_cont, class: 'form-control', placeholder: t(:description), autocomplete: 'off' %> +
+
+
+ +
+
+
+ <%= f.label t(:receipt_date_from) %> + <%= f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_from) %> +
+
+ +
+
+ <%= f.label t(:receipt_date_until) %> + <%= f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_until) %> +
+
+ +
+ + <%= link_to(t('.reset_btn'), registrar_account_activities_path, class: 'btn btn-default') %> +
+
+ <% end %> +
+
diff --git a/app/views/registrar/account_activities/index.html.erb b/app/views/registrar/account_activities/index.html.erb index 73e966b51..257c4d306 100644 --- a/app/views/registrar/account_activities/index.html.erb +++ b/app/views/registrar/account_activities/index.html.erb @@ -5,48 +5,7 @@ <%= render 'shared/title', name: t(:account_activity) %> -
-
- <%= search_form_for @q, url: [:registrar, :account_activities], html: { style: 'margin-bottom: 0;' } do |f| %> -
-
-
- <%= f.label t(:activity_type) %> - <%= f.select :activity_type_in, AccountActivity.types_for_select, {}, class: 'form-control js-combobox', placeholder: t(:choose), multiple: true %> -
-
-
-
- <%= f.label t(:description) %> - <%= f.search_field :description_cont, class: 'form-control', placeholder: t(:description), autocomplete: 'off' %> -
-
-
-
-
-
- <%= f.label t(:receipt_date_from) %> - <%= f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_from) %> -
-
-
-
- <%= f.label t(:receipt_date_until) %> - <%= f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_until) %> -
-
-
- - <%= link_to(t('.reset_btn'), registrar_account_activities_path, class: 'btn btn-default') %> -
-
- <% end %> -
-
+<%= render 'search_form' %>
diff --git a/config/locales/registrar/account_activities.en.yml b/config/locales/registrar/account_activities.en.yml index 27d0150d6..bba527c9c 100644 --- a/config/locales/registrar/account_activities.en.yml +++ b/config/locales/registrar/account_activities.en.yml @@ -1,5 +1,5 @@ en: registrar: account_activities: - index: + search_form: reset_btn: Reset From 33b9bff7a94d7a08d3c5f982c0ca4187ec8c2157 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 5 Nov 2019 15:43:27 +0200 Subject: [PATCH 6/6] Group submit buttons in UI --- app/views/registrar/account_activities/_search_form.html.erb | 3 +++ app/views/registrar/account_activities/index.html.erb | 1 - config/locales/en.yml | 1 - config/locales/registrar/account_activities.en.yml | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/registrar/account_activities/_search_form.html.erb b/app/views/registrar/account_activities/_search_form.html.erb index b5041a04c..92a715096 100644 --- a/app/views/registrar/account_activities/_search_form.html.erb +++ b/app/views/registrar/account_activities/_search_form.html.erb @@ -38,6 +38,9 @@   + <%= button_tag t('.download_btn'), + formaction: registrar_account_activities_path(format: 'csv'), + class: 'btn btn-default' %> <%= link_to(t('.reset_btn'), registrar_account_activities_path, class: 'btn btn-default') %>
diff --git a/app/views/registrar/account_activities/index.html.erb b/app/views/registrar/account_activities/index.html.erb index 257c4d306..c5eaf2063 100644 --- a/app/views/registrar/account_activities/index.html.erb +++ b/app/views/registrar/account_activities/index.html.erb @@ -1,6 +1,5 @@ <% content_for :actions do %> <%= link_to(t(:back_to_billing), registrar_invoices_path, class: 'btn btn-default') %> - <%= link_to(t(:export_csv), url_for(params.merge(format: 'csv')), class: 'btn btn-default') %> <% end %> <%= render 'shared/title', name: t(:account_activity) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index e57723cd1..5742398f7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -592,7 +592,6 @@ en: receipt_date_from: 'Receipt date from' receipt_date_until: 'Receipt date until' add_credit: 'Add credit' - export_csv: 'Export CSV' invalid_yaml: 'Invalid YAML' reserved_pw: 'Reserved pw' no_transfers_found: 'No transfers found' diff --git a/config/locales/registrar/account_activities.en.yml b/config/locales/registrar/account_activities.en.yml index bba527c9c..374760065 100644 --- a/config/locales/registrar/account_activities.en.yml +++ b/config/locales/registrar/account_activities.en.yml @@ -2,4 +2,5 @@ en: registrar: account_activities: search_form: + download_btn: Download CSV reset_btn: Reset