feat: refs #8304 added remove option to operator #1195

Merged
jtubau merged 27 commits from 8304-workerChangesAndFixes into dev 2025-02-05 12:25:27 +00:00
2 changed files with 28 additions and 12 deletions
Showing only changes of commit 83064c3813 - Show all commits

View File

@ -16,8 +16,11 @@ import VnSelect from 'components/common/VnSelect.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import VnInput from 'components/common/VnInput.vue'; import VnInput from 'components/common/VnInput.vue';
const emit = defineEmits(['onFetch']);
Review

Tengo dudas de este componente porque le hemos metido la lógica de cuando es input, y tenemos que jugar con 2 condiciones
Mi propuesta es definir un componente tipo VnObservation que se comporte como cuando dices que es just-input=true, VnNoteType para el Vnelect y VnNote que tenga solo la lógica del textarea
Pero creo que son demasiados cambios para esta PR

Conclusión: VnNotes depende de 3 condiciones para renderizar que elemento u otro. Desacoplar la lógica

Tengo dudas de este componente porque le hemos metido la lógica de cuando es input, y tenemos que jugar con 2 condiciones Mi propuesta es definir un componente tipo VnObservation que se comporte como cuando dices que es just-input=true, VnNoteType para el Vnelect y VnNote que tenga solo la lógica del textarea Pero creo que son demasiados cambios para esta PR Conclusión: VnNotes depende de 3 condiciones para renderizar que elemento u otro. Desacoplar la lógica
Review

Yo lo dejaria en 2. Un VnNoteInput y un VnNote.
Donde el VnNoteInput seria el textArea.
Y el VnNote tener la logica, y este dividido en 2 partes.
Arriba un slot que por defecto contenga el VnNoteInput
Y abajo el VnPaginate

Yo lo dejaria en 2. Un VnNoteInput y un VnNote. Donde el VnNoteInput seria el textArea. Y el VnNote tener la logica, y este dividido en 2 partes. Arriba un slot que por defecto contenga el VnNoteInput Y abajo el VnPaginate
Review

Por tanto, lo dejamos así y creamos tarea con los comentarios que hemos puesto
Importante: referenciar la PR y ambos comentarios en la descripción de la tarea. Indicando: que la funcionalidad que fusionemos en esta PR debe quedar en el mismo estado. Añadir estos como checklist

