feat: refs #8304 add required prop to VnNotes and update related components
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Jose Antonio Tubau 2025-01-22 16:29:04 +01:00
parent 3b4af9c749
commit 8599974437
4 changed files with 43 additions and 31 deletions

View File

@ -26,6 +26,7 @@ const $props = defineProps({
addNote: { type: Boolean, default: false },
selectType: { type: Boolean, default: false },
justInput: { type: Boolean, default: false },
required: { type: Boolean, default: false },
});
const { t } = useI18n();
@ -53,7 +54,6 @@ async function insert() {
await vnPaginateRef.value.fetch();
}
function confirmAndUpdate() {
if(!newNote.text && originalText)
quasar
@ -101,7 +101,7 @@ onBeforeRouteLeave((to, from, next) => {
:filter="{ fields: ['id', 'description'] }"
auto-load
@on-fetch="(data) => (observationTypes = data)"
/>
/>
<FetchData
v-if="justInput"
:url="url"
@ -110,7 +110,7 @@ onBeforeRouteLeave((to, from, next) => {
auto-load
/>
<QCard
class="q-pa-xs q-mb-lg full-width"
class="q-pa-xs q-mb-lg full-width"
v-if="$props.addNote || $props.justInput"
:style="$props.justInput ? 'padding-right: 18px; margin-bottom: 2px; box-shadow: none;' : ''"
>
@ -126,19 +126,19 @@ onBeforeRouteLeave((to, from, next) => {
v-model="newNote.observationTypeFk"
option-label="description"
style="flex: 0.15"
:required="true"
:required="$props.required"
@keyup.enter.stop="insert"
/>
<VnInput
v-model.trim="newNote.text"
type="textarea"
:label="t('Add note here...')"
:label="$props.justInput && newNote.text ? '' : t('Add note here...')"
filled
size="lg"
autogrow
@keyup.enter.stop="handleClick"
:required="$props.required"
clearable
:required="true"
>
<template #append>
<QBtn
@ -257,4 +257,6 @@ onBeforeRouteLeave((to, from, next) => {
New note: Nueva nota
Save (Enter): Guardar (Intro)
Observation type: Tipo de observación
New note is empty: La nueva nota esta vacia
Are you sure remove this note?: Estas seguro de quitar esta nota?
</i18n>

View File

@ -1,8 +1,10 @@
<script setup>
import { onMounted, onBeforeUnmount, ref } from 'vue';
import { useStateStore } from 'stores/useStateStore';
import { computed } from 'vue';
const stateStore = useStateStore();
const general = ref(null);
const actions = ref(null);
const data = ref(null);
const opts = { subtree: true, childList: true, attributes: true };
@ -12,35 +14,44 @@ onMounted(() => {
stateStore.toggleSubToolbar();
actions.value = document.querySelector('#st-actions');
data.value = document.querySelector('#st-data');
general.value = document.querySelector('#st-default');
if (!actions.value && !data.value) return;
if (!actions.value && !data.value && !general.value) return;
// Check if there's content to display
const observer = new MutationObserver(
() =>
(hasContent.value =
actions.value?.childNodes?.length + data.value?.childNodes?.length)
actions.value?.childNodes?.length + data.value?.childNodes?.length + general.value?.childNodes?.length)
);
if (actions.value) observer.observe(actions.value, opts);
if (data.value) observer.observe(data.value, opts);
if (general.value) observer.observe(general.value, opts);
});
onBeforeUnmount(() => stateStore.toggleSubToolbar());
const generalChildCount = () => {
return !!general.value.childNodes.length;
}
onBeforeUnmount(() => stateStore.toggleSubToolbar() && hasSubToolbar);
</script>
<template>
<QToolbar
id="subToolbar"
class="justify-end sticky"
v-show="hasContent || $slots['st-actions'] || $slots['st-data']"
v-show="hasContent || $slots['st-actions'] || $slots['st-data'] || $slots['st-default']"
:class="{'justify-end': !generalChildCount, 'sticky': !generalChildCount}"
>
<slot name="st-data">
<div id="st-data"></div>
</slot>
<QSpace />
<slot name="st-actions">
<div id="st-actions"></div>
<slot>
<div :class="{'full-width' : generalChildCount, 'q-px-none': generalChildCount }" id="st-default"></div>
</slot>
<slot name="st-data">
<div id="st-data"></div>
</slot>
<QSpace />
<slot name="st-actions">
<div id="st-actions"></div>
</slot>
</QToolbar>
</template>
<style lang="scss" scoped>

View File

@ -23,5 +23,6 @@ const noteFilter = computed(() => {
:body="{ clientFk: route.params.id }"
style="overflow-y: auto"
:select-type="true"
:required="true"
/>
</template>

View File

@ -193,20 +193,18 @@ watch([year, businessFk], () => refreshData());
:year-holidays="yearHolidays"
/>
</Teleport>
<div>
<VnNotes
v-if="canSeeNotes"
:just-input="true"
: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"
/>
</div>
<Teleport to="#st-default" v-if="stateStore.isSubToolbarShown()">
<VnNotes
v-if="canSeeNotes"
:just-input="true"
:url="`Workers/${route.params.id}/business`"
:filter="{fields: ['id', 'notes', 'workerFk']}"
:save-url="saveUrl"
@on-fetch="(data) => { saveUrl = `Businesses/${data[0].id}` }"
:body="body"
:required="false"
/>
</Teleport>
<QPage class="column items-center">
<QCard v-if="workerIsFreelance">
<QCardSection class="text-center">