diff --git a/CHANGELOG.md b/CHANGELOG.md index 86ffce3fd..f1d10b26e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,322 @@ +# Version 24.38 - 2024-09-17 + +### Added 🆕 + +- chore: refs #6772 fix e2e (origin/6772-warmfix-fixE2e) by:jorgep +- chore: refs #7323 worker changes by:jorgep +- chore: refs #7353 fix warnings by:jorgep +- chore: refs #7353 use Vue component nomenclature by:jorgep +- chore: refs #7356 fix type by:jorgep +- feat(AccountConnections): use VnToken by:alexm +- feat: add key to routerView by:Javier Segarra +- feat: add plus shortcut in VnTable by:Javier Segarra +- feat: add row by:Javier Segarra +- feat: addRow withour dialog by:Javier Segarra +- feat: apply mixin by:Javier Segarra +- feat by:Javier Segarra +- feat: change navBar buttons by:Javier Segarra +- feat: dense rows by:Javier Segarra +- feat: fields with wrong name by:jgallego +- feat: fix bugs and filters by:Javier Segarra +- feat: fix refund parameters by:jgallego +- feat: handle create row by:Javier Segarra +- feat: handle dates by:Javier Segarra +- feat: handle qCheckbox 3rd state by:Javier Segarra +- feat: imrpove VnInputTime to set cursor at start by:Javier Segarra +- feat: keyShortcut directive by:Javier Segarra +- feat: minor fixes by:jgallego +- feat: only filter by isDestiny by:Javier Segarra +- feat: refs #211153 businessDataLinkGrafana by:robert +- feat: refs #7129 add km start and end on create form by:pablone +- feat: refs #7353 add filter & fix customTags by:jorgep +- feat: refs #7353 add locale by:jorgep +- feat: refs #7353 add no one opt by:jorgep +- feat: refs #7353 add right icons by:jorgep +- feat: refs #7353 imporve toDateFormat by:jorgep +- feat: refs #7353 salesPerson nickname & id by:jorgep +- feat: refs #7353 split sections by:jorgep +- feat: refs #7847 remove reload btn by:jorgep +- feat: refs #7847 remove reload fn by:jorgep +- feat: refs #7889 added shortcuts to modules by:Jon +- feat: refs #7911 added shortcut to modules by:Jon +- feat: refuncInvoiceForm component by:jgallego +- feat: remove duplicity by:Javier Segarra +- feat: remove future itemFixedPrices by:Javier Segarra +- feat: replace stickyButtons by subtoolbar by:Javier Segarra +- feat: required validation by:Javier Segarra +- feat: show bad dates by:Javier Segarra +- feat: showdate icons by:Javier Segarra +- feat: solve ItemFixedFilterPanel by:Javier Segarra +- feat: transfer an invoice by:jgallego +- feat: try to fix ItemFixedFilterPanel by:Javier Segarra +- feat: unnecessary changes by:Javier Segarra +- feat: update changelog (origin/7896_down_devToTest_2436) by:Javier Segarra +- feat: updates by:Javier Segarra +- feat: update version and changelog by:Javier Segarra +- feat: vnInput\* by:Javier Segarra +- feat: with VnTable by:Javier Segarra +- refs #6772 feat: fix approach by:Javier Segarra +- refs #6772 feat: refresh shelving.basic-data by:Javier Segarra +- style: show subName value by:Javier Segarra + +### Changed 📦 + +- perf: add v-shortcut in VnCard by:Javier Segarra +- perf: approach by:Javier Segarra +- perf: change directive location by:Javier Segarra +- perf: change slots order by:Javier Segarra +- perf: examples by:Javier Segarra +- perf: hide icon for VnInputDate by:Javier Segarra +- perf: improve ItemFixedPricefilterPanel by:Javier Segarra +- perf: improve mainShrotcutMixin by:Javier Segarra +- perf: minor clean code by:Javier Segarra +- perf: onRowchange by:Javier Segarra +- perf: order by by:Javier Segarra +- perf: order components by:Javier Segarra +- perf: refs #7889 perf shortcut test by:Jon +- perf: remove console.log by:Javier Segarra +- perf: remove icons in header slot by:Javier Segarra +- perf: remove print variables by:Javier Segarra +- perf: restore CustomerBasicData by:Javier Segarra +- refactor: deleted useless prop by:Jon +- refactor: deleted useless prop in FetchedTags by:Jon +- refactor: refs #7323 drop useless code by:jorgep +- refactor: refs #7353 clients correction by:jorgep +- refactor: refs #7353 clients correction wip by:jorgep +- refactor: refs #7353 ease logic by:jorgep +- refactor: refs #7353 order correction by:jorgep +- refactor: refs #7353 simplify code by:jorgep +- refactor: refs #7353 tickets correction by:jorgep +- refactor: refs #7353 use global locales by:jorgep +- refactor: refs #7354 changed descriptor menu options by:Jon +- refactor: refs #7354 changed icon color in table and notification when deleting a zone by:Jon +- refactor: refs #7354 fix tableFilters by:Jon +- refactor: refs #7354 modified VnInputTime by:Jon +- refactor: refs #7354 refactor deliveryPanel by:Jon +- refactor: refs #7354 refactor zones section and fixed e2e tests by:Jon +- refactor: refs #7354 requested changes by:Jon +- refactor: refs #7354 reverse deliveryPanel changes by:Jon +- refactor: refs #7354 Zone migration changes by:Jon +- refactor: refs #7889 deleted subtitle attr and use keyBinding instead by:Jon +- refactor: refs #7889 modified shortcut and dashboard, and added tootlip in LeftMenu by:Jon +- refs #6722 perf: not fetch when id not exists by:Javier Segarra +- refs #6772 perf: change variable name by:JAVIER SEGARRA MARTINEZ +- refs #6772 perf: use ArrayData (6772_reload_sections) by:Javier Segarra +- refs #7283 refactor fix ItemDescriptor by:carlossa +- refs #7283 refactor ItexDescriptor by:carlossa + +### Fixed 🛠️ + +- chore: refs #6772 fix e2e (origin/6772-warmfix-fixE2e) by:jorgep +- chore: refs #7353 fix warnings by:jorgep +- chore: refs #7356 fix type by:jorgep +- feat: fix bugs and filters by:Javier Segarra +- feat: fix refund parameters by:jgallego +- feat: minor fixes by:jgallego +- feat: refs #7353 add filter & fix customTags by:jorgep +- feat: try to fix ItemFixedFilterPanel by:Javier Segarra +- fix: add border-top by:Javier Segarra +- fix: added missing descriptors and small details by:Jon +- fix branch by:carlossa +- fix: call upsert when crudModel haschanges by:Javier Segarra +- fix(ClaimList): fix summary by:alexm +- fix: cli warnings by:Javier Segarra +- fix: editTableOptions by:Javier Segarra +- fix events and descriptor menu by:Jon +- fix: InvoiceIn sections (origin/6772_reload_sections) by:Javier Segarra +- fix: minor changes by:Javier Segarra +- fix: minor error whit dates by:Javier Segarra +- fix: module icon by:Javier Segarra +- fix: options QDate by:Javier Segarra +- fix: refs #6900 e2e error by:jorgep +- fix: refs #6900 rollback by:jorgep +- fix: refs #7353 css by:jorgep +- fix: refs #7353 hide search param (origin/7353-warmfix-fixSearchbar) by:jorgep +- fix: refs #7353 iron out filter by:jorgep +- fix: refs #7353 iron out ticket table by:jorgep +- fix: refs #7353 padding by:jorgep +- fix: refs #7353 salesClientTable by:jorgep +- fix: refs #7353 salesorderTable by:jorgep +- fix: refs #7353 saleTicketMonitors by:jorgep +- fix: refs #7353 use same datakey by:jorgep +- fix: refs #7353 vnTable colors by:jorgep +- fix: refs #7354 e2e tests by:Jon +- fix: refs #7354 fix delivery days by:Jon +- fix: refs #7354 fix list searchbar and filters by:Jon +- fix: refs #7354 fix VnSearchbar search for zone section & finished basic tests by:Jon +- fix: refs #7354 fix VnTable filters and agency field by:Jon +- fix: refs #7354 fix zoneSearchbar by:Jon +- fix: refs #7354 requested changes by:Jon +- fix: refs #7356 colors by:jorgep +- fix: refs #7356 create claim dialog by:jorgep +- fix: refs #7889 fixed shortcut test by:Jon +- fix: refs #7903 fixed ticket's search bar and keybinding tooltip by:Jon +- fix: refs #7911 fixed shortcut and related files by:Jon +- fix: remove condition duplicated by:Javier Segarra +- fix: remove property by:Javier Segarra +- fix tootltip by:carlossa +- fix traduction by:carlossa +- fix(VnSectionMain): add QPage by:alexm +- fix(zone): zoneLocation and the others searchbar by:alexm +- refactor: refs #7354 fix tableFilters by:Jon +- refactor: refs #7354 refactor zones section and fixed e2e tests by:Jon +- refs #6772 feat: fix approach by:Javier Segarra +- refs #6772 fix: claimPhoto reload by:Javier Segarra +- refs #6896 fix searchbar by:carlossa +- refs #6897 fix entry by:carlossa +- refs #6899 fix invoiceFix by:carlossa +- refs #6899 fix order by:carlossa +- refs #7283 fix by:carlossa +- refs #7283 fix ItemDescriptor warehouse by:carlossa +- refs #7283 refactor fix ItemDescriptor by:carlossa +- refs #7355 #7366 fix account, summary, list, travelList, tooltip by:carlossa +- refs #7355 fix accountPrivileges by:carlossa +- refs #7355 fix accounts, vnTable by:carlossa +- refs #7355 fix privileges by:carlossa +- refs #7355 fix roles filters by:carlossa +- refs #7355 fix total by:carlossa +- refs #7355 fix views summarys, entryList, travelList refact by:carlossa +- refs #7366 fix travel hours by:carlossa +- test: fix e2e by:Javier Segarra + +# Version 24.36 - 2024-08-27 + +### Added 🆕 + +- feat(FormModel): trim data by default by:alexm +- feat(orderBasicData): add notes by:alexm +- feat(orderList): correct create order by:alexm +- feat(orderList): use orderFilter and fixed this by:alexm +- feat: #7323 handle workerPhoto (origin/7323_workerPhoto, 7323_workerPhoto) by:Javier Segarra +- feat: add recover password and reset password by:alexm +- feat: refs #7346 add seriaType option by:jgallego +- feat: refs #7346 elimino === by:jgallego +- feat: refs #7346 formdata uses serialType by:jgallego +- feat: refs #7346 refactor by:jgallego +- feat: refs #7346 sonarLint warnings (origin/7346-invoiceOutMultilple, 7346-invoiceOutMultilple) by:jgallego +- feat: refs #7710 uses cloneAll by:jgallego +- fix: refs #7717 fix OrderList table filters' and summary table style by:Jon + +### Changed 📦 + +- feat: refs #7346 refactor by:jgallego +- perf: date fields (mindshore/feature/TicketFutureFilter, feature/TicketFutureFilter) by:Javier Segarra +- perf: refs #7717 right menu filter by:Jon +- perf: use ref at component start by:Javier Segarra +- refactor: refs #7717 delete useless function and import by:Jon +- refactor: refs #7717 deleted useless code by:Jon + +### Fixed 🛠️ + +- feat(orderList): use orderFilter and fixed this by:alexm +- fix(VnTable): orderBy v-model by:alexm +- fix(account_card): redirection by:carlossa +- fix(orderLines): reload when delete and redirect when confirm by:alexm +- fix: #6336 ClaimListStates by:Javier Segarra +- fix: account subsections cards by:carlossa +- fix: duplicate key by:Jon +- fix: order description to vnTable by:alexm +- fix: orderCatalogFilter order by:alexm +- fix: quasar build warnings (6336_claim_fix_states) by:Javier Segarra +- fix: refs #7717 fix OrderList table filters' and summary table style by:Jon +- fix: refs #7717 fix basic data form & minor errors by:Jon +- fix: refs #7717 fix catalog filter, searchbar redirect and search by:Jon +- fix: refs #7717 fix catalog searchbar and worker tests(refs #7323) by:Jon +- fix: refs #7717 fix order sections by:Jon +- fix: refs #7717 fix volume and lines redirect by:Jon +- fix: refs #7717 fixed searchbar filter with rightmenu filters' applied by:Jon +- fix: test by:alexm +- fix: ticketDescriptorMenu by:Javier Segarra +- refs #7355 account fixes by:carlossa + +# Version 24.34 - 2024-08-20 + +### Added 🆕 + +- chore: #6900 order params by:jorgep +- chore: refs #6900 drop console log by:jorgep +- chore: refs #6900 drop vnCurrency by:jorgep +- chore: refs #6900 fix e2e tests by:jorgep +- chore: refs #6900 mv rectificative logic by:jorgep +- chore: refs #6900 responsive code by:jorgep +- chore: refs #7283 drop array types by:jorgep +- chore: refs #7283 drop import by:jorgep +- chore: refs #7283 fix e2e logout by:jorgep +- chore: refs #7283 update VnAvatar title handling by:jorgep +- chore: refs #7323 fix test by:jorgep +- chore: refs #7323 remove unused import by:jorgep +- chore: refs #7323drop commented code by:jorgep +- feat(VnCard): use props searchbar by:alexm +- feat(customer): improve basicData to balance by:alexm +- feat(customer_balance): refs #6943 add functionality from salix by:alexm +- feat(customer_balance): refs #6943 translations by:alexm +- feat: refs #6130 husky commitLint config by:pablone +- feat: refs #6130 husky hooks by:pablone +- feat: refs #6900 add InvoiceInSerial by:jorgep +- feat: refs #6900 add locale by:jorgep +- feat: refs #6900 use VnTable & sort filter fields by:jorgep +- feat: refs #7323 add flex-wrap by:jorgep +- feat: refs #7323 add my account" btn & fix models log selectable by:jorgep +- feat: refs #7323 improve test by:jorgep + +### Changed 📦 + +- refactor(customer_log: use VnLog by:alexm +- refactor(customer_recovery): to vnTable by:alexm +- refactor(customer_webAccess): FormModel by:alexm +- refactor: refs #7283 update avatar size and color by:jorgep + +### Fixed 🛠️ + +- chore: refs #6900 fix e2e tests by:jorgep +- chore: refs #7283 fix e2e logout by:jorgep +- chore: refs #7323 fix test by:jorgep +- feat: refs #7323 add my account" btn & fix models log selectable by:jorgep +- fix #7355 fix acls list by:carlossa +- fix(VnFilterPanel): emit userParams better by:alexm +- fix(claim_summary): url links (HEAD -> 7864_testToMaster_2434, origin/test, origin/7864_testToMaster_2434, test) by:alexm +- fix(customer_sms: fix reload by:alexm +- fix(twoFactor): unify code login and twoFactor by:alexm +- fix: VnCard VnSearchbar props by:alexm +- fix: accountMailAlias by:alexm +- fix: refs #6130 add commit lint modules by:pablone +- fix: refs #6130 pnpm-lock.yml by:pablone +- fix: refs #6900 improve loading by:jorgep +- fix: refs #6900 improve logic (origin/6900-addSerial) by:jorgep +- fix: refs #6900 improve logic by:jorgep +- fix: refs #6900 rectificative btn reactivity by:jorgep +- fix: refs #6900 use type number by:jorgep +- fix: refs #6900 vat & dueday by:jorgep +- fix: refs #6900 vat, dueday & intrastat by:jorgep +- fix: refs #6989 show entity name & default time from config table by:jorgep +- fix: refs #7283 basicData locale by:jorgep +- fix: refs #7283 itemLastEntries filter by:jorgep +- fix: refs #7283 itemTags & VnImg by:jorgep +- fix: refs #7283 locale by:jorgep +- fix: refs #7283 min-width vnImg by:jorgep +- fix: refs #7283 use vnAvatar & add optional zoom by:jorgep +- fix: refs #7283 userPanel pic by:jorgep +- fix: refs #7323 add department popup by:jorgep +- fix: refs #7323 add locale by:jorgep +- fix: refs #7323 css righ menu by:jorgep +- fix: refs #7323 data-key & add select by:jorgep +- fix: refs #7323 load all opts by:jorgep +- fix: refs #7323 righ menu bug by:jorgep +- fix: refs #7323 use global locale by:jorgep +- fix: refs #7323 use workerFilter (origin/7323-warmfix-fixErrors) by:jorgep +- fix: refs #7323 vnsubtoolbar css by:jorgep +- fix: refs #7323 wrong css by:jorgep +- refs #7355 fix Rol, alias by:carlossa +- refs #7355 fix accountAlias by:carlossa +- refs #7355 fix alias summary by:carlossa +- refs #7355 fix conflicts by:carlossa +- refs #7355 fix create Rol by:carlossa +- refs #7355 fix list by:carlossa +- refs #7355 fix lists redirects summary by:carlossa +- refs #7355 fix roles by:carlossa +- refs #7355 fix search exprBuilder by:carlossa +- refs #7355 fix vnTable by:carlossa + # Version 24.32 - 2024-08-06 ### Added 🆕 diff --git a/package.json b/package.json index 72bada823..ead0193c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-front", - "version": "24.34.0", + "version": "24.40.0", "description": "Salix frontend", "productName": "Salix", "author": "Verdnatura", diff --git a/src/boot/axios.js b/src/boot/axios.js index 9b32275bd..99a163cca 100644 --- a/src/boot/axios.js +++ b/src/boot/axios.js @@ -5,8 +5,10 @@ import useNotify from 'src/composables/useNotify.js'; const session = useSession(); const { notify } = useNotify(); +const baseUrl = '/api/'; -axios.defaults.baseURL = '/api/'; +axios.defaults.baseURL = baseUrl; +const axiosNoError = axios.create({ baseURL: baseUrl }); const onRequest = (config) => { const token = session.getToken(); @@ -79,5 +81,7 @@ const onResponseError = (error) => { axios.interceptors.request.use(onRequest, onRequestError); axios.interceptors.response.use(onResponse, onResponseError); +axiosNoError.interceptors.request.use(onRequest); +axiosNoError.interceptors.response.use(onResponse); -export { onRequest, onResponseError }; +export { onRequest, onResponseError, axiosNoError }; diff --git a/src/boot/keyShortcut.js b/src/boot/keyShortcut.js new file mode 100644 index 000000000..5afb5b74a --- /dev/null +++ b/src/boot/keyShortcut.js @@ -0,0 +1,34 @@ +export default { + mounted: function (el, binding) { + const shortcut = binding.value ?? '+'; + + const { key, ctrl, alt, callback } = + typeof shortcut === 'string' + ? { + key: shortcut, + ctrl: true, + alt: true, + callback: () => + document + .querySelector(`button[shortcut="${shortcut}"]`) + ?.click(), + } + : binding.value; + + const handleKeydown = (event) => { + if (event.key === key && (!ctrl || event.ctrlKey) && (!alt || event.altKey)) { + callback(); + } + }; + + // Attach the event listener to the window + window.addEventListener('keydown', handleKeydown); + + el._handleKeydown = handleKeydown; + }, + unmounted: function (el) { + if (el._handleKeydown) { + window.removeEventListener('keydown', el._handleKeydown); + } + }, +}; diff --git a/src/boot/mainShortcutMixin.js b/src/boot/mainShortcutMixin.js new file mode 100644 index 000000000..8e5f147db --- /dev/null +++ b/src/boot/mainShortcutMixin.js @@ -0,0 +1,38 @@ +import routes from 'src/router/modules'; +import { useRouter } from 'vue-router'; + +let isNotified = false; + +export default { + created: function () { + const router = useRouter(); + const keyBindingMap = routes + .filter((route) => route.meta.keyBinding) + .reduce((map, route) => { + map['Key' + route.meta.keyBinding.toUpperCase()] = route.path; + return map; + }, {}); + + const handleKeyDown = (event) => { + const { ctrlKey, altKey, code } = event; + + if (ctrlKey && altKey && keyBindingMap[code] && !isNotified) { + event.preventDefault(); + router.push(keyBindingMap[code]); + isNotified = true; + } + }; + + const handleKeyUp = (event) => { + const { ctrlKey, altKey } = event; + + // Resetea la bandera cuando se sueltan las teclas ctrl o alt + if (!ctrlKey || !altKey) { + isNotified = false; + } + }; + + window.addEventListener('keydown', handleKeyDown); + window.addEventListener('keyup', handleKeyUp); + }, +}; diff --git a/src/boot/qformEnterEvent.js b/src/boot/qFormEnterEvent.js similarity index 100% rename from src/boot/qformEnterEvent.js rename to src/boot/qFormEnterEvent.js diff --git a/src/boot/qFormFocus.js b/src/boot/qFormFocus.js new file mode 100644 index 000000000..466943db5 --- /dev/null +++ b/src/boot/qFormFocus.js @@ -0,0 +1,18 @@ +export default { + mounted() { + const observer = new MutationObserver((mutations, observerInstance) => { + const firstInput = this?.$el?.querySelector( + 'input:not([disabled]):not([type="checkbox"]), textarea:not([disabled]), [contenteditable]:not([disabled])' + ); + if (firstInput?.form) { + firstInput.focus(); + observerInstance.disconnect(); + } + }); + + observer.observe(this.$el, { + childList: true, + subtree: true, + }); + }, +}; diff --git a/src/boot/qformFocus.js b/src/boot/qformFocus.js deleted file mode 100644 index 9a6a4b8fe..000000000 --- a/src/boot/qformFocus.js +++ /dev/null @@ -1,29 +0,0 @@ -import { getCurrentInstance } from 'vue'; - -export default { - mounted() { - const vm = getCurrentInstance(); - if (vm.type.name === 'QForm') { - if (!['searchbarForm', 'filterPanelForm'].includes(this.$el?.id)) - this.observeForInputs(); - } - }, - methods: { - observeForInputs() { - const observer = new MutationObserver((mutations, observerInstance) => { - const firstInput = this.$el.querySelector( - 'input:not([disabled]):not([type="checkbox"], textarea:not([disabled]), [contenteditable]:not([disabled])' - ); - if (firstInput) { - firstInput.focus(); - observerInstance.disconnect(); - } - }); - - observer.observe(this.$el, { - childList: true, - subtree: true, - }); - }, - }, -}; diff --git a/src/boot/quasar.js b/src/boot/quasar.js index 19f4bdffd..f41dbf734 100644 --- a/src/boot/quasar.js +++ b/src/boot/quasar.js @@ -1,8 +1,18 @@ import { boot } from 'quasar/wrappers'; -import qformEnterEvent from './qformEnterEvent'; -import qformFocus from './qformFocus'; +import qFormEnterEvent from './qFormEnterEvent'; +import qFormFocus from './qFormFocus'; +import mainShortcutMixin from './mainShortcutMixin'; +import keyShortcut from './keyShortcut'; +import useNotify from 'src/composables/useNotify.js'; +const { notify } = useNotify(); export default boot(({ app }) => { - app.mixin(qformEnterEvent); - app.mixin(qformFocus); + app.mixin(qFormEnterEvent); + app.mixin(qFormFocus); + app.mixin(mainShortcutMixin); + app.directive('shortcut', keyShortcut); + app.config.errorHandler = function (err) { + console.error(err); + notify('globals.error', 'negative', 'error'); + }; }); diff --git a/src/components/CreateBankEntityForm.vue b/src/components/CreateBankEntityForm.vue index c46ac7752..1117225c7 100644 --- a/src/components/CreateBankEntityForm.vue +++ b/src/components/CreateBankEntityForm.vue @@ -1,5 +1,5 @@ + + + +es: + New expense: Nuevo gasto + It's a withholding: Es una retención + diff --git a/src/components/CreateNewPostcodeForm.vue b/src/components/CreateNewPostcodeForm.vue index a426ac2b4..4c44d29e2 100644 --- a/src/components/CreateNewPostcodeForm.vue +++ b/src/components/CreateNewPostcodeForm.vue @@ -105,7 +105,7 @@ async function setProvince(id, data) { option-label="name" option-value="id" :rules="validate('postcode.city')" - :roles-allowed-to-create="['deliveryAssistant']" + :acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]" :emit-value="false" clearable > diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue index 33c831e3f..0386e037b 100644 --- a/src/components/CrudModel.vue +++ b/src/components/CrudModel.vue @@ -189,11 +189,11 @@ async function saveChanges(data) { }); } -async function insert() { +async function insert(pushData = $props.dataRequired) { const $index = formData.value.length ? formData.value[formData.value.length - 1].$index + 1 : 0; - formData.value.push(Object.assign({ $index }, $props.dataRequired)); + formData.value.push(Object.assign({ $index }, pushData)); hasChanges.value = true; } diff --git a/src/components/FetchData.vue b/src/components/FetchData.vue index 2a0864d3e..3038aa88e 100644 --- a/src/components/FetchData.vue +++ b/src/components/FetchData.vue @@ -44,7 +44,7 @@ onMounted(async () => { async function fetch(fetchFilter = {}) { try { - const filter = Object.assign(fetchFilter, $props.filter); // eslint-disable-line vue/no-dupe-keys + const filter = { ...fetchFilter, ...$props.filter }; // eslint-disable-line vue/no-dupe-keys if ($props.where && !fetchFilter.where) filter.where = $props.where; if ($props.sortBy) filter.order = $props.sortBy; if ($props.limit) filter.limit = $props.limit; diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index a0f6bf479..05f947cf3 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -22,7 +22,7 @@ const { t } = useI18n(); const { validate } = useValidator(); const { notify } = useNotify(); const route = useRoute(); - +const myForm = ref(null); const $props = defineProps({ url: { type: String, @@ -87,6 +87,10 @@ const $props = defineProps({ type: Boolean, default: false, }, + defaultTrim: { + type: Boolean, + default: true, + }, }); const emit = defineEmits(['onFetch', 'onDataSaved']); const modelValue = computed( @@ -105,11 +109,14 @@ const defaultButtons = computed(() => ({ color: 'primary', icon: 'save', label: 'globals.save', + click: () => myForm.value.submit(), + type: 'submit', }, reset: { color: 'primary', icon: 'restart_alt', label: 'globals.reset', + click: () => reset(), }, ...$props.defaultButtons, })); @@ -195,6 +202,7 @@ async function save() { isLoading.value = true; try { + formData.value = trimData(formData.value); const body = $props.mapper ? $props.mapper(formData.value) : formData.value; const method = $props.urlCreate ? 'post' : 'patch'; const url = @@ -253,6 +261,14 @@ function updateAndEmit(evt, val, res) { emit(evt, state.get(modelValue), res); } +function trimData(data) { + if (!$props.defaultTrim) return data; + for (const key in data) { + if (typeof data[key] == 'string') data[key] = data[key].trim(); + } + return data; +} + defineExpose({ save, isLoading, @@ -263,7 +279,14 @@ defineExpose({