Merge pull request 'refactor: refs #8708 improve note components and update filter handling' (!1537) from 8581-warmfix-filterVnNotes into test
gitea/salix-front/pipeline/head This commit looks good
Details
gitea/salix-front/pipeline/head This commit looks good
Details
Reviewed-on: #1537 Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
commit
6c67a315dc
|
@ -26,12 +26,13 @@ const $attrs = computed(() => {
|
|||
});
|
||||
|
||||
const isRequired = computed(() => {
|
||||
return Object.keys($attrs).includes('required')
|
||||
return Object.keys($attrs).includes('required');
|
||||
});
|
||||
|
||||
const $props = defineProps({
|
||||
url: { type: String, default: null },
|
||||
saveUrl: {type: String, default: null},
|
||||
saveUrl: { type: String, default: null },
|
||||
userFilter: { type: Object, default: () => {} },
|
||||
filter: { type: Object, default: () => {} },
|
||||
body: { type: Object, default: () => {} },
|
||||
addNote: { type: Boolean, default: false },
|
||||
|
@ -65,7 +66,7 @@ async function insert() {
|
|||
}
|
||||
|
||||
function confirmAndUpdate() {
|
||||
if(!newNote.text && originalText)
|
||||
if (!newNote.text && originalText)
|
||||
quasar
|
||||
.dialog({
|
||||
component: VnConfirm,
|
||||
|
@ -88,11 +89,17 @@ async function update() {
|
|||
...body,
|
||||
...{ notes: newNote.text },
|
||||
};
|
||||
await axios.patch(`${$props.saveUrl ?? `${$props.url}/${$props.body.workerFk}`}`, newBody);
|
||||
await axios.patch(
|
||||
`${$props.saveUrl ?? `${$props.url}/${$props.body.workerFk}`}`,
|
||||
newBody,
|
||||
);
|
||||
}
|
||||
|
||||
onBeforeRouteLeave((to, from, next) => {
|
||||
if ((newNote.text && !$props.justInput) || (newNote.text !== originalText) && $props.justInput)
|
||||
if (
|
||||
(newNote.text && !$props.justInput) ||
|
||||
(newNote.text !== originalText && $props.justInput)
|
||||
)
|
||||
quasar.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
|
@ -104,12 +111,11 @@ onBeforeRouteLeave((to, from, next) => {
|
|||
else next();
|
||||
});
|
||||
|
||||
function fetchData([ data ]) {
|
||||
function fetchData([data]) {
|
||||
newNote.text = data?.notes;
|
||||
originalText = data?.notes;
|
||||
emit('onFetch', data);
|
||||
}
|
||||
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
|
@ -179,7 +185,8 @@ function fetchData([ data ]) {
|
|||
:url="$props.url"
|
||||
order="created DESC"
|
||||
:limit="0"
|
||||
:user-filter="$props.filter"
|
||||
:user-filter="userFilter"
|
||||
:filter="filter"
|
||||
auto-load
|
||||
ref="vnPaginateRef"
|
||||
class="show"
|
||||
|
@ -218,7 +225,7 @@ function fetchData([ data ]) {
|
|||
>
|
||||
{{
|
||||
observationTypes.find(
|
||||
(ot) => ot.id === note.observationTypeFk
|
||||
(ot) => ot.id === note.observationTypeFk,
|
||||
)?.description
|
||||
}}
|
||||
</QBadge>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { computed, useAttrs } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useState } from 'src/composables/useState';
|
||||
import VnNotes from 'src/components/ui/VnNotes.vue';
|
||||
|
@ -7,7 +7,6 @@ import VnNotes from 'src/components/ui/VnNotes.vue';
|
|||
const route = useRoute();
|
||||
const state = useState();
|
||||
const user = state.getUser();
|
||||
const $attrs = useAttrs();
|
||||
|
||||
const $props = defineProps({
|
||||
id: { type: [Number, String], default: null },
|
||||
|
@ -15,9 +14,7 @@ const $props = defineProps({
|
|||
});
|
||||
const claimId = computed(() => $props.id || route.params.id);
|
||||
|
||||
const claimFilter = computed(() => {
|
||||
return {
|
||||
where: { claimFk: claimId.value },
|
||||
const claimFilter = {
|
||||
fields: ['id', 'created', 'workerFk', 'text'],
|
||||
include: {
|
||||
relation: 'worker',
|
||||
|
@ -31,8 +28,7 @@ const claimFilter = computed(() => {
|
|||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
const body = {
|
||||
claimFk: claimId.value,
|
||||
|
@ -43,7 +39,8 @@ const body = {
|
|||
<VnNotes
|
||||
url="claimObservations"
|
||||
:add-note="$props.addNote"
|
||||
:filter="claimFilter"
|
||||
:user-filter="claimFilter"
|
||||
:filter="{ where: { claimFk: claimId } }"
|
||||
:body="body"
|
||||
v-bind="$attrs"
|
||||
style="overflow-y: auto"
|
||||
|
|
|
@ -1,28 +1,15 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import VnNotes from 'src/components/ui/VnNotes.vue';
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
const noteFilter = computed(() => {
|
||||
return {
|
||||
order: 'created DESC',
|
||||
where: {
|
||||
clientFk: `${route.params.id}`,
|
||||
},
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnNotes
|
||||
url="clientObservations"
|
||||
:add-note="true"
|
||||
:filter="noteFilter"
|
||||
:body="{ clientFk: route.params.id }"
|
||||
:filter="{ where: { clientFk: $route.params.id } }"
|
||||
:body="{ clientFk: $route.params.id }"
|
||||
style="overflow-y: auto"
|
||||
:select-type="true"
|
||||
required
|
||||
order="created DESC"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -5,9 +5,9 @@ import VnNotes from 'src/components/ui/VnNotes.vue';
|
|||
|
||||
const route = useRoute();
|
||||
|
||||
const filter = {
|
||||
const userFilter = {
|
||||
order: 'created DESC',
|
||||
where: { workerFk: route.params.id },
|
||||
|
||||
include: {
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
|
@ -22,11 +22,15 @@ const filter = {
|
|||
},
|
||||
};
|
||||
|
||||
const body = {
|
||||
workerFk: route.params.id,
|
||||
};
|
||||
const body = { workerFk: route.params.id };
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnNotes :add-note="true" url="WorkerObservations" :filter="filter" :body="body" />
|
||||
<VnNotes
|
||||
:add-note="true"
|
||||
url="WorkerObservations"
|
||||
:user-filter="userFilter"
|
||||
:filter="{ where: { workerFk: $route.params.id } }"
|
||||
:body="body"
|
||||
/>
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue