This commit is contained in:
parent
153c9b743f
commit
9ec2fb4c77
|
@ -7,7 +7,7 @@ import FetchData from '../FetchData.vue';
|
||||||
import useNotify from 'src/composables/useNotify';
|
import useNotify from 'src/composables/useNotify';
|
||||||
|
|
||||||
const props = defineProps({ submitFn: { type: Function, default: () => {} } });
|
const props = defineProps({ submitFn: { type: Function, default: () => {} } });
|
||||||
|
const emit = defineEmits(['onSubmit']);
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
|
||||||
|
@ -15,19 +15,27 @@ const form = ref();
|
||||||
const changePassDialog = ref();
|
const changePassDialog = ref();
|
||||||
const passwords = ref({ newPassword: null, repeatPassword: null });
|
const passwords = ref({ newPassword: null, repeatPassword: null });
|
||||||
const requirements = ref([]);
|
const requirements = ref([]);
|
||||||
|
const isLoading = ref(false);
|
||||||
|
|
||||||
const validate = async () => {
|
const validate = async () => {
|
||||||
const { newPassword, repeatPassword } = passwords.value;
|
const { newPassword, repeatPassword } = passwords.value;
|
||||||
|
if (!newPassword) {
|
||||||
|
notify(t('You must enter a new password'), 'negative');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (newPassword !== repeatPassword) {
|
if (newPassword !== repeatPassword) {
|
||||||
notify(t("Passwords don't match"), 'negative');
|
notify(t("Passwords don't match"), 'negative');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
isLoading.value = true;
|
||||||
await props.submitFn(newPassword);
|
await props.submitFn(newPassword);
|
||||||
|
emit('onSubmit');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
notify('errors.writeRequest', 'negative');
|
notify('errors.writeRequest', 'negative');
|
||||||
} finally {
|
} finally {
|
||||||
changePassDialog.value.hide();
|
changePassDialog.value.hide();
|
||||||
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -84,6 +92,8 @@ defineExpose({ show: () => changePassDialog.value.show() });
|
||||||
<QCardActions>
|
<QCardActions>
|
||||||
<slot name="actions">
|
<slot name="actions">
|
||||||
<QBtn
|
<QBtn
|
||||||
|
:disabled="isLoading"
|
||||||
|
:loading="isLoading"
|
||||||
:label="t('globals.cancel')"
|
:label="t('globals.cancel')"
|
||||||
class="q-ml-sm"
|
class="q-ml-sm"
|
||||||
color="primary"
|
color="primary"
|
||||||
|
@ -92,6 +102,8 @@ defineExpose({ show: () => changePassDialog.value.show() });
|
||||||
v-close-popup
|
v-close-popup
|
||||||
/>
|
/>
|
||||||
<QBtn
|
<QBtn
|
||||||
|
:disabled="isLoading"
|
||||||
|
:loading="isLoading"
|
||||||
:label="t('globals.confirm')"
|
:label="t('globals.confirm')"
|
||||||
color="primary"
|
color="primary"
|
||||||
@click="validate"
|
@click="validate"
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { useI18n } from 'vue-i18n';
|
||||||
import CardDescriptor from 'src/components/ui/CardDescriptor.vue';
|
import CardDescriptor from 'src/components/ui/CardDescriptor.vue';
|
||||||
import VnLv from 'src/components/ui/VnLv.vue';
|
import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue';
|
import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue';
|
||||||
import WorkerChangePasswordForm from 'src/pages/Worker/Card/WorkerChangePasswordForm.vue';
|
import VnChangePassword from 'src/components/common/VnChangePassword.vue';
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import VnImg from 'src/components/ui/VnImg.vue';
|
import VnImg from 'src/components/ui/VnImg.vue';
|
||||||
|
@ -24,18 +24,13 @@ const route = useRoute();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const user = state.getUser();
|
const user = state.getUser();
|
||||||
const changePasswordFormDialog = ref(null);
|
|
||||||
const cardDescriptorRef = ref(null);
|
|
||||||
const showEditPhotoForm = ref(false);
|
const showEditPhotoForm = ref(false);
|
||||||
const toggleEditPictureForm = () => {
|
const toggleEditPictureForm = () => {
|
||||||
showEditPhotoForm.value = !showEditPhotoForm.value;
|
showEditPhotoForm.value = !showEditPhotoForm.value;
|
||||||
};
|
};
|
||||||
|
|
||||||
const entityId = computed(() => {
|
const entityId = computed(() => {
|
||||||
return $props.id || route.params.id;
|
return $props.id || route.params.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
const worker = ref();
|
|
||||||
const workerExcluded = ref(false);
|
const workerExcluded = ref(false);
|
||||||
|
|
||||||
const getIsExcluded = async () => {
|
const getIsExcluded = async () => {
|
||||||
|
@ -61,10 +56,10 @@ const handleExcluded = async () => {
|
||||||
|
|
||||||
workerExcluded.value = !workerExcluded.value;
|
workerExcluded.value = !workerExcluded.value;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePhotoUpdated = (evt = false) => {
|
const handlePhotoUpdated = (evt = false) => {
|
||||||
image.value.reload(evt);
|
image.value.reload(evt);
|
||||||
};
|
};
|
||||||
const refetch = async () => await cardDescriptorRef.value.getData();
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<CardDescriptor
|
<CardDescriptor
|
||||||
|
@ -74,15 +69,10 @@ const refetch = async () => await cardDescriptorRef.value.getData();
|
||||||
url="Workers/descriptor"
|
url="Workers/descriptor"
|
||||||
:filter="{ where: { id: entityId } }"
|
:filter="{ where: { id: entityId } }"
|
||||||
title="user.nickname"
|
title="user.nickname"
|
||||||
@on-fetch="
|
@on-fetch="getIsExcluded"
|
||||||
(data) => {
|
|
||||||
worker = data;
|
|
||||||
getIsExcluded();
|
|
||||||
}
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<template #menu="{}">
|
<template #menu="{ entity }">
|
||||||
<QItem v-ripple clickable @click="handleExcluded()">
|
<QItem v-ripple clickable @click="handleExcluded">
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
{{
|
{{
|
||||||
workerExcluded
|
workerExcluded
|
||||||
|
@ -92,16 +82,13 @@ const refetch = async () => await cardDescriptorRef.value.getData();
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem
|
<QItem
|
||||||
v-if="!worker.user.emailVerified && user.id != worker.id"
|
v-if="!entity.user.emailVerified && user.id != entity.id"
|
||||||
v-ripple
|
v-ripple
|
||||||
clickable
|
clickable
|
||||||
@click="$refs.changePasswordFormDialog.show()"
|
@click="$refs.changePassRef.show"
|
||||||
>
|
>
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
{{ t('Change password') }}
|
{{ t('Change password') }}
|
||||||
<QDialog ref="changePasswordFormDialog">
|
|
||||||
<WorkerChangePasswordForm @on-submit="refetch()" :id="entityId" />
|
|
||||||
</QDialog>
|
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
</template>
|
</template>
|
||||||
|
@ -163,10 +150,10 @@ const refetch = async () => await cardDescriptorRef.value.getData();
|
||||||
<VnLinkPhone :phone-number="entity.phone" />
|
<VnLinkPhone :phone-number="entity.phone" />
|
||||||
</template>
|
</template>
|
||||||
</VnLv>
|
</VnLv>
|
||||||
<VnLv :value="worker?.sip?.extension">
|
<VnLv :value="entity?.sip?.extension">
|
||||||
<template #label>
|
<template #label>
|
||||||
{{ t('worker.summary.sipExtension') }}
|
{{ t('worker.summary.sipExtension') }}
|
||||||
<VnLinkPhone :phone-number="worker?.sip?.extension" />
|
<VnLinkPhone :phone-number="entity?.sip?.extension" />
|
||||||
</template>
|
</template>
|
||||||
</VnLv>
|
</VnLv>
|
||||||
</template>
|
</template>
|
||||||
|
@ -197,6 +184,15 @@ const refetch = async () => await cardDescriptorRef.value.getData();
|
||||||
</QCardActions>
|
</QCardActions>
|
||||||
</template>
|
</template>
|
||||||
</CardDescriptor>
|
</CardDescriptor>
|
||||||
|
<VnChangePassword
|
||||||
|
ref="changePassRef"
|
||||||
|
:submit-fn="
|
||||||
|
async (newPass) => {
|
||||||
|
await axios.patch(`Workers/${$route.params.id}/setPassword`, { newPass });
|
||||||
|
}
|
||||||
|
"
|
||||||
|
@on-submit="$refs.cardDescriptorRef?.getData"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
Loading…
Reference in New Issue