Merge pull request 'Imrpove VnLocation to show less fields' (!738) from fix_8018 into master
Reviewed-on: #738 Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
commit
48b7b879f2
|
@ -2,21 +2,68 @@
|
|||
import CreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue';
|
||||
import VnSelectDialog from 'components/common/VnSelectDialog.vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { ref } from 'vue';
|
||||
const { t } = useI18n();
|
||||
const value = defineModel({ type: [String, Number, Object] });
|
||||
const emit = defineEmits(['update:model-value', 'update:options']);
|
||||
|
||||
const props = defineProps({
|
||||
location: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
const formatLocation = (obj, properties) => {
|
||||
const parts = properties.map((prop) => {
|
||||
if (typeof prop === 'string') {
|
||||
return obj[prop];
|
||||
} else if (typeof prop === 'function') {
|
||||
return prop(obj);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
const filteredParts = parts.filter(
|
||||
(part) => part !== null && part !== undefined && part !== ''
|
||||
);
|
||||
|
||||
return filteredParts.join(', ');
|
||||
};
|
||||
|
||||
const locationProperties = [
|
||||
'postcode',
|
||||
(obj) =>
|
||||
obj.city
|
||||
? `${obj.city}${obj.province?.name ? `(${obj.province.name})` : ''}`
|
||||
: null,
|
||||
(obj) => obj.country?.name,
|
||||
];
|
||||
|
||||
const modelValue = ref(
|
||||
props.location ? formatLocation(props.location, locationProperties) : null
|
||||
);
|
||||
|
||||
const handleModelValue = (data) => {
|
||||
emit('update:model-value', data);
|
||||
};
|
||||
|
||||
function showLabel(data) {
|
||||
return `${data.code} - ${data.town}(${data.province}), ${data.country}`;
|
||||
const dataProperties = [
|
||||
'code',
|
||||
(obj) => (obj.town ? `${obj.town}(${obj.province})` : null),
|
||||
'country',
|
||||
];
|
||||
return formatLocation(data, dataProperties);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<VnSelectDialog
|
||||
v-model="value"
|
||||
option-value="code"
|
||||
v-model="modelValue"
|
||||
option-filter-value="search"
|
||||
:option-label="(opt) => showLabel(opt)"
|
||||
:option-label="
|
||||
(opt) => (typeof modelValue === 'string' ? modelValue : showLabel(opt))
|
||||
"
|
||||
url="Postcodes/filter"
|
||||
@update:model-value="handleModelValue"
|
||||
:use-like="false"
|
||||
:label="t('Location')"
|
||||
:placeholder="t('search_by_postalcode')"
|
||||
|
@ -27,7 +74,14 @@ function showLabel(data) {
|
|||
:emit-value="false"
|
||||
>
|
||||
<template #form>
|
||||
<CreateNewPostcode @on-data-saved="(newValue) => (value = newValue)" />
|
||||
<CreateNewPostcode
|
||||
@on-data-saved="
|
||||
(newValue) => {
|
||||
modelValue = newValue;
|
||||
emit('update:model-value', newValue);
|
||||
}
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
<template #option="{ itemProps, opt }">
|
||||
<QItem v-bind="itemProps">
|
||||
|
|
|
@ -93,8 +93,9 @@ function handleLocation(data, location) {
|
|||
<VnRow>
|
||||
<VnLocation
|
||||
:rules="validate('Worker.postcode')"
|
||||
:roles-allowed-to-create="['deliveryAssistant']"
|
||||
v-model="data.postcode"
|
||||
:roles-allowed-to-create="['deliveryAssistant', 'administrative']"
|
||||
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
|
||||
:location="data"
|
||||
@update:model-value="(location) => handleLocation(data, location)"
|
||||
/>
|
||||
</VnRow>
|
||||
|
|
|
@ -86,7 +86,7 @@ function handleLocation(data, location) {
|
|||
<VnRow>
|
||||
<VnLocation
|
||||
:rules="validate('Worker.postcode')"
|
||||
:roles-allowed-to-create="['deliveryAssistant']"
|
||||
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
|
||||
v-model="data.location"
|
||||
@update:model-value="(location) => handleLocation(data, location)"
|
||||
>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import { ref, computed, markRaw } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
import VnLocation from 'src/components/common/VnLocation.vue';
|
||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||
|
@ -69,7 +70,7 @@ const columns = computed(() => [
|
|||
optionFilter: 'firstName',
|
||||
useLike: false,
|
||||
},
|
||||
create: true,
|
||||
create: false,
|
||||
columnField: {
|
||||
component: null,
|
||||
},
|
||||
|
@ -195,6 +196,8 @@ const columns = computed(() => [
|
|||
component: 'select',
|
||||
attrs: {
|
||||
url: 'BusinessTypes',
|
||||
fields: ['code', 'description'],
|
||||
sortBy: 'description ASC ',
|
||||
optionLabel: 'description',
|
||||
optionValue: 'code',
|
||||
},
|
||||
|
@ -353,12 +356,13 @@ const columns = computed(() => [
|
|||
{
|
||||
title: t('Client ticket list'),
|
||||
icon: 'vn:ticket',
|
||||
action: redirectToCreateView,
|
||||
action: redirectToTicketsList,
|
||||
isPrimary: true,
|
||||
},
|
||||
{
|
||||
title: t('components.smartCard.viewSummary'),
|
||||
icon: 'preview',
|
||||
isPrimary: true,
|
||||
action: (row) => viewSummary(row.id, CustomerSummary),
|
||||
},
|
||||
],
|
||||
|
@ -366,11 +370,12 @@ const columns = computed(() => [
|
|||
]);
|
||||
|
||||
const { viewSummary } = useSummaryDialog();
|
||||
const redirectToCreateView = (row) => {
|
||||
const redirectToTicketsList = (row) => {
|
||||
router.push({
|
||||
name: 'TicketList',
|
||||
|
||||
query: {
|
||||
params: JSON.stringify({
|
||||
table: JSON.stringify({
|
||||
clientFk: row.id,
|
||||
}),
|
||||
},
|
||||
|
@ -395,10 +400,10 @@ function handleLocation(data, location) {
|
|||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="Customer"
|
||||
url="Clients/extendedListFilter"
|
||||
url="Clients/filter"
|
||||
:create="{
|
||||
urlCreate: 'Clients/createWithUser',
|
||||
title: 'Create client',
|
||||
title: t('globals.pageTitles.customerCreate'),
|
||||
onDataSaved: ({ id }) => tableRef.redirect(id),
|
||||
formInitialData: {
|
||||
active: true,
|
||||
|
@ -411,8 +416,41 @@ function handleLocation(data, location) {
|
|||
auto-load
|
||||
>
|
||||
<template #more-create-dialog="{ data }">
|
||||
<VnSelect
|
||||
url="Workers/search"
|
||||
v-model="data.salesPersonFk"
|
||||
:label="t('customer.basicData.salesPerson')"
|
||||
:params="{
|
||||
departmentCodes: ['VT', 'shopping'],
|
||||
}"
|
||||
:fields="['id', 'nickname']"
|
||||
sort-by="nickname ASC"
|
||||
:use-like="false"
|
||||
emit-value
|
||||
auto-load
|
||||
>
|
||||
<template #prepend>
|
||||
<VnAvatar
|
||||
:worker-id="data.salesPersonFk"
|
||||
color="primary"
|
||||
:title="title"
|
||||
/>
|
||||
</template>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel>{{ scope.opt?.name }}</QItemLabel>
|
||||
<QItemLabel caption
|
||||
>{{ scope.opt?.nickname }},
|
||||
{{ scope.opt?.code }}</QItemLabel
|
||||
>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelect>
|
||||
|
||||
<VnLocation
|
||||
:roles-allowed-to-create="['deliveryAssistant']"
|
||||
:acls="[{ model: 'Province', props: '*', accessType: 'WRITE' }]"
|
||||
v-model="data.location"
|
||||
@update:model-value="(location) => handleLocation(data, location)"
|
||||
/>
|
||||
|
|
|
@ -57,12 +57,12 @@ function handleLocation(data, location) {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<fetch-data
|
||||
<FetchData
|
||||
@on-fetch="(data) => (agencyModes = data)"
|
||||
auto-load
|
||||
url="AgencyModes/isActive"
|
||||
/>
|
||||
<fetch-data @on-fetch="(data) => (incoterms = data)" auto-load url="Incoterms" />
|
||||
<FetchData @on-fetch="(data) => (incoterms = data)" auto-load url="Incoterms" />
|
||||
|
||||
<FormModel
|
||||
:form-initial-data="formInitialData"
|
||||
|
@ -92,7 +92,7 @@ function handleLocation(data, location) {
|
|||
|
||||
<VnLocation
|
||||
:rules="validate('Worker.postcode')"
|
||||
:roles-allowed-to-create="['deliveryAssistant']"
|
||||
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
|
||||
v-model="data.location"
|
||||
@update:model-value="(location) => handleLocation(data, location)"
|
||||
/>
|
||||
|
|
|
@ -113,18 +113,18 @@ function handleLocation(data, location) {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<fetch-data
|
||||
<FetchData
|
||||
@on-fetch="(data) => (agencyModes = data)"
|
||||
auto-load
|
||||
url="AgencyModes/isActive"
|
||||
/>
|
||||
<fetch-data @on-fetch="(data) => (incoterms = data)" auto-load url="Incoterms" />
|
||||
<fetch-data
|
||||
<FetchData @on-fetch="(data) => (incoterms = data)" auto-load url="Incoterms" />
|
||||
<FetchData
|
||||
@on-fetch="(data) => (customsAgents = data)"
|
||||
auto-load
|
||||
url="CustomsAgents"
|
||||
/>
|
||||
<fetch-data @on-fetch="getData" auto-load url="ObservationTypes" />
|
||||
<FetchData @on-fetch="getData" auto-load url="ObservationTypes" />
|
||||
|
||||
<FormModel
|
||||
:observe-form-changes="false"
|
||||
|
@ -176,8 +176,13 @@ function handleLocation(data, location) {
|
|||
<div class="col">
|
||||
<VnLocation
|
||||
:rules="validate('Worker.postcode')"
|
||||
:roles-allowed-to-create="['deliveryAssistant']"
|
||||
v-model="data.postalCode"
|
||||
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
|
||||
:location="{
|
||||
postcode: data.postalCode,
|
||||
city: data.city,
|
||||
province: data.province,
|
||||
country: data.province.country,
|
||||
}"
|
||||
@update:model-value="(location) => handleLocation(data, location)"
|
||||
></VnLocation>
|
||||
</div>
|
||||
|
@ -267,16 +272,17 @@ function handleLocation(data, location) {
|
|||
</div>
|
||||
</VnRow>
|
||||
|
||||
<QIcon
|
||||
<QBtn
|
||||
@click.stop="addNote()"
|
||||
class="cursor-pointer add-icon q-mt-md"
|
||||
name="add"
|
||||
size="sm"
|
||||
flat
|
||||
icon="add"
|
||||
shortcut="+"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('Add note') }}
|
||||
</QTooltip>
|
||||
</QIcon>
|
||||
</QBtn>
|
||||
</template>
|
||||
</FormModel>
|
||||
</template>
|
||||
|
|
|
@ -21,6 +21,7 @@ const newAddressForm = reactive({
|
|||
provinceFk: null,
|
||||
phone: null,
|
||||
mobile: null,
|
||||
province: null,
|
||||
});
|
||||
|
||||
const onDataSaved = () => {
|
||||
|
@ -84,7 +85,17 @@ function handleLocation(data, location) {
|
|||
<VnLocation
|
||||
:rules="validate('Worker.postcode')"
|
||||
:roles-allowed-to-create="['deliveryAssistant']"
|
||||
v-model="data.location"
|
||||
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
|
||||
:location="
|
||||
data.postalCode
|
||||
? {
|
||||
postcode: data.postalCode,
|
||||
city: data.city,
|
||||
province: data.province,
|
||||
country: data.province.country,
|
||||
}
|
||||
: null
|
||||
"
|
||||
@update:model-value="(location) => handleLocation(data, location)"
|
||||
>
|
||||
</VnLocation>
|
||||
|
|
|
@ -51,6 +51,23 @@ function handleLocation(data, location) {
|
|||
:url="`Suppliers/${route.params.id}`"
|
||||
:url-update="`Suppliers/${route.params.id}/updateFiscalData`"
|
||||
model="supplier"
|
||||
:filter="{
|
||||
fields: ['id', 'name', 'city', 'postCode', 'countryFk', 'provinceFk'],
|
||||
include: [
|
||||
{
|
||||
relation: 'province',
|
||||
scope: {
|
||||
fields: ['id', 'name'],
|
||||
},
|
||||
},
|
||||
{
|
||||
relation: 'country',
|
||||
scope: {
|
||||
fields: ['id', 'name'],
|
||||
},
|
||||
},
|
||||
],
|
||||
}"
|
||||
auto-load
|
||||
:clear-store-on-unmount="false"
|
||||
>
|
||||
|
@ -130,7 +147,13 @@ function handleLocation(data, location) {
|
|||
<VnLocation
|
||||
:rules="validate('Worker.postcode')"
|
||||
:roles-allowed-to-create="['deliveryAssistant', 'administrative']"
|
||||
v-model="data.postCode"
|
||||
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
|
||||
:location="{
|
||||
postcode: data.postCode,
|
||||
city: data.city,
|
||||
province: data.province,
|
||||
country: data.country,
|
||||
}"
|
||||
@update:model-value="(location) => handleLocation(data, location)"
|
||||
>
|
||||
</VnLocation>
|
||||
|
|
|
@ -263,8 +263,8 @@ async function autofillBic(worker) {
|
|||
<VnRow>
|
||||
<VnLocation
|
||||
:roles-allowed-to-create="['deliveryAssistant']"
|
||||
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
|
||||
:options="postcodesOptions"
|
||||
v-model="data.location"
|
||||
@update:model-value="(location) => handleLocation(data, location)"
|
||||
:disable="data.isFreelance"
|
||||
>
|
||||
|
@ -311,7 +311,7 @@ async function autofillBic(worker) {
|
|||
option-label="name"
|
||||
option-value="id"
|
||||
hide-selected
|
||||
:roles-allowed-to-create="['salesAssistant', 'hr']"
|
||||
:acls="[{ model: 'BankEntity', props: '*', accessType: 'WRITE' }]"
|
||||
:disable="data.isFreelance"
|
||||
@update:model-value="autofillBic(data)"
|
||||
:filter-options="['bic', 'name']"
|
||||
|
|
Loading…
Reference in New Issue