Merge branch 'dev' of https: refs #8114//gitea.verdnatura.es/verdnatura/salix-front into 8114-removeAutoAddress
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
ce83879960
186
CHANGELOG.md
186
CHANGELOG.md
|
@ -1,3 +1,189 @@
|
|||
# Version 24.48 - 2024-11-25
|
||||
|
||||
### Added 🆕
|
||||
|
||||
- chore: correct checkNotification (fix_customer_issues) by:alexm
|
||||
- chore: perf (warmFix_order_equalSalix) by:alexm
|
||||
- chore: refs #6818 add spaces by:jorgep
|
||||
- chore: refs #6818 drop useless code & comment by:jorgep
|
||||
- chore: refs #7273 sticky add btn & refactor by:jorgep
|
||||
- chore: refs #7524 fix test by:jorgep
|
||||
- chore: refs #8039 not required by:alexm
|
||||
- chore: refs #8078 fiz tests by:jorgep
|
||||
- chore: refs #8078 rollback ref by:jorgep
|
||||
- chore: remove console.log (warmFix_invoiceOut_Global) by:alexm
|
||||
- chore: typo (fix_itemType-redirection) by:alexm
|
||||
- feat: #6943 use openURL quasar by:Javier Segarra
|
||||
- feat: #7782 add cypress report by:Javier Segarra
|
||||
- feat: #7782 cypress.config watchForFileChanges by:Javier Segarra
|
||||
- feat: #7782 npm run resetDatabase by:Javier Segarra
|
||||
- feat: #7782 waitUntil domContentLoad by:Javier Segarra
|
||||
- feat: added composable to confirm orders by:Jon
|
||||
- feat: add /reports in gitignore (warmFix_reports_in_gitignore) by:alexm
|
||||
- feat: apply changes for customerModule by:Javier Segarra
|
||||
- feat: disabled buttons by:Javier Segarra
|
||||
- feat: move buttons to DescriptorMenu by:Javier Segarra
|
||||
- feat: refs #6818 add icon by:jorgep
|
||||
- feat: refs #6818 fetch url & default channel by:jorgep
|
||||
- feat: refs #6818 saysimple integration by:jorgep
|
||||
- feat: refs #6839 module searching (6839-addSearchMenu) by:jorgep
|
||||
- feat: refs #6839 normalize search by:jorgep
|
||||
- feat: refs #6919 sync entry data by:jorgep
|
||||
- feat: refs #7006 itemType basic data new inputs by:guillermo
|
||||
- feat: refs #7006 itemTypeLog added by:guillermo
|
||||
- feat: refs #7193 modified parking to use the scope and corrected small errors by:Jon
|
||||
- feat: refs #7206 added inactive label and corrected minor errors by:Jon
|
||||
- feat: refs #7308 #7308 remove warnings related to useSession by:Javier Segarra
|
||||
- feat: refs #7349 usa back con permisos by:jgallego
|
||||
- feat: refs #7524 add front test by:jorgep
|
||||
- feat: refs #7874 improve vn-notes ui by:jorgep
|
||||
- feat: refs #7970 notify changes by:Jon
|
||||
- feat(): refs #8039 canceledError not notify by:alexm
|
||||
- feat: refs #8039 notify error unify by:alexm
|
||||
- feat: refs #8039 show duplicate request in local by:alexm
|
||||
- feat: refs #8078 add shortcut multi selection by:jorgep
|
||||
- feat: refs #8078 add tests by:jorgep
|
||||
- feat: refs#8087 Redadas en travel by:Carlos Andrés
|
||||
- feat: refs #8087 Traspasar redadas a travels by:Carlos Andrés
|
||||
- feat: remove comments by:Javier Segarra
|
||||
- feat(Supplier): add companySize by:alexm
|
||||
- feat: use composable to unify logic by:Javier Segarra
|
||||
- feat(VnInput): empty to null by:alexm
|
||||
- feat(VnSelect): order data equal salix by:alexm
|
||||
- feat(VnSelect): refs #7136 add scroll (7136-vnSelect_paginate_simplify_2) by:alexm
|
||||
|
||||
### Changed 📦
|
||||
|
||||
- chore: perf (warmFix_order_equalSalix) by:alexm
|
||||
- chore: refs #7273 sticky add btn & refactor by:jorgep
|
||||
- fix: better performance (warmFix_accountAcls) by:alexm
|
||||
- perf: minor bugs detected by:Javier Segarra
|
||||
- perf: refs #6943 #6943 merge command by:Javier Segarra
|
||||
- perf: refs #7283 #7283 declare composable inst4ead code duplicated by:Javier Segarra
|
||||
- perf: refs #7283 #7283 handle composable i18n by:Javier Segarra
|
||||
- perf: refs #7283 #7283 handle i18n by:Javier Segarra
|
||||
- perf: refs #7283 #7283 i18n params by:Javier Segarra
|
||||
- perf: refs #7308 #7308 remove comments by:Javier Segarra
|
||||
- perf: remove appendParams by:Javier Segarra
|
||||
- perf: use const in VnLocation by:Javier Segarra
|
||||
- perf: use required instead :required="true" by:Javier Segarra
|
||||
- refactor: apply QPopupProxy by:wbuezas
|
||||
- refactor: changed confirmOrder directory by:Jon
|
||||
- refactor: change keyup.enter for update:model-value by:wbuezas
|
||||
- refactor(InvoiceInBasicData): use VnDms by:alexm
|
||||
- refactor: modified composable by:Jon
|
||||
- refactor: refs #6818 change channel source by:jorgep
|
||||
- refactor: refs #6818 channel logic by:jorgep
|
||||
- refactor: refs #6919 export filter by:jorgep
|
||||
- refactor: refs #7132 1st wave of changes in global translations files by:Jon
|
||||
- refactor: refs #7132 account's module translations by:Jon
|
||||
- refactor: refs #7132 customer's module translations by:Jon
|
||||
- refactor: refs #7132 deleted pageTitles repeated by:Jon
|
||||
- refactor: refs #7132 delete duplicate translations' keys by:Jon
|
||||
- refactor: refs #7132 deleted useless code by:Jon
|
||||
- refactor: refs #7132 global translations files changed by:Jon
|
||||
- refactor: refs #7266 Changed method name by:guillermo
|
||||
- refactor: refs #7950 Created cmr model by:guillermo
|
||||
- refactor: refs #7970 added emit by:Jon
|
||||
- refactor: refs #7970 refactored VnConfirm to emit events by:Jon
|
||||
- refactor: refs #8185 modified LeftMenu to avoid duplicates by:Jon
|
||||
- refactor: remove unused variable by:wbuezas
|
||||
- refactor: revert catalog changes by:Jon
|
||||
- refactor: small change by:wbuezas
|
||||
- test: refactor e2e by:alexm
|
||||
- test: refs #8039 add hasNotify and, refactor: agencyWorkCenter test by:alexm
|
||||
|
||||
### Fixed 🛠️
|
||||
|
||||
- chore: refs #7524 fix test by:jorgep
|
||||
- fix: better performance (warmFix_accountAcls) by:alexm
|
||||
- fix: catalog view category and type filter by:wbuezas
|
||||
- fix: category and tags filters by:Jon
|
||||
- fix: changed route.query by:Jon
|
||||
- fix: change type vnput by:Javier Segarra
|
||||
- fix(ClaimList): stateCode orderBy priority by:alexm
|
||||
- fix: entryFilters by:carlossa
|
||||
- fix: filter panel by:Jon
|
||||
- fix(InvoiceOutGlobal): parallelism by:alexm
|
||||
- fix: itemBotanical by:Javier Segarra
|
||||
- fix: itemType redirection and fix filters by:alexm
|
||||
- fix: logout spec (warmFix_logout.spec) by:alexm
|
||||
- fix: merge errors by:alexm
|
||||
- fix: order catalog by:wbuezas
|
||||
- fix: order catalog fixes by:wbuezas
|
||||
- fix: refs #6818 use right icon by:jorgep
|
||||
- fix: refs #6896 fixed module problems by:Jon
|
||||
- fix: refs #7193 fixed e2e test by:Jon
|
||||
- fix: refs #7206 deleted duplicate code by:Jon
|
||||
- fix: refs #7273 use same filter by:jorgep
|
||||
- fix: refs #7283 #7283 bugs by:Javier Segarra
|
||||
- fix: refs #7283 #7283 ItemDiary subToolbar by:Javier Segarra
|
||||
- fix: refs #7283 #7283 ItemSummary bugs by:Javier Segarra
|
||||
- fix: refs #7283 Account image resolution by:guillermo
|
||||
- fix: refs #7283 css by:jorgep
|
||||
- fix: refs #7283 filter by:carlossa
|
||||
- fix: refs #7283 fix image by:carlossa
|
||||
- fix: refs #7283 fix pr by:carlossa
|
||||
- fix: refs #7283 fix preview by:carlossa
|
||||
- fix: refs #7283 fix required by:carlossa
|
||||
- fix: refs #7283 item filters by:carlossa
|
||||
- fix: refs #7283 itemtype fix by:carlossa
|
||||
- fix: refs #7283 order translation by:carlossa
|
||||
- fix: refs #7283 preview by:carlossa
|
||||
- fix: refs #7283 tooltips !Item by:Javier Segarra
|
||||
- fix: refs #7306 clean warning by:carlossa
|
||||
- fix: refs #7310 clean warning by:carlossa
|
||||
- fix: refs #7323 locale #7396 by:jorgep
|
||||
- fix: refs #7323 show advanced fields by:jorgep
|
||||
- fix: refs #7349 dependencia no usada by:jgallego
|
||||
- fix: refs #7524 e2e & worker module by:jorgep
|
||||
- fix: refs #7874 add title by:jorgep
|
||||
- fix: refs #7874 show name by:jorgep
|
||||
- fix: refs #7943 use correct data-key by:jorgep
|
||||
- fix: refs #7943 use summary by:jorgep
|
||||
- fix: refs #8039 bad tests by:alexm
|
||||
- fix: refs #8039 o not handle unnecessary errors by:alexm
|
||||
- fix: refs #8078 e2e #7970 by:jorgep
|
||||
- fix: refs #8078 handleSelection by:jorgep
|
||||
- fix: refs #8078 improve cy command (8078-enableMultiSelection) by:jorgep
|
||||
- fix: refs #8078 improve handleSelection by:jorgep
|
||||
- fix: reset category by:wbuezas
|
||||
- fix: tag chips by:Jon
|
||||
- fix: vnSearchbar spec (warmFix_vnSearchBar.spec) by:alexm
|
||||
- fix(VnSelect): setOptions when applyFilter by:alexm
|
||||
- fix: worker test e2e by:Jon
|
||||
- Merge branch 'dev' into fix_customer_issues by:Javier Segarra
|
||||
- refactor: revert catalog changes by:Jon
|
||||
- refs #7283 fix conflicts by:carlossa
|
||||
- refs #7283 fix descriptorproxy by:carlossa
|
||||
- refs #7283 fixedPrice by:carlossa
|
||||
- refs #7283 fixedPrices by:carlossa
|
||||
- refs #7283 fix itemFixed by:carlossa
|
||||
- refs #7283 fix itemFixedPrice by:carlossa
|
||||
- refs #7283 fix itemMigration by:carlossa
|
||||
- refs #7283 fix itemMigration list filters by:carlossa
|
||||
- refs #7283 fix items by:carlossa
|
||||
- refs #7283 fix items error get images by:carlossa
|
||||
- refs #7283 fix items images by:carlossa
|
||||
- refs #7283 fix request by:carlossa
|
||||
- refs #7283 fix searchbar by:carlossa
|
||||
- refs #7283 fix viewSummary by:carlossa
|
||||
- refs #7283 fix yml list basicData by:carlossa
|
||||
- refs #7283 itemRequest fix by:carlossa
|
||||
- refs #7283 itemRequest fix deny by:carlossa
|
||||
- refs #7283 itemRequest fix reload by:carlossa
|
||||
- refs #72983 fix filters by:carlossa
|
||||
- revert: commit by:Javier Segarra
|
||||
- revert e57a253c6f649382da187d1129449d265fb26d3b by:Javier Segarra
|
||||
- test: #8162 fix clientList spec by:Javier Segarra
|
||||
- test: #8162 fix vnLocation spec by:Javier Segarra
|
||||
- test: fix arrayData by:Javier Segarra
|
||||
- test: fix e2e by:alexm
|
||||
- test: fix e2e by:Javier Segarra
|
||||
- test: refs #8039 fix WorkerNotification e2e by:alexm
|
||||
- test: refs #8039 fix ZoneWarehouse e2e by:alexm
|
||||
- warmfix: ItemLastEntries to date (origin/warmfix_itemLastEntriesFilter) by:Javier Segarra
|
||||
|
||||
# Version 24.40 - 2024-10-02
|
||||
|
||||
### Added 🆕
|
||||
|
|
|
@ -40,18 +40,23 @@ const onDataSaved = (...args) => {
|
|||
url-create="towns"
|
||||
model="city"
|
||||
@on-data-saved="onDataSaved"
|
||||
data-cy="newCityForm"
|
||||
>
|
||||
<template #form-inputs="{ data, validate }">
|
||||
<VnRow>
|
||||
<VnInput
|
||||
:label="t('Names')"
|
||||
:label="t('Name')"
|
||||
v-model="data.name"
|
||||
:rules="validate('city.name')"
|
||||
required
|
||||
data-cy="cityName"
|
||||
/>
|
||||
<VnSelectProvince
|
||||
:province-selected="$props.provinceSelected"
|
||||
:country-fk="$props.countryFk"
|
||||
v-model="data.provinceFk"
|
||||
required
|
||||
data-cy="provinceCity"
|
||||
/>
|
||||
</VnRow>
|
||||
</template>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { reactive, ref, watch } from 'vue';
|
||||
import { reactive, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
|
@ -21,13 +21,15 @@ const postcodeFormData = reactive({
|
|||
provinceFk: null,
|
||||
townFk: null,
|
||||
});
|
||||
const townsFetchDataRef = ref(false);
|
||||
const townFilter = ref({});
|
||||
|
||||
const townsFetchDataRef = ref(null);
|
||||
const provincesFetchDataRef = ref(null);
|
||||
const countriesOptions = ref([]);
|
||||
const countriesRef = ref(false);
|
||||
const provincesFetchDataRef = ref(false);
|
||||
const provincesOptions = ref([]);
|
||||
const townsOptions = ref([]);
|
||||
const town = ref({});
|
||||
const countryFilter = ref({});
|
||||
|
||||
function onDataSaved(formData) {
|
||||
const newPostcode = {
|
||||
|
@ -39,13 +41,56 @@ function onDataSaved(formData) {
|
|||
({ id }) => id === formData.provinceFk
|
||||
);
|
||||
newPostcode.province = provinceObject?.name;
|
||||
const countryObject = countriesOptions.value.find(
|
||||
const countryObject = countriesRef.value.opts.find(
|
||||
({ id }) => id === formData.countryFk
|
||||
);
|
||||
newPostcode.country = countryObject?.name;
|
||||
emit('onDataSaved', newPostcode);
|
||||
}
|
||||
|
||||
async function setCountry(countryFk, data) {
|
||||
data.townFk = null;
|
||||
data.provinceFk = null;
|
||||
data.countryFk = countryFk;
|
||||
await fetchTowns();
|
||||
}
|
||||
|
||||
// Province
|
||||
|
||||
async function handleProvinces(data) {
|
||||
provincesOptions.value = data;
|
||||
if (postcodeFormData.countryFk) {
|
||||
await fetchTowns();
|
||||
}
|
||||
}
|
||||
async function setProvince(id, data) {
|
||||
if (data.provinceFk === id) return;
|
||||
const newProvince = provincesOptions.value.find((province) => province.id == id);
|
||||
if (newProvince) data.countryFk = newProvince.countryFk;
|
||||
postcodeFormData.provinceFk = id;
|
||||
await fetchTowns();
|
||||
}
|
||||
async function onProvinceCreated(data) {
|
||||
await provincesFetchDataRef.value.fetch({
|
||||
where: { countryFk: postcodeFormData.countryFk },
|
||||
});
|
||||
postcodeFormData.provinceFk = data.id;
|
||||
}
|
||||
function provinceByCountry(countryFk = postcodeFormData.countryFk) {
|
||||
return provincesOptions.value
|
||||
.filter((province) => province.countryFk === countryFk)
|
||||
.map(({ id }) => id);
|
||||
}
|
||||
|
||||
// Town
|
||||
async function handleTowns(data) {
|
||||
townsOptions.value = data;
|
||||
}
|
||||
function setTown(newTown, data) {
|
||||
town.value = newTown;
|
||||
data.provinceFk = newTown?.provinceFk ?? newTown;
|
||||
data.countryFk = newTown?.province?.countryFk ?? newTown;
|
||||
}
|
||||
async function onCityCreated(newTown, formData) {
|
||||
await provincesFetchDataRef.value.fetch();
|
||||
newTown.province = provincesOptions.value.find(
|
||||
|
@ -54,90 +99,28 @@ async function onCityCreated(newTown, formData) {
|
|||
formData.townFk = newTown;
|
||||
setTown(newTown, formData);
|
||||
}
|
||||
|
||||
function setTown(newTown, data) {
|
||||
data.provinceFk = newTown.provinceFk;
|
||||
data.countryFk = newTown.province.countryFk;
|
||||
if (!newTown) return;
|
||||
town.value = newTown;
|
||||
}
|
||||
|
||||
async function setProvince(id, data) {
|
||||
const newProvince = provincesOptions.value.find((province) => province.id == id);
|
||||
if (!newProvince) return;
|
||||
|
||||
data.countryFk = newProvince.countryFk;
|
||||
}
|
||||
|
||||
async function onProvinceCreated(data) {
|
||||
await provincesFetchDataRef.value.fetch({
|
||||
where: { countryFk: postcodeFormData.countryFk },
|
||||
});
|
||||
postcodeFormData.provinceFk = data.id;
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [postcodeFormData.countryFk],
|
||||
async (newCountryFk, oldValueFk) => {
|
||||
if (Array.isArray(newCountryFk)) {
|
||||
newCountryFk = newCountryFk[0];
|
||||
}
|
||||
if (Array.isArray(oldValueFk)) {
|
||||
oldValueFk = oldValueFk[0];
|
||||
}
|
||||
if (!!oldValueFk && newCountryFk !== oldValueFk) {
|
||||
postcodeFormData.provinceFk = null;
|
||||
postcodeFormData.townFk = null;
|
||||
}
|
||||
if (oldValueFk !== newCountryFk) {
|
||||
await fetchProvinces(newCountryFk);
|
||||
await fetchTowns(newCountryFk);
|
||||
}
|
||||
}
|
||||
);
|
||||
async function fetchTowns(countryFk) {
|
||||
const townsFilter = countryFk
|
||||
? {
|
||||
where: {
|
||||
async function fetchTowns(countryFk = postcodeFormData.countryFk) {
|
||||
if (!countryFk) return;
|
||||
const provinces = postcodeFormData.provinceFk
|
||||
? [postcodeFormData.provinceFk]
|
||||
: provinceByCountry();
|
||||
townFilter.value.where = {
|
||||
provinceFk: {
|
||||
inq: provincesOptions.value.map(({ id }) => id),
|
||||
inq: provinces,
|
||||
},
|
||||
};
|
||||
await townsFetchDataRef.value?.fetch();
|
||||
}
|
||||
|
||||
async function filterTowns(name) {
|
||||
if (name !== '') {
|
||||
townFilter.value.where = {
|
||||
name: {
|
||||
like: `%${name}%`,
|
||||
},
|
||||
};
|
||||
await townsFetchDataRef.value?.fetch();
|
||||
}
|
||||
: {};
|
||||
await townsFetchDataRef.value.fetch(townsFilter);
|
||||
}
|
||||
async function fetchProvinces(countryFk) {
|
||||
const provincesFilter = countryFk
|
||||
? {
|
||||
where: {
|
||||
countryFk: countryFk,
|
||||
},
|
||||
}
|
||||
: {};
|
||||
await provincesFetchDataRef.value.fetch(provincesFilter);
|
||||
}
|
||||
watch(
|
||||
() => postcodeFormData.provinceFk,
|
||||
async (newProvinceFk, oldValueFk) => {
|
||||
if (Array.isArray(newProvinceFk)) {
|
||||
newProvinceFk = newProvinceFk[0];
|
||||
}
|
||||
if (newProvinceFk !== oldValueFk) {
|
||||
await townsFetchDataRef.value.fetch({
|
||||
where: { provinceFk: newProvinceFk },
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
async function handleProvinces(data) {
|
||||
provincesOptions.value = data;
|
||||
}
|
||||
async function handleTowns(data) {
|
||||
townsOptions.value = data;
|
||||
}
|
||||
async function handleCountries(data) {
|
||||
countriesOptions.value = data;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -154,17 +137,11 @@ async function handleCountries(data) {
|
|||
ref="townsFetchDataRef"
|
||||
:sort-by="['name ASC']"
|
||||
:limit="30"
|
||||
:filter="townFilter"
|
||||
@on-fetch="handleTowns"
|
||||
auto-load
|
||||
url="Towns/location"
|
||||
/>
|
||||
<FetchData
|
||||
ref="CountriesFetchDataRef"
|
||||
:sort-by="['name ASC']"
|
||||
@on-fetch="handleCountries"
|
||||
auto-load
|
||||
url="Countries"
|
||||
/>
|
||||
|
||||
<FormModelPopup
|
||||
url-create="postcodes"
|
||||
|
@ -182,10 +159,13 @@ async function handleCountries(data) {
|
|||
v-model="data.code"
|
||||
:rules="validate('postcode.code')"
|
||||
clearable
|
||||
required
|
||||
data-cy="locationPostcode"
|
||||
/>
|
||||
<VnSelectDialog
|
||||
:label="t('City')"
|
||||
@update:model-value="(value) => setTown(value, data)"
|
||||
@filter="filterTowns"
|
||||
:tooltip="t('Create city')"
|
||||
v-model="data.townFk"
|
||||
:options="townsOptions"
|
||||
|
@ -194,7 +174,8 @@ async function handleCountries(data) {
|
|||
:rules="validate('postcode.city')"
|
||||
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
|
||||
:emit-value="false"
|
||||
:clearable="true"
|
||||
required
|
||||
data-cy="locationTown"
|
||||
>
|
||||
<template #option="{ itemProps, opt }">
|
||||
<QItem v-bind="itemProps">
|
||||
|
@ -225,18 +206,25 @@ async function handleCountries(data) {
|
|||
:province-selected="data.provinceFk"
|
||||
@update:model-value="(value) => setProvince(value, data)"
|
||||
v-model="data.provinceFk"
|
||||
:clearable="true"
|
||||
@on-province-created="onProvinceCreated"
|
||||
required
|
||||
/>
|
||||
<VnSelect
|
||||
ref="countriesRef"
|
||||
:limit="30"
|
||||
:filter="countryFilter"
|
||||
:sort-by="['name ASC']"
|
||||
auto-load
|
||||
url="Countries"
|
||||
required
|
||||
:label="t('Country')"
|
||||
@update:options="handleCountries"
|
||||
:options="countriesOptions"
|
||||
hide-selected
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
v-model="data.countryFk"
|
||||
:rules="validate('postcode.countryFk')"
|
||||
@update:model-value="(value) => setCountry(value, data)"
|
||||
data-cy="locationCountry"
|
||||
/>
|
||||
</VnRow>
|
||||
</template>
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
import { computed, reactive, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
@ -21,15 +20,11 @@ const $props = defineProps({
|
|||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
provinces: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
const autonomiesOptions = ref([]);
|
||||
const autonomiesRef = ref([]);
|
||||
|
||||
const onDataSaved = (dataSaved, requestResponse) => {
|
||||
requestResponse.autonomy = autonomiesOptions.value.find(
|
||||
requestResponse.autonomy = autonomiesRef.value.opts.find(
|
||||
(autonomy) => autonomy.id == requestResponse.autonomyFk
|
||||
);
|
||||
emit('onDataSaved', dataSaved, requestResponse);
|
||||
|
@ -43,16 +38,6 @@ const where = computed(() => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
@on-fetch="(data) => (autonomiesOptions = data)"
|
||||
auto-load
|
||||
:filter="{
|
||||
where,
|
||||
}"
|
||||
url="Autonomies/location"
|
||||
:sort-by="['name ASC']"
|
||||
:limit="30"
|
||||
/>
|
||||
<FormModelPopup
|
||||
:title="t('New province')"
|
||||
:subtitle="t('Please, ensure you put the correct data!')"
|
||||
|
@ -67,10 +52,19 @@ const where = computed(() => {
|
|||
:label="t('Name')"
|
||||
v-model="data.name"
|
||||
:rules="validate('province.name')"
|
||||
required
|
||||
data-cy="provinceName"
|
||||
/>
|
||||
<VnSelect
|
||||
data-cy="autonomyProvince"
|
||||
required
|
||||
ref="autonomiesRef"
|
||||
auto-load
|
||||
:where="where"
|
||||
url="Autonomies/location"
|
||||
:sort-by="['name ASC']"
|
||||
:limit="30"
|
||||
:label="t('Autonomy')"
|
||||
:options="autonomiesOptions"
|
||||
hide-selected
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
|
|
|
@ -10,6 +10,7 @@ import VnPaginate from 'components/ui/VnPaginate.vue';
|
|||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||
import SkeletonTable from 'components/ui/SkeletonTable.vue';
|
||||
import { tMobile } from 'src/composables/tMobile';
|
||||
import getDifferences from 'src/filters/getDifferences';
|
||||
|
||||
const { push } = useRouter();
|
||||
const quasar = useQuasar();
|
||||
|
@ -94,6 +95,7 @@ defineExpose({
|
|||
saveChanges,
|
||||
getChanges,
|
||||
formData,
|
||||
originalData,
|
||||
vnPaginateRef,
|
||||
});
|
||||
|
||||
|
@ -174,14 +176,13 @@ async function saveChanges(data) {
|
|||
const changes = data || getChanges();
|
||||
try {
|
||||
await axios.post($props.saveUrl || $props.url + '/crud', changes);
|
||||
} catch (e) {
|
||||
return (isLoading.value = false);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
originalData.value = JSON.parse(JSON.stringify(formData.value));
|
||||
if (changes.creates?.length) await vnPaginateRef.value.fetch();
|
||||
|
||||
hasChanges.value = false;
|
||||
isLoading.value = false;
|
||||
emit('saveChanges', data);
|
||||
quasar.notify({
|
||||
type: 'positive',
|
||||
|
@ -267,28 +268,6 @@ function getChanges() {
|
|||
return changes;
|
||||
}
|
||||
|
||||
function getDifferences(obj1, obj2) {
|
||||
let diff = {};
|
||||
delete obj1.$index;
|
||||
delete obj2.$index;
|
||||
|
||||
for (let key in obj1) {
|
||||
if (obj2[key] && JSON.stringify(obj1[key]) !== JSON.stringify(obj2[key])) {
|
||||
diff[key] = obj2[key];
|
||||
}
|
||||
}
|
||||
for (let key in obj2) {
|
||||
if (
|
||||
obj1[key] === undefined ||
|
||||
JSON.stringify(obj1[key]) !== JSON.stringify(obj2[key])
|
||||
) {
|
||||
diff[key] = obj2[key];
|
||||
}
|
||||
}
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
function isEmpty(obj) {
|
||||
if (obj == null) return true;
|
||||
if (obj === undefined) return true;
|
||||
|
|
|
@ -110,6 +110,7 @@ const originalData = ref({});
|
|||
const formData = computed(() => state.get(modelValue));
|
||||
const defaultButtons = computed(() => ({
|
||||
save: {
|
||||
dataCy: 'saveDefaultBtn',
|
||||
color: 'primary',
|
||||
icon: 'save',
|
||||
label: 'globals.save',
|
||||
|
@ -117,6 +118,7 @@ const defaultButtons = computed(() => ({
|
|||
type: 'submit',
|
||||
},
|
||||
reset: {
|
||||
dataCy: 'resetDefaultBtn',
|
||||
color: 'primary',
|
||||
icon: 'restart_alt',
|
||||
label: 'globals.reset',
|
||||
|
@ -207,7 +209,9 @@ async function save() {
|
|||
isLoading.value = true;
|
||||
try {
|
||||
formData.value = trimData(formData.value);
|
||||
const body = $props.mapper ? $props.mapper(formData.value) : formData.value;
|
||||
const body = $props.mapper
|
||||
? $props.mapper(formData.value, originalData.value)
|
||||
: formData.value;
|
||||
const method = $props.urlCreate ? 'post' : 'patch';
|
||||
const url =
|
||||
$props.urlCreate || $props.urlUpdate || $props.url || arrayData.store.url;
|
||||
|
@ -322,6 +326,7 @@ defineExpose({
|
|||
:title="t(defaultButtons.reset.label)"
|
||||
/>
|
||||
<QBtnDropdown
|
||||
data-cy="saveAndContinueDefaultBtn"
|
||||
v-if="$props.goTo"
|
||||
@click="saveAndGo"
|
||||
:label="tMobile('globals.saveAndContinue')"
|
||||
|
|
|
@ -7,7 +7,7 @@ import VnSelectDialog from 'components/common/VnSelectDialog.vue';
|
|||
import FetchData from 'components/FetchData.vue';
|
||||
import CreateNewProvinceForm from './CreateNewProvinceForm.vue';
|
||||
|
||||
const emit = defineEmits(['onProvinceCreated']);
|
||||
const emit = defineEmits(['onProvinceCreated', 'onProvinceFetched']);
|
||||
const $props = defineProps({
|
||||
countryFk: {
|
||||
type: Number,
|
||||
|
@ -50,6 +50,7 @@ watch(
|
|||
filter.value.where.countryFk = $props.countryFk;
|
||||
} else filter.value.where = {};
|
||||
await provincesFetchDataRef.value.fetch({});
|
||||
emit('onProvinceFetched', provincesOptions.value);
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
@ -63,6 +64,7 @@ watch(
|
|||
auto-load
|
||||
/>
|
||||
<VnSelectDialog
|
||||
data-cy="locationProvince"
|
||||
:label="t('Province')"
|
||||
:options="provincesOptions"
|
||||
:tooltip="t('Create province')"
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { nextTick, ref, watch } from 'vue';
|
||||
import { QInput } from 'quasar';
|
||||
|
||||
const props = defineProps({
|
||||
const $props = defineProps({
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
insertable: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'accountShortToStandard']);
|
||||
|
||||
let internalValue = ref(props.modelValue);
|
||||
let internalValue = ref($props.modelValue);
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
() => $props.modelValue,
|
||||
(newVal) => {
|
||||
internalValue.value = newVal;
|
||||
}
|
||||
|
@ -28,8 +32,46 @@ watch(
|
|||
}
|
||||
);
|
||||
|
||||
const handleKeydown = (e) => {
|
||||
if (e.key === 'Backspace') return;
|
||||
if (e.key === '.') {
|
||||
accountShortToStandard();
|
||||
// TODO: Fix this setTimeout, with nextTick doesn't work
|
||||
setTimeout(() => {
|
||||
setCursorPosition(0, e.target);
|
||||
}, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($props.insertable && e.key.match(/[0-9]/)) {
|
||||
handleInsertMode(e);
|
||||
}
|
||||
};
|
||||
function setCursorPosition(pos, el = vnInputRef.value) {
|
||||
el.focus();
|
||||
el.setSelectionRange(pos, pos);
|
||||
}
|
||||
const vnInputRef = ref(false);
|
||||
const handleInsertMode = (e) => {
|
||||
e.preventDefault();
|
||||
const input = e.target;
|
||||
const cursorPos = input.selectionStart;
|
||||
const { maxlength } = vnInputRef.value;
|
||||
let currentValue = internalValue.value;
|
||||
if (!currentValue) currentValue = e.key;
|
||||
const newValue = e.key;
|
||||
if (newValue && !isNaN(newValue) && cursorPos < maxlength) {
|
||||
internalValue.value =
|
||||
currentValue.substring(0, cursorPos) +
|
||||
newValue +
|
||||
currentValue.substring(cursorPos + 1);
|
||||
}
|
||||
nextTick(() => {
|
||||
input.setSelectionRange(cursorPos + 1, cursorPos + 1);
|
||||
});
|
||||
};
|
||||
function accountShortToStandard() {
|
||||
internalValue.value = internalValue.value.replace(
|
||||
internalValue.value = internalValue.value?.replace(
|
||||
'.',
|
||||
'0'.repeat(11 - internalValue.value.length)
|
||||
);
|
||||
|
@ -37,5 +79,5 @@ function accountShortToStandard() {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<q-input v-model="internalValue" />
|
||||
<QInput @keydown="handleKeydown" ref="vnInputRef" v-model="internalValue" />
|
||||
</template>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { computed, ref, useAttrs } from 'vue';
|
||||
import { computed, ref, useAttrs, nextTick } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRequired } from 'src/composables/useRequired';
|
||||
|
||||
|
@ -34,6 +34,14 @@ const $props = defineProps({
|
|||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
insertable: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
maxlength: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
|
||||
const vnInputRef = ref(null);
|
||||
|
@ -69,6 +77,9 @@ const mixinRules = [
|
|||
requiredFieldRule,
|
||||
...($attrs.rules ?? []),
|
||||
(val) => {
|
||||
const { maxlength } = vnInputRef.value;
|
||||
if (maxlength && +val.length > maxlength)
|
||||
return t(`maxLength`, { value: maxlength });
|
||||
const { min, max } = vnInputRef.value.$attrs;
|
||||
if (!min) return null;
|
||||
if (min >= 0) if (Math.floor(val) < min) return t('inputMin', { value: min });
|
||||
|
@ -78,6 +89,33 @@ const mixinRules = [
|
|||
}
|
||||
},
|
||||
];
|
||||
|
||||
const handleKeydown = (e) => {
|
||||
if (e.key === 'Backspace') return;
|
||||
|
||||
if ($props.insertable && e.key.match(/[0-9]/)) {
|
||||
handleInsertMode(e);
|
||||
}
|
||||
};
|
||||
|
||||
const handleInsertMode = (e) => {
|
||||
e.preventDefault();
|
||||
const input = e.target;
|
||||
const cursorPos = input.selectionStart;
|
||||
const { maxlength } = vnInputRef.value;
|
||||
let currentValue = value.value;
|
||||
if (!currentValue) currentValue = e.key;
|
||||
const newValue = e.key;
|
||||
if (newValue && !isNaN(newValue) && cursorPos < maxlength) {
|
||||
value.value =
|
||||
currentValue.substring(0, cursorPos) +
|
||||
newValue +
|
||||
currentValue.substring(cursorPos + 1);
|
||||
}
|
||||
nextTick(() => {
|
||||
input.setSelectionRange(cursorPos + 1, cursorPos + 1);
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -89,6 +127,7 @@ const mixinRules = [
|
|||
:type="$attrs.type"
|
||||
:class="{ required: isRequired }"
|
||||
@keyup.enter="emit('keyup.enter')"
|
||||
@keydown="handleKeydown"
|
||||
:clearable="false"
|
||||
:rules="mixinRules"
|
||||
:lazy-rules="true"
|
||||
|
@ -130,9 +169,11 @@ const mixinRules = [
|
|||
<i18n>
|
||||
en:
|
||||
inputMin: Must be more than {value}
|
||||
maxLength: The value exceeds {value} characters
|
||||
inputMax: Must be less than {value}
|
||||
es:
|
||||
inputMin: Debe ser mayor a {value}
|
||||
maxLength: El valor excede los {value} carácteres
|
||||
inputMax: Debe ser menor a {value}
|
||||
</i18n>
|
||||
<style lang="scss">
|
||||
|
|
|
@ -75,7 +75,6 @@ const handleModelValue = (data) => {
|
|||
:input-debounce="300"
|
||||
:class="{ required: isRequired }"
|
||||
v-bind="$attrs"
|
||||
clearable
|
||||
:emit-value="false"
|
||||
:tooltip="t('Create new location')"
|
||||
:rules="mixinRules"
|
||||
|
|
|
@ -8,7 +8,14 @@ import dataByOrder from 'src/utils/dataByOrder';
|
|||
const emit = defineEmits(['update:modelValue', 'update:options', 'remove']);
|
||||
const $attrs = useAttrs();
|
||||
const { t } = useI18n();
|
||||
const { isRequired, requiredFieldRule } = useRequired($attrs);
|
||||
|
||||
const isRequired = computed(() => {
|
||||
return useRequired($attrs).isRequired;
|
||||
});
|
||||
const requiredFieldRule = computed(() => {
|
||||
return useRequired($attrs).requiredFieldRule;
|
||||
});
|
||||
|
||||
const $props = defineProps({
|
||||
modelValue: {
|
||||
type: [String, Number, Object],
|
||||
|
@ -308,9 +315,9 @@ function handleKeyDown(event) {
|
|||
@virtual-scroll="onScroll"
|
||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_select'"
|
||||
>
|
||||
<template v-if="isClearable" #append>
|
||||
<template #append>
|
||||
<QIcon
|
||||
v-show="value"
|
||||
v-show="isClearable && value"
|
||||
name="close"
|
||||
@click.stop="
|
||||
() => {
|
||||
|
@ -323,7 +330,22 @@ function handleKeyDown(event) {
|
|||
/>
|
||||
</template>
|
||||
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
|
||||
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
||||
<div v-if="slotName == 'append'">
|
||||
<QIcon
|
||||
v-show="isClearable && value"
|
||||
name="close"
|
||||
@click.stop="
|
||||
() => {
|
||||
value = null;
|
||||
emit('remove');
|
||||
}
|
||||
"
|
||||
class="cursor-pointer"
|
||||
size="xs"
|
||||
/>
|
||||
<slot name="append" v-if="$slots.append" v-bind="slotData ?? {}" />
|
||||
</div>
|
||||
<slot v-else :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
||||
</template>
|
||||
</QSelect>
|
||||
</template>
|
||||
|
|
|
@ -43,6 +43,7 @@ const isAllowedToCreate = computed(() => {
|
|||
>
|
||||
<template v-if="isAllowedToCreate" #append>
|
||||
<QIcon
|
||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_icon'"
|
||||
@click.stop.prevent="$refs.dialog.show()"
|
||||
:name="actionIcon"
|
||||
:size="actionIcon === 'add' ? 'xs' : 'sm'"
|
||||
|
|
|
@ -6,7 +6,7 @@ import { useColor } from 'src/composables/useColor';
|
|||
import { getCssVar } from 'quasar';
|
||||
|
||||
const $props = defineProps({
|
||||
workerId: { type: Number, required: true },
|
||||
workerId: { type: [Number, undefined], default: null },
|
||||
description: { type: String, default: null },
|
||||
title: { type: String, default: null },
|
||||
color: { type: String, default: null },
|
||||
|
@ -38,7 +38,13 @@ watch(src, () => (showLetter.value = false));
|
|||
<template v-if="showLetter">
|
||||
{{ title.charAt(0) }}
|
||||
</template>
|
||||
<QImg v-else :src="src" spinner-color="white" @error="showLetter = true" />
|
||||
<QImg
|
||||
v-else-if="workerId"
|
||||
:src="src"
|
||||
spinner-color="white"
|
||||
@error="showLetter = true"
|
||||
/>
|
||||
<QIcon v-else name="mood" size="xs" />
|
||||
</QAvatar>
|
||||
<div class="description">
|
||||
<slot name="description" v-if="description">
|
||||
|
|
|
@ -273,6 +273,7 @@ function sanitizer(params) {
|
|||
:key="chip.label"
|
||||
:removable="!unremovableParams?.includes(chip.label)"
|
||||
@remove="remove(chip.label)"
|
||||
data-cy="vnFilterPanelChip"
|
||||
>
|
||||
<slot name="tags" :tag="chip" :format-fn="formatValue">
|
||||
<div class="q-gutter-x-xs">
|
||||
|
|
|
@ -1,22 +1,28 @@
|
|||
<script setup>
|
||||
import { reactive, useAttrs, onBeforeMount, capitalize } from 'vue';
|
||||
import { ref, reactive, useAttrs, onBeforeMount, capitalize } from 'vue';
|
||||
import axios from 'axios';
|
||||
import { parsePhone } from 'src/filters';
|
||||
import useOpenURL from 'src/composables/useOpenURL';
|
||||
|
||||
const props = defineProps({
|
||||
phoneNumber: { type: [String, Number], default: null },
|
||||
channel: { type: Number, default: null },
|
||||
country: { type: String, default: null },
|
||||
});
|
||||
|
||||
const phone = ref(props.phoneNumber);
|
||||
const config = reactive({
|
||||
sip: { icon: 'phone', href: `sip:${props.phoneNumber}` },
|
||||
'say-simple': {
|
||||
icon: 'vn:saysimple',
|
||||
href: null,
|
||||
url: null,
|
||||
channel: props.channel,
|
||||
},
|
||||
});
|
||||
const type = Object.keys(config).find((key) => key in useAttrs()) || 'sip';
|
||||
|
||||
onBeforeMount(async () => {
|
||||
if (!phone.value) return;
|
||||
let { channel } = config[type];
|
||||
|
||||
if (type === 'say-simple') {
|
||||
|
@ -24,23 +30,28 @@ onBeforeMount(async () => {
|
|||
.data;
|
||||
if (!channel) channel = defaultChannel;
|
||||
|
||||
phone.value = await parsePhone(props.phoneNumber, props.country.toLowerCase());
|
||||
config[
|
||||
type
|
||||
].href = `${url}?customerIdentity=%2B${props.phoneNumber}&channelId=${channel}`;
|
||||
].url = `${url}?customerIdentity=%2B${phone.value}&channelId=${channel}`;
|
||||
}
|
||||
});
|
||||
|
||||
function handleClick() {
|
||||
if (config[type].url) useOpenURL(config[type].url);
|
||||
else if (config[type].href) window.location.href = config[type].href;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<QBtn
|
||||
v-if="phoneNumber"
|
||||
v-if="phone"
|
||||
flat
|
||||
round
|
||||
:icon="config[type].icon"
|
||||
size="sm"
|
||||
color="primary"
|
||||
padding="none"
|
||||
:href="config[type].href"
|
||||
@click.stop
|
||||
@click.stop="handleClick"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ capitalize(type).replace('-', '') }}
|
||||
|
|
|
@ -101,6 +101,7 @@ onBeforeRouteLeave((to, from, next) => {
|
|||
@click="insert"
|
||||
class="q-mb-xs"
|
||||
dense
|
||||
data-cy="saveNote"
|
||||
/>
|
||||
</template>
|
||||
</VnInput>
|
||||
|
|
|
@ -133,7 +133,7 @@ const addFilter = async (filter, params) => {
|
|||
async function fetch(params) {
|
||||
useArrayData(props.dataKey, params);
|
||||
arrayData.reset(['filter.skip', 'skip', 'page']);
|
||||
await arrayData.fetch({ append: false });
|
||||
await arrayData.fetch({ append: false, updateRouter: mounted.value });
|
||||
return emitStoreData();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,14 @@ import { useValidator } from 'src/composables/useValidator';
|
|||
|
||||
export function useRequired($attrs) {
|
||||
const { validations } = useValidator();
|
||||
|
||||
const isRequired = Object.keys($attrs).includes('required');
|
||||
const hasRequired = Object.keys($attrs).includes('required');
|
||||
let isRequired = false;
|
||||
if (hasRequired) {
|
||||
const required = $attrs['required'];
|
||||
if (typeof required === 'boolean') {
|
||||
isRequired = required;
|
||||
}
|
||||
}
|
||||
const requiredFieldRule = (val) => validations().required(isRequired, val);
|
||||
|
||||
return {
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
export default function getDifferences(obj1, obj2) {
|
||||
let diff = {};
|
||||
delete obj1.$index;
|
||||
delete obj2.$index;
|
||||
|
||||
for (let key in obj1) {
|
||||
if (obj2[key] && JSON.stringify(obj1[key]) !== JSON.stringify(obj2[key])) {
|
||||
diff[key] = obj2[key];
|
||||
}
|
||||
}
|
||||
for (let key in obj2) {
|
||||
if (
|
||||
obj1[key] === undefined ||
|
||||
JSON.stringify(obj1[key]) !== JSON.stringify(obj2[key])
|
||||
) {
|
||||
diff[key] = obj2[key];
|
||||
}
|
||||
}
|
||||
|
||||
return diff;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
export default function getUpdatedValues(keys, formData) {
|
||||
return keys.reduce((acc, key) => {
|
||||
acc[key] = formData[key];
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
|
@ -11,11 +11,17 @@ import dashIfEmpty from './dashIfEmpty';
|
|||
import dateRange from './dateRange';
|
||||
import toHour from './toHour';
|
||||
import dashOrCurrency from './dashOrCurrency';
|
||||
import getDifferences from './getDifferences';
|
||||
import getUpdatedValues from './getUpdatedValues';
|
||||
import getParamWhere from './getParamWhere';
|
||||
import parsePhone from './parsePhone';
|
||||
import isDialogOpened from './isDialogOpened';
|
||||
|
||||
export {
|
||||
getUpdatedValues,
|
||||
getDifferences,
|
||||
isDialogOpened,
|
||||
parsePhone,
|
||||
toLowerCase,
|
||||
toLowerCamel,
|
||||
toDate,
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
import axios from 'axios';
|
||||
|
||||
export default async function parsePhone(phone, country) {
|
||||
if (!phone) return;
|
||||
if (phone.startsWith('+')) return `${phone.slice(1)}`;
|
||||
if (phone.startsWith('00')) return `${phone.slice(2)}`;
|
||||
|
||||
let prefix;
|
||||
try {
|
||||
prefix = (await axios.get(`Prefixes/${country.toLowerCase()}`)).data?.prefix;
|
||||
} catch (e) {
|
||||
prefix = (await axios.get('PbxConfigs/findOne')).data?.defaultPrefix;
|
||||
}
|
||||
prefix = prefix.replace(/^0+/, '');
|
||||
|
||||
if (phone.startsWith(prefix)) return phone;
|
||||
return `${prefix}${phone}`;
|
||||
}
|
|
@ -60,7 +60,7 @@ globals:
|
|||
reference: Reference
|
||||
agency: Agency
|
||||
warehouseOut: Warehouse Out
|
||||
wareHouseIn: Warehouse In
|
||||
warehouseIn: Warehouse In
|
||||
landed: Landed
|
||||
shipped: Shipped
|
||||
totalEntries: Total entries
|
||||
|
@ -768,7 +768,7 @@ travel:
|
|||
thermographs: Thermographs
|
||||
hb: HB
|
||||
basicData:
|
||||
daysInForward: Days in forward
|
||||
daysInForward: Automatic movement (Raid)
|
||||
isRaid: Raid
|
||||
thermographs:
|
||||
temperature: Temperature
|
||||
|
|
|
@ -762,7 +762,7 @@ travel:
|
|||
thermographs: Termógrafos
|
||||
hb: HB
|
||||
basicData:
|
||||
daysInForward: Días redada
|
||||
daysInForward: Desplazamiento automatico (redada)
|
||||
isRaid: Redada
|
||||
thermographs:
|
||||
temperature: Temperatura
|
||||
|
|
|
@ -41,8 +41,12 @@ const fetchAccountExistence = async () => {
|
|||
};
|
||||
|
||||
const fetchMailForwards = async () => {
|
||||
try {
|
||||
const response = await axios.get(`MailForwards/${route.params.id}`);
|
||||
return response.data;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const deleteMailForward = async () => {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import { onBeforeMount, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
|
||||
import axios from 'axios';
|
||||
|
||||
|
@ -52,7 +53,6 @@ const addressFilter = {
|
|||
|
||||
onBeforeMount(() => {
|
||||
const { id } = route.params;
|
||||
getAddressesData(id);
|
||||
getClientData(id);
|
||||
});
|
||||
|
||||
|
@ -60,23 +60,10 @@ watch(
|
|||
() => route.params.id,
|
||||
(newValue) => {
|
||||
if (!newValue) return;
|
||||
getAddressesData(newValue);
|
||||
getClientData(newValue);
|
||||
}
|
||||
);
|
||||
|
||||
const getAddressesData = async (id) => {
|
||||
try {
|
||||
const { data } = await axios.get(`Clients/${id}/addresses`, {
|
||||
params: { filter: JSON.stringify(addressFilter) },
|
||||
});
|
||||
addresses.value = data;
|
||||
sortAddresses();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
};
|
||||
|
||||
const getClientData = async (id) => {
|
||||
try {
|
||||
const { data } = await axios.get(`Clients/${id}`);
|
||||
|
@ -101,9 +88,9 @@ const setDefault = (address) => {
|
|||
});
|
||||
};
|
||||
|
||||
const sortAddresses = () => {
|
||||
if (!client.value || !addresses.value) return;
|
||||
addresses.value = addresses.value.sort((a, b) => {
|
||||
const sortAddresses = (data) => {
|
||||
if (!client.value || !data) return;
|
||||
addresses.value = data.sort((a, b) => {
|
||||
return isDefaultAddress(b) - isDefaultAddress(a);
|
||||
});
|
||||
};
|
||||
|
@ -124,8 +111,17 @@ const toCustomerAddressEdit = (addressId) => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
@on-fetch="sortAddresses"
|
||||
auto-load
|
||||
data-key="CustomerAddresses"
|
||||
order="id DESC"
|
||||
ref="vnPaginateRef"
|
||||
:filter="addressFilter"
|
||||
:url="`Clients/${route.params.id}/addresses`"
|
||||
/>
|
||||
<div class="full-width flex justify-center">
|
||||
<QCard class="card-width q-pa-lg" v-if="addresses.length">
|
||||
<QCard class="card-width q-pa-lg">
|
||||
<QCardSection>
|
||||
<div
|
||||
v-for="(item, index) in addresses"
|
||||
|
|
|
@ -9,6 +9,7 @@ import VnRow from 'components/ui/VnRow.vue';
|
|||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnAvatar from 'src/components/ui/VnAvatar.vue';
|
||||
import { getDifferences, getUpdatedValues } from 'src/filters';
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
|
@ -30,6 +31,13 @@ const exprBuilder = (param, value) => {
|
|||
and: [{ active: { neq: false } }, handleSalesModelValue(value)],
|
||||
};
|
||||
};
|
||||
|
||||
function onBeforeSave(formData, originalData) {
|
||||
return getUpdatedValues(
|
||||
Object.keys(getDifferences(formData, originalData)),
|
||||
formData
|
||||
);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
|
@ -43,7 +51,12 @@ const exprBuilder = (param, value) => {
|
|||
@on-fetch="(data) => (businessTypes = data)"
|
||||
auto-load
|
||||
/>
|
||||
<FormModel :url="`Clients/${route.params.id}`" auto-load model="customer">
|
||||
<FormModel
|
||||
:url="`Clients/${route.params.id}`"
|
||||
auto-load
|
||||
model="customer"
|
||||
:mapper="onBeforeSave"
|
||||
>
|
||||
<template #form="{ data, validate }">
|
||||
<VnRow>
|
||||
<VnInput
|
||||
|
@ -94,6 +107,7 @@ const exprBuilder = (param, value) => {
|
|||
:rules="validate('client.phone')"
|
||||
clearable
|
||||
v-model="data.phone"
|
||||
data-cy="customerPhone"
|
||||
/>
|
||||
<VnInput
|
||||
:label="t('customer.summary.mobile')"
|
||||
|
@ -155,7 +169,6 @@ const exprBuilder = (param, value) => {
|
|||
url="Clients"
|
||||
:input-debounce="0"
|
||||
:label="t('customer.basicData.previousClient')"
|
||||
:options="clients"
|
||||
:rules="validate('client.transferorFk')"
|
||||
emit-value
|
||||
map-options
|
||||
|
|
|
@ -28,12 +28,7 @@ const getBankEntities = (data, formData) => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<FormModel
|
||||
:url-update="`Clients/${route.params.id}`"
|
||||
:url="`Clients/${route.params.id}/getCard`"
|
||||
auto-load
|
||||
model="customer"
|
||||
>
|
||||
<FormModel :url-update="`Clients/${route.params.id}`" auto-load model="customer">
|
||||
<template #form="{ data, validate }">
|
||||
<VnRow>
|
||||
<VnSelect
|
||||
|
|
|
@ -93,22 +93,6 @@ const columns = computed(() => [
|
|||
<WorkerDescriptorProxy :id="row.worker.id" />
|
||||
</template>
|
||||
</VnTable>
|
||||
<!-- <QTable
|
||||
:columns="columns"
|
||||
:pagination="{ rowsPerPage: 0 }"
|
||||
:rows="rows"
|
||||
hide-bottom
|
||||
row-key="id"
|
||||
v-model:selected="selected"
|
||||
class="card-width q-px-lg"
|
||||
>
|
||||
<template #body-cell-employee="{ row }">
|
||||
<QTd @click.stop>
|
||||
<span class="link">{{ row.worker.user.nickname }}</span>
|
||||
<WorkerDescriptorProxy :id="row.clientFk" />
|
||||
</QTd>
|
||||
</template>
|
||||
</QTable> -->
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
|
|
|
@ -36,7 +36,10 @@ const entityId = computed(() => {
|
|||
});
|
||||
|
||||
const data = ref(useCardDescription());
|
||||
const setData = (entity) => (data.value = useCardDescription(entity?.name, entity?.id));
|
||||
const setData = (entity) => {
|
||||
data.value = useCardDescription(entity?.name, entity?.id);
|
||||
if (customer.value) customer.value.webAccess = data.value?.account?.isActive;
|
||||
};
|
||||
const debtWarning = computed(() => {
|
||||
return customer.value?.debt > customer.value?.credit ? 'negative' : 'primary';
|
||||
});
|
||||
|
|
|
@ -34,7 +34,6 @@ function handleLocation(data, location) {
|
|||
/>
|
||||
<FormModel
|
||||
:url-update="`Clients/${route.params.id}/updateFiscalData`"
|
||||
:url="`Clients/${route.params.id}/getCard`"
|
||||
auto-load
|
||||
model="customer"
|
||||
>
|
||||
|
@ -68,6 +67,7 @@ function handleLocation(data, location) {
|
|||
option-label="vat"
|
||||
option-value="id"
|
||||
v-model="data.sageTaxTypeFk"
|
||||
data-cy="sageTaxTypeFk"
|
||||
:required="data.isTaxDataChecked"
|
||||
/>
|
||||
<VnSelect
|
||||
|
@ -76,6 +76,7 @@ function handleLocation(data, location) {
|
|||
hide-selected
|
||||
option-label="transaction"
|
||||
option-value="id"
|
||||
data-cy="sageTransactionTypeFk"
|
||||
v-model="data.sageTransactionTypeFk"
|
||||
:required="data.isTaxDataChecked"
|
||||
>
|
||||
|
|
|
@ -95,6 +95,7 @@ const sumRisk = ({ clientRisks }) => {
|
|||
:phone-number="entity.mobile"
|
||||
:channel="entity.country?.saySimpleCountry?.channel"
|
||||
class="q-ml-xs"
|
||||
:country="entity.country?.code"
|
||||
/>
|
||||
</template>
|
||||
</VnLv>
|
||||
|
|
|
@ -1,164 +1,82 @@
|
|||
<script setup>
|
||||
import { computed, onBeforeMount, ref, watch, nextTick } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import FormModel from 'components/FormModel.vue';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import axios from 'axios';
|
||||
import useNotify from 'src/composables/useNotify';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
const formModelRef = ref(false);
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const { notify } = useNotify();
|
||||
const stateStore = useStateStore();
|
||||
|
||||
const amountInputRef = ref(null);
|
||||
const initialDated = Date.vnNew();
|
||||
const unpaidClient = ref(false);
|
||||
const isLoading = ref(false);
|
||||
const amount = ref(null);
|
||||
const dated = ref(initialDated);
|
||||
|
||||
const initialData = ref({
|
||||
dated: initialDated,
|
||||
dated: Date.vnNew(),
|
||||
amount: null,
|
||||
});
|
||||
|
||||
const hasChanged = computed(() => {
|
||||
return (
|
||||
initialData.value.dated !== dated.value ||
|
||||
initialData.value.amount !== amount.value
|
||||
);
|
||||
});
|
||||
|
||||
onBeforeMount(() => {
|
||||
getData(route.params.id);
|
||||
});
|
||||
|
||||
watch(
|
||||
() => route.params.id,
|
||||
(newValue) => {
|
||||
if (!newValue) return;
|
||||
getData(newValue);
|
||||
}
|
||||
);
|
||||
|
||||
const getData = async (id) => {
|
||||
const filter = { where: { clientFk: id } };
|
||||
try {
|
||||
const { data } = await axios.get('ClientUnpaids', {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
if (data.length) {
|
||||
setValues(data[0]);
|
||||
} else {
|
||||
defaultValues();
|
||||
}
|
||||
} catch (error) {
|
||||
defaultValues();
|
||||
}
|
||||
};
|
||||
|
||||
const setValues = (data) => {
|
||||
unpaidClient.value = true;
|
||||
amount.value = data.amount;
|
||||
dated.value = data.dated;
|
||||
initialData.value = data;
|
||||
};
|
||||
|
||||
const defaultValues = () => {
|
||||
unpaidClient.value = false;
|
||||
initialData.value.amount = null;
|
||||
setInitialData();
|
||||
};
|
||||
|
||||
const setInitialData = () => {
|
||||
amount.value = initialData.value.amount;
|
||||
dated.value = initialData.value.dated;
|
||||
};
|
||||
|
||||
const onSubmit = async () => {
|
||||
isLoading.value = true;
|
||||
|
||||
const payload = {
|
||||
amount: amount.value,
|
||||
const filterClientFindOne = {
|
||||
fields: ['unpaid', 'dated', 'amount'],
|
||||
where: {
|
||||
clientFk: route.params.id,
|
||||
dated: dated.value,
|
||||
},
|
||||
};
|
||||
try {
|
||||
await axios.patch('ClientUnpaids', payload);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
unpaidClient.value = true;
|
||||
} catch (error) {
|
||||
notify('errors.writeRequest', 'negative');
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
() => unpaidClient.value,
|
||||
async (val) => {
|
||||
await nextTick();
|
||||
if (val) amountInputRef.value.focus();
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport v-if="stateStore?.isSubToolbarShown()" to="#st-actions">
|
||||
<QBtnGroup push class="q-gutter-x-sm">
|
||||
<QBtn
|
||||
:disabled="!hasChanged"
|
||||
:label="t('globals.reset')"
|
||||
:loading="isLoading"
|
||||
@click="setInitialData"
|
||||
color="primary"
|
||||
flat
|
||||
icon="restart_alt"
|
||||
type="reset"
|
||||
<FetchData
|
||||
:filter="filterClientFindOne"
|
||||
auto-load
|
||||
url="ClientUnpaids"
|
||||
@on-fetch="
|
||||
(data) => {
|
||||
const unpaid = data.length == 1;
|
||||
initialData = { ...data[0], unpaid };
|
||||
}
|
||||
"
|
||||
/>
|
||||
<QBtn
|
||||
:disabled="!hasChanged"
|
||||
:label="t('globals.save')"
|
||||
:loading="isLoading"
|
||||
@click="onSubmit"
|
||||
color="primary"
|
||||
icon="save"
|
||||
/>
|
||||
</QBtnGroup>
|
||||
</Teleport>
|
||||
|
||||
<div class="full-width flex justify-center">
|
||||
<QCard class="card-width q-pa-lg">
|
||||
<QForm>
|
||||
<QCard>
|
||||
<FormModel
|
||||
v-if="'unpaid' in initialData"
|
||||
:observe-form-changes="false"
|
||||
ref="formModelRef"
|
||||
model="unpaid"
|
||||
url-update="ClientUnpaids"
|
||||
:mapper="(formData) => ({ ...formData, clientFk: route.params.id })"
|
||||
:form-initial-data="initialData"
|
||||
>
|
||||
<template #form="{ data }">
|
||||
<VnRow>
|
||||
<div class="col">
|
||||
<QCheckbox :label="t('Unpaid client')" v-model="unpaidClient" />
|
||||
</div>
|
||||
<QCheckbox :label="t('Unpaid client')" v-model="data.unpaid" />
|
||||
</VnRow>
|
||||
|
||||
<VnRow class="row q-gutter-md q-mb-md" v-show="unpaidClient">
|
||||
<VnRow class="row q-gutter-md q-mb-md" v-show="data.unpaid">
|
||||
<div class="col">
|
||||
<VnInputDate :label="t('Date')" v-model="dated" />
|
||||
<VnInputDate
|
||||
data-cy="customerUnpaidDate"
|
||||
:label="t('Date')"
|
||||
v-model="data.dated"
|
||||
/>
|
||||
</div>
|
||||
<div class="col">
|
||||
<VnInput
|
||||
<VnInputNumber
|
||||
data-cy="customerUnpaidAmount"
|
||||
ref="amountInputRef"
|
||||
:label="t('Amount')"
|
||||
clearable
|
||||
type="number"
|
||||
v-model="amount"
|
||||
v-model="data.amount"
|
||||
autofocus
|
||||
>
|
||||
<template #append>€</template></VnInput
|
||||
<template #append>€</template></VnInputNumber
|
||||
>
|
||||
</div>
|
||||
</VnRow>
|
||||
</QForm>
|
||||
</template>
|
||||
</FormModel>
|
||||
</QCard>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
|
|
|
@ -25,10 +25,9 @@ async function hasCustomerRole() {
|
|||
</script>
|
||||
<template>
|
||||
<FormModel
|
||||
url="VnUsers/preview"
|
||||
:url-update="`Clients/${route.params.id}/updateUser`"
|
||||
:filter="filter"
|
||||
model="webAccess"
|
||||
model="customer"
|
||||
:mapper="
|
||||
({ active, name, email }) => {
|
||||
return {
|
||||
|
@ -42,14 +41,14 @@ async function hasCustomerRole() {
|
|||
auto-load
|
||||
>
|
||||
<template #form="{ data, validate }">
|
||||
<QCheckbox :label="t('Enable web access')" v-model="data.active" />
|
||||
<VnInput :label="t('User')" clearable v-model="data.name" />
|
||||
<QCheckbox :label="t('Enable web access')" v-model="data.account.active" />
|
||||
<VnInput :label="t('User')" clearable v-model="data.account.name" />
|
||||
<VnInput
|
||||
:label="t('Recovery email')"
|
||||
:rules="validate('client.email')"
|
||||
clearable
|
||||
type="email"
|
||||
v-model="data.email"
|
||||
v-model="data.account.email"
|
||||
class="q-mt-sm"
|
||||
:info="t('This email is used for user to regain access their account')"
|
||||
/>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<script setup>
|
||||
import { computed, onBeforeMount, ref, watch } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import axios from 'axios';
|
||||
import FetchData from 'src/components/FetchData.vue';
|
||||
|
||||
import { toCurrency, toDateHourMin } from 'src/filters';
|
||||
|
||||
|
@ -20,10 +20,11 @@ const filter = {
|
|||
{ relation: 'mandateType', scope: { fields: ['id', 'name'] } },
|
||||
{ relation: 'company', scope: { fields: ['id', 'code'] } },
|
||||
],
|
||||
where: { clientFk: null },
|
||||
where: { clientFk: route.params.id },
|
||||
order: ['created DESC'],
|
||||
limit: 20,
|
||||
};
|
||||
const ClientDmsRef = ref(false);
|
||||
|
||||
const tableColumnComponents = {
|
||||
state: {
|
||||
|
@ -50,7 +51,7 @@ const tableColumnComponents = {
|
|||
component: CustomerCheckIconTooltip,
|
||||
props: ({ row }) => ({
|
||||
transaction: row,
|
||||
promise: refreshData,
|
||||
promise: () => ClientDmsRef.value.fetch(),
|
||||
}),
|
||||
event: () => {},
|
||||
},
|
||||
|
@ -89,38 +90,16 @@ const columns = computed(() => [
|
|||
name: 'validate',
|
||||
},
|
||||
]);
|
||||
|
||||
onBeforeMount(() => {
|
||||
getData(route.params.id);
|
||||
});
|
||||
|
||||
watch(
|
||||
() => route.params.id,
|
||||
(newValue) => {
|
||||
if (!newValue) return;
|
||||
getData(newValue);
|
||||
}
|
||||
);
|
||||
|
||||
const getData = async (id) => {
|
||||
filter.where.clientFk = id;
|
||||
try {
|
||||
const { data } = await axios.get('clients/transactions', {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
rows.value = data;
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
};
|
||||
|
||||
const refreshData = () => {
|
||||
getData(route.params.id);
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="full-width flex justify-center">
|
||||
<FetchData
|
||||
ref="ClientDmsRef"
|
||||
:filter="filter"
|
||||
@on-fetch="(data) => (rows = data)"
|
||||
auto-load
|
||||
url="Clients/transactions"
|
||||
/>
|
||||
<QPage class="card-width q-pa-lg">
|
||||
<QTable
|
||||
:columns="columns"
|
||||
|
@ -135,13 +114,9 @@ const refreshData = () => {
|
|||
<QTr :props="props">
|
||||
<component
|
||||
:is="tableColumnComponents[props.col.name].component"
|
||||
@click="
|
||||
tableColumnComponents[props.col.name].event(props)
|
||||
"
|
||||
@click="tableColumnComponents[props.col.name].event(props)"
|
||||
class="rounded-borders q-pa-sm"
|
||||
v-bind="
|
||||
tableColumnComponents[props.col.name].props(props)
|
||||
"
|
||||
v-bind="tableColumnComponents[props.col.name].props(props)"
|
||||
>
|
||||
{{ props.value }}
|
||||
</component>
|
||||
|
@ -154,7 +129,6 @@ const refreshData = () => {
|
|||
{{ t('globals.noResults') }}
|
||||
</h5>
|
||||
</QPage>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
|
|
|
@ -101,8 +101,8 @@ const exprBuilder = (param, value) => {
|
|||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem class="q-mb-sm">
|
||||
<QItemSection
|
||||
><VnSelect
|
||||
<QItemSection>
|
||||
<VnSelect
|
||||
url="Provinces"
|
||||
:label="t('Province')"
|
||||
v-model="params.provinceFk"
|
||||
|
@ -120,14 +120,12 @@ const exprBuilder = (param, value) => {
|
|||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem class="q-mb-md">
|
||||
<QItem class="q-mb-sm">
|
||||
<QItemSection>
|
||||
<VnInput :label="t('City')" v-model="params.city" is-outlined />
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QSeparator />
|
||||
<QExpansionItem :label="t('More options')" expand-separator>
|
||||
<QItem>
|
||||
<QItem class="q-mb-sm">
|
||||
<QItemSection>
|
||||
<VnInput :label="t('Phone')" v-model="params.phone" is-outlined>
|
||||
<template #prepend>
|
||||
|
@ -136,7 +134,7 @@ const exprBuilder = (param, value) => {
|
|||
</VnInput>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItem class="q-mb-sm">
|
||||
<QItemSection>
|
||||
<VnInput :label="t('Email')" v-model="params.email" is-outlined>
|
||||
<template #prepend>
|
||||
|
@ -145,7 +143,8 @@ const exprBuilder = (param, value) => {
|
|||
</VnInput>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItem class="q-mb-sm">
|
||||
<QItemSection>
|
||||
<VnSelect
|
||||
url="Zones"
|
||||
:label="t('Zone')"
|
||||
|
@ -160,9 +159,9 @@ const exprBuilder = (param, value) => {
|
|||
outlined
|
||||
rounded
|
||||
auto-load
|
||||
/>
|
||||
/></QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItem class="q-mb-sm">
|
||||
<QItemSection>
|
||||
<VnInput
|
||||
:label="t('Postcode')"
|
||||
|
@ -171,7 +170,6 @@ const exprBuilder = (param, value) => {
|
|||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</QExpansionItem>
|
||||
</template>
|
||||
</VnFilterPanel>
|
||||
</template>
|
||||
|
@ -203,7 +201,6 @@ es:
|
|||
Salesperson: Comercial
|
||||
Province: Provincia
|
||||
City: Ciudad
|
||||
More options: Más opciones
|
||||
Phone: Teléfono
|
||||
Email: Email
|
||||
Zone: Zona
|
||||
|
|
|
@ -12,6 +12,7 @@ import RightMenu from 'src/components/common/RightMenu.vue';
|
|||
import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue';
|
||||
import { toDate } from 'src/filters';
|
||||
import CustomerFilter from './CustomerFilter.vue';
|
||||
import VnAvatar from 'src/components/ui/VnAvatar.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
<script setup>
|
||||
import { onBeforeMount, reactive, ref } from 'vue';
|
||||
import { reactive, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
import axios from 'axios';
|
||||
import VnLocation from 'src/components/common/VnLocation.vue';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import FormModel from 'components/FormModel.vue';
|
||||
|
@ -19,26 +18,10 @@ const router = useRouter();
|
|||
|
||||
const formInitialData = reactive({ isDefaultAddress: false });
|
||||
|
||||
const urlCreate = ref('');
|
||||
|
||||
const agencyModes = ref([]);
|
||||
const incoterms = ref([]);
|
||||
const customsAgents = ref([]);
|
||||
|
||||
onBeforeMount(() => {
|
||||
urlCreate.value = `Clients/${route.params.id}/createAddress`;
|
||||
getCustomsAgents();
|
||||
});
|
||||
|
||||
const getCustomsAgents = async () => {
|
||||
const { data } = await axios.get('CustomsAgents');
|
||||
customsAgents.value = data;
|
||||
};
|
||||
|
||||
const refreshData = () => {
|
||||
getCustomsAgents();
|
||||
};
|
||||
|
||||
const toCustomerAddress = () => {
|
||||
router.push({
|
||||
name: 'CustomerAddress',
|
||||
|
@ -54,9 +37,19 @@ function handleLocation(data, location) {
|
|||
data.provinceFk = provinceFk;
|
||||
data.countryFk = countryFk;
|
||||
}
|
||||
|
||||
function onAgentCreated({ id, fiscalName }, data) {
|
||||
customsAgents.value.push({ id, fiscalName });
|
||||
data.customsAgentFk = id;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
@on-fetch="(data) => (customsAgents = data)"
|
||||
auto-load
|
||||
url="CustomsAgents"
|
||||
/>
|
||||
<FetchData
|
||||
@on-fetch="(data) => (agencyModes = data)"
|
||||
auto-load
|
||||
|
@ -67,7 +60,7 @@ function handleLocation(data, location) {
|
|||
<FormModel
|
||||
:form-initial-data="formInitialData"
|
||||
:observe-form-changes="false"
|
||||
:url-create="urlCreate"
|
||||
:url-create="`Clients/${route.params.id}/createAddress`"
|
||||
@on-data-saved="toCustomerAddress()"
|
||||
model="client"
|
||||
>
|
||||
|
@ -139,6 +132,7 @@ function handleLocation(data, location) {
|
|||
/>
|
||||
|
||||
<VnSelectDialog
|
||||
url="CustomsAgents"
|
||||
:label="t('Customs agent')"
|
||||
:options="customsAgents"
|
||||
hide-selected
|
||||
|
@ -148,7 +142,11 @@ function handleLocation(data, location) {
|
|||
:tooltip="t('Create a new expense')"
|
||||
>
|
||||
<template #form>
|
||||
<CustomerNewCustomsAgent @on-data-saved="refreshData()" />
|
||||
<CustomerNewCustomsAgent
|
||||
@on-data-saved="
|
||||
(requestResponse) => onAgentCreated(requestResponse, data)
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
</VnSelectDialog>
|
||||
</VnRow>
|
||||
|
|
|
@ -144,7 +144,7 @@ function handleLocation(data, location) {
|
|||
:url="`Addresses/${route.params.addressId}`"
|
||||
@on-data-saved="onDataSaved()"
|
||||
auto-load
|
||||
model="client"
|
||||
model="customer"
|
||||
>
|
||||
<template #moreActions>
|
||||
<QBtn
|
||||
|
|
|
@ -82,11 +82,11 @@ const entriesTableColumns = computed(() => [
|
|||
</QCardSection>
|
||||
<QCardActions align="right">
|
||||
<QBtn
|
||||
:label="t('printLabels')"
|
||||
:label="t('myEntries.printLabels')"
|
||||
color="primary"
|
||||
icon="print"
|
||||
:loading="isLoading"
|
||||
@click="openReport(`Entries/${entityId}/print`)"
|
||||
@click="openReport(`Entries/${entityId}/labelSupplier`)"
|
||||
unelevated
|
||||
autofocus
|
||||
/>
|
||||
|
@ -126,7 +126,9 @@ const entriesTableColumns = computed(() => [
|
|||
"
|
||||
unelevated
|
||||
>
|
||||
<QTooltip>{{ t('viewLabel') }}</QTooltip>
|
||||
<QTooltip>{{
|
||||
t('myEntries.viewLabel')
|
||||
}}</QTooltip>
|
||||
</QBtn>
|
||||
</QTr>
|
||||
</template>
|
||||
|
|
|
@ -101,7 +101,7 @@ const columns = computed(() => [
|
|||
name: 'tableActions',
|
||||
actions: [
|
||||
{
|
||||
title: t('printLabels'),
|
||||
title: t('myEntries.printLabels'),
|
||||
icon: 'print',
|
||||
isPrimary: true,
|
||||
action: (row) => printBuys(row.id),
|
||||
|
|
|
@ -184,5 +184,4 @@ es:
|
|||
Amount: Importe
|
||||
Issued: Fecha factura
|
||||
Id or supplier: Id o proveedor
|
||||
More options: Más opciones
|
||||
</i18n>
|
||||
|
|
|
@ -83,8 +83,6 @@ const states = ref();
|
|||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QSeparator />
|
||||
<QExpansionItem :label="t('More options')" expand-separator>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnInputDate
|
||||
|
@ -105,14 +103,9 @@ const states = ref();
|
|||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnInputDate
|
||||
v-model="params.dued"
|
||||
:label="t('Dued')"
|
||||
is-outlined
|
||||
/>
|
||||
<VnInputDate v-model="params.dued" :label="t('Dued')" is-outlined />
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</QExpansionItem>
|
||||
</template>
|
||||
</VnFilterPanel>
|
||||
</template>
|
||||
|
@ -149,5 +142,4 @@ es:
|
|||
Issued: Fecha emisión
|
||||
Created: Fecha creación
|
||||
Dued: Fecha vencimiento
|
||||
More options: Más opciones
|
||||
</i18n>
|
||||
|
|
|
@ -60,8 +60,15 @@ const columns = computed(() => [
|
|||
label: t('globals.reference'),
|
||||
isTitle: true,
|
||||
component: 'select',
|
||||
attrs: { url: MODEL, optionLabel: 'ref', optionValue: 'id' },
|
||||
attrs: {
|
||||
url: MODEL,
|
||||
optionLabel: 'ref',
|
||||
optionValue: 'ref',
|
||||
},
|
||||
columnField: { component: null },
|
||||
columnFilter: {
|
||||
inWhere: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -146,9 +153,7 @@ function downloadPdf() {
|
|||
const [invoiceOut] = selectedCardsArray;
|
||||
openPdf(invoiceOut.id);
|
||||
} else {
|
||||
const invoiceOutIdsArray = selectedCardsArray.map(
|
||||
(invoiceOut) => invoiceOut.id
|
||||
);
|
||||
const invoiceOutIdsArray = selectedCardsArray.map((invoiceOut) => invoiceOut.id);
|
||||
const invoiceOutIds = invoiceOutIdsArray.join(',');
|
||||
|
||||
const params = {
|
||||
|
@ -157,7 +162,6 @@ function downloadPdf() {
|
|||
|
||||
openReport(`${MODEL}/downloadZip`, params);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
watchEffect(selectedRows);
|
||||
|
|
|
@ -66,6 +66,7 @@ const insertTag = (rows) => {
|
|||
<FetchData
|
||||
url="Tags"
|
||||
:filter="{ fields: ['id', 'name', 'isFree', 'sourceTable'] }"
|
||||
sort-by="name"
|
||||
@on-fetch="(data) => (tagOptions = data)"
|
||||
auto-load
|
||||
/>
|
||||
|
@ -137,6 +138,7 @@ const insertTag = (rows) => {
|
|||
:required="false"
|
||||
:rules="validate('itemTag.tagFk')"
|
||||
:use-like="false"
|
||||
sort-by="value"
|
||||
/>
|
||||
<VnInput
|
||||
v-else-if="
|
||||
|
|
|
@ -18,7 +18,7 @@ const groupedStates = ref();
|
|||
const handleScopeDays = (params, days, callback) => {
|
||||
const [from, to] = dateRange(Date.vnNew());
|
||||
if (!days) {
|
||||
Object.assign(params, { from, to, scopeDays: 1 });
|
||||
Object.assign(params, { from, to, scopeDays: 0 });
|
||||
} else {
|
||||
params.from = from;
|
||||
to.setDate(to.getDate() + days);
|
||||
|
@ -59,7 +59,7 @@ const getLocale = (label) => {
|
|||
</template>
|
||||
<template #customTags="{ params, searchFn, formatFn }">
|
||||
<VnFilterPanelChip
|
||||
v-if="params.scopeDays"
|
||||
v-if="params.scopeDays !== null"
|
||||
removable
|
||||
@remove="handleScopeDays(params, null, searchFn)"
|
||||
>
|
||||
|
|
|
@ -25,11 +25,8 @@ const provinceOpts = ref([]);
|
|||
const stateOpts = ref([]);
|
||||
const zoneOpts = ref([]);
|
||||
const { viewSummary } = useSummaryDialog();
|
||||
const from = Date.vnNew();
|
||||
from.setHours(0, 0, 0, 0);
|
||||
const to = new Date(from.getTime());
|
||||
to.setDate(to.getDate() + 1);
|
||||
to.setHours(23, 59, 59, 999);
|
||||
|
||||
const [from, to] = dateRange(Date.vnNew());
|
||||
const stateColors = {
|
||||
notice: 'info',
|
||||
success: 'positive',
|
||||
|
@ -340,7 +337,7 @@ const openTab = (id) =>
|
|||
auto-load
|
||||
:row-click="({ id }) => openTab(id)"
|
||||
:disable-option="{ card: true }"
|
||||
:user-params="{ from, to, scopeDays: 1 }"
|
||||
:user-params="{ from, to, scopeDays: 0 }"
|
||||
>
|
||||
<template #top-left>
|
||||
<QBtn
|
||||
|
|
|
@ -36,7 +36,6 @@ const getSelectedTagValues = async (tag) => {
|
|||
const filter = {
|
||||
fields: ['value'],
|
||||
order: 'value ASC',
|
||||
limit: 30,
|
||||
};
|
||||
|
||||
const url = `Tags/${tag?.id}/filterValue`;
|
||||
|
@ -50,7 +49,7 @@ const getSelectedTagValues = async (tag) => {
|
|||
|
||||
<template>
|
||||
<QForm @submit="applyTags()" class="all-pointer-events">
|
||||
<QCard class="q-pa-sm column q-pa-lg">
|
||||
<QCard class="q-pa-sm column q-pa-lg" data-cy="catalogFilterValueDialog">
|
||||
<VnSelect
|
||||
:label="t('params.tag')"
|
||||
v-model="selectedTag"
|
||||
|
@ -64,6 +63,7 @@ const getSelectedTagValues = async (tag) => {
|
|||
:emit-value="false"
|
||||
use-input
|
||||
@update:model-value="getSelectedTagValues"
|
||||
data-cy="catalogFilterValueDialogTagSelect"
|
||||
/>
|
||||
<div
|
||||
v-for="(value, index) in tagValues"
|
||||
|
@ -94,6 +94,7 @@ const getSelectedTagValues = async (tag) => {
|
|||
:disable="!value"
|
||||
is-outlined
|
||||
class="col"
|
||||
data-cy="catalogFilterValueDialogValueInput"
|
||||
/>
|
||||
<QBtn
|
||||
icon="delete"
|
||||
|
|
|
@ -98,7 +98,7 @@ watch(
|
|||
/>
|
||||
</QScrollArea>
|
||||
</QDrawer>
|
||||
<QPage class="column items-center q-pa-md">
|
||||
<QPage class="column items-center q-pa-md" data-cy="orderCatalogPage">
|
||||
<div class="full-width">
|
||||
<VnPaginate
|
||||
:data-key="dataKey"
|
||||
|
@ -118,6 +118,7 @@ watch(
|
|||
:item="row"
|
||||
is-catalog
|
||||
class="fill-icon"
|
||||
data-cy="orderCatalogItem"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -178,6 +178,7 @@ function addOrder(value, field, params) {
|
|||
? resetCategory(params, searchFn)
|
||||
: removeTagGroupParam(params, searchFn, valIndex)
|
||||
"
|
||||
data-cy="catalogFilterCustomTag"
|
||||
>
|
||||
<strong v-if="customTag.label === 'categoryFk' && categoryList">
|
||||
{{
|
||||
|
@ -211,6 +212,7 @@ function addOrder(value, field, params) {
|
|||
:name="category.icon"
|
||||
class="category-icon"
|
||||
@click="selectCategory(params, category, searchFn)"
|
||||
data-cy="catalogFilterCategory"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t(category.name) }}
|
||||
|
@ -234,6 +236,7 @@ function addOrder(value, field, params) {
|
|||
sort-by="name ASC"
|
||||
:disable="!params.categoryFk"
|
||||
@update:model-value="searchFn()"
|
||||
data-cy="catalogFilterType"
|
||||
>
|
||||
<template #option="{ itemProps, opt }">
|
||||
<QItem v-bind="itemProps">
|
||||
|
@ -285,6 +288,7 @@ function addOrder(value, field, params) {
|
|||
:is-clearable="false"
|
||||
v-model="searchByTag"
|
||||
@keyup.enter="(val) => onSearchByTag(val, params)"
|
||||
data-cy="catalogFilterValueInput"
|
||||
>
|
||||
<template #prepend>
|
||||
<QIcon name="search" />
|
||||
|
@ -297,6 +301,7 @@ function addOrder(value, field, params) {
|
|||
color="primary"
|
||||
size="md"
|
||||
dense
|
||||
data-cy="catalogFilterValueDialogBtn"
|
||||
/>
|
||||
<QPopupProxy>
|
||||
<CatalogFilterValueDialog
|
||||
|
|
|
@ -15,6 +15,7 @@ import CustomerDescriptorProxy from '../Customer/Card/CustomerDescriptorProxy.vu
|
|||
import WorkerDescriptorProxy from '../Worker/Card/WorkerDescriptorProxy.vue';
|
||||
import { toDateTimeFormat } from 'src/filters/date';
|
||||
import { useRoute } from 'vue-router';
|
||||
import dataByOrder from 'src/utils/dataByOrder';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { viewSummary } = useSummaryDialog();
|
||||
|
@ -143,10 +144,16 @@ const columns = computed(() => [
|
|||
]);
|
||||
|
||||
async function fetchClientAddress(id, formData = {}) {
|
||||
const { data } = await axios.get(
|
||||
`Clients/${id}/addresses?filter[order]=isActive DESC`
|
||||
);
|
||||
const { data } = await axios.get(`Clients/${id}`, {
|
||||
params: {
|
||||
filter: {
|
||||
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
|
||||
include: { relation: 'addresses' },
|
||||
},
|
||||
},
|
||||
});
|
||||
addressOptions.value = data;
|
||||
addressesList.value = data.addresses;
|
||||
formData.addressId = data.defaultAddressFk;
|
||||
fetchAgencies(formData);
|
||||
}
|
||||
|
@ -157,7 +164,7 @@ async function fetchAgencies({ landed, addressId }) {
|
|||
const { data } = await axios.get('Agencies/landsThatDay', {
|
||||
params: { addressFk: addressId, landed },
|
||||
});
|
||||
agencyList.value = data;
|
||||
agencyList.value = dataByOrder(data, 'agencyMode ASC');
|
||||
}
|
||||
|
||||
const getDateColor = (date) => {
|
||||
|
@ -254,22 +261,27 @@ onMounted(() => {
|
|||
@update:model-value="() => fetchAgencies(data)"
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel
|
||||
:class="{
|
||||
'color-vn-label': !scope.opt?.isActive,
|
||||
}"
|
||||
<QItem
|
||||
v-bind="scope.itemProps"
|
||||
:class="{ disabled: !scope.opt.isActive }"
|
||||
>
|
||||
{{
|
||||
`${
|
||||
!scope.opt?.isActive
|
||||
? t('basicData.inactive')
|
||||
: ''
|
||||
} `
|
||||
}}
|
||||
{{ scope.opt?.nickname }}: {{ scope.opt?.street }},
|
||||
{{ scope.opt?.city }}
|
||||
<QItemSection style="min-width: min-content" avatar>
|
||||
<QIcon
|
||||
v-if="
|
||||
scope.opt.isActive && data.addressId === scope.opt.id
|
||||
"
|
||||
size="sm"
|
||||
color="grey"
|
||||
name="star"
|
||||
class="fill-icon"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QItemSection>
|
||||
<QItemLabel>
|
||||
{{ scope.opt.nickname }}
|
||||
</QItemLabel>
|
||||
<QItemLabel caption>
|
||||
{{ `${scope.opt.street}, ${scope.opt.city}` }}
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
|
|
|
@ -24,13 +24,14 @@ const supplier = ref(null);
|
|||
const supplierAccountRef = ref(null);
|
||||
const wireTransferFk = ref(null);
|
||||
const bankEntitiesOptions = ref([]);
|
||||
const filteredBankEntitiesOptions = ref([]);
|
||||
|
||||
const onBankEntityCreated = async (dataSaved, rowData) => {
|
||||
await bankEntitiesRef.value.fetch();
|
||||
rowData.bankEntityFk = dataSaved.id;
|
||||
};
|
||||
|
||||
const onChangesSaved = () => {
|
||||
const onChangesSaved = async () => {
|
||||
if (supplier.value.payMethodFk !== wireTransferFk.value)
|
||||
quasar
|
||||
.dialog({
|
||||
|
@ -55,12 +56,35 @@ const setWireTransfer = async () => {
|
|||
await axios.patch(`Suppliers/${route.params.id}`, params);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
};
|
||||
|
||||
function findBankFk(value, row) {
|
||||
row.bankEntityFk = null;
|
||||
if (!value) return;
|
||||
|
||||
const bankEntityFk = bankEntitiesOptions.value.find((b) => b.id == value.slice(4, 8));
|
||||
if (bankEntityFk) row.bankEntityFk = bankEntityFk.id;
|
||||
}
|
||||
|
||||
function bankEntityFilter(val, update) {
|
||||
update(() => {
|
||||
const needle = val.toLowerCase();
|
||||
filteredBankEntitiesOptions.value = bankEntitiesOptions.value.filter(
|
||||
(bank) =>
|
||||
bank.bic.toLowerCase().startsWith(needle) ||
|
||||
bank.name.toLowerCase().includes(needle)
|
||||
);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
ref="bankEntitiesRef"
|
||||
url="BankEntities"
|
||||
@on-fetch="(data) => (bankEntitiesOptions = data)"
|
||||
@on-fetch="
|
||||
(data) => {
|
||||
(bankEntitiesOptions = data), (filteredBankEntitiesOptions = data);
|
||||
}
|
||||
"
|
||||
auto-load
|
||||
/>
|
||||
<FetchData
|
||||
|
@ -98,6 +122,7 @@ const setWireTransfer = async () => {
|
|||
<VnInput
|
||||
:label="t('supplier.accounts.iban')"
|
||||
v-model="row.iban"
|
||||
@update:model-value="(value) => findBankFk(value, row)"
|
||||
:required="true"
|
||||
>
|
||||
<template #append>
|
||||
|
@ -109,7 +134,9 @@ const setWireTransfer = async () => {
|
|||
<VnSelectDialog
|
||||
:label="t('worker.create.bankEntity')"
|
||||
v-model="row.bankEntityFk"
|
||||
:options="bankEntitiesOptions"
|
||||
:options="filteredBankEntitiesOptions"
|
||||
:default-filter="false"
|
||||
@filter="(val, update) => bankEntityFilter(val, update)"
|
||||
option-label="bic"
|
||||
option-value="id"
|
||||
hide-selected
|
||||
|
|
|
@ -9,6 +9,7 @@ import VnRow from 'components/ui/VnRow.vue';
|
|||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnLocation from 'src/components/common/VnLocation.vue';
|
||||
import VnAccountNumber from 'src/components/common/VnAccountNumber.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
|
@ -100,10 +101,13 @@ function handleLocation(data, location) {
|
|||
/>
|
||||
</VnRow>
|
||||
<VnRow>
|
||||
<VnInput
|
||||
<VnAccountNumber
|
||||
v-model="data.account"
|
||||
:label="t('supplier.fiscalData.account')"
|
||||
clearable
|
||||
data-cy="supplierFiscalDataAccount"
|
||||
insertable
|
||||
:maxlength="10"
|
||||
/>
|
||||
<VnSelect
|
||||
:label="t('supplier.fiscalData.sageTaxTypeFk')"
|
||||
|
|
|
@ -124,8 +124,7 @@ const columns = computed(() => [
|
|||
</template>
|
||||
|
||||
<i18n>
|
||||
en:
|
||||
Search suppliers: Search suppliers
|
||||
es:
|
||||
Search suppliers: Buscar proveedores
|
||||
Create Supplier: Crear proveedor
|
||||
</i18n>
|
||||
|
|
|
@ -321,10 +321,6 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
|||
<div class="column">
|
||||
<span v-for="(saleComponent, index) in row.components" :key="index">
|
||||
{{ toCurrency(saleComponent.value * row.quantity, 'EUR', 3) }}
|
||||
<!-- <QTooltip>
|
||||
{{ saleComponent.component?.name }}:
|
||||
{{ toCurrency(saleComponent.value, 'EUR', 3) }}
|
||||
</QTooltip> -->
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -676,7 +676,7 @@ async function uploadDocuware(force) {
|
|||
<VnConfirm
|
||||
ref="weightDialog"
|
||||
:title="t('Set weight')"
|
||||
:message="t('This ticket may be invoiced, do you want to continue?')"
|
||||
:message="false"
|
||||
:promise="actions.setWeight"
|
||||
>
|
||||
<template #customHTML>
|
||||
|
@ -741,7 +741,6 @@ es:
|
|||
Ticket invoiced: Ticket facturado
|
||||
Set weight: Establecer peso
|
||||
Weight set: Peso establecido
|
||||
This ticket may be invoiced, do you want to continue?: Es posible que se facture este ticket, desea continuar?
|
||||
invoiceIds: "Se han generado las facturas con los siguientes ids: {invoiceIds}"
|
||||
This ticket will be removed from current route! Continue anyway?: ¡Se eliminará el ticket de la ruta actual! ¿Continuar de todas formas?
|
||||
You are going to delete this ticket: Vas a eliminar este ticket
|
||||
|
|
|
@ -181,20 +181,44 @@ const resetChanges = async () => {
|
|||
arrayData.fetch({ append: false });
|
||||
tableRef.value.reload();
|
||||
};
|
||||
const rowToUpdate = ref(null);
|
||||
const changeQuantity = async (sale) => {
|
||||
canProceed.value = await isSalePrepared(sale);
|
||||
if (!canProceed.value) return;
|
||||
if (
|
||||
!sale.itemFk ||
|
||||
sale.quantity == null ||
|
||||
edit.value?.oldQuantity === sale.quantity
|
||||
)
|
||||
return;
|
||||
if (!sale.id) return addSale(sale);
|
||||
|
||||
const updateQuantity = async (sale) => {
|
||||
const payload = { quantity: sale.quantity };
|
||||
await axios.post(`Sales/${sale.id}/updateQuantity`, payload);
|
||||
try {
|
||||
if (!rowToUpdate.value) return;
|
||||
rowToUpdate.value = null;
|
||||
await updateQuantity(sale);
|
||||
} catch (e) {
|
||||
const { quantity } = tableRef.value.CrudModelRef.originalData.find(
|
||||
(s) => s.id === sale.id
|
||||
);
|
||||
sale.quantity = quantity;
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
const updateQuantity = async ({ quantity, id }) => {
|
||||
const params = { quantity: quantity };
|
||||
await axios.post(`Sales/${id}/updateQuantity`, params);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
};
|
||||
|
||||
const addSale = async (sale) => {
|
||||
const payload = {
|
||||
const params = {
|
||||
barcode: sale.itemFk,
|
||||
quantity: sale.quantity,
|
||||
};
|
||||
|
||||
const { data } = await axios.post(`tickets/${route.params.id}/addSale`, payload);
|
||||
const { data } = await axios.post(`tickets/${route.params.id}/addSale`, params);
|
||||
|
||||
if (!data) return;
|
||||
|
||||
|
@ -212,19 +236,6 @@ const addSale = async (sale) => {
|
|||
window.location.reload();
|
||||
};
|
||||
|
||||
const changeQuantity = async (sale) => {
|
||||
canProceed.value = await isSalePrepared(sale);
|
||||
if (!canProceed.value) return;
|
||||
if (
|
||||
!sale.itemFk ||
|
||||
sale.quantity == null ||
|
||||
edit.value?.oldQuantity === sale.quantity
|
||||
)
|
||||
return;
|
||||
if (!sale.id) return addSale(sale);
|
||||
updateQuantity(sale);
|
||||
};
|
||||
|
||||
const updateConcept = async (sale) => {
|
||||
canProceed.value = await isSalePrepared(sale);
|
||||
if (!canProceed.value) return;
|
||||
|
@ -771,16 +782,12 @@ watch(
|
|||
</template>
|
||||
<template #column-quantity="{ row }">
|
||||
<VnInput
|
||||
v-if="row.isNew"
|
||||
v-model.number="row.quantity"
|
||||
v-if="row.isNew || isTicketEditable"
|
||||
type="number"
|
||||
@blur="changeQuantity(row)"
|
||||
@focus="edit.oldQuantity = row.quantity"
|
||||
/>
|
||||
<VnInput
|
||||
v-else-if="isTicketEditable"
|
||||
v-model.number="row.quantity"
|
||||
@blur="changeQuantity(row)"
|
||||
@keyup.enter="changeQuantity(row)"
|
||||
@update:model-value="() => (rowToUpdate = row)"
|
||||
@focus="edit.oldQuantity = row.quantity"
|
||||
/>
|
||||
<span v-else>{{ row.quantity }}</span>
|
||||
|
|
|
@ -471,7 +471,7 @@ const qCheckBoxController = (sale, action) => {
|
|||
url="Shelvings"
|
||||
hide-selected
|
||||
option-label="code"
|
||||
option-value="code"
|
||||
option-value="id"
|
||||
v-model="row.shelvingFk"
|
||||
@update:model-value="updateShelving(row)"
|
||||
style="max-width: 120px"
|
||||
|
|
|
@ -258,7 +258,7 @@ function toTicketUrl(section) {
|
|||
<QCard class="vn-one" v-if="entity.notes.length">
|
||||
<VnTitle
|
||||
:url="toTicketUrl('observation')"
|
||||
:text="t('ticket.pageTitles.notes')"
|
||||
:text="t('globals.pageTitles.notes')"
|
||||
/>
|
||||
<QVirtualScroll
|
||||
:items="entity.notes"
|
||||
|
|
|
@ -212,8 +212,6 @@ const getGroupedStates = (data) => {
|
|||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QSeparator />
|
||||
<QExpansionItem :label="t('More options')" expand-separator>
|
||||
<QItem>
|
||||
<QItemSection v-if="!provinces">
|
||||
<QSkeleton type="QInput" class="full-width" />
|
||||
|
@ -286,7 +284,6 @@ const getGroupedStates = (data) => {
|
|||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</QExpansionItem>
|
||||
</template>
|
||||
</VnFilterPanel>
|
||||
</template>
|
||||
|
@ -340,7 +337,6 @@ es:
|
|||
With problems: Con problemas
|
||||
Invoiced: Facturado
|
||||
Routed: Enrutado
|
||||
More options: Más opciones
|
||||
Province: Provincia
|
||||
Agency: Agencia
|
||||
Warehouse: Almacén
|
||||
|
|
|
@ -274,7 +274,7 @@ const fetchAddresses = async (formData) => {
|
|||
|
||||
const filter = {
|
||||
fields: ['nickname', 'street', 'city', 'id', 'isActive'],
|
||||
order: 'nickname ASC',
|
||||
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
|
||||
};
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
|
||||
|
@ -590,7 +590,22 @@ function setReference(data) {
|
|||
@update:model-value="() => fetchAvailableAgencies(data)"
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItem
|
||||
v-bind="scope.itemProps"
|
||||
:class="{ disabled: !scope.opt.isActive }"
|
||||
>
|
||||
<QItemSection style="min-width: min-content" avatar>
|
||||
<QIcon
|
||||
v-if="
|
||||
scope.opt.isActive &&
|
||||
selectedClient?.defaultAddressFk === scope.opt.id
|
||||
"
|
||||
size="sm"
|
||||
color="grey"
|
||||
name="star"
|
||||
class="fill-icon"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QItemSection>
|
||||
<QItemLabel
|
||||
:class="{
|
||||
|
|
|
@ -14,6 +14,8 @@ const route = useRoute();
|
|||
const { t } = useI18n();
|
||||
|
||||
const agenciesOptions = ref([]);
|
||||
const warehousesOptionsOut = ref([]);
|
||||
const warehousesOptionsIn = ref([]);
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
|
@ -21,6 +23,18 @@ const agenciesOptions = ref([]);
|
|||
@on-fetch="(data) => (agenciesOptions = data)"
|
||||
auto-load
|
||||
/>
|
||||
<FetchData
|
||||
url="Warehouses"
|
||||
@on-fetch="(data) => (warehousesOptionsOut = data)"
|
||||
auto-load
|
||||
:filter="{ where: { isOrigin: TRUE } }"
|
||||
/>
|
||||
<FetchData
|
||||
url="Warehouses"
|
||||
@on-fetch="(data) => (warehousesOptionsIn = data)"
|
||||
auto-load
|
||||
:filter="{ where: { isDestiny: TRUE } }"
|
||||
/>
|
||||
<FormModel :url-update="`Travels/${route.params.id}`" model="Travel" auto-load>
|
||||
<template #form="{ data }">
|
||||
<VnRow>
|
||||
|
@ -39,11 +53,12 @@ const agenciesOptions = ref([]);
|
|||
<VnInputDate v-model="data.shipped" :label="t('globals.shipped')" />
|
||||
<VnInputDate v-model="data.landed" :label="t('globals.landed')" />
|
||||
</VnRow>
|
||||
|
||||
<VnRow>
|
||||
<VnSelect
|
||||
:label="t('globals.warehouseOut')"
|
||||
v-model="data.warehouseOutFk"
|
||||
:options="agenciesOptions"
|
||||
:options="warehousesOptionsOut"
|
||||
option-value="id"
|
||||
option-label="name"
|
||||
map-options
|
||||
|
@ -52,7 +67,7 @@ const agenciesOptions = ref([]);
|
|||
<VnSelect
|
||||
:label="t('globals.warehouseIn')"
|
||||
v-model="data.warehouseInFk"
|
||||
:options="agenciesOptions"
|
||||
:options="warehousesOptionsIn"
|
||||
option-value="id"
|
||||
option-label="name"
|
||||
map-options
|
||||
|
@ -89,7 +104,7 @@ const agenciesOptions = ref([]);
|
|||
|
||||
<i18n>
|
||||
es:
|
||||
raidDays: Si se marca "Redada", la fecha de entrega se moverá automáticamente los días indicados (incluido 0). Si se deja vacio, la fecha no cambiará
|
||||
raidDays: El travel se desplaza automáticamente cada día para estar desde hoy al número de días indicado. Si se deja vacio no se moverá
|
||||
en:
|
||||
raidDays: If "Raid" is checked, the landing date will automatically shift by the specified number of days (including 0). If left empty, the date will stay the same.
|
||||
raidDays: The travel adjusts itself daily to match the number of days set, starting from today. If left blank, it won’t move
|
||||
</i18n>
|
||||
|
|
|
@ -7,13 +7,13 @@ import filter from './TravelFilter.js';
|
|||
<VnCard
|
||||
data-key="Travel"
|
||||
base-url="Travels"
|
||||
search-data-key="TravelList"
|
||||
:filter="filter"
|
||||
:descriptor="TravelDescriptor"
|
||||
:filter="filter"
|
||||
search-data-key="TravelList"
|
||||
:searchbar-props="{
|
||||
url: 'Travels',
|
||||
url: 'Travels/filter',
|
||||
searchUrl: 'table',
|
||||
label: 'Search travel',
|
||||
info: 'You can search by travel id or name',
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -44,8 +44,8 @@ const setData = (entity) => (data.value = useCardDescription(entity.ref, entity.
|
|||
<TravelDescriptorMenuItems :travel="entity" />
|
||||
</template>
|
||||
<template #body="{ entity }">
|
||||
<VnLv :label="t('globals.warehouseIn')" :value="entity.warehouseIn.name" />
|
||||
<VnLv :label="t('globals.warehouseOut')" :value="entity.warehouseOut.name" />
|
||||
<VnLv :label="t('globals.warehouseIn')" :value="entity.warehouseIn?.name" />
|
||||
<VnLv :label="t('globals.warehouseOut')" :value="entity.warehouseOut?.name" />
|
||||
<VnLv :label="t('globals.shipped')" :value="toDate(entity.shipped)" />
|
||||
<VnLv :label="t('globals.landed')" :value="toDate(entity.landed)" />
|
||||
<VnLv :label="t('globals.totalEntries')" :value="entity.totalEntries" />
|
||||
|
|
|
@ -208,6 +208,7 @@ const columns = computed(() => [
|
|||
ref="tableRef"
|
||||
data-key="TravelList"
|
||||
url="Travels/filter"
|
||||
redirect="travel"
|
||||
:create="{
|
||||
urlCreate: 'Travels',
|
||||
title: t('Create Travels'),
|
||||
|
@ -221,9 +222,7 @@ const columns = computed(() => [
|
|||
order="landed DESC"
|
||||
:columns="columns"
|
||||
auto-load
|
||||
redirect="travel"
|
||||
:is-editable="false"
|
||||
:use-model="true"
|
||||
>
|
||||
<template #column-status="{ row }">
|
||||
<div class="row">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { ref, computed, onMounted, reactive } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
|
@ -43,7 +43,7 @@ const { t } = useI18n();
|
|||
const { openConfirmationModal } = useVnConfirm();
|
||||
|
||||
const isNew = computed(() => props.isNewMode);
|
||||
const dated = ref(props.date);
|
||||
const dated = reactive(props.date);
|
||||
const tickedNodes = ref();
|
||||
|
||||
const _excludeType = ref('all');
|
||||
|
@ -67,12 +67,12 @@ const exclusionGeoCreate = async () => {
|
|||
};
|
||||
|
||||
const exclusionCreate = async () => {
|
||||
if (isNew.value)
|
||||
await axios.post(`Zones/${route.params.id}/exclusions`, [{ dated: dated.value }]);
|
||||
else
|
||||
await axios.post(`Zones/${route.params.id}/exclusions`, {
|
||||
dated: dated.value,
|
||||
});
|
||||
const url = `Zones/${route.params.id}/exclusions`;
|
||||
const body = {
|
||||
dated,
|
||||
};
|
||||
if (isNew.value || props.event?.type) await axios.post(`${url}`, [body]);
|
||||
else await axios.put(`${url}/${props.event?.id}`, body);
|
||||
await refetchEvents();
|
||||
};
|
||||
|
||||
|
@ -83,7 +83,8 @@ const onSubmit = async () => {
|
|||
|
||||
const deleteEvent = async () => {
|
||||
if (!props.event) return;
|
||||
await axios.delete(`Zones/${route.params.id}/exclusions`);
|
||||
const exclusionId = props.event?.zoneExclusionFk || props.event?.id;
|
||||
await axios.delete(`Zones/${route.params.id}/exclusions/${exclusionId}`);
|
||||
await refetchEvents();
|
||||
};
|
||||
|
||||
|
@ -118,11 +119,7 @@ onMounted(() => {
|
|||
>
|
||||
<template #form-inputs>
|
||||
<VnRow class="row q-gutter-md q-mb-lg">
|
||||
<VnInputDate
|
||||
:label="t('eventsInclusionForm.day')"
|
||||
v-model="dated"
|
||||
:required="true"
|
||||
/>
|
||||
<VnInputDate :label="t('eventsInclusionForm.day')" v-model="dated" />
|
||||
</VnRow>
|
||||
<div class="column q-gutter-y-sm q-mb-md">
|
||||
<QRadio
|
||||
|
@ -172,8 +169,8 @@ onMounted(() => {
|
|||
class="q-mr-sm"
|
||||
@click="
|
||||
openConfirmationModal(
|
||||
t('zone.deleteTitle'),
|
||||
t('zone.deleteSubtitle'),
|
||||
t('eventsPanel.deleteTitle'),
|
||||
t('eventsPanel.deleteSubtitle'),
|
||||
() => deleteEvent()
|
||||
)
|
||||
"
|
||||
|
|
|
@ -24,13 +24,14 @@ const zoneEventsFormProps = reactive({
|
|||
date: null,
|
||||
});
|
||||
|
||||
const openForm = (data) => {
|
||||
const openForm = (data, isBtnAdd) => {
|
||||
const { date = null, isNewMode, event, eventType, geoIds = [] } = data;
|
||||
zoneEventsFormProps.date = date;
|
||||
zoneEventsFormProps.isNewMode = isNewMode;
|
||||
zoneEventsFormProps.event = event;
|
||||
zoneEventsFormProps.eventType = eventType;
|
||||
if (geoIds.length) zoneEventsFormProps.geoIds = geoIds;
|
||||
if (isBtnAdd) formModeName.value = 'include';
|
||||
|
||||
showZoneEventForm.value = true;
|
||||
};
|
||||
|
@ -51,7 +52,6 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
|||
:last-day="lastDay"
|
||||
:events="events"
|
||||
v-model:formModeName="formModeName"
|
||||
@open-zone-form="openForm"
|
||||
/>
|
||||
</QScrollArea>
|
||||
</QDrawer>
|
||||
|
@ -65,7 +65,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
|||
/>
|
||||
<QDialog v-model="showZoneEventForm" @hide="onZoneEventFormClose()">
|
||||
<ZoneEventInclusionForm
|
||||
v-if="formModeName === 'include'"
|
||||
v-if="!formModeName || formModeName === 'include'"
|
||||
v-bind="zoneEventsFormProps"
|
||||
@close-form="onZoneEventFormClose()"
|
||||
/>
|
||||
|
@ -78,9 +78,12 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
|||
<QPageSticky :offset="[20, 20]">
|
||||
<QBtn
|
||||
@click="
|
||||
openForm({
|
||||
openForm(
|
||||
{
|
||||
isNewMode: true,
|
||||
})
|
||||
},
|
||||
true
|
||||
)
|
||||
"
|
||||
color="primary"
|
||||
fab
|
||||
|
|
|
@ -11,6 +11,10 @@ import { dashIfEmpty } from 'src/filters';
|
|||
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
|
||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||
|
||||
const formModeName = defineModel('formModeName', {
|
||||
type: String,
|
||||
required: true,
|
||||
});
|
||||
const props = defineProps({
|
||||
firstDay: {
|
||||
type: Date,
|
||||
|
@ -27,25 +31,13 @@ const props = defineProps({
|
|||
required: true,
|
||||
default: () => [],
|
||||
},
|
||||
formModeName: {
|
||||
type: String,
|
||||
required: true,
|
||||
default: 'include',
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['openZoneForm', 'update:formModeName']);
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const weekdayStore = useWeekdayStore();
|
||||
const { openConfirmationModal } = useVnConfirm();
|
||||
|
||||
const formName = computed({
|
||||
get: () => props.formModeName,
|
||||
set: (value) => emit('update:formModeName', value),
|
||||
});
|
||||
|
||||
const params = computed(() => ({
|
||||
zoneFk: route.params.id,
|
||||
started: props.firstDay,
|
||||
|
@ -88,16 +80,6 @@ const deleteEvent = async (id) => {
|
|||
await fetchData();
|
||||
};
|
||||
|
||||
const openInclusionForm = (event) => {
|
||||
formName.value = 'include';
|
||||
emit('openZoneForm', {
|
||||
date: event.dated,
|
||||
event,
|
||||
isNewMode: false,
|
||||
eventType: 'event',
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
weekdayStore.initStore();
|
||||
});
|
||||
|
@ -110,13 +92,13 @@ onMounted(async () => {
|
|||
t('eventsPanel.editMode')
|
||||
}}</span>
|
||||
<QRadio
|
||||
v-model="formName"
|
||||
v-model="formModeName"
|
||||
dense
|
||||
val="include"
|
||||
:label="t('eventsPanel.include')"
|
||||
/>
|
||||
<QRadio
|
||||
v-model="formName"
|
||||
v-model="formModeName"
|
||||
dense
|
||||
val="exclude"
|
||||
:label="t('eventsPanel.exclude')"
|
||||
|
|
|
@ -61,6 +61,8 @@ eventsPanel:
|
|||
events: Events
|
||||
everyday: Everyday
|
||||
delete: Delete
|
||||
deleteTitle: This item will be deleted
|
||||
deleteSubtitle: Are you sure you want to continue?
|
||||
eventsExclusionForm:
|
||||
addExclusion: Add exclusion
|
||||
editExclusion: Edit exclusion
|
||||
|
@ -76,6 +78,7 @@ eventsInclusionForm:
|
|||
rangeOfDates: Range of dates
|
||||
from: From
|
||||
to: To
|
||||
day: Day
|
||||
upcomingDeliveries:
|
||||
province: Province
|
||||
closing: Closing
|
||||
|
|
|
@ -61,6 +61,8 @@ eventsPanel:
|
|||
events: Eventos
|
||||
everyday: Todos los días
|
||||
delete: Eliminar
|
||||
deleteTitle: Eliminar evento
|
||||
deleteSubtitle: ¿Seguro que quieres eliminar este evento?
|
||||
eventsExclusionForm:
|
||||
addExclusion: Añadir exclusión
|
||||
editExclusion: Editar exclusión
|
||||
|
@ -76,5 +78,6 @@ eventsInclusionForm:
|
|||
rangeOfDates: Rango de fechas
|
||||
from: Desde
|
||||
to: Hasta
|
||||
day: Día
|
||||
upcomingDeliveries:
|
||||
province: Provincia
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
function orderData(data, order) {
|
||||
if (typeof order === 'function') return data.sort(data);
|
||||
if (typeof order === 'string') order = [order];
|
||||
if (!Array.isArray(data)) return [];
|
||||
if (Array.isArray(order)) {
|
||||
let orderComp = [];
|
||||
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
/// <reference types="cypress" />
|
||||
describe('OrderCatalog', () => {
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.viewport(1920, 720);
|
||||
cy.visit('/#/order/8/catalog');
|
||||
});
|
||||
|
||||
const checkCustomFilterTag = (filterName = 'Plant') => {
|
||||
cy.dataCy('catalogFilterCustomTag').should('exist');
|
||||
cy.dataCy('catalogFilterCustomTag').contains(filterName);
|
||||
};
|
||||
|
||||
const checkFilterTag = (filterName = 'Plant') => {
|
||||
cy.dataCy('vnFilterPanelChip').should('exist');
|
||||
cy.dataCy('vnFilterPanelChip').contains(filterName);
|
||||
};
|
||||
|
||||
const selectCategory = (categoryIndex = 1, categoryName = 'Plant') => {
|
||||
cy.get(
|
||||
`div.q-page-container div:nth-of-type(${categoryIndex}) > [data-cy='catalogFilterCategory']`
|
||||
).should('exist');
|
||||
cy.get(
|
||||
`div.q-page-container div:nth-of-type(${categoryIndex}) > [data-cy='catalogFilterCategory']`
|
||||
).click();
|
||||
checkCustomFilterTag(categoryName);
|
||||
};
|
||||
|
||||
const searchByCustomTagInput = (option) => {
|
||||
cy.dataCy('catalogFilterValueInput').find('input').last().focus();
|
||||
cy.dataCy('catalogFilterValueInput').find('input').last().type(option);
|
||||
cy.dataCy('catalogFilterValueInput').find('input').last().type('{enter}');
|
||||
checkCustomFilterTag(option);
|
||||
};
|
||||
|
||||
const selectTypeFilter = (option) => {
|
||||
cy.selectOption(
|
||||
'div.q-page-container div.list > div:nth-of-type(2) div:nth-of-type(3)',
|
||||
option
|
||||
);
|
||||
checkFilterTag(option);
|
||||
};
|
||||
|
||||
it('Shows empty state', () => {
|
||||
cy.dataCy('orderCatalogPage').should('exist');
|
||||
cy.dataCy('orderCatalogPage').contains('No data to display');
|
||||
});
|
||||
|
||||
it('filter by category', () => {
|
||||
selectCategory();
|
||||
cy.dataCy('orderCatalogItem').should('exist');
|
||||
});
|
||||
|
||||
it('filters by type', () => {
|
||||
selectCategory();
|
||||
selectTypeFilter('Anthurium');
|
||||
});
|
||||
|
||||
it('filters by custom value select', () => {
|
||||
selectCategory();
|
||||
searchByCustomTagInput('Silver');
|
||||
});
|
||||
|
||||
it('filters by custom value dialog', () => {
|
||||
Cypress.on('uncaught:exception', (err) => {
|
||||
if (err.message.includes('canceled')) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
selectCategory();
|
||||
cy.dataCy('catalogFilterValueDialogBtn').should('exist');
|
||||
cy.dataCy('catalogFilterValueDialogBtn').last().click();
|
||||
cy.dataCy('catalogFilterValueDialogTagSelect').should('exist');
|
||||
cy.selectOption("[data-cy='catalogFilterValueDialogTagSelect']", 'Tallos');
|
||||
cy.dataCy('catalogFilterValueDialogValueInput').find('input').focus();
|
||||
cy.dataCy('catalogFilterValueDialogValueInput').find('input').type('2');
|
||||
cy.dataCy('catalogFilterValueDialogValueInput').find('input').type('{enter}');
|
||||
checkCustomFilterTag('2');
|
||||
});
|
||||
|
||||
it('removes a secondary tag', () => {
|
||||
selectCategory();
|
||||
selectTypeFilter('Anthurium');
|
||||
cy.dataCy('vnFilterPanelChip').should('exist');
|
||||
cy.get(
|
||||
"div.q-page-container [data-cy='vnFilterPanelChip'] > i.q-chip__icon--remove"
|
||||
)
|
||||
.contains('cancel')
|
||||
.should('exist');
|
||||
cy.get(
|
||||
"div.q-page-container [data-cy='vnFilterPanelChip'] > i.q-chip__icon--remove"
|
||||
)
|
||||
.contains('cancel')
|
||||
.click();
|
||||
cy.dataCy('vnFilterPanelChip').should('not.exist');
|
||||
});
|
||||
|
||||
it('Removes category tag', () => {
|
||||
selectCategory();
|
||||
cy.get(
|
||||
"div.q-page-container [data-cy='catalogFilterCustomTag'] > i.q-chip__icon--remove"
|
||||
)
|
||||
.contains('cancel')
|
||||
.should('exist');
|
||||
cy.get(
|
||||
"div.q-page-container [data-cy='catalogFilterCustomTag'] > i.q-chip__icon--remove"
|
||||
)
|
||||
.contains('cancel')
|
||||
.click();
|
||||
cy.dataCy('catalogFilterCustomTag').should('not.exist');
|
||||
});
|
||||
});
|
|
@ -3,11 +3,17 @@ describe('Client basic data', () => {
|
|||
beforeEach(() => {
|
||||
cy.viewport(1280, 720);
|
||||
cy.login('developer');
|
||||
cy.visit('#/customer/1110/basic-data', {
|
||||
timeout: 5000,
|
||||
});
|
||||
cy.visit('#/customer/1102/basic-data');
|
||||
});
|
||||
it('Should load layout', () => {
|
||||
cy.get('.q-card').should('be.visible');
|
||||
cy.dataCy('customerPhone').filter('input').should('be.visible');
|
||||
cy.dataCy('customerPhone').filter('input').type('123456789');
|
||||
cy.get('.q-btn-group > .q-btn--standard').click();
|
||||
cy.intercept('PATCH', '/api/Clients/1102', (req) => {
|
||||
const { body } = req;
|
||||
cy.wrap(body).should('have.property', 'phone', '123456789');
|
||||
});
|
||||
cy.get('.q-notification__message').should('have.text', 'Data saved');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -8,6 +8,6 @@ describe('Client billing data', () => {
|
|||
});
|
||||
});
|
||||
it('Should load layout', () => {
|
||||
cy.get('.q-card').should('be.visible');
|
||||
cy.get('.q-page').should('be.visible');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,11 +3,16 @@ describe('Client fiscal data', () => {
|
|||
beforeEach(() => {
|
||||
cy.viewport(1280, 720);
|
||||
cy.login('developer');
|
||||
cy.visit('#/customer/1110/fiscal-data', {
|
||||
cy.visit('#/customer/1107/fiscal-data', {
|
||||
timeout: 5000,
|
||||
});
|
||||
});
|
||||
it('Should load layout', () => {
|
||||
it('Should change required value when change customer', () => {
|
||||
cy.get('.q-card').should('be.visible');
|
||||
cy.dataCy('sageTaxTypeFk').filter('input').should('not.have.attr', 'required');
|
||||
cy.get('#searchbar input').clear();
|
||||
cy.get('#searchbar input').type('1{enter}');
|
||||
cy.get('.q-item > .q-item__label').should('have.text', ' #1');
|
||||
cy.dataCy('sageTaxTypeFk').filter('input').should('have.attr', 'required');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,12 +17,14 @@ describe('Client list', () => {
|
|||
|
||||
it('Client list create new client', () => {
|
||||
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
|
||||
const randomInt = Math.floor(Math.random() * 90) + 10;
|
||||
|
||||
const data = {
|
||||
Name: { val: 'Name 1' },
|
||||
'Social name': { val: 'TEST 1' },
|
||||
'Tax number': { val: '20852113Z' },
|
||||
'Web user': { val: 'user_test_1' },
|
||||
Street: { val: 'C/ STREET 1' },
|
||||
Name: { val: `Name ${randomInt}` },
|
||||
'Social name': { val: `TEST ${randomInt}` },
|
||||
'Tax number': { val: `20852${randomInt.length}3Z` },
|
||||
'Web user': { val: `user_test_${randomInt}` },
|
||||
Street: { val: `C/ STREET ${randomInt}` },
|
||||
Email: { val: 'user.test@1.com' },
|
||||
'Sales person': { val: 'employee', type: 'select' },
|
||||
Location: { val: '46000, Valencia(Province one), España', type: 'select' },
|
||||
|
@ -32,7 +34,7 @@ describe('Client list', () => {
|
|||
|
||||
cy.get('.q-mt-lg > .q-btn--standard').click();
|
||||
|
||||
cy.checkNotification('created');
|
||||
cy.checkNotification('Data saved');
|
||||
cy.url().should('include', '/summary');
|
||||
});
|
||||
it('Client list search client', () => {
|
||||
|
@ -54,8 +56,8 @@ describe('Client list', () => {
|
|||
cy.openActionDescriptor('Create ticket');
|
||||
cy.waitForElement('#formModel');
|
||||
cy.waitForElement('.q-form');
|
||||
cy.checkValueSelectForm(1, search);
|
||||
cy.checkValueSelectForm(2, search);
|
||||
cy.checkValueForm(1, search);
|
||||
cy.checkValueForm(2, search);
|
||||
});
|
||||
it('Client founded create order', () => {
|
||||
const search = 'Jessica Jones';
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
/// <reference types="cypress" />
|
||||
describe('Client notes', () => {
|
||||
beforeEach(() => {
|
||||
cy.viewport(1280, 720);
|
||||
cy.login('developer');
|
||||
cy.visit('#/customer/1101/sms');
|
||||
});
|
||||
it('Should load layout', () => {
|
||||
cy.get('.q-page').should('be.visible');
|
||||
cy.get('.q-page > :nth-child(2) > :nth-child(1)').should('be.visible');
|
||||
});
|
||||
});
|
|
@ -3,11 +3,26 @@ describe('Client web-access', () => {
|
|||
beforeEach(() => {
|
||||
cy.viewport(1280, 720);
|
||||
cy.login('developer');
|
||||
cy.visit('#/customer/1110/web-access', {
|
||||
timeout: 5000,
|
||||
});
|
||||
});
|
||||
it('Should load layout', () => {
|
||||
it('Should test buttons ', () => {
|
||||
cy.visit('#/customer/1101/web-access');
|
||||
cy.get('.q-page').should('be.visible');
|
||||
cy.get('#formModel').should('be.visible');
|
||||
cy.get('.q-card').should('be.visible');
|
||||
cy.get('.q-btn-group > :nth-child(1)').should('not.be.disabled');
|
||||
cy.get('.q-checkbox__inner').click();
|
||||
cy.get('.q-btn-group > .q-btn--standard.q-btn--actionable').should(
|
||||
'not.be.disabled'
|
||||
);
|
||||
cy.get('.q-btn-group > .q-btn--flat').should('not.be.disabled');
|
||||
cy.get('.q-btn-group > :nth-child(1)').click();
|
||||
cy.get('.q-dialog__inner > .q-card > :nth-child(1)')
|
||||
.should('be.visible')
|
||||
.find('.text-h6')
|
||||
.should('have.text', 'Change password');
|
||||
});
|
||||
it('Should disabled buttons', () => {
|
||||
cy.visit('#/customer/1110/web-access');
|
||||
cy.get('.q-btn-group > :nth-child(1)').should('be.disabled');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/// <reference types="cypress" />
|
||||
describe('Client credit opinion', () => {
|
||||
describe('Client credit contracts', () => {
|
||||
beforeEach(() => {
|
||||
cy.viewport(1280, 720);
|
||||
cy.login('developer');
|
||||
|
@ -8,6 +8,6 @@ describe('Client credit opinion', () => {
|
|||
});
|
||||
});
|
||||
it('Should load layout', () => {
|
||||
cy.get('.q-card').should('be.visible');
|
||||
cy.get('.q-page').should('be.visible');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,11 +3,17 @@ describe('Client unpaid', () => {
|
|||
beforeEach(() => {
|
||||
cy.viewport(1280, 720);
|
||||
cy.login('developer');
|
||||
cy.visit('#/customer/1110/others/unpaid', {
|
||||
timeout: 5000,
|
||||
});
|
||||
});
|
||||
it('Should load layout', () => {
|
||||
it('Should add unpaid', () => {
|
||||
cy.visit('#/customer/1102/others/unpaid');
|
||||
cy.get('.q-card').should('be.visible');
|
||||
cy.get('.q-checkbox__inner').click();
|
||||
cy.dataCy('customerUnpaidAmount').find('input').type('100');
|
||||
cy.dataCy('customerUnpaidDate').find('input').type('01/01/2001');
|
||||
cy.get('.q-btn-group > .q-btn--standard').click();
|
||||
cy.reload();
|
||||
cy.get('.q-checkbox__inner')
|
||||
.should('be.visible')
|
||||
.and('not.have.class', 'q-checkbox__inner--active');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
describe('VnInput Component', () => {
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.viewport(1920, 1080);
|
||||
cy.visit('/#/supplier/1/fiscal-data');
|
||||
cy.domContentLoad();
|
||||
});
|
||||
|
||||
it('should replace character at cursor position in insert mode', () => {
|
||||
// Simula escribir en el input
|
||||
cy.dataCy('supplierFiscalDataAccount').clear();
|
||||
cy.dataCy('supplierFiscalDataAccount').type('4100000001');
|
||||
// Coloca el cursor en la posición 0
|
||||
cy.dataCy('supplierFiscalDataAccount').type('{movetostart}');
|
||||
// Escribe un número y verifica que se reemplace correctamente
|
||||
cy.dataCy('supplierFiscalDataAccount').type('999');
|
||||
cy.dataCy('supplierFiscalDataAccount')
|
||||
.should('have.value', '9990000001');
|
||||
});
|
||||
|
||||
it('should replace character at cursor position in insert mode', () => {
|
||||
// Simula escribir en el input
|
||||
cy.dataCy('supplierFiscalDataAccount').clear();
|
||||
cy.dataCy('supplierFiscalDataAccount').type('4100000001');
|
||||
// Coloca el cursor en la posición 0
|
||||
cy.dataCy('supplierFiscalDataAccount').type('{movetostart}');
|
||||
// Escribe un número y verifica que se reemplace correctamente en la posicion incial
|
||||
cy.dataCy('supplierFiscalDataAccount').type('999');
|
||||
cy.dataCy('supplierFiscalDataAccount')
|
||||
.should('have.value', '9990000001');
|
||||
});
|
||||
|
||||
it('should respect maxlength prop', () => {
|
||||
cy.dataCy('supplierFiscalDataAccount').clear();
|
||||
cy.dataCy('supplierFiscalDataAccount').type('123456789012345');
|
||||
cy.dataCy('supplierFiscalDataAccount')
|
||||
.should('have.value', '1234567890'); // asumiendo que maxlength es 10
|
||||
});
|
||||
});
|
|
@ -3,6 +3,7 @@ describe('VnBreadcrumbs', () => {
|
|||
const firstCard = '.q-infinite-scroll > :nth-child(1)';
|
||||
const lastBreadcrumb = '.q-breadcrumbs--last > .q-breadcrumbs__el';
|
||||
beforeEach(() => {
|
||||
cy.viewport(1920, 1080);
|
||||
cy.login('developer');
|
||||
cy.visit('/');
|
||||
});
|
|
@ -43,11 +43,9 @@ describe('VnLocation', () => {
|
|||
province
|
||||
);
|
||||
cy.get(
|
||||
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(3) > .q-icon`
|
||||
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(3) `
|
||||
).click();
|
||||
cy.get(
|
||||
`#q-portal--dialog--5 > .q-dialog > ${createForm.prefix} > .vn-row > .q-select > ${createForm.sufix} > :nth-child(1) input`
|
||||
).should('have.value', province);
|
||||
cy.dataCy('locationProvince').should('have.value', province);
|
||||
});
|
||||
});
|
||||
describe('Worker Create', () => {
|
||||
|
@ -105,12 +103,12 @@ describe('VnLocation', () => {
|
|||
const province = 'Valencia';
|
||||
cy.get(createLocationButton).click();
|
||||
cy.get('.q-card > h1').should('have.text', 'New postcode');
|
||||
cy.get(dialogInputs).eq(0).clear();
|
||||
cy.get(dialogInputs).eq(0).type(postCode);
|
||||
cy.selectOption(
|
||||
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix}`,
|
||||
province
|
||||
);
|
||||
cy.get(dialogInputs).eq(0).clear();
|
||||
cy.get(dialogInputs).eq(0).type(postCode);
|
||||
cy.get('.q-mt-lg > .q-btn--standard').click();
|
||||
cy.get(`${createForm.prefix}`).should('not.exist');
|
||||
cy.waitForElement('.q-form');
|
||||
|
@ -123,32 +121,16 @@ describe('VnLocation', () => {
|
|||
const province = randomString({ length: 4 });
|
||||
cy.get(createLocationButton).click();
|
||||
cy.get(dialogInputs).eq(0).type(postCode);
|
||||
cy.get(
|
||||
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(2) > .q-icon`
|
||||
).click();
|
||||
cy.selectOption('#q-portal--dialog--3 .q-select', 'one');
|
||||
cy.get('#q-portal--dialog--3 .q-input').type(province);
|
||||
cy.get('#q-portal--dialog--3 .q-btn--standard').click();
|
||||
cy.get('#q-portal--dialog--1 .q-btn--standard').click();
|
||||
cy.dataCy('City_icon').click();
|
||||
cy.selectOption('[data-cy="locationProvince"]:last', 'Province one');
|
||||
cy.dataCy('cityName').type(province);
|
||||
cy.dataCy('FormModelPopup_save').eq(1).click();
|
||||
cy.dataCy('FormModelPopup_save').eq(0).click();
|
||||
|
||||
cy.waitForElement('.q-form');
|
||||
checkVnLocation(postCode, province);
|
||||
});
|
||||
|
||||
it('Create province without country', () => {
|
||||
const provinceName = 'Saskatchew'.concat(Math.random(1 * 100));
|
||||
cy.get(createLocationButton).click();
|
||||
cy.get(
|
||||
`${createForm.prefix} > :nth-child(5) > .q-select > ${createForm.sufix} > :nth-child(2) `
|
||||
)
|
||||
.eq(0)
|
||||
.click();
|
||||
cy.selectOption('#q-portal--dialog--3 .q-select', 'one');
|
||||
cy.countSelectOptions('#q-portal--dialog--3 .q-select', 4);
|
||||
cy.get('#q-portal--dialog--3 .q-input').type(provinceName);
|
||||
|
||||
cy.get('#q-portal--dialog--3 .q-btn--standard').click();
|
||||
});
|
||||
|
||||
it('Create city with country', () => {
|
||||
const cityName = 'Saskatchew'.concat(Math.random(1 * 100));
|
||||
cy.get(createLocationButton).click();
|
||||
|
@ -156,14 +138,23 @@ describe('VnLocation', () => {
|
|||
`${createForm.prefix} > :nth-child(5) > :nth-child(3) `,
|
||||
'Italia'
|
||||
);
|
||||
cy.get(
|
||||
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(2) > .q-icon`
|
||||
).click();
|
||||
cy.selectOption('#q-portal--dialog--4 .q-select', 'Province four');
|
||||
cy.countSelectOptions('#q-portal--dialog--4 .q-select', 1);
|
||||
cy.dataCy('City_icon').click();
|
||||
cy.selectOption('[data-cy="locationProvince"]:last', 'Province four');
|
||||
cy.countSelectOptions('[data-cy="locationProvince"]:last', 1);
|
||||
|
||||
cy.get('#q-portal--dialog--4 .q-input').type(cityName);
|
||||
cy.get('#q-portal--dialog--4 .q-btn--standard').click();
|
||||
cy.dataCy('cityName').type(cityName);
|
||||
cy.dataCy('FormModelPopup_save').eq(1).click();
|
||||
});
|
||||
|
||||
it('Create province without country', () => {
|
||||
const provinceName = 'Saskatchew'.concat(Math.random(1 * 100));
|
||||
cy.get(createLocationButton).click();
|
||||
cy.dataCy('Province_icon').click();
|
||||
cy.selectOption('[data-cy="autonomyProvince"] ', 'Autonomy one');
|
||||
cy.countSelectOptions('[data-cy="autonomyProvince"]', 4);
|
||||
cy.dataCy('provinceName').type(provinceName);
|
||||
|
||||
cy.dataCy('FormModelPopup_save').eq(1).click();
|
||||
});
|
||||
|
||||
it('Create province with country', () => {
|
||||
|
@ -173,17 +164,13 @@ describe('VnLocation', () => {
|
|||
`${createForm.prefix} > :nth-child(5) > :nth-child(3) `,
|
||||
'España'
|
||||
);
|
||||
cy.get(
|
||||
`${createForm.prefix} > :nth-child(5) > .q-select > ${createForm.sufix} > :nth-child(2) `
|
||||
)
|
||||
.eq(0)
|
||||
.click();
|
||||
cy.dataCy('Province_icon').click();
|
||||
|
||||
cy.selectOption('#q-portal--dialog--4 .q-select', 'one');
|
||||
cy.countSelectOptions('#q-portal--dialog--4 .q-select', 2);
|
||||
cy.selectOption('[data-cy="autonomyProvince"] ', 'Autonomy one');
|
||||
cy.countSelectOptions('[data-cy="autonomyProvince"]', 2);
|
||||
|
||||
cy.get('#q-portal--dialog--4 .q-input').type(provinceName);
|
||||
cy.get('#q-portal--dialog--4 .q-btn--standard').click();
|
||||
cy.dataCy('provinceName').type(provinceName);
|
||||
cy.dataCy('FormModelPopup_save').eq(1).click();
|
||||
});
|
||||
|
||||
function checkVnLocation(postCode, province) {
|
|
@ -86,9 +86,10 @@ Cypress.Commands.add('getValue', (selector) => {
|
|||
});
|
||||
|
||||
// Fill Inputs
|
||||
Cypress.Commands.add('selectOption', (selector, option) => {
|
||||
Cypress.Commands.add('selectOption', (selector, option, timeout) => {
|
||||
cy.waitForElement(selector);
|
||||
cy.get(selector).click();
|
||||
cy.wait(timeout || 1000);
|
||||
cy.get('.q-menu .q-item').contains(option).click();
|
||||
});
|
||||
Cypress.Commands.add('countSelectOptions', (selector, option) => {
|
||||
|
@ -259,6 +260,7 @@ Cypress.Commands.add('writeSearchbar', (value) => {
|
|||
value
|
||||
);
|
||||
});
|
||||
|
||||
Cypress.Commands.add('validateContent', (selector, expectedValue) => {
|
||||
cy.get(selector).should('have.text', expectedValue);
|
||||
});
|
||||
|
@ -280,16 +282,38 @@ Cypress.Commands.add('clickButtonsDescriptor', (id) => {
|
|||
.click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('openActionDescriptor', (opt) => {
|
||||
cy.openActionsDescriptor();
|
||||
const listItem = '[role="menu"] .q-list .q-item';
|
||||
cy.contains(listItem, opt).click();
|
||||
1;
|
||||
});
|
||||
|
||||
Cypress.Commands.add('clickButtonsDescriptor', (id) => {
|
||||
cy.get(`.actions > .q-card__actions> .q-btn:nth-child(${id})`)
|
||||
.invoke('removeAttr', 'target')
|
||||
.click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('openActionDescriptor', (opt) => {
|
||||
cy.openActionsDescriptor();
|
||||
const listItem = '[role="menu"] .q-list .q-item';
|
||||
cy.contains(listItem, opt).click();
|
||||
1;
|
||||
});
|
||||
|
||||
Cypress.Commands.add('clickButtonsDescriptor', (id) => {
|
||||
cy.get(`.actions > .q-card__actions> .q-btn:nth-child(${id})`)
|
||||
.invoke('removeAttr', 'target')
|
||||
.click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('openUserPanel', () => {
|
||||
cy.get(
|
||||
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image'
|
||||
).click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('openActions', (row) => {
|
||||
cy.get('tbody > tr').eq(row).find('.actions > .q-btn').click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('checkNotification', (text) => {
|
||||
cy.get('.q-notification')
|
||||
.should('be.visible')
|
||||
|
@ -300,10 +324,14 @@ Cypress.Commands.add('checkNotification', (text) => {
|
|||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('openActions', (row) => {
|
||||
cy.get('tbody > tr').eq(row).find('.actions > .q-btn').click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('checkValueForm', (id, search) => {
|
||||
cy.get(
|
||||
`.grid-create > :nth-child(${id}) > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > .q-field__input`
|
||||
).should('have.value', search);
|
||||
cy.get(`.grid-create > :nth-child(${id}) `)
|
||||
.find('input')
|
||||
.should('have.value', search);
|
||||
});
|
||||
|
||||
Cypress.Commands.add('checkValueSelectForm', (id, search) => {
|
||||
|
@ -316,6 +344,6 @@ Cypress.Commands.add('searchByLabel', (label, value) => {
|
|||
cy.get(`[label="${label}"] > .q-field > .q-field__inner`).type(`${value}{enter}`);
|
||||
});
|
||||
|
||||
Cypress.Commands.add('dataCy', (dataTestId, attr = 'data-cy') => {
|
||||
return cy.get(`[${attr}="${dataTestId}"]`);
|
||||
Cypress.Commands.add('dataCy', (tag, attr = 'data-cy') => {
|
||||
return cy.get(`[${attr}="${tag}"]`);
|
||||
});
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
import { describe, it, expect, beforeAll, vi } from 'vitest';
|
||||
import { axios } from 'app/test/vitest/helper';
|
||||
import parsePhone from 'src/filters/parsePhone';
|
||||
|
||||
describe('parsePhone filter', () => {
|
||||
beforeAll(async () => {
|
||||
vi.spyOn(axios, 'get').mockReturnValue({ data: { prefix: '34' } });
|
||||
});
|
||||
|
||||
it('no phone', async () => {
|
||||
const phone = await parsePhone(null, '34');
|
||||
expect(phone).toBe(undefined);
|
||||
});
|
||||
|
||||
it("adds prefix +34 if it doesn't have one", async () => {
|
||||
const phone = await parsePhone('123456789', '34');
|
||||
expect(phone).toBe('34123456789');
|
||||
});
|
||||
|
||||
it('maintains prefix +34 if it is already correct', async () => {
|
||||
const phone = await parsePhone('+34123456789', '34');
|
||||
expect(phone).toBe('34123456789');
|
||||
});
|
||||
|
||||
it('converts prefix 0034 to +34', async () => {
|
||||
const phone = await parsePhone('0034123456789', '34');
|
||||
expect(phone).toBe('34123456789');
|
||||
});
|
||||
|
||||
it('converts prefix 34 without symbol to +34', async () => {
|
||||
const phone = await parsePhone('34123456789', '34');
|
||||
expect(phone).toBe('34123456789');
|
||||
});
|
||||
|
||||
it('replaces incorrect prefix with the correct one', async () => {
|
||||
const phone = await parsePhone('+44123456789', '34');
|
||||
expect(phone).toBe('44123456789');
|
||||
});
|
||||
|
||||
it('adds default prefix on error', async () => {
|
||||
vi.spyOn(axios, 'get').mockImplementation((url) => {
|
||||
if (url.includes('Prefixes'))
|
||||
return Promise.reject(new Error('Network error'));
|
||||
else if (url.includes('PbxConfigs'))
|
||||
return Promise.resolve({ data: { defaultPrefix: '39' } });
|
||||
});
|
||||
const phone = await parsePhone('123456789', '34');
|
||||
expect(phone).toBe('39123456789');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue