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(() => {
|
const isRequired = computed(() => {
|
||||||
return Object.keys($attrs).includes('required')
|
return Object.keys($attrs).includes('required');
|
||||||
});
|
});
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
url: { type: String, default: null },
|
url: { type: String, default: null },
|
||||||
saveUrl: {type: String, default: null},
|
saveUrl: { type: String, default: null },
|
||||||
|
userFilter: { type: Object, default: () => {} },
|
||||||
filter: { type: Object, default: () => {} },
|
filter: { type: Object, default: () => {} },
|
||||||
body: { type: Object, default: () => {} },
|
body: { type: Object, default: () => {} },
|
||||||
addNote: { type: Boolean, default: false },
|
addNote: { type: Boolean, default: false },
|
||||||
|
@ -65,7 +66,7 @@ async function insert() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function confirmAndUpdate() {
|
function confirmAndUpdate() {
|
||||||
if(!newNote.text && originalText)
|
if (!newNote.text && originalText)
|
||||||
quasar
|
quasar
|
||||||
.dialog({
|
.dialog({
|
||||||
component: VnConfirm,
|
component: VnConfirm,
|
||||||
|
@ -88,11 +89,17 @@ async function update() {
|
||||||
...body,
|
...body,
|
||||||
...{ notes: newNote.text },
|
...{ 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) => {
|
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({
|
quasar.dialog({
|
||||||
component: VnConfirm,
|
component: VnConfirm,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
@ -104,12 +111,11 @@ onBeforeRouteLeave((to, from, next) => {
|
||||||
else next();
|
else next();
|
||||||
});
|
});
|
||||||
|
|
||||||
function fetchData([ data ]) {
|
function fetchData([data]) {
|
||||||
newNote.text = data?.notes;
|
newNote.text = data?.notes;
|
||||||
originalText = data?.notes;
|
originalText = data?.notes;
|
||||||
emit('onFetch', data);
|
emit('onFetch', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
@ -126,8 +132,8 @@ function fetchData([ data ]) {
|
||||||
@on-fetch="fetchData"
|
@on-fetch="fetchData"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<QCard
|
<QCard
|
||||||
class="q-pa-xs q-mb-lg full-width"
|
class="q-pa-xs q-mb-lg full-width"
|
||||||
:class="{ 'just-input': $props.justInput }"
|
:class="{ 'just-input': $props.justInput }"
|
||||||
v-if="$props.addNote || $props.justInput"
|
v-if="$props.addNote || $props.justInput"
|
||||||
>
|
>
|
||||||
|
@ -179,7 +185,8 @@ function fetchData([ data ]) {
|
||||||
:url="$props.url"
|
:url="$props.url"
|
||||||
order="created DESC"
|
order="created DESC"
|
||||||
:limit="0"
|
:limit="0"
|
||||||
:user-filter="$props.filter"
|
:user-filter="userFilter"
|
||||||
|
:filter="filter"
|
||||||
auto-load
|
auto-load
|
||||||
ref="vnPaginateRef"
|
ref="vnPaginateRef"
|
||||||
class="show"
|
class="show"
|
||||||
|
@ -218,7 +225,7 @@ function fetchData([ data ]) {
|
||||||
>
|
>
|
||||||
{{
|
{{
|
||||||
observationTypes.find(
|
observationTypes.find(
|
||||||
(ot) => ot.id === note.observationTypeFk
|
(ot) => ot.id === note.observationTypeFk,
|
||||||
)?.description
|
)?.description
|
||||||
}}
|
}}
|
||||||
</QBadge>
|
</QBadge>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, useAttrs } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
import VnNotes from 'src/components/ui/VnNotes.vue';
|
import VnNotes from 'src/components/ui/VnNotes.vue';
|
||||||
|
@ -7,7 +7,6 @@ import VnNotes from 'src/components/ui/VnNotes.vue';
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const user = state.getUser();
|
const user = state.getUser();
|
||||||
const $attrs = useAttrs();
|
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
id: { type: [Number, String], default: null },
|
id: { type: [Number, String], default: null },
|
||||||
|
@ -15,24 +14,21 @@ const $props = defineProps({
|
||||||
});
|
});
|
||||||
const claimId = computed(() => $props.id || route.params.id);
|
const claimId = computed(() => $props.id || route.params.id);
|
||||||
|
|
||||||
const claimFilter = computed(() => {
|
const claimFilter = {
|
||||||
return {
|
fields: ['id', 'created', 'workerFk', 'text'],
|
||||||
where: { claimFk: claimId.value },
|
include: {
|
||||||
fields: ['id', 'created', 'workerFk', 'text'],
|
relation: 'worker',
|
||||||
include: {
|
scope: {
|
||||||
relation: 'worker',
|
fields: ['id', 'firstName', 'lastName'],
|
||||||
scope: {
|
include: {
|
||||||
fields: ['id', 'firstName', 'lastName'],
|
relation: 'user',
|
||||||
include: {
|
scope: {
|
||||||
relation: 'user',
|
fields: ['id', 'nickname', 'name'],
|
||||||
scope: {
|
|
||||||
fields: ['id', 'nickname', 'name'],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
},
|
||||||
});
|
};
|
||||||
|
|
||||||
const body = {
|
const body = {
|
||||||
claimFk: claimId.value,
|
claimFk: claimId.value,
|
||||||
|
@ -43,7 +39,8 @@ const body = {
|
||||||
<VnNotes
|
<VnNotes
|
||||||
url="claimObservations"
|
url="claimObservations"
|
||||||
:add-note="$props.addNote"
|
:add-note="$props.addNote"
|
||||||
:filter="claimFilter"
|
:user-filter="claimFilter"
|
||||||
|
:filter="{ where: { claimFk: claimId } }"
|
||||||
:body="body"
|
:body="body"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
style="overflow-y: auto"
|
style="overflow-y: auto"
|
||||||
|
|
|
@ -1,28 +1,15 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from 'vue';
|
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
import VnNotes from 'src/components/ui/VnNotes.vue';
|
import VnNotes from 'src/components/ui/VnNotes.vue';
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
|
|
||||||
const noteFilter = computed(() => {
|
|
||||||
return {
|
|
||||||
order: 'created DESC',
|
|
||||||
where: {
|
|
||||||
clientFk: `${route.params.id}`,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnNotes
|
<VnNotes
|
||||||
url="clientObservations"
|
url="clientObservations"
|
||||||
:add-note="true"
|
:add-note="true"
|
||||||
:filter="noteFilter"
|
:filter="{ where: { clientFk: $route.params.id } }"
|
||||||
:body="{ clientFk: route.params.id }"
|
:body="{ clientFk: $route.params.id }"
|
||||||
style="overflow-y: auto"
|
style="overflow-y: auto"
|
||||||
:select-type="true"
|
:select-type="true"
|
||||||
required
|
required
|
||||||
|
order="created DESC"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -5,9 +5,9 @@ import VnNotes from 'src/components/ui/VnNotes.vue';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
const filter = {
|
const userFilter = {
|
||||||
order: 'created DESC',
|
order: 'created DESC',
|
||||||
where: { workerFk: route.params.id },
|
|
||||||
include: {
|
include: {
|
||||||
relation: 'worker',
|
relation: 'worker',
|
||||||
scope: {
|
scope: {
|
||||||
|
@ -22,11 +22,15 @@ const filter = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const body = {
|
const body = { workerFk: route.params.id };
|
||||||
workerFk: route.params.id,
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<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>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue