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 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({
url: { type: String, default: null },
saveUrl: {type: String, default: null},
filter: { type: Object, default: () => {} },
body: { type: Object, default: () => {} },
addNote: { type: Boolean, default: false },
@ -34,7 +37,7 @@ let originalText;
function handleClick(e) {
if (e.shiftKey && e.key === 'Enter') return;
if ($props.justInput) update();
if ($props.justInput) confirmAndUpdate();
else insert();
}
@ -51,7 +54,7 @@ async function insert() {
}
async function update() {
function confirmAndUpdate() {
if(!newNote.text && originalText)
quasar
.dialog({
@ -61,21 +64,21 @@ async function update() {
message: t('Are you sure remove this note?'),
},
})
.onOk(() => save())
.onOk(() => update())
.onCancel(() => {
newNote.text = originalText;
});
else save();
else update();
}
async function save() {
async function update() {
originalText = newNote.text;
const body = $props.body;
const newBody = {
...body,
...{ 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) => {
@ -101,9 +104,9 @@ onBeforeRouteLeave((to, from, next) => {
/>
<FetchData
v-if="justInput"
url="Businesses"
:url="url"
: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))"
auto-load
/>
<QCard

View File

@ -1,8 +1,9 @@
<script setup>
import { nextTick, ref, watch } from 'vue';
import { nextTick, ref, watch, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import { useRouter } from 'vue-router';
import { useAcl } from 'src/composables/useAcl';
import WorkerCalendarFilter from 'pages/Worker/Card/WorkerCalendarFilter.vue';
import FetchData from 'components/FetchData.vue';
@ -16,6 +17,12 @@ const router = useRouter();
const stateStore = useStateStore();
const route = useRoute();
const { t } = useI18n();
const acl = useAcl();
const canSeeNotes = computed(() =>
acl.hasAny([
{ model: 'Worker', props: '__get__business', accessType: 'READ' },
])
);
const workerIsFreelance = ref();
const WorkerFreelanceRef = ref();
const workerCalendarFilterRef = ref(null);
@ -29,6 +36,7 @@ const contractHolidays = ref(null);
const yearHolidays = ref(null);
const eventsMap = 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 = {
workerFk: route.params.id,
};
@ -187,11 +195,16 @@ watch([year, businessFk], () => refreshData());
</Teleport>
<div>
<VnNotes
v-if="canSeeNotes"
: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"
:maxlength=10
:filter="{ fields: ['id', 'notes'], where: { workerFk: route.params.id }, order: 'started DESC' }"
/>
</div>
<QPage class="column items-center">