0
0
Fork 0

Merge pull request 'feat(AccountBasicData): add twoFactorFk' (!689) from 7792-accountBasicData_twoFactorFk into dev

Reviewed-on: verdnatura/salix-front#689
Reviewed-by: Jorge Penadés <jorgep@verdnatura.es>
This commit is contained in:
Alex Moreno 2024-09-18 10:41:56 +00:00
commit cba8647ac2
5 changed files with 77 additions and 61 deletions

View File

@ -0,0 +1,52 @@
<script setup>
import { onBeforeMount, ref, useAttrs } from 'vue';
import axios from 'axios';
import VnSelect from 'components/common/VnSelect.vue';
const { schema, table, column, translation, defaultOptions } = defineProps({
schema: {
type: String,
default: 'vn',
},
table: {
type: String,
required: true,
},
column: {
type: String,
required: true,
},
translation: {
type: Function,
default: null,
},
defaultOptions: {
type: Array,
default: () => [],
},
});
const $attrs = useAttrs();
const options = ref([]);
onBeforeMount(async () => {
options.value = [].concat(defaultOptions);
const { data } = await axios.get(`Applications/get-enum-values`, {
params: { schema, table, column },
});
for (const value of data)
options.value.push({
[$attrs['option-value'] ?? 'id']: value,
[$attrs['option-label'] ?? 'name']: translation ? translation(value) : value,
});
});
</script>
<template>
<VnSelect
v-bind="$attrs"
:options="options"
:key="options.length"
:input-debounce="0"
/>
</template>

View File

@ -2,6 +2,7 @@
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import VnSelectEnum from 'src/components/common/VnSelectEnum.vue';
import FormModel from 'components/FormModel.vue'; import FormModel from 'components/FormModel.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import { ref, watch } from 'vue'; import { ref, watch } from 'vue';
@ -24,7 +25,7 @@ watch(
<template> <template>
<FormModel <FormModel
ref="formModelRef" ref="formModelRef"
:url="`VnUsers/preview`" url="VnUsers/preview"
:url-update="`VnUsers/${route.params.id}/update-user`" :url-update="`VnUsers/${route.params.id}/update-user`"
:filter="accountFilter" :filter="accountFilter"
model="Accounts" model="Accounts"
@ -43,6 +44,15 @@ watch(
option-value="code" option-value="code"
option-label="code" option-label="code"
/> />
<VnSelectEnum
schema="account"
table="user"
column="twoFactor"
v-model="data.twoFactor"
:label="t('account.card.twoFactor')"
option-value="code"
option-label="code"
/>
</div> </div>
</template> </template>
</FormModel> </FormModel>

View File

@ -35,6 +35,7 @@ account:
willDeactivated: User will be deactivated willDeactivated: User will be deactivated
activated: User activated! activated: User activated!
deactivated: User deactivated! deactivated: User deactivated!
twoFactor: Two factor
actions: actions:
setPassword: Set password setPassword: Set password
disableAccount: disableAccount:

View File

@ -32,6 +32,7 @@ account:
activated: ¡Usuario activado! activated: ¡Usuario activado!
deactivated: ¡Usuario desactivado! deactivated: ¡Usuario desactivado!
newUser: Nuevo usuario newUser: Nuevo usuario
twoFactor: Doble factor
privileges: privileges:
delegate: Puede delegar privilegios delegate: Puede delegar privilegios
actions: actions:

View File

@ -3,58 +3,18 @@ import { ref } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import VnSelectEnum from 'src/components/common/VnSelectEnum.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.vue'; import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnInputDate from 'components/common/VnInputDate.vue'; import VnInputDate from 'components/common/VnInputDate.vue';
import axios from 'axios';
import VnAvatar from 'src/components/ui/VnAvatar.vue'; import VnAvatar from 'src/components/ui/VnAvatar.vue';
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
const claimStates = ref([]);
const claimStatesCopy = ref([]);
const optionsList = ref([]);
const workersOptions = ref([]); const workersOptions = ref([]);
function setClaimStates(data) {
claimStates.value = data;
claimStatesCopy.value = data;
}
async function getEnumValues() {
optionsList.value = [{ id: null, description: t('claim.null') }];
const { data } = await axios.get(`Applications/get-enum-values`, {
params: {
schema: 'vn',
table: 'claim',
column: 'pickup',
},
});
for (let value of data)
optionsList.value.push({ id: value, description: t(`claim.${value}`) });
}
getEnumValues();
const statesFilter = {
options: claimStates,
filterFn: (options, value) => {
const search = value.toLowerCase();
if (value === '') return claimStatesCopy.value;
return options.value.filter((row) => {
const description = row.description.toLowerCase();
return description.indexOf(search) > -1;
});
},
};
</script> </script>
<template> <template>
<FetchData <FetchData
@ -70,7 +30,7 @@ const statesFilter = {
auto-load auto-load
:reload="true" :reload="true"
> >
<template #form="{ data, validate, filter }"> <template #form="{ data, validate }">
<VnRow> <VnRow>
<VnInput <VnInput
v-model="data.client.name" v-model="data.client.name"
@ -101,20 +61,14 @@ const statesFilter = {
/> />
</template> </template>
</VnSelect> </VnSelect>
<QSelect <VnSelect
v-model="data.claimStateFk" v-model="data.claimStateFk"
:options="claimStates" url="ClaimStates"
option-value="id"
option-label="description"
emit-value
:label="t('claim.state')" :label="t('claim.state')"
map-options option-label="description"
use-input
@filter="(value, update) => filter(value, update, statesFilter)"
:rules="validate('claim.claimStateFk')" :rules="validate('claim.claimStateFk')"
:input-debounce="0" :input-debounce="0"
> />
</QSelect>
</VnRow> </VnRow>
<VnRow> <VnRow>
<QInput <QInput
@ -123,16 +77,14 @@ const statesFilter = {
:rules="validate('claim.packages')" :rules="validate('claim.packages')"
type="number" type="number"
/> />
<QSelect <VnSelectEnum
v-model="data.pickup" v-model="data.pickup"
:options="optionsList"
option-value="id"
option-label="description"
emit-value
:label="t('claim.pickup')" :label="t('claim.pickup')"
map-options table="claim"
use-input column="pickup"
:input-debounce="0" option-label="description"
:translation="(value) => t(`claim.${value}`)"
:default-options="[{ id: null, description: t('claim.null') }]"
/> />
</VnRow> </VnRow>
</template> </template>