Compare commits
No commits in common. "dev" and "7830-customerDesplegables" have entirely different histories.
dev
...
7830-custo
1012
CHANGELOG.md
1012
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
|
@ -4,8 +4,7 @@ def PROTECTED_BRANCH
|
||||||
|
|
||||||
def BRANCH_ENV = [
|
def BRANCH_ENV = [
|
||||||
test: 'test',
|
test: 'test',
|
||||||
master: 'production',
|
master: 'production'
|
||||||
beta: 'production'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
node {
|
node {
|
||||||
|
@ -16,8 +15,7 @@ node {
|
||||||
PROTECTED_BRANCH = [
|
PROTECTED_BRANCH = [
|
||||||
'dev',
|
'dev',
|
||||||
'test',
|
'test',
|
||||||
'master',
|
'master'
|
||||||
'beta'
|
|
||||||
].contains(env.BRANCH_NAME)
|
].contains(env.BRANCH_NAME)
|
||||||
|
|
||||||
// https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
|
// https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
const { defineConfig } = require('cypress');
|
const { defineConfig } = require('cypress');
|
||||||
// https://docs.cypress.io/app/tooling/reporters
|
|
||||||
// https://docs.cypress.io/app/references/configuration
|
|
||||||
// https://www.npmjs.com/package/cypress-mochawesome-reporter
|
|
||||||
|
|
||||||
module.exports = defineConfig({
|
module.exports = defineConfig({
|
||||||
e2e: {
|
e2e: {
|
||||||
|
@ -11,27 +8,15 @@ module.exports = defineConfig({
|
||||||
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',
|
|
||||||
video: false,
|
video: false,
|
||||||
specPattern: 'test/cypress/integration/**/*.spec.js',
|
specPattern: 'test/cypress/integration/**/*.spec.js',
|
||||||
experimentalRunAllSpecs: true,
|
experimentalRunAllSpecs: true,
|
||||||
watchForFileChanges: true,
|
|
||||||
reporter: 'cypress-mochawesome-reporter',
|
|
||||||
reporterOptions: {
|
|
||||||
charts: true,
|
|
||||||
reportPageTitle: 'Cypress Inline Reporter',
|
|
||||||
reportFilename: '[status]_[datetime]-report',
|
|
||||||
embeddedScreenshots: true,
|
|
||||||
reportDir: 'test/cypress/reports',
|
|
||||||
inlineAssets: true,
|
|
||||||
},
|
|
||||||
component: {
|
component: {
|
||||||
componentFolder: 'src',
|
componentFolder: 'src',
|
||||||
testFiles: '**/*.spec.js',
|
testFiles: '**/*.spec.js',
|
||||||
supportFile: 'test/cypress/support/unit.js',
|
supportFile: 'test/cypress/support/unit.js',
|
||||||
},
|
},
|
||||||
setupNodeEvents(on, config) {
|
setupNodeEvents(on, config) {
|
||||||
require('cypress-mochawesome-reporter/plugin')(on);
|
|
||||||
// implement node event listeners here
|
// implement node event listeners here
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
{
|
{
|
||||||
"name": "salix-front",
|
"name": "salix-front",
|
||||||
"version": "25.04.0",
|
"version": "24.34.0",
|
||||||
"description": "Salix frontend",
|
"description": "Salix frontend",
|
||||||
"productName": "Salix",
|
"productName": "Salix",
|
||||||
"author": "Verdnatura",
|
"author": "Verdnatura",
|
||||||
"private": true,
|
"private": true,
|
||||||
"packageManager": "pnpm@8.15.1",
|
"packageManager": "pnpm@8.15.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"resetDatabase": "cd ../salix && gulp docker",
|
|
||||||
"lint": "eslint --ext .js,.vue ./",
|
"lint": "eslint --ext .js,.vue ./",
|
||||||
"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": "cd ../salix && gulp docker && cd ../salix-front && cypress run",
|
||||||
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
|
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
|
||||||
"test:unit": "vitest",
|
"test:unit": "vitest",
|
||||||
"test:unit:ci": "vitest run",
|
"test:unit:ci": "vitest run",
|
||||||
|
@ -25,7 +24,6 @@
|
||||||
"axios": "^1.4.0",
|
"axios": "^1.4.0",
|
||||||
"chromium": "^3.0.3",
|
"chromium": "^3.0.3",
|
||||||
"croppie": "^2.6.5",
|
"croppie": "^2.6.5",
|
||||||
"moment": "^2.30.1",
|
|
||||||
"pinia": "^2.1.3",
|
"pinia": "^2.1.3",
|
||||||
"quasar": "^2.14.5",
|
"quasar": "^2.14.5",
|
||||||
"validator": "^13.9.0",
|
"validator": "^13.9.0",
|
||||||
|
@ -44,7 +42,6 @@
|
||||||
"@vue/test-utils": "^2.4.4",
|
"@vue/test-utils": "^2.4.4",
|
||||||
"autoprefixer": "^10.4.14",
|
"autoprefixer": "^10.4.14",
|
||||||
"cypress": "^13.6.6",
|
"cypress": "^13.6.6",
|
||||||
"cypress-mochawesome-reporter": "^3.8.2",
|
|
||||||
"eslint": "^8.41.0",
|
"eslint": "^8.41.0",
|
||||||
"eslint-config-prettier": "^8.8.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
"eslint-plugin-cypress": "^2.13.3",
|
"eslint-plugin-cypress": "^2.13.3",
|
||||||
|
|
386
pnpm-lock.yaml
386
pnpm-lock.yaml
|
@ -20,9 +20,6 @@ dependencies:
|
||||||
croppie:
|
croppie:
|
||||||
specifier: ^2.6.5
|
specifier: ^2.6.5
|
||||||
version: 2.6.5
|
version: 2.6.5
|
||||||
moment:
|
|
||||||
specifier: ^2.30.1
|
|
||||||
version: 2.30.1
|
|
||||||
pinia:
|
pinia:
|
||||||
specifier: ^2.1.3
|
specifier: ^2.1.3
|
||||||
version: 2.1.7(typescript@5.5.4)(vue@3.4.19)
|
version: 2.1.7(typescript@5.5.4)(vue@3.4.19)
|
||||||
|
@ -73,9 +70,6 @@ devDependencies:
|
||||||
cypress:
|
cypress:
|
||||||
specifier: ^13.6.6
|
specifier: ^13.6.6
|
||||||
version: 13.6.6
|
version: 13.6.6
|
||||||
cypress-mochawesome-reporter:
|
|
||||||
specifier: ^3.8.2
|
|
||||||
version: 3.8.2(cypress@13.6.6)(mocha@10.7.3)
|
|
||||||
eslint:
|
eslint:
|
||||||
specifier: ^8.41.0
|
specifier: ^8.41.0
|
||||||
version: 8.56.0
|
version: 8.56.0
|
||||||
|
@ -835,8 +829,8 @@ packages:
|
||||||
vue-i18n:
|
vue-i18n:
|
||||||
optional: true
|
optional: true
|
||||||
dependencies:
|
dependencies:
|
||||||
'@intlify/message-compiler': 11.0.0-rc.1
|
'@intlify/message-compiler': 10.0.0-beta.5
|
||||||
'@intlify/shared': 11.0.0-rc.1
|
'@intlify/shared': 10.0.0-beta.5
|
||||||
jsonc-eslint-parser: 1.4.1
|
jsonc-eslint-parser: 1.4.1
|
||||||
source-map: 0.6.1
|
source-map: 0.6.1
|
||||||
vue-i18n: 9.9.1(vue@3.4.19)
|
vue-i18n: 9.9.1(vue@3.4.19)
|
||||||
|
@ -850,11 +844,11 @@ packages:
|
||||||
'@intlify/message-compiler': 9.9.1
|
'@intlify/message-compiler': 9.9.1
|
||||||
'@intlify/shared': 9.9.1
|
'@intlify/shared': 9.9.1
|
||||||
|
|
||||||
/@intlify/message-compiler@11.0.0-rc.1:
|
/@intlify/message-compiler@10.0.0-beta.5:
|
||||||
resolution: {integrity: sha512-TGw2uBfuTFTegZf/BHtUQBEKxl7Q/dVGLoqRIdw8lFsp9g/53sYn5iD+0HxIzdYjbWL6BTJMXCPUHp9PxDTRPw==}
|
resolution: {integrity: sha512-hLLchnM1dmtSEruerkzvU9vePsLqBXz3RU85SCx/Vd12fFQiymP+/5Rn9MJ8MyfLmIOLDEx4PRh+/GkIQP6oog==}
|
||||||
engines: {node: '>= 16'}
|
engines: {node: '>= 16'}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@intlify/shared': 11.0.0-rc.1
|
'@intlify/shared': 10.0.0-beta.5
|
||||||
source-map-js: 1.0.2
|
source-map-js: 1.0.2
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
@ -865,8 +859,8 @@ packages:
|
||||||
'@intlify/shared': 9.9.1
|
'@intlify/shared': 9.9.1
|
||||||
source-map-js: 1.0.2
|
source-map-js: 1.0.2
|
||||||
|
|
||||||
/@intlify/shared@11.0.0-rc.1:
|
/@intlify/shared@10.0.0-beta.5:
|
||||||
resolution: {integrity: sha512-8tR1xe7ZEbkabTuE/tNhzpolygUn9OaYp9yuYAF4MgDNZg06C3Qny80bes2/e9/Wm3aVkPUlCw6WgU7mQd0yEg==}
|
resolution: {integrity: sha512-g9bq5Y1bOcC9qxtNk4UWtF3sXm6Wh0fGISb7vD5aLyF7yQv7ZFjxQjJzBP2GqG/9+PAGYutqjP1GGadNqFtyAQ==}
|
||||||
engines: {node: '>= 16'}
|
engines: {node: '>= 16'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
@ -890,7 +884,7 @@ packages:
|
||||||
optional: true
|
optional: true
|
||||||
dependencies:
|
dependencies:
|
||||||
'@intlify/bundle-utils': 4.0.0(vue-i18n@9.9.1)
|
'@intlify/bundle-utils': 4.0.0(vue-i18n@9.9.1)
|
||||||
'@intlify/shared': 11.0.0-rc.1
|
'@intlify/shared': 10.0.0-beta.5
|
||||||
'@rollup/pluginutils': 4.2.1
|
'@rollup/pluginutils': 4.2.1
|
||||||
'@vue/compiler-sfc': 3.4.19
|
'@vue/compiler-sfc': 3.4.19
|
||||||
debug: 4.3.4(supports-color@8.1.1)
|
debug: 4.3.4(supports-color@8.1.1)
|
||||||
|
@ -2005,10 +1999,6 @@ packages:
|
||||||
dependencies:
|
dependencies:
|
||||||
fill-range: 7.0.1
|
fill-range: 7.0.1
|
||||||
|
|
||||||
/browser-stdout@1.3.1:
|
|
||||||
resolution: {integrity: sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/browserslist@4.23.0:
|
/browserslist@4.23.0:
|
||||||
resolution: {integrity: sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==}
|
resolution: {integrity: sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==}
|
||||||
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
|
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
|
||||||
|
@ -2116,16 +2106,6 @@ packages:
|
||||||
upper-case: 1.1.3
|
upper-case: 1.1.3
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/camelcase@5.3.1:
|
|
||||||
resolution: {integrity: sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==}
|
|
||||||
engines: {node: '>=6'}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/camelcase@6.3.0:
|
|
||||||
resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==}
|
|
||||||
engines: {node: '>=10'}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/camelcase@7.0.1:
|
/camelcase@7.0.1:
|
||||||
resolution: {integrity: sha512-xlx1yCK2Oc1APsPXDL2LdlNP6+uu8OCDdhOBSVT279M/S+y75O30C2VuD8T2ogdePBBl7PfPF4504tnLgX3zfw==}
|
resolution: {integrity: sha512-xlx1yCK2Oc1APsPXDL2LdlNP6+uu8OCDdhOBSVT279M/S+y75O30C2VuD8T2ogdePBBl7PfPF4504tnLgX3zfw==}
|
||||||
engines: {node: '>=14.16'}
|
engines: {node: '>=14.16'}
|
||||||
|
@ -2275,22 +2255,6 @@ packages:
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/cliui@6.0.0:
|
|
||||||
resolution: {integrity: sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==}
|
|
||||||
dependencies:
|
|
||||||
string-width: 4.2.3
|
|
||||||
strip-ansi: 6.0.1
|
|
||||||
wrap-ansi: 6.2.0
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/cliui@7.0.4:
|
|
||||||
resolution: {integrity: sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==}
|
|
||||||
dependencies:
|
|
||||||
string-width: 4.2.3
|
|
||||||
strip-ansi: 6.0.1
|
|
||||||
wrap-ansi: 7.0.0
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/cliui@8.0.1:
|
/cliui@8.0.1:
|
||||||
resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==}
|
resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
|
@ -2594,23 +2558,6 @@ packages:
|
||||||
/csstype@3.1.3:
|
/csstype@3.1.3:
|
||||||
resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}
|
resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}
|
||||||
|
|
||||||
/cypress-mochawesome-reporter@3.8.2(cypress@13.6.6)(mocha@10.7.3):
|
|
||||||
resolution: {integrity: sha512-oJZkNzhNmN9ZD+LmZyFuPb8aWaIijyHyqYh52YOBvR6B6ckfJNCHP3A98a+/nG0H4t46CKTNwo+wNpMa4d2kjA==}
|
|
||||||
engines: {node: '>=14'}
|
|
||||||
hasBin: true
|
|
||||||
peerDependencies:
|
|
||||||
cypress: '>=6.2.0'
|
|
||||||
dependencies:
|
|
||||||
commander: 10.0.1
|
|
||||||
cypress: 13.6.6
|
|
||||||
fs-extra: 10.1.0
|
|
||||||
mochawesome: 7.1.3(mocha@10.7.3)
|
|
||||||
mochawesome-merge: 4.3.0
|
|
||||||
mochawesome-report-generator: 6.2.0
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- mocha
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/cypress@13.6.6:
|
/cypress@13.6.6:
|
||||||
resolution: {integrity: sha512-S+2S9S94611hXimH9a3EAYt81QM913ZVA03pUmGDfLTFa5gyp85NJ8dJGSlEAEmyRsYkioS1TtnWtbv/Fzt11A==}
|
resolution: {integrity: sha512-S+2S9S94611hXimH9a3EAYt81QM913ZVA03pUmGDfLTFa5gyp85NJ8dJGSlEAEmyRsYkioS1TtnWtbv/Fzt11A==}
|
||||||
engines: {node: ^16.0.0 || ^18.0.0 || >=20.0.0}
|
engines: {node: ^16.0.0 || ^18.0.0 || >=20.0.0}
|
||||||
|
@ -2680,10 +2627,6 @@ packages:
|
||||||
time-zone: 1.0.0
|
time-zone: 1.0.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/dateformat@4.6.3:
|
|
||||||
resolution: {integrity: sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/dayjs@1.11.10:
|
/dayjs@1.11.10:
|
||||||
resolution: {integrity: sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==}
|
resolution: {integrity: sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==}
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -2733,29 +2676,6 @@ packages:
|
||||||
ms: 2.1.2
|
ms: 2.1.2
|
||||||
supports-color: 8.1.1
|
supports-color: 8.1.1
|
||||||
|
|
||||||
/debug@4.3.7(supports-color@8.1.1):
|
|
||||||
resolution: {integrity: sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==}
|
|
||||||
engines: {node: '>=6.0'}
|
|
||||||
peerDependencies:
|
|
||||||
supports-color: '*'
|
|
||||||
peerDependenciesMeta:
|
|
||||||
supports-color:
|
|
||||||
optional: true
|
|
||||||
dependencies:
|
|
||||||
ms: 2.1.3
|
|
||||||
supports-color: 8.1.1
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/decamelize@1.2.0:
|
|
||||||
resolution: {integrity: sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==}
|
|
||||||
engines: {node: '>=0.10.0'}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/decamelize@4.0.0:
|
|
||||||
resolution: {integrity: sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==}
|
|
||||||
engines: {node: '>=10'}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/decompress-response@6.0.0:
|
/decompress-response@6.0.0:
|
||||||
resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==}
|
resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
|
@ -2838,11 +2758,6 @@ packages:
|
||||||
resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==}
|
resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==}
|
||||||
engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16}
|
engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16}
|
||||||
|
|
||||||
/diff@5.2.0:
|
|
||||||
resolution: {integrity: sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==}
|
|
||||||
engines: {node: '>=0.3.1'}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/doctrine@3.0.0:
|
/doctrine@3.0.0:
|
||||||
resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==}
|
resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==}
|
||||||
engines: {node: '>=6.0.0'}
|
engines: {node: '>=6.0.0'}
|
||||||
|
@ -3635,14 +3550,6 @@ packages:
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
/find-up@4.1.0:
|
|
||||||
resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==}
|
|
||||||
engines: {node: '>=8'}
|
|
||||||
dependencies:
|
|
||||||
locate-path: 5.0.0
|
|
||||||
path-exists: 4.0.0
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/find-up@5.0.0:
|
/find-up@5.0.0:
|
||||||
resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==}
|
resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
|
@ -3739,15 +3646,6 @@ packages:
|
||||||
resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==}
|
resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/fs-extra@10.1.0:
|
|
||||||
resolution: {integrity: sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==}
|
|
||||||
engines: {node: '>=12'}
|
|
||||||
dependencies:
|
|
||||||
graceful-fs: 4.2.11
|
|
||||||
jsonfile: 6.1.0
|
|
||||||
universalify: 2.0.1
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/fs-extra@11.2.0:
|
/fs-extra@11.2.0:
|
||||||
resolution: {integrity: sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==}
|
resolution: {integrity: sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==}
|
||||||
engines: {node: '>=14.14'}
|
engines: {node: '>=14.14'}
|
||||||
|
@ -3756,15 +3654,6 @@ packages:
|
||||||
jsonfile: 6.1.0
|
jsonfile: 6.1.0
|
||||||
universalify: 2.0.1
|
universalify: 2.0.1
|
||||||
|
|
||||||
/fs-extra@7.0.1:
|
|
||||||
resolution: {integrity: sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==}
|
|
||||||
engines: {node: '>=6 <7 || >=8'}
|
|
||||||
dependencies:
|
|
||||||
graceful-fs: 4.2.11
|
|
||||||
jsonfile: 4.0.0
|
|
||||||
universalify: 0.1.2
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/fs-extra@9.1.0:
|
/fs-extra@9.1.0:
|
||||||
resolution: {integrity: sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==}
|
resolution: {integrity: sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
|
@ -3786,10 +3675,6 @@ packages:
|
||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/fsu@1.1.1:
|
|
||||||
resolution: {integrity: sha512-xQVsnjJ/5pQtcKh+KjUoZGzVWn4uNkchxTF6Lwjr4Gf7nQr8fmUfhKJ62zE77+xQg9xnxi5KUps7XGs+VC986A==}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/function-bind@1.1.2:
|
/function-bind@1.1.2:
|
||||||
resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==}
|
resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==}
|
||||||
|
|
||||||
|
@ -3890,18 +3775,6 @@ packages:
|
||||||
once: 1.4.0
|
once: 1.4.0
|
||||||
path-is-absolute: 1.0.1
|
path-is-absolute: 1.0.1
|
||||||
|
|
||||||
/glob@8.1.0:
|
|
||||||
resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==}
|
|
||||||
engines: {node: '>=12'}
|
|
||||||
deprecated: Glob versions prior to v9 are no longer supported
|
|
||||||
dependencies:
|
|
||||||
fs.realpath: 1.0.0
|
|
||||||
inflight: 1.0.6
|
|
||||||
inherits: 2.0.4
|
|
||||||
minimatch: 5.1.6
|
|
||||||
once: 1.4.0
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/global-directory@4.0.1:
|
/global-directory@4.0.1:
|
||||||
resolution: {integrity: sha512-wHTUcDUoZ1H5/0iVqEudYW4/kAlN5cZ3j/bXn0Dpbizl9iaUVeWSHqiOjsgk6OW2bkLclbBjzewBz6weQ1zA2Q==}
|
resolution: {integrity: sha512-wHTUcDUoZ1H5/0iVqEudYW4/kAlN5cZ3j/bXn0Dpbizl9iaUVeWSHqiOjsgk6OW2bkLclbBjzewBz6weQ1zA2Q==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
|
@ -4316,11 +4189,6 @@ packages:
|
||||||
resolution: {integrity: sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==}
|
resolution: {integrity: sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
|
||||||
/is-plain-obj@2.1.0:
|
|
||||||
resolution: {integrity: sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==}
|
|
||||||
engines: {node: '>=8'}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/is-plain-obj@3.0.0:
|
/is-plain-obj@3.0.0:
|
||||||
resolution: {integrity: sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA==}
|
resolution: {integrity: sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
|
@ -4493,12 +4361,6 @@ packages:
|
||||||
resolution: {integrity: sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA==}
|
resolution: {integrity: sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/jsonfile@4.0.0:
|
|
||||||
resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==}
|
|
||||||
optionalDependencies:
|
|
||||||
graceful-fs: 4.2.11
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/jsonfile@6.1.0:
|
/jsonfile@6.1.0:
|
||||||
resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==}
|
resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -4590,13 +4452,6 @@ packages:
|
||||||
engines: {node: '>=14'}
|
engines: {node: '>=14'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/locate-path@5.0.0:
|
|
||||||
resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==}
|
|
||||||
engines: {node: '>=8'}
|
|
||||||
dependencies:
|
|
||||||
p-locate: 4.1.0
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/locate-path@6.0.0:
|
/locate-path@6.0.0:
|
||||||
resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==}
|
resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
|
@ -4631,26 +4486,10 @@ packages:
|
||||||
resolution: {integrity: sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==}
|
resolution: {integrity: sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/lodash.isempty@4.4.0:
|
|
||||||
resolution: {integrity: sha512-oKMuF3xEeqDltrGMfDxAPGIVMSSRv8tbRSODbrs4KGsRRLEhrW8N8Rd4DRgB2+621hY8A8XwwrTVhXWpxFvMzg==}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/lodash.isfunction@3.0.9:
|
|
||||||
resolution: {integrity: sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw==}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/lodash.isobject@3.0.2:
|
|
||||||
resolution: {integrity: sha512-3/Qptq2vr7WeJbB4KHUSKlq8Pl7ASXi3UG6CMbBm8WRtXi8+GHm7mKaU3urfpSEzWe2wCIChs6/sdocUsTKJiA==}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/lodash.isplainobject@4.0.6:
|
/lodash.isplainobject@4.0.6:
|
||||||
resolution: {integrity: sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==}
|
resolution: {integrity: sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/lodash.isstring@4.0.1:
|
|
||||||
resolution: {integrity: sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/lodash.kebabcase@4.1.1:
|
/lodash.kebabcase@4.1.1:
|
||||||
resolution: {integrity: sha512-N8XRTIMMqqDgSy4VLKPnJ/+hpGZN+PHQiJnSenYqPaVV/NCqEogTnAdZLQiGKhxX+JCs8waWq2t1XHWKOmlY8g==}
|
resolution: {integrity: sha512-N8XRTIMMqqDgSy4VLKPnJ/+hpGZN+PHQiJnSenYqPaVV/NCqEogTnAdZLQiGKhxX+JCs8waWq2t1XHWKOmlY8g==}
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -4713,13 +4552,6 @@ packages:
|
||||||
wrap-ansi: 6.2.0
|
wrap-ansi: 6.2.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/loose-envify@1.4.0:
|
|
||||||
resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==}
|
|
||||||
hasBin: true
|
|
||||||
dependencies:
|
|
||||||
js-tokens: 4.0.0
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/loupe@2.3.7:
|
/loupe@2.3.7:
|
||||||
resolution: {integrity: sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==}
|
resolution: {integrity: sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -4890,83 +4722,6 @@ packages:
|
||||||
ufo: 1.4.0
|
ufo: 1.4.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/mocha@10.7.3:
|
|
||||||
resolution: {integrity: sha512-uQWxAu44wwiACGqjbPYmjo7Lg8sFrS3dQe7PP2FQI+woptP4vZXSMcfMyFL/e1yFEeEpV4RtyTpZROOKmxis+A==}
|
|
||||||
engines: {node: '>= 14.0.0'}
|
|
||||||
hasBin: true
|
|
||||||
dependencies:
|
|
||||||
ansi-colors: 4.1.3
|
|
||||||
browser-stdout: 1.3.1
|
|
||||||
chokidar: 3.6.0
|
|
||||||
debug: 4.3.7(supports-color@8.1.1)
|
|
||||||
diff: 5.2.0
|
|
||||||
escape-string-regexp: 4.0.0
|
|
||||||
find-up: 5.0.0
|
|
||||||
glob: 8.1.0
|
|
||||||
he: 1.2.0
|
|
||||||
js-yaml: 4.1.0
|
|
||||||
log-symbols: 4.1.0
|
|
||||||
minimatch: 5.1.6
|
|
||||||
ms: 2.1.3
|
|
||||||
serialize-javascript: 6.0.2
|
|
||||||
strip-json-comments: 3.1.1
|
|
||||||
supports-color: 8.1.1
|
|
||||||
workerpool: 6.5.1
|
|
||||||
yargs: 16.2.0
|
|
||||||
yargs-parser: 20.2.9
|
|
||||||
yargs-unparser: 2.0.0
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/mochawesome-merge@4.3.0:
|
|
||||||
resolution: {integrity: sha512-1roR6g+VUlfdaRmL8dCiVpKiaUhbPVm1ZQYUM6zHX46mWk+tpsKVZR6ba98k2zc8nlPvYd71yn5gyH970pKBSw==}
|
|
||||||
engines: {node: '>=10.0.0'}
|
|
||||||
hasBin: true
|
|
||||||
dependencies:
|
|
||||||
fs-extra: 7.0.1
|
|
||||||
glob: 7.2.3
|
|
||||||
yargs: 15.4.1
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/mochawesome-report-generator@6.2.0:
|
|
||||||
resolution: {integrity: sha512-Ghw8JhQFizF0Vjbtp9B0i//+BOkV5OWcQCPpbO0NGOoxV33o+gKDYU0Pr2pGxkIHnqZ+g5mYiXF7GMNgAcDpSg==}
|
|
||||||
hasBin: true
|
|
||||||
dependencies:
|
|
||||||
chalk: 4.1.2
|
|
||||||
dateformat: 4.6.3
|
|
||||||
escape-html: 1.0.3
|
|
||||||
fs-extra: 10.1.0
|
|
||||||
fsu: 1.1.1
|
|
||||||
lodash.isfunction: 3.0.9
|
|
||||||
opener: 1.5.2
|
|
||||||
prop-types: 15.8.1
|
|
||||||
tcomb: 3.2.29
|
|
||||||
tcomb-validation: 3.4.1
|
|
||||||
validator: 13.11.0
|
|
||||||
yargs: 17.7.2
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/mochawesome@7.1.3(mocha@10.7.3):
|
|
||||||
resolution: {integrity: sha512-Vkb3jR5GZ1cXohMQQ73H3cZz7RoxGjjUo0G5hu0jLaW+0FdUxUwg3Cj29bqQdh0rFcnyV06pWmqmi5eBPnEuNQ==}
|
|
||||||
peerDependencies:
|
|
||||||
mocha: '>=7'
|
|
||||||
dependencies:
|
|
||||||
chalk: 4.1.2
|
|
||||||
diff: 5.2.0
|
|
||||||
json-stringify-safe: 5.0.1
|
|
||||||
lodash.isempty: 4.4.0
|
|
||||||
lodash.isfunction: 3.0.9
|
|
||||||
lodash.isobject: 3.0.2
|
|
||||||
lodash.isstring: 4.0.1
|
|
||||||
mocha: 10.7.3
|
|
||||||
mochawesome-report-generator: 6.2.0
|
|
||||||
strip-ansi: 6.0.1
|
|
||||||
uuid: 8.3.2
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/moment@2.30.1:
|
|
||||||
resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/ms@2.0.0:
|
/ms@2.0.0:
|
||||||
resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==}
|
resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==}
|
||||||
|
|
||||||
|
@ -5115,11 +4870,6 @@ packages:
|
||||||
is-wsl: 2.2.0
|
is-wsl: 2.2.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/opener@1.5.2:
|
|
||||||
resolution: {integrity: sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==}
|
|
||||||
hasBin: true
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/optionator@0.9.3:
|
/optionator@0.9.3:
|
||||||
resolution: {integrity: sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==}
|
resolution: {integrity: sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==}
|
||||||
engines: {node: '>= 0.8.0'}
|
engines: {node: '>= 0.8.0'}
|
||||||
|
@ -5165,13 +4915,6 @@ packages:
|
||||||
engines: {node: '>=12.20'}
|
engines: {node: '>=12.20'}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/p-limit@2.3.0:
|
|
||||||
resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==}
|
|
||||||
engines: {node: '>=6'}
|
|
||||||
dependencies:
|
|
||||||
p-try: 2.2.0
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/p-limit@3.1.0:
|
/p-limit@3.1.0:
|
||||||
resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==}
|
resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
|
@ -5186,13 +4929,6 @@ packages:
|
||||||
yocto-queue: 1.0.0
|
yocto-queue: 1.0.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/p-locate@4.1.0:
|
|
||||||
resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==}
|
|
||||||
engines: {node: '>=8'}
|
|
||||||
dependencies:
|
|
||||||
p-limit: 2.3.0
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/p-locate@5.0.0:
|
/p-locate@5.0.0:
|
||||||
resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==}
|
resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
|
@ -5214,11 +4950,6 @@ packages:
|
||||||
aggregate-error: 3.1.0
|
aggregate-error: 3.1.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/p-try@2.2.0:
|
|
||||||
resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==}
|
|
||||||
engines: {node: '>=6'}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/package-json@8.1.1:
|
/package-json@8.1.1:
|
||||||
resolution: {integrity: sha512-cbH9IAIJHNj9uXi196JVsRlt7cHKak6u/e6AkL/bkRelZ7rlL3X1YKxsZwa36xipOEKAsdtmaG6aAJoM1fx2zA==}
|
resolution: {integrity: sha512-cbH9IAIJHNj9uXi196JVsRlt7cHKak6u/e6AkL/bkRelZ7rlL3X1YKxsZwa36xipOEKAsdtmaG6aAJoM1fx2zA==}
|
||||||
engines: {node: '>=14.16'}
|
engines: {node: '>=14.16'}
|
||||||
|
@ -5408,14 +5139,6 @@ packages:
|
||||||
engines: {node: '>=0.4.0'}
|
engines: {node: '>=0.4.0'}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/prop-types@15.8.1:
|
|
||||||
resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==}
|
|
||||||
dependencies:
|
|
||||||
loose-envify: 1.4.0
|
|
||||||
object-assign: 4.1.1
|
|
||||||
react-is: 16.13.1
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/proto-list@1.2.4:
|
/proto-list@1.2.4:
|
||||||
resolution: {integrity: sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA==}
|
resolution: {integrity: sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA==}
|
||||||
|
|
||||||
|
@ -5519,10 +5242,6 @@ packages:
|
||||||
strip-json-comments: 2.0.1
|
strip-json-comments: 2.0.1
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/react-is@16.13.1:
|
|
||||||
resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/react-is@17.0.2:
|
/react-is@17.0.2:
|
||||||
resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==}
|
resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==}
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -5609,10 +5328,6 @@ packages:
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/require-main-filename@2.0.0:
|
|
||||||
resolution: {integrity: sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/requires-port@1.0.0:
|
/requires-port@1.0.0:
|
||||||
resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==}
|
resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==}
|
||||||
|
|
||||||
|
@ -5858,10 +5573,6 @@ packages:
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
/set-blocking@2.0.0:
|
|
||||||
resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/set-function-length@1.2.1:
|
/set-function-length@1.2.1:
|
||||||
resolution: {integrity: sha512-j4t6ccc+VsKwYHso+kElc5neZpjtq9EnRICFZtWyBsLojhmeF/ZBd/elqm22WJh/BziDe/SBiOeAt0m2mfLD0g==}
|
resolution: {integrity: sha512-j4t6ccc+VsKwYHso+kElc5neZpjtq9EnRICFZtWyBsLojhmeF/ZBd/elqm22WJh/BziDe/SBiOeAt0m2mfLD0g==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
|
@ -6118,16 +5829,6 @@ packages:
|
||||||
readable-stream: 3.6.2
|
readable-stream: 3.6.2
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/tcomb-validation@3.4.1:
|
|
||||||
resolution: {integrity: sha512-urVVMQOma4RXwiVCa2nM2eqrAomHROHvWPuj6UkDGz/eb5kcy0x6P0dVt6kzpUZtYMNoAqJLWmz1BPtxrtjtrA==}
|
|
||||||
dependencies:
|
|
||||||
tcomb: 3.2.29
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/tcomb@3.2.29:
|
|
||||||
resolution: {integrity: sha512-di2Hd1DB2Zfw6StGv861JoAF5h/uQVu/QJp2g8KVbtfKnoHdBQl5M32YWq6mnSYBQ1vFFrns5B1haWJL7rKaOQ==}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/text-extensions@2.4.0:
|
/text-extensions@2.4.0:
|
||||||
resolution: {integrity: sha512-te/NtwBwfiNRLf9Ijqx3T0nlqZiQ2XrrtBvu+cLL8ZRrGkO0NHTug8MYFKyoSrv/sHTaSKfilUkizV6XhxMJ3g==}
|
resolution: {integrity: sha512-te/NtwBwfiNRLf9Ijqx3T0nlqZiQ2XrrtBvu+cLL8ZRrGkO0NHTug8MYFKyoSrv/sHTaSKfilUkizV6XhxMJ3g==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
@ -6347,11 +6048,6 @@ packages:
|
||||||
crypto-random-string: 4.0.0
|
crypto-random-string: 4.0.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/universalify@0.1.2:
|
|
||||||
resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==}
|
|
||||||
engines: {node: '>= 4.0.0'}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/universalify@0.2.0:
|
/universalify@0.2.0:
|
||||||
resolution: {integrity: sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==}
|
resolution: {integrity: sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==}
|
||||||
engines: {node: '>= 4.0.0'}
|
engines: {node: '>= 4.0.0'}
|
||||||
|
@ -6441,6 +6137,7 @@ packages:
|
||||||
/validator@13.11.0:
|
/validator@13.11.0:
|
||||||
resolution: {integrity: sha512-Ii+sehpSfZy+At5nPdnyMhx78fEoPDkR2XW/zimHEL3MyGJQOCQ7WeP20jPYRz7ZCpcKLB21NxuXHF3bxjStBQ==}
|
resolution: {integrity: sha512-Ii+sehpSfZy+At5nPdnyMhx78fEoPDkR2XW/zimHEL3MyGJQOCQ7WeP20jPYRz7ZCpcKLB21NxuXHF3bxjStBQ==}
|
||||||
engines: {node: '>= 0.10'}
|
engines: {node: '>= 0.10'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/vary@1.1.2:
|
/vary@1.1.2:
|
||||||
resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==}
|
resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==}
|
||||||
|
@ -6787,10 +6484,6 @@ packages:
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/which-module@2.0.1:
|
|
||||||
resolution: {integrity: sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/which@2.0.2:
|
/which@2.0.2:
|
||||||
resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==}
|
resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==}
|
||||||
engines: {node: '>= 8'}
|
engines: {node: '>= 8'}
|
||||||
|
@ -6818,10 +6511,6 @@ packages:
|
||||||
resolution: {integrity: sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ==}
|
resolution: {integrity: sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/workerpool@6.5.1:
|
|
||||||
resolution: {integrity: sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/wrap-ansi@6.2.0:
|
/wrap-ansi@6.2.0:
|
||||||
resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==}
|
resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
@ -6870,10 +6559,6 @@ packages:
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/y18n@4.0.3:
|
|
||||||
resolution: {integrity: sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/y18n@5.0.8:
|
/y18n@5.0.8:
|
||||||
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
|
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
|
@ -6899,64 +6584,11 @@ packages:
|
||||||
engines: {node: '>= 6'}
|
engines: {node: '>= 6'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/yargs-parser@18.1.3:
|
|
||||||
resolution: {integrity: sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==}
|
|
||||||
engines: {node: '>=6'}
|
|
||||||
dependencies:
|
|
||||||
camelcase: 5.3.1
|
|
||||||
decamelize: 1.2.0
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/yargs-parser@20.2.9:
|
|
||||||
resolution: {integrity: sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==}
|
|
||||||
engines: {node: '>=10'}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/yargs-parser@21.1.1:
|
/yargs-parser@21.1.1:
|
||||||
resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==}
|
resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/yargs-unparser@2.0.0:
|
|
||||||
resolution: {integrity: sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==}
|
|
||||||
engines: {node: '>=10'}
|
|
||||||
dependencies:
|
|
||||||
camelcase: 6.3.0
|
|
||||||
decamelize: 4.0.0
|
|
||||||
flat: 5.0.2
|
|
||||||
is-plain-obj: 2.1.0
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/yargs@15.4.1:
|
|
||||||
resolution: {integrity: sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==}
|
|
||||||
engines: {node: '>=8'}
|
|
||||||
dependencies:
|
|
||||||
cliui: 6.0.0
|
|
||||||
decamelize: 1.2.0
|
|
||||||
find-up: 4.1.0
|
|
||||||
get-caller-file: 2.0.5
|
|
||||||
require-directory: 2.1.1
|
|
||||||
require-main-filename: 2.0.0
|
|
||||||
set-blocking: 2.0.0
|
|
||||||
string-width: 4.2.3
|
|
||||||
which-module: 2.0.1
|
|
||||||
y18n: 4.0.3
|
|
||||||
yargs-parser: 18.1.3
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/yargs@16.2.0:
|
|
||||||
resolution: {integrity: sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==}
|
|
||||||
engines: {node: '>=10'}
|
|
||||||
dependencies:
|
|
||||||
cliui: 7.0.4
|
|
||||||
escalade: 3.1.2
|
|
||||||
get-caller-file: 2.0.5
|
|
||||||
require-directory: 2.1.1
|
|
||||||
string-width: 4.2.3
|
|
||||||
y18n: 5.0.8
|
|
||||||
yargs-parser: 20.2.9
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/yargs@17.7.2:
|
/yargs@17.7.2:
|
||||||
resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==}
|
resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
|
|
|
@ -2,23 +2,18 @@ import axios from 'axios';
|
||||||
import { useSession } from 'src/composables/useSession';
|
import { useSession } from 'src/composables/useSession';
|
||||||
import { Router } from 'src/router';
|
import { Router } from 'src/router';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
import { useStateQueryStore } from 'src/stores/useStateQueryStore';
|
|
||||||
import { i18n } from 'src/boot/i18n';
|
|
||||||
|
|
||||||
const session = useSession();
|
const session = useSession();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
const stateQuery = useStateQueryStore();
|
|
||||||
const baseUrl = '/api/';
|
axios.defaults.baseURL = '/api/';
|
||||||
axios.defaults.baseURL = baseUrl;
|
|
||||||
const axiosNoError = axios.create({ baseURL: baseUrl });
|
|
||||||
|
|
||||||
const onRequest = (config) => {
|
const onRequest = (config) => {
|
||||||
const token = session.getToken();
|
const token = session.getToken();
|
||||||
if (token.length && !config.headers.Authorization) {
|
if (token.length && !config.headers.Authorization) {
|
||||||
config.headers.Authorization = token;
|
config.headers.Authorization = token;
|
||||||
config.headers['Accept-Language'] = i18n.global.locale.value;
|
|
||||||
}
|
}
|
||||||
stateQuery.add(config);
|
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,10 +22,10 @@ const onRequestError = (error) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onResponse = (response) => {
|
const onResponse = (response) => {
|
||||||
const config = response.config;
|
const { method } = response.config;
|
||||||
stateQuery.remove(config);
|
|
||||||
|
|
||||||
if (config.method === 'patch') {
|
const isSaveRequest = method === 'patch';
|
||||||
|
if (isSaveRequest) {
|
||||||
notify('globals.dataSaved', 'positive');
|
notify('globals.dataSaved', 'positive');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,9 +33,37 @@ const onResponse = (response) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onResponseError = (error) => {
|
const onResponseError = (error) => {
|
||||||
stateQuery.remove(error.config);
|
let message = '';
|
||||||
|
|
||||||
if (session.isLoggedIn() && error.response?.status === 401) {
|
const response = error.response;
|
||||||
|
const responseData = response && response.data;
|
||||||
|
const responseError = responseData && response.data.error;
|
||||||
|
if (responseError) {
|
||||||
|
message = responseError.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (response?.status) {
|
||||||
|
case 422:
|
||||||
|
if (error.name == 'ValidationError')
|
||||||
|
message +=
|
||||||
|
' "' +
|
||||||
|
responseError.details.context +
|
||||||
|
'.' +
|
||||||
|
Object.keys(responseError.details.codes).join(',') +
|
||||||
|
'"';
|
||||||
|
break;
|
||||||
|
case 500:
|
||||||
|
message = 'errors.statusInternalServerError';
|
||||||
|
break;
|
||||||
|
case 502:
|
||||||
|
message = 'errors.statusBadGateway';
|
||||||
|
break;
|
||||||
|
case 504:
|
||||||
|
message = 'errors.statusGatewayTimeout';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (session.isLoggedIn() && response?.status === 401) {
|
||||||
session.destroy(false);
|
session.destroy(false);
|
||||||
const hash = window.location.hash;
|
const hash = window.location.hash;
|
||||||
const url = hash.slice(1);
|
const url = hash.slice(1);
|
||||||
|
@ -49,12 +72,12 @@ const onResponseError = (error) => {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notify(message, 'negative');
|
||||||
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
};
|
};
|
||||||
|
|
||||||
axios.interceptors.request.use(onRequest, onRequestError);
|
axios.interceptors.request.use(onRequest, onRequestError);
|
||||||
axios.interceptors.response.use(onResponse, onResponseError);
|
axios.interceptors.response.use(onResponse, onResponseError);
|
||||||
axiosNoError.interceptors.request.use(onRequest);
|
|
||||||
axiosNoError.interceptors.response.use(onResponse);
|
|
||||||
|
|
||||||
export { onRequest, onResponseError, axiosNoError };
|
export { onRequest, onResponseError };
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
import { QInput } from 'quasar';
|
|
||||||
import setDefault from './setDefault';
|
|
||||||
|
|
||||||
setDefault(QInput, 'dense', true);
|
|
|
@ -1,4 +0,0 @@
|
||||||
import { QSelect } from 'quasar';
|
|
||||||
import setDefault from './setDefault';
|
|
||||||
|
|
||||||
setDefault(QSelect, 'dense', true);
|
|
|
@ -1,11 +1,9 @@
|
||||||
import { boot } from 'quasar/wrappers';
|
import { boot } from 'quasar/wrappers';
|
||||||
import { createI18n } from 'vue-i18n';
|
import { createI18n } from 'vue-i18n';
|
||||||
import messages from 'src/i18n';
|
import messages from 'src/i18n';
|
||||||
import { useState } from 'src/composables/useState';
|
|
||||||
const user = useState().getUser();
|
|
||||||
|
|
||||||
const i18n = createI18n({
|
const i18n = createI18n({
|
||||||
locale: user.value.lang || navigator.language || navigator.userLanguage,
|
locale: navigator.language || navigator.userLanguage,
|
||||||
fallbackLocale: 'en',
|
fallbackLocale: 'en',
|
||||||
globalInjection: true,
|
globalInjection: true,
|
||||||
messages,
|
messages,
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
export default {
|
|
||||||
mounted: function (el, binding) {
|
|
||||||
const shortcut = binding.value ?? '+';
|
|
||||||
|
|
||||||
const { key, ctrl, alt, callback } =
|
|
||||||
typeof shortcut === 'string'
|
|
||||||
? {
|
|
||||||
key: shortcut,
|
|
||||||
ctrl: true,
|
|
||||||
alt: true,
|
|
||||||
callback: () =>
|
|
||||||
document
|
|
||||||
.querySelector(`button[shortcut="${shortcut}"]`)
|
|
||||||
?.click(),
|
|
||||||
}
|
|
||||||
: binding.value;
|
|
||||||
|
|
||||||
const handleKeydown = (event) => {
|
|
||||||
if (event.key === key && (!ctrl || event.ctrlKey) && (!alt || event.altKey)) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Attach the event listener to the window
|
|
||||||
window.addEventListener('keydown', handleKeydown);
|
|
||||||
|
|
||||||
el._handleKeydown = handleKeydown;
|
|
||||||
},
|
|
||||||
unmounted: function (el) {
|
|
||||||
if (el._handleKeydown) {
|
|
||||||
window.removeEventListener('keydown', el._handleKeydown);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,36 +0,0 @@
|
||||||
import routes from 'src/router/modules';
|
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
|
|
||||||
let isNotified = false;
|
|
||||||
|
|
||||||
export default {
|
|
||||||
created: function () {
|
|
||||||
const router = useRouter();
|
|
||||||
const keyBindingMap = routes
|
|
||||||
.filter((route) => route.meta.keyBinding)
|
|
||||||
.reduce((map, route) => {
|
|
||||||
map['Key' + route.meta.keyBinding.toUpperCase()] = route.path;
|
|
||||||
return map;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
const handleKeyDown = (event) => {
|
|
||||||
const { ctrlKey, altKey, code } = event;
|
|
||||||
|
|
||||||
if (ctrlKey && altKey && keyBindingMap[code] && !isNotified) {
|
|
||||||
event.preventDefault();
|
|
||||||
router.push(keyBindingMap[code]);
|
|
||||||
isNotified = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleKeyUp = (event) => {
|
|
||||||
const { ctrlKey, altKey } = event;
|
|
||||||
if (!ctrlKey || !altKey) {
|
|
||||||
isNotified = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
window.addEventListener('keydown', handleKeyDown);
|
|
||||||
window.addEventListener('keyup', handleKeyUp);
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,51 +1,30 @@
|
||||||
function focusFirstInput(input) {
|
import { getCurrentInstance } from 'vue';
|
||||||
input.focus();
|
|
||||||
}
|
|
||||||
export default {
|
export default {
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
const that = this;
|
const vm = getCurrentInstance();
|
||||||
|
if (vm.type.name === 'QForm') {
|
||||||
const form = document.querySelector('.q-form#formModel');
|
if (!['searchbarForm', 'filterPanelForm'].includes(this.$el?.id)) {
|
||||||
if (!form) return;
|
// TODO: AUTOFOCUS IS NOT FOCUSING
|
||||||
try {
|
const that = this;
|
||||||
const inputsFormCard = form.querySelectorAll(
|
this.$el.addEventListener('keyup', function (evt) {
|
||||||
`input:not([disabled]):not([type="checkbox"])`
|
if (evt.key === 'Enter') {
|
||||||
);
|
const input = evt.target;
|
||||||
if (inputsFormCard.length) {
|
if (input.type == 'textarea' && evt.shiftKey) {
|
||||||
focusFirstInput(inputsFormCard[0]);
|
evt.preventDefault();
|
||||||
|
let { selectionStart, selectionEnd } = input;
|
||||||
|
input.value =
|
||||||
|
input.value.substring(0, selectionStart) +
|
||||||
|
'\n' +
|
||||||
|
input.value.substring(selectionEnd);
|
||||||
|
selectionStart = selectionEnd = selectionStart + 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
evt.preventDefault();
|
||||||
|
that.onSubmit();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
const textareas = document.querySelectorAll(
|
|
||||||
'textarea:not([disabled]), [contenteditable]:not([disabled])'
|
|
||||||
);
|
|
||||||
if (textareas.length) {
|
|
||||||
focusFirstInput(textareas[textareas.length - 1]);
|
|
||||||
}
|
|
||||||
const inputs = document.querySelectorAll(
|
|
||||||
'form#formModel input:not([disabled]):not([type="checkbox"])'
|
|
||||||
);
|
|
||||||
const input = inputs[0];
|
|
||||||
if (!input) return;
|
|
||||||
|
|
||||||
focusFirstInput(input);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
}
|
||||||
form.addEventListener('keyup', function (evt) {
|
|
||||||
if (evt.key === 'Enter' && !that.$attrs['prevent-submit']) {
|
|
||||||
const input = evt.target;
|
|
||||||
if (input.type == 'textarea' && evt.shiftKey) {
|
|
||||||
evt.preventDefault();
|
|
||||||
let { selectionStart, selectionEnd } = input;
|
|
||||||
input.value =
|
|
||||||
input.value.substring(0, selectionStart) +
|
|
||||||
'\n' +
|
|
||||||
input.value.substring(selectionEnd);
|
|
||||||
selectionStart = selectionEnd = selectionStart + 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
evt.preventDefault();
|
|
||||||
that.onSubmit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1 @@
|
||||||
export * from './defaults/qTable';
|
export * from './defaults/qTable';
|
||||||
export * from './defaults/qInput';
|
|
||||||
export * from './defaults/qSelect';
|
|
||||||
|
|
|
@ -1,54 +1,6 @@
|
||||||
import axios from 'axios';
|
|
||||||
import { boot } from 'quasar/wrappers';
|
import { boot } from 'quasar/wrappers';
|
||||||
import qFormMixin from './qformMixin';
|
import qFormMixin from './qformMixin';
|
||||||
import keyShortcut from './keyShortcut';
|
|
||||||
import { QForm } from 'quasar';
|
|
||||||
import { QLayout } from 'quasar';
|
|
||||||
import mainShortcutMixin from './mainShortcutMixin';
|
|
||||||
import { useCau } from 'src/composables/useCau';
|
|
||||||
|
|
||||||
export default boot(({ app }) => {
|
export default boot(({ app }) => {
|
||||||
QForm.mixins = [qFormMixin];
|
app.mixin(qFormMixin);
|
||||||
QLayout.mixins = [mainShortcutMixin];
|
|
||||||
|
|
||||||
app.directive('shortcut', keyShortcut);
|
|
||||||
app.config.errorHandler = async (error) => {
|
|
||||||
let message;
|
|
||||||
const response = error.response;
|
|
||||||
const responseData = response?.data;
|
|
||||||
const responseError = responseData && response.data.error;
|
|
||||||
if (responseError) {
|
|
||||||
message = responseError.message;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (response?.status) {
|
|
||||||
case 422:
|
|
||||||
if (error.name == 'ValidationError')
|
|
||||||
message +=
|
|
||||||
' "' +
|
|
||||||
responseError.details.context +
|
|
||||||
'.' +
|
|
||||||
Object.keys(responseError.details.codes).join(',') +
|
|
||||||
'"';
|
|
||||||
break;
|
|
||||||
case 500:
|
|
||||||
message = 'errors.statusInternalServerError';
|
|
||||||
break;
|
|
||||||
case 502:
|
|
||||||
message = 'errors.statusBadGateway';
|
|
||||||
break;
|
|
||||||
case 504:
|
|
||||||
message = 'errors.statusGatewayTimeout';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.error(error);
|
|
||||||
if (error instanceof axios.CanceledError) {
|
|
||||||
const env = process.env.NODE_ENV;
|
|
||||||
if (env && env !== 'development') return;
|
|
||||||
message = 'Duplicate request';
|
|
||||||
}
|
|
||||||
|
|
||||||
await useCau(response, message);
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, ref, onMounted, nextTick, computed } from 'vue';
|
import { reactive, ref, onMounted, nextTick } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
|
||||||
|
@ -7,29 +7,27 @@ import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
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 FormModelPopup from './FormModelPopup.vue';
|
import FormModelPopup from './FormModelPopup.vue';
|
||||||
import { useState } from 'src/composables/useState';
|
|
||||||
|
defineProps({ showEntityField: { type: Boolean, default: true } });
|
||||||
|
|
||||||
const emit = defineEmits(['onDataSaved']);
|
const emit = defineEmits(['onDataSaved']);
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const bicInputRef = ref(null);
|
const bicInputRef = ref(null);
|
||||||
const state = useState();
|
const bankEntityFormData = reactive({
|
||||||
|
name: null,
|
||||||
const customer = computed(() => state.get('customer'));
|
bic: null,
|
||||||
|
countryFk: null,
|
||||||
|
id: null,
|
||||||
|
});
|
||||||
|
|
||||||
const countriesFilter = {
|
const countriesFilter = {
|
||||||
fields: ['id', 'name', 'code'],
|
fields: ['id', 'name', 'code'],
|
||||||
};
|
};
|
||||||
|
|
||||||
const bankEntityFormData = reactive({
|
|
||||||
name: null,
|
|
||||||
bic: null,
|
|
||||||
countryFk: customer.value?.countryFk,
|
|
||||||
});
|
|
||||||
|
|
||||||
const countriesOptions = ref([]);
|
const countriesOptions = ref([]);
|
||||||
|
|
||||||
const onDataSaved = (...args) => {
|
const onDataSaved = (formData, requestResponse) => {
|
||||||
emit('onDataSaved', ...args);
|
emit('onDataSaved', formData, requestResponse);
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
@ -41,6 +39,7 @@ onMounted(async () => {
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
url="Countries"
|
url="Countries"
|
||||||
|
:filter="countriesFilter"
|
||||||
auto-load
|
auto-load
|
||||||
@on-fetch="(data) => (countriesOptions = data)"
|
@on-fetch="(data) => (countriesOptions = data)"
|
||||||
/>
|
/>
|
||||||
|
@ -50,7 +49,6 @@ onMounted(async () => {
|
||||||
:title="t('title')"
|
:title="t('title')"
|
||||||
:subtitle="t('subtitle')"
|
:subtitle="t('subtitle')"
|
||||||
:form-initial-data="bankEntityFormData"
|
:form-initial-data="bankEntityFormData"
|
||||||
:filter="countriesFilter"
|
|
||||||
@on-data-saved="onDataSaved"
|
@on-data-saved="onDataSaved"
|
||||||
>
|
>
|
||||||
<template #form-inputs="{ data, validate }">
|
<template #form-inputs="{ data, validate }">
|
||||||
|
@ -82,13 +80,7 @@ onMounted(async () => {
|
||||||
:rules="validate('bankEntity.countryFk')"
|
:rules="validate('bankEntity.countryFk')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div v-if="showEntityField" class="col">
|
||||||
v-if="
|
|
||||||
countriesOptions.find((c) => c.id === data.countryFk)?.code ==
|
|
||||||
'ES'
|
|
||||||
"
|
|
||||||
class="col"
|
|
||||||
>
|
|
||||||
<VnInput
|
<VnInput
|
||||||
:label="t('id')"
|
:label="t('id')"
|
||||||
v-model="data.id"
|
v-model="data.id"
|
||||||
|
|
|
@ -0,0 +1,155 @@
|
||||||
|
<script setup>
|
||||||
|
import { reactive, ref, computed } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
import FetchData from 'components/FetchData.vue';
|
||||||
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
import FormModelPopup from './FormModelPopup.vue';
|
||||||
|
import VnInputDate from './common/VnInputDate.vue';
|
||||||
|
|
||||||
|
const emit = defineEmits(['onDataSaved']);
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const manualInvoiceFormData = reactive({
|
||||||
|
maxShipped: Date.vnNew(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const formModelPopupRef = ref();
|
||||||
|
const invoiceOutSerialsOptions = ref([]);
|
||||||
|
const taxAreasOptions = ref([]);
|
||||||
|
const ticketsOptions = ref([]);
|
||||||
|
const clientsOptions = ref([]);
|
||||||
|
const isLoading = computed(() => formModelPopupRef.value?.isLoading);
|
||||||
|
|
||||||
|
const onDataSaved = async (formData, requestResponse) => {
|
||||||
|
emit('onDataSaved', formData, requestResponse);
|
||||||
|
if (requestResponse && requestResponse.id)
|
||||||
|
router.push({ name: 'InvoiceOutSummary', params: { id: requestResponse.id } });
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<FetchData
|
||||||
|
url="InvoiceOutSerials"
|
||||||
|
:filter="{ where: { code: { neq: 'R' } }, order: ['code'] }"
|
||||||
|
@on-fetch="(data) => (invoiceOutSerialsOptions = data)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
url="TaxAreas"
|
||||||
|
:filter="{ order: ['code'] }"
|
||||||
|
@on-fetch="(data) => (taxAreasOptions = data)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
|
<FormModelPopup
|
||||||
|
ref="formModelPopupRef"
|
||||||
|
:title="t('Create manual invoice')"
|
||||||
|
url-create="InvoiceOuts/createManualInvoice"
|
||||||
|
model="invoiceOut"
|
||||||
|
:form-initial-data="manualInvoiceFormData"
|
||||||
|
@on-data-saved="onDataSaved"
|
||||||
|
>
|
||||||
|
<template #form-inputs="{ data }">
|
||||||
|
<span v-if="isLoading" class="text-primary invoicing-text">
|
||||||
|
<QIcon name="warning" class="fill-icon q-mr-sm" size="md" />
|
||||||
|
{{ t('Invoicing in progress...') }}
|
||||||
|
</span>
|
||||||
|
<VnRow>
|
||||||
|
<VnSelect
|
||||||
|
:label="t('Ticket')"
|
||||||
|
:options="ticketsOptions"
|
||||||
|
hide-selected
|
||||||
|
option-label="id"
|
||||||
|
option-value="id"
|
||||||
|
v-model="data.ticketFk"
|
||||||
|
@update:model-value="data.clientFk = null"
|
||||||
|
url="Tickets"
|
||||||
|
:where="{ refFk: null }"
|
||||||
|
:fields="['id', 'nickname']"
|
||||||
|
:filter-options="{ order: 'shipped DESC' }"
|
||||||
|
>
|
||||||
|
<template #option="scope">
|
||||||
|
<QItem v-bind="scope.itemProps">
|
||||||
|
<QItemSection>
|
||||||
|
<QItemLabel> #{{ scope.opt?.id }} </QItemLabel>
|
||||||
|
<QItemLabel caption>{{ scope.opt?.nickname }}</QItemLabel>
|
||||||
|
</QItemSection>
|
||||||
|
</QItem>
|
||||||
|
</template>
|
||||||
|
</VnSelect>
|
||||||
|
<span class="row items-center" style="max-width: max-content">{{
|
||||||
|
t('Or')
|
||||||
|
}}</span>
|
||||||
|
<VnSelect
|
||||||
|
:label="t('Client')"
|
||||||
|
:options="clientsOptions"
|
||||||
|
hide-selected
|
||||||
|
option-label="name"
|
||||||
|
option-value="id"
|
||||||
|
v-model="data.clientFk"
|
||||||
|
@update:model-value="data.ticketFk = null"
|
||||||
|
url="Clients"
|
||||||
|
:fields="['id', 'name']"
|
||||||
|
:filter-options="{ order: 'name ASC' }"
|
||||||
|
/>
|
||||||
|
<VnInputDate :label="t('Max date')" v-model="data.maxShipped" />
|
||||||
|
</VnRow>
|
||||||
|
<VnRow>
|
||||||
|
<VnSelect
|
||||||
|
:label="t('Serial')"
|
||||||
|
:options="invoiceOutSerialsOptions"
|
||||||
|
hide-selected
|
||||||
|
option-label="description"
|
||||||
|
option-value="code"
|
||||||
|
v-model="data.serial"
|
||||||
|
/>
|
||||||
|
<VnSelect
|
||||||
|
:label="t('Area')"
|
||||||
|
:options="taxAreasOptions"
|
||||||
|
hide-selected
|
||||||
|
option-label="code"
|
||||||
|
option-value="code"
|
||||||
|
v-model="data.taxArea"
|
||||||
|
/>
|
||||||
|
</VnRow>
|
||||||
|
<VnRow>
|
||||||
|
<VnInput
|
||||||
|
:label="t('Reference')"
|
||||||
|
type="textarea"
|
||||||
|
v-model="data.reference"
|
||||||
|
fill-input
|
||||||
|
autogrow
|
||||||
|
/>
|
||||||
|
</VnRow>
|
||||||
|
</template>
|
||||||
|
</FormModelPopup>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.invoicing-text {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: $primary;
|
||||||
|
font-size: 24px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<i18n>
|
||||||
|
es:
|
||||||
|
Create manual invoice: Crear factura manual
|
||||||
|
Ticket: Ticket
|
||||||
|
Client: Cliente
|
||||||
|
Max date: Fecha límite
|
||||||
|
Serial: Serie
|
||||||
|
Area: Area
|
||||||
|
Reference: Referencia
|
||||||
|
Or: O
|
||||||
|
Invoicing in progress...: Facturación en progreso...
|
||||||
|
</i18n>
|
|
@ -1,38 +1,35 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
import FetchData from 'components/FetchData.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import VnSelectProvince from 'components/VnSelectProvince.vue';
|
import VnSelectProvince from 'components/VnSelectProvince.vue';
|
||||||
import VnInput from 'components/common/VnInput.vue';
|
import VnInput from 'components/common/VnInput.vue';
|
||||||
import FormModelPopup from './FormModelPopup.vue';
|
import FormModelPopup from './FormModelPopup.vue';
|
||||||
|
|
||||||
const emit = defineEmits(['onDataSaved']);
|
const emit = defineEmits(['onDataSaved']);
|
||||||
const $props = defineProps({
|
|
||||||
countryFk: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
provinceSelected: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const cityFormData = ref({
|
const cityFormData = reactive({
|
||||||
name: null,
|
name: null,
|
||||||
provinceFk: null,
|
provinceFk: null,
|
||||||
});
|
});
|
||||||
onMounted(() => {
|
|
||||||
cityFormData.value.provinceFk = $props.provinceSelected;
|
const provincesOptions = ref([]);
|
||||||
});
|
|
||||||
const onDataSaved = (...args) => {
|
const onDataSaved = (...args) => {
|
||||||
emit('onDataSaved', ...args);
|
emit('onDataSaved', ...args);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<FetchData
|
||||||
|
@on-fetch="(data) => (provincesOptions = data)"
|
||||||
|
auto-load
|
||||||
|
url="Provinces"
|
||||||
|
/>
|
||||||
<FormModelPopup
|
<FormModelPopup
|
||||||
:title="t('New city')"
|
:title="t('New city')"
|
||||||
:subtitle="t('Please, ensure you put the correct data!')"
|
:subtitle="t('Please, ensure you put the correct data!')"
|
||||||
|
@ -40,7 +37,6 @@ const onDataSaved = (...args) => {
|
||||||
url-create="towns"
|
url-create="towns"
|
||||||
model="city"
|
model="city"
|
||||||
@on-data-saved="onDataSaved"
|
@on-data-saved="onDataSaved"
|
||||||
data-cy="newCityForm"
|
|
||||||
>
|
>
|
||||||
<template #form-inputs="{ data, validate }">
|
<template #form-inputs="{ data, validate }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
|
@ -48,16 +44,8 @@ const onDataSaved = (...args) => {
|
||||||
:label="t('Name')"
|
:label="t('Name')"
|
||||||
v-model="data.name"
|
v-model="data.name"
|
||||||
:rules="validate('city.name')"
|
:rules="validate('city.name')"
|
||||||
required
|
|
||||||
data-cy="cityName"
|
|
||||||
/>
|
|
||||||
<VnSelectProvince
|
|
||||||
:province-selected="$props.provinceSelected"
|
|
||||||
:country-fk="$props.countryFk"
|
|
||||||
v-model="data.provinceFk"
|
|
||||||
required
|
|
||||||
data-cy="provinceCity"
|
|
||||||
/>
|
/>
|
||||||
|
<VnSelectProvince v-model="data.provinceFk" />
|
||||||
</VnRow>
|
</VnRow>
|
||||||
</template>
|
</template>
|
||||||
</FormModelPopup>
|
</FormModelPopup>
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
import FormModelPopup from './FormModelPopup.vue';
|
|
||||||
|
|
||||||
const emit = defineEmits(['onDataSaved']);
|
|
||||||
const { t } = useI18n();
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<FormModelPopup
|
|
||||||
url-create="Expenses"
|
|
||||||
model="Expense"
|
|
||||||
:title="t('New expense')"
|
|
||||||
:form-initial-data="{ id: null, isWithheld: false, name: null }"
|
|
||||||
@on-data-saved="emit('onDataSaved', $event)"
|
|
||||||
>
|
|
||||||
<template #form-inputs="{ data, validate }">
|
|
||||||
<VnRow>
|
|
||||||
<VnInput
|
|
||||||
:label="`${t('globals.code')}`"
|
|
||||||
v-model="data.id"
|
|
||||||
:required="true"
|
|
||||||
:rules="validate('expense.code')"
|
|
||||||
/>
|
|
||||||
<QCheckbox
|
|
||||||
dense
|
|
||||||
size="sm"
|
|
||||||
:label="`${t('It\'s a withholding')}`"
|
|
||||||
v-model="data.isWithheld"
|
|
||||||
:rules="validate('expense.isWithheld')"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow>
|
|
||||||
<VnInput
|
|
||||||
:label="`${t('globals.description')}`"
|
|
||||||
v-model="data.name"
|
|
||||||
:required="true"
|
|
||||||
:rules="validate('expense.description')"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
</template>
|
|
||||||
</FormModelPopup>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
New expense: Nuevo gasto
|
|
||||||
It's a withholding: Es una retención
|
|
||||||
</i18n>
|
|
|
@ -21,14 +21,11 @@ const postcodeFormData = reactive({
|
||||||
provinceFk: null,
|
provinceFk: null,
|
||||||
townFk: null,
|
townFk: null,
|
||||||
});
|
});
|
||||||
const townsFetchDataRef = ref(false);
|
|
||||||
const townFilter = ref({});
|
|
||||||
|
|
||||||
const countriesRef = ref(false);
|
const provincesFetchDataRef = ref(null);
|
||||||
|
const countriesOptions = ref([]);
|
||||||
const provincesOptions = ref([]);
|
const provincesOptions = ref([]);
|
||||||
const townsOptions = ref([]);
|
|
||||||
const town = ref({});
|
const town = ref({});
|
||||||
const countryFilter = ref({});
|
|
||||||
|
|
||||||
function onDataSaved(formData) {
|
function onDataSaved(formData) {
|
||||||
const newPostcode = {
|
const newPostcode = {
|
||||||
|
@ -40,90 +37,50 @@ function onDataSaved(formData) {
|
||||||
({ id }) => id === formData.provinceFk
|
({ id }) => id === formData.provinceFk
|
||||||
);
|
);
|
||||||
newPostcode.province = provinceObject?.name;
|
newPostcode.province = provinceObject?.name;
|
||||||
const countryObject = countriesRef.value.opts.find(
|
const countryObject = countriesOptions.value.find(
|
||||||
({ id }) => id === formData.countryFk
|
({ id }) => id === formData.countryFk
|
||||||
);
|
);
|
||||||
newPostcode.country = countryObject?.name;
|
newPostcode.country = countryObject?.name;
|
||||||
emit('onDataSaved', newPostcode);
|
emit('onDataSaved', newPostcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setCountry(countryFk, data) {
|
|
||||||
data.townFk = null;
|
|
||||||
data.provinceFk = null;
|
|
||||||
data.countryFk = countryFk;
|
|
||||||
await fetchTowns();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Province
|
|
||||||
async function setProvince(id, data) {
|
|
||||||
if (data.provinceFk === id) return;
|
|
||||||
const newProvince = provincesOptions.value.find((province) => province.id == id);
|
|
||||||
if (newProvince) data.countryFk = newProvince.countryFk;
|
|
||||||
postcodeFormData.provinceFk = id;
|
|
||||||
await fetchTowns();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onProvinceCreated(data) {
|
|
||||||
postcodeFormData.provinceFk = data.id;
|
|
||||||
}
|
|
||||||
function provinceByCountry(countryFk = postcodeFormData.countryFk) {
|
|
||||||
return provincesOptions.value
|
|
||||||
.filter((province) => province.countryFk === countryFk)
|
|
||||||
.map(({ id }) => id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Town
|
|
||||||
async function handleTowns(data) {
|
|
||||||
townsOptions.value = data;
|
|
||||||
}
|
|
||||||
function setTown(newTown, data) {
|
|
||||||
town.value = newTown;
|
|
||||||
data.provinceFk = newTown?.provinceFk ?? newTown;
|
|
||||||
data.countryFk = newTown?.province?.countryFk ?? newTown;
|
|
||||||
}
|
|
||||||
async function onCityCreated(newTown, formData) {
|
async function onCityCreated(newTown, formData) {
|
||||||
|
await provincesFetchDataRef.value.fetch();
|
||||||
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 fetchTowns(countryFk = postcodeFormData.countryFk) {
|
|
||||||
if (!countryFk) return;
|
function setTown(newTown, data) {
|
||||||
const provinces = postcodeFormData.provinceFk
|
if (!newTown) return;
|
||||||
? [postcodeFormData.provinceFk]
|
town.value = newTown;
|
||||||
: provinceByCountry();
|
data.provinceFk = newTown.provinceFk;
|
||||||
townFilter.value.where = {
|
data.countryFk = newTown.province.countryFk;
|
||||||
provinceFk: {
|
|
||||||
inq: provinces,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
await townsFetchDataRef.value?.fetch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function filterTowns(name) {
|
async function setProvince(id, data) {
|
||||||
if (name !== '') {
|
await provincesFetchDataRef.value.fetch();
|
||||||
townFilter.value.where = {
|
const newProvince = provincesOptions.value.find((province) => province.id == id);
|
||||||
name: {
|
if (!newProvince) return;
|
||||||
like: `%${name}%`,
|
|
||||||
},
|
data.countryFk = newProvince.countryFk;
|
||||||
};
|
|
||||||
await townsFetchDataRef.value?.fetch();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
ref="townsFetchDataRef"
|
ref="provincesFetchDataRef"
|
||||||
:sort-by="['name ASC']"
|
@on-fetch="(data) => (provincesOptions = data)"
|
||||||
:limit="30"
|
|
||||||
:filter="townFilter"
|
|
||||||
@on-fetch="handleTowns"
|
|
||||||
auto-load
|
auto-load
|
||||||
url="Towns/location"
|
url="Provinces/location"
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
@on-fetch="(data) => (countriesOptions = data)"
|
||||||
|
auto-load
|
||||||
|
url="Countries"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormModelPopup
|
<FormModelPopup
|
||||||
url-create="postcodes"
|
url-create="postcodes"
|
||||||
model="postcode"
|
model="postcode"
|
||||||
|
@ -139,24 +96,18 @@ async function filterTowns(name) {
|
||||||
:label="t('Postcode')"
|
:label="t('Postcode')"
|
||||||
v-model="data.code"
|
v-model="data.code"
|
||||||
:rules="validate('postcode.code')"
|
:rules="validate('postcode.code')"
|
||||||
clearable
|
|
||||||
required
|
|
||||||
data-cy="locationPostcode"
|
|
||||||
/>
|
/>
|
||||||
<VnSelectDialog
|
<VnSelectDialog
|
||||||
:label="t('City')"
|
:label="t('City')"
|
||||||
|
url="Towns/location"
|
||||||
@update:model-value="(value) => setTown(value, data)"
|
@update:model-value="(value) => setTown(value, data)"
|
||||||
@filter="filterTowns"
|
|
||||||
:tooltip="t('Create city')"
|
|
||||||
v-model="data.townFk"
|
v-model="data.townFk"
|
||||||
:options="townsOptions"
|
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
:rules="validate('postcode.city')"
|
:rules="validate('postcode.city')"
|
||||||
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
|
:roles-allowed-to-create="['deliveryAssistant']"
|
||||||
:emit-value="false"
|
:emit-value="false"
|
||||||
required
|
clearable
|
||||||
data-cy="locationTown"
|
|
||||||
>
|
>
|
||||||
<template #option="{ itemProps, opt }">
|
<template #option="{ itemProps, opt }">
|
||||||
<QItem v-bind="itemProps">
|
<QItem v-bind="itemProps">
|
||||||
|
@ -171,8 +122,6 @@ async function filterTowns(name) {
|
||||||
</template>
|
</template>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CreateNewCityForm
|
<CreateNewCityForm
|
||||||
:country-fk="data.countryFk"
|
|
||||||
:province-selected="data.provinceFk"
|
|
||||||
@on-data-saved="
|
@on-data-saved="
|
||||||
(_, requestResponse) =>
|
(_, requestResponse) =>
|
||||||
onCityCreated(requestResponse, data)
|
onCityCreated(requestResponse, data)
|
||||||
|
@ -183,34 +132,17 @@ async function filterTowns(name) {
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnSelectProvince
|
<VnSelectProvince
|
||||||
:country-fk="data.countryFk"
|
|
||||||
:province-selected="data.provinceFk"
|
|
||||||
@update:model-value="(value) => setProvince(value, data)"
|
@update:model-value="(value) => setProvince(value, data)"
|
||||||
@update:options="
|
|
||||||
(data) => {
|
|
||||||
provincesOptions = data;
|
|
||||||
}
|
|
||||||
"
|
|
||||||
v-model="data.provinceFk"
|
v-model="data.provinceFk"
|
||||||
@on-province-created="onProvinceCreated"
|
|
||||||
required
|
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
ref="countriesRef"
|
|
||||||
:limit="30"
|
|
||||||
:filter="countryFilter"
|
|
||||||
:sort-by="['name ASC']"
|
|
||||||
auto-load
|
|
||||||
url="Countries"
|
|
||||||
required
|
|
||||||
:label="t('Country')"
|
:label="t('Country')"
|
||||||
|
:options="countriesOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
v-model="data.countryFk"
|
v-model="data.countryFk"
|
||||||
:rules="validate('postcode.countryFk')"
|
:rules="validate('postcode.countryFk')"
|
||||||
@update:model-value="(value) => setCountry(value, data)"
|
|
||||||
data-cy="locationCountry"
|
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
</template>
|
</template>
|
||||||
|
@ -220,7 +152,6 @@ async function filterTowns(name) {
|
||||||
<i18n>
|
<i18n>
|
||||||
es:
|
es:
|
||||||
New postcode: Nuevo código postal
|
New postcode: Nuevo código postal
|
||||||
Create city: Crear población
|
|
||||||
Please, ensure you put the correct data!: ¡Por favor, asegúrese de poner los datos correctos!
|
Please, ensure you put the correct data!: ¡Por favor, asegúrese de poner los datos correctos!
|
||||||
City: Población
|
City: Población
|
||||||
Province: Provincia
|
Province: Provincia
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, reactive, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
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';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
@ -15,29 +16,23 @@ const provinceFormData = reactive({
|
||||||
name: null,
|
name: null,
|
||||||
autonomyFk: null,
|
autonomyFk: null,
|
||||||
});
|
});
|
||||||
const $props = defineProps({
|
|
||||||
countryFk: {
|
const autonomiesOptions = ref([]);
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const autonomiesRef = ref([]);
|
|
||||||
|
|
||||||
const onDataSaved = (dataSaved, requestResponse) => {
|
const onDataSaved = (dataSaved, requestResponse) => {
|
||||||
requestResponse.autonomy = autonomiesRef.value.opts.find(
|
requestResponse.autonomy = autonomiesOptions.value.find(
|
||||||
(autonomy) => autonomy.id == requestResponse.autonomyFk
|
(autonomy) => autonomy.id == requestResponse.autonomyFk
|
||||||
);
|
);
|
||||||
emit('onDataSaved', dataSaved, requestResponse);
|
emit('onDataSaved', dataSaved, requestResponse);
|
||||||
};
|
};
|
||||||
const where = computed(() => {
|
|
||||||
if (!$props.countryFk) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
return { countryFk: $props.countryFk };
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<FetchData
|
||||||
|
@on-fetch="(data) => (autonomiesOptions = data)"
|
||||||
|
auto-load
|
||||||
|
url="Autonomies/location"
|
||||||
|
/>
|
||||||
<FormModelPopup
|
<FormModelPopup
|
||||||
:title="t('New province')"
|
:title="t('New province')"
|
||||||
:subtitle="t('Please, ensure you put the correct data!')"
|
:subtitle="t('Please, ensure you put the correct data!')"
|
||||||
|
@ -52,19 +47,10 @@ const where = computed(() => {
|
||||||
:label="t('Name')"
|
:label="t('Name')"
|
||||||
v-model="data.name"
|
v-model="data.name"
|
||||||
:rules="validate('province.name')"
|
:rules="validate('province.name')"
|
||||||
required
|
|
||||||
data-cy="provinceName"
|
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
data-cy="autonomyProvince"
|
|
||||||
required
|
|
||||||
ref="autonomiesRef"
|
|
||||||
auto-load
|
|
||||||
:where="where"
|
|
||||||
url="Autonomies/location"
|
|
||||||
:sort-by="['name ASC']"
|
|
||||||
:limit="30"
|
|
||||||
:label="t('Autonomy')"
|
:label="t('Autonomy')"
|
||||||
|
:options="autonomiesOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
|
|
|
@ -38,7 +38,7 @@ const onDataSaved = (dataSaved) => {
|
||||||
@on-fetch="(data) => (warehousesOptions = data)"
|
@on-fetch="(data) => (warehousesOptions = data)"
|
||||||
auto-load
|
auto-load
|
||||||
url="Warehouses"
|
url="Warehouses"
|
||||||
:filter="{ fields: ['id', 'name'], order: 'name ASC' }"
|
:filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }"
|
||||||
/>
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
@on-fetch="(data) => (temperaturesOptions = data)"
|
@on-fetch="(data) => (temperaturesOptions = data)"
|
||||||
|
@ -50,7 +50,7 @@ const onDataSaved = (dataSaved) => {
|
||||||
model="thermograph"
|
model="thermograph"
|
||||||
:title="t('New thermograph')"
|
:title="t('New thermograph')"
|
||||||
:form-initial-data="thermographFormData"
|
:form-initial-data="thermographFormData"
|
||||||
@on-data-saved="(_, response) => onDataSaved(response)"
|
@on-data-saved="onDataSaved($event)"
|
||||||
>
|
>
|
||||||
<template #form-inputs="{ data, validate }">
|
<template #form-inputs="{ data, validate }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
|
|
|
@ -10,7 +10,6 @@ import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||||
import SkeletonTable from 'components/ui/SkeletonTable.vue';
|
import SkeletonTable from 'components/ui/SkeletonTable.vue';
|
||||||
import { tMobile } from 'src/composables/tMobile';
|
import { tMobile } from 'src/composables/tMobile';
|
||||||
import getDifferences from 'src/filters/getDifferences';
|
|
||||||
|
|
||||||
const { push } = useRouter();
|
const { push } = useRouter();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
|
@ -78,7 +77,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);
|
||||||
|
@ -95,7 +94,6 @@ defineExpose({
|
||||||
saveChanges,
|
saveChanges,
|
||||||
getChanges,
|
getChanges,
|
||||||
formData,
|
formData,
|
||||||
originalData,
|
|
||||||
vnPaginateRef,
|
vnPaginateRef,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -127,7 +125,7 @@ function resetData(data) {
|
||||||
originalData.value = JSON.parse(JSON.stringify(data));
|
originalData.value = JSON.parse(JSON.stringify(data));
|
||||||
formData.value = JSON.parse(JSON.stringify(data));
|
formData.value = JSON.parse(JSON.stringify(data));
|
||||||
|
|
||||||
if (watchChanges.value) watchChanges.value(); //destroy watcher
|
if (watchChanges.value) watchChanges.value(); //destoy watcher
|
||||||
watchChanges.value = watch(formData, () => (hasChanges.value = true), { deep: true });
|
watchChanges.value = watch(formData, () => (hasChanges.value = true), { deep: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,13 +174,14 @@ async function saveChanges(data) {
|
||||||
const changes = data || getChanges();
|
const changes = data || getChanges();
|
||||||
try {
|
try {
|
||||||
await axios.post($props.saveUrl || $props.url + '/crud', changes);
|
await axios.post($props.saveUrl || $props.url + '/crud', changes);
|
||||||
} finally {
|
} catch (e) {
|
||||||
isLoading.value = false;
|
return (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;
|
||||||
|
isLoading.value = false;
|
||||||
emit('saveChanges', data);
|
emit('saveChanges', data);
|
||||||
quasar.notify({
|
quasar.notify({
|
||||||
type: 'positive',
|
type: 'positive',
|
||||||
|
@ -190,11 +189,11 @@ async function saveChanges(data) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function insert(pushData = $props.dataRequired) {
|
async function insert() {
|
||||||
const $index = formData.value.length
|
const $index = formData.value.length
|
||||||
? formData.value[formData.value.length - 1].$index + 1
|
? formData.value[formData.value.length - 1].$index + 1
|
||||||
: 0;
|
: 0;
|
||||||
formData.value.push(Object.assign({ $index }, pushData));
|
formData.value.push(Object.assign({ $index }, $props.dataRequired));
|
||||||
hasChanges.value = true;
|
hasChanges.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,8 +234,6 @@ async function remove(data) {
|
||||||
newData = newData.filter((form) => !ids.some((id) => id == form[pk]));
|
newData = newData.filter((form) => !ids.some((id) => id == form[pk]));
|
||||||
fetch(newData);
|
fetch(newData);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
reset();
|
|
||||||
}
|
}
|
||||||
emit('update:selected', []);
|
emit('update:selected', []);
|
||||||
}
|
}
|
||||||
|
@ -249,7 +246,7 @@ function getChanges() {
|
||||||
for (const [i, row] of formData.value.entries()) {
|
for (const [i, row] of formData.value.entries()) {
|
||||||
if (!row[pk]) {
|
if (!row[pk]) {
|
||||||
creates.push(row);
|
creates.push(row);
|
||||||
} else if (originalData.value[i]) {
|
} else if (originalData.value) {
|
||||||
const data = getDifferences(originalData.value[i], row);
|
const data = getDifferences(originalData.value[i], row);
|
||||||
if (!isEmpty(data)) {
|
if (!isEmpty(data)) {
|
||||||
updates.push({
|
updates.push({
|
||||||
|
@ -268,10 +265,34 @@ function getChanges() {
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDifferences(obj1, obj2) {
|
||||||
|
let diff = {};
|
||||||
|
delete obj1.$index;
|
||||||
|
delete obj2.$index;
|
||||||
|
|
||||||
|
for (let key in obj1) {
|
||||||
|
if (obj2[key] && JSON.stringify(obj1[key]) !== JSON.stringify(obj2[key])) {
|
||||||
|
diff[key] = obj2[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let key in obj2) {
|
||||||
|
if (
|
||||||
|
obj1[key] === undefined ||
|
||||||
|
JSON.stringify(obj1[key]) !== JSON.stringify(obj2[key])
|
||||||
|
) {
|
||||||
|
diff[key] = obj2[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return diff;
|
||||||
|
}
|
||||||
|
|
||||||
function isEmpty(obj) {
|
function isEmpty(obj) {
|
||||||
if (obj == null) return true;
|
if (obj == null) return true;
|
||||||
if (Array.isArray(obj)) return !obj.length;
|
if (obj === undefined) return true;
|
||||||
return !Object.keys(obj).length;
|
if (Object.keys(obj).length === 0) return true;
|
||||||
|
|
||||||
|
if (obj.length > 0) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reload(params) {
|
async function reload(params) {
|
||||||
|
@ -371,7 +392,6 @@ watch(formUrl, async () => {
|
||||||
@click="onSubmit"
|
@click="onSubmit"
|
||||||
:disable="!hasChanges"
|
:disable="!hasChanges"
|
||||||
:title="t('globals.save')"
|
:title="t('globals.save')"
|
||||||
data-cy="crudModelDefaultSaveBtn"
|
|
||||||
/>
|
/>
|
||||||
<slot name="moreAfterActions" />
|
<slot name="moreAfterActions" />
|
||||||
</QBtnGroup>
|
</QBtnGroup>
|
||||||
|
|
|
@ -156,22 +156,26 @@ const rotateRight = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
if (!newPhoto.files && !newPhoto.url) {
|
try {
|
||||||
notify(t('Select an image'), 'negative');
|
if (!newPhoto.files && !newPhoto.url) {
|
||||||
return;
|
notify(t('Select an image'), 'negative');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
type: 'blob',
|
||||||
|
};
|
||||||
|
|
||||||
|
editor.value
|
||||||
|
.result(options)
|
||||||
|
.then((result) => {
|
||||||
|
const file = new File([result], newPhoto.files?.name || '');
|
||||||
|
newPhoto.blob = file;
|
||||||
|
})
|
||||||
|
.then(() => makeRequest());
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error uploading image');
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = {
|
|
||||||
type: 'blob',
|
|
||||||
};
|
|
||||||
|
|
||||||
editor.value
|
|
||||||
.result(options)
|
|
||||||
.then((result) => {
|
|
||||||
const file = new File([result], newPhoto.files?.name || '');
|
|
||||||
newPhoto.blob = file;
|
|
||||||
})
|
|
||||||
.then(() => makeRequest());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const makeRequest = async () => {
|
const makeRequest = async () => {
|
||||||
|
|
|
@ -51,17 +51,21 @@ const onDataSaved = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
isLoading.value = true;
|
try {
|
||||||
const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk }));
|
isLoading.value = true;
|
||||||
const payload = {
|
const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk }));
|
||||||
field: selectedField.value.field,
|
const payload = {
|
||||||
newValue: newValue.value,
|
field: selectedField.value.field,
|
||||||
lines: rowsToEdit,
|
newValue: newValue.value,
|
||||||
};
|
lines: rowsToEdit,
|
||||||
|
};
|
||||||
|
|
||||||
await axios.post($props.editUrl, payload);
|
await axios.post($props.editUrl, payload);
|
||||||
onDataSaved();
|
onDataSaved();
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error submitting table cell edit');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeForm = () => {
|
const closeForm = () => {
|
||||||
|
@ -85,14 +89,12 @@ const closeForm = () => {
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="label"
|
option-label="label"
|
||||||
v-model="selectedField"
|
v-model="selectedField"
|
||||||
data-cy="field-to-edit"
|
|
||||||
/>
|
/>
|
||||||
<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="value-to-edit"
|
|
||||||
style="width: 200px"
|
style="width: 200px"
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
|
|
@ -50,25 +50,25 @@ const loading = ref(false);
|
||||||
|
|
||||||
const tableColumns = computed(() => [
|
const tableColumns = computed(() => [
|
||||||
{
|
{
|
||||||
label: t('globals.id'),
|
label: t('entry.buys.id'),
|
||||||
name: 'id',
|
name: 'id',
|
||||||
field: 'id',
|
field: 'id',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('globals.name'),
|
label: t('entry.buys.name'),
|
||||||
name: 'name',
|
name: 'name',
|
||||||
field: 'name',
|
field: 'name',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('globals.size'),
|
label: t('entry.buys.size'),
|
||||||
name: 'size',
|
name: 'size',
|
||||||
field: 'size',
|
field: 'size',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('globals.producer'),
|
label: t('entry.buys.producer'),
|
||||||
name: 'producerName',
|
name: 'producerName',
|
||||||
field: 'producer',
|
field: 'producer',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
@ -84,30 +84,34 @@ const tableColumns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
let filter = itemFilter;
|
try {
|
||||||
const params = itemFilterParams;
|
let filter = itemFilter;
|
||||||
const where = {};
|
const params = itemFilterParams;
|
||||||
for (let key in params) {
|
const where = {};
|
||||||
const value = params[key];
|
for (let key in params) {
|
||||||
if (!value) continue;
|
const value = params[key];
|
||||||
|
if (!value) continue;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'name':
|
case 'name':
|
||||||
where[key] = { like: `%${value}%` };
|
where[key] = { like: `%${value}%` };
|
||||||
break;
|
break;
|
||||||
case 'producerFk':
|
case 'producerFk':
|
||||||
case 'typeFk':
|
case 'typeFk':
|
||||||
case 'size':
|
case 'size':
|
||||||
case 'inkFk':
|
case 'inkFk':
|
||||||
where[key] = value;
|
where[key] = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
filter.where = where;
|
||||||
filter.where = where;
|
|
||||||
|
|
||||||
const { data } = await axios.get(props.url, {
|
const { data } = await axios.get(props.url, {
|
||||||
params: { filter: JSON.stringify(filter) },
|
params: { filter: JSON.stringify(filter) },
|
||||||
});
|
});
|
||||||
tableRows.value = data;
|
tableRows.value = data;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching entries items');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeForm = () => {
|
const closeForm = () => {
|
||||||
|
@ -148,10 +152,10 @@ const selectItem = ({ id }) => {
|
||||||
</span>
|
</span>
|
||||||
<h1 class="title">{{ t('Filter item') }}</h1>
|
<h1 class="title">{{ t('Filter item') }}</h1>
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnInput :label="t('globals.name')" v-model="itemFilterParams.name" />
|
<VnInput :label="t('entry.buys.name')" v-model="itemFilterParams.name" />
|
||||||
<VnInput :label="t('entry.buys.size')" v-model="itemFilterParams.size" />
|
<VnInput :label="t('entry.buys.size')" v-model="itemFilterParams.size" />
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('globals.producer')"
|
:label="t('entry.buys.producer')"
|
||||||
:options="producersOptions"
|
:options="producersOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
|
@ -159,7 +163,7 @@ const selectItem = ({ id }) => {
|
||||||
v-model="itemFilterParams.producerFk"
|
v-model="itemFilterParams.producerFk"
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('globals.type')"
|
:label="t('entry.buys.type')"
|
||||||
:options="ItemTypesOptions"
|
:options="ItemTypesOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
|
|
|
@ -48,13 +48,13 @@ const loading = ref(false);
|
||||||
|
|
||||||
const tableColumns = computed(() => [
|
const tableColumns = computed(() => [
|
||||||
{
|
{
|
||||||
label: t('globals.id'),
|
label: t('entry.basicData.id'),
|
||||||
name: 'id',
|
name: 'id',
|
||||||
field: 'id',
|
field: 'id',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('globals.warehouseOut'),
|
label: t('entry.basicData.warehouseOut'),
|
||||||
name: 'warehouseOutFk',
|
name: 'warehouseOutFk',
|
||||||
field: 'warehouseOutFk',
|
field: 'warehouseOutFk',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
@ -62,7 +62,7 @@ const tableColumns = computed(() => [
|
||||||
warehousesOptions.value.find((warehouse) => warehouse.id === val).name,
|
warehousesOptions.value.find((warehouse) => warehouse.id === val).name,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('globals.warehouseIn'),
|
label: t('entry.basicData.warehouseIn'),
|
||||||
name: 'warehouseInFk',
|
name: 'warehouseInFk',
|
||||||
field: 'warehouseInFk',
|
field: 'warehouseInFk',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
@ -70,14 +70,14 @@ const tableColumns = computed(() => [
|
||||||
warehousesOptions.value.find((warehouse) => warehouse.id === val).name,
|
warehousesOptions.value.find((warehouse) => warehouse.id === val).name,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('globals.shipped'),
|
label: t('entry.basicData.shipped'),
|
||||||
name: 'shipped',
|
name: 'shipped',
|
||||||
field: 'shipped',
|
field: 'shipped',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
format: (val) => toDate(val),
|
format: (val) => toDate(val),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('globals.landed'),
|
label: t('entry.basicData.landed'),
|
||||||
name: 'landed',
|
name: 'landed',
|
||||||
field: 'landed',
|
field: 'landed',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
@ -86,28 +86,32 @@ const tableColumns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
let filter = travelFilter;
|
try {
|
||||||
const params = travelFilterParams;
|
let filter = travelFilter;
|
||||||
const where = {};
|
const params = travelFilterParams;
|
||||||
for (let key in params) {
|
const where = {};
|
||||||
const value = params[key];
|
for (let key in params) {
|
||||||
if (!value) continue;
|
const value = params[key];
|
||||||
|
if (!value) continue;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'agencyModeFk':
|
case 'agencyModeFk':
|
||||||
case 'warehouseInFk':
|
case 'warehouseInFk':
|
||||||
case 'warehouseOutFk':
|
case 'warehouseOutFk':
|
||||||
case 'shipped':
|
case 'shipped':
|
||||||
case 'landed':
|
case 'landed':
|
||||||
where[key] = value;
|
where[key] = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
filter.where = where;
|
filter.where = where;
|
||||||
const { data } = await axios.get('Travels', {
|
const { data } = await axios.get('Travels', {
|
||||||
params: { filter: JSON.stringify(filter) },
|
params: { filter: JSON.stringify(filter) },
|
||||||
});
|
});
|
||||||
tableRows.value = data;
|
tableRows.value = data;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching travels');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeForm = () => {
|
const closeForm = () => {
|
||||||
|
@ -142,7 +146,7 @@ const selectTravel = ({ id }) => {
|
||||||
<h1 class="title">{{ t('Filter travels') }}</h1>
|
<h1 class="title">{{ t('Filter travels') }}</h1>
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('globals.agency')"
|
:label="t('entry.basicData.agency')"
|
||||||
:options="agenciesOptions"
|
:options="agenciesOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
|
@ -150,7 +154,7 @@ const selectTravel = ({ id }) => {
|
||||||
v-model="travelFilterParams.agencyModeFk"
|
v-model="travelFilterParams.agencyModeFk"
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('globals.warehouseOut')"
|
:label="t('entry.basicData.warehouseOut')"
|
||||||
:options="warehousesOptions"
|
:options="warehousesOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
|
@ -158,7 +162,7 @@ const selectTravel = ({ id }) => {
|
||||||
v-model="travelFilterParams.warehouseOutFk"
|
v-model="travelFilterParams.warehouseOutFk"
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('globals.warehouseIn')"
|
:label="t('entry.basicData.warehouseIn')"
|
||||||
:options="warehousesOptions"
|
:options="warehousesOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
|
@ -166,11 +170,11 @@ const selectTravel = ({ id }) => {
|
||||||
v-model="travelFilterParams.warehouseInFk"
|
v-model="travelFilterParams.warehouseInFk"
|
||||||
/>
|
/>
|
||||||
<VnInputDate
|
<VnInputDate
|
||||||
:label="t('globals.shipped')"
|
:label="t('entry.basicData.shipped')"
|
||||||
v-model="travelFilterParams.shipped"
|
v-model="travelFilterParams.shipped"
|
||||||
/>
|
/>
|
||||||
<VnInputDate
|
<VnInputDate
|
||||||
:label="t('globals.landed')"
|
:label="t('entry.basicData.landed')"
|
||||||
v-model="travelFilterParams.landed"
|
v-model="travelFilterParams.landed"
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { onMounted, onUnmounted, computed, ref, watch, nextTick } from 'vue';
|
import { onMounted, onUnmounted, computed, ref, watch, nextTick } from 'vue';
|
||||||
import { onBeforeRouteLeave, useRouter, useRoute } from 'vue-router';
|
import { onBeforeRouteLeave, useRouter } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
|
@ -12,6 +12,7 @@ import SkeletonForm from 'components/ui/SkeletonForm.vue';
|
||||||
import VnConfirm from './ui/VnConfirm.vue';
|
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 { useRoute } from 'vue-router';
|
||||||
|
|
||||||
const { push } = useRouter();
|
const { push } = useRouter();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
|
@ -21,7 +22,7 @@ const { t } = useI18n();
|
||||||
const { validate } = useValidator();
|
const { validate } = useValidator();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const myForm = ref(null);
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
url: {
|
url: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -86,14 +87,6 @@ const $props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
defaultTrim: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
maxWidth: {
|
|
||||||
type: [String, Boolean],
|
|
||||||
default: '800px',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
||||||
const modelValue = computed(
|
const modelValue = computed(
|
||||||
|
@ -109,19 +102,14 @@ const originalData = ref({});
|
||||||
const formData = computed(() => state.get(modelValue));
|
const formData = computed(() => state.get(modelValue));
|
||||||
const defaultButtons = computed(() => ({
|
const defaultButtons = computed(() => ({
|
||||||
save: {
|
save: {
|
||||||
dataCy: 'saveDefaultBtn',
|
|
||||||
color: 'primary',
|
color: 'primary',
|
||||||
icon: 'save',
|
icon: 'save',
|
||||||
label: 'globals.save',
|
label: 'globals.save',
|
||||||
click: () => myForm.value.submit(),
|
|
||||||
type: 'submit',
|
|
||||||
},
|
},
|
||||||
reset: {
|
reset: {
|
||||||
dataCy: 'resetDefaultBtn',
|
|
||||||
color: 'primary',
|
color: 'primary',
|
||||||
icon: 'restart_alt',
|
icon: 'restart_alt',
|
||||||
label: 'globals.reset',
|
label: 'globals.reset',
|
||||||
click: () => reset(),
|
|
||||||
},
|
},
|
||||||
...$props.defaultButtons,
|
...$props.defaultButtons,
|
||||||
}));
|
}));
|
||||||
|
@ -198,7 +186,6 @@ async function fetch() {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
state.set(modelValue, {});
|
state.set(modelValue, {});
|
||||||
originalData.value = {};
|
originalData.value = {};
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,10 +195,7 @@ async function save() {
|
||||||
|
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
try {
|
try {
|
||||||
formData.value = trimData(formData.value);
|
const body = $props.mapper ? $props.mapper(formData.value) : formData.value;
|
||||||
const body = $props.mapper
|
|
||||||
? $props.mapper(formData.value, originalData.value)
|
|
||||||
: formData.value;
|
|
||||||
const method = $props.urlCreate ? 'post' : 'patch';
|
const 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;
|
||||||
|
@ -225,6 +209,9 @@ async function save() {
|
||||||
updateAndEmit('onDataSaved', formData.value, response?.data);
|
updateAndEmit('onDataSaved', formData.value, response?.data);
|
||||||
if ($props.reload) await arrayData.fetch({});
|
if ($props.reload) await arrayData.fetch({});
|
||||||
hasChanges.value = false;
|
hasChanges.value = false;
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
notify('errors.writeRequest', 'negative');
|
||||||
} finally {
|
} finally {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
|
@ -266,35 +253,17 @@ function updateAndEmit(evt, val, res) {
|
||||||
emit(evt, state.get(modelValue), res);
|
emit(evt, state.get(modelValue), res);
|
||||||
}
|
}
|
||||||
|
|
||||||
function trimData(data) {
|
|
||||||
if (!$props.defaultTrim) return data;
|
|
||||||
for (const key in data) {
|
|
||||||
if (typeof data[key] == 'string') data[key] = data[key].trim();
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
save,
|
save,
|
||||||
isLoading,
|
isLoading,
|
||||||
hasChanges,
|
hasChanges,
|
||||||
reset,
|
reset,
|
||||||
fetch,
|
fetch,
|
||||||
formData,
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="column items-center full-width">
|
<div class="column items-center full-width">
|
||||||
<QForm
|
<QForm @submit="save" @reset="reset" class="q-pa-md" id="formModel">
|
||||||
ref="myForm"
|
|
||||||
v-if="formData"
|
|
||||||
@submit="save"
|
|
||||||
@reset="reset"
|
|
||||||
class="q-pa-md"
|
|
||||||
:style="maxWidth ? 'max-width: ' + maxWidth : ''"
|
|
||||||
id="formModel"
|
|
||||||
:prevent-submit="$attrs['prevent-submit']"
|
|
||||||
>
|
|
||||||
<QCard>
|
<QCard>
|
||||||
<slot
|
<slot
|
||||||
v-if="formData"
|
v-if="formData"
|
||||||
|
@ -322,12 +291,11 @@ defineExpose({
|
||||||
:color="defaultButtons.reset.color"
|
:color="defaultButtons.reset.color"
|
||||||
:icon="defaultButtons.reset.icon"
|
:icon="defaultButtons.reset.icon"
|
||||||
flat
|
flat
|
||||||
@click="defaultButtons.reset.click"
|
@click="reset"
|
||||||
:disable="!hasChanges"
|
:disable="!hasChanges"
|
||||||
:title="t(defaultButtons.reset.label)"
|
:title="t(defaultButtons.reset.label)"
|
||||||
/>
|
/>
|
||||||
<QBtnDropdown
|
<QBtnDropdown
|
||||||
data-cy="saveAndContinueDefaultBtn"
|
|
||||||
v-if="$props.goTo"
|
v-if="$props.goTo"
|
||||||
@click="saveAndGo"
|
@click="saveAndGo"
|
||||||
:label="tMobile('globals.saveAndContinue')"
|
:label="tMobile('globals.saveAndContinue')"
|
||||||
|
@ -363,7 +331,7 @@ defineExpose({
|
||||||
:label="tMobile('globals.save')"
|
:label="tMobile('globals.save')"
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="save"
|
icon="save"
|
||||||
@click="defaultButtons.save.click"
|
@click="save"
|
||||||
:disable="!hasChanges"
|
:disable="!hasChanges"
|
||||||
:title="t(defaultButtons.save.label)"
|
:title="t(defaultButtons.save.label)"
|
||||||
/>
|
/>
|
||||||
|
@ -382,6 +350,7 @@ defineExpose({
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
#formModel {
|
#formModel {
|
||||||
|
max-width: 800px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,6 @@ defineExpose({
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
@click="emit('onDataCanceled')"
|
@click="emit('onDataCanceled')"
|
||||||
v-close-popup
|
v-close-popup
|
||||||
data-cy="FormModelPopup_cancel"
|
|
||||||
z-max
|
|
||||||
/>
|
/>
|
||||||
<QBtn
|
<QBtn
|
||||||
:label="t('globals.save')"
|
:label="t('globals.save')"
|
||||||
|
@ -72,8 +70,6 @@ defineExpose({
|
||||||
class="q-ml-sm"
|
class="q-ml-sm"
|
||||||
:disabled="isLoading"
|
:disabled="isLoading"
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
data-cy="FormModelPopup_save"
|
|
||||||
z-max
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
const emit = defineEmits(['onSubmit']);
|
const emit = defineEmits(['onSubmit']);
|
||||||
|
|
||||||
const $props = defineProps({
|
defineProps({
|
||||||
title: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
|
@ -25,21 +25,16 @@ const $props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
submitOnEnter: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const closeButton = ref(null);
|
const closeButton = ref(null);
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
if ($props.submitOnEnter) {
|
emit('onSubmit');
|
||||||
emit('onSubmit');
|
closeForm();
|
||||||
closeForm();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeForm = () => {
|
const closeForm = () => {
|
||||||
|
|
|
@ -9,8 +9,6 @@ import VnSelect from 'components/common/VnSelect.vue';
|
||||||
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
|
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
|
||||||
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { getParamWhere } from 'src/filters';
|
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
@ -28,22 +26,29 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const itemCategories = ref([]);
|
||||||
|
const selectedCategoryFk = ref(null);
|
||||||
|
const selectedTypeFk = ref(null);
|
||||||
const itemTypesOptions = ref([]);
|
const itemTypesOptions = ref([]);
|
||||||
const suppliersOptions = ref([]);
|
const suppliersOptions = ref([]);
|
||||||
const tagOptions = ref([]);
|
const tagOptions = ref([]);
|
||||||
const tagValues = ref([]);
|
const tagValues = ref([]);
|
||||||
const categoryList = ref(null);
|
|
||||||
const selectedCategoryFk = ref(getParamWhere(route.query.table, 'categoryFk', false));
|
|
||||||
const selectedTypeFk = ref(getParamWhere(route.query.table, 'typeFk', false));
|
|
||||||
|
|
||||||
const selectedCategory = computed(() => {
|
const categoryList = computed(() => {
|
||||||
return (categoryList.value || []).find(
|
return (itemCategories.value || [])
|
||||||
(category) => category?.id === selectedCategoryFk.value
|
.filter((category) => category.display)
|
||||||
);
|
.map((category) => ({
|
||||||
|
...category,
|
||||||
|
icon: `vn:${(category.icon || '').split('-')[1]}`,
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const selectedCategory = computed(() =>
|
||||||
|
(itemCategories.value || []).find(
|
||||||
|
(category) => category?.id === selectedCategoryFk.value
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
const selectedType = computed(() => {
|
const selectedType = computed(() => {
|
||||||
return (itemTypesOptions.value || []).find(
|
return (itemTypesOptions.value || []).find(
|
||||||
(type) => type?.id === selectedTypeFk.value
|
(type) => type?.id === selectedTypeFk.value
|
||||||
|
@ -82,17 +87,21 @@ const applyTags = (params, search) => {
|
||||||
search();
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchItemTypes = async (id = selectedCategoryFk.value) => {
|
const fetchItemTypes = async (id) => {
|
||||||
const filter = {
|
try {
|
||||||
fields: ['id', 'name', 'categoryFk'],
|
const filter = {
|
||||||
where: { categoryFk: id },
|
fields: ['id', 'name', 'categoryFk'],
|
||||||
include: 'category',
|
where: { categoryFk: id },
|
||||||
order: 'name ASC',
|
include: 'category',
|
||||||
};
|
order: 'name ASC',
|
||||||
const { data } = await axios.get('ItemTypes', {
|
};
|
||||||
params: { filter: JSON.stringify(filter) },
|
const { data } = await axios.get('ItemTypes', {
|
||||||
});
|
params: { filter: JSON.stringify(filter) },
|
||||||
itemTypesOptions.value = data;
|
});
|
||||||
|
itemTypesOptions.value = data;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching item types', err);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getCategoryClass = (category, params) => {
|
const getCategoryClass = (category, params) => {
|
||||||
|
@ -102,38 +111,38 @@ const getCategoryClass = (category, params) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSelectedTagValues = async (tag) => {
|
const getSelectedTagValues = async (tag) => {
|
||||||
if (!tag?.selectedTag?.id) return;
|
try {
|
||||||
tag.value = null;
|
if (!tag?.selectedTag?.id) return;
|
||||||
const filter = {
|
tag.value = null;
|
||||||
fields: ['value'],
|
const filter = {
|
||||||
order: 'value ASC',
|
fields: ['value'],
|
||||||
limit: 30,
|
order: 'value ASC',
|
||||||
};
|
limit: 30,
|
||||||
|
};
|
||||||
|
|
||||||
const params = { filter: JSON.stringify(filter) };
|
const params = { filter: JSON.stringify(filter) };
|
||||||
const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, {
|
const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, {
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
tag.valueOptions = data;
|
tag.valueOptions = data;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error getting selected tag values');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeTag = (index, params, search) => {
|
const removeTag = (index, params, search) => {
|
||||||
(tagValues.value || []).splice(index, 1);
|
(tagValues.value || []).splice(index, 1);
|
||||||
applyTags(params, search);
|
applyTags(params, search);
|
||||||
};
|
};
|
||||||
const setCategoryList = (data) => {
|
|
||||||
categoryList.value = (data || [])
|
|
||||||
.filter((category) => category.display)
|
|
||||||
.map((category) => ({
|
|
||||||
...category,
|
|
||||||
icon: `vn:${(category.icon || '').split('-')[1]}`,
|
|
||||||
}));
|
|
||||||
fetchItemTypes();
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData url="ItemCategories" limit="30" auto-load @on-fetch="setCategoryList" />
|
<FetchData
|
||||||
|
url="ItemCategories"
|
||||||
|
limit="30"
|
||||||
|
auto-load
|
||||||
|
@on-fetch="(data) => (itemCategories = data)"
|
||||||
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
url="Suppliers"
|
url="Suppliers"
|
||||||
limit="30"
|
limit="30"
|
||||||
|
@ -150,8 +159,8 @@ const setCategoryList = (data) => {
|
||||||
/>
|
/>
|
||||||
<VnFilterPanel
|
<VnFilterPanel
|
||||||
:data-key="props.dataKey"
|
:data-key="props.dataKey"
|
||||||
:expr-builder="props.exprBuilder"
|
:expr-builder="exprBuilder"
|
||||||
:custom-tags="props.customTags"
|
:custom-tags="customTags"
|
||||||
>
|
>
|
||||||
<template #tags="{ tag, formatFn }">
|
<template #tags="{ tag, formatFn }">
|
||||||
<strong v-if="tag.label === 'categoryFk'">
|
<strong v-if="tag.label === 'categoryFk'">
|
||||||
|
@ -239,7 +248,7 @@ const setCategoryList = (data) => {
|
||||||
>
|
>
|
||||||
<QItemSection class="col">
|
<QItemSection class="col">
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('globals.tag')"
|
:label="t('components.itemsFilterPanel.tag')"
|
||||||
v-model="value.selectedTag"
|
v-model="value.selectedTag"
|
||||||
:options="tagOptions"
|
:options="tagOptions"
|
||||||
option-label="name"
|
option-label="name"
|
||||||
|
@ -288,12 +297,11 @@ const setCategoryList = (data) => {
|
||||||
/>
|
/>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem class="q-mt-lg">
|
<QItem class="q-mt-lg">
|
||||||
<QBtn
|
<QIcon
|
||||||
icon="add_circle"
|
name="add_circle"
|
||||||
shortcut="+"
|
|
||||||
flat
|
|
||||||
class="fill-icon-on-hover q-px-xs"
|
class="fill-icon-on-hover q-px-xs"
|
||||||
color="primary"
|
color="primary"
|
||||||
|
size="sm"
|
||||||
@click="tagValues.push({})"
|
@click="tagValues.push({})"
|
||||||
/>
|
/>
|
||||||
</QItem>
|
</QItem>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { onMounted, watch, ref, reactive, computed } from 'vue';
|
import { onMounted, ref, reactive } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { QSeparator, useQuasar } from 'quasar';
|
import { QSeparator, useQuasar } from 'quasar';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
@ -9,7 +9,6 @@ import { toLowerCamel } from 'src/filters';
|
||||||
import routes from 'src/router/modules';
|
import routes from 'src/router/modules';
|
||||||
import LeftMenuItem from './LeftMenuItem.vue';
|
import LeftMenuItem from './LeftMenuItem.vue';
|
||||||
import LeftMenuItemGroup from './LeftMenuItemGroup.vue';
|
import LeftMenuItemGroup from './LeftMenuItemGroup.vue';
|
||||||
import VnInput from './common/VnInput.vue';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
@ -22,58 +21,14 @@ const props = defineProps({
|
||||||
default: 'main',
|
default: 'main',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const initialized = ref(false);
|
|
||||||
const items = ref([]);
|
|
||||||
const expansionItemElements = reactive({});
|
const expansionItemElements = reactive({});
|
||||||
const pinnedModules = computed(() => {
|
|
||||||
const map = new Map();
|
|
||||||
items.value.forEach((item) => item.isPinned && map.set(item.name, item));
|
|
||||||
return map;
|
|
||||||
});
|
|
||||||
const search = ref(null);
|
|
||||||
|
|
||||||
const filteredItems = computed(() => {
|
|
||||||
if (!search.value) return items.value;
|
|
||||||
const normalizedSearch = normalize(search.value);
|
|
||||||
return items.value.filter((item) => {
|
|
||||||
const locale = normalize(t(item.title));
|
|
||||||
return locale.includes(normalizedSearch);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const filteredPinnedModules = computed(() => {
|
|
||||||
if (!search.value) return pinnedModules.value;
|
|
||||||
const normalizedSearch = search.value
|
|
||||||
.normalize('NFD')
|
|
||||||
.replace(/[\u0300-\u036f]/g, '')
|
|
||||||
.toLowerCase();
|
|
||||||
const map = new Map();
|
|
||||||
for (const [key, pinnedModule] of pinnedModules.value) {
|
|
||||||
const locale = t(pinnedModule.title)
|
|
||||||
.normalize('NFD')
|
|
||||||
.replace(/[\u0300-\u036f]/g, '')
|
|
||||||
.toLowerCase();
|
|
||||||
if (locale.includes(normalizedSearch)) map.set(key, pinnedModule);
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await navigation.fetchPinned();
|
await navigation.fetchPinned();
|
||||||
getRoutes();
|
getRoutes();
|
||||||
initialized.value = true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
|
||||||
() => route.matched,
|
|
||||||
() => {
|
|
||||||
if (!initialized.value) return;
|
|
||||||
items.value = [];
|
|
||||||
getRoutes();
|
|
||||||
},
|
|
||||||
{ deep: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
function findMatches(search, item) {
|
function findMatches(search, item) {
|
||||||
const matches = [];
|
const matches = [];
|
||||||
function findRoute(search, item) {
|
function findRoute(search, item) {
|
||||||
|
@ -92,16 +47,18 @@ function findMatches(search, item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addChildren(module, route, parent) {
|
function addChildren(module, route, parent) {
|
||||||
const menus = route?.meta?.menu ?? route?.menus?.[props.source]; //backwards compatible
|
if (route.menus) {
|
||||||
if (!menus) return;
|
const mainMenus = route.menus[props.source];
|
||||||
|
const matches = findMatches(mainMenus, route);
|
||||||
|
|
||||||
const matches = findMatches(menus, route);
|
for (const child of matches) {
|
||||||
|
navigation.addMenuItem(module, child, parent);
|
||||||
for (const child of matches) {
|
}
|
||||||
navigation.addMenuItem(module, child, parent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const items = ref([]);
|
||||||
|
|
||||||
function getRoutes() {
|
function getRoutes() {
|
||||||
if (props.source === 'main') {
|
if (props.source === 'main') {
|
||||||
const modules = Object.assign([], navigation.getModules().value);
|
const modules = Object.assign([], navigation.getModules().value);
|
||||||
|
@ -122,26 +79,16 @@ function getRoutes() {
|
||||||
if (props.source === 'card') {
|
if (props.source === 'card') {
|
||||||
const currentRoute = route.matched[1];
|
const currentRoute = route.matched[1];
|
||||||
const currentModule = toLowerCamel(currentRoute.name);
|
const currentModule = toLowerCamel(currentRoute.name);
|
||||||
let moduleDef = routes.find(
|
const moduleDef = routes.find(
|
||||||
(route) => toLowerCamel(route.name) === currentModule
|
(route) => toLowerCamel(route.name) === currentModule
|
||||||
);
|
);
|
||||||
|
|
||||||
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();
|
||||||
|
@ -167,58 +114,21 @@ async function togglePinned(item, event) {
|
||||||
const handleItemExpansion = (itemName) => {
|
const handleItemExpansion = (itemName) => {
|
||||||
expansionItemElements[itemName].scrollToLastElement();
|
expansionItemElements[itemName].scrollToLastElement();
|
||||||
};
|
};
|
||||||
|
|
||||||
function normalize(text) {
|
|
||||||
return text
|
|
||||||
.normalize('NFD')
|
|
||||||
.replace(/[\u0300-\u036f]/g, '')
|
|
||||||
.toLowerCase();
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<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="header">
|
||||||
<VnInput
|
<QItemSection avatar>
|
||||||
v-model="search"
|
<QIcon name="view_module" />
|
||||||
:label="t('Search modules')"
|
</QItemSection>
|
||||||
class="full-width"
|
<QItemSection> {{ t('globals.modules') }}</QItemSection>
|
||||||
filled
|
|
||||||
dense
|
|
||||||
autofocus
|
|
||||||
/>
|
|
||||||
</QItem>
|
</QItem>
|
||||||
<QSeparator />
|
<QSeparator />
|
||||||
<template v-if="filteredPinnedModules.size">
|
<template v-for="item in items" :key="item.name">
|
||||||
<LeftMenuItem
|
<template v-if="item.children">
|
||||||
v-for="[key, pinnedModule] of filteredPinnedModules"
|
|
||||||
:key="key"
|
|
||||||
:item="pinnedModule"
|
|
||||||
group="modules"
|
|
||||||
>
|
|
||||||
<template #side>
|
|
||||||
<QBtn
|
|
||||||
v-if="pinnedModule.isPinned === true"
|
|
||||||
@click="togglePinned(pinnedModule, $event)"
|
|
||||||
icon="remove_circle"
|
|
||||||
size="xs"
|
|
||||||
flat
|
|
||||||
round
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ t('components.leftMenu.removeFromPinned') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</template>
|
|
||||||
</LeftMenuItem>
|
|
||||||
<QSeparator />
|
|
||||||
</template>
|
|
||||||
<template v-for="item in filteredItems" :key="item.name">
|
|
||||||
<template
|
|
||||||
v-if="item.children && !filteredPinnedModules.has(item.name)"
|
|
||||||
>
|
|
||||||
<LeftMenuItem :item="item" group="modules">
|
<LeftMenuItem :item="item" group="modules">
|
||||||
<template #side>
|
<template #side>
|
||||||
<QBtn
|
<QBtn
|
||||||
|
@ -337,7 +247,3 @@ function normalize(text) {
|
||||||
color: var(--vn-label-color);
|
color: var(--vn-label-color);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
Search modules: Buscar módulos
|
|
||||||
</i18n>
|
|
||||||
|
|
|
@ -33,17 +33,13 @@ const itemComputed = computed(() => {
|
||||||
<QItemSection avatar v-if="!itemComputed.icon">
|
<QItemSection avatar v-if="!itemComputed.icon">
|
||||||
<QIcon name="disabled_by_default" />
|
<QIcon name="disabled_by_default" />
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QItemSection>
|
<QItemSection>{{ t(itemComputed.title) }}</QItemSection>
|
||||||
{{ t(itemComputed.title) }}
|
|
||||||
<QTooltip v-if="item.keyBinding">
|
|
||||||
{{ 'Ctrl + Alt + ' + item?.keyBinding?.toUpperCase() }}
|
|
||||||
</QTooltip>
|
|
||||||
</QItemSection>
|
|
||||||
<QItemSection side>
|
<QItemSection side>
|
||||||
<slot name="side" :item="itemComputed" />
|
<slot name="side" :item="itemComputed" />
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.q-item {
|
.q-item {
|
||||||
min-height: 5vh;
|
min-height: 5vh;
|
||||||
|
|
|
@ -3,7 +3,6 @@ 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';
|
||||||
import { useStateQueryStore } from 'src/stores/useStateQueryStore';
|
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import PinnedModules from './PinnedModules.vue';
|
import PinnedModules from './PinnedModules.vue';
|
||||||
import UserPanel from 'components/UserPanel.vue';
|
import UserPanel from 'components/UserPanel.vue';
|
||||||
|
@ -13,24 +12,19 @@ import VnAvatar from './ui/VnAvatar.vue';
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const stateQuery = useStateQueryStore();
|
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const user = state.getUser();
|
const user = state.getUser();
|
||||||
const appName = 'Lilium';
|
const appName = 'Lilium';
|
||||||
const pinnedModulesRef = ref();
|
|
||||||
|
|
||||||
onMounted(() => stateStore.setMounted());
|
onMounted(() => stateStore.setMounted());
|
||||||
|
|
||||||
|
const pinnedModulesRef = ref();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<QHeader color="white" elevated>
|
<QHeader color="white" elevated>
|
||||||
<QToolbar class="q-py-sm q-px-md">
|
<QToolbar class="q-py-sm q-px-md">
|
||||||
<QBtn
|
<QBtn @click="stateStore.toggleLeftDrawer()" icon="menu" round dense flat>
|
||||||
@click="stateStore.toggleLeftDrawer()"
|
|
||||||
icon="dock_to_right"
|
|
||||||
round
|
|
||||||
dense
|
|
||||||
flat
|
|
||||||
>
|
|
||||||
<QTooltip bottom anchor="bottom right">
|
<QTooltip bottom anchor="bottom right">
|
||||||
{{ t('globals.collapseMenu') }}
|
{{ t('globals.collapseMenu') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
|
@ -50,20 +44,21 @@ onMounted(() => stateStore.setMounted());
|
||||||
</QBtn>
|
</QBtn>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<VnBreadcrumbs v-if="$q.screen.gt.sm" />
|
<VnBreadcrumbs v-if="$q.screen.gt.sm" />
|
||||||
<QSpinner
|
|
||||||
color="primary"
|
|
||||||
class="q-ml-md"
|
|
||||||
:class="{
|
|
||||||
'no-visible': !stateQuery.isLoading().value,
|
|
||||||
}"
|
|
||||||
size="xs"
|
|
||||||
data-cy="loading-spinner"
|
|
||||||
/>
|
|
||||||
<QSpace />
|
<QSpace />
|
||||||
<div id="searchbar" class="searchbar"></div>
|
<div id="searchbar" class="searchbar"></div>
|
||||||
<QSpace />
|
<QSpace />
|
||||||
<div class="q-pl-sm q-gutter-sm row items-center no-wrap">
|
<div class="q-pl-sm q-gutter-sm row items-center no-wrap">
|
||||||
<div id="actions-prepend"></div>
|
<div id="actions-prepend"></div>
|
||||||
|
<QBtn
|
||||||
|
flat
|
||||||
|
v-if="!quasar.platform.is.mobile"
|
||||||
|
@click="pinnedModulesRef.redirect($route.params.id)"
|
||||||
|
icon="more_up"
|
||||||
|
>
|
||||||
|
<QTooltip>
|
||||||
|
{{ t('Go to Salix') }}
|
||||||
|
</QTooltip>
|
||||||
|
</QBtn>
|
||||||
<QBtn
|
<QBtn
|
||||||
:class="{ 'q-pa-none': quasar.platform.is.mobile }"
|
:class="{ 'q-pa-none': quasar.platform.is.mobile }"
|
||||||
id="pinnedModules"
|
id="pinnedModules"
|
||||||
|
@ -95,6 +90,7 @@ onMounted(() => stateStore.setMounted());
|
||||||
<VnBreadcrumbs v-if="$q.screen.lt.md" class="q-ml-md" />
|
<VnBreadcrumbs v-if="$q.screen.lt.md" class="q-ml-md" />
|
||||||
</QHeader>
|
</QHeader>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.searchbar {
|
.searchbar {
|
||||||
width: max-content;
|
width: max-content;
|
||||||
|
@ -103,3 +99,9 @@ onMounted(() => stateStore.setMounted());
|
||||||
background-color: var(--vn-section-color);
|
background-color: var(--vn-section-color);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<i18n>
|
||||||
|
en:
|
||||||
|
Go to Salix: Go to Salix
|
||||||
|
es:
|
||||||
|
Go to Salix: Ir a Salix
|
||||||
|
</i18n>
|
||||||
|
|
|
@ -1,170 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref, reactive } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
import { useDialogPluginComponent } from 'quasar';
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
|
||||||
import FormPopup from './FormPopup.vue';
|
|
||||||
import axios from 'axios';
|
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
invoiceOutData: {
|
|
||||||
type: Object,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const { dialogRef } = useDialogPluginComponent();
|
|
||||||
const { t } = useI18n();
|
|
||||||
const router = useRouter();
|
|
||||||
const { notify } = useNotify();
|
|
||||||
|
|
||||||
const rectificativeTypeOptions = ref([]);
|
|
||||||
const siiTypeInvoiceOutsOptions = ref([]);
|
|
||||||
const invoiceParams = reactive({
|
|
||||||
id: $props.invoiceOutData?.id,
|
|
||||||
inheritWarehouse: true,
|
|
||||||
});
|
|
||||||
const invoiceCorrectionTypesOptions = ref([]);
|
|
||||||
|
|
||||||
const refund = async () => {
|
|
||||||
const params = {
|
|
||||||
id: invoiceParams.id,
|
|
||||||
withWarehouse: invoiceParams.inheritWarehouse,
|
|
||||||
cplusRectificationTypeFk: invoiceParams.cplusRectificationTypeFk,
|
|
||||||
siiTypeInvoiceOutFk: invoiceParams.siiTypeInvoiceOutFk,
|
|
||||||
invoiceCorrectionTypeFk: invoiceParams.invoiceCorrectionTypeFk,
|
|
||||||
};
|
|
||||||
|
|
||||||
const { data } = await axios.post('InvoiceOuts/refundAndInvoice', params);
|
|
||||||
notify(t('Refunded invoice'), 'positive');
|
|
||||||
const [id] = data?.refundId || [];
|
|
||||||
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<FetchData
|
|
||||||
url="CplusRectificationTypes"
|
|
||||||
:filter="{ order: 'description' }"
|
|
||||||
@on-fetch="
|
|
||||||
(data) => (
|
|
||||||
(rectificativeTypeOptions = data),
|
|
||||||
(invoiceParams.cplusRectificationTypeFk = data.filter(
|
|
||||||
(type) => type.description == 'I – Por diferencias'
|
|
||||||
)[0].id)
|
|
||||||
)
|
|
||||||
"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
url="SiiTypeInvoiceOuts"
|
|
||||||
:filter="{ where: { code: { like: 'R%' } } }"
|
|
||||||
@on-fetch="
|
|
||||||
(data) => (
|
|
||||||
(siiTypeInvoiceOutsOptions = data),
|
|
||||||
(invoiceParams.siiTypeInvoiceOutFk = data.filter(
|
|
||||||
(type) => type.code == 'R4'
|
|
||||||
)[0].id)
|
|
||||||
)
|
|
||||||
"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
url="InvoiceCorrectionTypes"
|
|
||||||
@on-fetch="(data) => (invoiceCorrectionTypesOptions = data)"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
|
|
||||||
<QDialog ref="dialogRef">
|
|
||||||
<FormPopup
|
|
||||||
@on-submit="refund()"
|
|
||||||
:custom-submit-button-label="t('Accept')"
|
|
||||||
:default-cancel-button="false"
|
|
||||||
>
|
|
||||||
<template #form-inputs>
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Rectificative type')"
|
|
||||||
:options="rectificativeTypeOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="description"
|
|
||||||
option-value="id"
|
|
||||||
v-model="invoiceParams.cplusRectificationTypeFk"
|
|
||||||
:required="true"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Class')"
|
|
||||||
:options="siiTypeInvoiceOutsOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="description"
|
|
||||||
option-value="id"
|
|
||||||
v-model="invoiceParams.siiTypeInvoiceOutFk"
|
|
||||||
:required="true"
|
|
||||||
>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem v-bind="scope.itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>
|
|
||||||
{{ scope.opt?.code }} -
|
|
||||||
{{ scope.opt?.description }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
</VnRow>
|
|
||||||
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Type')"
|
|
||||||
:options="invoiceCorrectionTypesOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="description"
|
|
||||||
option-value="id"
|
|
||||||
v-model="invoiceParams.invoiceCorrectionTypeFk"
|
|
||||||
:required="true"
|
|
||||||
/> </VnRow
|
|
||||||
><VnRow>
|
|
||||||
<div>
|
|
||||||
<QCheckbox
|
|
||||||
:label="t('Inherit warehouse')"
|
|
||||||
v-model="invoiceParams.inheritWarehouse"
|
|
||||||
/>
|
|
||||||
<QIcon name="info" class="cursor-info q-ml-sm" size="sm">
|
|
||||||
<QTooltip>{{ t('Inherit warehouse tooltip') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</div>
|
|
||||||
</VnRow>
|
|
||||||
</template>
|
|
||||||
</FormPopup>
|
|
||||||
</QDialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
en:
|
|
||||||
Refund invoice: Refund invoice
|
|
||||||
Rectificative type: Rectificative type
|
|
||||||
Class: Class
|
|
||||||
Type: Type
|
|
||||||
Refunded invoice: Refunded invoice
|
|
||||||
Inherit warehouse: Inherit the warehouse
|
|
||||||
Inherit warehouse tooltip: Select this option to inherit the warehouse when refunding the invoice
|
|
||||||
Accept: Accept
|
|
||||||
Error refunding invoice: Error refunding invoice
|
|
||||||
es:
|
|
||||||
Refund invoice: Abonar factura
|
|
||||||
Rectificative type: Tipo rectificativa
|
|
||||||
Class: Clase
|
|
||||||
Type: Tipo
|
|
||||||
Refunded invoice: Factura abonada
|
|
||||||
Inherit warehouse: Heredar el almacén
|
|
||||||
Inherit warehouse tooltip: Seleccione esta opción para heredar el almacén al abonar la factura.
|
|
||||||
Accept: Aceptar
|
|
||||||
Error refunding invoice: Error abonando factura
|
|
||||||
</i18n>
|
|
|
@ -44,7 +44,7 @@ const onDataSaved = (data) => {
|
||||||
<FormModelPopup
|
<FormModelPopup
|
||||||
url-create="Items/regularize"
|
url-create="Items/regularize"
|
||||||
model="Items"
|
model="Items"
|
||||||
:title="t('item.regularizeStock')"
|
:title="t('Regularize stock')"
|
||||||
:form-initial-data="regularizeFormData"
|
:form-initial-data="regularizeFormData"
|
||||||
@on-data-saved="onDataSaved($event)"
|
@on-data-saved="onDataSaved($event)"
|
||||||
>
|
>
|
||||||
|
@ -55,7 +55,6 @@ const onDataSaved = (data) => {
|
||||||
v-model.number="data.quantity"
|
v-model.number="data.quantity"
|
||||||
type="number"
|
type="number"
|
||||||
autofocus
|
autofocus
|
||||||
data-cy="regularizeStockInput"
|
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow>
|
<VnRow>
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
<script setup>
|
|
||||||
defineProps({ row: { type: Object, required: true } });
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<span>
|
|
||||||
<QIcon
|
|
||||||
v-if="row.isTaxDataChecked === 0"
|
|
||||||
name="vn:no036"
|
|
||||||
color="primary"
|
|
||||||
size="xs"
|
|
||||||
>
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.noVerifiedData') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.hasTicketRequest" name="vn:buyrequest" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.purchaseRequest') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.itemShortage" name="vn:unavailable" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.notVisible') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.isFreezed" name="vn:frozen" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.clientFrozen') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon
|
|
||||||
v-if="row.risk"
|
|
||||||
name="vn:risk"
|
|
||||||
:color="row.hasHighRisk ? 'negative' : 'primary'"
|
|
||||||
size="xs"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ $t('salesTicketsTable.risk') }}: {{ row.risk - row.credit }}
|
|
||||||
</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.hasComponentLack" name="vn:components" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.componentLack') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.isTooLittle" name="vn:isTooLittle" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.tooLittle') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
|
@ -2,12 +2,13 @@
|
||||||
import { ref, reactive } from 'vue';
|
import { ref, reactive } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { useQuasar, useDialogPluginComponent } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
import VnSelect from 'components/common/VnSelect.vue';
|
||||||
import FormPopup from './FormPopup.vue';
|
import FormPopup from './FormPopup.vue';
|
||||||
|
import { useDialogPluginComponent } from 'quasar';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
|
|
||||||
|
@ -17,19 +18,19 @@ const $props = defineProps({
|
||||||
default: () => {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { dialogRef } = useDialogPluginComponent();
|
const { dialogRef } = useDialogPluginComponent();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
|
||||||
const rectificativeTypeOptions = ref([]);
|
|
||||||
const siiTypeInvoiceOutsOptions = ref([]);
|
|
||||||
const checked = ref(true);
|
const checked = ref(true);
|
||||||
const transferInvoiceParams = reactive({
|
const transferInvoiceParams = reactive({
|
||||||
id: $props.invoiceOutData?.id,
|
id: $props.invoiceOutData?.id,
|
||||||
|
refFk: $props.invoiceOutData?.ref,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const rectificativeTypeOptions = ref([]);
|
||||||
|
const siiTypeInvoiceOutsOptions = ref([]);
|
||||||
const invoiceCorrectionTypesOptions = ref([]);
|
const invoiceCorrectionTypesOptions = ref([]);
|
||||||
|
|
||||||
const selectedClient = (client) => {
|
const selectedClient = (client) => {
|
||||||
|
@ -43,38 +44,43 @@ const makeInvoice = async () => {
|
||||||
const params = {
|
const params = {
|
||||||
id: transferInvoiceParams.id,
|
id: transferInvoiceParams.id,
|
||||||
cplusRectificationTypeFk: transferInvoiceParams.cplusRectificationTypeFk,
|
cplusRectificationTypeFk: transferInvoiceParams.cplusRectificationTypeFk,
|
||||||
siiTypeInvoiceOutFk: transferInvoiceParams.siiTypeInvoiceOutFk,
|
|
||||||
invoiceCorrectionTypeFk: transferInvoiceParams.invoiceCorrectionTypeFk,
|
invoiceCorrectionTypeFk: transferInvoiceParams.invoiceCorrectionTypeFk,
|
||||||
newClientFk: transferInvoiceParams.newClientFk,
|
newClientFk: transferInvoiceParams.newClientFk,
|
||||||
|
refFk: transferInvoiceParams.refFk,
|
||||||
|
siiTypeInvoiceOutFk: transferInvoiceParams.siiTypeInvoiceOutFk,
|
||||||
makeInvoice: checked.value,
|
makeInvoice: checked.value,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (checked.value && hasToInvoiceByAddress) {
|
try {
|
||||||
const response = await new Promise((resolve) => {
|
if (checked.value && hasToInvoiceByAddress) {
|
||||||
quasar
|
const response = await new Promise((resolve) => {
|
||||||
.dialog({
|
quasar
|
||||||
component: VnConfirm,
|
.dialog({
|
||||||
componentProps: {
|
component: VnConfirm,
|
||||||
title: t('Bill destination client'),
|
componentProps: {
|
||||||
message: t('transferInvoiceInfo'),
|
title: t('Bill destination client'),
|
||||||
},
|
message: t('transferInvoiceInfo'),
|
||||||
})
|
},
|
||||||
.onOk(() => {
|
})
|
||||||
resolve(true);
|
.onOk(() => {
|
||||||
})
|
resolve(true);
|
||||||
.onCancel(() => {
|
})
|
||||||
resolve(false);
|
.onCancel(() => {
|
||||||
});
|
resolve(false);
|
||||||
});
|
});
|
||||||
if (!response) {
|
});
|
||||||
return;
|
if (!response) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const { data } = await axios.post('InvoiceOuts/transfer', params);
|
const { data } = await axios.post('InvoiceOuts/transferInvoice', params);
|
||||||
notify(t('Transferred invoice'), 'positive');
|
notify(t('Transferred invoice'), 'positive');
|
||||||
const id = data?.[0];
|
const id = data?.[0];
|
||||||
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error transfering invoice', err);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,12 @@ import FetchData from 'components/FetchData.vue';
|
||||||
import { useClipboard } from 'src/composables/useClipboard';
|
import { useClipboard } from 'src/composables/useClipboard';
|
||||||
import { useRole } from 'src/composables/useRole';
|
import { useRole } from 'src/composables/useRole';
|
||||||
import VnAvatar from './ui/VnAvatar.vue';
|
import VnAvatar from './ui/VnAvatar.vue';
|
||||||
import useNotify from 'src/composables/useNotify';
|
|
||||||
|
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const session = useSession();
|
const session = useSession();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { t, locale } = useI18n();
|
const { t, locale } = useI18n();
|
||||||
const { copyText } = useClipboard();
|
const { copyText } = useClipboard();
|
||||||
const { notify } = useNotify();
|
|
||||||
|
|
||||||
const userLocale = computed({
|
const userLocale = computed({
|
||||||
get() {
|
get() {
|
||||||
|
@ -55,7 +53,6 @@ const user = state.getUser();
|
||||||
const warehousesData = ref();
|
const warehousesData = ref();
|
||||||
const companiesData = ref();
|
const companiesData = ref();
|
||||||
const accountBankData = ref();
|
const accountBankData = ref();
|
||||||
const isEmployee = computed(() => useRole().isEmployee());
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
updatePreferences();
|
updatePreferences();
|
||||||
|
@ -73,28 +70,18 @@ function updatePreferences() {
|
||||||
|
|
||||||
async function saveDarkMode(value) {
|
async function saveDarkMode(value) {
|
||||||
const query = `/UserConfigs/${user.value.id}`;
|
const query = `/UserConfigs/${user.value.id}`;
|
||||||
try {
|
await axios.patch(query, {
|
||||||
await axios.patch(query, {
|
darkMode: value,
|
||||||
darkMode: value,
|
});
|
||||||
});
|
user.value.darkMode = value;
|
||||||
user.value.darkMode = value;
|
|
||||||
onDataSaved();
|
|
||||||
} catch (error) {
|
|
||||||
onDataError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveLanguage(value) {
|
async function saveLanguage(value) {
|
||||||
const query = `/VnUsers/${user.value.id}`;
|
const query = `/VnUsers/${user.value.id}`;
|
||||||
try {
|
await axios.patch(query, {
|
||||||
await axios.patch(query, { lang: value });
|
lang: value,
|
||||||
|
});
|
||||||
user.value.lang = value;
|
user.value.lang = value;
|
||||||
useState().setUser(user.value);
|
|
||||||
onDataSaved();
|
|
||||||
} catch (error) {
|
|
||||||
onDataError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function logout() {
|
function logout() {
|
||||||
|
@ -110,23 +97,11 @@ function localUserData() {
|
||||||
state.setUser(user.value);
|
state.setUser(user.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveUserData(param, value) {
|
function saveUserData(param, value) {
|
||||||
try {
|
axios.post('UserConfigs/setUserConfig', { [param]: value });
|
||||||
await axios.post('UserConfigs/setUserConfig', { [param]: value });
|
localUserData();
|
||||||
localUserData();
|
|
||||||
onDataSaved();
|
|
||||||
} catch (error) {
|
|
||||||
onDataError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
const isEmployee = computed(() => useRole().isEmployee());
|
||||||
const onDataSaved = () => {
|
|
||||||
notify('globals.dataSaved', 'positive');
|
|
||||||
};
|
|
||||||
|
|
||||||
const onDataError = () => {
|
|
||||||
notify('errors.updateUserConfig', 'negative');
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -7,72 +7,38 @@ import VnSelectDialog from 'components/common/VnSelectDialog.vue';
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
import CreateNewProvinceForm from './CreateNewProvinceForm.vue';
|
import CreateNewProvinceForm from './CreateNewProvinceForm.vue';
|
||||||
|
|
||||||
const emit = defineEmits(['onProvinceCreated', 'onProvinceFetched', 'update:options']);
|
const emit = defineEmits(['onProvinceCreated']);
|
||||||
const $props = defineProps({
|
const provinceFk = defineModel({ type: Number });
|
||||||
countryFk: {
|
watch(provinceFk, async () => await provincesFetchDataRef.value.fetch());
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
provinceSelected: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const provinceFk = defineModel({ type: Number, default: null });
|
|
||||||
|
|
||||||
const { validate } = useValidator();
|
const { validate } = useValidator();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const filter = ref({
|
|
||||||
include: { relation: 'country' },
|
const provincesOptions = ref();
|
||||||
where: {
|
|
||||||
countryFk: $props.countryFk,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const provincesOptions = ref($props.provinces);
|
|
||||||
const provincesFetchDataRef = ref();
|
const provincesFetchDataRef = ref();
|
||||||
provinceFk.value = $props.provinceSelected;
|
|
||||||
if (!$props.countryFk) {
|
|
||||||
filter.value.where = {};
|
|
||||||
}
|
|
||||||
async function onProvinceCreated(_, data) {
|
async function onProvinceCreated(_, data) {
|
||||||
await provincesFetchDataRef.value.fetch({ where: { countryFk: $props.countryFk } });
|
await provincesFetchDataRef.value.fetch();
|
||||||
provinceFk.value = data.id;
|
provinceFk.value = data.id;
|
||||||
emit('onProvinceCreated', data);
|
emit('onProvinceCreated', data);
|
||||||
}
|
}
|
||||||
async function handleProvinces(data) {
|
|
||||||
provincesOptions.value = data;
|
|
||||||
emit('update:options', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => $props.countryFk,
|
|
||||||
async () => {
|
|
||||||
if ($props.countryFk) {
|
|
||||||
filter.value.where.countryFk = $props.countryFk;
|
|
||||||
} else filter.value.where = {};
|
|
||||||
await provincesFetchDataRef.value.fetch({});
|
|
||||||
emit('onProvinceFetched', provincesOptions.value);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
ref="provincesFetchDataRef"
|
ref="provincesFetchDataRef"
|
||||||
:filter="filter"
|
:filter="{ include: { relation: 'country' } }"
|
||||||
@on-fetch="handleProvinces"
|
@on-fetch="(data) => (provincesOptions = data)"
|
||||||
url="Provinces"
|
|
||||||
auto-load
|
auto-load
|
||||||
|
url="Provinces"
|
||||||
/>
|
/>
|
||||||
<VnSelectDialog
|
<VnSelectDialog
|
||||||
data-cy="locationProvince"
|
|
||||||
:label="t('Province')"
|
:label="t('Province')"
|
||||||
:options="provincesOptions"
|
:options="provincesOptions"
|
||||||
:tooltip="t('Create province')"
|
|
||||||
hide-selected
|
hide-selected
|
||||||
v-model="provinceFk"
|
v-model="provinceFk"
|
||||||
:rules="validate && validate('postcode.provinceFk')"
|
:rules="validate && validate('postcode.provinceFk')"
|
||||||
:acls="[{ model: 'Province', props: '*', accessType: 'WRITE' }]"
|
:roles-allowed-to-create="['deliveryAssistant']"
|
||||||
>
|
>
|
||||||
<template #option="{ itemProps, opt }">
|
<template #option="{ itemProps, opt }">
|
||||||
<QItem v-bind="itemProps">
|
<QItem v-bind="itemProps">
|
||||||
|
@ -83,15 +49,11 @@ watch(
|
||||||
</QItem>
|
</QItem>
|
||||||
</template>
|
</template>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CreateNewProvinceForm
|
<CreateNewProvinceForm @on-data-saved="onProvinceCreated" />
|
||||||
:country-fk="$props.countryFk"
|
|
||||||
@on-data-saved="onProvinceCreated"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
</VnSelectDialog>
|
</VnSelectDialog>
|
||||||
</template>
|
</template>
|
||||||
<i18n>
|
<i18n>
|
||||||
es:
|
es:
|
||||||
Province: Provincia
|
Province: Provincia
|
||||||
Create province: Crear provincia
|
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { markRaw, computed } from 'vue';
|
import { markRaw, computed, defineModel } from 'vue';
|
||||||
import { QIcon, QCheckbox } from 'quasar';
|
import { QIcon, QCheckbox } from 'quasar';
|
||||||
import { dashIfEmpty } from 'src/filters';
|
import { dashIfEmpty } from 'src/filters';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { markRaw, computed } from 'vue';
|
import { markRaw, computed, defineModel } from 'vue';
|
||||||
import { QCheckbox } from 'quasar';
|
import { QCheckbox } from 'quasar';
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ import VnInputDate from 'components/common/VnInputDate.vue';
|
||||||
import VnInputTime from 'components/common/VnInputTime.vue';
|
import VnInputTime from 'components/common/VnInputTime.vue';
|
||||||
import VnTableColumn from 'components/VnTable/VnColumn.vue';
|
import VnTableColumn from 'components/VnTable/VnColumn.vue';
|
||||||
|
|
||||||
|
defineExpose({ addFilter });
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
column: {
|
column: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
@ -25,20 +27,14 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
searchUrl: {
|
searchUrl: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'table',
|
default: 'params',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
defineExpose({ addFilter, props: $props });
|
|
||||||
|
|
||||||
const model = defineModel(undefined, { required: true });
|
const model = defineModel(undefined, { required: true });
|
||||||
const arrayData = useArrayData(
|
const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl });
|
||||||
$props.dataKey,
|
|
||||||
$props.searchUrl ? { searchUrl: $props.searchUrl } : null
|
|
||||||
);
|
|
||||||
const columnFilter = computed(() => $props.column?.columnFilter);
|
const columnFilter = computed(() => $props.column?.columnFilter);
|
||||||
|
|
||||||
const updateEvent = { 'update:modelValue': addFilter };
|
const updateEvent = { 'update:modelValue': addFilter, remove: () => addFilter(null) };
|
||||||
const enterEvent = {
|
const enterEvent = {
|
||||||
'keyup.enter': () => addFilter(model.value),
|
'keyup.enter': () => addFilter(model.value),
|
||||||
remove: () => addFilter(null),
|
remove: () => addFilter(null),
|
||||||
|
@ -119,11 +115,11 @@ const components = {
|
||||||
rawSelect: selectComponent,
|
rawSelect: selectComponent,
|
||||||
};
|
};
|
||||||
|
|
||||||
async function addFilter(value, name) {
|
async function addFilter(value) {
|
||||||
value ??= undefined;
|
value ??= undefined;
|
||||||
if (value && typeof value === 'object') value = model.value;
|
if (value && typeof value === 'object') value = model.value;
|
||||||
value = value === '' ? undefined : value;
|
value = value === '' ? undefined : value;
|
||||||
let field = columnFilter.value?.name ?? $props.column.name ?? name;
|
let field = columnFilter.value?.name ?? $props.column.name;
|
||||||
|
|
||||||
if (columnFilter.value?.inWhere) {
|
if (columnFilter.value?.inWhere) {
|
||||||
if (columnFilter.value.alias) field = columnFilter.value.alias + '.' + field;
|
if (columnFilter.value.alias) field = columnFilter.value.alias + '.' + field;
|
||||||
|
@ -146,10 +142,6 @@ function alignRow() {
|
||||||
const showFilter = computed(
|
const showFilter = computed(
|
||||||
() => $props.column?.columnFilter !== false && $props.column.name != 'tableActions'
|
() => $props.column?.columnFilter !== false && $props.column.name != 'tableActions'
|
||||||
);
|
);
|
||||||
|
|
||||||
const onTabPressed = async () => {
|
|
||||||
if (model.value) enterEvent['keyup.enter']();
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
|
@ -164,7 +156,6 @@ const onTabPressed = async () => {
|
||||||
v-model="model"
|
v-model="model"
|
||||||
:components="components"
|
:components="components"
|
||||||
component-prop="columnFilter"
|
component-prop="columnFilter"
|
||||||
@keydown.tab="onTabPressed"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { useArrayData } from 'composables/useArrayData';
|
||||||
const model = defineModel({ type: Object });
|
const model = defineModel({ type: Object });
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
name: {
|
name: {
|
||||||
type: [String, Boolean],
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
label: {
|
label: {
|
||||||
|
@ -17,7 +17,7 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
searchUrl: {
|
searchUrl: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'table',
|
default: 'params',
|
||||||
},
|
},
|
||||||
vertical: {
|
vertical: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onBeforeMount, onMounted, computed, watch, useAttrs } from 'vue';
|
import { ref, onBeforeMount, onMounted, computed, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { useFilterParams } from 'src/composables/useFilterParams';
|
|
||||||
|
|
||||||
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';
|
||||||
|
|
||||||
|
import VnFilterPanel from 'components/ui/VnFilterPanel.vue';
|
||||||
import VnTableColumn from 'components/VnTable/VnColumn.vue';
|
import VnTableColumn from 'components/VnTable/VnColumn.vue';
|
||||||
import VnFilter from 'components/VnTable/VnFilter.vue';
|
import VnTableFilter from 'components/VnTable/VnFilter.vue';
|
||||||
import VnTableChip from 'components/VnTable/VnChip.vue';
|
import VnTableChip from 'components/VnTable/VnChip.vue';
|
||||||
import VnVisibleColumn from 'src/components/VnTable/VnVisibleColumn.vue';
|
import VnVisibleColumn from 'src/components/VnTable/VnVisibleColumn.vue';
|
||||||
import VnLv from 'components/ui/VnLv.vue';
|
import VnLv from 'components/ui/VnLv.vue';
|
||||||
import VnTableOrder from 'src/components/VnTable/VnOrder.vue';
|
import VnTableOrder from 'src/components/VnTable/VnOrder.vue';
|
||||||
import VnTableFilter from './VnTableFilter.vue';
|
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
columns: {
|
columns: {
|
||||||
|
@ -34,10 +33,6 @@ const $props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
rightSearchIcon: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
rowClick: {
|
rowClick: {
|
||||||
type: [Function, Boolean],
|
type: [Function, Boolean],
|
||||||
default: null,
|
default: null,
|
||||||
|
@ -54,20 +49,12 @@ const $props = defineProps({
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
createAsDialog: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
bottom: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
cardClass: {
|
cardClass: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'flex-one',
|
default: 'flex-one',
|
||||||
},
|
},
|
||||||
searchUrl: {
|
searchUrl: {
|
||||||
type: [String, Boolean],
|
type: String,
|
||||||
default: 'table',
|
default: 'table',
|
||||||
},
|
},
|
||||||
isEditable: {
|
isEditable: {
|
||||||
|
@ -98,43 +85,30 @@ const $props = defineProps({
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
crudModel: {
|
|
||||||
type: Object,
|
|
||||||
default: () => ({}),
|
|
||||||
},
|
|
||||||
tableHeight: {
|
tableHeight: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '90vh',
|
default: '90vh',
|
||||||
},
|
},
|
||||||
footer: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
disabledAttr: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const $attrs = useAttrs();
|
|
||||||
|
|
||||||
const CARD_MODE = 'card';
|
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 hasParams = ref(false);
|
const hasParams = ref(false);
|
||||||
|
const routeQuery = JSON.parse(route?.query[$props.searchUrl] ?? '{}');
|
||||||
|
const params = ref({ ...routeQuery, ...routeQuery.filter?.where });
|
||||||
|
const orders = ref(parseOrder(routeQuery.filter?.order));
|
||||||
const CrudModelRef = ref({});
|
const CrudModelRef = ref({});
|
||||||
const showForm = ref(false);
|
const showForm = ref(false);
|
||||||
const splittedColumns = ref({ columns: [] });
|
const splittedColumns = ref({ columns: [] });
|
||||||
const columnsVisibilitySkipped = ref();
|
const columnsVisibilitySkiped = ref();
|
||||||
const createForm = ref();
|
const createForm = ref();
|
||||||
const tableRef = ref();
|
|
||||||
const params = ref(useFilterParams($attrs['data-key']).params);
|
|
||||||
const orders = ref(useFilterParams($attrs['data-key']).orders);
|
|
||||||
|
|
||||||
const tableModes = [
|
const tableModes = [
|
||||||
{
|
{
|
||||||
|
@ -150,10 +124,9 @@ const tableModes = [
|
||||||
disable: $props.disableOption?.card,
|
disable: $props.disableOption?.card,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
const urlParams = route.query[$props.searchUrl];
|
setUserParams(route.query[$props.searchUrl]);
|
||||||
hasParams.value = urlParams && Object.keys(urlParams).length !== 0;
|
hasParams.value = params.value && Object.keys(params.value).length !== 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
@ -161,10 +134,10 @@ onMounted(() => {
|
||||||
quasar.platform.is.mobile && !$props.disableOption?.card
|
quasar.platform.is.mobile && !$props.disableOption?.card
|
||||||
? CARD_MODE
|
? CARD_MODE
|
||||||
: $props.defaultMode;
|
: $props.defaultMode;
|
||||||
stateStore.rightDrawer = quasar.screen.gt.xs;
|
stateStore.rightDrawer = true;
|
||||||
columnsVisibilitySkipped.value = [
|
columnsVisibilitySkiped.value = [
|
||||||
...splittedColumns.value.columns
|
...splittedColumns.value.columns
|
||||||
.filter((c) => c.visible === false)
|
.filter((c) => c.visible == false)
|
||||||
.map((c) => c.name),
|
.map((c) => c.name),
|
||||||
...['tableActions'],
|
...['tableActions'],
|
||||||
];
|
];
|
||||||
|
@ -184,8 +157,30 @@ watch(
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => route.query[$props.searchUrl],
|
||||||
|
(val) => setUserParams(val)
|
||||||
|
);
|
||||||
|
|
||||||
const isTableMode = computed(() => mode.value == TABLE_MODE);
|
const isTableMode = computed(() => mode.value == TABLE_MODE);
|
||||||
const showRightIcon = computed(() => $props.rightSearch || $props.rightSearchIcon);
|
|
||||||
|
function setUserParams(watchedParams, watchedOrder) {
|
||||||
|
if (!watchedParams) return;
|
||||||
|
|
||||||
|
if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams);
|
||||||
|
const filter =
|
||||||
|
typeof watchedParams?.filter == 'string'
|
||||||
|
? JSON.parse(watchedParams?.filter ?? '{}')
|
||||||
|
: watchedParams?.filter;
|
||||||
|
const where = filter?.where;
|
||||||
|
const order = watchedOrder ?? filter?.order;
|
||||||
|
|
||||||
|
watchedParams = { ...watchedParams, ...where };
|
||||||
|
delete watchedParams.filter;
|
||||||
|
delete params.value?.filter;
|
||||||
|
params.value = { ...params.value, ...watchedParams };
|
||||||
|
orders.value = parseOrder(order);
|
||||||
|
}
|
||||||
|
|
||||||
function splitColumns(columns) {
|
function splitColumns(columns) {
|
||||||
splittedColumns.value = {
|
splittedColumns.value = {
|
||||||
|
@ -205,8 +200,8 @@ function splitColumns(columns) {
|
||||||
if (col.create) splittedColumns.value.create.push(col);
|
if (col.create) splittedColumns.value.create.push(col);
|
||||||
if (col.cardVisible) splittedColumns.value.cardVisible.push(col);
|
if (col.cardVisible) splittedColumns.value.cardVisible.push(col);
|
||||||
if ($props.isEditable && col.disable == null) col.disable = false;
|
if ($props.isEditable && col.disable == null) col.disable = false;
|
||||||
if ($props.useModel && col.columnFilter !== false)
|
if ($props.useModel && col.columnFilter != false)
|
||||||
col.columnFilter = { inWhere: true, ...col.columnFilter };
|
col.columnFilter = { ...col.columnFilter, inWhere: true };
|
||||||
splittedColumns.value.columns.push(col);
|
splittedColumns.value.columns.push(col);
|
||||||
}
|
}
|
||||||
// Status column
|
// Status column
|
||||||
|
@ -266,44 +261,23 @@ function getColAlign(col) {
|
||||||
return 'text-' + (col.align ?? 'left');
|
return 'text-' + (col.align ?? 'left');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseOrder(urlOrders) {
|
||||||
|
const orderObject = {};
|
||||||
|
if (!urlOrders) return orderObject;
|
||||||
|
if (typeof urlOrders == 'string') urlOrders = [urlOrders];
|
||||||
|
for (const [index, orders] of urlOrders.entries()) {
|
||||||
|
const [name, direction] = orders.split(' ');
|
||||||
|
orderObject[name] = { direction, index: index + 1 };
|
||||||
|
}
|
||||||
|
return orderObject;
|
||||||
|
}
|
||||||
|
|
||||||
const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']);
|
const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']);
|
||||||
defineExpose({
|
defineExpose({
|
||||||
create: createForm,
|
|
||||||
reload,
|
reload,
|
||||||
redirect: redirectFn,
|
redirect: redirectFn,
|
||||||
selected,
|
selected,
|
||||||
CrudModelRef,
|
|
||||||
params,
|
|
||||||
tableRef,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleOnDataSaved(_) {
|
|
||||||
if (_.onDataSaved) _.onDataSaved({ CrudModelRef: CrudModelRef.value });
|
|
||||||
else $props.create.onDataSaved(_);
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleScroll() {
|
|
||||||
if ($props.crudModel.disableInfiniteScroll) return;
|
|
||||||
|
|
||||||
const tMiddle = tableRef.value.$el.querySelector('.q-table__middle');
|
|
||||||
const { scrollHeight, scrollTop, clientHeight } = tMiddle;
|
|
||||||
const isAtBottom = Math.abs(scrollHeight - scrollTop - clientHeight) <= 40;
|
|
||||||
if (isAtBottom) CrudModelRef.value.vnPaginateRef.paginate();
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|
||||||
if (evt?.shiftKey && added) {
|
|
||||||
const rowIndex = selectedRows[0].$index;
|
|
||||||
const selectedIndexes = new Set(selected.value.map((row) => row.$index));
|
|
||||||
for (const row of rows) {
|
|
||||||
if (row.$index == rowIndex) break;
|
|
||||||
if (!selectedIndexes.has(row.$index)) {
|
|
||||||
selected.value.push(row);
|
|
||||||
selectedIndexes.add(row.$index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<QDrawer
|
<QDrawer
|
||||||
|
@ -314,331 +288,344 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
||||||
show-if-above
|
show-if-above
|
||||||
>
|
>
|
||||||
<QScrollArea class="fit">
|
<QScrollArea class="fit">
|
||||||
<VnTableFilter :data-key="$attrs['data-key']" :columns="columns" :redirect="redirect" />
|
<VnFilterPanel
|
||||||
|
:data-key="$attrs['data-key']"
|
||||||
|
:search-button="true"
|
||||||
|
v-model="params"
|
||||||
|
:search-url="searchUrl"
|
||||||
|
:redirect="!!redirect"
|
||||||
|
@set-user-params="setUserParams"
|
||||||
|
>
|
||||||
|
<template #body>
|
||||||
|
<div
|
||||||
|
class="row no-wrap flex-center"
|
||||||
|
v-for="col of splittedColumns.columns.filter(
|
||||||
|
(c) => c.columnFilter ?? true
|
||||||
|
)"
|
||||||
|
:key="col.id"
|
||||||
|
>
|
||||||
|
<VnTableFilter
|
||||||
|
:column="col"
|
||||||
|
:data-key="$attrs['data-key']"
|
||||||
|
v-model="params[columnName(col)]"
|
||||||
|
:search-url="searchUrl"
|
||||||
|
/>
|
||||||
|
<VnTableOrder
|
||||||
|
v-if="
|
||||||
|
col?.columnFilter !== false &&
|
||||||
|
col?.name !== 'tableActions'
|
||||||
|
"
|
||||||
|
v-model="orders[col.name]"
|
||||||
|
:name="col.orderBy ?? col.name"
|
||||||
|
:data-key="$attrs['data-key']"
|
||||||
|
:search-url="searchUrl"
|
||||||
|
:vertical="true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<slot
|
||||||
|
name="moreFilterPanel"
|
||||||
|
:params="params"
|
||||||
|
:columns="splittedColumns.columns"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</VnFilterPanel>
|
||||||
</QScrollArea>
|
</QScrollArea>
|
||||||
</QDrawer>
|
</QDrawer>
|
||||||
<CrudModel
|
<!-- class in div to fix warn-->
|
||||||
v-bind="$attrs"
|
<div class="q-px-md">
|
||||||
:class="$attrs['class'] ?? 'q-px-md'"
|
<CrudModel
|
||||||
:limit="$attrs['limit'] ?? 20"
|
v-bind="$attrs"
|
||||||
ref="CrudModelRef"
|
:limit="20"
|
||||||
@on-fetch="(...args) => emit('onFetch', ...args)"
|
ref="CrudModelRef"
|
||||||
:search-url="searchUrl"
|
@on-fetch="(...args) => emit('onFetch', ...args)"
|
||||||
:disable-infinite-scroll="isTableMode"
|
:search-url="searchUrl"
|
||||||
@save-changes="reload"
|
:disable-infinite-scroll="isTableMode"
|
||||||
:has-sub-toolbar="$props.hasSubToolbar ?? isEditable"
|
@save-changes="reload"
|
||||||
:auto-load="hasParams || $attrs['auto-load']"
|
:has-sub-toolbar="$props.hasSubToolbar ?? isEditable"
|
||||||
>
|
:auto-load="hasParams || $attrs['auto-load']"
|
||||||
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
|
>
|
||||||
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
<template
|
||||||
</template>
|
v-for="(_, slotName) in $slots"
|
||||||
<template #body="{ rows }">
|
#[slotName]="slotData"
|
||||||
<QTable
|
:key="slotName"
|
||||||
ref="tableRef"
|
|
||||||
v-bind="table"
|
|
||||||
class="vnTable"
|
|
||||||
:class="{ 'last-row-sticky': $props.footer }"
|
|
||||||
:columns="splittedColumns.columns"
|
|
||||||
:rows="rows"
|
|
||||||
v-model:selected="selected"
|
|
||||||
:grid="!isTableMode"
|
|
||||||
table-header-class="bg-header"
|
|
||||||
card-container-class="grid-three"
|
|
||||||
flat
|
|
||||||
:style="isTableMode && `max-height: ${tableHeight}`"
|
|
||||||
:virtual-scroll="isTableMode"
|
|
||||||
@virtual-scroll="handleScroll"
|
|
||||||
@row-click="(_, row) => rowClickFunction && rowClickFunction(row)"
|
|
||||||
@update:selected="emit('update:selected', $event)"
|
|
||||||
@selection="(details) => handleSelection(details, rows)"
|
|
||||||
>
|
>
|
||||||
<template #top-left v-if="!$props.withoutHeader">
|
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
||||||
<slot name="top-left"></slot>
|
</template>
|
||||||
</template>
|
<template #body="{ rows }">
|
||||||
<template #top-right v-if="!$props.withoutHeader">
|
<QTable
|
||||||
<VnVisibleColumn
|
v-bind="table"
|
||||||
v-if="isTableMode"
|
class="vnTable"
|
||||||
v-model="splittedColumns.columns"
|
:columns="splittedColumns.columns"
|
||||||
:table-code="tableCode ?? route.name"
|
:rows="rows"
|
||||||
:skip="columnsVisibilitySkipped"
|
v-model:selected="selected"
|
||||||
/>
|
:grid="!isTableMode"
|
||||||
<QBtnToggle
|
table-header-class="bg-header"
|
||||||
v-model="mode"
|
card-container-class="grid-three"
|
||||||
toggle-color="primary"
|
flat
|
||||||
class="bg-vn-section-color"
|
:style="isTableMode && `max-height: ${tableHeight}`"
|
||||||
dense
|
virtual-scroll
|
||||||
:options="tableModes.filter((mode) => !mode.disable)"
|
@virtual-scroll="
|
||||||
/>
|
(event) =>
|
||||||
<QBtn
|
event.index > rows.length - 2 &&
|
||||||
v-if="showRightIcon"
|
CrudModelRef.vnPaginateRef.paginate()
|
||||||
icon="filter_alt"
|
"
|
||||||
class="bg-vn-section-color q-ml-sm"
|
@row-click="(_, row) => rowClickFunction && rowClickFunction(row)"
|
||||||
dense
|
@update:selected="emit('update:selected', $event)"
|
||||||
@click="stateStore.toggleRightDrawer()"
|
>
|
||||||
/>
|
<template #top-left v-if="!$props.withoutHeader">
|
||||||
</template>
|
<slot name="top-left"></slot>
|
||||||
<template #header-cell="{ col }">
|
</template>
|
||||||
<QTh
|
<template #top-right v-if="!$props.withoutHeader">
|
||||||
v-if="col.visible ?? true"
|
<VnVisibleColumn
|
||||||
:style="col.headerStyle"
|
v-if="isTableMode"
|
||||||
:class="col.headerClass"
|
v-model="splittedColumns.columns"
|
||||||
>
|
:table-code="tableCode ?? route.name"
|
||||||
<div
|
:skip="columnsVisibilitySkiped"
|
||||||
class="column ellipsis"
|
/>
|
||||||
:class="`text-${col?.align ?? 'left'}`"
|
<QBtnToggle
|
||||||
:style="$props.columnSearch ? 'height: 75px' : ''"
|
v-model="mode"
|
||||||
>
|
toggle-color="primary"
|
||||||
<div class="row items-center no-wrap" style="height: 30px">
|
class="bg-vn-section-color"
|
||||||
<QTooltip v-if="col.toolTip">{{ col.toolTip }}</QTooltip>
|
dense
|
||||||
<VnTableOrder
|
:options="tableModes"
|
||||||
v-model="orders[col.orderBy ?? col.name]"
|
/>
|
||||||
:name="col.orderBy ?? col.name"
|
<QBtn
|
||||||
:label="col?.label"
|
v-if="$props.rightSearch"
|
||||||
|
icon="filter_alt"
|
||||||
|
class="bg-vn-section-color q-ml-md"
|
||||||
|
dense
|
||||||
|
@click="stateStore.toggleRightDrawer()"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #header-cell="{ col }">
|
||||||
|
<QTh v-if="col.visible ?? true">
|
||||||
|
<div
|
||||||
|
class="column self-start q-ml-xs ellipsis"
|
||||||
|
:class="`text-${col?.align ?? 'left'}`"
|
||||||
|
:style="$props.columnSearch ? 'height: 75px' : ''"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="row items-center no-wrap"
|
||||||
|
style="height: 30px"
|
||||||
|
>
|
||||||
|
<VnTableOrder
|
||||||
|
v-model="orders[col.name]"
|
||||||
|
:name="col.orderBy ?? col.name"
|
||||||
|
:label="col?.label"
|
||||||
|
:data-key="$attrs['data-key']"
|
||||||
|
:search-url="searchUrl"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<VnTableFilter
|
||||||
|
v-if="$props.columnSearch"
|
||||||
|
:column="col"
|
||||||
|
:show-title="true"
|
||||||
:data-key="$attrs['data-key']"
|
:data-key="$attrs['data-key']"
|
||||||
|
v-model="params[columnName(col)]"
|
||||||
:search-url="searchUrl"
|
:search-url="searchUrl"
|
||||||
|
class="full-width"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<VnFilter
|
|
||||||
v-if="$props.columnSearch"
|
|
||||||
:column="col"
|
|
||||||
:show-title="true"
|
|
||||||
:data-key="$attrs['data-key']"
|
|
||||||
v-model="params[columnName(col)]"
|
|
||||||
:search-url="searchUrl"
|
|
||||||
class="full-width"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</QTh>
|
|
||||||
</template>
|
|
||||||
<template #header-cell-tableActions>
|
|
||||||
<QTh auto-width class="sticky" />
|
|
||||||
</template>
|
|
||||||
<template #body-cell-tableStatus="{ col, row }">
|
|
||||||
<QTd auto-width :class="getColAlign(col)">
|
|
||||||
<VnTableChip :columns="splittedColumns.columnChips" :row="row">
|
|
||||||
<template #afterChip>
|
|
||||||
<slot name="afterChip" :row="row"></slot>
|
|
||||||
</template>
|
|
||||||
</VnTableChip>
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
<template #body-cell="{ col, row, rowIndex }">
|
|
||||||
<!-- Columns -->
|
|
||||||
<QTd
|
|
||||||
auto-width
|
|
||||||
class="no-margin"
|
|
||||||
:class="[getColAlign(col), col.columnClass]"
|
|
||||||
:style="col.style"
|
|
||||||
v-if="col.visible ?? true"
|
|
||||||
@click.ctrl="
|
|
||||||
($event) =>
|
|
||||||
rowCtrlClickFunction && rowCtrlClickFunction($event, row)
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<slot
|
|
||||||
:name="`column-${col.name}`"
|
|
||||||
:col="col"
|
|
||||||
:row="row"
|
|
||||||
:row-index="rowIndex"
|
|
||||||
>
|
|
||||||
<VnTableColumn
|
|
||||||
:column="col"
|
|
||||||
:row="row"
|
|
||||||
:is-editable="col.isEditable ?? isEditable"
|
|
||||||
v-model="row[col.name]"
|
|
||||||
component-prop="columnField"
|
|
||||||
/>
|
|
||||||
</slot>
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
<template #body-cell-tableActions="{ col, row }">
|
|
||||||
<QTd
|
|
||||||
auto-width
|
|
||||||
:class="getColAlign(col)"
|
|
||||||
class="sticky no-padding"
|
|
||||||
@click="stopEventPropagation($event)"
|
|
||||||
:style="col.style"
|
|
||||||
>
|
|
||||||
<QBtn
|
|
||||||
v-for="(btn, index) of col.actions"
|
|
||||||
v-show="btn.show ? btn.show(row) : true"
|
|
||||||
:key="index"
|
|
||||||
:title="btn.title"
|
|
||||||
:icon="btn.icon"
|
|
||||||
class="q-pa-xs"
|
|
||||||
flat
|
|
||||||
dense
|
|
||||||
:class="
|
|
||||||
btn.isPrimary ? 'text-primary-light' : 'color-vn-text '
|
|
||||||
"
|
|
||||||
:style="`visibility: ${
|
|
||||||
(btn.show && btn.show(row)) ?? true ? 'visible' : 'hidden'
|
|
||||||
}`"
|
|
||||||
@click="btn.action(row)"
|
|
||||||
/>
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
<template #item="{ row, colsMap }">
|
|
||||||
<component
|
|
||||||
:is="$props.redirect ? 'router-link' : 'span'"
|
|
||||||
:to="`/${$props.redirect}/` + row.id"
|
|
||||||
>
|
|
||||||
<QCard
|
|
||||||
bordered
|
|
||||||
flat
|
|
||||||
class="row no-wrap justify-between cursor-pointer"
|
|
||||||
@click="
|
|
||||||
(_, row) => {
|
|
||||||
$props.rowClick && $props.rowClick(row);
|
|
||||||
}
|
|
||||||
"
|
|
||||||
style="height: 100%"
|
|
||||||
>
|
|
||||||
<QCardSection
|
|
||||||
vertical
|
|
||||||
class="no-margin no-padding"
|
|
||||||
:class="colsMap.tableActions ? 'w-80' : 'fit'"
|
|
||||||
>
|
|
||||||
<!-- Chips -->
|
|
||||||
<QCardSection
|
|
||||||
v-if="splittedColumns.chips.length"
|
|
||||||
class="no-margin q-px-xs q-py-none"
|
|
||||||
>
|
|
||||||
<VnTableChip
|
|
||||||
:columns="splittedColumns.chips"
|
|
||||||
:row="row"
|
|
||||||
>
|
|
||||||
<template #afterChip>
|
|
||||||
<slot name="afterChip" :row="row"></slot>
|
|
||||||
</template>
|
|
||||||
</VnTableChip>
|
|
||||||
</QCardSection>
|
|
||||||
<!-- Title -->
|
|
||||||
<QCardSection
|
|
||||||
v-if="splittedColumns.title"
|
|
||||||
class="q-pl-sm q-py-none text-primary-light text-bold text-h6 cardEllipsis"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
:title="row[splittedColumns.title.name]"
|
|
||||||
@click="stopEventPropagation($event)"
|
|
||||||
class="cursor-text"
|
|
||||||
>
|
|
||||||
{{ row[splittedColumns.title.name] }}
|
|
||||||
</span>
|
|
||||||
</QCardSection>
|
|
||||||
<!-- Fields -->
|
|
||||||
<QCardSection
|
|
||||||
class="q-pl-sm q-pr-lg q-py-xs"
|
|
||||||
:class="$props.cardClass"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
v-for="(
|
|
||||||
col, index
|
|
||||||
) of splittedColumns.cardVisible"
|
|
||||||
:key="col.name"
|
|
||||||
class="fields"
|
|
||||||
>
|
|
||||||
<VnLv :label="col.label + ':'">
|
|
||||||
<template #value>
|
|
||||||
<span
|
|
||||||
@click="stopEventPropagation($event)"
|
|
||||||
>
|
|
||||||
<slot
|
|
||||||
:name="`column-${col.name}`"
|
|
||||||
:col="col"
|
|
||||||
:row="row"
|
|
||||||
:row-index="index"
|
|
||||||
>
|
|
||||||
<VnTableColumn
|
|
||||||
:column="col"
|
|
||||||
:row="row"
|
|
||||||
:is-editable="false"
|
|
||||||
v-model="row[col.name]"
|
|
||||||
component-prop="columnField"
|
|
||||||
:show-label="true"
|
|
||||||
/>
|
|
||||||
</slot>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</VnLv>
|
|
||||||
</div>
|
|
||||||
</QCardSection>
|
|
||||||
</QCardSection>
|
|
||||||
<!-- Actions -->
|
|
||||||
<QCardSection
|
|
||||||
v-if="colsMap.tableActions"
|
|
||||||
class="column flex-center w-10 no-margin q-pa-xs q-gutter-y-xs"
|
|
||||||
@click="stopEventPropagation($event)"
|
|
||||||
>
|
|
||||||
<QBtn
|
|
||||||
v-for="(btn, index) of splittedColumns.actions
|
|
||||||
.actions"
|
|
||||||
:key="index"
|
|
||||||
:title="btn.title"
|
|
||||||
:icon="btn.icon"
|
|
||||||
class="q-pa-xs"
|
|
||||||
flat
|
|
||||||
:class="
|
|
||||||
btn.isPrimary
|
|
||||||
? 'text-primary-light'
|
|
||||||
: 'color-vn-text '
|
|
||||||
"
|
|
||||||
@click="btn.action(row)"
|
|
||||||
/>
|
|
||||||
</QCardSection>
|
|
||||||
</QCard>
|
|
||||||
</component>
|
|
||||||
</template>
|
|
||||||
<template #bottom-row="{ cols }" v-if="$props.footer">
|
|
||||||
<QTr v-if="rows.length" style="height: 30px">
|
|
||||||
<QTh
|
|
||||||
v-for="col of cols.filter((cols) => cols.visible ?? true)"
|
|
||||||
:key="col?.id"
|
|
||||||
class="text-center"
|
|
||||||
:class="getColAlign(col)"
|
|
||||||
>
|
|
||||||
<slot :name="`column-footer-${col.name}`" />
|
|
||||||
</QTh>
|
</QTh>
|
||||||
</QTr>
|
</template>
|
||||||
</template>
|
<template #header-cell-tableActions>
|
||||||
</QTable>
|
<QTh auto-width class="sticky" />
|
||||||
<div class="full-width bottomButton" v-if="bottom">
|
</template>
|
||||||
<QBtn
|
<template #body-cell-tableStatus="{ col, row }">
|
||||||
@click="
|
<QTd auto-width :class="getColAlign(col)">
|
||||||
() =>
|
<VnTableChip
|
||||||
createAsDialog
|
:columns="splittedColumns.columnChips"
|
||||||
? (showForm = !showForm)
|
:row="row"
|
||||||
: handleOnDataSaved(create)
|
>
|
||||||
"
|
<template #afterChip>
|
||||||
class="cursor-pointer fill-icon"
|
<slot name="afterChip" :row="row"></slot>
|
||||||
color="primary"
|
</template>
|
||||||
icon="add_circle"
|
</VnTableChip>
|
||||||
size="md"
|
</QTd>
|
||||||
round
|
</template>
|
||||||
flat
|
<template #body-cell="{ col, row, rowIndex }">
|
||||||
shortcut="+"
|
<!-- Columns -->
|
||||||
:disabled="!disabledAttr"
|
<QTd
|
||||||
/>
|
auto-width
|
||||||
<QTooltip>
|
class="no-margin q-px-xs"
|
||||||
{{ createForm.title }}
|
:class="[getColAlign(col), col.columnClass]"
|
||||||
</QTooltip>
|
v-if="col.visible ?? true"
|
||||||
</div>
|
@click.ctrl="
|
||||||
</template>
|
($event) =>
|
||||||
</CrudModel>
|
rowCtrlClickFunction &&
|
||||||
<QPageSticky v-if="$props.create" :offset="[20, 20]" style="z-index: 2">
|
rowCtrlClickFunction($event, row)
|
||||||
<QBtn
|
"
|
||||||
@click="
|
>
|
||||||
() =>
|
<slot
|
||||||
createAsDialog ? (showForm = !showForm) : handleOnDataSaved(create)
|
:name="`column-${col.name}`"
|
||||||
"
|
:col="col"
|
||||||
color="primary"
|
:row="row"
|
||||||
fab
|
:row-index="rowIndex"
|
||||||
icon="add"
|
>
|
||||||
shortcut="+"
|
<VnTableColumn
|
||||||
data-cy="vnTableCreateBtn"
|
:column="col"
|
||||||
/>
|
:row="row"
|
||||||
<QTooltip self="top right">
|
:is-editable="col.isEditable ?? isEditable"
|
||||||
{{ createForm?.title }}
|
v-model="row[col.name]"
|
||||||
|
component-prop="columnField"
|
||||||
|
/>
|
||||||
|
</slot>
|
||||||
|
</QTd>
|
||||||
|
</template>
|
||||||
|
<template #body-cell-tableActions="{ col, row }">
|
||||||
|
<QTd
|
||||||
|
auto-width
|
||||||
|
:class="getColAlign(col)"
|
||||||
|
class="sticky no-padding"
|
||||||
|
@click="stopEventPropagation($event)"
|
||||||
|
>
|
||||||
|
<QBtn
|
||||||
|
v-for="(btn, index) of col.actions"
|
||||||
|
:key="index"
|
||||||
|
:title="btn.title"
|
||||||
|
:icon="btn.icon"
|
||||||
|
class="q-px-sm"
|
||||||
|
flat
|
||||||
|
:class="
|
||||||
|
btn.isPrimary
|
||||||
|
? 'text-primary-light'
|
||||||
|
: 'color-vn-text '
|
||||||
|
"
|
||||||
|
:style="`visibility: ${
|
||||||
|
(btn.show && btn.show(row)) ?? true
|
||||||
|
? 'visible'
|
||||||
|
: 'hidden'
|
||||||
|
}`"
|
||||||
|
@click="btn.action(row)"
|
||||||
|
/>
|
||||||
|
</QTd>
|
||||||
|
</template>
|
||||||
|
<template #item="{ row, colsMap }">
|
||||||
|
<component
|
||||||
|
:is="$props.redirect ? 'router-link' : 'span'"
|
||||||
|
:to="`/${$props.redirect}/` + row.id"
|
||||||
|
>
|
||||||
|
<QCard
|
||||||
|
bordered
|
||||||
|
flat
|
||||||
|
class="row no-wrap justify-between cursor-pointer"
|
||||||
|
@click="
|
||||||
|
(_, row) => {
|
||||||
|
$props.rowClick && $props.rowClick(row);
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<QCardSection
|
||||||
|
vertical
|
||||||
|
class="no-margin no-padding"
|
||||||
|
:class="colsMap.tableActions ? 'w-80' : 'fit'"
|
||||||
|
>
|
||||||
|
<!-- Chips -->
|
||||||
|
<QCardSection
|
||||||
|
v-if="splittedColumns.chips.length"
|
||||||
|
class="no-margin q-px-xs q-py-none"
|
||||||
|
>
|
||||||
|
<VnTableChip
|
||||||
|
:columns="splittedColumns.chips"
|
||||||
|
:row="row"
|
||||||
|
>
|
||||||
|
<template #afterChip>
|
||||||
|
<slot name="afterChip" :row="row"></slot>
|
||||||
|
</template>
|
||||||
|
</VnTableChip>
|
||||||
|
</QCardSection>
|
||||||
|
<!-- Title -->
|
||||||
|
<QCardSection
|
||||||
|
v-if="splittedColumns.title"
|
||||||
|
class="q-pl-sm q-py-none text-primary-light text-bold text-h6 cardEllipsis"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
:title="row[splittedColumns.title.name]"
|
||||||
|
@click="stopEventPropagation($event)"
|
||||||
|
class="cursor-text"
|
||||||
|
>
|
||||||
|
{{ row[splittedColumns.title.name] }}
|
||||||
|
</span>
|
||||||
|
</QCardSection>
|
||||||
|
<!-- Fields -->
|
||||||
|
<QCardSection
|
||||||
|
class="q-pl-sm q-pr-lg q-py-xs"
|
||||||
|
:class="$props.cardClass"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="(
|
||||||
|
col, index
|
||||||
|
) of splittedColumns.cardVisible"
|
||||||
|
:key="col.name"
|
||||||
|
class="fields"
|
||||||
|
>
|
||||||
|
<VnLv
|
||||||
|
:label="
|
||||||
|
!col.component && col.label
|
||||||
|
? `${col.label}:`
|
||||||
|
: ''
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<template #value>
|
||||||
|
<span
|
||||||
|
@click="
|
||||||
|
stopEventPropagation($event)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<slot
|
||||||
|
:name="`column-${col.name}`"
|
||||||
|
:col="col"
|
||||||
|
:row="row"
|
||||||
|
:row-index="index"
|
||||||
|
>
|
||||||
|
<VnTableColumn
|
||||||
|
:column="col"
|
||||||
|
:row="row"
|
||||||
|
:is-editable="false"
|
||||||
|
v-model="row[col.name]"
|
||||||
|
component-prop="columnField"
|
||||||
|
:show-label="true"
|
||||||
|
/>
|
||||||
|
</slot>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</VnLv>
|
||||||
|
</div>
|
||||||
|
</QCardSection>
|
||||||
|
</QCardSection>
|
||||||
|
<!-- Actions -->
|
||||||
|
<QCardSection
|
||||||
|
v-if="colsMap.tableActions"
|
||||||
|
class="column flex-center w-10 no-margin q-pa-xs q-gutter-y-xs"
|
||||||
|
@click="stopEventPropagation($event)"
|
||||||
|
>
|
||||||
|
<QBtn
|
||||||
|
v-for="(btn, index) of splittedColumns.actions
|
||||||
|
.actions"
|
||||||
|
:key="index"
|
||||||
|
:title="btn.title"
|
||||||
|
:icon="btn.icon"
|
||||||
|
class="q-pa-xs"
|
||||||
|
flat
|
||||||
|
:class="
|
||||||
|
btn.isPrimary
|
||||||
|
? 'text-primary-light'
|
||||||
|
: 'color-vn-text '
|
||||||
|
"
|
||||||
|
@click="btn.action(row)"
|
||||||
|
/>
|
||||||
|
</QCardSection>
|
||||||
|
</QCard>
|
||||||
|
</component>
|
||||||
|
</template>
|
||||||
|
</QTable>
|
||||||
|
</template>
|
||||||
|
</CrudModel>
|
||||||
|
</div>
|
||||||
|
<QPageSticky v-if="create" :offset="[20, 20]" style="z-index: 2">
|
||||||
|
<QBtn @click="showForm = !showForm" color="primary" fab icon="add" />
|
||||||
|
<QTooltip>
|
||||||
|
{{ createForm.title }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QPageSticky>
|
</QPageSticky>
|
||||||
<QDialog v-model="showForm" transition-show="scale" transition-hide="scale">
|
<QDialog v-model="showForm" transition-show="scale" transition-hide="scale">
|
||||||
|
@ -690,7 +677,7 @@ es:
|
||||||
}
|
}
|
||||||
|
|
||||||
.bg-header {
|
.bg-header {
|
||||||
background-color: var(--vn-accent-color);
|
background-color: var(--vn-header-color);
|
||||||
color: var(--vn-text-color);
|
color: var(--vn-text-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -698,9 +685,21 @@ es:
|
||||||
color: var(--vn-text-color);
|
color: var(--vn-text-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.q-table--dark .q-table__bottom,
|
||||||
|
.q-table--dark thead,
|
||||||
|
.q-table--dark tr,
|
||||||
|
.q-table--dark th,
|
||||||
|
.q-table--dark td {
|
||||||
|
border-color: var(--vn-section-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.q-table__container > div:first-child {
|
||||||
|
background-color: var(--vn-page-color);
|
||||||
|
}
|
||||||
|
|
||||||
.grid-three {
|
.grid-three {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(350px, max-content));
|
grid-template-columns: repeat(auto-fit, minmax(400px, max-content));
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
grid-gap: 20px;
|
grid-gap: 20px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
@ -726,15 +725,8 @@ es:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.q-table {
|
.q-table th {
|
||||||
th {
|
padding: 0;
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__top {
|
|
||||||
padding: 12px 0px;
|
|
||||||
top: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.vnTable {
|
.vnTable {
|
||||||
|
@ -747,7 +739,21 @@ es:
|
||||||
}
|
}
|
||||||
.q-table__top {
|
.q-table__top {
|
||||||
top: 0;
|
top: 0;
|
||||||
padding: 12px 0;
|
}
|
||||||
|
tbody {
|
||||||
|
.q-checkbox {
|
||||||
|
display: flex;
|
||||||
|
margin-bottom: 9px;
|
||||||
|
& .q-checkbox__label {
|
||||||
|
margin-left: 31px;
|
||||||
|
color: var(--vn-text-color);
|
||||||
|
}
|
||||||
|
& .q-checkbox__inner {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
color: var(--vn-label-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.sticky {
|
.sticky {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
|
@ -757,18 +763,6 @@ es:
|
||||||
background-color: var(--vn-section-color);
|
background-color: var(--vn-section-color);
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
table tbody th {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.last-row-sticky {
|
|
||||||
tbody:nth-last-child(1) {
|
|
||||||
@extend .bg-header;
|
|
||||||
position: sticky;
|
|
||||||
z-index: 2;
|
|
||||||
bottom: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.vn-label-value {
|
.vn-label-value {
|
||||||
|
@ -814,12 +808,4 @@ es:
|
||||||
cursor: text;
|
cursor: text;
|
||||||
user-select: all;
|
user-select: all;
|
||||||
}
|
}
|
||||||
|
|
||||||
.q-table__container {
|
|
||||||
background-color: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.q-table__middle.q-virtual-scroll.q-virtual-scroll--vertical.scroll {
|
|
||||||
background-color: var(--vn-section-color);
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref } from 'vue';
|
|
||||||
|
|
||||||
import VnFilterPanel from 'components/ui/VnFilterPanel.vue';
|
|
||||||
import VnFilter from 'components/VnTable/VnFilter.vue';
|
|
||||||
import VnTableOrder from 'src/components/VnTable/VnOrder.vue';
|
|
||||||
|
|
||||||
defineProps({
|
|
||||||
columns: {
|
|
||||||
type: Array,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
searchUrl: {
|
|
||||||
type: [String, Boolean],
|
|
||||||
default: 'table',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const tableFilterRef = ref([]);
|
|
||||||
|
|
||||||
function columnName(col) {
|
|
||||||
const column = { ...col, ...col.columnFilter };
|
|
||||||
let name = column.name;
|
|
||||||
if (column.alias) name = column.alias + '.' + name;
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<VnFilterPanel v-bind="$attrs" :search-button="true" :disable-submit-event="true">
|
|
||||||
<template #body="{ params, orders }">
|
|
||||||
<div
|
|
||||||
class="row no-wrap flex-center"
|
|
||||||
v-for="col of columns.filter((c) => c.columnFilter ?? true)"
|
|
||||||
:key="col.id"
|
|
||||||
>
|
|
||||||
<VnFilter
|
|
||||||
ref="tableFilterRef"
|
|
||||||
:column="col"
|
|
||||||
:data-key="$attrs['data-key']"
|
|
||||||
v-model="params[columnName(col)]"
|
|
||||||
:search-url="searchUrl"
|
|
||||||
/>
|
|
||||||
<VnTableOrder
|
|
||||||
v-if="col?.columnFilter !== false && col?.name !== 'tableActions'"
|
|
||||||
v-model="orders[col.orderBy ?? col.name]"
|
|
||||||
:name="col.orderBy ?? col.name"
|
|
||||||
:data-key="$attrs['data-key']"
|
|
||||||
:search-url="searchUrl"
|
|
||||||
:vertical="true"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<slot
|
|
||||||
name="moreFilterPanel"
|
|
||||||
:params="params"
|
|
||||||
:orders="orders"
|
|
||||||
:columns="columns"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template #tags="{ tag, formatFn, getLocale }">
|
|
||||||
<div class="q-gutter-x-xs">
|
|
||||||
<strong>{{ getLocale(`${tag.label}`) }}: </strong>
|
|
||||||
<span>{{ formatFn(tag.value) }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</VnFilterPanel>
|
|
||||||
</template>
|
|
|
@ -135,7 +135,7 @@ onMounted(async () => {
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<QBtn icon="vn:visible_columns" class="bg-vn-section-color q-mr-sm q-px-sm" dense>
|
<QBtn icon="vn:visible_columns" class="bg-vn-section-color q-mr-md q-px-sm" dense>
|
||||||
<QPopupProxy ref="popupProxyRef">
|
<QPopupProxy ref="popupProxyRef">
|
||||||
<QCard class="column q-pa-md">
|
<QCard class="column q-pa-md">
|
||||||
<QIcon name="info" size="sm" class="info-icon">
|
<QIcon name="info" size="sm" class="info-icon">
|
||||||
|
@ -152,7 +152,7 @@ onMounted(async () => {
|
||||||
<QCheckbox
|
<QCheckbox
|
||||||
v-for="col in localColumns"
|
v-for="col in localColumns"
|
||||||
:key="col.name"
|
:key="col.name"
|
||||||
:label="col.label ?? col.name"
|
:label="col.label"
|
||||||
v-model="col.visible"
|
v-model="col.visible"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
import { describe, expect, it, beforeAll, beforeEach, vi } from 'vitest';
|
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
|
||||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
|
||||||
|
|
||||||
describe('VnTable', () => {
|
|
||||||
let wrapper;
|
|
||||||
let vm;
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
wrapper = createWrapper(VnTable, {
|
|
||||||
propsData: {
|
|
||||||
columns: [],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
vm = wrapper.vm;
|
|
||||||
|
|
||||||
vi.mock('src/composables/useFilterParams', () => {
|
|
||||||
return {
|
|
||||||
useFilterParams: vi.fn(() => ({
|
|
||||||
params: {},
|
|
||||||
orders: {},
|
|
||||||
})),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => (vm.selected = []));
|
|
||||||
|
|
||||||
describe('handleSelection()', () => {
|
|
||||||
const rows = [{ $index: 0 }, { $index: 1 }, { $index: 2 }];
|
|
||||||
const selectedRows = [{ $index: 1 }];
|
|
||||||
it('should add rows to selected when shift key is pressed and rows are added except last one', () => {
|
|
||||||
vm.handleSelection(
|
|
||||||
{ evt: { shiftKey: true }, added: true, rows: selectedRows },
|
|
||||||
rows
|
|
||||||
);
|
|
||||||
expect(vm.selected).toEqual([{ $index: 0 }]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not add rows to selected when shift key is not pressed', () => {
|
|
||||||
vm.handleSelection(
|
|
||||||
{ evt: { shiftKey: false }, added: true, rows: selectedRows },
|
|
||||||
rows
|
|
||||||
);
|
|
||||||
expect(vm.selected).toEqual([]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not add rows to selected when rows are not added', () => {
|
|
||||||
vm.handleSelection(
|
|
||||||
{ evt: { shiftKey: true }, added: false, rows: selectedRows },
|
|
||||||
rows
|
|
||||||
);
|
|
||||||
expect(vm.selected).toEqual([]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,248 +0,0 @@
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
|
||||||
import CrudModel from 'components/CrudModel.vue';
|
|
||||||
import { vi, afterEach, beforeEach, beforeAll, describe, expect, it } from 'vitest';
|
|
||||||
|
|
||||||
describe('CrudModel', () => {
|
|
||||||
let wrapper;
|
|
||||||
let vm;
|
|
||||||
let data;
|
|
||||||
beforeAll(() => {
|
|
||||||
wrapper = createWrapper(CrudModel, {
|
|
||||||
global: {
|
|
||||||
stubs: [
|
|
||||||
'vnPaginate',
|
|
||||||
'useState',
|
|
||||||
'arrayData',
|
|
||||||
'useStateStore',
|
|
||||||
'vue-i18n',
|
|
||||||
],
|
|
||||||
mocks: {
|
|
||||||
validate: vi.fn(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
propsData: {
|
|
||||||
dataRequired: {
|
|
||||||
fk: 1,
|
|
||||||
},
|
|
||||||
dataKey: 'crudModelKey',
|
|
||||||
model: 'crudModel',
|
|
||||||
url: 'crudModelUrl',
|
|
||||||
saveFn: '',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
wrapper=wrapper.wrapper;
|
|
||||||
vm=wrapper.vm;
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
vm.fetch([]);
|
|
||||||
vm.watchChanges = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('insert()', () => {
|
|
||||||
it('should new element in list with index 0 if formData not has data', () => {
|
|
||||||
vm.insert();
|
|
||||||
|
|
||||||
expect(vm.formData.length).toEqual(1);
|
|
||||||
expect(vm.formData[0].fk).toEqual(1);
|
|
||||||
expect(vm.formData[0].$index).toEqual(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getChanges()', () => {
|
|
||||||
it('should return correct updates and creates', async () => {
|
|
||||||
vm.fetch([
|
|
||||||
{ id: 1, name: 'New name one' },
|
|
||||||
{ id: 2, name: 'New name two' },
|
|
||||||
{ id: 3, name: 'Bruce Wayne' },
|
|
||||||
]);
|
|
||||||
|
|
||||||
vm.originalData = [
|
|
||||||
{ id: 1, name: 'Tony Starks' },
|
|
||||||
{ id: 2, name: 'Jessica Jones' },
|
|
||||||
{ id: 3, name: 'Bruce Wayne' },
|
|
||||||
];
|
|
||||||
|
|
||||||
vm.insert();
|
|
||||||
const result = vm.getChanges();
|
|
||||||
|
|
||||||
const expected = {
|
|
||||||
creates: [
|
|
||||||
{
|
|
||||||
$index: 3,
|
|
||||||
fk: 1,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
updates: [
|
|
||||||
{
|
|
||||||
data: {
|
|
||||||
name: 'New name one',
|
|
||||||
},
|
|
||||||
where: {
|
|
||||||
id: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: {
|
|
||||||
name: 'New name two',
|
|
||||||
},
|
|
||||||
where: {
|
|
||||||
id: 2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(result).toEqual(expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getDifferences()', () => {
|
|
||||||
it('should return the differences between two objects', async () => {
|
|
||||||
const obj1 = {
|
|
||||||
a: 1,
|
|
||||||
b: 2,
|
|
||||||
c: 3,
|
|
||||||
};
|
|
||||||
const obj2 = {
|
|
||||||
a: null,
|
|
||||||
b: 4,
|
|
||||||
d: 5,
|
|
||||||
};
|
|
||||||
|
|
||||||
const result = vm.getDifferences(obj1, obj2);
|
|
||||||
|
|
||||||
expect(result).toEqual({
|
|
||||||
a: null,
|
|
||||||
b: 4,
|
|
||||||
d: 5,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('isEmpty()', () => {
|
|
||||||
let dummyObj;
|
|
||||||
let dummyArray;
|
|
||||||
let result;
|
|
||||||
it('should return true if object si null', async () => {
|
|
||||||
dummyObj = null;
|
|
||||||
result = vm.isEmpty(dummyObj);
|
|
||||||
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return true if object si undefined', async () => {
|
|
||||||
dummyObj = undefined;
|
|
||||||
result = vm.isEmpty(dummyObj);
|
|
||||||
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return true if object is empty', async () => {
|
|
||||||
dummyObj ={};
|
|
||||||
result = vm.isEmpty(dummyObj);
|
|
||||||
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false if object is not empty', async () => {
|
|
||||||
dummyObj = {a:1, b:2, c:3};
|
|
||||||
result = vm.isEmpty(dummyObj);
|
|
||||||
|
|
||||||
expect(result).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return true if array is empty', async () => {
|
|
||||||
dummyArray = [];
|
|
||||||
result = vm.isEmpty(dummyArray);
|
|
||||||
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false if array is not empty', async () => {
|
|
||||||
dummyArray = [1,2,3];
|
|
||||||
result = vm.isEmpty(dummyArray);
|
|
||||||
|
|
||||||
expect(result).toBe(false);
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('resetData()', () => {
|
|
||||||
it('should add $index to elements in data[] and sets originalData and formData with data', async () => {
|
|
||||||
data = [{
|
|
||||||
name: 'Tony',
|
|
||||||
lastName: 'Stark',
|
|
||||||
age: 42,
|
|
||||||
}];
|
|
||||||
|
|
||||||
vm.resetData(data);
|
|
||||||
|
|
||||||
expect(vm.originalData).toEqual(data);
|
|
||||||
expect(vm.originalData[0].$index).toEqual(0);
|
|
||||||
expect(vm.formData).toEqual(data);
|
|
||||||
expect(vm.formData[0].$index).toEqual(0);
|
|
||||||
expect(vm.watchChanges).not.toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should dont do nothing if data is null', async () => {
|
|
||||||
vm.resetData(null);
|
|
||||||
|
|
||||||
expect(vm.watchChanges).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set originalData and formatData with data and generate watchChanges', async () => {
|
|
||||||
data = {
|
|
||||||
name: 'Tony',
|
|
||||||
lastName: 'Stark',
|
|
||||||
age: 42,
|
|
||||||
};
|
|
||||||
|
|
||||||
vm.resetData(data);
|
|
||||||
|
|
||||||
expect(vm.originalData).toEqual(data);
|
|
||||||
expect(vm.formData).toEqual(data);
|
|
||||||
expect(vm.watchChanges).not.toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('saveChanges()', () => {
|
|
||||||
data = [{
|
|
||||||
name: 'Tony',
|
|
||||||
lastName: 'Stark',
|
|
||||||
age: 42,
|
|
||||||
}];
|
|
||||||
|
|
||||||
it('should call saveFn if exists', async () => {
|
|
||||||
await wrapper.setProps({ saveFn: vi.fn() });
|
|
||||||
|
|
||||||
vm.saveChanges(data);
|
|
||||||
|
|
||||||
expect(vm.saveFn).toHaveBeenCalledOnce();
|
|
||||||
expect(vm.isLoading).toBe(false);
|
|
||||||
expect(vm.hasChanges).toBe(false);
|
|
||||||
|
|
||||||
await wrapper.setProps({ saveFn: '' });
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should use default url if there's not saveFn", async () => {
|
|
||||||
const postMock =vi.spyOn(axios, 'post');
|
|
||||||
|
|
||||||
vm.formData = [{
|
|
||||||
name: 'Bruce',
|
|
||||||
lastName: 'Wayne',
|
|
||||||
age: 45,
|
|
||||||
}]
|
|
||||||
|
|
||||||
await vm.saveChanges(data);
|
|
||||||
|
|
||||||
expect(postMock).toHaveBeenCalledWith(vm.url + '/crud', data);
|
|
||||||
expect(vm.isLoading).toBe(false);
|
|
||||||
expect(vm.hasChanges).toBe(false);
|
|
||||||
expect(vm.originalData).toEqual(JSON.parse(JSON.stringify(vm.formData)));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,56 +0,0 @@
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
|
||||||
import EditForm from 'components/EditTableCellValueForm.vue';
|
|
||||||
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
|
||||||
|
|
||||||
const fieldA = 'fieldA';
|
|
||||||
const fieldB = 'fieldB';
|
|
||||||
|
|
||||||
describe('EditForm', () => {
|
|
||||||
let vm;
|
|
||||||
const mockRows = [
|
|
||||||
{ id: 1, itemFk: 101 },
|
|
||||||
{ id: 2, itemFk: 102 },
|
|
||||||
];
|
|
||||||
const mockFieldsOptions = [
|
|
||||||
{ label: 'Field A', field: fieldA, component: 'input', attrs: {} },
|
|
||||||
{ label: 'Field B', field: fieldB, component: 'date', attrs: {} },
|
|
||||||
];
|
|
||||||
const editUrl = '/api/edit';
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
vi.spyOn(axios, 'post').mockResolvedValue({ status: 200 });
|
|
||||||
vm = createWrapper(EditForm, {
|
|
||||||
props: {
|
|
||||||
rows: mockRows,
|
|
||||||
fieldsOptions: mockFieldsOptions,
|
|
||||||
editUrl,
|
|
||||||
},
|
|
||||||
}).vm;
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
|
||||||
it('should call axios.post with the correct parameters in the payload', async () => {
|
|
||||||
const selectedField = { field: fieldA, component: 'input', attrs: {} };
|
|
||||||
const newValue = 'Test Value';
|
|
||||||
|
|
||||||
vm.selectedField = selectedField;
|
|
||||||
vm.newValue = newValue;
|
|
||||||
|
|
||||||
await vm.onSubmit();
|
|
||||||
|
|
||||||
const payload = axios.post.mock.calls[0][1];
|
|
||||||
|
|
||||||
expect(axios.post).toHaveBeenCalledWith(editUrl, expect.any(Object));
|
|
||||||
expect(payload.field).toEqual(fieldA);
|
|
||||||
expect(payload.newValue).toEqual(newValue);
|
|
||||||
|
|
||||||
expect(payload.lines).toEqual(expect.arrayContaining(mockRows));
|
|
||||||
|
|
||||||
expect(vm.isLoading).toEqual(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,82 +0,0 @@
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
|
||||||
import FilterItemForm from 'src/components/FilterItemForm.vue';
|
|
||||||
import { vi, beforeAll, describe, expect, it } from 'vitest';
|
|
||||||
|
|
||||||
describe('FilterItemForm', () => {
|
|
||||||
let vm;
|
|
||||||
let wrapper;
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
wrapper = createWrapper(FilterItemForm, {
|
|
||||||
props: {
|
|
||||||
url: 'Items/withName',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
vm = wrapper.vm;
|
|
||||||
wrapper = wrapper.wrapper;
|
|
||||||
|
|
||||||
vi.spyOn(axios, 'get').mockResolvedValue({
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: 999996,
|
|
||||||
name: 'bolas de madera',
|
|
||||||
size: 2,
|
|
||||||
inkFk: null,
|
|
||||||
producerFk: null,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should filter data and populate tableRows for table display', async () => {
|
|
||||||
vm.itemFilterParams.name = 'bolas de madera';
|
|
||||||
|
|
||||||
await vm.onSubmit();
|
|
||||||
|
|
||||||
const expectedFilter = {
|
|
||||||
include: [
|
|
||||||
{ relation: 'producer', scope: { fields: ['name'] } },
|
|
||||||
{ relation: 'ink', scope: { fields: ['name'] } },
|
|
||||||
],
|
|
||||||
where: {"name":{"like":"%bolas de madera%"}},
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(axios.get).toHaveBeenCalledWith('Items/withName', {
|
|
||||||
params: { filter: JSON.stringify(expectedFilter) },
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(vm.tableRows).toEqual([
|
|
||||||
{
|
|
||||||
id: 999996,
|
|
||||||
name: 'bolas de madera',
|
|
||||||
size: 2,
|
|
||||||
inkFk: null,
|
|
||||||
producerFk: null,
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle an empty itemFilterParams correctly', async () => {
|
|
||||||
vm.itemFilterParams.name = null;
|
|
||||||
vm.itemFilterParams = {};
|
|
||||||
|
|
||||||
await vm.onSubmit();
|
|
||||||
|
|
||||||
const expectedFilter = {
|
|
||||||
include: [
|
|
||||||
{ relation: 'producer', scope: { fields: ['name'] } },
|
|
||||||
{ relation: 'ink', scope: { fields: ['name'] } },
|
|
||||||
],
|
|
||||||
where: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(axios.get).toHaveBeenCalledWith('Items/withName', {
|
|
||||||
params: { filter: JSON.stringify(expectedFilter) },
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should emit "itemSelected" with the correct id and close the form', () => {
|
|
||||||
vm.selectItem({ id: 12345 });
|
|
||||||
expect(wrapper.emitted('itemSelected')[0]).toEqual([12345]);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,149 +0,0 @@
|
||||||
import { describe, expect, it, beforeAll, vi, afterAll } from 'vitest';
|
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
|
||||||
import FormModel from 'src/components/FormModel.vue';
|
|
||||||
|
|
||||||
describe('FormModel', () => {
|
|
||||||
const model = 'mockModel';
|
|
||||||
const url = 'mockUrl';
|
|
||||||
const formInitialData = { mockKey: 'mockVal' };
|
|
||||||
|
|
||||||
describe('modelValue', () => {
|
|
||||||
it('should use the provided model', () => {
|
|
||||||
const { vm } = mount({ propsData: { model } });
|
|
||||||
expect(vm.modelValue).toBe(model);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should use the route meta title when model is not provided', () => {
|
|
||||||
const { vm } = mount({});
|
|
||||||
expect(vm.modelValue).toBe('formModel_mockTitle');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('onMounted()', () => {
|
|
||||||
let mockGet;
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
mockGet = vi.spyOn(axios, 'get').mockResolvedValue({ data: {} });
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(() => {
|
|
||||||
mockGet.mockRestore();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not fetch when has formInitialData', () => {
|
|
||||||
mount({ propsData: { url, model, autoLoad: true, formInitialData } });
|
|
||||||
expect(mockGet).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should fetch when there is url and auto-load', () => {
|
|
||||||
mount({ propsData: { url, model, autoLoad: true } });
|
|
||||||
expect(mockGet).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not observe changes', () => {
|
|
||||||
const { vm } = mount({
|
|
||||||
propsData: { url, model, observeFormChanges: false, formInitialData },
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(vm.hasChanges).toBe(true);
|
|
||||||
vm.reset();
|
|
||||||
expect(vm.hasChanges).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should observe changes', async () => {
|
|
||||||
const { vm } = mount({
|
|
||||||
propsData: { url, model, formInitialData },
|
|
||||||
});
|
|
||||||
vm.state.set(model, formInitialData);
|
|
||||||
expect(vm.hasChanges).toBe(false);
|
|
||||||
|
|
||||||
vm.formData.mockKey = 'newVal';
|
|
||||||
await vm.$nextTick();
|
|
||||||
expect(vm.hasChanges).toBe(true);
|
|
||||||
vm.formData.mockKey = 'mockVal';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('trimData()', () => {
|
|
||||||
let vm;
|
|
||||||
beforeAll(() => {
|
|
||||||
vm = mount({}).vm;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should trim whitespace from string values', () => {
|
|
||||||
const data = { key1: ' value1 ', key2: ' value2 ' };
|
|
||||||
const trimmedData = vm.trimData(data);
|
|
||||||
expect(trimmedData).toEqual({ key1: 'value1', key2: 'value2' });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not modify non-string values', () => {
|
|
||||||
const data = { key1: 123, key2: true, key3: null, key4: undefined };
|
|
||||||
const trimmedData = vm.trimData(data);
|
|
||||||
expect(trimmedData).toEqual(data);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('save()', async () => {
|
|
||||||
it('should not call if there are not changes', async () => {
|
|
||||||
const { vm } = mount({ propsData: { url, model } });
|
|
||||||
|
|
||||||
await vm.save();
|
|
||||||
expect(vm.hasChanges).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call axios.patch with the right data', async () => {
|
|
||||||
const spy = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
|
||||||
const { vm } = mount({ propsData: { url, model, formInitialData } });
|
|
||||||
vm.formData.mockKey = 'newVal';
|
|
||||||
await vm.$nextTick();
|
|
||||||
await vm.save();
|
|
||||||
expect(spy).toHaveBeenCalled();
|
|
||||||
vm.formData.mockKey = 'mockVal';
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call axios.post with the right data', async () => {
|
|
||||||
const spy = vi.spyOn(axios, 'post').mockResolvedValue({ data: {} });
|
|
||||||
const { vm } = mount({
|
|
||||||
propsData: { url, model, formInitialData, urlCreate: 'mockUrlCreate' },
|
|
||||||
});
|
|
||||||
vm.formData.mockKey = 'newVal';
|
|
||||||
await vm.$nextTick();
|
|
||||||
await vm.save();
|
|
||||||
expect(spy).toHaveBeenCalled();
|
|
||||||
vm.formData.mockKey = 'mockVal';
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should use the saveFn', async () => {
|
|
||||||
const { vm } = mount({
|
|
||||||
propsData: { url, model, formInitialData, saveFn: () => {} },
|
|
||||||
});
|
|
||||||
const spyPatch = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
|
||||||
const spySaveFn = vi.spyOn(vm.$props, 'saveFn');
|
|
||||||
|
|
||||||
vm.formData.mockKey = 'newVal';
|
|
||||||
await vm.$nextTick();
|
|
||||||
await vm.save();
|
|
||||||
expect(spyPatch).not.toHaveBeenCalled();
|
|
||||||
expect(spySaveFn).toHaveBeenCalled();
|
|
||||||
vm.formData.mockKey = 'mockVal';
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should reload the data after save', async () => {
|
|
||||||
const { vm } = mount({
|
|
||||||
propsData: { url, model, formInitialData, reload: true },
|
|
||||||
});
|
|
||||||
vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
|
||||||
|
|
||||||
vm.formData.mockKey = 'newVal';
|
|
||||||
await vm.$nextTick();
|
|
||||||
await vm.save();
|
|
||||||
vm.formData.mockKey = 'mockVal';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function mount({ propsData = {} }) {
|
|
||||||
return createWrapper(FormModel, {
|
|
||||||
propsData,
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -1,20 +1,32 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, useSlots } from 'vue';
|
import { ref, onMounted, useSlots } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { useQuasar } from 'quasar';
|
|
||||||
import { useHasContent } from 'src/composables/useHasContent';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
const quasar = useQuasar();
|
|
||||||
const stateStore = useStateStore();
|
|
||||||
const slots = useSlots();
|
const slots = useSlots();
|
||||||
const hasContent = useHasContent('#right-panel');
|
const hasContent = ref(false);
|
||||||
|
const rightPanel = ref(null);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if ((!slots['right-panel'] && !hasContent.value) || quasar.platform.is.mobile)
|
rightPanel.value = document.querySelector('#right-panel');
|
||||||
stateStore.rightDrawer = false;
|
if (!rightPanel.value) return;
|
||||||
|
|
||||||
|
// Check if there's content to display
|
||||||
|
const observer = new MutationObserver(() => {
|
||||||
|
hasContent.value = rightPanel.value.childNodes.length;
|
||||||
|
});
|
||||||
|
|
||||||
|
observer.observe(rightPanel.value, {
|
||||||
|
subtree: true,
|
||||||
|
childList: true,
|
||||||
|
attributes: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!slots['right-panel'] && !hasContent.value) stateStore.rightDrawer = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const stateStore = useStateStore();
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<Teleport to="#actions-append" v-if="stateStore.isHeaderMounted()">
|
<Teleport to="#actions-append" v-if="stateStore.isHeaderMounted()">
|
||||||
|
@ -25,7 +37,7 @@ onMounted(() => {
|
||||||
@click="stateStore.toggleRightDrawer()"
|
@click="stateStore.toggleRightDrawer()"
|
||||||
round
|
round
|
||||||
dense
|
dense
|
||||||
icon="dock_to_left"
|
icon="menu"
|
||||||
>
|
>
|
||||||
<QTooltip bottom anchor="bottom right">
|
<QTooltip bottom anchor="bottom right">
|
||||||
{{ t('globals.collapseMenu') }}
|
{{ t('globals.collapseMenu') }}
|
||||||
|
@ -33,7 +45,7 @@ onMounted(() => {
|
||||||
</QBtn>
|
</QBtn>
|
||||||
</div>
|
</div>
|
||||||
</Teleport>
|
</Teleport>
|
||||||
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256">
|
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
|
||||||
<QScrollArea class="fit">
|
<QScrollArea class="fit">
|
||||||
<div id="right-panel"></div>
|
<div id="right-panel"></div>
|
||||||
<slot v-if="!hasContent" name="right-panel" />
|
<slot v-if="!hasContent" name="right-panel" />
|
||||||
|
|
|
@ -58,71 +58,79 @@ const getConfig = async (url, filter) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchViewConfigData = async () => {
|
const fetchViewConfigData = async () => {
|
||||||
const userConfigFilter = {
|
try {
|
||||||
where: { tableCode: $props.tableCode, userFk: user.value.id },
|
const userConfigFilter = {
|
||||||
};
|
where: { tableCode: $props.tableCode, userFk: user.value.id },
|
||||||
const userConfig = await getConfig('UserConfigViews', userConfigFilter);
|
};
|
||||||
|
const userConfig = await getConfig('UserConfigViews', userConfigFilter);
|
||||||
|
|
||||||
if (userConfig) {
|
if (userConfig) {
|
||||||
initialUserConfigViewData.value = userConfig;
|
initialUserConfigViewData.value = userConfig;
|
||||||
setUserConfigViewData(userConfig.configuration);
|
setUserConfigViewData(userConfig.configuration);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultConfigFilter = { where: { tableCode: $props.tableCode } };
|
const defaultConfigFilter = { where: { tableCode: $props.tableCode } };
|
||||||
const defaultConfig = await getConfig('DefaultViewConfigs', defaultConfigFilter);
|
const defaultConfig = await getConfig('DefaultViewConfigs', defaultConfigFilter);
|
||||||
|
|
||||||
if (defaultConfig) {
|
if (defaultConfig) {
|
||||||
// Si el backend devuelve una configuración por defecto la usamos
|
// Si el backend devuelve una configuración por defecto la usamos
|
||||||
setUserConfigViewData(defaultConfig.columns);
|
setUserConfigViewData(defaultConfig.columns);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// Si no hay configuración por defecto mostramos todas las columnas
|
// Si no hay configuración por defecto mostramos todas las columnas
|
||||||
const defaultColumns = {};
|
const defaultColumns = {};
|
||||||
$props.allColumns.forEach((col) => (defaultColumns[col] = true));
|
$props.allColumns.forEach((col) => (defaultColumns[col] = true));
|
||||||
setUserConfigViewData(defaultColumns);
|
setUserConfigViewData(defaultColumns);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching config view data', err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveConfig = async () => {
|
const saveConfig = async () => {
|
||||||
const params = {};
|
try {
|
||||||
const configuration = {};
|
const params = {};
|
||||||
|
const configuration = {};
|
||||||
|
|
||||||
formattedCols.value.forEach((col) => {
|
formattedCols.value.forEach((col) => {
|
||||||
const { name, active } = col;
|
const { name, active } = col;
|
||||||
configuration[name] = active;
|
configuration[name] = active;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Si existe una view config del usuario hacemos un update si no la creamos
|
// Si existe una view config del usuario hacemos un update si no la creamos
|
||||||
if (initialUserConfigViewData.value) {
|
if (initialUserConfigViewData.value) {
|
||||||
params.updates = [
|
params.updates = [
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
|
configuration: configuration,
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
id: initialUserConfigViewData.value.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
params.creates = [
|
||||||
|
{
|
||||||
|
userFk: user.value.id,
|
||||||
|
tableCode: $props.tableCode,
|
||||||
|
tableConfig: $props.tableCode,
|
||||||
configuration: configuration,
|
configuration: configuration,
|
||||||
},
|
},
|
||||||
where: {
|
];
|
||||||
id: initialUserConfigViewData.value.id,
|
}
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
params.creates = [
|
|
||||||
{
|
|
||||||
userFk: user.value.id,
|
|
||||||
tableCode: $props.tableCode,
|
|
||||||
tableConfig: $props.tableCode,
|
|
||||||
configuration: configuration,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await axios.post('UserConfigViews/crud', params);
|
const response = await axios.post('UserConfigViews/crud', params);
|
||||||
if (response.data && response.data[0]) {
|
if (response.data && response.data[0]) {
|
||||||
initialUserConfigViewData.value = response.data[0];
|
initialUserConfigViewData.value = response.data[0];
|
||||||
|
}
|
||||||
|
emitSavedConfig();
|
||||||
|
notify('globals.dataSaved', 'positive');
|
||||||
|
popupProxyRef.value.hide();
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error saving user view config', err);
|
||||||
}
|
}
|
||||||
emitSavedConfig();
|
|
||||||
notify('globals.dataSaved', 'positive');
|
|
||||||
popupProxyRef.value.hide();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const emitSavedConfig = () => {
|
const emitSavedConfig = () => {
|
||||||
|
|
|
@ -1,24 +1,20 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { nextTick, ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
import { QInput } from 'quasar';
|
import { QInput } from 'quasar';
|
||||||
|
|
||||||
const $props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
insertable: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'accountShortToStandard']);
|
const emit = defineEmits(['update:modelValue', 'accountShortToStandard']);
|
||||||
|
|
||||||
let internalValue = ref($props.modelValue);
|
let internalValue = ref(props.modelValue);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => $props.modelValue,
|
() => props.modelValue,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
internalValue.value = newVal;
|
internalValue.value = newVal;
|
||||||
}
|
}
|
||||||
|
@ -32,46 +28,8 @@ watch(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleKeydown = (e) => {
|
|
||||||
if (e.key === 'Backspace') return;
|
|
||||||
if (e.key === '.') {
|
|
||||||
accountShortToStandard();
|
|
||||||
// TODO: Fix this setTimeout, with nextTick doesn't work
|
|
||||||
setTimeout(() => {
|
|
||||||
setCursorPosition(0, e.target);
|
|
||||||
}, 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($props.insertable && e.key.match(/[0-9]/)) {
|
|
||||||
handleInsertMode(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
function setCursorPosition(pos, el = vnInputRef.value) {
|
|
||||||
el.focus();
|
|
||||||
el.setSelectionRange(pos, pos);
|
|
||||||
}
|
|
||||||
const vnInputRef = ref(false);
|
|
||||||
const handleInsertMode = (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
const input = e.target;
|
|
||||||
const cursorPos = input.selectionStart;
|
|
||||||
const { maxlength } = vnInputRef.value;
|
|
||||||
let currentValue = internalValue.value;
|
|
||||||
if (!currentValue) currentValue = e.key;
|
|
||||||
const newValue = e.key;
|
|
||||||
if (newValue && !isNaN(newValue) && cursorPos < maxlength) {
|
|
||||||
internalValue.value =
|
|
||||||
currentValue.substring(0, cursorPos) +
|
|
||||||
newValue +
|
|
||||||
currentValue.substring(cursorPos + 1);
|
|
||||||
}
|
|
||||||
nextTick(() => {
|
|
||||||
input.setSelectionRange(cursorPos + 1, cursorPos + 1);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
function accountShortToStandard() {
|
function accountShortToStandard() {
|
||||||
internalValue.value = internalValue.value?.replace(
|
internalValue.value = internalValue.value.replace(
|
||||||
'.',
|
'.',
|
||||||
'0'.repeat(11 - internalValue.value.length)
|
'0'.repeat(11 - internalValue.value.length)
|
||||||
);
|
);
|
||||||
|
@ -79,5 +37,5 @@ function accountShortToStandard() {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<QInput @keydown="handleKeydown" ref="vnInputRef" v-model="internalValue" />
|
<q-input v-model="internalValue" />
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -15,7 +15,7 @@ let root = ref(null);
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
matched.value = currentRoute.value.matched.filter(
|
matched.value = currentRoute.value.matched.filter(
|
||||||
(matched) => !!matched?.meta?.title || !!matched?.meta?.icon
|
(matched) => Object.keys(matched.meta).length
|
||||||
);
|
);
|
||||||
breadcrumbs.value.length = 0;
|
breadcrumbs.value.length = 0;
|
||||||
if (!matched.value[0]) return;
|
if (!matched.value[0]) return;
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import VnSelect from './VnSelect.vue';
|
|
||||||
|
|
||||||
defineProps({
|
|
||||||
selectProps: { type: Object, required: true },
|
|
||||||
promise: { type: Function, default: () => {} },
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<QBtnDropdown v-bind="$attrs" color="primary">
|
|
||||||
<VnSelect
|
|
||||||
v-bind="selectProps"
|
|
||||||
hide-selected
|
|
||||||
hide-dropdown-icon
|
|
||||||
focus-on-mount
|
|
||||||
@update:model-value="promise"
|
|
||||||
data-cy="vnBtnSelect_select"
|
|
||||||
/>
|
|
||||||
</QBtnDropdown>
|
|
||||||
</template>
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onBeforeMount, computed } from 'vue';
|
import { onBeforeMount, computed } from 'vue';
|
||||||
import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router';
|
import { useRoute, 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';
|
||||||
|
@ -8,6 +8,7 @@ import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
||||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||||
import LeftMenu from 'components/LeftMenu.vue';
|
import LeftMenu from 'components/LeftMenu.vue';
|
||||||
import RightMenu from 'components/common/RightMenu.vue';
|
import RightMenu from 'components/common/RightMenu.vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
dataKey: { type: String, required: true },
|
dataKey: { type: String, required: true },
|
||||||
baseUrl: { type: String, default: undefined },
|
baseUrl: { type: String, default: undefined },
|
||||||
|
@ -17,36 +18,23 @@ const props = defineProps({
|
||||||
filterPanel: { type: Object, default: undefined },
|
filterPanel: { type: Object, default: undefined },
|
||||||
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 },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
|
||||||
const url = computed(() => {
|
const url = computed(() => {
|
||||||
if (props.baseUrl) {
|
if (props.baseUrl) return `${props.baseUrl}/${route.params.id}`;
|
||||||
return `${props.baseUrl}/${route.params.id}`;
|
|
||||||
}
|
|
||||||
return props.customUrl;
|
return props.customUrl;
|
||||||
});
|
});
|
||||||
const searchRightDataKey = computed(() => {
|
|
||||||
if (!props.searchDataKey) return route.name;
|
|
||||||
return props.searchDataKey;
|
|
||||||
});
|
|
||||||
const arrayData = useArrayData(props.dataKey, {
|
const arrayData = useArrayData(props.dataKey, {
|
||||||
url: url.value,
|
url: url.value,
|
||||||
filter: props.filter,
|
filter: props.filter,
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
try {
|
if (!props.baseUrl) arrayData.store.filter.where = { id: route.params.id };
|
||||||
if (!props.baseUrl) arrayData.store.filter.where = { id: route.params.id };
|
await arrayData.fetch({ append: false, updateRouter: false });
|
||||||
await arrayData.fetch({ append: false, updateRouter: false });
|
|
||||||
} catch {
|
|
||||||
const { matched: matches } = router.currentRoute.value;
|
|
||||||
const { path } = matches.at(-1);
|
|
||||||
router.push({ path: path.replace(/:id.*/, '') });
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (props.baseUrl) {
|
if (props.baseUrl) {
|
||||||
|
@ -74,16 +62,17 @@ if (props.baseUrl) {
|
||||||
<slot name="searchbar" v-if="props.searchDataKey">
|
<slot name="searchbar" v-if="props.searchDataKey">
|
||||||
<VnSearchbar :data-key="props.searchDataKey" v-bind="props.searchbarProps" />
|
<VnSearchbar :data-key="props.searchDataKey" v-bind="props.searchbarProps" />
|
||||||
</slot>
|
</slot>
|
||||||
|
<slot v-else name="searchbar" />
|
||||||
<RightMenu>
|
<RightMenu>
|
||||||
<template #right-panel v-if="props.filterPanel">
|
<template #right-panel v-if="props.filterPanel">
|
||||||
<component :is="props.filterPanel" :data-key="searchRightDataKey" />
|
<component :is="props.filterPanel" :data-key="props.searchDataKey" />
|
||||||
</template>
|
</template>
|
||||||
</RightMenu>
|
</RightMenu>
|
||||||
<QPageContainer>
|
<QPageContainer>
|
||||||
<QPage>
|
<QPage>
|
||||||
<VnSubToolbar />
|
<VnSubToolbar />
|
||||||
<div :class="[useCardSize(), $attrs.class]">
|
<div :class="[useCardSize(), $attrs.class]">
|
||||||
<RouterView :key="route.path" />
|
<RouterView />
|
||||||
</div>
|
</div>
|
||||||
</QPage>
|
</QPage>
|
||||||
</QPageContainer>
|
</QPageContainer>
|
||||||
|
|
|
@ -1,67 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { onBeforeMount, computed } from 'vue';
|
|
||||||
import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router';
|
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
|
||||||
import useCardSize from 'src/composables/useCardSize';
|
|
||||||
import LeftMenu from 'components/LeftMenu.vue';
|
|
||||||
import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
dataKey: { type: String, required: true },
|
|
||||||
baseUrl: { type: String, default: undefined },
|
|
||||||
customUrl: { type: String, default: undefined },
|
|
||||||
filter: { type: Object, default: () => {} },
|
|
||||||
descriptor: { type: Object, required: true },
|
|
||||||
filterPanel: { type: Object, default: undefined },
|
|
||||||
searchDataKey: { type: String, default: undefined },
|
|
||||||
searchbarProps: { type: Object, default: undefined },
|
|
||||||
redirectOnError: { type: Boolean, default: false },
|
|
||||||
});
|
|
||||||
|
|
||||||
const stateStore = useStateStore();
|
|
||||||
const route = useRoute();
|
|
||||||
const router = useRouter();
|
|
||||||
const url = computed(() => {
|
|
||||||
if (props.baseUrl) {
|
|
||||||
return `${props.baseUrl}/${route.params.id}`;
|
|
||||||
}
|
|
||||||
return props.customUrl;
|
|
||||||
});
|
|
||||||
|
|
||||||
const arrayData = useArrayData(props.dataKey, {
|
|
||||||
url: url.value,
|
|
||||||
filter: props.filter,
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
|
||||||
try {
|
|
||||||
if (!props.baseUrl) arrayData.store.filter.where = { id: route.params.id };
|
|
||||||
await arrayData.fetch({ append: false, updateRouter: false });
|
|
||||||
} catch {
|
|
||||||
const { matched: matches } = router.currentRoute.value;
|
|
||||||
const { path } = matches.at(-1);
|
|
||||||
router.push({ path: path.replace(/:id.*/, '') });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (props.baseUrl) {
|
|
||||||
onBeforeRouteUpdate(async (to, from) => {
|
|
||||||
if (to.params.id !== from.params.id) {
|
|
||||||
arrayData.store.url = `${props.baseUrl}/${to.params.id}`;
|
|
||||||
await arrayData.fetch({ append: false, updateRouter: false });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<Teleport to="#left-panel" v-if="stateStore.isHeaderMounted()">
|
|
||||||
<component :is="descriptor" />
|
|
||||||
<QSeparator />
|
|
||||||
<LeftMenu source="card" />
|
|
||||||
</Teleport>
|
|
||||||
<VnSubToolbar />
|
|
||||||
<div :class="[useCardSize(), $attrs.class]">
|
|
||||||
<RouterView :key="route.path" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
|
@ -1,136 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import VnRow from '../ui/VnRow.vue';
|
|
||||||
import FetchData from '../FetchData.vue';
|
|
||||||
import useNotify from 'src/composables/useNotify';
|
|
||||||
import VnInputPassword from 'src/components/common/VnInputPassword.vue';
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
submitFn: { type: Function, default: () => {} },
|
|
||||||
askOldPass: { type: Boolean, default: false },
|
|
||||||
});
|
|
||||||
const emit = defineEmits(['onSubmit']);
|
|
||||||
const { t } = useI18n();
|
|
||||||
const { notify } = useNotify();
|
|
||||||
|
|
||||||
const form = ref();
|
|
||||||
const changePassDialog = ref();
|
|
||||||
const passwords = ref({ newPassword: null, repeatPassword: null });
|
|
||||||
const requirements = ref([]);
|
|
||||||
const isLoading = ref(false);
|
|
||||||
|
|
||||||
const validate = async () => {
|
|
||||||
const { newPassword, repeatPassword, oldPassword } = passwords.value;
|
|
||||||
|
|
||||||
if (!newPassword) {
|
|
||||||
notify(t('You must enter a new password'), 'negative');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (newPassword !== repeatPassword) {
|
|
||||||
notify(t("Passwords don't match"), 'negative');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
isLoading.value = true;
|
|
||||||
await props.submitFn(newPassword, oldPassword);
|
|
||||||
emit('onSubmit');
|
|
||||||
} catch (e) {
|
|
||||||
notify('errors.writeRequest', 'negative');
|
|
||||||
} finally {
|
|
||||||
changePassDialog.value.hide();
|
|
||||||
isLoading.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
defineExpose({ show: () => changePassDialog.value.show() });
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<FetchData
|
|
||||||
url="UserPasswords/findOne"
|
|
||||||
auto-load
|
|
||||||
@on-fetch="(data) => (requirements = data)"
|
|
||||||
/>
|
|
||||||
<QDialog ref="changePassDialog">
|
|
||||||
<QCard style="width: 350px">
|
|
||||||
<QCardSection>
|
|
||||||
<slot name="header">
|
|
||||||
<VnRow class="items-center" style="flex-direction: row">
|
|
||||||
<span class="text-h6" v-text="t('globals.changePass')" />
|
|
||||||
<QIcon
|
|
||||||
class="cursor-pointer"
|
|
||||||
name="close"
|
|
||||||
size="xs"
|
|
||||||
style="flex: 0"
|
|
||||||
v-close-popup
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
</slot>
|
|
||||||
</QCardSection>
|
|
||||||
<QForm ref="form">
|
|
||||||
<QCardSection>
|
|
||||||
<VnInputPassword
|
|
||||||
v-if="props.askOldPass"
|
|
||||||
:label="t('Old password')"
|
|
||||||
v-model="passwords.oldPassword"
|
|
||||||
:required="true"
|
|
||||||
:toggle-visibility="true"
|
|
||||||
autofocus
|
|
||||||
/>
|
|
||||||
<VnInputPassword
|
|
||||||
:label="t('New password')"
|
|
||||||
v-model="passwords.newPassword"
|
|
||||||
:required="true"
|
|
||||||
:toggle-visibility="true"
|
|
||||||
:info="
|
|
||||||
t('passwordRequirements', {
|
|
||||||
length: requirements.length,
|
|
||||||
nAlpha: requirements.nAlpha,
|
|
||||||
nUpper: requirements.nUpper,
|
|
||||||
nDigits: requirements.nDigits,
|
|
||||||
nPunct: requirements.nPunct,
|
|
||||||
})
|
|
||||||
"
|
|
||||||
autofocus
|
|
||||||
/>
|
|
||||||
|
|
||||||
<VnInputPassword
|
|
||||||
:label="t('Repeat password')"
|
|
||||||
v-model="passwords.repeatPassword"
|
|
||||||
:toggle-visibility="true"
|
|
||||||
/>
|
|
||||||
</QCardSection>
|
|
||||||
</QForm>
|
|
||||||
<QCardActions>
|
|
||||||
<slot name="actions">
|
|
||||||
<QBtn
|
|
||||||
:disabled="isLoading"
|
|
||||||
:loading="isLoading"
|
|
||||||
:label="t('globals.cancel')"
|
|
||||||
class="q-ml-sm"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
type="reset"
|
|
||||||
v-close-popup
|
|
||||||
/>
|
|
||||||
<QBtn
|
|
||||||
:disabled="isLoading"
|
|
||||||
:loading="isLoading"
|
|
||||||
:label="t('globals.confirm')"
|
|
||||||
color="primary"
|
|
||||||
@click="validate"
|
|
||||||
/>
|
|
||||||
</slot>
|
|
||||||
</QCardActions>
|
|
||||||
</QCard>
|
|
||||||
</QDialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
New password: Nueva contraseña
|
|
||||||
Repeat password: Repetir contraseña
|
|
||||||
You must enter a new password: Debes introducir la nueva contraseña
|
|
||||||
Passwords don't match: Las contraseñas no coinciden
|
|
||||||
</i18n>
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from 'vue';
|
import { computed, defineModel } from 'vue';
|
||||||
|
|
||||||
const model = defineModel(undefined, { required: true });
|
const model = defineModel(undefined, { required: true });
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
|
@ -17,15 +17,17 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let mixed;
|
||||||
const componentArray = computed(() => {
|
const componentArray = computed(() => {
|
||||||
if (typeof $props.prop === 'object') return [$props.prop];
|
if (typeof $props.prop === 'object') return [$props.prop];
|
||||||
return $props.prop;
|
return $props.prop;
|
||||||
});
|
});
|
||||||
|
|
||||||
function mix(toComponent) {
|
function mix(toComponent) {
|
||||||
|
if (mixed) return mixed;
|
||||||
const { component, attrs, event } = toComponent;
|
const { component, attrs, event } = toComponent;
|
||||||
const customComponent = $props.components[component];
|
const customComponent = $props.components[component];
|
||||||
return {
|
mixed = {
|
||||||
component: customComponent?.component ?? component,
|
component: customComponent?.component ?? component,
|
||||||
attrs: {
|
attrs: {
|
||||||
...toValueAttrs(attrs),
|
...toValueAttrs(attrs),
|
||||||
|
@ -35,6 +37,7 @@ function mix(toComponent) {
|
||||||
},
|
},
|
||||||
event: { ...customComponent?.event, ...event },
|
event: { ...customComponent?.event, ...event },
|
||||||
};
|
};
|
||||||
|
return mixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toValueAttrs(attrs) {
|
function toValueAttrs(attrs) {
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
<script setup>
|
|
||||||
const model = defineModel({ type: [String, Number], required: true });
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<QDate v-model="model" :today-btn="true" :options="$attrs.options" />
|
|
||||||
</template>
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.q-date {
|
|
||||||
width: 245px;
|
|
||||||
min-width: unset;
|
|
||||||
|
|
||||||
:deep(.q-date__calendar) {
|
|
||||||
padding-bottom: 0;
|
|
||||||
}
|
|
||||||
:deep(.q-date__view) {
|
|
||||||
min-height: 245px;
|
|
||||||
padding: 8px;
|
|
||||||
}
|
|
||||||
:deep(.q-date__calendar-days-container) {
|
|
||||||
min-height: 160px;
|
|
||||||
height: unset;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.q-date__header) {
|
|
||||||
padding: 2px 2px 5px 12px;
|
|
||||||
height: 60px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,39 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { toDateFormat } from 'src/filters/date.js';
|
|
||||||
|
|
||||||
defineProps({ date: { type: [Date, String], required: true } });
|
|
||||||
|
|
||||||
function getBadgeAttrs(date) {
|
|
||||||
let today = Date.vnNew();
|
|
||||||
today.setHours(0, 0, 0, 0);
|
|
||||||
let timeTicket = new Date(date);
|
|
||||||
timeTicket.setHours(0, 0, 0, 0);
|
|
||||||
|
|
||||||
let timeDiff = today - timeTicket;
|
|
||||||
|
|
||||||
if (timeDiff == 0) return { color: 'warning', class: 'black-text-color' };
|
|
||||||
if (timeDiff < 0) return { color: 'success', class: 'black-text-color' };
|
|
||||||
return { color: 'transparent', class: 'normal-text-color' };
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatShippedDate(date) {
|
|
||||||
if (!date) return '-';
|
|
||||||
const dateSplit = date.split('T');
|
|
||||||
const [year, month, day] = dateSplit[0].split('-');
|
|
||||||
const newDate = new Date(year, month - 1, day);
|
|
||||||
return toDateFormat(newDate);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<QBadge v-bind="getBadgeAttrs(date)" class="q-pa-sm" style="font-size: 14px">
|
|
||||||
{{ formatShippedDate(date) }}
|
|
||||||
</QBadge>
|
|
||||||
</template>
|
|
||||||
<style lang="scss">
|
|
||||||
.black-text-color {
|
|
||||||
color: var(--vn-black-text-color);
|
|
||||||
}
|
|
||||||
.normal-text-color {
|
|
||||||
color: var(--vn-text-color);
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -31,10 +31,6 @@ const $props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
description: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const warehouses = ref();
|
const warehouses = ref();
|
||||||
|
@ -47,8 +43,7 @@ const dms = ref({});
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
defaultData();
|
defaultData();
|
||||||
if (!$props.formInitialData)
|
if (!$props.formInitialData)
|
||||||
dms.value.description =
|
dms.value.description = t($props.model + 'Description', dms.value);
|
||||||
$props.description ?? t($props.model + 'Description', dms.value);
|
|
||||||
});
|
});
|
||||||
function onFileChange(files) {
|
function onFileChange(files) {
|
||||||
dms.value.hasFileAttached = !!files;
|
dms.value.hasFileAttached = !!files;
|
||||||
|
@ -59,6 +54,7 @@ function mapperDms(data) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
const { files } = data;
|
const { files } = data;
|
||||||
if (files) formData.append(files?.name, files);
|
if (files) formData.append(files?.name, files);
|
||||||
|
delete data.files;
|
||||||
|
|
||||||
const dms = {
|
const dms = {
|
||||||
hasFile: !!data.hasFile,
|
hasFile: !!data.hasFile,
|
||||||
|
@ -82,7 +78,6 @@ async function save() {
|
||||||
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);
|
||||||
delete dms.value.files;
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,14 +158,13 @@ function addDefaultData(data) {
|
||||||
/>
|
/>
|
||||||
<QFile
|
<QFile
|
||||||
ref="inputFileRef"
|
ref="inputFileRef"
|
||||||
:label="t('globals.file')"
|
:label="t('entry.buys.file')"
|
||||||
v-model="dms.files"
|
v-model="dms.files"
|
||||||
:multiple="false"
|
:multiple="false"
|
||||||
:accept="allowedContentTypes"
|
:accept="allowedContentTypes"
|
||||||
@update:model-value="onFileChange(dms.files)"
|
@update:model-value="onFileChange(dms.files)"
|
||||||
class="required"
|
class="required"
|
||||||
:display-value="dms.file"
|
:display-value="dms.file"
|
||||||
data-cy="VnDms_inputFile"
|
|
||||||
>
|
>
|
||||||
<template #append>
|
<template #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
|
|
|
@ -5,14 +5,12 @@ 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 VnUserLink from '../ui/VnUserLink.vue';
|
|
||||||
import { downloadFile } from 'src/composables/downloadFile';
|
|
||||||
import VnImg from 'components/ui/VnImg.vue';
|
|
||||||
import VnPaginate from 'components/ui/VnPaginate.vue';
|
import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||||
import VnDms from 'src/components/common/VnDms.vue';
|
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 VnUserLink from '../ui/VnUserLink.vue';
|
||||||
|
import { downloadFile } from 'src/composables/downloadFile';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
|
@ -20,7 +18,6 @@ const { t } = useI18n();
|
||||||
const rows = ref();
|
const rows = ref();
|
||||||
const dmsRef = ref();
|
const dmsRef = ref();
|
||||||
const formDialog = ref({});
|
const formDialog = ref({});
|
||||||
const token = useSession().getTokenMultimedia();
|
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
model: {
|
model: {
|
||||||
|
@ -92,23 +89,6 @@ const dmsFilter = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
|
||||||
label: '',
|
|
||||||
name: 'file',
|
|
||||||
align: 'left',
|
|
||||||
component: VnImg,
|
|
||||||
props: (prop) => {
|
|
||||||
return {
|
|
||||||
storage: 'dms',
|
|
||||||
collection: null,
|
|
||||||
resolution: null,
|
|
||||||
id: prop.row.file.split('.')[0],
|
|
||||||
token: token,
|
|
||||||
class: 'rounded',
|
|
||||||
ratio: 1,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
align: 'left',
|
align: 'left',
|
||||||
field: 'id',
|
field: 'id',
|
||||||
|
@ -155,13 +135,19 @@ const columns = computed(() => [
|
||||||
field: 'hasFile',
|
field: 'hasFile',
|
||||||
label: t('globals.original'),
|
label: t('globals.original'),
|
||||||
name: 'hasFile',
|
name: 'hasFile',
|
||||||
toolTip: t('The documentation is available in paper form'),
|
|
||||||
component: QCheckbox,
|
component: QCheckbox,
|
||||||
props: (prop) => ({
|
props: (prop) => ({
|
||||||
disable: true,
|
disable: true,
|
||||||
'model-value': Boolean(prop.value),
|
'model-value': Boolean(prop.value),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
align: 'left',
|
||||||
|
field: 'file',
|
||||||
|
label: t('globals.file'),
|
||||||
|
name: 'file',
|
||||||
|
component: 'span',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
align: 'left',
|
align: 'left',
|
||||||
field: 'worker',
|
field: 'worker',
|
||||||
|
@ -297,7 +283,7 @@ defineExpose({
|
||||||
ref="dmsRef"
|
ref="dmsRef"
|
||||||
:data-key="$props.model"
|
:data-key="$props.model"
|
||||||
:url="$props.model"
|
:url="$props.model"
|
||||||
:user-filter="dmsFilter"
|
:filter="dmsFilter"
|
||||||
:order="['dmsFk DESC']"
|
:order="['dmsFk DESC']"
|
||||||
:auto-load="true"
|
:auto-load="true"
|
||||||
@on-fetch="setData"
|
@on-fetch="setData"
|
||||||
|
@ -311,14 +297,6 @@ defineExpose({
|
||||||
row-key="clientFk"
|
row-key="clientFk"
|
||||||
:grid="$q.screen.lt.sm"
|
:grid="$q.screen.lt.sm"
|
||||||
>
|
>
|
||||||
<template #header="props">
|
|
||||||
<QTr :props="props" class="bg">
|
|
||||||
<QTh v-for="col in props.cols" :key="col.name" :props="props">
|
|
||||||
<QTooltip v-if="col.toolTip">{{ col.toolTip }}</QTooltip
|
|
||||||
>{{ col.label }}
|
|
||||||
</QTh>
|
|
||||||
</QTr>
|
|
||||||
</template>
|
|
||||||
<template #body-cell="props">
|
<template #body-cell="props">
|
||||||
<QTd :props="props">
|
<QTd :props="props">
|
||||||
<QTr :props="props">
|
<QTr :props="props">
|
||||||
|
@ -400,14 +378,7 @@ defineExpose({
|
||||||
/>
|
/>
|
||||||
</QDialog>
|
</QDialog>
|
||||||
<QPageSticky position="bottom-right" :offset="[25, 25]">
|
<QPageSticky position="bottom-right" :offset="[25, 25]">
|
||||||
<QBtn
|
<QBtn fab color="primary" icon="add" @click="showFormDialog()" class="fill-icon">
|
||||||
fab
|
|
||||||
color="primary"
|
|
||||||
icon="add"
|
|
||||||
shortcut="+"
|
|
||||||
@click="showFormDialog()"
|
|
||||||
class="fill-icon"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ t('Upload file') }}
|
{{ t('Upload file') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
|
@ -415,6 +386,10 @@ defineExpose({
|
||||||
</QPageSticky>
|
</QPageSticky>
|
||||||
</template>
|
</template>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.q-gutter-y-ms {
|
||||||
|
display: grid;
|
||||||
|
row-gap: 20px;
|
||||||
|
}
|
||||||
.labelColor {
|
.labelColor {
|
||||||
color: var(--vn-label-color);
|
color: var(--vn-label-color);
|
||||||
}
|
}
|
||||||
|
@ -422,10 +397,8 @@ defineExpose({
|
||||||
<i18n>
|
<i18n>
|
||||||
en:
|
en:
|
||||||
contentTypesInfo: Allowed file types {allowedContentTypes}
|
contentTypesInfo: Allowed file types {allowedContentTypes}
|
||||||
The documentation is available in paper form: The documentation is available in paper form
|
|
||||||
es:
|
es:
|
||||||
contentTypesInfo: Tipos de archivo permitidos {allowedContentTypes}
|
contentTypesInfo: Tipos de archivo permitidos {allowedContentTypes}
|
||||||
Generate identifier for original file: Generar identificador para archivo original
|
Generate identifier for original file: Generar identificador para archivo original
|
||||||
Upload file: Subir fichero
|
Upload file: Subir fichero
|
||||||
the documentation is available in paper form: Se tiene la documentación en papel
|
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref, useAttrs, nextTick } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRequired } from 'src/composables/useRequired';
|
|
||||||
|
|
||||||
const $attrs = useAttrs();
|
|
||||||
const { isRequired, requiredFieldRule } = useRequired($attrs);
|
|
||||||
const { t } = useI18n();
|
|
||||||
const emit = defineEmits([
|
const emit = defineEmits([
|
||||||
'update:modelValue',
|
'update:modelValue',
|
||||||
'update:options',
|
'update:options',
|
||||||
|
@ -30,31 +26,16 @@ const $props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
emptyToNull: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
insertable: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
maxlength: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
uppercase: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const requiredFieldRule = (val) => !!val || t('globals.fieldRequired');
|
||||||
const vnInputRef = ref(null);
|
const vnInputRef = ref(null);
|
||||||
const value = computed({
|
const value = computed({
|
||||||
get() {
|
get() {
|
||||||
return $props.modelValue;
|
return $props.modelValue;
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
if ($props.emptyToNull && value === '') value = null;
|
|
||||||
emit('update:modelValue', value);
|
emit('update:modelValue', value);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -77,106 +58,48 @@ defineExpose({
|
||||||
focus,
|
focus,
|
||||||
});
|
});
|
||||||
|
|
||||||
const mixinRules = [
|
const inputRules = [
|
||||||
requiredFieldRule,
|
|
||||||
...($attrs.rules ?? []),
|
|
||||||
(val) => {
|
(val) => {
|
||||||
const { maxlength } = vnInputRef.value;
|
const { min } = vnInputRef.value.$attrs;
|
||||||
if (maxlength && +val.length > maxlength)
|
|
||||||
return t(`maxLength`, { value: maxlength });
|
|
||||||
const { min, max } = vnInputRef.value.$attrs;
|
|
||||||
if (!min) return null;
|
|
||||||
if (min >= 0) if (Math.floor(val) < min) return t('inputMin', { value: min });
|
if (min >= 0) if (Math.floor(val) < min) return t('inputMin', { value: min });
|
||||||
if (!max) return null;
|
|
||||||
if (max > 0) {
|
|
||||||
if (Math.floor(val) > max) return t('inputMax', { value: max });
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const handleKeydown = (e) => {
|
|
||||||
if (e.key === 'Backspace') return;
|
|
||||||
|
|
||||||
if ($props.insertable && e.key.match(/[0-9]/)) {
|
|
||||||
handleInsertMode(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleInsertMode = (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
const input = e.target;
|
|
||||||
const cursorPos = input.selectionStart;
|
|
||||||
const { maxlength } = vnInputRef.value;
|
|
||||||
let currentValue = value.value;
|
|
||||||
if (!currentValue) currentValue = e.key;
|
|
||||||
const newValue = e.key;
|
|
||||||
if (newValue && !isNaN(newValue) && cursorPos < maxlength) {
|
|
||||||
value.value =
|
|
||||||
currentValue.substring(0, cursorPos) +
|
|
||||||
newValue +
|
|
||||||
currentValue.substring(cursorPos + 1);
|
|
||||||
}
|
|
||||||
nextTick(() => {
|
|
||||||
input.setSelectionRange(cursorPos + 1, cursorPos + 1);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleUppercase = () => {
|
|
||||||
value.value = value.value?.toUpperCase() || '';
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div @mouseover="hover = true" @mouseleave="hover = false">
|
<div
|
||||||
|
@mouseover="hover = true"
|
||||||
|
@mouseleave="hover = false"
|
||||||
|
:rules="$attrs.required ? [requiredFieldRule] : null"
|
||||||
|
>
|
||||||
<QInput
|
<QInput
|
||||||
ref="vnInputRef"
|
ref="vnInputRef"
|
||||||
v-model="value"
|
v-model="value"
|
||||||
v-bind="{ ...$attrs, ...styleAttrs }"
|
v-bind="{ ...$attrs, ...styleAttrs }"
|
||||||
:type="$attrs.type"
|
:type="$attrs.type"
|
||||||
:class="{ required: isRequired }"
|
:class="{ required: $attrs.required }"
|
||||||
@keyup.enter="emit('keyup.enter')"
|
@keyup.enter="emit('keyup.enter')"
|
||||||
@keydown="handleKeydown"
|
|
||||||
:clearable="false"
|
:clearable="false"
|
||||||
:rules="mixinRules"
|
:rules="inputRules"
|
||||||
:lazy-rules="true"
|
:lazy-rules="true"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_input'"
|
|
||||||
>
|
>
|
||||||
<template #prepend>
|
<template v-if="$slots.prepend" #prepend>
|
||||||
<slot name="prepend" />
|
<slot name="prepend" />
|
||||||
</template>
|
</template>
|
||||||
<template #append>
|
<template #append>
|
||||||
|
<slot name="append" v-if="$slots.append && !$attrs.disabled" />
|
||||||
<QIcon
|
<QIcon
|
||||||
name="close"
|
name="close"
|
||||||
size="xs"
|
size="xs"
|
||||||
:style="{
|
v-if="hover && value && !$attrs.disabled && $props.clearable"
|
||||||
visibility:
|
|
||||||
hover &&
|
|
||||||
value &&
|
|
||||||
!$attrs.disabled &&
|
|
||||||
!$attrs.readonly &&
|
|
||||||
$props.clearable
|
|
||||||
? 'visible'
|
|
||||||
: 'hidden',
|
|
||||||
}"
|
|
||||||
@click="
|
@click="
|
||||||
() => {
|
() => {
|
||||||
value = null;
|
value = null;
|
||||||
vnInputRef.focus();
|
|
||||||
emit('remove');
|
emit('remove');
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
></QIcon>
|
></QIcon>
|
||||||
|
|
||||||
<QIcon
|
|
||||||
name="match_case"
|
|
||||||
size="xs"
|
|
||||||
v-if="!$attrs.disabled && !($attrs.readonly) && $props.uppercase"
|
|
||||||
@click="handleUppercase"
|
|
||||||
class="uppercase-icon"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<slot name="append" v-if="$slots.append && !$attrs.disabled" />
|
|
||||||
<QIcon v-if="info" name="info">
|
<QIcon v-if="info" name="info">
|
||||||
<QTooltip max-width="350px">
|
<QTooltip max-width="350px">
|
||||||
{{ info }}
|
{{ info }}
|
||||||
|
@ -186,14 +109,9 @@ const handleUppercase = () => {
|
||||||
</QInput>
|
</QInput>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
en:
|
en:
|
||||||
inputMin: Must be more than {value}
|
inputMin: Must be more than {value}
|
||||||
maxLength: The value exceeds {value} characters
|
|
||||||
inputMax: Must be less than {value}
|
|
||||||
es:
|
es:
|
||||||
inputMin: Debe ser mayor a {value}
|
inputMin: Debe ser mayor a {value}
|
||||||
maxLength: El valor excede los {value} carácteres
|
|
||||||
inputMax: Debe ser menor a {value}
|
|
||||||
</i18n>
|
</i18n>
|
|
@ -1,32 +1,38 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, watch, computed, ref, useAttrs } from 'vue';
|
import { onMounted, watch, computed, ref } from 'vue';
|
||||||
import { date } from 'quasar';
|
import { date } from 'quasar';
|
||||||
import VnDate from './VnDate.vue';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRequired } from 'src/composables/useRequired';
|
|
||||||
|
|
||||||
const $attrs = useAttrs();
|
|
||||||
const { isRequired, requiredFieldRule } = useRequired($attrs);
|
|
||||||
const model = defineModel({ type: [String, Date] });
|
|
||||||
|
|
||||||
|
const model = defineModel({ type: String });
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
isOutlined: {
|
isOutlined: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
showEvent: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const vnInputDateRef = ref(null);
|
const { t } = useI18n();
|
||||||
|
const requiredFieldRule = (val) => !!val || t('globals.fieldRequired');
|
||||||
|
|
||||||
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 mask = ref();
|
||||||
|
|
||||||
const mixinRules = [requiredFieldRule, ...($attrs.rules ?? [])];
|
onMounted(() => {
|
||||||
|
// fix quasar bug
|
||||||
|
mask.value = '##/##/####';
|
||||||
|
});
|
||||||
|
|
||||||
|
const styleAttrs = computed(() => {
|
||||||
|
return $props.isOutlined
|
||||||
|
? {
|
||||||
|
dense: true,
|
||||||
|
outlined: true,
|
||||||
|
rounded: true,
|
||||||
|
}
|
||||||
|
: {};
|
||||||
|
});
|
||||||
|
|
||||||
const formattedDate = computed({
|
const formattedDate = computed({
|
||||||
get() {
|
get() {
|
||||||
|
@ -38,12 +44,15 @@ const formattedDate = computed({
|
||||||
let newDate;
|
let newDate;
|
||||||
if (value) {
|
if (value) {
|
||||||
// parse input
|
// parse input
|
||||||
if (value.includes('/') && value.length >= 10) {
|
if (value.includes('/')) {
|
||||||
if (value.at(2) == '/') value = value.split('/').reverse().join('/');
|
if (value.length == 6) value = value + new Date().getFullYear();
|
||||||
value = date.formatDate(
|
if (value.length >= 10) {
|
||||||
new Date(value).toISOString(),
|
if (value.at(2) == '/') value = value.split('/').reverse().join('/');
|
||||||
'YYYY-MM-DDTHH:mm:ss.SSSZ'
|
value = date.formatDate(
|
||||||
);
|
new Date(value).toISOString(),
|
||||||
|
'YYYY-MM-DDTHH:mm:ss.SSSZ'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const [year, month, day] = value.split('-').map((e) => parseInt(e));
|
const [year, month, day] = value.split('-').map((e) => parseInt(e));
|
||||||
newDate = new Date(year, month - 1, day);
|
newDate = new Date(year, month - 1, day);
|
||||||
|
@ -66,46 +75,25 @@ const formattedDate = computed({
|
||||||
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(
|
watch(
|
||||||
() => model.value,
|
() => model.value,
|
||||||
(val) => (formattedDate.value = val),
|
(val) => (formattedDate.value = val),
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
const styleAttrs = computed(() => {
|
|
||||||
return $props.isOutlined
|
|
||||||
? {
|
|
||||||
dense: true,
|
|
||||||
outlined: true,
|
|
||||||
rounded: true,
|
|
||||||
}
|
|
||||||
: {};
|
|
||||||
});
|
|
||||||
|
|
||||||
const manageDate = (date) => {
|
|
||||||
formattedDate.value = date;
|
|
||||||
isPopupOpen.value = false;
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div @mouseover="hover = true" @mouseleave="hover = false">
|
<div @mouseover="hover = true" @mouseleave="hover = false">
|
||||||
<QInput
|
<QInput
|
||||||
ref="vnInputDateRef"
|
|
||||||
v-model="formattedDate"
|
v-model="formattedDate"
|
||||||
class="vn-input-date"
|
class="vn-input-date"
|
||||||
:mask="mask"
|
:mask="mask"
|
||||||
placeholder="dd/mm/aaaa"
|
placeholder="dd/mm/aaaa"
|
||||||
v-bind="{ ...$attrs, ...styleAttrs }"
|
v-bind="{ ...$attrs, ...styleAttrs }"
|
||||||
:class="{ required: isRequired }"
|
:class="{ required: $attrs.required }"
|
||||||
:rules="mixinRules"
|
:rules="$attrs.required ? [requiredFieldRule] : null"
|
||||||
:clearable="false"
|
:clearable="false"
|
||||||
@click="isPopupOpen = !isPopupOpen"
|
|
||||||
hide-bottom-space
|
|
||||||
>
|
>
|
||||||
<template #append>
|
<template #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
|
@ -118,14 +106,18 @@ const manageDate = (date) => {
|
||||||
!$attrs.disable
|
!$attrs.disable
|
||||||
"
|
"
|
||||||
@click="
|
@click="
|
||||||
vnInputDateRef.focus();
|
|
||||||
model = null;
|
model = null;
|
||||||
isPopupOpen = false;
|
isPopupOpen = false;
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
|
<QIcon
|
||||||
|
name="event"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="isPopupOpen = !isPopupOpen"
|
||||||
|
:title="t('Open date')"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<QMenu
|
<QMenu
|
||||||
v-if="$q.screen.gt.xs"
|
|
||||||
transition-show="scale"
|
transition-show="scale"
|
||||||
transition-hide="scale"
|
transition-hide="scale"
|
||||||
v-model="isPopupOpen"
|
v-model="isPopupOpen"
|
||||||
|
@ -134,14 +126,30 @@ const manageDate = (date) => {
|
||||||
:no-focus="true"
|
:no-focus="true"
|
||||||
:no-parent-event="true"
|
:no-parent-event="true"
|
||||||
>
|
>
|
||||||
<VnDate v-model="popupDate" @update:model-value="manageDate" />
|
<QDate
|
||||||
|
v-model="popupDate"
|
||||||
|
:landscape="true"
|
||||||
|
:today-btn="true"
|
||||||
|
@update:model-value="
|
||||||
|
(date) => {
|
||||||
|
formattedDate = date;
|
||||||
|
isPopupOpen = false;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/>
|
||||||
</QMenu>
|
</QMenu>
|
||||||
<QDialog v-else v-model="isPopupOpen">
|
|
||||||
<VnDate v-model="popupDate" @update:model-value="manageDate" />
|
|
||||||
</QDialog>
|
|
||||||
</QInput>
|
</QInput>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<style lang="scss">
|
||||||
|
.vn-input-date.q-field--standard.q-field--readonly .q-field__control:before {
|
||||||
|
border-bottom-style: solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vn-input-date.q-field--outlined.q-field--readonly .q-field__control:before {
|
||||||
|
border-style: solid;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<i18n>
|
<i18n>
|
||||||
es:
|
es:
|
||||||
Open date: Abrir fecha
|
Open date: Abrir fecha
|
||||||
|
|
|
@ -1,28 +1,8 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
|
||||||
defineProps({
|
|
||||||
step: { type: Number, default: 0.01 },
|
|
||||||
decimalPlaces: { type: Number, default: 2 },
|
|
||||||
positive: { type: Boolean, default: true },
|
|
||||||
});
|
|
||||||
|
|
||||||
const model = defineModel({ type: [Number, String] });
|
const model = defineModel({ type: [Number, String] });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnInput
|
<VnInput v-bind="$attrs" v-model.number="model" type="number" />
|
||||||
v-bind="$attrs"
|
|
||||||
v-model.number="model"
|
|
||||||
type="number"
|
|
||||||
:step="step"
|
|
||||||
@input="
|
|
||||||
(evt) => {
|
|
||||||
const val = evt.target.value;
|
|
||||||
if (positive && val < 0) return (model = 0);
|
|
||||||
const [, decimal] = val.split('.');
|
|
||||||
if (val && decimal?.length > decimalPlaces)
|
|
||||||
model = parseFloat(val).toFixed(decimalPlaces);
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
import { ref } from 'vue';
|
|
||||||
|
|
||||||
const model = defineModel({ type: [Number, String] });
|
|
||||||
const $props = defineProps({
|
|
||||||
toggleVisibility: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const showPassword = ref(false);
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<VnInput
|
|
||||||
v-bind="{ ...$attrs }"
|
|
||||||
v-model="model"
|
|
||||||
:type="
|
|
||||||
$props.toggleVisibility ? (showPassword ? 'text' : 'password') : $attrs.type
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<template #append v-if="toggleVisibility">
|
|
||||||
<QIcon
|
|
||||||
:name="showPassword ? 'visibility_off' : 'visibility'"
|
|
||||||
class="cursor-pointer"
|
|
||||||
@click="showPassword = !showPassword"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</VnInput>
|
|
||||||
</template>
|
|
|
@ -1,11 +1,8 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref, useAttrs } from 'vue';
|
import { watch, computed, ref, nextTick } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
import { date } from 'quasar';
|
import { date } from 'quasar';
|
||||||
import VnTime from './VnTime.vue';
|
|
||||||
import { useRequired } from 'src/composables/useRequired';
|
|
||||||
|
|
||||||
const $attrs = useAttrs();
|
|
||||||
const { isRequired, requiredFieldRule } = useRequired($attrs);
|
|
||||||
const model = defineModel({ type: String });
|
const model = defineModel({ type: String });
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
timeOnly: {
|
timeOnly: {
|
||||||
|
@ -17,12 +14,13 @@ const props = defineProps({
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const vnInputTimeRef = ref(null);
|
const { t } = useI18n();
|
||||||
const initialDate = ref(model.value ?? Date.vnNew());
|
const requiredFieldRule = (val) => !!val || t('globals.fieldRequired');
|
||||||
const mixinRules = [requiredFieldRule, ...($attrs.rules ?? [])];
|
|
||||||
const dateFormat = 'HH:mm';
|
const dateFormat = 'HH:mm';
|
||||||
const isPopupOpen = ref();
|
const isPopupOpen = ref();
|
||||||
const hover = ref();
|
const hover = ref();
|
||||||
|
const inputRef = ref();
|
||||||
|
|
||||||
const styleAttrs = computed(() => {
|
const styleAttrs = computed(() => {
|
||||||
return props.isOutlined
|
return props.isOutlined
|
||||||
|
@ -52,8 +50,7 @@ const formattedTime = computed({
|
||||||
}
|
}
|
||||||
if (!props.timeOnly) {
|
if (!props.timeOnly) {
|
||||||
const [hh, mm] = time.split(':');
|
const [hh, mm] = time.split(':');
|
||||||
|
const date = new Date(model.value ? model.value : null);
|
||||||
const date = new Date(model.value ? model.value : initialDate.value);
|
|
||||||
date.setHours(hh, mm, 0);
|
date.setHours(hh, mm, 0);
|
||||||
time = date?.toISOString();
|
time = date?.toISOString();
|
||||||
}
|
}
|
||||||
|
@ -65,22 +62,47 @@ const formattedTime = computed({
|
||||||
function dateToTime(newDate) {
|
function dateToTime(newDate) {
|
||||||
return date.formatDate(new Date(newDate), dateFormat);
|
return date.formatDate(new Date(newDate), dateFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => model.value,
|
||||||
|
(val) => (formattedTime.value = val),
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => formattedTime.value,
|
||||||
|
async (val) => {
|
||||||
|
let position = 3;
|
||||||
|
const input = inputRef.value?.getNativeElement();
|
||||||
|
if (!val || !input) return;
|
||||||
|
|
||||||
|
let [hh, mm] = val.split(':');
|
||||||
|
hh = parseInt(hh);
|
||||||
|
if (hh >= 10 || mm != '00') return;
|
||||||
|
|
||||||
|
await nextTick();
|
||||||
|
await nextTick();
|
||||||
|
if (!hh) position = 0;
|
||||||
|
input.setSelectionRange(position, position);
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div @mouseover="hover = true" @mouseleave="hover = false">
|
<div @mouseover="hover = true" @mouseleave="hover = false">
|
||||||
<QInput
|
<QInput
|
||||||
ref="vnInputTimeRef"
|
ref="inputRef"
|
||||||
class="vn-input-time"
|
class="vn-input-time"
|
||||||
mask="##:##"
|
mask="##:##"
|
||||||
placeholder="--:--"
|
placeholder="--:--"
|
||||||
v-model="formattedTime"
|
v-model="formattedTime"
|
||||||
v-bind="{ ...$attrs, ...styleAttrs }"
|
v-bind="{ ...$attrs, ...styleAttrs }"
|
||||||
:class="{ required: isRequired }"
|
:class="{ required: $attrs.required }"
|
||||||
style="min-width: 100px"
|
style="min-width: 100px"
|
||||||
:rules="mixinRules"
|
:rules="$attrs.required ? [requiredFieldRule] : null"
|
||||||
@click="isPopupOpen = !isPopupOpen"
|
@click="isPopupOpen = false"
|
||||||
type="time"
|
@focus="inputRef.getNativeElement().setSelectionRange(0, 0)"
|
||||||
hide-bottom-space
|
|
||||||
>
|
>
|
||||||
<template #append>
|
<template #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
|
@ -93,14 +115,18 @@ function dateToTime(newDate) {
|
||||||
!$attrs.disable
|
!$attrs.disable
|
||||||
"
|
"
|
||||||
@click="
|
@click="
|
||||||
vnInputTimeRef.focus();
|
|
||||||
model = null;
|
model = null;
|
||||||
isPopupOpen = false;
|
isPopupOpen = false;
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
|
<QIcon
|
||||||
|
name="Schedule"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="isPopupOpen = !isPopupOpen"
|
||||||
|
:title="t('Open time')"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<QMenu
|
<QMenu
|
||||||
v-if="$q.screen.gt.xs"
|
|
||||||
transition-show="scale"
|
transition-show="scale"
|
||||||
transition-hide="scale"
|
transition-hide="scale"
|
||||||
v-model="isPopupOpen"
|
v-model="isPopupOpen"
|
||||||
|
@ -109,11 +135,8 @@ function dateToTime(newDate) {
|
||||||
:no-focus="true"
|
:no-focus="true"
|
||||||
:no-parent-event="true"
|
:no-parent-event="true"
|
||||||
>
|
>
|
||||||
<VnTime v-model="formattedTime" />
|
<QTime v-model="formattedTime" mask="HH:mm" landscape now-btn />
|
||||||
</QMenu>
|
</QMenu>
|
||||||
<QDialog v-else v-model="isPopupOpen">
|
|
||||||
<VnTime v-model="formattedTime" />
|
|
||||||
</QDialog>
|
|
||||||
</QInput>
|
</QInput>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -126,11 +149,6 @@ function dateToTime(newDate) {
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<style lang="scss" scoped>
|
|
||||||
:deep(input[type='time']::-webkit-calendar-picker-indicator) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<i18n>
|
<i18n>
|
||||||
es:
|
es:
|
||||||
Open time: Abrir tiempo
|
Open time: Abrir tiempo
|
||||||
|
|
|
@ -2,99 +2,32 @@
|
||||||
import CreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue';
|
import CreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue';
|
||||||
import VnSelectDialog from 'components/common/VnSelectDialog.vue';
|
import VnSelectDialog from 'components/common/VnSelectDialog.vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { ref, watch } from 'vue';
|
|
||||||
import { useAttrs } from 'vue';
|
|
||||||
import { useRequired } from 'src/composables/useRequired';
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const emit = defineEmits(['update:model-value', 'update:options']);
|
const value = defineModel({ type: [String, Number, Object] });
|
||||||
const $attrs = useAttrs();
|
|
||||||
const { isRequired, requiredFieldRule } = useRequired($attrs);
|
|
||||||
const props = defineProps({
|
|
||||||
location: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.location,
|
|
||||||
(newValue) => {
|
|
||||||
if (!modelValue.value) return;
|
|
||||||
modelValue.value = formatLocation(newValue) ?? null;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const mixinRules = [requiredFieldRule];
|
|
||||||
const locationProperties = [
|
|
||||||
'postcode',
|
|
||||||
(obj) =>
|
|
||||||
obj.city
|
|
||||||
? `${obj.city}${obj.province?.name ? `(${obj.province.name})` : ''}`
|
|
||||||
: null,
|
|
||||||
(obj) => obj.country?.name,
|
|
||||||
];
|
|
||||||
|
|
||||||
const formatLocation = (obj, properties = locationProperties) => {
|
|
||||||
const parts = properties.map((prop) => {
|
|
||||||
if (typeof prop === 'string') {
|
|
||||||
return obj[prop];
|
|
||||||
} else if (typeof prop === 'function') {
|
|
||||||
return prop(obj);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
|
|
||||||
const filteredParts = parts.filter(
|
|
||||||
(part) => part !== null && part !== undefined && part !== ''
|
|
||||||
);
|
|
||||||
|
|
||||||
return filteredParts.join(', ');
|
|
||||||
};
|
|
||||||
|
|
||||||
const modelValue = ref(props.location ? formatLocation(props.location) : null);
|
|
||||||
|
|
||||||
function showLabel(data) {
|
function showLabel(data) {
|
||||||
const dataProperties = [
|
return `${data.code} - ${data.town}(${data.province}), ${data.country}`;
|
||||||
'code',
|
|
||||||
(obj) => (obj.town ? `${obj.town}(${obj.province})` : null),
|
|
||||||
'country',
|
|
||||||
];
|
|
||||||
return formatLocation(data, dataProperties);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleModelValue = (data) => {
|
|
||||||
emit('update:model-value', data);
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VnSelectDialog
|
<VnSelectDialog
|
||||||
v-model="modelValue"
|
v-model="value"
|
||||||
|
option-value="code"
|
||||||
option-filter-value="search"
|
option-filter-value="search"
|
||||||
:option-label="
|
:option-label="(opt) => showLabel(opt)"
|
||||||
(opt) => (typeof modelValue === 'string' ? modelValue : showLabel(opt))
|
|
||||||
"
|
|
||||||
url="Postcodes/filter"
|
url="Postcodes/filter"
|
||||||
@update:model-value="handleModelValue"
|
|
||||||
:use-like="false"
|
:use-like="false"
|
||||||
:label="t('Location')"
|
:label="t('Location')"
|
||||||
:placeholder="t('search_by_postalcode')"
|
:placeholder="t('search_by_postalcode')"
|
||||||
:input-debounce="300"
|
:input-debounce="300"
|
||||||
:class="{ required: isRequired }"
|
:class="{ required: $attrs.required }"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
|
clearable
|
||||||
:emit-value="false"
|
:emit-value="false"
|
||||||
:tooltip="t('Create new location')"
|
|
||||||
:rules="mixinRules"
|
|
||||||
:lazy-rules="true"
|
|
||||||
>
|
>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CreateNewPostcode
|
<CreateNewPostcode @on-data-saved="(newValue) => (value = newValue)" />
|
||||||
@on-data-saved="
|
|
||||||
(newValue) => {
|
|
||||||
modelValue = newValue;
|
|
||||||
emit('update:model-value', newValue);
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
<template #option="{ itemProps, opt }">
|
<template #option="{ itemProps, opt }">
|
||||||
<QItem v-bind="itemProps">
|
<QItem v-bind="itemProps">
|
||||||
|
@ -117,9 +50,7 @@ const handleModelValue = (data) => {
|
||||||
<i18n>
|
<i18n>
|
||||||
en:
|
en:
|
||||||
search_by_postalcode: Search by postalcode, town, province or country
|
search_by_postalcode: Search by postalcode, town, province or country
|
||||||
Create new location: Create new location
|
|
||||||
es:
|
es:
|
||||||
Location: Ubicación
|
Location: Ubicación
|
||||||
Create new location: Crear nueva ubicación
|
|
||||||
search_by_postalcode: Buscar por código postal, ciudad o país
|
search_by_postalcode: Buscar por código postal, ciudad o país
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -14,7 +14,6 @@ import VnJsonValue from '../common/VnJsonValue.vue';
|
||||||
import FetchData from '../FetchData.vue';
|
import FetchData from '../FetchData.vue';
|
||||||
import VnSelect from './VnSelect.vue';
|
import VnSelect from './VnSelect.vue';
|
||||||
import VnUserLink from '../ui/VnUserLink.vue';
|
import VnUserLink from '../ui/VnUserLink.vue';
|
||||||
import VnPaginate from '../ui/VnPaginate.vue';
|
|
||||||
|
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const validationsStore = useValidator();
|
const validationsStore = useValidator();
|
||||||
|
@ -67,10 +66,9 @@ const filter = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
where: { and: [{ originFk: route.params.id }] },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const paginate = ref();
|
const workers = ref();
|
||||||
const actions = ref();
|
const actions = ref();
|
||||||
const changeInput = ref();
|
const changeInput = ref();
|
||||||
const searchInput = ref();
|
const searchInput = ref();
|
||||||
|
@ -237,8 +235,9 @@ async function openPointRecord(id, modelLog) {
|
||||||
const locale = validations[modelLog.model]?.locale || {};
|
const locale = validations[modelLog.model]?.locale || {};
|
||||||
pointRecord.value = parseProps(propNames, locale, data);
|
pointRecord.value = parseProps(propNames, locale, data);
|
||||||
}
|
}
|
||||||
async function setLogTree(data) {
|
async function setLogTree() {
|
||||||
if (!data) return;
|
filter.where = { and: [{ originFk: route.params.id }] };
|
||||||
|
const { data } = await getLogs(filter);
|
||||||
logTree.value = getLogTree(data);
|
logTree.value = getLogTree(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +266,15 @@ async function applyFilter() {
|
||||||
filter.where.and.push(selectedFilters.value);
|
filter.where.and.push(selectedFilters.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
paginate.value.fetch(filter);
|
const { data } = await getLogs(filter);
|
||||||
|
|
||||||
|
logTree.value = getLogTree(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getLogs(filter) {
|
||||||
|
return axios.get(props.url ?? `${props.model}Logs`, {
|
||||||
|
params: { filter: JSON.stringify(filter) },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDate(type) {
|
function setDate(type) {
|
||||||
|
@ -370,6 +377,8 @@ async function clearFilter() {
|
||||||
await applyFilter();
|
await applyFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setLogTree();
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
stateStore.rightDrawer = false;
|
stateStore.rightDrawer = false;
|
||||||
});
|
});
|
||||||
|
@ -382,6 +391,16 @@ watch(
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
<FetchData
|
||||||
|
:url="`${props.model}Logs/${route.params.id}/editors`"
|
||||||
|
:filter="{
|
||||||
|
fields: ['id', 'nickname', 'name', 'image'],
|
||||||
|
order: 'nickname',
|
||||||
|
limit: 30,
|
||||||
|
}"
|
||||||
|
@on-fetch="(data) => (workers = data)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
:url="`${props.model}Logs/${route.params.id}/models`"
|
:url="`${props.model}Logs/${route.params.id}/models`"
|
||||||
:filter="{ order: ['changedModel'] }"
|
:filter="{ order: ['changedModel'] }"
|
||||||
|
@ -399,284 +418,231 @@ watch(
|
||||||
"
|
"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<VnPaginate
|
<div
|
||||||
ref="paginate"
|
class="column items-center logs origin-log q-mt-md"
|
||||||
:data-key="`${model}Log`"
|
v-for="(originLog, originLogIndex) in logTree"
|
||||||
:url="`${model}Logs`"
|
:key="originLogIndex"
|
||||||
:filter="filter"
|
|
||||||
:skeleton="false"
|
|
||||||
auto-load
|
|
||||||
@on-fetch="setLogTree"
|
|
||||||
search-url="logs"
|
|
||||||
>
|
>
|
||||||
<template #body>
|
<QItem class="origin-info items-center q-my-md" v-if="logTree.length > 1">
|
||||||
<div
|
<h6 class="origin-id text-grey">
|
||||||
class="column items-center logs origin-log q-mt-md"
|
{{ useCapitalize(validations[props.model].locale.name) }}
|
||||||
v-for="(originLog, originLogIndex) in logTree"
|
#{{ originLog.originFk }}
|
||||||
:key="originLogIndex"
|
</h6>
|
||||||
>
|
<div class="line bg-grey"></div>
|
||||||
<QItem class="origin-info items-center q-my-md" v-if="logTree.length > 1">
|
</QItem>
|
||||||
<h6 class="origin-id text-grey">
|
<div
|
||||||
{{ useCapitalize(validations[props.model].locale.name) }}
|
class="user-log q-mb-sm"
|
||||||
#{{ originLog.originFk }}
|
v-for="(userLog, userIndex) in originLog.logs"
|
||||||
</h6>
|
:key="userIndex"
|
||||||
<div class="line bg-grey"></div>
|
>
|
||||||
</QItem>
|
<div class="timeline">
|
||||||
<div
|
<div class="user-avatar">
|
||||||
class="user-log q-mb-sm"
|
<VnUserLink :worker-id="userLog?.user?.id">
|
||||||
v-for="(userLog, userIndex) in originLog.logs"
|
<template #link>
|
||||||
:key="userIndex"
|
<VnAvatar
|
||||||
|
:class="{ 'cursor-pointer': userLog?.user?.id }"
|
||||||
|
:worker-id="userLog?.user?.id"
|
||||||
|
:title="userLog?.user?.nickname"
|
||||||
|
:show-letter="!userLog?.user"
|
||||||
|
size="lg"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</VnUserLink>
|
||||||
|
</div>
|
||||||
|
<div class="arrow bg-panel" v-if="byRecord"></div>
|
||||||
|
<div class="line"></div>
|
||||||
|
</div>
|
||||||
|
<QList class="user-changes" v-if="userLog">
|
||||||
|
<QItem
|
||||||
|
class="model-log column q-px-none q-py-xs"
|
||||||
|
v-for="(modelLog, modelLogIndex) in userLog.logs"
|
||||||
|
:key="modelLogIndex"
|
||||||
>
|
>
|
||||||
<div class="timeline">
|
<QItemSection>
|
||||||
<div class="user-avatar">
|
<QItemLabel class="model-info q-mb-xs" v-if="!byRecord">
|
||||||
<VnUserLink :worker-id="userLog?.user?.id">
|
<QChip
|
||||||
<template #link>
|
dense
|
||||||
<VnAvatar
|
size="md"
|
||||||
:class="{ 'cursor-pointer': userLog?.user?.id }"
|
class="model-name q-mr-xs text-white"
|
||||||
:worker-id="userLog?.user?.id"
|
v-if="
|
||||||
:title="userLog?.user?.nickname"
|
!(modelLog.changedModel && modelLog.changedModelId) &&
|
||||||
:show-letter="!userLog?.user"
|
modelLog.model
|
||||||
size="lg"
|
"
|
||||||
/>
|
:style="{
|
||||||
</template>
|
backgroundColor: useColor(modelLog.model),
|
||||||
</VnUserLink>
|
}"
|
||||||
</div>
|
:title="`${modelLog.model} #${modelLog.id}`"
|
||||||
<div class="arrow bg-panel" v-if="byRecord"></div>
|
>
|
||||||
<div class="line"></div>
|
{{ t(modelLog.modelI18n) }}
|
||||||
</div>
|
</QChip>
|
||||||
<QList class="user-changes" v-if="userLog">
|
|
||||||
<QItem
|
|
||||||
class="model-log column q-px-none q-py-xs"
|
|
||||||
v-for="(modelLog, modelLogIndex) in userLog.logs"
|
|
||||||
:key="modelLogIndex"
|
|
||||||
>
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel class="model-info q-mb-xs" v-if="!byRecord">
|
|
||||||
<QChip
|
|
||||||
dense
|
|
||||||
size="md"
|
|
||||||
class="model-name q-mr-xs text-white"
|
|
||||||
v-if="
|
|
||||||
!(
|
|
||||||
modelLog.changedModel &&
|
|
||||||
modelLog.changedModelId
|
|
||||||
) && modelLog.model
|
|
||||||
"
|
|
||||||
:style="{
|
|
||||||
backgroundColor: useColor(modelLog.model),
|
|
||||||
}"
|
|
||||||
:title="`${modelLog.model} #${modelLog.id}`"
|
|
||||||
>
|
|
||||||
{{ t(modelLog.modelI18n) }}
|
|
||||||
</QChip>
|
|
||||||
|
|
||||||
<span
|
<span
|
||||||
class="model-id q-mr-xs"
|
class="model-id q-mr-xs"
|
||||||
v-if="modelLog.summaryId"
|
v-if="modelLog.summaryId"
|
||||||
v-text="`#${modelLog.summaryId}`"
|
v-text="`#${modelLog.summaryId}`"
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
class="model-value"
|
class="model-value"
|
||||||
:title="modelLog.showValue"
|
:title="modelLog.showValue"
|
||||||
v-text="modelLog.showValue"
|
v-text="modelLog.showValue"
|
||||||
/>
|
/>
|
||||||
<QBtn
|
<QBtn
|
||||||
flat
|
flat
|
||||||
round
|
round
|
||||||
color="grey"
|
color="grey"
|
||||||
class="q-mr-xs q-ml-auto"
|
class="q-mr-xs q-ml-auto"
|
||||||
size="sm"
|
size="sm"
|
||||||
icon="filter_alt"
|
icon="filter_alt"
|
||||||
:title="t('recordChanges')"
|
:title="t('recordChanges')"
|
||||||
@click.stop="filterByRecord(modelLog)"
|
@click.stop="filterByRecord(modelLog)"
|
||||||
/>
|
/>
|
||||||
</QItemLabel>
|
</QItemLabel>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<QCard
|
<QCard
|
||||||
class="changes-log q-py-none q-mb-xs"
|
class="changes-log q-py-none q-mb-xs"
|
||||||
v-for="(log, logIndex) in modelLog.logs"
|
v-for="(log, logIndex) in modelLog.logs"
|
||||||
:key="logIndex"
|
:key="logIndex"
|
||||||
|
>
|
||||||
|
<QCardSection class="change-info q-pa-none">
|
||||||
|
<QItem
|
||||||
|
class="q-px-sm q-py-xs justify-between items-center"
|
||||||
>
|
>
|
||||||
<QCardSection class="change-info q-pa-none">
|
<div
|
||||||
<QItem
|
class="date text-grey text-caption q-mr-sm"
|
||||||
class="q-px-sm q-py-xs justify-between items-center"
|
:title="
|
||||||
>
|
date.formatDate(
|
||||||
<div
|
log.creationDate,
|
||||||
class="date text-grey text-caption q-mr-sm"
|
'DD/MM/YYYY hh:mm:ss'
|
||||||
:title="
|
) ?? `date:'dd/MM/yyyy HH:mm:ss'`
|
||||||
date.formatDate(
|
"
|
||||||
log.creationDate,
|
|
||||||
'DD/MM/YYYY hh:mm:ss'
|
|
||||||
) ?? `date:'dd/MM/yyyy HH:mm:ss'`
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ toRelativeDate(log.creationDate) }}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<QBtn
|
|
||||||
color="grey"
|
|
||||||
class="pit"
|
|
||||||
icon="preview"
|
|
||||||
flat
|
|
||||||
round
|
|
||||||
:title="t('pointRecord')"
|
|
||||||
padding="none"
|
|
||||||
v-if="log.action != 'insert'"
|
|
||||||
@click.stop="
|
|
||||||
openPointRecord(log.id, modelLog)
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<QPopupProxy>
|
|
||||||
<QCard v-if="pointRecord">
|
|
||||||
<div
|
|
||||||
class="header q-px-sm q-py-xs q-ma-none text-white text-bold bg-primary"
|
|
||||||
>
|
|
||||||
{{ modelLog.modelI18n }}
|
|
||||||
<span v-if="modelLog.id"
|
|
||||||
>#{{
|
|
||||||
modelLog.id
|
|
||||||
}}</span
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<QCardSection
|
|
||||||
class="change-detail q-pa-sm"
|
|
||||||
>
|
|
||||||
<QItem
|
|
||||||
v-for="(
|
|
||||||
value, index
|
|
||||||
) in pointRecord"
|
|
||||||
:key="index"
|
|
||||||
class="q-pa-none"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="json-field q-mr-xs text-grey"
|
|
||||||
:title="
|
|
||||||
value.name
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{
|
|
||||||
value.nameI18n
|
|
||||||
}}:
|
|
||||||
</span>
|
|
||||||
<VnJsonValue
|
|
||||||
:value="
|
|
||||||
value.val.val
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</QItem>
|
|
||||||
</QCardSection>
|
|
||||||
</QCard>
|
|
||||||
</QPopupProxy>
|
|
||||||
</QBtn>
|
|
||||||
<QIcon
|
|
||||||
class="action q-ml-xs"
|
|
||||||
:class="actionsClass[log.action]"
|
|
||||||
:name="actionsIcon[log.action]"
|
|
||||||
:title="
|
|
||||||
t(
|
|
||||||
`actions.${
|
|
||||||
actionsText[log.action]
|
|
||||||
}`
|
|
||||||
)
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</QItem>
|
|
||||||
</QCardSection>
|
|
||||||
<QCardSection
|
|
||||||
class="change-detail q-px-sm q-py-xs"
|
|
||||||
:class="{ expanded: log.expand }"
|
|
||||||
v-if="log.props.length || log.description"
|
|
||||||
>
|
>
|
||||||
<QIcon
|
{{ toRelativeDate(log.creationDate) }}
|
||||||
class="cursor-pointer q-mr-md"
|
</div>
|
||||||
|
<div>
|
||||||
|
<QBtn
|
||||||
color="grey"
|
color="grey"
|
||||||
name="expand_more"
|
class="pit"
|
||||||
:title="t('globals.details')"
|
icon="preview"
|
||||||
size="sm"
|
flat
|
||||||
@click="log.expand = !log.expand"
|
round
|
||||||
/>
|
:title="t('pointRecord')"
|
||||||
<span v-if="log.props.length" class="attributes">
|
padding="none"
|
||||||
<span
|
v-if="log.action != 'insert'"
|
||||||
v-if="!log.expand"
|
@click.stop="
|
||||||
class="q-pa-none text-grey"
|
openPointRecord(log.id, modelLog)
|
||||||
>
|
"
|
||||||
<span
|
>
|
||||||
v-for="(prop, propIndex) in log.props"
|
<QPopupProxy>
|
||||||
:key="propIndex"
|
<QCard v-if="pointRecord">
|
||||||
class="basic-json"
|
<div
|
||||||
>
|
class="header q-px-sm q-py-xs q-ma-none text-white text-bold bg-primary"
|
||||||
<span
|
|
||||||
class="json-field"
|
|
||||||
:title="prop.name"
|
|
||||||
>
|
>
|
||||||
{{ prop.nameI18n }}:
|
{{ modelLog.modelI18n }}
|
||||||
</span>
|
<span v-if="modelLog.id"
|
||||||
<VnJsonValue :value="prop.val.val" />
|
>#{{ modelLog.id }}</span
|
||||||
<span
|
>
|
||||||
v-if="
|
</div>
|
||||||
propIndex <
|
<QCardSection
|
||||||
log.props.length - 1
|
class="change-detail q-pa-sm"
|
||||||
"
|
>
|
||||||
>,
|
<QItem
|
||||||
</span>
|
v-for="(
|
||||||
|
value, index
|
||||||
|
) in pointRecord"
|
||||||
|
:key="index"
|
||||||
|
class="q-pa-none"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="json-field q-mr-xs text-grey"
|
||||||
|
:title="value.name"
|
||||||
|
>
|
||||||
|
{{ value.nameI18n }}:
|
||||||
|
</span>
|
||||||
|
<VnJsonValue
|
||||||
|
:value="value.val.val"
|
||||||
|
/>
|
||||||
|
</QItem>
|
||||||
|
</QCardSection>
|
||||||
|
</QCard>
|
||||||
|
</QPopupProxy>
|
||||||
|
</QBtn>
|
||||||
|
<QIcon
|
||||||
|
class="action q-ml-xs"
|
||||||
|
:class="actionsClass[log.action]"
|
||||||
|
:name="actionsIcon[log.action]"
|
||||||
|
:title="
|
||||||
|
t(`actions.${actionsText[log.action]}`)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</QItem>
|
||||||
|
</QCardSection>
|
||||||
|
<QCardSection
|
||||||
|
class="change-detail q-px-sm q-py-xs"
|
||||||
|
:class="{ expanded: log.expand }"
|
||||||
|
v-if="log.props.length || log.description"
|
||||||
|
>
|
||||||
|
<QIcon
|
||||||
|
class="cursor-pointer q-mr-md"
|
||||||
|
color="grey"
|
||||||
|
name="expand_more"
|
||||||
|
:title="t('globals.details')"
|
||||||
|
size="sm"
|
||||||
|
@click="log.expand = !log.expand"
|
||||||
|
/>
|
||||||
|
<span v-if="log.props.length" class="attributes">
|
||||||
|
<span v-if="!log.expand" class="q-pa-none text-grey">
|
||||||
|
<span
|
||||||
|
v-for="(prop, propIndex) in log.props"
|
||||||
|
:key="propIndex"
|
||||||
|
class="basic-json"
|
||||||
|
>
|
||||||
|
<span class="json-field" :title="prop.name">
|
||||||
|
{{ prop.nameI18n }}:
|
||||||
|
</span>
|
||||||
|
<VnJsonValue :value="prop.val.val" />
|
||||||
|
<span v-if="propIndex < log.props.length - 1"
|
||||||
|
>,
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
v-if="log.expand"
|
||||||
|
class="expanded-json column q-pa-none"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="(prop, prop2Index) in log.props"
|
||||||
|
:key="prop2Index"
|
||||||
|
class="q-pa-none text-grey"
|
||||||
|
>
|
||||||
|
<span class="json-field" :title="prop.name">
|
||||||
|
{{ prop.nameI18n }}:
|
||||||
|
</span>
|
||||||
|
<VnJsonValue :value="prop.val.val" />
|
||||||
|
<span v-if="prop.val.id" class="id-value">
|
||||||
|
#{{ prop.val.id }}
|
||||||
|
</span>
|
||||||
|
<span v-if="log.action == 'update'">
|
||||||
|
←
|
||||||
|
<VnJsonValue :value="prop.old.val" />
|
||||||
|
<span v-if="prop.old.id" class="id-value">
|
||||||
|
#{{ prop.old.id }}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span
|
</div>
|
||||||
v-if="log.expand"
|
</span>
|
||||||
class="expanded-json column q-pa-none"
|
</span>
|
||||||
>
|
<span v-if="!log.props.length" class="description">
|
||||||
<div
|
{{ log.description }}
|
||||||
v-for="(
|
</span>
|
||||||
prop, prop2Index
|
</QCardSection>
|
||||||
) in log.props"
|
</QCard>
|
||||||
:key="prop2Index"
|
</QItemSection>
|
||||||
class="q-pa-none text-grey"
|
</QItem>
|
||||||
>
|
</QList>
|
||||||
<span
|
</div>
|
||||||
class="json-field"
|
</div>
|
||||||
:title="prop.name"
|
|
||||||
>
|
|
||||||
{{ prop.nameI18n }}:
|
|
||||||
</span>
|
|
||||||
<VnJsonValue :value="prop.val.val" />
|
|
||||||
<span
|
|
||||||
v-if="prop.val.id"
|
|
||||||
class="id-value"
|
|
||||||
>
|
|
||||||
#{{ prop.val.id }}
|
|
||||||
</span>
|
|
||||||
<span v-if="log.action == 'update'">
|
|
||||||
←
|
|
||||||
<VnJsonValue
|
|
||||||
:value="prop.old.val"
|
|
||||||
/>
|
|
||||||
<span
|
|
||||||
v-if="prop.old.id"
|
|
||||||
class="id-value"
|
|
||||||
>
|
|
||||||
#{{ prop.old.id }}
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
v-if="!log.props.length"
|
|
||||||
class="description"
|
|
||||||
>
|
|
||||||
{{ log.description }}
|
|
||||||
</span>
|
|
||||||
</QCardSection>
|
|
||||||
</QCard>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</QList>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</VnPaginate>
|
|
||||||
<Teleport to="#right-panel" v-if="stateStore.isHeaderMounted()">
|
<Teleport to="#right-panel" v-if="stateStore.isHeaderMounted()">
|
||||||
<QList dense>
|
<QList dense>
|
||||||
<QSeparator />
|
<QSeparator />
|
||||||
|
@ -725,16 +691,17 @@ watch(
|
||||||
</QOptionGroup>
|
</QOptionGroup>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem class="q-mt-sm">
|
<QItem class="q-mt-sm">
|
||||||
<QItemSection v-if="userRadio !== null">
|
<QItemSection v-if="!workers">
|
||||||
|
<QSkeleton type="QInput" class="full-width" />
|
||||||
|
</QItemSection>
|
||||||
|
<QItemSection v-if="workers && userRadio !== null">
|
||||||
<VnSelect
|
<VnSelect
|
||||||
class="full-width"
|
class="full-width"
|
||||||
:label="t('globals.user')"
|
:label="t('globals.user')"
|
||||||
v-model="userSelect"
|
v-model="userSelect"
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
:url="`${model}Logs/${$route.params.id}/editors`"
|
:options="workers"
|
||||||
:fields="['id', 'nickname', 'name', 'image']"
|
|
||||||
sort-by="nickname"
|
|
||||||
@update:model-value="selectFilter('userSelect')"
|
@update:model-value="selectFilter('userSelect')"
|
||||||
hide-selected
|
hide-selected
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
|
||||||
import { onMounted, ref } from 'vue';
|
|
||||||
import { useQuasar } from 'quasar';
|
|
||||||
import LeftMenu from '../LeftMenu.vue';
|
|
||||||
|
|
||||||
const stateStore = useStateStore();
|
|
||||||
const $props = defineProps({
|
|
||||||
leftDrawer: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
onMounted(
|
|
||||||
() => (stateStore.leftDrawer = useQuasar().screen.gt.xs ? $props.leftDrawer : false)
|
|
||||||
);
|
|
||||||
|
|
||||||
const teleportRef = ref({});
|
|
||||||
const hasContent = ref();
|
|
||||||
let observer;
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
if (!teleportRef.value) return;
|
|
||||||
const checkContent = () => {
|
|
||||||
hasContent.value = teleportRef.value?.innerHTML?.trim() !== '';
|
|
||||||
};
|
|
||||||
|
|
||||||
observer = new MutationObserver(checkContent);
|
|
||||||
observer.observe(teleportRef.value, { childList: true, subtree: true });
|
|
||||||
|
|
||||||
checkContent();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<QDrawer v-model="stateStore.leftDrawer" show-if-above :width="256">
|
|
||||||
<QScrollArea class="fit text-grey-8">
|
|
||||||
<div id="left-panel" ref="teleportRef"></div>
|
|
||||||
<LeftMenu v-if="!hasContent" />
|
|
||||||
</QScrollArea>
|
|
||||||
</QDrawer>
|
|
||||||
<QPageContainer>
|
|
||||||
<QPage>
|
|
||||||
<RouterView />
|
|
||||||
</QPage>
|
|
||||||
</QPageContainer>
|
|
||||||
</template>
|
|
|
@ -9,6 +9,10 @@ const $props = defineProps({
|
||||||
type: Number, //Progress value (1.0 > x > 0.0)
|
type: Number, //Progress value (1.0 > x > 0.0)
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
showDialog: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
cancelled: {
|
cancelled: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
|
@ -20,22 +24,30 @@ const emit = defineEmits(['cancel', 'close']);
|
||||||
|
|
||||||
const dialogRef = ref(null);
|
const dialogRef = ref(null);
|
||||||
|
|
||||||
const showDialog = defineModel('showDialog', {
|
const _showDialog = computed({
|
||||||
type: Boolean,
|
get: () => $props.showDialog,
|
||||||
default: false,
|
set: (value) => {
|
||||||
|
if (value) dialogRef.value.show();
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const _progress = computed(() => $props.progress);
|
const _progress = computed(() => $props.progress);
|
||||||
|
|
||||||
const progressLabel = computed(() => `${Math.round($props.progress * 100)}%`);
|
const progressLabel = computed(() => `${Math.round($props.progress * 100)}%`);
|
||||||
|
|
||||||
|
const cancel = () => {
|
||||||
|
dialogRef.value.hide();
|
||||||
|
emit('cancel');
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<QDialog ref="dialogRef" v-model="showDialog" @hide="emit('close')">
|
<QDialog ref="dialogRef" v-model="_showDialog" @hide="onDialogHide">
|
||||||
<QCard class="full-width dialog">
|
<QCard class="full-width dialog">
|
||||||
<QCardSection class="row">
|
<QCardSection class="row">
|
||||||
<span class="text-h6">{{ t('Progress') }}</span>
|
<span class="text-h6">{{ t('Progress') }}</span>
|
||||||
<QSpace />
|
<QSpace />
|
||||||
<QBtn icon="close" flat round dense v-close-popup />
|
<QBtn icon="close" flat round dense @click="emit('close')" />
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<QCardSection>
|
<QCardSection>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
|
@ -68,7 +80,7 @@ const progressLabel = computed(() => `${Math.round($props.progress * 100)}%`);
|
||||||
type="button"
|
type="button"
|
||||||
flat
|
flat
|
||||||
class="text-primary"
|
class="text-primary"
|
||||||
v-close-popup
|
@click="cancel()"
|
||||||
>
|
>
|
||||||
{{ t('globals.cancel') }}
|
{{ t('globals.cancel') }}
|
||||||
</QBtn>
|
</QBtn>
|
||||||
|
|
|
@ -2,12 +2,5 @@
|
||||||
const model = defineModel({ type: Boolean, required: true });
|
const model = defineModel({ type: Boolean, required: true });
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<QRadio
|
<QRadio v-model="model" v-bind="$attrs" dense :dark="true" class="q-mr-sm" />
|
||||||
v-model="model"
|
|
||||||
v-bind="$attrs"
|
|
||||||
dense
|
|
||||||
:dark="true"
|
|
||||||
class="q-mr-sm"
|
|
||||||
size="xs"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,97 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import RightMenu from './RightMenu.vue';
|
|
||||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
|
||||||
import VnTableFilter from '../VnTable/VnTableFilter.vue';
|
|
||||||
import { onBeforeMount, computed, ref } from 'vue';
|
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
import { useHasContent } from 'src/composables/useHasContent';
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
section: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
dataKey: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
searchBar: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
prefix: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
rightFilter: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
columns: {
|
|
||||||
type: Array,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
arrayDataProps: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
redirect: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
keepData: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
let arrayData;
|
|
||||||
const sectionValue = computed(() => $props.section ?? $props.dataKey);
|
|
||||||
const isMainSection = computed(() => {
|
|
||||||
const isSame = sectionValue.value == route.name;
|
|
||||||
if (!isSame && arrayData) {
|
|
||||||
arrayData.reset(['userParams', 'userFilter']);
|
|
||||||
}
|
|
||||||
return isSame;
|
|
||||||
});
|
|
||||||
const searchbarId = 'section-searchbar';
|
|
||||||
const hasContent = useHasContent(`#${searchbarId}`);
|
|
||||||
|
|
||||||
onBeforeMount(() => {
|
|
||||||
if ($props.dataKey)
|
|
||||||
arrayData = useArrayData($props.dataKey, {
|
|
||||||
searchUrl: 'table',
|
|
||||||
keepData: $props.keepData,
|
|
||||||
...$props.arrayDataProps,
|
|
||||||
navigate: $props.redirect,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<slot name="searchbar">
|
|
||||||
<VnSearchbar
|
|
||||||
v-if="searchBar && !hasContent"
|
|
||||||
v-bind="arrayDataProps"
|
|
||||||
:data-key="dataKey"
|
|
||||||
:label="$t(`${prefix}.search`)"
|
|
||||||
:info="$t(`${prefix}.searchInfo`)"
|
|
||||||
/>
|
|
||||||
<div :id="searchbarId"></div>
|
|
||||||
</slot>
|
|
||||||
<RightMenu>
|
|
||||||
<template #right-panel v-if="$slots['rightMenu'] || rightFilter">
|
|
||||||
<slot name="rightMenu">
|
|
||||||
<VnTableFilter
|
|
||||||
v-if="rightFilter && columns"
|
|
||||||
:data-key="dataKey"
|
|
||||||
:array-data="arrayData"
|
|
||||||
:columns="columns"
|
|
||||||
/>
|
|
||||||
</slot>
|
|
||||||
</template>
|
|
||||||
</RightMenu>
|
|
||||||
<slot name="body" v-if="isMainSection" />
|
|
||||||
<RouterView v-else />
|
|
||||||
</template>
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
<script setup>
|
||||||
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
|
import LeftMenu from 'components/LeftMenu.vue';
|
||||||
|
import { onMounted } from 'vue';
|
||||||
|
|
||||||
|
const stateStore = useStateStore();
|
||||||
|
const $props = defineProps({
|
||||||
|
leftDrawer: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
onMounted(() => (stateStore.leftDrawer = $props.leftDrawer));
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<QDrawer v-model="stateStore.leftDrawer" show-if-above :width="256">
|
||||||
|
<QScrollArea class="fit text-grey-8">
|
||||||
|
<LeftMenu />
|
||||||
|
</QScrollArea>
|
||||||
|
</QDrawer>
|
||||||
|
<QPageContainer>
|
||||||
|
<RouterView></RouterView>
|
||||||
|
</QPageContainer>
|
||||||
|
</template>
|
|
@ -1,21 +1,8 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, toRefs, computed, watch, onMounted, useAttrs } from 'vue';
|
import { ref, toRefs, computed, watch, onMounted } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import FetchData from 'src/components/FetchData.vue';
|
||||||
import { useRequired } from 'src/composables/useRequired';
|
|
||||||
import dataByOrder from 'src/utils/dataByOrder';
|
|
||||||
import { QItemLabel } from 'quasar';
|
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'update:options', 'remove']);
|
const emit = defineEmits(['update:modelValue', 'update:options', 'remove']);
|
||||||
const $attrs = useAttrs();
|
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
const isRequired = computed(() => {
|
|
||||||
return useRequired($attrs).isRequired;
|
|
||||||
});
|
|
||||||
const requiredFieldRule = computed(() => {
|
|
||||||
return useRequired($attrs).requiredFieldRule;
|
|
||||||
});
|
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
|
@ -34,10 +21,6 @@ const $props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: 'id',
|
default: 'id',
|
||||||
},
|
},
|
||||||
optionCaption: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
optionFilter: {
|
optionFilter: {
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
|
@ -54,10 +37,6 @@ const $props = defineProps({
|
||||||
type: [Array],
|
type: [Array],
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
exprBuilder: {
|
|
||||||
type: Function,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
isClearable: {
|
isClearable: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
|
@ -94,54 +73,19 @@ const $props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
params: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
noOne: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
dataKey: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
isOutlined: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const mixinRules = [requiredFieldRule, ...($attrs.rules ?? [])];
|
const { t } = useI18n();
|
||||||
const {
|
const requiredFieldRule = (val) => val ?? t('globals.fieldRequired');
|
||||||
optionLabel,
|
|
||||||
optionValue,
|
const { optionLabel, optionValue, optionFilter, optionFilterValue, options, modelValue } =
|
||||||
optionCaption,
|
toRefs($props);
|
||||||
optionFilter,
|
|
||||||
optionFilterValue,
|
|
||||||
options,
|
|
||||||
modelValue,
|
|
||||||
} = toRefs($props);
|
|
||||||
const myOptions = ref([]);
|
const myOptions = ref([]);
|
||||||
const myOptionsOriginal = ref([]);
|
const myOptionsOriginal = ref([]);
|
||||||
const vnSelectRef = ref();
|
const vnSelectRef = ref();
|
||||||
|
const dataRef = ref();
|
||||||
const lastVal = ref();
|
const lastVal = ref();
|
||||||
const noOneText = t('globals.noOne');
|
|
||||||
const noOneOpt = ref({
|
|
||||||
[optionValue.value]: false,
|
|
||||||
[optionLabel.value]: noOneText,
|
|
||||||
});
|
|
||||||
const styleAttrs = computed(() => {
|
|
||||||
return $props.isOutlined
|
|
||||||
? {
|
|
||||||
dense: true,
|
|
||||||
outlined: true,
|
|
||||||
rounded: true,
|
|
||||||
}
|
|
||||||
: {};
|
|
||||||
});
|
|
||||||
const isLoading = ref(false);
|
|
||||||
const useURL = computed(() => $props.url);
|
|
||||||
const value = computed({
|
const value = computed({
|
||||||
get() {
|
get() {
|
||||||
return $props.modelValue;
|
return $props.modelValue;
|
||||||
|
@ -156,39 +100,26 @@ watch(options, (newValue) => {
|
||||||
setOptions(newValue);
|
setOptions(newValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(modelValue, async (newValue) => {
|
watch(modelValue, (newValue) => {
|
||||||
if (!myOptions?.value?.some((option) => option[optionValue.value] == newValue))
|
if (!myOptions.value.some((option) => option[optionValue.value] == newValue))
|
||||||
await fetchFilter(newValue);
|
fetchFilter(newValue);
|
||||||
|
|
||||||
if ($props.noOne) myOptions.value.unshift(noOneOpt.value);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
setOptions(options.value);
|
setOptions(options.value);
|
||||||
if (useURL.value && $props.modelValue && !findKeyInOptions())
|
if ($props.url && $props.modelValue && !findKeyInOptions())
|
||||||
fetchFilter($props.modelValue);
|
fetchFilter($props.modelValue);
|
||||||
if ($props.focusOnMount) setTimeout(() => vnSelectRef.value.showPopup(), 300);
|
if ($props.focusOnMount) setTimeout(() => vnSelectRef.value.showPopup(), 300);
|
||||||
});
|
});
|
||||||
|
|
||||||
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, $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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function filter(val, options) {
|
function filter(val, options) {
|
||||||
|
@ -205,15 +136,15 @@ function filter(val, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!row) return;
|
if (!row) return;
|
||||||
const id = String(row[$props.optionValue]);
|
const id = row[$props.optionValue];
|
||||||
const optionLabel = String(row[$props.optionLabel]).toLowerCase();
|
const optionLabel = String(row[$props.optionLabel]).toLowerCase();
|
||||||
|
|
||||||
return id.includes(search) || optionLabel.includes(search);
|
return id == search || optionLabel.includes(search);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchFilter(val) {
|
async function fetchFilter(val) {
|
||||||
if (!$props.url) return;
|
if (!$props.url || !dataRef.value) return;
|
||||||
|
|
||||||
const { fields, include, sortBy, limit } = $props;
|
const { fields, include, sortBy, limit } = $props;
|
||||||
const key =
|
const key =
|
||||||
|
@ -222,24 +153,14 @@ async function fetchFilter(val) {
|
||||||
? optionValue.value
|
? optionValue.value
|
||||||
: optionFilter.value ?? optionLabel.value);
|
: optionFilter.value ?? optionLabel.value);
|
||||||
|
|
||||||
let defaultWhere = {};
|
const defaultWhere = $props.useLike
|
||||||
if ($props.filterOptions.length) {
|
? { [key]: { like: `%${val}%` } }
|
||||||
defaultWhere = $props.filterOptions.reduce((obj, prop) => {
|
: { [key]: val };
|
||||||
if (!obj.or) obj.or = [];
|
|
||||||
obj.or.push({ [prop]: getVal(val) });
|
|
||||||
return obj;
|
|
||||||
}, {});
|
|
||||||
} else defaultWhere = { [key]: getVal(val) };
|
|
||||||
const where = { ...(val ? defaultWhere : {}), ...$props.where };
|
const where = { ...(val ? defaultWhere : {}), ...$props.where };
|
||||||
$props.exprBuilder && Object.assign(where, $props.exprBuilder(key, val));
|
|
||||||
const fetchOptions = { where, include, limit };
|
const fetchOptions = { where, include, limit };
|
||||||
if (fields) fetchOptions.fields = fields;
|
if (fields) fetchOptions.fields = fields;
|
||||||
if (sortBy) fetchOptions.order = sortBy;
|
if (sortBy) fetchOptions.order = sortBy;
|
||||||
arrayData.resetPagination();
|
return dataRef.value.fetch(fetchOptions);
|
||||||
|
|
||||||
const { data } = await arrayData.applyFilter({ filter: fetchOptions });
|
|
||||||
setOptions(data);
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function filterHandler(val, update) {
|
async function filterHandler(val, update) {
|
||||||
|
@ -259,9 +180,6 @@ async function filterHandler(val, update) {
|
||||||
} else newOptions = filter(val, myOptionsOriginal.value);
|
} else newOptions = filter(val, myOptionsOriginal.value);
|
||||||
update(
|
update(
|
||||||
() => {
|
() => {
|
||||||
if ($props.noOne && noOneText.toLowerCase().includes(val.toLowerCase()))
|
|
||||||
newOptions.unshift(noOneOpt.value);
|
|
||||||
|
|
||||||
myOptions.value = newOptions;
|
myOptions.value = newOptions;
|
||||||
},
|
},
|
||||||
(ref) => {
|
(ref) => {
|
||||||
|
@ -276,72 +194,24 @@ async function filterHandler(val, update) {
|
||||||
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 }) {
|
|
||||||
const lastIndex = myOptions.value.length - 1;
|
|
||||||
|
|
||||||
if (from === 0 && index === 0) return;
|
|
||||||
if (!useURL.value && !$props.fetchRef) return;
|
|
||||||
if (direction === 'decrease') return;
|
|
||||||
if (to === lastIndex && arrayData.store.hasMoreData && !isLoading.value) {
|
|
||||||
isLoading.value = true;
|
|
||||||
await arrayData.loadMore();
|
|
||||||
setOptions(arrayData.store.data);
|
|
||||||
vnSelectRef.value.scrollTo(lastIndex);
|
|
||||||
isLoading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({ opts: myOptions });
|
|
||||||
|
|
||||||
function handleKeyDown(event) {
|
|
||||||
if (event.key === 'Tab' && !event.shiftKey) {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
const inputValue = vnSelectRef.value?.inputValue;
|
|
||||||
|
|
||||||
if (inputValue) {
|
|
||||||
const matchingOption = myOptions.value.find(
|
|
||||||
(option) =>
|
|
||||||
option[optionLabel.value].toLowerCase() === inputValue.toLowerCase()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matchingOption) {
|
|
||||||
emit('update:modelValue', matchingOption[optionValue.value]);
|
|
||||||
} else {
|
|
||||||
emit('update:modelValue', inputValue);
|
|
||||||
}
|
|
||||||
vnSelectRef.value?.hidePopup();
|
|
||||||
}
|
|
||||||
|
|
||||||
const focusableElements = document.querySelectorAll(
|
|
||||||
'a:not([disabled]), button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), details:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled])'
|
|
||||||
);
|
|
||||||
const currentIndex = Array.prototype.indexOf.call(
|
|
||||||
focusableElements,
|
|
||||||
event.target
|
|
||||||
);
|
|
||||||
if (currentIndex >= 0 && currentIndex < focusableElements.length - 1) {
|
|
||||||
focusableElements[currentIndex + 1].focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCaption(opt) {
|
|
||||||
if (optionCaption.value === false) return;
|
|
||||||
return opt[optionCaption.value] || opt[optionValue.value];
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<FetchData
|
||||||
|
ref="dataRef"
|
||||||
|
:url="$props.url"
|
||||||
|
@on-fetch="(data) => setOptions(data)"
|
||||||
|
:where="where || { [optionValue]: value }"
|
||||||
|
:limit="limit"
|
||||||
|
:sort-by="sortBy"
|
||||||
|
:fields="fields"
|
||||||
|
/>
|
||||||
<QSelect
|
<QSelect
|
||||||
v-model="value"
|
v-model="value"
|
||||||
:options="myOptions"
|
:options="myOptions"
|
||||||
:option-label="optionLabel"
|
:option-label="optionLabel"
|
||||||
:option-value="optionValue"
|
:option-value="optionValue"
|
||||||
v-bind="{ ...$attrs, ...styleAttrs }"
|
v-bind="$attrs"
|
||||||
@filter="filterHandler"
|
@filter="filterHandler"
|
||||||
:emit-value="nullishToTrue($attrs['emit-value'])"
|
:emit-value="nullishToTrue($attrs['emit-value'])"
|
||||||
:map-options="nullishToTrue($attrs['map-options'])"
|
:map-options="nullishToTrue($attrs['map-options'])"
|
||||||
|
@ -350,22 +220,15 @@ function getCaption(opt) {
|
||||||
:fill-input="nullishToTrue($attrs['fill-input'])"
|
:fill-input="nullishToTrue($attrs['fill-input'])"
|
||||||
ref="vnSelectRef"
|
ref="vnSelectRef"
|
||||||
lazy-rules
|
lazy-rules
|
||||||
:class="{ required: isRequired }"
|
:class="{ required: $attrs.required }"
|
||||||
:rules="mixinRules"
|
:rules="$attrs.required ? [requiredFieldRule] : null"
|
||||||
virtual-scroll-slice-size="options.length"
|
virtual-scroll-slice-size="options.length"
|
||||||
hide-bottom-space
|
|
||||||
:input-debounce="useURL ? '300' : '0'"
|
|
||||||
:loading="isLoading"
|
|
||||||
@virtual-scroll="onScroll"
|
|
||||||
@keydown="handleKeyDown"
|
|
||||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_select'"
|
|
||||||
:data-url="url"
|
|
||||||
>
|
>
|
||||||
<template #append>
|
<template v-if="isClearable" #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
v-show="isClearable && value"
|
v-show="value"
|
||||||
name="close"
|
name="close"
|
||||||
@click="
|
@click.stop="
|
||||||
() => {
|
() => {
|
||||||
value = null;
|
value = null;
|
||||||
emit('remove');
|
emit('remove');
|
||||||
|
@ -376,38 +239,7 @@ function getCaption(opt) {
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<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'">
|
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
||||||
<QIcon
|
|
||||||
v-show="isClearable && value"
|
|
||||||
name="close"
|
|
||||||
@click.stop="
|
|
||||||
() => {
|
|
||||||
value = null;
|
|
||||||
emit('remove');
|
|
||||||
}
|
|
||||||
"
|
|
||||||
class="cursor-pointer"
|
|
||||||
size="xs"
|
|
||||||
/>
|
|
||||||
<slot name="append" v-if="$slots.append" v-bind="slotData ?? {}" />
|
|
||||||
</div>
|
|
||||||
<slot v-else :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
|
||||||
</template>
|
|
||||||
<template #option="{ opt, itemProps }">
|
|
||||||
<QItem v-bind="itemProps">
|
|
||||||
<QItemSection v-if="typeof opt !== 'object'"> {{ opt }}</QItemSection>
|
|
||||||
<QItemSection v-else-if="opt[optionValue] == opt[optionLabel]">
|
|
||||||
<QItemLabel>{{ opt[optionLabel] }}</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
<QItemSection v-else>
|
|
||||||
<QItemLabel>
|
|
||||||
{{ opt[optionLabel] }}
|
|
||||||
</QItemLabel>
|
|
||||||
<QItemLabel caption v-if="getCaption(opt)">
|
|
||||||
{{ `#${getCaption(opt)}` }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
</template>
|
||||||
</QSelect>
|
</QSelect>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import { useRole } from 'src/composables/useRole';
|
import { useRole } from 'src/composables/useRole';
|
||||||
import { useAcl } from 'src/composables/useAcl';
|
|
||||||
|
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
const emit = defineEmits(['update:modelValue']);
|
const emit = defineEmits(['update:modelValue']);
|
||||||
|
@ -12,10 +11,6 @@ const $props = defineProps({
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => ['developer'],
|
default: () => ['developer'],
|
||||||
},
|
},
|
||||||
acls: {
|
|
||||||
type: Array,
|
|
||||||
default: () => [],
|
|
||||||
},
|
|
||||||
actionIcon: {
|
actionIcon: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'add',
|
default: 'add',
|
||||||
|
@ -27,12 +22,15 @@ const $props = defineProps({
|
||||||
});
|
});
|
||||||
|
|
||||||
const role = useRole();
|
const role = useRole();
|
||||||
const acl = useAcl();
|
const showForm = ref(false);
|
||||||
|
|
||||||
const isAllowedToCreate = computed(() => {
|
const isAllowedToCreate = computed(() => {
|
||||||
if ($props.acls.length) return acl.hasAny($props.acls);
|
|
||||||
return role.hasAny($props.rolesAllowedToCreate);
|
return role.hasAny($props.rolesAllowedToCreate);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const toggleForm = () => {
|
||||||
|
showForm.value = !showForm.value;
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -43,8 +41,7 @@ const isAllowedToCreate = computed(() => {
|
||||||
>
|
>
|
||||||
<template v-if="isAllowedToCreate" #append>
|
<template v-if="isAllowedToCreate" #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_icon'"
|
@click.stop.prevent="toggleForm()"
|
||||||
@click.stop.prevent="$refs.dialog.show()"
|
|
||||||
:name="actionIcon"
|
:name="actionIcon"
|
||||||
:size="actionIcon === 'add' ? 'xs' : 'sm'"
|
:size="actionIcon === 'add' ? 'xs' : 'sm'"
|
||||||
:class="['default-icon', { '--add-icon': actionIcon === 'add' }]"
|
:class="['default-icon', { '--add-icon': actionIcon === 'add' }]"
|
||||||
|
@ -54,7 +51,7 @@ const isAllowedToCreate = computed(() => {
|
||||||
>
|
>
|
||||||
<QTooltip v-if="tooltip">{{ tooltip }}</QTooltip>
|
<QTooltip v-if="tooltip">{{ tooltip }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QDialog ref="dialog" transition-show="scale" transition-hide="scale">
|
<QDialog v-model="showForm" transition-show="scale" transition-hide="scale">
|
||||||
<slot name="form" />
|
<slot name="form" />
|
||||||
</QDialog>
|
</QDialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { onBeforeMount, ref, useAttrs } from 'vue';
|
|
||||||
import axios from 'axios';
|
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
|
||||||
|
|
||||||
const { schema, table, column, translation, defaultOptions } = defineProps({
|
|
||||||
schema: {
|
|
||||||
type: String,
|
|
||||||
default: 'vn',
|
|
||||||
},
|
|
||||||
table: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
column: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
translation: {
|
|
||||||
type: Function,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
defaultOptions: {
|
|
||||||
type: Array,
|
|
||||||
default: () => [],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const $attrs = useAttrs();
|
|
||||||
const options = ref([]);
|
|
||||||
onBeforeMount(async () => {
|
|
||||||
options.value = [].concat(defaultOptions);
|
|
||||||
const { data } = await axios.get(`Applications/get-enum-values`, {
|
|
||||||
params: { schema, table, column },
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const value of data)
|
|
||||||
options.value.push({
|
|
||||||
[$attrs['option-value'] ?? 'id']: value,
|
|
||||||
[$attrs['option-label'] ?? 'name']: translation ? translation(value) : value,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<VnSelect
|
|
||||||
v-bind="$attrs"
|
|
||||||
:options="options"
|
|
||||||
:key="options.length"
|
|
||||||
:input-debounce="0"
|
|
||||||
/>
|
|
||||||
</template>
|
|
|
@ -1,86 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { computed, useAttrs } from 'vue';
|
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
|
||||||
import VnAvatar from 'src/components/ui/VnAvatar.vue';
|
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue']);
|
|
||||||
const $props = defineProps({
|
|
||||||
hasAvatar: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
hasInfo: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
modelValue: {
|
|
||||||
type: [String, Number, Object],
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const $attrs = useAttrs();
|
|
||||||
|
|
||||||
const value = computed({
|
|
||||||
get() {
|
|
||||||
return $props.modelValue;
|
|
||||||
},
|
|
||||||
set(val) {
|
|
||||||
emit('update:modelValue', val);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const url = computed(() => {
|
|
||||||
let url = 'Workers/search';
|
|
||||||
const { departmentCodes } = $attrs.params ?? {};
|
|
||||||
if (!departmentCodes) return url;
|
|
||||||
const params = new URLSearchParams({
|
|
||||||
departmentCodes: JSON.stringify(departmentCodes),
|
|
||||||
});
|
|
||||||
|
|
||||||
return url.concat(`?${params.toString()}`);
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<VnSelect
|
|
||||||
:label="$t('globals.worker')"
|
|
||||||
v-bind="$attrs"
|
|
||||||
v-model="value"
|
|
||||||
:url="url"
|
|
||||||
option-value="id"
|
|
||||||
option-label="nickname"
|
|
||||||
:fields="['id', 'name', 'nickname', 'code']"
|
|
||||||
:filter-options="['id', 'name', 'nickname', 'code']"
|
|
||||||
sort-by="nickname ASC"
|
|
||||||
>
|
|
||||||
<template #prepend v-if="$props.hasAvatar">
|
|
||||||
<VnAvatar :worker-id="value" color="primary" :title="title" />
|
|
||||||
</template>
|
|
||||||
<template #append v-if="$props.hasInfo">
|
|
||||||
<QIcon name="info" class="cursor-pointer">
|
|
||||||
<QTooltip>{{ $t($props.hasInfo) }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</template>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem v-bind="scope.itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>
|
|
||||||
{{ scope.opt.name }}
|
|
||||||
</QItemLabel>
|
|
||||||
<QItemLabel v-if="!scope.opt.id">
|
|
||||||
{{ scope.opt.nickname }}
|
|
||||||
</QItemLabel>
|
|
||||||
<QItemLabel caption v-else>
|
|
||||||
#{{ scope.opt.id }}, {{ scope.opt.nickname }}, {{ scope.opt.code }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
Responsible for approving invoices: Responsable de aprobar las facturas
|
|
||||||
</i18n>
|
|
|
@ -86,7 +86,7 @@ async function send() {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<QDialog ref="dialogRef" data-cy="vnSmsDialog">
|
<QDialog ref="dialogRef">
|
||||||
<QCard class="q-pa-sm">
|
<QCard class="q-pa-sm">
|
||||||
<QCardSection class="row items-center q-pb-none">
|
<QCardSection class="row items-center q-pb-none">
|
||||||
<span class="text-h6 text-grey">
|
<span class="text-h6 text-grey">
|
||||||
|
@ -161,7 +161,6 @@ async function send() {
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
color="primary"
|
color="primary"
|
||||||
unelevated
|
unelevated
|
||||||
data-cy="sendSmsBtn"
|
|
||||||
/>
|
/>
|
||||||
</QCardActions>
|
</QCardActions>
|
||||||
</QCard>
|
</QCard>
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
<script setup>
|
|
||||||
const model = defineModel({ type: [String, Number], required: true });
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<QTime v-model="model" now-btn mask="HH:mm" />
|
|
||||||
</template>
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.q-time {
|
|
||||||
width: 230px;
|
|
||||||
min-width: unset;
|
|
||||||
:deep(.q-time__header) {
|
|
||||||
min-height: unset;
|
|
||||||
height: 50px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -8,7 +8,7 @@ defineProps({
|
||||||
<template>
|
<template>
|
||||||
<div :class="$q.screen.gt.md ? 'q-pb-lg' : 'q-pb-md'">
|
<div :class="$q.screen.gt.md ? 'q-pb-lg' : 'q-pb-md'">
|
||||||
<div class="header-link" :style="{ cursor: url ? 'pointer' : 'default' }">
|
<div class="header-link" :style="{ cursor: url ? 'pointer' : 'default' }">
|
||||||
<a :href="url" :class="url ? 'link' : 'color-vn-text'" v-bind="$attrs">
|
<a :href="url" :class="url ? 'link' : 'color-vn-text'">
|
||||||
{{ text }}
|
{{ text }}
|
||||||
<QIcon v-if="url" :name="icon" />
|
<QIcon v-if="url" :name="icon" />
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
|
||||||
import VnChangePassword from 'src/components/common/VnChangePassword.vue';
|
|
||||||
import { vi, beforeEach, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
|
||||||
import { Notify } from 'quasar';
|
|
||||||
|
|
||||||
describe('VnSmsDialog', () => {
|
|
||||||
let vm;
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
vi.spyOn(axios, 'get').mockResolvedValue({
|
|
||||||
data: [],
|
|
||||||
});
|
|
||||||
vm = createWrapper(VnChangePassword, {
|
|
||||||
propsData: {
|
|
||||||
submitFn: vi.fn(),
|
|
||||||
},
|
|
||||||
}).vm;
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
Notify.create = vi.fn();
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should notify when new password is empty', async () => {
|
|
||||||
vm.passwords.newPassword = '';
|
|
||||||
vm.passwords.repeatPassword = 'password';
|
|
||||||
|
|
||||||
await vm.validate();
|
|
||||||
expect(Notify.create).toHaveBeenCalledWith(
|
|
||||||
expect.objectContaining({
|
|
||||||
message: 'You must enter a new password',
|
|
||||||
type: 'negative',
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should notify when passwords don't match", async () => {
|
|
||||||
vm.passwords.newPassword = 'password1';
|
|
||||||
vm.passwords.repeatPassword = 'password2';
|
|
||||||
await vm.validate();
|
|
||||||
expect(Notify.create).toHaveBeenCalledWith(
|
|
||||||
expect.objectContaining({
|
|
||||||
message: `Passwords don't match`,
|
|
||||||
type: 'negative',
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('if passwords match', () => {
|
|
||||||
it('should call submitFn and emit password', async () => {
|
|
||||||
vm.passwords.newPassword = 'password';
|
|
||||||
vm.passwords.repeatPassword = 'password';
|
|
||||||
await vm.validate();
|
|
||||||
expect(vm.props.submitFn).toHaveBeenCalledWith('password', undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call submitFn and emit password and old password', async () => {
|
|
||||||
vm.passwords.newPassword = 'password';
|
|
||||||
vm.passwords.repeatPassword = 'password';
|
|
||||||
vm.passwords.oldPassword = 'oldPassword';
|
|
||||||
|
|
||||||
await vm.validate();
|
|
||||||
expect(vm.props.submitFn).toHaveBeenCalledWith('password', 'oldPassword');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,28 +0,0 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
|
||||||
import VnDiscount from 'components/common/vnDiscount.vue';
|
|
||||||
|
|
||||||
describe('VnDiscount', () => {
|
|
||||||
let vm;
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
vm = createWrapper(VnDiscount, {
|
|
||||||
props: {
|
|
||||||
data: {},
|
|
||||||
price: 100,
|
|
||||||
quantity: 2,
|
|
||||||
discount: 10,
|
|
||||||
}
|
|
||||||
}).vm;
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('total', () => {
|
|
||||||
it('should calculate total correctly', () => {
|
|
||||||
expect(vm.total).toBe(180);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,87 +0,0 @@
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
|
||||||
import VnDmsList from 'src/components/common/VnDmsList.vue';
|
|
||||||
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
|
||||||
|
|
||||||
describe('VnDmsList', () => {
|
|
||||||
let vm;
|
|
||||||
const dms = {
|
|
||||||
userFk: 1,
|
|
||||||
name: 'DMS 1'
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
vi.spyOn(axios, 'get').mockResolvedValue({ data: [] });
|
|
||||||
vm = createWrapper(VnDmsList, {
|
|
||||||
props: {
|
|
||||||
model: 'WorkerDms/1110/filter',
|
|
||||||
defaultDmsCode: 'hhrrData',
|
|
||||||
filter: 'wd.workerFk',
|
|
||||||
updateModel: 'Workers',
|
|
||||||
deleteModel: 'WorkerDms',
|
|
||||||
downloadModel: 'WorkerDms'
|
|
||||||
}
|
|
||||||
}).vm;
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('setData()', () => {
|
|
||||||
const data = [
|
|
||||||
{
|
|
||||||
userFk: 1,
|
|
||||||
name: 'Jessica',
|
|
||||||
lastName: 'Jones',
|
|
||||||
file: '4.jpg',
|
|
||||||
created: '2021-07-28 21:00:00'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
userFk: 2,
|
|
||||||
name: 'Bruce',
|
|
||||||
lastName: 'Banner',
|
|
||||||
created: '2022-07-28 21:00:00',
|
|
||||||
dms: {
|
|
||||||
userFk: 2,
|
|
||||||
name: 'Bruce',
|
|
||||||
lastName: 'BannerDMS',
|
|
||||||
created: '2022-07-28 21:00:00',
|
|
||||||
file: '4.jpg',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
userFk: 3,
|
|
||||||
name: 'Natasha',
|
|
||||||
lastName: 'Romanoff',
|
|
||||||
file: '4.jpg',
|
|
||||||
created: '2021-10-28 21:00:00'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
it('Should replace objects that contain the "dms" property with the value of the same and sort by creation date', () => {
|
|
||||||
vm.setData(data);
|
|
||||||
expect([vm.rows][0][0].lastName).toEqual('BannerDMS');
|
|
||||||
expect([vm.rows][0][1].lastName).toEqual('Romanoff');
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('parseDms()', () => {
|
|
||||||
const resultDms = { ...dms, userId:1};
|
|
||||||
|
|
||||||
it('Should add properties that end with "Fk" by changing the suffix to "Id"', () => {
|
|
||||||
const parsedDms = vm.parseDms(dms);
|
|
||||||
expect(parsedDms).toEqual(resultDms);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('showFormDialog()', () => {
|
|
||||||
const resultDms = { ...dms, userId:1};
|
|
||||||
|
|
||||||
it('should call fn parseDms() and set show true if dms is defined', () => {
|
|
||||||
vm.showFormDialog(dms);
|
|
||||||
expect(vm.formDialog.show).toEqual(true);
|
|
||||||
expect(vm.formDialog.dms).toEqual(resultDms);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,72 +0,0 @@
|
||||||
import { createWrapper } from 'app/test/vitest/helper.js';
|
|
||||||
import { describe, it, expect } from 'vitest';
|
|
||||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
|
||||||
|
|
||||||
let vm;
|
|
||||||
let wrapper;
|
|
||||||
|
|
||||||
function generateWrapper(date, outlined, required) {
|
|
||||||
wrapper = createWrapper(VnInputDate, {
|
|
||||||
props: {
|
|
||||||
modelValue: date,
|
|
||||||
},
|
|
||||||
attrs: {
|
|
||||||
isOutlined: outlined,
|
|
||||||
required: required
|
|
||||||
},
|
|
||||||
});
|
|
||||||
wrapper = wrapper.wrapper;
|
|
||||||
vm = wrapper.vm;
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('VnInputDate', () => {
|
|
||||||
|
|
||||||
describe('formattedDate', () => {
|
|
||||||
it('formats a valid date correctly', async () => {
|
|
||||||
generateWrapper('2023-12-25', false, false);
|
|
||||||
await vm.$nextTick();
|
|
||||||
expect(vm.formattedDate).toBe('25/12/2023');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('updates the model value when a new date is set', async () => {
|
|
||||||
const input = wrapper.find('input');
|
|
||||||
await input.setValue('31/12/2023');
|
|
||||||
expect(wrapper.emitted()['update:modelValue']).toBeTruthy();
|
|
||||||
expect(wrapper.emitted()['update:modelValue'][0][0]).toBe('2023-12-31T00:00:00.000Z');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not update the model value when an invalid date is set', async () => {
|
|
||||||
const input = wrapper.find('input');
|
|
||||||
await input.setValue('invalid-date');
|
|
||||||
expect(wrapper.emitted()['update:modelValue'][0][0]).toBe('2023-12-31T00:00:00.000Z');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('styleAttrs', () => {
|
|
||||||
it('should return empty styleAttrs when isOutlined is false', async () => {
|
|
||||||
generateWrapper('2023-12-25', false, false);
|
|
||||||
await vm.$nextTick();
|
|
||||||
expect(vm.styleAttrs).toEqual({});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set styleAttrs when isOutlined is true', async () => {
|
|
||||||
generateWrapper('2023-12-25', true, false);
|
|
||||||
await vm.$nextTick();
|
|
||||||
expect(vm.styleAttrs.outlined).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('required', () => {
|
|
||||||
it('should not applies required class when isRequired is false', async () => {
|
|
||||||
generateWrapper('2023-12-25', false, false);
|
|
||||||
await vm.$nextTick();
|
|
||||||
expect(wrapper.find('.vn-input-date').classes()).not.toContain('required');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should applies required class when isRequired is true', async () => {
|
|
||||||
generateWrapper('2023-12-25', false, true);
|
|
||||||
await vm.$nextTick();
|
|
||||||
expect(wrapper.find('.vn-input-date').classes()).toContain('required');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,63 +0,0 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
|
||||||
import VnInputTime from 'components/common/VnInputTime.vue';
|
|
||||||
|
|
||||||
describe('VnInputTime', () => {
|
|
||||||
let wrapper;
|
|
||||||
let vm;
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
wrapper = createWrapper(VnInputTime, {
|
|
||||||
props: {
|
|
||||||
isOutlined: true,
|
|
||||||
timeOnly: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
vm = wrapper.vm;
|
|
||||||
wrapper = wrapper.wrapper;
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return the correct data if isOutlined is true', () => {
|
|
||||||
expect(vm.isOutlined).toBe(true);
|
|
||||||
expect(vm.styleAttrs).toEqual({ dense: true, outlined: true, rounded: true });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return the formatted data', () => {
|
|
||||||
expect(vm.dateToTime('2022-01-01T03:23:43')).toBe('03:23');
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('formattedTime', () => {
|
|
||||||
it('should return the formatted time for a valid ISO date', () => {
|
|
||||||
vm.model = '2025-01-02T15:45:00';
|
|
||||||
expect(vm.formattedTime).toBe('15:45');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle null model value gracefully', () => {
|
|
||||||
vm.model = null;
|
|
||||||
expect(vm.formattedTime).toBe(null);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle time-only input correctly', async () => {
|
|
||||||
await wrapper.setProps({ timeOnly: true });
|
|
||||||
vm.formattedTime = '14:30';
|
|
||||||
expect(vm.model).toBe('14:30');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should pad short time values correctly', async () => {
|
|
||||||
await wrapper.setProps({ timeOnly: true });
|
|
||||||
vm.formattedTime = '9';
|
|
||||||
expect(vm.model).toBe('09:00');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not update the model if the value is unchanged', () => {
|
|
||||||
vm.model = '14:30';
|
|
||||||
const previousModel = vm.model;
|
|
||||||
vm.formattedTime = '14:30';
|
|
||||||
expect(vm.model).toBe(previousModel);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,95 +0,0 @@
|
||||||
import { describe, it, expect } from 'vitest';
|
|
||||||
import VnJsonValue from 'src/components/common/VnJsonValue.vue';
|
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
|
||||||
|
|
||||||
const buildComponent = (props) => {
|
|
||||||
return createWrapper(VnJsonValue, {
|
|
||||||
props,
|
|
||||||
}).wrapper;
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('VnJsonValue', () => {
|
|
||||||
it('renders null value correctly', async () => {
|
|
||||||
const wrapper = buildComponent({ value: null });
|
|
||||||
const span = wrapper.find('span');
|
|
||||||
expect(span.text()).toBe('∅');
|
|
||||||
expect(span.classes()).toContain('json-null');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renders boolean true correctly', async () => {
|
|
||||||
const wrapper = buildComponent({ value: true });
|
|
||||||
const span = wrapper.find('span');
|
|
||||||
expect(span.text()).toBe('✓');
|
|
||||||
expect(span.classes()).toContain('json-true');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renders boolean false correctly', async () => {
|
|
||||||
const wrapper = buildComponent({ value: false });
|
|
||||||
const span = wrapper.find('span');
|
|
||||||
expect(span.text()).toBe('✗');
|
|
||||||
expect(span.classes()).toContain('json-false');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renders a short string correctly', async () => {
|
|
||||||
const wrapper = buildComponent({ value: 'Hello' });
|
|
||||||
const span = wrapper.find('span');
|
|
||||||
expect(span.text()).toBe('Hello');
|
|
||||||
expect(span.classes()).toContain('json-string');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renders a long string correctly with ellipsis', async () => {
|
|
||||||
const longString = 'a'.repeat(600);
|
|
||||||
const wrapper = buildComponent({ value: longString });
|
|
||||||
const span = wrapper.find('span');
|
|
||||||
expect(span.text()).toContain('...');
|
|
||||||
expect(span.text().length).toBeLessThanOrEqual(515);
|
|
||||||
expect(span.attributes('title')).toBe(longString);
|
|
||||||
expect(span.classes()).toContain('json-string');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renders a number correctly', async () => {
|
|
||||||
const wrapper = buildComponent({ value: 123.4567 });
|
|
||||||
const span = wrapper.find('span');
|
|
||||||
expect(span.text()).toBe('123.457');
|
|
||||||
expect(span.classes()).toContain('json-number');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renders an integer correctly', async () => {
|
|
||||||
const wrapper = buildComponent({ value: 42 });
|
|
||||||
const span = wrapper.find('span');
|
|
||||||
expect(span.text()).toBe('42');
|
|
||||||
expect(span.classes()).toContain('json-number');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renders a date correctly', async () => {
|
|
||||||
const date = new Date('2023-01-01');
|
|
||||||
const wrapper = buildComponent({ value: date });
|
|
||||||
const span = wrapper.find('span');
|
|
||||||
expect(span.text()).toBe('2023-01-01');
|
|
||||||
expect(span.classes()).toContain('json-object');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renders an object correctly', async () => {
|
|
||||||
const obj = { key: 'value' };
|
|
||||||
const wrapper = buildComponent({ value: obj });
|
|
||||||
const span = wrapper.find('span');
|
|
||||||
expect(span.text()).toBe(obj.toString());
|
|
||||||
expect(span.classes()).toContain('json-object');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renders an array correctly', async () => {
|
|
||||||
const arr = [1, 2, 3];
|
|
||||||
const wrapper = buildComponent({ value: arr });
|
|
||||||
const span = wrapper.find('span');
|
|
||||||
expect(span.text()).toBe(arr.toString());
|
|
||||||
expect(span.classes()).toContain('json-object');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('updates value when prop changes', async () => {
|
|
||||||
const wrapper = buildComponent({ value: true });
|
|
||||||
await wrapper.setProps({ value: 123 });
|
|
||||||
const span = wrapper.find('span');
|
|
||||||
expect(span.text()).toBe('123');
|
|
||||||
expect(span.classes()).toContain('json-number');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,91 +0,0 @@
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
|
||||||
import VnLocation from 'components/common/VnLocation.vue';
|
|
||||||
import { vi, afterEach, expect, it, beforeEach, describe } from 'vitest';
|
|
||||||
|
|
||||||
function buildComponent(data) {
|
|
||||||
return createWrapper(VnLocation, {
|
|
||||||
global: {
|
|
||||||
props: {
|
|
||||||
location: data
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}).vm;
|
|
||||||
}
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('formatLocation', () => {
|
|
||||||
let locationBase;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
locationBase = {
|
|
||||||
postcode: '46680',
|
|
||||||
city: 'Algemesi',
|
|
||||||
province: { name: 'Valencia' },
|
|
||||||
country: { name: 'Spain' }
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return the postcode, city, province and country', () => {
|
|
||||||
const location = { ...locationBase };
|
|
||||||
const vm = buildComponent(location);
|
|
||||||
expect(vm.formatLocation(location)).toEqual('46680, Algemesi(Valencia), Spain');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return the postcode and country', () => {
|
|
||||||
const location = { ...locationBase, city: undefined };
|
|
||||||
const vm = buildComponent(location);
|
|
||||||
expect(vm.formatLocation(location)).toEqual('46680, Spain');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return the city, province and country', () => {
|
|
||||||
const location = { ...locationBase, postcode: undefined };
|
|
||||||
const vm = buildComponent(location);
|
|
||||||
expect(vm.formatLocation(location)).toEqual('Algemesi(Valencia), Spain');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return the country', () => {
|
|
||||||
const location = { ...locationBase, postcode: undefined, city: undefined, province: undefined };
|
|
||||||
const vm = buildComponent(location);
|
|
||||||
expect(vm.formatLocation(location)).toEqual('Spain');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('showLabel', () => {
|
|
||||||
let locationBase;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
locationBase = {
|
|
||||||
code: '46680',
|
|
||||||
town: 'Algemesi',
|
|
||||||
province: 'Valencia',
|
|
||||||
country: 'Spain'
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should show the label with postcode, city, province and country', () => {
|
|
||||||
const location = { ...locationBase };
|
|
||||||
const vm = buildComponent(location);
|
|
||||||
expect(vm.showLabel(location)).toEqual('46680, Algemesi(Valencia), Spain');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should show the label with postcode and country', () => {
|
|
||||||
const location = { ...locationBase, town: undefined };
|
|
||||||
const vm = buildComponent(location);
|
|
||||||
expect(vm.showLabel(location)).toEqual('46680, Spain');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should show the label with city, province and country', () => {
|
|
||||||
const location = { ...locationBase, code: undefined };
|
|
||||||
const vm = buildComponent(location);
|
|
||||||
expect(vm.showLabel(location)).toEqual('Algemesi(Valencia), Spain');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should show the label with country', () => {
|
|
||||||
const location = { ...locationBase, code: undefined, town: undefined, province: undefined };
|
|
||||||
const vm = buildComponent(location);
|
|
||||||
expect(vm.showLabel(location)).toEqual('Spain');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,107 +0,0 @@
|
||||||
import { describe, it, expect, vi, beforeAll, afterEach, beforeEach } from 'vitest';
|
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
|
||||||
import VnNotes from 'src/components/ui/VnNotes.vue';
|
|
||||||
|
|
||||||
describe('VnNotes', () => {
|
|
||||||
let vm;
|
|
||||||
let wrapper;
|
|
||||||
let spyFetch;
|
|
||||||
let postMock;
|
|
||||||
let expectedBody;
|
|
||||||
const mockData= {name: 'Tony', lastName: 'Stark', text: 'Test Note', observationTypeFk: 1};
|
|
||||||
|
|
||||||
function generateExpectedBody() {
|
|
||||||
expectedBody = {...vm.$props.body, ...{ text: vm.newNote.text, observationTypeFk: vm.newNote.observationTypeFk }};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function setTestParams(text, observationType, type){
|
|
||||||
vm.newNote.text = text;
|
|
||||||
vm.newNote.observationTypeFk = observationType;
|
|
||||||
wrapper.setProps({ selectType: type });
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
|
||||||
vi.spyOn(axios, 'get').mockReturnValue({ data: [] });
|
|
||||||
|
|
||||||
wrapper = createWrapper(VnNotes, {
|
|
||||||
propsData: {
|
|
||||||
url: '/test',
|
|
||||||
body: { name: 'Tony', lastName: 'Stark' },
|
|
||||||
}
|
|
||||||
});
|
|
||||||
wrapper = wrapper.wrapper;
|
|
||||||
vm = wrapper.vm;
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
postMock = vi.spyOn(axios, 'post').mockResolvedValue(mockData);
|
|
||||||
spyFetch = vi.spyOn(vm.vnPaginateRef, 'fetch').mockImplementation(() => vi.fn());
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.clearAllMocks();
|
|
||||||
expectedBody = {};
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('insert', () => {
|
|
||||||
it('should not call axios.post and vnPaginateRef.fetch if newNote.text is null', async () => {
|
|
||||||
await setTestParams( null, null, true );
|
|
||||||
|
|
||||||
await vm.insert();
|
|
||||||
|
|
||||||
expect(postMock).not.toHaveBeenCalled();
|
|
||||||
expect(spyFetch).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not call axios.post and vnPaginateRef.fetch if newNote.text is empty', async () => {
|
|
||||||
await setTestParams( "", null, false );
|
|
||||||
|
|
||||||
await vm.insert();
|
|
||||||
|
|
||||||
expect(postMock).not.toHaveBeenCalled();
|
|
||||||
expect(spyFetch).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not call axios.post and vnPaginateRef.fetch if observationTypeFk is missing and selectType is true', async () => {
|
|
||||||
await setTestParams( "Test Note", null, true );
|
|
||||||
|
|
||||||
await vm.insert();
|
|
||||||
|
|
||||||
expect(postMock).not.toHaveBeenCalled();
|
|
||||||
expect(spyFetch).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call axios.post and vnPaginateRef.fetch if observationTypeFk is missing and selectType is false', async () => {
|
|
||||||
await setTestParams( "Test Note", null, false );
|
|
||||||
|
|
||||||
generateExpectedBody();
|
|
||||||
|
|
||||||
await vm.insert();
|
|
||||||
|
|
||||||
expect(postMock).toHaveBeenCalledWith(vm.$props.url, expectedBody);
|
|
||||||
expect(spyFetch).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call axios.post and vnPaginateRef.fetch if observationTypeFk is setted and selectType is false', async () => {
|
|
||||||
await setTestParams( "Test Note", 1, false );
|
|
||||||
|
|
||||||
generateExpectedBody();
|
|
||||||
|
|
||||||
await vm.insert();
|
|
||||||
|
|
||||||
expect(postMock).toHaveBeenCalledWith(vm.$props.url, expectedBody);
|
|
||||||
expect(spyFetch).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call axios.post and vnPaginateRef.fetch when newNote is valid', async () => {
|
|
||||||
await setTestParams( "Test Note", 1, true );
|
|
||||||
|
|
||||||
generateExpectedBody();
|
|
||||||
|
|
||||||
await vm.insert();
|
|
||||||
|
|
||||||
expect(postMock).toHaveBeenCalledWith(vm.$props.url, expectedBody);
|
|
||||||
expect(spyFetch).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -6,7 +6,6 @@ import { useArrayData } from 'composables/useArrayData';
|
||||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import VnMoreOptions from './VnMoreOptions.vue';
|
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
url: {
|
url: {
|
||||||
|
@ -159,11 +158,24 @@ const toModule = computed(() =>
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QBtn>
|
</QBtn>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<VnMoreOptions v-if="$slots.menu">
|
<QBtn
|
||||||
<template #menu="{ menuRef }">
|
v-if="$slots.menu"
|
||||||
<slot name="menu" :entity="entity" :menu-ref="menuRef" />
|
color="white"
|
||||||
</template>
|
dense
|
||||||
</VnMoreOptions>
|
flat
|
||||||
|
icon="more_vert"
|
||||||
|
round
|
||||||
|
size="md"
|
||||||
|
>
|
||||||
|
<QTooltip>
|
||||||
|
{{ t('components.cardDescriptor.moreOptions') }}
|
||||||
|
</QTooltip>
|
||||||
|
<QMenu ref="menuRef">
|
||||||
|
<QList>
|
||||||
|
<slot name="menu" :entity="entity" :menu-ref="menuRef" />
|
||||||
|
</QList>
|
||||||
|
</QMenu>
|
||||||
|
</QBtn>
|
||||||
</div>
|
</div>
|
||||||
<slot name="before" />
|
<slot name="before" />
|
||||||
<div class="body q-py-sm">
|
<div class="body q-py-sm">
|
||||||
|
|
|
@ -2,9 +2,8 @@
|
||||||
import { ref, computed, watch, onBeforeMount } from 'vue';
|
import { ref, computed, watch, onBeforeMount } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import SkeletonSummary from 'components/ui/SkeletonSummary.vue';
|
import SkeletonSummary from 'components/ui/SkeletonSummary.vue';
|
||||||
|
import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
import { isDialogOpened } from 'src/filters';
|
|
||||||
import VnMoreOptions from './VnMoreOptions.vue';
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
url: {
|
url: {
|
||||||
|
@ -59,6 +58,22 @@ async function fetch() {
|
||||||
emit('onFetch', Array.isArray(data) ? data[0] : data);
|
emit('onFetch', Array.isArray(data) ? data[0] : data);
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const showRedirectToSummaryIcon = computed(() => {
|
||||||
|
const exist = existSummary(route.matched);
|
||||||
|
return !isSummary.value && route.meta.moduleName && exist;
|
||||||
|
});
|
||||||
|
|
||||||
|
function existSummary(routes) {
|
||||||
|
const hasSummary = routes.some((r) => r.name === `${route.meta.moduleName}Summary`);
|
||||||
|
if (hasSummary) return hasSummary;
|
||||||
|
for (const current of routes) {
|
||||||
|
if (current.path != '/' && current.children) {
|
||||||
|
const exist = existSummary(current.children);
|
||||||
|
if (exist) return exist;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -69,7 +84,7 @@ async function fetch() {
|
||||||
<div class="summaryHeader bg-primary q-pa-sm text-weight-bolder">
|
<div class="summaryHeader bg-primary q-pa-sm text-weight-bolder">
|
||||||
<slot name="header-left">
|
<slot name="header-left">
|
||||||
<router-link
|
<router-link
|
||||||
v-if="isDialogOpened()"
|
v-if="showRedirectToSummaryIcon"
|
||||||
class="header link"
|
class="header link"
|
||||||
:to="{
|
:to="{
|
||||||
name: `${moduleName ?? route.meta.moduleName}Summary`,
|
name: `${moduleName ?? route.meta.moduleName}Summary`,
|
||||||
|
@ -81,16 +96,11 @@ async function fetch() {
|
||||||
<span v-else></span>
|
<span v-else></span>
|
||||||
</slot>
|
</slot>
|
||||||
<slot name="header" :entity="entity" dense>
|
<slot name="header" :entity="entity" dense>
|
||||||
{{ entity.id + ' - ' + entity.name }}
|
<VnLv :label="`${entity.id} -`" :value="entity.name" />
|
||||||
|
</slot>
|
||||||
|
<slot name="header-right">
|
||||||
|
<span></span>
|
||||||
</slot>
|
</slot>
|
||||||
<span class="row no-wrap">
|
|
||||||
<slot name="header-right" :entity="entity" />
|
|
||||||
<VnMoreOptions v-if="$slots.menu && isDialogOpened()">
|
|
||||||
<template #menu="{ menuRef }">
|
|
||||||
<slot name="menu" :entity="entity" :menu-ref="menuRef" />
|
|
||||||
</template>
|
|
||||||
</VnMoreOptions>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="summaryBody row q-mb-md">
|
<div class="summaryBody row q-mb-md">
|
||||||
<slot name="body" :entity="entity" />
|
<slot name="body" :entity="entity" />
|
||||||
|
@ -108,7 +118,6 @@ async function fetch() {
|
||||||
|
|
||||||
.cardSummary {
|
.cardSummary {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-height: 70vh;
|
|
||||||
.summaryHeader {
|
.summaryHeader {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, toRef } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
import VnLv from 'components/ui/VnLv.vue';
|
import VnLv from 'components/ui/VnLv.vue';
|
||||||
|
@ -13,7 +13,7 @@ const DEFAULT_PRICE_KG = 0;
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const props = defineProps({
|
defineProps({
|
||||||
item: {
|
item: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -25,63 +25,57 @@ const props = defineProps({
|
||||||
});
|
});
|
||||||
|
|
||||||
const dialog = ref(null);
|
const dialog = ref(null);
|
||||||
const card = toRef(props, 'item');
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="container order-catalog-item overflow-hidden">
|
<div class="container order-catalog-item overflow-hidden">
|
||||||
<QCard class="card shadow-6">
|
<QCard class="card shadow-6">
|
||||||
<div class="img-wrapper">
|
<div class="img-wrapper">
|
||||||
<VnImg :id="card.id" class="image" zoom-resolution="1600x900" />
|
<VnImg :id="item.id" class="image" />
|
||||||
<div v-if="card.hex && isCatalog" class="item-color-container">
|
<div v-if="item.hex && isCatalog" class="item-color-container">
|
||||||
<div
|
<div
|
||||||
class="item-color"
|
class="item-color"
|
||||||
:style="{ backgroundColor: `#${card.hex}` }"
|
:style="{ backgroundColor: `#${item.hex}` }"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<span class="link">
|
<span class="link">
|
||||||
{{ card.name }}
|
{{ item.name }}
|
||||||
<ItemDescriptorProxy :id="card.id" />
|
<ItemDescriptorProxy :id="item.id" />
|
||||||
</span>
|
</span>
|
||||||
<p class="subName">{{ card.subName }}</p>
|
<p class="subName">{{ item.subName }}</p>
|
||||||
<template v-for="index in 4" :key="`tag-${index}`">
|
<template v-for="index in 4" :key="`tag-${index}`">
|
||||||
<VnLv
|
<VnLv
|
||||||
v-if="card?.[`tag${index + 4}`]"
|
v-if="item?.[`tag${index + 4}`]"
|
||||||
:label="card?.[`tag${index + 4}`] + ':'"
|
:label="item?.[`tag${index + 4}`] + ':'"
|
||||||
:value="card?.[`value${index + 4}`]"
|
:value="item?.[`value${index + 4}`]"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<div v-if="card.minQuantity" class="min-quantity">
|
<div v-if="item.minQuantity" class="min-quantity">
|
||||||
<QIcon name="production_quantity_limits" size="xs" />
|
<QIcon name="production_quantity_limits" size="xs" />
|
||||||
{{ card.minQuantity }}
|
{{ item.minQuantity }}
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<div class="price">
|
<div class="price">
|
||||||
<p v-if="isCatalog">
|
<p v-if="isCatalog">
|
||||||
{{ card.available }} {{ t('to') }}
|
{{ item.available }} {{ t('to') }}
|
||||||
{{ toCurrency(card.price) }}
|
{{ toCurrency(item.price) }}
|
||||||
</p>
|
</p>
|
||||||
<slot name="price" />
|
<slot name="price" />
|
||||||
<QIcon v-if="isCatalog" name="add_circle" class="icon">
|
<QIcon v-if="isCatalog" name="add_circle" class="icon">
|
||||||
<QTooltip>{{ t('globals.add') }}</QTooltip>
|
<QTooltip>{{ t('globals.add') }}</QTooltip>
|
||||||
<QPopupProxy ref="dialog">
|
<QPopupProxy ref="dialog">
|
||||||
<OrderCatalogItemDialog
|
<OrderCatalogItemDialog
|
||||||
:item="card"
|
:prices="item.prices"
|
||||||
@added="
|
@added="() => dialog.hide()"
|
||||||
(quantityAdded) => {
|
|
||||||
card.available += quantityAdded;
|
|
||||||
dialog.hide();
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
/>
|
||||||
</QPopupProxy>
|
</QPopupProxy>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
</div>
|
</div>
|
||||||
<p v-if="card.priceKg" class="price-kg">
|
<p v-if="item.priceKg" class="price-kg">
|
||||||
{{ t('price-kg') }}
|
{{ t('price-kg') }}
|
||||||
{{ toCurrency(card.priceKg) || DEFAULT_PRICE_KG }}
|
{{ toCurrency(item.priceKg) || DEFAULT_PRICE_KG }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
|
maxLength: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
item: {
|
item: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -16,12 +20,7 @@ const $props = defineProps({
|
||||||
required: false,
|
required: false,
|
||||||
default: 'value',
|
default: 'value',
|
||||||
},
|
},
|
||||||
columns: {
|
|
||||||
type: Number,
|
|
||||||
default: 3,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const tags = computed(() => {
|
const tags = computed(() => {
|
||||||
return Object.keys($props.item)
|
return Object.keys($props.item)
|
||||||
.filter((i) => i.startsWith(`${$props.tag}`))
|
.filter((i) => i.startsWith(`${$props.tag}`))
|
||||||
|
@ -33,21 +32,10 @@ const tags = computed(() => {
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
});
|
});
|
||||||
|
|
||||||
const columnStyle = computed(() => {
|
|
||||||
if ($props.columns) {
|
|
||||||
return {
|
|
||||||
'grid-template-columns': `repeat(${$props.columns}, 1fr)`,
|
|
||||||
'max-width': `${$props.columns * 4}rem`,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="fetchedTags">
|
<div class="fetchedTags">
|
||||||
<div class="wrap" :style="columnStyle">
|
<div class="wrap">
|
||||||
<div
|
<div
|
||||||
v-for="(val, key) in tags"
|
v-for="(val, key) in tags"
|
||||||
:key="key"
|
:key="key"
|
||||||
|
@ -55,43 +43,37 @@ const columnStyle = computed(() => {
|
||||||
:title="`${key}: ${val}`"
|
:title="`${key}: ${val}`"
|
||||||
:class="{ empty: !val }"
|
:class="{ empty: !val }"
|
||||||
>
|
>
|
||||||
<span class="text">{{ val }} </span>
|
{{ val }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.fetchedTags {
|
.fetchedTags {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
.wrap {
|
.wrap {
|
||||||
display: grid;
|
width: 100%;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.inline-tag {
|
.inline-tag {
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
height: 1rem;
|
height: 1rem;
|
||||||
margin: 0.05rem;
|
margin: 0.05rem;
|
||||||
color: var(--vn-label-color);
|
color: $color-font-secondary;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: smaller;
|
font-size: smaller;
|
||||||
padding: 1px;
|
padding: 1px;
|
||||||
border: 1px solid var(--vn-label-color);
|
flex: 1;
|
||||||
|
border: 1px solid $color-spacer;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
min-width: 4rem;
|
min-width: 4rem;
|
||||||
max-width: 4rem;
|
max-width: 4rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text {
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
font-size: smaller;
|
|
||||||
}
|
|
||||||
.empty {
|
.empty {
|
||||||
border: 1px solid var(--vn-empty-tag);
|
border: 1px solid #2b2b2b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,49 +1,38 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="header bg-primary q-pa-sm q-mb-md">
|
<div class="header bg-primary q-pa-sm q-mb-md">
|
||||||
<QSkeleton type="rect" square />
|
<QSkeleton type="rect" square />
|
||||||
<QSkeleton type="rect" square />
|
|
||||||
</div>
|
</div>
|
||||||
<div class="row q-pa-md q-col-gutter-md q-mb-md">
|
<div class="row q-pa-md q-col-gutter-md q-mb-md">
|
||||||
<div class="col">
|
<QSkeleton type="rect" class="q-mb-md" square />
|
||||||
<QSkeleton type="rect" class="q-mb-md" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="rect" class="q-mb-md" square />
|
||||||
</div>
|
<QSkeleton type="text" square />
|
||||||
<div class="col">
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="rect" class="q-mb-md" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="rect" class="q-mb-md" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="text" square />
|
||||||
</div>
|
<QSkeleton type="text" square />
|
||||||
<div class="col">
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="rect" class="q-mb-md" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="rect" class="q-mb-md" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="text" square />
|
||||||
</div>
|
<QSkeleton type="text" square />
|
||||||
<div class="col">
|
<QSkeleton type="rect" class="q-mb-md" square />
|
||||||
<QSkeleton type="rect" class="q-mb-md" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
<QSkeleton type="text" square />
|
||||||
<QSkeleton type="text" square />
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<QSkeleton type="rect" class="q-mb-md" square />
|
|
||||||
<QSkeleton type="text" square />
|
|
||||||
<QSkeleton type="text" square />
|
|
||||||
<QSkeleton type="text" square />
|
|
||||||
<QSkeleton type="text" square />
|
|
||||||
<QSkeleton type="text" square />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { useColor } from 'src/composables/useColor';
|
||||||
import { getCssVar } from 'quasar';
|
import { getCssVar } from 'quasar';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
workerId: { type: [Number, undefined], default: null },
|
workerId: { type: Number, required: true },
|
||||||
description: { type: String, default: null },
|
description: { type: String, default: null },
|
||||||
title: { type: String, default: null },
|
title: { type: String, default: null },
|
||||||
color: { type: String, default: null },
|
color: { type: String, default: null },
|
||||||
|
@ -38,13 +38,7 @@ watch(src, () => (showLetter.value = false));
|
||||||
<template v-if="showLetter">
|
<template v-if="showLetter">
|
||||||
{{ title.charAt(0) }}
|
{{ title.charAt(0) }}
|
||||||
</template>
|
</template>
|
||||||
<QImg
|
<QImg v-else :src="src" spinner-color="white" @error="showLetter = true" />
|
||||||
v-else-if="workerId"
|
|
||||||
:src="src"
|
|
||||||
spinner-color="white"
|
|
||||||
@error="showLetter = true"
|
|
||||||
/>
|
|
||||||
<QIcon v-else name="mood" size="xs" />
|
|
||||||
</QAvatar>
|
</QAvatar>
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<slot name="description" v-if="description">
|
<slot name="description" v-if="description">
|
||||||
|
|
|
@ -15,7 +15,7 @@ const props = defineProps({
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
message: {
|
message: {
|
||||||
type: [String, Boolean],
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
|
@ -30,17 +30,12 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['confirm', 'cancel', ...useDialogPluginComponent.emits]);
|
defineEmits(['confirm', ...useDialogPluginComponent.emits]);
|
||||||
defineExpose({ show: () => dialogRef.value.show(), hide: () => dialogRef.value.hide() });
|
|
||||||
|
|
||||||
const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } =
|
const { dialogRef, onDialogOK } = useDialogPluginComponent();
|
||||||
useDialogPluginComponent();
|
|
||||||
|
|
||||||
const title = props.title || t('Confirm');
|
const title = props.title || t('Confirm');
|
||||||
const message =
|
const message = props.message || t('Are you sure you want to continue?');
|
||||||
props.message ||
|
|
||||||
(props.message !== false ? t('Are you sure you want to continue?') : false);
|
|
||||||
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
|
||||||
async function confirm() {
|
async function confirm() {
|
||||||
|
@ -54,14 +49,9 @@ async function confirm() {
|
||||||
}
|
}
|
||||||
onDialogOK(props.data);
|
onDialogOK(props.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancel() {
|
|
||||||
emit('cancel');
|
|
||||||
onDialogCancel();
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<QDialog ref="dialogRef" @hide="onDialogHide">
|
<QDialog ref="dialogRef">
|
||||||
<QCard class="q-pa-sm">
|
<QCard class="q-pa-sm">
|
||||||
<QCardSection class="row items-center q-pb-none">
|
<QCardSection class="row items-center q-pb-none">
|
||||||
<QAvatar
|
<QAvatar
|
||||||
|
@ -71,21 +61,12 @@ function cancel() {
|
||||||
size="xl"
|
size="xl"
|
||||||
v-if="icon"
|
v-if="icon"
|
||||||
/>
|
/>
|
||||||
<span class="text-h6">{{ title }}</span>
|
<span class="text-h6 text-grey">{{ title }}</span>
|
||||||
<QSpace />
|
<QSpace />
|
||||||
<QBtn
|
<QBtn icon="close" :disable="isLoading" flat round dense v-close-popup />
|
||||||
icon="close"
|
|
||||||
:disable="isLoading"
|
|
||||||
flat
|
|
||||||
round
|
|
||||||
dense
|
|
||||||
@click="cancel()"
|
|
||||||
/>
|
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<QCardSection class="q-pb-none">
|
<QCardSection class="row items-center">
|
||||||
<span v-if="message !== false" v-html="message" />
|
<span v-html="message"></span>
|
||||||
</QCardSection>
|
|
||||||
<QCardSection class="row items-center q-pt-none">
|
|
||||||
<slot name="customHTML"></slot>
|
<slot name="customHTML"></slot>
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<QCardActions align="right">
|
<QCardActions align="right">
|
||||||
|
@ -94,17 +75,15 @@ function cancel() {
|
||||||
color="primary"
|
color="primary"
|
||||||
:disable="isLoading"
|
:disable="isLoading"
|
||||||
flat
|
flat
|
||||||
@click="cancel()"
|
v-close-popup
|
||||||
/>
|
/>
|
||||||
<QBtn
|
<QBtn
|
||||||
:label="t('globals.confirm')"
|
:label="t('globals.confirm')"
|
||||||
:title="t('globals.confirm')"
|
|
||||||
color="primary"
|
color="primary"
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
@click="confirm()"
|
@click="confirm()"
|
||||||
unelevated
|
unelevated
|
||||||
autofocus
|
autofocus
|
||||||
data-cy="VnConfirm_confirm"
|
|
||||||
/>
|
/>
|
||||||
</QCardActions>
|
</QCardActions>
|
||||||
</QCard>
|
</QCard>
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { onMounted, ref, computed, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
import { date } from 'quasar';
|
||||||
import toDate from 'filters/toDate';
|
import toDate from 'filters/toDate';
|
||||||
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
|
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
|
||||||
import { useFilterParams } from 'src/composables/useFilterParams';
|
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
|
|
||||||
const { t, te } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
@ -26,7 +25,7 @@ const $props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
unremovableParams: {
|
unRemovableParams: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: false,
|
required: false,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
|
@ -39,7 +38,7 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
hiddenTags: {
|
hiddenTags: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => ['filter', 'or', 'and'],
|
default: () => ['filter', 'search', 'or', 'and'],
|
||||||
},
|
},
|
||||||
customTags: {
|
customTags: {
|
||||||
type: Array,
|
type: Array,
|
||||||
|
@ -51,18 +50,15 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
searchUrl: {
|
searchUrl: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'table',
|
default: 'params',
|
||||||
},
|
},
|
||||||
redirect: {
|
redirect: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
arrayData: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
defineExpose({ search, sanitizer });
|
||||||
const emit = defineEmits([
|
const emit = defineEmits([
|
||||||
'update:modelValue',
|
'update:modelValue',
|
||||||
'refresh',
|
'refresh',
|
||||||
|
@ -73,65 +69,101 @@ const emit = defineEmits([
|
||||||
'setUserParams',
|
'setUserParams',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const arrayData =
|
const arrayData = useArrayData($props.dataKey, {
|
||||||
$props.arrayData ??
|
exprBuilder: $props.exprBuilder,
|
||||||
useArrayData($props.dataKey, {
|
searchUrl: $props.searchUrl,
|
||||||
exprBuilder: $props.exprBuilder,
|
navigate: $props.redirect ? {} : null,
|
||||||
searchUrl: $props.searchUrl,
|
});
|
||||||
navigate: $props.redirect ? {} : null,
|
const route = useRoute();
|
||||||
});
|
|
||||||
|
|
||||||
const store = arrayData.store;
|
const store = arrayData.store;
|
||||||
const userParams = ref(useFilterParams($props.dataKey).params);
|
const userParams = ref({});
|
||||||
const userOrders = ref(useFilterParams($props.dataKey).orders);
|
onMounted(() => {
|
||||||
|
userParams.value = $props.modelValue ?? {};
|
||||||
|
emit('init', { params: userParams.value });
|
||||||
|
});
|
||||||
|
|
||||||
defineExpose({ search, params: userParams, remove });
|
function setUserParams(watchedParams) {
|
||||||
|
if (!watchedParams || Object.keys(watchedParams).length == 0) return;
|
||||||
|
|
||||||
|
if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams);
|
||||||
|
if (typeof watchedParams?.filter == 'string')
|
||||||
|
watchedParams.filter = JSON.parse(watchedParams.filter);
|
||||||
|
|
||||||
|
watchedParams = { ...watchedParams, ...watchedParams.filter?.where };
|
||||||
|
const order = watchedParams.filter?.order;
|
||||||
|
|
||||||
|
delete watchedParams.filter;
|
||||||
|
userParams.value = { ...userParams.value, ...sanitizer(watchedParams) };
|
||||||
|
emit('setUserParams', userParams.value, order);
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [route.query[$props.searchUrl], arrayData.store.userParams],
|
||||||
|
([newSearchUrl, newUserParams], [oldSearchUrl, oldUserParams]) => {
|
||||||
|
if (newSearchUrl || oldSearchUrl) setUserParams(newSearchUrl);
|
||||||
|
if (newUserParams || oldUserParams) setUserParams(newUserParams);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => $props.modelValue,
|
||||||
|
(val) => (userParams.value = val ?? {})
|
||||||
|
);
|
||||||
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
async function search(evt) {
|
async function search(evt) {
|
||||||
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 };
|
||||||
store.userParamsChanged = true;
|
store.userParamsChanged = true;
|
||||||
await arrayData.addFilter({
|
const { params: newParams } = await arrayData.addFilter({
|
||||||
params: filter,
|
params: filter,
|
||||||
});
|
});
|
||||||
|
userParams.value = newParams;
|
||||||
|
|
||||||
if (!$props.showAll && !Object.values(filter).length) store.data = [];
|
if (!$props.showAll && !Object.values(filter).length) store.data = [];
|
||||||
emit('search');
|
|
||||||
} finally {
|
isLoading.value = false;
|
||||||
isLoading.value = false;
|
emit('search');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function reload() {
|
||||||
|
isLoading.value = true;
|
||||||
|
const params = Object.values(userParams.value).filter((param) => param);
|
||||||
|
store.skip = 0;
|
||||||
|
store.page = 1;
|
||||||
|
await arrayData.fetch({ append: false });
|
||||||
|
if (!$props.showAll && !params.length) store.data = [];
|
||||||
|
isLoading.value = false;
|
||||||
|
emit('refresh');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clearFilters() {
|
async function clearFilters() {
|
||||||
try {
|
isLoading.value = true;
|
||||||
isLoading.value = true;
|
store.userParamsChanged = true;
|
||||||
store.userParamsChanged = true;
|
arrayData.reset(['skip', 'filter.skip', 'page']);
|
||||||
arrayData.resetPagination();
|
// Filtrar los params no removibles
|
||||||
// Filtrar los params no removibles
|
const removableFilters = Object.keys(userParams.value).filter((param) =>
|
||||||
const removableFilters = Object.keys(userParams.value).filter((param) =>
|
$props.unRemovableParams.includes(param)
|
||||||
$props.unremovableParams.includes(param)
|
);
|
||||||
);
|
const newParams = {};
|
||||||
const newParams = {};
|
// Conservar solo los params que no son removibles
|
||||||
// Conservar solo los params que no son removibles
|
for (const key of removableFilters) {
|
||||||
for (const key of removableFilters) {
|
newParams[key] = userParams.value[key];
|
||||||
newParams[key] = userParams.value[key];
|
|
||||||
}
|
|
||||||
|
|
||||||
await arrayData.applyFilter({ params: { ...newParams } });
|
|
||||||
|
|
||||||
if (!$props.showAll) {
|
|
||||||
store.data = [];
|
|
||||||
}
|
|
||||||
emit('clear');
|
|
||||||
emit('update:modelValue', userParams.value);
|
|
||||||
} finally {
|
|
||||||
isLoading.value = false;
|
|
||||||
}
|
}
|
||||||
|
userParams.value = {};
|
||||||
|
userParams.value = { ...newParams }; // Actualizar los params con los removibles
|
||||||
|
await arrayData.applyFilter({ params: userParams.value });
|
||||||
|
|
||||||
|
if (!$props.showAll) {
|
||||||
|
store.data = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
isLoading.value = false;
|
||||||
|
emit('clear');
|
||||||
|
emit('update:modelValue', userParams.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const tagsList = computed(() => {
|
const tagsList = computed(() => {
|
||||||
|
@ -144,54 +176,37 @@ const tagsList = computed(() => {
|
||||||
return tagList;
|
return tagList;
|
||||||
});
|
});
|
||||||
|
|
||||||
const formatTags = (tags) => {
|
|
||||||
const formattedTags = [];
|
|
||||||
tags.forEach((tag) => {
|
|
||||||
if (tag.label === 'and') {
|
|
||||||
tag.value.forEach((item) => {
|
|
||||||
for (const key in item) {
|
|
||||||
formattedTags.push({ label: key, value: item[key] });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
formattedTags.push(tag);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return formattedTags;
|
|
||||||
};
|
|
||||||
|
|
||||||
const tags = computed(() => {
|
const tags = computed(() => {
|
||||||
const filteredTags = tagsList.value.filter(
|
return tagsList.value.filter((tag) => !($props.customTags || []).includes(tag.key));
|
||||||
(tag) => !($props.customTags || []).includes(tag.label)
|
|
||||||
);
|
|
||||||
return formatTags(filteredTags);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const customTags = computed(() =>
|
const customTags = computed(() =>
|
||||||
tagsList.value.filter((tag) => ($props.customTags || []).includes(tag.label))
|
tagsList.value.filter((tag) => ($props.customTags || []).includes(tag.key))
|
||||||
);
|
);
|
||||||
|
|
||||||
async function remove(key) {
|
async function remove(key) {
|
||||||
userParams.value[key] = undefined;
|
userParams.value[key] = undefined;
|
||||||
await search();
|
search();
|
||||||
emit('remove', key);
|
emit('remove', key);
|
||||||
emit('update:modelValue', userParams.value);
|
emit('update:modelValue', userParams.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatValue(value) {
|
function formatValue(value) {
|
||||||
|
if (value instanceof Date) return date.formatDate(value, 'DD/MM/YYYY');
|
||||||
if (typeof value === 'boolean') return value ? t('Yes') : t('No');
|
if (typeof value === 'boolean') return value ? t('Yes') : t('No');
|
||||||
if (isNaN(value) && !isNaN(Date.parse(value))) return toDate(value);
|
if (isNaN(value) && !isNaN(Date.parse(value))) return toDate(value);
|
||||||
|
|
||||||
return `"${value}"`;
|
return `"${value}"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getLocale = (label) => {
|
function sanitizer(params) {
|
||||||
const param = label.split('.').at(-1);
|
for (const [key, value] of Object.entries(params)) {
|
||||||
const globalLocale = `globals.params.${param}`;
|
if (typeof value == 'object') {
|
||||||
if (te(globalLocale)) return t(globalLocale);
|
const param = Object.values(value)[0];
|
||||||
else if (te(t(`params.${param}`)));
|
if (typeof param == 'string') params[key] = param.replaceAll('%', '');
|
||||||
else return t(`${route.meta.moduleName.toLowerCase()}.params.${param}`);
|
}
|
||||||
};
|
}
|
||||||
|
return params;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -202,12 +217,8 @@ const getLocale = (label) => {
|
||||||
style="position: fixed; z-index: 1; right: 0; bottom: 0"
|
style="position: fixed; z-index: 1; right: 0; bottom: 0"
|
||||||
icon="search"
|
icon="search"
|
||||||
@click="search()"
|
@click="search()"
|
||||||
>
|
></QBtn>
|
||||||
<QTooltip bottom anchor="bottom right">
|
<QForm @submit="search" id="filterPanelForm">
|
||||||
{{ t('globals.search') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
<QForm @submit="search" id="filterPanelForm" @keyup.enter="search()">
|
|
||||||
<QList dense>
|
<QList dense>
|
||||||
<QItem class="q-mt-xs">
|
<QItem class="q-mt-xs">
|
||||||
<QItemSection top>
|
<QItemSection top>
|
||||||
|
@ -216,18 +227,32 @@ const getLocale = (label) => {
|
||||||
</QItemLabel>
|
</QItemLabel>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QItemSection top side>
|
<QItemSection top side>
|
||||||
<QBtn
|
<div class="q-gutter-xs">
|
||||||
@click="clearFilters"
|
<QBtn
|
||||||
color="primary"
|
@click="clearFilters"
|
||||||
dense
|
color="primary"
|
||||||
flat
|
dense
|
||||||
icon="filter_list_off"
|
flat
|
||||||
padding="none"
|
icon="filter_list_off"
|
||||||
round
|
padding="none"
|
||||||
size="sm"
|
round
|
||||||
>
|
size="sm"
|
||||||
<QTooltip>{{ t('Remove filters') }}</QTooltip>
|
>
|
||||||
</QBtn>
|
<QTooltip>{{ t('Remove filters') }}</QTooltip>
|
||||||
|
</QBtn>
|
||||||
|
<QBtn
|
||||||
|
@click="reload"
|
||||||
|
color="primary"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
icon="refresh"
|
||||||
|
padding="none"
|
||||||
|
round
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
|
<QTooltip>{{ t('Refresh') }}</QTooltip>
|
||||||
|
</QBtn>
|
||||||
|
</div>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem class="q-mb-sm">
|
<QItem class="q-mb-sm">
|
||||||
|
@ -241,16 +266,10 @@ const getLocale = (label) => {
|
||||||
<VnFilterPanelChip
|
<VnFilterPanelChip
|
||||||
v-for="chip of tags"
|
v-for="chip of tags"
|
||||||
: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"
|
|
||||||
>
|
>
|
||||||
<slot
|
<slot name="tags" :tag="chip" :format-fn="formatValue">
|
||||||
name="tags"
|
|
||||||
:tag="chip"
|
|
||||||
:format-fn="formatValue"
|
|
||||||
:get-locale="getLocale"
|
|
||||||
>
|
|
||||||
<div class="q-gutter-x-xs">
|
<div class="q-gutter-x-xs">
|
||||||
<strong>{{ chip.label }}:</strong>
|
<strong>{{ chip.label }}:</strong>
|
||||||
<span>"{{ formatValue(chip.value) }}"</span>
|
<span>"{{ formatValue(chip.value) }}"</span>
|
||||||
|
@ -263,7 +282,6 @@ const getLocale = (label) => {
|
||||||
:params="userParams"
|
:params="userParams"
|
||||||
:tags="customTags"
|
:tags="customTags"
|
||||||
:format-fn="formatValue"
|
:format-fn="formatValue"
|
||||||
:get-locale="getLocale"
|
|
||||||
:search-fn="search"
|
:search-fn="search"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -271,13 +289,7 @@ const getLocale = (label) => {
|
||||||
<QSeparator />
|
<QSeparator />
|
||||||
</QList>
|
</QList>
|
||||||
<QList dense class="list q-gutter-y-sm q-mt-sm">
|
<QList dense class="list q-gutter-y-sm q-mt-sm">
|
||||||
<slot
|
<slot name="body" :params="sanitizer(userParams)" :search-fn="search"></slot>
|
||||||
name="body"
|
|
||||||
:get-locale="getLocale"
|
|
||||||
:params="userParams"
|
|
||||||
:orders="userOrders"
|
|
||||||
:search-fn="search"
|
|
||||||
></slot>
|
|
||||||
</QList>
|
</QList>
|
||||||
</QForm>
|
</QForm>
|
||||||
<QInnerLoading
|
<QInnerLoading
|
||||||
|
|
|
@ -39,8 +39,6 @@ const getUrl = (zoom = false) => {
|
||||||
const curResolution = zoom
|
const curResolution = zoom
|
||||||
? $props.zoomResolution || $props.resolution
|
? $props.zoomResolution || $props.resolution
|
||||||
: $props.resolution;
|
: $props.resolution;
|
||||||
if ($props.storage === 'dms')
|
|
||||||
return `/api/${$props.storage}/${$props.id}/downloadFile?access_token=${token}`;
|
|
||||||
return isEmployee
|
return isEmployee
|
||||||
? `/api/${$props.storage}/${$props.collection}/${curResolution}/${$props.id}/download?access_token=${token}&${timeStamp.value}`
|
? `/api/${$props.storage}/${$props.collection}/${curResolution}/${$props.id}/download?access_token=${token}&${timeStamp.value}`
|
||||||
: noImage;
|
: noImage;
|
||||||
|
@ -54,21 +52,18 @@ defineExpose({
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<QImg
|
<QImg
|
||||||
:draggable="true"
|
|
||||||
:class="{ zoomIn: zoom }"
|
:class="{ zoomIn: zoom }"
|
||||||
:src="getUrl()"
|
:src="getUrl()"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
@click.stop="show = $props.zoom"
|
@click.stop="show = $props.zoom ? true : false"
|
||||||
spinner-color="primary"
|
spinner-color="primary"
|
||||||
/>
|
/>
|
||||||
<QDialog v-if="$props.zoom" v-model="show">
|
<QDialog v-if="$props.zoom" v-model="show">
|
||||||
<QImg
|
<QImg
|
||||||
:draggable="true"
|
|
||||||
:src="getUrl(true)"
|
:src="getUrl(true)"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
spinner-color="primary"
|
spinner-color="primary"
|
||||||
class="img_zoom"
|
class="img_zoom"
|
||||||
:ratio="0"
|
|
||||||
/>
|
/>
|
||||||
</QDialog>
|
</QDialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
<script setup>
|
|
||||||
defineProps({ email: { type: [String], default: null } });
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<QBtn
|
|
||||||
v-if="email"
|
|
||||||
flat
|
|
||||||
round
|
|
||||||
icon="email"
|
|
||||||
size="sm"
|
|
||||||
color="primary"
|
|
||||||
padding="none"
|
|
||||||
:href="`mailto:${email}`"
|
|
||||||
@click.stop
|
|
||||||
/>
|
|
||||||
</template>
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue