renalware-core 2.0.109 → 2.0.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/renalware/loading-gears-animation.gif +0 -0
  3. data/app/assets/javascripts/renalware/drugs.js +3 -4
  4. data/app/assets/javascripts/renalware/letters.js +47 -2
  5. data/app/assets/pdf/blank_page.pdf +56 -0
  6. data/app/assets/stylesheets/renalware/modules/_letters.scss +46 -0
  7. data/app/assets/stylesheets/renalware/partials/_tables.scss +2 -2
  8. data/app/controllers/renalware/base_controller.rb +9 -2
  9. data/app/controllers/renalware/clinics/appointments_controller.rb +8 -3
  10. data/app/controllers/renalware/letters/batches_controller.rb +106 -0
  11. data/app/controllers/renalware/letters/completed_batches_controller.rb +32 -0
  12. data/app/controllers/renalware/letters/lists_controller.rb +34 -5
  13. data/app/controllers/renalware/pathology/requests/requests_controller.rb +1 -1
  14. data/app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb +38 -0
  15. data/app/jobs/renalware/hd/update_rolling_patient_statistics_job.rb +4 -2
  16. data/app/jobs/renalware/letters/printing/batch_print_job.rb +27 -0
  17. data/app/models/concerns/renalware/patients_ransack_helper.rb +1 -1
  18. data/app/models/concerns/renalware/using_temp_folder.rb +14 -0
  19. data/app/models/renalware/clinics/appointment.rb +2 -3
  20. data/app/models/renalware/clinics/appointment_query.rb +5 -1
  21. data/app/models/renalware/hd/sessions/save_session.rb +5 -1
  22. data/app/models/renalware/hd/update_rolling_patient_statistics.rb +1 -1
  23. data/app/models/renalware/letters/batch.rb +37 -0
  24. data/app/models/renalware/letters/batch_item.rb +17 -0
  25. data/app/models/renalware/letters/lists/form.rb +101 -0
  26. data/app/models/renalware/letters/pdf_letter_cache.rb +1 -1
  27. data/app/models/renalware/letters/printing/batch_compile_pdfs.rb +121 -0
  28. data/app/models/renalware/letters/printing/complete_batch.rb +24 -0
  29. data/app/models/renalware/letters/printing/create_pdf_by_interleaving_address_sheet_and_letter_for_each_recipient.rb.dead +90 -0
  30. data/app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb +1 -1
  31. data/app/models/renalware/letters/printing/pdf_combining.rb +24 -21
  32. data/app/models/renalware/pathology/{consultant.rb → consultant.rb.dead} +0 -0
  33. data/app/models/renalware/pathology/observations_grouped_by_date_query.rb +1 -1
  34. data/app/models/renalware/pathology/relevant_observation_description.rb +1 -1
  35. data/app/models/renalware/pathology/requests/global_rule/transplant_date_within_weeks.rb +1 -1
  36. data/app/models/renalware/pathology/requests/global_rule/transplant_registration_status.rb +3 -1
  37. data/app/models/renalware/pathology/requests/request.rb +1 -1
  38. data/app/models/renalware/pathology/requests/request_params_factory.rb +11 -12
  39. data/app/models/renalware/patient.rb +3 -2
  40. data/app/models/renalware/pd/apd_regime.rb +6 -6
  41. data/app/models/renalware/renal/consultant.rb +16 -0
  42. data/app/models/renalware/transplants/registrations/wait_list_query.rb +4 -10
  43. data/app/models/renalware/ukrdc/treatment_timeline/generator_factory.rb +1 -1
  44. data/app/pdfs/renalware/letters/printing/recipient_address_page_pdf.rb +50 -0
  45. data/app/policies/renalware/letters/batch_policy.rb +13 -0
  46. data/app/presenters/renalware/letters/recipient_presenter.rb +1 -1
  47. data/app/presenters/renalware/pathology/requests/request_presenter.rb +1 -1
  48. data/app/presenters/renalware/transplants/mdm_presenter.rb +1 -1
  49. data/app/presenters/renalware/virology/dashboard_presenter.rb +2 -1
  50. data/app/views/renalware/api/ukrdc/patients/_hd_session_observations.xml.builder +2 -2
  51. data/app/views/renalware/clinics/appointments/index.html.slim +5 -4
  52. data/app/views/renalware/clinics/appointments/new.html.slim +3 -0
  53. data/app/views/renalware/letters/batches/_create.html.slim +27 -0
  54. data/app/views/renalware/letters/batches/create.js.erb +3 -0
  55. data/app/views/renalware/letters/batches/index.html.slim +20 -0
  56. data/app/views/renalware/letters/batches/show.html.slim +7 -0
  57. data/app/views/renalware/letters/completed_batches/create.js.erb +9 -0
  58. data/app/views/renalware/letters/completed_batches/new.html.slim +26 -0
  59. data/app/views/renalware/letters/lists/_table.html.slim +1 -1
  60. data/app/views/renalware/letters/lists/_tabs.html.slim +9 -0
  61. data/app/views/renalware/letters/lists/index.html.slim.dead +101 -0
  62. data/app/views/renalware/letters/lists/index.html.slim.dead1 +90 -0
  63. data/app/views/renalware/letters/lists/show.html.slim +57 -11
  64. data/app/views/renalware/medications/prescriptions/_form.html.slim +1 -0
  65. data/app/views/renalware/navigation/_super_admin.html.slim +1 -0
  66. data/app/views/renalware/pathology/requests/requests/_pdf_header.html.slim +2 -3
  67. data/app/views/renalware/pathology/requests/requests/index.html.slim +1 -1
  68. data/app/views/renalware/pathology/requests/requests/new.html.slim +0 -1
  69. data/config/locales/renalware/letters/letter.en.yml +5 -0
  70. data/config/routes/letters.rb +18 -1
  71. data/db/migrate/20190830153416_create_letter_batches.rb +14 -0
  72. data/db/migrate/20190902085216_create_letter_batch_items.rb +13 -0
  73. data/db/migrate/20190919073410_add_filepath_to_letter_batches.rb +7 -0
  74. data/db/migrate/20190920063447_add_status_to_letter_batch_items.rb +15 -0
  75. data/db/migrate/20190925104902_remove_user_from_appointments.rb +19 -0
  76. data/db/migrate/20190925130052_add_telephone_to_renal_consultants.rb +7 -0
  77. data/db/migrate/20190925161724_change_path_request_consultant_id.rb +19 -0
  78. data/db/migrate/20190925173849_renal_consultants_changes.rb +9 -0
  79. data/db/migrate/20190928131032_add_some_more_missing_indexes.rb +18 -0
  80. data/db/views/pathology_observation_digests_v01.sql +1 -1
  81. data/lib/renalware/configuration.rb +2 -0
  82. data/lib/renalware/engine.rb +1 -0
  83. data/lib/renalware/version.rb +1 -1
  84. data/lib/tasks/demo_data.rake +66 -0
  85. data/lib/tasks/pd.rake +32 -0
  86. data/spec/factories/clinics/appointments.rb +1 -1
  87. data/spec/factories/medications/medication_route.rb +5 -0
  88. data/spec/factories/renal/consultants.rb +9 -0
  89. data/spec/support/pages/medications/prescription_fom.rb +54 -0
  90. metadata +43 -7
  91. data/app/models/renalware/letters/printing/create_pdf_by_interleaving_address_sheet_and_letter_for_each_recipient.rb +0 -140
  92. data/spec/factories/pathology/consultant.rb +0 -5
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "renalware/letters/letter_policy"
4
+
5
+ module Renalware
6
+ module Letters
7
+ class BatchPolicy < BasePolicy
8
+ def status?
9
+ show?
10
+ end
11
+ end
12
+ end
13
+ end
@@ -20,7 +20,7 @@ module Renalware
20
20
  private
21
21
 
22
22
  def address_for_addressee
23
- __getobj__.address
23
+ __getobj__&.address
24
24
  end
25
25
 
26
26
  # The address for a recipient such as a primary care physician or a patient are
@@ -23,7 +23,7 @@ module Renalware
23
23
  end
24
24
 
25
25
  def consultant
26
- request_form.consultant.full_name
26
+ request_form.consultant&.name
27
27
  end
28
28
 
29
29
  def clinical_detail
@@ -10,7 +10,7 @@ module Renalware
10
10
  end
11
11
 
12
12
  def cmvdna_pathology
13
- @cmvdna_pathology ||= pathology_for_codes("CMVDNA")
13
+ @cmvdna_pathology ||= pathology_for_codes("CMVD")
14
14
  end
15
15
  end
16
16
  end
@@ -11,9 +11,10 @@ module Renalware
11
11
 
12
12
  def latest_hep_b_antibody_statuses
13
13
  @latest_hep_b_antibody_statuses ||= begin
14
+ observation_descriptions = Renalware::Pathology::ObservationDescription.for(Array("BHBS"))
14
15
  Renalware::Pathology::CreateObservationsGroupedByDateTable.new(
15
16
  patient: patient,
16
- observation_descriptions: Renalware::Pathology::ObservationDescription.for(Array("BHBS")),
17
+ observation_descriptions: observation_descriptions,
17
18
  page: 1,
18
19
  per_page: 5
19
20
  ).call
@@ -3,8 +3,8 @@
3
3
  xml = builder
4
4
 
5
5
  observation_times = {
6
- pre: session.performed_on + session.start_time.seconds_since_midnight.seconds,
7
- post: session.performed_on + session.end_time.seconds_since_midnight.seconds
6
+ pre: session.performed_on.to_datetime + session.start_time.seconds_since_midnight.seconds,
7
+ post: session.performed_on.to_datetime + session.end_time.seconds_since_midnight.seconds
8
8
  }
9
9
 
10
10
  {
@@ -10,7 +10,9 @@
10
10
  .medium-3.large-3.columns
11
11
  = f.input :clinic_id_eq, collection: clinics, label: "Clinic"
12
12
  .medium-3.large-3.columns
13
- = f.input :user_id_eq, as: :user_picker, collection: users, label: "User"
13
+ = f.input(:consultant_id_eq,
14
+ collection: Renalware::Renal::Consultant.pluck(:name, :id),
15
+ label: "Consultant")
14
16
  .medium-3.large-3.columns.actions.end
15
17
  = f.submit "Filter", class: "button"
16
18
 
@@ -29,7 +31,6 @@
29
31
  | Generate request forms
30
32
 
31
33
  = within_admin_layout(title: "Upcoming Clinic Visit Appointments") do
32
-
33
34
  table#appointments
34
35
  thead
35
36
  tr
@@ -68,7 +69,7 @@
68
69
  = " | "
69
70
  - if appointment.becomes_visit_id.present?
70
71
  = link_to edit_patient_clinic_visit_path(appointment.patient,
71
- id: appointment.becomes_visit_id) do
72
+ id: appointment.becomes_visit_id) do
72
73
  | View Clinic Visit
73
74
  - else
