@byu-oit/vue-decision-processing-components 8.35.8 → 8.35.10

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 (136) hide show
  1. package/.github/CODEOWNERS +1 -0
  2. package/.github/workflows/deploy.yml +40 -50
  3. package/.repo-meta.yml +55 -55
  4. package/AdmitPeriodConfig.vue +115 -115
  5. package/ApiCallButton.vue +91 -91
  6. package/ApplicantInfo.vue +100 -100
  7. package/AssignmentBulkDialog.vue +153 -153
  8. package/AssignmentDialog.vue +117 -117
  9. package/AssignmentSummary.vue +75 -75
  10. package/BackgroundBadge.vue +83 -83
  11. package/BackgroundDetailCrime.vue +78 -78
  12. package/BackgroundDetailPluralMarriage.vue +43 -43
  13. package/BackgroundDetailSexRegistry.vue +43 -43
  14. package/BackgroundDetailUniversity.vue +37 -37
  15. package/CHANGELOG.md +676 -676
  16. package/Dashboard.vue +201 -201
  17. package/DashboardApplicationList.vue +50 -50
  18. package/DecisionDialog.vue +178 -178
  19. package/Details.vue +124 -124
  20. package/DetailsActivity.vue +59 -59
  21. package/DetailsBackground.vue +143 -143
  22. package/DetailsBackgroundDetail.vue +47 -47
  23. package/DetailsBackgroundSummary.vue +66 -66
  24. package/DetailsCesHold.vue +107 -107
  25. package/DetailsCollege.vue +93 -93
  26. package/DetailsContact.vue +65 -65
  27. package/DetailsDecision.vue +183 -183
  28. package/DetailsDecisionHistory.vue +56 -56
  29. package/DetailsEndorsement.vue +74 -74
  30. package/DetailsEssay.vue +59 -59
  31. package/DetailsFilenote.vue +62 -62
  32. package/DetailsFilenoteList.vue +109 -109
  33. package/DetailsFlagSection.vue +176 -176
  34. package/DetailsHeader.vue +263 -263
  35. package/DetailsHighSchool.vue +99 -99
  36. package/DetailsHsTranscript.vue +100 -100
  37. package/DetailsInstitute.vue +90 -90
  38. package/DetailsMission.vue +88 -88
  39. package/DetailsNewAppHistory.vue +50 -50
  40. package/DetailsNotes.vue +83 -83
  41. package/DetailsPathway.vue +45 -45
  42. package/DetailsScoringSection.vue +128 -128
  43. package/DetailsSection.vue +116 -116
  44. package/DetailsSeminary.vue +184 -184
  45. package/DetailsSrs.vue +52 -52
  46. package/DetailsSubnav.vue +54 -54
  47. package/DetailsTestScores.vue +131 -131
  48. package/ExpandIndicator.vue +75 -75
  49. package/ExternalLink.vue +34 -34
  50. package/FilterBreadcrumb.vue +85 -85
  51. package/FilterButton.vue +86 -86
  52. package/FilterButtonAdmitPeriod.vue +104 -104
  53. package/FilterButtonAppType.vue +103 -103
  54. package/FilterButtonAssignedTo.vue +96 -96
  55. package/FilterButtonClearFilters.vue +65 -65
  56. package/FilterButtonSex.vue +105 -105
  57. package/FlagButton.vue +59 -59
  58. package/FlagDialog.vue +129 -129
  59. package/Footer.vue +432 -432
  60. package/Header.vue +132 -132
  61. package/HighSchoolSummary.vue +60 -60
  62. package/InternationalIndicator.vue +44 -44
  63. package/InternationalStatus.vue +48 -48
  64. package/LICENSE +201 -201
  65. package/LoadingBadge.vue +58 -58
  66. package/ManageAssignments.vue +123 -123
  67. package/NoAuth.vue +14 -14
  68. package/NoteDialog.vue +106 -106
  69. package/ObjectViewer.vue +49 -49
  70. package/Queues.vue +278 -268
  71. package/QuickLinks.vue +25 -25
  72. package/README.md +2 -2
  73. package/RecentApplications.vue +53 -53
  74. package/Report.vue +340 -340
  75. package/ReportDetail.vue +279 -279
  76. package/ReportList.vue +87 -87
  77. package/ReportPhotos.vue +65 -65
  78. package/ReportSvg.vue +78 -78
  79. package/ReportViewer.vue +165 -165
  80. package/RequestAccess.vue +14 -14
  81. package/RequestAccessList.vue +45 -45
  82. package/RoleSelector.vue +29 -29
  83. package/Search.vue +22 -22
  84. package/ShowApplicantIds.vue +100 -100
  85. package/SortableHeader.vue +53 -53
  86. package/Spinner.vue +34 -34
  87. package/StarredIndicator.vue +36 -36
  88. package/StatBox.vue +73 -73
  89. package/StatCharts.vue +196 -196
  90. package/SupportDialog.vue +172 -172
  91. package/UserInfo.vue +52 -52
  92. package/YesNoIndicator.vue +48 -48
  93. package/dateTimeFormat.js +67 -67
  94. package/gpaCalculation.js +162 -162
  95. package/gpaFilter.js +5 -5
  96. package/hsSummary.json +2019 -2019
  97. package/package.json +37 -36
  98. package/parsers/application.js +396 -396
  99. package/parsers/decisionHistory.js +27 -27
  100. package/parsers/filenotes.js +27 -27
  101. package/parsers/notes.js +49 -49
  102. package/parsers/packet.js +88 -88
  103. package/parsers/packetList.js +57 -57
  104. package/parsers/reports.js +13 -13
  105. package/sat2Act.js +46 -46
  106. package/test.js +48 -48
  107. package/themes/ByuiFooter.vue +38 -38
  108. package/themes/ByuiHeader.vue +96 -96
  109. package/themes/LdsbcFooter.vue +38 -38
  110. package/themes/LdsbcHeader.vue +100 -100
  111. package/vuexModules/application/activity.js +32 -32
  112. package/vuexModules/application/applicationList.js +71 -71
  113. package/vuexModules/application/background.js +47 -47
  114. package/vuexModules/application/bio.js +38 -38
  115. package/vuexModules/application/citizenship.js +30 -30
  116. package/vuexModules/application/collegeSummaries.js +32 -32
  117. package/vuexModules/application/essay.js +26 -26
  118. package/vuexModules/application/highSchoolSummaries.js +40 -40
  119. package/vuexModules/application/index.js +157 -157
  120. package/vuexModules/application/institute.js +30 -30
  121. package/vuexModules/application/mission.js +48 -48
  122. package/vuexModules/application/personalRecords.js +24 -24
  123. package/vuexModules/application/questions.js +23 -23
  124. package/vuexModules/application/seminary.js +39 -39
  125. package/vuexModules/application/testScores.js +26 -26
  126. package/vuexModules/notes/index.js +22 -22
  127. package/vuexModules/packet/decision.js +43 -43
  128. package/vuexModules/packet/decisionHistory.js +28 -28
  129. package/vuexModules/packet/flags.js +174 -174
  130. package/vuexModules/packet/index.js +52 -52
  131. package/vuexModules/packet/packetList.js +127 -127
  132. package/vuexModules/packet/processes.js +28 -28
  133. package/vuexModules/reports/index.js +32 -32
  134. package/vuexModules/ui/index.js +56 -56
  135. package/vuexModules/users/index.js +46 -46
  136. package/yyyyMmFilter.js +7 -7
