Compare commits
5 Commits
dev
...
6452-useId
Author | SHA1 | Date |
---|---|---|
|
df07f80dbb | |
|
898f549466 | |
|
92da474d7b | |
|
5e33e5fb7c | |
|
506bc40037 |
|
@ -0,0 +1,6 @@
|
||||||
|
/dist
|
||||||
|
/src-capacitor
|
||||||
|
/src-cordova
|
||||||
|
/.quasar
|
||||||
|
/node_modules
|
||||||
|
.eslintrc.js
|
|
@ -0,0 +1,75 @@
|
||||||
|
export default {
|
||||||
|
// 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)
|
||||||
|
root: true,
|
||||||
|
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: '2021', // Allows for the parsing of modern ECMAScript features
|
||||||
|
},
|
||||||
|
|
||||||
|
env: {
|
||||||
|
node: true,
|
||||||
|
browser: true,
|
||||||
|
'vue/setup-compiler-macros': true,
|
||||||
|
},
|
||||||
|
|
||||||
|
// Rules order is important, please avoid shuffling them
|
||||||
|
extends: [
|
||||||
|
// Base ESLint recommended rules
|
||||||
|
'eslint:recommended',
|
||||||
|
|
||||||
|
// Uncomment any of the lines below to choose desired strictness,
|
||||||
|
// but leave only one uncommented!
|
||||||
|
// See https://eslint.vuejs.org/rules/#available-rules
|
||||||
|
// 'plugin:vue/vue3-essential', // Priority A: Essential (Error Prevention)
|
||||||
|
'plugin:vue/vue3-strongly-recommended', // Priority B: Strongly Recommended (Improving Readability)
|
||||||
|
// 'plugin:vue/vue3-recommended', // Priority C: Recommended (Minimizing Arbitrary Choices and Cognitive Overhead)
|
||||||
|
|
||||||
|
// https://github.com/prettier/eslint-config-prettier#installation
|
||||||
|
// usage with Prettier, provided by 'eslint-config-prettier'.
|
||||||
|
'prettier',
|
||||||
|
],
|
||||||
|
|
||||||
|
plugins: [
|
||||||
|
// https://eslint.vuejs.org/user-guide/#why-doesn-t-it-work-on-vue-files
|
||||||
|
// required to lint *.vue files
|
||||||
|
'vue',
|
||||||
|
|
||||||
|
// https://github.com/typescript-eslint/typescript-eslint/issues/389#issuecomment-509292674
|
||||||
|
// Prettier has not been included as plugin to avoid performance impact
|
||||||
|
// add it as an extension for your IDE
|
||||||
|
],
|
||||||
|
|
||||||
|
globals: {
|
||||||
|
ga: 'readonly', // Google Analytics
|
||||||
|
cordova: 'readonly',
|
||||||
|
__statics: 'readonly',
|
||||||
|
__QUASAR_SSR__: 'readonly',
|
||||||
|
__QUASAR_SSR_SERVER__: 'readonly',
|
||||||
|
__QUASAR_SSR_CLIENT__: 'readonly',
|
||||||
|
__QUASAR_SSR_PWA__: 'readonly',
|
||||||
|
process: 'readonly',
|
||||||
|
Capacitor: 'readonly',
|
||||||
|
chrome: 'readonly',
|
||||||
|
},
|
||||||
|
|
||||||
|
// add your custom rules here
|
||||||
|
rules: {
|
||||||
|
'prefer-promise-reject-errors': 'off',
|
||||||
|
'no-unused-vars': 'warn',
|
||||||
|
'vue/no-multiple-template-root': 'off',
|
||||||
|
// allow debugger during development only
|
||||||
|
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||||
|
},
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
files: ['test/cypress/**/*.*'],
|
||||||
|
extends: [
|
||||||
|
// Add Cypress-specific lint rules, globals and Cypress plugin
|
||||||
|
// See https://github.com/cypress-io/eslint-plugin-cypress#rules
|
||||||
|
'plugin:cypress/recommended',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"extends": ["plugin:cypress/recommended"]
|
|
||||||
}
|
|
|
@ -31,7 +31,6 @@ yarn-error.log*
|
||||||
# Cypress directories and files
|
# Cypress directories and files
|
||||||
/test/cypress/videos
|
/test/cypress/videos
|
||||||
/test/cypress/screenshots
|
/test/cypress/screenshots
|
||||||
/junit
|
|
||||||
|
|
||||||
# VitePress directories and files
|
# VitePress directories and files
|
||||||
/docs/.vitepress/cache
|
/docs/.vitepress/cache
|
||||||
|
|
211
CHANGELOG.md
211
CHANGELOG.md
|
@ -1,214 +1,3 @@
|
||||||
# Version 25.12 - 2025-03-25
|
|
||||||
|
|
||||||
### Added 🆕
|
|
||||||
|
|
||||||
- chore: add junit-merge dependency to package.json by:alexm
|
|
||||||
- chore: downgrade version from 25.14.0 to 25.12.0 in package.json by:alexm
|
|
||||||
- chore: reduce page load timeout in Cypress configuration by:alexm
|
|
||||||
- chore: refs #6695 update Cypress to version 14.1.0 and simplify test execution in Jenkinsfile by:alexm
|
|
||||||
- chore: refs #8602 add comments for clarity in Cypress commands file by:pablone
|
|
||||||
- chore: refs #8602 enhance Cypress support files with detailed comments and organization by:pablone
|
|
||||||
- ci: refs #6695 feat jenkins parallel e2e by:alexm
|
|
||||||
- feat: integrate vue-router to enhance routing capabilities in ZoneCard component by:alexm
|
|
||||||
- feat: refs #6695 implement parallel Cypress testing and enhance timeout configurations by:alexm
|
|
||||||
- feat: refs #6695 update Cypress parallel test execution to use 3 instances by:alexm
|
|
||||||
- feat: refs #6802 add dash placeholder for empty department names in InvoiceOut list by:jgallego
|
|
||||||
- feat: refs #6802 add DepartmentDescriptorProxy to InvoiceOutList and update translations by:jgallego
|
|
||||||
- feat: refs #6802 add DepartmentDescriptorProxy to various components and update department handling by:jgallego
|
|
||||||
- feat: refs #7587 add 'ticketClaimed' translation and implement claims retrieval in TicketDescriptor by:jtubau
|
|
||||||
- feat: refs #7949 show new field in ticket sales by:Jon
|
|
||||||
- feat: refs #8045 added new logic to show the correct icon and the correct path to redirect by:Jon
|
|
||||||
- feat: refs #8045 modified icon and route to redirect from CardDescriptor by:Jon
|
|
||||||
- feat: refs #8074 modified spinner size by:Jon
|
|
||||||
- feat: refs #8600 added calendar e2e and modified basic data by:Jon
|
|
||||||
- feat: refs #8600 added deliveryDays and modified warehouse E2Es by:Jon
|
|
||||||
- feat: refs #8600 added new tests for zoneSummary & zoneLocations by:provira
|
|
||||||
- feat: refs #8602 add custom Cypress commands for improved element interaction and request handling by:pablone
|
|
||||||
- feat: refs #8602 add new Cypress command for clicking buttons with icons by:pablone
|
|
||||||
- feat: refs #8602 add remove functionality for tag filters in EntryBuys component by:pablone
|
|
||||||
- feat: refs #8602 add sorting options for select fields and update locale files with supplier name by:pablone
|
|
||||||
- feat: refs #8602 refactor EntryBuys component and enhance observation tests by:pablone
|
|
||||||
- feat: refs #8602 remove unused state property from useArrayDataStore by:pablone
|
|
||||||
- feat: refs #8602 remove unused URL property from VnTable in ClaimList component by:pablone
|
|
||||||
- feat: refs #8602 skip warehouse creation and removal test in ZoneWarehouse spec by:pablone
|
|
||||||
- feat: refs #8602 streamline beforeSaveFn execution in CrudModel component by:pablone
|
|
||||||
- feat: refs #8602 streamline beforeSaveFn execution in VnTable component by:pablone
|
|
||||||
- feat: refs #8602 streamline filter logic in EntryBuys component by:pablone
|
|
||||||
- feat: refs #8602 update entry components and tests, add data-cy attributes for Cypress integration by:pablone
|
|
||||||
- feat: refs #8602 update localization for purchased spaces and enhance Entry components with new labels by:pablone
|
|
||||||
- feat: refs #8606 adapt module to VnCatdBeta by:Jon
|
|
||||||
- feat: refs #8612 added summary button & changed e2e tests by:provira
|
|
||||||
- feat: refs #8612 changed shelving to VnTable & created e2e tests by:provira
|
|
||||||
- feat: refs #8616 add summary prop to CardDescriptor in RoadmapDescriptor and WorkerDescriptor by:jtubau
|
|
||||||
- feat: refs #8616 add VnCheckbox component to VnFilter and update prop types in VnFilterPanel and VnSearchbar by:jtubau
|
|
||||||
- feat: refs #8630 add Agency and Vehicle descriptor components with summary props by:jtubau
|
|
||||||
- feat: refs #8638 add AWB field to travel and entry forms, update translations and styles by:pablone
|
|
||||||
- feat: refs #8638 add data attributes for transfer buys functionality in EntryBuys.vue and corresponding tests by:pablone
|
|
||||||
- feat: refs #8648 enhance roadmapList tests with improved selectors and additional scenarios by:jtubau
|
|
||||||
- feat: refs #8664 add CmrFilter component and integrate it into CmrList for enhanced filtering options by:jtubau
|
|
||||||
- feat: refs #8721 add ticket navigation and update route columns by:jtubau
|
|
||||||
- feat: run.sh build neccessary images by:alexm
|
|
||||||
- feat: update Jenkinsfile to pull Docker images for back and db services by:alexm
|
|
||||||
- feat: update labels and add department selection in InvoiceOut filter and list by:jgallego
|
|
||||||
- refactor: refs #8626 update button styles and improve route redirection logic by:jtubau
|
|
||||||
- style: refs #8041 new variable by:benjaminedc
|
|
||||||
|
|
||||||
### Changed 📦
|
|
||||||
|
|
||||||
- feat: refs #8602 refactor EntryBuys component and enhance observation tests by:pablone
|
|
||||||
- refactor(cypress): refs #6695 simplify parallel test execution script by:alexm
|
|
||||||
- refactor: deleted useless (origin/Warmfix-DepartmentIcon) by:Jon
|
|
||||||
- refactor: refs #6695 enable ClaimNotes test suite by:alexm
|
|
||||||
- refactor: refs #6695 fix invoiceOutSummary by:alexm
|
|
||||||
- refactor: refs #6695 improve notification check and extend waitForElement timeout by:alexm
|
|
||||||
- refactor: refs #6695 remove mocha dependency and optimize Cypress command execution by:alexm
|
|
||||||
- refactor: refs #6695 skips by:alexm
|
|
||||||
- refactor: refs #6695 skip zoneWarehouse by:alexm
|
|
||||||
- refactor: refs #6695 streamline Cypress test execution and remove deprecated configurations by:alexm
|
|
||||||
- refactor: refs #6802 replace salesPerson references with department in claims and tickets by:jgallego
|
|
||||||
- refactor: refs #6802 replace 'salesPerson' terminology with 'team' across multiple locales and components by:jgallego
|
|
||||||
- refactor: refs #6802 update import paths for DepartmentDescriptorProxy to use Worker directory by:jgallego
|
|
||||||
- refactor: refs #6802 update InvoiceOutNegativeBases to use Department instead of Worker by:jgallego
|
|
||||||
- refactor: refs #6802 update TicketFilter and TicketSale components to use departmentFk and adjust API endpoints by:jgallego
|
|
||||||
- refactor: refs #8041 unify class link and unify titles to VnTitles by:benjaminedc
|
|
||||||
- refactor: refs #8045 modified icon and module const by:Jon
|
|
||||||
- refactor: refs #8197 rename VnCardBeta to VnCard by:alexm
|
|
||||||
- refactor: refs #8197 simplify menu retrieval logic in LeftMenu component by:alexm
|
|
||||||
- refactor: refs #8322 changed Wagon component to use VnSection/VnCardBeta by:provira
|
|
||||||
- refactor: refs #8322 remove keyBinding from Wagon router module by:alexm
|
|
||||||
- refactor: refs #8322 update WagonCard component and routing structure by:alexm
|
|
||||||
- refactor: refs #8370 modified function to get the correct date by:Jon
|
|
||||||
- refactor: refs #8472 remove added div and add class to VnInput by:jtubau
|
|
||||||
- refactor: refs #8472 unified styling for the more-create-dialog slot to ensure consistency across all scenarios by:jtubau
|
|
||||||
- refactor: refs #8472 update class names from q-span-2 to col-span-2 for consistency in layout by:jtubau
|
|
||||||
- refactor: refs #8600 changed test case description by:provira
|
|
||||||
- refactor: refs #8600 modified make invoice and send dialog e2es by:Jon
|
|
||||||
- refactor: refs #8600 modified upcomingDeliveries e2e and created deliveryDays by:Jon
|
|
||||||
- refactor: refs #8600 modified zoneSummary e2e by:Jon
|
|
||||||
- refactor: refs #8602 remove redundant date input test from entryList.spec.js by:pablone
|
|
||||||
- refactor: refs #8606 clear some warnings by:Jon
|
|
||||||
- refactor: refs #8606 deleted code and fixed translation by:Jon
|
|
||||||
- refactor: refs #8606 merged previous and e2e changes and corrected minor errors by:Jon
|
|
||||||
- refactor: refs #8606 requested changes by:Jon
|
|
||||||
- refactor: refs #8616 integrate summary dialog and update navigation in Agency and Vehicle components by:jtubau
|
|
||||||
- refactor: refs #8616 integrate VnSelectWorker component in RouteList and optimize format functions by:jtubau
|
|
||||||
- refactor: refs #8616 simplify template bindings and improve link generation in VehicleSummary by:jtubau
|
|
||||||
- refactor: refs #8616 update routing components for AgencyList and RouteRoadmap in route.js by:jtubau
|
|
||||||
- refactor: refs #8619 simplify empty data check in RouteDescriptor component by:jtubau
|
|
||||||
- refactor: refs #8626 add cardVisible property to RouteList columns by:jtubau
|
|
||||||
- refactor: refs #8626 add formatting for agency and vehicle columns in RouteList by:jtubau
|
|
||||||
- refactor: refs #8626 enhance Worker and Agency components with data attributes and improved routing by:jtubau
|
|
||||||
- refactor: refs #8626 improve test messages and selectors in route tests by:jtubau
|
|
||||||
- refactor: refs #8626 update button styles and improve route redirection logic by:jtubau
|
|
||||||
- refactor: refs #8626 update RouteList columns and enable AgencyWorkCenter tests by:jtubau
|
|
||||||
- refactor: refs #8630 add vehicle translations and enhance route list columns by:jtubau
|
|
||||||
- refactor: refs #8648 update roadmap deletion test to use current element text by:jtubau
|
|
||||||
- refactor: refs #8664 enhance CmrList component with query initialization and user parameters by:jtubau
|
|
||||||
- refactor: refs #8664 localization files by:jtubau
|
|
||||||
- refactor: refs #8664 remove CmrFilter and replace with VnSearchbar in CmrList by:jtubau
|
|
||||||
- refactor: remove unnecessary login and reload calls in ClaimDevelopment tests by:alexm
|
|
||||||
- refactor: simplify client selection in order creation test by:alexm
|
|
||||||
- refactor: update client ID input selector and remove viewport setting by:alexm
|
|
||||||
- test: refs #8197 comment out ticket list tests for refactoring by:alexm
|
|
||||||
- test: refs #8626 refactor notification check in routeList.spec.js by:jtubau
|
|
||||||
- test: refs #8626 refactor routeList.spec.js to use a constant for summary URL by:jtubau
|
|
||||||
- test: refs #8626 refactor routeList.spec.js to use selectors and improve readability by:jtubau
|
|
||||||
|
|
||||||
### Fixed 🛠️
|
|
||||||
|
|
||||||
- fix: add --init flag to Docker container for Cypress tests by:alexm
|
|
||||||
- fix: agency list filters by:jtubau
|
|
||||||
- fix: align Article label to the left in EntryBuys component by:alexm
|
|
||||||
- fix: card descriptor imports by:Jon
|
|
||||||
- fix: card descriptor merge by:Jon
|
|
||||||
- fix(ClaimAction): update shelving options to use URL instead of static data by:jgallego
|
|
||||||
- fix(ClaimSummary): clean url by:alexm
|
|
||||||
- fix(cypress.config.js): refs #6695 update reporter to junit and remove unused dependencies by:alexm
|
|
||||||
- fix(cypressParallel.sh): refs #6695 improve script readability by:alexm
|
|
||||||
- fix(cypressParallel.sh): refs #6695 improve test execution output for clarity by:alexm
|
|
||||||
- fix(cypressParallel.sh): refs #6695 simplify test execution output format by:alexm
|
|
||||||
- fix(cypress scripts): refs #6695 improve cleanup process and adjust output redirection by:alexm
|
|
||||||
- fix: fixed department descriptor icon by:Jon
|
|
||||||
- fix: fixed submodule descriptors icons by:Jon
|
|
||||||
- fix(invoiceOutSummary.spec.js): refs #6695 remove unnecessary visibility check for descriptor by:alexm
|
|
||||||
- fix(Jenkinsfile): reduce parallel Cypress test execution from 3 to 2 by:alexm
|
|
||||||
- fix(Jenkinsfile): refs #6695 add credentials for Docker login in E2E stage by:alexm
|
|
||||||
- fix(Jenkinsfile): refs #6695 change parallel test execution from 4 to 2 by:alexm
|
|
||||||
- fix(Jenkinsfile): refs #6695 increase parallel test execution from 2 to 4 by:alexm
|
|
||||||
- fix(Jenkinsfile): refs #6695 update parallel test execution to 4 by:alexm
|
|
||||||
- fix(LeftMenu): refs #8197 handle missing children in findRoute and update menu structure by:alexm
|
|
||||||
- fix: refs #6695 update Cypress configuration and test result paths by:alexm
|
|
||||||
- fix: refs #6695 update Jenkinsfile to build Docker image correctly and modify logout test visit method by:alexm
|
|
||||||
- fix: refs #6695 update Jenkinsfile to remove specific e2e XML files and adjust Cypress parallel execution by:alexm
|
|
||||||
- fix: refs #6695 update Jenkinsfile to source cypressParallel.sh correctly by:alexm
|
|
||||||
- fix: refs #6695 update visit method in TicketLackDetail.spec.js to prevent page reload by:alexm
|
|
||||||
- fix: refs #6802 update import path for DepartmentDescriptorProxy in OrderList.vue by:jgallego
|
|
||||||
- fix: refs #6802 update OrderFilter to use department relation instead of salesPerson by:jgallego
|
|
||||||
- fix: refs #8041 update redirection from preview to summary in ShelvingList tests by:benjaminedc
|
|
||||||
- fix: refs #8041 update selector for summary header in ParkingList tests by:benjaminedc
|
|
||||||
- fix: refs #8041 update summaryHeader selector in ParkingList test by:benjaminedc
|
|
||||||
- fix: refs #8322 update order property for WagonList component by:alexm
|
|
||||||
- fix: refs #8370 change param rely on month by:Jon
|
|
||||||
- fix: refs #8417 added data-cy to all files and fixed test by:provira
|
|
||||||
- fix: refs #8417 added data-cy to delete button by:provira
|
|
||||||
- fix: refs #8417 fixed claimPhoto e2e by:provira
|
|
||||||
- fix: refs #8417 fixed claimPhoto e2e test by:provira
|
|
||||||
- fix: refs #8417 fixed e2e test by:provira
|
|
||||||
- fix: refs #8417 fixed e2e test case by:provira
|
|
||||||
- fix: refs #8417 fixed failing test case by:provira
|
|
||||||
- fix: refs #8417 fixed invoiceOutSummary e2e test by:provira
|
|
||||||
- fix: refs #8417 removed .only by:provira
|
|
||||||
- fix: refs #8583 basicData, business, summary by:carlossa
|
|
||||||
- fix: refs #8583 basicData e2e by:carlossa
|
|
||||||
- fix: refs #8583 basicData timeControl by:carlossa
|
|
||||||
- fix: refs #8583 cypressconf by:carlossa
|
|
||||||
- fix: refs #8583 dataCy operator by:carlossa
|
|
||||||
- fix: refs #8583 fix AddCard by:carlossa
|
|
||||||
- fix: refs #8583 mutual create by:carlossa
|
|
||||||
- fix: refs #8583 operator by:carlossa
|
|
||||||
- fix: refs #8583 remove workerTimeControl by:carlossa
|
|
||||||
- fix: refs #8583 tMutual, tNotes, TOperator by:carlossa
|
|
||||||
- fix: refs #8583 wBusiness by:carlossa
|
|
||||||
- fix: refs #8583 wBusiness e2e by:carlossa
|
|
||||||
- fix: refs #8583 workerBasicData & workerTimeControl by:carlossa
|
|
||||||
- fix: refs #8583 workerBusiness by:carlossa
|
|
||||||
- fix: refs #8583 workerBusiness e2e by:carlossa
|
|
||||||
- fix: refs #8583 workerBusiness test by:carlossa
|
|
||||||
- fix: refs #8583 workerE2E by:carlossa
|
|
||||||
- fix: refs #8583 worker mutual e2e by:carlossa
|
|
||||||
- fix: refs #8583 workerSummary test by:carlossa
|
|
||||||
- fix: refs #8583 workerTimeControl by:carlossa
|
|
||||||
- fix: refs #8583 workerTimeControl e2e by:carlossa
|
|
||||||
- fix: refs #8600 e2e by:Jon
|
|
||||||
- fix: refs #8600 fixed calendar e2e by:Jon
|
|
||||||
- fix: refs #8600 fixed e2e and skip client ones by:Jon
|
|
||||||
- fix: refs #8600 fixed e2e by:Jon
|
|
||||||
- fix: refs #8600 fixed invoiceOut summary e2e by:Jon
|
|
||||||
- fix: refs #8600 fixed zoneList & added test case to zoneSummary by:provira
|
|
||||||
- fix: refs #8600 zone basic data e2e and skip intermitent invoice out summary it by:Jon
|
|
||||||
- fix: refs #8602 delete unused entryDms and stockBought test files (origin/8581-e2eInvoiceIn) by:pablone
|
|
||||||
- fix: refs #8606 deleted code by:Jon
|
|
||||||
- fix: refs #8612 changed QCheckbox for VnCheckbox by:provira
|
|
||||||
- fix: refs #8612 fixed shelving e2e tests by:provira
|
|
||||||
- fix: refs #8616 add conditional for SupplierDescriptorProxy and bind attributes in CardDescriptor by:jtubau
|
|
||||||
- fix: refs #8616 remove redundant v-on binding from QCheckbox in VnCheckbox.vue by:jtubau
|
|
||||||
- fix: refs #8616 update binding syntax for is-editable prop in AgencyList.vue by:jtubau
|
|
||||||
- fix: refs #8616 update FormModel prop from 'update-url' to 'url-update' in Agency and RoadMap BasicData by:jtubau
|
|
||||||
- fix: refs #8619 handle empty ticket records in RouteDescriptor component by:jtubau
|
|
||||||
- fix: refs #8619 update route descriptor to handle empty ticket records and adjust test cases by:jtubau
|
|
||||||
- fix: refs #8626 remove duplicate ref attribute from RouteList.vue by:jtubau
|
|
||||||
- fix: refs #8630 remove duplicated locations by:jtubau
|
|
||||||
- fix: refs #8638 restore invoiceInBasicData by:pablone
|
|
||||||
- fix: refs #8638 update comment formatting in VnTable.vue by:pablone
|
|
||||||
- fix: refs #8638 update null check for maxlength validation in VnInput.vue by:pablone
|
|
||||||
- fix: simplify menu structure in monitor router module (origin/fix_monitor_leftMenu) by:Javier Segarra
|
|
||||||
- refactor: refs #6695 fix invoiceOutSummary by:alexm
|
|
||||||
- refactor: refs #8606 deleted code and fixed translation by:Jon
|
|
||||||
- test: fix intermitent e2e by:alexm
|
|
||||||
- test: fix orderList e2e, unestables by:alexm
|
|
||||||
- test(OrderList): fix inconsistency by:alexm
|
|
||||||
- test(TicketList): fix inconsistency by:alexm
|
|
||||||
|
|
||||||
# Version 25.10 - 2025-03-11
|
# Version 25.10 - 2025-03-11
|
||||||
|
|
||||||
### Added 🆕
|
### Added 🆕
|
||||||
|
|
|
@ -114,28 +114,21 @@ pipeline {
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
sh 'rm -f junit/e2e-*.xml'
|
sh 'rm junit/e2e-*.xml || true'
|
||||||
sh 'rm -rf test/cypress/screenshots'
|
|
||||||
env.COMPOSE_TAG = PROTECTED_BRANCH.contains(env.CHANGE_TARGET) ? env.CHANGE_TARGET : 'dev'
|
env.COMPOSE_TAG = PROTECTED_BRANCH.contains(env.CHANGE_TARGET) ? env.CHANGE_TARGET : 'dev'
|
||||||
|
|
||||||
def image = docker.build('lilium-dev', '-f docs/Dockerfile.dev docs')
|
|
||||||
|
|
||||||
sh 'docker login --username $CREDS_USR --password $CREDS_PSW $REGISTRY'
|
sh 'docker login --username $CREDS_USR --password $CREDS_PSW $REGISTRY'
|
||||||
sh "docker-compose ${env.COMPOSE_PARAMS} pull back"
|
|
||||||
sh "docker-compose ${env.COMPOSE_PARAMS} pull db"
|
|
||||||
sh "docker-compose ${env.COMPOSE_PARAMS} up -d"
|
sh "docker-compose ${env.COMPOSE_PARAMS} up -d"
|
||||||
|
|
||||||
def modules = sh(script: "node test/cypress/docker/find/find.js ${env.COMPOSE_TAG}", returnStdout: true).trim()
|
def image = docker.build('lilium-dev', '-f docs/Dockerfile.dev docs')
|
||||||
echo "E2E MODULES: ${modules}"
|
|
||||||
image.inside("--network ${env.COMPOSE_PROJECT}_default -e CI -e TZ --init") {
|
image.inside("--network ${env.COMPOSE_PROJECT}_default -e CI -e TZ --init") {
|
||||||
sh "sh test/cypress/docker/cypressParallel.sh 1 '${modules}'"
|
sh 'cypress run --browser chromium || true'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
always {
|
always {
|
||||||
sh "docker-compose ${env.COMPOSE_PARAMS} down -v"
|
sh "docker-compose ${env.COMPOSE_PARAMS} down -v"
|
||||||
archiveArtifacts artifacts: 'test/cypress/screenshots/**/*', allowEmptyArchive: true
|
|
||||||
junit(
|
junit(
|
||||||
testResults: 'junit/e2e-*.xml',
|
testResults: 'junit/e2e-*.xml',
|
||||||
allowEmptyResults: true
|
allowEmptyResults: true
|
||||||
|
@ -185,4 +178,3 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
18
README.md
18
README.md
|
@ -32,26 +32,8 @@ pnpm run test:front
|
||||||
pnpm run test:e2e
|
pnpm run test:e2e
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run e2e parallel
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pnpm run test:e2e:parallel
|
|
||||||
```
|
|
||||||
|
|
||||||
### View e2e parallel report
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pnpm run test:e2e:summary
|
|
||||||
```
|
|
||||||
|
|
||||||
### Build the app for production
|
### Build the app for production
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
quasar build
|
quasar build
|
||||||
```
|
```
|
||||||
|
|
||||||
### Serve the app for production
|
|
||||||
|
|
||||||
```bash
|
|
||||||
quasar build quasar serve dist/spa --host 0.0.0.0 --proxy=./proxy-serve.js
|
|
||||||
```
|
|
||||||
|
|
|
@ -1,18 +1,13 @@
|
||||||
import { defineConfig } from 'cypress';
|
import { defineConfig } from 'cypress';
|
||||||
|
|
||||||
let urlHost, reporter, reporterOptions, timeouts;
|
let urlHost, reporter, reporterOptions;
|
||||||
|
|
||||||
if (process.env.CI) {
|
if (process.env.CI) {
|
||||||
urlHost = 'front';
|
urlHost = 'front';
|
||||||
reporter = 'junit';
|
reporter = 'junit';
|
||||||
reporterOptions = {
|
reporterOptions = {
|
||||||
mochaFile: 'junit/e2e-[hash].xml',
|
mochaFile: 'junit/e2e-[hash].xml',
|
||||||
};
|
toConsole: false,
|
||||||
timeouts = {
|
|
||||||
defaultCommandTimeout: 30000,
|
|
||||||
requestTimeout: 30000,
|
|
||||||
responseTimeout: 60000,
|
|
||||||
pageLoadTimeout: 60000,
|
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
urlHost = 'localhost';
|
urlHost = 'localhost';
|
||||||
|
@ -25,26 +20,23 @@ if (process.env.CI) {
|
||||||
reportDir: 'test/cypress/reports',
|
reportDir: 'test/cypress/reports',
|
||||||
inlineAssets: true,
|
inlineAssets: true,
|
||||||
};
|
};
|
||||||
timeouts = {
|
|
||||||
defaultCommandTimeout: 10000,
|
|
||||||
requestTimeout: 10000,
|
|
||||||
responseTimeout: 30000,
|
|
||||||
pageLoadTimeout: 60000,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
e2e: {
|
e2e: {
|
||||||
baseUrl: `http://${urlHost}:9000`,
|
baseUrl: `http://${urlHost}:9000`,
|
||||||
experimentalStudio: false,
|
experimentalStudio: false,
|
||||||
|
defaultCommandTimeout: 10000,
|
||||||
trashAssetsBeforeRuns: false,
|
trashAssetsBeforeRuns: false,
|
||||||
|
requestTimeout: 10000,
|
||||||
|
responseTimeout: 30000,
|
||||||
|
pageLoadTimeout: 60000,
|
||||||
defaultBrowser: 'chromium',
|
defaultBrowser: 'chromium',
|
||||||
fixturesFolder: 'test/cypress/fixtures',
|
fixturesFolder: 'test/cypress/fixtures',
|
||||||
screenshotsFolder: 'test/cypress/screenshots',
|
screenshotsFolder: 'test/cypress/screenshots',
|
||||||
supportFile: 'test/cypress/support/index.js',
|
supportFile: 'test/cypress/support/index.js',
|
||||||
videosFolder: 'test/cypress/videos',
|
videosFolder: 'test/cypress/videos',
|
||||||
downloadsFolder: 'test/cypress/downloads',
|
downloadsFolder: 'test/cypress/downloads',
|
||||||
tmpUploadFolder: 'test/cypress/storage/tmp/dms',
|
|
||||||
video: false,
|
video: false,
|
||||||
specPattern: 'test/cypress/integration/**/*.spec.js',
|
specPattern: 'test/cypress/integration/**/*.spec.js',
|
||||||
experimentalRunAllSpecs: true,
|
experimentalRunAllSpecs: true,
|
||||||
|
@ -58,8 +50,8 @@ export default defineConfig({
|
||||||
},
|
},
|
||||||
viewportWidth: 1280,
|
viewportWidth: 1280,
|
||||||
viewportHeight: 720,
|
viewportHeight: 720,
|
||||||
...timeouts,
|
|
||||||
includeShadowDom: true,
|
|
||||||
waitForAnimations: true,
|
|
||||||
},
|
},
|
||||||
|
experimentalMemoryManagement: true,
|
||||||
|
defaultCommandTimeout: 10000,
|
||||||
|
numTestsKeptInMemory: 2,
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,8 +25,6 @@ RUN apt-get update \
|
||||||
libnss3 \
|
libnss3 \
|
||||||
libxss1 \
|
libxss1 \
|
||||||
libxtst6 \
|
libxtst6 \
|
||||||
mesa-vulkan-drivers \
|
|
||||||
vulkan-tools \
|
|
||||||
xauth \
|
xauth \
|
||||||
xvfb \
|
xvfb \
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
|
@ -41,7 +39,7 @@ ENV PNPM_HOME="/home/app/.local/share/pnpm"
|
||||||
ENV PATH="$PNPM_HOME:$PATH"
|
ENV PATH="$PNPM_HOME:$PATH"
|
||||||
|
|
||||||
RUN pnpm setup \
|
RUN pnpm setup \
|
||||||
&& pnpm install --global cypress@14.1.0 \
|
&& pnpm install --global cypress@13.6.6 \
|
||||||
&& cypress install
|
&& cypress install
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
|
@ -1,87 +0,0 @@
|
||||||
import cypress from 'eslint-plugin-cypress';
|
|
||||||
import eslint from 'eslint-plugin-import';
|
|
||||||
import globals from 'globals';
|
|
||||||
import js from '@eslint/js';
|
|
||||||
import vue from 'eslint-plugin-vue';
|
|
||||||
export default {
|
|
||||||
plugins: { vue, eslint, cypress },
|
|
||||||
languageOptions: {
|
|
||||||
globals: {
|
|
||||||
...globals.node,
|
|
||||||
...globals.browser,
|
|
||||||
...vue.configs['vue3-strongly-recommended'].globals,
|
|
||||||
...cypress.environments.globals.globals,
|
|
||||||
ga: 'readonly',
|
|
||||||
cordova: 'readonly',
|
|
||||||
__statics: 'readonly',
|
|
||||||
__QUASAR_SSR__: 'readonly',
|
|
||||||
__QUASAR_SSR_SERVER__: 'readonly',
|
|
||||||
__QUASAR_SSR_CLIENT__: 'readonly',
|
|
||||||
__QUASAR_SSR_PWA__: 'readonly',
|
|
||||||
process: 'readonly',
|
|
||||||
Capacitor: 'readonly',
|
|
||||||
chrome: 'readonly',
|
|
||||||
},
|
|
||||||
|
|
||||||
ecmaVersion: 2020,
|
|
||||||
sourceType: 'module',
|
|
||||||
|
|
||||||
parserOptions: {
|
|
||||||
parser: '@babel/eslint-parser',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
...vue.rules['flat/strongly-recommended'],
|
|
||||||
...js.configs.recommended.rules,
|
|
||||||
semi: 'off',
|
|
||||||
'generator-star-spacing': 'warn',
|
|
||||||
'arrow-parens': 'warn',
|
|
||||||
'no-var': 'error',
|
|
||||||
'prefer-const': 'error',
|
|
||||||
'prefer-template': 'warn',
|
|
||||||
'prefer-destructuring': 'off',
|
|
||||||
'prefer-spread': 'warn',
|
|
||||||
'prefer-rest-params': 'warn',
|
|
||||||
'prefer-object-spread': 'warn',
|
|
||||||
'prefer-arrow-callback': 'warn',
|
|
||||||
'prefer-numeric-literals': 'warn',
|
|
||||||
'prefer-exponentiation-operator': 'warn',
|
|
||||||
'prefer-regex-literals': 'warn',
|
|
||||||
'one-var': [
|
|
||||||
'error',
|
|
||||||
{
|
|
||||||
let: 'never',
|
|
||||||
const: 'never',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'no-void': 'off',
|
|
||||||
'prefer-promise-reject-errors': 'error',
|
|
||||||
'multiline-ternary': 'warn',
|
|
||||||
'no-restricted-imports': 'warn',
|
|
||||||
'no-import-assign': 'warn',
|
|
||||||
'no-duplicate-imports': 'warn',
|
|
||||||
'no-useless-rename': 'warn',
|
|
||||||
'eslint/no-named-as-default': 'warn',
|
|
||||||
'eslint/no-named-as-default-member': 'warn',
|
|
||||||
'no-unsafe-optional-chaining': 'warn',
|
|
||||||
'no-undef': 'error',
|
|
||||||
'no-unused-vars': 'error',
|
|
||||||
'no-console': 'error',
|
|
||||||
'no-debugger': 'error',
|
|
||||||
'no-useless-escape': 'error',
|
|
||||||
'no-prototype-builtins': 'error',
|
|
||||||
'no-async-promise-executor': 'error',
|
|
||||||
'no-irregular-whitespace': 'error',
|
|
||||||
'no-constant-condition': 'error',
|
|
||||||
'no-unsafe-finally': 'error',
|
|
||||||
'no-extend-native': 'error',
|
|
||||||
},
|
|
||||||
ignores: [
|
|
||||||
'/dist',
|
|
||||||
'/src-capacitor',
|
|
||||||
'/src-cordova',
|
|
||||||
'/.quasar',
|
|
||||||
'/node_modules',
|
|
||||||
'.eslintrc.js',
|
|
||||||
],
|
|
||||||
};
|
|
32
package.json
32
package.json
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "salix-front",
|
"name": "salix-front",
|
||||||
"version": "25.18.0",
|
"version": "25.10.0",
|
||||||
"description": "Salix frontend",
|
"description": "Salix frontend",
|
||||||
"productName": "Salix",
|
"productName": "Salix",
|
||||||
"author": "Verdnatura",
|
"author": "Verdnatura",
|
||||||
|
@ -9,17 +9,12 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"resetDatabase": "cd ../salix && gulp docker",
|
"resetDatabase": "cd ../salix && gulp docker",
|
||||||
"lint": "eslint \"**/*.{vue,js}\" ",
|
"lint": "eslint --ext .js,.vue ./",
|
||||||
"lint:fix": "eslint \"**/*.{vue,js}\" --fix ",
|
|
||||||
"format": "prettier --write \"**/*.{js,vue,scss,html,md,json}\" --ignore-path .gitignore",
|
"format": "prettier --write \"**/*.{js,vue,scss,html,md,json}\" --ignore-path .gitignore",
|
||||||
"test:e2e": "cypress open",
|
"test:e2e": "cypress open",
|
||||||
"test:e2e:ci": "npm run resetDatabase && cd ../salix-front && cypress run",
|
"test:e2e:ci": "npm run resetDatabase && cd ../salix-front && cypress run",
|
||||||
"test:e2e:parallel": "bash ./test/cypress/run.sh",
|
|
||||||
"test:e2e:summary": "bash ./test/cypress/summary.sh",
|
|
||||||
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
|
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
|
||||||
"test:front": "vitest",
|
"test:front": "vitest",
|
||||||
"test:ui": "vitest --ui",
|
|
||||||
"test:coverage": "vitest run --coverage",
|
|
||||||
"test:front:ci": "vitest run",
|
"test:front:ci": "vitest run",
|
||||||
"commitlint": "commitlint --edit",
|
"commitlint": "commitlint --edit",
|
||||||
"prepare": "npx husky install",
|
"prepare": "npx husky install",
|
||||||
|
@ -29,54 +24,41 @@
|
||||||
"docs:preview": "vitepress preview docs"
|
"docs:preview": "vitepress preview docs"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint/eslintrc": "^3.2.0",
|
|
||||||
"@eslint/js": "^9.20.0",
|
|
||||||
"@quasar/cli": "^2.4.1",
|
"@quasar/cli": "^2.4.1",
|
||||||
"@quasar/extras": "^1.16.16",
|
"@quasar/extras": "^1.16.16",
|
||||||
"axios": "^1.4.0",
|
"axios": "^1.4.0",
|
||||||
"chromium": "^3.0.3",
|
"chromium": "^3.0.3",
|
||||||
"croppie": "^2.6.5",
|
"croppie": "^2.6.5",
|
||||||
"es-module-lexer": "^1.6.0",
|
|
||||||
"fast-glob": "^3.3.3",
|
|
||||||
"moment": "^2.30.1",
|
"moment": "^2.30.1",
|
||||||
"pinia": "^2.1.3",
|
"pinia": "^2.1.3",
|
||||||
"quasar": "^2.17.7",
|
"quasar": "^2.17.7",
|
||||||
"validator": "^13.9.0",
|
"validator": "^13.9.0",
|
||||||
"vue": "^3.5.13",
|
"vue": "^3.5.13",
|
||||||
"vue-i18n": "^9.4.0",
|
"vue-i18n": "^9.3.0",
|
||||||
"vue-router": "^4.2.5"
|
"vue-router": "^4.2.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^19.2.1",
|
"@commitlint/cli": "^19.2.1",
|
||||||
"@commitlint/config-conventional": "^19.1.0",
|
"@commitlint/config-conventional": "^19.1.0",
|
||||||
"@eslint/eslintrc": "^3.2.0",
|
"@intlify/unplugin-vue-i18n": "^0.8.2",
|
||||||
"@eslint/js": "^9.20.0",
|
|
||||||
"@intlify/unplugin-vue-i18n": "^4.0.0",
|
|
||||||
"@pinia/testing": "^0.1.2",
|
"@pinia/testing": "^0.1.2",
|
||||||
"@quasar/app-vite": "^2.0.8",
|
"@quasar/app-vite": "^2.0.8",
|
||||||
"@quasar/quasar-app-extension-qcalendar": "^4.0.2",
|
"@quasar/quasar-app-extension-qcalendar": "^4.0.2",
|
||||||
"@quasar/quasar-app-extension-testing-unit-vitest": "^0.4.0",
|
"@quasar/quasar-app-extension-testing-unit-vitest": "^0.4.0",
|
||||||
"@vitest/ui": "3.1.1",
|
|
||||||
"@vue/compiler-sfc": "^3.5.13",
|
|
||||||
"@vue/test-utils": "^2.4.4",
|
"@vue/test-utils": "^2.4.4",
|
||||||
"autoprefixer": "^10.4.14",
|
"autoprefixer": "^10.4.14",
|
||||||
"cypress": "^14.1.0",
|
"cypress": "^13.6.6",
|
||||||
"cypress-mochawesome-reporter": "^3.8.2",
|
"cypress-mochawesome-reporter": "^3.8.2",
|
||||||
"eslint": "^9.18.0",
|
"eslint": "^9.18.0",
|
||||||
"eslint-config-prettier": "^10.0.1",
|
"eslint-config-prettier": "^10.0.1",
|
||||||
"eslint-import-resolver-alias": "^1.1.2",
|
|
||||||
"eslint-plugin-cypress": "^4.1.0",
|
"eslint-plugin-cypress": "^4.1.0",
|
||||||
"eslint-plugin-import": "^2.31.0",
|
|
||||||
"eslint-plugin-vue": "^9.32.0",
|
"eslint-plugin-vue": "^9.32.0",
|
||||||
"globals": "^16.0.0",
|
|
||||||
"husky": "^8.0.0",
|
"husky": "^8.0.0",
|
||||||
"junit-merge": "^2.0.0",
|
|
||||||
"mocha": "^11.1.0",
|
|
||||||
"postcss": "^8.4.23",
|
"postcss": "^8.4.23",
|
||||||
"prettier": "^3.4.2",
|
"prettier": "^3.4.2",
|
||||||
"sass": "^1.83.4",
|
"sass": "^1.83.4",
|
||||||
"vitest": "^3.0.3",
|
"vitepress": "^1.6.3",
|
||||||
"xunit-viewer": "^10.6.1"
|
"vitest": "^0.34.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^20 || ^18 || ^16",
|
"node": "^20 || ^18 || ^16",
|
||||||
|
|
4278
pnpm-lock.yaml
4278
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -53,7 +53,7 @@ export default configure(function (/* ctx */) {
|
||||||
build: {
|
build: {
|
||||||
target: {
|
target: {
|
||||||
browser: ['es2022', 'edge88', 'firefox78', 'chrome87', 'safari13.1'],
|
browser: ['es2022', 'edge88', 'firefox78', 'chrome87', 'safari13.1'],
|
||||||
node: 'node20',
|
node: 'node18',
|
||||||
},
|
},
|
||||||
|
|
||||||
vueRouterMode: 'hash', // available values: 'hash', 'history'
|
vueRouterMode: 'hash', // available values: 'hash', 'history'
|
||||||
|
@ -92,7 +92,6 @@ export default configure(function (/* ctx */) {
|
||||||
vitePlugins: [
|
vitePlugins: [
|
||||||
[
|
[
|
||||||
VueI18nPlugin({
|
VueI18nPlugin({
|
||||||
strictMessage: false,
|
|
||||||
runtimeOnly: false,
|
runtimeOnly: false,
|
||||||
include: [
|
include: [
|
||||||
path.resolve(__dirname, './src/i18n/locale/**'),
|
path.resolve(__dirname, './src/i18n/locale/**'),
|
||||||
|
|
|
@ -1,227 +0,0 @@
|
||||||
/* eslint-disable */
|
|
||||||
/**
|
|
||||||
* THIS FILE IS GENERATED AUTOMATICALLY.
|
|
||||||
* 1. DO NOT edit this file directly as it won't do anything.
|
|
||||||
* 2. EDIT the original quasar.config file INSTEAD.
|
|
||||||
* 3. DO NOT git commit this file. It should be ignored.
|
|
||||||
*
|
|
||||||
* This file is still here because there was an error in
|
|
||||||
* the original quasar.config file and this allows you to
|
|
||||||
* investigate the Node.js stack error.
|
|
||||||
*
|
|
||||||
* After you fix the original file, this file will be
|
|
||||||
* deleted automatically.
|
|
||||||
**/
|
|
||||||
|
|
||||||
|
|
||||||
// quasar.config.js
|
|
||||||
import { configure } from "quasar/wrappers";
|
|
||||||
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
|
|
||||||
import path from "path";
|
|
||||||
var __quasar_inject_dirname__ = "/home/jsegarra/Projects/salix-front";
|
|
||||||
var target = `http://${process.env.CI ? "back" : "localhost"}:3000`;
|
|
||||||
var quasar_config_default = configure(function() {
|
|
||||||
return {
|
|
||||||
eslint: {
|
|
||||||
// fix: true,
|
|
||||||
// include = [],
|
|
||||||
// exclude = [],
|
|
||||||
// rawOptions = {},
|
|
||||||
warnings: true,
|
|
||||||
errors: true
|
|
||||||
},
|
|
||||||
// https://v2.quasar.dev/quasar-cli/prefetch-feature
|
|
||||||
// preFetch: true,
|
|
||||||
// app boot file (/src/boot)
|
|
||||||
// --> boot files are part of "main.js"
|
|
||||||
// https://v2.quasar.dev/quasar-cli/boot-files
|
|
||||||
boot: ["i18n", "axios", "vnDate", "validations", "quasar", "quasar.defaults"],
|
|
||||||
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css
|
|
||||||
css: ["app.scss"],
|
|
||||||
// https://github.com/quasarframework/quasar/tree/dev/extras
|
|
||||||
extras: [
|
|
||||||
// 'ionicons-v4',
|
|
||||||
// 'mdi-v5',
|
|
||||||
// 'fontawesome-v6',
|
|
||||||
// 'eva-icons',
|
|
||||||
// 'themify',
|
|
||||||
// 'line-awesome',
|
|
||||||
// 'roboto-font-latin-ext', // this or either 'roboto-font', NEVER both!
|
|
||||||
"roboto-font",
|
|
||||||
"material-icons-outlined",
|
|
||||||
"material-symbols-outlined"
|
|
||||||
],
|
|
||||||
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#build
|
|
||||||
build: {
|
|
||||||
target: {
|
|
||||||
browser: ["es2022", "edge88", "firefox78", "chrome87", "safari13.1"],
|
|
||||||
node: "node20"
|
|
||||||
},
|
|
||||||
vueRouterMode: "hash",
|
|
||||||
// available values: 'hash', 'history'
|
|
||||||
// vueRouterBase,
|
|
||||||
// vueDevtools,
|
|
||||||
// vueOptionsAPI: false,
|
|
||||||
// rebuildCache: true, // rebuilds Vite/linter/etc cache on startup
|
|
||||||
// publicPath: '/',
|
|
||||||
// analyze: true,
|
|
||||||
// env: {},
|
|
||||||
rawDefine: {
|
|
||||||
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV)
|
|
||||||
},
|
|
||||||
// ignorePublicFolder: true,
|
|
||||||
// minify: false,
|
|
||||||
// polyfillModulePreload: true,
|
|
||||||
// distDir
|
|
||||||
extendViteConf(viteConf) {
|
|
||||||
delete viteConf.build.polyfillModulePreload;
|
|
||||||
viteConf.build.modulePreload = {
|
|
||||||
polyfill: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
// viteVuePluginOptions: {},
|
|
||||||
alias: {
|
|
||||||
composables: path.join(__quasar_inject_dirname__, "./src/composables"),
|
|
||||||
filters: path.join(__quasar_inject_dirname__, "./src/filters")
|
|
||||||
},
|
|
||||||
vitePlugins: [
|
|
||||||
[
|
|
||||||
VueI18nPlugin({
|
|
||||||
strictMessage: false,
|
|
||||||
runtimeOnly: false,
|
|
||||||
include: [
|
|
||||||
path.resolve(__quasar_inject_dirname__, "./src/i18n/locale/**"),
|
|
||||||
path.resolve(__quasar_inject_dirname__, "./src/pages/**/locale/**")
|
|
||||||
]
|
|
||||||
})
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#devServer
|
|
||||||
devServer: {
|
|
||||||
server: {
|
|
||||||
type: "http"
|
|
||||||
},
|
|
||||||
proxy: {
|
|
||||||
"/api": {
|
|
||||||
target,
|
|
||||||
logLevel: "debug",
|
|
||||||
changeOrigin: true,
|
|
||||||
secure: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
open: false,
|
|
||||||
allowedHosts: [
|
|
||||||
"front",
|
|
||||||
// Agrega este nombre de host
|
|
||||||
"localhost"
|
|
||||||
// Opcional, para pruebas locales
|
|
||||||
]
|
|
||||||
},
|
|
||||||
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#framework
|
|
||||||
framework: {
|
|
||||||
config: {
|
|
||||||
config: {
|
|
||||||
dark: "auto"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
lang: "en-GB",
|
|
||||||
// iconSet: 'material-icons', // Quasar icon set
|
|
||||||
// lang: 'en-US', // Quasar language pack
|
|
||||||
// For special cases outside of where the auto-import strategy can have an impact
|
|
||||||
// (like functional components as one of the examples),
|
|
||||||
// you can manually specify Quasar components/directives to be available everywhere:
|
|
||||||
//
|
|
||||||
// components: [],
|
|
||||||
// directives: [],
|
|
||||||
// Quasar plugins
|
|
||||||
plugins: ["Notify", "Dialog"],
|
|
||||||
all: "auto",
|
|
||||||
autoImportComponentCase: "pascal"
|
|
||||||
},
|
|
||||||
// animations: 'all', // --- includes all animations
|
|
||||||
// https://v2.quasar.dev/options/animations
|
|
||||||
animations: [],
|
|
||||||
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#property-sourcefiles
|
|
||||||
// sourceFiles: {
|
|
||||||
// rootComponent: 'src/App.vue',
|
|
||||||
// router: 'src/router/index',
|
|
||||||
// store: 'src/store/index',
|
|
||||||
// registerServiceWorker: 'src-pwa/register-service-worker',
|
|
||||||
// serviceWorker: 'src-pwa/custom-service-worker',
|
|
||||||
// pwaManifestFile: 'src-pwa/manifest.json',
|
|
||||||
// electronMain: 'src-electron/electron-main',
|
|
||||||
// electronPreload: 'src-electron/electron-preload'
|
|
||||||
// },
|
|
||||||
// https://v2.quasar.dev/quasar-cli/developing-ssr/configuring-ssr
|
|
||||||
ssr: {
|
|
||||||
// ssrPwaHtmlFilename: 'offline.html', // do NOT use index.html as name!
|
|
||||||
// will mess up SSR
|
|
||||||
// extendSSRWebserverConf (esbuildConf) {},
|
|
||||||
// extendPackageJson (json) {},
|
|
||||||
pwa: false,
|
|
||||||
// manualStoreHydration: true,
|
|
||||||
// manualPostHydrationTrigger: true,
|
|
||||||
prodPort: 3e3,
|
|
||||||
// The default port that the production server should use
|
|
||||||
// (gets superseded if process.env.PORT is specified at runtime)
|
|
||||||
middlewares: [
|
|
||||||
"render"
|
|
||||||
// keep this as last one
|
|
||||||
]
|
|
||||||
},
|
|
||||||
// https://v2.quasar.dev/quasar-cli/developing-pwa/configuring-pwa
|
|
||||||
pwa: {
|
|
||||||
workboxMode: "generateSW",
|
|
||||||
// or 'injectManifest'
|
|
||||||
injectPwaMetaTags: true,
|
|
||||||
swFilename: "sw.js",
|
|
||||||
manifestFilename: "manifest.json",
|
|
||||||
useCredentialsForManifestTag: false
|
|
||||||
// useFilenameHashes: true,
|
|
||||||
// extendGenerateSWOptions (cfg) {}
|
|
||||||
// extendInjectManifestOptions (cfg) {},
|
|
||||||
// extendManifestJson (json) {}
|
|
||||||
// extendPWACustomSWConf (esbuildConf) {}
|
|
||||||
},
|
|
||||||
// Full list of options: https://v2.quasar.dev/quasar-cli/developing-cordova-apps/configuring-cordova
|
|
||||||
cordova: {
|
|
||||||
// noIosLegacyBuildFlag: true, // uncomment only if you know what you are doing
|
|
||||||
},
|
|
||||||
// Full list of options: https://v2.quasar.dev/quasar-cli/developing-capacitor-apps/configuring-capacitor
|
|
||||||
capacitor: {
|
|
||||||
hideSplashscreen: true
|
|
||||||
},
|
|
||||||
// Full list of options: https://v2.quasar.dev/quasar-cli/developing-electron-apps/configuring-electron
|
|
||||||
electron: {
|
|
||||||
// extendElectronMainConf (esbuildConf)
|
|
||||||
// extendElectronPreloadConf (esbuildConf)
|
|
||||||
inspectPort: 5858,
|
|
||||||
bundler: "packager",
|
|
||||||
// 'packager' or 'builder'
|
|
||||||
packager: {
|
|
||||||
// https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options
|
|
||||||
// OS X / Mac App Store
|
|
||||||
// appBundleId: '',
|
|
||||||
// appCategoryType: '',
|
|
||||||
// osxSign: '',
|
|
||||||
// protocol: 'myapp://path',
|
|
||||||
// Windows only
|
|
||||||
// win32metadata: { ... }
|
|
||||||
},
|
|
||||||
builder: {
|
|
||||||
// https://www.electron.build/configuration/configuration
|
|
||||||
appId: "salix-frontend"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-browser-extensions/configuring-bex
|
|
||||||
bex: {
|
|
||||||
contentScripts: ["my-content-script"]
|
|
||||||
// extendBexScriptsConf (esbuildConf) {}
|
|
||||||
// extendBexManifestJson (json) {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
export {
|
|
||||||
quasar_config_default as default
|
|
||||||
};
|
|
|
@ -2,7 +2,6 @@
|
||||||
import { onMounted } from 'vue';
|
import { onMounted } from 'vue';
|
||||||
import { useQuasar, Dark } from 'quasar';
|
import { useQuasar, Dark } from 'quasar';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import VnScroll from './components/common/VnScroll.vue';
|
|
||||||
|
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const { availableLocales, locale, fallbackLocale } = useI18n();
|
const { availableLocales, locale, fallbackLocale } = useI18n();
|
||||||
|
@ -39,7 +38,6 @@ quasar.iconMapFn = (iconName) => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<RouterView />
|
<RouterView />
|
||||||
<VnScroll/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
|
@ -9,30 +9,6 @@ vi.mock('src/composables/useSession', () => ({
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Mock axios
|
|
||||||
vi.mock('axios', () => ({
|
|
||||||
default: {
|
|
||||||
create: vi.fn(() => ({
|
|
||||||
interceptors: {
|
|
||||||
request: { use: vi.fn() },
|
|
||||||
response: { use: vi.fn() },
|
|
||||||
},
|
|
||||||
})),
|
|
||||||
interceptors: {
|
|
||||||
request: { use: vi.fn() },
|
|
||||||
response: { use: vi.fn() },
|
|
||||||
},
|
|
||||||
defaults: {
|
|
||||||
baseURL: '',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
vi.mock('src/router', () => ({
|
|
||||||
Router: {
|
|
||||||
push: vi.fn(),
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
vi.mock('src/stores/useStateQueryStore', () => ({
|
vi.mock('src/stores/useStateQueryStore', () => ({
|
||||||
useStateQueryStore: () => ({
|
useStateQueryStore: () => ({
|
||||||
add: () => vi.fn(),
|
add: () => vi.fn(),
|
||||||
|
@ -53,7 +29,7 @@ describe('Axios boot', () => {
|
||||||
'Accept-Language': 'en-US',
|
'Accept-Language': 'en-US',
|
||||||
Authorization: 'DEFAULT_TOKEN',
|
Authorization: 'DEFAULT_TOKEN',
|
||||||
},
|
},
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -67,7 +43,7 @@ describe('Axios boot', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = onResponseError(error);
|
const result = onResponseError(error);
|
||||||
await expect(result).rejects.toEqual(expect.objectContaining(error));
|
expect(result).rejects.toEqual(expect.objectContaining(error));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call to the Notify plugin with a message from the response property', async () => {
|
it('should call to the Notify plugin with a message from the response property', async () => {
|
||||||
|
@ -83,7 +59,7 @@ describe('Axios boot', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = onResponseError(error);
|
const result = onResponseError(error);
|
||||||
await expect(result).rejects.toEqual(expect.objectContaining(error));
|
expect(result).rejects.toEqual(expect.objectContaining(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* eslint-disable eslint/export */
|
|
||||||
export * from './defaults/qTable';
|
export * from './defaults/qTable';
|
||||||
export * from './defaults/qInput';
|
export * from './defaults/qInput';
|
||||||
export * from './defaults/qSelect';
|
export * from './defaults/qSelect';
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import { boot } from 'quasar/wrappers';
|
import { boot } from 'quasar/wrappers';
|
||||||
import { date as quasarDate } from 'quasar';
|
|
||||||
const { formatDate } = quasarDate;
|
|
||||||
|
|
||||||
export default boot(() => {
|
export default boot(() => {
|
||||||
Date.vnUTC = () => {
|
Date.vnUTC = () => {
|
||||||
|
@ -27,34 +25,4 @@ export default boot(() => {
|
||||||
const date = new Date(Date.vnUTC());
|
const date = new Date(Date.vnUTC());
|
||||||
return new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
return new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
Date.getCurrentDateTimeFormatted = (
|
|
||||||
options = {
|
|
||||||
startOfDay: false,
|
|
||||||
endOfDay: true,
|
|
||||||
iso: true,
|
|
||||||
mask: 'DD-MM-YYYY HH:mm',
|
|
||||||
},
|
|
||||||
) => {
|
|
||||||
const date = Date.vnUTC();
|
|
||||||
if (options.startOfDay) {
|
|
||||||
date.setHours(0, 0, 0);
|
|
||||||
}
|
|
||||||
if (options.endOfDay) {
|
|
||||||
date.setHours(23, 59, 0);
|
|
||||||
}
|
|
||||||
if (options.iso) {
|
|
||||||
return date.toISOString();
|
|
||||||
}
|
|
||||||
return formatDate(date, options.mask);
|
|
||||||
};
|
|
||||||
|
|
||||||
Date.convertToISODateTime = (dateTimeStr) => {
|
|
||||||
const [datePart, timePart] = dateTimeStr.split(' ');
|
|
||||||
const [day, month, year] = datePart.split('-');
|
|
||||||
const [hours, minutes] = timePart.split(':');
|
|
||||||
|
|
||||||
const isoDate = new Date(year, month - 1, day, hours, minutes);
|
|
||||||
return isoDate.toISOString();
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,6 +20,7 @@ const postcodeFormData = reactive({
|
||||||
provinceFk: null,
|
provinceFk: null,
|
||||||
townFk: null,
|
townFk: null,
|
||||||
});
|
});
|
||||||
|
const townFilter = ref({});
|
||||||
|
|
||||||
const countriesRef = ref(false);
|
const countriesRef = ref(false);
|
||||||
const provincesOptions = ref([]);
|
const provincesOptions = ref([]);
|
||||||
|
@ -32,11 +33,11 @@ function onDataSaved(formData) {
|
||||||
newPostcode.town = town.value.name;
|
newPostcode.town = town.value.name;
|
||||||
newPostcode.townFk = town.value.id;
|
newPostcode.townFk = town.value.id;
|
||||||
const provinceObject = provincesOptions.value.find(
|
const provinceObject = provincesOptions.value.find(
|
||||||
({ id }) => id === formData.provinceFk,
|
({ id }) => id === formData.provinceFk
|
||||||
);
|
);
|
||||||
newPostcode.province = provinceObject?.name;
|
newPostcode.province = provinceObject?.name;
|
||||||
const countryObject = countriesRef.value.opts.find(
|
const countryObject = countriesRef.value.opts.find(
|
||||||
({ id }) => id === formData.countryFk,
|
({ id }) => id === formData.countryFk
|
||||||
);
|
);
|
||||||
newPostcode.country = countryObject?.name;
|
newPostcode.country = countryObject?.name;
|
||||||
emit('onDataSaved', newPostcode);
|
emit('onDataSaved', newPostcode);
|
||||||
|
@ -66,11 +67,21 @@ function setTown(newTown, data) {
|
||||||
}
|
}
|
||||||
async function onCityCreated(newTown, formData) {
|
async function onCityCreated(newTown, formData) {
|
||||||
newTown.province = provincesOptions.value.find(
|
newTown.province = provincesOptions.value.find(
|
||||||
(province) => province.id === newTown.provinceFk,
|
(province) => province.id === newTown.provinceFk
|
||||||
);
|
);
|
||||||
formData.townFk = newTown;
|
formData.townFk = newTown;
|
||||||
setTown(newTown, formData);
|
setTown(newTown, formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function filterTowns(name) {
|
||||||
|
if (name !== '') {
|
||||||
|
townFilter.value.where = {
|
||||||
|
name: {
|
||||||
|
like: `%${name}%`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -96,6 +107,7 @@ async function onCityCreated(newTown, formData) {
|
||||||
<VnSelectDialog
|
<VnSelectDialog
|
||||||
:label="t('City')"
|
:label="t('City')"
|
||||||
@update:model-value="(value) => setTown(value, data)"
|
@update:model-value="(value) => setTown(value, data)"
|
||||||
|
@filter="filterTowns"
|
||||||
:tooltip="t('Create city')"
|
:tooltip="t('Create city')"
|
||||||
v-model="data.townFk"
|
v-model="data.townFk"
|
||||||
url="Towns/location"
|
url="Towns/location"
|
||||||
|
|
|
@ -65,7 +65,7 @@ const $props = defineProps({
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
beforeSaveFn: {
|
beforeSaveFn: {
|
||||||
type: [String, Function],
|
type: Function,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
goTo: {
|
goTo: {
|
||||||
|
@ -83,7 +83,7 @@ const isLoading = ref(false);
|
||||||
const hasChanges = ref(false);
|
const hasChanges = ref(false);
|
||||||
const originalData = ref();
|
const originalData = ref();
|
||||||
const vnPaginateRef = ref();
|
const vnPaginateRef = ref();
|
||||||
const formData = ref();
|
const formData = ref([]);
|
||||||
const saveButtonRef = ref(null);
|
const saveButtonRef = ref(null);
|
||||||
const watchChanges = ref();
|
const watchChanges = ref();
|
||||||
const formUrl = computed(() => $props.url);
|
const formUrl = computed(() => $props.url);
|
||||||
|
@ -181,8 +181,9 @@ async function saveChanges(data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let changes = data || getChanges();
|
let changes = data || getChanges();
|
||||||
if ($props.beforeSaveFn) changes = await $props.beforeSaveFn(changes, getChanges);
|
if ($props.beforeSaveFn) {
|
||||||
|
changes = await $props.beforeSaveFn(changes, getChanges);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (changes?.creates?.length === 0 && changes?.updates?.length === 0) {
|
if (changes?.creates?.length === 0 && changes?.updates?.length === 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -193,7 +194,7 @@ async function saveChanges(data) {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
originalData.value = JSON.parse(JSON.stringify(formData.value));
|
originalData.value = JSON.parse(JSON.stringify(formData.value));
|
||||||
if (changes?.creates?.length) await vnPaginateRef.value.fetch();
|
if (changes.creates?.length) await vnPaginateRef.value.fetch();
|
||||||
|
|
||||||
hasChanges.value = false;
|
hasChanges.value = false;
|
||||||
emit('saveChanges', data);
|
emit('saveChanges', data);
|
||||||
|
@ -298,10 +299,6 @@ watch(formUrl, async () => {
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<SkeletonTable
|
|
||||||
v-if="!formData && ($attrs['auto-load'] === '' || $attrs['auto-load'])"
|
|
||||||
:columns="$attrs.columns?.length"
|
|
||||||
/>
|
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
:url="url"
|
:url="url"
|
||||||
:limit="limit"
|
:limit="limit"
|
||||||
|
@ -320,6 +317,10 @@ watch(formUrl, async () => {
|
||||||
></slot>
|
></slot>
|
||||||
</template>
|
</template>
|
||||||
</VnPaginate>
|
</VnPaginate>
|
||||||
|
<SkeletonTable
|
||||||
|
v-if="!formData && $attrs.autoLoad"
|
||||||
|
:columns="$attrs.columns?.length"
|
||||||
|
/>
|
||||||
<Teleport to="#st-actions" v-if="stateStore?.isSubToolbarShown() && hasSubToolbar">
|
<Teleport to="#st-actions" v-if="stateStore?.isSubToolbarShown() && hasSubToolbar">
|
||||||
<QBtnGroup push style="column-gap: 10px">
|
<QBtnGroup push style="column-gap: 10px">
|
||||||
<slot name="moreBeforeActions" />
|
<slot name="moreBeforeActions" />
|
||||||
|
@ -332,7 +333,6 @@ watch(formUrl, async () => {
|
||||||
:disable="!selected?.length"
|
:disable="!selected?.length"
|
||||||
:title="t('globals.remove')"
|
:title="t('globals.remove')"
|
||||||
v-if="$props.defaultRemove"
|
v-if="$props.defaultRemove"
|
||||||
data-cy="crudModelDefaultRemoveBtn"
|
|
||||||
/>
|
/>
|
||||||
<QBtn
|
<QBtn
|
||||||
:label="tMobile('globals.reset')"
|
:label="tMobile('globals.reset')"
|
||||||
|
|
|
@ -140,7 +140,7 @@ const updatePhotoPreview = (value) => {
|
||||||
img.onerror = () => {
|
img.onerror = () => {
|
||||||
notify(
|
notify(
|
||||||
t("This photo provider doesn't allow remote downloads"),
|
t("This photo provider doesn't allow remote downloads"),
|
||||||
'negative',
|
'negative'
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,11 @@ const makeRequest = async () => {
|
||||||
color="primary"
|
color="primary"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="rotateLeft()"
|
@click="rotateLeft()"
|
||||||
/>
|
>
|
||||||
|
<!-- <QTooltip class="no-pointer-events">
|
||||||
|
{{ t('Rotate left') }}
|
||||||
|
</QTooltip> -->
|
||||||
|
</QIcon>
|
||||||
<div>
|
<div>
|
||||||
<div ref="photoContainerRef" />
|
<div ref="photoContainerRef" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -229,7 +233,11 @@ const makeRequest = async () => {
|
||||||
color="primary"
|
color="primary"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="rotateRight()"
|
@click="rotateRight()"
|
||||||
/>
|
>
|
||||||
|
<!-- <QTooltip class="no-pointer-events">
|
||||||
|
{{ t('Rotate right') }}
|
||||||
|
</QTooltip> -->
|
||||||
|
</QIcon>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="column">
|
<div class="column">
|
||||||
|
@ -257,6 +265,7 @@ const makeRequest = async () => {
|
||||||
class="cursor-pointer q-mr-sm"
|
class="cursor-pointer q-mr-sm"
|
||||||
@click="openInputFile()"
|
@click="openInputFile()"
|
||||||
>
|
>
|
||||||
|
<!-- <QTooltip>{{ t('globals.selectFile') }}</QTooltip> -->
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon name="info" class="cursor-pointer">
|
<QIcon name="info" class="cursor-pointer">
|
||||||
<QTooltip>{{
|
<QTooltip>{{
|
||||||
|
|
|
@ -8,6 +8,11 @@ import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import { QCheckbox } from 'quasar';
|
import { QCheckbox } from 'quasar';
|
||||||
|
|
||||||
|
import axios from 'axios';
|
||||||
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
|
|
||||||
|
const emit = defineEmits(['onDataSaved']);
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
rows: {
|
rows: {
|
||||||
type: Array,
|
type: Array,
|
||||||
|
@ -21,14 +26,10 @@ const $props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
beforeSave: {
|
|
||||||
type: Function,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const emit = defineEmits(['onDataSaved']);
|
const { notify } = useNotify();
|
||||||
|
|
||||||
const inputs = {
|
const inputs = {
|
||||||
input: markRaw(VnInput),
|
input: markRaw(VnInput),
|
||||||
|
@ -43,13 +44,24 @@ const selectedField = ref(null);
|
||||||
const closeButton = ref(null);
|
const closeButton = ref(null);
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
|
||||||
|
const onDataSaved = () => {
|
||||||
|
notify('globals.dataSaved', 'positive');
|
||||||
|
emit('onDataSaved');
|
||||||
|
closeForm();
|
||||||
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
$props.rows.forEach((row) => {
|
const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk }));
|
||||||
row[selectedField.value.name] = newValue.value;
|
const payload = {
|
||||||
});
|
field: selectedField.value.field,
|
||||||
emit('onDataSaved', $props.rows);
|
newValue: newValue.value,
|
||||||
closeForm();
|
lines: rowsToEdit,
|
||||||
|
};
|
||||||
|
|
||||||
|
await axios.post($props.editUrl, payload);
|
||||||
|
onDataSaved();
|
||||||
|
isLoading.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeForm = () => {
|
const closeForm = () => {
|
||||||
|
@ -66,24 +78,21 @@ const closeForm = () => {
|
||||||
<span class="title">{{ t('Edit') }}</span>
|
<span class="title">{{ t('Edit') }}</span>
|
||||||
<span class="countLines">{{ ` ${rows.length} ` }}</span>
|
<span class="countLines">{{ ` ${rows.length} ` }}</span>
|
||||||
<span class="title">{{ t('buy(s)') }}</span>
|
<span class="title">{{ t('buy(s)') }}</span>
|
||||||
<VnRow class="q-mt-md">
|
<VnRow>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
class="editOption"
|
|
||||||
:label="t('Field to edit')"
|
:label="t('Field to edit')"
|
||||||
:options="fieldsOptions"
|
:options="fieldsOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="label"
|
option-label="label"
|
||||||
v-model="selectedField"
|
v-model="selectedField"
|
||||||
data-cy="EditFixedPriceSelectOption"
|
data-cy="field-to-edit"
|
||||||
@update:model-value="newValue = null"
|
|
||||||
:class="{ 'is-select': selectedField?.component === 'select' }"
|
|
||||||
/>
|
/>
|
||||||
<component
|
<component
|
||||||
:is="inputs[selectedField?.component || 'input']"
|
:is="inputs[selectedField?.component || 'input']"
|
||||||
v-bind="selectedField?.attrs || {}"
|
v-bind="selectedField?.attrs || {}"
|
||||||
v-model="newValue"
|
v-model="newValue"
|
||||||
:label="t('Value')"
|
:label="t('Value')"
|
||||||
data-cy="EditFixedPriceValueOption"
|
data-cy="value-to-edit"
|
||||||
style="width: 200px"
|
style="width: 200px"
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
@ -131,15 +140,6 @@ const closeForm = () => {
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
.editOption .q-field__inner .q-field__control {
|
|
||||||
padding: 0 !important;
|
|
||||||
}
|
|
||||||
.editOption.is-select .q-field__inner .q-field__control {
|
|
||||||
padding: 0 !important;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
es:
|
es:
|
||||||
Edit: Editar
|
Edit: Editar
|
|
@ -1,152 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref, computed } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import { date } from 'quasar';
|
|
||||||
import QCalendarMonthWrapper from 'src/components/ui/QCalendarMonthWrapper.vue';
|
|
||||||
import { QCalendarMonth } from '@quasar/quasar-ui-qcalendar/src/index.js';
|
|
||||||
import '@quasar/quasar-ui-qcalendar/src/QCalendarVariables.scss';
|
|
||||||
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
|
|
||||||
import useWeekdaysOrder from 'src/composables/getWeekdays';
|
|
||||||
|
|
||||||
const formatDate = (dateToFormat, format = 'YYYY-MM-DD') => (
|
|
||||||
date.formatDate(dateToFormat, format)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
year: {
|
|
||||||
type: Number,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
month: {
|
|
||||||
type: Number,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
monthDate: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
daysMap: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits(['onDateSelected']);
|
|
||||||
|
|
||||||
const { locale } = useI18n();
|
|
||||||
const weekdayStore = useWeekdayStore();
|
|
||||||
const weekDays = useWeekdaysOrder();
|
|
||||||
const calendarRef = ref(null);
|
|
||||||
const today = ref(formatDate(Date.vnNew()));
|
|
||||||
const todayTimestamp = computed(() => {
|
|
||||||
const date = Date.vnNew();
|
|
||||||
date.setHours(0, 0, 0, 0);
|
|
||||||
return date.getTime();
|
|
||||||
});
|
|
||||||
const _monthDate = computed(() => formatDate(props.monthDate));
|
|
||||||
|
|
||||||
const calendarHeaderTitle = computed(() => {
|
|
||||||
return `${weekdayStore.getLocaleMonths[props.month - 1].locale} ${props.year}`;
|
|
||||||
});
|
|
||||||
|
|
||||||
const isToday = (timestamp) => {
|
|
||||||
const { year, month, day } = timestamp;
|
|
||||||
return todayTimestamp.value === new Date(year, month - 1, day).getTime();
|
|
||||||
};
|
|
||||||
|
|
||||||
const getEventByTimestamp = ({ year, month, day }) => {
|
|
||||||
const stamp = new Date(year, month - 1, day).getTime();
|
|
||||||
return props.daysMap?.[stamp] || null;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDateClick = (timestamp) => {
|
|
||||||
const event = getEventByTimestamp(timestamp);
|
|
||||||
const { year, month, day } = timestamp;
|
|
||||||
const date = new Date(year, month - 1, day);
|
|
||||||
emit('onDateSelected', {
|
|
||||||
date,
|
|
||||||
isNewMode: !event,
|
|
||||||
event: event?.[0] || null
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const getEventAttrs = (timestamp) => {
|
|
||||||
return {
|
|
||||||
class: '--event',
|
|
||||||
label: timestamp.day,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
defineExpose({ getEventByTimestamp, handleDateClick });
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<QCalendarMonthWrapper
|
|
||||||
style="height: 290px; width: 290px"
|
|
||||||
transparent-background
|
|
||||||
view-customization="workerCalendar"
|
|
||||||
>
|
|
||||||
<template #header>
|
|
||||||
<span class="full-width text-center text-body1 q-py-sm">{{
|
|
||||||
calendarHeaderTitle
|
|
||||||
}}</span>
|
|
||||||
</template>
|
|
||||||
<template #calendar>
|
|
||||||
<QCalendarMonth
|
|
||||||
ref="calendarRef"
|
|
||||||
:model-value="_monthDate"
|
|
||||||
show-work-weeks
|
|
||||||
no-outside-days
|
|
||||||
no-active-date
|
|
||||||
:weekdays="weekDays"
|
|
||||||
short-weekday-label
|
|
||||||
:locale="locale"
|
|
||||||
:now="today"
|
|
||||||
@click-date="handleDateClick($event.scope.timestamp)"
|
|
||||||
mini-mode
|
|
||||||
>
|
|
||||||
<template #day="{ scope: { timestamp } }">
|
|
||||||
<slot name="day" :timestamp="timestamp" :getEventAttrs="getEventAttrs">
|
|
||||||
<QBtn
|
|
||||||
v-if="getEventByTimestamp(timestamp)"
|
|
||||||
v-bind="{ ...getEventAttrs(timestamp) }"
|
|
||||||
@click="handleDateClick(timestamp)"
|
|
||||||
rounded
|
|
||||||
dense
|
|
||||||
flat
|
|
||||||
class="calendar-event"
|
|
||||||
:class="{ '--today': isToday(timestamp) }"
|
|
||||||
/>
|
|
||||||
</slot>
|
|
||||||
</template>
|
|
||||||
</QCalendarMonth>
|
|
||||||
</template>
|
|
||||||
</QCalendarMonthWrapper>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
.calendar-event {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
font-size: 13px;
|
|
||||||
line-height: 1.715em;
|
|
||||||
cursor: pointer;
|
|
||||||
color: white;
|
|
||||||
|
|
||||||
&.--today {
|
|
||||||
border: 2px solid $info;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.--event {
|
|
||||||
background-color: $positive;
|
|
||||||
color: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
opacity: 0.8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,126 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { computed, onMounted, ref, onUnmounted, nextTick } from 'vue';
|
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
|
||||||
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
|
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
dataKey: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
calendarComponent: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
additionalProps: {
|
|
||||||
type: Object,
|
|
||||||
default: () => ({}),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const stateStore = useStateStore();
|
|
||||||
const weekdayStore = useWeekdayStore();
|
|
||||||
const nMonths = ref(4);
|
|
||||||
const _date = ref(Date.vnNew());
|
|
||||||
const firstDay = ref(Date.vnNew());
|
|
||||||
const lastDay = ref(Date.vnNew());
|
|
||||||
const months = ref([]);
|
|
||||||
const arrayData = useArrayData(props.dataKey);
|
|
||||||
onMounted(async () => {
|
|
||||||
const initialDate = Date.vnNew();
|
|
||||||
initialDate.setDate(1);
|
|
||||||
initialDate.setHours(0, 0, 0, 0);
|
|
||||||
date.value = initialDate;
|
|
||||||
await nextTick();
|
|
||||||
stateStore.rightDrawer = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
onUnmounted(() => arrayData.destroy());
|
|
||||||
|
|
||||||
const emit = defineEmits([
|
|
||||||
'update:firstDay',
|
|
||||||
'update:lastDay',
|
|
||||||
'update:events',
|
|
||||||
'onDateSelected',
|
|
||||||
]);
|
|
||||||
|
|
||||||
const date = computed({
|
|
||||||
get: () => _date.value,
|
|
||||||
set: (value) => {
|
|
||||||
if (!(value instanceof Date)) return;
|
|
||||||
_date.value = value;
|
|
||||||
const stamp = value.getTime();
|
|
||||||
|
|
||||||
firstDay.value = new Date(stamp);
|
|
||||||
firstDay.value.setDate(1);
|
|
||||||
|
|
||||||
lastDay.value = new Date(stamp);
|
|
||||||
lastDay.value.setMonth(lastDay.value.getMonth() + nMonths.value);
|
|
||||||
lastDay.value.setDate(0);
|
|
||||||
|
|
||||||
months.value = [];
|
|
||||||
for (let i = 0; i < nMonths.value; i++) {
|
|
||||||
const monthDate = new Date(stamp);
|
|
||||||
monthDate.setMonth(value.getMonth() + i);
|
|
||||||
months.value.push(monthDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
emit('update:firstDay', firstDay.value);
|
|
||||||
emit('update:lastDay', lastDay.value);
|
|
||||||
emit('refresh-events');
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const headerTitle = computed(() => {
|
|
||||||
if (!months.value?.length) return '';
|
|
||||||
const getMonthName = date =>
|
|
||||||
`${weekdayStore.getLocaleMonths[date.getMonth()].locale} ${date.getFullYear()}`;
|
|
||||||
return `${getMonthName(months.value[0])} - ${getMonthName(months.value[months.value.length - 1])}`;
|
|
||||||
});
|
|
||||||
|
|
||||||
const step = (direction) => {
|
|
||||||
const newDate = new Date(date.value);
|
|
||||||
newDate.setMonth(newDate.getMonth() + nMonths.value * direction);
|
|
||||||
date.value = newDate;
|
|
||||||
};
|
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
firstDay,
|
|
||||||
lastDay
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<QCard style="height: max-content">
|
|
||||||
<div class="calendars-header">
|
|
||||||
<QBtn
|
|
||||||
icon="arrow_left"
|
|
||||||
size="sm"
|
|
||||||
flat
|
|
||||||
class="full-height"
|
|
||||||
@click="step(-1)"
|
|
||||||
/>
|
|
||||||
<span>{{ headerTitle }}</span>
|
|
||||||
<QBtn
|
|
||||||
icon="arrow_right"
|
|
||||||
size="sm"
|
|
||||||
flat
|
|
||||||
class="full-height"
|
|
||||||
@click="step(1)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="calendars-container">
|
|
||||||
<component
|
|
||||||
:is="calendarComponent"
|
|
||||||
v-for="(month, index) in months"
|
|
||||||
:key="index"
|
|
||||||
:month="month.getMonth() + 1"
|
|
||||||
:year="month.getFullYear()"
|
|
||||||
:month-date="month"
|
|
||||||
v-bind="additionalProps"
|
|
||||||
@on-date-selected="data => emit('onDateSelected', data)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</QCard>
|
|
||||||
</template>
|
|
|
@ -188,7 +188,7 @@ const selectItem = ({ id }) => {
|
||||||
>
|
>
|
||||||
<template #body-cell-id="{ row }">
|
<template #body-cell-id="{ row }">
|
||||||
<QTd auto-width @click.stop>
|
<QTd auto-width @click.stop>
|
||||||
<QBtn flat class="link">{{ row.id }}</QBtn>
|
<QBtn flat color="blue">{{ row.id }}</QBtn>
|
||||||
<ItemDescriptorProxy :id="row.id" />
|
<ItemDescriptorProxy :id="row.id" />
|
||||||
</QTd>
|
</QTd>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -156,9 +156,6 @@ const selectTravel = ({ id }) => {
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
v-model="travelFilterParams.warehouseOutFk"
|
v-model="travelFilterParams.warehouseOutFk"
|
||||||
:where="{
|
|
||||||
isOrigin: true,
|
|
||||||
}"
|
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('globals.warehouseIn')"
|
:label="t('globals.warehouseIn')"
|
||||||
|
@ -167,9 +164,6 @@ const selectTravel = ({ id }) => {
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
v-model="travelFilterParams.warehouseInFk"
|
v-model="travelFilterParams.warehouseInFk"
|
||||||
:where="{
|
|
||||||
isDestiny: true,
|
|
||||||
}"
|
|
||||||
/>
|
/>
|
||||||
<VnInputDate
|
<VnInputDate
|
||||||
:label="t('globals.shipped')"
|
:label="t('globals.shipped')"
|
||||||
|
@ -202,7 +196,7 @@ const selectTravel = ({ id }) => {
|
||||||
>
|
>
|
||||||
<template #body-cell-id="{ row }">
|
<template #body-cell-id="{ row }">
|
||||||
<QTd auto-width @click.stop data-cy="travelFk-travel-form">
|
<QTd auto-width @click.stop data-cy="travelFk-travel-form">
|
||||||
<QBtn flat class="link">{{ row.id }}</QBtn>
|
<QBtn flat color="blue">{{ row.id }}</QBtn>
|
||||||
<TravelDescriptorProxy :id="row.id" />
|
<TravelDescriptorProxy :id="row.id" />
|
||||||
</QTd>
|
</QTd>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -13,15 +13,17 @@ import VnConfirm from './ui/VnConfirm.vue';
|
||||||
import { tMobile } from 'src/composables/tMobile';
|
import { tMobile } from 'src/composables/tMobile';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
import { getDifferences, getUpdatedValues } from 'src/filters';
|
import { getDifferences, getUpdatedValues } from 'src/filters';
|
||||||
|
|
||||||
const { push } = useRouter();
|
const { push } = useRouter();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { validate, validations } = useValidator();
|
const { validate } = useValidator();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const myForm = ref(null);
|
const myForm = ref(null);
|
||||||
|
const attrs = useAttrs();
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
url: {
|
url: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -98,12 +100,8 @@ const $props = defineProps({
|
||||||
type: Function,
|
type: Function,
|
||||||
default: () => {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
preventSubmit: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
const emit = defineEmits(['onFetch', 'onDataSaved', 'submit']);
|
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
||||||
const modelValue = computed(
|
const modelValue = computed(
|
||||||
() => $props.model ?? `formModel_${route?.meta?.title ?? route.name}`,
|
() => $props.model ?? `formModel_${route?.meta?.title ?? route.name}`,
|
||||||
).value;
|
).value;
|
||||||
|
@ -121,7 +119,7 @@ const defaultButtons = computed(() => ({
|
||||||
color: 'primary',
|
color: 'primary',
|
||||||
icon: 'save',
|
icon: 'save',
|
||||||
label: 'globals.save',
|
label: 'globals.save',
|
||||||
click: async (evt) => submitForm(evt),
|
click: async () => await save(),
|
||||||
type: 'submit',
|
type: 'submit',
|
||||||
},
|
},
|
||||||
reset: {
|
reset: {
|
||||||
|
@ -134,13 +132,6 @@ const defaultButtons = computed(() => ({
|
||||||
...$props.defaultButtons,
|
...$props.defaultButtons,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const submitForm = async (evt) => {
|
|
||||||
const isFormValid = await myForm.value.validate();
|
|
||||||
if (isFormValid) {
|
|
||||||
await save(evt);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
nextTick(() => (componentIsRendered.value = true));
|
nextTick(() => (componentIsRendered.value = true));
|
||||||
|
|
||||||
|
@ -236,9 +227,10 @@ async function save() {
|
||||||
const method = $props.urlCreate ? 'post' : 'patch';
|
const method = $props.urlCreate ? 'post' : 'patch';
|
||||||
const url =
|
const url =
|
||||||
$props.urlCreate || $props.urlUpdate || $props.url || arrayData.store.url;
|
$props.urlCreate || $props.urlUpdate || $props.url || arrayData.store.url;
|
||||||
const response = await Promise.resolve(
|
let response;
|
||||||
$props.saveFn ? $props.saveFn(body) : axios[method](url, body),
|
|
||||||
);
|
if ($props.saveFn) response = await $props.saveFn(body);
|
||||||
|
else response = await axios[method](url, body);
|
||||||
|
|
||||||
if ($props.urlCreate) notify('globals.dataCreated', 'positive');
|
if ($props.urlCreate) notify('globals.dataCreated', 'positive');
|
||||||
|
|
||||||
|
@ -304,7 +296,7 @@ function onBeforeSave(formData, originalData) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
async function onKeyup(evt) {
|
async function onKeyup(evt) {
|
||||||
if (evt.key === 'Enter' && !$props.preventSubmit) {
|
if (evt.key === 'Enter' && !('prevent-submit' in attrs)) {
|
||||||
const input = evt.target;
|
const input = evt.target;
|
||||||
if (input.type == 'textarea' && evt.shiftKey) {
|
if (input.type == 'textarea' && evt.shiftKey) {
|
||||||
let { selectionStart, selectionEnd } = input;
|
let { selectionStart, selectionEnd } = input;
|
||||||
|
@ -315,13 +307,11 @@ async function onKeyup(evt) {
|
||||||
selectionStart = selectionEnd = selectionStart + 1;
|
selectionStart = selectionEnd = selectionStart + 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await myForm.value.submit(evt);
|
await save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
submitForm,
|
|
||||||
myForm,
|
|
||||||
save,
|
save,
|
||||||
isLoading,
|
isLoading,
|
||||||
hasChanges,
|
hasChanges,
|
||||||
|
@ -333,10 +323,9 @@ defineExpose({
|
||||||
<template>
|
<template>
|
||||||
<div class="column items-center full-width">
|
<div class="column items-center full-width">
|
||||||
<QForm
|
<QForm
|
||||||
v-on="$attrs"
|
|
||||||
ref="myForm"
|
ref="myForm"
|
||||||
v-if="formData"
|
v-if="formData"
|
||||||
@submit.prevent="save"
|
@submit.prevent
|
||||||
@keyup.prevent="onKeyup"
|
@keyup.prevent="onKeyup"
|
||||||
@reset="reset"
|
@reset="reset"
|
||||||
class="q-pa-md"
|
class="q-pa-md"
|
||||||
|
@ -350,7 +339,6 @@ defineExpose({
|
||||||
name="form"
|
name="form"
|
||||||
:data="formData"
|
:data="formData"
|
||||||
:validate="validate"
|
:validate="validate"
|
||||||
:validations="validations()"
|
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
/>
|
/>
|
||||||
<SkeletonForm v-else />
|
<SkeletonForm v-else />
|
||||||
|
@ -410,7 +398,6 @@ defineExpose({
|
||||||
</QBtnDropdown>
|
</QBtnDropdown>
|
||||||
<QBtn
|
<QBtn
|
||||||
v-else
|
v-else
|
||||||
data-cy="saveDefaultBtn"
|
|
||||||
:label="tMobile('globals.save')"
|
:label="tMobile('globals.save')"
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="save"
|
icon="save"
|
||||||
|
|
|
@ -41,12 +41,9 @@ const onDataSaved = async (formData, requestResponse) => {
|
||||||
emit('onDataSaved', formData, requestResponse);
|
emit('onDataSaved', formData, requestResponse);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClick = async (saveAndContinue = showSaveAndContinueBtn) => {
|
const onClick = async (saveAndContinue) => {
|
||||||
await formModelRef.value.myForm.validate(true);
|
|
||||||
isSaveAndContinue.value = saveAndContinue;
|
isSaveAndContinue.value = saveAndContinue;
|
||||||
if (formModelRef.value) {
|
await formModelRef.value.save();
|
||||||
await formModelRef.value.submitForm();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
@ -62,23 +59,16 @@ defineExpose({
|
||||||
ref="formModelRef"
|
ref="formModelRef"
|
||||||
:observe-form-changes="false"
|
:observe-form-changes="false"
|
||||||
:default-actions="false"
|
:default-actions="false"
|
||||||
@submit="onClick"
|
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
@on-data-saved="onDataSaved"
|
@on-data-saved="onDataSaved"
|
||||||
:prevent-submit="false"
|
|
||||||
>
|
>
|
||||||
<template #form="{ data, validate, validations }">
|
<template #form="{ data, validate }">
|
||||||
<span ref="closeButton" class="close-icon" v-close-popup>
|
<span ref="closeButton" class="close-icon" v-close-popup>
|
||||||
<QIcon name="close" size="sm" />
|
<QIcon name="close" size="sm" />
|
||||||
</span>
|
</span>
|
||||||
<h1 class="title">{{ title }}</h1>
|
<h1 class="title">{{ title }}</h1>
|
||||||
<p>{{ subtitle }}</p>
|
<p>{{ subtitle }}</p>
|
||||||
<slot
|
<slot name="form-inputs" :data="data" :validate="validate" />
|
||||||
name="form-inputs"
|
|
||||||
:data="data"
|
|
||||||
:validate="validate"
|
|
||||||
:validations="validations"
|
|
||||||
/>
|
|
||||||
<div class="q-mt-lg row justify-end">
|
<div class="q-mt-lg row justify-end">
|
||||||
<QBtn
|
<QBtn
|
||||||
:label="t('globals.cancel')"
|
:label="t('globals.cancel')"
|
||||||
|
@ -97,13 +87,12 @@ defineExpose({
|
||||||
:flat="showSaveAndContinueBtn"
|
:flat="showSaveAndContinueBtn"
|
||||||
:label="t('globals.save')"
|
:label="t('globals.save')"
|
||||||
:title="t('globals.save')"
|
:title="t('globals.save')"
|
||||||
:type="!showSaveAndContinueBtn ? 'submit' : 'button'"
|
@click="onClick(false)"
|
||||||
color="primary"
|
color="primary"
|
||||||
class="q-ml-sm"
|
class="q-ml-sm"
|
||||||
:disabled="isLoading"
|
:disabled="isLoading"
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
data-cy="FormModelPopup_save"
|
data-cy="FormModelPopup_save"
|
||||||
@click="showSaveAndContinueBtn ? onClick(false) : null"
|
|
||||||
z-max
|
z-max
|
||||||
/>
|
/>
|
||||||
<QBtn
|
<QBtn
|
||||||
|
@ -111,13 +100,12 @@ defineExpose({
|
||||||
:label="t('globals.isSaveAndContinue')"
|
:label="t('globals.isSaveAndContinue')"
|
||||||
:title="t('globals.isSaveAndContinue')"
|
:title="t('globals.isSaveAndContinue')"
|
||||||
color="primary"
|
color="primary"
|
||||||
:type="showSaveAndContinueBtn ? 'submit' : 'button'"
|
|
||||||
class="q-ml-sm"
|
class="q-ml-sm"
|
||||||
:disabled="isLoading"
|
:disabled="isLoading"
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
data-cy="FormModelPopup_isSaveAndContinue"
|
data-cy="FormModelPopup_isSaveAndContinue"
|
||||||
@click="showSaveAndContinueBtn ? onClick(true) : null"
|
|
||||||
z-max
|
z-max
|
||||||
|
@click="onClick(true)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -198,7 +198,8 @@ const setCategoryList = (data) => {
|
||||||
v-model="params.typeFk"
|
v-model="params.typeFk"
|
||||||
:options="itemTypesOptions"
|
:options="itemTypesOptions"
|
||||||
dense
|
dense
|
||||||
filled
|
outlined
|
||||||
|
rounded
|
||||||
use-input
|
use-input
|
||||||
:disable="!selectedCategoryFk"
|
:disable="!selectedCategoryFk"
|
||||||
@update:model-value="
|
@update:model-value="
|
||||||
|
@ -234,7 +235,8 @@ const setCategoryList = (data) => {
|
||||||
v-model="value.selectedTag"
|
v-model="value.selectedTag"
|
||||||
:options="tagOptions"
|
:options="tagOptions"
|
||||||
dense
|
dense
|
||||||
filled
|
outlined
|
||||||
|
rounded
|
||||||
:emit-value="false"
|
:emit-value="false"
|
||||||
use-input
|
use-input
|
||||||
:is-clearable="false"
|
:is-clearable="false"
|
||||||
|
@ -250,7 +252,8 @@ const setCategoryList = (data) => {
|
||||||
option-value="value"
|
option-value="value"
|
||||||
option-label="value"
|
option-label="value"
|
||||||
dense
|
dense
|
||||||
filled
|
outlined
|
||||||
|
rounded
|
||||||
emit-value
|
emit-value
|
||||||
use-input
|
use-input
|
||||||
:disable="!value"
|
:disable="!value"
|
||||||
|
@ -262,6 +265,7 @@ const setCategoryList = (data) => {
|
||||||
v-model="value.value"
|
v-model="value.value"
|
||||||
:label="t('components.itemsFilterPanel.value')"
|
:label="t('components.itemsFilterPanel.value')"
|
||||||
:disable="!value"
|
:disable="!value"
|
||||||
|
is-outlined
|
||||||
:is-clearable="false"
|
:is-clearable="false"
|
||||||
@keyup.enter="applyTags(params, searchFn)"
|
@keyup.enter="applyTags(params, searchFn)"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -77,7 +77,6 @@ watch(
|
||||||
function findMatches(search, item) {
|
function findMatches(search, item) {
|
||||||
const matches = [];
|
const matches = [];
|
||||||
function findRoute(search, item) {
|
function findRoute(search, item) {
|
||||||
if (!item?.children) return;
|
|
||||||
for (const child of item.children) {
|
for (const child of item.children) {
|
||||||
if (search?.indexOf(child.name) > -1) {
|
if (search?.indexOf(child.name) > -1) {
|
||||||
matches.push(child);
|
matches.push(child);
|
||||||
|
@ -93,7 +92,7 @@ function findMatches(search, item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addChildren(module, route, parent) {
|
function addChildren(module, route, parent) {
|
||||||
const menus = route?.meta?.menu;
|
const menus = route?.meta?.menu ?? route?.menus?.[props.source]; //backwards compatible
|
||||||
if (!menus) return;
|
if (!menus) return;
|
||||||
|
|
||||||
const matches = findMatches(menus, route);
|
const matches = findMatches(menus, route);
|
||||||
|
@ -108,7 +107,11 @@ function getRoutes() {
|
||||||
main: getMainRoutes,
|
main: getMainRoutes,
|
||||||
card: getCardRoutes,
|
card: getCardRoutes,
|
||||||
};
|
};
|
||||||
|
try {
|
||||||
handleRoutes[props.source]();
|
handleRoutes[props.source]();
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(`Method is not defined`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function getMainRoutes() {
|
function getMainRoutes() {
|
||||||
const modules = Object.assign([], navigation.getModules().value);
|
const modules = Object.assign([], navigation.getModules().value);
|
||||||
|
@ -119,6 +122,7 @@ function getMainRoutes() {
|
||||||
);
|
);
|
||||||
if (!moduleDef) continue;
|
if (!moduleDef) continue;
|
||||||
item.children = [];
|
item.children = [];
|
||||||
|
|
||||||
addChildren(item.module, moduleDef, item.children);
|
addChildren(item.module, moduleDef, item.children);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,18 +132,23 @@ function getMainRoutes() {
|
||||||
function getCardRoutes() {
|
function getCardRoutes() {
|
||||||
const currentRoute = route.matched[1];
|
const currentRoute = route.matched[1];
|
||||||
const currentModule = toLowerCamel(currentRoute.name);
|
const currentModule = toLowerCamel(currentRoute.name);
|
||||||
let moduleDef;
|
let moduleDef = routes.find((route) => toLowerCamel(route.name) === currentModule);
|
||||||
|
|
||||||
let index = route.matched.length - 1;
|
|
||||||
while (!moduleDef && index > 0) {
|
|
||||||
if (route.matched[index]?.meta?.menu) moduleDef = route.matched[index];
|
|
||||||
index--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!moduleDef) return;
|
if (!moduleDef) return;
|
||||||
|
if (!moduleDef?.menus) moduleDef = betaGetRoutes();
|
||||||
addChildren(currentModule, moduleDef, items.value);
|
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) {
|
async function togglePinned(item, event) {
|
||||||
if (event.defaultPrevented) return;
|
if (event.defaultPrevented) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -181,7 +190,7 @@ const searchModule = () => {
|
||||||
<template>
|
<template>
|
||||||
<QList padding class="column-max-width">
|
<QList padding class="column-max-width">
|
||||||
<template v-if="$props.source === 'main'">
|
<template v-if="$props.source === 'main'">
|
||||||
<template v-if="route?.matched[1]?.name === 'Dashboard'">
|
<template v-if="$route?.matched[1]?.name === 'Dashboard'">
|
||||||
<QItem class="q-pb-md">
|
<QItem class="q-pb-md">
|
||||||
<VnInput
|
<VnInput
|
||||||
v-model="search"
|
v-model="search"
|
||||||
|
@ -262,7 +271,7 @@ const searchModule = () => {
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-for="item in items" :key="item.name">
|
<template v-for="item in items" :key="item.name">
|
||||||
<template v-if="item.name === route?.matched[1]?.name">
|
<template v-if="item.name === $route?.matched[1]?.name">
|
||||||
<QItem class="header">
|
<QItem class="header">
|
||||||
<QItemSection avatar v-if="item.icon">
|
<QItemSection avatar v-if="item.icon">
|
||||||
<QIcon :name="item.icon" />
|
<QIcon :name="item.icon" />
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref, computed } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
|
@ -18,14 +18,6 @@ const state = useState();
|
||||||
const user = state.getUser();
|
const user = state.getUser();
|
||||||
const appName = 'Lilium';
|
const appName = 'Lilium';
|
||||||
const pinnedModulesRef = ref();
|
const pinnedModulesRef = ref();
|
||||||
const hostname = window.location.hostname;
|
|
||||||
const env = ref();
|
|
||||||
|
|
||||||
const getEnvironment = computed(() => {
|
|
||||||
env.value = hostname.split('-');
|
|
||||||
if (env.value.length <= 1) return;
|
|
||||||
return env.value[0];
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(() => stateStore.setMounted());
|
onMounted(() => stateStore.setMounted());
|
||||||
const refresh = () => window.location.reload();
|
const refresh = () => window.location.reload();
|
||||||
|
@ -57,9 +49,6 @@ const refresh = () => window.location.reload();
|
||||||
{{ t('globals.backToDashboard') }}
|
{{ t('globals.backToDashboard') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QBtn>
|
</QBtn>
|
||||||
<QBadge v-if="getEnvironment" color="primary" align="top">
|
|
||||||
{{ getEnvironment }}
|
|
||||||
</QBadge>
|
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<VnBreadcrumbs v-if="$q.screen.gt.sm" />
|
<VnBreadcrumbs v-if="$q.screen.gt.sm" />
|
||||||
<QSpinner
|
<QSpinner
|
||||||
|
@ -68,8 +57,8 @@ const refresh = () => window.location.reload();
|
||||||
:class="{
|
:class="{
|
||||||
'no-visible': !stateQuery.isLoading().value,
|
'no-visible': !stateQuery.isLoading().value,
|
||||||
}"
|
}"
|
||||||
size="sm"
|
size="xs"
|
||||||
data-cy="navBar-spinner"
|
data-cy="loading-spinner"
|
||||||
/>
|
/>
|
||||||
<QSpace />
|
<QSpace />
|
||||||
<div id="searchbar" class="searchbar"></div>
|
<div id="searchbar" class="searchbar"></div>
|
||||||
|
|
|
@ -40,9 +40,6 @@ const onDataSaved = (data) => {
|
||||||
url="Warehouses"
|
url="Warehouses"
|
||||||
@on-fetch="(data) => (warehousesOptions = data)"
|
@on-fetch="(data) => (warehousesOptions = data)"
|
||||||
auto-load
|
auto-load
|
||||||
:where="{
|
|
||||||
isInventory: true,
|
|
||||||
}"
|
|
||||||
/>
|
/>
|
||||||
<FormModelPopup
|
<FormModelPopup
|
||||||
url-create="Items/regularize"
|
url-create="Items/regularize"
|
||||||
|
|
|
@ -1,45 +1,35 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { toCurrency } from 'src/filters';
|
import { toCurrency } from 'src/filters';
|
||||||
import { getValueFromPath } from 'src/composables/getValueFromPath';
|
|
||||||
|
|
||||||
const { row, visibleProblems = null } = defineProps({
|
defineProps({ row: { type: Object, required: true } });
|
||||||
row: { type: Object, required: true },
|
|
||||||
visibleProblems: { type: Array },
|
|
||||||
});
|
|
||||||
|
|
||||||
function showProblem(problem) {
|
|
||||||
const val = getValueFromPath(row, problem);
|
|
||||||
if (!visibleProblems) return val;
|
|
||||||
return !!(visibleProblems?.includes(problem) && val);
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<span class="q-gutter-x-xs">
|
<span class="q-gutter-x-xs">
|
||||||
<router-link
|
<router-link
|
||||||
v-if="showProblem('claim.claimFk')"
|
v-if="row.claim?.claimFk"
|
||||||
:to="{ name: 'ClaimBasicData', params: { id: row.claim?.claimFk } }"
|
:to="{ name: 'ClaimBasicData', params: { id: row.claim?.claimFk } }"
|
||||||
class="link"
|
class="link"
|
||||||
>
|
>
|
||||||
<QIcon name="vn:claims" size="xs">
|
<QIcon name="vn:claims" size="xs">
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ $t('ticketSale.claim') }}:
|
{{ t('ticketSale.claim') }}:
|
||||||
{{ row.claim?.claimFk }}
|
{{ row.claim?.claimFk }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
</router-link>
|
</router-link>
|
||||||
<QIcon
|
<QIcon
|
||||||
v-if="showProblem('isDeleted')"
|
v-if="row?.reserved"
|
||||||
color="primary"
|
color="primary"
|
||||||
name="vn:deletedTicket"
|
name="vn:reserva"
|
||||||
size="xs"
|
size="xs"
|
||||||
data-cy="ticketDeletedIcon"
|
data-cy="ticketSaleReservedIcon"
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ t('Ticket deleted') }}
|
{{ t('ticketSale.reserved') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon
|
<QIcon
|
||||||
v-if="showProblem('hasRisk')"
|
v-if="row?.hasRisk"
|
||||||
name="vn:risk"
|
name="vn:risk"
|
||||||
:color="row.hasHighRisk ? 'negative' : 'primary'"
|
:color="row.hasHighRisk ? 'negative' : 'primary'"
|
||||||
size="xs"
|
size="xs"
|
||||||
|
@ -50,76 +40,51 @@ function showProblem(problem) {
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon
|
<QIcon
|
||||||
v-if="showProblem('hasComponentLack')"
|
v-if="row?.hasComponentLack"
|
||||||
name="vn:components"
|
name="vn:components"
|
||||||
color="primary"
|
color="primary"
|
||||||
size="xs"
|
size="xs"
|
||||||
>
|
>
|
||||||
<QTooltip>{{ $t('salesTicketsTable.componentLack') }}</QTooltip>
|
<QTooltip>{{ $t('salesTicketsTable.componentLack') }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon
|
<QIcon v-if="row?.hasItemDelay" color="primary" size="xs" name="vn:hasItemDelay">
|
||||||
v-if="showProblem('hasItemDelay')"
|
|
||||||
color="primary"
|
|
||||||
size="xs"
|
|
||||||
name="vn:hasItemDelay"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ $t('ticket.summary.hasItemDelay') }}
|
{{ $t('ticket.summary.hasItemDelay') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon
|
<QIcon v-if="row?.hasItemLost" color="primary" size="xs" name="vn:hasItemLost">
|
||||||
v-if="showProblem('hasItemLost')"
|
|
||||||
color="primary"
|
|
||||||
size="xs"
|
|
||||||
name="vn:hasItemLost"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ $t('salesTicketsTable.hasItemLost') }}
|
{{ $t('salesTicketsTable.hasItemLost') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon
|
<QIcon
|
||||||
v-if="showProblem('hasItemShortage')"
|
v-if="row?.hasItemShortage"
|
||||||
name="vn:unavailable"
|
name="vn:unavailable"
|
||||||
color="primary"
|
color="primary"
|
||||||
size="xs"
|
size="xs"
|
||||||
>
|
>
|
||||||
<QTooltip>{{ $t('salesTicketsTable.notVisible') }}</QTooltip>
|
<QTooltip>{{ $t('salesTicketsTable.notVisible') }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon
|
<QIcon v-if="row?.hasRounding" color="primary" name="sync_problem" size="xs">
|
||||||
v-if="showProblem('hasRounding')"
|
|
||||||
color="primary"
|
|
||||||
name="sync_problem"
|
|
||||||
size="xs"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ $t('ticketList.rounding') }}
|
{{ $t('ticketList.rounding') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon
|
<QIcon
|
||||||
v-if="showProblem('hasTicketRequest')"
|
v-if="row?.hasTicketRequest"
|
||||||
name="vn:buyrequest"
|
name="vn:buyrequest"
|
||||||
color="primary"
|
color="primary"
|
||||||
size="xs"
|
size="xs"
|
||||||
>
|
>
|
||||||
<QTooltip>{{ $t('salesTicketsTable.purchaseRequest') }}</QTooltip>
|
<QTooltip>{{ $t('salesTicketsTable.purchaseRequest') }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon
|
<QIcon v-if="row?.isTaxDataChecked" name="vn:no036" color="primary" size="xs">
|
||||||
v-if="showProblem('isTaxDataChecked')"
|
|
||||||
name="vn:no036"
|
|
||||||
color="primary"
|
|
||||||
size="xs"
|
|
||||||
>
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.noVerifiedData') }}</QTooltip>
|
<QTooltip>{{ $t('salesTicketsTable.noVerifiedData') }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon v-if="showProblem('isFreezed')" name="vn:frozen" color="primary" size="xs">
|
<QIcon v-if="row?.isFreezed" name="vn:frozen" color="primary" size="xs">
|
||||||
<QTooltip>{{ $t('salesTicketsTable.clientFrozen') }}</QTooltip>
|
<QTooltip>{{ $t('salesTicketsTable.clientFrozen') }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon
|
<QIcon v-if="row?.isTooLittle" name="vn:isTooLittle" color="primary" size="xs">
|
||||||
v-if="showProblem('isTooLittle')"
|
|
||||||
name="vn:isTooLittle"
|
|
||||||
color="primary"
|
|
||||||
size="xs"
|
|
||||||
>
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.tooLittle') }}</QTooltip>
|
<QTooltip>{{ $t('salesTicketsTable.tooLittle') }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -87,7 +87,7 @@ const makeInvoice = async () => {
|
||||||
(data) => (
|
(data) => (
|
||||||
(rectificativeTypeOptions = data),
|
(rectificativeTypeOptions = data),
|
||||||
(transferInvoiceParams.cplusRectificationTypeFk = data.filter(
|
(transferInvoiceParams.cplusRectificationTypeFk = data.filter(
|
||||||
(type) => type.description == 'I – Por diferencias',
|
(type) => type.description == 'I – Por diferencias'
|
||||||
)[0].id)
|
)[0].id)
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
|
@ -100,7 +100,7 @@ const makeInvoice = async () => {
|
||||||
(data) => (
|
(data) => (
|
||||||
(siiTypeInvoiceOutsOptions = data),
|
(siiTypeInvoiceOutsOptions = data),
|
||||||
(transferInvoiceParams.siiTypeInvoiceOutFk = data.filter(
|
(transferInvoiceParams.siiTypeInvoiceOutFk = data.filter(
|
||||||
(type) => type.code == 'R4',
|
(type) => type.code == 'R4'
|
||||||
)[0].id)
|
)[0].id)
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
|
@ -122,6 +122,7 @@ const makeInvoice = async () => {
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('Client')"
|
:label="t('Client')"
|
||||||
|
:options="clientsOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
|
|
|
@ -55,8 +55,6 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const label = $props.showLabel && $props.column.label ? $props.column.label : '';
|
|
||||||
|
|
||||||
const defaultSelect = {
|
const defaultSelect = {
|
||||||
attrs: {
|
attrs: {
|
||||||
row: $props.row,
|
row: $props.row,
|
||||||
|
@ -64,7 +62,7 @@ const defaultSelect = {
|
||||||
class: 'fit',
|
class: 'fit',
|
||||||
},
|
},
|
||||||
forceAttrs: {
|
forceAttrs: {
|
||||||
label,
|
label: $props.showLabel && $props.column.label,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -76,7 +74,7 @@ const defaultComponents = {
|
||||||
class: 'fit',
|
class: 'fit',
|
||||||
},
|
},
|
||||||
forceAttrs: {
|
forceAttrs: {
|
||||||
label,
|
label: $props.showLabel && $props.column.label,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
number: {
|
number: {
|
||||||
|
@ -86,7 +84,7 @@ const defaultComponents = {
|
||||||
class: 'fit',
|
class: 'fit',
|
||||||
},
|
},
|
||||||
forceAttrs: {
|
forceAttrs: {
|
||||||
label,
|
label: $props.showLabel && $props.column.label,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
date: {
|
date: {
|
||||||
|
@ -98,7 +96,7 @@ const defaultComponents = {
|
||||||
class: 'fit',
|
class: 'fit',
|
||||||
},
|
},
|
||||||
forceAttrs: {
|
forceAttrs: {
|
||||||
label,
|
label: $props.showLabel && $props.column.label,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
time: {
|
time: {
|
||||||
|
@ -107,7 +105,7 @@ const defaultComponents = {
|
||||||
disable: !$props.isEditable,
|
disable: !$props.isEditable,
|
||||||
},
|
},
|
||||||
forceAttrs: {
|
forceAttrs: {
|
||||||
label,
|
label: $props.showLabel && $props.column.label,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
checkbox: {
|
checkbox: {
|
||||||
|
@ -127,7 +125,7 @@ const defaultComponents = {
|
||||||
return defaultAttrs;
|
return defaultAttrs;
|
||||||
},
|
},
|
||||||
forceAttrs: {
|
forceAttrs: {
|
||||||
label,
|
label: $props.showLabel && $props.column.label,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { markRaw, computed, onBeforeMount } from 'vue';
|
import { markRaw, computed } from 'vue';
|
||||||
import { QToggle } from 'quasar';
|
import { QCheckbox, QToggle } from 'quasar';
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
import VnSelect from 'components/common/VnSelect.vue';
|
||||||
import VnInput from 'components/common/VnInput.vue';
|
import VnInput from 'components/common/VnInput.vue';
|
||||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||||
import VnInputTime from 'components/common/VnInputTime.vue';
|
import VnInputTime from 'components/common/VnInputTime.vue';
|
||||||
import VnCheckbox from 'components/common/VnCheckbox.vue';
|
|
||||||
import VnColumn from 'components/VnTable/VnColumn.vue';
|
import VnColumn from 'components/VnTable/VnColumn.vue';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
|
@ -107,7 +106,7 @@ const components = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
checkbox: {
|
checkbox: {
|
||||||
component: markRaw(VnCheckbox),
|
component: markRaw(QCheckbox),
|
||||||
event: updateEvent,
|
event: updateEvent,
|
||||||
attrs: {
|
attrs: {
|
||||||
class: $props.showTitle ? 'q-py-sm' : 'q-px-md q-py-xs fit',
|
class: $props.showTitle ? 'q-py-sm' : 'q-px-md q-py-xs fit',
|
||||||
|
@ -150,16 +149,6 @@ const showFilter = computed(
|
||||||
const onTabPressed = async () => {
|
const onTabPressed = async () => {
|
||||||
if (model.value) enterEvent['keyup.enter']();
|
if (model.value) enterEvent['keyup.enter']();
|
||||||
};
|
};
|
||||||
|
|
||||||
onBeforeMount(() => {
|
|
||||||
const columnFilter = $props.column?.columnFilter;
|
|
||||||
const component = columnFilter?.component;
|
|
||||||
const defaultComponent = components[component];
|
|
||||||
const events = { update: updateEvent, enter: enterEvent };
|
|
||||||
|
|
||||||
if (!columnFilter || defaultComponent) return;
|
|
||||||
$props.column.columnFilter.event = events[columnFilter.event];
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div v-if="showFilter" class="full-width" style="overflow: hidden">
|
<div v-if="showFilter" class="full-width" style="overflow: hidden">
|
||||||
|
|
|
@ -16,7 +16,7 @@ const $props = defineProps({
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
searchUrl: {
|
searchUrl: {
|
||||||
type: [String, Boolean],
|
type: String,
|
||||||
default: 'table',
|
default: 'table',
|
||||||
},
|
},
|
||||||
vertical: {
|
vertical: {
|
||||||
|
@ -70,7 +70,7 @@ function textAlignToFlex(textAlign) {
|
||||||
:style="textAlignToFlex(align)"
|
:style="textAlignToFlex(align)"
|
||||||
>
|
>
|
||||||
<span :title="label">{{ label }}</span>
|
<span :title="label">{{ label }}</span>
|
||||||
<div v-if="name && (model?.index || vertical)">
|
<div v-if="name && model?.index">
|
||||||
<QChip
|
<QChip
|
||||||
:label="!vertical ? model?.index : ''"
|
:label="!vertical ? model?.index : ''"
|
||||||
:icon="
|
:icon="
|
||||||
|
@ -83,14 +83,14 @@ function textAlignToFlex(textAlign) {
|
||||||
:size="vertical ? '' : 'sm'"
|
:size="vertical ? '' : 'sm'"
|
||||||
:class="[
|
:class="[
|
||||||
model?.index ? 'color-vn-text' : 'bg-transparent',
|
model?.index ? 'color-vn-text' : 'bg-transparent',
|
||||||
vertical ? 'q-mx-none q-py-lg' : '',
|
vertical ? 'q-px-none' : '',
|
||||||
]"
|
]"
|
||||||
class="no-box-shadow"
|
class="no-box-shadow"
|
||||||
:clickable="true"
|
:clickable="true"
|
||||||
style="min-width: 40px; max-height: 30px"
|
style="min-width: 40px; max-height: 30px"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="column justify-center text-center"
|
class="column flex-center"
|
||||||
v-if="vertical"
|
v-if="vertical"
|
||||||
:style="!model?.index && 'color: #5d5d5d'"
|
:style="!model?.index && 'color: #5d5d5d'"
|
||||||
>
|
>
|
||||||
|
|
|
@ -19,7 +19,6 @@ import { useQuasar, date } from 'quasar';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { useFilterParams } from 'src/composables/useFilterParams';
|
import { useFilterParams } from 'src/composables/useFilterParams';
|
||||||
import { dashIfEmpty, toDate } from 'src/filters';
|
import { dashIfEmpty, toDate } from 'src/filters';
|
||||||
import { useTableHeight } from './filters/useTableHeight';
|
|
||||||
|
|
||||||
import CrudModel from 'src/components/CrudModel.vue';
|
import CrudModel from 'src/components/CrudModel.vue';
|
||||||
import FormModelPopup from 'components/FormModelPopup.vue';
|
import FormModelPopup from 'components/FormModelPopup.vue';
|
||||||
|
@ -33,8 +32,6 @@ import VnTableOrder from 'src/components/VnTable/VnOrder.vue';
|
||||||
import VnTableFilter from './VnTableFilter.vue';
|
import VnTableFilter from './VnTableFilter.vue';
|
||||||
import { getColAlign } from 'src/composables/getColAlign';
|
import { getColAlign } from 'src/composables/getColAlign';
|
||||||
import RightMenu from '../common/RightMenu.vue';
|
import RightMenu from '../common/RightMenu.vue';
|
||||||
import VnScroll from '../common/VnScroll.vue';
|
|
||||||
import VnMultiCheck from '../common/VnMultiCheck.vue';
|
|
||||||
|
|
||||||
const arrayData = useArrayData(useAttrs()['data-key']);
|
const arrayData = useArrayData(useAttrs()['data-key']);
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
|
@ -67,7 +64,7 @@ const $props = defineProps({
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
create: {
|
create: {
|
||||||
type: [Boolean, Object],
|
type: Object,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
createAsDialog: {
|
createAsDialog: {
|
||||||
|
@ -114,17 +111,13 @@ const $props = defineProps({
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
multiCheck: {
|
|
||||||
type: Object,
|
|
||||||
default: () => ({}),
|
|
||||||
},
|
|
||||||
crudModel: {
|
crudModel: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
tableHeight: {
|
tableHeight: {
|
||||||
type: String,
|
type: String,
|
||||||
default: undefined,
|
default: '90vh',
|
||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -147,7 +140,7 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
dataCy: {
|
dataCy: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'vnTable',
|
default: 'vn-table',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -162,7 +155,6 @@ const CARD_MODE = 'card';
|
||||||
const TABLE_MODE = 'table';
|
const TABLE_MODE = 'table';
|
||||||
const mode = ref(CARD_MODE);
|
const mode = ref(CARD_MODE);
|
||||||
const selected = ref([]);
|
const selected = ref([]);
|
||||||
const selectAll = ref(false);
|
|
||||||
const hasParams = ref(false);
|
const hasParams = ref(false);
|
||||||
const CrudModelRef = ref({});
|
const CrudModelRef = ref({});
|
||||||
const showForm = ref(false);
|
const showForm = ref(false);
|
||||||
|
@ -174,8 +166,6 @@ const tableRef = ref();
|
||||||
const params = ref(useFilterParams($attrs['data-key']).params);
|
const params = ref(useFilterParams($attrs['data-key']).params);
|
||||||
const orders = ref(useFilterParams($attrs['data-key']).orders);
|
const orders = ref(useFilterParams($attrs['data-key']).orders);
|
||||||
const app = inject('app');
|
const app = inject('app');
|
||||||
const tableHeight = useTableHeight();
|
|
||||||
const vnScrollRef = ref(null);
|
|
||||||
|
|
||||||
const editingRow = ref(null);
|
const editingRow = ref(null);
|
||||||
const editingField = ref(null);
|
const editingField = ref(null);
|
||||||
|
@ -197,17 +187,6 @@ const tableModes = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const onVirtualScroll = ({ to }) => {
|
|
||||||
handleScroll();
|
|
||||||
const virtualScrollContainer = tableRef.value?.$el?.querySelector('.q-table__middle');
|
|
||||||
if (virtualScrollContainer) {
|
|
||||||
virtualScrollContainer.dispatchEvent(new CustomEvent('scroll'));
|
|
||||||
if (vnScrollRef.value) {
|
|
||||||
vnScrollRef.value.updateScrollContainer(virtualScrollContainer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
const urlParams = route.query[$props.searchUrl];
|
const urlParams = route.query[$props.searchUrl];
|
||||||
hasParams.value = urlParams && Object.keys(urlParams).length !== 0;
|
hasParams.value = urlParams && Object.keys(urlParams).length !== 0;
|
||||||
|
@ -248,7 +227,6 @@ watch(
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
create: createForm,
|
create: createForm,
|
||||||
showForm,
|
|
||||||
reload,
|
reload,
|
||||||
redirect: redirectFn,
|
redirect: redirectFn,
|
||||||
selected,
|
selected,
|
||||||
|
@ -346,13 +324,16 @@ function handleOnDataSaved(_) {
|
||||||
if (_.onDataSaved) _.onDataSaved({ CrudModelRef: CrudModelRef.value });
|
if (_.onDataSaved) _.onDataSaved({ CrudModelRef: CrudModelRef.value });
|
||||||
else $props.create.onDataSaved(_);
|
else $props.create.onDataSaved(_);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleScroll() {
|
function handleScroll() {
|
||||||
if ($props.crudModel.disableInfiniteScroll) return;
|
if ($props.crudModel.disableInfiniteScroll) return;
|
||||||
|
|
||||||
const tMiddle = tableRef.value.$el.querySelector('.q-table__middle');
|
const tMiddle = tableRef.value.$el.querySelector('.q-table__middle');
|
||||||
const { scrollHeight, scrollTop, clientHeight } = tMiddle;
|
const { scrollHeight, scrollTop, clientHeight } = tMiddle;
|
||||||
const isAtBottom = Math.abs(scrollHeight - scrollTop - clientHeight) <= 40;
|
const isAtBottom = Math.abs(scrollHeight - scrollTop - clientHeight) <= 40;
|
||||||
if (isAtBottom) CrudModelRef.value.vnPaginateRef.paginate();
|
if (isAtBottom) CrudModelRef.value.vnPaginateRef.paginate();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
||||||
if (evt?.shiftKey && added) {
|
if (evt?.shiftKey && added) {
|
||||||
const rowIndex = selectedRows[0].$index;
|
const rowIndex = selectedRows[0].$index;
|
||||||
|
@ -614,7 +595,8 @@ function cardClick(_, row) {
|
||||||
|
|
||||||
function removeTextValue(data, getChanges) {
|
function removeTextValue(data, getChanges) {
|
||||||
let changes = data.updates;
|
let changes = data.updates;
|
||||||
if (changes) {
|
if (!changes) return data;
|
||||||
|
|
||||||
for (const change of changes) {
|
for (const change of changes) {
|
||||||
for (const key in change.data) {
|
for (const key in change.data) {
|
||||||
if (key.endsWith('VnTableTextValue')) {
|
if (key.endsWith('VnTableTextValue')) {
|
||||||
|
@ -624,7 +606,7 @@ function removeTextValue(data, getChanges) {
|
||||||
}
|
}
|
||||||
|
|
||||||
data.updates = changes.filter((change) => Object.keys(change.data).length > 0);
|
data.updates = changes.filter((change) => Object.keys(change.data).length > 0);
|
||||||
}
|
|
||||||
if ($attrs?.beforeSaveFn) data = $attrs.beforeSaveFn(data, getChanges);
|
if ($attrs?.beforeSaveFn) data = $attrs.beforeSaveFn(data, getChanges);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
@ -644,23 +626,6 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
};
|
};
|
||||||
return () => {};
|
return () => {};
|
||||||
});
|
});
|
||||||
const handleMultiCheck = (value) => {
|
|
||||||
if (value) {
|
|
||||||
selected.value = tableRef.value.rows;
|
|
||||||
} else {
|
|
||||||
selected.value = [];
|
|
||||||
}
|
|
||||||
emit('update:selected', selected.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSelectedAll = (data) => {
|
|
||||||
if (data) {
|
|
||||||
selected.value = data;
|
|
||||||
} else {
|
|
||||||
selected.value = [];
|
|
||||||
}
|
|
||||||
emit('update:selected', selected.value);
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<RightMenu v-if="$props.rightSearch" :overlay="overlay">
|
<RightMenu v-if="$props.rightSearch" :overlay="overlay">
|
||||||
|
@ -669,7 +634,6 @@ const handleSelectedAll = (data) => {
|
||||||
:data-key="$attrs['data-key']"
|
:data-key="$attrs['data-key']"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:redirect="redirect"
|
:redirect="redirect"
|
||||||
v-bind="$attrs?.['table-filter']"
|
|
||||||
>
|
>
|
||||||
<template
|
<template
|
||||||
v-for="(_, slotName) in $slots"
|
v-for="(_, slotName) in $slots"
|
||||||
|
@ -714,26 +678,15 @@ const handleSelectedAll = (data) => {
|
||||||
table-header-class="bg-header"
|
table-header-class="bg-header"
|
||||||
card-container-class="grid-three"
|
card-container-class="grid-three"
|
||||||
flat
|
flat
|
||||||
:style="isTableMode && `max-height: ${$props.tableHeight || tableHeight}`"
|
:style="isTableMode && `max-height: ${tableHeight}`"
|
||||||
:virtual-scroll="isTableMode"
|
:virtual-scroll="isTableMode"
|
||||||
@virtual-scroll="onVirtualScroll"
|
@virtual-scroll="handleScroll"
|
||||||
@row-click="(event, row) => handleRowClick(event, row)"
|
@row-click="(event, row) => handleRowClick(event, row)"
|
||||||
@update:selected="emit('update:selected', $event)"
|
@update:selected="emit('update:selected', $event)"
|
||||||
@selection="(details) => handleSelection(details, rows)"
|
@selection="(details) => handleSelection(details, rows)"
|
||||||
:hide-selected-banner="true"
|
:hide-selected-banner="true"
|
||||||
:data-cy
|
:data-cy="$props.dataCy ?? 'vnTable'"
|
||||||
>
|
>
|
||||||
<template #header-selection>
|
|
||||||
<VnMultiCheck
|
|
||||||
:searchUrl="searchUrl"
|
|
||||||
:expand="$props.multiCheck.expand"
|
|
||||||
v-model="selectAll"
|
|
||||||
:url="$attrs['url']"
|
|
||||||
@update:selected="handleMultiCheck"
|
|
||||||
@select:all="handleSelectedAll"
|
|
||||||
></VnMultiCheck>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #top-left v-if="!$props.withoutHeader">
|
<template #top-left v-if="!$props.withoutHeader">
|
||||||
<slot name="top-left"> </slot>
|
<slot name="top-left"> </slot>
|
||||||
</template>
|
</template>
|
||||||
|
@ -785,7 +738,6 @@ const handleSelectedAll = (data) => {
|
||||||
withFilters
|
withFilters
|
||||||
"
|
"
|
||||||
:column="col"
|
:column="col"
|
||||||
:data-cy="`column-filter-${col.name}`"
|
|
||||||
:show-title="true"
|
:show-title="true"
|
||||||
:data-key="$attrs['data-key']"
|
:data-key="$attrs['data-key']"
|
||||||
v-model="params[columnName(col)]"
|
v-model="params[columnName(col)]"
|
||||||
|
@ -824,13 +776,12 @@ const handleSelectedAll = (data) => {
|
||||||
:data-col-field="col?.name"
|
:data-col-field="col?.name"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="no-padding no-margin"
|
class="no-padding no-margin peter"
|
||||||
style="
|
style="
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
"
|
"
|
||||||
:data-cy="`vnTableCell_${col.name}`"
|
|
||||||
>
|
>
|
||||||
<slot
|
<slot
|
||||||
:name="`column-${col.name}`"
|
:name="`column-${col.name}`"
|
||||||
|
@ -969,24 +920,12 @@ const handleSelectedAll = (data) => {
|
||||||
:row-index="index"
|
:row-index="index"
|
||||||
>
|
>
|
||||||
<VnColumn
|
<VnColumn
|
||||||
:column="{
|
:column="col"
|
||||||
...col,
|
|
||||||
disable:
|
|
||||||
col?.component ===
|
|
||||||
'checkbox'
|
|
||||||
? true
|
|
||||||
: false,
|
|
||||||
}"
|
|
||||||
:row="row"
|
:row="row"
|
||||||
:is-editable="false"
|
:is-editable="false"
|
||||||
v-model="row[col.name]"
|
v-model="row[col.name]"
|
||||||
component-prop="columnField"
|
component-prop="columnField"
|
||||||
:show-label="
|
:show-label="true"
|
||||||
col?.component ===
|
|
||||||
'checkbox'
|
|
||||||
? false
|
|
||||||
: true
|
|
||||||
"
|
|
||||||
/>
|
/>
|
||||||
</slot>
|
</slot>
|
||||||
</span>
|
</span>
|
||||||
|
@ -1027,8 +966,6 @@ const handleSelectedAll = (data) => {
|
||||||
v-for="col of cols.filter((cols) => cols.visible ?? true)"
|
v-for="col of cols.filter((cols) => cols.visible ?? true)"
|
||||||
:key="col?.id"
|
:key="col?.id"
|
||||||
:class="getColAlign(col)"
|
:class="getColAlign(col)"
|
||||||
:style="col?.width ? `max-width: ${col?.width}` : ''"
|
|
||||||
style="font-size: small"
|
|
||||||
>
|
>
|
||||||
<slot
|
<slot
|
||||||
:name="`column-footer-${col.name}`"
|
:name="`column-footer-${col.name}`"
|
||||||
|
@ -1090,8 +1027,7 @@ const handleSelectedAll = (data) => {
|
||||||
:model="$attrs['data-key'] + 'Create'"
|
:model="$attrs['data-key'] + 'Create'"
|
||||||
@on-data-saved="(_, res) => createForm.onDataSaved(res)"
|
@on-data-saved="(_, res) => createForm.onDataSaved(res)"
|
||||||
>
|
>
|
||||||
<template #form-inputs="{ data, validations }">
|
<template #form-inputs="{ data }">
|
||||||
<slot name="alter-create" :data="data">
|
|
||||||
<div :style="createComplement?.containerStyle">
|
<div :style="createComplement?.containerStyle">
|
||||||
<div
|
<div
|
||||||
:style="createComplement?.previousStyle"
|
:style="createComplement?.previousStyle"
|
||||||
|
@ -1099,23 +1035,19 @@ const handleSelectedAll = (data) => {
|
||||||
>
|
>
|
||||||
<slot name="previous-create-dialog" :data="data" />
|
<slot name="previous-create-dialog" :data="data" />
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div class="grid-create" :style="createComplement?.columnGridStyle">
|
||||||
class="grid-create"
|
|
||||||
:style="createComplement?.columnGridStyle"
|
|
||||||
>
|
|
||||||
<slot
|
<slot
|
||||||
v-for="column of splittedColumns.create"
|
v-for="column of splittedColumns.create"
|
||||||
:key="column.name"
|
:key="column.name"
|
||||||
:name="`column-create-${column.name}`"
|
:name="`column-create-${column.name}`"
|
||||||
:data="data"
|
:data="data"
|
||||||
:validations="validations"
|
|
||||||
:column-name="column.name"
|
:column-name="column.name"
|
||||||
:label="column.label"
|
:label="column.label"
|
||||||
>
|
>
|
||||||
<VnColumn
|
<VnColumn
|
||||||
:column="{
|
:column="{
|
||||||
...column,
|
...column,
|
||||||
...column?.createAttrs,
|
...{ disable: column?.createDisable ?? false },
|
||||||
}"
|
}"
|
||||||
:row="{}"
|
:row="{}"
|
||||||
default="input"
|
default="input"
|
||||||
|
@ -1128,15 +1060,9 @@ const handleSelectedAll = (data) => {
|
||||||
<slot name="more-create-dialog" :data="data" />
|
<slot name="more-create-dialog" :data="data" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</slot>
|
|
||||||
</template>
|
</template>
|
||||||
</FormModelPopup>
|
</FormModelPopup>
|
||||||
</QDialog>
|
</QDialog>
|
||||||
<VnScroll
|
|
||||||
ref="vnScrollRef"
|
|
||||||
v-if="isTableMode"
|
|
||||||
:scroll-target="tableRef?.$el?.querySelector('.q-table__middle')"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
<i18n>
|
<i18n>
|
||||||
en:
|
en:
|
||||||
|
@ -1211,12 +1137,8 @@ es:
|
||||||
.grid-create {
|
.grid-create {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(150px, max-content));
|
grid-template-columns: repeat(auto-fit, minmax(150px, max-content));
|
||||||
max-width: 100%;
|
|
||||||
grid-gap: 20px;
|
grid-gap: 20px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
.col-span-2 {
|
|
||||||
grid-column: span 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.flex-one {
|
.flex-one {
|
||||||
|
|
|
@ -26,13 +26,7 @@ function columnName(col) {
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VnFilterPanel
|
<VnFilterPanel v-bind="$attrs" :search-button="true" :disable-submit-event="true">
|
||||||
v-bind="$attrs"
|
|
||||||
:search-button="true"
|
|
||||||
:disable-submit-event="true"
|
|
||||||
:data-key="$attrs['data-key']"
|
|
||||||
:search-url
|
|
||||||
>
|
|
||||||
<template #body="{ params, orders, searchFn }">
|
<template #body="{ params, orders, searchFn }">
|
||||||
<div
|
<div
|
||||||
class="container"
|
class="container"
|
||||||
|
@ -40,12 +34,6 @@ function columnName(col) {
|
||||||
:key="col.id"
|
:key="col.id"
|
||||||
>
|
>
|
||||||
<div class="filter">
|
<div class="filter">
|
||||||
<slot
|
|
||||||
:name="`filter-${col.name}`"
|
|
||||||
:params="params"
|
|
||||||
:column-name="columnName(col)"
|
|
||||||
:search-fn
|
|
||||||
>
|
|
||||||
<VnFilter
|
<VnFilter
|
||||||
ref="tableFilterRef"
|
ref="tableFilterRef"
|
||||||
:column="col"
|
:column="col"
|
||||||
|
@ -53,7 +41,6 @@ function columnName(col) {
|
||||||
v-model="params[columnName(col)]"
|
v-model="params[columnName(col)]"
|
||||||
:search-url="searchUrl"
|
:search-url="searchUrl"
|
||||||
/>
|
/>
|
||||||
</slot>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="order">
|
<div class="order">
|
||||||
<VnTableOrder
|
<VnTableOrder
|
||||||
|
@ -90,13 +77,13 @@ function columnName(col) {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
min-height: 45px;
|
height: 45px;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter {
|
.filter {
|
||||||
width: 70%;
|
width: 70%;
|
||||||
min-height: 40px;
|
height: 40px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.order {
|
.order {
|
||||||
|
|
|
@ -58,7 +58,7 @@ async function getConfig(url, filter) {
|
||||||
const response = await axios.get(url, {
|
const response = await axios.get(url, {
|
||||||
params: { filter: filter },
|
params: { filter: filter },
|
||||||
});
|
});
|
||||||
return response?.data && response?.data?.length > 0 ? response.data[0] : null;
|
return response.data && response.data.length > 0 ? response.data[0] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchViewConfigData() {
|
async function fetchViewConfigData() {
|
||||||
|
|
|
@ -11,9 +11,6 @@ describe('VnTable', () => {
|
||||||
propsData: {
|
propsData: {
|
||||||
columns: [],
|
columns: [],
|
||||||
},
|
},
|
||||||
attrs: {
|
|
||||||
'data-key': 'test',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
vm = wrapper.vm;
|
vm = wrapper.vm;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { describe, expect, it, beforeEach, afterEach, vi } from 'vitest';
|
import { describe, expect, it, beforeEach, afterEach, vi } from 'vitest';
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import VnVisibleColumn from '../VnVisibleColumn.vue';
|
import VnVisibleColumn from '../VnVisibleColumn.vue';
|
||||||
import { default as axios } from 'axios';
|
import { axios } from 'app/test/vitest/helper';
|
||||||
|
|
||||||
describe('VnVisibleColumns', () => {
|
describe('VnVisibleColumns', () => {
|
||||||
let wrapper;
|
let wrapper;
|
||||||
let vm;
|
let vm;
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
import { onMounted, nextTick, ref } from 'vue';
|
|
||||||
|
|
||||||
export function useTableHeight() {
|
|
||||||
const tableHeight = ref('90vh');
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
await nextTick();
|
|
||||||
let height = 100;
|
|
||||||
Array.from(document.querySelectorAll('[role="toolbar"]'))
|
|
||||||
.filter((element) => window.getComputedStyle(element).display !== 'none')
|
|
||||||
.forEach(() => {
|
|
||||||
height -= 10;
|
|
||||||
});
|
|
||||||
tableHeight.value = `${height}vh`;
|
|
||||||
});
|
|
||||||
|
|
||||||
return tableHeight;
|
|
||||||
}
|
|
|
@ -1,6 +1,4 @@
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||||
import { default as axios } from 'axios';
|
|
||||||
|
|
||||||
import CrudModel from 'components/CrudModel.vue';
|
import CrudModel from 'components/CrudModel.vue';
|
||||||
import { vi, afterEach, beforeEach, beforeAll, describe, expect, it } from 'vitest';
|
import { vi, afterEach, beforeEach, beforeAll, describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
|
@ -11,7 +9,13 @@ describe('CrudModel', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
wrapper = createWrapper(CrudModel, {
|
wrapper = createWrapper(CrudModel, {
|
||||||
global: {
|
global: {
|
||||||
stubs: ['vnPaginate', 'vue-i18n'],
|
stubs: [
|
||||||
|
'vnPaginate',
|
||||||
|
'useState',
|
||||||
|
'arrayData',
|
||||||
|
'useStateStore',
|
||||||
|
'vue-i18n',
|
||||||
|
],
|
||||||
mocks: {
|
mocks: {
|
||||||
validate: vi.fn(),
|
validate: vi.fn(),
|
||||||
},
|
},
|
||||||
|
@ -23,7 +27,7 @@ describe('CrudModel', () => {
|
||||||
dataKey: 'crudModelKey',
|
dataKey: 'crudModelKey',
|
||||||
model: 'crudModel',
|
model: 'crudModel',
|
||||||
url: 'crudModelUrl',
|
url: 'crudModelUrl',
|
||||||
saveFn: vi.fn(),
|
saveFn: '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
wrapper = wrapper.wrapper;
|
wrapper = wrapper.wrapper;
|
||||||
|
@ -225,7 +229,7 @@ describe('CrudModel', () => {
|
||||||
expect(vm.isLoading).toBe(false);
|
expect(vm.isLoading).toBe(false);
|
||||||
expect(vm.hasChanges).toBe(false);
|
expect(vm.hasChanges).toBe(false);
|
||||||
|
|
||||||
await wrapper.setProps({ saveFn: null });
|
await wrapper.setProps({ saveFn: '' });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should use default url if there's not saveFn", async () => {
|
it("should use default url if there's not saveFn", async () => {
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
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,6 +1,4 @@
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||||
import { default as axios } from 'axios';
|
|
||||||
|
|
||||||
import FilterItemForm from 'src/components/FilterItemForm.vue';
|
import FilterItemForm from 'src/components/FilterItemForm.vue';
|
||||||
import { vi, beforeAll, describe, expect, it } from 'vitest';
|
import { vi, beforeAll, describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
|
@ -40,7 +38,7 @@ describe('FilterItemForm', () => {
|
||||||
{ relation: 'producer', scope: { fields: ['name'] } },
|
{ relation: 'producer', scope: { fields: ['name'] } },
|
||||||
{ relation: 'ink', scope: { fields: ['name'] } },
|
{ relation: 'ink', scope: { fields: ['name'] } },
|
||||||
],
|
],
|
||||||
where: { name: { like: '%bolas de madera%' } },
|
where: {"name":{"like":"%bolas de madera%"}},
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(axios.get).toHaveBeenCalledWith('Items/withName', {
|
expect(axios.get).toHaveBeenCalledWith('Items/withName', {
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import { describe, expect, it, beforeAll, vi, afterAll } from 'vitest';
|
import { describe, expect, it, beforeAll, vi, afterAll } from 'vitest';
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||||
import { default as axios } from 'axios';
|
|
||||||
|
|
||||||
import FormModel from 'src/components/FormModel.vue';
|
import FormModel from 'src/components/FormModel.vue';
|
||||||
|
|
||||||
describe('FormModel', () => {
|
describe('FormModel', () => {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterEach, beforeEach } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vitest';
|
||||||
import { default as axios } from 'axios';
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
import Leftmenu from 'components/LeftMenu.vue';
|
||||||
import LeftMenu from 'components/LeftMenu.vue';
|
|
||||||
import * as vueRouter from 'vue-router';
|
import * as vueRouter from 'vue-router';
|
||||||
import { useNavigationStore } from 'src/stores/useNavigationStore';
|
import { useNavigationStore } from 'src/stores/useNavigationStore';
|
||||||
|
|
||||||
|
@ -16,7 +15,10 @@ vi.mock('src/router/modules', () => ({
|
||||||
meta: {
|
meta: {
|
||||||
title: 'customers',
|
title: 'customers',
|
||||||
icon: 'vn:client',
|
icon: 'vn:client',
|
||||||
menu: ['CustomerList', 'CustomerCreate'],
|
},
|
||||||
|
menus: {
|
||||||
|
main: ['CustomerList', 'CustomerCreate'],
|
||||||
|
card: ['CustomerBasicData'],
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
@ -48,6 +50,14 @@ vi.mock('src/router/modules', () => ({
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'create',
|
||||||
|
name: 'CustomerCreate',
|
||||||
|
meta: {
|
||||||
|
title: 'createCustomer',
|
||||||
|
icon: 'vn:addperson',
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -88,7 +98,7 @@ vi.spyOn(vueRouter, 'useRoute').mockReturnValue({
|
||||||
icon: 'vn:client',
|
icon: 'vn:client',
|
||||||
moduleName: 'Customer',
|
moduleName: 'Customer',
|
||||||
keyBinding: 'c',
|
keyBinding: 'c',
|
||||||
menu: ['customer'],
|
menu: 'customer',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -102,7 +112,7 @@ function mount(source = 'main') {
|
||||||
vi.spyOn(axios, 'get').mockResolvedValue({
|
vi.spyOn(axios, 'get').mockResolvedValue({
|
||||||
data: [],
|
data: [],
|
||||||
});
|
});
|
||||||
const wrapper = createWrapper(LeftMenu, {
|
const wrapper = createWrapper(Leftmenu, {
|
||||||
propsData: {
|
propsData: {
|
||||||
source,
|
source,
|
||||||
},
|
},
|
||||||
|
@ -165,16 +175,16 @@ describe('getRoutes', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('LeftMenu as card', () => {
|
describe('Leftmenu as card', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
vm = mount('card').vm;
|
vm = mount('card').vm;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get routes for card source', () => {
|
it('should get routes for card source', async () => {
|
||||||
vm.getRoutes();
|
vm.getRoutes();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('LeftMenu as main', () => {
|
describe('Leftmenu as main', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vm = mount().vm;
|
vm = mount().vm;
|
||||||
});
|
});
|
||||||
|
@ -250,7 +260,17 @@ describe('LeftMenu as main', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle a single matched route with a menu', () => {
|
||||||
|
const route = {
|
||||||
|
matched: [{ meta: { menu: 'customer' } }],
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = vm.betaGetRoutes();
|
||||||
|
|
||||||
|
expect(result.meta.menu).toEqual(route.matched[0].meta.menu);
|
||||||
|
});
|
||||||
it('should get routes for main source', () => {
|
it('should get routes for main source', () => {
|
||||||
|
vm.props.source = 'main';
|
||||||
vm.getRoutes();
|
vm.getRoutes();
|
||||||
expect(navigation.getModules).toHaveBeenCalled();
|
expect(navigation.getModules).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
@ -331,9 +351,8 @@ describe('addChildren', () => {
|
||||||
|
|
||||||
it('should handle routes with no meta menu', () => {
|
it('should handle routes with no meta menu', () => {
|
||||||
const route = {
|
const route = {
|
||||||
meta: {
|
meta: {},
|
||||||
menu: [],
|
menus: {},
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const parent = [];
|
const parent = [];
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
import { vi, describe, expect, it, beforeEach, beforeAll, afterEach } from 'vitest';
|
import { vi, describe, expect, it, beforeEach, afterEach } from 'vitest';
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import UserPanel from 'src/components/UserPanel.vue';
|
import UserPanel from 'src/components/UserPanel.vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
|
|
||||||
|
vi.mock('src/utils/quasarLang', () => ({
|
||||||
|
default: vi.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('UserPanel', () => {
|
describe('UserPanel', () => {
|
||||||
let wrapper;
|
let wrapper;
|
||||||
let vm;
|
let vm;
|
||||||
|
@ -39,7 +43,7 @@ describe('UserPanel', () => {
|
||||||
await vm.saveDarkMode(true);
|
await vm.saveDarkMode(true);
|
||||||
expect(axios.patch).toHaveBeenCalledWith('/UserConfigs/115', { darkMode: true });
|
expect(axios.patch).toHaveBeenCalledWith('/UserConfigs/115', { darkMode: true });
|
||||||
expect(vm.user.darkMode).toBe(true);
|
expect(vm.user.darkMode).toBe(true);
|
||||||
vm.updatePreferences();
|
await vm.updatePreferences();
|
||||||
expect(vm.darkMode).toBe(true);
|
expect(vm.darkMode).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -48,7 +52,7 @@ describe('UserPanel', () => {
|
||||||
await vm.saveLanguage(userLanguage);
|
await vm.saveLanguage(userLanguage);
|
||||||
expect(axios.patch).toHaveBeenCalledWith('/VnUsers/115', { lang: userLanguage });
|
expect(axios.patch).toHaveBeenCalledWith('/VnUsers/115', { lang: userLanguage });
|
||||||
expect(vm.user.lang).toBe(userLanguage);
|
expect(vm.user.lang).toBe(userLanguage);
|
||||||
vm.updatePreferences();
|
await vm.updatePreferences();
|
||||||
expect(vm.locale).toBe(userLanguage);
|
expect(vm.locale).toBe(userLanguage);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -56,8 +60,6 @@ describe('UserPanel', () => {
|
||||||
const key = 'name';
|
const key = 'name';
|
||||||
const value = 'itboss';
|
const value = 'itboss';
|
||||||
await vm.saveUserData(key, value);
|
await vm.saveUserData(key, value);
|
||||||
expect(axios.post).toHaveBeenCalledWith('UserConfigs/setUserConfig', {
|
expect(axios.post).toHaveBeenCalledWith('UserConfigs/setUserConfig', { [key]: value });
|
||||||
[key]: value,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -56,12 +56,7 @@ async function confirm() {
|
||||||
{{ t('The notification will be sent to the following address') }}
|
{{ t('The notification will be sent to the following address') }}
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<QCardSection class="q-pt-none">
|
<QCardSection class="q-pt-none">
|
||||||
<VnInput
|
<VnInput v-model="address" is-outlined autofocus />
|
||||||
v-model="address"
|
|
||||||
is-outlined
|
|
||||||
autofocus
|
|
||||||
data-cy="SendEmailNotificationDialogInput"
|
|
||||||
/>
|
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<QCardActions align="right">
|
<QCardActions align="right">
|
||||||
<QBtn :label="t('globals.cancel')" color="primary" flat v-close-popup />
|
<QBtn :label="t('globals.cancel')" color="primary" flat v-close-popup />
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { useI18n } from 'vue-i18n';
|
||||||
import {computed, ref} from 'vue';
|
import {computed, ref} from 'vue';
|
||||||
import VnInput from 'components/common/VnInput.vue';
|
import VnInput from 'components/common/VnInput.vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import useNotify from 'composables/useNotify';
|
import useNotify from "composables/useNotify";
|
||||||
|
|
||||||
const MESSAGE_MAX_LENGTH = 160;
|
const MESSAGE_MAX_LENGTH = 160;
|
||||||
|
|
||||||
|
@ -43,10 +43,10 @@ const smsRules = [
|
||||||
t("The message it's too long"),
|
t("The message it's too long"),
|
||||||
];
|
];
|
||||||
|
|
||||||
const message = ref(t('routeDelay'));
|
const message = ref('');
|
||||||
|
|
||||||
const charactersRemaining = computed(
|
const charactersRemaining = computed(
|
||||||
() => MESSAGE_MAX_LENGTH - new Blob([message.value]).size,
|
() => MESSAGE_MAX_LENGTH - new Blob([message.value]).size
|
||||||
);
|
);
|
||||||
|
|
||||||
const charactersChipColor = computed(() => {
|
const charactersChipColor = computed(() => {
|
||||||
|
@ -114,7 +114,7 @@ const onSubmit = async () => {
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{
|
{{
|
||||||
t(
|
t(
|
||||||
'Special characters like accents counts as a multiple',
|
'Special characters like accents counts as a multiple'
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
|
@ -144,10 +144,7 @@ const onSubmit = async () => {
|
||||||
max-width: 450px;
|
max-width: 450px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
en:
|
|
||||||
routeDelay: "Your order has been delayed in transit.\nDelivery will take place throughout the day.\nWe apologize for the inconvenience and appreciate your patience."
|
|
||||||
es:
|
es:
|
||||||
Message: Mensaje
|
Message: Mensaje
|
||||||
Send: Enviar
|
Send: Enviar
|
||||||
|
@ -156,5 +153,4 @@ es:
|
||||||
The destination can't be empty: El destinatario no puede estar vacio
|
The destination can't be empty: El destinatario no puede estar vacio
|
||||||
The message can't be empty: El mensaje no puede estar vacio
|
The message can't be empty: El mensaje no puede estar vacio
|
||||||
The message it's too long: El mensaje es demasiado largo
|
The message it's too long: El mensaje es demasiado largo
|
||||||
routeDelay: "Retraso en ruta.\nInformamos que la ruta que lleva su pedido ha sufrido un retraso y la entrega se hará a lo largo del día.\nDisculpe las molestias."
|
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -1,15 +1,35 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { nextTick, ref } from 'vue';
|
||||||
import VnInput from './VnInput.vue';
|
import VnInput from './VnInput.vue';
|
||||||
import { useAccountShortToStandard } from 'src/composables/useAccountShortToStandard';
|
import { useAccountShortToStandard } from 'src/composables/useAccountShortToStandard';
|
||||||
|
|
||||||
|
const $props = defineProps({
|
||||||
|
insertable: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['update:modelValue', 'accountShortToStandard']);
|
||||||
const model = defineModel({ prop: 'modelValue' });
|
const model = defineModel({ prop: 'modelValue' });
|
||||||
|
const inputRef = ref(false);
|
||||||
|
|
||||||
|
function setCursorPosition(pos) {
|
||||||
|
const input = inputRef.value.vnInputRef.$el.querySelector('input');
|
||||||
|
input.focus();
|
||||||
|
input.setSelectionRange(pos, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleUpdateModel(val) {
|
||||||
|
model.value = val?.at(-1) === '.' ? useAccountShortToStandard(val) : val;
|
||||||
|
await nextTick(() => setCursorPosition(0));
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VnInput
|
<VnInput
|
||||||
v-model="model"
|
v-model="model"
|
||||||
ref="inputRef"
|
ref="inputRef"
|
||||||
@keydown.tab="$refs.inputRef.vnInputRef.blur()"
|
:insertable
|
||||||
@blur="model = useAccountShortToStandard(model) ?? model"
|
@update:model-value="handleUpdateModel"
|
||||||
@input="model = $event.target.value.replace(/[^\d.]/g, '')"
|
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,93 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
import FetchData from '../FetchData.vue';
|
|
||||||
import VnSelectDialog from './VnSelectDialog.vue';
|
|
||||||
|
|
||||||
import CreateBankEntityForm from '../CreateBankEntityForm.vue';
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
iban: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
bankEntityFk: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
disableElement: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const filter = {
|
|
||||||
fields: ['id', 'bic', 'name'],
|
|
||||||
order: 'bic ASC',
|
|
||||||
};
|
|
||||||
const { t } = useI18n();
|
|
||||||
const emit = defineEmits(['updateBic']);
|
|
||||||
const iban = ref($props.iban);
|
|
||||||
const bankEntityFk = ref($props.bankEntityFk);
|
|
||||||
const bankEntities = ref([]);
|
|
||||||
|
|
||||||
const autofillBic = async (bic) => {
|
|
||||||
if (!bic) return;
|
|
||||||
const bankEntityId = parseInt(bic.substr(4, 4));
|
|
||||||
const ibanCountry = bic.substr(0, 2);
|
|
||||||
if (ibanCountry != 'ES') return;
|
|
||||||
|
|
||||||
const existBank = bankEntities.value.find((b) => b.id === bankEntityId);
|
|
||||||
bankEntityFk.value = existBank ? bankEntityId : null;
|
|
||||||
emit('updateBic', { iban: iban.value, bankEntityFk: bankEntityFk.value });
|
|
||||||
};
|
|
||||||
|
|
||||||
const getBankEntities = (data) => {
|
|
||||||
bankEntityFk.value = data.id;
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<FetchData
|
|
||||||
url="BankEntities"
|
|
||||||
:filter="filter"
|
|
||||||
auto-load
|
|
||||||
@on-fetch="(data) => (bankEntities = data)"
|
|
||||||
/>
|
|
||||||
<VnInput
|
|
||||||
:label="t('IBAN')"
|
|
||||||
clearable
|
|
||||||
v-model="iban"
|
|
||||||
@update:model-value="autofillBic($event)"
|
|
||||||
:disable="disableElement"
|
|
||||||
>
|
|
||||||
<template #append>
|
|
||||||
<QIcon name="info" class="cursor-info">
|
|
||||||
<QTooltip>{{ t('components.iban_tooltip') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</template>
|
|
||||||
</VnInput>
|
|
||||||
<VnSelectDialog
|
|
||||||
:label="t('Swift / BIC')"
|
|
||||||
:acls="[{ model: 'BankEntity', props: '*', accessType: 'WRITE' }]"
|
|
||||||
:options="bankEntities"
|
|
||||||
hide-selected
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
v-model="bankEntityFk"
|
|
||||||
@update:model-value="$emit('updateBic', { iban, bankEntityFk })"
|
|
||||||
:disable="disableElement"
|
|
||||||
>
|
|
||||||
<template #form>
|
|
||||||
<CreateBankEntityForm @on-data-saved="getBankEntities($event)" />
|
|
||||||
</template>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem v-bind="scope.itemProps">
|
|
||||||
<QItemSection v-if="scope.opt">
|
|
||||||
<QItemLabel>{{ scope.opt.bic }} </QItemLabel>
|
|
||||||
<QItemLabel caption> {{ scope.opt.name }}</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelectDialog>
|
|
||||||
</template>
|
|
|
@ -1,93 +1,89 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onBeforeMount, computed, markRaw } from 'vue';
|
import { onBeforeMount, computed } from 'vue';
|
||||||
import { useRoute, useRouter, onBeforeRouteUpdate, onBeforeRouteLeave } from 'vue-router';
|
import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import useCardSize from 'src/composables/useCardSize';
|
import useCardSize from 'src/composables/useCardSize';
|
||||||
import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
||||||
|
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||||
const emit = defineEmits(['onFetch']);
|
import LeftMenu from 'components/LeftMenu.vue';
|
||||||
|
import RightMenu from 'components/common/RightMenu.vue';
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
id: { type: Number, required: false, default: null },
|
|
||||||
dataKey: { type: String, required: true },
|
dataKey: { type: String, required: true },
|
||||||
url: { type: String, default: undefined },
|
url: { type: String, default: undefined },
|
||||||
idInWhere: { type: Boolean, default: false },
|
|
||||||
filter: { type: Object, default: () => {} },
|
filter: { type: Object, default: () => {} },
|
||||||
descriptor: { type: Object, required: true },
|
descriptor: { type: Object, required: true },
|
||||||
filterPanel: { type: Object, default: undefined },
|
filterPanel: { type: Object, default: undefined },
|
||||||
|
idInWhere: { type: Boolean, default: false },
|
||||||
searchDataKey: { type: String, default: undefined },
|
searchDataKey: { type: String, default: undefined },
|
||||||
searchbarProps: { type: Object, default: undefined },
|
searchbarProps: { type: Object, default: undefined },
|
||||||
redirectOnError: { type: Boolean, default: false },
|
redirectOnError: { type: Boolean, default: false },
|
||||||
visual: { type: Boolean, default: true },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const entityId = computed(() => props.id || route?.params?.id);
|
const searchRightDataKey = computed(() => {
|
||||||
let arrayData = getArrayData(entityId.value, props.url);
|
if (!props.searchDataKey) return route.name;
|
||||||
|
return props.searchDataKey;
|
||||||
|
});
|
||||||
|
|
||||||
onBeforeRouteLeave(() => {
|
const arrayData = useArrayData(props.dataKey, {
|
||||||
stateStore.cardDescriptorChangeValue(null);
|
url: props.url,
|
||||||
|
userFilter: props.filter,
|
||||||
|
oneRecord: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
stateStore.cardDescriptorChangeValue(markRaw(props.descriptor));
|
|
||||||
|
|
||||||
const route = router.currentRoute.value;
|
|
||||||
try {
|
try {
|
||||||
await fetch(entityId.value);
|
await fetch(route.params.id);
|
||||||
} catch {
|
} catch {
|
||||||
const { matched: matches } = route;
|
const { matched: matches } = router.currentRoute.value;
|
||||||
const { path } = matches.at(-1);
|
const { path } = matches.at(-1);
|
||||||
router.push({ path: path.replace(/:id.*/, '') });
|
router.push({ path: path.replace(/:id.*/, '') });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeRouteUpdate(async (to, from) => {
|
onBeforeRouteUpdate(async (to, from) => {
|
||||||
if (hasRouteParam(to.params)) {
|
const id = to.params.id;
|
||||||
const { matched } = router.currentRoute.value;
|
if (id !== from.params.id) await fetch(id, true);
|
||||||
const { name } = matched.at(-3);
|
|
||||||
if (name) {
|
|
||||||
router.push({ name, params: to.params });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (entityId.value !== to.params.id) await fetch(to.params.id, true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
async function fetch(id, append = false) {
|
async function fetch(id, append = false) {
|
||||||
if (props.idInWhere) arrayData.store.filter.where = { id };
|
|
||||||
else {
|
|
||||||
arrayData = getArrayData(id);
|
|
||||||
}
|
|
||||||
await arrayData.fetch({ append, updateRouter: false });
|
|
||||||
emit('onFetch', arrayData.store.data);
|
|
||||||
}
|
|
||||||
function hasRouteParam(params, valueToCheck = ':addressId') {
|
|
||||||
return Object.values(params).includes(valueToCheck);
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatUrl(id) {
|
|
||||||
const newId = id || entityId.value;
|
|
||||||
const regex = /\/(\d+)/;
|
const regex = /\/(\d+)/;
|
||||||
if (!regex.test(props.url)) return `${props.url}/${newId}`;
|
if (props.idInWhere) arrayData.store.filter.where = { id };
|
||||||
return props.url.replace(regex, `/${newId}`);
|
else if (!regex.test(props.url)) arrayData.store.url = `${props.url}/${id}`;
|
||||||
}
|
else arrayData.store.url = props.url.replace(regex, `/${id}`);
|
||||||
|
await arrayData.fetch({ append, updateRouter: false });
|
||||||
function getArrayData(id, url) {
|
|
||||||
return useArrayData(props.dataKey, {
|
|
||||||
url: url ?? formatUrl(id),
|
|
||||||
userFilter: props.filter,
|
|
||||||
oneRecord: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<template v-if="visual">
|
<QDrawer
|
||||||
|
v-model="stateStore.leftDrawer"
|
||||||
|
show-if-above
|
||||||
|
:width="256"
|
||||||
|
v-if="stateStore.isHeaderMounted()"
|
||||||
|
>
|
||||||
|
<QScrollArea class="fit">
|
||||||
|
<component :is="descriptor" />
|
||||||
|
<QSeparator />
|
||||||
|
<LeftMenu source="card" />
|
||||||
|
</QScrollArea>
|
||||||
|
</QDrawer>
|
||||||
|
<slot name="searchbar" v-if="props.searchDataKey">
|
||||||
|
<VnSearchbar :data-key="props.searchDataKey" v-bind="props.searchbarProps" />
|
||||||
|
</slot>
|
||||||
|
<RightMenu>
|
||||||
|
<template #right-panel v-if="props.filterPanel">
|
||||||
|
<component :is="props.filterPanel" :data-key="searchRightDataKey" />
|
||||||
|
</template>
|
||||||
|
</RightMenu>
|
||||||
|
<QPageContainer>
|
||||||
|
<QPage>
|
||||||
<VnSubToolbar />
|
<VnSubToolbar />
|
||||||
<div :class="[useCardSize(), $attrs.class]">
|
<div :class="[useCardSize(), $attrs.class]">
|
||||||
<RouterView :key="$route.path" />
|
<RouterView :key="$route.path" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</QPage>
|
||||||
|
</QPageContainer>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
<script setup>
|
||||||
|
import { onBeforeMount } from 'vue';
|
||||||
|
import { useRouter, onBeforeRouteUpdate, onBeforeRouteLeave } from 'vue-router';
|
||||||
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
|
import useCardSize from 'src/composables/useCardSize';
|
||||||
|
import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
dataKey: { type: String, required: true },
|
||||||
|
url: { type: String, default: undefined },
|
||||||
|
idInWhere: { type: Boolean, default: false },
|
||||||
|
filter: { 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 router = useRouter();
|
||||||
|
const arrayData = useArrayData(props.dataKey, {
|
||||||
|
url: props.url,
|
||||||
|
userFilter: props.filter,
|
||||||
|
oneRecord: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeRouteLeave(() => {
|
||||||
|
stateStore.cardDescriptorChangeValue(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeMount(async () => {
|
||||||
|
stateStore.cardDescriptorChangeValue(props.descriptor);
|
||||||
|
|
||||||
|
const route = router.currentRoute.value;
|
||||||
|
try {
|
||||||
|
await fetch(route.params.id);
|
||||||
|
} catch {
|
||||||
|
const { matched: matches } = route;
|
||||||
|
const { path } = matches.at(-1);
|
||||||
|
router.push({ path: path.replace(/:id.*/, '') });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeRouteUpdate(async (to, from) => {
|
||||||
|
if (hasRouteParam(to.params)) {
|
||||||
|
const { matched } = router.currentRoute.value;
|
||||||
|
const { name } = matched.at(-3);
|
||||||
|
if (name) {
|
||||||
|
router.push({ name, params: to.params });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const id = to.params.id;
|
||||||
|
if (id !== from.params.id) await fetch(id, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
async function fetch(id, append = false) {
|
||||||
|
const regex = /\/(\d+)/;
|
||||||
|
if (props.idInWhere) arrayData.store.filter.where = { id };
|
||||||
|
else if (!regex.test(props.url)) arrayData.store.url = `${props.url}/${id}`;
|
||||||
|
else arrayData.store.url = props.url.replace(regex, `/${id}`);
|
||||||
|
await arrayData.fetch({ append, updateRouter: false });
|
||||||
|
}
|
||||||
|
function hasRouteParam(params, valueToCheck = ':addressId') {
|
||||||
|
return Object.values(params).includes(valueToCheck);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<VnSubToolbar />
|
||||||
|
<div :class="[useCardSize(), $attrs.class]">
|
||||||
|
<RouterView :key="$route.path" />
|
||||||
|
</div>
|
||||||
|
</template>
|
|
@ -27,11 +27,7 @@ const checkboxModel = computed({
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<QCheckbox
|
<QCheckbox v-bind="$attrs" v-model="checkboxModel" />
|
||||||
v-bind="$attrs"
|
|
||||||
v-model="checkboxModel"
|
|
||||||
:data-cy="$attrs['data-cy'] ?? `vnCheckbox${$attrs['label'] ?? ''}`"
|
|
||||||
/>
|
|
||||||
<QIcon
|
<QIcon
|
||||||
v-if="info"
|
v-if="info"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from 'vue';
|
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
colors: {
|
colors: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -8,9 +6,9 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const colorArray = computed(() => JSON.parse($props.colors)?.value);
|
const colorArray = JSON.parse($props.colors)?.value;
|
||||||
const maxHeight = 30;
|
const maxHeight = 30;
|
||||||
const colorHeight = maxHeight / colorArray.value?.length;
|
const colorHeight = maxHeight / colorArray?.length;
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div v-if="colors" class="color-div" :style="{ height: `${maxHeight}px` }">
|
<div v-if="colors" class="color-div" :style="{ height: `${maxHeight}px` }">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
const model = defineModel({ type: [String, Number], default: '' });
|
const model = defineModel({ type: [String, Number], required: true });
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<QDate v-model="model" :today-btn="true" :options="$attrs.options" />
|
<QDate v-model="model" :today-btn="true" :options="$attrs.options" />
|
||||||
|
|
|
@ -4,7 +4,6 @@ import { useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
|
@ -13,7 +12,6 @@ import FormModelPopup from 'components/FormModelPopup.vue';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { notify } = useNotify();
|
|
||||||
const emit = defineEmits(['onDataSaved']);
|
const emit = defineEmits(['onDataSaved']);
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
|
@ -37,10 +35,6 @@ const $props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
hasFile: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const warehouses = ref();
|
const warehouses = ref();
|
||||||
|
@ -63,11 +57,8 @@ function onFileChange(files) {
|
||||||
|
|
||||||
function mapperDms(data) {
|
function mapperDms(data) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
let files = data.files;
|
const { files } = data;
|
||||||
if (files) {
|
if (files) formData.append(files?.name, files);
|
||||||
files = Array.isArray(files) ? files : [files];
|
|
||||||
files.forEach((file) => formData.append(file?.name, file));
|
|
||||||
}
|
|
||||||
|
|
||||||
const dms = {
|
const dms = {
|
||||||
hasFile: !!data.hasFile,
|
hasFile: !!data.hasFile,
|
||||||
|
@ -88,23 +79,17 @@ function getUrl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
try {
|
|
||||||
const body = mapperDms(dms.value);
|
const body = mapperDms(dms.value);
|
||||||
const response = await axios.post(getUrl(), body[0], body[1]);
|
const response = await axios.post(getUrl(), body[0], body[1]);
|
||||||
emit('onDataSaved', body[1].params, response);
|
emit('onDataSaved', body[1].params, response);
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
|
||||||
delete dms.value.files;
|
delete dms.value.files;
|
||||||
return response;
|
return response;
|
||||||
} catch (e) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function defaultData() {
|
function defaultData() {
|
||||||
if ($props.formInitialData) return (dms.value = $props.formInitialData);
|
if ($props.formInitialData) return (dms.value = $props.formInitialData);
|
||||||
return addDefaultData({
|
return addDefaultData({
|
||||||
reference: route.params.id,
|
reference: route.params.id,
|
||||||
hasFile: $props.hasFile,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +177,6 @@ function addDefaultData(data) {
|
||||||
name="vn:attach"
|
name="vn:attach"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="inputFileRef.pickFiles()"
|
@click="inputFileRef.pickFiles()"
|
||||||
data-cy="attachFile"
|
|
||||||
>
|
>
|
||||||
<QTooltip>{{ t('globals.selectFile') }}</QTooltip>
|
<QTooltip>{{ t('globals.selectFile') }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
|
|
|
@ -1,166 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import VnConfirm from '../ui/VnConfirm.vue';
|
|
||||||
import VnInput from './VnInput.vue';
|
|
||||||
import VnDms from './VnDms.vue';
|
|
||||||
import axios from 'axios';
|
|
||||||
import { useQuasar } from 'quasar';
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import { downloadFile } from 'src/composables/downloadFile';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
const quasar = useQuasar();
|
|
||||||
const documentDialogRef = ref({});
|
|
||||||
const editDownloadDisabled = ref(false);
|
|
||||||
const $props = defineProps({
|
|
||||||
defaultDmsCode: {
|
|
||||||
type: String,
|
|
||||||
default: 'invoiceIn',
|
|
||||||
},
|
|
||||||
disable: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
formRef: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
function deleteFile(dmsFk) {
|
|
||||||
quasar
|
|
||||||
.dialog({
|
|
||||||
component: VnConfirm,
|
|
||||||
componentProps: {
|
|
||||||
title: t('globals.confirmDeletion'),
|
|
||||||
message: t('globals.confirmDeletionMessage'),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.onOk(async () => {
|
|
||||||
await axios.post(`dms/${dmsFk}/removeFile`);
|
|
||||||
$props.formRef.formData.dmsFk = null;
|
|
||||||
$props.formRef.formData.dms = undefined;
|
|
||||||
$props.formRef.hasChanges = true;
|
|
||||||
$props.formRef.save();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<div class="row no-wrap">
|
|
||||||
<VnInput
|
|
||||||
:label="t('Document')"
|
|
||||||
v-model="data.dmsFk"
|
|
||||||
clearable
|
|
||||||
clear-icon="close"
|
|
||||||
class="full-width"
|
|
||||||
:disable="disable"
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
v-if="data.dmsFk"
|
|
||||||
class="row no-wrap q-pa-xs q-gutter-x-xs"
|
|
||||||
data-cy="dms-buttons"
|
|
||||||
>
|
|
||||||
<QBtn
|
|
||||||
:disable="editDownloadDisabled"
|
|
||||||
@click="downloadFile(data.dmsFk)"
|
|
||||||
icon="cloud_download"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
:class="{
|
|
||||||
'no-pointer-events': editDownloadDisabled,
|
|
||||||
}"
|
|
||||||
padding="xs"
|
|
||||||
round
|
|
||||||
>
|
|
||||||
<QTooltip>{{ t('Download file') }}</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
<QBtn
|
|
||||||
:disable="editDownloadDisabled"
|
|
||||||
@click="
|
|
||||||
() => {
|
|
||||||
documentDialogRef.show = true;
|
|
||||||
documentDialogRef.dms = data.dms;
|
|
||||||
}
|
|
||||||
"
|
|
||||||
icon="edit"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
:class="{
|
|
||||||
'no-pointer-events': editDownloadDisabled,
|
|
||||||
}"
|
|
||||||
padding="xs"
|
|
||||||
round
|
|
||||||
>
|
|
||||||
<QTooltip>{{ t('Edit document') }}</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
<QBtn
|
|
||||||
:disable="editDownloadDisabled"
|
|
||||||
@click="deleteFile(data.dmsFk)"
|
|
||||||
icon="delete"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
round
|
|
||||||
:class="{
|
|
||||||
'no-pointer-events': editDownloadDisabled,
|
|
||||||
}"
|
|
||||||
padding="xs"
|
|
||||||
>
|
|
||||||
<QTooltip>{{ t('Delete file') }}</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</div>
|
|
||||||
<QBtn
|
|
||||||
v-else
|
|
||||||
icon="add_circle"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
round
|
|
||||||
v-shortcut="'+'"
|
|
||||||
padding="xs"
|
|
||||||
@click="
|
|
||||||
() => {
|
|
||||||
documentDialogRef.show = true;
|
|
||||||
delete documentDialogRef.dms;
|
|
||||||
}
|
|
||||||
"
|
|
||||||
data-cy="dms-create"
|
|
||||||
>
|
|
||||||
<QTooltip>{{ t('Create document') }}</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</div>
|
|
||||||
<QDialog v-model="documentDialogRef.show">
|
|
||||||
<VnDms
|
|
||||||
model="dms"
|
|
||||||
:default-dms-code="defaultDmsCode"
|
|
||||||
:form-initial-data="documentDialogRef.dms"
|
|
||||||
:url="
|
|
||||||
documentDialogRef.dms
|
|
||||||
? `Dms/${documentDialogRef.dms.id}/updateFile`
|
|
||||||
: 'Dms/uploadFile'
|
|
||||||
"
|
|
||||||
:description="documentDialogRef.supplierName"
|
|
||||||
@on-data-saved="
|
|
||||||
(_, { data }) => {
|
|
||||||
let dmsData = data;
|
|
||||||
if (Array.isArray(data)) dmsData = data[0];
|
|
||||||
formRef.formData.dmsFk = dmsData.id;
|
|
||||||
formRef.formData.dms = dmsData;
|
|
||||||
formRef.hasChanges = true;
|
|
||||||
formRef.save();
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</QDialog>
|
|
||||||
</template>
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
Document: Documento
|
|
||||||
Download file: Descargar archivo
|
|
||||||
Edit document: Editar documento
|
|
||||||
Delete file: Eliminar archivo
|
|
||||||
Create document: Crear documento
|
|
||||||
|
|
||||||
</i18n>
|
|
|
@ -4,7 +4,6 @@ import { useI18n } from 'vue-i18n';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useQuasar, QCheckbox, QBtn, QInput } from 'quasar';
|
import { useQuasar, QCheckbox, QBtn, QInput } from 'quasar';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { usePrintService } from 'composables/usePrintService';
|
|
||||||
|
|
||||||
import VnUserLink from '../ui/VnUserLink.vue';
|
import VnUserLink from '../ui/VnUserLink.vue';
|
||||||
import { downloadFile } from 'src/composables/downloadFile';
|
import { downloadFile } from 'src/composables/downloadFile';
|
||||||
|
@ -14,17 +13,14 @@ import VnDms from 'src/components/common/VnDms.vue';
|
||||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||||
import { useSession } from 'src/composables/useSession';
|
import { useSession } from 'src/composables/useSession';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { notify } = useNotify();
|
|
||||||
const rows = ref([]);
|
const rows = ref([]);
|
||||||
const dmsRef = ref();
|
const dmsRef = ref();
|
||||||
const formDialog = ref({});
|
const formDialog = ref({});
|
||||||
const token = useSession().getTokenMultimedia();
|
const token = useSession().getTokenMultimedia();
|
||||||
const { openReport } = usePrintService();
|
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
model: {
|
model: {
|
||||||
|
@ -92,6 +88,7 @@ const dmsFilter = {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
where: { [$props.filter]: route.params.id },
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
|
@ -201,7 +198,12 @@ const columns = computed(() => [
|
||||||
color: 'primary',
|
color: 'primary',
|
||||||
}),
|
}),
|
||||||
click: (prop) =>
|
click: (prop) =>
|
||||||
openReport(`dms/${prop.row.id}/downloadFile`, {}, '_blank'),
|
downloadFile(
|
||||||
|
prop.row.id,
|
||||||
|
$props.downloadModel,
|
||||||
|
undefined,
|
||||||
|
prop.row.download,
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: QBtn,
|
component: QBtn,
|
||||||
|
@ -256,16 +258,9 @@ function deleteDms(dmsFk) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.onOk(async () => {
|
.onOk(async () => {
|
||||||
try {
|
await axios.post(`${$props.deleteModel ?? $props.model}/${dmsFk}/removeFile`);
|
||||||
await axios.post(
|
|
||||||
`${$props.deleteModel ?? $props.model}/${dmsFk}/removeFile`,
|
|
||||||
);
|
|
||||||
const index = rows.value.findIndex((row) => row.id == dmsFk);
|
const index = rows.value.findIndex((row) => row.id == dmsFk);
|
||||||
rows.value.splice(index, 1);
|
rows.value.splice(index, 1);
|
||||||
notify(t('globals.dataDeleted'), 'positive');
|
|
||||||
} catch (e) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,9 +298,7 @@ defineExpose({
|
||||||
:data-key="$props.model"
|
:data-key="$props.model"
|
||||||
:url="$props.model"
|
:url="$props.model"
|
||||||
:user-filter="dmsFilter"
|
:user-filter="dmsFilter"
|
||||||
search-url="dmsFilter"
|
|
||||||
:order="['dmsFk DESC']"
|
:order="['dmsFk DESC']"
|
||||||
:filter="{ where: { [$props.filter]: route.params.id } }"
|
|
||||||
auto-load
|
auto-load
|
||||||
@on-fetch="setData"
|
@on-fetch="setData"
|
||||||
>
|
>
|
||||||
|
@ -396,7 +389,10 @@ defineExpose({
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</QTable>
|
</QTable>
|
||||||
<div v-else class="info-row q-pa-md text-center">
|
<div
|
||||||
|
v-else
|
||||||
|
class="info-row q-pa-md text-center"
|
||||||
|
>
|
||||||
<h5>
|
<h5>
|
||||||
{{ t('No data to display') }}
|
{{ t('No data to display') }}
|
||||||
</h5>
|
</h5>
|
||||||
|
@ -420,7 +416,6 @@ defineExpose({
|
||||||
v-shortcut
|
v-shortcut
|
||||||
@click="showFormDialog()"
|
@click="showFormDialog()"
|
||||||
class="fill-icon"
|
class="fill-icon"
|
||||||
data-cy="addButton"
|
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ t('Upload file') }}
|
{{ t('Upload file') }}
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import VnSelect from './VnSelect.vue';
|
|
||||||
|
|
||||||
const stateBtnDropdownRef = ref();
|
|
||||||
|
|
||||||
const emit = defineEmits(['changeState']);
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
disable: {
|
|
||||||
type: Boolean,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
options: {
|
|
||||||
type: Array,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
optionLabel: {
|
|
||||||
type: String,
|
|
||||||
default: 'name',
|
|
||||||
},
|
|
||||||
optionValue: {
|
|
||||||
type: String,
|
|
||||||
default: 'id',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
async function changeState(value) {
|
|
||||||
stateBtnDropdownRef.value?.hide();
|
|
||||||
emit('changeState', value);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<QBtnDropdown
|
|
||||||
ref="stateBtnDropdownRef"
|
|
||||||
color="black"
|
|
||||||
text-color="white"
|
|
||||||
:label="$t('globals.changeState')"
|
|
||||||
:disable="$props.disable"
|
|
||||||
>
|
|
||||||
<VnSelect
|
|
||||||
:options="$props.options"
|
|
||||||
:option-label="$props.optionLabel"
|
|
||||||
:option-value="$props.optionValue"
|
|
||||||
hide-selected
|
|
||||||
hide-dropdown-icon
|
|
||||||
focus-on-mount
|
|
||||||
@update:model-value="changeState"
|
|
||||||
>
|
|
||||||
</VnSelect>
|
|
||||||
</QBtnDropdown>
|
|
||||||
</template>
|
|
|
@ -84,7 +84,7 @@ const mixinRules = [
|
||||||
...($attrs.rules ?? []),
|
...($attrs.rules ?? []),
|
||||||
(val) => {
|
(val) => {
|
||||||
const maxlength = $props.maxlength;
|
const maxlength = $props.maxlength;
|
||||||
if (maxlength && +val?.length > maxlength)
|
if (maxlength && +val.length > maxlength)
|
||||||
return t(`maxLength`, { value: maxlength });
|
return t(`maxLength`, { value: maxlength });
|
||||||
const { min, max } = vnInputRef.value.$attrs;
|
const { min, max } = vnInputRef.value.$attrs;
|
||||||
if (!min) return null;
|
if (!min) return null;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { nextTick, watch, computed, ref, useAttrs } from 'vue';
|
import { onMounted, watch, computed, ref, useAttrs } from 'vue';
|
||||||
import { date, getCssVar } from 'quasar';
|
import { date } from 'quasar';
|
||||||
import VnDate from './VnDate.vue';
|
import VnDate from './VnDate.vue';
|
||||||
import { useRequired } from 'src/composables/useRequired';
|
import { useRequired } from 'src/composables/useRequired';
|
||||||
|
|
||||||
|
@ -20,18 +20,61 @@ const $props = defineProps({
|
||||||
});
|
});
|
||||||
|
|
||||||
const vnInputDateRef = ref(null);
|
const vnInputDateRef = ref(null);
|
||||||
const errColor = getCssVar('negative');
|
|
||||||
const textColor = ref('');
|
|
||||||
|
|
||||||
const dateFormat = 'DD/MM/YYYY';
|
const dateFormat = 'DD/MM/YYYY';
|
||||||
const isPopupOpen = ref();
|
const isPopupOpen = ref();
|
||||||
const hover = ref();
|
const hover = ref();
|
||||||
|
const mask = ref();
|
||||||
|
|
||||||
const mixinRules = [requiredFieldRule, ...($attrs.rules ?? [])];
|
const mixinRules = [requiredFieldRule, ...($attrs.rules ?? [])];
|
||||||
|
|
||||||
|
const formattedDate = computed({
|
||||||
|
get() {
|
||||||
|
if (!model.value) return model.value;
|
||||||
|
return date.formatDate(new Date(model.value), dateFormat);
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
if (value == model.value) return;
|
||||||
|
let newDate;
|
||||||
|
if (value) {
|
||||||
|
// parse input
|
||||||
|
if (value.includes('/') && value.length >= 10) {
|
||||||
|
if (value.at(2) == '/') value = value.split('/').reverse().join('/');
|
||||||
|
value = date.formatDate(
|
||||||
|
new Date(value).toISOString(),
|
||||||
|
'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const [year, month, day] = value.split('-').map((e) => parseInt(e));
|
||||||
|
newDate = new Date(year, month - 1, day);
|
||||||
|
if (model.value) {
|
||||||
|
const orgDate =
|
||||||
|
model.value instanceof Date ? model.value : new Date(model.value);
|
||||||
|
|
||||||
|
newDate.setHours(
|
||||||
|
orgDate.getHours(),
|
||||||
|
orgDate.getMinutes(),
|
||||||
|
orgDate.getSeconds(),
|
||||||
|
orgDate.getMilliseconds(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isNaN(newDate)) model.value = newDate.toISOString();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const popupDate = computed(() =>
|
const popupDate = computed(() =>
|
||||||
model.value ? date.formatDate(new Date(model.value), 'YYYY/MM/DD') : model.value,
|
model.value ? date.formatDate(new Date(model.value), 'YYYY/MM/DD') : model.value,
|
||||||
);
|
);
|
||||||
|
onMounted(() => {
|
||||||
|
// fix quasar bug
|
||||||
|
mask.value = '##/##/####';
|
||||||
|
});
|
||||||
|
watch(
|
||||||
|
() => model.value,
|
||||||
|
(val) => (formattedDate.value = val),
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
|
||||||
const styleAttrs = computed(() => {
|
const styleAttrs = computed(() => {
|
||||||
return $props.isOutlined
|
return $props.isOutlined
|
||||||
|
@ -43,138 +86,28 @@ const styleAttrs = computed(() => {
|
||||||
: {};
|
: {};
|
||||||
});
|
});
|
||||||
|
|
||||||
const inputValue = ref('');
|
|
||||||
|
|
||||||
const validateAndCleanInput = (value) => {
|
|
||||||
inputValue.value = value.replace(/[^0-9./-]/g, '');
|
|
||||||
};
|
|
||||||
|
|
||||||
const manageDate = (date) => {
|
const manageDate = (date) => {
|
||||||
inputValue.value = date.split('/').reverse().join('/');
|
formattedDate.value = date;
|
||||||
isPopupOpen.value = false;
|
isPopupOpen.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
|
||||||
() => model.value,
|
|
||||||
(nVal) => {
|
|
||||||
if (nVal) inputValue.value = date.formatDate(new Date(model.value), dateFormat);
|
|
||||||
else inputValue.value = '';
|
|
||||||
},
|
|
||||||
{ immediate: true },
|
|
||||||
);
|
|
||||||
|
|
||||||
const formatDate = () => {
|
|
||||||
let value = inputValue.value;
|
|
||||||
if (!value || value === model.value) {
|
|
||||||
textColor.value = '';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const regex =
|
|
||||||
/^([0]?[1-9]|[12][0-9]|3[01])([./-])([0]?[1-9]|1[0-2])([./-](\d{1,4}))?$/;
|
|
||||||
if (!regex.test(value)) {
|
|
||||||
textColor.value = errColor;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = value.replace(/[.-]/g, '/');
|
|
||||||
const parts = value.split('/');
|
|
||||||
if (parts.length < 2) {
|
|
||||||
textColor.value = errColor;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let [day, month, year] = parts;
|
|
||||||
if (day.length === 1) day = '0' + day;
|
|
||||||
if (month.length === 1) month = '0' + month;
|
|
||||||
|
|
||||||
const currentYear = Date.vnNew().getFullYear();
|
|
||||||
if (!year) year = currentYear;
|
|
||||||
const millennium = currentYear.toString().slice(0, 1);
|
|
||||||
|
|
||||||
switch (year.length) {
|
|
||||||
case 1:
|
|
||||||
year = `${millennium}00${year}`;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
year = `${millennium}0${year}`;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
year = `${millennium}${year}`;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
let isoCandidate = `${year}/${month}/${day}`;
|
|
||||||
isoCandidate = date.formatDate(
|
|
||||||
new Date(isoCandidate).toISOString(),
|
|
||||||
'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
||||||
);
|
|
||||||
const [isoYear, isoMonth, isoDay] = isoCandidate.split('-').map((e) => parseInt(e));
|
|
||||||
const parsedDate = new Date(isoYear, isoMonth - 1, isoDay);
|
|
||||||
|
|
||||||
const isValidDate =
|
|
||||||
parsedDate instanceof Date &&
|
|
||||||
!isNaN(parsedDate) &&
|
|
||||||
parsedDate.getFullYear() === parseInt(year) &&
|
|
||||||
parsedDate.getMonth() === parseInt(month) - 1 &&
|
|
||||||
parsedDate.getDate() === parseInt(day);
|
|
||||||
|
|
||||||
if (!isValidDate) {
|
|
||||||
textColor.value = errColor;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.value) {
|
|
||||||
const original =
|
|
||||||
model.value instanceof Date ? model.value : new Date(model.value);
|
|
||||||
parsedDate.setHours(
|
|
||||||
original.getHours(),
|
|
||||||
original.getMinutes(),
|
|
||||||
original.getSeconds(),
|
|
||||||
original.getMilliseconds(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
model.value = parsedDate.toISOString();
|
|
||||||
|
|
||||||
textColor.value = '';
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleEnter = (event) => {
|
|
||||||
formatDate();
|
|
||||||
|
|
||||||
nextTick(() => {
|
|
||||||
const newEvent = new KeyboardEvent('keydown', {
|
|
||||||
key: 'Enter',
|
|
||||||
code: 'Enter',
|
|
||||||
bubbles: true,
|
|
||||||
cancelable: true,
|
|
||||||
});
|
|
||||||
vnInputDateRef.value?.$el?.dispatchEvent(newEvent);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div @mouseover="hover = true" @mouseleave="hover = false">
|
<div @mouseover="hover = true" @mouseleave="hover = false">
|
||||||
<QInput
|
<QInput
|
||||||
ref="vnInputDateRef"
|
ref="vnInputDateRef"
|
||||||
v-model="inputValue"
|
v-model="formattedDate"
|
||||||
class="vn-input-date"
|
class="vn-input-date"
|
||||||
|
:mask="mask"
|
||||||
placeholder="dd/mm/aaaa"
|
placeholder="dd/mm/aaaa"
|
||||||
v-bind="{ ...$attrs, ...styleAttrs }"
|
v-bind="{ ...$attrs, ...styleAttrs }"
|
||||||
:class="{ required: isRequired }"
|
:class="{ required: isRequired }"
|
||||||
:rules="mixinRules"
|
:rules="mixinRules"
|
||||||
:clearable="false"
|
:clearable="false"
|
||||||
:input-style="{ color: textColor }"
|
|
||||||
@click="isPopupOpen = !isPopupOpen"
|
@click="isPopupOpen = !isPopupOpen"
|
||||||
@keydown="isPopupOpen = false"
|
@keydown="isPopupOpen = false"
|
||||||
@blur="formatDate"
|
|
||||||
@keydown.enter.prevent="handleEnter"
|
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
:data-cy="($attrs['data-cy'] ?? $attrs.label) + '_inputDate'"
|
:data-cy="$attrs.dataCy ?? $attrs.label + '_inputDate'"
|
||||||
@update:model-value="validateAndCleanInput"
|
|
||||||
>
|
>
|
||||||
<template #append>
|
<template #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
|
@ -183,12 +116,11 @@ const handleEnter = (event) => {
|
||||||
v-if="
|
v-if="
|
||||||
($attrs.clearable == undefined || $attrs.clearable) &&
|
($attrs.clearable == undefined || $attrs.clearable) &&
|
||||||
hover &&
|
hover &&
|
||||||
inputValue &&
|
model &&
|
||||||
!$attrs.disable
|
!$attrs.disable
|
||||||
"
|
"
|
||||||
@click="
|
@click="
|
||||||
vnInputDateRef.focus();
|
vnInputDateRef.focus();
|
||||||
inputValue = null;
|
|
||||||
model = null;
|
model = null;
|
||||||
isPopupOpen = false;
|
isPopupOpen = false;
|
||||||
"
|
"
|
||||||
|
|
|
@ -1,79 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { computed, useAttrs } from 'vue';
|
|
||||||
import { date } from 'quasar';
|
|
||||||
import VnDate from './VnDate.vue';
|
|
||||||
import VnTime from './VnTime.vue';
|
|
||||||
|
|
||||||
const $attrs = useAttrs();
|
|
||||||
const model = defineModel({ type: [Date, String] });
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
isOutlined: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
showEvent: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const styleAttrs = computed(() => {
|
|
||||||
return $props.isOutlined
|
|
||||||
? {
|
|
||||||
dense: true,
|
|
||||||
outlined: true,
|
|
||||||
rounded: true,
|
|
||||||
}
|
|
||||||
: {};
|
|
||||||
});
|
|
||||||
const mask = 'DD-MM-YYYY HH:mm';
|
|
||||||
const selectedDate = computed({
|
|
||||||
get() {
|
|
||||||
if (!model.value) return JSON.stringify(new Date(model.value));
|
|
||||||
return date.formatDate(new Date(model.value), mask);
|
|
||||||
},
|
|
||||||
set(value) {
|
|
||||||
model.value = Date.convertToISODateTime(value);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const manageDate = (date) => {
|
|
||||||
selectedDate.value = date;
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div @mouseover="hover = true" @mouseleave="hover = false">
|
|
||||||
<QInput
|
|
||||||
ref="vnInputDateRef"
|
|
||||||
v-model="selectedDate"
|
|
||||||
class="vn-input-date"
|
|
||||||
placeholder="dd/mm/aaaa HH:mm"
|
|
||||||
v-bind="{ ...$attrs, ...styleAttrs }"
|
|
||||||
:clearable="false"
|
|
||||||
@click="isPopupOpen = !isPopupOpen"
|
|
||||||
@keydown="isPopupOpen = false"
|
|
||||||
hide-bottom-space
|
|
||||||
@update:model-value="manageDate"
|
|
||||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_inputDateTime'"
|
|
||||||
>
|
|
||||||
<template #prepend>
|
|
||||||
<QIcon name="today" size="xs">
|
|
||||||
<QPopupProxy cover transition-show="scale" transition-hide="scale">
|
|
||||||
<VnDate :mask="mask" v-model="selectedDate" />
|
|
||||||
</QPopupProxy>
|
|
||||||
</QIcon>
|
|
||||||
</template>
|
|
||||||
<template #append>
|
|
||||||
<QIcon name="access_time" size="xs">
|
|
||||||
<QPopupProxy cover transition-show="scale" transition-hide="scale">
|
|
||||||
<VnTime format24h :mask="mask" v-model="selectedDate" />
|
|
||||||
</QPopupProxy>
|
|
||||||
</QIcon>
|
|
||||||
</template>
|
|
||||||
</QInput>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
Open date: Abrir fecha
|
|
||||||
</i18n>
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { watch } from 'vue';
|
import { watch } from 'vue';
|
||||||
import { toDateHourMinSec } from 'src/filters';
|
import { toDateString } from 'src/filters';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
value: { type: [String, Number, Boolean, Object], default: undefined },
|
value: { type: [String, Number, Boolean, Object], default: undefined },
|
||||||
|
@ -40,7 +40,7 @@ const updateValue = () => {
|
||||||
break;
|
break;
|
||||||
case 'object':
|
case 'object':
|
||||||
if (props.value instanceof Date) {
|
if (props.value instanceof Date) {
|
||||||
t = toDateHourMinSec(props.value);
|
t = toDateString(props.value);
|
||||||
} else {
|
} else {
|
||||||
t = props.value.toString();
|
t = props.value.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, onUnmounted, computed } from 'vue';
|
import { ref, onUnmounted, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
@ -10,12 +10,12 @@ import { useColor } from 'src/composables/useColor';
|
||||||
import { useCapitalize } from 'src/composables/useCapitalize';
|
import { useCapitalize } from 'src/composables/useCapitalize';
|
||||||
import { useValidator } from 'src/composables/useValidator';
|
import { useValidator } from 'src/composables/useValidator';
|
||||||
import VnAvatar from '../ui/VnAvatar.vue';
|
import VnAvatar from '../ui/VnAvatar.vue';
|
||||||
import VnLogValue from './VnLogValue.vue';
|
import VnJsonValue from '../common/VnJsonValue.vue';
|
||||||
|
import FetchData from '../FetchData.vue';
|
||||||
|
import VnSelect from './VnSelect.vue';
|
||||||
import VnUserLink from '../ui/VnUserLink.vue';
|
import VnUserLink from '../ui/VnUserLink.vue';
|
||||||
import VnPaginate from '../ui/VnPaginate.vue';
|
import VnPaginate from '../ui/VnPaginate.vue';
|
||||||
import VnLogFilter from 'src/components/common/VnLogFilter.vue';
|
|
||||||
import RightMenu from './RightMenu.vue';
|
import RightMenu from './RightMenu.vue';
|
||||||
import { useFilterParams } from 'src/composables/useFilterParams';
|
|
||||||
|
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const validationsStore = useValidator();
|
const validationsStore = useValidator();
|
||||||
|
@ -68,11 +68,43 @@ const filter = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
where: { and: [{ originFk: route.params.id }] },
|
||||||
};
|
};
|
||||||
|
|
||||||
const paginate = ref();
|
const paginate = ref();
|
||||||
const dataKey = computed(() => `${props.model}Log`);
|
const actions = ref();
|
||||||
const userParams = ref(useFilterParams(dataKey.value).params);
|
const changeInput = ref();
|
||||||
|
const searchInput = ref();
|
||||||
|
const userRadio = ref();
|
||||||
|
const userSelect = ref();
|
||||||
|
const dateFrom = ref();
|
||||||
|
const dateFromDialog = ref(false);
|
||||||
|
const dateTo = ref();
|
||||||
|
const dateToDialog = ref(false);
|
||||||
|
const selectedFilters = ref({});
|
||||||
|
const userTypes = [
|
||||||
|
{ label: 'All', value: undefined },
|
||||||
|
{ label: 'User', value: { neq: null } },
|
||||||
|
{ label: 'System', value: null },
|
||||||
|
];
|
||||||
|
const checkboxOptions = ref({
|
||||||
|
insert: {
|
||||||
|
label: 'Creates',
|
||||||
|
selected: false,
|
||||||
|
},
|
||||||
|
update: {
|
||||||
|
label: 'Edits',
|
||||||
|
selected: false,
|
||||||
|
},
|
||||||
|
delete: {
|
||||||
|
label: 'Deletes',
|
||||||
|
selected: false,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
label: 'Accesses',
|
||||||
|
selected: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
let validations = models;
|
let validations = models;
|
||||||
let pointRecord = ref(null);
|
let pointRecord = ref(null);
|
||||||
|
@ -214,73 +246,169 @@ async function setLogTree(data) {
|
||||||
function filterByRecord(modelLog) {
|
function filterByRecord(modelLog) {
|
||||||
byRecord.value = true;
|
byRecord.value = true;
|
||||||
const { id, model } = modelLog;
|
const { id, model } = modelLog;
|
||||||
applyFilter({ changedModelId: id, changedModel: model });
|
|
||||||
|
searchInput.value = id;
|
||||||
|
selectedFilters.value.changedModelId = id;
|
||||||
|
selectedFilters.value.changedModel = model;
|
||||||
|
applyFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function applyFilter(params = {}) {
|
async function applyFilter() {
|
||||||
paginate.value.arrayData.resetPagination();
|
filter.where = { and: [] };
|
||||||
paginate.value.arrayData.applyFilter({
|
if (
|
||||||
filter: {},
|
!selectedFilters.value.changedModel ||
|
||||||
params: { originFk: route.params.id, ...params },
|
(!selectedFilters.value.changedModelValue &&
|
||||||
});
|
!selectedFilters.value.changedModelId)
|
||||||
|
)
|
||||||
|
byRecord.value = false;
|
||||||
|
|
||||||
|
if (!byRecord.value) filter.where.and.push({ originFk: route.params.id });
|
||||||
|
|
||||||
|
if (Object.keys(selectedFilters.value).length) {
|
||||||
|
filter.where.and.push(selectedFilters.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function exprBuilder(param, value) {
|
paginate.value.fetch({ filter });
|
||||||
switch (param) {
|
}
|
||||||
case 'changedModelValue':
|
|
||||||
return { [param]: { like: `%${value}%` } };
|
function setDate(type) {
|
||||||
case 'change':
|
let from = dateFrom.value
|
||||||
if (value)
|
? date.formatDate(dateFrom.value.split('-').reverse().join('-'), 'YYYY-MM-DD')
|
||||||
return {
|
: undefined;
|
||||||
or: [
|
from = date.adjustDate(from, { hour: 0, minute: 0, second: 0, millisecond: 0 }, true);
|
||||||
{ oldJson: { like: `%${value}%` } },
|
|
||||||
{ newJson: { like: `%${value}%` } },
|
let to = dateTo.value
|
||||||
{ description: { like: `%${value}%` } },
|
? date.formatDate(dateTo.value.split('-').reverse().join('-'), 'YYYY-MM-DD')
|
||||||
],
|
: date.formatDate(dateFrom.value.split('-').reverse().join('-'), 'YYYY-MM-DD');
|
||||||
};
|
to = date.adjustDate(
|
||||||
break;
|
to,
|
||||||
case 'action':
|
{ hour: 21, minute: 59, second: 59, millisecond: 999 },
|
||||||
if (value?.length) return { [param]: { inq: value } };
|
true,
|
||||||
break;
|
);
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
case 'from':
|
case 'from':
|
||||||
return { creationDate: { gte: value } };
|
return { between: [from, to] };
|
||||||
case 'to':
|
case 'to': {
|
||||||
return { creationDate: { lte: value } };
|
if (dateFrom.value) {
|
||||||
case 'userType':
|
return {
|
||||||
if (value === 'User') return { userFk: { neq: null } };
|
between: [from, to],
|
||||||
if (value === 'System') return { userFk: null };
|
};
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return { [param]: value };
|
|
||||||
}
|
}
|
||||||
|
return { lte: to };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectFilter(type, dateType) {
|
||||||
|
const filter = {};
|
||||||
|
const actions = { inq: [] };
|
||||||
|
let reload = true;
|
||||||
|
|
||||||
|
if (type === 'search') {
|
||||||
|
if (/^\s*[0-9]+\s*$/.test(searchInput.value) || props.byRecord) {
|
||||||
|
selectedFilters.value.changedModelId = searchInput.value.trim();
|
||||||
|
} else if (!searchInput.value) {
|
||||||
|
selectedFilters.value.changedModelId = undefined;
|
||||||
|
selectedFilters.value.changedModelValue = undefined;
|
||||||
|
} else {
|
||||||
|
selectedFilters.value.changedModelValue = { like: `%${searchInput.value}%` };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type === 'action' && selectedFilters.value.changedModel === null) {
|
||||||
|
selectedFilters.value.changedModel = undefined;
|
||||||
|
}
|
||||||
|
if (type === 'userRadio') {
|
||||||
|
selectedFilters.value.userFk = userRadio.value;
|
||||||
|
}
|
||||||
|
if (type === 'change') {
|
||||||
|
if (changeInput.value)
|
||||||
|
selectedFilters.value.or = [
|
||||||
|
{ oldJson: { like: `%${changeInput.value}%` } },
|
||||||
|
{ newJson: { like: `%${changeInput.value}%` } },
|
||||||
|
{ description: { like: `%${changeInput.value}%` } },
|
||||||
|
];
|
||||||
|
else selectedFilters.value.or = undefined;
|
||||||
|
}
|
||||||
|
if (type === 'userSelect') {
|
||||||
|
selectedFilters.value.userFk =
|
||||||
|
userSelect.value !== null ? userSelect.value : undefined;
|
||||||
|
}
|
||||||
|
if (type === 'date') {
|
||||||
|
if (!dateFrom.value && !dateTo.value) {
|
||||||
|
selectedFilters.value.creationDate = undefined;
|
||||||
|
} else if (dateType === 'to') {
|
||||||
|
selectedFilters.value.creationDate = setDate('to');
|
||||||
|
} else if (dateType === 'from') {
|
||||||
|
selectedFilters.value.creationDate = setDate('from');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.keys(checkboxOptions.value).forEach((key) => {
|
||||||
|
if (checkboxOptions.value[key].selected) actions.inq.push(key);
|
||||||
|
});
|
||||||
|
selectedFilters.value.action = actions.inq.length ? actions : undefined;
|
||||||
|
|
||||||
|
Object.keys(selectedFilters.value).forEach((key) => {
|
||||||
|
if (selectedFilters.value[key]) filter[key] = selectedFilters.value[key];
|
||||||
|
});
|
||||||
|
|
||||||
|
if (reload) applyFilter(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clearFilter() {
|
async function clearFilter() {
|
||||||
|
selectedFilters.value = {};
|
||||||
byRecord.value = false;
|
byRecord.value = false;
|
||||||
|
userSelect.value = undefined;
|
||||||
|
searchInput.value = undefined;
|
||||||
|
changeInput.value = undefined;
|
||||||
|
dateFrom.value = undefined;
|
||||||
|
dateTo.value = undefined;
|
||||||
|
userRadio.value = undefined;
|
||||||
|
Object.keys(checkboxOptions.value).forEach(
|
||||||
|
(opt) => (checkboxOptions.value[opt].selected = false),
|
||||||
|
);
|
||||||
await applyFilter();
|
await applyFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
stateStore.rightDrawerChangeValue(true);
|
|
||||||
});
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
stateStore.rightDrawer = false;
|
stateStore.rightDrawer = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => router.currentRoute.value.params.id,
|
||||||
|
() => {
|
||||||
|
applyFilter();
|
||||||
|
},
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
<FetchData
|
||||||
|
:url="`${props.model}Logs/${route.params.id}/models`"
|
||||||
|
:filter="{ order: ['changedModel'] }"
|
||||||
|
@on-fetch="
|
||||||
|
(data) =>
|
||||||
|
(actions = data.map((item) => {
|
||||||
|
const changedModel = item.changedModel;
|
||||||
|
return {
|
||||||
|
locale: useCapitalize(
|
||||||
|
validations[changedModel]?.locale?.name ?? changedModel,
|
||||||
|
),
|
||||||
|
value: changedModel,
|
||||||
|
};
|
||||||
|
}))
|
||||||
|
"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
ref="paginate"
|
ref="paginate"
|
||||||
:data-key
|
:data-key="`${model}Log`"
|
||||||
:url="dataKey + 's'"
|
:url="`${model}Logs`"
|
||||||
:user-filter="filter"
|
:user-filter="filter"
|
||||||
:filter="{ where: { and: [{ originFk: route.params.id }] } }"
|
|
||||||
:skeleton="false"
|
:skeleton="false"
|
||||||
auto-load
|
auto-load
|
||||||
@on-fetch="setLogTree"
|
@on-fetch="setLogTree"
|
||||||
@on-change="setLogTree"
|
|
||||||
search-url="logs"
|
search-url="logs"
|
||||||
:exprBuilder
|
|
||||||
:order="['creationDate DESC', 'id DESC']"
|
|
||||||
>
|
>
|
||||||
<template #body>
|
<template #body>
|
||||||
<div
|
<div
|
||||||
|
@ -339,7 +467,6 @@ onUnmounted(() => {
|
||||||
backgroundColor: useColor(modelLog.model),
|
backgroundColor: useColor(modelLog.model),
|
||||||
}"
|
}"
|
||||||
:title="`${modelLog.model} #${modelLog.id}`"
|
:title="`${modelLog.model} #${modelLog.id}`"
|
||||||
data-cy="vnLog-model-chip"
|
|
||||||
>
|
>
|
||||||
{{ t(modelLog.modelI18n) }}
|
{{ t(modelLog.modelI18n) }}
|
||||||
</QChip>
|
</QChip>
|
||||||
|
@ -433,9 +560,10 @@ onUnmounted(() => {
|
||||||
value.nameI18n
|
value.nameI18n
|
||||||
}}:
|
}}:
|
||||||
</span>
|
</span>
|
||||||
<VnLogValue
|
<VnJsonValue
|
||||||
:value="value.val"
|
:value="
|
||||||
:name="value.name"
|
value.val.val
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
</QItem>
|
</QItem>
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
|
@ -453,7 +581,6 @@ onUnmounted(() => {
|
||||||
}`,
|
}`,
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
data-cy="vnLog-action-icon"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</QItem>
|
</QItem>
|
||||||
|
@ -487,10 +614,7 @@ onUnmounted(() => {
|
||||||
>
|
>
|
||||||
{{ prop.nameI18n }}:
|
{{ prop.nameI18n }}:
|
||||||
</span>
|
</span>
|
||||||
<VnLogValue
|
<VnJsonValue :value="prop.val.val" />
|
||||||
:value="prop.val"
|
|
||||||
:name="prop.name"
|
|
||||||
/>
|
|
||||||
<span
|
<span
|
||||||
v-if="
|
v-if="
|
||||||
propIndex <
|
propIndex <
|
||||||
|
@ -518,9 +642,8 @@ onUnmounted(() => {
|
||||||
{{ prop.nameI18n }}:
|
{{ prop.nameI18n }}:
|
||||||
</span>
|
</span>
|
||||||
<span v-if="log.action == 'update'">
|
<span v-if="log.action == 'update'">
|
||||||
<VnLogValue
|
<VnJsonValue
|
||||||
:value="prop.old"
|
:value="prop.old.val"
|
||||||
:name="prop.name"
|
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
v-if="prop.old.id"
|
v-if="prop.old.id"
|
||||||
|
@ -529,9 +652,8 @@ onUnmounted(() => {
|
||||||
#{{ prop.old.id }}
|
#{{ prop.old.id }}
|
||||||
</span>
|
</span>
|
||||||
→
|
→
|
||||||
<VnLogValue
|
<VnJsonValue
|
||||||
:value="prop.val"
|
:value="prop.val.val"
|
||||||
:name="prop.name"
|
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
v-if="prop.val.id"
|
v-if="prop.val.id"
|
||||||
|
@ -541,9 +663,8 @@ onUnmounted(() => {
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span v-else="prop.old.val">
|
<span v-else="prop.old.val">
|
||||||
<VnLogValue
|
<VnJsonValue
|
||||||
:value="prop.val"
|
:value="prop.val.val"
|
||||||
:name="prop.name"
|
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
v-if="prop.old.id"
|
v-if="prop.old.id"
|
||||||
|
@ -571,12 +692,176 @@ onUnmounted(() => {
|
||||||
</VnPaginate>
|
</VnPaginate>
|
||||||
<RightMenu>
|
<RightMenu>
|
||||||
<template #right-panel>
|
<template #right-panel>
|
||||||
<VnLogFilter :data-key />
|
<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.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"
|
||||||
|
>
|
||||||
|
<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>
|
</template>
|
||||||
</RightMenu>
|
</RightMenu>
|
||||||
|
<QDialog v-model="dateFromDialog">
|
||||||
|
<QDate
|
||||||
|
:years-in-month-view="false"
|
||||||
|
v-model="dateFrom"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
minimal
|
||||||
|
@update:model-value="
|
||||||
|
(value) => {
|
||||||
|
dateFromDialog = false;
|
||||||
|
dateFrom = date.formatDate(value, 'DD-MM-YYYY');
|
||||||
|
selectFilter('date', 'from');
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</QDialog>
|
||||||
|
<QDialog v-model="dateToDialog">
|
||||||
|
<QDate
|
||||||
|
v-model="dateTo"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
minimal
|
||||||
|
@update:model-value="
|
||||||
|
(value) => {
|
||||||
|
dateToDialog = false;
|
||||||
|
dateTo = date.formatDate(value, 'DD-MM-YYYY');
|
||||||
|
selectFilter('date', 'to');
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</QDialog>
|
||||||
<QPageSticky position="bottom-right" :offset="[25, 25]">
|
<QPageSticky position="bottom-right" :offset="[25, 25]">
|
||||||
<QBtn
|
<QBtn
|
||||||
v-if="Object.keys(userParams).some((filter) => filter !== 'originFk')"
|
v-if="Object.values(selectedFilters).some((filter) => filter !== undefined)"
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="filter_alt_off"
|
icon="filter_alt_off"
|
||||||
size="md"
|
size="md"
|
||||||
|
|
|
@ -1,249 +1,77 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import VnTableFilter from '../VnTable/VnTableFilter.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
import VnSelect from './VnSelect.vue';
|
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
import VnInput from './VnInput.vue';
|
|
||||||
import { ref, computed, watch } from 'vue';
|
|
||||||
import VnInputDate from './VnInputDate.vue';
|
|
||||||
import { useFilterParams } from 'src/composables/useFilterParams';
|
|
||||||
import FetchData from '../FetchData.vue';
|
|
||||||
import { useValidator } from 'src/composables/useValidator';
|
|
||||||
import { useCapitalize } from 'src/composables/useCapitalize';
|
|
||||||
import VnAvatar from '../ui/VnAvatar.vue';
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
dataKey: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
const props = defineProps({
|
||||||
const validationsStore = useValidator();
|
dataKey: {
|
||||||
const { models } = validationsStore;
|
type: String,
|
||||||
const entities = ref([]);
|
required: true,
|
||||||
const editors = ref([]);
|
|
||||||
const userParams = ref(useFilterParams($props.dataKey).params);
|
|
||||||
let validations = models;
|
|
||||||
const userTypes = [
|
|
||||||
{ value: 'All', label: t(`Users.All`) },
|
|
||||||
{ value: 'User', label: t(`Users.User`) },
|
|
||||||
{ value: 'System', label: t(`Users.System`) },
|
|
||||||
];
|
|
||||||
const checkboxOptions = ref([
|
|
||||||
{ name: 'insert', label: 'Creates', selected: false },
|
|
||||||
{ name: 'update', label: 'Edits', selected: false },
|
|
||||||
{ name: 'delete', label: 'Deletes', selected: false },
|
|
||||||
{ name: 'select', label: 'Accesses', selected: false },
|
|
||||||
]);
|
|
||||||
const columns = computed(() => [
|
|
||||||
{ name: 'changedModelValue', orderBy: 'id' },
|
|
||||||
{ name: 'changedModel' },
|
|
||||||
{ name: 'userType', orderBy: false },
|
|
||||||
{ name: 'userFk' },
|
|
||||||
{ name: 'change', orderBy: false },
|
|
||||||
{ name: 'action' },
|
|
||||||
{ name: 'from', orderBy: 'creationDate' },
|
|
||||||
{ name: 'to', orderBy: 'creationDate' },
|
|
||||||
]);
|
|
||||||
|
|
||||||
const userParamsWatcher = watch(
|
|
||||||
() => userParams.value,
|
|
||||||
(params) => {
|
|
||||||
if (params.action) {
|
|
||||||
params.action.forEach((option) => {
|
|
||||||
checkboxOptions.value.find((o) => o.name === option).selected = true;
|
|
||||||
});
|
|
||||||
userParamsWatcher();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
|
|
||||||
function getActions() {
|
const workers = ref();
|
||||||
const actions = checkboxOptions.value
|
|
||||||
.filter((option) => option.selected)
|
|
||||||
?.map((o) => o.name);
|
|
||||||
return actions.length ? actions : null;
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
:url="`${dataKey}s/${route.params.id}/models`"
|
url="Workers/activeWithInheritedRole"
|
||||||
:filter="{ order: ['changedModel'] }"
|
:filter="{ where: { role: 'salesPerson' } }"
|
||||||
@on-fetch="
|
@on-fetch="(data) => (workers = data)"
|
||||||
(data) =>
|
|
||||||
(entities = data.map((item) => {
|
|
||||||
const changedModel = item.changedModel;
|
|
||||||
return {
|
|
||||||
locale: useCapitalize(
|
|
||||||
validations[changedModel]?.locale?.name ?? changedModel,
|
|
||||||
),
|
|
||||||
value: changedModel,
|
|
||||||
};
|
|
||||||
}))
|
|
||||||
"
|
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<FetchData
|
<VnFilterPanel :data-key="props.dataKey" :search-button="true">
|
||||||
:url="`${dataKey}s/${route.params.id}/editors`"
|
<template #tags="{ tag, formatFn }">
|
||||||
:filter="{ fields: ['id', 'nickname', 'name', 'image'] }"
|
<div class="q-gutter-x-xs">
|
||||||
sort-by="nickname"
|
<strong>{{ t(`params.${tag.label}`) }}: </strong>
|
||||||
@on-fetch="(data) => (editors = data)"
|
<span>{{ formatFn(tag.value) }}</span>
|
||||||
auto-load
|
</div>
|
||||||
/>
|
</template>
|
||||||
<VnTableFilter
|
<template #body="{ params, searchFn }">
|
||||||
v-if="dataKey"
|
<QDate
|
||||||
:data-key
|
v-model="params.created"
|
||||||
:columns="columns"
|
@update:model-value="searchFn()"
|
||||||
:redirect="false"
|
dense
|
||||||
:hiddenTags="['originFk', 'creationDate']"
|
flat
|
||||||
search-url="logs"
|
minimal
|
||||||
:showTagChips="false"
|
|
||||||
>
|
>
|
||||||
<template #filter-changedModelValue="{ params, columnName, searchFn }">
|
</QDate>
|
||||||
<VnInput
|
<QSeparator />
|
||||||
:label="t('globals.search')"
|
<QItem>
|
||||||
v-model="params[columnName]"
|
<QItemSection v-if="!workers">
|
||||||
@keyup.enter="searchFn"
|
<QSkeleton type="QInput" class="full-width" />
|
||||||
@blur="searchFn"
|
|
||||||
@remove="searchFn"
|
|
||||||
:info="t('tooltips.search')"
|
|
||||||
dense
|
|
||||||
filled
|
|
||||||
data-cy="vnLog-search"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template #filter-changedModel="{ params, columnName, searchFn }">
|
|
||||||
<VnSelect
|
|
||||||
:label="t('globals.entity')"
|
|
||||||
v-model="params[columnName]"
|
|
||||||
option-label="locale"
|
|
||||||
option-value="value"
|
|
||||||
:options="entities"
|
|
||||||
@update:model-value="() => searchFn()"
|
|
||||||
dense
|
|
||||||
filled
|
|
||||||
data-cy="vnLog-entity"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template #filter-userType="{ params, columnName, searchFn }">
|
|
||||||
<QOptionGroup
|
|
||||||
class="text-left"
|
|
||||||
size="sm"
|
|
||||||
v-model="params[columnName]"
|
|
||||||
:options="userTypes"
|
|
||||||
color="primary"
|
|
||||||
@update:model-value="
|
|
||||||
() => {
|
|
||||||
params.userFk = null;
|
|
||||||
searchFn();
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template #filter-userFk="{ params, columnName, searchFn }">
|
|
||||||
<VnSelect
|
|
||||||
:label="t('globals.user')"
|
|
||||||
v-model="params[columnName]"
|
|
||||||
:options="editors"
|
|
||||||
@update:modelValue="() => searchFn()"
|
|
||||||
:disable="params.userType === 'System'"
|
|
||||||
dense
|
|
||||||
filled
|
|
||||||
>
|
|
||||||
<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>
|
||||||
<QItemSection class="col-9 justify-center">
|
<QItemSection v-if="workers">
|
||||||
<span>{{ opt.name }}</span>
|
<QSelect
|
||||||
<span class="text-grey">{{ opt.nickname }}</span>
|
:label="t('User')"
|
||||||
|
v-model="params.userFk"
|
||||||
|
@update:model-value="searchFn()"
|
||||||
|
:options="workers"
|
||||||
|
option-value="id"
|
||||||
|
option-label="name"
|
||||||
|
emit-value
|
||||||
|
map-options
|
||||||
|
use-input
|
||||||
|
:input-debounce="0"
|
||||||
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
</template>
|
</template>
|
||||||
</VnSelect>
|
</VnFilterPanel>
|
||||||
</template>
|
</template>
|
||||||
<template #filter-change="{ params, columnName, searchFn }">
|
|
||||||
<VnInput
|
|
||||||
:label="t('globals.changes')"
|
|
||||||
v-model="params[columnName]"
|
|
||||||
@keyup.enter="searchFn"
|
|
||||||
@blur="searchFn"
|
|
||||||
@remove="searchFn"
|
|
||||||
:info="t('tooltips.changes')"
|
|
||||||
dense
|
|
||||||
filled
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template #filter-action="{ searchFn }">
|
|
||||||
<div class="column">
|
|
||||||
<QCheckbox
|
|
||||||
v-for="checkboxOption in checkboxOptions"
|
|
||||||
:key="checkboxOption"
|
|
||||||
size="sm"
|
|
||||||
v-model="checkboxOption.selected"
|
|
||||||
:label="t(`actions.${checkboxOption.label}`)"
|
|
||||||
@update:model-value="
|
|
||||||
() => searchFn(undefined, 'action', getActions())
|
|
||||||
"
|
|
||||||
data-cy="vnLog-checkbox"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template #filter-from="{ params, columnName, searchFn }">
|
|
||||||
<VnInputDate
|
|
||||||
:label="t('globals.from')"
|
|
||||||
v-model="params[columnName]"
|
|
||||||
dense
|
|
||||||
filled
|
|
||||||
@update:modelValue="() => searchFn()"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template #filter-to="{ params, columnName, searchFn }">
|
|
||||||
<VnInputDate
|
|
||||||
:label="t('globals.to')"
|
|
||||||
v-model="params[columnName]"
|
|
||||||
dense
|
|
||||||
filled
|
|
||||||
@update:modelValue="() => searchFn()"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</VnTableFilter>
|
|
||||||
</template>
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
tooltips:
|
|
||||||
search: Buscar por identificador o concepto
|
|
||||||
changes: Buscar por cambios. Los atributos deben buscarse por su nombre interno, para obtenerlo situar el cursor sobre el atributo.
|
|
||||||
actions:
|
|
||||||
Creates: Crea
|
|
||||||
Edits: Modifica
|
|
||||||
Deletes: Elimina
|
|
||||||
Accesses: Accede
|
|
||||||
Users:
|
|
||||||
User: Usuario
|
|
||||||
All: Todo
|
|
||||||
System: Sistema
|
|
||||||
params:
|
|
||||||
changedModel: Entity
|
|
||||||
|
|
||||||
|
<i18n>
|
||||||
en:
|
en:
|
||||||
tooltips:
|
|
||||||
search: Search by identifier or concept
|
|
||||||
changes: Search by changes. Attributes must be searched by their internal name, to get it place the cursor over the attribute.
|
|
||||||
actions:
|
|
||||||
Creates: Creates
|
|
||||||
Edits: Edits
|
|
||||||
Deletes: Deletes
|
|
||||||
Accesses: Accesses
|
|
||||||
Users:
|
|
||||||
User: User
|
|
||||||
All: All
|
|
||||||
System: System
|
|
||||||
params:
|
params:
|
||||||
changedModel: Entidad
|
search: Contains
|
||||||
|
userFk: User
|
||||||
|
created: Created
|
||||||
|
es:
|
||||||
|
params:
|
||||||
|
search: Contiene
|
||||||
|
userFk: Usuario
|
||||||
|
created: Creada
|
||||||
|
User: Usuario
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { useDescriptorStore } from 'src/stores/useDescriptorStore';
|
|
||||||
import VnJsonValue from './VnJsonValue.vue';
|
|
||||||
import { computed } from 'vue';
|
|
||||||
const descriptorStore = useDescriptorStore();
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
value: { type: Object, default: () => {} },
|
|
||||||
name: { type: String, default: undefined },
|
|
||||||
});
|
|
||||||
|
|
||||||
const descriptor = computed(() => descriptorStore.has($props.name));
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<VnJsonValue :value="value.val" />
|
|
||||||
<span
|
|
||||||
v-if="(value.id || typeof value.val == 'number') && descriptor"
|
|
||||||
style="margin-left: 2px"
|
|
||||||
>
|
|
||||||
<QIcon
|
|
||||||
name="launch"
|
|
||||||
class="link"
|
|
||||||
:data-cy="'iconLaunch-' + $props.name"
|
|
||||||
style="padding-bottom: 2px"
|
|
||||||
/>
|
|
||||||
<component :is="descriptor" :id="value.id ?? value.val" />
|
|
||||||
</span>
|
|
||||||
</template>
|
|
|
@ -1,80 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import VnCheckbox from './VnCheckbox.vue';
|
|
||||||
import axios from 'axios';
|
|
||||||
import { toRaw } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
const route = useRoute();
|
|
||||||
const { t } = useI18n();
|
|
||||||
const model = defineModel({ type: [Boolean] });
|
|
||||||
const props = defineProps({
|
|
||||||
expand: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
url: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
searchUrl: {
|
|
||||||
type: [String, Boolean],
|
|
||||||
default: 'table',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const value = ref(false);
|
|
||||||
const rows = ref(0);
|
|
||||||
const onClick = () => {
|
|
||||||
if (value.value) {
|
|
||||||
const { filter } = JSON.parse(route.query[props.searchUrl]);
|
|
||||||
filter.limit = 0;
|
|
||||||
const params = {
|
|
||||||
params: { filter: JSON.stringify(filter) },
|
|
||||||
};
|
|
||||||
axios
|
|
||||||
.get(props.url, params)
|
|
||||||
.then(({ data }) => {
|
|
||||||
rows.value = data;
|
|
||||||
})
|
|
||||||
.catch(console.error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
defineEmits(['update:selected', 'select:all']);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div style="display: flex">
|
|
||||||
<VnCheckbox v-model="value" @click="$emit('update:selected', value)" />
|
|
||||||
<QBtn
|
|
||||||
v-if="value && $props.expand"
|
|
||||||
flat
|
|
||||||
dense
|
|
||||||
icon="expand_more"
|
|
||||||
@click="onClick"
|
|
||||||
>
|
|
||||||
<QMenu anchor="bottom right" self="top right">
|
|
||||||
<QList>
|
|
||||||
<QItem v-ripple clickable @click="$emit('select:all', toRaw(rows))">
|
|
||||||
{{ t('Select all', { rows: rows.length }) }}
|
|
||||||
</QItem>
|
|
||||||
<slot name="more-options"></slot>
|
|
||||||
</QList>
|
|
||||||
</QMenu>
|
|
||||||
</QBtn>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<i18n lang="yml">
|
|
||||||
en:
|
|
||||||
Select all: 'Select all ({rows})'
|
|
||||||
fr:
|
|
||||||
Select all: 'Sélectionner tout ({rows})'
|
|
||||||
es:
|
|
||||||
Select all: 'Seleccionar todo ({rows})'
|
|
||||||
de:
|
|
||||||
Select all: 'Alle auswählen ({rows})'
|
|
||||||
it:
|
|
||||||
Select all: 'Seleziona tutto ({rows})'
|
|
||||||
pt:
|
|
||||||
Select all: 'Selecionar tudo ({rows})'
|
|
||||||
</i18n>
|
|
|
@ -1,100 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref, onMounted, onUnmounted, watch, nextTick } from 'vue';
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
scrollTarget: { type: [String, Object], default: 'window' }
|
|
||||||
});
|
|
||||||
|
|
||||||
const scrollPosition = ref(0);
|
|
||||||
const showButton = ref(false);
|
|
||||||
let scrollContainer = null;
|
|
||||||
|
|
||||||
const onScroll = () => {
|
|
||||||
if (!scrollContainer) return;
|
|
||||||
scrollPosition.value =
|
|
||||||
typeof props.scrollTarget === 'object'
|
|
||||||
? scrollContainer.scrollTop
|
|
||||||
: window.scrollY;
|
|
||||||
};
|
|
||||||
|
|
||||||
watch(scrollPosition, (newValue) => {
|
|
||||||
showButton.value = newValue > 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
const scrollToTop = () => {
|
|
||||||
if (scrollContainer) {
|
|
||||||
scrollContainer.scrollTo({ top: 0, behavior: 'smooth' });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateScrollContainer = (container) => {
|
|
||||||
if (container) {
|
|
||||||
if (scrollContainer) {
|
|
||||||
scrollContainer.removeEventListener('scroll', onScroll);
|
|
||||||
}
|
|
||||||
scrollContainer = container;
|
|
||||||
scrollContainer.addEventListener('scroll', onScroll);
|
|
||||||
onScroll();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
updateScrollContainer
|
|
||||||
});
|
|
||||||
|
|
||||||
const initScrollContainer = async () => {
|
|
||||||
await nextTick();
|
|
||||||
|
|
||||||
if (typeof props.scrollTarget === 'object') {
|
|
||||||
scrollContainer = props.scrollTarget;
|
|
||||||
} else {
|
|
||||||
scrollContainer = window;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!scrollContainer) return
|
|
||||||
scrollContainer.addEventListener('scroll', onScroll);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
initScrollContainer();
|
|
||||||
});
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
|
||||||
if (scrollContainer) {
|
|
||||||
scrollContainer.removeEventListener('scroll', onScroll);
|
|
||||||
scrollContainer = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<QIcon
|
|
||||||
v-if="showButton"
|
|
||||||
color="primary"
|
|
||||||
name="keyboard_arrow_up"
|
|
||||||
class="scroll-to-top"
|
|
||||||
@click="scrollToTop"
|
|
||||||
>
|
|
||||||
<QTooltip>{{ $t('globals.scrollToTop') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.scroll-to-top {
|
|
||||||
position: fixed;
|
|
||||||
top: 70px;
|
|
||||||
font-size: 65px;
|
|
||||||
left: 50%;
|
|
||||||
transform: translateX(-50%);
|
|
||||||
z-index: 1000;
|
|
||||||
transition: transform 0.2s ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
.scroll-to-top:hover {
|
|
||||||
transform: translateX(-50%) scale(1.2);
|
|
||||||
cursor: pointer;
|
|
||||||
filter: brightness(0.8);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -40,6 +40,10 @@ const $props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
keepData: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
@ -57,6 +61,7 @@ onBeforeMount(() => {
|
||||||
if ($props.dataKey)
|
if ($props.dataKey)
|
||||||
arrayData = useArrayData($props.dataKey, {
|
arrayData = useArrayData($props.dataKey, {
|
||||||
searchUrl: 'table',
|
searchUrl: 'table',
|
||||||
|
keepData: $props.keepData,
|
||||||
...$props.arrayDataProps,
|
...$props.arrayDataProps,
|
||||||
navigate: $props.redirect,
|
navigate: $props.redirect,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, toRefs, computed, watch, onMounted, useAttrs, nextTick } from 'vue';
|
import { ref, toRefs, computed, watch, onMounted, useAttrs } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
import { useRequired } from 'src/composables/useRequired';
|
import { useRequired } from 'src/composables/useRequired';
|
||||||
|
@ -54,10 +54,6 @@ const $props = defineProps({
|
||||||
type: [Array],
|
type: [Array],
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
filterFn: {
|
|
||||||
type: Function,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
exprBuilder: {
|
exprBuilder: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: null,
|
default: null,
|
||||||
|
@ -66,12 +62,16 @@ const $props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
defaultFilter: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
fields: {
|
fields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
type: [Object, Array, String],
|
type: [Object, Array],
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
|
@ -79,7 +79,7 @@ const $props = defineProps({
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
sortBy: {
|
sortBy: {
|
||||||
type: [String, Array],
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
|
@ -152,22 +152,6 @@ const value = computed({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
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 computedSortBy = computed(() => {
|
|
||||||
return $props.sortBy || $props.optionLabel + ' ASC';
|
|
||||||
});
|
|
||||||
|
|
||||||
const getVal = (val) => ($props.useLike ? { like: `%${val}%` } : val);
|
|
||||||
|
|
||||||
watch(options, (newValue) => {
|
watch(options, (newValue) => {
|
||||||
setOptions(newValue);
|
setOptions(newValue);
|
||||||
});
|
});
|
||||||
|
@ -186,14 +170,23 @@ onMounted(() => {
|
||||||
if ($props.focusOnMount) setTimeout(() => vnSelectRef.value.showPopup(), 300);
|
if ($props.focusOnMount) setTimeout(() => vnSelectRef.value.showPopup(), 300);
|
||||||
});
|
});
|
||||||
|
|
||||||
const someIsLoading = computed(() => isLoading.value || !!arrayData?.isLoading?.value);
|
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'],
|
||||||
|
});
|
||||||
|
|
||||||
function findKeyInOptions() {
|
function findKeyInOptions() {
|
||||||
if (!$props.options) return;
|
if (!$props.options) return;
|
||||||
return filter($props.modelValue, $props.options)?.length;
|
return filter($props.modelValue, $props.options)?.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setOptions(data) {
|
function setOptions(data) {
|
||||||
data = dataByOrder(data, computedSortBy.value);
|
data = dataByOrder(data, $props.sortBy);
|
||||||
myOptions.value = JSON.parse(JSON.stringify(data));
|
myOptions.value = JSON.parse(JSON.stringify(data));
|
||||||
myOptionsOriginal.value = JSON.parse(JSON.stringify(data));
|
myOptionsOriginal.value = JSON.parse(JSON.stringify(data));
|
||||||
emit('update:options', data);
|
emit('update:options', data);
|
||||||
|
@ -223,8 +216,7 @@ function filter(val, options) {
|
||||||
async function fetchFilter(val) {
|
async function fetchFilter(val) {
|
||||||
if (!$props.url) return;
|
if (!$props.url) return;
|
||||||
|
|
||||||
const { fields, include, limit } = $props;
|
const { fields, include, sortBy, limit } = $props;
|
||||||
const sortBy = computedSortBy.value;
|
|
||||||
const key =
|
const key =
|
||||||
optionFilterValue.value ??
|
optionFilterValue.value ??
|
||||||
(new RegExp(/\d/g).test(val)
|
(new RegExp(/\d/g).test(val)
|
||||||
|
@ -255,18 +247,20 @@ async function fetchFilter(val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function filterHandler(val, update) {
|
async function filterHandler(val, update) {
|
||||||
|
if (!val && lastVal.value === val) {
|
||||||
|
lastVal.value = val;
|
||||||
|
return update();
|
||||||
|
}
|
||||||
|
lastVal.value = val;
|
||||||
let newOptions;
|
let newOptions;
|
||||||
|
|
||||||
if ($props.filterFn) update($props.filterFn(val));
|
if (!$props.defaultFilter) return update();
|
||||||
else if (!val && lastVal.value === val) update();
|
if (
|
||||||
else {
|
$props.url &&
|
||||||
const makeRequest =
|
($props.limit || (!$props.limit && Object.keys(myOptions.value).length === 0))
|
||||||
($props.url && $props.limit) ||
|
) {
|
||||||
(!$props.limit && Object.keys(myOptions.value).length === 0);
|
newOptions = await fetchFilter(val);
|
||||||
newOptions = makeRequest
|
} else newOptions = filter(val, myOptionsOriginal.value);
|
||||||
? await fetchFilter(val)
|
|
||||||
: filter(val, myOptionsOriginal.value);
|
|
||||||
|
|
||||||
update(
|
update(
|
||||||
() => {
|
() => {
|
||||||
if ($props.noOne && noOneText.toLowerCase().includes(val.toLowerCase()))
|
if ($props.noOne && noOneText.toLowerCase().includes(val.toLowerCase()))
|
||||||
|
@ -283,13 +277,12 @@ async function filterHandler(val, update) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
lastVal.value = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
function nullishToTrue(value) {
|
function nullishToTrue(value) {
|
||||||
return value ?? true;
|
return value ?? true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getVal = (val) => ($props.useLike ? { like: `%${val}%` } : val);
|
||||||
|
|
||||||
async function onScroll({ to, direction, from, index }) {
|
async function onScroll({ to, direction, from, index }) {
|
||||||
const lastIndex = myOptions.value.length - 1;
|
const lastIndex = myOptions.value.length - 1;
|
||||||
|
|
||||||
|
@ -301,7 +294,6 @@ async function onScroll({ to, direction, from, index }) {
|
||||||
await arrayData.loadMore();
|
await arrayData.loadMore();
|
||||||
setOptions(arrayData.store.data);
|
setOptions(arrayData.store.data);
|
||||||
vnSelectRef.value.scrollTo(lastIndex);
|
vnSelectRef.value.scrollTo(lastIndex);
|
||||||
await nextTick();
|
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -367,7 +359,7 @@ function getCaption(opt) {
|
||||||
virtual-scroll-slice-size="options.length"
|
virtual-scroll-slice-size="options.length"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
:input-debounce="useURL ? '300' : '0'"
|
:input-debounce="useURL ? '300' : '0'"
|
||||||
:loading="someIsLoading"
|
:loading="isLoading"
|
||||||
@virtual-scroll="onScroll"
|
@virtual-scroll="onScroll"
|
||||||
@keydown="handleKeyDown"
|
@keydown="handleKeyDown"
|
||||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_select'"
|
:data-cy="$attrs.dataCy ?? $attrs.label + '_select'"
|
||||||
|
@ -375,7 +367,7 @@ function getCaption(opt) {
|
||||||
>
|
>
|
||||||
<template #append>
|
<template #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
v-show="isClearable && value != null && value !== ''"
|
v-show="isClearable && value"
|
||||||
name="close"
|
name="close"
|
||||||
@click="
|
@click="
|
||||||
() => {
|
() => {
|
||||||
|
@ -390,7 +382,7 @@ function getCaption(opt) {
|
||||||
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
|
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
|
||||||
<div v-if="slotName == 'append'">
|
<div v-if="slotName == 'append'">
|
||||||
<QIcon
|
<QIcon
|
||||||
v-show="isClearable && value != null && value !== ''"
|
v-show="isClearable && value"
|
||||||
name="close"
|
name="close"
|
||||||
@click.stop="
|
@click.stop="
|
||||||
() => {
|
() => {
|
||||||
|
@ -415,7 +407,7 @@ function getCaption(opt) {
|
||||||
<QItemLabel>
|
<QItemLabel>
|
||||||
{{ opt[optionLabel] }}
|
{{ opt[optionLabel] }}
|
||||||
</QItemLabel>
|
</QItemLabel>
|
||||||
<QItemLabel caption v-if="getCaption(opt) !== false">
|
<QItemLabel caption v-if="getCaption(opt)">
|
||||||
{{ `#${getCaption(opt)}` }}
|
{{ `#${getCaption(opt)}` }}
|
||||||
</QItemLabel>
|
</QItemLabel>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
|
|
|
@ -232,7 +232,7 @@ fr:
|
||||||
pt: Portugais
|
pt: Portugais
|
||||||
pt:
|
pt:
|
||||||
Send SMS: Enviar SMS
|
Send SMS: Enviar SMS
|
||||||
CustomerDefaultLanguage: Este cliente utiliza o {locale} como seu idioma padrão
|
CustomerDefaultLanguage: Este cliente utiliza o <strong>{locale}</strong> como seu idioma padrão
|
||||||
Language: Linguagem
|
Language: Linguagem
|
||||||
Phone: Móvel
|
Phone: Móvel
|
||||||
Subject: Assunto
|
Subject: Assunto
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
|
||||||
import VnBankDetailsForm from 'components/common/VnBankDetailsForm.vue';
|
|
||||||
import { vi, afterEach, expect, it, beforeEach, describe } from 'vitest';
|
|
||||||
|
|
||||||
describe('VnBankDetail Component', () => {
|
|
||||||
let vm;
|
|
||||||
let wrapper;
|
|
||||||
const bankEntities = [
|
|
||||||
{ id: 2100, bic: 'CAIXESBBXXX', name: 'CaixaBank' },
|
|
||||||
{ id: 1234, bic: 'TESTBIC', name: 'Test Bank' },
|
|
||||||
];
|
|
||||||
const correctIban = 'ES6621000418401234567891';
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
wrapper = createWrapper(VnBankDetailsForm, {
|
|
||||||
$props: {
|
|
||||||
iban: null,
|
|
||||||
bankEntityFk: null,
|
|
||||||
disableElement: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
vm = wrapper.vm;
|
|
||||||
wrapper = wrapper.wrapper;
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should update bankEntityFk when IBAN exists in bankEntities', async () => {
|
|
||||||
vm.bankEntities = bankEntities;
|
|
||||||
|
|
||||||
await vm.autofillBic(correctIban);
|
|
||||||
expect(vm.bankEntityFk).toBe(2100);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set bankEntityFk to null when IBAN bank code is not found', async () => {
|
|
||||||
vm.bankEntities = bankEntities;
|
|
||||||
|
|
||||||
await vm.autofillBic('ES1234567891324567891234');
|
|
||||||
expect(vm.bankEntityFk).toBe(null);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,5 +1,4 @@
|
||||||
import axios from 'axios';
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
|
||||||
import VnChangePassword from 'src/components/common/VnChangePassword.vue';
|
import VnChangePassword from 'src/components/common/VnChangePassword.vue';
|
||||||
import { vi, beforeEach, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
import { vi, beforeEach, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||||
import { Notify } from 'quasar';
|
import { Notify } from 'quasar';
|
||||||
|
|
|
@ -12,9 +12,7 @@ describe('VnDiscount', () => {
|
||||||
price: 100,
|
price: 100,
|
||||||
quantity: 2,
|
quantity: 2,
|
||||||
discount: 10,
|
discount: 10,
|
||||||
mana: 10,
|
}
|
||||||
promise: vi.fn(),
|
|
||||||
},
|
|
||||||
}).vm;
|
}).vm;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||||
import { default as axios } from 'axios';
|
|
||||||
import { vi, afterEach, beforeEach, beforeAll, describe, expect, it } from 'vitest';
|
import { vi, afterEach, beforeEach, beforeAll, describe, expect, it } from 'vitest';
|
||||||
import VnDms from 'src/components/common/VnDms.vue';
|
import VnDms from 'src/components/common/VnDms.vue';
|
||||||
|
|
||||||
|
@ -41,12 +40,7 @@ describe('VnDms', () => {
|
||||||
companyFk: 2,
|
companyFk: 2,
|
||||||
dmsTypeFk: 3,
|
dmsTypeFk: 3,
|
||||||
description: 'This is a test description',
|
description: 'This is a test description',
|
||||||
files: [
|
files: { name: 'example.txt', content: new Blob(['file content'], { type: 'text/plain' })},
|
||||||
{
|
|
||||||
name: 'example.txt',
|
|
||||||
content: new Blob(['file content'], { type: 'text/plain' }),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const expectedBody = {
|
const expectedBody = {
|
||||||
|
@ -65,7 +59,7 @@ describe('VnDms', () => {
|
||||||
url: '/test',
|
url: '/test',
|
||||||
formInitialData: { id: 1, reference: 'test' },
|
formInitialData: { id: 1, reference: 'test' },
|
||||||
model: 'Worker',
|
model: 'Worker',
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
wrapper = wrapper.wrapper;
|
wrapper = wrapper.wrapper;
|
||||||
vm = wrapper.vm;
|
vm = wrapper.vm;
|
||||||
|
@ -85,7 +79,7 @@ describe('VnDms', () => {
|
||||||
it('should map DMS data correctly and add file to FormData', () => {
|
it('should map DMS data correctly and add file to FormData', () => {
|
||||||
const [formData, params] = vm.mapperDms(data);
|
const [formData, params] = vm.mapperDms(data);
|
||||||
|
|
||||||
expect([formData.get('example.txt')]).toStrictEqual(data.files);
|
expect(formData.get('example.txt')).toBe(data.files);
|
||||||
expect(expectedBody).toEqual(params.params);
|
expect(expectedBody).toEqual(params.params);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -119,9 +113,7 @@ describe('VnDms', () => {
|
||||||
describe('save', () => {
|
describe('save', () => {
|
||||||
it('should save data correctly', async () => {
|
it('should save data correctly', async () => {
|
||||||
await vm.save();
|
await vm.save();
|
||||||
expect(postMock).toHaveBeenCalledWith(vm.getUrl(), expect.any(FormData), {
|
expect(postMock).toHaveBeenCalledWith(vm.getUrl(), expect.any(FormData), { params: expectedBody });
|
||||||
params: expectedBody,
|
|
||||||
});
|
|
||||||
expect(wrapper.emitted('onDataSaved')).toBeTruthy();
|
expect(wrapper.emitted('onDataSaved')).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -135,8 +127,8 @@ describe('VnDms', () => {
|
||||||
warehouseFk: 2,
|
warehouseFk: 2,
|
||||||
companyFk: 3,
|
companyFk: 3,
|
||||||
dmsTypeFk: 2,
|
dmsTypeFk: 2,
|
||||||
description: 'This is a test description',
|
description: 'This is a test description'
|
||||||
};
|
}
|
||||||
await wrapper.setProps({ formInitialData: testData });
|
await wrapper.setProps({ formInitialData: testData });
|
||||||
vm.defaultData();
|
vm.defaultData();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||||
import { default as axios } from 'axios';
|
|
||||||
|
|
||||||
import VnDmsList from 'src/components/common/VnDmsList.vue';
|
import VnDmsList from 'src/components/common/VnDmsList.vue';
|
||||||
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
|
@ -8,13 +6,10 @@ describe('VnDmsList', () => {
|
||||||
let vm;
|
let vm;
|
||||||
const dms = {
|
const dms = {
|
||||||
userFk: 1,
|
userFk: 1,
|
||||||
name: 'DMS 1',
|
name: 'DMS 1'
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
vi.mock('src/composables/getUrl', () => ({
|
|
||||||
getUrl: vi.fn().mockResolvedValue(''),
|
|
||||||
}));
|
|
||||||
vi.spyOn(axios, 'get').mockResolvedValue({ data: [] });
|
vi.spyOn(axios, 'get').mockResolvedValue({ data: [] });
|
||||||
vm = createWrapper(VnDmsList, {
|
vm = createWrapper(VnDmsList, {
|
||||||
props: {
|
props: {
|
||||||
|
@ -23,8 +18,8 @@ describe('VnDmsList', () => {
|
||||||
filter: 'wd.workerFk',
|
filter: 'wd.workerFk',
|
||||||
updateModel: 'Workers',
|
updateModel: 'Workers',
|
||||||
deleteModel: 'WorkerDms',
|
deleteModel: 'WorkerDms',
|
||||||
downloadModel: 'WorkerDms',
|
downloadModel: 'WorkerDms'
|
||||||
},
|
}
|
||||||
}).vm;
|
}).vm;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -39,7 +34,7 @@ describe('VnDmsList', () => {
|
||||||
name: 'Jessica',
|
name: 'Jessica',
|
||||||
lastName: 'Jones',
|
lastName: 'Jones',
|
||||||
file: '4.jpg',
|
file: '4.jpg',
|
||||||
created: '2021-07-28 21:00:00',
|
created: '2021-07-28 21:00:00'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
userFk: 2,
|
userFk: 2,
|
||||||
|
@ -52,21 +47,22 @@ describe('VnDmsList', () => {
|
||||||
lastName: 'BannerDMS',
|
lastName: 'BannerDMS',
|
||||||
created: '2022-07-28 21:00:00',
|
created: '2022-07-28 21:00:00',
|
||||||
file: '4.jpg',
|
file: '4.jpg',
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
userFk: 3,
|
userFk: 3,
|
||||||
name: 'Natasha',
|
name: 'Natasha',
|
||||||
lastName: 'Romanoff',
|
lastName: 'Romanoff',
|
||||||
file: '4.jpg',
|
file: '4.jpg',
|
||||||
created: '2021-10-28 21:00:00',
|
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', () => {
|
it('Should replace objects that contain the "dms" property with the value of the same and sort by creation date', () => {
|
||||||
vm.setData(data);
|
vm.setData(data);
|
||||||
expect([vm.rows][0][0].lastName).toEqual('BannerDMS');
|
expect([vm.rows][0][0].lastName).toEqual('BannerDMS');
|
||||||
expect([vm.rows][0][1].lastName).toEqual('Romanoff');
|
expect([vm.rows][0][1].lastName).toEqual('Romanoff');
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import { vi, describe, expect, it } from 'vitest';
|
import { vi, describe, expect, it } from 'vitest';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
|
||||||
|
|
||||||
describe('VnInput', () => {
|
describe('VnInput', () => {
|
||||||
let vm;
|
let vm;
|
||||||
let wrapper;
|
let wrapper;
|
||||||
|
@ -11,27 +12,25 @@ describe('VnInput', () => {
|
||||||
wrapper = createWrapper(VnInput, {
|
wrapper = createWrapper(VnInput, {
|
||||||
props: {
|
props: {
|
||||||
modelValue: value,
|
modelValue: value,
|
||||||
isOutlined,
|
isOutlined, emptyToNull, insertable,
|
||||||
emptyToNull,
|
maxlength: 101
|
||||||
insertable,
|
|
||||||
maxlength: 101,
|
|
||||||
},
|
},
|
||||||
attrs: {
|
attrs: {
|
||||||
label: 'test',
|
label: 'test',
|
||||||
required: true,
|
required: true,
|
||||||
maxlength: 101,
|
maxlength: 101,
|
||||||
maxLength: 10,
|
maxLength: 10,
|
||||||
'max-length': 20,
|
'max-length':20
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
wrapper = wrapper.wrapper;
|
wrapper = wrapper.wrapper;
|
||||||
vm = wrapper.vm;
|
vm = wrapper.vm;
|
||||||
input = wrapper.find('[data-cy="test_input"]');
|
input = wrapper.find('[data-cy="test_input"]');
|
||||||
}
|
};
|
||||||
|
|
||||||
describe('value', () => {
|
describe('value', () => {
|
||||||
it('should emit update:modelValue when value changes', async () => {
|
it('should emit update:modelValue when value changes', async () => {
|
||||||
generateWrapper('12345', false, false, true);
|
generateWrapper('12345', false, false, true)
|
||||||
await input.setValue('123');
|
await input.setValue('123');
|
||||||
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
||||||
expect(wrapper.emitted('update:modelValue')[0]).toEqual(['123']);
|
expect(wrapper.emitted('update:modelValue')[0]).toEqual(['123']);
|
||||||
|
@ -63,6 +62,7 @@ describe('VnInput', () => {
|
||||||
expect(wrapper.emitted('update:modelValue')).toBeUndefined();
|
expect(wrapper.emitted('update:modelValue')).toBeUndefined();
|
||||||
const spyhandler = vi.spyOn(vm, 'handleInsertMode');
|
const spyhandler = vi.spyOn(vm, 'handleInsertMode');
|
||||||
expect(spyhandler).not.toHaveBeenCalled();
|
expect(spyhandler).not.toHaveBeenCalled();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -71,7 +71,7 @@ describe('VnInput', () => {
|
||||||
it.skip('handleKeydown respects insertable behavior', async () => {
|
it.skip('handleKeydown respects insertable behavior', async () => {
|
||||||
const expectedValue = '12345';
|
const expectedValue = '12345';
|
||||||
generateWrapper('1234', false, false, true);
|
generateWrapper('1234', false, false, true);
|
||||||
vm.focus();
|
vm.focus()
|
||||||
await input.trigger('keydown', { key: '5' });
|
await input.trigger('keydown', { key: '5' });
|
||||||
await vm.$nextTick();
|
await vm.$nextTick();
|
||||||
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
||||||
|
|
|
@ -5,71 +5,52 @@ import VnInputDate from 'components/common/VnInputDate.vue';
|
||||||
let vm;
|
let vm;
|
||||||
let wrapper;
|
let wrapper;
|
||||||
|
|
||||||
function generateWrapper(outlined = false, required = false) {
|
function generateWrapper(date, outlined, required) {
|
||||||
wrapper = createWrapper(VnInputDate, {
|
wrapper = createWrapper(VnInputDate, {
|
||||||
props: {
|
props: {
|
||||||
modelValue: '2000-12-31T23:00:00.000Z',
|
modelValue: date,
|
||||||
'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e }),
|
|
||||||
},
|
},
|
||||||
attrs: {
|
attrs: {
|
||||||
isOutlined: outlined,
|
isOutlined: outlined,
|
||||||
required: required,
|
required: required
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
wrapper = wrapper.wrapper;
|
wrapper = wrapper.wrapper;
|
||||||
vm = wrapper.vm;
|
vm = wrapper.vm;
|
||||||
}
|
};
|
||||||
|
|
||||||
describe('VnInputDate', () => {
|
describe('VnInputDate', () => {
|
||||||
|
|
||||||
describe('formattedDate', () => {
|
describe('formattedDate', () => {
|
||||||
it('validateAndCleanInput should remove non-numeric characters', async () => {
|
it('formats a valid date correctly', async () => {
|
||||||
generateWrapper();
|
generateWrapper('2023-12-25', false, false);
|
||||||
vm.validateAndCleanInput('10a/1s2/2dd0a23');
|
|
||||||
await vm.$nextTick();
|
await vm.$nextTick();
|
||||||
expect(vm.inputValue).toBe('10/12/2023');
|
expect(vm.formattedDate).toBe('25/12/2023');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('manageDate should reverse the date', async () => {
|
it('updates the model value when a new date is set', async () => {
|
||||||
generateWrapper();
|
|
||||||
vm.manageDate('10/12/2023');
|
|
||||||
await vm.$nextTick();
|
|
||||||
expect(vm.inputValue).toBe('2023/12/10');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('formatDate should format the date correctly when a valid date is entered with full year', async () => {
|
|
||||||
const input = wrapper.find('input');
|
const input = wrapper.find('input');
|
||||||
await input.setValue('25.12/2002');
|
await input.setValue('31/12/2023');
|
||||||
await vm.$nextTick();
|
expect(wrapper.emitted()['update:modelValue']).toBeTruthy();
|
||||||
await vm.formatDate();
|
expect(wrapper.emitted()['update:modelValue'][0][0]).toBe('2023-12-31T00:00:00.000Z');
|
||||||
expect(vm.model).toBe('2002-12-24T23:00:00.000Z');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should format the date correctly when a valid date is entered with short year', async () => {
|
it('should not update the model value when an invalid date is set', async () => {
|
||||||
const input = wrapper.find('input');
|
const input = wrapper.find('input');
|
||||||
await input.setValue('31.12-23');
|
await input.setValue('invalid-date');
|
||||||
await vm.$nextTick();
|
expect(wrapper.emitted()['update:modelValue'][0][0]).toBe('2023-12-31T00:00:00.000Z');
|
||||||
await vm.formatDate();
|
|
||||||
expect(vm.model).toBe('2023-12-30T23:00:00.000Z');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should format the date correctly when a valid date is entered without year', async () => {
|
|
||||||
const input = wrapper.find('input');
|
|
||||||
await input.setValue('12.03');
|
|
||||||
await vm.$nextTick();
|
|
||||||
await vm.formatDate();
|
|
||||||
expect(vm.model).toBe('2001-03-11T23:00:00.000Z');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('styleAttrs', () => {
|
describe('styleAttrs', () => {
|
||||||
it('should return empty styleAttrs when isOutlined is false', async () => {
|
it('should return empty styleAttrs when isOutlined is false', async () => {
|
||||||
generateWrapper();
|
generateWrapper('2023-12-25', false, false);
|
||||||
await vm.$nextTick();
|
await vm.$nextTick();
|
||||||
expect(vm.styleAttrs).toEqual({});
|
expect(vm.styleAttrs).toEqual({});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set styleAttrs when isOutlined is true', async () => {
|
it('should set styleAttrs when isOutlined is true', async () => {
|
||||||
generateWrapper(true, false);
|
generateWrapper('2023-12-25', true, false);
|
||||||
await vm.$nextTick();
|
await vm.$nextTick();
|
||||||
expect(vm.styleAttrs.outlined).toBe(true);
|
expect(vm.styleAttrs.outlined).toBe(true);
|
||||||
});
|
});
|
||||||
|
@ -77,13 +58,13 @@ describe('VnInputDate', () => {
|
||||||
|
|
||||||
describe('required', () => {
|
describe('required', () => {
|
||||||
it('should not applies required class when isRequired is false', async () => {
|
it('should not applies required class when isRequired is false', async () => {
|
||||||
generateWrapper();
|
generateWrapper('2023-12-25', false, false);
|
||||||
await vm.$nextTick();
|
await vm.$nextTick();
|
||||||
expect(wrapper.find('.vn-input-date').classes()).not.toContain('required');
|
expect(wrapper.find('.vn-input-date').classes()).not.toContain('required');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should applies required class when isRequired is true', async () => {
|
it('should applies required class when isRequired is true', async () => {
|
||||||
generateWrapper(false, true);
|
generateWrapper('2023-12-25', false, true);
|
||||||
await vm.$nextTick();
|
await vm.$nextTick();
|
||||||
expect(wrapper.find('.vn-input-date').classes()).toContain('required');
|
expect(wrapper.find('.vn-input-date').classes()).toContain('required');
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,81 +0,0 @@
|
||||||
import { createWrapper } from 'app/test/vitest/helper.js';
|
|
||||||
import { describe, it, expect, beforeAll } from 'vitest';
|
|
||||||
import VnInputDateTime from 'components/common/VnInputDateTime.vue';
|
|
||||||
import vnDateBoot from 'src/boot/vnDate';
|
|
||||||
|
|
||||||
let vm;
|
|
||||||
let wrapper;
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
// Initialize the vnDate boot
|
|
||||||
vnDateBoot();
|
|
||||||
});
|
|
||||||
function generateWrapper(date, outlined, showEvent) {
|
|
||||||
wrapper = createWrapper(VnInputDateTime, {
|
|
||||||
props: {
|
|
||||||
modelValue: date,
|
|
||||||
isOutlined: outlined,
|
|
||||||
showEvent: showEvent,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
wrapper = wrapper.wrapper;
|
|
||||||
vm = wrapper.vm;
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('VnInputDateTime', () => {
|
|
||||||
describe('selectedDate', () => {
|
|
||||||
it('formats a valid datetime correctly', async () => {
|
|
||||||
generateWrapper('2023-12-25T10:30:00', false, true);
|
|
||||||
await vm.$nextTick();
|
|
||||||
expect(vm.selectedDate).toBe('25-12-2023 10:30');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('handles null date value', async () => {
|
|
||||||
generateWrapper(null, false, true);
|
|
||||||
await vm.$nextTick();
|
|
||||||
expect(vm.selectedDate).not.toBe(null);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('updates the model value when a new datetime is set', async () => {
|
|
||||||
vm.selectedDate = '31-12-2023 15:45';
|
|
||||||
await vm.$nextTick();
|
|
||||||
expect(wrapper.emitted()['update:modelValue']).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('styleAttrs', () => {
|
|
||||||
it('should return empty styleAttrs when isOutlined is false', async () => {
|
|
||||||
generateWrapper('2023-12-25T10:30:00', false, true);
|
|
||||||
await vm.$nextTick();
|
|
||||||
expect(vm.styleAttrs).toEqual({});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set styleAttrs when isOutlined is true', async () => {
|
|
||||||
generateWrapper('2023-12-25T10:30:00', true, true);
|
|
||||||
await vm.$nextTick();
|
|
||||||
expect(vm.styleAttrs).toEqual({
|
|
||||||
dense: true,
|
|
||||||
outlined: true,
|
|
||||||
rounded: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('component rendering', () => {
|
|
||||||
it('should render date and time icons', async () => {
|
|
||||||
generateWrapper('2023-12-25T10:30:00', false, true);
|
|
||||||
await vm.$nextTick();
|
|
||||||
const icons = wrapper.findAllComponents({ name: 'QIcon' });
|
|
||||||
expect(icons.length).toBe(2);
|
|
||||||
expect(icons[0].props('name')).toBe('today');
|
|
||||||
expect(icons[1].props('name')).toBe('access_time');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should render popup proxies for date and time', async () => {
|
|
||||||
generateWrapper('2023-12-25T10:30:00', false, true);
|
|
||||||
await vm.$nextTick();
|
|
||||||
const popups = wrapper.findAllComponents({ name: 'QPopupProxy' });
|
|
||||||
expect(popups.length).toBe(2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -65,7 +65,7 @@ describe('VnJsonValue', () => {
|
||||||
const date = new Date('2023-01-01');
|
const date = new Date('2023-01-01');
|
||||||
const wrapper = buildComponent({ value: date });
|
const wrapper = buildComponent({ value: date });
|
||||||
const span = wrapper.find('span');
|
const span = wrapper.find('span');
|
||||||
expect(span.text()).toBe('01/01/2023, 01:00:00');
|
expect(span.text()).toBe('2023-01-01');
|
||||||
expect(span.classes()).toContain('json-object');
|
expect(span.classes()).toContain('json-object');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||||
import axios from 'axios';
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
|
||||||
import VnLog from 'src/components/common/VnLog.vue';
|
import VnLog from 'src/components/common/VnLog.vue';
|
||||||
|
|
||||||
describe('VnLog', () => {
|
describe('VnLog', () => {
|
||||||
|
@ -90,10 +89,8 @@ describe('VnLog', () => {
|
||||||
|
|
||||||
vm = createWrapper(VnLog, {
|
vm = createWrapper(VnLog, {
|
||||||
global: {
|
global: {
|
||||||
stubs: ['FetchData', 'vue-i18n'],
|
stubs: [],
|
||||||
mocks: {
|
mocks: {},
|
||||||
fetch: vi.fn(),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
propsData: {
|
propsData: {
|
||||||
model: 'Claim',
|
model: 'Claim',
|
||||||
|
@ -111,4 +108,27 @@ describe('VnLog', () => {
|
||||||
expect(vm.logTree[0].originFk).toEqual(1);
|
expect(vm.logTree[0].originFk).toEqual(1);
|
||||||
expect(vm.logTree[0].logs[0].user.name).toEqual('salesPerson');
|
expect(vm.logTree[0].logs[0].user.name).toEqual('salesPerson');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should correctly set the selectedFilters when filtering', () => {
|
||||||
|
vm.searchInput = '1';
|
||||||
|
vm.userSelect = '21';
|
||||||
|
vm.checkboxOptions.insert.selected = true;
|
||||||
|
vm.checkboxOptions.update.selected = true;
|
||||||
|
|
||||||
|
vm.selectFilter('search');
|
||||||
|
vm.selectFilter('userSelect');
|
||||||
|
|
||||||
|
expect(vm.selectedFilters.changedModelId).toEqual('1');
|
||||||
|
expect(vm.selectedFilters.userFk).toEqual('21');
|
||||||
|
expect(vm.selectedFilters.action).toEqual({ inq: ['insert', 'update'] });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should correctly set the date from', () => {
|
||||||
|
vm.dateFrom = '18-09-2023';
|
||||||
|
vm.selectFilter('date', 'from');
|
||||||
|
expect(vm.selectedFilters.creationDate.between).toEqual([
|
||||||
|
new Date('2023-09-18T00:00:00.000Z'),
|
||||||
|
new Date('2023-09-18T21:59:59.999Z'),
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
|
||||||
import VnLogFilter from 'src/components/common/VnLogFilter.vue';
|
|
||||||
|
|
||||||
describe('VnLogFilter', () => {
|
|
||||||
let vm;
|
|
||||||
beforeAll(async () => {
|
|
||||||
vm = createWrapper(VnLogFilter, {
|
|
||||||
props: {
|
|
||||||
dataKey: 'ClaimLog',
|
|
||||||
},
|
|
||||||
}).vm;
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should getActions selected', async () => {
|
|
||||||
vm.checkboxOptions.find((o) => o.name == 'insert').selected = true;
|
|
||||||
vm.checkboxOptions.find((o) => o.name == 'update').selected = true;
|
|
||||||
|
|
||||||
const actions = vm.getActions();
|
|
||||||
|
|
||||||
expect(actions.length).toEqual(2);
|
|
||||||
expect(actions).toEqual(['insert', 'update']);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,26 +0,0 @@
|
||||||
import { describe, it, expect } from 'vitest';
|
|
||||||
import VnLogValue from 'src/components/common/VnLogValue.vue';
|
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
|
||||||
|
|
||||||
const buildComponent = (props) => {
|
|
||||||
return createWrapper(VnLogValue, {
|
|
||||||
props,
|
|
||||||
global: {},
|
|
||||||
}).wrapper;
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('VnLogValue', () => {
|
|
||||||
const id = 1;
|
|
||||||
it('renders without descriptor', async () => {
|
|
||||||
expect(getIcon('inventFk').exists()).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renders with descriptor', async () => {
|
|
||||||
expect(getIcon('claimFk').text()).toBe('launch');
|
|
||||||
});
|
|
||||||
|
|
||||||
function getIcon(name) {
|
|
||||||
const wrapper = buildComponent({ value: { val: id }, name });
|
|
||||||
return wrapper.find('.q-icon');
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -1,7 +1,16 @@
|
||||||
import { describe, it, expect, vi, afterEach, beforeEach, afterAll } from 'vitest';
|
import {
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
describe,
|
||||||
import { default as axios } from 'axios';
|
it,
|
||||||
|
expect,
|
||||||
|
vi,
|
||||||
|
beforeAll,
|
||||||
|
afterEach,
|
||||||
|
beforeEach,
|
||||||
|
afterAll,
|
||||||
|
} from 'vitest';
|
||||||
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||||
import VnNotes from 'src/components/ui/VnNotes.vue';
|
import VnNotes from 'src/components/ui/VnNotes.vue';
|
||||||
|
import vnDate from 'src/boot/vnDate';
|
||||||
|
|
||||||
describe('VnNotes', () => {
|
describe('VnNotes', () => {
|
||||||
let vm;
|
let vm;
|
||||||
|
@ -9,7 +18,6 @@ describe('VnNotes', () => {
|
||||||
let spyFetch;
|
let spyFetch;
|
||||||
let postMock;
|
let postMock;
|
||||||
let patchMock;
|
let patchMock;
|
||||||
let deleteMock;
|
|
||||||
let expectedInsertBody;
|
let expectedInsertBody;
|
||||||
let expectedUpdateBody;
|
let expectedUpdateBody;
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
|
@ -26,7 +34,7 @@ describe('VnNotes', () => {
|
||||||
) {
|
) {
|
||||||
vi.spyOn(axios, 'get').mockResolvedValue({ data: [] });
|
vi.spyOn(axios, 'get').mockResolvedValue({ data: [] });
|
||||||
wrapper = createWrapper(VnNotes, {
|
wrapper = createWrapper(VnNotes, {
|
||||||
propsData: { ...defaultOptions, ...options },
|
propsData: options,
|
||||||
});
|
});
|
||||||
wrapper = wrapper.wrapper;
|
wrapper = wrapper.wrapper;
|
||||||
vm = wrapper.vm;
|
vm = wrapper.vm;
|
||||||
|
@ -49,7 +57,6 @@ describe('VnNotes', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
postMock = vi.spyOn(axios, 'post');
|
postMock = vi.spyOn(axios, 'post');
|
||||||
patchMock = vi.spyOn(axios, 'patch');
|
patchMock = vi.spyOn(axios, 'patch');
|
||||||
deleteMock = vi.spyOn(axios, 'delete');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -146,16 +153,4 @@ describe('VnNotes', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('delete', () => {
|
|
||||||
it('Should call axios.delete with url and vnPaginateRef.fetch', async () => {
|
|
||||||
generateWrapper();
|
|
||||||
createSpyFetch();
|
|
||||||
|
|
||||||
await vm.deleteNote({ id: 1 });
|
|
||||||
|
|
||||||
expect(deleteMock).toHaveBeenCalledWith(`${vm.$props.url}/1`);
|
|
||||||
expect(spyFetch).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,38 +1,332 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import { onBeforeMount, watch, computed, ref } from 'vue';
|
||||||
import VnDescriptor from './VnDescriptor.vue';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import SkeletonDescriptor from 'components/ui/SkeletonDescriptor.vue';
|
||||||
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
|
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||||
|
import { useState } from 'src/composables/useState';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
import { useClipboard } from 'src/composables/useClipboard';
|
||||||
|
import VnMoreOptions from './VnMoreOptions.vue';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
id: {
|
url: {
|
||||||
type: Number,
|
type: String,
|
||||||
default: false,
|
default: '',
|
||||||
},
|
},
|
||||||
card: {
|
filter: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
subtitle: {
|
||||||
|
type: Number,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
dataKey: {
|
||||||
|
type: String,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
summary: {
|
||||||
|
type: Object,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
width: {
|
||||||
|
type: String,
|
||||||
|
default: 'md-width',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const state = useState();
|
||||||
|
const route = useRoute();
|
||||||
|
const { t } = useI18n();
|
||||||
|
const { copyText } = useClipboard();
|
||||||
|
const { viewSummary } = useSummaryDialog();
|
||||||
|
let arrayData;
|
||||||
|
let store;
|
||||||
|
let entity;
|
||||||
|
const isLoading = ref(false);
|
||||||
|
const isSameDataKey = computed(() => $props.dataKey === route.meta.moduleName);
|
||||||
|
defineExpose({ getData });
|
||||||
|
|
||||||
|
onBeforeMount(async () => {
|
||||||
|
arrayData = useArrayData($props.dataKey, {
|
||||||
|
url: $props.url,
|
||||||
|
userFilter: $props.filter,
|
||||||
|
skip: 0,
|
||||||
|
oneRecord: true,
|
||||||
|
});
|
||||||
|
store = arrayData.store;
|
||||||
|
entity = computed(() => {
|
||||||
|
const data = store.data ?? {};
|
||||||
|
if (data) emit('onFetch', data);
|
||||||
|
return data;
|
||||||
|
});
|
||||||
|
|
||||||
|
// It enables to load data only once if the module is the same as the dataKey
|
||||||
|
if (!isSameDataKey.value || !route.params.id) await getData();
|
||||||
|
watch(
|
||||||
|
() => [$props.url, $props.filter],
|
||||||
|
async () => {
|
||||||
|
if (!isSameDataKey.value) await getData();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const routeName = computed(() => {
|
||||||
|
const DESCRIPTOR_PROXY = 'DescriptorProxy';
|
||||||
|
|
||||||
|
let name = $props.dataKey;
|
||||||
|
if ($props.dataKey.includes(DESCRIPTOR_PROXY)) {
|
||||||
|
name = name.split(DESCRIPTOR_PROXY)[0];
|
||||||
|
}
|
||||||
|
return `${name}Summary`;
|
||||||
|
});
|
||||||
|
async function getData() {
|
||||||
|
store.url = $props.url;
|
||||||
|
store.filter = $props.filter ?? {};
|
||||||
|
isLoading.value = true;
|
||||||
|
try {
|
||||||
|
const { data } = await arrayData.fetch({ append: false, updateRouter: false });
|
||||||
|
state.set($props.dataKey, data);
|
||||||
|
emit('onFetch', data);
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getValueFromPath(path) {
|
||||||
|
if (!path) return;
|
||||||
|
const keys = path.toString().split('.');
|
||||||
|
let current = entity.value;
|
||||||
|
|
||||||
|
for (const key of keys) {
|
||||||
|
if (current[key] === undefined) return undefined;
|
||||||
|
else current = current[key];
|
||||||
|
}
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyIdText(id) {
|
||||||
|
copyText(id, {
|
||||||
|
component: {
|
||||||
|
copyValue: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const emit = defineEmits(['onFetch']);
|
const emit = defineEmits(['onFetch']);
|
||||||
const entity = ref();
|
|
||||||
|
const iconModule = computed(() => route.matched[1].meta.icon);
|
||||||
|
const toModule = computed(() =>
|
||||||
|
route.matched[1].path.split('/').length > 2
|
||||||
|
? route.matched[1].redirect
|
||||||
|
: route.matched[1].children[0].redirect,
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<component
|
<div class="descriptor">
|
||||||
:is="card"
|
<template v-if="entity && !isLoading">
|
||||||
:id
|
<div class="header bg-primary q-pa-sm justify-between">
|
||||||
:visual="false"
|
<slot name="header-extra-action"
|
||||||
v-bind="$attrs"
|
><QBtn
|
||||||
@on-fetch="
|
round
|
||||||
(data) => {
|
flat
|
||||||
entity = data;
|
dense
|
||||||
emit('onFetch', data);
|
size="md"
|
||||||
}
|
:icon="iconModule"
|
||||||
"
|
color="white"
|
||||||
|
class="link"
|
||||||
|
:to="$attrs['to-module'] ?? toModule"
|
||||||
|
>
|
||||||
|
<QTooltip>
|
||||||
|
{{ t('globals.goToModuleIndex') }}
|
||||||
|
</QTooltip>
|
||||||
|
</QBtn></slot
|
||||||
|
>
|
||||||
|
<QBtn
|
||||||
|
@click.stop="viewSummary(entity.id, $props.summary, $props.width)"
|
||||||
|
round
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
size="md"
|
||||||
|
icon="preview"
|
||||||
|
color="white"
|
||||||
|
class="link"
|
||||||
|
v-if="summary"
|
||||||
|
>
|
||||||
|
<QTooltip>
|
||||||
|
{{ t('components.smartCard.openSummary') }}
|
||||||
|
</QTooltip>
|
||||||
|
</QBtn>
|
||||||
|
<RouterLink :to="{ name: routeName, params: { id: entity.id } }">
|
||||||
|
<QBtn
|
||||||
|
class="link"
|
||||||
|
color="white"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
icon="launch"
|
||||||
|
round
|
||||||
|
size="md"
|
||||||
|
>
|
||||||
|
<QTooltip>
|
||||||
|
{{ t('components.cardDescriptor.summary') }}
|
||||||
|
</QTooltip>
|
||||||
|
</QBtn>
|
||||||
|
</RouterLink>
|
||||||
|
<VnMoreOptions v-if="$slots.menu">
|
||||||
|
<template #menu="{ menuRef }">
|
||||||
|
<slot name="menu" :entity="entity" :menu-ref="menuRef" />
|
||||||
|
</template>
|
||||||
|
</VnMoreOptions>
|
||||||
|
</div>
|
||||||
|
<slot name="before" />
|
||||||
|
<div class="body q-py-sm">
|
||||||
|
<QList dense>
|
||||||
|
<QItemLabel header class="ellipsis text-h5" :lines="1">
|
||||||
|
<div class="title">
|
||||||
|
<span v-if="$props.title" :title="getValueFromPath(title)">
|
||||||
|
{{ getValueFromPath(title) ?? $props.title }}
|
||||||
|
</span>
|
||||||
|
<slot v-else name="description" :entity="entity">
|
||||||
|
<span :title="entity.name">
|
||||||
|
{{ entity.name }}
|
||||||
|
</span>
|
||||||
|
</slot>
|
||||||
|
</div>
|
||||||
|
</QItemLabel>
|
||||||
|
<QItem>
|
||||||
|
<QItemLabel class="subtitle">
|
||||||
|
#{{ getValueFromPath(subtitle) ?? entity.id }}
|
||||||
|
</QItemLabel>
|
||||||
|
<QBtn
|
||||||
|
round
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
size="sm"
|
||||||
|
icon="content_copy"
|
||||||
|
color="primary"
|
||||||
|
@click.stop="copyIdText(entity.id)"
|
||||||
|
>
|
||||||
|
<QTooltip>
|
||||||
|
{{ t('globals.copyId') }}
|
||||||
|
</QTooltip>
|
||||||
|
</QBtn>
|
||||||
|
</QItem>
|
||||||
|
</QList>
|
||||||
|
<div class="list-box q-mt-xs">
|
||||||
|
<slot name="body" :entity="entity" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="icons">
|
||||||
|
<slot name="icons" :entity="entity" />
|
||||||
|
</div>
|
||||||
|
<div class="actions justify-center" data-cy="descriptor_actions">
|
||||||
|
<slot name="actions" :entity="entity" />
|
||||||
|
</div>
|
||||||
|
<slot name="after" />
|
||||||
|
</template>
|
||||||
|
<!-- Skeleton -->
|
||||||
|
<SkeletonDescriptor v-if="!entity || isLoading" />
|
||||||
|
</div>
|
||||||
|
<QInnerLoading
|
||||||
|
:label="t('globals.pleaseWait')"
|
||||||
|
:showing="isLoading"
|
||||||
|
color="primary"
|
||||||
/>
|
/>
|
||||||
<VnDescriptor v-model="entity" v-bind="$attrs">
|
|
||||||
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
|
|
||||||
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
|
||||||
</template>
|
|
||||||
</VnDescriptor>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.body {
|
||||||
|
background-color: var(--vn-section-color);
|
||||||
|
.text-h5 {
|
||||||
|
font-size: 20px;
|
||||||
|
padding-top: 5px;
|
||||||
|
padding-bottom: 0px;
|
||||||
|
}
|
||||||
|
.q-item {
|
||||||
|
min-height: 20px;
|
||||||
|
|
||||||
|
.link {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.vn-label-value {
|
||||||
|
display: flex;
|
||||||
|
padding: 0px 16px;
|
||||||
|
.label {
|
||||||
|
color: var(--vn-label-color);
|
||||||
|
font-size: 14px;
|
||||||
|
|
||||||
|
&:not(:has(a))::after {
|
||||||
|
content: ':';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.value {
|
||||||
|
color: var(--vn-text-color);
|
||||||
|
font-size: 14px;
|
||||||
|
margin-left: 4px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.info {
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.title {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
span {
|
||||||
|
color: var(--vn-text-color);
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.subtitle {
|
||||||
|
color: var(--vn-text-color);
|
||||||
|
font-size: 16px;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
}
|
||||||
|
.list-box {
|
||||||
|
.q-item__label {
|
||||||
|
color: var(--vn-label-color);
|
||||||
|
padding-bottom: 0%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.descriptor {
|
||||||
|
width: 256px;
|
||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.icons {
|
||||||
|
margin: 0 10px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
.q-icon {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.actions {
|
||||||
|
margin: 0 5px;
|
||||||
|
justify-content: center !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<i18n>
|
||||||
|
en:
|
||||||
|
globals:
|
||||||
|
copyId: Copy ID
|
||||||
|
es:
|
||||||
|
globals:
|
||||||
|
copyId: Copiar ID
|
||||||
|
</i18n>
|
||||||
|
|
|
@ -81,7 +81,6 @@ async function fetch() {
|
||||||
name: `${moduleName ?? route.meta.moduleName}Summary`,
|
name: `${moduleName ?? route.meta.moduleName}Summary`,
|
||||||
params: { id: entityId || entity.id },
|
params: { id: entityId || entity.id },
|
||||||
}"
|
}"
|
||||||
data-cy="goToSummaryBtn"
|
|
||||||
>
|
>
|
||||||
<QIcon name="open_in_new" color="white" size="sm" />
|
<QIcon name="open_in_new" color="white" size="sm" />
|
||||||
</router-link>
|
</router-link>
|
||||||
|
@ -159,7 +158,6 @@ async function fetch() {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
align-items: start;
|
|
||||||
.label {
|
.label {
|
||||||
color: var(--vn-label-color);
|
color: var(--vn-label-color);
|
||||||
width: 9em;
|
width: 9em;
|
||||||
|
@ -170,15 +168,9 @@ async function fetch() {
|
||||||
flex-grow: 0;
|
flex-grow: 0;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
&.ellipsis > .value {
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: pre;
|
|
||||||
}
|
|
||||||
.value {
|
.value {
|
||||||
color: var(--vn-text-color);
|
color: var(--vn-text-color);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: nowrap;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.header {
|
.header {
|
||||||
|
@ -208,23 +200,6 @@ async function fetch() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.vn-card-group {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
||||||
gap: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vn-card-content {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
overflow: hidden;
|
|
||||||
white-space: nowrap;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
> div {
|
|
||||||
max-height: 70px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.summaryHeader .vn-label-value {
|
.summaryHeader .vn-label-value {
|
||||||
|
|
|
@ -1,85 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { watch, ref, onMounted } from 'vue';
|
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
|
||||||
import VnDescriptor from './VnDescriptor.vue';
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
url: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
dataKey: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
let arrayData;
|
|
||||||
let store;
|
|
||||||
const entity = ref();
|
|
||||||
const isLoading = ref(false);
|
|
||||||
const containerRef = ref(null);
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
let isPopup;
|
|
||||||
let el = containerRef.value.$el;
|
|
||||||
while (el) {
|
|
||||||
if (el.classList?.contains('q-menu')) {
|
|
||||||
isPopup = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
el = el.parentElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
arrayData = useArrayData($props.dataKey + (isPopup ? 'Proxy' : ''), {
|
|
||||||
url: $props.url,
|
|
||||||
userFilter: $props.filter,
|
|
||||||
skip: 0,
|
|
||||||
oneRecord: true,
|
|
||||||
});
|
|
||||||
store = arrayData.store;
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => [$props.url, $props.filter],
|
|
||||||
async () => {
|
|
||||||
await getData();
|
|
||||||
},
|
|
||||||
{ immediate: true },
|
|
||||||
);
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => arrayData.store.data,
|
|
||||||
(newValue) => {
|
|
||||||
entity.value = newValue;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
defineExpose({ getData });
|
|
||||||
const emit = defineEmits(['onFetch']);
|
|
||||||
|
|
||||||
async function getData() {
|
|
||||||
store.url = $props.url;
|
|
||||||
store.filter = $props.filter ?? {};
|
|
||||||
isLoading.value = true;
|
|
||||||
try {
|
|
||||||
await arrayData.fetch({ append: false, updateRouter: false });
|
|
||||||
const { data } = store;
|
|
||||||
emit('onFetch', data);
|
|
||||||
} finally {
|
|
||||||
isLoading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<VnDescriptor v-model="entity" v-bind="$attrs" :module="dataKey" ref="containerRef">
|
|
||||||
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
|
|
||||||
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
|
||||||
</template>
|
|
||||||
</VnDescriptor>
|
|
||||||
</template>
|
|
|
@ -89,7 +89,6 @@ function cancel() {
|
||||||
<slot name="customHTML"></slot>
|
<slot name="customHTML"></slot>
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<QCardActions align="right">
|
<QCardActions align="right">
|
||||||
<slot name="actions" :actions="{ confirm, cancel }">
|
|
||||||
<QBtn
|
<QBtn
|
||||||
:label="t('globals.cancel')"
|
:label="t('globals.cancel')"
|
||||||
color="primary"
|
color="primary"
|
||||||
|
@ -108,7 +107,6 @@ function cancel() {
|
||||||
autofocus
|
autofocus
|
||||||
data-cy="VnConfirm_confirm"
|
data-cy="VnConfirm_confirm"
|
||||||
/>
|
/>
|
||||||
</slot>
|
|
||||||
</QCardActions>
|
</QCardActions>
|
||||||
</QCard>
|
</QCard>
|
||||||
</QDialog>
|
</QDialog>
|
||||||
|
|
|
@ -1,311 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { computed, ref } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import SkeletonDescriptor from 'components/ui/SkeletonDescriptor.vue';
|
|
||||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
|
||||||
import { useClipboard } from 'src/composables/useClipboard';
|
|
||||||
import VnMoreOptions from './VnMoreOptions.vue';
|
|
||||||
import { getValueFromPath } from 'src/composables/getValueFromPath';
|
|
||||||
|
|
||||||
const entity = defineModel({ type: Object, default: null });
|
|
||||||
const $props = defineProps({
|
|
||||||
title: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
subtitle: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
summary: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: 'md-width',
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
toModule: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
const router = useRouter();
|
|
||||||
const { t } = useI18n();
|
|
||||||
const { copyText } = useClipboard();
|
|
||||||
const { viewSummary } = useSummaryDialog();
|
|
||||||
const DESCRIPTOR_PROXY = 'DescriptorProxy';
|
|
||||||
const moduleName = ref();
|
|
||||||
const isSameModuleName = route.matched[1].meta.moduleName !== moduleName.value;
|
|
||||||
|
|
||||||
function getName() {
|
|
||||||
let name = $props.module;
|
|
||||||
if ($props.module.includes(DESCRIPTOR_PROXY)) {
|
|
||||||
name = name.split(DESCRIPTOR_PROXY)[0];
|
|
||||||
}
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
const routeName = computed(() => {
|
|
||||||
let routeName = getName();
|
|
||||||
return `${routeName}Summary`;
|
|
||||||
});
|
|
||||||
|
|
||||||
function copyIdText(id) {
|
|
||||||
copyText(id, {
|
|
||||||
component: {
|
|
||||||
copyValue: id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const emit = defineEmits(['onFetch']);
|
|
||||||
|
|
||||||
const iconModule = computed(() => {
|
|
||||||
moduleName.value = getName();
|
|
||||||
if ($props.toModule) {
|
|
||||||
return router.getRoutes().find((r) => r.name === $props.toModule.name).meta.icon;
|
|
||||||
}
|
|
||||||
if (isSameModuleName) {
|
|
||||||
return router.options.routes[1].children.find((r) => r.name === moduleName.value)
|
|
||||||
?.meta?.icon;
|
|
||||||
} else {
|
|
||||||
return route.matched[1].meta.icon;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const toModule = computed(() => {
|
|
||||||
moduleName.value = getName();
|
|
||||||
if ($props.toModule) return $props.toModule;
|
|
||||||
if (isSameModuleName) {
|
|
||||||
return router.options.routes[1].children.find((r) => r.name === moduleName.value)
|
|
||||||
?.redirect;
|
|
||||||
} else {
|
|
||||||
return route.matched[1].path.split('/').length > 2
|
|
||||||
? route.matched[1].redirect
|
|
||||||
: route.matched[1].children[0].redirect;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="descriptor" data-cy="vnDescriptor">
|
|
||||||
<template v-if="entity && entity?.id">
|
|
||||||
<div class="header bg-primary q-pa-sm justify-between">
|
|
||||||
<slot name="header-extra-action">
|
|
||||||
<QBtn
|
|
||||||
round
|
|
||||||
flat
|
|
||||||
dense
|
|
||||||
size="md"
|
|
||||||
:icon="iconModule"
|
|
||||||
color="white"
|
|
||||||
class="link"
|
|
||||||
:to="toModule"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ t('globals.goToModuleIndex') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</slot>
|
|
||||||
<QBtn
|
|
||||||
@click.stop="viewSummary(entity.id, summary, width)"
|
|
||||||
round
|
|
||||||
flat
|
|
||||||
dense
|
|
||||||
size="md"
|
|
||||||
icon="preview"
|
|
||||||
color="white"
|
|
||||||
class="link"
|
|
||||||
v-if="summary"
|
|
||||||
data-cy="openSummaryBtn"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ t('components.smartCard.openSummary') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
<RouterLink :to="{ name: routeName, params: { id: entity.id } }">
|
|
||||||
<QBtn
|
|
||||||
class="link"
|
|
||||||
color="white"
|
|
||||||
dense
|
|
||||||
flat
|
|
||||||
icon="launch"
|
|
||||||
round
|
|
||||||
size="md"
|
|
||||||
data-cy="goToSummaryBtn"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ t('components.vnDescriptor.summary') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</RouterLink>
|
|
||||||
<VnMoreOptions v-if="$slots.menu">
|
|
||||||
<template #menu="{ menuRef }">
|
|
||||||
<slot name="menu" :entity="entity" :menu-ref="menuRef" />
|
|
||||||
</template>
|
|
||||||
</VnMoreOptions>
|
|
||||||
</div>
|
|
||||||
<slot name="before" />
|
|
||||||
<div class="body q-py-sm">
|
|
||||||
<QList dense>
|
|
||||||
<QItemLabel header class="ellipsis text-h5" :lines="1">
|
|
||||||
<div class="title">
|
|
||||||
<span
|
|
||||||
v-if="title"
|
|
||||||
:title="getValueFromPath(entity, title)"
|
|
||||||
:data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_title`"
|
|
||||||
>
|
|
||||||
{{ getValueFromPath(entity, title) ?? title }}
|
|
||||||
</span>
|
|
||||||
<slot v-else name="description" :entity="entity">
|
|
||||||
<span
|
|
||||||
:title="entity.name"
|
|
||||||
:data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_description`"
|
|
||||||
v-text="entity.name"
|
|
||||||
/>
|
|
||||||
</slot>
|
|
||||||
</div>
|
|
||||||
</QItemLabel>
|
|
||||||
<QItem>
|
|
||||||
<QItemLabel
|
|
||||||
class="subtitle"
|
|
||||||
:data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_subtitle`"
|
|
||||||
>
|
|
||||||
#{{ getValueFromPath(entity, subtitle) ?? entity.id }}
|
|
||||||
</QItemLabel>
|
|
||||||
<QBtn
|
|
||||||
round
|
|
||||||
flat
|
|
||||||
dense
|
|
||||||
size="sm"
|
|
||||||
icon="content_copy"
|
|
||||||
color="primary"
|
|
||||||
@click.stop="copyIdText(entity.id)"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ t('globals.copyId') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</QItem>
|
|
||||||
</QList>
|
|
||||||
<div
|
|
||||||
class="list-box q-mt-xs"
|
|
||||||
:data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_listbox`"
|
|
||||||
>
|
|
||||||
<slot name="body" :entity="entity" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="icons">
|
|
||||||
<slot name="icons" :entity="entity" />
|
|
||||||
</div>
|
|
||||||
<div class="actions justify-center" data-cy="descriptor_actions">
|
|
||||||
<slot name="actions" :entity="entity" />
|
|
||||||
</div>
|
|
||||||
<slot name="after" />
|
|
||||||
</template>
|
|
||||||
<SkeletonDescriptor v-if="!entity" />
|
|
||||||
</div>
|
|
||||||
<QInnerLoading :label="t('globals.pleaseWait')" :showing="!entity" color="primary" />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
.body {
|
|
||||||
background-color: var(--vn-section-color);
|
|
||||||
.text-h5 {
|
|
||||||
font-size: 20px;
|
|
||||||
padding-top: 5px;
|
|
||||||
padding-bottom: 0px;
|
|
||||||
}
|
|
||||||
.q-item {
|
|
||||||
min-height: 20px;
|
|
||||||
|
|
||||||
.link {
|
|
||||||
margin-left: 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.vn-label-value {
|
|
||||||
display: flex;
|
|
||||||
padding: 0px 16px;
|
|
||||||
.label {
|
|
||||||
color: var(--vn-label-color);
|
|
||||||
font-size: 14px;
|
|
||||||
|
|
||||||
&:not(:has(a))::after {
|
|
||||||
content: ':';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&.ellipsis > .value {
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: pre;
|
|
||||||
}
|
|
||||||
.value {
|
|
||||||
color: var(--vn-text-color);
|
|
||||||
font-size: 14px;
|
|
||||||
margin-left: 4px;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
.info {
|
|
||||||
margin-left: 5px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.title {
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
span {
|
|
||||||
color: var(--vn-text-color);
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.subtitle {
|
|
||||||
color: var(--vn-text-color);
|
|
||||||
font-size: 16px;
|
|
||||||
margin-bottom: 2px;
|
|
||||||
}
|
|
||||||
.list-box {
|
|
||||||
.q-item__label {
|
|
||||||
color: var(--vn-label-color);
|
|
||||||
padding-bottom: 0%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.descriptor {
|
|
||||||
width: 256px;
|
|
||||||
.header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
.icons {
|
|
||||||
margin: 0 10px;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
.q-icon {
|
|
||||||
margin-right: 5px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.actions {
|
|
||||||
margin: 0 5px;
|
|
||||||
justify-content: center !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<i18n>
|
|
||||||
en:
|
|
||||||
globals:
|
|
||||||
copyId: Copy ID
|
|
||||||
es:
|
|
||||||
globals:
|
|
||||||
copyId: Copiar ID
|
|
||||||
</i18n>
|
|
|
@ -54,17 +54,13 @@ const $props = defineProps({
|
||||||
default: 'table',
|
default: 'table',
|
||||||
},
|
},
|
||||||
redirect: {
|
redirect: {
|
||||||
type: [String, Boolean],
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
arrayData: {
|
arrayData: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
showTagChips: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits([
|
const emit = defineEmits([
|
||||||
|
@ -92,14 +88,13 @@ const userOrders = ref(useFilterParams($props.dataKey).orders);
|
||||||
defineExpose({ search, params: userParams, remove });
|
defineExpose({ search, params: userParams, remove });
|
||||||
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
async function search(evt, name, value) {
|
async function search(evt) {
|
||||||
try {
|
try {
|
||||||
if (evt && $props.disableSubmitEvent) return;
|
if (evt && $props.disableSubmitEvent) return;
|
||||||
|
|
||||||
store.filter.where = {};
|
store.filter.where = {};
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
const filter = { ...userParams.value, ...$props.modelValue };
|
const filter = { ...userParams.value, ...$props.modelValue };
|
||||||
if (name) filter[name] = value;
|
|
||||||
store.userParamsChanged = true;
|
store.userParamsChanged = true;
|
||||||
await arrayData.addFilter({
|
await arrayData.addFilter({
|
||||||
params: filter,
|
params: filter,
|
||||||
|
@ -212,7 +207,6 @@ const getLocale = (label) => {
|
||||||
color="primary"
|
color="primary"
|
||||||
style="position: fixed; z-index: 1; right: 0; bottom: 0"
|
style="position: fixed; z-index: 1; right: 0; bottom: 0"
|
||||||
icon="search"
|
icon="search"
|
||||||
data-cy="vnFilterPanel_search"
|
|
||||||
@click="search()"
|
@click="search()"
|
||||||
>
|
>
|
||||||
<QTooltip bottom anchor="bottom right">
|
<QTooltip bottom anchor="bottom right">
|
||||||
|
@ -220,7 +214,7 @@ const getLocale = (label) => {
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QBtn>
|
</QBtn>
|
||||||
<QForm @submit="search" id="filterPanelForm" @keyup.enter="search()">
|
<QForm @submit="search" id="filterPanelForm" @keyup.enter="search()">
|
||||||
<QList dense v-if="showTagChips">
|
<QList dense>
|
||||||
<QItem class="q-mt-xs">
|
<QItem class="q-mt-xs">
|
||||||
<QItemSection top>
|
<QItemSection top>
|
||||||
<QItemLabel header lines="1" class="text-uppercase q-py-xs q-px-none">
|
<QItemLabel header lines="1" class="text-uppercase q-py-xs q-px-none">
|
||||||
|
@ -230,7 +224,6 @@ const getLocale = (label) => {
|
||||||
<QItemSection top side>
|
<QItemSection top side>
|
||||||
<QBtn
|
<QBtn
|
||||||
@click="clearFilters"
|
@click="clearFilters"
|
||||||
data-cy="clearFilters"
|
|
||||||
color="primary"
|
color="primary"
|
||||||
dense
|
dense
|
||||||
flat
|
flat
|
||||||
|
@ -256,7 +249,7 @@ const getLocale = (label) => {
|
||||||
:key="chip.label"
|
:key="chip.label"
|
||||||
:removable="!unremovableParams?.includes(chip.label)"
|
:removable="!unremovableParams?.includes(chip.label)"
|
||||||
@remove="remove(chip.label)"
|
@remove="remove(chip.label)"
|
||||||
:data-cy="`vnFilterPanelChip_${chip.label}`"
|
data-cy="vnFilterPanelChip"
|
||||||
>
|
>
|
||||||
<slot
|
<slot
|
||||||
name="tags"
|
name="tags"
|
||||||
|
@ -294,7 +287,6 @@ const getLocale = (label) => {
|
||||||
</QList>
|
</QList>
|
||||||
</QForm>
|
</QForm>
|
||||||
<QInnerLoading
|
<QInnerLoading
|
||||||
data-cy="filterPanel-spinner"
|
|
||||||
:label="t('globals.pleaseWait')"
|
:label="t('globals.pleaseWait')"
|
||||||
:showing="isLoading"
|
:showing="isLoading"
|
||||||
color="primary"
|
color="primary"
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { dashIfEmpty } from 'src/filters';
|
|
||||||
|
|
||||||
defineProps({ email: { type: [String], default: null } });
|
defineProps({ email: { type: [String], default: null } });
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<QBtn
|
<QBtn
|
||||||
class="q-pr-xs"
|
|
||||||
v-if="email"
|
v-if="email"
|
||||||
flat
|
flat
|
||||||
round
|
round
|
||||||
|
@ -16,5 +13,4 @@ defineProps({ email: { type: [String], default: null } });
|
||||||
:href="`mailto:${email}`"
|
:href="`mailto:${email}`"
|
||||||
@click.stop
|
@click.stop
|
||||||
/>
|
/>
|
||||||
<span>{{ dashIfEmpty(email) }}</span>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive, useAttrs, onBeforeMount, capitalize } from 'vue';
|
import { ref, reactive, useAttrs, onBeforeMount, capitalize } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { dashIfEmpty, parsePhone } from 'src/filters';
|
import { parsePhone } from 'src/filters';
|
||||||
import useOpenURL from 'src/composables/useOpenURL';
|
import useOpenURL from 'src/composables/useOpenURL';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
@ -12,51 +12,38 @@ const props = defineProps({
|
||||||
|
|
||||||
const phone = ref(props.phoneNumber);
|
const phone = ref(props.phoneNumber);
|
||||||
const config = reactive({
|
const config = reactive({
|
||||||
|
sip: { icon: 'phone', href: `sip:${props.phoneNumber}` },
|
||||||
'say-simple': {
|
'say-simple': {
|
||||||
icon: 'vn:saysimple',
|
icon: 'vn:saysimple',
|
||||||
url: null,
|
url: null,
|
||||||
channel: props.channel,
|
channel: props.channel,
|
||||||
},
|
},
|
||||||
sip: { icon: 'phone', href: `sip:${props.phoneNumber}` },
|
|
||||||
});
|
});
|
||||||
|
const type = Object.keys(config).find((key) => key in useAttrs()) || 'sip';
|
||||||
const attrs = useAttrs();
|
|
||||||
const types = Object.keys(config)
|
|
||||||
.filter((key) => key in attrs)
|
|
||||||
.sort();
|
|
||||||
const activeTypes = types.length ? types : ['sip'];
|
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
if (!phone.value) return;
|
if (!phone.value) return;
|
||||||
|
|
||||||
for (const type of activeTypes) {
|
|
||||||
if (type === 'say-simple') {
|
|
||||||
let { channel } = config[type];
|
let { channel } = config[type];
|
||||||
|
|
||||||
|
if (type === 'say-simple') {
|
||||||
const { url, defaultChannel } = (await axios.get('SaySimpleConfigs/findOne'))
|
const { url, defaultChannel } = (await axios.get('SaySimpleConfigs/findOne'))
|
||||||
.data;
|
.data;
|
||||||
if (!channel) channel = defaultChannel;
|
if (!channel) channel = defaultChannel;
|
||||||
|
|
||||||
phone.value = await parsePhone(
|
phone.value = await parsePhone(props.phoneNumber, props.country?.toLowerCase());
|
||||||
props.phoneNumber,
|
config[
|
||||||
props.country?.toLowerCase(),
|
type
|
||||||
);
|
].url = `${url}?customerIdentity=%2B${phone.value}&channelId=${channel}`;
|
||||||
config[type].url =
|
|
||||||
`${url}?customerIdentity=%2B${phone.value}&channelId=${channel}`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleClick(type) {
|
function handleClick() {
|
||||||
if (config[type].url) useOpenURL(config[type].url);
|
if (config[type].url) useOpenURL(config[type].url);
|
||||||
else if (config[type].href) window.location.href = config[type].href;
|
else if (config[type].href) window.location.href = config[type].href;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex items-center gap-2">
|
|
||||||
<template v-for="type in activeTypes">
|
|
||||||
<QBtn
|
<QBtn
|
||||||
:key="type"
|
|
||||||
v-if="phone"
|
v-if="phone"
|
||||||
flat
|
flat
|
||||||
round
|
round
|
||||||
|
@ -64,13 +51,10 @@ function handleClick(type) {
|
||||||
size="sm"
|
size="sm"
|
||||||
color="primary"
|
color="primary"
|
||||||
padding="none"
|
padding="none"
|
||||||
@click.stop="() => handleClick(type)"
|
@click.stop="handleClick"
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ capitalize(type).replace('-', '') }}
|
{{ capitalize(type).replace('-', '') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QBtn></template
|
</QBtn>
|
||||||
>
|
|
||||||
<span>{{ dashIfEmpty(phone) }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -6,7 +6,6 @@ import { computed } from 'vue';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
label: { type: String, default: null },
|
label: { type: String, default: null },
|
||||||
tooltip: { type: String, default: null },
|
|
||||||
value: {
|
value: {
|
||||||
type: [String, Boolean, Number],
|
type: [String, Boolean, Number],
|
||||||
default: null,
|
default: null,
|
||||||
|
@ -29,27 +28,23 @@ function copyValueText() {
|
||||||
const val = computed(() => $props.value);
|
const val = computed(() => $props.value);
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="vn-label-value" :data-cy="`${$attrs['data-cy'] ?? 'vnLv'}${label ?? ''}`">
|
<div class="vn-label-value">
|
||||||
<QCheckbox
|
<QCheckbox
|
||||||
v-if="typeof value === 'boolean'"
|
v-if="typeof value === 'boolean'"
|
||||||
v-model="val"
|
v-model="val"
|
||||||
:label="label"
|
:label="label"
|
||||||
disable
|
disable
|
||||||
dense
|
dense
|
||||||
size="sm"
|
|
||||||
/>
|
/>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div v-if="label || $slots.label" class="label">
|
<div v-if="label || $slots.label" class="label">
|
||||||
<slot name="label">
|
<slot name="label">
|
||||||
<QTooltip v-if="tooltip">{{ tooltip }}</QTooltip>
|
<span style="color: var(--vn-label-color)">{{ label }}</span>
|
||||||
<span style="color: var(--vn-label-color)">
|
|
||||||
{{ label }}
|
|
||||||
</span>
|
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
<div class="value" v-if="value || $slots.value">
|
<div class="value">
|
||||||
<slot name="value">
|
<slot name="value">
|
||||||
<span :title="value" style="text-overflow: ellipsis">
|
<span :title="value">
|
||||||
{{ dash ? dashIfEmpty(value) : value }}
|
{{ dash ? dashIfEmpty(value) : value }}
|
||||||
</span>
|
</span>
|
||||||
</slot>
|
</slot>
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
data-cy="descriptor-more-opts"
|
data-cy="descriptor-more-opts"
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ $t('components.vnDescriptor.moreOptions') }}
|
{{ $t('components.cardDescriptor.moreOptions') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
<QMenu ref="menuRef" data-cy="descriptor-more-opts-menu">
|
<QMenu ref="menuRef" data-cy="descriptor-more-opts-menu">
|
||||||
<QList data-cy="descriptor-more-opts_list">
|
<QList>
|
||||||
<slot name="menu" :menu-ref="$refs.menuRef" />
|
<slot name="menu" :menu-ref="$refs.menuRef" />
|
||||||
</QList>
|
</QList>
|
||||||
</QMenu>
|
</QMenu>
|
||||||
|
|
|
@ -18,10 +18,10 @@ import VnInput from 'components/common/VnInput.vue';
|
||||||
|
|
||||||
const emit = defineEmits(['onFetch']);
|
const emit = defineEmits(['onFetch']);
|
||||||
|
|
||||||
const originalAttrs = useAttrs();
|
const $attrs = useAttrs();
|
||||||
const $attrs = computed(() => {
|
|
||||||
const { required, deletable, ...rest } = originalAttrs;
|
const isRequired = computed(() => {
|
||||||
return rest;
|
return Object.keys($attrs).includes('required');
|
||||||
});
|
});
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
|
@ -40,11 +40,6 @@ const quasar = useQuasar();
|
||||||
const newNote = reactive({ text: null, observationTypeFk: null });
|
const newNote = reactive({ text: null, observationTypeFk: null });
|
||||||
const observationTypes = ref([]);
|
const observationTypes = ref([]);
|
||||||
const vnPaginateRef = ref();
|
const vnPaginateRef = ref();
|
||||||
|
|
||||||
const defaultObservationType = computed(() =>
|
|
||||||
observationTypes.value.find(ot => ot.code === 'salesPerson')?.id
|
|
||||||
);
|
|
||||||
|
|
||||||
let originalText;
|
let originalText;
|
||||||
|
|
||||||
function handleClick(e) {
|
function handleClick(e) {
|
||||||
|
@ -53,11 +48,6 @@ function handleClick(e) {
|
||||||
else insert();
|
else insert();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteNote(e) {
|
|
||||||
await axios.delete(`${$props.url}/${e.id}`);
|
|
||||||
await vnPaginateRef.value.fetch();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function insert() {
|
async function insert() {
|
||||||
if (!newNote.text || ($props.selectType && !newNote.observationTypeFk)) return;
|
if (!newNote.text || ($props.selectType && !newNote.observationTypeFk)) return;
|
||||||
|
|
||||||
|
@ -121,22 +111,14 @@ function fetchData([data]) {
|
||||||
originalText = data?.notes;
|
originalText = data?.notes;
|
||||||
emit('onFetch', data);
|
emit('onFetch', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleObservationTypes = (data) => {
|
|
||||||
observationTypes.value = data;
|
|
||||||
if(defaultObservationType.value) {
|
|
||||||
newNote.observationTypeFk = defaultObservationType.value;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
v-if="selectType"
|
v-if="selectType"
|
||||||
url="ObservationTypes"
|
url="ObservationTypes"
|
||||||
:filter="{ fields: ['id', 'description', 'code'] }"
|
:filter="{ fields: ['id', 'description'] }"
|
||||||
auto-load
|
auto-load
|
||||||
@on-fetch="handleObservationTypes"
|
@on-fetch="(data) => (observationTypes = data)"
|
||||||
/>
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
v-if="justInput"
|
v-if="justInput"
|
||||||
|
@ -162,7 +144,7 @@ const handleObservationTypes = (data) => {
|
||||||
v-model="newNote.observationTypeFk"
|
v-model="newNote.observationTypeFk"
|
||||||
option-label="description"
|
option-label="description"
|
||||||
style="flex: 0.15"
|
style="flex: 0.15"
|
||||||
:required="'required' in originalAttrs"
|
:required="isRequired"
|
||||||
@keyup.enter.stop="insert"
|
@keyup.enter.stop="insert"
|
||||||
/>
|
/>
|
||||||
<VnInput
|
<VnInput
|
||||||
|
@ -170,10 +152,10 @@ const handleObservationTypes = (data) => {
|
||||||
type="textarea"
|
type="textarea"
|
||||||
:label="$props.justInput && newNote.text ? '' : t('Add note here...')"
|
:label="$props.justInput && newNote.text ? '' : t('Add note here...')"
|
||||||
filled
|
filled
|
||||||
|
size="lg"
|
||||||
autogrow
|
autogrow
|
||||||
autofocus
|
|
||||||
@keyup.enter.stop="handleClick"
|
@keyup.enter.stop="handleClick"
|
||||||
:required="'required' in originalAttrs"
|
:required="isRequired"
|
||||||
clearable
|
clearable
|
||||||
>
|
>
|
||||||
<template #append>
|
<template #append>
|
||||||
|
@ -204,9 +186,10 @@ const handleObservationTypes = (data) => {
|
||||||
ref="vnPaginateRef"
|
ref="vnPaginateRef"
|
||||||
class="show"
|
class="show"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
:search-url="false"
|
search-url="notes"
|
||||||
@on-fetch="
|
@on-fetch="
|
||||||
newNote.text = '';
|
newNote.text = '';
|
||||||
|
newNote.observationTypeFk = null;
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<template #body="{ rows }">
|
<template #body="{ rows }">
|
||||||
|
@ -243,21 +226,6 @@ const handleObservationTypes = (data) => {
|
||||||
</QBadge>
|
</QBadge>
|
||||||
</div>
|
</div>
|
||||||
<span v-text="toDateHourMin(note.created)" />
|
<span v-text="toDateHourMin(note.created)" />
|
||||||
<div>
|
|
||||||
<QIcon
|
|
||||||
v-if="'deletable' in originalAttrs"
|
|
||||||
name="delete"
|
|
||||||
size="sm"
|
|
||||||
class="cursor-pointer"
|
|
||||||
color="primary"
|
|
||||||
@click="deleteNote(note)"
|
|
||||||
data-cy="notesRemoveNoteBtn"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ t('ticketNotes.removeNote') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<QCardSection class="q-pa-xs q-my-none q-py-none">
|
<QCardSection class="q-pa-xs q-my-none q-py-none">
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
import { onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
import { onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
import { useAttrs } from 'vue';
|
|
||||||
|
|
||||||
const attrs = useAttrs();
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
@ -69,7 +67,7 @@ const props = defineProps({
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
searchUrl: {
|
searchUrl: {
|
||||||
type: [String, Boolean],
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
disableInfiniteScroll: {
|
disableInfiniteScroll: {
|
||||||
|
@ -77,7 +75,7 @@ const props = defineProps({
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
mapKey: {
|
mapKey: {
|
||||||
type: [String, Boolean],
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
keyData: {
|
keyData: {
|
||||||
|
@ -117,7 +115,7 @@ onMounted(async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
arrayData.reset(['data']);
|
if (!store.keepData) arrayData.reset(['data']);
|
||||||
arrayData.resetPagination();
|
arrayData.resetPagination();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -217,7 +215,6 @@ defineExpose({
|
||||||
paginate,
|
paginate,
|
||||||
userParams: arrayData.store.userParams,
|
userParams: arrayData.store.userParams,
|
||||||
currentFilter: arrayData.store.currentFilter,
|
currentFilter: arrayData.store.currentFilter,
|
||||||
arrayData,
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,6 @@ const props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
userFilter: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
filter: {
|
filter: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null,
|
default: null,
|
||||||
|
@ -46,7 +42,7 @@ const props = defineProps({
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
type: [String, Array],
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue