fix: Avoid keys getting translated in availability (#1418)

This commit is contained in:
Pranav Raj S
2020-11-17 10:39:46 +05:30
committed by GitHub
parent 2d70131097
commit 3ee453c01e
34 changed files with 111 additions and 401 deletions

View File

@@ -6,7 +6,7 @@
/> />
<div class="status-view--title"> <div class="status-view--title">
{{ currentUserAvailabilityStatus }} {{ availabilityDisplayLabel }}
</div> </div>
</div> </div>
@@ -47,6 +47,7 @@
<script> <script>
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { mixin as clickaway } from 'vue-clickaway'; import { mixin as clickaway } from 'vue-clickaway';
const AVAILABILITY_STATUS_KEYS = ['online', 'busy', 'offline'];
export default { export default {
mixins: [clickaway], mixins: [clickaway],
@@ -62,14 +63,25 @@ export default {
...mapGetters({ ...mapGetters({
currentUser: 'getCurrentUser', currentUser: 'getCurrentUser',
}), }),
availabilityDisplayLabel() {
const availabilityIndex = AVAILABILITY_STATUS_KEYS.findIndex(
key => key === this.currentUserAvailabilityStatus
);
return this.$t('PROFILE_SETTINGS.FORM.AVAILABILITY.STATUSES_LIST')[
availabilityIndex
];
},
currentUserAvailabilityStatus() { currentUserAvailabilityStatus() {
return this.currentUser.availability_status; return this.currentUser.availability_status;
}, },
availabilityStatuses() { availabilityStatuses() {
return this.$t('PROFILE_SETTINGS.FORM.AVAILABILITY.STATUSES_LIST').map( return this.$t('PROFILE_SETTINGS.FORM.AVAILABILITY.STATUSES_LIST').map(
status => ({ (statusLabel, index) => ({
...status, label: statusLabel,
disabled: this.currentUserAvailabilityStatus === status.value, value: AVAILABILITY_STATUS_KEYS[index],
disabled:
this.currentUserAvailabilityStatus ===
AVAILABILITY_STATUS_KEYS[index],
}) })
); );
}, },

View File

@@ -46,7 +46,7 @@ describe('AvailabilityStatus', () => {
it('shows current user status', () => { it('shows current user status', () => {
const statusViewTitle = availabilityStatus.find('.status-view--title'); const statusViewTitle = availabilityStatus.find('.status-view--title');
expect(statusViewTitle.text()).toBe(currentUser.availability_status); expect(statusViewTitle.text()).toBe('Online');
}); });
it('opens the menu when user clicks "change"', async () => { it('opens the menu when user clicks "change"', async () => {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "التوفر", "LABEL": "التوفر",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "متصل",
"value": "متصل", "مشغول",
"label": "متصل" "غير متصل"
},
{
"value": "مشغول",
"label": "مشغول"
},
{
"value": "غير متصل",
"label": "غير متصل"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Disponibilitat", "LABEL": "Disponibilitat",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "En línia",
"value": "en línia", "Ocupat",
"label": "En línia" "Fora de línia"
},
{
"value": "ocupat",
"label": "Ocupat"
},
{
"value": "fora de línia",
"label": "Fora de línia"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Availability", "LABEL": "Availability",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Online",
"value": "online", "Busy",
"label": "Online" "Offline"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Availability", "LABEL": "Availability",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Online",
"value": "online", "Busy",
"label": "Online" "Offline"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Διαθεσιμότητα", "LABEL": "Διαθεσιμότητα",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Στην Γραμμή",
"value": "online", "Απασχολημένος",
"label": "Στην Γραμμή" "Εκτός"
},
{
"value": "busy",
"label": "Απασχολημένος"
},
{
"value": "offline",
"label": "Εκτός"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -57,18 +57,10 @@
}, },
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Availability", "LABEL": "Availability",
"STATUSES_LIST": [{ "STATUSES_LIST": [
"value": "online", "Online",
"label": "Online" "Busy",
}, "Offline"
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Disponibilidad", "LABEL": "Disponibilidad",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "En línea",
"value": "online", "Ocupado",
"label": "En línea" "Fuera de línea"
},
{
"value": "busy",
"label": "Ocupado"
},
{
"value": "offline",
"label": "Fuera de línea"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "در دسترس", "LABEL": "در دسترس",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "آنلاین",
"value": "آنلاین", "مشغول",
"label": نلاین" فلاین"
},
{
"value": "مشغول",
"label": "مشغول"
},
{
"value": "آفلاین",
"label": "آفلاین"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Availability", "LABEL": "Availability",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Online",
"value": "online", "Busy",
"label": "Online" "Offline"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Disponibilité", "LABEL": "Disponibilité",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "En ligne",
"value": "online", "Occupé(e)",
"label": "En ligne" "Hors-ligne"
},
{
"value": "busy",
"label": "Occupé(e)"
},
{
"value": "offline",
"label": "Hors-ligne"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Availability", "LABEL": "Availability",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Online",
"value": "online", "Busy",
"label": "Online" "Offline"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Availability", "LABEL": "Availability",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Online",
"value": "online", "Busy",
"label": "Online" "Offline"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Availability", "LABEL": "Availability",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Online",
"value": "online", "Busy",
"label": "Online" "Offline"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "利用可能期間", "LABEL": "利用可能期間",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "オンライン",
"value": "オンライン", "取り込み中",
"label": "オライン" "オライン"
},
{
"value": "取り込み中",
"label": "取り込み中"
},
{
"value": "オフライン",
"label": "オフライン"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Availability", "LABEL": "Availability",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Online",
"value": "online", "Busy",
"label": "Online" "Offline"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "ലഭ്യത", "LABEL": "ലഭ്യത",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "ഓൺ‌ലൈൻ",
"value": "online", "തിരക്ക്",
"label": "ഓ‌ലൈൻ" "ഓഫ്‌ലൈൻ"
},
{
"value": "busy",
"label": "തിരക്ക്"
},
{
"value": "offline",
"label": "ഓഫ്‌ലൈൻ"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Availability", "LABEL": "Availability",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Online",
"value": "online", "Druk",
"label": "Online" "Offline"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Availability", "LABEL": "Availability",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Online",
"value": "online", "Busy",
"label": "Online" "Offline"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Disponibilidade", "LABEL": "Disponibilidade",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Disponível",
"value": "online", "Ocupado",
"label": "Disponível" "Desconectado"
},
{
"value": "busy",
"label": "Ocupado"
},
{
"value": "offline",
"label": "Desconectado"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Disponibilitate", "LABEL": "Disponibilitate",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Online",
"value": "online", "Ocupat",
"label": "Online" "Deconectat"
},
{
"value": "busy",
"label": "Ocupat"
},
{
"value": "offline",
"label": "Deconectat"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Доступность", "LABEL": "Доступность",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "В сети",
"value": "online", "Занят",
"label": "В сети" "Оффлайн"
},
{
"value": "busy",
"label": "Занят"
},
{
"value": "offline",
"label": "Оффлайн"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Availability", "LABEL": "Availability",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Online",
"value": "online", "Busy",
"label": "Online" "Offline"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Availability", "LABEL": "Availability",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Online",
"value": "online", "Busy",
"label": "Online" "Offline"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Availability", "LABEL": "Availability",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Online",
"value": "online", "Busy",
"label": "Online" "Offline"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Availability", "LABEL": "Availability",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Online",
"value": "online", "Busy",
"label": "Online" "Offline"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Availability", "LABEL": "Availability",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Online",
"value": "online", "Busy",
"label": "Online" "Offline"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Availability", "LABEL": "Availability",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Online",
"value": "online", "Busy",
"label": "Online" "Offline"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "Khả dụng", "LABEL": "Khả dụng",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "Trực Tuyến",
"value": "online", "Bận",
"label": "Trực Tuyến" "Không Trực Tuyến"
},
{
"value": "busy",
"label": "Bận"
},
{
"value": "offline",
"label": "Không Trực Tuyến"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -56,18 +56,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "有效的", "LABEL": "有效的",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "在线的",
"value": "online", "忙碌中",
"label": "线的" "线的"
},
{
"value": "busy",
"label": "忙碌中"
},
{
"value": "offline",
"label": "离线的"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "有效的", "LABEL": "有效的",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "在线的",
"value": "online", "忙碌中",
"label": "线的" "线的"
},
{
"value": "busy",
"label": "忙碌中"
},
{
"value": "offline",
"label": "离线的"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": { "AVAILABILITY": {
"LABEL": "有效的", "LABEL": "有效的",
"STATUSES_LIST": [ "STATUSES_LIST": [
{ "線上的",
"value": "online", "忙碌中",
"label": "線上的" "離線的"
},
{
"value": "busy",
"label": "忙碌中"
},
{
"value": "offline",
"label": "離線的"
}
] ]
}, },
"EMAIL": { "EMAIL": {

View File

@@ -49,21 +49,6 @@
{{ $t('PROFILE_SETTINGS.FORM.EMAIL.ERROR') }} {{ $t('PROFILE_SETTINGS.FORM.EMAIL.ERROR') }}
</span> </span>
</label> </label>
<label>
{{ $t('PROFILE_SETTINGS.FORM.AVAILABILITY.LABEL') }}
<select v-model="availability">
<option
v-for="status in $t(
'PROFILE_SETTINGS.FORM.AVAILABILITY.STATUSES_LIST'
)"
:key="status.key"
class="text-capitalize"
:value="status.value"
>
{{ status.label }}
</option>
</select>
</label>
</div> </div>
</div> </div>
<div class="profile--settings--row row"> <div class="profile--settings--row row">
@@ -145,7 +130,6 @@ export default {
email: '', email: '',
password: '', password: '',
passwordConfirmation: '', passwordConfirmation: '',
availability: 'online',
isUpdating: false, isUpdating: false,
}; };
}, },
@@ -175,7 +159,6 @@ export default {
...mapGetters({ ...mapGetters({
currentUser: 'getCurrentUser', currentUser: 'getCurrentUser',
currentUserId: 'getCurrentUserID', currentUserId: 'getCurrentUserID',
currentAvailabilityStatus: 'getCurrentUserAvailabilityStatus',
}), }),
}, },
watch: { watch: {
@@ -184,11 +167,6 @@ export default {
this.initializeUser(); this.initializeUser();
} }
}, },
currentAvailabilityStatus(newStatus, oldStatus) {
if (newStatus !== oldStatus) {
this.availability = newStatus;
}
},
}, },
mounted() { mounted() {
if (this.currentUserId) { if (this.currentUserId) {
@@ -200,7 +178,6 @@ export default {
this.name = this.currentUser.name; this.name = this.currentUser.name;
this.email = this.currentUser.email; this.email = this.currentUser.email;
this.avatarUrl = this.currentUser.avatar_url; this.avatarUrl = this.currentUser.avatar_url;
this.availability = this.currentUser.availability_status;
this.displayName = this.currentUser.display_name; this.displayName = this.currentUser.display_name;
}, },
async updateUser() { async updateUser() {
@@ -218,7 +195,6 @@ export default {
avatar: this.avatarFile, avatar: this.avatarFile,
password: this.password, password: this.password,
displayName: this.displayName, displayName: this.displayName,
availability: this.availability,
password_confirmation: this.passwordConfirmation, password_confirmation: this.passwordConfirmation,
}); });
this.isUpdating = false; this.isUpdating = false;