package/Report.vue CHANGED
@@ -1,340 +1,340 @@
1
- <!--
2
- Copyright 2018 Brigham Young University
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License")
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- -->
16
- <template>
17
- <div class="report" v-if="metadata">
18
- <ReportSvg
19
- v-if="chart"
20
- v-bind="$attrs"
21
- v-on="$listeners"
22
- :svgContent="svgContent"
23
- :loaded="loaded"
24
- :error="error"/>
25
- <template v-if="!hideDescription">
26
- <h1 v-if="metadata.description">{{metadata.description}}</h1>
27
- <h4 v-if="metadata.long_description" class="no-uppercase">{{metadata.long_description}}</h4>
28
- <byu-control-date-selector
29
- v-if="metadata.parameters.includes('admitPeriod')"
30
- :value="selectedAdmitPeriod"
31
- @change="selectedAdmitPeriod = $event.target.value"
32
- date-type="CURRENT_YYT"
33
- prior-terms="3"
34
- subsequent-terms="4"
35
- ></byu-control-date-selector>
36
- <date-picker
37
- v-if="metadata.parameters.includes('date_start') && metadata.parameters.includes('date_end')"
38
- v-model="dateRange"
39
- range
40
- :not-after="new Date()"
41
- lang="en"
42
- />
43
- </template>
44
- <template v-if="detail && photoLink">
45
- <div>
46
- <input type="checkbox" v-model="showPhotos" id="components-Report-showPhotos">
47
- <label for="components-Report-showPhotos">Show Photos</label>
48
- </div>
49
- <ReportPhotos
50
- v-if="showPhotos"
51
- :rows="rows"
52
- :column-metadata="metadata.columns"
53
- :loading="loading"
54
- :error="error"/>
55
- <ReportDetail
56
- v-else
57
- :csv="csvContent"
58
- :column-metadata="metadata.columns"
59
- :rows="rows"
60
- :loading="loading"
61
- :error="error"
62
- :detailPath="detailPath"
63
- :newTab="newTab"/>
64
- </template>
65
- <template v-else>
66
- <ReportDetail
67
- v-if="detail"
68
- :csv="csvContent"
69
- :column-metadata="metadata.columns"
70
- :rows="rows"
71
- :loading="loading"
72
- :error="error"
73
- :detailPath="detailPath"
74
- :newTab="newTab" />
75
- </template>
76
- <router-link v-else-if="to" :to="to">View Details</router-link>
77
- </div>
78
- </template>
79
-
80
- <script>
81
- import { parse } from 'csv-string'
82
- import ReportDetail from './ReportDetail.vue'
83
- import ReportPhotos from './ReportPhotos.vue'
84
- import ReportSvg from './ReportSvg.vue'
85
- import Reports from './vuexModules/reports'
86
- import DatePicker from 'vue2-datepicker'
87
-
88
- let tabHiddenState = document.hidden
89
-
90
- export default {
91
- name: 'Report',
92
- components: { DatePicker, ReportDetail, ReportPhotos, ReportSvg },
93
- props: {
94
- reportName: {
95
- type: String,
96
- required: true
97
- },
98
- baseUrl: {
99
- type: String,
100
- required: true
101
- },
102
- chart: Boolean,
103
- detail: Boolean,
104
- to: [String, Object],
105
- detailPath: {
106
- type: String,
107
- default: '/report'
108
- },
109
- loadData: Boolean,
110
- admitPeriod: {
111
- type: String
112
- },
113
- paginationParameter: {
114
- type: String
115
- },
116
- limit: {
117
- type: String
118
- },
119
- hideDescription: Boolean,
120
- newTab: Boolean,
121
- autoRefresh: Boolean,
122
- setById: {
123
- type: String,
124
- default: ''
125
- }
126
- },
127
- data () {
128
- return {
129
- loading: false,
130
- loaded: false,
131
- error: false,
132
- svgContent: null,
133
- csvContent: null,
134
- rows: null,
135
- selectedAdmitPeriod: this.admitPeriod,
136
- dateRange: null,
137
- showPhotos: false,
138
- paginateReport: this.paginationParameter,
139
- newCursor: 'null'
140
- }
141
- },
142
- computed: {
143
- metadata () {
144
- return this.$store.getters.reportMetadata(this.reportName)
145
- },
146
- photoLink () {
147
- const columnMetadata = this.metadata.columns
148
- return columnMetadata && columnMetadata.find(m => m.qualifier.includes('link_photo'))
149
- }
150
- },
151
- methods: {
152
- async loadReports () {
153
- if(!this.metadata) {
154
- // wait for metadata before trying to load report
155
- return
156
- }
157
- this.loaded = false
158
- this.error = false
159
- this.loading = true
160
- this.$emit('loading')
161
- window.scrollTo(0, 0)
162
-
163
- const q = new URLSearchParams()
164
- q.append('name', this.reportName)
165
- if (this.selectedAdmitPeriod) {
166
- q.append('admit_period', this.selectedAdmitPeriod)
167
- } else if(this.metadata.parameters.includes('admitPeriod')) {
168
- // Don't attempt to load report if we're missing the admit period
169
- return
170
- }
171
- if (this.paginateReport && this.paginateReport !== 'null') {
172
- q.append('pagination_parameter', this.paginateReport)
173
- q.append('limit', this.limit)
174
- q.append('cursor', this.newCursor)
175
- }
176
- if (this.dateRange) {
177
- const toYYYYMMDD = dt => dt.toISOString().substr(0, 10)
178
- const startDate = toYYYYMMDD(this.dateRange[0])
179
- const endDate = toYYYYMMDD(this.dateRange[1])
180
- q.append('date_start', startDate)
181
- q.append('date_end', endDate)
182
- }
183
- if (this.metadata.parameters.includes('setById') && this.setById) {
184
- q.append('set_by_id', this.setById)
185
- }
186
- // appends institution if available to url search params
187
- if(this.metadata.parameters.includes('institutions')) {
188
- if(this.metadata.parameters.institutions.includes(state.institution))
189
- q.append('institution', state.institution)
190
- }
191
-
192
- const url = this.baseUrl + '?' + q.toString()
193
- const loadRequested = () => {
194
- let promises = []
195
- if (this.chart) {
196
- promises.push(this.loadSvg(url))
197
- }
198
- if (this.detail || this.loadData) {
199
- promises.push(this.loadCsv(url))
200
- }
201
- return promises
202
- }
203
- const promises = loadRequested()
204
- try {
205
- await Promise.all(promises)
206
- this.loaded = true
207
- this.loading = false
208
- } catch (err) {
209
- console.error(err)
210
- this.error = true
211
- this.loading = false
212
- }
213
- },
214
- async loadSvg (url) {
215
- const svg = await this.loadReport(url, 'image/svg+xml')
216
- this.svgContent = svg
217
- },
218
- async loadCsv (url) {
219
- let csv = ''
220
- do {
221
- const reportResponse = await this.loadReport(url, 'text/csv')
222
- csv = csv + reportResponse
223
- const q = this.getQuery()
224
- url = this.baseUrl + '?' + q.toString()
225
- } while (this.newCursor && this.newCursor !== 'null')
226
-
227
- if (csv && csv.length > 0 && /\n/.test(csv)) {
228
- this.csvContent = csv
229
- const [headData, ...data] = parse(csv)
230
- this.rows = data
231
- this.$emit('csvLoaded', csv)
232
- this.$emit('reportData', { data })
233
- } else {
234
- this.headData = []
235
- this.rows = []
236
- this.$emit('csvLoaded', csv)
237
- this.$emit('reportData', { headers: [], data: [] })
238
- }
239
- },
240
- async loadReport (url, acceptHeader) {
241
- const options = {
242
- headers: {
243
- 'authorization': `Bearer ${window.byu.auth.accessToken}`,
244
- 'accept': acceptHeader
245
- },
246
- cache: 'no-store'
247
- }
248
- try {
249
- const response = await fetch(url, options)
250
- if (!response.ok) {
251
- this.error = true
252
- const err = Error(`Error ${response.status}-'${response.statusText}' while fetching report from ${url}`)
253
- console.error(err)
254
- console.error(err.stack)
255
- return null
256
- }
257
- this.newCursor = response.headers.get('Cursor')
258
- return await response.text()
259
- } catch (err) {
260
- this.error = true
261
- console.error(err)
262
- console.error(err.stack)
263
- }
264
- },
265
- reloadOnPageBackIntoFocus () {
266
- if (tabHiddenState != document.hidden) {
267
- if (!document.hidden) {
268
- this.loadReports()
269
- }
270
- }
271
- tabHiddenState = document.hidden
272
- },
273
- getQuery() {
274
- const q = new URLSearchParams()
275
- q.append('name', this.reportName)
276
- if (this.selectedAdmitPeriod) {
277
- q.append('admit_period', this.selectedAdmitPeriod)
278
- } else if(this.metadata.parameters.includes('admitPeriod')) {
279
- // Don't attempt to load report if we're missing the admit period
280
- return
281
- }
282
- if (this.paginateReport && this.paginateReport !== 'null') {
283
- q.append('pagination_parameter', this.paginateReport)
284
- q.append('limit', this.limit)
285
- q.append('cursor', this.newCursor)
286
- }
287
- if (this.dateRange) {
288
- const toYYYYMMDD = dt => dt.toISOString().substr(0, 10)
289
- const startDate = toYYYYMMDD(this.dateRange[0])
290
- const endDate = toYYYYMMDD(this.dateRange[1])
291
- q.append('date_start', startDate)
292
- q.append('date_end', endDate)
293
- }
294
- if (this.metadata.parameters.includes('setById') && this.setById) {
295
- q.append('set_by_id', this.setById)
296
- }
297
- // appends institution if available to url search params
298
- if(this.metadata.parameters.includes('institutions')) {
299
- if(this.metadata.parameters.institutions.includes(state.institution))
300
- q.append('institution', state.institution)
301
- }
302
- return q
303
- }
304
- },
305
- watch: {
306
- metadata: {
307
- handler: 'loadReports'
308
- },
309
- baseUrl: {
310
- handler: 'loadReports',
311
- immediate: true
312
- },
313
- reportName: {
314
- handler: 'loadReports'
315
- },
316
- admitPeriod(newValue) {
317
- this.selectedAdmitPeriod = newValue
318
- },
319
- selectedAdmitPeriod: 'loadReports',
320
- dateRange: 'loadReports'
321
- },
322
- mounted () {
323
- if (this.autoRefresh) {
324
- document.addEventListener('visibilitychange', this.reloadOnPageBackIntoFocus)
325
- }
326
- },
327
- beforeDestroy () {
328
- if (this.autoRefresh) {
329
- document.removeEventListener('visibilitychange', this.reloadOnPageBackIntoFocus)
330
- }
331
- }
332
- }
333
- </script>
334
- <style scoped>
335
- .no-uppercase {
336
- text-transform: none;
337
- color: var(--gray, gray);
338
- font-size: 1rem;
339
- }
340
- </style>
1
+ <!--
2
+ Copyright 2018 Brigham Young University
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License")
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ -->
16
+ <template>
17
+ <div class="report" v-if="metadata">
18
+ <ReportSvg
19
+ v-if="chart"
20
+ v-bind="$attrs"
21
+ v-on="$listeners"
22
+ :svgContent="svgContent"
23
+ :loaded="loaded"
24
+ :error="error"/>
25
+ <template v-if="!hideDescription">
26
+ <h1 v-if="metadata.description">{{metadata.description}}</h1>
27
+ <h4 v-if="metadata.long_description" class="no-uppercase">{{metadata.long_description}}</h4>
28
+ <byu-control-date-selector
29
+ v-if="metadata.parameters.includes('admitPeriod')"
30
+ :value="selectedAdmitPeriod"
31
+ @change="selectedAdmitPeriod = $event.target.value"
32
+ date-type="CURRENT_YYT"
33
+ prior-terms="3"
34
+ subsequent-terms="4"
35
+ ></byu-control-date-selector>
36
+ <date-picker
37
+ v-if="metadata.parameters.includes('date_start') && metadata.parameters.includes('date_end')"
38
+ v-model="dateRange"
39
+ range
40
+ :not-after="new Date()"
41
+ lang="en"
42
+ />
43
+ </template>
44
+ <template v-if="detail && photoLink">
45
+ <div>
46
+ <input type="checkbox" v-model="showPhotos" id="components-Report-showPhotos">
47
+ <label for="components-Report-showPhotos">Show Photos</label>
48
+ </div>
49
+ <ReportPhotos
50
+ v-if="showPhotos"
51
+ :rows="rows"
52
+ :column-metadata="metadata.columns"
53
+ :loading="loading"
54
+ :error="error"/>
55
+ <ReportDetail
56
+ v-else
57
+ :csv="csvContent"
58
+ :column-metadata="metadata.columns"
59
+ :rows="rows"
60
+ :loading="loading"
61
+ :error="error"
62
+ :detailPath="detailPath"
63
+ :newTab="newTab"/>
64
+ </template>
65
+ <template v-else>
66
+ <ReportDetail
67
+ v-if="detail"
68
+ :csv="csvContent"
69
+ :column-metadata="metadata.columns"
70
+ :rows="rows"
71
+ :loading="loading"
72
+ :error="error"
73
+ :detailPath="detailPath"
74
+ :newTab="newTab" />
75
+ </template>
76
+ <router-link v-else-if="to" :to="to">View Details</router-link>
77
+ </div>
78
+ </template>
79
+
80
+ <script>
81
+ import { parse } from 'csv-string'
82
+ import ReportDetail from './ReportDetail.vue'
83
+ import ReportPhotos from './ReportPhotos.vue'
84
+ import ReportSvg from './ReportSvg.vue'
85
+ import Reports from './vuexModules/reports'
86
+ import DatePicker from 'vue2-datepicker'
87
+
88
+ let tabHiddenState = document.hidden
89
+
90
+ export default {
91
+ name: 'Report',
92
+ components: { DatePicker, ReportDetail, ReportPhotos, ReportSvg },
93
+ props: {
94
+ reportName: {
95
+ type: String,
96
+ required: true
97
+ },
98
+ baseUrl: {
99
+ type: String,
100
+ required: true
101
+ },
102
+ chart: Boolean,
103
+ detail: Boolean,
104
+ to: [String, Object],
105
+ detailPath: {
106
+ type: String,
107
+ default: '/report'
108
+ },
109
+ loadData: Boolean,
110
+ admitPeriod: {
111
+ type: String
112
+ },
113
+ paginationParameter: {
114
+ type: String
115
+ },
116
+ limit: {
117
+ type: String
118
+ },
119
+ hideDescription: Boolean,
120
+ newTab: Boolean,
121
+ autoRefresh: Boolean,
122
+ setById: {
123
+ type: String,
124
+ default: ''
125
+ }
126
+ },
127
+ data () {
128
+ return {
129
+ loading: false,
130
+ loaded: false,
131
+ error: false,
132
+ svgContent: null,
133
+ csvContent: null,
134
+ rows: null,
135
+ selectedAdmitPeriod: this.admitPeriod,
136
+ dateRange: null,
137
+ showPhotos: false,
138
+ paginateReport: this.paginationParameter,
139
+ newCursor: 'null'
140
+ }
141
+ },
142
+ computed: {
143
+ metadata () {
144
+ return this.$store.getters.reportMetadata(this.reportName)
145
+ },
146
+ photoLink () {
147
+ const columnMetadata = this.metadata.columns
148
+ return columnMetadata && columnMetadata.find(m => m.qualifier.includes('link_photo'))
149
+ }
150
+ },
151
+ methods: {
152
+ async loadReports () {
153
+ if(!this.metadata) {
154
+ // wait for metadata before trying to load report
155
+ return
156
+ }
157
+ this.loaded = false
158
+ this.error = false
159
+ this.loading = true
160
+ this.$emit('loading')
161
+ window.scrollTo(0, 0)
162
+
163
+ const q = new URLSearchParams()
164
+ q.append('name', this.reportName)
165
+ if (this.selectedAdmitPeriod) {
166
+ q.append('admit_period', this.selectedAdmitPeriod)
167
+ } else if(this.metadata.parameters.includes('admitPeriod')) {
168
+ // Don't attempt to load report if we're missing the admit period
169
+ return
170
+ }
171
+ if (this.paginateReport && this.paginateReport !== 'null') {
172
+ q.append('pagination_parameter', this.paginateReport)
173
+ q.append('limit', this.limit)
174
+ q.append('cursor', this.newCursor)
175
+ }
176
+ if (this.dateRange) {
177
+ const toYYYYMMDD = dt => dt.toISOString().substr(0, 10)
178
+ const startDate = toYYYYMMDD(this.dateRange[0])
179
+ const endDate = toYYYYMMDD(this.dateRange[1])
180
+ q.append('date_start', startDate)
181
+ q.append('date_end', endDate)
182
+ }
183
+ if (this.metadata.parameters.includes('setById') && this.setById) {
184
+ q.append('set_by_id', this.setById)
185
+ }
186
+ // appends institution if available to url search params
187
+ if(this.metadata.parameters.includes('institutions')) {
188
+ if(this.metadata.parameters.institutions.includes(state.institution))
189
+ q.append('institution', state.institution)
190
+ }
191
+
192
+ const url = this.baseUrl + '?' + q.toString()
193
+ const loadRequested = () => {
194
+ let promises = []
195
+ if (this.chart) {
196
+ promises.push(this.loadSvg(url))
197
+ }
198
+ if (this.detail || this.loadData) {
199
+ promises.push(this.loadCsv(url))
200
+ }
201
+ return promises
202
+ }
203
+ const promises = loadRequested()
204
+ try {
205
+ await Promise.all(promises)
206
+ this.loaded = true
207
+ this.loading = false
208
+ } catch (err) {
209
+ console.error(err)
210
+ this.error = true
211
+ this.loading = false
212
+ }
213
+ },
214
+ async loadSvg (url) {
215
+ const svg = await this.loadReport(url, 'image/svg+xml')
216
+ this.svgContent = svg
217
+ },
218
+ async loadCsv (url) {
219
+ let csv = ''
220
+ do {
221
+ const reportResponse = await this.loadReport(url, 'text/csv')
222
+ csv = csv + reportResponse
223
+ const q = this.getQuery()
224
+ url = this.baseUrl + '?' + q.toString()
225
+ } while (this.newCursor && this.newCursor !== 'null')
226
+
227
+ if (csv && csv.length > 0 && /\n/.test(csv)) {
228
+ this.csvContent = csv
229
+ const [headData, ...data] = parse(csv)
230
+ this.rows = data
231
+ this.$emit('csvLoaded', csv)
232
+ this.$emit('reportData', { data })
233
+ } else {
234
+ this.headData = []
235
+ this.rows = []
236
+ this.$emit('csvLoaded', csv)
237
+ this.$emit('reportData', { headers: [], data: [] })
238
+ }
239
+ },
240
+ async loadReport (url, acceptHeader) {
241
+ const options = {
242
+ headers: {
243
+ 'authorization': `Bearer ${window.byu.auth.accessToken}`,
244
+ 'accept': acceptHeader
245
+ },
246
+ cache: 'no-store'
247
+ }
248
+ try {
249
+ const response = await fetch(url, options)
250
+ if (!response.ok) {
251
+ this.error = true
252
+ const err = Error(`Error ${response.status}-'${response.statusText}' while fetching report from ${url}`)
253
+ console.error(err)
254
+ console.error(err.stack)
255
+ return null
256
+ }
257
+ this.newCursor = response.headers.get('Cursor')
258
+ return await response.text()
259
+ } catch (err) {
260
+ this.error = true
261
+ console.error(err)
262
+ console.error(err.stack)
263
+ }
264
+ },
265
+ reloadOnPageBackIntoFocus () {
266
+ if (tabHiddenState != document.hidden) {
267
+ if (!document.hidden) {
268
+ this.loadReports()
269
+ }
270
+ }
271
+ tabHiddenState = document.hidden
272
+ },
273
+ getQuery() {
274
+ const q = new URLSearchParams()
275
+ q.append('name', this.reportName)
276
+ if (this.selectedAdmitPeriod) {
277
+ q.append('admit_period', this.selectedAdmitPeriod)
278
+ } else if(this.metadata.parameters.includes('admitPeriod')) {
279
+ // Don't attempt to load report if we're missing the admit period
280
+ return
281
+ }
282
+ if (this.paginateReport && this.paginateReport !== 'null') {
283
+ q.append('pagination_parameter', this.paginateReport)
284
+ q.append('limit', this.limit)
285
+ q.append('cursor', this.newCursor)
286
+ }
287
+ if (this.dateRange) {
288
+ const toYYYYMMDD = dt => dt.toISOString().substr(0, 10)
289
+ const startDate = toYYYYMMDD(this.dateRange[0])
290
+ const endDate = toYYYYMMDD(this.dateRange[1])
291
+ q.append('date_start', startDate)
292
+ q.append('date_end', endDate)
293
+ }
294
+ if (this.metadata.parameters.includes('setById') && this.setById) {
295
+ q.append('set_by_id', this.setById)
296
+ }
297
+ // appends institution if available to url search params
298
+ if(this.metadata.parameters.includes('institutions')) {
299
+ if(this.metadata.parameters.institutions.includes(state.institution))
300
+ q.append('institution', state.institution)
301
+ }
302
+ return q
303
+ }
304
+ },
305
+ watch: {
306
+ metadata: {
307
+ handler: 'loadReports'
308
+ },
309
+ baseUrl: {
310
+ handler: 'loadReports',
311
+ immediate: true
312
+ },
313
+ reportName: {
314
+ handler: 'loadReports'
315
+ },
316
+ admitPeriod(newValue) {
317
+ this.selectedAdmitPeriod = newValue
318
+ },
319
+ selectedAdmitPeriod: 'loadReports',
320
+ dateRange: 'loadReports'
321
+ },
322
+ mounted () {
323
+ if (this.autoRefresh) {
324
+ document.addEventListener('visibilitychange', this.reloadOnPageBackIntoFocus)
325
+ }
326
+ },
327
+ beforeDestroy () {
328
+ if (this.autoRefresh) {
329
+ document.removeEventListener('visibilitychange', this.reloadOnPageBackIntoFocus)
330
+ }
331
+ }
332
+ }
333
+ </script>
334
+ <style scoped>
335
+ .no-uppercase {
336
+ text-transform: none;
337
+ color: var(--gray, gray);
338
+ font-size: 1rem;
339
+ }
340
+ </style>