@byu-oit/vue-decision-processing-components 8.36.2 → 8.37.0-1

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.
@@ -15,126 +15,82 @@
15
15
  -->
16
16
  <template>
17
17
  <div class="ces-hold">
18
- <span
19
- v-if="loaded"
20
- :class="holdSet ? flagClass : noFlagClass"
21
- >
22
- <font-awesome-icon :icon="holdIcon" />
23
- {{ holdSet ? 'CES Standards Hold' : 'No CES Standards Hold' }}
24
- </span>
25
- <span v-else-if="error" class="text-error">
26
- <font-awesome-icon :icon="holdIcon" />
27
- Error checking CES Standards Hold
28
- </span>
29
- <span v-else class="text-gray">
30
- <font-awesome-icon :icon="spinner" spin />
31
- Loading...
18
+ <span :class="statusClass">
19
+ <font-awesome-icon :icon="flagIcon" />
20
+
21
+ {{cesHoldStatus}}
32
22
  </span>
33
23
  </div>
34
24
  </template>
35
25
  <script>
36
- import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
37
- import { faCheck, faExclamationTriangle, faQuestionCircle, faSpinner } from '@fortawesome/free-solid-svg-icons'
26
+ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
27
+ import { faCheck, faExclamationTriangle, faSquare, faMinus, faHourglassHalf, faQuestionCircle } from '@fortawesome/free-solid-svg-icons'
38
28
 
39
- import { mapState } from 'vuex'
29
+ import { mapGetters } from 'vuex'
40
30
 
41
- export default {
42
- name: 'DetailsCesHold',
43
- components: {
44
- FontAwesomeIcon
45
- },
46
- props: {
47
- flagClass: {
48
- type: String,
49
- default: 'text-error'
50
- },
51
- noFlagClass: {
52
- type: String,
53
- default: 'text-secondary'
54
- }
55
- },
56
- data () {
57
- return {
58
- error: false,
59
- loaded: false,
60
- holdSet: false
61
- }
62
- },
63
- computed: {
64
- ...mapState({
65
- env: 'environment',
66
- applicantId: state => state.application.applicantId,
67
- applicantFirstName: state => state.application.basic.preferredFirstName,
68
- applicantSurname: state => state.application.basic.surname,
69
- applicantDob: state => state.application.personalRecords.dateOfBirth
70
- }),
71
- spinner () { return faSpinner },
72
- holdIcon () {
73
- return this.holdSet ? faExclamationTriangle : this.error ? faQuestionCircle : faCheck
31
+ export default {
32
+ name: 'DetailsCesHold',
33
+ components: {
34
+ FontAwesomeIcon
35
+ },
36
+ computed: {
37
+ ...mapGetters([ 'flagByValue' ]),
38
+ flag() { return this.flagByValue('cesHolds') },
39
+ statusClass() {
40
+ if (this.flag != null){
41
+ switch(this.flag.state.toLowerCase()){
42
+ case 'pass':
43
+ return { 'text-success': true }
44
+ case 'fail':
45
+ return { 'text-danger': true }
46
+ case 'error':
47
+ return { 'text-danger': true, 'font-weight-bold': true }
48
+ case 'indeterminate':
49
+ return { 'text-dark': true }
50
+ default:
51
+ return { 'text-danger': true, 'font-weight-bold': true }
52
+ }
74
53
  }
75
54
  },
76
- methods: {
77
- getByuId: async function () {
78
- try {
79
- const surname = this.applicantSurname ? this.applicantSurname.trim() : ''
80
- const preferredFirstName = this.applicantFirstName ? this.applicantFirstName.trim() : ''
81
- const applicantDob = this.applicantDob ? new Date(this.applicantDob).toISOString().split('T')[0].trim() : ''
82
- const url = this.env === 'production'
83
- ? `https://api.byu.edu/byuapi/persons/v4/?preferred_first_name=${preferredFirstName}&surname=${surname}&vital_record.date_of_birth=${applicantDob}`
84
- : `https://api-sandbox.byu.edu/byuapi/persons/v4/?preferred_first_name=${preferredFirstName}&surname=${surname}&vital_record.date_of_birth=${applicantDob}`
85
-
86
- const { body, status } = await window.byu.auth.request({ url })
87
- if (status >= 400) {
88
- this.error = true
89
- return null
90
- }
91
-
92
- const data = JSON.parse(body)
93
- const recordCount = data.values.length
94
-
95
- if (recordCount !== 1) {
96
- return null
97
- }
98
-
99
- return data.values[0].byu_id.value
100
- } catch (err) {
101
- console.error(err)
102
- this.error = true
55
+ flagIcon() {
56
+ if (this.flag != null) {
57
+ switch (this.flag.state.toLowerCase()) {
58
+ case 'pass':
59
+ return faCheck
60
+ case 'fail':
61
+ return faMinus
62
+ case 'error':
63
+ return faExclamationTriangle
64
+ case 'indeterminate':
65
+ return faSquare
66
+ default:
67
+ return faExclamationTriangle
103
68
  }
104
69
  }
105
70
  },
106
- async mounted () {
107
- const applicantId = this.applicantId ? this.applicantId : await this.getByuId()
108
- if (!applicantId) {
109
- this.error = true
110
- return
111
- }
112
- try {
113
- const url = this.env !== 'development'
114
- ? `https://api.byu.edu/recordsYAPI/v1.0/student/byuId/${applicantId.trim()}/CESflagsHolds`
115
- : `https://api-sandbox.byu.edu/recordsYAPI/v1.0/student/byuId/${applicantId.trim()}/CESflagsHolds`
116
- const { body, status } = await window.byu.auth.request({ url })
117
- if (status >= 400) {
118
- this.error = true
119
- return
71
+ cesHoldStatus() {
72
+ if (this.flag != null) {
73
+ if (this.flag.message != null && this.flag.message.length > 0) {
74
+ return this.flag.message
120
75
  }
121
- const data = JSON.parse(body)
122
- const recordCount = data.metadata.rows
123
-
124
- if (recordCount > 0) {
125
- this.holdSet = true
126
- this.$emit('ces-hold-set')
127
- } else {
128
- this.$emit('ces-hold-clear')
76
+ else {
77
+ switch (this.flag.state.toLowerCase()) {
78
+ case 'pass':
79
+ return 'Everything looks good!'
80
+ case 'fail':
81
+ return 'Requires additional attention.'
82
+ case 'error':
83
+ return 'An error occurred. Try again later.'
84
+ case 'indeterminate':
85
+ return 'No data available.'
86
+ default:
87
+ return 'An error occurred. Try again later.'
88
+ }
129
89
  }
130
-
131
- this.loaded = true
132
- } catch (err) {
133
- console.error(err)
134
- this.error = true
135
90
  }
136
91
  }
137
92
  }
93
+ }
138
94
  </script>
139
95
  <style scoped>
140
96
  </style>
@@ -29,7 +29,7 @@
29
29
  </template>
30
30
  <script>
31
31
  import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
32
- import { faCheck, faHourglassHalf, faExclamationTriangle } from '@fortawesome/free-solid-svg-icons'
32
+ import { faCheck, faExclamationTriangle, faSquare, faMinus, faHourglassHalf } from '@fortawesome/free-solid-svg-icons'
33
33
  import { mapState, mapGetters } from 'vuex'
34
34
 
35
35
  export default {
@@ -44,19 +44,70 @@
44
44
  endorsementPendingFlag () { return this.flagByValue('EP') },
45
45
  endorsementDeniedFlag () { return this.flagByValue('ED') },
46
46
  endorsementIssuesFlag () { return this.flagByValue('EI') },
47
+ endorsementNewFlag () { return this.flagByValue('endorsement')},
47
48
  icon () {
49
+ if (this.endorsementNewFlag != null){
50
+ switch(this.endorsementNewFlag.state.toLowerCase()){
51
+ case 'pass':
52
+ return faCheck
53
+ case 'fail':
54
+ return faMinus
55
+ case 'error':
56
+ return faExclamationTriangle
57
+ case 'indeterminate':
58
+ return faSquare
59
+ default:
60
+ return faExclamationTriangle
61
+ }
62
+ }
63
+ //BELOW THIS IS THE OLD SYSTEM'S FLAG LOGIC (before the 'state' column was added)
48
64
  if (this.endorsementDeniedFlag.isActive) return faExclamationTriangle
49
65
  else if (this.endorsementIssuesFlag.isActive) return faExclamationTriangle
50
66
  else if (this.endorsementPendingFlag.isActive) return faHourglassHalf
51
67
  return faCheck
52
68
  },
53
69
  statusClass () {
70
+ if (this.endorsementNewFlag != null){
71
+ switch(this.endorsementNewFlag.state.toLowerCase()){
72
+ case 'pass':
73
+ return { 'text-success': true }
74
+ case 'fail':
75
+ return { 'text-danger': true }
76
+ case 'error':
77
+ return { 'text-danger': true, 'font-weight-bold': true }
78
+ case 'indeterminate':
79
+ return { 'text-dark': true }
80
+ default:
81
+ return { 'text-danger': true, 'font-weight-bold': true }
82
+ }
83
+ }
84
+ //BELOW THIS IS THE OLD SYSTEM'S FLAG LOGIC (before the 'state' column was added)
54
85
  if (this.endorsementDeniedFlag.isActive) return { 'text-danger': true }
55
86
  else if (this.endorsementIssuesFlag.isActive) return { 'text-danger': true }
56
87
  else if (this.endorsementPendingFlag.isActive) return { 'text-dark': true, 'font-weight-bold': true }
57
88
  return { 'text-success': true }
58
89
  },
59
90
  endorsementStatus () {
91
+ if (this.endorsementNewFlag != null) {
92
+ if (this.endorsementNewFlag.message != null && this.endorsementNewFlag.message.length > 0) {
93
+ return this.endorsementNewFlag.message
94
+ }
95
+ else {
96
+ switch (this.endorsementNewFlag.state.toLowerCase()) {
97
+ case 'pass':
98
+ return 'Everything looks good!'
99
+ case 'fail':
100
+ return 'Requires additional attention.'
101
+ case 'error':
102
+ return 'An error occurred. Try again later.'
103
+ case 'indeterminate':
104
+ return 'No data available.'
105
+ default:
106
+ return 'An error occurred. Try again later.'
107
+ }
108
+ }
109
+ }
110
+ //BELOW THIS IS THE OLD SYSTEM'S FLAG LOGIC (before the 'state' column was added)
60
111
  if (this.endorsementDeniedFlag.isActive) return `Endorsement Denied`
61
112
  else if (this.endorsementIssuesFlag.isActive) return `Endorsement Issues`
62
113
  else if (this.endorsementPendingFlag.isActive) return `Endorsement Pending`
@@ -23,6 +23,7 @@
23
23
  <button :class="btnClass" @click="flagModal">
24
24
  {{btnText}}
25
25
  </button>
26
+ <!-- <slot name="refreshButton"></slot>-->
26
27
  </div>
27
28
  <div v-if="hasSummary" class="summary">
28
29
  <slot name="summary"></slot>
@@ -32,13 +33,11 @@
32
33
  <slot></slot>
33
34
  </div>
34
35
  </div>
35
- </span>
36
36
  </template>
37
37
  <script>
38
38
  import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
39
- import { faCheck, faExclamationTriangle } from '@fortawesome/free-solid-svg-icons'
39
+ import { faCheck,faExclamationTriangle,faSquare,faMinus } from '@fortawesome/free-solid-svg-icons'
40
40
  import { mapGetters } from 'vuex'
41
-
42
41
  import ExpandIndicator from './ExpandIndicator'
43
42
 
44
43
  export default {
@@ -58,7 +57,11 @@
58
57
  },
59
58
  'flagActiveColor': { type: String },
60
59
  'flagInactiveColor': { type: String },
61
- 'hideIfUnset': { type: Boolean }
60
+ 'hideIfUnset': { type: Boolean },
61
+ 'flagPassColor': { type: String, default: 'success' },
62
+ 'flagErrorColor': { type: String, default: 'dark' },
63
+ 'flagFailColor': { type: String, default: 'danger' },
64
+ 'flagIndeterminateColor': { type: String, default: 'secondary' }
62
65
  },
63
66
  data () {
64
67
  return {
@@ -83,9 +86,46 @@
83
86
  return this.flag.isActive ? 'clear flag' : 'set flag'
84
87
  },
85
88
  flagIcon () {
89
+ //If there is no flag set, the state is 'indeterminate'
90
+ if (this.flag == null){
91
+ return faSquare
92
+ }
93
+ if (this.flag.state != null){
94
+ switch (this.flag.state.toLowerCase()){
95
+ case 'pass':
96
+ return faCheck
97
+ case 'fail':
98
+ return faMinus
99
+ case 'error':
100
+ return faExclamationTriangle
101
+ case 'indeterminate':
102
+ return faSquare
103
+ default:
104
+ return faExclamationTriangle
105
+ }
106
+ }
86
107
  return this.flag.isActive ? faExclamationTriangle : faCheck
87
108
  },
88
109
  flagBg () {
110
+ //If there is no flag set, the state is 'indeterminate'
111
+ if (this.flag == null){
112
+ return `bg-${this.flagIndeterminateColor}`
113
+ }
114
+ if (this.flag.state != null){
115
+ switch (this.flag.state.toLowerCase()){
116
+ case 'pass':
117
+ return `bg-${this.flagPassColor}`
118
+ case 'fail':
119
+ return `bg-${this.flagFailColor}`
120
+ case 'error':
121
+ return `bg-${this.flagErrorColor}`
122
+ case 'indeterminate':
123
+ return `bg-${this.flagIndeterminateColor}`
124
+ default:
125
+ return `bg-${this.flagErrorColor}`
126
+ }
127
+ }
128
+
89
129
  const stateAware = this.flagActiveColor && this.flagInactiveColor
90
130
  if (!stateAware) return `bg-${this.flagType}`
91
131
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byu-oit/vue-decision-processing-components",
3
- "version": "8.36.2",
3
+ "version": "8.37.0-1",
4
4
  "description": "Vue components shared between decision processing systems for the CES schools.",
5
5
  "dependencies": {
6
6
  "@fortawesome/fontawesome-free": "^5.15.4",
package/parsers/packet.js CHANGED
@@ -12,6 +12,8 @@ export const parseFlag = f => {
12
12
  const clearedBy = get(f, 'id_cleared_by.description')
13
13
  const clearedById = get(f, 'id_cleared_by.value')
14
14
  const type = get(f, 'type.value')
15
+ const state = get(f, 'state.value')
16
+ const message = get(f, 'message.value')
15
17
  return {
16
18
  dateTimeCleared,
17
19
  setBy,
@@ -21,7 +23,9 @@ export const parseFlag = f => {
21
23
  dateTimeSet,
22
24
  clearedBy,
23
25
  clearedById,
24
- type
26
+ type,
27
+ state,
28
+ message
25
29
  }
26
30
  }
27
31
 
@@ -17,14 +17,36 @@ const blockingVirtualFlag = flags => {
17
17
  }
18
18
 
19
19
  const endorseVirtualFlag = flags => {
20
+ // Get new endorsement flag data
21
+ const endorsementNewFlag = flags.filter(f => f.value === 'endorsement')
22
+ if(endorsementNewFlag.length > 0) return endorsementNewFlag[0]
23
+
24
+ // Maintain old functionality
20
25
  const edFlag = flags.filter(f => f.value === 'ED').filter(f => f.isActive)
21
26
  const eiFlag = flags.filter(f => f.value === 'EI').filter(f => f.isActive)
22
27
  const allFlags = edFlag.concat(eiFlag)
23
28
  if (allFlags.length > 0) return allFlags[0]
24
- const value = 'endorse'
29
+
30
+ // Default if no flag data is found
31
+ const value = 'endorsement'
25
32
  const name = 'Endorsement Problem'
26
33
  const type = 'Process'
27
- return { value, name, type, isActive: false, isSet: false, isCleared: false, isBlocking: true }
34
+ return { value, name, type, isActive: false, isSet: false, isCleared: false, isBlocking: true, state: 'indeterminate' }
35
+ }
36
+
37
+ const cesHoldsVirtualFlag = flags => {
38
+ const cesHoldsFlag = flags.filter(f => f.value === 'cesHolds')
39
+ if (cesHoldsFlag.length > 0) return cesHoldsFlag[0]
40
+
41
+ const cesFlags = flags.find(f => f.value === 'CES')
42
+ if (cesFlags != null) {
43
+ return { ...cesFlags, state: 'fail' }
44
+ }
45
+
46
+ const value = 'cesHolds'
47
+ const name = 'CES Standard Hold'
48
+ const type = 'Process'
49
+ return { value, name, type, isActive: false, isSet: false, isCleared: false, isBlocking: true, state: 'indeterminate' }
28
50
  }
29
51
 
30
52
  // getters
@@ -38,8 +60,10 @@ export const getters = {
38
60
  const flags = getters.flags
39
61
  if (flagValue === 'blocking') {
40
62
  return blockingVirtualFlag(flags)
41
- } else if (flagValue === 'endorse') {
63
+ } else if (flagValue === 'endorsement') {
42
64
  return endorseVirtualFlag(flags)
65
+ } else if (flagValue === 'cesHolds') {
66
+ return cesHoldsVirtualFlag(flags)
43
67
  }
44
68
  const flag = flags.find(({ value }) => value === flagValue)
45
69
  return flag || { value: flagValue, name: flagValueToName(flagValue), isSet: false, isCleared: false, isActive: false }
@@ -86,7 +110,9 @@ export const convertFlag = flag => {
86
110
  dateTimeSet,
87
111
  setBy,
88
112
  dateTimeCleared,
89
- clearedBy
113
+ clearedBy,
114
+ state,
115
+ message
90
116
  } = flag
91
117
  const isBlocking = /process|wait/i.test(type)
92
118
  return {
@@ -100,7 +126,9 @@ export const convertFlag = flag => {
100
126
  setBy,
101
127
  dateTimeCleared,
102
128
  clearedBy,
103
- isBlocking
129
+ isBlocking,
130
+ state,
131
+ message
104
132
  }
105
133
  }
106
134