|
2 | 2 |
|
3 | 3 | angular.module('yourStlCourts').controller('CitationInfoCtrl', function (faqData,$state, $window, citations,municipalities,courts,Courts,Session,moment,$anchorScroll) { |
4 | 4 | var ctrl = this; |
| 5 | + var PLACEHOLDER_DL_NUM = "NO_DL_NUM"; |
| 6 | + |
5 | 7 | ctrl.faqData = faqData; |
6 | 8 | ctrl.selectedCitation = null; |
7 | 9 | ctrl.paymentUrl = ""; |
8 | 10 | ctrl.citationCourtLocations = {}; |
| 11 | + ctrl.groupedCitations = {}; |
| 12 | + |
| 13 | + ctrl.groupCitationsByDL = function(){ |
| 14 | + var dlNum = ""; |
| 15 | + var dlState = ""; |
| 16 | + var groupedCitations = {}; |
| 17 | + |
| 18 | + citations.forEach(function(citation){ |
| 19 | + dlNum = citation.drivers_license_number; |
| 20 | + dlState = citation.drivers_license_state; |
| 21 | + if (dlNum === ""){ |
| 22 | + //in the event the defendant does not have a DL Num assign one so the object has a key |
| 23 | + dlNum = PLACEHOLDER_DL_NUM; |
| 24 | + } |
| 25 | + if (!groupedCitations[dlNum+dlState]){ |
| 26 | + groupedCitations[dlNum+dlState] = []; |
| 27 | + } |
| 28 | + groupedCitations[dlNum+dlState].push(citation); |
| 29 | + }); |
| 30 | + |
| 31 | + return groupedCitations; |
| 32 | + }; |
| 33 | + |
| 34 | + ctrl.issueMultiplePeopleWarning = function(){ |
| 35 | + |
| 36 | + return (_.size(ctrl.groupedCitations) > 1); |
| 37 | + }; |
9 | 38 |
|
10 | 39 | ctrl.selectCitation = function(citation,idToScrollTo){ |
11 | 40 | ctrl.selectedCitation = citation; |
@@ -44,6 +73,7 @@ angular.module('yourStlCourts').controller('CitationInfoCtrl', function (faqData |
44 | 73 | $state.go('home'); |
45 | 74 | } else { |
46 | 75 | ctrl.citations = citations; |
| 76 | + ctrl.groupedCitations = ctrl.groupCitationsByDL(); |
47 | 77 | for(var citationCount = 0; citationCount < citations.length; citationCount++){ |
48 | 78 | var courtId = citations[citationCount].court_id; |
49 | 79 | var foundCourt = _.find(courts, {id: courtId}); |
|
0 commit comments