Por tanto, lo dejamos así y creamos tarea con los comentarios que hemos puesto *Importante*: referenciar la PR y ambos comentarios en la descripción de la tarea. *Indicando*: que la funcionalidad que fusionemos en esta PR debe quedar en el mismo estado. Añadir estos como checklist
const $props = defineProps({ const $props = defineProps({
url: { type: String, default: null }, url: { type: String, default: null },
saveUrl: {type: String, default: null},
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 },
@ -34,7 +37,7 @@ let originalText;
function handleClick(e) { function handleClick(e) {
if (e.shiftKey && e.key === 'Enter') return; if (e.shiftKey && e.key === 'Enter') return;
jtubau marked this conversation as resolved Outdated

Diría que esta lógica ya existe o está implementada en qFormMixin

Diría que esta lógica ya existe o está implementada en qFormMixin
if ($props.justInput) update(); if ($props.justInput) confirmAndUpdate();
else insert(); else insert();
} }
@ -51,7 +54,7 @@ async function insert() {
} }
async function update() { function confirmAndUpdate() {
if(!newNote.text && originalText) if(!newNote.text && originalText)
quasar quasar
.dialog({ .dialog({
@ -61,21 +64,21 @@ async function update() {
message: t('Are you sure remove this note?'), message: t('Are you sure remove this note?'),
}, },
}) })
.onOk(() => save()) .onOk(() => update())
jtubau marked this conversation as resolved Outdated

.onOk(update)

.onOk(update)
.onCancel(() => { .onCancel(() => {
newNote.text = originalText; newNote.text = originalText;
}); });
else save(); else update();
} }
async function save() { async function update() {
originalText = newNote.text; originalText = newNote.text;
const body = $props.body; const body = $props.body;
const newBody = { const newBody = {
...body, ...body,
...{ notes: newNote.text }, ...{ notes: newNote.text },
}; };
await axios.patch(`${$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) => {
@ -101,9 +104,9 @@ onBeforeRouteLeave((to, from, next) => {
/> />
<FetchData <FetchData
v-if="justInput" v-if="justInput"
jtubau marked this conversation as resolved Outdated

Si usamos selectType para vincularlo con un VnSelect, porque si lo relacionamos con VnInput no hacemos inputType?

Si usamos selectType para vincularlo con un VnSelect, porque si lo relacionamos con VnInput no hacemos inputType?
url="Businesses" :url="url"
:filter="filter" :filter="filter"
@on-fetch="(data) => (newNote.text = data[0]?.notes, originalText = data[0]?.notes)" @on-fetch="(data) => (newNote.text = data[0]?.notes, originalText = data[0]?.notes, emit('onFetch', data))"
jtubau marked this conversation as resolved Outdated

Demasiadas operaciones para mantener en el apartado template
Como max. 2

Demasiadas operaciones para mantener en el apartado template Como max. 2

function fetchData(data) {
newNote.text = data[0]?.notes;
originalText = data[0]?.notes;
emit('onFetch', data);
}

<FetchData
v-if="justInput"
:url="url"
:filter="filter"
@on-fetch="(data) => (fetchData(data))"
auto-load
/>

así mejor no? le pondrías otro nombre?

function fetchData(data) { newNote.text = data[0]?.notes; originalText = data[0]?.notes; emit('onFetch', data); } <FetchData v-if="justInput" :url="url" :filter="filter" @on-fetch="(data) => (fetchData(data))" auto-load /> así mejor no? le pondrías otro nombre?
auto-load auto-load
/> />
<QCard <QCard

View File

@ -1,8 +1,9 @@
<script setup> <script setup>
import { nextTick, ref, watch } from 'vue'; import { nextTick, ref, watch, computed } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { useAcl } from 'src/composables/useAcl';
import WorkerCalendarFilter from 'pages/Worker/Card/WorkerCalendarFilter.vue'; import WorkerCalendarFilter from 'pages/Worker/Card/WorkerCalendarFilter.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
@ -16,6 +17,12 @@ const router = useRouter();
const stateStore = useStateStore(); const stateStore = useStateStore();
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
const acl = useAcl();
const canSeeNotes = computed(() =>
acl.hasAny([
{ model: 'Worker', props: '__get__business', accessType: 'READ' },
])
);
const workerIsFreelance = ref(); const workerIsFreelance = ref();
const WorkerFreelanceRef = ref(); const WorkerFreelanceRef = ref();
const workerCalendarFilterRef = ref(null); const workerCalendarFilterRef = ref(null);
@ -29,6 +36,7 @@ const contractHolidays = ref(null);
const yearHolidays = ref(null); const yearHolidays = ref(null);
const eventsMap = ref({}); const eventsMap = ref({});
const festiveEventsMap = ref({}); const festiveEventsMap = ref({});
const saveUrl = ref();
jsegarra marked this conversation as resolved
Review

entiendo la buena practica pero al ser 1 sola linea, menor abajo
2 bien, pero 3 ya no

entiendo la buena practica pero al ser 1 sola linea, menor abajo 2 bien, pero 3 ya no
const body = { const body = {
workerFk: route.params.id, workerFk: route.params.id,
}; };
@ -187,11 +195,16 @@ watch([year, businessFk], () => refreshData());
</Teleport> </Teleport>
<div> <div>
<VnNotes <VnNotes
v-if="canSeeNotes"
:just-input="true" :just-input="true"
:url="`businesses`" :url="`Workers/${route.params.id}/business`"
:filter="{fields: ['id', 'notes', 'workerFk']}"
:save-url="saveUrl"
@on-fetch="(data) => {
console.log(data);
saveUrl = `Businesses/${data[0].id}`
}"
:body="body" :body="body"
:maxlength=10
:filter="{ fields: ['id', 'notes'], where: { workerFk: route.params.id }, order: 'started DESC' }"
/> />
</div> </div>
<QPage class="column items-center"> <QPage class="column items-center">