74
75
  = link_to new_patient_clinic_visit_path(appointment.patient,
@@ -83,7 +84,7 @@
83
84
  td= appointment.patient.age
84
85
  td= appointment.patient.current_modality
85
86
  td= appointment.clinic.name
86
- td= appointment.user.full_name
87
+ td= appointment.consultant&.name
87
88
  td.show-for-large-up.col-width-medium-with-ellipsis= appointment.outcome_notes
88
89
  td.show-for-large-up.col-width-medium-with-ellipsis= appointment.dna_notes
89
90
  = content_tag(:tr, id: "appointment-quick-preview-#{appointment.id}", style: "display: none")
@@ -26,6 +26,9 @@
26
26
  = f.input :clinic_id,
27
27
  collection: Renalware::Clinics::Clinic.all,
28
28
  wrapper: :horizontal_medium
29
+ = f.input :consultant_id,
30
+ collection: Renalware::Renal::Consultant.pluck(:name, :id),
31
+ wrapper: :horizontal_medium
29
32
  = f.input :starts_at, as: :datetime_picker, wrapper: :horizontal_datepicker
30
33
  = f.input :outcome_notes, as: :text, wrapper: :horizontal_large
31
34
  = f.input :dna_notes, as: :text, wrapper: :horizontal_large
@@ -0,0 +1,27 @@
1
+ .modal
2
+ .modal__header
3
+ h1= "Compiling #{batch.batch_items_count} letters"
4
+ .percent_complete
5
+ .modal__body
6
+ .content
7
+ .batch_results_container(data={"poll-url" => renalware.letters_batch_status_path(batch)})
8
+ .preparing
9
+ = image_tag("renalware/loading-gears-animation.gif", height: "116")
10
+
11
+
12
+ .generated-batch-print-pdf-container(style="display:none")
13
+ = link_to letters_batch_path(batch, format: :pdf),
14
+ target: "_blank",
15
+ class: "print-batch-letter",
16
+ data: { "modal-url" => new_letters_batch_completion_path(batch) } do
17
+ i.far.fa-check-circle
18
+ | Open PDF in a new tab
19
+
20
+ .modal__footer
21
+ .left
22
+ = "##{batch.id}"
23
+ .right
24
+ = link_to "Cancel",
25
+ "#",
26
+ "aria-label" => "Close",
27
+ class: "reveal-modal-close cancel-link"
@@ -0,0 +1,3 @@
1
+ <%= refresh("#batch-print-modal", partial: "create", locals: local_assigns) %>
2
+ $("#batch-print-modal").foundation('reveal', 'open');
3
+ Renalware.Letters.pollBatchStatus('<%= letters_batch_status_path(batch) %>');
@@ -0,0 +1,20 @@
1
+ = within_admin_layout(title: "Print Batches") do
2
+
3
+ table
4
+ thead
5
+ tr
6
+ th.col-width-tiny Id
7
+ th.col-width-medium Status
8
+ th.col-width-date-time Created
9
+ th.col-width-tiny Letters
10
+ th Created by
11
+ tbody
12
+ - batches.each do |batch|
13
+ tr
14
+ td= batch.id
15
+ td= batch.status.humanize
16
+ td= l(batch.created_at)
17
+ td= batch.batch_items_count
18
+ td= batch.created_by
19
+
20
+ = paginate batches
@@ -0,0 +1,7 @@
1
+ .generated-batch-print-pdf-container
2
+ = link_to letters_batch_path(batch, format: :pdf),
3
+ target: "_blank",
4
+ class: "print-batch-letter",
5
+ data: { "modal-url" => new_letters_batch_completion_path(batch) } do
6
+ i.far.fa-file-pdf
7
+ | Open PDF in a new tab
@@ -0,0 +1,9 @@
1
+ // We have just 'created' a Letter Completion resource on the server
2
+ // (in other words we have updated the letter state to Completed!) and now we
3
+ // need to refresh the view the user was on. This could be any page
4
+ // were the letter is listed or displayed. So look for a URL stored
5
+ // somewhere on the page in a data attribute and if found make an AJAX call
6
+ // which will probably reload e.g. a letters table or something like that.
7
+ <%# url = $(".reveal-modal").data("refresh-url");
8
+ if(url) { $.getScript(url); } %>
9
+ location.reload(true);
@@ -0,0 +1,26 @@
1
+ .modal
2
+ .modal__header
3
+ h2= "Was printing successful?"
4
+ .modal__body
5
+ / dl.dl-horizontal
6
+ / dt Patient
7
+ / dd= letter.patient.to_s
8
+ / dt Letter
9
+ / dd= letter.description
10
+ / dt Date
11
+ / dd= l(letter.issued_on)
12
+ / dt Author
13
+ / dd= letter.author
14
+ br
15
+ .modal__footer
16
+ = link_to "No - leave in the Print Queue",
17
+ "#",
18
+ class: "button secondary reveal-modal-close",
19
+ "aria-label" => "Close"
20
+ | &nbsp;&nbsp;&nbsp;
21
+ = link_to "Yes - remove from the Print Queue",
22
+ letters_batch_completions_path(batch),
23
+ method: :post,
24
+ remote: true,
25
+ data: { disable_with: "Updating..." },
26
+ class: "button primary right"
@@ -2,7 +2,7 @@
2
2
  table.report.letters
3
3
  thead
4
4
  tr
5
- th.noprint.col-width-17
5
+ th.noprint.col-width-large
6
6
  th Type
7
7
  th= sort_link([:renalware, q], :type, "State")
8
8
  th.col-width-medium= sort_link([:renalware, q], :patient_family_name, "Patient")
@@ -0,0 +1,9 @@
1
+ - named_filter_param = params[:named_filter]
2
+ dl.sub-nav
3
+ - filter = :all
4
+ dd(class=("active" if named_filter_param.to_s == filter.to_s))
5
+ = link_to t(".tab.#{filter}"), renalware.letters_filtered_letters_list_path(named_filter: filter)
6
+ - if Renalware.config.batch_printing_enabled
7
+ - filter = :batch_printable
8
+ dd(class=("active" if named_filter_param.to_s == filter.to_s))
9
+ = link_to t(".tab.#{filter}"), renalware.letters_filtered_letters_list_path(named_filter: filter)
@@ -0,0 +1,101 @@
1
+ / OK
2
+ / elements
3
+ / tabs - ok done
4
+ / filters
5
+ / for each named_dfilter
6
+ / - what is displayed
7
+ / - what is enabled
8
+ / - what values it has
9
+ / { filter: { enclosures_present: { disabled: true, options: [], visible: false } } }
10
+
11
+ = content_for(:tabs) do
12
+ = render "tabs"
13
+
14
+ = content_for(:filters) do
15
+ .search-form.filters
16
+ = simple_form_for q,
17
+ as: :q,
18
+ url: renalware.letters_filtered_letters_list_path(named_filter: params[:named_filter]),
19
+ html: { autocomplete: "off" },
20
+ method: :get do |f|
21
+ .row
22
+ - unless filter_options.dig(:enclosures_present, :hidden)
23
+ .small-6.medium-1.large-1.columns
24
+ = f.input :enclosures_present,
25
+ as: :select,
26
+ label: "Enclosure",
27
+ input_html: { disabled: filter_options.dig(:enclosures_present, :disabled) }
28
+ .small-6.medium-2.large-2.columns
29
+ = f.input :state_eq,
30
+ collection: filter_options.dig(:state_eq, :options)&.call,
31
+ label: "State",
32
+ input_html: { disabled: filter_options.dig(:state_eq, :disabled) }
33
+ .small-6.medium-2.large-2.columns
34
+ = f.input :author_id_eq,
35
+ as: :user_picker,
36
+ collection: authors,
37
+ label: "Author",
38
+ input_html: { disabled: filter_options.dig(:author_id_eq, :disabled) }
39
+ .small-6.medium-2.large-2.columns
40
+ = f.input :created_by_id_eq,
41
+ as: :user_picker,
42
+ collection: typists,
43
+ label: "Typist"
44
+ .small-6.medium-2.large-2.columns
45
+ = f.input :letterhead_id_eq, collection: letterheads, label: "Letterhead"
46
+ .small-6.medium-1.large-1.columns
47
+ = f.input :page_count_in_array,
48
+ collection: [["1 or 2", "[1,2]"],["3 or 4", "[3,4]"]],
49
+ label: "Pages"
50
+ .small-12.medium-2.large-2.columns.actions.end
51
+ = f.submit t("helpers.submit.filter"), class: "button secondary"
52
+ span= " or "
53
+ = link_to t("helpers.reset"), letters_list_path
54
+
55
+ = link_to("#", data: { "reveal-id" => "batch-print-modal" }, class: "button") do
56
+ i.fas.fa-print
57
+ | Batch print these letters
58
+
59
+ #batch-print-modal.reveal-modal.medium(data-reveal)
60
+ .modal
61
+ .modal__header
62
+ h1= "Batch print #{letters.total_count} letters"
63
+ /= render "renalware/shared/modal_close_link"
64
+ .modal__body
65
+ p Excludes 2 letters with enclosures
66
+ .content
67
+ / This for uses the same attributes as the filter form but when submitted will
68
+ / queue a print job for the current search criteria.
69
+ = simple_form_for q,
70
+ as: :batch,
71
+ url: letters_batches_path,
72
+ method: :post,
73
+ remote: true do |f|
74
+ = f.input :enclosures_present, as: :hidden
75
+ = f.input :state_eq, as: :hidden
76
+ = f.input :author_id_eq, as: :hidden
77
+ = f.input :created_by_id_eq, as: :hidden
78
+ = f.input :letterhead_id_eq, as: :hidden
79
+ = f.input :page_count_in_array, as: :hidden
80
+ = f.submit "Print", class: "button", data: { disable_with: "Printing" }
81
+ n= " or "
82
+ = link_to "Cancel",
83
+ "#",
84
+ "aria-label" => "Close",
85
+ class: "reveal-modal-close"
86
+ .modal__footer
87
+
88
+ = within_admin_layout(title: "Letters") do
89
+ = render "table", letters: letters, q: q
90
+
91
+ / The modal dialog container for the dialog which will ask the user
92
+ / if they want to mark the letter as printed. We load this dialog via ajax.
93
+ / See letters/completed_letters/new.html.slim for th dialog content.
94
+ / See also
95
+ / - letters/completed_letters/create.js.erb
96
+ / - ./show.js.erb
97
+ / - letters.js
98
+ / for the complete works. Using ujs for these sort of dialog -> -> post -> page refresh
99
+ / cycles is a bit complex and we could move to using something like stimulus
100
+ / to keep thing a bit simpler
101
+ #letter-print-modal.reveal-modal.medium(data-reveal data-refresh-url=request.original_fullpath)
@@ -0,0 +1,90 @@
1
+ = content_for(:tabs) do
2
+ = render "tabs"
3
+
4
+ = content_for(:filters) do
5
+ .search-form.filters
6
+ = simple_form_for q,
7
+ as: :q,
8
+ url: renalware.letters_filtered_letters_list_path(named_filter: params[:named_filter]),
9
+ html: { autocomplete: "off" },
10
+ method: :get do |f|
11
+ .row
12
+ - unless filter_options.dig(:enclosures_present, :hidden)
13
+ .small-6.medium-1.large-1.columns
14
+ = f.input :enclosures_present,
15
+ as: :select,
16
+ label: "Enclosure",
17
+ input_html: { disabled: filter_options.dig(:enclosures_present, :disabled) }
18
+ .small-6.medium-2.large-2.columns
19
+ = f.input :state_eq,
20
+ collection: filter_options.dig(:state_eq, :options)&.call,
21
+ label: "State",
22
+ input_html: { disabled: filter_options.dig(:state_eq, :disabled) }
23
+ .small-6.medium-2.large-2.columns
24
+ = f.input :author_id_eq,
25
+ as: :user_picker,
26
+ collection: authors,
27
+ label: "Author",
28
+ input_html: { disabled: filter_options.dig(:author_id_eq, :disabled) }
29
+ .small-6.medium-2.large-2.columns
30
+ = f.input :created_by_id_eq,
31
+ as: :user_picker,
32
+ collection: typists,
33
+ label: "Typist"
34
+ .small-6.medium-2.large-2.columns
35
+ = f.input :letterhead_id_eq, collection: letterheads, label: "Letterhead"
36
+ .small-6.medium-1.large-1.columns
37
+ = f.input :page_count_in_array,
38
+ collection: [["1 or 2", "[1,2]"],["3 or 4", "[3,4]"]],
39
+ label: "Pages"
40
+ .small-12.medium-2.large-2.columns.actions.end
41
+ = f.submit t("helpers.submit.filter"), class: "button secondary"
42
+ span= " or "
43
+ = link_to t("helpers.reset"), letters_list_path
44
+
45
+ = link_to("#", data: { "reveal-id" => "batch-print-modal" }, class: "button") do
46
+ i.fas.fa-print
47
+ | Batch print these letters
48
+
49
+ #batch-print-modal.reveal-modal.medium(data-reveal)
50
+ .modal
51
+ .modal__header
52
+ h1= "Batch print #{letters.total_count} letters"
53
+ /= render "renalware/shared/modal_close_link"
54
+ .modal__body
55
+ .content
56
+ / This for uses the same attributes as the filter form but when submitted will
57
+ / queue a print job for the current search criteria.
58
+ = simple_form_for q,
59
+ as: :batch,
60
+ url: letters_batches_path,
61
+ method: :post,
62
+ remote: true do |f|
63
+ = f.input :enclosures_present, as: :hidden
64
+ = f.input :state_eq, as: :hidden
65
+ = f.input :author_id_eq, as: :hidden
66
+ = f.input :created_by_id_eq, as: :hidden
67
+ = f.input :letterhead_id_eq, as: :hidden
68
+ = f.input :page_count_in_array, as: :hidden
69
+ = f.submit "Print", class: "button", data: { disable_with: "Printing" }
70
+ n= " or "
71
+ = link_to "Cancel",
72
+ "#",
73
+ "aria-label" => "Close",
74
+ class: "reveal-modal-close"
75
+ .modal__footer
76
+
77
+ = within_admin_layout(title: "Letters") do
78
+ = render "table", letters: letters, q: q
79
+
80
+ / The modal dialog container for the dialog which will ask the user
81
+ / if they want to mark the letter as printed. We load this dialog via ajax.
82
+ / See letters/completed_letters/new.html.slim for th dialog content.
83
+ / See also
84
+ / - letters/completed_letters/create.js.erb
85
+ / - ./show.js.erb
86
+ / - letters.js
87
+ / for the complete works. Using ujs for these sort of dialog -> -> post -> page refresh
88
+ / cycles is a bit complex and we could move to using something like stimulus
89
+ / to keep thing a bit simpler
90
+ #letter-print-modal.reveal-modal.medium(data-reveal data-refresh-url=request.original_fullpath)
@@ -1,29 +1,75 @@
1
+ - named_filter = params[:named_filter]&.to_sym || :all
2
+
3
+ = content_for(:tabs) do
4
+ = render "tabs"
5
+
1
6
  = content_for(:filters) do
2
7
  .search-form.filters
3
- = simple_form_for q,
8
+ = simple_form_for form,
4
9
  as: :q,
5
- url: letters_list_path,
10
+ url: renalware.letters_filtered_letters_list_path(named_filter: named_filter),
6
11
  html: { autocomplete: "off" },
7
12
  method: :get do |f|
8
13
  .row
9
14
  .small-6.medium-1.large-1.columns
10
- = f.input :enclosures_present, as: :select, label: "Enclosure"
15
+ = f.input :enclosures_present,
16
+ as: :select,
17
+ label: "Enclosure",
18
+ input_html: { disabled: form.disabled_inputs.include?(:enclosures_present) }
11
19
  .small-6.medium-2.large-2.columns
12
- = f.input :state_eq, collection: state_options_for_receptionists, label: "State"
20
+ = f.input :state_eq,
21
+ collection: form.letter_state_options,
22
+ label: "State",
23
+ include_blank: form.allow_blank_inputs.include?(:state_eq),
24
+ input_html: { disabled: form.disabled_inputs.include?(:state_eq) }
13
25
  .small-6.medium-2.large-2.columns
14
- = f.input :author_id_eq, as: :user_picker, collection: authors, label: "Author"
26
+ = f.input :author_id_eq,
27
+ as: :user_picker,
28
+ collection: form.author_options,
29
+ label: "Author",
30
+ input_html: { disabled: form.disabled_inputs.include?(:author_id_eq) }
15
31
  .small-6.medium-2.large-2.columns
16
- = f.input :created_by_id_eq, as: :user_picker, collection: typists, label: "Typist"
32
+ = f.input :created_by_id_eq,
33
+ as: :user_picker,
34
+ collection: form.typist_options,
35
+ label: "Typist"
17
36
  .small-6.medium-2.large-2.columns
18
- = f.input :letterhead_id_eq, collection: letterheads, label: "Letterhead"
37
+ = f.input :letterhead_id_eq,
38
+ collection: form.letterhead_options,
39
+ label: "Letterhead"
19
40
  .small-6.medium-1.large-1.columns
20
41
  = f.input :page_count_in_array,
21
- collection: [["1 or 2", "[1,2]"],["3 or 4", "[3,4]"]],
22
- label: "Pages"
42
+ collection: form.page_count_options,
43
+ label: "Pages",
44
+ include_blank: form.allow_blank_inputs.include?(:page_count_in_array)
23
45
  .small-12.medium-2.large-2.columns.actions.end
24
- = f.submit t("helpers.submit.filter"), class: "button"
46
+ = f.submit t("helpers.submit.filter"), class: "button secondary"
25
47
  span= " or "
26
- = link_to t("helpers.reset"), letters_list_path
48
+ = link_to t("helpers.reset"), renalware.letters_filtered_letters_list_path(named_filter: named_filter)
49
+
50
+ - if named_filter == :batch_printable
51
+ / Thus form wil all hidden fields and one button is otherwise a mirror of the above filter form.
52
+ / It POSTs the form to create a batch and its items (which really just help us to keep track)
53
+ / or what was printed and the user does not need to know about it) and once created
54
+ / it pops up a dialog with a spinner and an asycn_render partial that, once the PDFs are compiled
55
+ / will return with a partial containing a link to the PDF. The user clicks on this to open it in a
56
+ / new window. At the same time on the original page we close the modal and display another one
57
+ / which asks the user if the print batch was successful - if so we send a patch to update
58
+ / the batch status and set letter status to Completed.
59
+ = simple_form_for form,
60
+ as: :batch,
61
+ url: letters_batches_path,
62
+ method: :post,
63
+ remote: true do |f|
64
+ = f.input :enclosures_present, as: :hidden
65
+ = f.input :state_eq, as: :hidden
66
+ = f.input :author_id_eq, as: :hidden
67
+ = f.input :created_by_id_eq, as: :hidden
68
+ = f.input :letterhead_id_eq, as: :hidden
69
+ = f.input :page_count_in_array, as: :hidden
70
+ = f.submit "Batch Print #{letters.total_count} letters", class: "button", disabled: letters.none?
71
+
72
+ #batch-print-modal.reveal-modal.small(data-reveal)
27
73
 
28
74
  = within_admin_layout(title: "Letters") do
29
75
  = render "table", letters: letters, q: q