From a692ca4a1828ab356a90bba2d90fc1f1e7751e0e Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 10 May 2024 16:01:32 +0200 Subject: [PATCH] feat: refs #5919 test & set workerFk null. --- src/pages/Worker/Card/WorkerLocker.vue | 18 +++++++++++++----- .../integration/worker/workerLocker.spec.js | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 test/cypress/integration/worker/workerLocker.spec.js diff --git a/src/pages/Worker/Card/WorkerLocker.vue b/src/pages/Worker/Card/WorkerLocker.vue index d7cd10b48..171074b20 100644 --- a/src/pages/Worker/Card/WorkerLocker.vue +++ b/src/pages/Worker/Card/WorkerLocker.vue @@ -12,6 +12,7 @@ import FetchData from 'components/FetchData.vue'; const { hasAny } = useRole(); const { t } = useI18n(); const fetchData = ref(); +const originaLockerId = ref(); const lockers = ref([]); const { store } = useArrayData('Worker'); const entityId = computed(() => useRoute().params.id); @@ -22,10 +23,17 @@ const filter = computed(() => ({ }, })); -const canEdit = () => hasAny(['productionBoss', 'hr']); +const save = async (data) => { + const lockerId = data.id ?? originaLockerId.value; + const workerFk = lockerId == originaLockerId.value ? null : entityId.value; -const save = async (data) => - await axios.patch(`Lockers/${data.id}`, { workerFk: entityId.value }); + await axios.patch(`Lockers/${lockerId}`, { workerFk }); +}; + +const init = async (data) => { + await fetchData.value.fetch(); + originaLockerId.value = data.id; +};