Compare commits
No commits in common. "dev" and "8061_improve_newCP" have entirely different histories.
dev
...
8061_impro
|
@ -1,4 +1,4 @@
|
|||
export default {
|
||||
module.exports = {
|
||||
// https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
|
||||
// This option interrupts the configuration hierarchy at this file
|
||||
// Remove this if you have an higher level ESLint config file (it usually happens into a monorepos)
|
||||
|
@ -58,7 +58,7 @@ export default {
|
|||
rules: {
|
||||
'prefer-promise-reject-errors': 'off',
|
||||
'no-unused-vars': 'warn',
|
||||
'vue/no-multiple-template-root': 'off',
|
||||
"vue/no-multiple-template-root": "off" ,
|
||||
// allow debugger during development only
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
},
|
|
@ -29,9 +29,5 @@ yarn-error.log*
|
|||
*.sln
|
||||
|
||||
# Cypress directories and files
|
||||
/test/cypress/videos
|
||||
/test/cypress/screenshots
|
||||
|
||||
# VitePress directories and files
|
||||
/docs/.vitepress/cache
|
||||
/docs/.vuepress
|
||||
/tests/cypress/videos
|
||||
/tests/cypress/screenshots
|
|
@ -1,24 +1,23 @@
|
|||
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
||||
import { join, resolve } from 'path';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function getCurrentBranchName(p = process.cwd()) {
|
||||
if (!existsSync(p)) return false;
|
||||
if (!fs.existsSync(p)) return false;
|
||||
|
||||
const gitHeadPath = join(p, '.git', 'HEAD');
|
||||
const gitHeadPath = path.join(p, '.git', 'HEAD');
|
||||
|
||||
if (!existsSync(gitHeadPath)) {
|
||||
return getCurrentBranchName(resolve(p, '..'));
|
||||
}
|
||||
if (!fs.existsSync(gitHeadPath))
|
||||
return getCurrentBranchName(path.resolve(p, '..'));
|
||||
|
||||
const headContent = readFileSync(gitHeadPath, 'utf-8');
|
||||
const headContent = fs.readFileSync(gitHeadPath, 'utf-8');
|
||||
return headContent.trim().split('/')[2];
|
||||
}
|
||||
|
||||
const branchName = getCurrentBranchName();
|
||||
|
||||
if (branchName) {
|
||||
const msgPath = '.git/COMMIT_EDITMSG';
|
||||
const msg = readFileSync(msgPath, 'utf-8');
|
||||
const msgPath = `.git/COMMIT_EDITMSG`;
|
||||
const msg = fs.readFileSync(msgPath, 'utf-8');
|
||||
const reference = branchName.match(/^\d+/);
|
||||
|
||||
const referenceTag = `refs #${reference}`;
|
||||
|
@ -27,7 +26,8 @@ if (branchName) {
|
|||
|
||||
if (splitedMsg.length > 1) {
|
||||
const finalMsg = splitedMsg[0] + ': ' + referenceTag + splitedMsg.slice(1).join(':');
|
||||
writeFileSync(msgPath, finalMsg);
|
||||
fs.writeFileSync(msgPath, finalMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export default {
|
||||
module.exports = {
|
||||
singleQuote: true,
|
||||
printWidth: 90,
|
||||
tabWidth: 4,
|
||||
|
|
481
CHANGELOG.md
481
CHANGELOG.md
|
@ -1,484 +1,3 @@
|
|||
# Version 25.04 - 2025-01-28
|
||||
|
||||
### Added 🆕
|
||||
|
||||
- chore: add task comment by:jorgep
|
||||
- chore: refs #8198 rollback by:jorgep
|
||||
- chore: refs #8322 unnecessary prop by:alexm
|
||||
- feat: refs #7055 added new test case by:provira
|
||||
- feat: refs #7055 created FilterItemForm test by:provira
|
||||
- feat: refs #7077 created test for VnInputTime by:provira
|
||||
- feat: refs #7078 created test for VnJsonValue by:provira
|
||||
- feat: refs #7087 added more test cases by:provira
|
||||
- feat: refs #7087 added new test by:provira
|
||||
- feat: refs #7087 created CardSummary test by:provira
|
||||
- feat: refs #7088 created test for FetchedTags by:provira
|
||||
- feat: refs #7202 added new field by:Jon
|
||||
- feat: refs #7882 Added coords to create a address by:guillermo
|
||||
- feat: refs #7957 add tooltip and i18n support for search link in VnSearchbar component by:jorgep
|
||||
- feat: refs #7957 enhance search functionality and improve data filtering logic by:jorgep
|
||||
- feat: refs #7957 open in new tab by:jorgep
|
||||
- feat: refs #7957 simplify fn to by:jorgep
|
||||
- feat: refs #7957 update VnSearchbar component with improved search URL handling and styling enhancements by:jorgep
|
||||
- feat: refs #8117 filters and values added as needed by:jtubau
|
||||
- feat: refs #8197 useHasContent and use in VnSection and RightMenu by:alexm
|
||||
- feat: refs #8219 added invoice out e2e tests by:Jon
|
||||
- feat: refs #8219 global invoicing e2e by:Jon
|
||||
- feat: refs #8220 added barcodes e2e test by:Jon
|
||||
- feat: refs #8220 created items e2e by:Jon
|
||||
- feat: refs #8220 modified create item form and added respective e2e by:Jon
|
||||
- feat: refs #8225 added account and invoiceOut modules by:Jon
|
||||
- feat: refs #8225 added entry module and fixed translations by:Jon
|
||||
- feat: refs #8225 added invoiceIn and travel module by:Jon
|
||||
- feat: refs #8225 added moreOptions and use it in customer and ticket summary by:Jon
|
||||
- feat: refs #8225 added route and shelving module by:Jon
|
||||
- feat: refs #8225 added worker and zone modules by:Jon
|
||||
- feat: refs #8225 use it in claim, item and order modules by:Jon
|
||||
- feat: refs #8258 added button to pass to uppercase by:provira
|
||||
- feat: refs #8258 added uppercase option to VnInput by:provira
|
||||
- feat: refs #8258 added uppercase validation on supplier create by:provira
|
||||
- feat: refs #8298 add price optimum input and update translations for bonus and price optimum by:jgallego
|
||||
- feat: refs #8316 add entryFilter prop to VnTable component in EntryList by:jtubau
|
||||
- feat: refs #8322 added department changes by:provira
|
||||
- feat: refs #8372 workerPBX by:robert
|
||||
- feat: refs #8381 add initial and final temperature fields to entry forms and summaries by:jgallego
|
||||
- feat: refs #8381 add initial and final temperature labels in English and Spanish locales by:jgallego
|
||||
- feat: refs #8381 add toCelsius filter and update temperature fields in entry forms and summaries by:jgallego
|
||||
- feat: skip tests by:jorgep
|
||||
- style: refs #7957 update VnSearchbar padding for improved layout by:jorgep
|
||||
|
||||
### Changed 📦
|
||||
|
||||
- perf: refs #8219 #8219 minor change by:Javier Segarra
|
||||
- perf: refs #8220 on-fetch and added missing translations by:Jon
|
||||
- perf: refs #8220 on-fetch by:Jon
|
||||
- perf: refs #8220 translations by:Jon
|
||||
- perf: refs #8220 use searchbar selector in e2e tests by:Jon
|
||||
- perf: remove warning default value by:Javier Segarra
|
||||
- refactor: redirect using params by:Jon
|
||||
- refactor: refs #7077 removed some comments by:provira
|
||||
- refactor: refs #7087 removed unused imports by:provira
|
||||
- refactor: refs #7100 added const mockData by:jtubau
|
||||
- refactor: refs #7100 delete unnecesary set prop by:jtubau
|
||||
- refactor: refs #7100 refactorized with methods by:jtubau
|
||||
- refactor: refs #7957 remove blank by:jorgep
|
||||
- refactor: refs #8198 simplify data fetching and filtering logic by:jorgep
|
||||
- refactor: refs #8198 simplify state management and data fetching in ItemDiary component by:jorgep
|
||||
- refactor: refs #8219 modified e2e tests and fixed some translations by:Jon
|
||||
- refactor: refs #8219 modified list test, created cypress download folder and added to gitignore by:Jon
|
||||
- refactor: refs #8219 requested changes by:Jon
|
||||
- refactor: refs #8219 use checkNotification command by:Jon
|
||||
- refactor: refs #8220 added data-cy for e2e tests by:Jon
|
||||
- refactor: refs #8220 requested changes by:Jon
|
||||
- refactor: refs #8220 skip failling test and modifed tag test by:Jon
|
||||
- refactor: refs #8225 requested changes by:Jon
|
||||
- refactor: refs #8247 use new acl for sysadmin by:Jon
|
||||
- refactor: refs #8316 added claimFilter by:jtubau
|
||||
- refactor: refs #8316 added entryFilter by:jtubau
|
||||
- refactor: refs #8316 add new localization keys and update existing ones for entry components by:jtubau
|
||||
- refactor: refs #8316 moved localizations to local locale by:jtubau
|
||||
- refactor: refs #8316 move order localization by:jtubau
|
||||
- refactor: refs #8316 remove unused OrderSearchbar component by:jtubau
|
||||
- refactor: refs #8316 update EntryCard to use user-filter prop and remove exprBuilder from EntryList by:jtubau
|
||||
- refactor: refs #8316 used VnSection and VnCardBeta by:jtubau
|
||||
- refactor: refs #8322 changed translations by:provira
|
||||
- refactor: refs #8322 changed Worker component to use VnSection/VnCardBeta by:provira
|
||||
- refactor: refs #8322 set department inside worker by:alexm
|
||||
- refactor: skip intermitent failing test by:Jon
|
||||
|
||||
### Fixed 🛠️
|
||||
|
||||
- feat: refs #8225 added entry module and fixed translations by:Jon
|
||||
- fix: added missing translations in InvoiceIn by:provira
|
||||
- fix: changed invoiceIn for InvoiceIn by:provira
|
||||
- fix: changed translations to only use "invoicein" by:provira
|
||||
- fix: department descriptor link by:Jon
|
||||
- fix: e2e tests by:Jon
|
||||
- fix: entry summary view and build warnings by:Jon
|
||||
- fix: fixed InvoiceIn filter translations by:provira
|
||||
- fix: modified setData in customerDescriptor to show the icons by:Jon
|
||||
- fix: redirect to TicketSale from OrderLines (origin/Fix-RedirectToTicketSale) by:Jon
|
||||
- fix: redirect when confirming lines by:Jon
|
||||
- fix: refs #7055 #7055 #7055 fixed some tests by:provira
|
||||
- fix: refs #7077 removed unused imports by:provira
|
||||
- fix: refs #7078 added missing case with array by:provira
|
||||
- fix: refs #7087 fixed some tests by:provira
|
||||
- fix: refs #7088 changed "vm.vm" to "vm" by:provira
|
||||
- fix: refs #7088 changed wrapper to vm by:provira
|
||||
- fix: refs #7699 add icons and hint by:carlossa
|
||||
- fix: refs #7699 add pwd vnInput by:carlossa
|
||||
- fix: refs #7699 fix component by:carlossa
|
||||
- fix: refs #7699 fix password visibility by:carlossa
|
||||
- fix: refs #7699 fix tfront clean code by:carlossa
|
||||
- fix: refs #7699 fix vnChangePassword, clean VnInput by:carlossa
|
||||
- fix: refs #7699 fix vnInputPassword by:carlossa
|
||||
- fix: refs #7957 add missing closing brace by:jorgep
|
||||
- fix: refs #7957 css by:jorgep
|
||||
- fix: refs #7957 rollback by:jorgep
|
||||
- fix: refs #7957 update data-cy by:jorgep
|
||||
- fix: refs #7957 update visibility handling for clear icon in VnInput component by:jorgep
|
||||
- fix: refs #7957 vn-searchbar test by:jorgep
|
||||
- fix: refs #8117 update salesPersonFk filter options and URL for improved data retrieval by:jtubau
|
||||
- fix: refs #8197 not use yet by:alexm
|
||||
- fix: refs #8198 update query param by:jorgep
|
||||
- fix: refs #8219 fixed e2e tests by:Jon
|
||||
- fix: refs #8219 fixed summary and global tests by:Jon
|
||||
- fix: refs #8219 forgotten dataCy by:Jon
|
||||
- fix: refs #8219 global e2e by:Jon
|
||||
- fix: refs #8219 requested changes by:Jon
|
||||
- fix: refs #8220 itemTag test by:Javier Segarra
|
||||
- fix: refs #8225 invoice in translations by:Jon
|
||||
- fix: refs #8243 fixed SkeletonSummary by:provira
|
||||
- fix: refs #8247 conflicts by:Jon
|
||||
- fix: refs #8247 fixed acls and added lost options by:Jon
|
||||
- fix: refs #8316 ref="claimFilterRef" by:alexm
|
||||
- fix: refs #8316 userFilter by:alexm
|
||||
- fix: refs #8316 use rightMenu by:alexm
|
||||
- fix: refs #8316 use section-searchbar by:alexm
|
||||
- fix: refs #8317 disable action buttons when no rows are selected in ItemFixedPrice by:jtubau
|
||||
- fix: refs #8322 unnecessary section by:alexm
|
||||
- fix: refs #8338 fixed VnTable translations by:provira
|
||||
- fix: refs #8338 removed chipLocale property/added more translations by:provira
|
||||
- fix: refs #8448 e2e by:Jon
|
||||
- fix: refs #8448 not use croppie by:alexm
|
||||
- fix: remove departmentCode by:Javier Segarra
|
||||
- fix: removed unused searchbar by:PAU ROVIRA ROSALENY
|
||||
- fix: skip failling e2e by:Jon
|
||||
- fix: sort by name in description by:Jon
|
||||
- fix: translations by:Jon
|
||||
- fix: use entryFilter by:alexm
|
||||
- fix(VnCardBeta): add userFilter by:alexm
|
||||
- refactor: refs #8219 modified e2e tests and fixed some translations by:Jon
|
||||
- revert: revert header by:alexm
|
||||
- test: fix expedition e2e by:alexm
|
||||
|
||||
# Version 25.00 - 2025-01-14
|
||||
|
||||
### Added 🆕
|
||||
|
||||
- chore: refs #7056 move test by:jorgep
|
||||
- feat: refs #7050 7050 add object check by:Jtubau
|
||||
- feat: refs #7050 7050 add test to isEmpty() by:Jtubau
|
||||
- feat: refs #7056 add tests in FormModel by:jorgep
|
||||
- feat: refs #7056 update route meta information and add FormModel tests by:jorgep
|
||||
- feat: refs #7074 tests for fns setData(), parseDms() and showFormDialog() (7074-makeFrontTestToVnDmsList) by:Jtubau
|
||||
- feat: refs #7079 created VnLocation front test by:provira
|
||||
- feat: refs #7189 add Accept-Language header to axios requests by:jorgep
|
||||
- feat: refs #7924 add custom inspection checkbox and localization support by:jgallego
|
||||
- feat: refs #7924 update custom inspection label for clarity in English and Spanish locales by:jgallego
|
||||
- feat: refs #8004 enhance FetchedTags component with column support and styling updates by:pablone
|
||||
- feat: refs #8004 hide rightFilter by:pablone
|
||||
- feat: refs #8246 added new field in list by:Jon
|
||||
- feat: refs #8266 added descriptor to item name by:jtubau
|
||||
- feat: refs #8293 add zone filter by:Jtubau
|
||||
- feat: refs #8293 include zone data in each record by:Jtubau
|
||||
- fix: refs #8004 more list style issues by:pablone
|
||||
- fix: refs #8004 some style issues on all list by:pablone
|
||||
- style: refs #8004 update layout and styling in FetchedTags and ItemList components by:pablone
|
||||
- style: update CustomerBalance.vue to set label color by:jgallego
|
||||
|
||||
### Changed 📦
|
||||
|
||||
- perf: order by:alexm
|
||||
- perf: redirect transition list to card by:alexm
|
||||
- perf: refs #8201 onDataSaved fetch by:Jon
|
||||
- perf: revert processData by:alexm
|
||||
- perf: simplify if by:alexm
|
||||
- perf: simplify if (perf_redirectTransition) by:alexm
|
||||
- refactor: item fixedPrice by:Jon
|
||||
- refactor: refs #7050 refactorize by:jtubau
|
||||
- refactor: refs #7050 removed blank spaces by:jtubau
|
||||
- refactor: refs #7052 move EditTableCellValueForm tests to a new location and enhance test coverage by:jgallego
|
||||
- refactor: refs #7052 remove unnecessary console logs from EditTableCellValueForm tests by:jgallego
|
||||
- refactor: refs #7074 move dms constant to global scope by:Jtubau
|
||||
- refactor: refs #7079 removed useless code by:provira
|
||||
- refactor: refs #7924 simplify custom inspection icon rendering in ExtraCommunity.vue by:jgallego
|
||||
- refactor: refs #8004 remove console log from CardSummary component on mount by:pablone
|
||||
- refactor: refs #8004 remove consoleLogs by:pablone
|
||||
- refactor: refs #8004 remove unused stateStore import in InvoiceInList.vue by:pablone
|
||||
- refactor: refs #8004 remove unused travelFilterRef and chip definition in TravelList.vue by:pablone
|
||||
- refactor: refs #8004 replace VnSelect with VnSelectWorker in CustomerList component by:pablone
|
||||
- refactor: refs #8201 added onMounted to stablish the value to show icons by:Jon
|
||||
- refactor: refs #8201 deleted condition by:Jon
|
||||
- refactor: refs #8201 deleted log by:Jon
|
||||
- refactor: refs #8201 deleted logs by:Jon
|
||||
- refactor: refs #8266 8266 change expedition item name by:Jtubau
|
||||
- refactor: refs #8266 change expedition label by:Jtubau
|
||||
- refactor: refs #8293 remove redundant attributes by:Jtubau
|
||||
- refactor: refs #8320 changed folder names from "specs" to "**tests**" by:provira
|
||||
- refactor: refs #8320 moved front tests to their respective sections by:provira
|
||||
- refactor: refs #8813 removed unused class property by:provira
|
||||
|
||||
### Fixed 🛠️
|
||||
|
||||
- fix: discount class by:PAU ROVIRA ROSALENY
|
||||
- fix: duplicate transalation after test to dev by:alexm
|
||||
- fix: fix translations by:carlossa
|
||||
- fix: redirect to sales when confirming lines by:Jon
|
||||
- fix: refs #7050 delete import added by mistake by:Jtubau
|
||||
- fix: refs #7133 handleSalesModelValue function to handle empty input by:jorgep
|
||||
- fix: refs #7189 update user language on sessionStorage by:jorgep
|
||||
- fix: refs #7935 remove unused 'companyFk' column from InvoiceInList component by:jorgep
|
||||
- fix: refs #8004 more list style issues by:pablone
|
||||
- fix: refs #8004 some style issues on all list by:pablone
|
||||
- fix: refs #8004 update label for daysOnward in TravelFilter component and add translations by:pablone
|
||||
- fix: refs #8004 vnTable card with and add permanent labels by:pablone
|
||||
- fix: refs #8201 added onDataSaved emi to refetch when cahnges are made by:Jon
|
||||
- fix: refs #8201 use arrayData to fix the error by:Jon
|
||||
- fix: refs #8314 space between label and value by:jtubau
|
||||
- fix: refs #8813 fixed ClaimLines format by:provira
|
||||
- fix: update button sizes in ExtraCommunity.vue for better visibility by:jgallego
|
||||
- perf: revert processData by:alexm
|
||||
- refactor: item fixedPrice by:Jon
|
||||
|
||||
# Version 24.52 - 2024-01-07
|
||||
|
||||
### Added 🆕
|
||||
|
||||
- chore: refs #8197 remove console log by:alexm
|
||||
- chore: refs #8197 replace name by:alexm
|
||||
- chore: refs #8197 unnecessary file by:alexm
|
||||
- feat: #8110 apply mixin in quasar components by:Javier Segarra
|
||||
- feat(Account & AccountRole): refs #8197 add VnCardMain by:alexm
|
||||
- feat: addDptoLink by:Jtubau
|
||||
- feat: added restore ticket function in ticket descriptor menu by:Jon
|
||||
- feat: add support service wip by:jorgep
|
||||
- feat: focus menu searchbar by:jorgep
|
||||
- feat: make additional data object by:jorgep
|
||||
- feat: message to grant access by:jorgep
|
||||
- feat: refs #6583 add default param by:jorgep
|
||||
- feat: refs #6583 add destination opt filter by:jorgep
|
||||
- feat: refs #6583 add icon by:jorgep
|
||||
- feat: refs #6583 add locale by:jorgep
|
||||
- feat: refs #7072 added test to computed fn total by:Jtubau
|
||||
- feat: refs #7235 update invoice out global form to fetch config based on serial type by:jgallego
|
||||
- feat: refs #7301 add exclude inventory supplier from list by:pablone
|
||||
- feat: refs #7301 enhance VnDateBadge styling and improve ItemLastEntries component by:pablone
|
||||
- feat: refs #7882 Added distribution point by:guillermo
|
||||
- feat: refs #7882 Added longitude & latitude by:guillermo
|
||||
- feat: refs #7936 add autocomplete on tab fn by:jorgep
|
||||
- feat: refs #7936 add company filter by:jorgep
|
||||
- feat: refs #7936 add currency check before fetching by:jorgep
|
||||
- feat: refs #7936 add dueDated field by:jorgep
|
||||
- feat: refs #7936 add number validation to VnInputNumber & new daysAgo filter in InvoiceInFilter by:jorgep
|
||||
- feat: refs #7936 add optionCaption by:jorgep
|
||||
- feat: refs #7936 add row click navigation to InvoiceInSerial by:jorgep
|
||||
- feat: refs #7936 add unit tests by:jorgep
|
||||
- feat: refs #7936 add useAccountShortToStandard composable by:jorgep
|
||||
- feat: refs #7936 calculate exchange & update taxable base by:jorgep
|
||||
- feat: refs #7936 enhance downloadFile function to support opening in a new tab by:jorgep
|
||||
- feat: refs #7936 enhance getTotal fn & add unit tests by:jorgep
|
||||
- feat: refs #7936 enhance vn-select by:jorgep
|
||||
- feat: refs #7936 improve optionLabel logic in InvoiceInVat component for better handling of numeric values by:jorgep
|
||||
- feat: refs #7936 limit decimal places by:jorgep
|
||||
- feat: refs #7936 make fields required by:jorgep
|
||||
- feat: refs #7936 show country code & isVies fields by:jorgep
|
||||
- feat: refs #7936 show id & value by:jorgep
|
||||
- feat: refs #7936 simplify optionLabel wip by:jorgep
|
||||
- feat: refs #7936 update 'isVies' label to use global translation key by:jorgep
|
||||
- feat: refs #7936 update option labels in InvoiceIn components for better clarity by:jorgep
|
||||
- feat: refs #7936 use default invoice data by:jorgep
|
||||
- feat: refs #8001 change request by:robert
|
||||
- feat: refs #8001 ticketExpeditionGrafana by:robert
|
||||
- feat: refs #8194 created VnSelectWorker component and use it in Lilium by:Jon
|
||||
- feat: refs #8197 better leftMenu and VnCardMain improvements by:alexm
|
||||
- feat: refs #8197 default leftMenu by:alexm
|
||||
- feat: refs #8197 default sectionName by:alexm
|
||||
- feat: refs #8197 keepData in VnSection by:alexm
|
||||
- feat: refs #8197 vnTableFilter by:alexm
|
||||
- feat: refs #8197 working rightMenu by:alexm
|
||||
- feat: remove re-fetch when add element by:Javier Segarra
|
||||
- feat: remove search after category by:Javier Segarra
|
||||
- feat: requested changes in item module by:Jon
|
||||
- feat: update quantity by:Javier Segarra
|
||||
- feat(VnPaginate): refs #8197 hold data when change to Card by:alexm
|
||||
|
||||
### Changed 📦
|
||||
|
||||
- perf: #6896 REMOVE COMMENTS by:Javier Segarra
|
||||
- perf: qFormMixin by:Javier Segarra
|
||||
- perf: qFormMixin improvement by:Javier Segarra
|
||||
- perf: refs #8194 select worker component by:Jon
|
||||
- perf: refs #8197 perf by:alexm
|
||||
- perf: remove comments by:Javier Segarra
|
||||
- perf: remove unused variables (origin/warmfix_noUsedVars) by:Javier Segarra
|
||||
- refactor: added again search emit by:Jon
|
||||
- refactor: add useCau composable by:jorgep
|
||||
- refactor: deleted log by:Jon
|
||||
- refactor: deleted onUnmounted code by:Jon
|
||||
- refactor: deleted useless hidden tag by:Jon
|
||||
- refactor: deleted warnings and corrected itemTag by:Jon
|
||||
- refactor: drop logic by:jorgep
|
||||
- refactor: ignore params when searching by id on searchbar (origin/VnSearchbar-SearchRemoveParams) by:Jon
|
||||
- refactor: log error by:Jon
|
||||
- refactor: refs #7936 locale by:jorgep
|
||||
- refactor: refs #7936 simplify getTotal fn by:jorgep
|
||||
- refactor: refs #7936 update label capitalization and replace invoice type options by:jorgep
|
||||
- refactor: refs #8194 deleted unnecessary label by:Jon
|
||||
- refactor: refs #8194 modified select worker template by:Jon
|
||||
- refactor: refs #8194 modified select worker to allow no one filter from monitor ticket by:Jon
|
||||
- refactor: refs #8194 moved translation to the correct place by:Jon
|
||||
- refactor: refs #8194 requested changes by:Jon
|
||||
- refactor: refs #8194 structure changes in component and related files by:Jon
|
||||
- refactor: refs #8197 adapt AccountAcls to VnCardMain by:alexm
|
||||
- refactor: refs #8197 adapt AccountAlias by:alexm
|
||||
- refactor: refs #8197 adapt Ticket to VnCardMain by:alexm
|
||||
- refactor: refs #8197 backward compatible (8197-VnCardMain_backwardCompatibility) by:alexm
|
||||
- refactor: refs #8197 rename VnSectionMain to VnModule and VnCardMain to VnSection by:alexm
|
||||
- refactor: refs #8288 changed invoice out spanish translation by:provira
|
||||
- refactor: use locale keys by:jorgep
|
||||
- refactor: use teleport to avoid qdrawer overlapping by:Jon
|
||||
- refactor: use VnSelectWorker by:Jon
|
||||
|
||||
### Fixed 🛠️
|
||||
|
||||
- fix: account by:carlossa
|
||||
- fix: account create by:carlossa
|
||||
- fix: accountList create by:carlossa
|
||||
- fix(AccountList): use $refs by:alexm
|
||||
- fix: add data-key by:alexm
|
||||
- fix: addLocales by:Jtubau
|
||||
- fix: dated field by:Jon
|
||||
- fix: e2e by:jorgep
|
||||
- fix: fix department filter by:carlossa
|
||||
- fix: fixed translations by:Javier Segarra
|
||||
- fix: fixed translations by:provira
|
||||
- fix: get total from api by:Javier Segarra
|
||||
- fix: handle non-object options by:jorgep
|
||||
- fix: monitorPayMethodFilter by:carlossa
|
||||
- fix: orderBy priority by:Javier Segarra
|
||||
- fix: prevent null by:jorgep
|
||||
- fix: redirection vnTable VnTableFilter by:alexm
|
||||
- fix: refs #6389 fix filter trad by:carlossa
|
||||
- fix: refs #6389 fix front, filters, itp by:carlossa
|
||||
- fix: refs #6389 front add packing filter by:carlossa
|
||||
- fix: refs #6389 front by:carlossa
|
||||
- fix: refs #6389 front filters by:carlossa
|
||||
- fix: refs #6389 ipt by:carlossa
|
||||
- fix: refs #6389 packing by:carlossa
|
||||
- fix: refs #6583 update checkbox for filtering by destination in TicketAdvanceFilter by:jorgep
|
||||
- fix: refs #7031 add test e2e by:carlossa
|
||||
- fix: refs #7031 fix zoneTest by:carlossa
|
||||
- fix: refs #7301 unnecessary console logs from ItemLastEntries.vue by:pablone
|
||||
- fix: refs #7936 changes by:jorgep
|
||||
- fix: refs #7936 decimal places & locale by:jorgep
|
||||
- fix: refs #7936 descriptor & dueday by:jorgep
|
||||
- fix: refs #7936 exclude disabled els on tab by:jorgep
|
||||
- fix: refs #7936 format tax calculation to two decimal places by:jorgep
|
||||
- fix: refs #7936 improve error handling by:jorgep
|
||||
- fix: refs #7936 redirection by:jorgep
|
||||
- fix: refs #7936 rollback by:jorgep
|
||||
- fix: refs #7936 serial by:jorgep
|
||||
- fix: refs #7936 tabulation wip by:jorgep
|
||||
- fix: refs #7936 test by:jorgep
|
||||
- fix: refs #8114 clean by:carlossa
|
||||
- fix: refs #8114 fix agencyList by:carlossa
|
||||
- fix: refs #8114 fix lifeCycle hooks by:carlossa
|
||||
- fix: refs #8114 fix pr by:carlossa
|
||||
- fix: refs #8114 fix removeAddress by:carlossa
|
||||
- fix: refs #8114 orderList by:carlossa
|
||||
- fix: refs #8114 remove logs by:carlossa
|
||||
- fix: refs #8197 mapKey (origin/8197-perf_vnTableInside, 8197-perf_vnTableInside) by:alexm
|
||||
- fix: refs #8197 redirection (8197-perf_redirection) by:alexm
|
||||
- fix: refs #8197 staticParams and redirect by:alexm
|
||||
- fix: refs #8197 vnPaginate onFetch emit by:alexm
|
||||
- fix: refs #8197 vnPaginate when change :id by:alexm
|
||||
- fix: refs #8197 vnTableFilter in vnTable by:alexm
|
||||
- fix: refs #8315 ticketBoxing test by:alexm
|
||||
- fix: remove url by:carlossa
|
||||
- fix: rollback by:jorgep
|
||||
- fix: test by:jorgep
|
||||
- fix(VnDmsList): refs #8197 add mapKey by:alexm
|
||||
- revert: refs #8197 arrayData changes by:alexm
|
||||
- test: refs #8197 fix e2e by:alexm
|
||||
- test: refs #8315 fix claimDevelopment fixtures by:alexm
|
||||
- test: refs #8315 fix clientList by:alexm
|
||||
- test: refs #8315 fix VnSelect in e2e by:alexm
|
||||
|
||||
# Version 24.50 - 2024-12-10
|
||||
|
||||
### Added 🆕
|
||||
|
||||
- feat: add reportFileName option by:Javier Segarra
|
||||
- feat: all clients just with global series by:jgallego
|
||||
- feat: improve Merge branch 'test' into dev by:Javier Segarra
|
||||
- feat: manual invoice in two lines by:jgallego
|
||||
- feat: manualInvoice with address by:jgallego
|
||||
- feat: randomize functions and example by:Javier Segarra
|
||||
- feat: refs #6999 added search when user tabs on a filter with value by:Jon
|
||||
- feat: refs #6999 added tab to search in VnTable filter by:Jon
|
||||
- feat: refs #7346 #7346 improve form by:Javier Segarra
|
||||
- feat: refs #7346 address ordered by:jgallego
|
||||
- feat: refs #7346 radioButton by:jgallego
|
||||
- feat: refs #7346 style radioButton by:jgallego
|
||||
- feat: refs #7346 traducciones en cammelCase (7346-manualInvoice) by:jgallego
|
||||
- feat: refs #8038 added new functionality in VnSelect and refactor styles by:Jon
|
||||
- feat: refs #8061 #8061 updates by:Javier Segarra
|
||||
- feat: refs #8087 reactive data by:jorgep
|
||||
- feat: refs #8087 refs#8087 Redadas en travel by:Carlos Andrés
|
||||
- feat: refs #8138 add component ticket problems by:pablone
|
||||
- feat: refs #8163 add max length and more tests by:wbuezas
|
||||
- feat: refs #8163 add prop by:wbuezas
|
||||
- feat: refs #8163 add VnInput insert functionality and e2e test by:wbuezas
|
||||
- feat: refs #8163 limit with maxLength by:Javier Segarra
|
||||
- feat: refs #8163 maxLength SupplierFD account by:Javier Segarra
|
||||
- feat: refs #8163 maxLengthVnInput by:Javier Segarra
|
||||
- feat: refs #8163 use VnAccountNumber in VnAccountNumber by:Javier Segarra
|
||||
- feat: refs #8166 show notification by:jorgep
|
||||
|
||||
### Changed 📦
|
||||
|
||||
- feat: refs #8038 added new functionality in VnSelect and refactor styles by:Jon
|
||||
- perf: add dataCy by:Javier Segarra
|
||||
- perf: refs #7346 #7346 Imrpove interface dialog by:Javier Segarra
|
||||
- perf: refs #7346 #7346 use v-show instead v-if by:Javier Segarra
|
||||
- perf: refs #8036 currentFilter by:alexm
|
||||
- perf: refs #8061 filter autonomy by:Javier Segarra
|
||||
- perf: refs #8061 solve conflicts and random posCode it by:Javier Segarra
|
||||
- perf: refs #8061 use opts from VnSelect by:Javier Segarra
|
||||
- perf: refs #8163 #8061 createNewPostCodeForm by:Javier Segarra
|
||||
- perf: remove console by:Javier Segarra
|
||||
- perf: remove timeout by:Javier Segarra
|
||||
- perf: test command fillInForm by:Javier Segarra
|
||||
- refactor: refs #8162 remove comment by:wbuezas
|
||||
- refactor: remove unnecesary things by:wbuezas
|
||||
|
||||
### Fixed 🛠️
|
||||
|
||||
- fix: #8016 fetching data by:Javier Segarra
|
||||
- fix: icons by:jgallego
|
||||
- fix: refs #7229 download file by:jorgep
|
||||
- fix: refs #7229 remove catch by:jorgep
|
||||
- fix: refs #7229 set url by:jorgep
|
||||
- fix: refs #7229 test by:jorgep
|
||||
- fix: refs #7229 url by:jorgep
|
||||
- fix: refs #7229 url + test by:jorgep
|
||||
- fix: refs #7304 7304 clean warning by:carlossa
|
||||
- fix: refs #7304 fix list by:carlossa
|
||||
- fix: refs #7304 fix warning by:carlossa
|
||||
- fix: refs #7346 traslations by:jgallego
|
||||
- fix: refs #7529 add save by:carlossa
|
||||
- fix: refs #7529 fix e2e by:carlossa
|
||||
- fix: refs #7529 fix front by:carlossa
|
||||
- fix: refs #7529 fix scss by:carlossa
|
||||
- fix: refs #7529 fix te2e by:carlossa
|
||||
- fix: refs #7529 fix workerPit e2e by:carlossa
|
||||
- fix: refs #7529 front by:carlossa
|
||||
- fix: refs #8036 apply exprBuilder after save filters by:alexm
|
||||
- fix: refs #8036 only add where when required by:alexm
|
||||
- fix: refs #8038 solve conflicts by:Jon
|
||||
- fix: refs #8061 improve code dependencies (origin/8061_improve_newCP) by:Javier Segarra
|
||||
- fix: refs #8138 move component from ui folder by:pablone
|
||||
- fix: refs #8138 sme minor issues by:pablone
|
||||
- fix: refs #8163 #8061 createNewPostCodeForm by:Javier Segarra
|
||||
- fix: refs #8163 minor problem when keypress by:Javier Segarra
|
||||
- fix: refs #8166 show zone error by:jorgep
|
||||
- fix: removed selectedClient by:jgallego
|
||||
- refs #7529 fix workerPit by:carlossa
|
||||
- revert: refs #8061 test #8061 updates by:Javier Segarra
|
||||
- test: fix own test by:Javier Segarra
|
||||
- test: refs #8162 #8162 fix TicketList spec by:Javier Segarra
|
||||
|
||||
# Version 24.48 - 2024-11-25
|
||||
|
||||
### Added 🆕
|
||||
|
|
|
@ -4,8 +4,7 @@ def PROTECTED_BRANCH
|
|||
|
||||
def BRANCH_ENV = [
|
||||
test: 'test',
|
||||
master: 'production',
|
||||
beta: 'production'
|
||||
master: 'production'
|
||||
]
|
||||
|
||||
node {
|
||||
|
@ -16,8 +15,7 @@ node {
|
|||
PROTECTED_BRANCH = [
|
||||
'dev',
|
||||
'test',
|
||||
'master',
|
||||
'beta'
|
||||
'master'
|
||||
].contains(env.BRANCH_NAME)
|
||||
|
||||
// https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default { extends: ['@commitlint/config-conventional'] };
|
||||
module.exports = { extends: ['@commitlint/config-conventional'] };
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { defineConfig } from 'cypress';
|
||||
const { defineConfig } = require('cypress');
|
||||
// https://docs.cypress.io/app/tooling/reporters
|
||||
// https://docs.cypress.io/app/references/configuration
|
||||
// https://www.npmjs.com/package/cypress-mochawesome-reporter
|
||||
|
||||
export default defineConfig({
|
||||
module.exports = defineConfig({
|
||||
e2e: {
|
||||
baseUrl: 'http://localhost:9000/',
|
||||
experimentalStudio: true,
|
||||
|
@ -11,7 +11,6 @@ export default defineConfig({
|
|||
screenshotsFolder: 'test/cypress/screenshots',
|
||||
supportFile: 'test/cypress/support/index.js',
|
||||
videosFolder: 'test/cypress/videos',
|
||||
downloadsFolder: 'test/cypress/downloads',
|
||||
video: false,
|
||||
specPattern: 'test/cypress/integration/**/*.spec.js',
|
||||
experimentalRunAllSpecs: true,
|
||||
|
@ -30,13 +29,9 @@ export default defineConfig({
|
|||
testFiles: '**/*.spec.js',
|
||||
supportFile: 'test/cypress/support/unit.js',
|
||||
},
|
||||
setupNodeEvents: async (on, config) => {
|
||||
const plugin = await import('cypress-mochawesome-reporter/plugin');
|
||||
plugin.default(on);
|
||||
|
||||
return config;
|
||||
setupNodeEvents(on, config) {
|
||||
require('cypress-mochawesome-reporter/plugin')(on);
|
||||
// implement node event listeners here
|
||||
},
|
||||
viewportWidth: 1280,
|
||||
viewportHeight: 720,
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
import { defineConfig } from 'vitepress';
|
||||
|
||||
// https://vitepress.dev/reference/site-config
|
||||
export default defineConfig({
|
||||
title: 'Lilium',
|
||||
description: 'Lilium docs',
|
||||
themeConfig: {
|
||||
// https://vitepress.dev/reference/default-theme-config
|
||||
nav: [
|
||||
{ text: 'Home', link: '/' },
|
||||
{ text: 'Components', link: '/components/vnInput' },
|
||||
{ text: 'Composables', link: '/composables/useArrayData' },
|
||||
],
|
||||
|
||||
sidebar: [
|
||||
{
|
||||
items: [
|
||||
{
|
||||
text: 'Components',
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [{ text: 'VnInput', link: '/components/vnInput' }],
|
||||
},
|
||||
{
|
||||
text: 'Composables',
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: 'useArrayData', link: '/composables/useArrayData' },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
socialLinks: [{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }],
|
||||
},
|
||||
});
|
|
@ -1,136 +0,0 @@
|
|||
# VnInput
|
||||
|
||||
`VnInput` is a custom input component that provides various useful features such as validation, input clearing, and more.
|
||||
|
||||
## Props
|
||||
|
||||
### `modelValue`
|
||||
|
||||
- **Type:** `String | Number`
|
||||
- **Default:** `null`
|
||||
- **Description:** The value of the model bound to the component.
|
||||
|
||||
### `isOutlined`
|
||||
|
||||
- **Type:** `Boolean`
|
||||
- **Default:** `false`
|
||||
- **Description:** If `true`, the component is rendered with an outlined style.
|
||||
|
||||
### `info`
|
||||
|
||||
- **Type:** `String`
|
||||
- **Default:** `''`
|
||||
- **Description:** Additional information displayed alongside the component.
|
||||
|
||||
### `clearable`
|
||||
|
||||
- **Type:** `Boolean`
|
||||
- **Default:** `true`
|
||||
- **Description:** If `true`, the component shows a button to clear the input.
|
||||
|
||||
### `emptyToNull`
|
||||
|
||||
- **Type:** `Boolean`
|
||||
- **Default:** `true`
|
||||
- **Description:** If `true`, converts empty inputs to `null`.
|
||||
|
||||
### `insertable`
|
||||
|
||||
- **Type:** `Boolean`
|
||||
- **Default:** `false`
|
||||
- **Description:** If `true`, allows the insertion of new values.
|
||||
|
||||
### `maxlength`
|
||||
|
||||
- **Type:** `Number`
|
||||
- **Default:** `null`
|
||||
- **Description:** The maximum number of characters allowed in the input.
|
||||
|
||||
### `uppercase`
|
||||
|
||||
- **Type:** `Boolean`
|
||||
- **Default:** `false`
|
||||
- **Description:** If `true`, converts the input text to uppercase.
|
||||
|
||||
## Emits
|
||||
|
||||
### `update:modelValue`
|
||||
|
||||
- **Description:** Emits the updated model value.
|
||||
- **Behavior:** This event is emitted whenever the input value changes. It is used to update the model value bound to the component.
|
||||
|
||||
### `update:options`
|
||||
|
||||
- **Description:** Emits the updated options.
|
||||
- **Behavior:** This event is emitted when the component's options change. It is useful for components with dynamic options.
|
||||
|
||||
### `keyup.enter`
|
||||
|
||||
- **Description:** Emits an event when the Enter key is pressed.
|
||||
- **Behavior:** This event is emitted whenever the Enter key is pressed while the input is focused. It can be used to handle specific actions when the input is confirmed.
|
||||
|
||||
### `remove`
|
||||
|
||||
- **Description:** Emits an event to remove the current value.
|
||||
- **Behavior:** This event is emitted when the clear button (close icon) is clicked. It is used to handle the removal of the current input value.
|
||||
|
||||
## Functions
|
||||
|
||||
### `focus`
|
||||
|
||||
- **Description:** Focuses the input.
|
||||
- **Behavior:** This function is exposed so it can be called from outside the component. It uses `vnInputRef.value.focus()` to focus the input.
|
||||
|
||||
### `handleKeydown`
|
||||
|
||||
- **Description:** Handles the `keydown` event of the input.
|
||||
- **Behavior:** This function is called whenever a key is pressed while the input is focused. If the pressed key is `Backspace`, it does nothing. If `insertable` is `true` and the pressed key is a number, it calls `handleInsertMode`.
|
||||
|
||||
### `handleInsertMode`
|
||||
|
||||
- **Description:** Handles the insertion mode of values.
|
||||
- **Behavior:** This function is called when `insertable` is `true` and a numeric key is pressed. It inserts the value at the cursor position and updates the input value. Then, it moves the cursor to the correct position.
|
||||
|
||||
### `handleUppercase`
|
||||
|
||||
- **Description:** Converts the input value to uppercase.
|
||||
- **Behavior:** This function is called when the uppercase icon is clicked. It converts the current input value to uppercase.
|
||||
|
||||
## Usage
|
||||
|
||||
```vue
|
||||
<template>
|
||||
<VnInput
|
||||
v-model="inputValue"
|
||||
:isOutlined="true"
|
||||
info="Additional information"
|
||||
:clearable="true"
|
||||
:emptyToNull="true"
|
||||
:insertable="false"
|
||||
:maxlength="50"
|
||||
:uppercase="true"
|
||||
@update:modelValue="handleUpdate"
|
||||
@keyup.enter="handleEnter"
|
||||
@remove="handleRemove"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
||||
const inputValue = ref('');
|
||||
|
||||
const handleUpdate = (value) => {
|
||||
console.log('Updated value:', value);
|
||||
};
|
||||
|
||||
const handleEnter = () => {
|
||||
console.log('Enter pressed');
|
||||
};
|
||||
|
||||
const handleRemove = () => {
|
||||
console.log('Value removed');
|
||||
};
|
||||
</script>
|
||||
```
|
|
@ -1,215 +0,0 @@
|
|||
# useArrayData
|
||||
|
||||
`useArrayData` is a composable function that provides a set of utilities for managing array data in a Vue component. It leverages Pinia for state management and provides various methods for fetching, filtering, and manipulating data.
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
|
||||
const {
|
||||
fetch,
|
||||
applyFilter,
|
||||
addFilter,
|
||||
getCurrentFilter,
|
||||
setCurrentFilter,
|
||||
addFilterWhere,
|
||||
addOrder,
|
||||
deleteOrder,
|
||||
refresh,
|
||||
destroy,
|
||||
loadMore,
|
||||
store,
|
||||
totalRows,
|
||||
updateStateParams,
|
||||
isLoading,
|
||||
deleteOption,
|
||||
reset,
|
||||
resetPagination,
|
||||
} = useArrayData('myKey', userOptions);
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### `key`
|
||||
|
||||
- **Type:** `String`
|
||||
- **Description:** A unique key to identify the data store.
|
||||
|
||||
### `userOptions`
|
||||
|
||||
- **Type:** `Object`
|
||||
- **Description:** An object containing user-defined options for configuring the data store.
|
||||
|
||||
## Methods
|
||||
|
||||
### `fetch`
|
||||
|
||||
Fetches data from the server.
|
||||
|
||||
#### Parameters
|
||||
|
||||
- **`options`** : An object with the following properties:
|
||||
- `append` (Boolean): Whether to append the fetched data to the existing data.
|
||||
- `updateRouter` (Boolean): Whether to update the router with the current filter.
|
||||
|
||||
#### Returns
|
||||
|
||||
- **`Promise`** : A promise that resolves with the fetched data.
|
||||
|
||||
### `applyFilter`
|
||||
|
||||
Applies a filter to the data.
|
||||
|
||||
#### Parameters
|
||||
|
||||
- **`filter`** : An object containing the filter criteria.
|
||||
- **`params`** : Additional parameters for the filter.
|
||||
- **`fetchOptions`** : Options for the fetch method.
|
||||
|
||||
#### Returns
|
||||
|
||||
- **`Promise`** : A promise that resolves with the filtered data.
|
||||
|
||||
### `addFilter`
|
||||
|
||||
Adds a filter to the existing filters.
|
||||
|
||||
#### Parameters
|
||||
|
||||
- **`filter`** : An object containing the filter criteria.
|
||||
- **`params`** : Additional parameters for the filter.
|
||||
|
||||
#### Returns
|
||||
|
||||
- **`Promise`** : A promise that resolves with the updated filter and parameters.
|
||||
|
||||
### `getCurrentFilter`
|
||||
|
||||
Gets the current filter applied to the data.
|
||||
|
||||
#### Returns
|
||||
|
||||
- **`Object`** : The current filter and parameters.
|
||||
|
||||
### `setCurrentFilter`
|
||||
|
||||
Sets the current filter for the data.
|
||||
|
||||
#### Returns
|
||||
|
||||
- **`Object`** : The current filter and parameters.
|
||||
|
||||
### `addFilterWhere`
|
||||
|
||||
Adds a `where` clause to the existing filters.
|
||||
|
||||
#### Parameters
|
||||
|
||||
- **`where`** : An object containing the `where` clause.
|
||||
|
||||
#### Returns
|
||||
|
||||
- **`Promise`** : A promise that resolves when the filter is applied.
|
||||
|
||||
### `addOrder`
|
||||
|
||||
Adds an order to the existing orders.
|
||||
|
||||
#### Parameters
|
||||
|
||||
- **`field`** : The field to order by.
|
||||
- **`direction`** : The direction of the order (`ASC` or `DESC`).
|
||||
|
||||
#### Returns
|
||||
|
||||
- **`Promise`** : A promise that resolves with the updated order.
|
||||
|
||||
### `deleteOrder`
|
||||
|
||||
Deletes an order from the existing orders.
|
||||
|
||||
#### Parameters
|
||||
|
||||
- **`field`** : The field to delete the order for.
|
||||
|
||||
#### Returns
|
||||
|
||||
- **`Promise`** : A promise that resolves when the order is deleted.
|
||||
|
||||
### `refresh`
|
||||
|
||||
Refreshes the data by re-fetching it from the server.
|
||||
|
||||
#### Returns
|
||||
|
||||
- **`Promise`** : A promise that resolves with the refreshed data.
|
||||
|
||||
### `destroy`
|
||||
|
||||
Destroys the data store for the given key.
|
||||
|
||||
### `loadMore`
|
||||
|
||||
Loads more data by incrementing the pagination.
|
||||
|
||||
#### Returns
|
||||
|
||||
- **`Promise`** : A promise that resolves with the additional data.
|
||||
|
||||
### `updateStateParams`
|
||||
|
||||
Updates the state parameters with the given data.
|
||||
|
||||
#### Parameters
|
||||
|
||||
- **`data`** : The data to update the state parameters with.
|
||||
|
||||
### `deleteOption`
|
||||
|
||||
Deletes an option from the store.
|
||||
|
||||
#### Parameters
|
||||
|
||||
- **`option`** : The option to delete.
|
||||
|
||||
### `reset`
|
||||
|
||||
Resets the store to its default state.
|
||||
|
||||
#### Parameters
|
||||
|
||||
- **`opts`** : An array of options to reset.
|
||||
|
||||
### `resetPagination`
|
||||
|
||||
Resets the pagination for the store.
|
||||
|
||||
## Computed Properties
|
||||
|
||||
### `totalRows`
|
||||
|
||||
- **Description:** The total number of rows in the data.
|
||||
- **Type:** `Number`
|
||||
|
||||
### `isLoading`
|
||||
|
||||
- **Description:** Whether the data is currently being loaded.
|
||||
- **Type:** `Boolean`
|
||||
|
||||
```vue
|
||||
<script setup>
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
|
||||
const userOptions = {
|
||||
url: '/api/data',
|
||||
limit: 10,
|
||||
};
|
||||
|
||||
const arrayData = useArrayData('myKey', userOptions);
|
||||
</script>
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
```
|
|
@ -1,13 +0,0 @@
|
|||
---
|
||||
# https://vitepress.dev/reference/default-theme-home-page
|
||||
layout: home
|
||||
|
||||
hero:
|
||||
name: 'Lilium'
|
||||
text: 'Lilium docs'
|
||||
tagline: Powered by Verdnatura
|
||||
actions:
|
||||
- theme: brand
|
||||
text: Docs
|
||||
link: /components/vnInput
|
||||
---
|
137
package.json
137
package.json
|
@ -1,74 +1,67 @@
|
|||
{
|
||||
"name": "salix-front",
|
||||
"version": "25.06.0",
|
||||
"description": "Salix frontend",
|
||||
"productName": "Salix",
|
||||
"author": "Verdnatura",
|
||||
"private": true,
|
||||
"packageManager": "pnpm@8.15.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"resetDatabase": "cd ../salix && gulp docker",
|
||||
"lint": "eslint --ext .js,.vue ./",
|
||||
"format": "prettier --write \"**/*.{js,vue,scss,html,md,json}\" --ignore-path .gitignore",
|
||||
"test:e2e": "cypress open",
|
||||
"test:e2e:ci": "npm run resetDatabase && cd ../salix-front && cypress run",
|
||||
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
|
||||
"test:unit": "vitest",
|
||||
"test:unit:ci": "vitest run",
|
||||
"commitlint": "commitlint --edit",
|
||||
"prepare": "npx husky install",
|
||||
"addReferenceTag": "node .husky/addReferenceTag.js",
|
||||
"docs:dev": "vitepress dev docs",
|
||||
"docs:build": "vitepress build docs",
|
||||
"docs:preview": "vitepress preview docs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@quasar/cli": "^2.4.1",
|
||||
"@quasar/extras": "^1.16.16",
|
||||
"axios": "^1.4.0",
|
||||
"chromium": "^3.0.3",
|
||||
"croppie": "^2.6.5",
|
||||
"moment": "^2.30.1",
|
||||
"pinia": "^2.1.3",
|
||||
"quasar": "^2.17.7",
|
||||
"validator": "^13.9.0",
|
||||
"vue": "^3.5.13",
|
||||
"vue-i18n": "^9.3.0",
|
||||
"vue-router": "^4.2.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^19.2.1",
|
||||
"@commitlint/config-conventional": "^19.1.0",
|
||||
"@intlify/unplugin-vue-i18n": "^0.8.2",
|
||||
"@pinia/testing": "^0.1.2",
|
||||
"@quasar/app-vite": "^2.0.8",
|
||||
"@quasar/quasar-app-extension-qcalendar": "^4.0.2",
|
||||
"@quasar/quasar-app-extension-testing-unit-vitest": "^0.4.0",
|
||||
"@vue/test-utils": "^2.4.4",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"cypress": "^13.6.6",
|
||||
"cypress-mochawesome-reporter": "^3.8.2",
|
||||
"eslint": "^9.18.0",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
"eslint-plugin-cypress": "^4.1.0",
|
||||
"eslint-plugin-vue": "^9.32.0",
|
||||
"husky": "^8.0.0",
|
||||
"postcss": "^8.4.23",
|
||||
"prettier": "^3.4.2",
|
||||
"sass": "^1.83.4",
|
||||
"vitepress": "^1.6.3",
|
||||
"vitest": "^0.34.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20 || ^18 || ^16",
|
||||
"npm": ">= 8.1.2",
|
||||
"yarn": ">= 1.21.1",
|
||||
"bun": ">= 1.0.25"
|
||||
},
|
||||
"overrides": {
|
||||
"@vitejs/plugin-vue": "^5.2.1",
|
||||
"vite": "^6.0.11",
|
||||
"vitest": "^0.31.1"
|
||||
}
|
||||
"name": "salix-front",
|
||||
"version": "24.50.0",
|
||||
"description": "Salix frontend",
|
||||
"productName": "Salix",
|
||||
"author": "Verdnatura",
|
||||
"private": true,
|
||||
"packageManager": "pnpm@8.15.1",
|
||||
"scripts": {
|
||||
"resetDatabase": "cd ../salix && gulp docker",
|
||||
"lint": "eslint --ext .js,.vue ./",
|
||||
"format": "prettier --write \"**/*.{js,vue,scss,html,md,json}\" --ignore-path .gitignore",
|
||||
"test:e2e": "cypress open",
|
||||
"test:e2e:ci": "npm run resetDatabase && cd ../salix-front && cypress run",
|
||||
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
|
||||
"test:unit": "vitest",
|
||||
"test:unit:ci": "vitest run",
|
||||
"commitlint": "commitlint --edit",
|
||||
"prepare": "npx husky install",
|
||||
"addReferenceTag": "node .husky/addReferenceTag.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@quasar/cli": "^2.3.0",
|
||||
"@quasar/extras": "^1.16.9",
|
||||
"axios": "^1.4.0",
|
||||
"chromium": "^3.0.3",
|
||||
"croppie": "^2.6.5",
|
||||
"pinia": "^2.1.3",
|
||||
"quasar": "^2.14.5",
|
||||
"validator": "^13.9.0",
|
||||
"vue": "^3.3.4",
|
||||
"vue-i18n": "^9.2.2",
|
||||
"vue-router": "^4.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^19.2.1",
|
||||
"@commitlint/config-conventional": "^19.1.0",
|
||||
"@intlify/unplugin-vue-i18n": "^0.8.1",
|
||||
"@pinia/testing": "^0.1.2",
|
||||
"@quasar/app-vite": "^1.7.3",
|
||||
"@quasar/quasar-app-extension-qcalendar": "4.0.0-beta.15",
|
||||
"@quasar/quasar-app-extension-testing-unit-vitest": "^0.4.0",
|
||||
"@vue/test-utils": "^2.4.4",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"cypress": "^13.6.6",
|
||||
"cypress-mochawesome-reporter": "^3.8.2",
|
||||
"eslint": "^8.41.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-plugin-cypress": "^2.13.3",
|
||||
"eslint-plugin-vue": "^9.14.1",
|
||||
"husky": "^8.0.0",
|
||||
"postcss": "^8.4.23",
|
||||
"prettier": "^2.8.8",
|
||||
"vitest": "^0.31.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20 || ^18 || ^16",
|
||||
"npm": ">= 8.1.2",
|
||||
"yarn": ">= 1.21.1",
|
||||
"bun": ">= 1.0.25"
|
||||
},
|
||||
"overrides": {
|
||||
"@vitejs/plugin-vue": "^5.0.4",
|
||||
"vite": "^5.1.4",
|
||||
"vitest": "^0.31.1"
|
||||
}
|
||||
}
|
4784
pnpm-lock.yaml
4784
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -1,14 +1,10 @@
|
|||
/* eslint-disable */
|
||||
// https://github.com/michael-ciniawsky/postcss-load-config
|
||||
|
||||
import autoprefixer from 'autoprefixer';
|
||||
// Uncomment the following line if you want to support RTL CSS
|
||||
// import rtlcss from 'postcss-rtlcss';
|
||||
|
||||
export default {
|
||||
module.exports = {
|
||||
plugins: [
|
||||
// https://github.com/postcss/autoprefixer
|
||||
autoprefixer({
|
||||
require('autoprefixer')({
|
||||
overrideBrowserslist: [
|
||||
'last 4 Chrome versions',
|
||||
'last 4 Firefox versions',
|
||||
|
@ -22,7 +18,10 @@ export default {
|
|||
}),
|
||||
|
||||
// https://github.com/elchininet/postcss-rtlcss
|
||||
// If you want to support RTL CSS, uncomment the following line:
|
||||
// rtlcss(),
|
||||
// If you want to support RTL css, then
|
||||
// 1. yarn/npm install postcss-rtlcss
|
||||
// 2. optionally set quasar.config.js > framework > lang to an RTL language
|
||||
// 3. uncomment the following line:
|
||||
// require('postcss-rtlcss')
|
||||
],
|
||||
};
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
export default [
|
||||
{
|
||||
path: '/api',
|
||||
rule: { target: 'http://0.0.0.0:3000' },
|
||||
},
|
||||
];
|
|
@ -8,11 +8,11 @@
|
|||
// Configuration for your app
|
||||
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js
|
||||
|
||||
import { configure } from 'quasar/wrappers';
|
||||
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
|
||||
import path from 'path';
|
||||
const { configure } = require('quasar/wrappers');
|
||||
const VueI18nPlugin = require('@intlify/unplugin-vue-i18n/vite');
|
||||
const path = require('path');
|
||||
|
||||
export default configure(function (/* ctx */) {
|
||||
module.exports = configure(function (/* ctx */) {
|
||||
return {
|
||||
eslint: {
|
||||
// fix: true,
|
||||
|
@ -179,6 +179,7 @@ export default configure(function (/* ctx */) {
|
|||
'render', // keep this as last one
|
||||
],
|
||||
},
|
||||
|
||||
// https://v2.quasar.dev/quasar-cli/developing-pwa/configuring-pwa
|
||||
pwa: {
|
||||
workboxMode: 'generateSW', // or 'injectManifest'
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
{
|
||||
"@quasar/testing-unit-vitest": {
|
||||
"options": [
|
||||
"scripts"
|
||||
]
|
||||
"options": ["scripts"]
|
||||
},
|
||||
"@quasar/qcalendar": {}
|
||||
}
|
||||
|
|
|
@ -3,20 +3,19 @@ import { useSession } from 'src/composables/useSession';
|
|||
import { Router } from 'src/router';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import { useStateQueryStore } from 'src/stores/useStateQueryStore';
|
||||
import { getToken, isLoggedIn } from 'src/utils/session';
|
||||
import { i18n } from 'src/boot/i18n';
|
||||
|
||||
const session = useSession();
|
||||
const { notify } = useNotify();
|
||||
const stateQuery = useStateQueryStore();
|
||||
const baseUrl = '/api/';
|
||||
|
||||
axios.defaults.baseURL = baseUrl;
|
||||
const axiosNoError = axios.create({ baseURL: baseUrl });
|
||||
|
||||
const onRequest = (config) => {
|
||||
const token = getToken();
|
||||
const token = session.getToken();
|
||||
if (token.length && !config.headers.Authorization) {
|
||||
config.headers.Authorization = token;
|
||||
config.headers['Accept-Language'] = i18n.global.locale.value;
|
||||
}
|
||||
stateQuery.add(config);
|
||||
return config;
|
||||
|
@ -37,15 +36,15 @@ const onResponse = (response) => {
|
|||
return response;
|
||||
};
|
||||
|
||||
const onResponseError = async (error) => {
|
||||
const onResponseError = (error) => {
|
||||
stateQuery.remove(error.config);
|
||||
|
||||
if (isLoggedIn() && error.response?.status === 401) {
|
||||
await useSession().destroy(false);
|
||||
if (session.isLoggedIn() && error.response?.status === 401) {
|
||||
session.destroy(false);
|
||||
const hash = window.location.hash;
|
||||
const url = hash.slice(1);
|
||||
Router.push(`/login?redirect=${url}`);
|
||||
} else if (!isLoggedIn()) {
|
||||
} else if (!session.isLoggedIn()) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import { boot } from 'quasar/wrappers';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import messages from 'src/i18n';
|
||||
import { useState } from 'src/composables/useState';
|
||||
const user = useState().getUser();
|
||||
|
||||
const i18n = createI18n({
|
||||
locale: user.value.lang || navigator.language || navigator.userLanguage,
|
||||
locale: navigator.language || navigator.userLanguage,
|
||||
fallbackLocale: 'en',
|
||||
globalInjection: true,
|
||||
messages,
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
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;
|
||||
if (!ctrlKey || !altKey) {
|
||||
isNotified = false;
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('keydown', handleKeyDown);
|
||||
window.addEventListener('keyup', handleKeyUp);
|
||||
},
|
||||
};
|
|
@ -1,51 +1,30 @@
|
|||
function focusFirstInput(input) {
|
||||
input.focus();
|
||||
}
|
||||
import { getCurrentInstance } from 'vue';
|
||||
|
||||
export default {
|
||||
mounted: function () {
|
||||
const that = this;
|
||||
|
||||
const form = document.querySelector('.q-form#formModel');
|
||||
if (!form) return;
|
||||
try {
|
||||
const inputsFormCard = form.querySelectorAll(
|
||||
`input:not([disabled]):not([type="checkbox"])`
|
||||
);
|
||||
if (inputsFormCard.length) {
|
||||
focusFirstInput(inputsFormCard[0]);
|
||||
const vm = getCurrentInstance();
|
||||
if (vm.type.name === 'QForm') {
|
||||
if (!['searchbarForm', 'filterPanelForm'].includes(this.$el?.id)) {
|
||||
// TODO: AUTOFOCUS IS NOT FOCUSING
|
||||
const that = this;
|
||||
this.$el.addEventListener('keyup', function (evt) {
|
||||
if (evt.key === 'Enter') {
|
||||
const input = evt.target;
|
||||
if (input.type == 'textarea' && evt.shiftKey) {
|
||||
evt.preventDefault();
|
||||
let { selectionStart, selectionEnd } = input;
|
||||
input.value =
|
||||
input.value.substring(0, selectionStart) +
|
||||
'\n' +
|
||||
input.value.substring(selectionEnd);
|
||||
selectionStart = selectionEnd = selectionStart + 1;
|
||||
return;
|
||||
}
|
||||
evt.preventDefault();
|
||||
that.onSubmit();
|
||||
}
|
||||
});
|
||||
}
|
||||
const textareas = document.querySelectorAll(
|
||||
'textarea:not([disabled]), [contenteditable]:not([disabled])'
|
||||
);
|
||||
if (textareas.length) {
|
||||
focusFirstInput(textareas[textareas.length - 1]);
|
||||
}
|
||||
const inputs = document.querySelectorAll(
|
||||
'form#formModel input:not([disabled]):not([type="checkbox"])'
|
||||
);
|
||||
const input = inputs[0];
|
||||
if (!input) return;
|
||||
|
||||
focusFirstInput(input);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
form.addEventListener('keyup', function (evt) {
|
||||
if (evt.key === 'Enter' && !that.$attrs['prevent-submit']) {
|
||||
const input = evt.target;
|
||||
if (input.type == 'textarea' && evt.shiftKey) {
|
||||
evt.preventDefault();
|
||||
let { selectionStart, selectionEnd } = input;
|
||||
input.value =
|
||||
input.value.substring(0, selectionStart) +
|
||||
'\n' +
|
||||
input.value.substring(selectionEnd);
|
||||
selectionStart = selectionEnd = selectionStart + 1;
|
||||
return;
|
||||
}
|
||||
evt.preventDefault();
|
||||
that.onSubmit();
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
import axios from 'axios';
|
||||
import { boot } from 'quasar/wrappers';
|
||||
import qFormMixin from './qformMixin';
|
||||
import keyShortcut from './keyShortcut';
|
||||
import { QForm } from 'quasar';
|
||||
import { QLayout } from 'quasar';
|
||||
import mainShortcutMixin from './mainShortcutMixin';
|
||||
import { useCau } from 'src/composables/useCau';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import { CanceledError } from 'axios';
|
||||
|
||||
const { notify } = useNotify();
|
||||
|
||||
export default boot(({ app }) => {
|
||||
QForm.mixins = [qFormMixin];
|
||||
QLayout.mixins = [mainShortcutMixin];
|
||||
|
||||
app.mixin(qFormMixin);
|
||||
app.directive('shortcut', keyShortcut);
|
||||
app.config.errorHandler = async (error) => {
|
||||
app.config.errorHandler = (error) => {
|
||||
let message;
|
||||
const response = error.response;
|
||||
const responseData = response?.data;
|
||||
|
@ -43,12 +40,12 @@ export default boot(({ app }) => {
|
|||
}
|
||||
|
||||
console.error(error);
|
||||
if (error instanceof axios.CanceledError) {
|
||||
if (error instanceof CanceledError) {
|
||||
const env = process.env.NODE_ENV;
|
||||
if (env && env !== 'development') return;
|
||||
message = 'Duplicate request';
|
||||
}
|
||||
|
||||
await useCau(response, message);
|
||||
notify(message ?? 'globals.error', 'negative', 'error');
|
||||
};
|
||||
});
|
||||
|
|
|
@ -40,7 +40,6 @@ const onDataSaved = (...args) => {
|
|||
url-create="towns"
|
||||
model="city"
|
||||
@on-data-saved="onDataSaved"
|
||||
data-cy="newCityForm"
|
||||
>
|
||||
<template #form-inputs="{ data, validate }">
|
||||
<VnRow>
|
||||
|
@ -49,14 +48,12 @@ const onDataSaved = (...args) => {
|
|||
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 } from 'vue';
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
|
@ -21,13 +21,14 @@ const postcodeFormData = reactive({
|
|||
provinceFk: null,
|
||||
townFk: null,
|
||||
});
|
||||
const townsFetchDataRef = ref(false);
|
||||
const townFilter = ref({});
|
||||
|
||||
const townsFetchDataRef = ref(false);
|
||||
const countriesRef = ref(false);
|
||||
const townsRef = ref(false);
|
||||
const provincesFetchDataRef = ref(false);
|
||||
const provincesOptions = ref([]);
|
||||
const townsOptions = ref([]);
|
||||
const town = ref({});
|
||||
const townFilter = ref({});
|
||||
const countryFilter = ref({});
|
||||
|
||||
function onDataSaved(formData) {
|
||||
|
@ -47,81 +48,62 @@ function onDataSaved(formData) {
|
|||
emit('onDataSaved', newPostcode);
|
||||
}
|
||||
|
||||
async function setCountry(countryFk, data) {
|
||||
data.townFk = null;
|
||||
data.provinceFk = null;
|
||||
data.countryFk = countryFk;
|
||||
await fetchTowns();
|
||||
}
|
||||
|
||||
// Province
|
||||
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) {
|
||||
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(
|
||||
(province) => province.id === newTown.provinceFk
|
||||
);
|
||||
formData.townFk = newTown;
|
||||
setTown(newTown, formData);
|
||||
}
|
||||
async function fetchTowns(countryFk = postcodeFormData.countryFk) {
|
||||
if (!countryFk) return;
|
||||
const provinces = postcodeFormData.provinceFk
|
||||
? [postcodeFormData.provinceFk]
|
||||
: provinceByCountry();
|
||||
townFilter.value.where = {
|
||||
provinceFk: {
|
||||
inq: provinces,
|
||||
},
|
||||
};
|
||||
await townsFetchDataRef.value?.fetch();
|
||||
|
||||
function setTown(newTown, data) {
|
||||
town.value = newTown;
|
||||
data.provinceFk = newTown?.provinceFk ?? newTown;
|
||||
data.countryFk = newTown?.province?.countryFk ?? newTown;
|
||||
}
|
||||
|
||||
async function filterTowns(name) {
|
||||
if (name !== '') {
|
||||
townFilter.value.where = {
|
||||
name: {
|
||||
like: `%${name}%`,
|
||||
},
|
||||
};
|
||||
await townsFetchDataRef.value?.fetch();
|
||||
}
|
||||
async function setCountry(countryFk, data) {
|
||||
data.townFk = null;
|
||||
data.provinceFk = null;
|
||||
data.countryFk = countryFk;
|
||||
}
|
||||
|
||||
async function handleProvinces(data) {
|
||||
provincesOptions.value = data;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
const whereTowns = computed(() => {
|
||||
return {
|
||||
provinceFk: {
|
||||
inq: provincesOptions.value.map(({ id }) => id),
|
||||
},
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
ref="townsFetchDataRef"
|
||||
ref="provincesFetchDataRef"
|
||||
@on-fetch="handleProvinces"
|
||||
:sort-by="['name ASC']"
|
||||
:limit="30"
|
||||
:filter="townFilter"
|
||||
@on-fetch="handleTowns"
|
||||
auto-load
|
||||
url="Towns/location"
|
||||
url="Provinces/location"
|
||||
/>
|
||||
|
||||
<FormModelPopup
|
||||
|
@ -141,22 +123,25 @@ async function filterTowns(name) {
|
|||
:rules="validate('postcode.code')"
|
||||
clearable
|
||||
required
|
||||
data-cy="locationPostcode"
|
||||
/>
|
||||
<VnSelectDialog
|
||||
ref="townsRef"
|
||||
:sort-by="['name ASC']"
|
||||
:limit="30"
|
||||
auto-load
|
||||
url="Towns/location"
|
||||
:where="whereTowns"
|
||||
:label="t('City')"
|
||||
@update:model-value="(value) => setTown(value, data)"
|
||||
@filter="filterTowns"
|
||||
:tooltip="t('Create city')"
|
||||
v-model="data.townFk"
|
||||
:options="townsOptions"
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
: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">
|
||||
|
@ -186,12 +171,8 @@ async function filterTowns(name) {
|
|||
:country-fk="data.countryFk"
|
||||
:province-selected="data.provinceFk"
|
||||
@update:model-value="(value) => setProvince(value, data)"
|
||||
@update:options="
|
||||
(data) => {
|
||||
provincesOptions = data;
|
||||
}
|
||||
"
|
||||
v-model="data.provinceFk"
|
||||
@on-province-fetched="handleProvinces"
|
||||
@on-province-created="onProvinceCreated"
|
||||
required
|
||||
/>
|
||||
|
@ -210,7 +191,6 @@ async function filterTowns(name) {
|
|||
v-model="data.countryFk"
|
||||
:rules="validate('postcode.countryFk')"
|
||||
@update:model-value="(value) => setCountry(value, data)"
|
||||
data-cy="locationCountry"
|
||||
/>
|
||||
</VnRow>
|
||||
</template>
|
||||
|
|
|
@ -53,10 +53,8 @@ const where = computed(() => {
|
|||
v-model="data.name"
|
||||
:rules="validate('province.name')"
|
||||
required
|
||||
data-cy="provinceName"
|
||||
/>
|
||||
<VnSelect
|
||||
data-cy="autonomyProvince"
|
||||
required
|
||||
ref="autonomiesRef"
|
||||
auto-load
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
import axios from 'axios';
|
||||
import { computed, ref, useAttrs, watch } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useRouter, onBeforeRouteLeave } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
@ -10,14 +10,12 @@ 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();
|
||||
const stateStore = useStateStore();
|
||||
const { t } = useI18n();
|
||||
const { validate } = useValidator();
|
||||
const $attrs = useAttrs();
|
||||
|
||||
const $props = defineProps({
|
||||
model: {
|
||||
|
@ -114,11 +112,9 @@ onBeforeRouteLeave((to, from, next) => {
|
|||
});
|
||||
|
||||
async function fetch(data) {
|
||||
const keyData = $attrs['key-data'];
|
||||
const rows = keyData ? data[keyData] : data;
|
||||
resetData(rows);
|
||||
emit('onFetch', rows);
|
||||
return rows;
|
||||
resetData(data);
|
||||
emit('onFetch', data);
|
||||
return data;
|
||||
}
|
||||
|
||||
function resetData(data) {
|
||||
|
@ -130,7 +126,7 @@ function resetData(data) {
|
|||
originalData.value = JSON.parse(JSON.stringify(data));
|
||||
formData.value = JSON.parse(JSON.stringify(data));
|
||||
|
||||
if (watchChanges.value) watchChanges.value(); //destroy watcher
|
||||
if (watchChanges.value) watchChanges.value(); //destoy watcher
|
||||
watchChanges.value = watch(formData, () => (hasChanges.value = true), { deep: true });
|
||||
}
|
||||
|
||||
|
@ -149,7 +145,7 @@ function filter(value, update, filterOptions) {
|
|||
(ref) => {
|
||||
ref.setOptionIndex(-1);
|
||||
ref.moveOptionSelection(1, true);
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -179,13 +175,14 @@ async function saveChanges(data) {
|
|||
const changes = data || getChanges();
|
||||
try {
|
||||
await axios.post($props.saveUrl || $props.url + '/crud', changes);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
} catch (e) {
|
||||
return (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',
|
||||
|
@ -215,7 +212,7 @@ async function remove(data) {
|
|||
|
||||
if (preRemove.length) {
|
||||
newData = newData.filter(
|
||||
(form) => !preRemove.some((index) => index == form.$index),
|
||||
(form) => !preRemove.some((index) => index == form.$index)
|
||||
);
|
||||
const changes = getChanges();
|
||||
if (!changes.creates?.length && !changes.updates?.length)
|
||||
|
@ -252,7 +249,7 @@ function getChanges() {
|
|||
for (const [i, row] of formData.value.entries()) {
|
||||
if (!row[pk]) {
|
||||
creates.push(row);
|
||||
} else if (originalData.value[i]) {
|
||||
} else if (originalData.value) {
|
||||
const data = getDifferences(originalData.value[i], row);
|
||||
if (!isEmpty(data)) {
|
||||
updates.push({
|
||||
|
@ -271,10 +268,34 @@ 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 (Array.isArray(obj)) return !obj.length;
|
||||
return !Object.keys(obj).length;
|
||||
if (obj === undefined) return true;
|
||||
if (Object.keys(obj).length === 0) return true;
|
||||
|
||||
if (obj.length > 0) return false;
|
||||
}
|
||||
|
||||
async function reload(params) {
|
||||
|
|
|
@ -85,14 +85,12 @@ const closeForm = () => {
|
|||
hide-selected
|
||||
option-label="label"
|
||||
v-model="selectedField"
|
||||
data-cy="field-to-edit"
|
||||
/>
|
||||
<component
|
||||
:is="inputs[selectedField?.component || 'input']"
|
||||
v-bind="selectedField?.attrs || {}"
|
||||
v-model="newValue"
|
||||
:label="t('Value')"
|
||||
data-cy="value-to-edit"
|
||||
style="width: 200px"
|
||||
/>
|
||||
</VnRow>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script setup>
|
||||
import axios from 'axios';
|
||||
import { onMounted, onUnmounted, computed, ref, watch, nextTick } from 'vue';
|
||||
import { onBeforeRouteLeave, useRouter, useRoute } from 'vue-router';
|
||||
import { onBeforeRouteLeave, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useState } from 'src/composables/useState';
|
||||
|
@ -12,6 +12,7 @@ import SkeletonForm from 'components/ui/SkeletonForm.vue';
|
|||
import VnConfirm from './ui/VnConfirm.vue';
|
||||
import { tMobile } from 'src/composables/tMobile';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
const { push } = useRouter();
|
||||
const quasar = useQuasar();
|
||||
|
@ -109,7 +110,6 @@ const originalData = ref({});
|
|||
const formData = computed(() => state.get(modelValue));
|
||||
const defaultButtons = computed(() => ({
|
||||
save: {
|
||||
dataCy: 'saveDefaultBtn',
|
||||
color: 'primary',
|
||||
icon: 'save',
|
||||
label: 'globals.save',
|
||||
|
@ -117,7 +117,6 @@ const defaultButtons = computed(() => ({
|
|||
type: 'submit',
|
||||
},
|
||||
reset: {
|
||||
dataCy: 'resetDefaultBtn',
|
||||
color: 'primary',
|
||||
icon: 'restart_alt',
|
||||
label: 'globals.reset',
|
||||
|
@ -198,7 +197,6 @@ async function fetch() {
|
|||
} catch (e) {
|
||||
state.set(modelValue, {});
|
||||
originalData.value = {};
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,9 +207,7 @@ async function save() {
|
|||
isLoading.value = true;
|
||||
try {
|
||||
formData.value = trimData(formData.value);
|
||||
const body = $props.mapper
|
||||
? $props.mapper(formData.value, originalData.value)
|
||||
: formData.value;
|
||||
const body = $props.mapper ? $props.mapper(formData.value) : formData.value;
|
||||
const method = $props.urlCreate ? 'post' : 'patch';
|
||||
const url =
|
||||
$props.urlCreate || $props.urlUpdate || $props.url || arrayData.store.url;
|
||||
|
@ -293,7 +289,6 @@ defineExpose({
|
|||
class="q-pa-md"
|
||||
:style="maxWidth ? 'max-width: ' + maxWidth : ''"
|
||||
id="formModel"
|
||||
:prevent-submit="$attrs['prevent-submit']"
|
||||
>
|
||||
<QCard>
|
||||
<slot
|
||||
|
@ -327,7 +322,6 @@ defineExpose({
|
|||
:title="t(defaultButtons.reset.label)"
|
||||
/>
|
||||
<QBtnDropdown
|
||||
data-cy="saveAndContinueDefaultBtn"
|
||||
v-if="$props.goTo"
|
||||
@click="saveAndGo"
|
||||
:label="tMobile('globals.saveAndContinue')"
|
||||
|
|
|
@ -62,7 +62,6 @@ defineExpose({
|
|||
@click="emit('onDataCanceled')"
|
||||
v-close-popup
|
||||
data-cy="FormModelPopup_cancel"
|
||||
z-max
|
||||
/>
|
||||
<QBtn
|
||||
:label="t('globals.save')"
|
||||
|
@ -73,7 +72,6 @@ defineExpose({
|
|||
:disabled="isLoading"
|
||||
:loading="isLoading"
|
||||
data-cy="FormModelPopup_save"
|
||||
z-max
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -9,8 +9,6 @@ import VnSelect from 'components/common/VnSelect.vue';
|
|||
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
|
||||
|
||||
import axios from 'axios';
|
||||
import { getParamWhere } from 'src/filters';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
const { t } = useI18n();
|
||||
const props = defineProps({
|
||||
|
@ -28,24 +26,32 @@ const props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
const itemCategories = ref([]);
|
||||
const selectedCategoryFk = ref(null);
|
||||
const selectedTypeFk = ref(null);
|
||||
const itemTypesOptions = ref([]);
|
||||
const suppliersOptions = ref([]);
|
||||
const tagOptions = ref([]);
|
||||
const tagValues = ref([]);
|
||||
const categoryList = ref(null);
|
||||
const selectedCategoryFk = ref(getParamWhere(route.query.table, 'categoryFk', false));
|
||||
const selectedTypeFk = ref(getParamWhere(route.query.table, 'typeFk', false));
|
||||
|
||||
const selectedCategory = computed(() => {
|
||||
return (categoryList.value || []).find(
|
||||
(category) => category?.id === selectedCategoryFk.value,
|
||||
);
|
||||
const categoryList = computed(() => {
|
||||
return (itemCategories.value || [])
|
||||
.filter((category) => category.display)
|
||||
.map((category) => ({
|
||||
...category,
|
||||
icon: `vn:${(category.icon || '').split('-')[1]}`,
|
||||
}));
|
||||
});
|
||||
|
||||
const selectedCategory = computed(() =>
|
||||
(itemCategories.value || []).find(
|
||||
(category) => category?.id === selectedCategoryFk.value
|
||||
)
|
||||
);
|
||||
|
||||
const selectedType = computed(() => {
|
||||
return (itemTypesOptions.value || []).find(
|
||||
(type) => type?.id === selectedTypeFk.value,
|
||||
(type) => type?.id === selectedTypeFk.value
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -81,7 +87,7 @@ const applyTags = (params, search) => {
|
|||
search();
|
||||
};
|
||||
|
||||
const fetchItemTypes = async (id = selectedCategoryFk.value) => {
|
||||
const fetchItemTypes = async (id) => {
|
||||
const filter = {
|
||||
fields: ['id', 'name', 'categoryFk'],
|
||||
where: { categoryFk: id },
|
||||
|
@ -120,19 +126,22 @@ const removeTag = (index, params, search) => {
|
|||
(tagValues.value || []).splice(index, 1);
|
||||
applyTags(params, search);
|
||||
};
|
||||
const setCategoryList = (data) => {
|
||||
categoryList.value = (data || [])
|
||||
.filter((category) => category.display)
|
||||
.map((category) => ({
|
||||
...category,
|
||||
icon: `vn:${(category.icon || '').split('-')[1]}`,
|
||||
}));
|
||||
fetchItemTypes();
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData url="ItemCategories" limit="30" auto-load @on-fetch="setCategoryList" />
|
||||
<FetchData
|
||||
url="ItemCategories"
|
||||
limit="30"
|
||||
auto-load
|
||||
@on-fetch="(data) => (itemCategories = data)"
|
||||
/>
|
||||
<FetchData
|
||||
url="Suppliers"
|
||||
limit="30"
|
||||
auto-load
|
||||
:filter="{ fields: ['id', 'name', 'nickname'], order: 'name ASC', limit: 30 }"
|
||||
@on-fetch="(data) => (suppliersOptions = data)"
|
||||
/>
|
||||
<FetchData
|
||||
url="Tags"
|
||||
:filter="{ fields: ['id', 'name', 'isFree'] }"
|
||||
|
@ -341,11 +350,4 @@ es:
|
|||
floramondo: Floramondo
|
||||
salesPersonFk: Comprador
|
||||
categoryFk: Categoría
|
||||
Plant: Planta natural
|
||||
Flower: Flor fresca
|
||||
Handmade: Hecho a mano
|
||||
Artificial: Artificial
|
||||
Green: Verdes frescos
|
||||
Accessories: Complementos florales
|
||||
Fruit: Fruta
|
||||
</i18n>
|
||||
|
|
|
@ -10,13 +10,12 @@ import routes from 'src/router/modules';
|
|||
import LeftMenuItem from './LeftMenuItem.vue';
|
||||
import LeftMenuItemGroup from './LeftMenuItemGroup.vue';
|
||||
import VnInput from './common/VnInput.vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const quasar = useQuasar();
|
||||
const navigation = useNavigationStore();
|
||||
const router = useRouter();
|
||||
|
||||
const props = defineProps({
|
||||
source: {
|
||||
type: String,
|
||||
|
@ -93,13 +92,13 @@ function findMatches(search, item) {
|
|||
}
|
||||
|
||||
function addChildren(module, route, parent) {
|
||||
const menus = route?.meta?.menu ?? route?.menus?.[props.source]; //backwards compatible
|
||||
if (!menus) return;
|
||||
if (route.menus) {
|
||||
const mainMenus = route.menus[props.source];
|
||||
const matches = findMatches(mainMenus, route);
|
||||
|
||||
const matches = findMatches(menus, route);
|
||||
|
||||
for (const child of matches) {
|
||||
navigation.addMenuItem(module, child, parent);
|
||||
for (const child of matches) {
|
||||
navigation.addMenuItem(module, child, parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,26 +122,16 @@ function getRoutes() {
|
|||
if (props.source === 'card') {
|
||||
const currentRoute = route.matched[1];
|
||||
const currentModule = toLowerCamel(currentRoute.name);
|
||||
let moduleDef = routes.find(
|
||||
const moduleDef = routes.find(
|
||||
(route) => toLowerCamel(route.name) === currentModule
|
||||
);
|
||||
|
||||
if (!moduleDef) return;
|
||||
if (!moduleDef?.menus) moduleDef = betaGetRoutes();
|
||||
|
||||
addChildren(currentModule, moduleDef, items.value);
|
||||
}
|
||||
}
|
||||
|
||||
function betaGetRoutes() {
|
||||
let menuRoute;
|
||||
let index = route.matched.length - 1;
|
||||
while (!menuRoute && index > 0) {
|
||||
if (route.matched[index]?.meta?.menu) menuRoute = route.matched[index];
|
||||
index--;
|
||||
}
|
||||
return menuRoute;
|
||||
}
|
||||
|
||||
async function togglePinned(item, event) {
|
||||
if (event.defaultPrevented) return;
|
||||
event.preventDefault();
|
||||
|
@ -175,10 +164,6 @@ function normalize(text) {
|
|||
.replace(/[\u0300-\u036f]/g, '')
|
||||
.toLowerCase();
|
||||
}
|
||||
const searchModule = () => {
|
||||
const [item] = filteredItems.value;
|
||||
if (item) router.push({ name: item.name });
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -192,12 +177,10 @@ const searchModule = () => {
|
|||
class="full-width"
|
||||
filled
|
||||
dense
|
||||
autofocus
|
||||
@keyup.enter.stop="searchModule()"
|
||||
/>
|
||||
</QItem>
|
||||
<QSeparator />
|
||||
<template v-if="filteredPinnedModules.size && !search">
|
||||
<template v-if="filteredPinnedModules.size">
|
||||
<LeftMenuItem
|
||||
v-for="[key, pinnedModule] of filteredPinnedModules"
|
||||
:key="key"
|
||||
|
@ -221,11 +204,11 @@ const searchModule = () => {
|
|||
</LeftMenuItem>
|
||||
<QSeparator />
|
||||
</template>
|
||||
<template v-for="(item, index) in filteredItems" :key="item.name">
|
||||
<template v-for="item in filteredItems" :key="item.name">
|
||||
<template
|
||||
v-if="search ||item.children && !filteredPinnedModules.has(item.name)"
|
||||
v-if="item.children && !filteredPinnedModules.has(item.name)"
|
||||
>
|
||||
<LeftMenuItem :item="item" group="modules" :class="search && index === 0 ? 'searched' : ''">
|
||||
<LeftMenuItem :item="item" group="modules">
|
||||
<template #side>
|
||||
<QBtn
|
||||
v-if="item.isPinned === true"
|
||||
|
@ -342,9 +325,6 @@ const searchModule = () => {
|
|||
.header {
|
||||
color: var(--vn-label-color);
|
||||
}
|
||||
.searched{
|
||||
background-color: var(--vn-section-hover-color);
|
||||
}
|
||||
</style>
|
||||
<i18n>
|
||||
es:
|
||||
|
|
|
@ -17,11 +17,12 @@ const stateQuery = useStateQueryStore();
|
|||
const state = useState();
|
||||
const user = state.getUser();
|
||||
const appName = 'Lilium';
|
||||
const pinnedModulesRef = ref();
|
||||
|
||||
onMounted(() => stateStore.setMounted());
|
||||
const refresh = () => window.location.reload();
|
||||
|
||||
const pinnedModulesRef = ref();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<QHeader color="white" elevated>
|
||||
<QToolbar class="q-py-sm q-px-md">
|
||||
|
@ -58,20 +59,22 @@ const refresh = () => window.location.reload();
|
|||
'no-visible': !stateQuery.isLoading().value,
|
||||
}"
|
||||
size="xs"
|
||||
data-cy="loading-spinner"
|
||||
/>
|
||||
<QSpace />
|
||||
<div id="searchbar" class="searchbar"></div>
|
||||
<QSpace />
|
||||
<div class="q-pl-sm q-gutter-sm row items-center no-wrap">
|
||||
<div id="actions-prepend"></div>
|
||||
<QIcon
|
||||
name="refresh"
|
||||
size="md"
|
||||
color="red"
|
||||
v-if="state.get('error')"
|
||||
@click="refresh"
|
||||
/>
|
||||
<QBtn
|
||||
flat
|
||||
v-if="!quasar.platform.is.mobile"
|
||||
@click="pinnedModulesRef.redirect($route.params.id)"
|
||||
icon="more_up"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('Go to Salix') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
<QBtn
|
||||
:class="{ 'q-pa-none': quasar.platform.is.mobile }"
|
||||
id="pinnedModules"
|
||||
|
@ -103,6 +106,7 @@ const refresh = () => window.location.reload();
|
|||
<VnBreadcrumbs v-if="$q.screen.lt.md" class="q-ml-md" />
|
||||
</QHeader>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.searchbar {
|
||||
width: max-content;
|
||||
|
@ -111,3 +115,9 @@ const refresh = () => window.location.reload();
|
|||
background-color: var(--vn-section-color);
|
||||
}
|
||||
</style>
|
||||
<i18n>
|
||||
en:
|
||||
Go to Salix: Go to Salix
|
||||
es:
|
||||
Go to Salix: Ir a Salix
|
||||
</i18n>
|
||||
|
|
|
@ -44,7 +44,7 @@ const onDataSaved = (data) => {
|
|||
<FormModelPopup
|
||||
url-create="Items/regularize"
|
||||
model="Items"
|
||||
:title="t('item.regularizeStock')"
|
||||
:title="t('Regularize stock')"
|
||||
:form-initial-data="regularizeFormData"
|
||||
@on-data-saved="onDataSaved($event)"
|
||||
>
|
||||
|
@ -55,7 +55,6 @@ const onDataSaved = (data) => {
|
|||
v-model.number="data.quantity"
|
||||
type="number"
|
||||
autofocus
|
||||
data-cy="regularizeStockInput"
|
||||
/>
|
||||
</VnRow>
|
||||
<VnRow>
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
<script setup>
|
||||
import quasarLang from 'src/utils/quasarLang';
|
||||
|
||||
import { onMounted, computed, ref } from 'vue';
|
||||
|
||||
import { Dark } from 'quasar';
|
||||
import { Dark, Quasar } from 'quasar';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
|
@ -34,7 +31,14 @@ const userLocale = computed({
|
|||
|
||||
value = localeEquivalence[value] ?? value;
|
||||
|
||||
quasarLang(value);
|
||||
try {
|
||||
/* @vite-ignore */
|
||||
import(`../../node_modules/quasar/lang/${value}.mjs`).then((lang) => {
|
||||
Quasar.lang.set(lang.default);
|
||||
});
|
||||
} catch (error) {
|
||||
//
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -83,10 +87,10 @@ async function saveDarkMode(value) {
|
|||
async function saveLanguage(value) {
|
||||
const query = `/VnUsers/${user.value.id}`;
|
||||
try {
|
||||
await axios.patch(query, { lang: value });
|
||||
|
||||
await axios.patch(query, {
|
||||
lang: value,
|
||||
});
|
||||
user.value.lang = value;
|
||||
useState().setUser(user.value);
|
||||
onDataSaved();
|
||||
} catch (error) {
|
||||
onDataError();
|
||||
|
|
|
@ -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', 'onProvinceFetched', 'update:options']);
|
||||
const emit = defineEmits(['onProvinceCreated', 'onProvinceFetched']);
|
||||
const $props = defineProps({
|
||||
countryFk: {
|
||||
type: Number,
|
||||
|
@ -41,7 +41,6 @@ async function onProvinceCreated(_, data) {
|
|||
}
|
||||
async function handleProvinces(data) {
|
||||
provincesOptions.value = data;
|
||||
emit('update:options', data);
|
||||
}
|
||||
|
||||
watch(
|
||||
|
@ -65,11 +64,11 @@ watch(
|
|||
auto-load
|
||||
/>
|
||||
<VnSelectDialog
|
||||
data-cy="locationProvince"
|
||||
:label="t('Province')"
|
||||
:options="provincesOptions"
|
||||
:tooltip="t('Create province')"
|
||||
hide-selected
|
||||
:clearable="true"
|
||||
v-model="provinceFk"
|
||||
:rules="validate && validate('postcode.provinceFk')"
|
||||
:acls="[{ model: 'Province', props: '*', accessType: 'WRITE' }]"
|
||||
|
|
|
@ -32,10 +32,7 @@ const $props = defineProps({
|
|||
defineExpose({ addFilter, props: $props });
|
||||
|
||||
const model = defineModel(undefined, { required: true });
|
||||
const arrayData = useArrayData(
|
||||
$props.dataKey,
|
||||
$props.searchUrl ? { searchUrl: $props.searchUrl } : null
|
||||
);
|
||||
const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl });
|
||||
const columnFilter = computed(() => $props.column?.columnFilter);
|
||||
|
||||
const updateEvent = { 'update:modelValue': addFilter };
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
<script setup>
|
||||
import { ref, onBeforeMount, onMounted, computed, watch, useAttrs } from 'vue';
|
||||
import { ref, onBeforeMount, onMounted, computed, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { useFilterParams } from 'src/composables/useFilterParams';
|
||||
|
||||
import CrudModel from 'src/components/CrudModel.vue';
|
||||
import FormModelPopup from 'components/FormModelPopup.vue';
|
||||
|
||||
import VnFilterPanel from 'components/ui/VnFilterPanel.vue';
|
||||
import VnTableColumn from 'components/VnTable/VnColumn.vue';
|
||||
import VnFilter from 'components/VnTable/VnFilter.vue';
|
||||
import VnTableChip from 'components/VnTable/VnChip.vue';
|
||||
import VnVisibleColumn from 'src/components/VnTable/VnVisibleColumn.vue';
|
||||
import VnLv from 'components/ui/VnLv.vue';
|
||||
import VnTableOrder from 'src/components/VnTable/VnOrder.vue';
|
||||
import VnTableFilter from './VnTableFilter.vue';
|
||||
|
||||
const $props = defineProps({
|
||||
columns: {
|
||||
|
@ -34,10 +33,6 @@ const $props = defineProps({
|
|||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
rightSearchIcon: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
rowClick: {
|
||||
type: [Function, Boolean],
|
||||
default: null,
|
||||
|
@ -59,8 +54,8 @@ const $props = defineProps({
|
|||
default: true,
|
||||
},
|
||||
bottom: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
cardClass: {
|
||||
type: String,
|
||||
|
@ -106,6 +101,10 @@ const $props = defineProps({
|
|||
type: String,
|
||||
default: '90vh',
|
||||
},
|
||||
chipLocale: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
footer: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
|
@ -120,21 +119,22 @@ const stateStore = useStateStore();
|
|||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const quasar = useQuasar();
|
||||
const $attrs = useAttrs();
|
||||
|
||||
const CARD_MODE = 'card';
|
||||
const TABLE_MODE = 'table';
|
||||
const mode = ref(CARD_MODE);
|
||||
const selected = ref([]);
|
||||
const hasParams = ref(false);
|
||||
const routeQuery = JSON.parse(route?.query[$props.searchUrl] ?? '{}');
|
||||
const params = ref({ ...routeQuery, ...routeQuery.filter?.where });
|
||||
const orders = ref(parseOrder(routeQuery.filter?.order));
|
||||
const CrudModelRef = ref({});
|
||||
const showForm = ref(false);
|
||||
const splittedColumns = ref({ columns: [] });
|
||||
const columnsVisibilitySkipped = ref();
|
||||
const createForm = ref();
|
||||
const tableFilterRef = ref([]);
|
||||
const tableRef = ref();
|
||||
const params = ref(useFilterParams($attrs['data-key']).params);
|
||||
const orders = ref(useFilterParams($attrs['data-key']).orders);
|
||||
|
||||
const tableModes = [
|
||||
{
|
||||
|
@ -150,7 +150,6 @@ const tableModes = [
|
|||
disable: $props.disableOption?.card,
|
||||
},
|
||||
];
|
||||
|
||||
onBeforeMount(() => {
|
||||
const urlParams = route.query[$props.searchUrl];
|
||||
hasParams.value = urlParams && Object.keys(urlParams).length !== 0;
|
||||
|
@ -163,9 +162,7 @@ onMounted(() => {
|
|||
: $props.defaultMode;
|
||||
stateStore.rightDrawer = quasar.screen.gt.xs;
|
||||
columnsVisibilitySkipped.value = [
|
||||
...splittedColumns.value.columns
|
||||
.filter((c) => c.visible === false)
|
||||
.map((c) => c.name),
|
||||
...splittedColumns.value.columns.filter((c) => !c.visible).map((c) => c.name),
|
||||
...['tableActions'],
|
||||
];
|
||||
createForm.value = $props.create;
|
||||
|
@ -181,11 +178,44 @@ onMounted(() => {
|
|||
watch(
|
||||
() => $props.columns,
|
||||
(value) => splitColumns(value),
|
||||
{ immediate: true },
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
() => route.query[$props.searchUrl],
|
||||
(val) => setUserParams(val),
|
||||
{ immediate: true, deep: true }
|
||||
);
|
||||
|
||||
const isTableMode = computed(() => mode.value == TABLE_MODE);
|
||||
const showRightIcon = computed(() => $props.rightSearch || $props.rightSearchIcon);
|
||||
|
||||
function setUserParams(watchedParams, watchedOrder) {
|
||||
if (!watchedParams) return;
|
||||
|
||||
if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams);
|
||||
const filter =
|
||||
typeof watchedParams?.filter == 'string'
|
||||
? JSON.parse(watchedParams?.filter ?? '{}')
|
||||
: watchedParams?.filter;
|
||||
const where = filter?.where;
|
||||
const order = watchedOrder ?? filter?.order;
|
||||
|
||||
watchedParams = { ...watchedParams, ...where };
|
||||
delete watchedParams.filter;
|
||||
delete params.value?.filter;
|
||||
params.value = { ...params.value, ...sanitizer(watchedParams) };
|
||||
orders.value = parseOrder(order);
|
||||
}
|
||||
|
||||
function sanitizer(params) {
|
||||
for (const [key, value] of Object.entries(params)) {
|
||||
if (value && typeof value == 'object') {
|
||||
const param = Object.values(value)[0];
|
||||
if (typeof param == 'string') params[key] = param.replaceAll('%', '');
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
function splitColumns(columns) {
|
||||
splittedColumns.value = {
|
||||
|
@ -212,7 +242,7 @@ function splitColumns(columns) {
|
|||
// Status column
|
||||
if (splittedColumns.value.chips.length) {
|
||||
splittedColumns.value.columnChips = splittedColumns.value.chips.filter(
|
||||
(c) => !c.isId,
|
||||
(c) => !c.isId
|
||||
);
|
||||
if (splittedColumns.value.columnChips.length)
|
||||
splittedColumns.value.columns.unshift({
|
||||
|
@ -266,6 +296,17 @@ function getColAlign(col) {
|
|||
return 'text-' + (col.align ?? 'left');
|
||||
}
|
||||
|
||||
function parseOrder(urlOrders) {
|
||||
const orderObject = {};
|
||||
if (!urlOrders) return orderObject;
|
||||
if (typeof urlOrders == 'string') urlOrders = [urlOrders];
|
||||
for (const [index, orders] of urlOrders.entries()) {
|
||||
const [name, direction] = orders.split(' ');
|
||||
orderObject[name] = { direction, index: index + 1 };
|
||||
}
|
||||
return orderObject;
|
||||
}
|
||||
|
||||
const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']);
|
||||
defineExpose({
|
||||
create: createForm,
|
||||
|
@ -314,19 +355,61 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
show-if-above
|
||||
>
|
||||
<QScrollArea class="fit">
|
||||
<VnTableFilter
|
||||
<VnFilterPanel
|
||||
:data-key="$attrs['data-key']"
|
||||
:columns="columns"
|
||||
:redirect="redirect"
|
||||
:search-button="true"
|
||||
v-model="params"
|
||||
:search-url="searchUrl"
|
||||
:redirect="!!redirect"
|
||||
@set-user-params="setUserParams"
|
||||
:disable-submit-event="true"
|
||||
@remove="
|
||||
(key) =>
|
||||
tableFilterRef
|
||||
.find((f) => f.props?.column.name == key)
|
||||
?.addFilter()
|
||||
"
|
||||
>
|
||||
<template
|
||||
v-for="(_, slotName) in $slots"
|
||||
#[slotName]="slotData"
|
||||
:key="slotName"
|
||||
>
|
||||
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
||||
<template #body>
|
||||
<div
|
||||
class="row no-wrap flex-center"
|
||||
v-for="col of splittedColumns.columns.filter(
|
||||
(c) => c.columnFilter ?? true
|
||||
)"
|
||||
:key="col.id"
|
||||
>
|
||||
<VnFilter
|
||||
ref="tableFilterRef"
|
||||
:column="col"
|
||||
:data-key="$attrs['data-key']"
|
||||
v-model="params[columnName(col)]"
|
||||
:search-url="searchUrl"
|
||||
/>
|
||||
<VnTableOrder
|
||||
v-if="
|
||||
col?.columnFilter !== false &&
|
||||
col?.name !== 'tableActions'
|
||||
"
|
||||
v-model="orders[col.orderBy ?? col.name]"
|
||||
:name="col.orderBy ?? col.name"
|
||||
:data-key="$attrs['data-key']"
|
||||
:search-url="searchUrl"
|
||||
:vertical="false"
|
||||
/>
|
||||
</div>
|
||||
<slot
|
||||
name="moreFilterPanel"
|
||||
:params="params"
|
||||
:columns="splittedColumns.columns"
|
||||
/>
|
||||
</template>
|
||||
</VnTableFilter>
|
||||
<template #tags="{ tag, formatFn }" v-if="chipLocale">
|
||||
<div class="q-gutter-x-xs">
|
||||
<strong>{{ t(`${chipLocale}.${tag.label}`) }}: </strong>
|
||||
<span>{{ formatFn(tag.value) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</VnFilterPanel>
|
||||
</QScrollArea>
|
||||
</QDrawer>
|
||||
<CrudModel
|
||||
|
@ -382,7 +465,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
:options="tableModes.filter((mode) => !mode.disable)"
|
||||
/>
|
||||
<QBtn
|
||||
v-if="showRightIcon"
|
||||
v-if="$props.rightSearch"
|
||||
icon="filter_alt"
|
||||
class="bg-vn-section-color q-ml-sm"
|
||||
dense
|
||||
|
@ -396,7 +479,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
:class="col.headerClass"
|
||||
>
|
||||
<div
|
||||
class="column ellipsis"
|
||||
class="column self-start q-ml-xs ellipsis"
|
||||
:class="`text-${col?.align ?? 'left'}`"
|
||||
:style="$props.columnSearch ? 'height: 75px' : ''"
|
||||
>
|
||||
|
@ -438,7 +521,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
<!-- Columns -->
|
||||
<QTd
|
||||
auto-width
|
||||
class="no-margin"
|
||||
class="no-margin q-px-xs"
|
||||
:class="[getColAlign(col), col.columnClass]"
|
||||
:style="col.style"
|
||||
v-if="col.visible ?? true"
|
||||
|
@ -484,14 +567,35 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
btn.isPrimary ? 'text-primary-light' : 'color-vn-text '
|
||||
"
|
||||
:style="`visibility: ${
|
||||
((btn.show && btn.show(row)) ?? true)
|
||||
? 'visible'
|
||||
: 'hidden'
|
||||
(btn.show && btn.show(row)) ?? true ? 'visible' : 'hidden'
|
||||
}`"
|
||||
@click="btn.action(row)"
|
||||
/>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #bottom v-if="bottom">
|
||||
<slot name="bottom-table">
|
||||
<QBtn
|
||||
@click="
|
||||
() =>
|
||||
createAsDialog
|
||||
? (showForm = !showForm)
|
||||
: handleOnDataSaved(create)
|
||||
"
|
||||
class="cursor-pointer fill-icon"
|
||||
color="primary"
|
||||
icon="add_circle"
|
||||
size="md"
|
||||
round
|
||||
flat
|
||||
shortcut="+"
|
||||
:disabled="!disabledAttr"
|
||||
/>
|
||||
<QTooltip>
|
||||
{{ createForm.title }}
|
||||
</QTooltip>
|
||||
</slot>
|
||||
</template>
|
||||
<template #item="{ row, colsMap }">
|
||||
<component
|
||||
:is="$props.redirect ? 'router-link' : 'span'"
|
||||
|
@ -506,7 +610,6 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
$props.rowClick && $props.rowClick(row);
|
||||
}
|
||||
"
|
||||
style="height: 100%"
|
||||
>
|
||||
<QCardSection
|
||||
vertical
|
||||
|
@ -552,7 +655,13 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
:key="col.name"
|
||||
class="fields"
|
||||
>
|
||||
<VnLv :label="col.label + ':'">
|
||||
<VnLv
|
||||
:label="
|
||||
!col.component && col.label
|
||||
? `${col.label}:`
|
||||
: ''
|
||||
"
|
||||
>
|
||||
<template #value>
|
||||
<span
|
||||
@click="stopEventPropagation($event)"
|
||||
|
@ -616,27 +725,6 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
</QTr>
|
||||
</template>
|
||||
</QTable>
|
||||
<div class="full-width bottomButton" v-if="bottom">
|
||||
<QBtn
|
||||
@click="
|
||||
() =>
|
||||
createAsDialog
|
||||
? (showForm = !showForm)
|
||||
: handleOnDataSaved(create)
|
||||
"
|
||||
class="cursor-pointer fill-icon"
|
||||
color="primary"
|
||||
icon="add_circle"
|
||||
size="md"
|
||||
round
|
||||
flat
|
||||
shortcut="+"
|
||||
:disabled="!disabledAttr"
|
||||
/>
|
||||
<QTooltip>
|
||||
{{ createForm.title }}
|
||||
</QTooltip>
|
||||
</div>
|
||||
</template>
|
||||
</CrudModel>
|
||||
<QPageSticky v-if="$props.create" :offset="[20, 20]" style="z-index: 2">
|
||||
|
@ -714,7 +802,7 @@ es:
|
|||
|
||||
.grid-three {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(350px, max-content));
|
||||
grid-template-columns: repeat(auto-fit, minmax(400px, max-content));
|
||||
max-width: 100%;
|
||||
grid-gap: 20px;
|
||||
margin: 0 auto;
|
||||
|
@ -763,6 +851,21 @@ es:
|
|||
top: 0;
|
||||
padding: 12px 0;
|
||||
}
|
||||
tbody {
|
||||
.q-checkbox {
|
||||
display: flex;
|
||||
margin-bottom: 9px;
|
||||
& .q-checkbox__label {
|
||||
margin-left: 31px;
|
||||
color: var(--vn-text-color);
|
||||
}
|
||||
& .q-checkbox__inner {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
color: var(--vn-label-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
.sticky {
|
||||
position: sticky;
|
||||
right: 0;
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
import VnFilterPanel from 'components/ui/VnFilterPanel.vue';
|
||||
import VnFilter from 'components/VnTable/VnFilter.vue';
|
||||
import VnTableOrder from 'src/components/VnTable/VnOrder.vue';
|
||||
|
||||
defineProps({
|
||||
columns: {
|
||||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
searchUrl: {
|
||||
type: [String, Boolean],
|
||||
default: 'table',
|
||||
},
|
||||
});
|
||||
|
||||
const tableFilterRef = ref([]);
|
||||
|
||||
function columnName(col) {
|
||||
const column = { ...col, ...col.columnFilter };
|
||||
let name = column.name;
|
||||
if (column.alias) name = column.alias + '.' + name;
|
||||
return name;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<VnFilterPanel v-bind="$attrs" :search-button="true" :disable-submit-event="true">
|
||||
<template #body="{ params, orders }">
|
||||
<div
|
||||
class="row no-wrap flex-center"
|
||||
v-for="col of columns.filter((c) => c.columnFilter ?? true)"
|
||||
:key="col.id"
|
||||
>
|
||||
<VnFilter
|
||||
ref="tableFilterRef"
|
||||
:column="col"
|
||||
:data-key="$attrs['data-key']"
|
||||
v-model="params[columnName(col)]"
|
||||
:search-url="searchUrl"
|
||||
/>
|
||||
<VnTableOrder
|
||||
v-if="col?.columnFilter !== false && col?.name !== 'tableActions'"
|
||||
v-model="orders[col.orderBy ?? col.name]"
|
||||
:name="col.orderBy ?? col.name"
|
||||
:data-key="$attrs['data-key']"
|
||||
:search-url="searchUrl"
|
||||
:vertical="true"
|
||||
/>
|
||||
</div>
|
||||
<slot
|
||||
name="moreFilterPanel"
|
||||
:params="params"
|
||||
:orders="orders"
|
||||
:columns="columns"
|
||||
/>
|
||||
</template>
|
||||
<template #tags="{ tag, formatFn, getLocale }">
|
||||
<div class="q-gutter-x-xs">
|
||||
<strong>{{ getLocale(`${tag.label}`) }}: </strong>
|
||||
<span>{{ formatFn(tag.value) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
|
||||
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
||||
</template>
|
||||
</VnFilterPanel>
|
||||
</template>
|
|
@ -152,7 +152,7 @@ onMounted(async () => {
|
|||
<QCheckbox
|
||||
v-for="col in localColumns"
|
||||
:key="col.name"
|
||||
:label="col.label ?? col.name"
|
||||
:label="col.label"
|
||||
v-model="col.visible"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
import { describe, expect, it, beforeEach, afterEach, vi } from 'vitest';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import VnVisibleColumn from '../VnVisibleColumn.vue';
|
||||
import { axios } from 'app/test/vitest/helper';
|
||||
|
||||
describe('VnVisibleColumns', () => {
|
||||
let wrapper;
|
||||
let vm;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = createWrapper(VnVisibleColumn, {
|
||||
propsData: {
|
||||
tableCode: 'testTable',
|
||||
skip: ['skippedColumn'],
|
||||
},
|
||||
});
|
||||
vm = wrapper.vm;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('setUserConfigViewData()', () => {
|
||||
it('should initialize localColumns with visible configuration', () => {
|
||||
vm.columns = [
|
||||
{ name: 'columnMockName', label: undefined },
|
||||
{ name: 'columnMockAddress', label: undefined },
|
||||
{ name: 'columnMockId', label: undefined },
|
||||
];
|
||||
const configuration = {
|
||||
columnMockName: true,
|
||||
columnMockAddress: false,
|
||||
columnMockId: true,
|
||||
};
|
||||
const expectedColumns = [
|
||||
{ name: 'columnMockName', label: undefined, visible: true },
|
||||
{ name: 'columnMockAddress', label: undefined, visible: false },
|
||||
{ name: 'columnMockId', label: undefined, visible: true },
|
||||
];
|
||||
|
||||
vm.setUserConfigViewData(configuration, false);
|
||||
|
||||
expect(vm.localColumns).toEqual(expectedColumns);
|
||||
});
|
||||
|
||||
it('should skip columns based on props', () => {
|
||||
vm.columns = [
|
||||
{ name: 'columnMockName', label: undefined },
|
||||
{ name: 'columnMockId', label: undefined },
|
||||
{ name: 'skippedColumn', label: 'Skipped Column' },
|
||||
];
|
||||
const configuration = {
|
||||
columnMockName: true,
|
||||
skippedColumn: false,
|
||||
columnMockId: true,
|
||||
};
|
||||
const expectedColumns = [
|
||||
{ name: 'columnMockName', label: undefined, visible: true },
|
||||
{ name: 'columnMockId', label: undefined, visible: true },
|
||||
];
|
||||
|
||||
vm.setUserConfigViewData(configuration, false);
|
||||
|
||||
expect(vm.localColumns).toEqual(expectedColumns);
|
||||
});
|
||||
});
|
||||
|
||||
describe('toggleMarkAll()', () => {
|
||||
it('should set all localColumns to visible=true', () => {
|
||||
vm.localColumns = [
|
||||
{ name: 'columnMockName', visible: false },
|
||||
{ name: 'columnMockId', visible: false },
|
||||
];
|
||||
|
||||
vm.toggleMarkAll(true);
|
||||
|
||||
expect(vm.localColumns.every((col) => col.visible)).toBe(true);
|
||||
});
|
||||
|
||||
it('should set all localColumns to visible=false', () => {
|
||||
vm.localColumns = [
|
||||
{ name: 'columnMockName', visible: true },
|
||||
{ name: 'columnMockId', visible: true },
|
||||
];
|
||||
|
||||
vm.toggleMarkAll(false);
|
||||
|
||||
expect(vm.localColumns.every((col) => col.visible)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('saveConfig()', () => {
|
||||
it('should call setUserConfigViewData and axios.post with correct params', async () => {
|
||||
const mockAxiosPost = vi.spyOn(axios, 'post').mockResolvedValue({
|
||||
data: [{ id: 1 }],
|
||||
});
|
||||
|
||||
vm.localColumns = [
|
||||
{ name: 'columnMockName', visible: true },
|
||||
{ name: 'columnMockId', visible: false },
|
||||
];
|
||||
|
||||
await vm.saveConfig();
|
||||
|
||||
expect(mockAxiosPost).toHaveBeenCalledWith('UserConfigViews/crud', {
|
||||
creates: [
|
||||
{
|
||||
userFk: vm.user.id,
|
||||
tableCode: vm.tableCode,
|
||||
tableConfig: vm.tableCode,
|
||||
configuration: {
|
||||
columnMockName: true,
|
||||
columnMockId: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,12 +0,0 @@
|
|||
export default function (initialFooter, data) {
|
||||
const footer = data.reduce(
|
||||
(acc, row) => {
|
||||
Object.entries(initialFooter).forEach(([key, initialValue]) => {
|
||||
acc[key] += row?.[key] !== undefined ? row[key] : initialValue;
|
||||
});
|
||||
return acc;
|
||||
},
|
||||
{ ...initialFooter }
|
||||
);
|
||||
return footer;
|
||||
}
|
|
@ -1,248 +0,0 @@
|
|||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import CrudModel from 'components/CrudModel.vue';
|
||||
import { vi, afterEach, beforeEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
describe('CrudModel', () => {
|
||||
let wrapper;
|
||||
let vm;
|
||||
let data;
|
||||
beforeAll(() => {
|
||||
wrapper = createWrapper(CrudModel, {
|
||||
global: {
|
||||
stubs: [
|
||||
'vnPaginate',
|
||||
'useState',
|
||||
'arrayData',
|
||||
'useStateStore',
|
||||
'vue-i18n',
|
||||
],
|
||||
mocks: {
|
||||
validate: vi.fn(),
|
||||
},
|
||||
},
|
||||
propsData: {
|
||||
dataRequired: {
|
||||
fk: 1,
|
||||
},
|
||||
dataKey: 'crudModelKey',
|
||||
model: 'crudModel',
|
||||
url: 'crudModelUrl',
|
||||
saveFn: '',
|
||||
},
|
||||
});
|
||||
wrapper=wrapper.wrapper;
|
||||
vm=wrapper.vm;
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vm.fetch([]);
|
||||
vm.watchChanges = null;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('insert()', () => {
|
||||
it('should new element in list with index 0 if formData not has data', () => {
|
||||
vm.insert();
|
||||
|
||||
expect(vm.formData.length).toEqual(1);
|
||||
expect(vm.formData[0].fk).toEqual(1);
|
||||
expect(vm.formData[0].$index).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getChanges()', () => {
|
||||
it('should return correct updates and creates', async () => {
|
||||
vm.fetch([
|
||||
{ id: 1, name: 'New name one' },
|
||||
{ id: 2, name: 'New name two' },
|
||||
{ id: 3, name: 'Bruce Wayne' },
|
||||
]);
|
||||
|
||||
vm.originalData = [
|
||||
{ id: 1, name: 'Tony Starks' },
|
||||
{ id: 2, name: 'Jessica Jones' },
|
||||
{ id: 3, name: 'Bruce Wayne' },
|
||||
];
|
||||
|
||||
vm.insert();
|
||||
const result = vm.getChanges();
|
||||
|
||||
const expected = {
|
||||
creates: [
|
||||
{
|
||||
$index: 3,
|
||||
fk: 1,
|
||||
},
|
||||
],
|
||||
updates: [
|
||||
{
|
||||
data: {
|
||||
name: 'New name one',
|
||||
},
|
||||
where: {
|
||||
id: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
data: {
|
||||
name: 'New name two',
|
||||
},
|
||||
where: {
|
||||
id: 2,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getDifferences()', () => {
|
||||
it('should return the differences between two objects', async () => {
|
||||
const obj1 = {
|
||||
a: 1,
|
||||
b: 2,
|
||||
c: 3,
|
||||
};
|
||||
const obj2 = {
|
||||
a: null,
|
||||
b: 4,
|
||||
d: 5,
|
||||
};
|
||||
|
||||
const result = vm.getDifferences(obj1, obj2);
|
||||
|
||||
expect(result).toEqual({
|
||||
a: null,
|
||||
b: 4,
|
||||
d: 5,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('isEmpty()', () => {
|
||||
let dummyObj;
|
||||
let dummyArray;
|
||||
let result;
|
||||
it('should return true if object si null', async () => {
|
||||
dummyObj = null;
|
||||
result = vm.isEmpty(dummyObj);
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true if object si undefined', async () => {
|
||||
dummyObj = undefined;
|
||||
result = vm.isEmpty(dummyObj);
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true if object is empty', async () => {
|
||||
dummyObj ={};
|
||||
result = vm.isEmpty(dummyObj);
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false if object is not empty', async () => {
|
||||
dummyObj = {a:1, b:2, c:3};
|
||||
result = vm.isEmpty(dummyObj);
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('should return true if array is empty', async () => {
|
||||
dummyArray = [];
|
||||
result = vm.isEmpty(dummyArray);
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false if array is not empty', async () => {
|
||||
dummyArray = [1,2,3];
|
||||
result = vm.isEmpty(dummyArray);
|
||||
|
||||
expect(result).toBe(false);
|
||||
})
|
||||
});
|
||||
|
||||
describe('resetData()', () => {
|
||||
it('should add $index to elements in data[] and sets originalData and formData with data', async () => {
|
||||
data = [{
|
||||
name: 'Tony',
|
||||
lastName: 'Stark',
|
||||
age: 42,
|
||||
}];
|
||||
|
||||
vm.resetData(data);
|
||||
|
||||
expect(vm.originalData).toEqual(data);
|
||||
expect(vm.originalData[0].$index).toEqual(0);
|
||||
expect(vm.formData).toEqual(data);
|
||||
expect(vm.formData[0].$index).toEqual(0);
|
||||
expect(vm.watchChanges).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should dont do nothing if data is null', async () => {
|
||||
vm.resetData(null);
|
||||
|
||||
expect(vm.watchChanges).toBeNull();
|
||||
});
|
||||
|
||||
it('should set originalData and formatData with data and generate watchChanges', async () => {
|
||||
data = {
|
||||
name: 'Tony',
|
||||
lastName: 'Stark',
|
||||
age: 42,
|
||||
};
|
||||
|
||||
vm.resetData(data);
|
||||
|
||||
expect(vm.originalData).toEqual(data);
|
||||
expect(vm.formData).toEqual(data);
|
||||
expect(vm.watchChanges).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('saveChanges()', () => {
|
||||
data = [{
|
||||
name: 'Tony',
|
||||
lastName: 'Stark',
|
||||
age: 42,
|
||||
}];
|
||||
|
||||
it('should call saveFn if exists', async () => {
|
||||
await wrapper.setProps({ saveFn: vi.fn() });
|
||||
|
||||
vm.saveChanges(data);
|
||||
|
||||
expect(vm.saveFn).toHaveBeenCalledOnce();
|
||||
expect(vm.isLoading).toBe(false);
|
||||
expect(vm.hasChanges).toBe(false);
|
||||
|
||||
await wrapper.setProps({ saveFn: '' });
|
||||
});
|
||||
|
||||
it("should use default url if there's not saveFn", async () => {
|
||||
const postMock =vi.spyOn(axios, 'post');
|
||||
|
||||
vm.formData = [{
|
||||
name: 'Bruce',
|
||||
lastName: 'Wayne',
|
||||
age: 45,
|
||||
}]
|
||||
|
||||
await vm.saveChanges(data);
|
||||
|
||||
expect(postMock).toHaveBeenCalledWith(vm.url + '/crud', data);
|
||||
expect(vm.isLoading).toBe(false);
|
||||
expect(vm.hasChanges).toBe(false);
|
||||
expect(vm.originalData).toEqual(JSON.parse(JSON.stringify(vm.formData)));
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,56 +0,0 @@
|
|||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import EditForm from 'components/EditTableCellValueForm.vue';
|
||||
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
const fieldA = 'fieldA';
|
||||
const fieldB = 'fieldB';
|
||||
|
||||
describe('EditForm', () => {
|
||||
let vm;
|
||||
const mockRows = [
|
||||
{ id: 1, itemFk: 101 },
|
||||
{ id: 2, itemFk: 102 },
|
||||
];
|
||||
const mockFieldsOptions = [
|
||||
{ label: 'Field A', field: fieldA, component: 'input', attrs: {} },
|
||||
{ label: 'Field B', field: fieldB, component: 'date', attrs: {} },
|
||||
];
|
||||
const editUrl = '/api/edit';
|
||||
|
||||
beforeAll(() => {
|
||||
vi.spyOn(axios, 'post').mockResolvedValue({ status: 200 });
|
||||
vm = createWrapper(EditForm, {
|
||||
props: {
|
||||
rows: mockRows,
|
||||
fieldsOptions: mockFieldsOptions,
|
||||
editUrl,
|
||||
},
|
||||
}).vm;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
it('should call axios.post with the correct parameters in the payload', async () => {
|
||||
const selectedField = { field: fieldA, component: 'input', attrs: {} };
|
||||
const newValue = 'Test Value';
|
||||
|
||||
vm.selectedField = selectedField;
|
||||
vm.newValue = newValue;
|
||||
|
||||
await vm.onSubmit();
|
||||
|
||||
const payload = axios.post.mock.calls[0][1];
|
||||
|
||||
expect(axios.post).toHaveBeenCalledWith(editUrl, expect.any(Object));
|
||||
expect(payload.field).toEqual(fieldA);
|
||||
expect(payload.newValue).toEqual(newValue);
|
||||
|
||||
expect(payload.lines).toEqual(expect.arrayContaining(mockRows));
|
||||
|
||||
expect(vm.isLoading).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,82 +0,0 @@
|
|||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import FilterItemForm from 'src/components/FilterItemForm.vue';
|
||||
import { vi, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
describe('FilterItemForm', () => {
|
||||
let vm;
|
||||
let wrapper;
|
||||
|
||||
beforeAll(() => {
|
||||
wrapper = createWrapper(FilterItemForm, {
|
||||
props: {
|
||||
url: 'Items/withName',
|
||||
},
|
||||
});
|
||||
vm = wrapper.vm;
|
||||
wrapper = wrapper.wrapper;
|
||||
|
||||
vi.spyOn(axios, 'get').mockResolvedValue({
|
||||
data: [
|
||||
{
|
||||
id: 999996,
|
||||
name: 'bolas de madera',
|
||||
size: 2,
|
||||
inkFk: null,
|
||||
producerFk: null,
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('should filter data and populate tableRows for table display', async () => {
|
||||
vm.itemFilterParams.name = 'bolas de madera';
|
||||
|
||||
await vm.onSubmit();
|
||||
|
||||
const expectedFilter = {
|
||||
include: [
|
||||
{ relation: 'producer', scope: { fields: ['name'] } },
|
||||
{ relation: 'ink', scope: { fields: ['name'] } },
|
||||
],
|
||||
where: {"name":{"like":"%bolas de madera%"}},
|
||||
};
|
||||
|
||||
expect(axios.get).toHaveBeenCalledWith('Items/withName', {
|
||||
params: { filter: JSON.stringify(expectedFilter) },
|
||||
});
|
||||
|
||||
expect(vm.tableRows).toEqual([
|
||||
{
|
||||
id: 999996,
|
||||
name: 'bolas de madera',
|
||||
size: 2,
|
||||
inkFk: null,
|
||||
producerFk: null,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('should handle an empty itemFilterParams correctly', async () => {
|
||||
vm.itemFilterParams.name = null;
|
||||
vm.itemFilterParams = {};
|
||||
|
||||
await vm.onSubmit();
|
||||
|
||||
const expectedFilter = {
|
||||
include: [
|
||||
{ relation: 'producer', scope: { fields: ['name'] } },
|
||||
{ relation: 'ink', scope: { fields: ['name'] } },
|
||||
],
|
||||
where: {},
|
||||
};
|
||||
|
||||
expect(axios.get).toHaveBeenCalledWith('Items/withName', {
|
||||
params: { filter: JSON.stringify(expectedFilter) },
|
||||
});
|
||||
});
|
||||
|
||||
it('should emit "itemSelected" with the correct id and close the form', () => {
|
||||
vm.selectItem({ id: 12345 });
|
||||
expect(wrapper.emitted('itemSelected')[0]).toEqual([12345]);
|
||||
});
|
||||
});
|
|
@ -1,149 +0,0 @@
|
|||
import { describe, expect, it, beforeAll, vi, afterAll } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import FormModel from 'src/components/FormModel.vue';
|
||||
|
||||
describe('FormModel', () => {
|
||||
const model = 'mockModel';
|
||||
const url = 'mockUrl';
|
||||
const formInitialData = { mockKey: 'mockVal' };
|
||||
|
||||
describe('modelValue', () => {
|
||||
it('should use the provided model', () => {
|
||||
const { vm } = mount({ propsData: { model } });
|
||||
expect(vm.modelValue).toBe(model);
|
||||
});
|
||||
|
||||
it('should use the route meta title when model is not provided', () => {
|
||||
const { vm } = mount({});
|
||||
expect(vm.modelValue).toBe('formModel_mockTitle');
|
||||
});
|
||||
});
|
||||
|
||||
describe('onMounted()', () => {
|
||||
let mockGet;
|
||||
|
||||
beforeAll(() => {
|
||||
mockGet = vi.spyOn(axios, 'get').mockResolvedValue({ data: {} });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
mockGet.mockRestore();
|
||||
});
|
||||
|
||||
it('should not fetch when has formInitialData', () => {
|
||||
mount({ propsData: { url, model, autoLoad: true, formInitialData } });
|
||||
expect(mockGet).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should fetch when there is url and auto-load', () => {
|
||||
mount({ propsData: { url, model, autoLoad: true } });
|
||||
expect(mockGet).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not observe changes', () => {
|
||||
const { vm } = mount({
|
||||
propsData: { url, model, observeFormChanges: false, formInitialData },
|
||||
});
|
||||
|
||||
expect(vm.hasChanges).toBe(true);
|
||||
vm.reset();
|
||||
expect(vm.hasChanges).toBe(true);
|
||||
});
|
||||
|
||||
it('should observe changes', async () => {
|
||||
const { vm } = mount({
|
||||
propsData: { url, model, formInitialData },
|
||||
});
|
||||
vm.state.set(model, formInitialData);
|
||||
expect(vm.hasChanges).toBe(false);
|
||||
|
||||
vm.formData.mockKey = 'newVal';
|
||||
await vm.$nextTick();
|
||||
expect(vm.hasChanges).toBe(true);
|
||||
vm.formData.mockKey = 'mockVal';
|
||||
});
|
||||
});
|
||||
|
||||
describe('trimData()', () => {
|
||||
let vm;
|
||||
beforeAll(() => {
|
||||
vm = mount({}).vm;
|
||||
});
|
||||
|
||||
it('should trim whitespace from string values', () => {
|
||||
const data = { key1: ' value1 ', key2: ' value2 ' };
|
||||
const trimmedData = vm.trimData(data);
|
||||
expect(trimmedData).toEqual({ key1: 'value1', key2: 'value2' });
|
||||
});
|
||||
|
||||
it('should not modify non-string values', () => {
|
||||
const data = { key1: 123, key2: true, key3: null, key4: undefined };
|
||||
const trimmedData = vm.trimData(data);
|
||||
expect(trimmedData).toEqual(data);
|
||||
});
|
||||
});
|
||||
|
||||
describe('save()', async () => {
|
||||
it('should not call if there are not changes', async () => {
|
||||
const { vm } = mount({ propsData: { url, model } });
|
||||
|
||||
await vm.save();
|
||||
expect(vm.hasChanges).toBe(false);
|
||||
});
|
||||
|
||||
it('should call axios.patch with the right data', async () => {
|
||||
const spy = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
||||
const { vm } = mount({ propsData: { url, model, formInitialData } });
|
||||
vm.formData.mockKey = 'newVal';
|
||||
await vm.$nextTick();
|
||||
await vm.save();
|
||||
expect(spy).toHaveBeenCalled();
|
||||
vm.formData.mockKey = 'mockVal';
|
||||
});
|
||||
|
||||
it('should call axios.post with the right data', async () => {
|
||||
const spy = vi.spyOn(axios, 'post').mockResolvedValue({ data: {} });
|
||||
const { vm } = mount({
|
||||
propsData: { url, model, formInitialData, urlCreate: 'mockUrlCreate' },
|
||||
});
|
||||
vm.formData.mockKey = 'newVal';
|
||||
await vm.$nextTick();
|
||||
await vm.save();
|
||||
expect(spy).toHaveBeenCalled();
|
||||
vm.formData.mockKey = 'mockVal';
|
||||
});
|
||||
|
||||
it('should use the saveFn', async () => {
|
||||
const { vm } = mount({
|
||||
propsData: { url, model, formInitialData, saveFn: () => {} },
|
||||
});
|
||||
const spyPatch = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
||||
const spySaveFn = vi.spyOn(vm.$props, 'saveFn');
|
||||
|
||||
vm.formData.mockKey = 'newVal';
|
||||
await vm.$nextTick();
|
||||
await vm.save();
|
||||
expect(spyPatch).not.toHaveBeenCalled();
|
||||
expect(spySaveFn).toHaveBeenCalled();
|
||||
vm.formData.mockKey = 'mockVal';
|
||||
});
|
||||
|
||||
it('should reload the data after save', async () => {
|
||||
const { vm } = mount({
|
||||
propsData: { url, model, formInitialData, reload: true },
|
||||
});
|
||||
vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
||||
|
||||
vm.formData.mockKey = 'newVal';
|
||||
await vm.$nextTick();
|
||||
await vm.save();
|
||||
vm.formData.mockKey = 'mockVal';
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function mount({ propsData = {} }) {
|
||||
return createWrapper(FormModel, {
|
||||
propsData,
|
||||
});
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
<script setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { useHasContent } from 'src/composables/useHasContent';
|
||||
import { watch } from 'vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const stateStore = useStateStore();
|
||||
const hasContent = useHasContent('#advanced-menu');
|
||||
|
||||
const $props = defineProps({
|
||||
isMainSection: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
watch(
|
||||
() => $props.isMainSection,
|
||||
(val) => {
|
||||
if (stateStore) stateStore.rightAdvancedDrawer = val;
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
</script>
|
||||
<template>
|
||||
<Teleport to="#searchbar-after" v-if="stateStore.isHeaderMounted()">
|
||||
<QBtn
|
||||
v-if="hasContent || $slots['advanced-menu']"
|
||||
flat
|
||||
@click="stateStore.toggleRightAdvancedDrawer()"
|
||||
round
|
||||
icon="tune"
|
||||
color="white"
|
||||
>
|
||||
<QTooltip bottom anchor="bottom right">
|
||||
{{ t('globals.advancedMenu') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
</Teleport>
|
||||
<QDrawer
|
||||
v-model="stateStore.rightAdvancedDrawer"
|
||||
side="right"
|
||||
:width="256"
|
||||
:overlay="!isMainSection"
|
||||
v-bind="$attrs"
|
||||
>
|
||||
<QScrollArea class="fit">
|
||||
<div id="advanced-menu"></div>
|
||||
<slot v-if="!hasContent" name="advanced-menu" />
|
||||
</QScrollArea>
|
||||
</QDrawer>
|
||||
</template>
|
|
@ -1,23 +1,35 @@
|
|||
<script setup>
|
||||
import { onMounted, useSlots } from 'vue';
|
||||
import { ref, onMounted, useSlots } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useHasContent } from 'src/composables/useHasContent';
|
||||
|
||||
const { t } = useI18n();
|
||||
const quasar = useQuasar();
|
||||
const stateStore = useStateStore();
|
||||
const slots = useSlots();
|
||||
const hasContent = useHasContent('#right-panel');
|
||||
const hasContent = ref(false);
|
||||
const rightPanel = ref(null);
|
||||
|
||||
onMounted(() => {
|
||||
if ((!slots['right-panel'] && !hasContent.value) || quasar.platform.is.mobile)
|
||||
stateStore.rightDrawer = false;
|
||||
rightPanel.value = document.querySelector('#right-panel');
|
||||
if (!rightPanel.value) return;
|
||||
|
||||
// Check if there's content to display
|
||||
const observer = new MutationObserver(() => {
|
||||
hasContent.value = rightPanel.value.childNodes.length;
|
||||
});
|
||||
|
||||
observer.observe(rightPanel.value, {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
attributes: true,
|
||||
});
|
||||
|
||||
if (!slots['right-panel'] && !hasContent.value) stateStore.rightDrawer = false;
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
const stateStore = useStateStore();
|
||||
</script>
|
||||
<template>
|
||||
<Teleport to="#actions-prepend" v-if="stateStore.isHeaderMounted()">
|
||||
<Teleport to="#actions-append" v-if="stateStore.isHeaderMounted()">
|
||||
<div class="row q-gutter-x-sm">
|
||||
<QBtn
|
||||
v-if="hasContent || $slots['right-panel']"
|
||||
|
@ -26,7 +38,6 @@ onMounted(() => {
|
|||
round
|
||||
dense
|
||||
icon="dock_to_left"
|
||||
data-cy="toggle-right-drawer"
|
||||
>
|
||||
<QTooltip bottom anchor="bottom right">
|
||||
{{ t('globals.collapseMenu') }}
|
||||
|
@ -34,7 +45,7 @@ onMounted(() => {
|
|||
</QBtn>
|
||||
</div>
|
||||
</Teleport>
|
||||
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256">
|
||||
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
|
||||
<QScrollArea class="fit">
|
||||
<div id="right-panel"></div>
|
||||
<slot v-if="!hasContent" name="right-panel" />
|
||||
|
|
|
@ -15,7 +15,7 @@ let root = ref(null);
|
|||
|
||||
watchEffect(() => {
|
||||
matched.value = currentRoute.value.matched.filter(
|
||||
(matched) => !!matched?.meta?.title || !!matched?.meta?.icon
|
||||
(matched) => Object.keys(matched.meta).length
|
||||
);
|
||||
breadcrumbs.value.length = 0;
|
||||
if (!matched.value[0]) return;
|
||||
|
|
|
@ -14,7 +14,6 @@ defineProps({
|
|||
hide-dropdown-icon
|
||||
focus-on-mount
|
||||
@update:model-value="promise"
|
||||
data-cy="vnBtnSelect_select"
|
||||
/>
|
||||
</QBtnDropdown>
|
||||
</template>
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
<script setup>
|
||||
import { onBeforeMount, computed } from 'vue';
|
||||
import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import useCardSize from 'src/composables/useCardSize';
|
||||
import LeftMenu from 'components/LeftMenu.vue';
|
||||
import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
||||
|
||||
const props = defineProps({
|
||||
dataKey: { type: String, required: true },
|
||||
baseUrl: { type: String, default: undefined },
|
||||
customUrl: { type: String, default: undefined },
|
||||
filter: { type: Object, default: () => {} },
|
||||
userFilter: { type: Object, default: () => {} },
|
||||
descriptor: { type: Object, required: true },
|
||||
filterPanel: { type: Object, default: undefined },
|
||||
searchDataKey: { type: String, default: undefined },
|
||||
searchbarProps: { type: Object, default: undefined },
|
||||
redirectOnError: { type: Boolean, default: false },
|
||||
});
|
||||
|
||||
const stateStore = useStateStore();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const url = computed(() => {
|
||||
if (props.baseUrl) {
|
||||
return `${props.baseUrl}/${route.params.id}`;
|
||||
}
|
||||
return props.customUrl;
|
||||
});
|
||||
|
||||
const arrayData = useArrayData(props.dataKey, {
|
||||
url: url.value,
|
||||
filter: props.filter,
|
||||
userFilter: props.userFilter,
|
||||
});
|
||||
|
||||
onBeforeMount(async () => {
|
||||
try {
|
||||
if (!props.baseUrl) arrayData.store.filter.where = { id: route.params.id };
|
||||
await arrayData.fetch({ append: false, updateRouter: false });
|
||||
} catch {
|
||||
const { matched: matches } = router.currentRoute.value;
|
||||
const { path } = matches.at(-1);
|
||||
router.push({ path: path.replace(/:id.*/, '') });
|
||||
}
|
||||
});
|
||||
|
||||
if (props.baseUrl) {
|
||||
onBeforeRouteUpdate(async (to, from) => {
|
||||
if (to.params.id !== from.params.id) {
|
||||
arrayData.store.url = `${props.baseUrl}/${to.params.id}`;
|
||||
await arrayData.fetch({ append: false, updateRouter: false });
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Teleport to="#left-panel" v-if="stateStore.isHeaderMounted()">
|
||||
<component :is="descriptor" />
|
||||
<QSeparator />
|
||||
<LeftMenu source="card" />
|
||||
</Teleport>
|
||||
<VnSubToolbar />
|
||||
<div :class="[useCardSize(), $attrs.class]">
|
||||
<RouterView :key="route.path" />
|
||||
</div>
|
||||
</template>
|
|
@ -2,9 +2,9 @@
|
|||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import VnRow from '../ui/VnRow.vue';
|
||||
import VnInput from './VnInput.vue';
|
||||
import FetchData from '../FetchData.vue';
|
||||
import useNotify from 'src/composables/useNotify';
|
||||
import VnInputPassword from 'src/components/common/VnInputPassword.vue';
|
||||
|
||||
const props = defineProps({
|
||||
submitFn: { type: Function, default: () => {} },
|
||||
|
@ -70,19 +70,19 @@ defineExpose({ show: () => changePassDialog.value.show() });
|
|||
</QCardSection>
|
||||
<QForm ref="form">
|
||||
<QCardSection>
|
||||
<VnInputPassword
|
||||
<VnInput
|
||||
v-if="props.askOldPass"
|
||||
:label="t('Old password')"
|
||||
v-model="passwords.oldPassword"
|
||||
type="password"
|
||||
:required="true"
|
||||
:toggle-visibility="true"
|
||||
autofocus
|
||||
/>
|
||||
<VnInputPassword
|
||||
<VnInput
|
||||
:label="t('New password')"
|
||||
v-model="passwords.newPassword"
|
||||
type="password"
|
||||
:required="true"
|
||||
:toggle-visibility="true"
|
||||
:info="
|
||||
t('passwordRequirements', {
|
||||
length: requirements.length,
|
||||
|
@ -95,10 +95,10 @@ defineExpose({ show: () => changePassDialog.value.show() });
|
|||
autofocus
|
||||
/>
|
||||
|
||||
<VnInputPassword
|
||||
<VnInput
|
||||
:label="t('Repeat password')"
|
||||
v-model="passwords.repeatPassword"
|
||||
:toggle-visibility="true"
|
||||
type="password"
|
||||
/>
|
||||
</QCardSection>
|
||||
</QForm>
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
<script setup>
|
||||
import { toDateFormat } from 'src/filters/date.js';
|
||||
|
||||
defineProps({ date: { type: [Date, String], required: true } });
|
||||
|
||||
function getBadgeAttrs(date) {
|
||||
let today = Date.vnNew();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
let timeTicket = new Date(date);
|
||||
timeTicket.setHours(0, 0, 0, 0);
|
||||
|
||||
let timeDiff = today - timeTicket;
|
||||
|
||||
if (timeDiff == 0) return { color: 'warning', class: 'black-text-color' };
|
||||
if (timeDiff < 0) return { color: 'success', class: 'black-text-color' };
|
||||
return { color: 'transparent', class: 'normal-text-color' };
|
||||
}
|
||||
|
||||
function formatShippedDate(date) {
|
||||
if (!date) return '-';
|
||||
const dateSplit = date.split('T');
|
||||
const [year, month, day] = dateSplit[0].split('-');
|
||||
const newDate = new Date(year, month - 1, day);
|
||||
return toDateFormat(newDate);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<QBadge v-bind="getBadgeAttrs(date)" class="q-pa-sm" style="font-size: 14px">
|
||||
{{ formatShippedDate(date) }}
|
||||
</QBadge>
|
||||
</template>
|
||||
<style lang="scss">
|
||||
.black-text-color {
|
||||
color: var(--vn-black-text-color);
|
||||
}
|
||||
.normal-text-color {
|
||||
color: var(--vn-text-color);
|
||||
}
|
||||
</style>
|
|
@ -102,7 +102,7 @@ const columns = computed(() => [
|
|||
storage: 'dms',
|
||||
collection: null,
|
||||
resolution: null,
|
||||
id: Number(prop.row.file.split('.')[0]),
|
||||
id: prop.row.file.split('.')[0],
|
||||
token: token,
|
||||
class: 'rounded',
|
||||
ratio: 1,
|
||||
|
@ -202,7 +202,7 @@ const columns = computed(() => [
|
|||
prop.row.id,
|
||||
$props.downloadModel,
|
||||
undefined,
|
||||
prop.row.download,
|
||||
prop.row.download
|
||||
),
|
||||
},
|
||||
{
|
||||
|
@ -297,14 +297,13 @@ defineExpose({
|
|||
ref="dmsRef"
|
||||
:data-key="$props.model"
|
||||
:url="$props.model"
|
||||
:user-filter="dmsFilter"
|
||||
:filter="dmsFilter"
|
||||
:order="['dmsFk DESC']"
|
||||
auto-load
|
||||
:auto-load="true"
|
||||
@on-fetch="setData"
|
||||
>
|
||||
<template #body>
|
||||
<QTable
|
||||
v-if="rows"
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
class="full-width q-mt-md"
|
||||
|
@ -374,7 +373,7 @@ defineExpose({
|
|||
v-if="
|
||||
shouldRenderButton(
|
||||
button.name,
|
||||
props.row.isDocuware,
|
||||
props.row.isDocuware
|
||||
)
|
||||
"
|
||||
:is="button.component"
|
||||
|
|
|
@ -42,10 +42,6 @@ const $props = defineProps({
|
|||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
uppercase: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
const vnInputRef = ref(null);
|
||||
|
@ -75,7 +71,6 @@ const focus = () => {
|
|||
|
||||
defineExpose({
|
||||
focus,
|
||||
vnInputRef,
|
||||
});
|
||||
|
||||
const mixinRules = [
|
||||
|
@ -121,10 +116,6 @@ const handleInsertMode = (e) => {
|
|||
input.setSelectionRange(cursorPos + 1, cursorPos + 1);
|
||||
});
|
||||
};
|
||||
|
||||
const handleUppercase = () => {
|
||||
value.value = value.value?.toUpperCase() || '';
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -143,23 +134,20 @@ const handleUppercase = () => {
|
|||
hide-bottom-space
|
||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_input'"
|
||||
>
|
||||
<template #prepend>
|
||||
<template v-if="$slots.prepend" #prepend>
|
||||
<slot name="prepend" />
|
||||
</template>
|
||||
<template #append>
|
||||
<QIcon
|
||||
name="close"
|
||||
size="xs"
|
||||
:style="{
|
||||
visibility:
|
||||
hover &&
|
||||
value &&
|
||||
!$attrs.disabled &&
|
||||
!$attrs.readonly &&
|
||||
$props.clearable
|
||||
? 'visible'
|
||||
: 'hidden',
|
||||
}"
|
||||
v-if="
|
||||
hover &&
|
||||
value &&
|
||||
!$attrs.disabled &&
|
||||
!$attrs.readonly &&
|
||||
$props.clearable
|
||||
"
|
||||
@click="
|
||||
() => {
|
||||
value = null;
|
||||
|
@ -168,19 +156,6 @@ const handleUppercase = () => {
|
|||
}
|
||||
"
|
||||
></QIcon>
|
||||
|
||||
<QIcon
|
||||
name="match_case"
|
||||
size="xs"
|
||||
v-if="!$attrs.disabled && !($attrs.readonly) && $props.uppercase"
|
||||
@click="handleUppercase"
|
||||
class="uppercase-icon"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('Convert to uppercase') }}
|
||||
</QTooltip>
|
||||
</QIcon>
|
||||
|
||||
<slot name="append" v-if="$slots.append && !$attrs.disabled" />
|
||||
<QIcon v-if="info" name="info">
|
||||
<QTooltip max-width="350px">
|
||||
|
@ -191,27 +166,18 @@ const handleUppercase = () => {
|
|||
</QInput>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.uppercase-icon {
|
||||
transition: color 0.3s, transform 0.2s;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.uppercase-icon:hover {
|
||||
color: #ed9937;
|
||||
transform: scale(1.2);
|
||||
}
|
||||
</style>
|
||||
<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}
|
||||
Convert to uppercase: Convertir a mayúsculas
|
||||
</i18n>
|
||||
</i18n>
|
||||
<style lang="scss">
|
||||
.q-field__append {
|
||||
padding-inline: 0;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
<script setup>
|
||||
import { onMounted, watch, computed, ref, useAttrs } from 'vue';
|
||||
import { date } from 'quasar';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import VnDate from './VnDate.vue';
|
||||
import { useRequired } from 'src/composables/useRequired';
|
||||
|
||||
const $attrs = useAttrs();
|
||||
const { isRequired, requiredFieldRule } = useRequired($attrs);
|
||||
const model = defineModel({ type: [String, Date] });
|
||||
const { t } = useI18n();
|
||||
|
||||
const $props = defineProps({
|
||||
isOutlined: {
|
||||
|
@ -104,8 +106,7 @@ const manageDate = (date) => {
|
|||
:class="{ required: isRequired }"
|
||||
:rules="mixinRules"
|
||||
:clearable="false"
|
||||
@click="isPopupOpen = !isPopupOpen"
|
||||
@keydown="isPopupOpen = false"
|
||||
@click="isPopupOpen = true"
|
||||
hide-bottom-space
|
||||
>
|
||||
<template #append>
|
||||
|
@ -124,6 +125,13 @@ const manageDate = (date) => {
|
|||
isPopupOpen = false;
|
||||
"
|
||||
/>
|
||||
<QIcon
|
||||
v-if="showEvent"
|
||||
name="event"
|
||||
class="cursor-pointer"
|
||||
@click="isPopupOpen = !isPopupOpen"
|
||||
:title="t('Open date')"
|
||||
/>
|
||||
</template>
|
||||
<QMenu
|
||||
v-if="$q.screen.gt.xs"
|
||||
|
@ -143,6 +151,15 @@ const manageDate = (date) => {
|
|||
</QInput>
|
||||
</div>
|
||||
</template>
|
||||
<style lang="scss">
|
||||
.vn-input-date.q-field--standard.q-field--readonly .q-field__control:before {
|
||||
border-bottom-style: solid;
|
||||
}
|
||||
|
||||
.vn-input-date.q-field--outlined.q-field--readonly .q-field__control:before {
|
||||
border-style: solid;
|
||||
}
|
||||
</style>
|
||||
<i18n>
|
||||
es:
|
||||
Open date: Abrir fecha
|
||||
|
|
|
@ -1,28 +1,13 @@
|
|||
<script setup>
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
||||
defineProps({
|
||||
step: { type: Number, default: 0.01 },
|
||||
decimalPlaces: { type: Number, default: 2 },
|
||||
positive: { type: Boolean, default: true },
|
||||
});
|
||||
import { ref } from 'vue';
|
||||
import { useAttrs } from 'vue';
|
||||
|
||||
const model = defineModel({ type: [Number, String] });
|
||||
const $attrs = useAttrs();
|
||||
const step = ref($attrs.step || 0.01);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnInput
|
||||
v-bind="$attrs"
|
||||
v-model.number="model"
|
||||
type="number"
|
||||
:step="step"
|
||||
@input="
|
||||
(evt) => {
|
||||
const val = evt.target.value;
|
||||
if (positive && val < 0) return (model = 0);
|
||||
const [, decimal] = val.split('.');
|
||||
if (val && decimal?.length > decimalPlaces)
|
||||
model = parseFloat(val).toFixed(decimalPlaces);
|
||||
}
|
||||
"
|
||||
/>
|
||||
<VnInput v-bind="$attrs" v-model.number="model" type="number" :step="step" />
|
||||
</template>
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
<script setup>
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import { ref } from 'vue';
|
||||
|
||||
const model = defineModel({ type: [Number, String] });
|
||||
const $props = defineProps({
|
||||
toggleVisibility: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
const showPassword = ref(false);
|
||||
</script>
|
||||
<template>
|
||||
<VnInput
|
||||
v-bind="{ ...$attrs }"
|
||||
v-model="model"
|
||||
:type="
|
||||
$props.toggleVisibility ? (showPassword ? 'text' : 'password') : $attrs.type
|
||||
"
|
||||
>
|
||||
<template #append v-if="toggleVisibility">
|
||||
<QIcon
|
||||
:name="showPassword ? 'visibility_off' : 'visibility'"
|
||||
class="cursor-pointer"
|
||||
@click="showPassword = !showPassword"
|
||||
/>
|
||||
</template>
|
||||
</VnInput>
|
||||
</template>
|
|
@ -1,11 +1,13 @@
|
|||
<script setup>
|
||||
import { computed, ref, useAttrs } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { date } from 'quasar';
|
||||
import VnTime from './VnTime.vue';
|
||||
import { useRequired } from 'src/composables/useRequired';
|
||||
|
||||
const $attrs = useAttrs();
|
||||
const { isRequired, requiredFieldRule } = useRequired($attrs);
|
||||
const { t } = useI18n();
|
||||
const model = defineModel({ type: String });
|
||||
const props = defineProps({
|
||||
timeOnly: {
|
||||
|
@ -78,8 +80,7 @@ function dateToTime(newDate) {
|
|||
:class="{ required: isRequired }"
|
||||
style="min-width: 100px"
|
||||
:rules="mixinRules"
|
||||
@click="isPopupOpen = !isPopupOpen"
|
||||
@keydown="isPopupOpen = false"
|
||||
@click="isPopupOpen = false"
|
||||
type="time"
|
||||
hide-bottom-space
|
||||
>
|
||||
|
@ -99,6 +100,12 @@ function dateToTime(newDate) {
|
|||
isPopupOpen = false;
|
||||
"
|
||||
/>
|
||||
<QIcon
|
||||
name="Schedule"
|
||||
class="cursor-pointer"
|
||||
@click="isPopupOpen = !isPopupOpen"
|
||||
:title="t('Open time')"
|
||||
/>
|
||||
</template>
|
||||
<QMenu
|
||||
v-if="$q.screen.gt.xs"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import CreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue';
|
||||
import VnSelectDialog from 'components/common/VnSelectDialog.vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ref, watch } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
import { useAttrs } from 'vue';
|
||||
import { useRequired } from 'src/composables/useRequired';
|
||||
const { t } = useI18n();
|
||||
|
@ -16,14 +16,6 @@ const props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.location,
|
||||
(newValue) => {
|
||||
if (!modelValue.value) return;
|
||||
modelValue.value = formatLocation(newValue) ?? null;
|
||||
}
|
||||
);
|
||||
|
||||
const mixinRules = [requiredFieldRule];
|
||||
const locationProperties = [
|
||||
'postcode',
|
||||
|
@ -34,7 +26,7 @@ const locationProperties = [
|
|||
(obj) => obj.country?.name,
|
||||
];
|
||||
|
||||
const formatLocation = (obj, properties = locationProperties) => {
|
||||
const formatLocation = (obj, properties) => {
|
||||
const parts = properties.map((prop) => {
|
||||
if (typeof prop === 'string') {
|
||||
return obj[prop];
|
||||
|
@ -51,7 +43,9 @@ const formatLocation = (obj, properties = locationProperties) => {
|
|||
return filteredParts.join(', ');
|
||||
};
|
||||
|
||||
const modelValue = ref(props.location ? formatLocation(props.location) : null);
|
||||
const modelValue = ref(
|
||||
props.location ? formatLocation(props.location, locationProperties) : null
|
||||
);
|
||||
|
||||
function showLabel(data) {
|
||||
const dataProperties = [
|
||||
|
@ -81,6 +75,7 @@ const handleModelValue = (data) => {
|
|||
:input-debounce="300"
|
||||
:class="{ required: isRequired }"
|
||||
v-bind="$attrs"
|
||||
clearable
|
||||
:emit-value="false"
|
||||
:tooltip="t('Create new location')"
|
||||
:rules="mixinRules"
|
||||
|
|
|
@ -15,7 +15,6 @@ import FetchData from '../FetchData.vue';
|
|||
import VnSelect from './VnSelect.vue';
|
||||
import VnUserLink from '../ui/VnUserLink.vue';
|
||||
import VnPaginate from '../ui/VnPaginate.vue';
|
||||
import RightMenu from './RightMenu.vue';
|
||||
|
||||
const stateStore = useStateStore();
|
||||
const validationsStore = useValidator();
|
||||
|
@ -131,7 +130,7 @@ const actionsIcon = {
|
|||
};
|
||||
const validDate = new RegExp(
|
||||
/^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])/.source +
|
||||
/T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/.source,
|
||||
/T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/.source
|
||||
);
|
||||
|
||||
function castJsonValue(value) {
|
||||
|
@ -193,7 +192,7 @@ function getLogTree(data) {
|
|||
user: log.user,
|
||||
userFk: log.userFk,
|
||||
logs: [],
|
||||
}),
|
||||
})
|
||||
);
|
||||
}
|
||||
// Model
|
||||
|
@ -211,7 +210,7 @@ function getLogTree(data) {
|
|||
id: log.changedModelId,
|
||||
showValue: log.changedModelValue,
|
||||
logs: [],
|
||||
}),
|
||||
})
|
||||
);
|
||||
nLogs = 0;
|
||||
}
|
||||
|
@ -239,7 +238,6 @@ async function openPointRecord(id, modelLog) {
|
|||
pointRecord.value = parseProps(propNames, locale, data);
|
||||
}
|
||||
async function setLogTree(data) {
|
||||
if (!data) return;
|
||||
logTree.value = getLogTree(data);
|
||||
}
|
||||
|
||||
|
@ -283,7 +281,7 @@ function setDate(type) {
|
|||
to = date.adjustDate(
|
||||
to,
|
||||
{ hour: 21, minute: 59, second: 59, millisecond: 999 },
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
switch (type) {
|
||||
|
@ -366,7 +364,7 @@ async function clearFilter() {
|
|||
dateTo.value = undefined;
|
||||
userRadio.value = undefined;
|
||||
Object.keys(checkboxOptions.value).forEach(
|
||||
(opt) => (checkboxOptions.value[opt].selected = false),
|
||||
(opt) => (checkboxOptions.value[opt].selected = false)
|
||||
);
|
||||
await applyFilter();
|
||||
}
|
||||
|
@ -379,7 +377,7 @@ watch(
|
|||
() => router.currentRoute.value.params.id,
|
||||
() => {
|
||||
applyFilter();
|
||||
},
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<template>
|
||||
|
@ -392,7 +390,7 @@ watch(
|
|||
const changedModel = item.changedModel;
|
||||
return {
|
||||
locale: useCapitalize(
|
||||
validations[changedModel]?.locale?.name ?? changedModel,
|
||||
validations[changedModel]?.locale?.name ?? changedModel
|
||||
),
|
||||
value: changedModel,
|
||||
};
|
||||
|
@ -508,7 +506,7 @@ watch(
|
|||
:title="
|
||||
date.formatDate(
|
||||
log.creationDate,
|
||||
'DD/MM/YYYY hh:mm:ss',
|
||||
'DD/MM/YYYY hh:mm:ss'
|
||||
) ?? `date:'dd/MM/yyyy HH:mm:ss'`
|
||||
"
|
||||
>
|
||||
|
@ -578,7 +576,7 @@ watch(
|
|||
t(
|
||||
`actions.${
|
||||
actionsText[log.action]
|
||||
}`,
|
||||
}`
|
||||
)
|
||||
"
|
||||
/>
|
||||
|
@ -678,144 +676,139 @@ watch(
|
|||
</div>
|
||||
</template>
|
||||
</VnPaginate>
|
||||
<RightMenu>
|
||||
<template #right-panel>
|
||||
<QList dense>
|
||||
<QSeparator />
|
||||
<QItem class="q-mt-sm">
|
||||
<QInput
|
||||
:label="t('globals.search')"
|
||||
v-model="searchInput"
|
||||
class="full-width"
|
||||
clearable
|
||||
clear-icon="close"
|
||||
@keyup.enter="() => selectFilter('search')"
|
||||
@focusout="() => selectFilter('search')"
|
||||
@clear="() => selectFilter('search')"
|
||||
>
|
||||
<template #append>
|
||||
<QIcon name="info" class="cursor-pointer">
|
||||
<QTooltip>{{ t('tooltips.search') }}</QTooltip>
|
||||
</QIcon>
|
||||
</template>
|
||||
</QInput>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<Teleport to="#right-panel" v-if="stateStore.isHeaderMounted()">
|
||||
<QList dense>
|
||||
<QSeparator />
|
||||
<QItem class="q-mt-sm">
|
||||
<QInput
|
||||
:label="t('globals.search')"
|
||||
v-model="searchInput"
|
||||
class="full-width"
|
||||
clearable
|
||||
clear-icon="close"
|
||||
@keyup.enter="() => selectFilter('search')"
|
||||
@focusout="() => selectFilter('search')"
|
||||
@clear="() => selectFilter('search')"
|
||||
>
|
||||
<template #append>
|
||||
<QIcon name="info" class="cursor-pointer">
|
||||
<QTooltip>{{ t('tooltips.search') }}</QTooltip>
|
||||
</QIcon>
|
||||
</template>
|
||||
</QInput>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<VnSelect
|
||||
class="full-width"
|
||||
:label="t('globals.entity')"
|
||||
v-model="selectedFilters.changedModel"
|
||||
option-label="locale"
|
||||
option-value="value"
|
||||
:options="actions"
|
||||
@update:model-value="selectFilter('action')"
|
||||
hide-selected
|
||||
/>
|
||||
</QItem>
|
||||
<QItem class="q-mt-sm">
|
||||
<QOptionGroup
|
||||
size="sm"
|
||||
v-model="userRadio"
|
||||
:options="userTypes"
|
||||
color="primary"
|
||||
@update:model-value="selectFilter('userRadio')"
|
||||
right-label
|
||||
>
|
||||
<template #label="{ label }">
|
||||
{{ t(`Users.${label}`) }}
|
||||
</template>
|
||||
</QOptionGroup>
|
||||
</QItem>
|
||||
<QItem class="q-mt-sm">
|
||||
<QItemSection v-if="userRadio !== null">
|
||||
<VnSelect
|
||||
class="full-width"
|
||||
:label="t('globals.entity')"
|
||||
v-model="selectedFilters.changedModel"
|
||||
option-label="locale"
|
||||
option-value="value"
|
||||
:options="actions"
|
||||
@update:model-value="selectFilter('action')"
|
||||
:label="t('globals.user')"
|
||||
v-model="userSelect"
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
:url="`${model}Logs/${$route.params.id}/editors`"
|
||||
:fields="['id', 'nickname', 'name', 'image']"
|
||||
sort-by="nickname"
|
||||
@update:model-value="selectFilter('userSelect')"
|
||||
hide-selected
|
||||
/>
|
||||
</QItem>
|
||||
<QItem class="q-mt-sm">
|
||||
<QOptionGroup
|
||||
size="sm"
|
||||
v-model="userRadio"
|
||||
:options="userTypes"
|
||||
color="primary"
|
||||
@update:model-value="selectFilter('userRadio')"
|
||||
right-label
|
||||
>
|
||||
<template #label="{ label }">
|
||||
{{ t(`Users.${label}`) }}
|
||||
<template #option="{ opt, itemProps }">
|
||||
<QItem v-bind="itemProps" class="q-pa-xs row items-center">
|
||||
<QItemSection class="col-3 items-center">
|
||||
<VnAvatar :worker-id="opt.id" />
|
||||
</QItemSection>
|
||||
<QItemSection class="col-9 justify-center">
|
||||
<span>{{ opt.name }}</span>
|
||||
<span class="text-grey">{{ opt.nickname }}</span>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</QOptionGroup>
|
||||
</QItem>
|
||||
<QItem class="q-mt-sm">
|
||||
<QItemSection v-if="userRadio !== null">
|
||||
<VnSelect
|
||||
class="full-width"
|
||||
:label="t('globals.user')"
|
||||
v-model="userSelect"
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
:url="`${model}Logs/${route.params.id}/editors`"
|
||||
:fields="['id', 'nickname', 'name', 'image']"
|
||||
sort-by="nickname"
|
||||
@update:model-value="selectFilter('userSelect')"
|
||||
hide-selected
|
||||
>
|
||||
<template #option="{ opt, itemProps }">
|
||||
<QItem
|
||||
v-bind="itemProps"
|
||||
class="q-pa-xs row items-center"
|
||||
>
|
||||
<QItemSection class="col-3 items-center">
|
||||
<VnAvatar :worker-id="opt.id" />
|
||||
</QItemSection>
|
||||
<QItemSection class="col-9 justify-center">
|
||||
<span>{{ opt.name }}</span>
|
||||
<span class="text-grey">{{ opt.nickname }}</span>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelect>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem class="q-mt-sm">
|
||||
<QInput
|
||||
:label="t('globals.changes')"
|
||||
v-model="changeInput"
|
||||
class="full-width"
|
||||
clearable
|
||||
clear-icon="close"
|
||||
@keyup.enter="selectFilter('change')"
|
||||
@focusout="selectFilter('change')"
|
||||
@clear="selectFilter('change')"
|
||||
>
|
||||
<template #append>
|
||||
<QIcon name="info" class="cursor-pointer">
|
||||
<QTooltip max-width="250px">{{
|
||||
t('tooltips.changes')
|
||||
}}</QTooltip>
|
||||
</QIcon>
|
||||
</template>
|
||||
</QInput>
|
||||
</QItem>
|
||||
<QItem
|
||||
:class="index == 'create' ? 'q-mt-md' : 'q-mt-xs'"
|
||||
v-for="(checkboxOption, index) in checkboxOptions"
|
||||
:key="index"
|
||||
</VnSelect>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem class="q-mt-sm">
|
||||
<QInput
|
||||
:label="t('globals.changes')"
|
||||
v-model="changeInput"
|
||||
class="full-width"
|
||||
clearable
|
||||
clear-icon="close"
|
||||
@keyup.enter="selectFilter('change')"
|
||||
@focusout="selectFilter('change')"
|
||||
@clear="selectFilter('change')"
|
||||
>
|
||||
<QCheckbox
|
||||
size="sm"
|
||||
v-model="checkboxOption.selected"
|
||||
:label="t(`actions.${checkboxOption.label}`)"
|
||||
@update:model-value="selectFilter"
|
||||
/>
|
||||
</QItem>
|
||||
<QItem class="q-mt-sm">
|
||||
<QInput
|
||||
class="full-width"
|
||||
:label="t('globals.date')"
|
||||
@click="dateFromDialog = true"
|
||||
@focus="(evt) => evt.target.blur()"
|
||||
@clear="selectFilter('date', 'to')"
|
||||
v-model="dateFrom"
|
||||
clearable
|
||||
clear-icon="close"
|
||||
/>
|
||||
</QItem>
|
||||
<QItem class="q-mt-sm">
|
||||
<QInput
|
||||
class="full-width"
|
||||
:label="t('globals.to')"
|
||||
@click="dateToDialog = true"
|
||||
@focus="(evt) => evt.target.blur()"
|
||||
@clear="selectFilter('date', 'from')"
|
||||
v-model="dateTo"
|
||||
clearable
|
||||
clear-icon="close"
|
||||
/>
|
||||
</QItem>
|
||||
</QList>
|
||||
</template>
|
||||
</RightMenu>
|
||||
<template #append>
|
||||
<QIcon name="info" class="cursor-pointer">
|
||||
<QTooltip max-width="250px">{{
|
||||
t('tooltips.changes')
|
||||
}}</QTooltip>
|
||||
</QIcon>
|
||||
</template>
|
||||
</QInput>
|
||||
</QItem>
|
||||
<QItem
|
||||
:class="index == 'create' ? 'q-mt-md' : 'q-mt-xs'"
|
||||
v-for="(checkboxOption, index) in checkboxOptions"
|
||||
:key="index"
|
||||
>
|
||||
<QCheckbox
|
||||
size="sm"
|
||||
v-model="checkboxOption.selected"
|
||||
:label="t(`actions.${checkboxOption.label}`)"
|
||||
@update:model-value="selectFilter"
|
||||
/>
|
||||
</QItem>
|
||||
<QItem class="q-mt-sm">
|
||||
<QInput
|
||||
class="full-width"
|
||||
:label="t('globals.date')"
|
||||
@click="dateFromDialog = true"
|
||||
@focus="(evt) => evt.target.blur()"
|
||||
@clear="selectFilter('date', 'to')"
|
||||
v-model="dateFrom"
|
||||
clearable
|
||||
clear-icon="close"
|
||||
/>
|
||||
</QItem>
|
||||
<QItem class="q-mt-sm">
|
||||
<QInput
|
||||
class="full-width"
|
||||
:label="t('to')"
|
||||
@click="dateToDialog = true"
|
||||
@focus="(evt) => evt.target.blur()"
|
||||
@clear="selectFilter('date', 'from')"
|
||||
v-model="dateTo"
|
||||
clearable
|
||||
clear-icon="close"
|
||||
/>
|
||||
</QItem>
|
||||
</QList>
|
||||
</Teleport>
|
||||
<QDialog v-model="dateFromDialog">
|
||||
<QDate
|
||||
:years-in-month-view="false"
|
||||
|
@ -1059,9 +1052,9 @@ en:
|
|||
Deletes: Deletes
|
||||
Accesses: Accesses
|
||||
Users:
|
||||
User: User
|
||||
All: All
|
||||
System: System
|
||||
User: Usuario
|
||||
All: Todo
|
||||
System: Sistema
|
||||
properties:
|
||||
id: ID
|
||||
claimFk: Claim ID
|
||||
|
|
|
@ -1,115 +0,0 @@
|
|||
<script setup>
|
||||
import RightAdvancedMenu from './RightAdvancedMenu.vue';
|
||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||
import VnTableFilter from '../VnTable/VnTableFilter.vue';
|
||||
import { onBeforeMount, onMounted, onUnmounted, computed, ref } from 'vue';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useHasContent } from 'src/composables/useHasContent';
|
||||
|
||||
const $props = defineProps({
|
||||
section: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
dataKey: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
searchBar: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
prefix: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
rightFilter: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
columns: {
|
||||
type: Array,
|
||||
default: null,
|
||||
},
|
||||
arrayDataProps: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
redirect: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
keepData: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
let arrayData;
|
||||
const sectionValue = computed(() => $props.section ?? $props.dataKey);
|
||||
const isMainSection = ref(false);
|
||||
|
||||
const searchbarId = 'section-searchbar';
|
||||
const advancedMenuSlot = 'advanced-menu';
|
||||
const hasContent = useHasContent(`#${searchbarId}`);
|
||||
|
||||
onBeforeMount(() => {
|
||||
if ($props.dataKey)
|
||||
arrayData = useArrayData($props.dataKey, {
|
||||
searchUrl: 'table',
|
||||
keepData: $props.keepData,
|
||||
...$props.arrayDataProps,
|
||||
navigate: $props.redirect,
|
||||
});
|
||||
checkIsMain();
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
const unsubscribe = router.afterEach(() => {
|
||||
checkIsMain();
|
||||
});
|
||||
onUnmounted(unsubscribe);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
if (arrayData) arrayData.destroy();
|
||||
});
|
||||
|
||||
function checkIsMain() {
|
||||
isMainSection.value = sectionValue.value == route.name;
|
||||
if (!isMainSection.value && arrayData) {
|
||||
arrayData.reset(['userParams', 'filter']);
|
||||
arrayData.setCurrentFilter();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<slot name="searchbar">
|
||||
<VnSearchbar
|
||||
v-if="searchBar && !hasContent"
|
||||
v-bind="arrayDataProps"
|
||||
:data-key="dataKey"
|
||||
:label="$t(`${prefix}.search`)"
|
||||
:info="$t(`${prefix}.searchInfo`)"
|
||||
/>
|
||||
<div :id="searchbarId"></div>
|
||||
</slot>
|
||||
<RightAdvancedMenu :is-main-section="isMainSection">
|
||||
<template #advanced-menu v-if="$slots[advancedMenuSlot] || rightFilter">
|
||||
<slot :name="advancedMenuSlot">
|
||||
<VnTableFilter
|
||||
v-if="rightFilter && columns"
|
||||
:data-key="dataKey"
|
||||
:array-data="arrayData"
|
||||
:columns="columns"
|
||||
/>
|
||||
</slot>
|
||||
</template>
|
||||
</RightAdvancedMenu>
|
||||
<slot name="body" v-if="isMainSection" />
|
||||
<RouterView v-else />
|
||||
</template>
|
|
@ -1,8 +1,8 @@
|
|||
<script setup>
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import LeftMenu from 'components/LeftMenu.vue';
|
||||
import { onMounted } from 'vue';
|
||||
import { useQuasar } from 'quasar';
|
||||
import LeftMenu from '../LeftMenu.vue';
|
||||
|
||||
const stateStore = useStateStore();
|
||||
const $props = defineProps({
|
||||
|
@ -14,29 +14,12 @@ const $props = defineProps({
|
|||
onMounted(
|
||||
() => (stateStore.leftDrawer = useQuasar().screen.gt.xs ? $props.leftDrawer : false)
|
||||
);
|
||||
|
||||
const teleportRef = ref({});
|
||||
const hasContent = ref();
|
||||
let observer;
|
||||
|
||||
onMounted(() => {
|
||||
if (!teleportRef.value) return;
|
||||
const checkContent = () => {
|
||||
hasContent.value = teleportRef.value?.innerHTML?.trim() !== '';
|
||||
};
|
||||
|
||||
observer = new MutationObserver(checkContent);
|
||||
observer.observe(teleportRef.value, { childList: true, subtree: true });
|
||||
|
||||
checkContent();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<QDrawer v-model="stateStore.leftDrawer" show-if-above :width="256">
|
||||
<QScrollArea class="fit text-grey-8">
|
||||
<div id="left-panel" ref="teleportRef"></div>
|
||||
<LeftMenu v-if="!hasContent" />
|
||||
<LeftMenu />
|
||||
</QScrollArea>
|
||||
</QDrawer>
|
||||
<QPageContainer>
|
|
@ -4,19 +4,11 @@ import { useI18n } from 'vue-i18n';
|
|||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { useRequired } from 'src/composables/useRequired';
|
||||
import dataByOrder from 'src/utils/dataByOrder';
|
||||
import { QItemLabel } from 'quasar';
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'update:options', 'remove']);
|
||||
const $attrs = useAttrs();
|
||||
const { t } = useI18n();
|
||||
|
||||
const isRequired = computed(() => {
|
||||
return useRequired($attrs).isRequired;
|
||||
});
|
||||
const requiredFieldRule = computed(() => {
|
||||
return useRequired($attrs).requiredFieldRule;
|
||||
});
|
||||
|
||||
const { isRequired, requiredFieldRule } = useRequired($attrs);
|
||||
const $props = defineProps({
|
||||
modelValue: {
|
||||
type: [String, Number, Object],
|
||||
|
@ -27,17 +19,13 @@ const $props = defineProps({
|
|||
default: () => [],
|
||||
},
|
||||
optionLabel: {
|
||||
type: [String, Function],
|
||||
type: [String],
|
||||
default: 'name',
|
||||
},
|
||||
optionValue: {
|
||||
type: String,
|
||||
default: 'id',
|
||||
},
|
||||
optionCaption: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
optionFilter: {
|
||||
type: String,
|
||||
default: null,
|
||||
|
@ -106,22 +94,11 @@ const $props = defineProps({
|
|||
type: String,
|
||||
default: null,
|
||||
},
|
||||
isOutlined: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
const mixinRules = [requiredFieldRule, ...($attrs.rules ?? [])];
|
||||
const {
|
||||
optionLabel,
|
||||
optionValue,
|
||||
optionCaption,
|
||||
optionFilter,
|
||||
optionFilterValue,
|
||||
options,
|
||||
modelValue,
|
||||
} = toRefs($props);
|
||||
const { optionLabel, optionValue, optionFilter, optionFilterValue, options, modelValue } =
|
||||
toRefs($props);
|
||||
const myOptions = ref([]);
|
||||
const myOptionsOriginal = ref([]);
|
||||
const vnSelectRef = ref();
|
||||
|
@ -131,15 +108,6 @@ const noOneOpt = ref({
|
|||
[optionValue.value]: false,
|
||||
[optionLabel.value]: noOneText,
|
||||
});
|
||||
const styleAttrs = computed(() => {
|
||||
return $props.isOutlined
|
||||
? {
|
||||
dense: true,
|
||||
outlined: true,
|
||||
rounded: true,
|
||||
}
|
||||
: {};
|
||||
});
|
||||
const isLoading = ref(false);
|
||||
const useURL = computed(() => $props.url);
|
||||
const value = computed({
|
||||
|
@ -173,11 +141,7 @@ onMounted(() => {
|
|||
const arrayDataKey =
|
||||
$props.dataKey ?? ($props.url?.length > 0 ? $props.url : $attrs.name ?? $attrs.label);
|
||||
|
||||
const arrayData = useArrayData(arrayDataKey, {
|
||||
url: $props.url,
|
||||
searchUrl: false,
|
||||
mapKey: $attrs['map-key'],
|
||||
});
|
||||
const arrayData = useArrayData(arrayDataKey, { url: $props.url, searchUrl: false });
|
||||
|
||||
function findKeyInOptions() {
|
||||
if (!$props.options) return;
|
||||
|
@ -205,10 +169,10 @@ function filter(val, options) {
|
|||
}
|
||||
|
||||
if (!row) return;
|
||||
const id = String(row[$props.optionValue]);
|
||||
const id = row[$props.optionValue];
|
||||
const optionLabel = String(row[$props.optionLabel]).toLowerCase();
|
||||
|
||||
return id.includes(search) || optionLabel.includes(search);
|
||||
return id == search || optionLabel.includes(search);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -232,15 +196,12 @@ async function fetchFilter(val) {
|
|||
} else defaultWhere = { [key]: getVal(val) };
|
||||
const where = { ...(val ? defaultWhere : {}), ...$props.where };
|
||||
$props.exprBuilder && Object.assign(where, $props.exprBuilder(key, val));
|
||||
const filterOptions = { where, include, limit };
|
||||
if (fields) filterOptions.fields = fields;
|
||||
if (sortBy) filterOptions.order = sortBy;
|
||||
arrayData.resetPagination();
|
||||
const fetchOptions = { where, include, limit };
|
||||
if (fields) fetchOptions.fields = fields;
|
||||
if (sortBy) fetchOptions.order = sortBy;
|
||||
arrayData.reset(['skip', 'filter.skip', 'page']);
|
||||
|
||||
const { data } = await arrayData.applyFilter(
|
||||
{ filter: filterOptions },
|
||||
{ updateRouter: false }
|
||||
);
|
||||
const { data } = await arrayData.applyFilter({ filter: fetchOptions });
|
||||
setOptions(data);
|
||||
return data;
|
||||
}
|
||||
|
@ -297,10 +258,10 @@ async function onScroll({ to, direction, from, index }) {
|
|||
}
|
||||
}
|
||||
|
||||
defineExpose({ opts: myOptions, vnSelectRef });
|
||||
defineExpose({ opts: myOptions });
|
||||
|
||||
function handleKeyDown(event) {
|
||||
if (event.key === 'Tab' && !event.shiftKey) {
|
||||
if (event.key === 'Tab') {
|
||||
event.preventDefault();
|
||||
|
||||
const inputValue = vnSelectRef.value?.inputValue;
|
||||
|
@ -318,24 +279,8 @@ function handleKeyDown(event) {
|
|||
}
|
||||
vnSelectRef.value?.hidePopup();
|
||||
}
|
||||
|
||||
const focusableElements = document.querySelectorAll(
|
||||
'a:not([disabled]), button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), details:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled])'
|
||||
);
|
||||
const currentIndex = Array.prototype.indexOf.call(
|
||||
focusableElements,
|
||||
event.target
|
||||
);
|
||||
if (currentIndex >= 0 && currentIndex < focusableElements.length - 1) {
|
||||
focusableElements[currentIndex + 1].focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getCaption(opt) {
|
||||
if (optionCaption.value === false) return;
|
||||
return opt[optionCaption.value] || opt[optionValue.value];
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -344,8 +289,9 @@ function getCaption(opt) {
|
|||
:options="myOptions"
|
||||
:option-label="optionLabel"
|
||||
:option-value="optionValue"
|
||||
v-bind="{ ...$attrs, ...styleAttrs }"
|
||||
v-bind="$attrs"
|
||||
@filter="filterHandler"
|
||||
@keydown="handleKeyDown"
|
||||
:emit-value="nullishToTrue($attrs['emit-value'])"
|
||||
:map-options="nullishToTrue($attrs['map-options'])"
|
||||
:use-input="nullishToTrue($attrs['use-input'])"
|
||||
|
@ -360,15 +306,13 @@ function getCaption(opt) {
|
|||
:input-debounce="useURL ? '300' : '0'"
|
||||
:loading="isLoading"
|
||||
@virtual-scroll="onScroll"
|
||||
@keydown="handleKeyDown"
|
||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_select'"
|
||||
:data-url="url"
|
||||
>
|
||||
<template #append>
|
||||
<template v-if="isClearable" #append>
|
||||
<QIcon
|
||||
v-show="isClearable && value"
|
||||
v-show="value"
|
||||
name="close"
|
||||
@click="
|
||||
@click.stop="
|
||||
() => {
|
||||
value = null;
|
||||
emit('remove');
|
||||
|
@ -379,38 +323,7 @@ function getCaption(opt) {
|
|||
/>
|
||||
</template>
|
||||
<template v-for="(_, slotName) in $slots" #[slotName]="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>
|
||||
<template #option="{ opt, itemProps }">
|
||||
<QItem v-bind="itemProps">
|
||||
<QItemSection v-if="typeof opt !== 'object'"> {{ opt }}</QItemSection>
|
||||
<QItemSection v-else-if="opt[optionValue] == opt[optionLabel]">
|
||||
<QItemLabel>{{ opt[optionLabel] }}</QItemLabel>
|
||||
</QItemSection>
|
||||
<QItemSection v-else>
|
||||
<QItemLabel>
|
||||
{{ opt[optionLabel] }}
|
||||
</QItemLabel>
|
||||
<QItemLabel caption v-if="getCaption(opt)">
|
||||
{{ `#${getCaption(opt)}` }}
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
||||
</template>
|
||||
</QSelect>
|
||||
</template>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
import { useRole } from 'src/composables/useRole';
|
||||
import { useAcl } from 'src/composables/useAcl';
|
||||
|
||||
|
@ -7,7 +7,6 @@ import VnSelect from 'src/components/common/VnSelect.vue';
|
|||
const emit = defineEmits(['update:modelValue']);
|
||||
|
||||
const value = defineModel({ type: [String, Number, Object] });
|
||||
const select = ref(null);
|
||||
const $props = defineProps({
|
||||
rolesAllowedToCreate: {
|
||||
type: Array,
|
||||
|
@ -34,20 +33,16 @@ const isAllowedToCreate = computed(() => {
|
|||
if ($props.acls.length) return acl.hasAny($props.acls);
|
||||
return role.hasAny($props.rolesAllowedToCreate);
|
||||
});
|
||||
|
||||
defineExpose({ vnSelectDialogRef: select });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnSelect
|
||||
ref="select"
|
||||
v-model="value"
|
||||
v-bind="$attrs"
|
||||
@update:model-value="(...args) => emit('update:modelValue', ...args)"
|
||||
>
|
||||
<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'"
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import VnSelect from 'components/common/VnSelect.vue';
|
||||
|
||||
const model = defineModel({ type: [String, Number, Object] });
|
||||
const url = 'Suppliers';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnSelect
|
||||
:label="$t('globals.supplier')"
|
||||
v-bind="$attrs"
|
||||
v-model="model"
|
||||
:url="url"
|
||||
option-value="id"
|
||||
option-label="nickname"
|
||||
:fields="['id', 'name', 'nickname', 'nif']"
|
||||
sort-by="name ASC"
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel>
|
||||
{{ scope.opt?.name }}
|
||||
</QItemLabel>
|
||||
<QItemLabel caption>
|
||||
{{
|
||||
`#${scope.opt?.id} , ${scope.opt?.nickname} (${scope.opt?.nif})`
|
||||
}}
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelect>
|
||||
</template>
|
|
@ -1,88 +0,0 @@
|
|||
<script setup>
|
||||
import { computed, useAttrs } from 'vue';
|
||||
import VnSelect from 'components/common/VnSelect.vue';
|
||||
import VnAvatar from 'src/components/ui/VnAvatar.vue';
|
||||
|
||||
const emit = defineEmits(['update:modelValue']);
|
||||
const $props = defineProps({
|
||||
hasAvatar: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
info: {
|
||||
type: String,
|
||||
default: undefined,
|
||||
},
|
||||
modelValue: {
|
||||
type: [String, Number, Object],
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
|
||||
const $attrs = useAttrs();
|
||||
|
||||
const value = computed({
|
||||
get() {
|
||||
return $props.modelValue;
|
||||
},
|
||||
set(val) {
|
||||
emit('update:modelValue', val);
|
||||
},
|
||||
});
|
||||
|
||||
const url = computed(() => {
|
||||
let url = 'Workers/search';
|
||||
const { departmentCodes } = $attrs.params ?? {};
|
||||
if (!departmentCodes) return url;
|
||||
const params = new URLSearchParams({
|
||||
departmentCodes: JSON.stringify(departmentCodes),
|
||||
});
|
||||
|
||||
return url.concat(`?${params.toString()}`);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnSelect
|
||||
:label="$t('globals.worker')"
|
||||
v-bind="$attrs"
|
||||
v-model="value"
|
||||
:url="url"
|
||||
option-value="id"
|
||||
option-label="nickname"
|
||||
:fields="['id', 'name', 'nickname', 'code']"
|
||||
:filter-options="['id', 'name', 'nickname', 'code']"
|
||||
sort-by="nickname ASC"
|
||||
data-cy="vnWorkerSelect"
|
||||
>
|
||||
<template #prepend v-if="$props.hasAvatar">
|
||||
<VnAvatar :worker-id="value" color="primary" v-bind="$attrs" />
|
||||
</template>
|
||||
<template #append v-if="$props.info">
|
||||
<QIcon name="info" class="cursor-pointer">
|
||||
<QTooltip>{{ $t($props.info) }}</QTooltip>
|
||||
</QIcon>
|
||||
</template>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel>
|
||||
{{ scope.opt.name }}
|
||||
</QItemLabel>
|
||||
<QItemLabel v-if="!scope.opt.id">
|
||||
{{ scope.opt.nickname }}
|
||||
</QItemLabel>
|
||||
<QItemLabel caption v-else>
|
||||
#{{ scope.opt.id }}, {{ scope.opt.nickname }},
|
||||
{{ scope.opt.code }}
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelect>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
Responsible for approving invoices: Responsable de aprobar las facturas
|
||||
</i18n>
|
|
@ -10,10 +10,6 @@ defineProps({
|
|||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
width: {
|
||||
type: String,
|
||||
default: 'md-width',
|
||||
},
|
||||
});
|
||||
|
||||
defineEmits([...useDialogPluginComponent.emits]);
|
||||
|
@ -21,19 +17,7 @@ defineEmits([...useDialogPluginComponent.emits]);
|
|||
const { dialogRef, onDialogHide } = useDialogPluginComponent();
|
||||
</script>
|
||||
<template>
|
||||
<QDialog ref="dialogRef" @hide="onDialogHide">
|
||||
<component :is="summary" :id="id" :class="width" />
|
||||
<QDialog ref="dialogRef" @hide="onDialogHide" full-width>
|
||||
<component :is="summary" :id="id" />
|
||||
</QDialog>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.md-width {
|
||||
max-width: $width-md;
|
||||
}
|
||||
.lg-width {
|
||||
max-width: $width-lg;
|
||||
}
|
||||
.xlg-width {
|
||||
max-width: $width-xl;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import VnDiscount from 'components/common/vnDiscount.vue';
|
||||
|
||||
describe('VnDiscount', () => {
|
||||
let vm;
|
||||
|
||||
beforeAll(() => {
|
||||
vm = createWrapper(VnDiscount, {
|
||||
props: {
|
||||
data: {},
|
||||
price: 100,
|
||||
quantity: 2,
|
||||
discount: 10,
|
||||
}
|
||||
}).vm;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('total', () => {
|
||||
it('should calculate total correctly', () => {
|
||||
expect(vm.total).toBe(180);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,146 +0,0 @@
|
|||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import { vi, afterEach, beforeEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
import VnDms from 'src/components/common/VnDms.vue';
|
||||
|
||||
class MockFormData {
|
||||
constructor() {
|
||||
this.entries = {};
|
||||
}
|
||||
|
||||
append(key, value) {
|
||||
if (!key) {
|
||||
throw new Error('Key is required for FormData.append');
|
||||
}
|
||||
this.entries[key] = value;
|
||||
}
|
||||
|
||||
get(key) {
|
||||
return this.entries[key] || null;
|
||||
}
|
||||
|
||||
getAll() {
|
||||
return this.entries;
|
||||
}
|
||||
}
|
||||
|
||||
global.FormData = MockFormData;
|
||||
|
||||
describe('VnDms', () => {
|
||||
let wrapper;
|
||||
let vm;
|
||||
let postMock;
|
||||
|
||||
const postResponseMock = { data: { success: true } };
|
||||
|
||||
const data = {
|
||||
hasFile: true,
|
||||
hasFileAttached: true,
|
||||
reference: 'DMS-test',
|
||||
warehouseFk: 1,
|
||||
companyFk: 2,
|
||||
dmsTypeFk: 3,
|
||||
description: 'This is a test description',
|
||||
files: { name: 'example.txt', content: new Blob(['file content'], { type: 'text/plain' })},
|
||||
};
|
||||
|
||||
const expectedBody = {
|
||||
hasFile: true,
|
||||
hasFileAttached: true,
|
||||
reference: 'DMS-test',
|
||||
warehouseId: 1,
|
||||
companyId: 2,
|
||||
dmsTypeId: 3,
|
||||
description: 'This is a test description',
|
||||
};
|
||||
|
||||
beforeAll(() => {
|
||||
wrapper = createWrapper(VnDms, {
|
||||
propsData: {
|
||||
url: '/test',
|
||||
formInitialData: { id: 1, reference: 'test' },
|
||||
model: 'Worker',
|
||||
}
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
vm = wrapper.vm;
|
||||
vi.spyOn(vm, '$emit');
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
postMock = vi.spyOn(axios, 'post').mockResolvedValue(postResponseMock);
|
||||
vm.dms = data;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('mapperDms', () => {
|
||||
it('should map DMS data correctly and add file to FormData', () => {
|
||||
const [formData, params] = vm.mapperDms(data);
|
||||
|
||||
expect(formData.get('example.txt')).toBe(data.files);
|
||||
expect(expectedBody).toEqual(params.params);
|
||||
});
|
||||
|
||||
it('should map DMS data correctly without file', () => {
|
||||
delete data.files;
|
||||
|
||||
const [formData, params] = vm.mapperDms(data);
|
||||
|
||||
expect(formData.getAll()).toEqual({});
|
||||
expect(expectedBody).toEqual(params.params);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getUrl', () => {
|
||||
it('should returns prop url when is set', async () => {
|
||||
expect(vm.getUrl()).toBe('/test');
|
||||
});
|
||||
|
||||
it('should returns url dms/"props.formInitialData.id"/updateFile when prop url is null', async () => {
|
||||
await wrapper.setProps({ url: null });
|
||||
expect(vm.getUrl()).toBe('dms/1/updateFile');
|
||||
});
|
||||
|
||||
it('should returns url "props.model"/"route.params.id"/uploadFile when formInitialData is null', async () => {
|
||||
await wrapper.setProps({ formInitialData: null });
|
||||
vm.route.params.id = '123';
|
||||
expect(vm.getUrl()).toBe('Worker/123/uploadFile');
|
||||
});
|
||||
});
|
||||
|
||||
describe('save', () => {
|
||||
it('should save data correctly', async () => {
|
||||
await vm.save();
|
||||
expect(postMock).toHaveBeenCalledWith(vm.getUrl(), expect.any(FormData), { params: expectedBody });
|
||||
expect(wrapper.emitted('onDataSaved')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('defaultData', () => {
|
||||
it('should set dms with formInitialData', async () => {
|
||||
const testData = {
|
||||
hasFile: false,
|
||||
hasFileAttached: false,
|
||||
reference: 'defaultData-test',
|
||||
warehouseFk: 2,
|
||||
companyFk: 3,
|
||||
dmsTypeFk: 2,
|
||||
description: 'This is a test description'
|
||||
}
|
||||
await wrapper.setProps({ formInitialData: testData });
|
||||
vm.defaultData();
|
||||
|
||||
expect(vm.dms).toEqual(testData);
|
||||
});
|
||||
|
||||
it('should add reference with "route.params.id" to dms if formInitialData is null', async () => {
|
||||
await wrapper.setProps({ formInitialData: null });
|
||||
vm.route.params.id= '111';
|
||||
vm.defaultData();
|
||||
|
||||
expect(vm.dms.reference).toBe('111');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,87 +0,0 @@
|
|||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import VnDmsList from 'src/components/common/VnDmsList.vue';
|
||||
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
describe('VnDmsList', () => {
|
||||
let vm;
|
||||
const dms = {
|
||||
userFk: 1,
|
||||
name: 'DMS 1'
|
||||
};
|
||||
|
||||
beforeAll(() => {
|
||||
vi.spyOn(axios, 'get').mockResolvedValue({ data: [] });
|
||||
vm = createWrapper(VnDmsList, {
|
||||
props: {
|
||||
model: 'WorkerDms/1110/filter',
|
||||
defaultDmsCode: 'hhrrData',
|
||||
filter: 'wd.workerFk',
|
||||
updateModel: 'Workers',
|
||||
deleteModel: 'WorkerDms',
|
||||
downloadModel: 'WorkerDms'
|
||||
}
|
||||
}).vm;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('setData()', () => {
|
||||
const data = [
|
||||
{
|
||||
userFk: 1,
|
||||
name: 'Jessica',
|
||||
lastName: 'Jones',
|
||||
file: '4.jpg',
|
||||
created: '2021-07-28 21:00:00'
|
||||
},
|
||||
{
|
||||
userFk: 2,
|
||||
name: 'Bruce',
|
||||
lastName: 'Banner',
|
||||
created: '2022-07-28 21:00:00',
|
||||
dms: {
|
||||
userFk: 2,
|
||||
name: 'Bruce',
|
||||
lastName: 'BannerDMS',
|
||||
created: '2022-07-28 21:00:00',
|
||||
file: '4.jpg',
|
||||
}
|
||||
},
|
||||
{
|
||||
userFk: 3,
|
||||
name: 'Natasha',
|
||||
lastName: 'Romanoff',
|
||||
file: '4.jpg',
|
||||
created: '2021-10-28 21:00:00'
|
||||
}
|
||||
]
|
||||
|
||||
it('Should replace objects that contain the "dms" property with the value of the same and sort by creation date', () => {
|
||||
vm.setData(data);
|
||||
expect([vm.rows][0][0].lastName).toEqual('BannerDMS');
|
||||
expect([vm.rows][0][1].lastName).toEqual('Romanoff');
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseDms()', () => {
|
||||
const resultDms = { ...dms, userId:1};
|
||||
|
||||
it('Should add properties that end with "Fk" by changing the suffix to "Id"', () => {
|
||||
const parsedDms = vm.parseDms(dms);
|
||||
expect(parsedDms).toEqual(resultDms);
|
||||
});
|
||||
});
|
||||
|
||||
describe('showFormDialog()', () => {
|
||||
const resultDms = { ...dms, userId:1};
|
||||
|
||||
it('should call fn parseDms() and set show true if dms is defined', () => {
|
||||
vm.showFormDialog(dms);
|
||||
expect(vm.formDialog.show).toEqual(true);
|
||||
expect(vm.formDialog.dms).toEqual(resultDms);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,91 +0,0 @@
|
|||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import { vi, describe, expect, it } from 'vitest';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
||||
|
||||
describe('VnInput', () => {
|
||||
let vm;
|
||||
let wrapper;
|
||||
let input;
|
||||
|
||||
function generateWrapper(value, isOutlined, emptyToNull, insertable) {
|
||||
wrapper = createWrapper(VnInput, {
|
||||
props: {
|
||||
modelValue: value,
|
||||
isOutlined, emptyToNull, insertable,
|
||||
maxlength: 101
|
||||
},
|
||||
attrs: {
|
||||
label: 'test',
|
||||
required: true,
|
||||
maxlength: 101,
|
||||
maxLength: 10,
|
||||
'max-length':20
|
||||
},
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
vm = wrapper.vm;
|
||||
input = wrapper.find('[data-cy="test_input"]');
|
||||
};
|
||||
|
||||
describe('value', () => {
|
||||
it('should emit update:modelValue when value changes', async () => {
|
||||
generateWrapper('12345', false, false, true)
|
||||
await input.setValue('123');
|
||||
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
||||
expect(wrapper.emitted('update:modelValue')[0]).toEqual(['123']);
|
||||
});
|
||||
|
||||
it('should emit update:modelValue with null when input is empty', async () => {
|
||||
generateWrapper('12345', false, true, true);
|
||||
await input.setValue('');
|
||||
expect(wrapper.emitted('update:modelValue')[0]).toEqual([null]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('styleAttrs', () => {
|
||||
it('should return empty styleAttrs when isOutlined is false', async () => {
|
||||
generateWrapper('123', false, false, false);
|
||||
expect(vm.styleAttrs).toEqual({});
|
||||
});
|
||||
|
||||
it('should set styleAttrs when isOutlined is true', async () => {
|
||||
generateWrapper('123', true, false, false);
|
||||
expect(vm.styleAttrs.outlined).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('handleKeydown', () => {
|
||||
it('should do nothing when "Backspace" key is pressed', async () => {
|
||||
generateWrapper('12345', false, false, true);
|
||||
await input.trigger('keydown', { key: 'Backspace' });
|
||||
expect(wrapper.emitted('update:modelValue')).toBeUndefined();
|
||||
const spyhandler = vi.spyOn(vm, 'handleInsertMode');
|
||||
expect(spyhandler).not.toHaveBeenCalled();
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
TODO: #8399 REDMINE
|
||||
*/
|
||||
it.skip('handleKeydown respects insertable behavior', async () => {
|
||||
const expectedValue = '12345';
|
||||
generateWrapper('1234', false, false, true);
|
||||
vm.focus()
|
||||
await input.trigger('keydown', { key: '5' });
|
||||
await vm.$nextTick();
|
||||
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
||||
expect(wrapper.emitted('update:modelValue')[0]).toEqual([expectedValue ]);
|
||||
expect(vm.value).toBe( expectedValue);
|
||||
});
|
||||
});
|
||||
|
||||
describe('focus', () => {
|
||||
it('should call focus method when input is focused', async () => {
|
||||
generateWrapper('123', false, false, true);
|
||||
const focusSpy = vi.spyOn(input.element, 'focus');
|
||||
vm.focus();
|
||||
expect(focusSpy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,72 +0,0 @@
|
|||
import { createWrapper } from 'app/test/vitest/helper.js';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||
|
||||
let vm;
|
||||
let wrapper;
|
||||
|
||||
function generateWrapper(date, outlined, required) {
|
||||
wrapper = createWrapper(VnInputDate, {
|
||||
props: {
|
||||
modelValue: date,
|
||||
},
|
||||
attrs: {
|
||||
isOutlined: outlined,
|
||||
required: required
|
||||
},
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
vm = wrapper.vm;
|
||||
};
|
||||
|
||||
describe('VnInputDate', () => {
|
||||
|
||||
describe('formattedDate', () => {
|
||||
it('formats a valid date correctly', async () => {
|
||||
generateWrapper('2023-12-25', false, false);
|
||||
await vm.$nextTick();
|
||||
expect(vm.formattedDate).toBe('25/12/2023');
|
||||
});
|
||||
|
||||
it('updates the model value when a new date is set', async () => {
|
||||
const input = wrapper.find('input');
|
||||
await input.setValue('31/12/2023');
|
||||
expect(wrapper.emitted()['update:modelValue']).toBeTruthy();
|
||||
expect(wrapper.emitted()['update:modelValue'][0][0]).toBe('2023-12-31T00:00:00.000Z');
|
||||
});
|
||||
|
||||
it('should not update the model value when an invalid date is set', async () => {
|
||||
const input = wrapper.find('input');
|
||||
await input.setValue('invalid-date');
|
||||
expect(wrapper.emitted()['update:modelValue'][0][0]).toBe('2023-12-31T00:00:00.000Z');
|
||||
});
|
||||
});
|
||||
|
||||
describe('styleAttrs', () => {
|
||||
it('should return empty styleAttrs when isOutlined is false', async () => {
|
||||
generateWrapper('2023-12-25', false, false);
|
||||
await vm.$nextTick();
|
||||
expect(vm.styleAttrs).toEqual({});
|
||||
});
|
||||
|
||||
it('should set styleAttrs when isOutlined is true', async () => {
|
||||
generateWrapper('2023-12-25', true, false);
|
||||
await vm.$nextTick();
|
||||
expect(vm.styleAttrs.outlined).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('required', () => {
|
||||
it('should not applies required class when isRequired is false', async () => {
|
||||
generateWrapper('2023-12-25', false, false);
|
||||
await vm.$nextTick();
|
||||
expect(wrapper.find('.vn-input-date').classes()).not.toContain('required');
|
||||
});
|
||||
|
||||
it('should applies required class when isRequired is true', async () => {
|
||||
generateWrapper('2023-12-25', false, true);
|
||||
await vm.$nextTick();
|
||||
expect(wrapper.find('.vn-input-date').classes()).toContain('required');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,63 +0,0 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import VnInputTime from 'components/common/VnInputTime.vue';
|
||||
|
||||
describe('VnInputTime', () => {
|
||||
let wrapper;
|
||||
let vm;
|
||||
|
||||
beforeAll(() => {
|
||||
wrapper = createWrapper(VnInputTime, {
|
||||
props: {
|
||||
isOutlined: true,
|
||||
timeOnly: false,
|
||||
},
|
||||
});
|
||||
vm = wrapper.vm;
|
||||
wrapper = wrapper.wrapper;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should return the correct data if isOutlined is true', () => {
|
||||
expect(vm.isOutlined).toBe(true);
|
||||
expect(vm.styleAttrs).toEqual({ dense: true, outlined: true, rounded: true });
|
||||
});
|
||||
|
||||
it('should return the formatted data', () => {
|
||||
expect(vm.dateToTime('2022-01-01T03:23:43')).toBe('03:23');
|
||||
});
|
||||
|
||||
describe('formattedTime', () => {
|
||||
it('should return the formatted time for a valid ISO date', () => {
|
||||
vm.model = '2025-01-02T15:45:00';
|
||||
expect(vm.formattedTime).toBe('15:45');
|
||||
});
|
||||
|
||||
it('should handle null model value gracefully', () => {
|
||||
vm.model = null;
|
||||
expect(vm.formattedTime).toBe(null);
|
||||
});
|
||||
|
||||
it('should handle time-only input correctly', async () => {
|
||||
await wrapper.setProps({ timeOnly: true });
|
||||
vm.formattedTime = '14:30';
|
||||
expect(vm.model).toBe('14:30');
|
||||
});
|
||||
|
||||
it('should pad short time values correctly', async () => {
|
||||
await wrapper.setProps({ timeOnly: true });
|
||||
vm.formattedTime = '9';
|
||||
expect(vm.model).toBe('09:00');
|
||||
});
|
||||
|
||||
it('should not update the model if the value is unchanged', () => {
|
||||
vm.model = '14:30';
|
||||
const previousModel = vm.model;
|
||||
vm.formattedTime = '14:30';
|
||||
expect(vm.model).toBe(previousModel);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,95 +0,0 @@
|
|||
import { describe, it, expect } from 'vitest';
|
||||
import VnJsonValue from 'src/components/common/VnJsonValue.vue';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
|
||||
const buildComponent = (props) => {
|
||||
return createWrapper(VnJsonValue, {
|
||||
props,
|
||||
}).wrapper;
|
||||
};
|
||||
|
||||
describe('VnJsonValue', () => {
|
||||
it('renders null value correctly', async () => {
|
||||
const wrapper = buildComponent({ value: null });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe('∅');
|
||||
expect(span.classes()).toContain('json-null');
|
||||
});
|
||||
|
||||
it('renders boolean true correctly', async () => {
|
||||
const wrapper = buildComponent({ value: true });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe('✓');
|
||||
expect(span.classes()).toContain('json-true');
|
||||
});
|
||||
|
||||
it('renders boolean false correctly', async () => {
|
||||
const wrapper = buildComponent({ value: false });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe('✗');
|
||||
expect(span.classes()).toContain('json-false');
|
||||
});
|
||||
|
||||
it('renders a short string correctly', async () => {
|
||||
const wrapper = buildComponent({ value: 'Hello' });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe('Hello');
|
||||
expect(span.classes()).toContain('json-string');
|
||||
});
|
||||
|
||||
it('renders a long string correctly with ellipsis', async () => {
|
||||
const longString = 'a'.repeat(600);
|
||||
const wrapper = buildComponent({ value: longString });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toContain('...');
|
||||
expect(span.text().length).toBeLessThanOrEqual(515);
|
||||
expect(span.attributes('title')).toBe(longString);
|
||||
expect(span.classes()).toContain('json-string');
|
||||
});
|
||||
|
||||
it('renders a number correctly', async () => {
|
||||
const wrapper = buildComponent({ value: 123.4567 });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe('123.457');
|
||||
expect(span.classes()).toContain('json-number');
|
||||
});
|
||||
|
||||
it('renders an integer correctly', async () => {
|
||||
const wrapper = buildComponent({ value: 42 });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe('42');
|
||||
expect(span.classes()).toContain('json-number');
|
||||
});
|
||||
|
||||
it('renders a date correctly', async () => {
|
||||
const date = new Date('2023-01-01');
|
||||
const wrapper = buildComponent({ value: date });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe('2023-01-01');
|
||||
expect(span.classes()).toContain('json-object');
|
||||
});
|
||||
|
||||
it('renders an object correctly', async () => {
|
||||
const obj = { key: 'value' };
|
||||
const wrapper = buildComponent({ value: obj });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe(obj.toString());
|
||||
expect(span.classes()).toContain('json-object');
|
||||
});
|
||||
|
||||
it('renders an array correctly', async () => {
|
||||
const arr = [1, 2, 3];
|
||||
const wrapper = buildComponent({ value: arr });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe(arr.toString());
|
||||
expect(span.classes()).toContain('json-object');
|
||||
});
|
||||
|
||||
it('updates value when prop changes', async () => {
|
||||
const wrapper = buildComponent({ value: true });
|
||||
await wrapper.setProps({ value: 123 });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe('123');
|
||||
expect(span.classes()).toContain('json-number');
|
||||
});
|
||||
});
|
|
@ -1,91 +0,0 @@
|
|||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import VnLocation from 'components/common/VnLocation.vue';
|
||||
import { vi, afterEach, expect, it, beforeEach, describe } from 'vitest';
|
||||
|
||||
function buildComponent(data) {
|
||||
return createWrapper(VnLocation, {
|
||||
global: {
|
||||
props: {
|
||||
location: data
|
||||
}
|
||||
},
|
||||
}).vm;
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('formatLocation', () => {
|
||||
let locationBase;
|
||||
|
||||
beforeEach(() => {
|
||||
locationBase = {
|
||||
postcode: '46680',
|
||||
city: 'Algemesi',
|
||||
province: { name: 'Valencia' },
|
||||
country: { name: 'Spain' }
|
||||
};
|
||||
});
|
||||
|
||||
it('should return the postcode, city, province and country', () => {
|
||||
const location = { ...locationBase };
|
||||
const vm = buildComponent(location);
|
||||
expect(vm.formatLocation(location)).toEqual('46680, Algemesi(Valencia), Spain');
|
||||
});
|
||||
|
||||
it('should return the postcode and country', () => {
|
||||
const location = { ...locationBase, city: undefined };
|
||||
const vm = buildComponent(location);
|
||||
expect(vm.formatLocation(location)).toEqual('46680, Spain');
|
||||
});
|
||||
|
||||
it('should return the city, province and country', () => {
|
||||
const location = { ...locationBase, postcode: undefined };
|
||||
const vm = buildComponent(location);
|
||||
expect(vm.formatLocation(location)).toEqual('Algemesi(Valencia), Spain');
|
||||
});
|
||||
|
||||
it('should return the country', () => {
|
||||
const location = { ...locationBase, postcode: undefined, city: undefined, province: undefined };
|
||||
const vm = buildComponent(location);
|
||||
expect(vm.formatLocation(location)).toEqual('Spain');
|
||||
});
|
||||
});
|
||||
|
||||
describe('showLabel', () => {
|
||||
let locationBase;
|
||||
|
||||
beforeEach(() => {
|
||||
locationBase = {
|
||||
code: '46680',
|
||||
town: 'Algemesi',
|
||||
province: 'Valencia',
|
||||
country: 'Spain'
|
||||
};
|
||||
});
|
||||
|
||||
it('should show the label with postcode, city, province and country', () => {
|
||||
const location = { ...locationBase };
|
||||
const vm = buildComponent(location);
|
||||
expect(vm.showLabel(location)).toEqual('46680, Algemesi(Valencia), Spain');
|
||||
});
|
||||
|
||||
it('should show the label with postcode and country', () => {
|
||||
const location = { ...locationBase, town: undefined };
|
||||
const vm = buildComponent(location);
|
||||
expect(vm.showLabel(location)).toEqual('46680, Spain');
|
||||
});
|
||||
|
||||
it('should show the label with city, province and country', () => {
|
||||
const location = { ...locationBase, code: undefined };
|
||||
const vm = buildComponent(location);
|
||||
expect(vm.showLabel(location)).toEqual('Algemesi(Valencia), Spain');
|
||||
});
|
||||
|
||||
it('should show the label with country', () => {
|
||||
const location = { ...locationBase, code: undefined, town: undefined, province: undefined };
|
||||
const vm = buildComponent(location);
|
||||
expect(vm.showLabel(location)).toEqual('Spain');
|
||||
});
|
||||
});
|
|
@ -1,107 +0,0 @@
|
|||
import { describe, it, expect, vi, beforeAll, afterEach, beforeEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import VnNotes from 'src/components/ui/VnNotes.vue';
|
||||
|
||||
describe('VnNotes', () => {
|
||||
let vm;
|
||||
let wrapper;
|
||||
let spyFetch;
|
||||
let postMock;
|
||||
let expectedBody;
|
||||
const mockData= {name: 'Tony', lastName: 'Stark', text: 'Test Note', observationTypeFk: 1};
|
||||
|
||||
function generateExpectedBody() {
|
||||
expectedBody = {...vm.$props.body, ...{ text: vm.newNote.text, observationTypeFk: vm.newNote.observationTypeFk }};
|
||||
}
|
||||
|
||||
async function setTestParams(text, observationType, type){
|
||||
vm.newNote.text = text;
|
||||
vm.newNote.observationTypeFk = observationType;
|
||||
wrapper.setProps({ selectType: type });
|
||||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
vi.spyOn(axios, 'get').mockReturnValue({ data: [] });
|
||||
|
||||
wrapper = createWrapper(VnNotes, {
|
||||
propsData: {
|
||||
url: '/test',
|
||||
body: { name: 'Tony', lastName: 'Stark' },
|
||||
}
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
vm = wrapper.vm;
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
postMock = vi.spyOn(axios, 'post').mockResolvedValue(mockData);
|
||||
spyFetch = vi.spyOn(vm.vnPaginateRef, 'fetch').mockImplementation(() => vi.fn());
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
expectedBody = {};
|
||||
});
|
||||
|
||||
describe('insert', () => {
|
||||
it('should not call axios.post and vnPaginateRef.fetch if newNote.text is null', async () => {
|
||||
await setTestParams( null, null, true );
|
||||
|
||||
await vm.insert();
|
||||
|
||||
expect(postMock).not.toHaveBeenCalled();
|
||||
expect(spyFetch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not call axios.post and vnPaginateRef.fetch if newNote.text is empty', async () => {
|
||||
await setTestParams( "", null, false );
|
||||
|
||||
await vm.insert();
|
||||
|
||||
expect(postMock).not.toHaveBeenCalled();
|
||||
expect(spyFetch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not call axios.post and vnPaginateRef.fetch if observationTypeFk is missing and selectType is true', async () => {
|
||||
await setTestParams( "Test Note", null, true );
|
||||
|
||||
await vm.insert();
|
||||
|
||||
expect(postMock).not.toHaveBeenCalled();
|
||||
expect(spyFetch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call axios.post and vnPaginateRef.fetch if observationTypeFk is missing and selectType is false', async () => {
|
||||
await setTestParams( "Test Note", null, false );
|
||||
|
||||
generateExpectedBody();
|
||||
|
||||
await vm.insert();
|
||||
|
||||
expect(postMock).toHaveBeenCalledWith(vm.$props.url, expectedBody);
|
||||
expect(spyFetch).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call axios.post and vnPaginateRef.fetch if observationTypeFk is setted and selectType is false', async () => {
|
||||
await setTestParams( "Test Note", 1, false );
|
||||
|
||||
generateExpectedBody();
|
||||
|
||||
await vm.insert();
|
||||
|
||||
expect(postMock).toHaveBeenCalledWith(vm.$props.url, expectedBody);
|
||||
expect(spyFetch).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call axios.post and vnPaginateRef.fetch when newNote is valid', async () => {
|
||||
await setTestParams( "Test Note", 1, true );
|
||||
|
||||
generateExpectedBody();
|
||||
|
||||
await vm.insert();
|
||||
|
||||
expect(postMock).toHaveBeenCalledWith(vm.$props.url, expectedBody);
|
||||
expect(spyFetch).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -6,7 +6,6 @@ import { useArrayData } from 'composables/useArrayData';
|
|||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||
import { useState } from 'src/composables/useState';
|
||||
import { useRoute } from 'vue-router';
|
||||
import VnMoreOptions from './VnMoreOptions.vue';
|
||||
|
||||
const $props = defineProps({
|
||||
url: {
|
||||
|
@ -37,10 +36,6 @@ const $props = defineProps({
|
|||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
width: {
|
||||
type: String,
|
||||
default: 'md-width',
|
||||
},
|
||||
});
|
||||
|
||||
const state = useState();
|
||||
|
@ -52,6 +47,7 @@ let store;
|
|||
let entity;
|
||||
const isLoading = ref(false);
|
||||
const isSameDataKey = computed(() => $props.dataKey === route.meta.moduleName);
|
||||
const menuRef = ref();
|
||||
defineExpose({ getData });
|
||||
|
||||
onBeforeMount(async () => {
|
||||
|
@ -132,8 +128,9 @@ const toModule = computed(() =>
|
|||
</QTooltip>
|
||||
</QBtn></slot
|
||||
>
|
||||
|
||||
<QBtn
|
||||
@click.stop="viewSummary(entity.id, $props.summary, $props.width)"
|
||||
@click.stop="viewSummary(entity.id, $props.summary)"
|
||||
round
|
||||
flat
|
||||
dense
|
||||
|
@ -162,11 +159,25 @@ const toModule = computed(() =>
|
|||
</QTooltip>
|
||||
</QBtn>
|
||||
</RouterLink>
|
||||
<VnMoreOptions v-if="$slots.menu">
|
||||
<template #menu="{ menuRef }">
|
||||
<slot name="menu" :entity="entity" :menu-ref="menuRef" />
|
||||
</template>
|
||||
</VnMoreOptions>
|
||||
<QBtn
|
||||
v-if="$slots.menu"
|
||||
color="white"
|
||||
dense
|
||||
flat
|
||||
icon="more_vert"
|
||||
round
|
||||
size="md"
|
||||
data-cy="descriptor-more-opts"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('components.cardDescriptor.moreOptions') }}
|
||||
</QTooltip>
|
||||
<QMenu :ref="menuRef">
|
||||
<QList>
|
||||
<slot name="menu" :entity="entity" :menu-ref="menuRef" />
|
||||
</QList>
|
||||
</QMenu>
|
||||
</QBtn>
|
||||
</div>
|
||||
<slot name="before" />
|
||||
<div class="body q-py-sm">
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
import { ref, computed, watch, onBeforeMount } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import SkeletonSummary from 'components/ui/SkeletonSummary.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { isDialogOpened } from 'src/filters';
|
||||
import VnMoreOptions from './VnMoreOptions.vue';
|
||||
|
||||
const props = defineProps({
|
||||
url: {
|
||||
|
@ -81,16 +81,11 @@ async function fetch() {
|
|||
<span v-else></span>
|
||||
</slot>
|
||||
<slot name="header" :entity="entity" dense>
|
||||
{{ entity.id + ' - ' + entity.name }}
|
||||
<VnLv :label="`${entity.id} -`" :value="entity.name" />
|
||||
</slot>
|
||||
<slot name="header-right" :entity="entity">
|
||||
<span></span>
|
||||
</slot>
|
||||
<span class="row no-wrap">
|
||||
<slot name="header-right" :entity="entity" />
|
||||
<VnMoreOptions v-if="$slots.menu && isDialogOpened()">
|
||||
<template #menu="{ menuRef }">
|
||||
<slot name="menu" :entity="entity" :menu-ref="menuRef" />
|
||||
</template>
|
||||
</VnMoreOptions>
|
||||
</span>
|
||||
</div>
|
||||
<div class="summaryBody row q-mb-md">
|
||||
<slot name="body" :entity="entity" />
|
||||
|
@ -175,7 +170,7 @@ async function fetch() {
|
|||
display: inline-block;
|
||||
}
|
||||
.header.link:hover {
|
||||
color: rgba(var(--q-primary), 0.8);
|
||||
color: lighten($primary, 20%);
|
||||
}
|
||||
.q-checkbox {
|
||||
& .q-checkbox__label {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { ref, toRef } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import VnLv from 'components/ui/VnLv.vue';
|
||||
|
@ -13,7 +13,7 @@ const DEFAULT_PRICE_KG = 0;
|
|||
|
||||
const { t } = useI18n();
|
||||
|
||||
const props = defineProps({
|
||||
defineProps({
|
||||
item: {
|
||||
type: Object,
|
||||
required: true,
|
||||
|
@ -25,63 +25,57 @@ const props = defineProps({
|
|||
});
|
||||
|
||||
const dialog = ref(null);
|
||||
const card = toRef(props, 'item');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="container order-catalog-item overflow-hidden">
|
||||
<QCard class="card shadow-6">
|
||||
<div class="img-wrapper">
|
||||
<VnImg :id="card.id" class="image" zoom-resolution="1600x900" />
|
||||
<div v-if="card.hex && isCatalog" class="item-color-container">
|
||||
<VnImg :id="item.id" class="image" zoom-resolution="1600x900" />
|
||||
<div v-if="item.hex && isCatalog" class="item-color-container">
|
||||
<div
|
||||
class="item-color"
|
||||
:style="{ backgroundColor: `#${card.hex}` }"
|
||||
:style="{ backgroundColor: `#${item.hex}` }"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<span class="link" @click.stop>
|
||||
{{ card.name }}
|
||||
<ItemDescriptorProxy :id="card.id" />
|
||||
<span class="link">
|
||||
{{ item.name }}
|
||||
<ItemDescriptorProxy :id="item.id" />
|
||||
</span>
|
||||
<p class="subName">{{ card.subName }}</p>
|
||||
<p class="subName">{{ item.subName }}</p>
|
||||
<template v-for="index in 4" :key="`tag-${index}`">
|
||||
<VnLv
|
||||
v-if="card?.[`tag${index + 4}`]"
|
||||
:label="card?.[`tag${index + 4}`] + ':'"
|
||||
:value="card?.[`value${index + 4}`]"
|
||||
v-if="item?.[`tag${index + 4}`]"
|
||||
:label="item?.[`tag${index + 4}`] + ':'"
|
||||
:value="item?.[`value${index + 4}`]"
|
||||
/>
|
||||
</template>
|
||||
<div v-if="card.minQuantity" class="min-quantity">
|
||||
<div v-if="item.minQuantity" class="min-quantity">
|
||||
<QIcon name="production_quantity_limits" size="xs" />
|
||||
{{ card.minQuantity }}
|
||||
{{ item.minQuantity }}
|
||||
</div>
|
||||
<div class="footer">
|
||||
<div class="price">
|
||||
<p v-if="isCatalog">
|
||||
{{ card.available }} {{ t('to') }}
|
||||
{{ toCurrency(card.price) }}
|
||||
{{ item.available }} {{ t('to') }}
|
||||
{{ toCurrency(item.price) }}
|
||||
</p>
|
||||
<slot name="price" />
|
||||
<QIcon v-if="isCatalog" name="add_circle" class="icon">
|
||||
<QTooltip>{{ t('globals.add') }}</QTooltip>
|
||||
<QPopupProxy ref="dialog">
|
||||
<OrderCatalogItemDialog
|
||||
:item="card"
|
||||
@added="
|
||||
(quantityAdded) => {
|
||||
card.available += quantityAdded;
|
||||
dialog.hide();
|
||||
}
|
||||
"
|
||||
:prices="item.prices"
|
||||
@added="() => dialog.hide()"
|
||||
/>
|
||||
</QPopupProxy>
|
||||
</QIcon>
|
||||
</div>
|
||||
<p v-if="card.priceKg" class="price-kg">
|
||||
<p v-if="item.priceKg" class="price-kg">
|
||||
{{ t('price-kg') }}
|
||||
{{ toCurrency(card.priceKg) || DEFAULT_PRICE_KG }}
|
||||
{{ toCurrency(item.priceKg) || DEFAULT_PRICE_KG }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -16,12 +16,7 @@ const $props = defineProps({
|
|||
required: false,
|
||||
default: 'value',
|
||||
},
|
||||
columns: {
|
||||
type: Number,
|
||||
default: 3,
|
||||
},
|
||||
});
|
||||
|
||||
const tags = computed(() => {
|
||||
return Object.keys($props.item)
|
||||
.filter((i) => i.startsWith(`${$props.tag}`))
|
||||
|
@ -33,21 +28,10 @@ const tags = computed(() => {
|
|||
return acc;
|
||||
}, {});
|
||||
});
|
||||
|
||||
const columnStyle = computed(() => {
|
||||
if ($props.columns) {
|
||||
return {
|
||||
'grid-template-columns': `repeat(${$props.columns}, 1fr)`,
|
||||
'max-width': `${$props.columns * 4}rem`,
|
||||
};
|
||||
}
|
||||
return {};
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="fetchedTags">
|
||||
<div class="wrap" :style="columnStyle">
|
||||
<div class="wrap">
|
||||
<div
|
||||
v-for="(val, key) in tags"
|
||||
:key="key"
|
||||
|
@ -55,43 +39,37 @@ const columnStyle = computed(() => {
|
|||
:title="`${key}: ${val}`"
|
||||
:class="{ empty: !val }"
|
||||
>
|
||||
<span class="text">{{ val }} </span>
|
||||
{{ val }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.fetchedTags {
|
||||
align-items: center;
|
||||
.wrap {
|
||||
display: grid;
|
||||
width: 100%;
|
||||
flex-wrap: wrap;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.inline-tag {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 1rem;
|
||||
margin: 0.05rem;
|
||||
color: var(--vn-label-color);
|
||||
color: $color-font-secondary;
|
||||
text-align: center;
|
||||
font-size: smaller;
|
||||
padding: 1px;
|
||||
border: 1px solid var(--vn-label-color);
|
||||
flex: 1;
|
||||
border: 1px solid $color-spacer;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
min-width: 4rem;
|
||||
max-width: 4rem;
|
||||
}
|
||||
|
||||
.text {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
font-size: smaller;
|
||||
}
|
||||
.empty {
|
||||
border: 1px solid var(--vn-empty-tag);
|
||||
border: 1px solid #2b2b2b;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { useQuasar } from 'quasar';
|
||||
import '@quasar/quasar-ui-qcalendar/src/QCalendarVariables.scss';
|
||||
import '@quasar/quasar-ui-qcalendar/src/QCalendarVariables.sass';
|
||||
|
||||
const $props = defineProps({
|
||||
bordered: {
|
||||
|
|
|
@ -1,49 +1,38 @@
|
|||
<template>
|
||||
<div class="header bg-primary q-pa-sm q-mb-md">
|
||||
<QSkeleton type="rect" square />
|
||||
<QSkeleton type="rect" square />
|
||||
</div>
|
||||
<div class="row q-pa-md q-col-gutter-md q-mb-md">
|
||||
<div class="col">
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
</div>
|
||||
<div class="col">
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
</div>
|
||||
<div class="col">
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
</div>
|
||||
<div class="col">
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
</div>
|
||||
<div class="col">
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
</div>
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import { useColor } from 'src/composables/useColor';
|
|||
import { getCssVar } from 'quasar';
|
||||
|
||||
const $props = defineProps({
|
||||
workerId: { type: [Number, undefined], default: null },
|
||||
workerId: { type: Number, required: true },
|
||||
description: { type: String, default: null },
|
||||
title: { type: String, default: null },
|
||||
color: { type: String, default: null },
|
||||
|
@ -38,13 +38,7 @@ watch(src, () => (showLetter.value = false));
|
|||
<template v-if="showLetter">
|
||||
{{ title.charAt(0) }}
|
||||
</template>
|
||||
<QImg
|
||||
v-else-if="workerId"
|
||||
:src="src"
|
||||
spinner-color="white"
|
||||
@error="showLetter = true"
|
||||
/>
|
||||
<QIcon v-else name="mood" size="xs" />
|
||||
<QImg v-else :src="src" spinner-color="white" @error="showLetter = true" />
|
||||
</QAvatar>
|
||||
<div class="description">
|
||||
<slot name="description" v-if="description">
|
||||
|
|
|
@ -98,7 +98,6 @@ function cancel() {
|
|||
/>
|
||||
<QBtn
|
||||
:label="t('globals.confirm')"
|
||||
:title="t('globals.confirm')"
|
||||
color="primary"
|
||||
:loading="isLoading"
|
||||
@click="confirm()"
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { onMounted, ref, computed, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import { useRoute } from 'vue-router';
|
||||
import toDate from 'filters/toDate';
|
||||
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
|
||||
import { useFilterParams } from 'src/composables/useFilterParams';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
const $props = defineProps({
|
||||
modelValue: {
|
||||
type: Object,
|
||||
|
@ -57,35 +55,62 @@ const $props = defineProps({
|
|||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
arrayData: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits([
|
||||
'update:modelValue',
|
||||
'refresh',
|
||||
'clear',
|
||||
'search',
|
||||
'init',
|
||||
'remove',
|
||||
'setUserParams',
|
||||
]);
|
||||
|
||||
const arrayData =
|
||||
$props.arrayData ??
|
||||
useArrayData($props.dataKey, {
|
||||
exprBuilder: $props.exprBuilder,
|
||||
searchUrl: $props.searchUrl,
|
||||
navigate: $props.redirect ? {} : null,
|
||||
});
|
||||
|
||||
const arrayData = useArrayData($props.dataKey, {
|
||||
exprBuilder: $props.exprBuilder,
|
||||
searchUrl: $props.searchUrl,
|
||||
navigate: $props.redirect ? {} : null,
|
||||
});
|
||||
const route = useRoute();
|
||||
const store = arrayData.store;
|
||||
const userParams = ref(useFilterParams($props.dataKey).params);
|
||||
const userOrders = ref(useFilterParams($props.dataKey).orders);
|
||||
const userParams = ref({});
|
||||
|
||||
defineExpose({ search, params: userParams, remove });
|
||||
defineExpose({ search, sanitizer, params: userParams });
|
||||
|
||||
onMounted(() => {
|
||||
userParams.value = $props.modelValue ?? {};
|
||||
emit('init', { params: userParams.value });
|
||||
});
|
||||
|
||||
function setUserParams(watchedParams) {
|
||||
if (!watchedParams || Object.keys(watchedParams).length == 0) return;
|
||||
|
||||
if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams);
|
||||
if (typeof watchedParams?.filter == 'string')
|
||||
watchedParams.filter = JSON.parse(watchedParams.filter);
|
||||
|
||||
watchedParams = { ...watchedParams, ...watchedParams.filter?.where };
|
||||
const order = watchedParams.filter?.order;
|
||||
|
||||
delete watchedParams.filter;
|
||||
userParams.value = sanitizer(watchedParams);
|
||||
emit('setUserParams', userParams.value, order);
|
||||
}
|
||||
|
||||
watch(
|
||||
() => route.query[$props.searchUrl],
|
||||
(val, oldValue) => (val || oldValue) && setUserParams(val)
|
||||
);
|
||||
|
||||
watch(
|
||||
() => arrayData.store.userParams,
|
||||
(val, oldValue) => (val || oldValue) && setUserParams(val)
|
||||
);
|
||||
|
||||
watch(
|
||||
() => $props.modelValue,
|
||||
(val) => (userParams.value = val ?? {})
|
||||
);
|
||||
|
||||
const isLoading = ref(false);
|
||||
async function search(evt) {
|
||||
|
@ -96,9 +121,10 @@ async function search(evt) {
|
|||
isLoading.value = true;
|
||||
const filter = { ...userParams.value, ...$props.modelValue };
|
||||
store.userParamsChanged = true;
|
||||
await arrayData.addFilter({
|
||||
const { params: newParams } = await arrayData.addFilter({
|
||||
params: filter,
|
||||
});
|
||||
userParams.value = newParams;
|
||||
|
||||
if (!$props.showAll && !Object.values(filter).length) store.data = [];
|
||||
emit('search');
|
||||
|
@ -111,7 +137,7 @@ async function clearFilters() {
|
|||
try {
|
||||
isLoading.value = true;
|
||||
store.userParamsChanged = true;
|
||||
arrayData.resetPagination();
|
||||
arrayData.reset(['skip', 'filter.skip', 'page']);
|
||||
// Filtrar los params no removibles
|
||||
const removableFilters = Object.keys(userParams.value).filter((param) =>
|
||||
$props.unremovableParams.includes(param)
|
||||
|
@ -121,8 +147,9 @@ async function clearFilters() {
|
|||
for (const key of removableFilters) {
|
||||
newParams[key] = userParams.value[key];
|
||||
}
|
||||
|
||||
await arrayData.applyFilter({ params: { ...newParams } });
|
||||
userParams.value = {};
|
||||
userParams.value = { ...newParams }; // Actualizar los params con los removibles
|
||||
await arrayData.applyFilter({ params: userParams.value });
|
||||
|
||||
if (!$props.showAll) {
|
||||
store.data = [];
|
||||
|
@ -185,16 +212,20 @@ function formatValue(value) {
|
|||
return `"${value}"`;
|
||||
}
|
||||
|
||||
const getLocale = (label) => {
|
||||
const param = label.split('.').at(-1);
|
||||
const globalLocale = `globals.params.${param}`;
|
||||
if (te(globalLocale)) return t(globalLocale);
|
||||
else if (te(t(`params.${param}`)));
|
||||
else {
|
||||
const camelCaseModuleName = route.meta.moduleName.charAt(0).toLowerCase() + route.meta.moduleName.slice(1);
|
||||
return t(`${camelCaseModuleName}.params.${param}`);
|
||||
function sanitizer(params) {
|
||||
for (const [key, value] of Object.entries(params)) {
|
||||
if (key === 'and' && Array.isArray(value)) {
|
||||
value.forEach((item) => {
|
||||
Object.assign(params, item);
|
||||
});
|
||||
delete params[key];
|
||||
} else if (value && typeof value === 'object') {
|
||||
const param = Object.values(value)[0];
|
||||
if (typeof param == 'string') params[key] = param.replaceAll('%', '');
|
||||
}
|
||||
}
|
||||
};
|
||||
return params;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -205,11 +236,7 @@ const getLocale = (label) => {
|
|||
style="position: fixed; z-index: 1; right: 0; bottom: 0"
|
||||
icon="search"
|
||||
@click="search()"
|
||||
>
|
||||
<QTooltip bottom anchor="bottom right">
|
||||
{{ t('globals.search') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
></QBtn>
|
||||
<QForm @submit="search" id="filterPanelForm" @keyup.enter="search()">
|
||||
<QList dense>
|
||||
<QItem class="q-mt-xs">
|
||||
|
@ -248,12 +275,7 @@ const getLocale = (label) => {
|
|||
@remove="remove(chip.label)"
|
||||
data-cy="vnFilterPanelChip"
|
||||
>
|
||||
<slot
|
||||
name="tags"
|
||||
:tag="chip"
|
||||
:format-fn="formatValue"
|
||||
:get-locale="getLocale"
|
||||
>
|
||||
<slot name="tags" :tag="chip" :format-fn="formatValue">
|
||||
<div class="q-gutter-x-xs">
|
||||
<strong>{{ chip.label }}:</strong>
|
||||
<span>"{{ formatValue(chip.value) }}"</span>
|
||||
|
@ -266,7 +288,6 @@ const getLocale = (label) => {
|
|||
:params="userParams"
|
||||
:tags="customTags"
|
||||
:format-fn="formatValue"
|
||||
:get-locale="getLocale"
|
||||
:search-fn="search"
|
||||
/>
|
||||
</div>
|
||||
|
@ -274,13 +295,7 @@ const getLocale = (label) => {
|
|||
<QSeparator />
|
||||
</QList>
|
||||
<QList dense class="list q-gutter-y-sm q-mt-sm">
|
||||
<slot
|
||||
name="body"
|
||||
:get-locale="getLocale"
|
||||
:params="userParams"
|
||||
:orders="userOrders"
|
||||
:search-fn="search"
|
||||
></slot>
|
||||
<slot name="body" :params="sanitizer(userParams)" :search-fn="search"></slot>
|
||||
</QList>
|
||||
</QForm>
|
||||
<QInnerLoading
|
||||
|
|
|
@ -1,28 +1,22 @@
|
|||
<script setup>
|
||||
import { ref, reactive, useAttrs, onBeforeMount, capitalize } from 'vue';
|
||||
import { 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',
|
||||
url: null,
|
||||
href: 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') {
|
||||
|
@ -30,28 +24,23 @@ onBeforeMount(async () => {
|
|||
.data;
|
||||
if (!channel) channel = defaultChannel;
|
||||
|
||||
phone.value = await parsePhone(props.phoneNumber, props.country?.toLowerCase());
|
||||
config[
|
||||
type
|
||||
].url = `${url}?customerIdentity=%2B${phone.value}&channelId=${channel}`;
|
||||
].href = `${url}?customerIdentity=%2B${props.phoneNumber}&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="phone"
|
||||
v-if="phoneNumber"
|
||||
flat
|
||||
round
|
||||
:icon="config[type].icon"
|
||||
size="sm"
|
||||
color="primary"
|
||||
padding="none"
|
||||
@click.stop="handleClick"
|
||||
:href="config[type].href"
|
||||
@click.stop
|
||||
>
|
||||
<QTooltip>
|
||||
{{ capitalize(type).replace('-', '') }}
|
||||
|
|
|
@ -39,7 +39,7 @@ const val = computed(() => $props.value);
|
|||
<template v-else>
|
||||
<div v-if="label || $slots.label" class="label">
|
||||
<slot name="label">
|
||||
<span style="color: var(--vn-label-color)">{{ label }}</span>
|
||||
<span>{{ label }}</span>
|
||||
</slot>
|
||||
</div>
|
||||
<div class="value">
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<template>
|
||||
<QBtn
|
||||
color="white"
|
||||
dense
|
||||
flat
|
||||
icon="more_vert"
|
||||
round
|
||||
size="md"
|
||||
data-cy="descriptor-more-opts"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ $t('components.cardDescriptor.moreOptions') }}
|
||||
</QTooltip>
|
||||
<QMenu ref="menuRef">
|
||||
<QList>
|
||||
<slot name="menu" :menu-ref="$refs.menuRef" />
|
||||
</QList>
|
||||
</QMenu>
|
||||
</QBtn>
|
||||
</template>
|
|
@ -6,6 +6,7 @@ import { useI18n } from 'vue-i18n';
|
|||
import { useQuasar } from 'quasar';
|
||||
|
||||
import { toDateHourMin } from 'src/filters';
|
||||
import { useState } from 'src/composables/useState';
|
||||
|
||||
import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||
import VnUserLink from 'components/ui/VnUserLink.vue';
|
||||
|
@ -25,7 +26,9 @@ const $props = defineProps({
|
|||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
const state = useState();
|
||||
const quasar = useQuasar();
|
||||
const currentUser = ref(state.getUser());
|
||||
const newNote = reactive({ text: null, observationTypeFk: null });
|
||||
const observationTypes = ref([]);
|
||||
const vnPaginateRef = ref();
|
||||
|
@ -98,7 +101,6 @@ onBeforeRouteLeave((to, from, next) => {
|
|||
@click="insert"
|
||||
class="q-mb-xs"
|
||||
dense
|
||||
data-cy="saveNote"
|
||||
/>
|
||||
</template>
|
||||
</VnInput>
|
||||
|
@ -110,7 +112,7 @@ onBeforeRouteLeave((to, from, next) => {
|
|||
:url="$props.url"
|
||||
order="created DESC"
|
||||
:limit="0"
|
||||
:user-filter="$props.filter"
|
||||
:filter="$props.filter"
|
||||
auto-load
|
||||
ref="vnPaginateRef"
|
||||
class="show"
|
||||
|
|
|
@ -74,14 +74,6 @@ const props = defineProps({
|
|||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
mapKey: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
keyData: {
|
||||
type: String,
|
||||
default: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['onFetch', 'onPaginate', 'onChange']);
|
||||
|
@ -104,26 +96,21 @@ const arrayData = useArrayData(props.dataKey, {
|
|||
exprBuilder: props.exprBuilder,
|
||||
keepOpts: props.keepOpts,
|
||||
searchUrl: props.searchUrl,
|
||||
mapKey: props.mapKey,
|
||||
});
|
||||
const store = arrayData.store;
|
||||
|
||||
onMounted(async () => {
|
||||
if (props.autoLoad && !store.data?.length) await fetch();
|
||||
else emit('onFetch', store.data);
|
||||
mounted.value = true;
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (!store.keepData) arrayData.reset(['data']);
|
||||
arrayData.resetPagination();
|
||||
});
|
||||
onBeforeUnmount(() => arrayData.reset());
|
||||
|
||||
watch(
|
||||
() => props.data,
|
||||
() => {
|
||||
store.data = props.data;
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
|
@ -132,12 +119,12 @@ watch(
|
|||
if (!mounted.value) return;
|
||||
emit('onChange', data);
|
||||
},
|
||||
{ immediate: true },
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
() => [props.url, props.filter],
|
||||
([url, filter]) => mounted.value && fetch({ url, filter }),
|
||||
([url, filter]) => mounted.value && fetch({ url, filter })
|
||||
);
|
||||
const addFilter = async (filter, params) => {
|
||||
await arrayData.addFilter({ filter, params });
|
||||
|
@ -145,7 +132,7 @@ const addFilter = async (filter, params) => {
|
|||
|
||||
async function fetch(params) {
|
||||
useArrayData(props.dataKey, params);
|
||||
arrayData.resetPagination();
|
||||
arrayData.reset(['filter.skip', 'skip', 'page']);
|
||||
await arrayData.fetch({ append: false });
|
||||
return emitStoreData();
|
||||
}
|
||||
|
@ -170,7 +157,7 @@ function emitStoreData() {
|
|||
async function paginate() {
|
||||
const { page, rowsPerPage, sortBy, descending } = pagination.value;
|
||||
|
||||
if (!arrayData.store.url) return;
|
||||
if (!props.url) return;
|
||||
|
||||
isLoading.value = true;
|
||||
await arrayData.loadMore();
|
||||
|
@ -198,7 +185,7 @@ function endPagination() {
|
|||
async function onLoad(index, done) {
|
||||
if (!store.data || !mounted.value) return done();
|
||||
|
||||
if (store.data.length === 0 || !arrayData.store.url) return done(false);
|
||||
if (store.data.length === 0 || !props.url) return done(false);
|
||||
|
||||
pagination.value.page = pagination.value.page + 1;
|
||||
|
||||
|
@ -208,20 +195,13 @@ async function onLoad(index, done) {
|
|||
done(isDone);
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
fetch,
|
||||
update,
|
||||
addFilter,
|
||||
paginate,
|
||||
userParams: arrayData.store.userParams,
|
||||
currentFilter: arrayData.store.currentFilter,
|
||||
});
|
||||
defineExpose({ fetch, update, addFilter, paginate });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="full-width">
|
||||
<div
|
||||
v-if="!store.data && !store.data?.length && !isLoading"
|
||||
v-if="!props.autoLoad && !store.data && !isLoading"
|
||||
class="info-row q-pa-md text-center"
|
||||
>
|
||||
<h5>
|
||||
|
@ -259,7 +239,7 @@ defineExpose({
|
|||
:disable="disableInfiniteScroll || !store.hasMoreData"
|
||||
v-bind="$attrs"
|
||||
>
|
||||
<slot name="body" :rows="keyData ? store.data[keyData] : store.data"></slot>
|
||||
<slot name="body" :rows="store.data"></slot>
|
||||
<div v-if="isLoading" class="spinner info-row q-pa-md text-center">
|
||||
<QSpinner color="primary" size="md" />
|
||||
</div>
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
<script setup>
|
||||
import { onMounted, ref, computed, watch } from 'vue';
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useStateStore } from 'src/stores/useStateStore';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
const quasar = useQuasar();
|
||||
const { t } = useI18n();
|
||||
const state = useStateStore();
|
||||
const route = useRoute();
|
||||
|
||||
const props = defineProps({
|
||||
dataKey: {
|
||||
|
@ -53,6 +51,10 @@ const props = defineProps({
|
|||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
staticParams: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
exprBuilder: {
|
||||
type: Function,
|
||||
default: null,
|
||||
|
@ -65,10 +67,6 @@ const props = defineProps({
|
|||
type: Function,
|
||||
default: undefined,
|
||||
},
|
||||
searchRemoveParams: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
|
||||
const searchText = ref();
|
||||
|
@ -85,24 +83,13 @@ if (props.redirect)
|
|||
};
|
||||
let arrayData = useArrayData(props.dataKey, arrayDataProps);
|
||||
let store = arrayData.store;
|
||||
const to = computed(() => {
|
||||
const url = { path: route.path, query: { ...(route.query ?? {}) } };
|
||||
const searchUrl = arrayData.store.searchUrl;
|
||||
const currentFilter = {
|
||||
...arrayData.store.currentFilter,
|
||||
search: searchText.value || undefined,
|
||||
};
|
||||
|
||||
if (searchUrl) url.query[searchUrl] = JSON.stringify(currentFilter);
|
||||
return url;
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.dataKey,
|
||||
(val) => {
|
||||
arrayData = useArrayData(val, { ...props });
|
||||
store = arrayData.store;
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
|
@ -113,21 +100,16 @@ onMounted(() => {
|
|||
});
|
||||
|
||||
async function search() {
|
||||
arrayData.resetPagination();
|
||||
const staticParams = Object.entries(store.userParams);
|
||||
arrayData.reset(['skip', 'page']);
|
||||
|
||||
let filter = { params: { search: searchText.value } };
|
||||
|
||||
if (!props.searchRemoveParams || !searchText.value) {
|
||||
filter = {
|
||||
params: {
|
||||
...store.userParams,
|
||||
search: searchText.value,
|
||||
},
|
||||
filter: store.filter,
|
||||
};
|
||||
} else {
|
||||
arrayData.reset(['currentFilter', 'userParams']);
|
||||
}
|
||||
const filter = {
|
||||
params: {
|
||||
...Object.fromEntries(staticParams),
|
||||
search: searchText.value,
|
||||
},
|
||||
...{ filter: props.filter },
|
||||
};
|
||||
|
||||
if (props.whereFilter) {
|
||||
filter.filter = {
|
||||
|
@ -136,38 +118,28 @@ async function search() {
|
|||
delete filter.params.search;
|
||||
}
|
||||
await arrayData.applyFilter(filter);
|
||||
searchText.value = undefined;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Teleport to="#searchbar" v-if="state.isHeaderMounted()">
|
||||
<QForm @submit="search" id="searchbarForm">
|
||||
<RouterLink
|
||||
:to="to"
|
||||
@click="
|
||||
!$event.shiftKey && !$event.ctrlKey && search();
|
||||
$refs.input.focus();
|
||||
"
|
||||
>
|
||||
<QIcon
|
||||
v-if="!quasar.platform.is.mobile"
|
||||
class="cursor-pointer"
|
||||
name="search"
|
||||
size="sm"
|
||||
>
|
||||
<QTooltip>{{ t('link') }}</QTooltip>
|
||||
</QIcon>
|
||||
</RouterLink>
|
||||
<VnInput
|
||||
id="searchbar"
|
||||
ref="input"
|
||||
v-model.trim="searchText"
|
||||
:placeholder="t(props.label)"
|
||||
dense
|
||||
standout
|
||||
autofocus
|
||||
data-cy="vn-searchbar"
|
||||
borderless
|
||||
data-cy="vnSearchBar"
|
||||
>
|
||||
<template #prepend>
|
||||
<QIcon
|
||||
v-if="!quasar.platform.is.mobile"
|
||||
class="cursor-pointer"
|
||||
name="search"
|
||||
@click="search"
|
||||
/>
|
||||
</template>
|
||||
<template #append>
|
||||
<QIcon
|
||||
v-if="props.info && $q.screen.gt.xs"
|
||||
|
@ -176,7 +148,6 @@ async function search() {
|
|||
>
|
||||
<QTooltip>{{ t(props.info) }}</QTooltip>
|
||||
</QIcon>
|
||||
<div id="searchbar-after"></div>
|
||||
</template>
|
||||
</VnInput>
|
||||
</QForm>
|
||||
|
@ -193,52 +164,20 @@ async function search() {
|
|||
.q-field {
|
||||
transition: width 0.36s;
|
||||
}
|
||||
</style>
|
||||
|
||||
:deep(.q-field__native) {
|
||||
padding-top: 10px;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
:deep(.q-field--dark .q-field__native:focus) {
|
||||
color: black;
|
||||
}
|
||||
|
||||
:deep(.q-field--focused) {
|
||||
.q-icon {
|
||||
color: black;
|
||||
}
|
||||
}
|
||||
|
||||
<style lang="scss">
|
||||
.cursor-info {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.q-form {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-radius: 4px;
|
||||
padding: 0 5px;
|
||||
background-color: var(--vn-search-color);
|
||||
|
||||
&:hover {
|
||||
background-color: var(--vn-search-color-hover);
|
||||
}
|
||||
&:focus-within {
|
||||
#searchbar {
|
||||
.q-field--standout.q-field--highlighted .q-field__control {
|
||||
background-color: white;
|
||||
|
||||
color: black;
|
||||
.q-field__native,
|
||||
.q-icon {
|
||||
color: black;
|
||||
color: black !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.q-icon {
|
||||
color: var(--vn-label-color);
|
||||
}
|
||||
</style>
|
||||
<i18n>
|
||||
en:
|
||||
link: click to search, ctrl + click to open in a new tab, shift + click to open in a new window
|
||||
es:
|
||||
link: clic para buscar, ctrl + clic para abrir en una nueva pestaña, shift + clic para abrir en una nueva ventana
|
||||
</i18n>
|
||||
|
|
|
@ -54,7 +54,6 @@ function formatNumber(number) {
|
|||
:offset="100"
|
||||
:limit="5"
|
||||
auto-load
|
||||
map-key="smsFk"
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
<QCard
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { defineProps, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach, beforeEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import CardSummary from 'src/components/ui/CardSummary.vue';
|
||||
import * as vueRouter from 'vue-router';
|
||||
|
||||
describe('CardSummary', () => {
|
||||
let vm;
|
||||
let wrapper;
|
||||
|
||||
beforeAll(() => {
|
||||
vi.spyOn(axios, 'get').mockResolvedValue({ data: [] });
|
||||
});
|
||||
|
||||
vi.spyOn(vueRouter, 'useRoute').mockReturnValue({
|
||||
query: {},
|
||||
params: {},
|
||||
meta: { moduleName: 'mockName' },
|
||||
path: 'mockName/1/summary',
|
||||
name: 'CardSummary',
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = createWrapper(CardSummary, {
|
||||
propsData: {
|
||||
dataKey: 'cardSummaryKey',
|
||||
url: 'cardSummaryUrl',
|
||||
filter: 'cardFilter',
|
||||
},
|
||||
});
|
||||
vm = wrapper.vm;
|
||||
wrapper = wrapper.wrapper;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should fetch data correctly', async () => {
|
||||
const fetchSpy = vi
|
||||
.spyOn(vm.arrayData, 'fetch')
|
||||
.mockResolvedValue({ data: [{ id: 1, name: 'Test Entity' }] });
|
||||
await vm.fetch();
|
||||
|
||||
expect(fetchSpy).toHaveBeenCalledWith({ append: false, updateRouter: false });
|
||||
expect(wrapper.emitted('onFetch')).toBeTruthy();
|
||||
expect(vm.isLoading).toBe(false);
|
||||
});
|
||||
|
||||
it('should set correct props to the store', () => {
|
||||
expect(vm.store.url).toEqual('cardSummaryUrl');
|
||||
expect(vm.store.filter).toEqual('cardFilter');
|
||||
});
|
||||
|
||||
it('should compute entity correctly from store data', () => {
|
||||
vm.store.data = [{ id: 1, name: 'Entity 1' }];
|
||||
expect(vm.entity).toEqual({ id: 1, name: 'Entity 1' });
|
||||
});
|
||||
|
||||
it('should handle empty data gracefully', () => {
|
||||
vm.store.data = [];
|
||||
expect(vm.entity).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should respond to prop changes and refetch data', async () => {
|
||||
const newUrl = 'CardSummary/35';
|
||||
const newKey = 'cardSummaryKey/35';
|
||||
const fetchSpy = vi.spyOn(vm.arrayData, 'fetch');
|
||||
await wrapper.setProps({ url: newUrl, filter: { key: newKey } });
|
||||
|
||||
expect(fetchSpy).toHaveBeenCalled();
|
||||
expect(vm.store.url).toBe(newUrl);
|
||||
expect(vm.store.filter).toEqual({ key: newKey });
|
||||
});
|
||||
|
||||
it('should return true if route path ends with /summary' , () => {
|
||||
expect(vm.isSummary).toBe(true);
|
||||
});
|
||||
});
|
|
@ -1,81 +0,0 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import FetchedTags from 'src/components/ui/FetchedTags.vue';
|
||||
|
||||
describe('tags computed property', () => {
|
||||
it('returns an object with the correct keys and values', () => {
|
||||
const vm = createWrapper(FetchedTags, {
|
||||
props: {
|
||||
item: {
|
||||
tag1: 'JavaScript',
|
||||
value1: 'Programming Language',
|
||||
tag2: 'Vue',
|
||||
value2: 'Framework',
|
||||
tag3: 'EmptyTag',
|
||||
},
|
||||
tag: 'tag',
|
||||
value: 'value',
|
||||
columns: 2,
|
||||
},
|
||||
}).vm;
|
||||
expect(vm.tags).toEqual({
|
||||
JavaScript: 'Programming Language',
|
||||
Vue: 'Framework',
|
||||
EmptyTag: '',
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an empty object if the item prop is an empty object', () => {
|
||||
const vm = createWrapper(FetchedTags, {
|
||||
props: {
|
||||
item: {},
|
||||
tag: 'tag',
|
||||
value: 'value',
|
||||
},
|
||||
}).vm;
|
||||
expect(vm.tags).toEqual({});
|
||||
});
|
||||
|
||||
it('should calculate the correct columnStyle when columns prop is defined', () => {
|
||||
const vm = createWrapper(FetchedTags, {
|
||||
props: {
|
||||
item: {
|
||||
tag1: 'JavaScript',
|
||||
value1: 'Programming Language',
|
||||
tag2: 'Vue',
|
||||
value2: 'Framework',
|
||||
tag3: 'EmptyTag',
|
||||
},
|
||||
tag: 'tag',
|
||||
value: 'value',
|
||||
columns: 2,
|
||||
},
|
||||
}).vm;
|
||||
|
||||
const expectedStyle = {
|
||||
'grid-template-columns': 'repeat(2, 1fr)',
|
||||
'max-width': '8rem',
|
||||
};
|
||||
|
||||
expect(vm.columnStyle).toEqual(expectedStyle);
|
||||
});
|
||||
|
||||
it('should return an empty object for columnStyle when columns prop is not defined', () => {
|
||||
const vm = createWrapper(FetchedTags, {
|
||||
props: {
|
||||
item: {
|
||||
tag1: 'JavaScript',
|
||||
value1: 'Programming Language',
|
||||
tag2: 'Vue',
|
||||
value2: 'Framework',
|
||||
tag3: 'EmptyTag',
|
||||
},
|
||||
tag: 'tag',
|
||||
value: 'value',
|
||||
columns: null,
|
||||
},
|
||||
}).vm;
|
||||
|
||||
expect(vm.columnStyle).toEqual({});
|
||||
});
|
||||
});
|
|
@ -1,89 +0,0 @@
|
|||
import { vi, describe, expect, it, beforeEach, afterEach } from 'vitest';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import VnImg from 'src/components/ui/VnImg.vue';
|
||||
|
||||
let wrapper;
|
||||
let vm;
|
||||
const isEmployeeMock = vi.fn();
|
||||
|
||||
function generateWrapper(storage = 'images') {
|
||||
wrapper = createWrapper(VnImg, {
|
||||
props: {
|
||||
id: 123,
|
||||
zoomResolution: '400x400',
|
||||
storage,
|
||||
}
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
vm = wrapper.vm;
|
||||
vm.timeStamp = 'timestamp';
|
||||
};
|
||||
|
||||
vi.mock('src/composables/useSession', () => ({
|
||||
useSession: () => ({
|
||||
getTokenMultimedia: () => 'token',
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock('src/composables/useRole', () => ({
|
||||
useRole: () => ({
|
||||
isEmployee: isEmployeeMock,
|
||||
}),
|
||||
}));
|
||||
|
||||
|
||||
describe('VnImg', () => {
|
||||
beforeEach(() => {
|
||||
isEmployeeMock.mockReset();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('getUrl', () => {
|
||||
it('should return /api/{storage}/{id}/downloadFile?access_token={token} when storage is dms', async () => {
|
||||
isEmployeeMock.mockReturnValue(false);
|
||||
generateWrapper('dms');
|
||||
await vm.$nextTick();
|
||||
const url = vm.getUrl();
|
||||
expect(url).toBe('/api/dms/123/downloadFile?access_token=token');
|
||||
});
|
||||
|
||||
it('should return /no-user.png when role is not employee and storage is not dms', async () => {
|
||||
isEmployeeMock.mockReturnValue(false);
|
||||
generateWrapper();
|
||||
await vm.$nextTick();
|
||||
const url = vm.getUrl();
|
||||
expect(url).toBe('/no-user.png');
|
||||
});
|
||||
|
||||
it('should return /api/{storage}/{collection}/{curResolution}/{id}/download?access_token={token}&{timeStamp} when zoom is false and role is employee and storage is not dms', async () => {
|
||||
isEmployeeMock.mockReturnValue(true);
|
||||
generateWrapper();
|
||||
await vm.$nextTick();
|
||||
const url = vm.getUrl();
|
||||
expect(url).toBe('/api/images/catalog/200x200/123/download?access_token=token×tamp');
|
||||
});
|
||||
|
||||
it('should return /api/{storage}/{collection}/{curResolution}/{id}/download?access_token={token}&{timeStamp} when zoom is true and role is employee and storage is not dms', async () => {
|
||||
isEmployeeMock.mockReturnValue(true);
|
||||
generateWrapper();
|
||||
await vm.$nextTick();
|
||||
const url = vm.getUrl(true);
|
||||
expect(url).toBe('/api/images/catalog/400x400/123/download?access_token=token×tamp');
|
||||
});
|
||||
});
|
||||
|
||||
describe('reload', () => {
|
||||
it('should update the timestamp', async () => {
|
||||
generateWrapper();
|
||||
const initialTimestamp = wrapper.vm.timeStamp;
|
||||
|
||||
wrapper.vm.reload();
|
||||
const newTimestamp = wrapper.vm.timeStamp;
|
||||
|
||||
expect(initialTimestamp).not.toEqual(newTimestamp);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,50 +0,0 @@
|
|||
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');
|
||||
});
|
||||
});
|
|
@ -1,71 +0,0 @@
|
|||
import { vi, describe, expect, it, beforeEach, afterEach } from 'vitest';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
||||
|
||||
describe('VnSearchbar', () => {
|
||||
let vm;
|
||||
let wrapper;
|
||||
let applyFilterSpy;
|
||||
const searchText = 'Bolas de madera';
|
||||
const userParams = {staticKey: 'staticValue'};
|
||||
|
||||
beforeEach(async () => {
|
||||
wrapper = createWrapper(VnSearchbar, {
|
||||
propsData: {
|
||||
dataKey: 'testKey',
|
||||
filter: null,
|
||||
whereFilter: null,
|
||||
searchRemoveParams: true,
|
||||
},
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
vm = wrapper.vm;
|
||||
|
||||
vm.searchText = searchText;
|
||||
vm.arrayData.store.userParams = userParams;
|
||||
applyFilterSpy = vi.spyOn(vm.arrayData, 'applyFilter').mockImplementation(() => {});
|
||||
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('search resets pagination and applies filter', async () => {
|
||||
const resetPaginationSpy = vi.spyOn(vm.arrayData, 'resetPagination').mockImplementation(() => {});
|
||||
await vm.search();
|
||||
|
||||
expect(resetPaginationSpy).toHaveBeenCalled();
|
||||
expect(applyFilterSpy).toHaveBeenCalledWith({
|
||||
params: { search: searchText },
|
||||
});
|
||||
});
|
||||
|
||||
it('search includes static params if searchRemoveParams is false', async () => {
|
||||
wrapper.setProps({ searchRemoveParams: false });
|
||||
await vm.$nextTick();
|
||||
await vm.search();
|
||||
|
||||
expect(applyFilterSpy).toHaveBeenCalledWith({
|
||||
params: { staticKey: 'staticValue', search: searchText },
|
||||
filter: {skip: 0},
|
||||
});
|
||||
});
|
||||
|
||||
it('updates store when dataKey changes', async () => {
|
||||
expect(vm.store.userParams).toEqual(userParams);
|
||||
wrapper.setProps({ dataKey: 'newTestKey' });
|
||||
await vm.$nextTick();
|
||||
expect(vm.store.userParams).toEqual({});
|
||||
});
|
||||
|
||||
it('computes the "to" property correctly for redirection', () => {
|
||||
vm.arrayData.store.searchUrl = 'searchParam';
|
||||
vm.arrayData.store.currentFilter = { category: 'plants' };
|
||||
const expectedQuery = JSON.stringify({
|
||||
...vm.arrayData.store.currentFilter,
|
||||
search: searchText,
|
||||
});
|
||||
expect(vm.to.query.searchParam).toBe(expectedQuery);
|
||||
});
|
||||
});
|
|
@ -1,45 +0,0 @@
|
|||
import { describe, expect, it, vi } from 'vitest';
|
||||
import axios from 'axios';
|
||||
import { getExchange } from 'src/composables/getExchange';
|
||||
|
||||
vi.mock('axios');
|
||||
|
||||
describe('getExchange()', () => {
|
||||
it('should return the correct exchange rate', async () => {
|
||||
axios.get.mockResolvedValue({
|
||||
data: { value: 1.2 },
|
||||
});
|
||||
|
||||
const amount = 100;
|
||||
const currencyFk = 1;
|
||||
const dated = '2023-01-01';
|
||||
const result = await getExchange(amount, currencyFk, dated);
|
||||
|
||||
expect(result).toBe('83.33');
|
||||
});
|
||||
|
||||
it('should return the correct exchange rate with custom decimal places', async () => {
|
||||
axios.get.mockResolvedValue({
|
||||
data: { value: 1.2 },
|
||||
});
|
||||
|
||||
const amount = 100;
|
||||
const currencyFk = 1;
|
||||
const dated = '2023-01-01';
|
||||
const decimalPlaces = 3;
|
||||
const result = await getExchange(amount, currencyFk, dated, decimalPlaces);
|
||||
|
||||
expect(result).toBe('83.333');
|
||||
});
|
||||
|
||||
it('should return null if the API call fails', async () => {
|
||||
axios.get.mockRejectedValue(new Error('Network error'));
|
||||
|
||||
const amount = 100;
|
||||
const currencyFk = 1;
|
||||
const dated = '2023-01-01';
|
||||
const result = await getExchange(amount, currencyFk, dated);
|
||||
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
});
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue