Skip to content

Commit 822832e

Browse files
authored
Merge pull request #2879 from uw-it-aca/qa
MUWM-5134 initial setup of the name-pron card (#2797)
2 parents 8b69a79 + 6937e51 commit 822832e

File tree

7 files changed

+103
-36
lines changed

7 files changed

+103
-36
lines changed

myuw/templates/profile.html

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<template #mobile>
1212
<div class="col-md-12 px-0">
1313
<myuw-uname></myuw-uname>
14+
<myuw-name-pron></myuw-name-pron>
1415
<myuw-employee-profile></myuw-employee-profile>
1516
<myuw-student-profile></myuw-student-profile>
1617
<myuw-applicant-profile></myuw-applicant-profile>
@@ -22,6 +23,7 @@
2223
<myuw-uname></myuw-uname>
2324
</div>
2425
<div class="col-md-8">
26+
<myuw-name-pron></myuw-name-pron>
2527
<myuw-employee-profile></myuw-employee-profile>
2628
<myuw-student-profile></myuw-student-profile>
2729
<myuw-applicant-profile></myuw-applicant-profile>

myuw_vue/components/profile/employee-profile.vue

+1
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,4 @@ export default {
154154
padding-left: 32px;
155155
}
156156
</style>
157+
+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<template>
2+
<uw-card :loaded="isReady" :errored="isErrored" :errored-show="showError">
3+
<template #card-heading>
4+
<h2 class="h4 mb-3 text-dark-beige myuw-font-encode-sans">Name &amp; Pronouns</h2>
5+
</template>
6+
<template #card-body>
7+
<uw-card-property-group>
8+
<uw-card-property title="Official Name">
9+
{{ fullName }}
10+
</uw-card-property>
11+
12+
<uw-card-property title="Preferred Name">
13+
<p v-if="!hasPreferredName" class="text-muted">No Preferred name listed</p>
14+
<div v-else>
15+
{{ prefName }}
16+
</div>
17+
</uw-card-property>
18+
<uw-card-property title="Pronouns">
19+
<div v-if="hasPronouns">
20+
{{ pronouns }}
21+
</div>
22+
<div v-else class="text-muted">No pronouns listed</div>
23+
<div class="mt-4">
24+
<uw-link-button
25+
class="px-2 py-1"
26+
href="https://identity.uw.edu/"
27+
>Edit in Identity.UW
28+
</uw-link-button>
29+
</div>
30+
</uw-card-property>
31+
</uw-card-property-group>
32+
</template>
33+
</uw-card>
34+
</template>
35+
36+
<script>
37+
import { mapGetters, mapState, mapActions } from 'vuex';
38+
import Card from '../_templates/card.vue';
39+
import CardProperty from '../_templates/card-property.vue';
40+
import CardPropertyGroup from '../_templates/card-property-group.vue';
41+
import LinkButton from '../_templates/link-button.vue';
42+
43+
export default {
44+
components: {
45+
'uw-card': Card,
46+
'uw-card-property': CardProperty,
47+
'uw-card-property-group': CardPropertyGroup,
48+
'uw-link-button': LinkButton,
49+
},
50+
computed: {
51+
...mapState({
52+
fullName: (state) => state.directory.value.full_name,
53+
prefName: (state) => state.directory.value.display_name,
54+
pronouns: (state) => state.directory.value.pronouns,
55+
}),
56+
...mapGetters('directory', {
57+
isReady: 'isReady',
58+
isErrored: 'isErrored',
59+
}),
60+
hasPreferredName() {
61+
return Boolean(this.prefName && this.prefName.length);
62+
},
63+
hasPronouns() {
64+
return Boolean(this.pronouns && this.pronouns.length);
65+
},
66+
showError() {
67+
return false;
68+
},
69+
},
70+
mounted() {
71+
this.fetch();
72+
},
73+
methods: {
74+
...mapActions('directory', {
75+
fetch: 'fetch',
76+
}),
77+
},
78+
};
79+
</script>
80+
81+

myuw_vue/components/profile/student-profile.vue

-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ export default {
169169
...mapGetters('profile', {
170170
isReady: 'isReady',
171171
isErrored: 'isErrored',
172-
statusCode: 'statusCode',
173172
}),
174173
...mapState({
175174
student: (state) => state.user.affiliations.student,

myuw_vue/components/profile/user-name.vue

+13-31
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,34 @@
11
<template>
2-
<uw-panel
3-
v-if="hasName"
4-
:loaded="isReady"
5-
:errored="isErrored"
6-
>
2+
<uw-panel v-if="hasName" :loaded="isReady" :errored="isErrored">
73
<template #panel-body>
84
<h2 class="h4 mb-3">
9-
<span v-if="hasPreferred">
10-
{{ titleCaseName(displayName) }}
11-
<span v-if="fullName"
12-
class="myuw-text-md text-uppercase"
13-
title="Full name"
14-
>
15-
({{ titleCaseName(fullName) }})
5+
<span>
6+
{{ titleCaseName(name) }}
7+
<span v-if="hasPronouns" class="myuw-text-md text-uppercase" title="Pronouns">
8+
({{ titleCaseName(pronouns) }})
169
</span>
1710
</span>
18-
<span v-else-if="fullName" title="Full name">
19-
{{ titleCaseName(fullName) }}
20-
</span>
21-
<a
22-
v-out="'Manage preferred name - Identity.UW'"
23-
href="https://identity.uw.edu/"
24-
title="Manage your preferred name">
25-
<font-awesome-icon :icon="faPencilAlt" class="myuw-text-md" />
26-
<span class="visually-hidden">Manage your preferred name</span>
27-
</a>
2811
</h2>
2912
</template>
3013
</uw-panel>
3114
</template>
3215

3316
<script>
34-
import {
35-
faPencilAlt,
36-
} from '@fortawesome/free-solid-svg-icons';
37-
import {mapGetters, mapState, mapActions} from 'vuex';
17+
import { mapGetters, mapState, mapActions } from 'vuex';
3818
import Card from '../_templates/panel.vue';
3919
4020
export default {
4121
components: {
4222
'uw-panel': Card,
4323
},
4424
data() {
45-
return {
46-
faPencilAlt,
47-
};
25+
return {};
4826
},
4927
computed: {
5028
...mapState({
5129
displayName: (state) => state.directory.value.display_name,
5230
fullName: (state) => state.directory.value.full_name,
31+
pronouns: (state) => state.directory.value.pronouns,
5332
}),
5433
...mapGetters('directory', {
5534
isReady: 'isReady',
@@ -58,8 +37,11 @@ export default {
5837
hasName() {
5938
return Boolean(this.displayName) || Boolean(this.fullName);
6039
},
61-
hasPreferred() {
62-
return Boolean(this.displayName) && this.displayName !== this.fullName;
40+
name() {
41+
return this.displayName ? this.displayName : this.fullName;
42+
},
43+
hasPronouns() {
44+
return Boolean(this.pronouns && this.pronouns.length);
6345
},
6446
},
6547
mounted() {

myuw_vue/profile.js

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Boilerplate from './components/_templates/boilerplate/boilerplate.vue';
55

66
// components
77
import Uname from './components/profile/user-name.vue';
8+
import NamePron from './components/profile/name-pron.vue';
89
import StudentProfile from './components/profile/student-profile.vue';
910
import EmployeeProfile from './components/profile/employee-profile.vue';
1011
import ApplicantProfile from './components/profile/applicant-profile.vue';
@@ -27,6 +28,7 @@ vueConf.store.commit('addVarToState', {
2728

2829
Vue.component('myuw-boilerplate', Boilerplate);
2930
Vue.component('myuw-uname', Uname);
31+
Vue.component('myuw-name-pron', NamePron);
3032
Vue.component('myuw-student-profile', StudentProfile);
3133
Vue.component('myuw-employee-profile', EmployeeProfile);
3234
Vue.component('myuw-applicant-profile', ApplicantProfile);

myuw_vue/tests/user-name.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ describe('Uname Card', () => {
2727
});
2828
});
2929

30-
it('Test case1', async () => {
30+
it('Having diff pref name and full name specified', async () => {
3131
axios.get.mockResolvedValue({data: mockData});
3232
const wrapper = mount(Uname, {store, localVue});
3333
// It takes like 10 ms to process the mock data through fetch postProcess
3434
await new Promise(setImmediate);
3535
expect(wrapper.vm.isReady).toBe(true);
3636
expect(wrapper.vm.hasName).toBe(true);
37-
expect(wrapper.vm.hasPreferred).toBe(true);
37+
expect(wrapper.vm.name).toBe("J. Average Student");
3838
});
39-
it('Test case2', async () => {
39+
it('Pref name is the same as full name', async () => {
4040
axios.get.mockResolvedValue({data: mockData1});
4141
const wrapper = mount(Uname, {store, localVue});
4242
// It takes like 10 ms to process the mock data through fetch postProcess
4343
await new Promise(setImmediate);
4444
expect(wrapper.vm.isReady).toBe(true);
4545
expect(wrapper.vm.hasName).toBe(true);
46-
expect(wrapper.vm.hasPreferred).toBe(false);
46+
expect(wrapper.vm.name).toBe("JAMES AVERAGE STUDENT");
4747
});
4848
});

0 commit comments

Comments
 (0)