@@ -17,95 +17,7 @@ def initialize(
1717 @auto_matched_records = auto_matched_records . sort_by ( &:row_number )
1818 @import_issues = import_issues . sort_by ( &:row_number )
1919 @school_moves = school_moves
20- end
21-
22- def call
23- helpers . safe_join (
24- [
25- render_section (
26- title : "New records" ,
27- description : new_records_message ,
28- summary : pluralize ( @new_records . count , "new record" ) ,
29- changesets : @new_records
30- ) do
31- render (
32- AppImportReviewRecordsSummaryComponent . new ( changesets : @new_records )
33- )
34- end ,
35- render_section (
36- title : "Records already in Mavis" ,
37- description : auto_matched_message ,
38- summary :
39- "#{ pluralize ( @auto_matched_records . count , "record" ) } already in Mavis" ,
40- changesets : @auto_matched_records
41- ) do
42- render (
43- AppImportReviewRecordsSummaryComponent . new (
44- changesets : @auto_matched_records
45- )
46- )
47- end ,
48- render_section (
49- title :
50- "Children moving from another SAIS team's area - will need review after import" ,
51- description : inter_team_message ,
52- summary :
53- "#{ pluralize ( @inter_team . count , "school move" ) } across teams" ,
54- changesets : @inter_team
55- ) do
56- render (
57- AppImportReviewSchoolMovesSummaryComponent . new (
58- changesets : @inter_team
59- )
60- )
61- end ,
62- if @inter_team_import_issues . any?
63- render_expander (
64- summary :
65- "#{ pluralize ( @inter_team_import_issues . count , "close match" ) } to existing records"
66- ) do
67- render (
68- AppImportReviewIssuesSummaryComponent . new (
69- import : @import ,
70- records : @inter_team_import_issues
71- )
72- )
73- end
74- end ,
75- render_section (
76- title :
77- "Close matches to existing records - will need review after import" ,
78- description : import_issues_message ,
79- summary :
80- "#{ pluralize ( @import_issues . count , "close match" ) } to existing records" ,
81- changesets : @import_issues
82- ) do
83- render (
84- AppImportReviewIssuesSummaryComponent . new (
85- import : @import ,
86- records : @import_issues
87- )
88- )
89- end ,
90- render_section (
91- title : "School moves - will need review after import" ,
92- description : school_moves_message ,
93- summary : pluralize ( @school_moves . count , "school move" ) ,
94- changesets : @school_moves
95- ) do
96- render (
97- AppImportReviewSchoolMovesSummaryComponent . new (
98- changesets : @school_moves
99- )
100- )
101- end ,
102- helpers . tag . hr (
103- class :
104- "nhsuk-section-break nhsuk-section-break--visible nhsuk-section-break--l"
105- ) ,
106- render_button_group
107- ] . compact
108- )
20+ @school_moves_from_file = @school_moves . reject { it . row_number . nil? }
10921 end
11022
11123 private
@@ -122,6 +34,7 @@ def auto_matched_message
12234 count = @auto_matched_records . count
12335 "This upload includes #{ pluralize ( count , "record" ) } that already " \
12436 "#{ count > 1 ? "exist" : "exists" } in Mavis. " \
37+ "You do not need to remove #{ count > 1 ? "these" : "this" } from your CSV file. " \
12538 "If you approve the upload, any additional information will be added to " \
12639 "the existing #{ count > 1 ? "records" : "record" } ."
12740 end
@@ -130,31 +43,37 @@ def import_issues_message
13043 count = @import_issues . count
13144 "This upload includes #{ pluralize ( count , "record" ) } that " \
13245 "#{ count > 1 ? "are close matches to existing records" : "is a close match to an existing record" } " \
133- "in Mavis. If you approve the upload, any differences will be flagged as " \
134- "import issues needing review ."
46+ "in Mavis. If you approve the upload, you will need to resolve " \
47+ "#{ count > 1 ? "these records" : "this record" } in the Issues tab ."
13548 end
13649
13750 def inter_team_message
13851 count = @inter_team . count
13952 "This upload includes #{ count > 1 ? "children" : "child" } who " \
14053 "#{ count > 1 ? "are" : "is" } currently registered with another team. " \
141- "If you approve the upload, the records below will be flagged as school moves needing review."
54+ "If you approve the upload, you will need to resolve #{ count > 1 ? "these records" : "this record" } " \
55+ "in the School moves area of Mavis."
14256 end
14357
14458 def school_moves_message
14559 count = @school_moves . count
14660 if @import . is_a? ( ClassImport )
14761 "This upload will change the school of the #{ count > 1 ? "children" : "child" } listed below. " \
14862 "Children present in the class list will be moved into the school, and those who are not in the " \
149- "class list will be moved out of the school. If you approve the upload, these will be flagged as " \
150- "school moves needing review ."
63+ "class list will be moved out of the school. If you approve the upload, you will need to resolve " \
64+ "#{ count > 1 ? "these records" : "this record" } in the School moves area of Mavis ."
15165 else
15266 "This upload includes #{ count } #{ count > 1 ? "children" : "child" } with a different school to " \
153- "the one on their Mavis record. If you approve the upload, these will be flagged as " \
154- "school moves needing review ."
67+ "the one on their Mavis record. If you approve the upload, you will need to resolve " \
68+ "#{ count > 1 ? "these records" : "this record" } in the School moves area of Mavis ."
15569 end
15670 end
15771
72+ def show_cancel_button?
73+ @new_records . any? || @auto_matched_records . any? || @import_issues . any? ||
74+ @school_moves_from_file . any?
75+ end
76+
15877 def cancel_button_text
15978 @import . in_re_review? ? "Ignore changes" : "Cancel and delete upload"
16079 end
@@ -166,52 +85,4 @@ def approve_button_text
16685 "Approve and import records"
16786 end
16887 end
169-
170- def render_section ( title :, description :, summary :, changesets :, &block )
171- return if changesets . blank?
172-
173- helpers . safe_join (
174- [
175- tag . h2 ( title , class : "nhsuk-heading-m" ) ,
176- tag . p ( description , class : "nhsuk-u-reading-width" ) ,
177- render_expander ( summary :, &block )
178- ]
179- )
180- end
181-
182- def render_expander ( summary :, &block )
183- tag . details ( class : "nhsuk-details nhsuk-expander" ) do
184- helpers . safe_join (
185- [
186- tag . summary (
187- class : "nhsuk-details__summary" ,
188- data : {
189- module : "app-sticky"
190- }
191- ) { tag . span ( summary , class : "nhsuk-details__summary-text" ) } ,
192- tag . div ( class : "nhsuk-details__text" , &block )
193- ]
194- )
195- end
196- end
197-
198- def render_button_group
199- tag . div ( class : "nhsuk-button-group" ) do
200- helpers . safe_join (
201- [
202- helpers . govuk_button_to (
203- approve_button_text ,
204- polymorphic_path ( [ :approve , @import ] ) ,
205- method : :post
206- ) ,
207- helpers . govuk_button_to (
208- cancel_button_text ,
209- polymorphic_path ( [ :cancel , @import ] ) ,
210- secondary : true ,
211- method : :post
212- )
213- ]
214- )
215- end
216- end
21788end
0 commit comments