-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathHome.vue
239 lines (224 loc) · 8.64 KB
/
Home.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<template>
<b-card bg-variant="white" class="home">
<b-card>
<b-card-title class="my-0 ml-4 h1 text-primary"> Supreme Court Viewer </b-card-title>
</b-card>
<b-row cols="2" body-class="py-0">
<b-col md="6" cols="6">
<b-card align="left" body-class="pt-1 pb-0">
<b-card>
<b-card-title class="h3 my-0 text-secondary"> Search by File Number and Location: </b-card-title>
</b-card>
<b-card body-class="py-1">
<b-card-text class="mb-1" for="filenumber"> File Number: </b-card-text>
<b-form-input
id="filenumber"
v-model="fileSearch.fileNumber"
placeholder="Enter File Number"
></b-form-input>
</b-card>
<b-card body-class="pb-1">
<b-card-text class="mb-1" for="civil/criminal"> Civil/Criminal: </b-card-text>
<b-form-select v-model="selectedFileSearch" :options="options"></b-form-select>
</b-card>
<b-card>
<b-card-text class="mb-1" for="location"> Location: </b-card-text>
<b-form-select
v-model="selectedCourtLocation"
id="locationSelect"
:disabled="!searchAllowed"
:state="selectedCourtLocationState ? null : false"
@change="LocationChanged"
:options="courtRoomsAndLocations"
style="height:39px"
>
</b-form-select>
</b-card>
<b-card class="pb-0">
<b-button variant="outline-primary text-dark" @click="navigateToFilesView(fileSearch)">
<b-icon-search class="mr-1" variant="dark"></b-icon-search>
Search
</b-button>
</b-card>
</b-card>
<b-card align="left" body-class="py-1">
<b-card>
<b-card-title class="my-0 h3"> Search by File ID: </b-card-title>
</b-card>
<b-card body-class="py-1">
<b-card-text class="mb-1" for="fileId"> File ID: </b-card-text>
<b-form-input id="fileId" v-model="fileInformation.fileNumber" placeholder="Enter File ID"></b-form-input>
</b-card>
<b-card>
<b-card-text class="mb-1" for="civil/criminal"> Civil/Criminal: </b-card-text>
<b-form-select v-model="selected" :options="options"></b-form-select>
</b-card>
<b-card>
<b-button variant="outline-primary text-dark" @click="navigateToDocumentsView(fileInformation)">
<b-icon-search class="mr-1" variant="dark"></b-icon-search>
Search
</b-button>
</b-card>
</b-card>
</b-col>
<b-col md="6" cols="6">
<b-card align="left" body-class="pt-1 pb-0">
<b-card>
<b-card-title class="h3 my-0"> Search by Court List: </b-card-title>
</b-card>
<b-card body-class="mt-0 pt-0">
<b-button variant="outline-primary text-dark" @click="navigateToCourtList()">
<b-icon-search class="mr-1" variant="dark"></b-icon-search>
Navigate to Court List Search
</b-button>
</b-card>
</b-card>
</b-col>
</b-row>
<b-modal v-model="openErrorModal" header-class="bg-warning text-light">
<b-card class="h4 mx-2 py-2">
<span v-if="errorCode == 403" class="p-0"> You are not authorized to access this page.</span>
<span v-else class="p-0">{{ errorText }}</span>
</b-card>
<template v-slot:modal-footer>
<b-button variant="primary" @click="openErrorModal = false">Ok</b-button>
</template>
<template v-slot:modal-header-close>
<b-button variant="outline-warning" class="text-light closeButton" @click="openErrorModal = false"
>×</b-button
>
</template>
</b-modal>
</b-card>
</template>
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { namespace } from "vuex-class";
import * as _ from "underscore";
import "@store/modules/CivilFileInformation";
const civilState = namespace("CivilFileInformation");
import "@store/modules/CriminalFileInformation";
const criminalState = namespace("CriminalFileInformation");
import { criminalFileInformationType, fileSearchCriminalInfoType } from "@/types/criminal";
import { civilFileInformationType, fileSearchCivilInfoType } from "@/types/civil";
import { courtRoomsAndLocationsInfoType, locationInfoType } from "@/types/courtlist";
import { CourtRoomsJsonInfoType } from "@/types/common";
@Component
export default class Home extends Vue {
@civilState.Action
public UpdateCivilFile!: (newCivilFileInformation: civilFileInformationType) => void;
@criminalState.Action
public UpdateCriminalFile!: (newCriminalFileInformation: criminalFileInformationType) => void;
selected = "criminal";
selectedFileSearch = "criminal";
options = [
{ value: "civil", text: "Civil" },
{ value: "criminal", text: "Criminal" },
];
fileInformation = {};
fileSearch = {};
errorCode = 0;
errorText = "";
openErrorModal = false;
syncFlag = true;
searchingRequest = false;
searchAllowed = true;
isLocationDataMounted = false;
isLocationDataReady = false;
courtRoomsAndLocationsJson: CourtRoomsJsonInfoType[] = [];
courtRoomsAndLocations: courtRoomsAndLocationsInfoType[] = [];
fileSearchCivilInfo: fileSearchCivilInfoType[] = [];
fileSearchCriminalInfo: fileSearchCriminalInfoType[] = [];
selectedCourtLocation = {} as locationInfoType;
selectedCourtLocationState = true;
// TODO: add validation so that the user has to enter values before clicking the search button
public navigateToDocumentsView(fileInformation): void {
if (this.selected == "civil") {
this.UpdateCivilFile(fileInformation);
this.$router.push({ name: "CivilCaseDetails", params: { fileNumber: fileInformation.fileNumber } });
} else if (this.selected == "criminal") {
this.UpdateCriminalFile(fileInformation);
this.$router.push({ name: "CriminalCaseDetails", params: { fileNumber: fileInformation.fileNumber } });
}
}
public navigateToFilesView(fileSearch): void {
fileSearch.location = this.selectedCourtLocation.LocationID;
if (this.selectedFileSearch == "civil") {
this.$router.push({
name: "CivilFileSearchResultsView",
query: { fileNumber: fileSearch.fileNumber, location: fileSearch.location },
});
} else if (this.selectedFileSearch == "criminal") {
this.$router.push({
name: "CriminalFileSearchResultsView",
query: { fileNumber: fileSearch.fileNumber, location: fileSearch.location },
});
}
}
mounted() {
this.getListOfAvailableCourts();
}
public getListOfAvailableCourts(): void {
this.errorCode = 0;
this.$http
.get("api/location/court-rooms")
.then(
(Response) => Response.json(),
(err) => {
this.errorCode = err.status;
this.errorText = err.statusText;
if (this.errorCode != 401) {
this.$bvToast.toast(`Error - ${this.errorCode} - ${this.errorText}`, {
title: "An error has occured.",
variant: "danger",
autoHideDelay: 10000,
});
}
console.log(this.errorCode);
}
)
.then((data) => {
if (data) {
this.courtRoomsAndLocationsJson = data;
this.ExtractCourtRoomsAndLocationsInfo();
if (this.courtRoomsAndLocations.length > 0) {
this.isLocationDataReady = true;
}
}
this.isLocationDataMounted = true;
});
}
public ExtractCourtRoomsAndLocationsInfo() {
for (const jroomAndLocation of this.courtRoomsAndLocationsJson) {
if (jroomAndLocation.courtRooms.length > 0) {
const roomAndLocationInfo = {} as courtRoomsAndLocationsInfoType;
roomAndLocationInfo.text = jroomAndLocation.name + " (" + jroomAndLocation.code + ")";
roomAndLocationInfo.value = {} as locationInfoType;
roomAndLocationInfo.value.Location = jroomAndLocation.name;
roomAndLocationInfo.value.LocationID = jroomAndLocation.code;
this.courtRoomsAndLocations.push(roomAndLocationInfo);
}
}
this.courtRoomsAndLocations = _.sortBy(this.courtRoomsAndLocations, "text");
this.selectedCourtLocation = this.courtRoomsAndLocations[0].value;
}
public LocationChanged() {
this.searchingRequest = false;
this.selectedCourtLocationState = true;
this.syncFlag = false;
this.syncFlag = true;
}
public navigateToCourtList(): void {
this.$router.push({ name: "CourtList" });
}
}
</script>
<style scoped>
input,
select {
width: 300px;
}
.card {
border: white;
}
</style>