0
0
Fork 0

Se hacen correcciones solicitadas para aprobacion de pr

This commit is contained in:
carlosfonseca 2023-12-14 07:57:55 -05:00
commit 672b4fd732
4 changed files with 124 additions and 49 deletions

View File

@ -0,0 +1,75 @@
<script setup>
import { ref, computed } from 'vue';
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
import { useRole } from 'src/composables/useRole';
const emit = defineEmits(['update:modelValue', 'update:options']);
const $props = defineProps({
modelValue: {
type: [String, Number, Object],
default: null,
},
options: {
type: Array,
default: () => [],
},
optionLabel: {
type: String,
default: '',
},
rolesAllowedToCreate: {
type: Array,
default: () => ['developer'],
},
});
const role = useRole();
const showForm = ref(false);
const value = computed({
get() {
return $props.modelValue;
},
set(value) {
emit('update:modelValue', value);
},
});
const isAllowedToCreate = computed(() => {
return role.hasAny($props.rolesAllowedToCreate);
});
const toggleForm = () => {
showForm.value = !showForm.value;
};
</script>
<template>
<VnSelectFilter v-model="value" :options="options">
<template v-if="isAllowedToCreate" #append>
<QIcon
@click.stop.prevent="toggleForm()"
name="add"
size="19px"
class="add-icon"
/>
<QDialog v-model="showForm" transition-show="scale" transition-hide="scale">
<slot name="form" @close-form="toggleForm()" />
</QDialog>
</template>
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
<slot :name="slotName" v-bind="slotData" :key="slotName" />
</template>
</VnSelectFilter>
</template>
<style lang="scss" scoped>
.add-icon {
cursor: pointer;
background-color: $primary;
border-radius: 50px;
}
</style>

View File

@ -105,8 +105,8 @@ const value = computed({
size="18px" size="18px"
/> />
</template> </template>
<template v-for="(_, slotName) in $slots" #[slotName]="slotData"> <template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
<slot :name="slotName" v-bind="slotData ?? {}" /> <slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
</template> </template>
</QSelect> </QSelect>
</template> </template>

View File

@ -32,50 +32,34 @@ const businessTypesOptions = ref([]);
const citiesLocationOptions = ref([]); const citiesLocationOptions = ref([]);
const provincesLocationOptions = ref([]); const provincesLocationOptions = ref([]);
const countriesOptions = ref([]); const countriesOptions = ref([]);
const onFetchWorkers = (workers) => {
workersOptions.value = [...workers];
};
const onFetchBusinessTypes = (businessTypes) => {
businessTypesOptions.value = [...businessTypes];
};
const onFetchCitiesLocation = (citiesLocation) => {
citiesLocationOptions.value = [...citiesLocation];
};
const onFetchProvincesLocation = (provincesLocation) => {
provincesLocationOptions.value = [...provincesLocation];
};
const onFetchCountries = (countries) => {
countriesOptions.value = [...countries];
};
</script> </script>
<template> <template>
<FetchData <FetchData
@on-fetch="(data) => onFetchWorkers(data)" @on-fetch="(data) => (workersOptions = data)"
auto-load auto-load
url="Workers/search?departmentCodes" url="Workers/search?departmentCodes"
/> />
<FetchData <FetchData
@on-fetch="(data) => onFetchBusinessTypes(data)" @on-fetch="(data) => (businessTypesOptions = data)"
auto-load auto-load
url="BusinessTypes" url="BusinessTypes"
/> />
<FetchData <FetchData
@on-fetch="(data) => onFetchCitiesLocation(data)" @on-fetch="(data) => (citiesLocationOptions = data)"
auto-load auto-load
url="Towns/location" url="Towns/location"
/> />
<FetchData <FetchData
@on-fetch="(data) => onFetchProvincesLocation(data)" @on-fetch="(data) => (provincesLocationOptions = data)"
auto-load auto-load
url="Provinces/location" url="Provinces/location"
/> />
<FetchData url="Countries" @on-fetch="(data) => onFetchCountries(data)" auto-load /> <FetchData
@on-fetch="(data) => (countriesOptions = data)"
auto-load
url="Countries"
/>
<QPage> <QPage>
<QToolbar class="bg-vn-dark"> <QToolbar class="bg-vn-dark">
<div id="st-data"></div> <div id="st-data"></div>

View File

@ -24,18 +24,6 @@ const isLoading = ref(false);
const provincesOptions = ref([]); const provincesOptions = ref([]);
const townsLocationOptions = ref([]); const townsLocationOptions = ref([]);
const onFetchTownsLocation = (townsLocation) => {
townsLocationOptions.value = [...townsLocation];
};
const onFetchProvinces = (provinces) => {
provincesOptions.value = [...provinces];
};
const onFetchCountries = (countries) => {
countriesOptions.value = [...countries];
};
async function save() { async function save() {
isLoading.value = true; isLoading.value = true;
@ -60,24 +48,32 @@ async function save() {
<template> <template>
<FetchData <FetchData
@on-fetch="(data) => onFetchTownsLocation(data)" @on-fetch="(data) => (townsLocationOptions = data)"
auto-load auto-load
url="Towns/location" url="Towns/location"
/> />
<FetchData @on-fetch="(data) => onFetchProvinces(data)" auto-load url="Provinces" /> <FetchData
<FetchData @on-fetch="(data) => onFetchCountries(data)" auto-load url="Countries" /> @on-fetch="(data) => (provincesOptions = data)"
auto-load
url="Provinces"
/>
<FetchData
@on-fetch="(data) => (countriesOptions = data)"
auto-load
url="Countries"
/>
<div class="q-pa-lg"> <div class="q-pa-lg">
<h6 class="q-my-xs">New postcode</h6> <h6 class="q-my-xs">{{ t('New postcode') }}</h6>
<p>Please, ensure you put the correct data!</p> <p>{{ t('Please, ensure you put the correct data!') }}</p>
<VnRow class="row q-gutter-md q-mb-md"> <VnRow class="row q-gutter-md q-mb-md">
<div class="col"> <div class="col">
<QInput label="Postcode" v-model="data.code" /> <QInput label="Postcode" v-model="data.code" />
</div> </div>
<div class="col"> <div class="col">
<VnSelectFilter <VnSelectFilter
:label="t('City')"
:options="townsLocationOptions" :options="townsLocationOptions"
hide-selected hide-selected
label="City"
option-label="name" option-label="name"
option-value="city" option-value="city"
v-model="data.city" v-model="data.city"
@ -87,9 +83,9 @@ async function save() {
<VnRow class="row q-gutter-md q-mb-xl"> <VnRow class="row q-gutter-md q-mb-xl">
<div class="col"> <div class="col">
<VnSelectFilter <VnSelectFilter
:label="t('Province')"
:options="provincesOptions" :options="provincesOptions"
hide-selected hide-selected
label="Province"
option-label="name" option-label="name"
option-value="id" option-value="id"
v-model="data.provinceFk" v-model="data.provinceFk"
@ -97,9 +93,9 @@ async function save() {
</div> </div>
<div class="col"> <div class="col">
<VnSelectFilter <VnSelectFilter
:label="t('Country')"
:options="countriesOptions" :options="countriesOptions"
hide-selected hide-selected
label="Country"
option-label="country" option-label="country"
option-value="id" option-value="id"
v-model="data.countryFk" v-model="data.countryFk"
@ -107,8 +103,19 @@ async function save() {
</div> </div>
</VnRow> </VnRow>
<div class="flex justify-end"> <div class="flex justify-end">
<QBtn class="q-mr-lg" color="primary" label="Cancel" outline v-close-popup /> <QBtn
<QBtn @click="save" color="primary" label="Save" v-close-popup /> :label="t('globals.cancel')"
class="q-mr-lg"
color="primary"
outline
v-close-popup
/>
<QBtn
:label="t('globals.save')"
@click="save"
color="primary"
v-close-popup
/>
</div> </div>
</div> </div>
<QInnerLoading <QInnerLoading
@ -125,3 +132,12 @@ async function save() {
grid-gap: 20px; grid-gap: 20px;
} }
</style> </style>
<i18n>
es:
New postcode: Nuevo código postal
Please, ensure you put the correct data!: ¡Por favor, asegúrese de poner los datos correctos!
City: Ciudad
Province: Provincia
Country: País
</i18n>