Client - refactoring users admin selects

This commit is contained in:
Sam 2021-11-02 14:19:37 +01:00
parent 6c6a024ad6
commit 05b22e6f72
6 changed files with 43 additions and 30 deletions

View File

@ -6,10 +6,11 @@
<button class="top-button" @click.prevent="$router.push('/admin')"> <button class="top-button" @click.prevent="$router.push('/admin')">
{{ $t('admin.BACK_TO_ADMIN') }} {{ $t('admin.BACK_TO_ADMIN') }}
</button> </button>
<AdminUsersSelects <FilterSelects
:sort="sortList" :sort="sortList"
:order_by="orderByList" :order_by="orderByList"
:query="query" :query="query"
message="admin.USERS.SELECTS.ORDER_BY"
@updateSelect="reloadUsers" @updateSelect="reloadUsers"
/> />
<div class="responsive-table"> <div class="responsive-table">
@ -128,7 +129,7 @@
} from 'vue' } from 'vue'
import { LocationQuery, useRoute, useRouter } from 'vue-router' import { LocationQuery, useRoute, useRouter } from 'vue-router'
import AdminUsersSelects from '@/components/Administration/AdminUsersSelects.vue' import FilterSelects from '@/components/Common/FilterSelects.vue'
import Pagination from '@/components/Common/Pagination.vue' import Pagination from '@/components/Common/Pagination.vue'
import UserPicture from '@/components/User/UserPicture.vue' import UserPicture from '@/components/User/UserPicture.vue'
import { ROOT_STORE, USER_STORE, USERS_STORE } from '@/store/constants' import { ROOT_STORE, USER_STORE, USERS_STORE } from '@/store/constants'
@ -141,7 +142,7 @@
export default defineComponent({ export default defineComponent({
name: 'AdminUsers', name: 'AdminUsers',
components: { components: {
AdminUsersSelects, FilterSelects,
Pagination, Pagination,
UserPicture, UserPicture,
}, },

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="table-selects"> <div class="table-selects">
<label> <label>
{{ $t('admin.USERS.SELECTS.ORDER_BY.LABEL') }}: {{ $t('common.SELECTS.ORDER_BY.LABEL') }}:
<select <select
name="order_by" name="order_by"
id="order_by" id="order_by"
@ -9,12 +9,12 @@
@change="onSelectUpdate" @change="onSelectUpdate"
> >
<option v-for="order in order_by" :value="order" :key="order"> <option v-for="order in order_by" :value="order" :key="order">
{{ $t(`admin.USERS.SELECTS.ORDER_BY.${order}`) }} {{ $t(`${message}.${order}`) }}
</option> </option>
</select> </select>
</label> </label>
<label> <label>
{{ $t('admin.USERS.SELECTS.ORDER.LABEL') }}: {{ $t('common.SELECTS.ORDER.LABEL') }}:
<select <select
name="order" name="order"
id="order" id="order"
@ -22,12 +22,12 @@
@change="onSelectUpdate" @change="onSelectUpdate"
> >
<option v-for="order in sort" :value="order" :key="order"> <option v-for="order in sort" :value="order" :key="order">
{{ $t(`admin.USERS.SELECTS.ORDER.${order.toUpperCase()}`) }} {{ $t(`common.SELECTS.ORDER.${order.toUpperCase()}`) }}
</option> </option>
</select> </select>
</label> </label>
<label> <label>
{{ $t('admin.USERS.SELECTS.PER_PAGE.LABEL') }}: {{ $t('common.SELECTS.PER_PAGE.LABEL') }}:
<select <select
name="per_page" name="per_page"
id="per_page" id="per_page"
@ -48,7 +48,7 @@
import { TPaginationPayload } from '@/types/api' import { TPaginationPayload } from '@/types/api'
export default defineComponent({ export default defineComponent({
name: 'AdminUsersSelects', name: 'FilterSelects',
props: { props: {
order_by: { order_by: {
type: Object as PropType<string[]>, type: Object as PropType<string[]>,
@ -62,6 +62,10 @@
type: Object as PropType<string[]>, type: Object as PropType<string[]>,
required: true, required: true,
}, },
message: {
type: String,
required: true,
},
}, },
emits: ['updateSelect'], emits: ['updateSelect'],
setup(props, { emit }) { setup(props, { emit }) {
@ -70,7 +74,7 @@
} }
return { return {
per_page: [10, 50, 100], per_page: [10, 25, 50, 100],
onSelectUpdate, onSelectUpdate,
} }
}, },

View File

@ -36,19 +36,10 @@
}, },
"SELECTS": { "SELECTS": {
"ORDER_BY": { "ORDER_BY": {
"LABEL": "order by",
"admin": "admin status", "admin": "admin status",
"created_at": "registration date", "created_at": "registration date",
"username": "username", "username": "username",
"workouts_count": "workout count" "workouts_count": "workout count"
},
"ORDER": {
"LABEL": "sort",
"ASC": "ascending",
"DESC": "descending"
},
"PER_PAGE": {
"LABEL": "par page"
} }
} }
} }

View File

@ -2,5 +2,18 @@
"CONFIRMATION": "Confirmation", "CONFIRMATION": "Confirmation",
"DAY": "day | days", "DAY": "day | days",
"HOME": "Home", "HOME": "Home",
"HERE": "here" "HERE": "here",
"SELECTS": {
"ORDER_BY": {
"LABEL": "order by"
},
"ORDER": {
"LABEL": "sort",
"ASC": "ascending",
"DESC": "descending"
},
"PER_PAGE": {
"LABEL": "par page"
}
}
} }

View File

@ -36,19 +36,10 @@
}, },
"SELECTS": { "SELECTS": {
"ORDER_BY": { "ORDER_BY": {
"LABEL": "trier par ",
"admin": "status administrateur", "admin": "status administrateur",
"created_at": "date d'inscription", "created_at": "date d'inscription",
"username": "nom d'utilisateur", "username": "nom d'utilisateur",
"workouts_count": "nombre de séances" "workouts_count": "nombre de séances"
},
"ORDER": {
"LABEL": "tri",
"ASC": "ascendant",
"DESC": "descendant"
},
"PER_PAGE": {
"LABEL": "par page"
} }
} }
} }

View File

@ -2,5 +2,18 @@
"CONFIRMATION": "Confirmation", "CONFIRMATION": "Confirmation",
"DAY": "jour | jours", "DAY": "jour | jours",
"HOME": "Accueil", "HOME": "Accueil",
"HERE": "ici" "HERE": "ici",
"SELECTS": {
"ORDER_BY": {
"LABEL": "trier par "
},
"ORDER": {
"LABEL": "tri",
"ASC": "ascendant",
"DESC": "descendant"
},
"PER_PAGE": {
"LABEL": "par page"
}
}
} }