@byu-oit/vue-decision-processing-components 9.1.0 → 9.3.0
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.
- package/DetailsMission.vue +5 -2
- package/FilterButtonAdmitPeriod.vue +61 -29
- package/dateTimeFormat.js +29 -0
- package/package.json +1 -1
package/DetailsMission.vue
CHANGED
|
@@ -101,10 +101,13 @@ export default {
|
|
|
101
101
|
formatEndDate () {
|
|
102
102
|
if (!this.mission) return ''
|
|
103
103
|
const yyyyMmDd = /^[0-9]{4}-([0][1-9]||[1][0-2])-([0][1-9]||[1-2][0-9]||[3][0-1])$/
|
|
104
|
+
const yyyyMm = /^[0-9]{4}-([0][1-9]||[1][0-2])$/
|
|
104
105
|
if (this.mission.endMonth === 'Ongoing') return 'Ongoing'
|
|
105
106
|
const endDate = this.mission.endMonth
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
const yyyyMmDdResult = yyyyMmDd.test(endDate)
|
|
108
|
+
const yyyyMmResult = yyyyMm.test(endDate)
|
|
109
|
+
if (!endDate || (!yyyyMmDdResult && !yyyyMmResult)) return ''
|
|
110
|
+
if (!yyyyMmDdResult) return dayjs(endDate).format('YYYY/MM')
|
|
108
111
|
return dayjs(endDate).format('YYYY/MM/DD')
|
|
109
112
|
},
|
|
110
113
|
estimateStartDate() {
|
|
@@ -14,45 +14,61 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
-->
|
|
16
16
|
<template>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
17
|
+
<FilterButton @show="show = true" @hide="show = false" :show="show">
|
|
18
|
+
<FontAwesomeIcon slot="icon" :icon="calendarIcon" />
|
|
19
|
+
<span slot="label">Admit Period</span>
|
|
20
|
+
<button class="dropdown-item" @click="clearFilter">Show All</button>
|
|
21
|
+
<div
|
|
22
|
+
v-for="(admitPeriod, i) of getAdmitPeriodList()"
|
|
23
|
+
:key="i"
|
|
24
|
+
class="dropdown-item"
|
|
25
|
+
>
|
|
26
|
+
<input
|
|
27
|
+
type="checkbox"
|
|
28
|
+
:id="`filter-button-admit-period-option-${i}`"
|
|
29
|
+
:value="admitPeriod"
|
|
30
|
+
:checked="selectedPeriods.includes(admitPeriod)"
|
|
31
|
+
@change="toggle(admitPeriod)"
|
|
32
|
+
></input>
|
|
33
|
+
<label :for="`filter-button-admit-period-option-${i}`">{{getAdmitPeriodTextFilter(admitPeriod) }}</label>
|
|
34
|
+
</div>
|
|
35
|
+
</FilterButton>
|
|
36
36
|
</template>
|
|
37
37
|
<script>
|
|
38
38
|
import FilterButton from './FilterButton'
|
|
39
|
-
import { yearTermLongFormat } from './dateTimeFormat'
|
|
39
|
+
import { yearTermLongFormat, yearTermLongFormatV2 } from './dateTimeFormat'
|
|
40
40
|
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
|
|
41
41
|
import { faCalendarAlt } from '@fortawesome/free-solid-svg-icons'
|
|
42
|
-
import { mapGetters, mapMutations, mapActions } from 'vuex'
|
|
42
|
+
import { mapGetters, mapMutations, mapActions, mapState } from 'vuex'
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
function calcAdmitPeriodV2() {
|
|
46
|
+
const currentMonth = new Date().getMonth() + 1 // JavaScript months are 0-indexed
|
|
47
|
+
let currentYear = new Date().getFullYear()
|
|
48
|
+
// EC has 6 admit periods. This feels cleaner than a bunch of if statements.
|
|
49
|
+
let startAdmitPeriod = Math.floor(currentMonth / 2);
|
|
50
|
+
if (startAdmitPeriod === 0) startAdmitPeriod = 1;
|
|
51
|
+
let admitPeriods = []
|
|
52
|
+
for (let i = 0; i < 6; i ++) {
|
|
53
|
+
if (startAdmitPeriod > 6) {
|
|
54
|
+
startAdmitPeriod = 1
|
|
55
|
+
currentYear++
|
|
56
|
+
}
|
|
57
|
+
admitPeriods.push(`${currentYear}${startAdmitPeriod}`)
|
|
58
|
+
startAdmitPeriod++
|
|
59
|
+
}
|
|
60
|
+
return admitPeriods
|
|
61
|
+
}
|
|
43
62
|
|
|
44
63
|
function calcAdmitPeriods () {
|
|
45
64
|
const currentMonth = new Date().getMonth() + 1 // JavaScript months are 0-indexed
|
|
46
65
|
const currentYear = new Date().getFullYear()
|
|
47
|
-
|
|
48
66
|
if (currentMonth >= 1 && currentMonth <= 4) { // Spring Evaluated: January-April
|
|
49
67
|
return [`${currentYear}1`, `${currentYear}3`, `${currentYear}5`, `${currentYear + 1}1`]
|
|
50
|
-
}
|
|
51
|
-
else if (currentMonth >= 5 && currentMonth <= 8) { // Fall Evaluated: May - August
|
|
68
|
+
} else if (currentMonth >= 5 && currentMonth <= 8) { // Fall Evaluated: May - August
|
|
52
69
|
return [`${currentYear}3`, `${currentYear}5`, `${currentYear + 1}1`, `${currentYear + 1}3`]
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return [`${currentYear}5`, `${currentYear+1}1`, `${currentYear+1}3`, `${currentYear + 1}5`]
|
|
70
|
+
} else if (currentMonth >= 9 && currentMonth <= 12) { // Winter Evaluated: September - December
|
|
71
|
+
return [`${currentYear}5`, `${currentYear + 1}1`, `${currentYear + 1}3`, `${currentYear + 1}5`]
|
|
56
72
|
}
|
|
57
73
|
return []
|
|
58
74
|
}
|
|
@@ -60,17 +76,20 @@ function calcAdmitPeriods () {
|
|
|
60
76
|
export default {
|
|
61
77
|
name: 'FilterButtonAdmitPeriod',
|
|
62
78
|
components: { FilterButton, FontAwesomeIcon },
|
|
63
|
-
filters: { yearTerm: yearTermLongFormat },
|
|
64
79
|
props: {
|
|
65
80
|
admitPeriods: {
|
|
66
81
|
type: Array,
|
|
67
82
|
default() {
|
|
68
|
-
return
|
|
83
|
+
return []
|
|
69
84
|
}
|
|
70
85
|
}
|
|
86
|
+
},
|
|
87
|
+
mounted () {
|
|
88
|
+
|
|
71
89
|
},
|
|
72
90
|
computed: {
|
|
73
91
|
...mapGetters(['packetListFilters']),
|
|
92
|
+
...mapState({institution: state => state?.ui?.institution}),
|
|
74
93
|
calendarIcon: () => faCalendarAlt,
|
|
75
94
|
activeFilter () {
|
|
76
95
|
const filters = this.packetListFilters
|
|
@@ -110,6 +129,19 @@ export default {
|
|
|
110
129
|
this.clearPacketListFilter({type: 'admitPeriod'})
|
|
111
130
|
this.fetchPacketList({force: true})
|
|
112
131
|
this.show = false
|
|
132
|
+
},
|
|
133
|
+
getAdmitPeriodList() {
|
|
134
|
+
if (this.institution === 'EC') {
|
|
135
|
+
return calcAdmitPeriodV2()
|
|
136
|
+
}
|
|
137
|
+
return calcAdmitPeriods()
|
|
138
|
+
},
|
|
139
|
+
getAdmitPeriodTextFilter(period) {
|
|
140
|
+
if (this.institution === 'EC') {
|
|
141
|
+
return yearTermLongFormatV2(period)
|
|
142
|
+
|
|
143
|
+
}
|
|
144
|
+
return yearTermLongFormat(period)
|
|
113
145
|
}
|
|
114
146
|
}
|
|
115
147
|
}
|
package/dateTimeFormat.js
CHANGED
|
@@ -42,6 +42,7 @@ export const timeFormat = value => {
|
|
|
42
42
|
return fmt(new Date(value))
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
// V2 versions of these functions were written to allow Ensign to view applications based on their new block schedule.
|
|
45
46
|
export const yearTermFormat = value => {
|
|
46
47
|
if (!value) return value
|
|
47
48
|
if (!/^[0-9]{4}[1345]$/.test(value)) return value
|
|
@@ -54,6 +55,20 @@ export const yearTermFormat = value => {
|
|
|
54
55
|
return value.substr(0, 4).concat(term)
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
export const yearTermFormatV2 = value => {
|
|
59
|
+
if (!value) return value
|
|
60
|
+
if (!/^[0-9]{4}[1-6]$/.test(value)) return value
|
|
61
|
+
const term = {
|
|
62
|
+
1: 'W1',
|
|
63
|
+
2: 'W2',
|
|
64
|
+
3: 'S1',
|
|
65
|
+
4: 'S2',
|
|
66
|
+
5: 'F1',
|
|
67
|
+
6: 'F2'
|
|
68
|
+
}[value.substr(-1)]
|
|
69
|
+
return value.substr(0, 4).concat(term)
|
|
70
|
+
}
|
|
71
|
+
|
|
57
72
|
export const yearTermLongFormat = value => {
|
|
58
73
|
if (!value) return value
|
|
59
74
|
if (!/^[0-9]{4}[1345]$/.test(value)) return value
|
|
@@ -65,3 +80,17 @@ export const yearTermLongFormat = value => {
|
|
|
65
80
|
}[value.substr(-1)]
|
|
66
81
|
return `${term} ${value.substr(0, 4)}`
|
|
67
82
|
}
|
|
83
|
+
|
|
84
|
+
export const yearTermLongFormatV2 = value => {
|
|
85
|
+
if (!value) return value
|
|
86
|
+
if (!/^[0-9]{4}[1-6]$/.test(value)) return value
|
|
87
|
+
const term = {
|
|
88
|
+
1: 'Winter 1',
|
|
89
|
+
2: 'Winter 2',
|
|
90
|
+
3: 'Spring 1',
|
|
91
|
+
4: 'Spring 2',
|
|
92
|
+
5: 'Fall 1',
|
|
93
|
+
6: 'Fall 2'
|
|
94
|
+
}[value.substr(-1)]
|
|
95
|
+
return `${term} ${value.substr(0, 4)}`
|
|
96
|
+
}
|
package/package.json
CHANGED