Compare commits
No commits in common. "dev" and "6897-entryBuyListRefactor" have entirely different histories.
dev
...
6897-entry
|
@ -1 +0,0 @@
|
||||||
node_modules
|
|
|
@ -31,7 +31,6 @@ yarn-error.log*
|
||||||
# Cypress directories and files
|
# Cypress directories and files
|
||||||
/test/cypress/videos
|
/test/cypress/videos
|
||||||
/test/cypress/screenshots
|
/test/cypress/screenshots
|
||||||
/junit
|
|
||||||
|
|
||||||
# VitePress directories and files
|
# VitePress directories and files
|
||||||
/docs/.vitepress/cache
|
/docs/.vitepress/cache
|
||||||
|
|
3528
CHANGELOG.md
3528
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env groovy
|
#!/usr/bin/env groovy
|
||||||
|
|
||||||
def PROTECTED_BRANCH
|
def PROTECTED_BRANCH
|
||||||
def IS_LATEST
|
|
||||||
|
|
||||||
def BRANCH_ENV = [
|
def BRANCH_ENV = [
|
||||||
test: 'test',
|
test: 'test',
|
||||||
|
@ -11,22 +10,19 @@ def BRANCH_ENV = [
|
||||||
|
|
||||||
node {
|
node {
|
||||||
stage('Setup') {
|
stage('Setup') {
|
||||||
|
env.FRONT_REPLICAS = 1
|
||||||
env.NODE_ENV = BRANCH_ENV[env.BRANCH_NAME] ?: 'dev'
|
env.NODE_ENV = BRANCH_ENV[env.BRANCH_NAME] ?: 'dev'
|
||||||
|
|
||||||
PROTECTED_BRANCH = [
|
PROTECTED_BRANCH = [
|
||||||
'dev',
|
'dev',
|
||||||
'test',
|
'test',
|
||||||
'master',
|
'master',
|
||||||
'main',
|
|
||||||
'beta'
|
'beta'
|
||||||
]
|
].contains(env.BRANCH_NAME)
|
||||||
|
|
||||||
IS_PROTECTED_BRANCH = PROTECTED_BRANCH.contains(env.BRANCH_NAME)
|
// https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
|
||||||
IS_LATEST = ['master', 'main'].contains(env.BRANCH_NAME)
|
|
||||||
|
|
||||||
// https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
|
|
||||||
echo "NODE_NAME: ${env.NODE_NAME}"
|
echo "NODE_NAME: ${env.NODE_NAME}"
|
||||||
echo "WORKSPACE: ${env.WORKSPACE}"
|
echo "WORKSPACE: ${env.WORKSPACE}"
|
||||||
echo "CHANGE_TARGET: ${env.CHANGE_TARGET}"
|
|
||||||
|
|
||||||
configFileProvider([
|
configFileProvider([
|
||||||
configFile(fileId: 'salix-front.properties',
|
configFile(fileId: 'salix-front.properties',
|
||||||
|
@ -37,7 +33,7 @@ node {
|
||||||
props.each {key, value -> echo "${key}: ${value}" }
|
props.each {key, value -> echo "${key}: ${value}" }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_PROTECTED_BRANCH) {
|
if (PROTECTED_BRANCH) {
|
||||||
configFileProvider([
|
configFileProvider([
|
||||||
configFile(fileId: "salix-front.branch.${env.BRANCH_NAME}",
|
configFile(fileId: "salix-front.branch.${env.BRANCH_NAME}",
|
||||||
variable: 'BRANCH_PROPS_FILE')
|
variable: 'BRANCH_PROPS_FILE')
|
||||||
|
@ -62,19 +58,6 @@ pipeline {
|
||||||
PROJECT_NAME = 'lilium'
|
PROJECT_NAME = 'lilium'
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
stage('Version') {
|
|
||||||
when {
|
|
||||||
expression { IS_PROTECTED_BRANCH }
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
def packageJson = readJSON file: 'package.json'
|
|
||||||
def version = "${packageJson.version}-build${env.BUILD_ID}"
|
|
||||||
writeFile(file: 'VERSION.txt', text: version)
|
|
||||||
echo "VERSION: ${version}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Install') {
|
stage('Install') {
|
||||||
environment {
|
environment {
|
||||||
NODE_ENV = ""
|
NODE_ENV = ""
|
||||||
|
@ -85,93 +68,48 @@ pipeline {
|
||||||
}
|
}
|
||||||
stage('Test') {
|
stage('Test') {
|
||||||
when {
|
when {
|
||||||
expression { !IS_PROTECTED_BRANCH }
|
expression { !PROTECTED_BRANCH }
|
||||||
}
|
}
|
||||||
environment {
|
environment {
|
||||||
NODE_ENV = ''
|
NODE_ENV = ""
|
||||||
CI = 'true'
|
|
||||||
TZ = 'Europe/Madrid'
|
|
||||||
}
|
}
|
||||||
parallel {
|
steps {
|
||||||
stage('Unit') {
|
sh 'pnpm run test:unit:ci'
|
||||||
steps {
|
}
|
||||||
sh 'pnpm run test:front:ci'
|
post {
|
||||||
}
|
always {
|
||||||
post {
|
junit(
|
||||||
always {
|
testResults: 'junitresults.xml',
|
||||||
junit(
|
allowEmptyResults: true
|
||||||
testResults: 'junit/vitest.xml',
|
)
|
||||||
allowEmptyResults: true
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('E2E') {
|
|
||||||
environment {
|
|
||||||
CREDS = credentials('docker-registry')
|
|
||||||
COMPOSE_PROJECT = "${PROJECT_NAME}-${env.BUILD_ID}"
|
|
||||||
COMPOSE_PARAMS = "-p ${env.COMPOSE_PROJECT} -f test/cypress/docker-compose.yml --project-directory ."
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
sh 'rm -f junit/e2e-*.xml'
|
|
||||||
sh 'rm -rf test/cypress/screenshots'
|
|
||||||
env.COMPOSE_TAG = PROTECTED_BRANCH.contains(env.CHANGE_TARGET) ? env.CHANGE_TARGET : 'dev'
|
|
||||||
|
|
||||||
def image = docker.build('lilium-dev', '-f docs/Dockerfile.dev docs')
|
|
||||||
|
|
||||||
sh 'docker login --username $CREDS_USR --password $CREDS_PSW $REGISTRY'
|
|
||||||
sh "docker-compose ${env.COMPOSE_PARAMS} pull back"
|
|
||||||
sh "docker-compose ${env.COMPOSE_PARAMS} pull db"
|
|
||||||
sh "docker-compose ${env.COMPOSE_PARAMS} up -d"
|
|
||||||
|
|
||||||
image.inside("--network ${env.COMPOSE_PROJECT}_default -e CI -e TZ --init") {
|
|
||||||
sh 'sh test/cypress/cypressParallel.sh 2'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
post {
|
|
||||||
always {
|
|
||||||
sh "docker-compose ${env.COMPOSE_PARAMS} down -v"
|
|
||||||
archiveArtifacts artifacts: 'test/cypress/screenshots/**/*', allowEmptyArchive: true
|
|
||||||
junit(
|
|
||||||
testResults: 'junit/e2e-*.xml',
|
|
||||||
allowEmptyResults: true
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Build') {
|
stage('Build') {
|
||||||
when {
|
when {
|
||||||
expression { IS_PROTECTED_BRANCH }
|
expression { PROTECTED_BRANCH }
|
||||||
}
|
}
|
||||||
environment {
|
environment {
|
||||||
VERSION = readFile 'VERSION.txt'
|
CREDENTIALS = credentials('docker-registry')
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
|
sh 'quasar build'
|
||||||
script {
|
script {
|
||||||
sh 'quasar build'
|
def packageJson = readJSON file: 'package.json'
|
||||||
|
env.VERSION = "${packageJson.version}-build${env.BUILD_ID}"
|
||||||
def baseImage = "salix-frontend:${env.VERSION}"
|
|
||||||
def image = docker.build(baseImage, ".")
|
|
||||||
docker.withRegistry("https://${env.REGISTRY}", 'docker-registry') {
|
|
||||||
image.push()
|
|
||||||
image.push(env.BRANCH_NAME)
|
|
||||||
if (IS_LATEST) image.push('latest')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
dockerBuild()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Deploy') {
|
stage('Deploy') {
|
||||||
when {
|
when {
|
||||||
expression { IS_PROTECTED_BRANCH }
|
expression { PROTECTED_BRANCH }
|
||||||
}
|
|
||||||
environment {
|
|
||||||
VERSION = readFile 'VERSION.txt'
|
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
|
script {
|
||||||
|
def packageJson = readJSON file: 'package.json'
|
||||||
|
env.VERSION = "${packageJson.version}-build${env.BUILD_ID}"
|
||||||
|
}
|
||||||
withKubeConfig([
|
withKubeConfig([
|
||||||
serverUrl: "$KUBERNETES_API",
|
serverUrl: "$KUBERNETES_API",
|
||||||
credentialsId: 'kubernetes',
|
credentialsId: 'kubernetes',
|
||||||
|
|
20
README.md
20
README.md
|
@ -23,7 +23,7 @@ quasar dev
|
||||||
### Run unit tests
|
### Run unit tests
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm run test:front
|
pnpm run test:unit
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run e2e tests
|
### Run e2e tests
|
||||||
|
@ -32,26 +32,8 @@ pnpm run test:front
|
||||||
pnpm run test:e2e
|
pnpm run test:e2e
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run e2e parallel
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pnpm run test:e2e:parallel
|
|
||||||
```
|
|
||||||
|
|
||||||
### View e2e parallel report
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pnpm run test:e2e:summary
|
|
||||||
```
|
|
||||||
|
|
||||||
### Build the app for production
|
### Build the app for production
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
quasar build
|
quasar build
|
||||||
```
|
```
|
||||||
|
|
||||||
### Serve the app for production
|
|
||||||
|
|
||||||
```bash
|
|
||||||
quasar build quasar serve dist/spa --host 0.0.0.0 --proxy=./proxy-serve.js
|
|
||||||
```
|
|
||||||
|
|
|
@ -1,44 +1,12 @@
|
||||||
import { defineConfig } from 'cypress';
|
import { defineConfig } from 'cypress';
|
||||||
|
// https://docs.cypress.io/app/tooling/reporters
|
||||||
let urlHost, reporter, reporterOptions, timeouts;
|
// https://docs.cypress.io/app/references/configuration
|
||||||
|
// https://www.npmjs.com/package/cypress-mochawesome-reporter
|
||||||
if (process.env.CI) {
|
|
||||||
urlHost = 'front';
|
|
||||||
reporter = 'junit';
|
|
||||||
reporterOptions = {
|
|
||||||
mochaFile: 'junit/e2e-[hash].xml',
|
|
||||||
};
|
|
||||||
timeouts = {
|
|
||||||
defaultCommandTimeout: 30000,
|
|
||||||
requestTimeout: 30000,
|
|
||||||
responseTimeout: 60000,
|
|
||||||
pageLoadTimeout: 60000,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
urlHost = 'localhost';
|
|
||||||
reporter = 'cypress-mochawesome-reporter';
|
|
||||||
reporterOptions = {
|
|
||||||
charts: true,
|
|
||||||
reportPageTitle: 'Cypress Inline Reporter',
|
|
||||||
reportFilename: '[status]_[datetime]-report',
|
|
||||||
embeddedScreenshots: true,
|
|
||||||
reportDir: 'test/cypress/reports',
|
|
||||||
inlineAssets: true,
|
|
||||||
};
|
|
||||||
timeouts = {
|
|
||||||
defaultCommandTimeout: 10000,
|
|
||||||
requestTimeout: 10000,
|
|
||||||
responseTimeout: 30000,
|
|
||||||
pageLoadTimeout: 60000,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
e2e: {
|
e2e: {
|
||||||
baseUrl: `http://${urlHost}:9000`,
|
baseUrl: 'http://localhost:9000/',
|
||||||
experimentalStudio: false,
|
experimentalStudio: true,
|
||||||
trashAssetsBeforeRuns: false,
|
|
||||||
defaultBrowser: 'chromium',
|
|
||||||
fixturesFolder: 'test/cypress/fixtures',
|
fixturesFolder: 'test/cypress/fixtures',
|
||||||
screenshotsFolder: 'test/cypress/screenshots',
|
screenshotsFolder: 'test/cypress/screenshots',
|
||||||
supportFile: 'test/cypress/support/index.js',
|
supportFile: 'test/cypress/support/index.js',
|
||||||
|
@ -46,19 +14,29 @@ export default defineConfig({
|
||||||
downloadsFolder: 'test/cypress/downloads',
|
downloadsFolder: 'test/cypress/downloads',
|
||||||
video: false,
|
video: false,
|
||||||
specPattern: 'test/cypress/integration/**/*.spec.js',
|
specPattern: 'test/cypress/integration/**/*.spec.js',
|
||||||
experimentalRunAllSpecs: true,
|
experimentalRunAllSpecs: false,
|
||||||
watchForFileChanges: true,
|
watchForFileChanges: false,
|
||||||
reporter,
|
reporter: 'cypress-mochawesome-reporter',
|
||||||
reporterOptions,
|
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: async (on, config) => {
|
||||||
|
const plugin = await import('cypress-mochawesome-reporter/plugin');
|
||||||
|
plugin.default(on);
|
||||||
|
|
||||||
|
return config;
|
||||||
|
},
|
||||||
viewportWidth: 1280,
|
viewportWidth: 1280,
|
||||||
viewportHeight: 720,
|
viewportHeight: 720,
|
||||||
...timeouts,
|
|
||||||
includeShadowDom: true,
|
|
||||||
waitForAnimations: true,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
version: '3.7'
|
||||||
|
services:
|
||||||
|
main:
|
||||||
|
image: registry.verdnatura.es/salix-frontend:${VERSION:?}
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: ./Dockerfile
|
|
@ -1,47 +0,0 @@
|
||||||
FROM debian:12.9-slim
|
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
|
||||||
|
|
||||||
RUN apt-get update \
|
|
||||||
&& apt-get install -y --no-install-recommends \
|
|
||||||
ca-certificates \
|
|
||||||
curl \
|
|
||||||
gnupg2 \
|
|
||||||
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
|
||||||
&& apt-get install -y --no-install-recommends nodejs \
|
|
||||||
&& npm install -g corepack@0.31.0 \
|
|
||||||
&& corepack enable pnpm \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
RUN apt-get update \
|
|
||||||
&& apt-get -y --no-install-recommends install \
|
|
||||||
apt-utils \
|
|
||||||
chromium \
|
|
||||||
libasound2 \
|
|
||||||
libgbm-dev \
|
|
||||||
libgtk-3-0 \
|
|
||||||
libgtk2.0-0 \
|
|
||||||
libnotify-dev \
|
|
||||||
libnss3 \
|
|
||||||
libxss1 \
|
|
||||||
libxtst6 \
|
|
||||||
mesa-vulkan-drivers \
|
|
||||||
vulkan-tools \
|
|
||||||
xauth \
|
|
||||||
xvfb \
|
|
||||||
&& apt-get clean \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
RUN groupadd -r -g 1000 app \
|
|
||||||
&& useradd -r -u 1000 -g app -m -d /home/app app
|
|
||||||
USER app
|
|
||||||
|
|
||||||
ENV SHELL=bash
|
|
||||||
ENV PNPM_HOME="/home/app/.local/share/pnpm"
|
|
||||||
ENV PATH="$PNPM_HOME:$PATH"
|
|
||||||
|
|
||||||
RUN pnpm setup \
|
|
||||||
&& pnpm install --global cypress@14.1.0 \
|
|
||||||
&& cypress install
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
17
package.json
17
package.json
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "salix-front",
|
"name": "salix-front",
|
||||||
"version": "25.16.0",
|
"version": "25.08.0",
|
||||||
"description": "Salix frontend",
|
"description": "Salix frontend",
|
||||||
"productName": "Salix",
|
"productName": "Salix",
|
||||||
"author": "Verdnatura",
|
"author": "Verdnatura",
|
||||||
|
@ -13,11 +13,9 @@
|
||||||
"format": "prettier --write \"**/*.{js,vue,scss,html,md,json}\" --ignore-path .gitignore",
|
"format": "prettier --write \"**/*.{js,vue,scss,html,md,json}\" --ignore-path .gitignore",
|
||||||
"test:e2e": "cypress open",
|
"test:e2e": "cypress open",
|
||||||
"test:e2e:ci": "npm run resetDatabase && cd ../salix-front && cypress run",
|
"test:e2e:ci": "npm run resetDatabase && cd ../salix-front && cypress run",
|
||||||
"test:e2e:parallel": "bash ./test/cypress/run.sh",
|
|
||||||
"test:e2e:summary": "bash ./test/cypress/summary.sh",
|
|
||||||
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
|
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
|
||||||
"test:front": "vitest",
|
"test:unit": "vitest",
|
||||||
"test:front:ci": "vitest run",
|
"test:unit:ci": "vitest run",
|
||||||
"commitlint": "commitlint --edit",
|
"commitlint": "commitlint --edit",
|
||||||
"prepare": "npx husky install",
|
"prepare": "npx husky install",
|
||||||
"addReferenceTag": "node .husky/addReferenceTag.js",
|
"addReferenceTag": "node .husky/addReferenceTag.js",
|
||||||
|
@ -49,21 +47,18 @@
|
||||||
"@quasar/quasar-app-extension-testing-unit-vitest": "^0.4.0",
|
"@quasar/quasar-app-extension-testing-unit-vitest": "^0.4.0",
|
||||||
"@vue/test-utils": "^2.4.4",
|
"@vue/test-utils": "^2.4.4",
|
||||||
"autoprefixer": "^10.4.14",
|
"autoprefixer": "^10.4.14",
|
||||||
"cypress": "^14.1.0",
|
"cypress": "^13.6.6",
|
||||||
"cypress-mochawesome-reporter": "^3.8.2",
|
"cypress-mochawesome-reporter": "^3.8.2",
|
||||||
"eslint": "^9.18.0",
|
"eslint": "^9.18.0",
|
||||||
"eslint-config-prettier": "^10.0.1",
|
"eslint-config-prettier": "^10.0.1",
|
||||||
"eslint-plugin-cypress": "^4.1.0",
|
"eslint-plugin-cypress": "^4.1.0",
|
||||||
"eslint-plugin-vue": "^9.32.0",
|
"eslint-plugin-vue": "^9.32.0",
|
||||||
"husky": "^8.0.0",
|
"husky": "^8.0.0",
|
||||||
"junit-merge": "^2.0.0",
|
|
||||||
"mocha": "^11.1.0",
|
|
||||||
"postcss": "^8.4.23",
|
"postcss": "^8.4.23",
|
||||||
"prettier": "^3.4.2",
|
"prettier": "^3.4.2",
|
||||||
"sass": "^1.83.4",
|
"sass": "^1.83.4",
|
||||||
"vitepress": "^1.6.3",
|
"vitepress": "^1.6.3",
|
||||||
"vitest": "^0.34.0",
|
"vitest": "^0.34.0"
|
||||||
"xunit-viewer": "^10.6.1"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^20 || ^18 || ^16",
|
"node": "^20 || ^18 || ^16",
|
||||||
|
@ -76,4 +71,4 @@
|
||||||
"vite": "^6.0.11",
|
"vite": "^6.0.11",
|
||||||
"vitest": "^0.31.1"
|
"vitest": "^0.31.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
2082
pnpm-lock.yaml
2082
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
path: '/api',
|
path: '/api',
|
||||||
rule: { target: 'http://127.0.0.1:3000' },
|
rule: { target: 'http://0.0.0.0:3000' },
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
import { configure } from 'quasar/wrappers';
|
import { configure } from 'quasar/wrappers';
|
||||||
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
|
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
const target = `http://${process.env.CI ? 'back' : 'localhost'}:3000`;
|
|
||||||
|
|
||||||
export default configure(function (/* ctx */) {
|
export default configure(function (/* ctx */) {
|
||||||
return {
|
return {
|
||||||
|
@ -109,17 +108,13 @@ export default configure(function (/* ctx */) {
|
||||||
},
|
},
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: target,
|
target: 'http://0.0.0.0:3000',
|
||||||
logLevel: 'debug',
|
logLevel: 'debug',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
secure: false,
|
secure: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
open: false,
|
open: false,
|
||||||
allowedHosts: [
|
|
||||||
'front', // Agrega este nombre de host
|
|
||||||
'localhost', // Opcional, para pruebas locales
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#framework
|
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#framework
|
||||||
|
|
|
@ -9,19 +9,19 @@ export default {
|
||||||
if (!form) return;
|
if (!form) return;
|
||||||
try {
|
try {
|
||||||
const inputsFormCard = form.querySelectorAll(
|
const inputsFormCard = form.querySelectorAll(
|
||||||
`input:not([disabled]):not([type="checkbox"])`,
|
`input:not([disabled]):not([type="checkbox"])`
|
||||||
);
|
);
|
||||||
if (inputsFormCard.length) {
|
if (inputsFormCard.length) {
|
||||||
focusFirstInput(inputsFormCard[0]);
|
focusFirstInput(inputsFormCard[0]);
|
||||||
}
|
}
|
||||||
const textareas = document.querySelectorAll(
|
const textareas = document.querySelectorAll(
|
||||||
'textarea:not([disabled]), [contenteditable]:not([disabled])',
|
'textarea:not([disabled]), [contenteditable]:not([disabled])'
|
||||||
);
|
);
|
||||||
if (textareas.length) {
|
if (textareas.length) {
|
||||||
focusFirstInput(textareas[textareas.length - 1]);
|
focusFirstInput(textareas[textareas.length - 1]);
|
||||||
}
|
}
|
||||||
const inputs = document.querySelectorAll(
|
const inputs = document.querySelectorAll(
|
||||||
'form#formModel input:not([disabled]):not([type="checkbox"])',
|
'form#formModel input:not([disabled]):not([type="checkbox"])'
|
||||||
);
|
);
|
||||||
const input = inputs[0];
|
const input = inputs[0];
|
||||||
if (!input) return;
|
if (!input) return;
|
||||||
|
@ -30,5 +30,22 @@ export default {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(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();
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import { 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 VnSelectProvince from 'src/components/VnSelectProvince.vue';
|
import VnSelectProvince from 'src/components/VnSelectProvince.vue';
|
||||||
|
@ -20,11 +21,14 @@ const postcodeFormData = reactive({
|
||||||
provinceFk: null,
|
provinceFk: null,
|
||||||
townFk: null,
|
townFk: null,
|
||||||
});
|
});
|
||||||
|
const townsFetchDataRef = ref(false);
|
||||||
const townFilter = ref({});
|
const townFilter = ref({});
|
||||||
|
|
||||||
const countriesRef = ref(false);
|
const countriesRef = ref(false);
|
||||||
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 = {
|
||||||
|
@ -47,6 +51,7 @@ async function setCountry(countryFk, data) {
|
||||||
data.townFk = null;
|
data.townFk = null;
|
||||||
data.provinceFk = null;
|
data.provinceFk = null;
|
||||||
data.countryFk = countryFk;
|
data.countryFk = countryFk;
|
||||||
|
await fetchTowns();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Province
|
// Province
|
||||||
|
@ -55,11 +60,22 @@ async function setProvince(id, data) {
|
||||||
const newProvince = provincesOptions.value.find((province) => province.id == id);
|
const newProvince = provincesOptions.value.find((province) => province.id == id);
|
||||||
if (newProvince) data.countryFk = newProvince.countryFk;
|
if (newProvince) data.countryFk = newProvince.countryFk;
|
||||||
postcodeFormData.provinceFk = id;
|
postcodeFormData.provinceFk = id;
|
||||||
|
await fetchTowns();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onProvinceCreated(data) {
|
async function onProvinceCreated(data) {
|
||||||
postcodeFormData.provinceFk = data.id;
|
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) {
|
function setTown(newTown, data) {
|
||||||
town.value = newTown;
|
town.value = newTown;
|
||||||
data.provinceFk = newTown?.provinceFk ?? newTown;
|
data.provinceFk = newTown?.provinceFk ?? newTown;
|
||||||
|
@ -72,6 +88,18 @@ async function onCityCreated(newTown, formData) {
|
||||||
formData.townFk = newTown;
|
formData.townFk = newTown;
|
||||||
setTown(newTown, formData);
|
setTown(newTown, formData);
|
||||||
}
|
}
|
||||||
|
async function fetchTowns(countryFk = postcodeFormData.countryFk) {
|
||||||
|
if (!countryFk) return;
|
||||||
|
const provinces = postcodeFormData.provinceFk
|
||||||
|
? [postcodeFormData.provinceFk]
|
||||||
|
: provinceByCountry();
|
||||||
|
townFilter.value.where = {
|
||||||
|
provinceFk: {
|
||||||
|
inq: provinces,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
await townsFetchDataRef.value?.fetch();
|
||||||
|
}
|
||||||
|
|
||||||
async function filterTowns(name) {
|
async function filterTowns(name) {
|
||||||
if (name !== '') {
|
if (name !== '') {
|
||||||
|
@ -80,11 +108,22 @@ async function filterTowns(name) {
|
||||||
like: `%${name}%`,
|
like: `%${name}%`,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
await townsFetchDataRef.value?.fetch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<FetchData
|
||||||
|
ref="townsFetchDataRef"
|
||||||
|
:sort-by="['name ASC']"
|
||||||
|
:limit="30"
|
||||||
|
:filter="townFilter"
|
||||||
|
@on-fetch="handleTowns"
|
||||||
|
auto-load
|
||||||
|
url="Towns/location"
|
||||||
|
/>
|
||||||
|
|
||||||
<FormModelPopup
|
<FormModelPopup
|
||||||
url-create="postcodes"
|
url-create="postcodes"
|
||||||
model="postcode"
|
model="postcode"
|
||||||
|
@ -110,13 +149,14 @@ async function filterTowns(name) {
|
||||||
@filter="filterTowns"
|
@filter="filterTowns"
|
||||||
:tooltip="t('Create city')"
|
:tooltip="t('Create city')"
|
||||||
v-model="data.townFk"
|
v-model="data.townFk"
|
||||||
url="Towns/location"
|
:options="townsOptions"
|
||||||
|
option-label="name"
|
||||||
|
option-value="id"
|
||||||
:rules="validate('postcode.city')"
|
:rules="validate('postcode.city')"
|
||||||
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
|
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
|
||||||
:emit-value="false"
|
:emit-value="false"
|
||||||
required
|
required
|
||||||
data-cy="locationTown"
|
data-cy="locationTown"
|
||||||
sort-by="name ASC"
|
|
||||||
>
|
>
|
||||||
<template #option="{ itemProps, opt }">
|
<template #option="{ itemProps, opt }">
|
||||||
<QItem v-bind="itemProps">
|
<QItem v-bind="itemProps">
|
||||||
|
@ -157,12 +197,16 @@ async function filterTowns(name) {
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
ref="countriesRef"
|
ref="countriesRef"
|
||||||
|
:limit="30"
|
||||||
|
:filter="countryFilter"
|
||||||
:sort-by="['name ASC']"
|
:sort-by="['name ASC']"
|
||||||
auto-load
|
auto-load
|
||||||
url="Countries"
|
url="Countries"
|
||||||
required
|
required
|
||||||
:label="t('Country')"
|
:label="t('Country')"
|
||||||
hide-selected
|
hide-selected
|
||||||
|
option-label="name"
|
||||||
|
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)"
|
@update:model-value="(value) => setCountry(value, data)"
|
||||||
|
|
|
@ -62,9 +62,12 @@ const where = computed(() => {
|
||||||
auto-load
|
auto-load
|
||||||
:where="where"
|
:where="where"
|
||||||
url="Autonomies/location"
|
url="Autonomies/location"
|
||||||
sort-by="name ASC"
|
:sort-by="['name ASC']"
|
||||||
|
:limit="30"
|
||||||
:label="t('Autonomy')"
|
:label="t('Autonomy')"
|
||||||
hide-selected
|
hide-selected
|
||||||
|
option-label="name"
|
||||||
|
option-value="id"
|
||||||
v-model="data.autonomyFk"
|
v-model="data.autonomyFk"
|
||||||
:rules="validate('province.autonomyFk')"
|
:rules="validate('province.autonomyFk')"
|
||||||
>
|
>
|
||||||
|
|
|
@ -181,19 +181,17 @@ async function saveChanges(data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let changes = data || getChanges();
|
let changes = data || getChanges();
|
||||||
if ($props.beforeSaveFn) changes = await $props.beforeSaveFn(changes, getChanges);
|
if ($props.beforeSaveFn) {
|
||||||
|
changes = await $props.beforeSaveFn(changes, getChanges);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (changes?.creates?.length === 0 && changes?.updates?.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await axios.post($props.saveUrl || $props.url + '/crud', changes);
|
await axios.post($props.saveUrl || $props.url + '/crud', changes);
|
||||||
} finally {
|
} finally {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
originalData.value = JSON.parse(JSON.stringify(formData.value));
|
originalData.value = JSON.parse(JSON.stringify(formData.value));
|
||||||
if (changes?.creates?.length) await vnPaginateRef.value.fetch();
|
if (changes.creates?.length) await vnPaginateRef.value.fetch();
|
||||||
|
|
||||||
hasChanges.value = false;
|
hasChanges.value = false;
|
||||||
emit('saveChanges', data);
|
emit('saveChanges', data);
|
||||||
|
|
|
@ -42,6 +42,7 @@ const itemFilter = {
|
||||||
const itemFilterParams = reactive({});
|
const itemFilterParams = reactive({});
|
||||||
const closeButton = ref(null);
|
const closeButton = ref(null);
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
const producersOptions = ref([]);
|
||||||
const ItemTypesOptions = ref([]);
|
const ItemTypesOptions = ref([]);
|
||||||
const InksOptions = ref([]);
|
const InksOptions = ref([]);
|
||||||
const tableRows = ref([]);
|
const tableRows = ref([]);
|
||||||
|
@ -120,17 +121,23 @@ const selectItem = ({ id }) => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<FetchData
|
||||||
|
url="Producers"
|
||||||
|
@on-fetch="(data) => (producersOptions = data)"
|
||||||
|
:filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
url="ItemTypes"
|
url="ItemTypes"
|
||||||
:filter="{ fields: ['id', 'name'], order: 'name ASC' }"
|
:filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }"
|
||||||
order="name ASC"
|
order="name"
|
||||||
@on-fetch="(data) => (ItemTypesOptions = data)"
|
@on-fetch="(data) => (ItemTypesOptions = data)"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
url="Inks"
|
url="Inks"
|
||||||
:filter="{ fields: ['id', 'name'], order: 'name ASC' }"
|
:filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }"
|
||||||
order="name ASC"
|
order="name"
|
||||||
@on-fetch="(data) => (InksOptions = data)"
|
@on-fetch="(data) => (InksOptions = data)"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
|
@ -145,11 +152,11 @@ const selectItem = ({ id }) => {
|
||||||
<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('globals.producer')"
|
||||||
|
:options="producersOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
|
option-label="name"
|
||||||
|
option-value="id"
|
||||||
v-model="itemFilterParams.producerFk"
|
v-model="itemFilterParams.producerFk"
|
||||||
url="Producers"
|
|
||||||
:fields="['id', 'name']"
|
|
||||||
sort-by="name ASC"
|
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('globals.type')"
|
:label="t('globals.type')"
|
||||||
|
@ -188,7 +195,7 @@ const selectItem = ({ id }) => {
|
||||||
>
|
>
|
||||||
<template #body-cell-id="{ row }">
|
<template #body-cell-id="{ row }">
|
||||||
<QTd auto-width @click.stop>
|
<QTd auto-width @click.stop>
|
||||||
<QBtn flat class="link">{{ row.id }}</QBtn>
|
<QBtn flat color="blue">{{ row.id }}</QBtn>
|
||||||
<ItemDescriptorProxy :id="row.id" />
|
<ItemDescriptorProxy :id="row.id" />
|
||||||
</QTd>
|
</QTd>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -124,7 +124,7 @@ const selectTravel = ({ id }) => {
|
||||||
<FetchData
|
<FetchData
|
||||||
url="AgencyModes"
|
url="AgencyModes"
|
||||||
@on-fetch="(data) => (agenciesOptions = data)"
|
@on-fetch="(data) => (agenciesOptions = data)"
|
||||||
:filter="{ fields: ['id', 'name'], order: ['name ASC'] }"
|
:filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
@ -196,7 +196,7 @@ const selectTravel = ({ id }) => {
|
||||||
>
|
>
|
||||||
<template #body-cell-id="{ row }">
|
<template #body-cell-id="{ row }">
|
||||||
<QTd auto-width @click.stop data-cy="travelFk-travel-form">
|
<QTd auto-width @click.stop data-cy="travelFk-travel-form">
|
||||||
<QBtn flat class="link">{{ row.id }}</QBtn>
|
<QBtn flat color="blue">{{ row.id }}</QBtn>
|
||||||
<TravelDescriptorProxy :id="row.id" />
|
<TravelDescriptorProxy :id="row.id" />
|
||||||
</QTd>
|
</QTd>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { onMounted, onUnmounted, computed, ref, watch, nextTick, useAttrs } from 'vue';
|
import { onMounted, onUnmounted, computed, ref, watch, nextTick } from 'vue';
|
||||||
import { onBeforeRouteLeave, useRouter, useRoute } from 'vue-router';
|
import { onBeforeRouteLeave, useRouter, useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
|
@ -12,7 +12,6 @@ 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 { getDifferences, getUpdatedValues } from 'src/filters';
|
|
||||||
|
|
||||||
const { push } = useRouter();
|
const { push } = useRouter();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
|
@ -23,7 +22,6 @@ const { validate } = useValidator();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const myForm = ref(null);
|
const myForm = ref(null);
|
||||||
const attrs = useAttrs();
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
url: {
|
url: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -96,10 +94,6 @@ const $props = defineProps({
|
||||||
type: [String, Boolean],
|
type: [String, Boolean],
|
||||||
default: '800px',
|
default: '800px',
|
||||||
},
|
},
|
||||||
onDataSaved: {
|
|
||||||
type: Function,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
||||||
const modelValue = computed(
|
const modelValue = computed(
|
||||||
|
@ -112,14 +106,14 @@ const isLoading = ref(false);
|
||||||
const isResetting = ref(false);
|
const isResetting = ref(false);
|
||||||
const hasChanges = ref(!$props.observeFormChanges);
|
const hasChanges = ref(!$props.observeFormChanges);
|
||||||
const originalData = computed(() => state.get(modelValue));
|
const originalData = computed(() => state.get(modelValue));
|
||||||
const formData = ref();
|
const formData = ref({});
|
||||||
const defaultButtons = computed(() => ({
|
const defaultButtons = computed(() => ({
|
||||||
save: {
|
save: {
|
||||||
dataCy: 'saveDefaultBtn',
|
dataCy: 'saveDefaultBtn',
|
||||||
color: 'primary',
|
color: 'primary',
|
||||||
icon: 'save',
|
icon: 'save',
|
||||||
label: 'globals.save',
|
label: 'globals.save',
|
||||||
click: async () => await save(),
|
click: () => myForm.value.submit(),
|
||||||
type: 'submit',
|
type: 'submit',
|
||||||
},
|
},
|
||||||
reset: {
|
reset: {
|
||||||
|
@ -140,8 +134,7 @@ onMounted(async () => {
|
||||||
|
|
||||||
if (!$props.formInitialData) {
|
if (!$props.formInitialData) {
|
||||||
if ($props.autoLoad && $props.url) await fetch();
|
if ($props.autoLoad && $props.url) await fetch();
|
||||||
else if (arrayData.store.data)
|
else if (arrayData.store.data) updateAndEmit('onFetch', arrayData.store.data);
|
||||||
updateAndEmit('onFetch', { val: arrayData.store.data });
|
|
||||||
}
|
}
|
||||||
if ($props.observeFormChanges) {
|
if ($props.observeFormChanges) {
|
||||||
watch(
|
watch(
|
||||||
|
@ -161,7 +154,7 @@ onMounted(async () => {
|
||||||
if (!$props.url)
|
if (!$props.url)
|
||||||
watch(
|
watch(
|
||||||
() => arrayData.store.data,
|
() => arrayData.store.data,
|
||||||
(val) => updateAndEmit('onFetch', { val }),
|
(val) => updateAndEmit('onFetch', val),
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
@ -207,7 +200,7 @@ async function fetch() {
|
||||||
});
|
});
|
||||||
if (Array.isArray(data)) data = data[0] ?? {};
|
if (Array.isArray(data)) data = data[0] ?? {};
|
||||||
|
|
||||||
updateAndEmit('onFetch', { val: data });
|
updateAndEmit('onFetch', data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
state.set(modelValue, {});
|
state.set(modelValue, {});
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -234,11 +227,7 @@ async function save() {
|
||||||
|
|
||||||
if ($props.urlCreate) notify('globals.dataCreated', 'positive');
|
if ($props.urlCreate) notify('globals.dataCreated', 'positive');
|
||||||
|
|
||||||
updateAndEmit('onDataSaved', {
|
updateAndEmit('onDataSaved', formData.value, response?.data);
|
||||||
val: formData.value,
|
|
||||||
res: response?.data,
|
|
||||||
old: originalData.value,
|
|
||||||
});
|
|
||||||
if ($props.reload) await arrayData.fetch({});
|
if ($props.reload) await arrayData.fetch({});
|
||||||
hasChanges.value = false;
|
hasChanges.value = false;
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -253,7 +242,7 @@ async function saveAndGo() {
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
formData.value = JSON.parse(JSON.stringify(originalData.value));
|
formData.value = JSON.parse(JSON.stringify(originalData.value));
|
||||||
updateAndEmit('onFetch', { val: originalData.value });
|
updateAndEmit('onFetch', originalData.value);
|
||||||
if ($props.observeFormChanges) {
|
if ($props.observeFormChanges) {
|
||||||
hasChanges.value = false;
|
hasChanges.value = false;
|
||||||
isResetting.value = true;
|
isResetting.value = true;
|
||||||
|
@ -275,11 +264,11 @@ function filter(value, update, filterOptions) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateAndEmit(evt, { val, res, old } = { val: null, res: null, old: null }) {
|
function updateAndEmit(evt, val, res) {
|
||||||
state.set(modelValue, val);
|
state.set(modelValue, val);
|
||||||
if (!$props.url) arrayData.store.data = val;
|
if (!$props.url) arrayData.store.data = val;
|
||||||
|
|
||||||
emit(evt, state.get(modelValue), res, old);
|
emit(evt, state.get(modelValue), res);
|
||||||
}
|
}
|
||||||
|
|
||||||
function trimData(data) {
|
function trimData(data) {
|
||||||
|
@ -289,27 +278,6 @@ function trimData(data) {
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
function onBeforeSave(formData, originalData) {
|
|
||||||
return getUpdatedValues(
|
|
||||||
Object.keys(getDifferences(formData, originalData)),
|
|
||||||
formData,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
async function onKeyup(evt) {
|
|
||||||
if (evt.key === 'Enter' && !('prevent-submit' in attrs)) {
|
|
||||||
const input = evt.target;
|
|
||||||
if (input.type == 'textarea' && evt.shiftKey) {
|
|
||||||
let { selectionStart, selectionEnd } = input;
|
|
||||||
input.value =
|
|
||||||
input.value.substring(0, selectionStart) +
|
|
||||||
'\n' +
|
|
||||||
input.value.substring(selectionEnd);
|
|
||||||
selectionStart = selectionEnd = selectionStart + 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
save,
|
save,
|
||||||
|
@ -325,13 +293,12 @@ defineExpose({
|
||||||
<QForm
|
<QForm
|
||||||
ref="myForm"
|
ref="myForm"
|
||||||
v-if="formData"
|
v-if="formData"
|
||||||
@submit.prevent
|
@submit="save"
|
||||||
@keyup.prevent="onKeyup"
|
|
||||||
@reset="reset"
|
@reset="reset"
|
||||||
class="q-pa-md"
|
class="q-pa-md"
|
||||||
:style="maxWidth ? 'max-width: ' + maxWidth : ''"
|
:style="maxWidth ? 'max-width: ' + maxWidth : ''"
|
||||||
id="formModel"
|
id="formModel"
|
||||||
:mapper="onBeforeSave"
|
:prevent-submit="$attrs['prevent-submit']"
|
||||||
>
|
>
|
||||||
<QCard>
|
<QCard>
|
||||||
<slot
|
<slot
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, useAttrs, nextTick } from 'vue';
|
import { ref, computed, onMounted } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useState } from 'src/composables/useState';
|
|
||||||
|
|
||||||
import FormModel from 'components/FormModel.vue';
|
import FormModel from 'components/FormModel.vue';
|
||||||
|
|
||||||
const emit = defineEmits(['onDataSaved', 'onDataCanceled']);
|
const emit = defineEmits(['onDataSaved', 'onDataCanceled']);
|
||||||
|
|
||||||
const props = defineProps({
|
defineProps({
|
||||||
title: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
|
@ -23,28 +22,17 @@ const props = defineProps({
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const attrs = useAttrs();
|
|
||||||
const state = useState();
|
|
||||||
const formModelRef = ref(null);
|
const formModelRef = ref(null);
|
||||||
const closeButton = ref(null);
|
const closeButton = ref(null);
|
||||||
const isSaveAndContinue = ref(props.showSaveAndContinueBtn);
|
const isSaveAndContinue = ref(false);
|
||||||
const isLoading = computed(() => formModelRef.value?.isLoading);
|
const onDataSaved = (formData, requestResponse) => {
|
||||||
const reset = computed(() => formModelRef.value?.reset);
|
if (closeButton.value && isSaveAndContinue) closeButton.value.click();
|
||||||
|
|
||||||
const onDataSaved = async (formData, requestResponse) => {
|
|
||||||
if (!isSaveAndContinue.value) closeButton.value?.click();
|
|
||||||
if (isSaveAndContinue.value) {
|
|
||||||
await nextTick();
|
|
||||||
state.set(attrs.model, attrs.formInitialData);
|
|
||||||
}
|
|
||||||
isSaveAndContinue.value = props.showSaveAndContinueBtn;
|
|
||||||
emit('onDataSaved', formData, requestResponse);
|
emit('onDataSaved', formData, requestResponse);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClick = async (saveAndContinue) => {
|
const isLoading = computed(() => formModelRef.value?.isLoading);
|
||||||
isSaveAndContinue.value = saveAndContinue;
|
const reset = computed(() => formModelRef.value?.reset);
|
||||||
await formModelRef.value.save();
|
|
||||||
};
|
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
isLoading,
|
isLoading,
|
||||||
|
@ -70,6 +58,19 @@ defineExpose({
|
||||||
<p>{{ subtitle }}</p>
|
<p>{{ subtitle }}</p>
|
||||||
<slot name="form-inputs" :data="data" :validate="validate" />
|
<slot name="form-inputs" :data="data" :validate="validate" />
|
||||||
<div class="q-mt-lg row justify-end">
|
<div class="q-mt-lg row justify-end">
|
||||||
|
<QBtn
|
||||||
|
v-if="showSaveAndContinueBtn"
|
||||||
|
:label="t('globals.isSaveAndContinue')"
|
||||||
|
:title="t('globals.isSaveAndContinue')"
|
||||||
|
type="submit"
|
||||||
|
color="primary"
|
||||||
|
class="q-ml-sm"
|
||||||
|
:disabled="isLoading"
|
||||||
|
:loading="isLoading"
|
||||||
|
data-cy="FormModelPopup_isSaveAndContinue"
|
||||||
|
z-max
|
||||||
|
@click="() => (isSaveAndContinue = true)"
|
||||||
|
/>
|
||||||
<QBtn
|
<QBtn
|
||||||
:label="t('globals.cancel')"
|
:label="t('globals.cancel')"
|
||||||
:title="t('globals.cancel')"
|
:title="t('globals.cancel')"
|
||||||
|
@ -81,31 +82,24 @@ defineExpose({
|
||||||
data-cy="FormModelPopup_cancel"
|
data-cy="FormModelPopup_cancel"
|
||||||
v-close-popup
|
v-close-popup
|
||||||
z-max
|
z-max
|
||||||
@click="emit('onDataCanceled')"
|
@click="
|
||||||
|
() => {
|
||||||
|
isSaveAndContinue = false;
|
||||||
|
emit('onDataCanceled');
|
||||||
|
}
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
<QBtn
|
<QBtn
|
||||||
:flat="showSaveAndContinueBtn"
|
|
||||||
:label="t('globals.save')"
|
:label="t('globals.save')"
|
||||||
:title="t('globals.save')"
|
:title="t('globals.save')"
|
||||||
@click="onClick(false)"
|
type="submit"
|
||||||
color="primary"
|
color="primary"
|
||||||
class="q-ml-sm"
|
class="q-ml-sm"
|
||||||
:disabled="isLoading"
|
:disabled="isLoading"
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
data-cy="FormModelPopup_save"
|
data-cy="FormModelPopup_save"
|
||||||
z-max
|
z-max
|
||||||
/>
|
@click="() => (isSaveAndContinue = false)"
|
||||||
<QBtn
|
|
||||||
v-if="showSaveAndContinueBtn"
|
|
||||||
:label="t('globals.isSaveAndContinue')"
|
|
||||||
:title="t('globals.isSaveAndContinue')"
|
|
||||||
color="primary"
|
|
||||||
class="q-ml-sm"
|
|
||||||
:disabled="isLoading"
|
|
||||||
:loading="isLoading"
|
|
||||||
data-cy="FormModelPopup_isSaveAndContinue"
|
|
||||||
z-max
|
|
||||||
@click="onClick(true)"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -121,25 +121,23 @@ const removeTag = (index, params, search) => {
|
||||||
applyTags(params, search);
|
applyTags(params, search);
|
||||||
};
|
};
|
||||||
const setCategoryList = (data) => {
|
const setCategoryList = (data) => {
|
||||||
categoryList.value = (data || []).map((category) => ({
|
categoryList.value = (data || [])
|
||||||
...category,
|
.filter((category) => category.display)
|
||||||
icon: `vn:${(category.icon || '').split('-')[1]}`,
|
.map((category) => ({
|
||||||
}));
|
...category,
|
||||||
|
icon: `vn:${(category.icon || '').split('-')[1]}`,
|
||||||
|
}));
|
||||||
fetchItemTypes();
|
fetchItemTypes();
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData url="ItemCategories" limit="30" auto-load @on-fetch="setCategoryList" />
|
||||||
url="ItemCategories"
|
|
||||||
auto-load
|
|
||||||
@on-fetch="setCategoryList"
|
|
||||||
:where="{ display: { neq: 0 } }"
|
|
||||||
/>
|
|
||||||
<FetchData
|
<FetchData
|
||||||
url="Tags"
|
url="Tags"
|
||||||
:filter="{ fields: ['id', 'name', 'isFree'] }"
|
:filter="{ fields: ['id', 'name', 'isFree'] }"
|
||||||
auto-load
|
auto-load
|
||||||
|
limit="30"
|
||||||
@on-fetch="(data) => (tagOptions = data)"
|
@on-fetch="(data) => (tagOptions = data)"
|
||||||
/>
|
/>
|
||||||
<VnFilterPanel
|
<VnFilterPanel
|
||||||
|
@ -197,8 +195,11 @@ const setCategoryList = (data) => {
|
||||||
:label="t('components.itemsFilterPanel.typeFk')"
|
:label="t('components.itemsFilterPanel.typeFk')"
|
||||||
v-model="params.typeFk"
|
v-model="params.typeFk"
|
||||||
:options="itemTypesOptions"
|
:options="itemTypesOptions"
|
||||||
|
option-value="id"
|
||||||
|
option-label="name"
|
||||||
dense
|
dense
|
||||||
filled
|
outlined
|
||||||
|
rounded
|
||||||
use-input
|
use-input
|
||||||
:disable="!selectedCategoryFk"
|
:disable="!selectedCategoryFk"
|
||||||
@update:model-value="
|
@update:model-value="
|
||||||
|
@ -233,8 +234,10 @@ const setCategoryList = (data) => {
|
||||||
:label="t('globals.tag')"
|
:label="t('globals.tag')"
|
||||||
v-model="value.selectedTag"
|
v-model="value.selectedTag"
|
||||||
:options="tagOptions"
|
:options="tagOptions"
|
||||||
|
option-label="name"
|
||||||
dense
|
dense
|
||||||
filled
|
outlined
|
||||||
|
rounded
|
||||||
:emit-value="false"
|
:emit-value="false"
|
||||||
use-input
|
use-input
|
||||||
:is-clearable="false"
|
:is-clearable="false"
|
||||||
|
@ -250,7 +253,8 @@ const setCategoryList = (data) => {
|
||||||
option-value="value"
|
option-value="value"
|
||||||
option-label="value"
|
option-label="value"
|
||||||
dense
|
dense
|
||||||
filled
|
outlined
|
||||||
|
rounded
|
||||||
emit-value
|
emit-value
|
||||||
use-input
|
use-input
|
||||||
:disable="!value"
|
:disable="!value"
|
||||||
|
@ -262,6 +266,7 @@ const setCategoryList = (data) => {
|
||||||
v-model="value.value"
|
v-model="value.value"
|
||||||
:label="t('components.itemsFilterPanel.value')"
|
:label="t('components.itemsFilterPanel.value')"
|
||||||
:disable="!value"
|
:disable="!value"
|
||||||
|
is-outlined
|
||||||
:is-clearable="false"
|
:is-clearable="false"
|
||||||
@keyup.enter="applyTags(params, searchFn)"
|
@keyup.enter="applyTags(params, searchFn)"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -77,7 +77,6 @@ watch(
|
||||||
function findMatches(search, item) {
|
function findMatches(search, item) {
|
||||||
const matches = [];
|
const matches = [];
|
||||||
function findRoute(search, item) {
|
function findRoute(search, item) {
|
||||||
if (!item?.children) return;
|
|
||||||
for (const child of item.children) {
|
for (const child of item.children) {
|
||||||
if (search?.indexOf(child.name) > -1) {
|
if (search?.indexOf(child.name) > -1) {
|
||||||
matches.push(child);
|
matches.push(child);
|
||||||
|
@ -93,7 +92,7 @@ function findMatches(search, item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addChildren(module, route, parent) {
|
function addChildren(module, route, parent) {
|
||||||
const menus = route?.meta?.menu;
|
const menus = route?.meta?.menu ?? route?.menus?.[props.source]; //backwards compatible
|
||||||
if (!menus) return;
|
if (!menus) return;
|
||||||
|
|
||||||
const matches = findMatches(menus, route);
|
const matches = findMatches(menus, route);
|
||||||
|
@ -108,7 +107,11 @@ function getRoutes() {
|
||||||
main: getMainRoutes,
|
main: getMainRoutes,
|
||||||
card: getCardRoutes,
|
card: getCardRoutes,
|
||||||
};
|
};
|
||||||
handleRoutes[props.source]();
|
try {
|
||||||
|
handleRoutes[props.source]();
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(`Method is not defined`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function getMainRoutes() {
|
function getMainRoutes() {
|
||||||
const modules = Object.assign([], navigation.getModules().value);
|
const modules = Object.assign([], navigation.getModules().value);
|
||||||
|
@ -119,6 +122,7 @@ function getMainRoutes() {
|
||||||
);
|
);
|
||||||
if (!moduleDef) continue;
|
if (!moduleDef) continue;
|
||||||
item.children = [];
|
item.children = [];
|
||||||
|
|
||||||
addChildren(item.module, moduleDef, item.children);
|
addChildren(item.module, moduleDef, item.children);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,18 +132,23 @@ function getMainRoutes() {
|
||||||
function getCardRoutes() {
|
function getCardRoutes() {
|
||||||
const currentRoute = route.matched[1];
|
const currentRoute = route.matched[1];
|
||||||
const currentModule = toLowerCamel(currentRoute.name);
|
const currentModule = toLowerCamel(currentRoute.name);
|
||||||
let moduleDef;
|
let moduleDef = routes.find((route) => toLowerCamel(route.name) === currentModule);
|
||||||
|
|
||||||
let index = route.matched.length - 1;
|
|
||||||
while (!moduleDef && index > 0) {
|
|
||||||
if (route.matched[index]?.meta?.menu) moduleDef = route.matched[index];
|
|
||||||
index--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!moduleDef) return;
|
if (!moduleDef) return;
|
||||||
|
if (!moduleDef?.menus) moduleDef = betaGetRoutes();
|
||||||
addChildren(currentModule, moduleDef, items.value);
|
addChildren(currentModule, moduleDef, items.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function betaGetRoutes() {
|
||||||
|
let menuRoute;
|
||||||
|
let index = route.matched.length - 1;
|
||||||
|
while (!menuRoute && index > 0) {
|
||||||
|
if (route.matched[index]?.meta?.menu) menuRoute = route.matched[index];
|
||||||
|
index--;
|
||||||
|
}
|
||||||
|
return menuRoute;
|
||||||
|
}
|
||||||
|
|
||||||
async function togglePinned(item, event) {
|
async function togglePinned(item, event) {
|
||||||
if (event.defaultPrevented) return;
|
if (event.defaultPrevented) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref, computed } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
|
@ -18,14 +18,6 @@ const state = useState();
|
||||||
const user = state.getUser();
|
const user = state.getUser();
|
||||||
const appName = 'Lilium';
|
const appName = 'Lilium';
|
||||||
const pinnedModulesRef = ref();
|
const pinnedModulesRef = ref();
|
||||||
const hostname = window.location.hostname;
|
|
||||||
const env = ref();
|
|
||||||
|
|
||||||
const getEnvironment = computed(() => {
|
|
||||||
env.value = hostname.split('-');
|
|
||||||
if (env.value.length <= 1) return;
|
|
||||||
return env.value[0];
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(() => stateStore.setMounted());
|
onMounted(() => stateStore.setMounted());
|
||||||
const refresh = () => window.location.reload();
|
const refresh = () => window.location.reload();
|
||||||
|
@ -57,9 +49,6 @@ const refresh = () => window.location.reload();
|
||||||
{{ t('globals.backToDashboard') }}
|
{{ t('globals.backToDashboard') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QBtn>
|
</QBtn>
|
||||||
<QBadge v-if="getEnvironment" color="primary" align="top">
|
|
||||||
{{ getEnvironment }}
|
|
||||||
</QBadge>
|
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<VnBreadcrumbs v-if="$q.screen.gt.sm" />
|
<VnBreadcrumbs v-if="$q.screen.gt.sm" />
|
||||||
<QSpinner
|
<QSpinner
|
||||||
|
@ -68,7 +57,7 @@ const refresh = () => window.location.reload();
|
||||||
:class="{
|
:class="{
|
||||||
'no-visible': !stateQuery.isLoading().value,
|
'no-visible': !stateQuery.isLoading().value,
|
||||||
}"
|
}"
|
||||||
size="sm"
|
size="xs"
|
||||||
data-cy="loading-spinner"
|
data-cy="loading-spinner"
|
||||||
/>
|
/>
|
||||||
<QSpace />
|
<QSpace />
|
||||||
|
@ -96,15 +85,7 @@ const refresh = () => window.location.reload();
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
<PinnedModules ref="pinnedModulesRef" />
|
<PinnedModules ref="pinnedModulesRef" />
|
||||||
</QBtn>
|
</QBtn>
|
||||||
<QBtn
|
<QBtn class="q-pa-none" rounded dense flat no-wrap id="user">
|
||||||
class="q-pa-none"
|
|
||||||
rounded
|
|
||||||
dense
|
|
||||||
flat
|
|
||||||
no-wrap
|
|
||||||
id="user"
|
|
||||||
data-cy="userPanel_btn"
|
|
||||||
>
|
|
||||||
<VnAvatar
|
<VnAvatar
|
||||||
:worker-id="user.id"
|
:worker-id="user.id"
|
||||||
:title="user.name"
|
:title="user.name"
|
||||||
|
|
|
@ -1,42 +1,16 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { toCurrency } from 'src/filters';
|
|
||||||
|
|
||||||
defineProps({ row: { type: Object, required: true } });
|
defineProps({ row: { type: Object, required: true } });
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<span class="q-gutter-x-xs">
|
<span class="q-gutter-x-xs">
|
||||||
<router-link
|
|
||||||
v-if="row.claim?.claimFk"
|
|
||||||
:to="{ name: 'ClaimBasicData', params: { id: row.claim?.claimFk } }"
|
|
||||||
class="link"
|
|
||||||
>
|
|
||||||
<QIcon name="vn:claims" size="xs">
|
|
||||||
<QTooltip>
|
|
||||||
{{ $t('ticketSale.claim') }}:
|
|
||||||
{{ row.claim?.claimFk }}
|
|
||||||
</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</router-link>
|
|
||||||
<QIcon
|
<QIcon
|
||||||
v-if="row?.isDeleted"
|
v-if="row?.risk"
|
||||||
color="primary"
|
|
||||||
name="vn:deletedTicket"
|
|
||||||
size="xs"
|
|
||||||
data-cy="ticketDeletedIcon"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ t('Ticket deleted') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon
|
|
||||||
v-if="row?.hasRisk"
|
|
||||||
name="vn:risk"
|
name="vn:risk"
|
||||||
:color="row.hasHighRisk ? 'negative' : 'primary'"
|
:color="row.hasHighRisk ? 'negative' : 'primary'"
|
||||||
size="xs"
|
size="xs"
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ $t('salesTicketsTable.risk') }}:
|
{{ $t('salesTicketsTable.risk') }}: {{ row.risk - row.credit }}
|
||||||
{{ toCurrency(row.risk - (row.credit ?? 0)) }}
|
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon
|
<QIcon
|
||||||
|
@ -78,7 +52,12 @@ defineProps({ row: { type: Object, required: true } });
|
||||||
>
|
>
|
||||||
<QTooltip>{{ $t('salesTicketsTable.purchaseRequest') }}</QTooltip>
|
<QTooltip>{{ $t('salesTicketsTable.purchaseRequest') }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon v-if="row?.isTaxDataChecked" name="vn:no036" color="primary" size="xs">
|
<QIcon
|
||||||
|
v-if="!row?.isTaxDataChecked === 0"
|
||||||
|
name="vn:no036"
|
||||||
|
color="primary"
|
||||||
|
size="xs"
|
||||||
|
>
|
||||||
<QTooltip>{{ $t('salesTicketsTable.noVerifiedData') }}</QTooltip>
|
<QTooltip>{{ $t('salesTicketsTable.noVerifiedData') }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon v-if="row?.isFreezed" name="vn:frozen" color="primary" size="xs">
|
<QIcon v-if="row?.isFreezed" name="vn:frozen" color="primary" size="xs">
|
||||||
|
|
|
@ -87,7 +87,7 @@ const makeInvoice = async () => {
|
||||||
(data) => (
|
(data) => (
|
||||||
(rectificativeTypeOptions = data),
|
(rectificativeTypeOptions = data),
|
||||||
(transferInvoiceParams.cplusRectificationTypeFk = data.filter(
|
(transferInvoiceParams.cplusRectificationTypeFk = data.filter(
|
||||||
(type) => type.description == 'I – Por diferencias',
|
(type) => type.description == 'I – Por diferencias'
|
||||||
)[0].id)
|
)[0].id)
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
|
@ -100,7 +100,7 @@ const makeInvoice = async () => {
|
||||||
(data) => (
|
(data) => (
|
||||||
(siiTypeInvoiceOutsOptions = data),
|
(siiTypeInvoiceOutsOptions = data),
|
||||||
(transferInvoiceParams.siiTypeInvoiceOutFk = data.filter(
|
(transferInvoiceParams.siiTypeInvoiceOutFk = data.filter(
|
||||||
(type) => type.code == 'R4',
|
(type) => type.code == 'R4'
|
||||||
)[0].id)
|
)[0].id)
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
|
@ -122,6 +122,7 @@ const makeInvoice = async () => {
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('Client')"
|
:label="t('Client')"
|
||||||
|
:options="clientsOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { markRaw, computed } from 'vue';
|
import { markRaw, computed } from 'vue';
|
||||||
import { QIcon, QToggle } from 'quasar';
|
import { QIcon, QCheckbox, QToggle } from 'quasar';
|
||||||
import { dashIfEmpty } from 'src/filters';
|
import { dashIfEmpty } from 'src/filters';
|
||||||
|
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
import VnSelect from 'components/common/VnSelect.vue';
|
||||||
|
@ -55,8 +55,6 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const label = $props.showLabel && $props.column.label ? $props.column.label : '';
|
|
||||||
|
|
||||||
const defaultSelect = {
|
const defaultSelect = {
|
||||||
attrs: {
|
attrs: {
|
||||||
row: $props.row,
|
row: $props.row,
|
||||||
|
@ -64,7 +62,7 @@ const defaultSelect = {
|
||||||
class: 'fit',
|
class: 'fit',
|
||||||
},
|
},
|
||||||
forceAttrs: {
|
forceAttrs: {
|
||||||
label,
|
label: $props.showLabel && $props.column.label,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -76,7 +74,7 @@ const defaultComponents = {
|
||||||
class: 'fit',
|
class: 'fit',
|
||||||
},
|
},
|
||||||
forceAttrs: {
|
forceAttrs: {
|
||||||
label,
|
label: $props.showLabel && $props.column.label,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
number: {
|
number: {
|
||||||
|
@ -86,7 +84,7 @@ const defaultComponents = {
|
||||||
class: 'fit',
|
class: 'fit',
|
||||||
},
|
},
|
||||||
forceAttrs: {
|
forceAttrs: {
|
||||||
label,
|
label: $props.showLabel && $props.column.label,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
date: {
|
date: {
|
||||||
|
@ -98,7 +96,7 @@ const defaultComponents = {
|
||||||
class: 'fit',
|
class: 'fit',
|
||||||
},
|
},
|
||||||
forceAttrs: {
|
forceAttrs: {
|
||||||
label,
|
label: $props.showLabel && $props.column.label,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
time: {
|
time: {
|
||||||
|
@ -107,7 +105,7 @@ const defaultComponents = {
|
||||||
disable: !$props.isEditable,
|
disable: !$props.isEditable,
|
||||||
},
|
},
|
||||||
forceAttrs: {
|
forceAttrs: {
|
||||||
label,
|
label: $props.showLabel && $props.column.label,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
checkbox: {
|
checkbox: {
|
||||||
|
@ -127,7 +125,7 @@ const defaultComponents = {
|
||||||
return defaultAttrs;
|
return defaultAttrs;
|
||||||
},
|
},
|
||||||
forceAttrs: {
|
forceAttrs: {
|
||||||
label,
|
label: $props.showLabel && $props.column.label,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
|
|
|
@ -2,11 +2,12 @@
|
||||||
import { markRaw, computed } from 'vue';
|
import { markRaw, computed } from 'vue';
|
||||||
import { QCheckbox, QToggle } from 'quasar';
|
import { QCheckbox, QToggle } from 'quasar';
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
|
|
||||||
|
/* basic input */
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
import VnSelect from 'components/common/VnSelect.vue';
|
||||||
import VnInput from 'components/common/VnInput.vue';
|
import VnInput from 'components/common/VnInput.vue';
|
||||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||||
import VnInputTime from 'components/common/VnInputTime.vue';
|
import VnInputTime from 'components/common/VnInputTime.vue';
|
||||||
import VnCheckbox from 'components/common/VnCheckbox.vue';
|
|
||||||
import VnColumn from 'components/VnTable/VnColumn.vue';
|
import VnColumn from 'components/VnTable/VnColumn.vue';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
|
@ -26,10 +27,6 @@ const $props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: 'table',
|
default: 'table',
|
||||||
},
|
},
|
||||||
customClass: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
defineExpose({ addFilter, props: $props });
|
defineExpose({ addFilter, props: $props });
|
||||||
|
@ -60,7 +57,7 @@ const selectComponent = {
|
||||||
component: markRaw(VnSelect),
|
component: markRaw(VnSelect),
|
||||||
event: updateEvent,
|
event: updateEvent,
|
||||||
attrs: {
|
attrs: {
|
||||||
class: `q-pt-none fit ${$props.customClass}`,
|
class: 'q-pt-none fit vn-label-padding',
|
||||||
dense: true,
|
dense: true,
|
||||||
filled: !$props.showTitle,
|
filled: !$props.showTitle,
|
||||||
},
|
},
|
||||||
|
@ -92,6 +89,7 @@ const components = {
|
||||||
event: updateEvent,
|
event: updateEvent,
|
||||||
attrs: {
|
attrs: {
|
||||||
...defaultAttrs,
|
...defaultAttrs,
|
||||||
|
style: 'min-width: 150px',
|
||||||
},
|
},
|
||||||
forceAttrs,
|
forceAttrs,
|
||||||
},
|
},
|
||||||
|
@ -107,7 +105,7 @@ const components = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
checkbox: {
|
checkbox: {
|
||||||
component: markRaw(VnCheckbox),
|
component: markRaw(QCheckbox),
|
||||||
event: updateEvent,
|
event: updateEvent,
|
||||||
attrs: {
|
attrs: {
|
||||||
class: $props.showTitle ? 'q-py-sm' : 'q-px-md q-py-xs fit',
|
class: $props.showTitle ? 'q-py-sm' : 'q-px-md q-py-xs fit',
|
||||||
|
@ -152,7 +150,7 @@ const onTabPressed = async () => {
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div v-if="showFilter" class="full-width" style="overflow: hidden">
|
<div v-if="showFilter" class="full-width flex-center" style="overflow: hidden">
|
||||||
<VnColumn
|
<VnColumn
|
||||||
:column="$props.column"
|
:column="$props.column"
|
||||||
default="input"
|
default="input"
|
||||||
|
@ -163,8 +161,8 @@ const onTabPressed = async () => {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss">
|
||||||
label.vn-label-padding > .q-field__inner > .q-field__control {
|
label.vn-label-padding > .q-field__inner > .q-field__control {
|
||||||
padding: inherit !important;
|
padding: inherit;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -23,10 +23,6 @@ const $props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
align: {
|
|
||||||
type: String,
|
|
||||||
default: 'end',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
const hover = ref();
|
const hover = ref();
|
||||||
const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl });
|
const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl });
|
||||||
|
@ -50,27 +46,16 @@ async function orderBy(name, direction) {
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({ orderBy });
|
defineExpose({ orderBy });
|
||||||
|
|
||||||
function textAlignToFlex(textAlign) {
|
|
||||||
return `justify-content: ${
|
|
||||||
{
|
|
||||||
'text-center': 'center',
|
|
||||||
'text-left': 'start',
|
|
||||||
'text-right': 'end',
|
|
||||||
}[textAlign] || 'start'
|
|
||||||
};`;
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
@mouseenter="hover = true"
|
@mouseenter="hover = true"
|
||||||
@mouseleave="hover = false"
|
@mouseleave="hover = false"
|
||||||
@click="orderBy(name, model?.direction)"
|
@click="orderBy(name, model?.direction)"
|
||||||
class="items-center no-wrap cursor-pointer title"
|
class="row items-center no-wrap cursor-pointer title"
|
||||||
:style="textAlignToFlex(align)"
|
|
||||||
>
|
>
|
||||||
<span :title="label">{{ label }}</span>
|
<span :title="label">{{ label }}</span>
|
||||||
<div v-if="name && (model?.index || vertical)">
|
<sup v-if="name && model?.index">
|
||||||
<QChip
|
<QChip
|
||||||
:label="!vertical ? model?.index : ''"
|
:label="!vertical ? model?.index : ''"
|
||||||
:icon="
|
:icon="
|
||||||
|
@ -83,14 +68,14 @@ function textAlignToFlex(textAlign) {
|
||||||
:size="vertical ? '' : 'sm'"
|
:size="vertical ? '' : 'sm'"
|
||||||
:class="[
|
:class="[
|
||||||
model?.index ? 'color-vn-text' : 'bg-transparent',
|
model?.index ? 'color-vn-text' : 'bg-transparent',
|
||||||
vertical ? 'q-mx-none q-py-lg' : '',
|
vertical ? 'q-px-none' : '',
|
||||||
]"
|
]"
|
||||||
class="no-box-shadow"
|
class="no-box-shadow"
|
||||||
:clickable="true"
|
:clickable="true"
|
||||||
style="min-width: 40px; max-height: 30px"
|
style="min-width: 40px; max-height: 30px"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="column justify-center text-center"
|
class="column flex-center"
|
||||||
v-if="vertical"
|
v-if="vertical"
|
||||||
:style="!model?.index && 'color: #5d5d5d'"
|
:style="!model?.index && 'color: #5d5d5d'"
|
||||||
>
|
>
|
||||||
|
@ -107,16 +92,20 @@ function textAlignToFlex(textAlign) {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</QChip>
|
</QChip>
|
||||||
</div>
|
</sup>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.title {
|
.title {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
color: var(--vn-label-color);
|
color: var(--vn-label-color);
|
||||||
white-space: nowrap;
|
}
|
||||||
|
sup {
|
||||||
|
vertical-align: super; /* Valor predeterminado */
|
||||||
|
/* También puedes usar otros valores como "baseline", "top", "text-top", etc. */
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -10,15 +10,14 @@ import {
|
||||||
render,
|
render,
|
||||||
inject,
|
inject,
|
||||||
useAttrs,
|
useAttrs,
|
||||||
nextTick,
|
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { useQuasar, date } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { useFilterParams } from 'src/composables/useFilterParams';
|
import { useFilterParams } from 'src/composables/useFilterParams';
|
||||||
import { dashIfEmpty, toDate } from 'src/filters';
|
import { dashIfEmpty } from 'src/filters';
|
||||||
|
|
||||||
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';
|
||||||
|
@ -31,7 +30,6 @@ 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';
|
import VnTableFilter from './VnTableFilter.vue';
|
||||||
import { getColAlign } from 'src/composables/getColAlign';
|
import { getColAlign } from 'src/composables/getColAlign';
|
||||||
import RightMenu from '../common/RightMenu.vue';
|
|
||||||
|
|
||||||
const arrayData = useArrayData(useAttrs()['data-key']);
|
const arrayData = useArrayData(useAttrs()['data-key']);
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
|
@ -51,11 +49,11 @@ const $props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
rowClick: {
|
rightSearchIcon: {
|
||||||
type: [Function, Boolean],
|
type: Boolean,
|
||||||
default: null,
|
default: true,
|
||||||
},
|
},
|
||||||
rowCtrlClick: {
|
rowClick: {
|
||||||
type: [Function, Boolean],
|
type: [Function, Boolean],
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
|
@ -138,10 +136,6 @@ const $props = defineProps({
|
||||||
createComplement: {
|
createComplement: {
|
||||||
type: Object,
|
type: Object,
|
||||||
},
|
},
|
||||||
dataCy: {
|
|
||||||
type: String,
|
|
||||||
default: 'vnTable',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -170,6 +164,7 @@ const app = inject('app');
|
||||||
const editingRow = ref(null);
|
const editingRow = ref(null);
|
||||||
const editingField = ref(null);
|
const editingField = ref(null);
|
||||||
const isTableMode = computed(() => mode.value == TABLE_MODE);
|
const isTableMode = computed(() => mode.value == TABLE_MODE);
|
||||||
|
const showRightIcon = computed(() => $props.rightSearch || $props.rightSearchIcon);
|
||||||
const selectRegex = /select/;
|
const selectRegex = /select/;
|
||||||
const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']);
|
const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']);
|
||||||
const tableModes = [
|
const tableModes = [
|
||||||
|
@ -257,9 +252,7 @@ function splitColumns(columns) {
|
||||||
col.columnFilter = { inWhere: true, ...col.columnFilter };
|
col.columnFilter = { inWhere: true, ...col.columnFilter };
|
||||||
splittedColumns.value.columns.push(col);
|
splittedColumns.value.columns.push(col);
|
||||||
}
|
}
|
||||||
|
// Status column
|
||||||
splittedColumns.value.create = createOrderSort(splittedColumns.value.create);
|
|
||||||
|
|
||||||
if (splittedColumns.value.chips.length) {
|
if (splittedColumns.value.chips.length) {
|
||||||
splittedColumns.value.columnChips = splittedColumns.value.chips.filter(
|
splittedColumns.value.columnChips = splittedColumns.value.chips.filter(
|
||||||
(c) => !c.isId,
|
(c) => !c.isId,
|
||||||
|
@ -275,24 +268,6 @@ function splitColumns(columns) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createOrderSort(columns) {
|
|
||||||
const orderedColumn = columns
|
|
||||||
.map((column, index) =>
|
|
||||||
column.createOrder !== undefined ? { ...column, originalIndex: index } : null,
|
|
||||||
)
|
|
||||||
.filter((item) => item !== null);
|
|
||||||
|
|
||||||
orderedColumn.sort((a, b) => a.createOrder - b.createOrder);
|
|
||||||
|
|
||||||
const filteredColumns = columns.filter((col) => col.createOrder === undefined);
|
|
||||||
|
|
||||||
orderedColumn.forEach((col) => {
|
|
||||||
filteredColumns.splice(col.createOrder, 0, col);
|
|
||||||
});
|
|
||||||
|
|
||||||
return filteredColumns;
|
|
||||||
}
|
|
||||||
|
|
||||||
const rowClickFunction = computed(() => {
|
const rowClickFunction = computed(() => {
|
||||||
if ($props.rowClick != undefined) return $props.rowClick;
|
if ($props.rowClick != undefined) return $props.rowClick;
|
||||||
if ($props.redirect) return ({ id }) => redirectFn(id);
|
if ($props.redirect) return ({ id }) => redirectFn(id);
|
||||||
|
@ -338,14 +313,8 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
||||||
if (evt?.shiftKey && added) {
|
if (evt?.shiftKey && added) {
|
||||||
const rowIndex = selectedRows[0].$index;
|
const rowIndex = selectedRows[0].$index;
|
||||||
const selectedIndexes = new Set(selected.value.map((row) => row.$index));
|
const selectedIndexes = new Set(selected.value.map((row) => row.$index));
|
||||||
const minIndex = selectedIndexes.size
|
for (const row of rows) {
|
||||||
? Math.min(...selectedIndexes, rowIndex)
|
if (row.$index == rowIndex) break;
|
||||||
: 0;
|
|
||||||
const maxIndex = Math.max(...selectedIndexes, rowIndex);
|
|
||||||
|
|
||||||
for (let i = minIndex; i <= maxIndex; i++) {
|
|
||||||
const row = rows[i];
|
|
||||||
if (row.$index == rowIndex) continue;
|
|
||||||
if (!selectedIndexes.has(row.$index)) {
|
if (!selectedIndexes.has(row.$index)) {
|
||||||
selected.value.push(row);
|
selected.value.push(row);
|
||||||
selectedIndexes.add(row.$index);
|
selectedIndexes.add(row.$index);
|
||||||
|
@ -368,34 +337,34 @@ function hasEditableFormat(column) {
|
||||||
|
|
||||||
const clickHandler = async (event) => {
|
const clickHandler = async (event) => {
|
||||||
const clickedElement = event.target.closest('td');
|
const clickedElement = event.target.closest('td');
|
||||||
|
|
||||||
const isDateElement = event.target.closest('.q-date');
|
const isDateElement = event.target.closest('.q-date');
|
||||||
const isTimeElement = event.target.closest('.q-time');
|
const isTimeElement = event.target.closest('.q-time');
|
||||||
const isQSelectDropDown = event.target.closest('.q-select__dropdown-icon');
|
|
||||||
|
|
||||||
if (isDateElement || isTimeElement || isQSelectDropDown) return;
|
if (isDateElement || isTimeElement) return;
|
||||||
|
|
||||||
if (clickedElement === null) {
|
if (clickedElement === null) {
|
||||||
await destroyInput(editingRow.value, editingField.value);
|
destroyInput(editingRow.value, editingField.value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const rowIndex = clickedElement.getAttribute('data-row-index');
|
const rowIndex = clickedElement.getAttribute('data-row-index');
|
||||||
const colField = clickedElement.getAttribute('data-col-field');
|
const colField = clickedElement.getAttribute('data-col-field');
|
||||||
const column = $props.columns.find((col) => col.name === colField);
|
const column = $props.columns.find((col) => col.name === colField);
|
||||||
|
|
||||||
if (editingRow.value !== null && editingField.value !== null) {
|
if (editingRow.value != null && editingField.value != null) {
|
||||||
if (editingRow.value == rowIndex && editingField.value == colField) return;
|
if (editingRow.value == rowIndex && editingField.value == colField) {
|
||||||
|
return;
|
||||||
await destroyInput(editingRow.value, editingField.value);
|
} else {
|
||||||
|
destroyInput(editingRow.value, editingField.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (isEditableColumn(column))
|
||||||
if (isEditableColumn(column)) {
|
|
||||||
await renderInput(Number(rowIndex), colField, clickedElement);
|
await renderInput(Number(rowIndex), colField, clickedElement);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
async function handleTabKey(event, rowIndex, colField) {
|
async function handleTabKey(event, rowIndex, colField) {
|
||||||
if (editingRow.value == rowIndex && editingField.value == colField)
|
if (editingRow.value == rowIndex && editingField.value == colField)
|
||||||
await destroyInput(editingRow.value, editingField.value);
|
destroyInput(editingRow.value, editingField.value);
|
||||||
|
|
||||||
const direction = event.shiftKey ? -1 : 1;
|
const direction = event.shiftKey ? -1 : 1;
|
||||||
const { nextRowIndex, nextColumnName } = await handleTabNavigation(
|
const { nextRowIndex, nextColumnName } = await handleTabNavigation(
|
||||||
|
@ -415,7 +384,7 @@ async function renderInput(rowId, field, clickedElement) {
|
||||||
editingRow.value = rowId;
|
editingRow.value = rowId;
|
||||||
|
|
||||||
const originalColumn = $props.columns.find((col) => col.name === field);
|
const originalColumn = $props.columns.find((col) => col.name === field);
|
||||||
const column = { ...originalColumn, ...{ label: '' } };
|
const column = { ...originalColumn };
|
||||||
const row = CrudModelRef.value.formData[rowId];
|
const row = CrudModelRef.value.formData[rowId];
|
||||||
const oldValue = CrudModelRef.value.formData[rowId][column?.name];
|
const oldValue = CrudModelRef.value.formData[rowId][column?.name];
|
||||||
|
|
||||||
|
@ -442,14 +411,20 @@ async function renderInput(rowId, field, clickedElement) {
|
||||||
focusOnMount: true,
|
focusOnMount: true,
|
||||||
eventHandlers: {
|
eventHandlers: {
|
||||||
'update:modelValue': async (value) => {
|
'update:modelValue': async (value) => {
|
||||||
if (isSelect && value) {
|
if (isSelect) {
|
||||||
await updateSelectValue(value, column, row, oldValue);
|
row[column.name] = value[column.attrs?.optionValue ?? 'id'];
|
||||||
|
row[column?.name + 'TextValue'] =
|
||||||
|
value[column.attrs?.optionLabel ?? 'name'];
|
||||||
|
await column?.cellEvent?.['update:modelValue']?.(
|
||||||
|
value,
|
||||||
|
oldValue,
|
||||||
|
row,
|
||||||
|
);
|
||||||
} else row[column.name] = value;
|
} else row[column.name] = value;
|
||||||
await column?.cellEvent?.['update:modelValue']?.(value, oldValue, row);
|
await column?.cellEvent?.['update:modelValue']?.(value, oldValue, row);
|
||||||
},
|
},
|
||||||
keyup: async (event) => {
|
keyup: async (event) => {
|
||||||
if (event.key === 'Enter')
|
if (event.key === 'Enter') handleBlur(rowId, field, clickedElement);
|
||||||
await destroyInput(rowId, field, clickedElement);
|
|
||||||
},
|
},
|
||||||
keydown: async (event) => {
|
keydown: async (event) => {
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
|
@ -458,7 +433,7 @@ async function renderInput(rowId, field, clickedElement) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
case 'Escape':
|
case 'Escape':
|
||||||
await destroyInput(rowId, field, clickedElement);
|
destroyInput(rowId, field, clickedElement);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -473,31 +448,16 @@ async function renderInput(rowId, field, clickedElement) {
|
||||||
node.appContext = app._context;
|
node.appContext = app._context;
|
||||||
render(node, clickedElement);
|
render(node, clickedElement);
|
||||||
|
|
||||||
if (['toggle'].includes(column?.component))
|
if (['checkbox', 'toggle', undefined].includes(column?.component))
|
||||||
node.el?.querySelector('span > div').focus();
|
node.el?.querySelector('span > div').focus();
|
||||||
|
|
||||||
if (['checkbox', undefined].includes(column?.component))
|
|
||||||
node.el?.querySelector('span > div > div').focus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateSelectValue(value, column, row, oldValue) {
|
function destroyInput(rowIndex, field, clickedElement) {
|
||||||
row[column.name] = value[column.attrs?.optionValue ?? 'id'];
|
|
||||||
|
|
||||||
row[column?.name + 'VnTableTextValue'] = value[column.attrs?.optionLabel ?? 'name'];
|
|
||||||
|
|
||||||
if (column?.attrs?.find?.label)
|
|
||||||
row[column?.attrs?.find?.label] = value[column.attrs?.optionLabel ?? 'name'];
|
|
||||||
|
|
||||||
await column?.cellEvent?.['update:modelValue']?.(value, oldValue, row);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function destroyInput(rowIndex, field, clickedElement) {
|
|
||||||
if (!clickedElement)
|
if (!clickedElement)
|
||||||
clickedElement = document.querySelector(
|
clickedElement = document.querySelector(
|
||||||
`[data-row-index="${rowIndex}"][data-col-field="${field}"]`,
|
`[data-row-index="${rowIndex}"][data-col-field="${field}"]`,
|
||||||
);
|
);
|
||||||
if (clickedElement) {
|
if (clickedElement) {
|
||||||
await nextTick();
|
|
||||||
render(null, clickedElement);
|
render(null, clickedElement);
|
||||||
Array.from(clickedElement.childNodes).forEach((child) => {
|
Array.from(clickedElement.childNodes).forEach((child) => {
|
||||||
child.style.visibility = 'visible';
|
child.style.visibility = 'visible';
|
||||||
|
@ -509,6 +469,10 @@ async function destroyInput(rowIndex, field, clickedElement) {
|
||||||
editingField.value = null;
|
editingField.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleBlur(rowIndex, field, clickedElement) {
|
||||||
|
destroyInput(rowIndex, field, clickedElement);
|
||||||
|
}
|
||||||
|
|
||||||
async function handleTabNavigation(rowIndex, colName, direction) {
|
async function handleTabNavigation(rowIndex, colName, direction) {
|
||||||
const columns = $props.columns;
|
const columns = $props.columns;
|
||||||
const totalColumns = columns.length;
|
const totalColumns = columns.length;
|
||||||
|
@ -524,7 +488,9 @@ async function handleTabNavigation(rowIndex, colName, direction) {
|
||||||
if (isEditableColumn(columns[newColumnIndex])) break;
|
if (isEditableColumn(columns[newColumnIndex])) break;
|
||||||
} while (iterations < totalColumns);
|
} while (iterations < totalColumns);
|
||||||
|
|
||||||
if (iterations >= totalColumns + 1) return;
|
if (iterations >= totalColumns) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (direction === 1 && newColumnIndex <= currentColumnIndex) {
|
if (direction === 1 && newColumnIndex <= currentColumnIndex) {
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
|
@ -553,87 +519,31 @@ function getToggleIcon(value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatColumnValue(col, row, dashIfEmpty) {
|
function formatColumnValue(col, row, dashIfEmpty) {
|
||||||
if (col?.format || row[col?.name + 'VnTableTextValue']) {
|
if (col?.format) {
|
||||||
if (selectRegex.test(col?.component) && row[col?.name + 'VnTableTextValue']) {
|
if (selectRegex.test(col?.component) && row[col?.name + 'TextValue']) {
|
||||||
return dashIfEmpty(row[col?.name + 'VnTableTextValue']);
|
return dashIfEmpty(row[col?.name + 'TextValue']);
|
||||||
} else {
|
} else {
|
||||||
return col.format(row, dashIfEmpty);
|
return col.format(row, dashIfEmpty);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return dashIfEmpty(row[col?.name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (col?.component === 'date') return dashIfEmpty(toDate(row[col?.name]));
|
|
||||||
|
|
||||||
if (col?.component === 'time')
|
|
||||||
return row[col?.name] >= 5
|
|
||||||
? dashIfEmpty(date.formatDate(new Date(row[col?.name]), 'HH:mm'))
|
|
||||||
: row[col?.name];
|
|
||||||
|
|
||||||
if (selectRegex.test(col?.component) && $props.isEditable) {
|
|
||||||
const { find, url } = col.attrs;
|
|
||||||
const urlRelation = url?.charAt(0)?.toLocaleLowerCase() + url?.slice(1, -1);
|
|
||||||
|
|
||||||
if (col?.attrs.options) {
|
|
||||||
const find = col?.attrs.options.find((option) => option.id === row[col.name]);
|
|
||||||
if (!col.attrs?.optionLabel || !find) return dashIfEmpty(row[col?.name]);
|
|
||||||
return dashIfEmpty(find[col.attrs?.optionLabel ?? 'name']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof row[urlRelation] == 'object') {
|
|
||||||
if (typeof find == 'object')
|
|
||||||
return dashIfEmpty(row[urlRelation][find?.label ?? 'name']);
|
|
||||||
|
|
||||||
return dashIfEmpty(row[urlRelation][col?.attrs.optionLabel ?? 'name']);
|
|
||||||
}
|
|
||||||
if (typeof row[urlRelation] == 'string') return dashIfEmpty(row[urlRelation]);
|
|
||||||
}
|
|
||||||
return dashIfEmpty(row[col?.name]);
|
|
||||||
}
|
}
|
||||||
|
const checkbox = ref(null);
|
||||||
function cardClick(_, row) {
|
|
||||||
if ($props.redirect) router.push({ path: `/${$props.redirect}/${row.id}` });
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeTextValue(data, getChanges) {
|
|
||||||
let changes = data.updates;
|
|
||||||
if (changes) {
|
|
||||||
for (const change of changes) {
|
|
||||||
for (const key in change.data) {
|
|
||||||
if (key.endsWith('VnTableTextValue')) {
|
|
||||||
delete change.data[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data.updates = changes.filter((change) => Object.keys(change.data).length > 0);
|
|
||||||
}
|
|
||||||
if ($attrs?.beforeSaveFn) data = $attrs.beforeSaveFn(data, getChanges);
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleRowClick(event, row) {
|
|
||||||
if (event.ctrlKey) return rowCtrlClickFunction.value(event, row);
|
|
||||||
if (rowClickFunction.value) rowClickFunction.value(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
const rowCtrlClickFunction = computed(() => {
|
|
||||||
if ($props.rowCtrlClick != undefined) return $props.rowCtrlClick;
|
|
||||||
if ($props.redirect)
|
|
||||||
return (evt, { id }) => {
|
|
||||||
stopEventPropagation(evt);
|
|
||||||
window.open(`/#/${$props.redirect}/${id}`, '_blank');
|
|
||||||
};
|
|
||||||
return () => {};
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<RightMenu v-if="$props.rightSearch" :overlay="overlay">
|
<QDrawer
|
||||||
<template #right-panel>
|
v-if="$props.rightSearch"
|
||||||
|
v-model="stateStore.rightDrawer"
|
||||||
|
side="right"
|
||||||
|
:width="256"
|
||||||
|
:overlay="$props.overlay"
|
||||||
|
>
|
||||||
|
<QScrollArea class="fit">
|
||||||
<VnTableFilter
|
<VnTableFilter
|
||||||
:data-key="$attrs['data-key']"
|
:data-key="$attrs['data-key']"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:redirect="redirect"
|
:redirect="redirect"
|
||||||
v-bind="$attrs?.['table-filter']"
|
|
||||||
>
|
>
|
||||||
<template
|
<template
|
||||||
v-for="(_, slotName) in $slots"
|
v-for="(_, slotName) in $slots"
|
||||||
|
@ -643,8 +553,8 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
||||||
</template>
|
</template>
|
||||||
</VnTableFilter>
|
</VnTableFilter>
|
||||||
</template>
|
</QScrollArea>
|
||||||
</RightMenu>
|
</QDrawer>
|
||||||
<CrudModel
|
<CrudModel
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
:class="$attrs['class'] ?? 'q-px-md'"
|
:class="$attrs['class'] ?? 'q-px-md'"
|
||||||
|
@ -653,7 +563,6 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
@on-fetch="(...args) => emit('onFetch', ...args)"
|
@on-fetch="(...args) => emit('onFetch', ...args)"
|
||||||
:search-url="searchUrl"
|
:search-url="searchUrl"
|
||||||
:disable-infinite-scroll="isTableMode"
|
:disable-infinite-scroll="isTableMode"
|
||||||
:before-save-fn="removeTextValue"
|
|
||||||
@save-changes="reload"
|
@save-changes="reload"
|
||||||
:has-sub-toolbar="$props.hasSubToolbar ?? isEditable"
|
:has-sub-toolbar="$props.hasSubToolbar ?? isEditable"
|
||||||
:auto-load="hasParams || $attrs['auto-load']"
|
:auto-load="hasParams || $attrs['auto-load']"
|
||||||
|
@ -681,11 +590,9 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
:style="isTableMode && `max-height: ${tableHeight}`"
|
:style="isTableMode && `max-height: ${tableHeight}`"
|
||||||
:virtual-scroll="isTableMode"
|
:virtual-scroll="isTableMode"
|
||||||
@virtual-scroll="handleScroll"
|
@virtual-scroll="handleScroll"
|
||||||
@row-click="(event, row) => handleRowClick(event, row)"
|
@row-click="(_, row) => rowClickFunction && rowClickFunction(row)"
|
||||||
@update:selected="emit('update:selected', $event)"
|
@update:selected="emit('update:selected', $event)"
|
||||||
@selection="(details) => handleSelection(details, rows)"
|
@selection="(details) => handleSelection(details, rows)"
|
||||||
:hide-selected-banner="true"
|
|
||||||
:data-cy
|
|
||||||
>
|
>
|
||||||
<template #top-left v-if="!$props.withoutHeader">
|
<template #top-left v-if="!$props.withoutHeader">
|
||||||
<slot name="top-left"> </slot>
|
<slot name="top-left"> </slot>
|
||||||
|
@ -699,28 +606,34 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
:skip="columnsVisibilitySkipped"
|
:skip="columnsVisibilitySkipped"
|
||||||
/>
|
/>
|
||||||
<QBtnToggle
|
<QBtnToggle
|
||||||
v-if="!tableModes.some((mode) => mode.disable)"
|
|
||||||
v-model="mode"
|
v-model="mode"
|
||||||
toggle-color="primary"
|
toggle-color="primary"
|
||||||
class="bg-vn-section-color"
|
class="bg-vn-section-color"
|
||||||
dense
|
dense
|
||||||
:options="tableModes.filter((mode) => !mode.disable)"
|
:options="tableModes.filter((mode) => !mode.disable)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<QBtn
|
||||||
|
v-if="showRightIcon"
|
||||||
|
icon="filter_alt"
|
||||||
|
class="bg-vn-section-color q-ml-sm"
|
||||||
|
dense
|
||||||
|
@click="stateStore.toggleRightDrawer()"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #header-cell="{ col }">
|
<template #header-cell="{ col }">
|
||||||
<QTh
|
<QTh
|
||||||
v-if="col.visible ?? true"
|
v-if="col.visible ?? true"
|
||||||
v-bind:class="col.headerClass"
|
|
||||||
class="body-cell"
|
class="body-cell"
|
||||||
:style="col?.width ? `max-width: ${col?.width}` : ''"
|
:style="col?.width ? `max-width: ${col?.width}` : ''"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="no-padding"
|
class="no-padding"
|
||||||
:style="[
|
:style="
|
||||||
withFilters && $props.columnSearch ? 'height: 75px' : '',
|
withFilters && $props.columnSearch ? 'height: 75px' : ''
|
||||||
]"
|
"
|
||||||
>
|
>
|
||||||
<div style="height: 30px">
|
<div class="text-center" style="height: 30px">
|
||||||
<QTooltip v-if="col.toolTip">{{ col.toolTip }}</QTooltip>
|
<QTooltip v-if="col.toolTip">{{ col.toolTip }}</QTooltip>
|
||||||
<VnTableOrder
|
<VnTableOrder
|
||||||
v-model="orders[col.orderBy ?? col.name]"
|
v-model="orders[col.orderBy ?? col.name]"
|
||||||
|
@ -728,7 +641,6 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
:label="col?.labelAbbreviation ?? col?.label"
|
:label="col?.labelAbbreviation ?? col?.label"
|
||||||
:data-key="$attrs['data-key']"
|
:data-key="$attrs['data-key']"
|
||||||
:search-url="searchUrl"
|
:search-url="searchUrl"
|
||||||
:align="getColAlign(col)"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<VnFilter
|
<VnFilter
|
||||||
|
@ -742,7 +654,7 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
:data-key="$attrs['data-key']"
|
:data-key="$attrs['data-key']"
|
||||||
v-model="params[columnName(col)]"
|
v-model="params[columnName(col)]"
|
||||||
:search-url="searchUrl"
|
:search-url="searchUrl"
|
||||||
customClass="header-filter"
|
class="full-width"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</QTh>
|
</QTh>
|
||||||
|
@ -776,13 +688,12 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
:data-col-field="col?.name"
|
:data-col-field="col?.name"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="no-padding no-margin"
|
class="no-padding no-margin peter"
|
||||||
style="
|
style="
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
"
|
"
|
||||||
:data-cy="`vnTableCell_${col.name}`"
|
|
||||||
>
|
>
|
||||||
<slot
|
<slot
|
||||||
:name="`column-${col.name}`"
|
:name="`column-${col.name}`"
|
||||||
|
@ -811,11 +722,7 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
<span
|
<span
|
||||||
v-else
|
v-else
|
||||||
:class="hasEditableFormat(col)"
|
:class="hasEditableFormat(col)"
|
||||||
:style="
|
:style="col?.style ? col.style(row) : null"
|
||||||
typeof col?.style == 'function'
|
|
||||||
? col.style(row)
|
|
||||||
: col?.style
|
|
||||||
"
|
|
||||||
style="bottom: 0"
|
style="bottom: 0"
|
||||||
>
|
>
|
||||||
{{ formatColumnValue(col, row, dashIfEmpty) }}
|
{{ formatColumnValue(col, row, dashIfEmpty) }}
|
||||||
|
@ -842,7 +749,7 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
flat
|
flat
|
||||||
dense
|
dense
|
||||||
:class="
|
:class="
|
||||||
btn.isPrimary ? 'text-primary-light' : 'color-vn-label'
|
btn.isPrimary ? 'text-primary-light' : 'color-vn-text '
|
||||||
"
|
"
|
||||||
:style="`visibility: ${
|
:style="`visibility: ${
|
||||||
((btn.show && btn.show(row)) ?? true)
|
((btn.show && btn.show(row)) ?? true)
|
||||||
|
@ -850,19 +757,23 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
: 'hidden'
|
: 'hidden'
|
||||||
}`"
|
}`"
|
||||||
@click="btn.action(row)"
|
@click="btn.action(row)"
|
||||||
:data-cy="btn?.name ?? `tableAction-${index}`"
|
|
||||||
/>
|
/>
|
||||||
</QTd>
|
</QTd>
|
||||||
</template>
|
</template>
|
||||||
<template #item="{ row, colsMap }">
|
<template #item="{ row, colsMap }">
|
||||||
<component
|
<component
|
||||||
v-bind:is="'div'"
|
:is="$props.redirect ? 'router-link' : 'span'"
|
||||||
@click="(event) => cardClick(event, row)"
|
:to="`/${$props.redirect}/` + row.id"
|
||||||
>
|
>
|
||||||
<QCard
|
<QCard
|
||||||
bordered
|
bordered
|
||||||
flat
|
flat
|
||||||
class="row no-wrap justify-between cursor-pointer q-pa-sm"
|
class="row no-wrap justify-between cursor-pointer q-pa-sm"
|
||||||
|
@click="
|
||||||
|
(_, row) => {
|
||||||
|
$props.rowClick && $props.rowClick(row);
|
||||||
|
}
|
||||||
|
"
|
||||||
style="height: 100%"
|
style="height: 100%"
|
||||||
>
|
>
|
||||||
<QCardSection
|
<QCardSection
|
||||||
|
@ -897,9 +808,9 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
{{ row[splittedColumns.title.name] }}
|
{{ row[splittedColumns.title.name] }}
|
||||||
</span>
|
</span>
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<!-- Fields -->
|
<!-- Fields -->
|
||||||
<QCardSection
|
<QCardSection
|
||||||
class="q-pl-sm q-py-xs"
|
class="q-pl-sm q-pr-lg q-py-xs"
|
||||||
:class="$props.cardClass"
|
:class="$props.cardClass"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
@ -921,24 +832,12 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
:row-index="index"
|
:row-index="index"
|
||||||
>
|
>
|
||||||
<VnColumn
|
<VnColumn
|
||||||
:column="{
|
:column="col"
|
||||||
...col,
|
|
||||||
disable:
|
|
||||||
col?.component ===
|
|
||||||
'checkbox'
|
|
||||||
? true
|
|
||||||
: false,
|
|
||||||
}"
|
|
||||||
:row="row"
|
:row="row"
|
||||||
:is-editable="false"
|
:is-editable="false"
|
||||||
v-model="row[col.name]"
|
v-model="row[col.name]"
|
||||||
component-prop="columnField"
|
component-prop="columnField"
|
||||||
:show-label="
|
:show-label="true"
|
||||||
col?.component ===
|
|
||||||
'checkbox'
|
|
||||||
? false
|
|
||||||
: true
|
|
||||||
"
|
|
||||||
/>
|
/>
|
||||||
</slot>
|
</slot>
|
||||||
</span>
|
</span>
|
||||||
|
@ -958,14 +857,13 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
:key="index"
|
:key="index"
|
||||||
:title="btn.title"
|
:title="btn.title"
|
||||||
:icon="btn.icon"
|
:icon="btn.icon"
|
||||||
data-cy="cardBtn"
|
|
||||||
class="q-pa-xs"
|
class="q-pa-xs"
|
||||||
|
flat
|
||||||
:class="
|
:class="
|
||||||
btn.isPrimary
|
btn.isPrimary
|
||||||
? 'text-primary-light'
|
? 'text-primary-light'
|
||||||
: 'color-vn-label'
|
: 'color-vn-text '
|
||||||
"
|
"
|
||||||
flat
|
|
||||||
@click="btn.action(row)"
|
@click="btn.action(row)"
|
||||||
/>
|
/>
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
|
@ -979,8 +877,6 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
v-for="col of cols.filter((cols) => cols.visible ?? true)"
|
v-for="col of cols.filter((cols) => cols.visible ?? true)"
|
||||||
:key="col?.id"
|
:key="col?.id"
|
||||||
:class="getColAlign(col)"
|
:class="getColAlign(col)"
|
||||||
:style="col?.width ? `max-width: ${col?.width}` : ''"
|
|
||||||
style="font-size: small"
|
|
||||||
>
|
>
|
||||||
<slot
|
<slot
|
||||||
:name="`column-footer-${col.name}`"
|
:name="`column-footer-${col.name}`"
|
||||||
|
@ -1034,6 +930,14 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
transition-show="scale"
|
transition-show="scale"
|
||||||
transition-hide="scale"
|
transition-hide="scale"
|
||||||
:full-width="createComplement?.isFullWidth ?? false"
|
:full-width="createComplement?.isFullWidth ?? false"
|
||||||
|
@before-hide="
|
||||||
|
() => {
|
||||||
|
if (createRef.isSaveAndContinue) {
|
||||||
|
showForm = true;
|
||||||
|
createForm.formInitialData = { ...create.formInitialData };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"
|
||||||
data-cy="vn-table-create-dialog"
|
data-cy="vn-table-create-dialog"
|
||||||
>
|
>
|
||||||
<FormModelPopup
|
<FormModelPopup
|
||||||
|
@ -1043,43 +947,32 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
@on-data-saved="(_, res) => createForm.onDataSaved(res)"
|
@on-data-saved="(_, res) => createForm.onDataSaved(res)"
|
||||||
>
|
>
|
||||||
<template #form-inputs="{ data }">
|
<template #form-inputs="{ data }">
|
||||||
<slot name="alter-create" :data="data">
|
<div :style="createComplement?.containerStyle">
|
||||||
<div :style="createComplement?.containerStyle">
|
<div>
|
||||||
<div
|
<slot name="previous-create-dialog" :data="data" />
|
||||||
:style="createComplement?.previousStyle"
|
|
||||||
v-if="!quasar.screen.xs"
|
|
||||||
>
|
|
||||||
<slot name="previous-create-dialog" :data="data" />
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="grid-create"
|
|
||||||
:style="createComplement?.columnGridStyle"
|
|
||||||
>
|
|
||||||
<slot
|
|
||||||
v-for="column of splittedColumns.create"
|
|
||||||
:key="column.name"
|
|
||||||
:name="`column-create-${column.name}`"
|
|
||||||
:data="data"
|
|
||||||
:column-name="column.name"
|
|
||||||
:label="column.label"
|
|
||||||
>
|
|
||||||
<VnColumn
|
|
||||||
:column="{
|
|
||||||
...column,
|
|
||||||
...column?.createAttrs,
|
|
||||||
}"
|
|
||||||
:row="{}"
|
|
||||||
default="input"
|
|
||||||
v-model="data[column.name]"
|
|
||||||
:show-label="true"
|
|
||||||
component-prop="columnCreate"
|
|
||||||
:data-cy="`${column.name}-create-popup`"
|
|
||||||
/>
|
|
||||||
</slot>
|
|
||||||
<slot name="more-create-dialog" :data="data" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</slot>
|
<div class="grid-create" :style="createComplement?.columnGridStyle">
|
||||||
|
<slot
|
||||||
|
v-for="column of splittedColumns.create"
|
||||||
|
:key="column.name"
|
||||||
|
:name="`column-create-${column.name}`"
|
||||||
|
:data="data"
|
||||||
|
:column-name="column.name"
|
||||||
|
:label="column.label"
|
||||||
|
>
|
||||||
|
<VnColumn
|
||||||
|
:column="column"
|
||||||
|
:row="{}"
|
||||||
|
default="input"
|
||||||
|
v-model="data[column.name]"
|
||||||
|
:show-label="true"
|
||||||
|
component-prop="columnCreate"
|
||||||
|
:data-cy="`${column.name}-create-popup`"
|
||||||
|
/>
|
||||||
|
</slot>
|
||||||
|
<slot name="more-create-dialog" :data="data" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</FormModelPopup>
|
</FormModelPopup>
|
||||||
</QDialog>
|
</QDialog>
|
||||||
|
@ -1128,8 +1021,8 @@ es:
|
||||||
}
|
}
|
||||||
|
|
||||||
.body-cell {
|
.body-cell {
|
||||||
padding-left: 4px !important;
|
padding-left: 2px !important;
|
||||||
padding-right: 4px !important;
|
padding-right: 2px !important;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
.bg-chip-secondary {
|
.bg-chip-secondary {
|
||||||
|
@ -1148,8 +1041,8 @@ es:
|
||||||
|
|
||||||
.grid-three {
|
.grid-three {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(300px, max-content));
|
grid-template-columns: repeat(auto-fit, minmax(150px, max-content));
|
||||||
width: 100%;
|
max-width: 100%;
|
||||||
grid-gap: 20px;
|
grid-gap: 20px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
@ -1157,12 +1050,8 @@ es:
|
||||||
.grid-create {
|
.grid-create {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(150px, max-content));
|
grid-template-columns: repeat(auto-fit, minmax(150px, max-content));
|
||||||
max-width: 100%;
|
|
||||||
grid-gap: 20px;
|
grid-gap: 20px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
.col-span-2 {
|
|
||||||
grid-column: span 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.flex-one {
|
.flex-one {
|
||||||
|
@ -1227,7 +1116,6 @@ es:
|
||||||
.vn-label-value {
|
.vn-label-value {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
|
||||||
color: var(--vn-text-color);
|
color: var(--vn-text-color);
|
||||||
.value {
|
.value {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
@ -1286,8 +1174,4 @@ es:
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
label.header-filter > .q-field__inner > .q-field__control {
|
|
||||||
padding: inherit;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -26,12 +26,7 @@ function columnName(col) {
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VnFilterPanel
|
<VnFilterPanel v-bind="$attrs" :search-button="true" :disable-submit-event="true">
|
||||||
v-bind="$attrs"
|
|
||||||
:search-button="true"
|
|
||||||
:disable-submit-event="true"
|
|
||||||
:search-url
|
|
||||||
>
|
|
||||||
<template #body="{ params, orders, searchFn }">
|
<template #body="{ params, orders, searchFn }">
|
||||||
<div
|
<div
|
||||||
class="container"
|
class="container"
|
||||||
|
@ -39,20 +34,13 @@ function columnName(col) {
|
||||||
:key="col.id"
|
:key="col.id"
|
||||||
>
|
>
|
||||||
<div class="filter">
|
<div class="filter">
|
||||||
<slot
|
<VnFilter
|
||||||
:name="`filter-${col.name}`"
|
ref="tableFilterRef"
|
||||||
:params="params"
|
:column="col"
|
||||||
:column-name="columnName(col)"
|
:data-key="$attrs['data-key']"
|
||||||
:search-fn
|
v-model="params[columnName(col)]"
|
||||||
>
|
:search-url="searchUrl"
|
||||||
<VnFilter
|
/>
|
||||||
ref="tableFilterRef"
|
|
||||||
:column="col"
|
|
||||||
:data-key="$attrs['data-key']"
|
|
||||||
v-model="params[columnName(col)]"
|
|
||||||
:search-url="searchUrl"
|
|
||||||
/>
|
|
||||||
</slot>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="order">
|
<div class="order">
|
||||||
<VnTableOrder
|
<VnTableOrder
|
||||||
|
@ -89,13 +77,13 @@ function columnName(col) {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
min-height: 45px;
|
height: 45px;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter {
|
.filter {
|
||||||
width: 70%;
|
width: 70%;
|
||||||
min-height: 40px;
|
height: 40px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.order {
|
.order {
|
||||||
|
|
|
@ -27,58 +27,30 @@ describe('VnTable', () => {
|
||||||
beforeEach(() => (vm.selected = []));
|
beforeEach(() => (vm.selected = []));
|
||||||
|
|
||||||
describe('handleSelection()', () => {
|
describe('handleSelection()', () => {
|
||||||
const rows = [
|
const rows = [{ $index: 0 }, { $index: 1 }, { $index: 2 }];
|
||||||
{ $index: 0 },
|
const selectedRows = [{ $index: 1 }];
|
||||||
{ $index: 1 },
|
it('should add rows to selected when shift key is pressed and rows are added except last one', () => {
|
||||||
{ $index: 2 },
|
|
||||||
{ $index: 3 },
|
|
||||||
{ $index: 4 },
|
|
||||||
];
|
|
||||||
|
|
||||||
it('should add rows to selected when shift key is pressed and rows are added in ascending order', () => {
|
|
||||||
const selectedRows = [{ $index: 1 }];
|
|
||||||
vm.handleSelection(
|
vm.handleSelection(
|
||||||
{ evt: { shiftKey: true }, added: true, rows: selectedRows },
|
{ evt: { shiftKey: true }, added: true, rows: selectedRows },
|
||||||
rows,
|
rows
|
||||||
);
|
);
|
||||||
expect(vm.selected).toEqual([{ $index: 0 }]);
|
expect(vm.selected).toEqual([{ $index: 0 }]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add rows to selected when shift key is pressed and rows are added in descending order', () => {
|
|
||||||
const selectedRows = [{ $index: 3 }];
|
|
||||||
vm.handleSelection(
|
|
||||||
{ evt: { shiftKey: true }, added: true, rows: selectedRows },
|
|
||||||
rows,
|
|
||||||
);
|
|
||||||
expect(vm.selected).toEqual([{ $index: 0 }, { $index: 1 }, { $index: 2 }]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not add rows to selected when shift key is not pressed', () => {
|
it('should not add rows to selected when shift key is not pressed', () => {
|
||||||
const selectedRows = [{ $index: 1 }];
|
|
||||||
vm.handleSelection(
|
vm.handleSelection(
|
||||||
{ evt: { shiftKey: false }, added: true, rows: selectedRows },
|
{ evt: { shiftKey: false }, added: true, rows: selectedRows },
|
||||||
rows,
|
rows
|
||||||
);
|
);
|
||||||
expect(vm.selected).toEqual([]);
|
expect(vm.selected).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not add rows to selected when rows are not added', () => {
|
it('should not add rows to selected when rows are not added', () => {
|
||||||
const selectedRows = [{ $index: 1 }];
|
|
||||||
vm.handleSelection(
|
vm.handleSelection(
|
||||||
{ evt: { shiftKey: true }, added: false, rows: selectedRows },
|
{ evt: { shiftKey: true }, added: false, rows: selectedRows },
|
||||||
rows,
|
rows
|
||||||
);
|
);
|
||||||
expect(vm.selected).toEqual([]);
|
expect(vm.selected).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add all rows between the smallest and largest selected indexes', () => {
|
|
||||||
vm.selected = [{ $index: 1 }, { $index: 3 }];
|
|
||||||
const selectedRows = [{ $index: 4 }];
|
|
||||||
vm.handleSelection(
|
|
||||||
{ evt: { shiftKey: true }, added: true, rows: selectedRows },
|
|
||||||
rows,
|
|
||||||
);
|
|
||||||
expect(vm.selected).toEqual([{ $index: 1 }, { $index: 3 }, { $index: 2 }]);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,8 +30,8 @@ describe('CrudModel', () => {
|
||||||
saveFn: '',
|
saveFn: '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
wrapper = wrapper.wrapper;
|
wrapper=wrapper.wrapper;
|
||||||
vm = wrapper.vm;
|
vm=wrapper.vm;
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -143,14 +143,14 @@ describe('CrudModel', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true if object is empty', async () => {
|
it('should return true if object is empty', async () => {
|
||||||
dummyObj = {};
|
dummyObj ={};
|
||||||
result = vm.isEmpty(dummyObj);
|
result = vm.isEmpty(dummyObj);
|
||||||
|
|
||||||
expect(result).toBe(true);
|
expect(result).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false if object is not empty', async () => {
|
it('should return false if object is not empty', async () => {
|
||||||
dummyObj = { a: 1, b: 2, c: 3 };
|
dummyObj = {a:1, b:2, c:3};
|
||||||
result = vm.isEmpty(dummyObj);
|
result = vm.isEmpty(dummyObj);
|
||||||
|
|
||||||
expect(result).toBe(false);
|
expect(result).toBe(false);
|
||||||
|
@ -158,31 +158,29 @@ describe('CrudModel', () => {
|
||||||
|
|
||||||
it('should return true if array is empty', async () => {
|
it('should return true if array is empty', async () => {
|
||||||
dummyArray = [];
|
dummyArray = [];
|
||||||
result = vm.isEmpty(dummyArray);
|
result = vm.isEmpty(dummyArray);
|
||||||
|
|
||||||
expect(result).toBe(true);
|
expect(result).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false if array is not empty', async () => {
|
it('should return false if array is not empty', async () => {
|
||||||
dummyArray = [1, 2, 3];
|
dummyArray = [1,2,3];
|
||||||
result = vm.isEmpty(dummyArray);
|
result = vm.isEmpty(dummyArray);
|
||||||
|
|
||||||
expect(result).toBe(false);
|
expect(result).toBe(false);
|
||||||
});
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('resetData()', () => {
|
describe('resetData()', () => {
|
||||||
it('should add $index to elements in data[] and sets originalData and formData with data', async () => {
|
it('should add $index to elements in data[] and sets originalData and formData with data', async () => {
|
||||||
data = [
|
data = [{
|
||||||
{
|
name: 'Tony',
|
||||||
name: 'Tony',
|
lastName: 'Stark',
|
||||||
lastName: 'Stark',
|
age: 42,
|
||||||
age: 42,
|
}];
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
vm.resetData(data);
|
vm.resetData(data);
|
||||||
|
|
||||||
expect(vm.originalData).toEqual(data);
|
expect(vm.originalData).toEqual(data);
|
||||||
expect(vm.originalData[0].$index).toEqual(0);
|
expect(vm.originalData[0].$index).toEqual(0);
|
||||||
expect(vm.formData).toEqual(data);
|
expect(vm.formData).toEqual(data);
|
||||||
|
@ -202,7 +200,7 @@ describe('CrudModel', () => {
|
||||||
lastName: 'Stark',
|
lastName: 'Stark',
|
||||||
age: 42,
|
age: 42,
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.resetData(data);
|
vm.resetData(data);
|
||||||
|
|
||||||
expect(vm.originalData).toEqual(data);
|
expect(vm.originalData).toEqual(data);
|
||||||
|
@ -212,19 +210,17 @@ describe('CrudModel', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('saveChanges()', () => {
|
describe('saveChanges()', () => {
|
||||||
data = [
|
data = [{
|
||||||
{
|
name: 'Tony',
|
||||||
name: 'Tony',
|
lastName: 'Stark',
|
||||||
lastName: 'Stark',
|
age: 42,
|
||||||
age: 42,
|
}];
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
it('should call saveFn if exists', async () => {
|
it('should call saveFn if exists', async () => {
|
||||||
await wrapper.setProps({ saveFn: vi.fn() });
|
await wrapper.setProps({ saveFn: vi.fn() });
|
||||||
|
|
||||||
vm.saveChanges(data);
|
vm.saveChanges(data);
|
||||||
|
|
||||||
expect(vm.saveFn).toHaveBeenCalledOnce();
|
expect(vm.saveFn).toHaveBeenCalledOnce();
|
||||||
expect(vm.isLoading).toBe(false);
|
expect(vm.isLoading).toBe(false);
|
||||||
expect(vm.hasChanges).toBe(false);
|
expect(vm.hasChanges).toBe(false);
|
||||||
|
@ -233,15 +229,13 @@ describe('CrudModel', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should use default url if there's not saveFn", async () => {
|
it("should use default url if there's not saveFn", async () => {
|
||||||
const postMock = vi.spyOn(axios, 'post');
|
const postMock =vi.spyOn(axios, 'post');
|
||||||
|
|
||||||
vm.formData = [
|
vm.formData = [{
|
||||||
{
|
name: 'Bruce',
|
||||||
name: 'Bruce',
|
lastName: 'Wayne',
|
||||||
lastName: 'Wayne',
|
age: 45,
|
||||||
age: 45,
|
}]
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
await vm.saveChanges(data);
|
await vm.saveChanges(data);
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@ describe('FormModel', () => {
|
||||||
vm.state.set(model, formInitialData);
|
vm.state.set(model, formInitialData);
|
||||||
expect(vm.hasChanges).toBe(false);
|
expect(vm.hasChanges).toBe(false);
|
||||||
|
|
||||||
await vm.$nextTick();
|
|
||||||
vm.formData.mockKey = 'newVal';
|
vm.formData.mockKey = 'newVal';
|
||||||
await vm.$nextTick();
|
await vm.$nextTick();
|
||||||
expect(vm.hasChanges).toBe(true);
|
expect(vm.hasChanges).toBe(true);
|
||||||
|
@ -95,12 +94,8 @@ describe('FormModel', () => {
|
||||||
it('should call axios.patch with the right data', async () => {
|
it('should call axios.patch with the right data', async () => {
|
||||||
const spy = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
const spy = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
||||||
const { vm } = mount({ propsData: { url, model } });
|
const { vm } = mount({ propsData: { url, model } });
|
||||||
|
vm.formData.mockKey = 'newVal';
|
||||||
vm.formData = {};
|
|
||||||
await vm.$nextTick();
|
await vm.$nextTick();
|
||||||
vm.formData = { mockKey: 'newVal' };
|
|
||||||
await vm.$nextTick();
|
|
||||||
|
|
||||||
await vm.save();
|
await vm.save();
|
||||||
expect(spy).toHaveBeenCalled();
|
expect(spy).toHaveBeenCalled();
|
||||||
vm.formData.mockKey = 'mockVal';
|
vm.formData.mockKey = 'mockVal';
|
||||||
|
|
|
@ -15,7 +15,10 @@ vi.mock('src/router/modules', () => ({
|
||||||
meta: {
|
meta: {
|
||||||
title: 'customers',
|
title: 'customers',
|
||||||
icon: 'vn:client',
|
icon: 'vn:client',
|
||||||
menu: ['CustomerList', 'CustomerCreate'],
|
},
|
||||||
|
menus: {
|
||||||
|
main: ['CustomerList', 'CustomerCreate'],
|
||||||
|
card: ['CustomerBasicData'],
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
@ -47,6 +50,14 @@ vi.mock('src/router/modules', () => ({
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'create',
|
||||||
|
name: 'CustomerCreate',
|
||||||
|
meta: {
|
||||||
|
title: 'createCustomer',
|
||||||
|
icon: 'vn:addperson',
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -87,7 +98,7 @@ vi.spyOn(vueRouter, 'useRoute').mockReturnValue({
|
||||||
icon: 'vn:client',
|
icon: 'vn:client',
|
||||||
moduleName: 'Customer',
|
moduleName: 'Customer',
|
||||||
keyBinding: 'c',
|
keyBinding: 'c',
|
||||||
menu: ['customer'],
|
menu: 'customer',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -249,6 +260,15 @@ describe('Leftmenu as main', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle a single matched route with a menu', () => {
|
||||||
|
const route = {
|
||||||
|
matched: [{ meta: { menu: 'customer' } }],
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = vm.betaGetRoutes();
|
||||||
|
|
||||||
|
expect(result.meta.menu).toEqual(route.matched[0].meta.menu);
|
||||||
|
});
|
||||||
it('should get routes for main source', () => {
|
it('should get routes for main source', () => {
|
||||||
vm.props.source = 'main';
|
vm.props.source = 'main';
|
||||||
vm.getRoutes();
|
vm.getRoutes();
|
||||||
|
@ -331,9 +351,8 @@ describe('addChildren', () => {
|
||||||
|
|
||||||
it('should handle routes with no meta menu', () => {
|
it('should handle routes with no meta menu', () => {
|
||||||
const route = {
|
const route = {
|
||||||
meta: {
|
meta: {},
|
||||||
menu: [],
|
menus: {},
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const parent = [];
|
const parent = [];
|
||||||
|
|
|
@ -1,65 +1,61 @@
|
||||||
import { vi, describe, expect, it, beforeEach, afterEach } from 'vitest';
|
import { vi, describe, expect, it, beforeEach, beforeAll, afterEach } from 'vitest';
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import UserPanel from 'src/components/UserPanel.vue';
|
import UserPanel from 'src/components/UserPanel.vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
|
|
||||||
vi.mock('src/utils/quasarLang', () => ({
|
|
||||||
default: vi.fn(),
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('UserPanel', () => {
|
describe('UserPanel', () => {
|
||||||
let wrapper;
|
let wrapper;
|
||||||
let vm;
|
let vm;
|
||||||
let state;
|
let state;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
wrapper = createWrapper(UserPanel, {});
|
wrapper = createWrapper(UserPanel, {});
|
||||||
state = useState();
|
state = useState();
|
||||||
state.setUser({
|
state.setUser({
|
||||||
id: 115,
|
id: 115,
|
||||||
name: 'itmanagement',
|
name: 'itmanagement',
|
||||||
nickname: 'itManagementNick',
|
nickname: 'itManagementNick',
|
||||||
lang: 'en',
|
lang: 'en',
|
||||||
darkMode: false,
|
darkMode: false,
|
||||||
companyFk: 442,
|
companyFk: 442,
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
|
});
|
||||||
|
wrapper = wrapper.wrapper;
|
||||||
|
vm = wrapper.vm;
|
||||||
});
|
});
|
||||||
wrapper = wrapper.wrapper;
|
|
||||||
vm = wrapper.vm;
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch warehouses data on mounted', async () => {
|
it('should fetch warehouses data on mounted', async () => {
|
||||||
const fetchData = wrapper.findComponent({ name: 'FetchData' });
|
const fetchData = wrapper.findComponent({ name: 'FetchData' });
|
||||||
expect(fetchData.props('url')).toBe('Warehouses');
|
expect(fetchData.props('url')).toBe('Warehouses');
|
||||||
expect(fetchData.props('autoLoad')).toBe(true);
|
expect(fetchData.props('autoLoad')).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should toggle dark mode correctly and update preferences', async () => {
|
it('should toggle dark mode correctly and update preferences', async () => {
|
||||||
await vm.saveDarkMode(true);
|
await vm.saveDarkMode(true);
|
||||||
expect(axios.patch).toHaveBeenCalledWith('/UserConfigs/115', { darkMode: true });
|
expect(axios.patch).toHaveBeenCalledWith('/UserConfigs/115', { darkMode: true });
|
||||||
expect(vm.user.darkMode).toBe(true);
|
expect(vm.user.darkMode).toBe(true);
|
||||||
await vm.updatePreferences();
|
vm.updatePreferences();
|
||||||
expect(vm.darkMode).toBe(true);
|
expect(vm.darkMode).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change user language and update preferences', async () => {
|
it('should change user language and update preferences', async () => {
|
||||||
const userLanguage = 'es';
|
const userLanguage = 'es';
|
||||||
await vm.saveLanguage(userLanguage);
|
await vm.saveLanguage(userLanguage);
|
||||||
expect(axios.patch).toHaveBeenCalledWith('/VnUsers/115', { lang: userLanguage });
|
expect(axios.patch).toHaveBeenCalledWith('/VnUsers/115', { lang: userLanguage });
|
||||||
expect(vm.user.lang).toBe(userLanguage);
|
expect(vm.user.lang).toBe(userLanguage);
|
||||||
await vm.updatePreferences();
|
vm.updatePreferences();
|
||||||
expect(vm.locale).toBe(userLanguage);
|
expect(vm.locale).toBe(userLanguage);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update user data', async () => {
|
it('should update user data', async () => {
|
||||||
const key = 'name';
|
const key = 'name';
|
||||||
const value = 'itboss';
|
const value = 'itboss';
|
||||||
await vm.saveUserData(key, value);
|
await vm.saveUserData(key, value);
|
||||||
expect(axios.post).toHaveBeenCalledWith('UserConfigs/setUserConfig', { [key]: value });
|
expect(axios.post).toHaveBeenCalledWith('UserConfigs/setUserConfig', { [key]: value });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,13 +11,6 @@ const stateStore = useStateStore();
|
||||||
const slots = useSlots();
|
const slots = useSlots();
|
||||||
const hasContent = useHasContent('#right-panel');
|
const hasContent = useHasContent('#right-panel');
|
||||||
|
|
||||||
defineProps({
|
|
||||||
overlay: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if ((!slots['right-panel'] && !hasContent.value) || quasar.platform.is.mobile)
|
if ((!slots['right-panel'] && !hasContent.value) || quasar.platform.is.mobile)
|
||||||
stateStore.rightDrawer = false;
|
stateStore.rightDrawer = false;
|
||||||
|
@ -41,12 +34,7 @@ onMounted(() => {
|
||||||
</QBtn>
|
</QBtn>
|
||||||
</div>
|
</div>
|
||||||
</Teleport>
|
</Teleport>
|
||||||
<QDrawer
|
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256">
|
||||||
v-model="stateStore.rightDrawer"
|
|
||||||
side="right"
|
|
||||||
:width="256"
|
|
||||||
:overlay="overlay"
|
|
||||||
>
|
|
||||||
<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" />
|
||||||
|
|
|
@ -56,12 +56,7 @@ async function confirm() {
|
||||||
{{ t('The notification will be sent to the following address') }}
|
{{ t('The notification will be sent to the following address') }}
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<QCardSection class="q-pt-none">
|
<QCardSection class="q-pt-none">
|
||||||
<VnInput
|
<VnInput v-model="address" is-outlined autofocus />
|
||||||
v-model="address"
|
|
||||||
is-outlined
|
|
||||||
autofocus
|
|
||||||
data-cy="SendEmailNotifiactionDialogInput"
|
|
||||||
/>
|
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<QCardActions align="right">
|
<QCardActions align="right">
|
||||||
<QBtn :label="t('globals.cancel')" color="primary" flat v-close-popup />
|
<QBtn :label="t('globals.cancel')" color="primary" flat v-close-popup />
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useDialogPluginComponent } from 'quasar';
|
import {useDialogPluginComponent} from 'quasar';
|
||||||
import { useI18n } from 'vue-i18n';
|
import {useI18n} from 'vue-i18n';
|
||||||
import { computed, ref } from 'vue';
|
import {computed, ref} from 'vue';
|
||||||
import VnInput from 'components/common/VnInput.vue';
|
import VnInput from 'components/common/VnInput.vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import useNotify from 'composables/useNotify';
|
import useNotify from "composables/useNotify";
|
||||||
|
|
||||||
const MESSAGE_MAX_LENGTH = 160;
|
const MESSAGE_MAX_LENGTH = 160;
|
||||||
|
|
||||||
const { t } = useI18n();
|
const {t} = useI18n();
|
||||||
const { notify } = useNotify();
|
const {notify} = useNotify();
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
title: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -34,7 +34,7 @@ const props = defineProps({
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits([...useDialogPluginComponent.emits, 'sent']);
|
const emit = defineEmits([...useDialogPluginComponent.emits, 'sent']);
|
||||||
const { dialogRef, onDialogHide } = useDialogPluginComponent();
|
const {dialogRef, onDialogHide} = useDialogPluginComponent();
|
||||||
|
|
||||||
const smsRules = [
|
const smsRules = [
|
||||||
(val) => (val && val.length > 0) || t("The message can't be empty"),
|
(val) => (val && val.length > 0) || t("The message can't be empty"),
|
||||||
|
@ -43,10 +43,10 @@ const smsRules = [
|
||||||
t("The message it's too long"),
|
t("The message it's too long"),
|
||||||
];
|
];
|
||||||
|
|
||||||
const message = ref(t('routeDelay'));
|
const message = ref('');
|
||||||
|
|
||||||
const charactersRemaining = computed(
|
const charactersRemaining = computed(
|
||||||
() => MESSAGE_MAX_LENGTH - new Blob([message.value]).size,
|
() => MESSAGE_MAX_LENGTH - new Blob([message.value]).size
|
||||||
);
|
);
|
||||||
|
|
||||||
const charactersChipColor = computed(() => {
|
const charactersChipColor = computed(() => {
|
||||||
|
@ -114,7 +114,7 @@ const onSubmit = async () => {
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{
|
{{
|
||||||
t(
|
t(
|
||||||
'Special characters like accents counts as a multiple',
|
'Special characters like accents counts as a multiple'
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
|
@ -144,10 +144,7 @@ const onSubmit = async () => {
|
||||||
max-width: 450px;
|
max-width: 450px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
en:
|
|
||||||
routeDelay: "Your order has been delayed in transit.\nDelivery will take place throughout the day.\nWe apologize for the inconvenience and appreciate your patience."
|
|
||||||
es:
|
es:
|
||||||
Message: Mensaje
|
Message: Mensaje
|
||||||
Send: Enviar
|
Send: Enviar
|
||||||
|
@ -156,5 +153,4 @@ es:
|
||||||
The destination can't be empty: El destinatario no puede estar vacio
|
The destination can't be empty: El destinatario no puede estar vacio
|
||||||
The message can't be empty: El mensaje no puede estar vacio
|
The message can't be empty: El mensaje no puede estar vacio
|
||||||
The message it's too long: El mensaje es demasiado largo
|
The message it's too long: El mensaje es demasiado largo
|
||||||
routeDelay: "Retraso en ruta.\nInformamos que la ruta que lleva su pedido ha sufrido un retraso y la entrega se hará a lo largo del día.\nDisculpe las molestias."
|
</i18n>
|
||||||
</i18n>
|
|
||||||
|
|
|
@ -1,14 +1,83 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import VnInput from './VnInput.vue';
|
import { nextTick, ref, watch } from 'vue';
|
||||||
import { useAccountShortToStandard } from 'src/composables/useAccountShortToStandard';
|
import { QInput } from 'quasar';
|
||||||
|
|
||||||
const model = defineModel({ prop: 'modelValue' });
|
const $props = defineProps({
|
||||||
|
modelValue: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
insertable: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['update:modelValue', 'accountShortToStandard']);
|
||||||
|
|
||||||
|
let internalValue = ref($props.modelValue);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => $props.modelValue,
|
||||||
|
(newVal) => {
|
||||||
|
internalValue.value = newVal;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => internalValue.value,
|
||||||
|
(newVal) => {
|
||||||
|
emit('update:modelValue', newVal);
|
||||||
|
accountShortToStandard();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleKeydown = (e) => {
|
||||||
|
if (e.key === 'Backspace') return;
|
||||||
|
if (e.key === '.') {
|
||||||
|
accountShortToStandard();
|
||||||
|
// TODO: Fix this setTimeout, with nextTick doesn't work
|
||||||
|
setTimeout(() => {
|
||||||
|
setCursorPosition(0, e.target);
|
||||||
|
}, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($props.insertable && e.key.match(/[0-9]/)) {
|
||||||
|
handleInsertMode(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
function setCursorPosition(pos, el = vnInputRef.value) {
|
||||||
|
el.focus();
|
||||||
|
el.setSelectionRange(pos, pos);
|
||||||
|
}
|
||||||
|
const vnInputRef = ref(false);
|
||||||
|
const handleInsertMode = (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const input = e.target;
|
||||||
|
const cursorPos = input.selectionStart;
|
||||||
|
const { maxlength } = vnInputRef.value;
|
||||||
|
let currentValue = internalValue.value;
|
||||||
|
if (!currentValue) currentValue = e.key;
|
||||||
|
const newValue = e.key;
|
||||||
|
if (newValue && !isNaN(newValue) && cursorPos < maxlength) {
|
||||||
|
internalValue.value =
|
||||||
|
currentValue.substring(0, cursorPos) +
|
||||||
|
newValue +
|
||||||
|
currentValue.substring(cursorPos + 1);
|
||||||
|
}
|
||||||
|
nextTick(() => {
|
||||||
|
input.setSelectionRange(cursorPos + 1, cursorPos + 1);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
function accountShortToStandard() {
|
||||||
|
internalValue.value = internalValue.value?.replace(
|
||||||
|
'.',
|
||||||
|
'0'.repeat(11 - internalValue.value.length)
|
||||||
|
);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnInput
|
<QInput @keydown="handleKeydown" ref="vnInputRef" v-model="internalValue" />
|
||||||
v-model="model"
|
|
||||||
ref="inputRef"
|
|
||||||
@keydown.tab="model = useAccountShortToStandard($event.target.value) ?? model"
|
|
||||||
@input="model = $event.target.value.replace(/[^\d.]/g, '')"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,93 +1,89 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onBeforeMount, computed, markRaw } from 'vue';
|
import { onBeforeMount, computed } from 'vue';
|
||||||
import { useRoute, useRouter, onBeforeRouteUpdate, onBeforeRouteLeave } from 'vue-router';
|
import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import useCardSize from 'src/composables/useCardSize';
|
import useCardSize from 'src/composables/useCardSize';
|
||||||
import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
||||||
|
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||||
const emit = defineEmits(['onFetch']);
|
import LeftMenu from 'components/LeftMenu.vue';
|
||||||
|
import RightMenu from 'components/common/RightMenu.vue';
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
id: { type: Number, required: false, default: null },
|
|
||||||
dataKey: { type: String, required: true },
|
dataKey: { type: String, required: true },
|
||||||
url: { type: String, default: undefined },
|
url: { type: String, default: undefined },
|
||||||
idInWhere: { type: Boolean, default: false },
|
|
||||||
filter: { type: Object, default: () => {} },
|
filter: { type: Object, default: () => {} },
|
||||||
descriptor: { type: Object, required: true },
|
descriptor: { type: Object, required: true },
|
||||||
filterPanel: { type: Object, default: undefined },
|
filterPanel: { type: Object, default: undefined },
|
||||||
|
idInWhere: { type: Boolean, default: false },
|
||||||
searchDataKey: { type: String, default: undefined },
|
searchDataKey: { type: String, default: undefined },
|
||||||
searchbarProps: { type: Object, default: undefined },
|
searchbarProps: { type: Object, default: undefined },
|
||||||
redirectOnError: { type: Boolean, default: false },
|
redirectOnError: { type: Boolean, default: false },
|
||||||
visual: { type: Boolean, default: true },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const entityId = computed(() => props.id || route?.params?.id);
|
const searchRightDataKey = computed(() => {
|
||||||
let arrayData = getArrayData(entityId.value, props.url);
|
if (!props.searchDataKey) return route.name;
|
||||||
|
return props.searchDataKey;
|
||||||
|
});
|
||||||
|
|
||||||
onBeforeRouteLeave(() => {
|
const arrayData = useArrayData(props.dataKey, {
|
||||||
stateStore.cardDescriptorChangeValue(null);
|
url: props.url,
|
||||||
|
userFilter: props.filter,
|
||||||
|
oneRecord: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
stateStore.cardDescriptorChangeValue(markRaw(props.descriptor));
|
|
||||||
|
|
||||||
const route = router.currentRoute.value;
|
|
||||||
try {
|
try {
|
||||||
await fetch(entityId.value);
|
await fetch(route.params.id);
|
||||||
} catch {
|
} catch {
|
||||||
const { matched: matches } = route;
|
const { matched: matches } = router.currentRoute.value;
|
||||||
const { path } = matches.at(-1);
|
const { path } = matches.at(-1);
|
||||||
router.push({ path: path.replace(/:id.*/, '') });
|
router.push({ path: path.replace(/:id.*/, '') });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeRouteUpdate(async (to, from) => {
|
onBeforeRouteUpdate(async (to, from) => {
|
||||||
if (hasRouteParam(to.params)) {
|
const id = to.params.id;
|
||||||
const { matched } = router.currentRoute.value;
|
if (id !== from.params.id) await fetch(id, true);
|
||||||
const { name } = matched.at(-3);
|
|
||||||
if (name) {
|
|
||||||
router.push({ name, params: to.params });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (entityId.value !== to.params.id) await fetch(to.params.id, true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
async function fetch(id, append = false) {
|
async function fetch(id, append = false) {
|
||||||
if (props.idInWhere) arrayData.store.filter.where = { id };
|
|
||||||
else {
|
|
||||||
arrayData = getArrayData(id);
|
|
||||||
}
|
|
||||||
await arrayData.fetch({ append, updateRouter: false });
|
|
||||||
emit('onFetch', arrayData.store.data);
|
|
||||||
}
|
|
||||||
function hasRouteParam(params, valueToCheck = ':addressId') {
|
|
||||||
return Object.values(params).includes(valueToCheck);
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatUrl(id) {
|
|
||||||
const newId = id || entityId.value;
|
|
||||||
const regex = /\/(\d+)/;
|
const regex = /\/(\d+)/;
|
||||||
if (!regex.test(props.url)) return `${props.url}/${newId}`;
|
if (props.idInWhere) arrayData.store.filter.where = { id };
|
||||||
return props.url.replace(regex, `/${newId}`);
|
else if (!regex.test(props.url)) arrayData.store.url = `${props.url}/${id}`;
|
||||||
}
|
else arrayData.store.url = props.url.replace(regex, `/${id}`);
|
||||||
|
await arrayData.fetch({ append, updateRouter: false });
|
||||||
function getArrayData(id, url) {
|
|
||||||
return useArrayData(props.dataKey, {
|
|
||||||
url: url ?? formatUrl(id),
|
|
||||||
userFilter: props.filter,
|
|
||||||
oneRecord: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<template v-if="visual">
|
<QDrawer
|
||||||
<VnSubToolbar />
|
v-model="stateStore.leftDrawer"
|
||||||
<div :class="[useCardSize(), $attrs.class]">
|
show-if-above
|
||||||
<RouterView :key="$route.path" />
|
:width="256"
|
||||||
</div>
|
v-if="stateStore.isHeaderMounted()"
|
||||||
</template>
|
>
|
||||||
|
<QScrollArea class="fit">
|
||||||
|
<component :is="descriptor" />
|
||||||
|
<QSeparator />
|
||||||
|
<LeftMenu source="card" />
|
||||||
|
</QScrollArea>
|
||||||
|
</QDrawer>
|
||||||
|
<slot name="searchbar" v-if="props.searchDataKey">
|
||||||
|
<VnSearchbar :data-key="props.searchDataKey" v-bind="props.searchbarProps" />
|
||||||
|
</slot>
|
||||||
|
<RightMenu>
|
||||||
|
<template #right-panel v-if="props.filterPanel">
|
||||||
|
<component :is="props.filterPanel" :data-key="searchRightDataKey" />
|
||||||
|
</template>
|
||||||
|
</RightMenu>
|
||||||
|
<QPageContainer>
|
||||||
|
<QPage>
|
||||||
|
<VnSubToolbar />
|
||||||
|
<div :class="[useCardSize(), $attrs.class]">
|
||||||
|
<RouterView :key="$route.path" />
|
||||||
|
</div>
|
||||||
|
</QPage>
|
||||||
|
</QPageContainer>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
<script setup>
|
||||||
|
import { onBeforeMount } from 'vue';
|
||||||
|
import { 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 },
|
||||||
|
url: { type: String, default: undefined },
|
||||||
|
idInWhere: { type: Boolean, default: false },
|
||||||
|
filter: { type: Object, default: () => {} },
|
||||||
|
descriptor: { type: Object, required: true },
|
||||||
|
filterPanel: { type: Object, default: undefined },
|
||||||
|
searchDataKey: { type: String, default: undefined },
|
||||||
|
searchbarProps: { type: Object, default: undefined },
|
||||||
|
redirectOnError: { type: Boolean, default: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const stateStore = useStateStore();
|
||||||
|
const router = useRouter();
|
||||||
|
const arrayData = useArrayData(props.dataKey, {
|
||||||
|
url: props.url,
|
||||||
|
userFilter: props.filter,
|
||||||
|
oneRecord: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeMount(async () => {
|
||||||
|
const route = router.currentRoute.value;
|
||||||
|
try {
|
||||||
|
await fetch(route.params.id);
|
||||||
|
} catch {
|
||||||
|
const { matched: matches } = route;
|
||||||
|
const { path } = matches.at(-1);
|
||||||
|
router.push({ path: path.replace(/:id.*/, '') });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeRouteUpdate(async (to, from) => {
|
||||||
|
const id = to.params.id;
|
||||||
|
if (id !== from.params.id) await fetch(id, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
async function fetch(id, append = false) {
|
||||||
|
const regex = /\/(\d+)/;
|
||||||
|
if (props.idInWhere) arrayData.store.filter.where = { id };
|
||||||
|
else if (!regex.test(props.url)) arrayData.store.url = `${props.url}/${id}`;
|
||||||
|
else arrayData.store.url = props.url.replace(regex, `/${id}`);
|
||||||
|
await arrayData.fetch({ append, updateRouter: false });
|
||||||
|
}
|
||||||
|
</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>
|
|
@ -27,11 +27,7 @@ const checkboxModel = computed({
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<QCheckbox
|
<QCheckbox v-bind="$attrs" v-on="$attrs" v-model="checkboxModel" />
|
||||||
v-bind="$attrs"
|
|
||||||
v-model="checkboxModel"
|
|
||||||
:data-cy="$attrs['data-cy'] ?? `vnCheckbox${$attrs['label'] ?? ''}`"
|
|
||||||
/>
|
|
||||||
<QIcon
|
<QIcon
|
||||||
v-if="info"
|
v-if="info"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
colors: {
|
colors: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '{"value": []}',
|
default: '{"value":[]}',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ const maxHeight = 30;
|
||||||
const colorHeight = maxHeight / colorArray?.length;
|
const colorHeight = maxHeight / colorArray?.length;
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div v-if="colors" class="color-div" :style="{ height: `${maxHeight}px` }">
|
<div class="color-div" :style="{ height: `${maxHeight}px` }">
|
||||||
<div
|
<div
|
||||||
v-for="(color, index) in colorArray"
|
v-for="(color, index) in colorArray"
|
||||||
:key="index"
|
:key="index"
|
||||||
|
|
|
@ -48,8 +48,7 @@ function toValueAttrs(attrs) {
|
||||||
<span
|
<span
|
||||||
v-for="toComponent of componentArray"
|
v-for="toComponent of componentArray"
|
||||||
:key="toComponent.name"
|
:key="toComponent.name"
|
||||||
class="column fit"
|
class="column flex-center fit"
|
||||||
:class="toComponent?.component == 'checkbox' ? 'flex-center' : ''"
|
|
||||||
>
|
>
|
||||||
<component
|
<component
|
||||||
v-if="toComponent?.component"
|
v-if="toComponent?.component"
|
||||||
|
|
|
@ -35,10 +35,6 @@ const $props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
hasFile: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const warehouses = ref();
|
const warehouses = ref();
|
||||||
|
@ -94,7 +90,6 @@ function defaultData() {
|
||||||
if ($props.formInitialData) return (dms.value = $props.formInitialData);
|
if ($props.formInitialData) return (dms.value = $props.formInitialData);
|
||||||
return addDefaultData({
|
return addDefaultData({
|
||||||
reference: route.params.id,
|
reference: route.params.id,
|
||||||
hasFile: $props.hasFile,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +177,6 @@ function addDefaultData(data) {
|
||||||
name="vn:attach"
|
name="vn:attach"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="inputFileRef.pickFiles()"
|
@click="inputFileRef.pickFiles()"
|
||||||
data-cy="attachFile"
|
|
||||||
>
|
>
|
||||||
<QTooltip>{{ t('globals.selectFile') }}</QTooltip>
|
<QTooltip>{{ t('globals.selectFile') }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
|
|
|
@ -1,166 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import VnConfirm from '../ui/VnConfirm.vue';
|
|
||||||
import VnInput from './VnInput.vue';
|
|
||||||
import VnDms from './VnDms.vue';
|
|
||||||
import axios from 'axios';
|
|
||||||
import { useQuasar } from 'quasar';
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import { downloadFile } from 'src/composables/downloadFile';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
const quasar = useQuasar();
|
|
||||||
const documentDialogRef = ref({});
|
|
||||||
const editDownloadDisabled = ref(false);
|
|
||||||
const $props = defineProps({
|
|
||||||
defaultDmsCode: {
|
|
||||||
type: String,
|
|
||||||
default: 'invoiceIn',
|
|
||||||
},
|
|
||||||
disable: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
formRef: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
function deleteFile(dmsFk) {
|
|
||||||
quasar
|
|
||||||
.dialog({
|
|
||||||
component: VnConfirm,
|
|
||||||
componentProps: {
|
|
||||||
title: t('globals.confirmDeletion'),
|
|
||||||
message: t('globals.confirmDeletionMessage'),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.onOk(async () => {
|
|
||||||
await axios.post(`dms/${dmsFk}/removeFile`);
|
|
||||||
$props.formRef.formData.dmsFk = null;
|
|
||||||
$props.formRef.formData.dms = undefined;
|
|
||||||
$props.formRef.hasChanges = true;
|
|
||||||
$props.formRef.save();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<div class="row no-wrap">
|
|
||||||
<VnInput
|
|
||||||
:label="t('Document')"
|
|
||||||
v-model="data.dmsFk"
|
|
||||||
clearable
|
|
||||||
clear-icon="close"
|
|
||||||
class="full-width"
|
|
||||||
:disable="disable"
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
v-if="data.dmsFk"
|
|
||||||
class="row no-wrap q-pa-xs q-gutter-x-xs"
|
|
||||||
data-cy="dms-buttons"
|
|
||||||
>
|
|
||||||
<QBtn
|
|
||||||
:disable="editDownloadDisabled"
|
|
||||||
@click="downloadFile(data.dmsFk)"
|
|
||||||
icon="cloud_download"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
:class="{
|
|
||||||
'no-pointer-events': editDownloadDisabled,
|
|
||||||
}"
|
|
||||||
padding="xs"
|
|
||||||
round
|
|
||||||
>
|
|
||||||
<QTooltip>{{ t('Download file') }}</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
<QBtn
|
|
||||||
:disable="editDownloadDisabled"
|
|
||||||
@click="
|
|
||||||
() => {
|
|
||||||
documentDialogRef.show = true;
|
|
||||||
documentDialogRef.dms = data.dms;
|
|
||||||
}
|
|
||||||
"
|
|
||||||
icon="edit"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
:class="{
|
|
||||||
'no-pointer-events': editDownloadDisabled,
|
|
||||||
}"
|
|
||||||
padding="xs"
|
|
||||||
round
|
|
||||||
>
|
|
||||||
<QTooltip>{{ t('Edit document') }}</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
<QBtn
|
|
||||||
:disable="editDownloadDisabled"
|
|
||||||
@click="deleteFile(data.dmsFk)"
|
|
||||||
icon="delete"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
round
|
|
||||||
:class="{
|
|
||||||
'no-pointer-events': editDownloadDisabled,
|
|
||||||
}"
|
|
||||||
padding="xs"
|
|
||||||
>
|
|
||||||
<QTooltip>{{ t('Delete file') }}</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</div>
|
|
||||||
<QBtn
|
|
||||||
v-else
|
|
||||||
icon="add_circle"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
round
|
|
||||||
v-shortcut="'+'"
|
|
||||||
padding="xs"
|
|
||||||
@click="
|
|
||||||
() => {
|
|
||||||
documentDialogRef.show = true;
|
|
||||||
delete documentDialogRef.dms;
|
|
||||||
}
|
|
||||||
"
|
|
||||||
data-cy="dms-create"
|
|
||||||
>
|
|
||||||
<QTooltip>{{ t('Create document') }}</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</div>
|
|
||||||
<QDialog v-model="documentDialogRef.show">
|
|
||||||
<VnDms
|
|
||||||
model="dms"
|
|
||||||
:default-dms-code="defaultDmsCode"
|
|
||||||
:form-initial-data="documentDialogRef.dms"
|
|
||||||
:url="
|
|
||||||
documentDialogRef.dms
|
|
||||||
? `Dms/${documentDialogRef.dms.id}/updateFile`
|
|
||||||
: 'Dms/uploadFile'
|
|
||||||
"
|
|
||||||
:description="documentDialogRef.supplierName"
|
|
||||||
@on-data-saved="
|
|
||||||
(_, { data }) => {
|
|
||||||
let dmsData = data;
|
|
||||||
if (Array.isArray(data)) dmsData = data[0];
|
|
||||||
formRef.formData.dmsFk = dmsData.id;
|
|
||||||
formRef.formData.dms = dmsData;
|
|
||||||
formRef.hasChanges = true;
|
|
||||||
formRef.save();
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</QDialog>
|
|
||||||
</template>
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
Document: Documento
|
|
||||||
Download file: Descargar archivo
|
|
||||||
Edit document: Editar documento
|
|
||||||
Delete file: Eliminar archivo
|
|
||||||
Create document: Crear documento
|
|
||||||
|
|
||||||
</i18n>
|
|
|
@ -389,7 +389,10 @@ defineExpose({
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</QTable>
|
</QTable>
|
||||||
<div v-else class="info-row q-pa-md text-center">
|
<div
|
||||||
|
v-else
|
||||||
|
class="info-row q-pa-md text-center"
|
||||||
|
>
|
||||||
<h5>
|
<h5>
|
||||||
{{ t('No data to display') }}
|
{{ t('No data to display') }}
|
||||||
</h5>
|
</h5>
|
||||||
|
@ -413,7 +416,6 @@ defineExpose({
|
||||||
v-shortcut
|
v-shortcut
|
||||||
@click="showFormDialog()"
|
@click="showFormDialog()"
|
||||||
class="fill-icon"
|
class="fill-icon"
|
||||||
data-cy="addButton"
|
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ t('Upload file') }}
|
{{ t('Upload file') }}
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import VnSelect from './VnSelect.vue';
|
|
||||||
|
|
||||||
const stateBtnDropdownRef = ref();
|
|
||||||
|
|
||||||
const emit = defineEmits(['changeState']);
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
disable: {
|
|
||||||
type: Boolean,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
options: {
|
|
||||||
type: Array,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
optionLabel: {
|
|
||||||
type: String,
|
|
||||||
default: 'name',
|
|
||||||
},
|
|
||||||
optionValue: {
|
|
||||||
type: String,
|
|
||||||
default: 'id',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
async function changeState(value) {
|
|
||||||
stateBtnDropdownRef.value?.hide();
|
|
||||||
emit('changeState', value);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<QBtnDropdown
|
|
||||||
ref="stateBtnDropdownRef"
|
|
||||||
color="black"
|
|
||||||
text-color="white"
|
|
||||||
:label="$t('globals.changeState')"
|
|
||||||
:disable="$props.disable"
|
|
||||||
>
|
|
||||||
<VnSelect
|
|
||||||
:options="$props.options"
|
|
||||||
:option-label="$props.optionLabel"
|
|
||||||
:option-value="$props.optionValue"
|
|
||||||
hide-selected
|
|
||||||
hide-dropdown-icon
|
|
||||||
focus-on-mount
|
|
||||||
@update:model-value="changeState"
|
|
||||||
>
|
|
||||||
</VnSelect>
|
|
||||||
</QBtnDropdown>
|
|
||||||
</template>
|
|
|
@ -83,8 +83,8 @@ const mixinRules = [
|
||||||
requiredFieldRule,
|
requiredFieldRule,
|
||||||
...($attrs.rules ?? []),
|
...($attrs.rules ?? []),
|
||||||
(val) => {
|
(val) => {
|
||||||
const maxlength = $props.maxlength;
|
const { maxlength } = vnInputRef.value;
|
||||||
if (maxlength && +val?.length > maxlength)
|
if (maxlength && +val.length > maxlength)
|
||||||
return t(`maxLength`, { value: maxlength });
|
return t(`maxLength`, { value: maxlength });
|
||||||
const { min, max } = vnInputRef.value.$attrs;
|
const { min, max } = vnInputRef.value.$attrs;
|
||||||
if (!min) return null;
|
if (!min) return null;
|
||||||
|
@ -108,7 +108,7 @@ const handleInsertMode = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const input = e.target;
|
const input = e.target;
|
||||||
const cursorPos = input.selectionStart;
|
const cursorPos = input.selectionStart;
|
||||||
const maxlength = $props.maxlength;
|
const { maxlength } = vnInputRef.value;
|
||||||
let currentValue = value.value;
|
let currentValue = value.value;
|
||||||
if (!currentValue) currentValue = e.key;
|
if (!currentValue) currentValue = e.key;
|
||||||
const newValue = e.key;
|
const newValue = e.key;
|
||||||
|
@ -143,7 +143,7 @@ const handleUppercase = () => {
|
||||||
:rules="mixinRules"
|
:rules="mixinRules"
|
||||||
:lazy-rules="true"
|
:lazy-rules="true"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
:data-cy="($attrs['data-cy'] ?? $attrs.label) + '_input'"
|
:data-cy="$attrs.dataCy ?? $attrs.label + '_input'"
|
||||||
>
|
>
|
||||||
<template #prepend v-if="$slots.prepend">
|
<template #prepend v-if="$slots.prepend">
|
||||||
<slot name="prepend" />
|
<slot name="prepend" />
|
||||||
|
|
|
@ -107,7 +107,6 @@ const manageDate = (date) => {
|
||||||
@click="isPopupOpen = !isPopupOpen"
|
@click="isPopupOpen = !isPopupOpen"
|
||||||
@keydown="isPopupOpen = false"
|
@keydown="isPopupOpen = false"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
:data-cy="($attrs['data-cy'] ?? $attrs.label) + '_inputDate'"
|
|
||||||
>
|
>
|
||||||
<template #append>
|
<template #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
|
|
|
@ -23,6 +23,7 @@ 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 emit = defineEmits(['blur']);
|
||||||
|
|
||||||
const styleAttrs = computed(() => {
|
const styleAttrs = computed(() => {
|
||||||
return props.isOutlined
|
return props.isOutlined
|
||||||
|
|
|
@ -85,7 +85,6 @@ const handleModelValue = (data) => {
|
||||||
:tooltip="t('Create new location')"
|
:tooltip="t('Create new location')"
|
||||||
:rules="mixinRules"
|
:rules="mixinRules"
|
||||||
:lazy-rules="true"
|
:lazy-rules="true"
|
||||||
required
|
|
||||||
>
|
>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CreateNewPostcode
|
<CreateNewPostcode
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, onUnmounted, watch, computed } from 'vue';
|
import { ref, onUnmounted, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
@ -10,12 +10,12 @@ import { useColor } from 'src/composables/useColor';
|
||||||
import { useCapitalize } from 'src/composables/useCapitalize';
|
import { useCapitalize } from 'src/composables/useCapitalize';
|
||||||
import { useValidator } from 'src/composables/useValidator';
|
import { useValidator } from 'src/composables/useValidator';
|
||||||
import VnAvatar from '../ui/VnAvatar.vue';
|
import VnAvatar from '../ui/VnAvatar.vue';
|
||||||
import VnLogValue from './VnLogValue.vue';
|
import VnJsonValue from '../common/VnJsonValue.vue';
|
||||||
|
import FetchData from '../FetchData.vue';
|
||||||
|
import VnSelect from './VnSelect.vue';
|
||||||
import VnUserLink from '../ui/VnUserLink.vue';
|
import VnUserLink from '../ui/VnUserLink.vue';
|
||||||
import VnPaginate from '../ui/VnPaginate.vue';
|
import VnPaginate from '../ui/VnPaginate.vue';
|
||||||
import VnLogFilter from 'src/components/common/VnLogFilter.vue';
|
|
||||||
import RightMenu from './RightMenu.vue';
|
import RightMenu from './RightMenu.vue';
|
||||||
import { useFilterParams } from 'src/composables/useFilterParams';
|
|
||||||
|
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const validationsStore = useValidator();
|
const validationsStore = useValidator();
|
||||||
|
@ -72,8 +72,39 @@ const filter = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const paginate = ref();
|
const paginate = ref();
|
||||||
const dataKey = computed(() => `${props.model}Log`);
|
const actions = ref();
|
||||||
const userParams = ref(useFilterParams(dataKey.value).params);
|
const changeInput = ref();
|
||||||
|
const searchInput = ref();
|
||||||
|
const userRadio = ref();
|
||||||
|
const userSelect = ref();
|
||||||
|
const dateFrom = ref();
|
||||||
|
const dateFromDialog = ref(false);
|
||||||
|
const dateTo = ref();
|
||||||
|
const dateToDialog = ref(false);
|
||||||
|
const selectedFilters = ref({});
|
||||||
|
const userTypes = [
|
||||||
|
{ label: 'All', value: undefined },
|
||||||
|
{ label: 'User', value: { neq: null } },
|
||||||
|
{ label: 'System', value: null },
|
||||||
|
];
|
||||||
|
const checkboxOptions = ref({
|
||||||
|
insert: {
|
||||||
|
label: 'Creates',
|
||||||
|
selected: false,
|
||||||
|
},
|
||||||
|
update: {
|
||||||
|
label: 'Edits',
|
||||||
|
selected: false,
|
||||||
|
},
|
||||||
|
delete: {
|
||||||
|
label: 'Deletes',
|
||||||
|
selected: false,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
label: 'Accesses',
|
||||||
|
selected: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
let validations = models;
|
let validations = models;
|
||||||
let pointRecord = ref(null);
|
let pointRecord = ref(null);
|
||||||
|
@ -215,54 +246,131 @@ async function setLogTree(data) {
|
||||||
function filterByRecord(modelLog) {
|
function filterByRecord(modelLog) {
|
||||||
byRecord.value = true;
|
byRecord.value = true;
|
||||||
const { id, model } = modelLog;
|
const { id, model } = modelLog;
|
||||||
applyFilter({ changedModelId: id, changedModel: model });
|
|
||||||
|
searchInput.value = id;
|
||||||
|
selectedFilters.value.changedModelId = id;
|
||||||
|
selectedFilters.value.changedModel = model;
|
||||||
|
applyFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function applyFilter(params = {}) {
|
async function applyFilter() {
|
||||||
paginate.value.arrayData.applyFilter({
|
filter.where = { and: [] };
|
||||||
filter: {},
|
if (
|
||||||
params: { originFk: route.params.id, ...params },
|
!selectedFilters.value.changedModel ||
|
||||||
});
|
(!selectedFilters.value.changedModelValue &&
|
||||||
|
!selectedFilters.value.changedModelId)
|
||||||
|
)
|
||||||
|
byRecord.value = false;
|
||||||
|
|
||||||
|
if (!byRecord.value) filter.where.and.push({ originFk: route.params.id });
|
||||||
|
|
||||||
|
if (Object.keys(selectedFilters.value).length) {
|
||||||
|
filter.where.and.push(selectedFilters.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
paginate.value.fetch({ filter });
|
||||||
}
|
}
|
||||||
|
|
||||||
function exprBuilder(param, value) {
|
function setDate(type) {
|
||||||
switch (param) {
|
let from = dateFrom.value
|
||||||
case 'changedModelValue':
|
? date.formatDate(dateFrom.value.split('-').reverse().join('-'), 'YYYY-MM-DD')
|
||||||
return { [param]: { like: `%${value}%` } };
|
: undefined;
|
||||||
case 'change':
|
from = date.adjustDate(from, { hour: 0, minute: 0, second: 0, millisecond: 0 }, true);
|
||||||
if (value)
|
|
||||||
return {
|
let to = dateTo.value
|
||||||
or: [
|
? date.formatDate(dateTo.value.split('-').reverse().join('-'), 'YYYY-MM-DD')
|
||||||
{ oldJson: { like: `%${value}%` } },
|
: date.formatDate(dateFrom.value.split('-').reverse().join('-'), 'YYYY-MM-DD');
|
||||||
{ newJson: { like: `%${value}%` } },
|
to = date.adjustDate(
|
||||||
{ description: { like: `%${value}%` } },
|
to,
|
||||||
],
|
{ hour: 21, minute: 59, second: 59, millisecond: 999 },
|
||||||
};
|
true,
|
||||||
break;
|
);
|
||||||
case 'action':
|
|
||||||
if (value?.length) return { [param]: { inq: value } };
|
switch (type) {
|
||||||
break;
|
|
||||||
case 'from':
|
case 'from':
|
||||||
return { creationDate: { gte: value } };
|
return { between: [from, to] };
|
||||||
case 'to':
|
case 'to': {
|
||||||
return { creationDate: { lte: value } };
|
if (dateFrom.value) {
|
||||||
case 'userType':
|
return {
|
||||||
if (value === 'User') return { userFk: { neq: null } };
|
between: [from, to],
|
||||||
if (value === 'System') return { userFk: null };
|
};
|
||||||
break;
|
}
|
||||||
default:
|
return { lte: to };
|
||||||
return { [param]: value };
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectFilter(type, dateType) {
|
||||||
|
const filter = {};
|
||||||
|
const actions = { inq: [] };
|
||||||
|
let reload = true;
|
||||||
|
|
||||||
|
if (type === 'search') {
|
||||||
|
if (/^\s*[0-9]+\s*$/.test(searchInput.value) || props.byRecord) {
|
||||||
|
selectedFilters.value.changedModelId = searchInput.value.trim();
|
||||||
|
} else if (!searchInput.value) {
|
||||||
|
selectedFilters.value.changedModelId = undefined;
|
||||||
|
selectedFilters.value.changedModelValue = undefined;
|
||||||
|
} else {
|
||||||
|
selectedFilters.value.changedModelValue = { like: `%${searchInput.value}%` };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type === 'action' && selectedFilters.value.changedModel === null) {
|
||||||
|
selectedFilters.value.changedModel = undefined;
|
||||||
|
}
|
||||||
|
if (type === 'userRadio') {
|
||||||
|
selectedFilters.value.userFk = userRadio.value;
|
||||||
|
}
|
||||||
|
if (type === 'change') {
|
||||||
|
if (changeInput.value)
|
||||||
|
selectedFilters.value.or = [
|
||||||
|
{ oldJson: { like: `%${changeInput.value}%` } },
|
||||||
|
{ newJson: { like: `%${changeInput.value}%` } },
|
||||||
|
{ description: { like: `%${changeInput.value}%` } },
|
||||||
|
];
|
||||||
|
else selectedFilters.value.or = undefined;
|
||||||
|
}
|
||||||
|
if (type === 'userSelect') {
|
||||||
|
selectedFilters.value.userFk =
|
||||||
|
userSelect.value !== null ? userSelect.value : undefined;
|
||||||
|
}
|
||||||
|
if (type === 'date') {
|
||||||
|
if (!dateFrom.value && !dateTo.value) {
|
||||||
|
selectedFilters.value.creationDate = undefined;
|
||||||
|
} else if (dateType === 'to') {
|
||||||
|
selectedFilters.value.creationDate = setDate('to');
|
||||||
|
} else if (dateType === 'from') {
|
||||||
|
selectedFilters.value.creationDate = setDate('from');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.keys(checkboxOptions.value).forEach((key) => {
|
||||||
|
if (checkboxOptions.value[key].selected) actions.inq.push(key);
|
||||||
|
});
|
||||||
|
selectedFilters.value.action = actions.inq.length ? actions : undefined;
|
||||||
|
|
||||||
|
Object.keys(selectedFilters.value).forEach((key) => {
|
||||||
|
if (selectedFilters.value[key]) filter[key] = selectedFilters.value[key];
|
||||||
|
});
|
||||||
|
|
||||||
|
if (reload) applyFilter(filter);
|
||||||
|
}
|
||||||
|
|
||||||
async function clearFilter() {
|
async function clearFilter() {
|
||||||
|
selectedFilters.value = {};
|
||||||
byRecord.value = false;
|
byRecord.value = false;
|
||||||
|
userSelect.value = undefined;
|
||||||
|
searchInput.value = undefined;
|
||||||
|
changeInput.value = undefined;
|
||||||
|
dateFrom.value = undefined;
|
||||||
|
dateTo.value = undefined;
|
||||||
|
userRadio.value = undefined;
|
||||||
|
Object.keys(checkboxOptions.value).forEach(
|
||||||
|
(opt) => (checkboxOptions.value[opt].selected = false),
|
||||||
|
);
|
||||||
await applyFilter();
|
await applyFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
stateStore.rightDrawerChangeValue(true);
|
|
||||||
});
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
stateStore.rightDrawer = false;
|
stateStore.rightDrawer = false;
|
||||||
});
|
});
|
||||||
|
@ -275,18 +383,32 @@ watch(
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
<FetchData
|
||||||
|
:url="`${props.model}Logs/${route.params.id}/models`"
|
||||||
|
:filter="{ order: ['changedModel'] }"
|
||||||
|
@on-fetch="
|
||||||
|
(data) =>
|
||||||
|
(actions = data.map((item) => {
|
||||||
|
const changedModel = item.changedModel;
|
||||||
|
return {
|
||||||
|
locale: useCapitalize(
|
||||||
|
validations[changedModel]?.locale?.name ?? changedModel,
|
||||||
|
),
|
||||||
|
value: changedModel,
|
||||||
|
};
|
||||||
|
}))
|
||||||
|
"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
ref="paginate"
|
ref="paginate"
|
||||||
:data-key
|
:data-key="`${model}Log`"
|
||||||
:url="dataKey + 's'"
|
:url="`${model}Logs`"
|
||||||
:user-filter="filter"
|
:user-filter="filter"
|
||||||
:skeleton="false"
|
:skeleton="false"
|
||||||
auto-load
|
auto-load
|
||||||
@on-fetch="setLogTree"
|
@on-fetch="setLogTree"
|
||||||
@on-change="setLogTree"
|
|
||||||
search-url="logs"
|
search-url="logs"
|
||||||
:exprBuilder
|
|
||||||
:order="['creationDate DESC', 'id DESC']"
|
|
||||||
>
|
>
|
||||||
<template #body>
|
<template #body>
|
||||||
<div
|
<div
|
||||||
|
@ -345,7 +467,6 @@ watch(
|
||||||
backgroundColor: useColor(modelLog.model),
|
backgroundColor: useColor(modelLog.model),
|
||||||
}"
|
}"
|
||||||
:title="`${modelLog.model} #${modelLog.id}`"
|
:title="`${modelLog.model} #${modelLog.id}`"
|
||||||
data-cy="vnLog-model-chip"
|
|
||||||
>
|
>
|
||||||
{{ t(modelLog.modelI18n) }}
|
{{ t(modelLog.modelI18n) }}
|
||||||
</QChip>
|
</QChip>
|
||||||
|
@ -439,9 +560,10 @@ watch(
|
||||||
value.nameI18n
|
value.nameI18n
|
||||||
}}:
|
}}:
|
||||||
</span>
|
</span>
|
||||||
<VnLogValue
|
<VnJsonValue
|
||||||
:value="value.val"
|
:value="
|
||||||
:name="value.name"
|
value.val.val
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
</QItem>
|
</QItem>
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
|
@ -459,7 +581,6 @@ watch(
|
||||||
}`,
|
}`,
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
data-cy="vnLog-action-icon"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</QItem>
|
</QItem>
|
||||||
|
@ -493,10 +614,7 @@ watch(
|
||||||
>
|
>
|
||||||
{{ prop.nameI18n }}:
|
{{ prop.nameI18n }}:
|
||||||
</span>
|
</span>
|
||||||
<VnLogValue
|
<VnJsonValue :value="prop.val.val" />
|
||||||
:value="prop.val"
|
|
||||||
:name="prop.name"
|
|
||||||
/>
|
|
||||||
<span
|
<span
|
||||||
v-if="
|
v-if="
|
||||||
propIndex <
|
propIndex <
|
||||||
|
@ -523,10 +641,17 @@ watch(
|
||||||
>
|
>
|
||||||
{{ prop.nameI18n }}:
|
{{ prop.nameI18n }}:
|
||||||
</span>
|
</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'">
|
<span v-if="log.action == 'update'">
|
||||||
<VnLogValue
|
←
|
||||||
:value="prop.old"
|
<VnJsonValue
|
||||||
:name="prop.name"
|
:value="prop.old.val"
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
v-if="prop.old.id"
|
v-if="prop.old.id"
|
||||||
|
@ -534,28 +659,6 @@ watch(
|
||||||
>
|
>
|
||||||
#{{ prop.old.id }}
|
#{{ prop.old.id }}
|
||||||
</span>
|
</span>
|
||||||
→
|
|
||||||
<VnLogValue
|
|
||||||
:value="prop.val"
|
|
||||||
:name="prop.name"
|
|
||||||
/>
|
|
||||||
<span
|
|
||||||
v-if="prop.val.id"
|
|
||||||
class="id-value"
|
|
||||||
>
|
|
||||||
#{{ prop.val.id }}
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
<span v-else="prop.old.val">
|
|
||||||
<VnLogValue
|
|
||||||
:value="prop.val"
|
|
||||||
:name="prop.name"
|
|
||||||
/>
|
|
||||||
<span
|
|
||||||
v-if="prop.old.id"
|
|
||||||
class="id-value"
|
|
||||||
>#{{ prop.old.id }}</span
|
|
||||||
>
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
|
@ -577,12 +680,176 @@ watch(
|
||||||
</VnPaginate>
|
</VnPaginate>
|
||||||
<RightMenu>
|
<RightMenu>
|
||||||
<template #right-panel>
|
<template #right-panel>
|
||||||
<VnLogFilter :data-key />
|
<QList dense>
|
||||||
|
<QSeparator />
|
||||||
|
<QItem class="q-mt-sm">
|
||||||
|
<QInput
|
||||||
|
:label="t('globals.search')"
|
||||||
|
v-model="searchInput"
|
||||||
|
class="full-width"
|
||||||
|
clearable
|
||||||
|
clear-icon="close"
|
||||||
|
@keyup.enter="() => selectFilter('search')"
|
||||||
|
@focusout="() => selectFilter('search')"
|
||||||
|
@clear="() => selectFilter('search')"
|
||||||
|
>
|
||||||
|
<template #append>
|
||||||
|
<QIcon name="info" class="cursor-pointer">
|
||||||
|
<QTooltip>{{ t('tooltips.search') }}</QTooltip>
|
||||||
|
</QIcon>
|
||||||
|
</template>
|
||||||
|
</QInput>
|
||||||
|
</QItem>
|
||||||
|
<QItem>
|
||||||
|
<VnSelect
|
||||||
|
class="full-width"
|
||||||
|
:label="t('globals.entity')"
|
||||||
|
v-model="selectedFilters.changedModel"
|
||||||
|
option-label="locale"
|
||||||
|
option-value="value"
|
||||||
|
:options="actions"
|
||||||
|
@update:model-value="selectFilter('action')"
|
||||||
|
hide-selected
|
||||||
|
/>
|
||||||
|
</QItem>
|
||||||
|
<QItem class="q-mt-sm">
|
||||||
|
<QOptionGroup
|
||||||
|
size="sm"
|
||||||
|
v-model="userRadio"
|
||||||
|
:options="userTypes"
|
||||||
|
color="primary"
|
||||||
|
@update:model-value="selectFilter('userRadio')"
|
||||||
|
right-label
|
||||||
|
>
|
||||||
|
<template #label="{ label }">
|
||||||
|
{{ t(`Users.${label}`) }}
|
||||||
|
</template>
|
||||||
|
</QOptionGroup>
|
||||||
|
</QItem>
|
||||||
|
<QItem class="q-mt-sm">
|
||||||
|
<QItemSection v-if="userRadio !== null">
|
||||||
|
<VnSelect
|
||||||
|
class="full-width"
|
||||||
|
:label="t('globals.user')"
|
||||||
|
v-model="userSelect"
|
||||||
|
option-label="name"
|
||||||
|
option-value="id"
|
||||||
|
:url="`${model}Logs/${route.params.id}/editors`"
|
||||||
|
:fields="['id', 'nickname', 'name', 'image']"
|
||||||
|
sort-by="nickname"
|
||||||
|
@update:model-value="selectFilter('userSelect')"
|
||||||
|
hide-selected
|
||||||
|
>
|
||||||
|
<template #option="{ opt, itemProps }">
|
||||||
|
<QItem
|
||||||
|
v-bind="itemProps"
|
||||||
|
class="q-pa-xs row items-center"
|
||||||
|
>
|
||||||
|
<QItemSection class="col-3 items-center">
|
||||||
|
<VnAvatar :worker-id="opt.id" />
|
||||||
|
</QItemSection>
|
||||||
|
<QItemSection class="col-9 justify-center">
|
||||||
|
<span>{{ opt.name }}</span>
|
||||||
|
<span class="text-grey">{{ opt.nickname }}</span>
|
||||||
|
</QItemSection>
|
||||||
|
</QItem>
|
||||||
|
</template>
|
||||||
|
</VnSelect>
|
||||||
|
</QItemSection>
|
||||||
|
</QItem>
|
||||||
|
<QItem class="q-mt-sm">
|
||||||
|
<QInput
|
||||||
|
:label="t('globals.changes')"
|
||||||
|
v-model="changeInput"
|
||||||
|
class="full-width"
|
||||||
|
clearable
|
||||||
|
clear-icon="close"
|
||||||
|
@keyup.enter="selectFilter('change')"
|
||||||
|
@focusout="selectFilter('change')"
|
||||||
|
@clear="selectFilter('change')"
|
||||||
|
>
|
||||||
|
<template #append>
|
||||||
|
<QIcon name="info" class="cursor-pointer">
|
||||||
|
<QTooltip max-width="250px">{{
|
||||||
|
t('tooltips.changes')
|
||||||
|
}}</QTooltip>
|
||||||
|
</QIcon>
|
||||||
|
</template>
|
||||||
|
</QInput>
|
||||||
|
</QItem>
|
||||||
|
<QItem
|
||||||
|
:class="index == 'create' ? 'q-mt-md' : 'q-mt-xs'"
|
||||||
|
v-for="(checkboxOption, index) in checkboxOptions"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
|
<QCheckbox
|
||||||
|
size="sm"
|
||||||
|
v-model="checkboxOption.selected"
|
||||||
|
:label="t(`actions.${checkboxOption.label}`)"
|
||||||
|
@update:model-value="selectFilter"
|
||||||
|
/>
|
||||||
|
</QItem>
|
||||||
|
<QItem class="q-mt-sm">
|
||||||
|
<QInput
|
||||||
|
class="full-width"
|
||||||
|
:label="t('globals.date')"
|
||||||
|
@click="dateFromDialog = true"
|
||||||
|
@focus="(evt) => evt.target.blur()"
|
||||||
|
@clear="selectFilter('date', 'to')"
|
||||||
|
v-model="dateFrom"
|
||||||
|
clearable
|
||||||
|
clear-icon="close"
|
||||||
|
/>
|
||||||
|
</QItem>
|
||||||
|
<QItem class="q-mt-sm">
|
||||||
|
<QInput
|
||||||
|
class="full-width"
|
||||||
|
:label="t('globals.to')"
|
||||||
|
@click="dateToDialog = true"
|
||||||
|
@focus="(evt) => evt.target.blur()"
|
||||||
|
@clear="selectFilter('date', 'from')"
|
||||||
|
v-model="dateTo"
|
||||||
|
clearable
|
||||||
|
clear-icon="close"
|
||||||
|
/>
|
||||||
|
</QItem>
|
||||||
|
</QList>
|
||||||
</template>
|
</template>
|
||||||
</RightMenu>
|
</RightMenu>
|
||||||
|
<QDialog v-model="dateFromDialog">
|
||||||
|
<QDate
|
||||||
|
:years-in-month-view="false"
|
||||||
|
v-model="dateFrom"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
minimal
|
||||||
|
@update:model-value="
|
||||||
|
(value) => {
|
||||||
|
dateFromDialog = false;
|
||||||
|
dateFrom = date.formatDate(value, 'DD-MM-YYYY');
|
||||||
|
selectFilter('date', 'from');
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</QDialog>
|
||||||
|
<QDialog v-model="dateToDialog">
|
||||||
|
<QDate
|
||||||
|
v-model="dateTo"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
minimal
|
||||||
|
@update:model-value="
|
||||||
|
(value) => {
|
||||||
|
dateToDialog = false;
|
||||||
|
dateTo = date.formatDate(value, 'DD-MM-YYYY');
|
||||||
|
selectFilter('date', 'to');
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</QDialog>
|
||||||
<QPageSticky position="bottom-right" :offset="[25, 25]">
|
<QPageSticky position="bottom-right" :offset="[25, 25]">
|
||||||
<QBtn
|
<QBtn
|
||||||
v-if="Object.keys(userParams).some((filter) => filter !== 'originFk')"
|
v-if="Object.values(selectedFilters).some((filter) => filter !== undefined)"
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="filter_alt_off"
|
icon="filter_alt_off"
|
||||||
size="md"
|
size="md"
|
||||||
|
|
|
@ -1,249 +1,77 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import VnTableFilter from '../VnTable/VnTableFilter.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
import VnSelect from './VnSelect.vue';
|
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
import VnInput from './VnInput.vue';
|
|
||||||
import { ref, computed, watch } from 'vue';
|
|
||||||
import VnInputDate from './VnInputDate.vue';
|
|
||||||
import { useFilterParams } from 'src/composables/useFilterParams';
|
|
||||||
import FetchData from '../FetchData.vue';
|
|
||||||
import { useValidator } from 'src/composables/useValidator';
|
|
||||||
import { useCapitalize } from 'src/composables/useCapitalize';
|
|
||||||
|
|
||||||
const $props = defineProps({
|
const { t } = useI18n();
|
||||||
|
const props = defineProps({
|
||||||
dataKey: {
|
dataKey: {
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
required: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useI18n();
|
const workers = ref();
|
||||||
const route = useRoute();
|
|
||||||
const validationsStore = useValidator();
|
|
||||||
const { models } = validationsStore;
|
|
||||||
const entities = ref([]);
|
|
||||||
const editors = ref([]);
|
|
||||||
const userParams = ref(useFilterParams($props.dataKey).params);
|
|
||||||
let validations = models;
|
|
||||||
const userTypes = [
|
|
||||||
{ value: 'All', label: t(`Users.All`) },
|
|
||||||
{ value: 'User', label: t(`Users.User`) },
|
|
||||||
{ value: 'System', label: t(`Users.System`) },
|
|
||||||
];
|
|
||||||
const checkboxOptions = ref([
|
|
||||||
{ name: 'insert', label: 'Creates', selected: false },
|
|
||||||
{ name: 'update', label: 'Edits', selected: false },
|
|
||||||
{ name: 'delete', label: 'Deletes', selected: false },
|
|
||||||
{ name: 'select', label: 'Accesses', selected: false },
|
|
||||||
]);
|
|
||||||
const columns = computed(() => [
|
|
||||||
{ name: 'changedModelValue' },
|
|
||||||
{ name: 'changedModel' },
|
|
||||||
{ name: 'userType', orderBy: false },
|
|
||||||
{ name: 'userFk' },
|
|
||||||
{ name: 'change', orderBy: false },
|
|
||||||
{ name: 'action' },
|
|
||||||
{ name: 'from', orderBy: 'creationDate' },
|
|
||||||
{ name: 'to', orderBy: 'creationDate' },
|
|
||||||
]);
|
|
||||||
|
|
||||||
const userParamsWatcher = watch(
|
|
||||||
() => userParams.value,
|
|
||||||
(params) => {
|
|
||||||
if (params.action) {
|
|
||||||
params.action.forEach((option) => {
|
|
||||||
checkboxOptions.value.find((o) => o.name === option).selected = true;
|
|
||||||
});
|
|
||||||
userParamsWatcher();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
function getActions() {
|
|
||||||
const actions = checkboxOptions.value
|
|
||||||
.filter((option) => option.selected)
|
|
||||||
?.map((o) => o.name);
|
|
||||||
return actions.length ? actions : null;
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
:url="`${dataKey}s/${route.params.id}/models`"
|
url="Workers/activeWithInheritedRole"
|
||||||
:filter="{ order: ['changedModel'] }"
|
:filter="{ where: { role: 'salesPerson' } }"
|
||||||
@on-fetch="
|
@on-fetch="(data) => (workers = data)"
|
||||||
(data) =>
|
|
||||||
(entities = data.map((item) => {
|
|
||||||
const changedModel = item.changedModel;
|
|
||||||
return {
|
|
||||||
locale: useCapitalize(
|
|
||||||
validations[changedModel]?.locale?.name ?? changedModel,
|
|
||||||
),
|
|
||||||
value: changedModel,
|
|
||||||
};
|
|
||||||
}))
|
|
||||||
"
|
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<FetchData
|
<VnFilterPanel :data-key="props.dataKey" :search-button="true">
|
||||||
:url="`${dataKey}s/${route.params.id}/editors`"
|
<template #tags="{ tag, formatFn }">
|
||||||
:filter="{ fields: ['id', 'nickname', 'name', 'image'] }"
|
<div class="q-gutter-x-xs">
|
||||||
sort-by="nickname"
|
<strong>{{ t(`params.${tag.label}`) }}: </strong>
|
||||||
@on-fetch="(data) => (editors = data)"
|
<span>{{ formatFn(tag.value) }}</span>
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<VnTableFilter
|
|
||||||
v-if="dataKey"
|
|
||||||
:data-key
|
|
||||||
:columns="columns"
|
|
||||||
:redirect="false"
|
|
||||||
:hiddenTags="['originFk', 'creationDate']"
|
|
||||||
:exprBuilder
|
|
||||||
search-url="logs"
|
|
||||||
:showTagChips="false"
|
|
||||||
>
|
|
||||||
<template #filter-changedModelValue="{ params, columnName, searchFn }">
|
|
||||||
<VnInput
|
|
||||||
:label="t('globals.search')"
|
|
||||||
v-model="params[columnName]"
|
|
||||||
@keyup.enter="searchFn"
|
|
||||||
@blur="searchFn"
|
|
||||||
@remove="searchFn"
|
|
||||||
:info="t('tooltips.search')"
|
|
||||||
dense
|
|
||||||
filled
|
|
||||||
data-cy="vnLog-search"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template #filter-changedModel="{ params, columnName, searchFn }">
|
|
||||||
<VnSelect
|
|
||||||
:label="t('globals.entity')"
|
|
||||||
v-model="params[columnName]"
|
|
||||||
option-label="locale"
|
|
||||||
option-value="value"
|
|
||||||
:options="entities"
|
|
||||||
@update:model-value="() => searchFn()"
|
|
||||||
dense
|
|
||||||
filled
|
|
||||||
data-cy="vnLog-entity"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template #filter-userType="{ params, columnName, searchFn }">
|
|
||||||
<QOptionGroup
|
|
||||||
class="text-left"
|
|
||||||
size="sm"
|
|
||||||
v-model="params[columnName]"
|
|
||||||
:options="userTypes"
|
|
||||||
color="primary"
|
|
||||||
@update:model-value="
|
|
||||||
() => {
|
|
||||||
params.userFk = null;
|
|
||||||
searchFn();
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template #filter-userFk="{ params, columnName, searchFn }">
|
|
||||||
<VnSelect
|
|
||||||
:label="t('globals.user')"
|
|
||||||
v-model="params[columnName]"
|
|
||||||
:options="editors"
|
|
||||||
@update:modelValue="() => searchFn()"
|
|
||||||
:disable="params.userType === 'System'"
|
|
||||||
dense
|
|
||||||
filled
|
|
||||||
>
|
|
||||||
<template #option="{ opt, itemProps }">
|
|
||||||
<QItem v-bind="itemProps" class="q-pa-xs row items-center">
|
|
||||||
<QItemSection class="col-3 items-center">
|
|
||||||
<VnAvatar :worker-id="opt.id" />
|
|
||||||
</QItemSection>
|
|
||||||
<QItemSection class="col-9 justify-center">
|
|
||||||
<span>{{ opt.name }}</span>
|
|
||||||
<span class="text-grey">{{ opt.nickname }}</span>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
</template>
|
|
||||||
<template #filter-change="{ params, columnName, searchFn }">
|
|
||||||
<VnInput
|
|
||||||
:label="t('globals.changes')"
|
|
||||||
v-model="params[columnName]"
|
|
||||||
@keyup.enter="searchFn"
|
|
||||||
@blur="searchFn"
|
|
||||||
@remove="searchFn"
|
|
||||||
:info="t('tooltips.changes')"
|
|
||||||
dense
|
|
||||||
filled
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template #filter-action="{ searchFn }">
|
|
||||||
<div class="column">
|
|
||||||
<QCheckbox
|
|
||||||
v-for="checkboxOption in checkboxOptions"
|
|
||||||
:key="checkboxOption"
|
|
||||||
size="sm"
|
|
||||||
v-model="checkboxOption.selected"
|
|
||||||
:label="t(`actions.${checkboxOption.label}`)"
|
|
||||||
@update:model-value="
|
|
||||||
() => searchFn(undefined, 'action', getActions())
|
|
||||||
"
|
|
||||||
data-cy="vnLog-checkbox"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #filter-from="{ params, columnName, searchFn }">
|
<template #body="{ params, searchFn }">
|
||||||
<VnInputDate
|
<QDate
|
||||||
:label="t('globals.from')"
|
v-model="params.created"
|
||||||
v-model="params[columnName]"
|
@update:model-value="searchFn()"
|
||||||
dense
|
dense
|
||||||
filled
|
flat
|
||||||
@update:modelValue="() => searchFn()"
|
minimal
|
||||||
/>
|
>
|
||||||
|
</QDate>
|
||||||
|
<QSeparator />
|
||||||
|
<QItem>
|
||||||
|
<QItemSection v-if="!workers">
|
||||||
|
<QSkeleton type="QInput" class="full-width" />
|
||||||
|
</QItemSection>
|
||||||
|
<QItemSection v-if="workers">
|
||||||
|
<QSelect
|
||||||
|
:label="t('User')"
|
||||||
|
v-model="params.userFk"
|
||||||
|
@update:model-value="searchFn()"
|
||||||
|
:options="workers"
|
||||||
|
option-value="id"
|
||||||
|
option-label="name"
|
||||||
|
emit-value
|
||||||
|
map-options
|
||||||
|
use-input
|
||||||
|
:input-debounce="0"
|
||||||
|
/>
|
||||||
|
</QItemSection>
|
||||||
|
</QItem>
|
||||||
</template>
|
</template>
|
||||||
<template #filter-to="{ params, columnName, searchFn }">
|
</VnFilterPanel>
|
||||||
<VnInputDate
|
|
||||||
:label="t('globals.to')"
|
|
||||||
v-model="params[columnName]"
|
|
||||||
dense
|
|
||||||
filled
|
|
||||||
@update:modelValue="() => searchFn()"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</VnTableFilter>
|
|
||||||
</template>
|
</template>
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
tooltips:
|
|
||||||
search: Buscar por identificador o concepto
|
|
||||||
changes: Buscar por cambios. Los atributos deben buscarse por su nombre interno, para obtenerlo situar el cursor sobre el atributo.
|
|
||||||
actions:
|
|
||||||
Creates: Crea
|
|
||||||
Edits: Modifica
|
|
||||||
Deletes: Elimina
|
|
||||||
Accesses: Accede
|
|
||||||
Users:
|
|
||||||
User: Usuario
|
|
||||||
All: Todo
|
|
||||||
System: Sistema
|
|
||||||
params:
|
|
||||||
changedModel: Entity
|
|
||||||
|
|
||||||
|
<i18n>
|
||||||
en:
|
en:
|
||||||
tooltips:
|
|
||||||
search: Search by identifier or concept
|
|
||||||
changes: Search by changes. Attributes must be searched by their internal name, to get it place the cursor over the attribute.
|
|
||||||
actions:
|
|
||||||
Creates: Creates
|
|
||||||
Edits: Edits
|
|
||||||
Deletes: Deletes
|
|
||||||
Accesses: Accesses
|
|
||||||
Users:
|
|
||||||
User: User
|
|
||||||
All: All
|
|
||||||
System: System
|
|
||||||
params:
|
params:
|
||||||
changedModel: Entidad
|
search: Contains
|
||||||
|
userFk: User
|
||||||
|
created: Created
|
||||||
|
es:
|
||||||
|
params:
|
||||||
|
search: Contiene
|
||||||
|
userFk: Usuario
|
||||||
|
created: Creada
|
||||||
|
User: Usuario
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { useDescriptorStore } from 'src/stores/useDescriptorStore';
|
|
||||||
import VnJsonValue from './VnJsonValue.vue';
|
|
||||||
import { computed } from 'vue';
|
|
||||||
const descriptorStore = useDescriptorStore();
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
value: { type: Object, default: () => {} },
|
|
||||||
name: { type: String, default: undefined },
|
|
||||||
});
|
|
||||||
|
|
||||||
const descriptor = computed(() => descriptorStore.has($props.name));
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<VnJsonValue :value="value.val" />
|
|
||||||
<span
|
|
||||||
v-if="(value.id || typeof value.val == 'number') && descriptor"
|
|
||||||
style="margin-left: 2px"
|
|
||||||
>
|
|
||||||
<QIcon
|
|
||||||
name="launch"
|
|
||||||
class="link"
|
|
||||||
:data-cy="'iconLaunch-' + $props.name"
|
|
||||||
style="padding-bottom: 2px"
|
|
||||||
/>
|
|
||||||
<component :is="descriptor" :id="value.id ?? value.val" />
|
|
||||||
</span>
|
|
||||||
</template>
|
|
|
@ -12,7 +12,7 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
onMounted(
|
onMounted(
|
||||||
() => (stateStore.leftDrawer = useQuasar().screen.gt.xs ? $props.leftDrawer : false),
|
() => (stateStore.leftDrawer = useQuasar().screen.gt.xs ? $props.leftDrawer : false)
|
||||||
);
|
);
|
||||||
|
|
||||||
const teleportRef = ref({});
|
const teleportRef = ref({});
|
||||||
|
@ -35,14 +35,8 @@ onMounted(() => {
|
||||||
<template>
|
<template>
|
||||||
<QDrawer v-model="stateStore.leftDrawer" show-if-above :width="256">
|
<QDrawer v-model="stateStore.leftDrawer" show-if-above :width="256">
|
||||||
<QScrollArea class="fit text-grey-8">
|
<QScrollArea class="fit text-grey-8">
|
||||||
<div id="left-panel" ref="teleportRef">
|
<div id="left-panel" ref="teleportRef"></div>
|
||||||
<template v-if="stateStore.cardDescriptor">
|
<LeftMenu v-if="!hasContent" />
|
||||||
<component :is="stateStore.cardDescriptor" />
|
|
||||||
<QSeparator />
|
|
||||||
<LeftMenu source="card" />
|
|
||||||
</template>
|
|
||||||
<template v-else> <LeftMenu /></template>
|
|
||||||
</div>
|
|
||||||
</QScrollArea>
|
</QScrollArea>
|
||||||
</QDrawer>
|
</QDrawer>
|
||||||
<QPageContainer>
|
<QPageContainer>
|
||||||
|
|
|
@ -40,6 +40,10 @@ const $props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
keepData: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
@ -57,6 +61,7 @@ onBeforeMount(() => {
|
||||||
if ($props.dataKey)
|
if ($props.dataKey)
|
||||||
arrayData = useArrayData($props.dataKey, {
|
arrayData = useArrayData($props.dataKey, {
|
||||||
searchUrl: 'table',
|
searchUrl: 'table',
|
||||||
|
keepData: $props.keepData,
|
||||||
...$props.arrayDataProps,
|
...$props.arrayDataProps,
|
||||||
navigate: $props.redirect,
|
navigate: $props.redirect,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, toRefs, computed, watch, onMounted, useAttrs, nextTick } from 'vue';
|
import { ref, toRefs, computed, watch, onMounted, useAttrs } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
import { useRequired } from 'src/composables/useRequired';
|
import { useRequired } from 'src/composables/useRequired';
|
||||||
|
@ -152,10 +152,6 @@ const value = computed({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const computedSortBy = computed(() => {
|
|
||||||
return $props.sortBy || $props.optionLabel + ' ASC';
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(options, (newValue) => {
|
watch(options, (newValue) => {
|
||||||
setOptions(newValue);
|
setOptions(newValue);
|
||||||
});
|
});
|
||||||
|
@ -190,7 +186,7 @@ function findKeyInOptions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setOptions(data) {
|
function setOptions(data) {
|
||||||
data = dataByOrder(data, computedSortBy.value);
|
data = dataByOrder(data, $props.sortBy);
|
||||||
myOptions.value = JSON.parse(JSON.stringify(data));
|
myOptions.value = JSON.parse(JSON.stringify(data));
|
||||||
myOptionsOriginal.value = JSON.parse(JSON.stringify(data));
|
myOptionsOriginal.value = JSON.parse(JSON.stringify(data));
|
||||||
emit('update:options', data);
|
emit('update:options', data);
|
||||||
|
@ -220,8 +216,7 @@ function filter(val, options) {
|
||||||
async function fetchFilter(val) {
|
async function fetchFilter(val) {
|
||||||
if (!$props.url) return;
|
if (!$props.url) return;
|
||||||
|
|
||||||
const { fields, include, limit } = $props;
|
const { fields, include, sortBy, limit } = $props;
|
||||||
const sortBy = computedSortBy.value;
|
|
||||||
const key =
|
const key =
|
||||||
optionFilterValue.value ??
|
optionFilterValue.value ??
|
||||||
(new RegExp(/\d/g).test(val)
|
(new RegExp(/\d/g).test(val)
|
||||||
|
@ -252,7 +247,6 @@ async function fetchFilter(val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function filterHandler(val, update) {
|
async function filterHandler(val, update) {
|
||||||
if (isLoading.value) return update();
|
|
||||||
if (!val && lastVal.value === val) {
|
if (!val && lastVal.value === val) {
|
||||||
lastVal.value = val;
|
lastVal.value = val;
|
||||||
return update();
|
return update();
|
||||||
|
@ -300,7 +294,6 @@ async function onScroll({ to, direction, from, index }) {
|
||||||
await arrayData.loadMore();
|
await arrayData.loadMore();
|
||||||
setOptions(arrayData.store.data);
|
setOptions(arrayData.store.data);
|
||||||
vnSelectRef.value.scrollTo(lastIndex);
|
vnSelectRef.value.scrollTo(lastIndex);
|
||||||
await nextTick();
|
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,12 @@ import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
describe('VnDmsList', () => {
|
describe('VnDmsList', () => {
|
||||||
let vm;
|
let vm;
|
||||||
const dms = {
|
const dms = {
|
||||||
userFk: 1,
|
userFk: 1,
|
||||||
name: 'DMS 1',
|
name: 'DMS 1'
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
vi.mock('src/composables/getUrl', () => ({
|
|
||||||
getUrl: vi.fn().mockResolvedValue(''),
|
|
||||||
}));
|
|
||||||
vi.spyOn(axios, 'get').mockResolvedValue({ data: [] });
|
vi.spyOn(axios, 'get').mockResolvedValue({ data: [] });
|
||||||
vm = createWrapper(VnDmsList, {
|
vm = createWrapper(VnDmsList, {
|
||||||
props: {
|
props: {
|
||||||
|
@ -21,8 +18,8 @@ describe('VnDmsList', () => {
|
||||||
filter: 'wd.workerFk',
|
filter: 'wd.workerFk',
|
||||||
updateModel: 'Workers',
|
updateModel: 'Workers',
|
||||||
deleteModel: 'WorkerDms',
|
deleteModel: 'WorkerDms',
|
||||||
downloadModel: 'WorkerDms',
|
downloadModel: 'WorkerDms'
|
||||||
},
|
}
|
||||||
}).vm;
|
}).vm;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -32,45 +29,46 @@ describe('VnDmsList', () => {
|
||||||
|
|
||||||
describe('setData()', () => {
|
describe('setData()', () => {
|
||||||
const data = [
|
const data = [
|
||||||
{
|
{
|
||||||
userFk: 1,
|
userFk: 1,
|
||||||
name: 'Jessica',
|
name: 'Jessica',
|
||||||
lastName: 'Jones',
|
lastName: 'Jones',
|
||||||
file: '4.jpg',
|
file: '4.jpg',
|
||||||
created: '2021-07-28 21:00:00',
|
created: '2021-07-28 21:00:00'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
userFk: 2,
|
userFk: 2,
|
||||||
name: 'Bruce',
|
name: 'Bruce',
|
||||||
lastName: 'Banner',
|
lastName: 'Banner',
|
||||||
created: '2022-07-28 21:00:00',
|
created: '2022-07-28 21:00:00',
|
||||||
dms: {
|
dms: {
|
||||||
userFk: 2,
|
userFk: 2,
|
||||||
name: 'Bruce',
|
name: 'Bruce',
|
||||||
lastName: 'BannerDMS',
|
lastName: 'BannerDMS',
|
||||||
created: '2022-07-28 21:00:00',
|
created: '2022-07-28 21:00:00',
|
||||||
file: '4.jpg',
|
file: '4.jpg',
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
userFk: 3,
|
userFk: 3,
|
||||||
name: 'Natasha',
|
name: 'Natasha',
|
||||||
lastName: 'Romanoff',
|
lastName: 'Romanoff',
|
||||||
file: '4.jpg',
|
file: '4.jpg',
|
||||||
created: '2021-10-28 21:00:00',
|
created: '2021-10-28 21:00:00'
|
||||||
},
|
}
|
||||||
];
|
]
|
||||||
|
|
||||||
it('Should replace objects that contain the "dms" property with the value of the same and sort by creation date', () => {
|
it('Should replace objects that contain the "dms" property with the value of the same and sort by creation date', () => {
|
||||||
vm.setData(data);
|
vm.setData(data);
|
||||||
expect([vm.rows][0][0].lastName).toEqual('BannerDMS');
|
expect([vm.rows][0][0].lastName).toEqual('BannerDMS');
|
||||||
expect([vm.rows][0][1].lastName).toEqual('Romanoff');
|
expect([vm.rows][0][1].lastName).toEqual('Romanoff');
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('parseDms()', () => {
|
describe('parseDms()', () => {
|
||||||
const resultDms = { ...dms, userId: 1 };
|
const resultDms = { ...dms, userId:1};
|
||||||
|
|
||||||
it('Should add properties that end with "Fk" by changing the suffix to "Id"', () => {
|
it('Should add properties that end with "Fk" by changing the suffix to "Id"', () => {
|
||||||
const parsedDms = vm.parseDms(dms);
|
const parsedDms = vm.parseDms(dms);
|
||||||
expect(parsedDms).toEqual(resultDms);
|
expect(parsedDms).toEqual(resultDms);
|
||||||
|
@ -78,12 +76,12 @@ describe('VnDmsList', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('showFormDialog()', () => {
|
describe('showFormDialog()', () => {
|
||||||
const resultDms = { ...dms, userId: 1 };
|
const resultDms = { ...dms, userId:1};
|
||||||
|
|
||||||
it('should call fn parseDms() and set show true if dms is defined', () => {
|
it('should call fn parseDms() and set show true if dms is defined', () => {
|
||||||
vm.showFormDialog(dms);
|
vm.showFormDialog(dms);
|
||||||
expect(vm.formDialog.show).toEqual(true);
|
expect(vm.formDialog.show).toEqual(true);
|
||||||
expect(vm.formDialog.dms).toEqual(resultDms);
|
expect(vm.formDialog.dms).toEqual(resultDms);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -108,4 +108,27 @@ describe('VnLog', () => {
|
||||||
expect(vm.logTree[0].originFk).toEqual(1);
|
expect(vm.logTree[0].originFk).toEqual(1);
|
||||||
expect(vm.logTree[0].logs[0].user.name).toEqual('salesPerson');
|
expect(vm.logTree[0].logs[0].user.name).toEqual('salesPerson');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should correctly set the selectedFilters when filtering', () => {
|
||||||
|
vm.searchInput = '1';
|
||||||
|
vm.userSelect = '21';
|
||||||
|
vm.checkboxOptions.insert.selected = true;
|
||||||
|
vm.checkboxOptions.update.selected = true;
|
||||||
|
|
||||||
|
vm.selectFilter('search');
|
||||||
|
vm.selectFilter('userSelect');
|
||||||
|
|
||||||
|
expect(vm.selectedFilters.changedModelId).toEqual('1');
|
||||||
|
expect(vm.selectedFilters.userFk).toEqual('21');
|
||||||
|
expect(vm.selectedFilters.action).toEqual({ inq: ['insert', 'update'] });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should correctly set the date from', () => {
|
||||||
|
vm.dateFrom = '18-09-2023';
|
||||||
|
vm.selectFilter('date', 'from');
|
||||||
|
expect(vm.selectedFilters.creationDate.between).toEqual([
|
||||||
|
new Date('2023-09-18T00:00:00.000Z'),
|
||||||
|
new Date('2023-09-18T21:59:59.999Z'),
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
|
||||||
import VnLogFilter from 'src/components/common/VnLogFilter.vue';
|
|
||||||
|
|
||||||
describe('VnLogFilter', () => {
|
|
||||||
let vm;
|
|
||||||
beforeAll(async () => {
|
|
||||||
vm = createWrapper(VnLogFilter, {
|
|
||||||
props: {
|
|
||||||
dataKey: 'ClaimLog',
|
|
||||||
},
|
|
||||||
}).vm;
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should getActions selected', async () => {
|
|
||||||
vm.checkboxOptions.find((o) => o.name == 'insert').selected = true;
|
|
||||||
vm.checkboxOptions.find((o) => o.name == 'update').selected = true;
|
|
||||||
|
|
||||||
const actions = vm.getActions();
|
|
||||||
|
|
||||||
expect(actions.length).toEqual(2);
|
|
||||||
expect(actions).toEqual(['insert', 'update']);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,26 +0,0 @@
|
||||||
import { describe, it, expect } from 'vitest';
|
|
||||||
import VnLogValue from 'src/components/common/VnLogValue.vue';
|
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
|
||||||
|
|
||||||
const buildComponent = (props) => {
|
|
||||||
return createWrapper(VnLogValue, {
|
|
||||||
props,
|
|
||||||
global: {},
|
|
||||||
}).wrapper;
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('VnLogValue', () => {
|
|
||||||
const id = 1;
|
|
||||||
it('renders without descriptor', async () => {
|
|
||||||
expect(getIcon('inventFk').exists()).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renders with descriptor', async () => {
|
|
||||||
expect(getIcon('claimFk').text()).toBe('launch');
|
|
||||||
});
|
|
||||||
|
|
||||||
function getIcon(name) {
|
|
||||||
const wrapper = buildComponent({ value: { val: id }, name });
|
|
||||||
return wrapper.find('.q-icon');
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -1,6 +1,16 @@
|
||||||
import { describe, it, expect, vi, afterEach, beforeEach, afterAll } from 'vitest';
|
import {
|
||||||
|
describe,
|
||||||
|
it,
|
||||||
|
expect,
|
||||||
|
vi,
|
||||||
|
beforeAll,
|
||||||
|
afterEach,
|
||||||
|
beforeEach,
|
||||||
|
afterAll,
|
||||||
|
} from 'vitest';
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||||
import VnNotes from 'src/components/ui/VnNotes.vue';
|
import VnNotes from 'src/components/ui/VnNotes.vue';
|
||||||
|
import vnDate from 'src/boot/vnDate';
|
||||||
|
|
||||||
describe('VnNotes', () => {
|
describe('VnNotes', () => {
|
||||||
let vm;
|
let vm;
|
||||||
|
@ -8,7 +18,6 @@ describe('VnNotes', () => {
|
||||||
let spyFetch;
|
let spyFetch;
|
||||||
let postMock;
|
let postMock;
|
||||||
let patchMock;
|
let patchMock;
|
||||||
let deleteMock;
|
|
||||||
let expectedInsertBody;
|
let expectedInsertBody;
|
||||||
let expectedUpdateBody;
|
let expectedUpdateBody;
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
|
@ -48,7 +57,6 @@ describe('VnNotes', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
postMock = vi.spyOn(axios, 'post');
|
postMock = vi.spyOn(axios, 'post');
|
||||||
patchMock = vi.spyOn(axios, 'patch');
|
patchMock = vi.spyOn(axios, 'patch');
|
||||||
deleteMock = vi.spyOn(axios, 'delete');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -145,16 +153,4 @@ describe('VnNotes', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('delete', () => {
|
|
||||||
it('Should call axios.delete with url and vnPaginateRef.fetch', async () => {
|
|
||||||
generateWrapper();
|
|
||||||
createSpyFetch();
|
|
||||||
|
|
||||||
await vm.deleteNote({ id: 1 });
|
|
||||||
|
|
||||||
expect(deleteMock).toHaveBeenCalledWith(`${vm.$props.url}/1`);
|
|
||||||
expect(spyFetch).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,38 +1,296 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import { onBeforeMount, watch, computed, ref } from 'vue';
|
||||||
import VnDescriptor from './VnDescriptor.vue';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import SkeletonDescriptor from 'components/ui/SkeletonDescriptor.vue';
|
||||||
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
|
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||||
|
import { useState } from 'src/composables/useState';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
import VnMoreOptions from './VnMoreOptions.vue';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
id: {
|
url: {
|
||||||
type: Number,
|
type: String,
|
||||||
default: false,
|
default: '',
|
||||||
},
|
},
|
||||||
card: {
|
filter: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
subtitle: {
|
||||||
|
type: Number,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
dataKey: {
|
||||||
|
type: String,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
type: String,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
summary: {
|
||||||
|
type: Object,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
width: {
|
||||||
|
type: String,
|
||||||
|
default: 'md-width',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const state = useState();
|
||||||
|
const route = useRoute();
|
||||||
|
const { t } = useI18n();
|
||||||
|
const { viewSummary } = useSummaryDialog();
|
||||||
|
let arrayData;
|
||||||
|
let store;
|
||||||
|
let entity;
|
||||||
|
const isLoading = ref(false);
|
||||||
|
const isSameDataKey = computed(() => $props.dataKey === route.meta.moduleName);
|
||||||
|
defineExpose({ getData });
|
||||||
|
|
||||||
|
onBeforeMount(async () => {
|
||||||
|
arrayData = useArrayData($props.dataKey, {
|
||||||
|
url: $props.url,
|
||||||
|
userFilter: $props.filter,
|
||||||
|
skip: 0,
|
||||||
|
oneRecord: true,
|
||||||
|
});
|
||||||
|
store = arrayData.store;
|
||||||
|
entity = computed(() => {
|
||||||
|
const data = store.data ?? {};
|
||||||
|
if (data) emit('onFetch', data);
|
||||||
|
return data;
|
||||||
|
});
|
||||||
|
|
||||||
|
// It enables to load data only once if the module is the same as the dataKey
|
||||||
|
if (!isSameDataKey.value || !route.params.id) await getData();
|
||||||
|
watch(
|
||||||
|
() => [$props.url, $props.filter],
|
||||||
|
async () => {
|
||||||
|
if (!isSameDataKey.value) await getData();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
async function getData() {
|
||||||
|
store.url = $props.url;
|
||||||
|
store.filter = $props.filter ?? {};
|
||||||
|
isLoading.value = true;
|
||||||
|
try {
|
||||||
|
const { data } = await arrayData.fetch({ append: false, updateRouter: false });
|
||||||
|
state.set($props.dataKey, data);
|
||||||
|
emit('onFetch', data);
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getValueFromPath(path) {
|
||||||
|
if (!path) return;
|
||||||
|
const keys = path.toString().split('.');
|
||||||
|
let current = entity.value;
|
||||||
|
|
||||||
|
for (const key of keys) {
|
||||||
|
if (current[key] === undefined) return undefined;
|
||||||
|
else current = current[key];
|
||||||
|
}
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
|
||||||
const emit = defineEmits(['onFetch']);
|
const emit = defineEmits(['onFetch']);
|
||||||
const entity = ref();
|
|
||||||
|
const iconModule = computed(() => route.matched[1].meta.icon);
|
||||||
|
const toModule = computed(() =>
|
||||||
|
route.matched[1].path.split('/').length > 2
|
||||||
|
? route.matched[1].redirect
|
||||||
|
: route.matched[1].children[0].redirect,
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<component
|
<div class="descriptor">
|
||||||
:is="card"
|
<template v-if="entity && !isLoading">
|
||||||
:id
|
<div class="header bg-primary q-pa-sm justify-between">
|
||||||
:visual="false"
|
<slot name="header-extra-action"
|
||||||
v-bind="$attrs"
|
><QBtn
|
||||||
@on-fetch="
|
round
|
||||||
(data) => {
|
flat
|
||||||
entity = data;
|
dense
|
||||||
emit('onFetch', data);
|
size="md"
|
||||||
}
|
:icon="iconModule"
|
||||||
"
|
color="white"
|
||||||
/>
|
class="link"
|
||||||
<VnDescriptor v-model="entity" v-bind="$attrs">
|
:to="$attrs['to-module'] ?? toModule"
|
||||||
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
|
>
|
||||||
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
<QTooltip>
|
||||||
|
{{ t('globals.goToModuleIndex') }}
|
||||||
|
</QTooltip>
|
||||||
|
</QBtn></slot
|
||||||
|
>
|
||||||
|
<QBtn
|
||||||
|
@click.stop="viewSummary(entity.id, $props.summary, $props.width)"
|
||||||
|
round
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
size="md"
|
||||||
|
icon="preview"
|
||||||
|
color="white"
|
||||||
|
class="link"
|
||||||
|
v-if="summary"
|
||||||
|
>
|
||||||
|
<QTooltip>
|
||||||
|
{{ t('components.smartCard.openSummary') }}
|
||||||
|
</QTooltip>
|
||||||
|
</QBtn>
|
||||||
|
<RouterLink :to="{ name: `${module}Summary`, params: { id: entity.id } }">
|
||||||
|
<QBtn
|
||||||
|
class="link"
|
||||||
|
color="white"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
icon="launch"
|
||||||
|
round
|
||||||
|
size="md"
|
||||||
|
>
|
||||||
|
<QTooltip>
|
||||||
|
{{ t('components.cardDescriptor.summary') }}
|
||||||
|
</QTooltip>
|
||||||
|
</QBtn>
|
||||||
|
</RouterLink>
|
||||||
|
<VnMoreOptions v-if="$slots.menu">
|
||||||
|
<template #menu="{ menuRef }">
|
||||||
|
<slot name="menu" :entity="entity" :menu-ref="menuRef" />
|
||||||
|
</template>
|
||||||
|
</VnMoreOptions>
|
||||||
|
</div>
|
||||||
|
<slot name="before" />
|
||||||
|
<div class="body q-py-sm">
|
||||||
|
<QList dense>
|
||||||
|
<QItemLabel header class="ellipsis text-h5" :lines="1">
|
||||||
|
<div class="title">
|
||||||
|
<span v-if="$props.title" :title="getValueFromPath(title)">
|
||||||
|
{{ getValueFromPath(title) ?? $props.title }}
|
||||||
|
</span>
|
||||||
|
<slot v-else name="description" :entity="entity">
|
||||||
|
<span :title="entity.name">
|
||||||
|
{{ entity.name }}
|
||||||
|
</span>
|
||||||
|
</slot>
|
||||||
|
</div>
|
||||||
|
</QItemLabel>
|
||||||
|
<QItem dense>
|
||||||
|
<QItemLabel class="subtitle" caption>
|
||||||
|
#{{ getValueFromPath(subtitle) ?? entity.id }}
|
||||||
|
</QItemLabel>
|
||||||
|
</QItem>
|
||||||
|
</QList>
|
||||||
|
<div class="list-box q-mt-xs">
|
||||||
|
<slot name="body" :entity="entity" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="icons">
|
||||||
|
<slot name="icons" :entity="entity" />
|
||||||
|
</div>
|
||||||
|
<div class="actions justify-center">
|
||||||
|
<slot name="actions" :entity="entity" />
|
||||||
|
</div>
|
||||||
|
<slot name="after" />
|
||||||
</template>
|
</template>
|
||||||
</VnDescriptor>
|
<!-- Skeleton -->
|
||||||
|
<SkeletonDescriptor v-if="!entity || isLoading" />
|
||||||
|
</div>
|
||||||
|
<QInnerLoading
|
||||||
|
:label="t('globals.pleaseWait')"
|
||||||
|
:showing="isLoading"
|
||||||
|
color="primary"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.body {
|
||||||
|
background-color: var(--vn-section-color);
|
||||||
|
.text-h5 {
|
||||||
|
font-size: 20px;
|
||||||
|
padding-top: 5px;
|
||||||
|
padding-bottom: 0px;
|
||||||
|
}
|
||||||
|
.q-item {
|
||||||
|
min-height: 20px;
|
||||||
|
|
||||||
|
.link {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.vn-label-value {
|
||||||
|
display: flex;
|
||||||
|
padding: 0px 16px;
|
||||||
|
.label {
|
||||||
|
color: var(--vn-label-color);
|
||||||
|
font-size: 14px;
|
||||||
|
|
||||||
|
&:not(:has(a))::after {
|
||||||
|
content: ':';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.value {
|
||||||
|
color: var(--vn-text-color);
|
||||||
|
font-size: 14px;
|
||||||
|
margin-left: 4px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.info {
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.title {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
span {
|
||||||
|
color: var(--vn-text-color);
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.subtitle {
|
||||||
|
color: var(--vn-text-color);
|
||||||
|
font-size: 16px;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
}
|
||||||
|
.list-box {
|
||||||
|
.q-item__label {
|
||||||
|
color: var(--vn-label-color);
|
||||||
|
padding-bottom: 0%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.descriptor {
|
||||||
|
width: 256px;
|
||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.icons {
|
||||||
|
margin: 0 10px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
.q-icon {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.actions {
|
||||||
|
margin: 0 5px;
|
||||||
|
justify-content: center !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
@ -81,7 +81,6 @@ async function fetch() {
|
||||||
name: `${moduleName ?? route.meta.moduleName}Summary`,
|
name: `${moduleName ?? route.meta.moduleName}Summary`,
|
||||||
params: { id: entityId || entity.id },
|
params: { id: entityId || entity.id },
|
||||||
}"
|
}"
|
||||||
data-cy="goToSummaryBtn"
|
|
||||||
>
|
>
|
||||||
<QIcon name="open_in_new" color="white" size="sm" />
|
<QIcon name="open_in_new" color="white" size="sm" />
|
||||||
</router-link>
|
</router-link>
|
||||||
|
@ -159,7 +158,6 @@ async function fetch() {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
align-items: start;
|
|
||||||
.label {
|
.label {
|
||||||
color: var(--vn-label-color);
|
color: var(--vn-label-color);
|
||||||
width: 9em;
|
width: 9em;
|
||||||
|
@ -170,10 +168,6 @@ async function fetch() {
|
||||||
flex-grow: 0;
|
flex-grow: 0;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
&.ellipsis > .value {
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: pre;
|
|
||||||
}
|
|
||||||
.value {
|
.value {
|
||||||
color: var(--vn-text-color);
|
color: var(--vn-text-color);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
@ -206,29 +200,6 @@ async function fetch() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.vn-card-group {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vn-card-content {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
> div {
|
|
||||||
max-height: 70px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1010px) {
|
|
||||||
.vn-card-group {
|
|
||||||
flex-direction: row;
|
|
||||||
}
|
|
||||||
.vn-card-content {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.summaryHeader .vn-label-value {
|
.summaryHeader .vn-label-value {
|
||||||
|
|
|
@ -132,8 +132,7 @@ const card = toRef(props, 'item');
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
white-space: nowrap;
|
|
||||||
width: 192px;
|
|
||||||
p {
|
p {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,78 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { onBeforeMount, watch, computed, ref } from 'vue';
|
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
|
||||||
import { useState } from 'src/composables/useState';
|
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
import VnDescriptor from './VnDescriptor.vue';
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
url: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
dataKey: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const state = useState();
|
|
||||||
const route = useRoute();
|
|
||||||
let arrayData;
|
|
||||||
let store;
|
|
||||||
let entity;
|
|
||||||
const isLoading = ref(false);
|
|
||||||
const isSameDataKey = computed(() => $props.dataKey === route.meta.moduleName);
|
|
||||||
defineExpose({ getData });
|
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
|
||||||
arrayData = useArrayData($props.dataKey, {
|
|
||||||
url: $props.url,
|
|
||||||
userFilter: $props.filter,
|
|
||||||
skip: 0,
|
|
||||||
oneRecord: true,
|
|
||||||
});
|
|
||||||
store = arrayData.store;
|
|
||||||
entity = computed(() => {
|
|
||||||
const data = store.data ?? {};
|
|
||||||
if (data) emit('onFetch', data);
|
|
||||||
return data;
|
|
||||||
});
|
|
||||||
|
|
||||||
// It enables to load data only once if the module is the same as the dataKey
|
|
||||||
if (!isSameDataKey.value || !route.params.id) await getData();
|
|
||||||
watch(
|
|
||||||
() => [$props.url, $props.filter],
|
|
||||||
async () => {
|
|
||||||
if (!isSameDataKey.value) await getData();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
async function getData() {
|
|
||||||
store.url = $props.url;
|
|
||||||
store.filter = $props.filter ?? {};
|
|
||||||
isLoading.value = true;
|
|
||||||
try {
|
|
||||||
const { data } = await arrayData.fetch({ append: false, updateRouter: false });
|
|
||||||
state.set($props.dataKey, data);
|
|
||||||
emit('onFetch', data);
|
|
||||||
} finally {
|
|
||||||
isLoading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const emit = defineEmits(['onFetch']);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<VnDescriptor v-model="entity" v-bind="$attrs" :module="dataKey">
|
|
||||||
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
|
|
||||||
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
|
||||||
</template>
|
|
||||||
</VnDescriptor>
|
|
||||||
</template>
|
|
|
@ -1,318 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { computed, ref } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import SkeletonDescriptor from 'components/ui/SkeletonDescriptor.vue';
|
|
||||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
|
||||||
import { useClipboard } from 'src/composables/useClipboard';
|
|
||||||
import VnMoreOptions from './VnMoreOptions.vue';
|
|
||||||
|
|
||||||
const entity = defineModel({ type: Object, default: null });
|
|
||||||
const $props = defineProps({
|
|
||||||
title: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
subtitle: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
summary: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: 'md-width',
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
toModule: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
const router = useRouter();
|
|
||||||
const { t } = useI18n();
|
|
||||||
const { copyText } = useClipboard();
|
|
||||||
const { viewSummary } = useSummaryDialog();
|
|
||||||
const DESCRIPTOR_PROXY = 'DescriptorProxy';
|
|
||||||
const moduleName = ref();
|
|
||||||
const isSameModuleName = route.matched[1].meta.moduleName !== moduleName.value;
|
|
||||||
|
|
||||||
function getName() {
|
|
||||||
let name = $props.module;
|
|
||||||
if ($props.module.includes(DESCRIPTOR_PROXY)) {
|
|
||||||
name = name.split(DESCRIPTOR_PROXY)[0];
|
|
||||||
}
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
const routeName = computed(() => {
|
|
||||||
let routeName = getName();
|
|
||||||
return `${routeName}Summary`;
|
|
||||||
});
|
|
||||||
|
|
||||||
function getValueFromPath(path) {
|
|
||||||
if (!path) return;
|
|
||||||
const keys = path.toString().split('.');
|
|
||||||
let current = entity.value;
|
|
||||||
|
|
||||||
for (const key of keys) {
|
|
||||||
if (current[key] === undefined) return undefined;
|
|
||||||
else current = current[key];
|
|
||||||
}
|
|
||||||
return current;
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyIdText(id) {
|
|
||||||
copyText(id, {
|
|
||||||
component: {
|
|
||||||
copyValue: id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const emit = defineEmits(['onFetch']);
|
|
||||||
|
|
||||||
const iconModule = computed(() => {
|
|
||||||
moduleName.value = getName();
|
|
||||||
if ($props.toModule) {
|
|
||||||
return router.getRoutes().find((r) => r.name === $props.toModule.name).meta.icon;
|
|
||||||
}
|
|
||||||
if (isSameModuleName) {
|
|
||||||
return router.options.routes[1].children.find((r) => r.name === moduleName.value)
|
|
||||||
?.meta?.icon;
|
|
||||||
} else {
|
|
||||||
return route.matched[1].meta.icon;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const toModule = computed(() => {
|
|
||||||
moduleName.value = getName();
|
|
||||||
if ($props.toModule) return $props.toModule;
|
|
||||||
if (isSameModuleName) {
|
|
||||||
return router.options.routes[1].children.find((r) => r.name === moduleName.value)
|
|
||||||
?.redirect;
|
|
||||||
} else {
|
|
||||||
return route.matched[1].path.split('/').length > 2
|
|
||||||
? route.matched[1].redirect
|
|
||||||
: route.matched[1].children[0].redirect;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="descriptor" data-cy="vnDescriptor">
|
|
||||||
<template v-if="entity && entity?.id">
|
|
||||||
<div class="header bg-primary q-pa-sm justify-between">
|
|
||||||
<slot name="header-extra-action">
|
|
||||||
<QBtn
|
|
||||||
round
|
|
||||||
flat
|
|
||||||
dense
|
|
||||||
size="md"
|
|
||||||
:icon="iconModule"
|
|
||||||
color="white"
|
|
||||||
class="link"
|
|
||||||
:to="toModule"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ t('globals.goToModuleIndex') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</slot>
|
|
||||||
<QBtn
|
|
||||||
@click.stop="viewSummary(entity.id, summary, width)"
|
|
||||||
round
|
|
||||||
flat
|
|
||||||
dense
|
|
||||||
size="md"
|
|
||||||
icon="preview"
|
|
||||||
color="white"
|
|
||||||
class="link"
|
|
||||||
v-if="summary"
|
|
||||||
data-cy="openSummaryBtn"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ t('components.smartCard.openSummary') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
<RouterLink :to="{ name: routeName, params: { id: entity.id } }">
|
|
||||||
<QBtn
|
|
||||||
class="link"
|
|
||||||
color="white"
|
|
||||||
dense
|
|
||||||
flat
|
|
||||||
icon="launch"
|
|
||||||
round
|
|
||||||
size="md"
|
|
||||||
data-cy="goToSummaryBtn"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ t('components.vnDescriptor.summary') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</RouterLink>
|
|
||||||
<VnMoreOptions v-if="$slots.menu">
|
|
||||||
<template #menu="{ menuRef }">
|
|
||||||
<slot name="menu" :entity="entity" :menu-ref="menuRef" />
|
|
||||||
</template>
|
|
||||||
</VnMoreOptions>
|
|
||||||
</div>
|
|
||||||
<slot name="before" />
|
|
||||||
<div class="body q-py-sm">
|
|
||||||
<QList dense>
|
|
||||||
<QItemLabel header class="ellipsis text-h5" :lines="1">
|
|
||||||
<div class="title">
|
|
||||||
<span
|
|
||||||
v-if="title"
|
|
||||||
:title="getValueFromPath(title)"
|
|
||||||
:data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_title`"
|
|
||||||
>
|
|
||||||
{{ getValueFromPath(title) ?? title }}
|
|
||||||
</span>
|
|
||||||
<slot v-else name="description" :entity="entity">
|
|
||||||
<span
|
|
||||||
:title="entity.name"
|
|
||||||
:data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_description`"
|
|
||||||
v-text="entity.name"
|
|
||||||
/>
|
|
||||||
</slot>
|
|
||||||
</div>
|
|
||||||
</QItemLabel>
|
|
||||||
<QItem>
|
|
||||||
<QItemLabel
|
|
||||||
class="subtitle"
|
|
||||||
:data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_subtitle`"
|
|
||||||
>
|
|
||||||
#{{ getValueFromPath(subtitle) ?? entity.id }}
|
|
||||||
</QItemLabel>
|
|
||||||
<QBtn
|
|
||||||
round
|
|
||||||
flat
|
|
||||||
dense
|
|
||||||
size="sm"
|
|
||||||
icon="content_copy"
|
|
||||||
color="primary"
|
|
||||||
@click.stop="copyIdText(entity.id)"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ t('globals.copyId') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</QItem>
|
|
||||||
</QList>
|
|
||||||
<div
|
|
||||||
class="list-box q-mt-xs"
|
|
||||||
:data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_listbox`"
|
|
||||||
>
|
|
||||||
<slot name="body" :entity="entity" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="icons">
|
|
||||||
<slot name="icons" :entity="entity" />
|
|
||||||
</div>
|
|
||||||
<div class="actions justify-center" data-cy="descriptor_actions">
|
|
||||||
<slot name="actions" :entity="entity" />
|
|
||||||
</div>
|
|
||||||
<slot name="after" />
|
|
||||||
</template>
|
|
||||||
<SkeletonDescriptor v-if="!entity" />
|
|
||||||
</div>
|
|
||||||
<QInnerLoading :label="t('globals.pleaseWait')" :showing="!entity" color="primary" />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
.body {
|
|
||||||
background-color: var(--vn-section-color);
|
|
||||||
.text-h5 {
|
|
||||||
font-size: 20px;
|
|
||||||
padding-top: 5px;
|
|
||||||
padding-bottom: 0px;
|
|
||||||
}
|
|
||||||
.q-item {
|
|
||||||
min-height: 20px;
|
|
||||||
|
|
||||||
.link {
|
|
||||||
margin-left: 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.vn-label-value {
|
|
||||||
display: flex;
|
|
||||||
padding: 0px 16px;
|
|
||||||
.label {
|
|
||||||
color: var(--vn-label-color);
|
|
||||||
font-size: 14px;
|
|
||||||
|
|
||||||
&:not(:has(a))::after {
|
|
||||||
content: ':';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.value {
|
|
||||||
color: var(--vn-text-color);
|
|
||||||
font-size: 14px;
|
|
||||||
margin-left: 4px;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
.info {
|
|
||||||
margin-left: 5px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.title {
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
span {
|
|
||||||
color: var(--vn-text-color);
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.subtitle {
|
|
||||||
color: var(--vn-text-color);
|
|
||||||
font-size: 16px;
|
|
||||||
margin-bottom: 2px;
|
|
||||||
}
|
|
||||||
.list-box {
|
|
||||||
.q-item__label {
|
|
||||||
color: var(--vn-label-color);
|
|
||||||
padding-bottom: 0%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.descriptor {
|
|
||||||
width: 256px;
|
|
||||||
.header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
.icons {
|
|
||||||
margin: 0 10px;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
.q-icon {
|
|
||||||
margin-right: 5px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.actions {
|
|
||||||
margin: 0 5px;
|
|
||||||
justify-content: center !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<i18n>
|
|
||||||
en:
|
|
||||||
globals:
|
|
||||||
copyId: Copy ID
|
|
||||||
es:
|
|
||||||
globals:
|
|
||||||
copyId: Copiar ID
|
|
||||||
</i18n>
|
|
|
@ -54,17 +54,13 @@ const $props = defineProps({
|
||||||
default: 'table',
|
default: 'table',
|
||||||
},
|
},
|
||||||
redirect: {
|
redirect: {
|
||||||
type: [String, Boolean],
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
arrayData: {
|
arrayData: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
showTagChips: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits([
|
const emit = defineEmits([
|
||||||
|
@ -92,14 +88,13 @@ const userOrders = ref(useFilterParams($props.dataKey).orders);
|
||||||
defineExpose({ search, params: userParams, remove });
|
defineExpose({ search, params: userParams, remove });
|
||||||
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
async function search(evt, name, value) {
|
async function search(evt) {
|
||||||
try {
|
try {
|
||||||
if (evt && $props.disableSubmitEvent) return;
|
if (evt && $props.disableSubmitEvent) return;
|
||||||
|
|
||||||
store.filter.where = {};
|
store.filter.where = {};
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
const filter = { ...userParams.value, ...$props.modelValue };
|
const filter = { ...userParams.value, ...$props.modelValue };
|
||||||
if (name) filter[name] = value;
|
|
||||||
store.userParamsChanged = true;
|
store.userParamsChanged = true;
|
||||||
await arrayData.addFilter({
|
await arrayData.addFilter({
|
||||||
params: filter,
|
params: filter,
|
||||||
|
@ -219,7 +214,7 @@ const getLocale = (label) => {
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QBtn>
|
</QBtn>
|
||||||
<QForm @submit="search" id="filterPanelForm" @keyup.enter="search()">
|
<QForm @submit="search" id="filterPanelForm" @keyup.enter="search()">
|
||||||
<QList dense v-if="showTagChips">
|
<QList dense>
|
||||||
<QItem class="q-mt-xs">
|
<QItem class="q-mt-xs">
|
||||||
<QItemSection top>
|
<QItemSection top>
|
||||||
<QItemLabel header lines="1" class="text-uppercase q-py-xs q-px-none">
|
<QItemLabel header lines="1" class="text-uppercase q-py-xs q-px-none">
|
||||||
|
@ -254,7 +249,7 @@ const getLocale = (label) => {
|
||||||
:key="chip.label"
|
:key="chip.label"
|
||||||
:removable="!unremovableParams?.includes(chip.label)"
|
:removable="!unremovableParams?.includes(chip.label)"
|
||||||
@remove="remove(chip.label)"
|
@remove="remove(chip.label)"
|
||||||
:data-cy="`vnFilterPanelChip_${chip.label}`"
|
data-cy="vnFilterPanelChip"
|
||||||
>
|
>
|
||||||
<slot
|
<slot
|
||||||
name="tags"
|
name="tags"
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { dashIfEmpty } from 'src/filters';
|
|
||||||
|
|
||||||
defineProps({ email: { type: [String], default: null } });
|
defineProps({ email: { type: [String], default: null } });
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<QBtn
|
<QBtn
|
||||||
class="q-pr-xs"
|
|
||||||
v-if="email"
|
v-if="email"
|
||||||
flat
|
flat
|
||||||
round
|
round
|
||||||
|
@ -16,5 +13,4 @@ defineProps({ email: { type: [String], default: null } });
|
||||||
:href="`mailto:${email}`"
|
:href="`mailto:${email}`"
|
||||||
@click.stop
|
@click.stop
|
||||||
/>
|
/>
|
||||||
<span>{{ dashIfEmpty(email) }}</span>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive, useAttrs, onBeforeMount, capitalize } from 'vue';
|
import { ref, reactive, useAttrs, onBeforeMount, capitalize } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { dashIfEmpty, parsePhone } from 'src/filters';
|
import { parsePhone } from 'src/filters';
|
||||||
import useOpenURL from 'src/composables/useOpenURL';
|
import useOpenURL from 'src/composables/useOpenURL';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
@ -12,65 +12,49 @@ const props = defineProps({
|
||||||
|
|
||||||
const phone = ref(props.phoneNumber);
|
const phone = ref(props.phoneNumber);
|
||||||
const config = reactive({
|
const config = reactive({
|
||||||
|
sip: { icon: 'phone', href: `sip:${props.phoneNumber}` },
|
||||||
'say-simple': {
|
'say-simple': {
|
||||||
icon: 'vn:saysimple',
|
icon: 'vn:saysimple',
|
||||||
url: null,
|
url: null,
|
||||||
channel: props.channel,
|
channel: props.channel,
|
||||||
},
|
},
|
||||||
sip: { icon: 'phone', href: `sip:${props.phoneNumber}` },
|
|
||||||
});
|
});
|
||||||
|
const type = Object.keys(config).find((key) => key in useAttrs()) || 'sip';
|
||||||
const attrs = useAttrs();
|
|
||||||
const types = Object.keys(config)
|
|
||||||
.filter((key) => key in attrs)
|
|
||||||
.sort();
|
|
||||||
const activeTypes = types.length ? types : ['sip'];
|
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
if (!phone.value) return;
|
if (!phone.value) return;
|
||||||
|
let { channel } = config[type];
|
||||||
|
|
||||||
for (const type of activeTypes) {
|
if (type === 'say-simple') {
|
||||||
if (type === 'say-simple') {
|
const { url, defaultChannel } = (await axios.get('SaySimpleConfigs/findOne'))
|
||||||
let { channel } = config[type];
|
.data;
|
||||||
const { url, defaultChannel } = (await axios.get('SaySimpleConfigs/findOne'))
|
if (!channel) channel = defaultChannel;
|
||||||
.data;
|
|
||||||
if (!channel) channel = defaultChannel;
|
|
||||||
|
|
||||||
phone.value = await parsePhone(
|
phone.value = await parsePhone(props.phoneNumber, props.country?.toLowerCase());
|
||||||
props.phoneNumber,
|
config[
|
||||||
props.country?.toLowerCase(),
|
type
|
||||||
);
|
].url = `${url}?customerIdentity=%2B${phone.value}&channelId=${channel}`;
|
||||||
config[type].url =
|
|
||||||
`${url}?customerIdentity=%2B${phone.value}&channelId=${channel}`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleClick(type) {
|
function handleClick() {
|
||||||
if (config[type].url) useOpenURL(config[type].url);
|
if (config[type].url) useOpenURL(config[type].url);
|
||||||
else if (config[type].href) window.location.href = config[type].href;
|
else if (config[type].href) window.location.href = config[type].href;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex items-center gap-2">
|
<QBtn
|
||||||
<template v-for="type in activeTypes">
|
v-if="phone"
|
||||||
<QBtn
|
flat
|
||||||
:key="type"
|
round
|
||||||
v-if="phone"
|
:icon="config[type].icon"
|
||||||
flat
|
size="sm"
|
||||||
round
|
color="primary"
|
||||||
:icon="config[type].icon"
|
padding="none"
|
||||||
size="sm"
|
@click.stop="handleClick"
|
||||||
color="primary"
|
>
|
||||||
padding="none"
|
<QTooltip>
|
||||||
@click.stop="() => handleClick(type)"
|
{{ capitalize(type).replace('-', '') }}
|
||||||
>
|
</QTooltip>
|
||||||
<QTooltip>
|
</QBtn>
|
||||||
{{ capitalize(type).replace('-', '') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn></template
|
|
||||||
>
|
|
||||||
<span>{{ dashIfEmpty(phone) }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -28,14 +28,13 @@ function copyValueText() {
|
||||||
const val = computed(() => $props.value);
|
const val = computed(() => $props.value);
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="vn-label-value" :data-cy="`${$attrs['data-cy'] ?? 'vnLv'}${label ?? ''}`">
|
<div class="vn-label-value">
|
||||||
<QCheckbox
|
<QCheckbox
|
||||||
v-if="typeof value === 'boolean'"
|
v-if="typeof value === 'boolean'"
|
||||||
v-model="val"
|
v-model="val"
|
||||||
:label="label"
|
:label="label"
|
||||||
disable
|
disable
|
||||||
dense
|
dense
|
||||||
size="sm"
|
|
||||||
/>
|
/>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div v-if="label || $slots.label" class="label">
|
<div v-if="label || $slots.label" class="label">
|
||||||
|
@ -43,9 +42,9 @@ const val = computed(() => $props.value);
|
||||||
<span style="color: var(--vn-label-color)">{{ label }}</span>
|
<span style="color: var(--vn-label-color)">{{ label }}</span>
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
<div class="value" v-if="value || $slots.value">
|
<div class="value">
|
||||||
<slot name="value">
|
<slot name="value">
|
||||||
<span :title="value" style="text-overflow: ellipsis">
|
<span :title="value">
|
||||||
{{ dash ? dashIfEmpty(value) : value }}
|
{{ dash ? dashIfEmpty(value) : value }}
|
||||||
</span>
|
</span>
|
||||||
</slot>
|
</slot>
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
data-cy="descriptor-more-opts"
|
data-cy="descriptor-more-opts"
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ $t('components.vnDescriptor.moreOptions') }}
|
{{ $t('components.cardDescriptor.moreOptions') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
<QMenu ref="menuRef" data-cy="descriptor-more-opts-menu">
|
<QMenu ref="menuRef" data-cy="descriptor-more-opts-menu">
|
||||||
<QList data-cy="descriptor-more-opts_list">
|
<QList>
|
||||||
<slot name="menu" :menu-ref="$refs.menuRef" />
|
<slot name="menu" :menu-ref="$refs.menuRef" />
|
||||||
</QList>
|
</QList>
|
||||||
</QMenu>
|
</QMenu>
|
||||||
|
|
|
@ -19,15 +19,19 @@ import VnInput from 'components/common/VnInput.vue';
|
||||||
const emit = defineEmits(['onFetch']);
|
const emit = defineEmits(['onFetch']);
|
||||||
|
|
||||||
const originalAttrs = useAttrs();
|
const originalAttrs = useAttrs();
|
||||||
|
|
||||||
const $attrs = computed(() => {
|
const $attrs = computed(() => {
|
||||||
const { required, deletable, ...rest } = originalAttrs;
|
const { style, ...rest } = originalAttrs;
|
||||||
return rest;
|
return rest;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isRequired = computed(() => {
|
||||||
|
return Object.keys($attrs).includes('required')
|
||||||
|
});
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
url: { type: String, default: null },
|
url: { type: String, default: null },
|
||||||
saveUrl: { type: String, default: null },
|
saveUrl: {type: String, default: null},
|
||||||
userFilter: { type: Object, default: () => {} },
|
|
||||||
filter: { type: Object, default: () => {} },
|
filter: { type: Object, default: () => {} },
|
||||||
body: { type: Object, default: () => {} },
|
body: { type: Object, default: () => {} },
|
||||||
addNote: { type: Boolean, default: false },
|
addNote: { type: Boolean, default: false },
|
||||||
|
@ -40,11 +44,6 @@ const quasar = useQuasar();
|
||||||
const newNote = reactive({ text: null, observationTypeFk: null });
|
const newNote = reactive({ text: null, observationTypeFk: null });
|
||||||
const observationTypes = ref([]);
|
const observationTypes = ref([]);
|
||||||
const vnPaginateRef = ref();
|
const vnPaginateRef = ref();
|
||||||
|
|
||||||
const defaultObservationType = computed(() =>
|
|
||||||
observationTypes.value.find(ot => ot.code === 'salesPerson')?.id
|
|
||||||
);
|
|
||||||
|
|
||||||
let originalText;
|
let originalText;
|
||||||
|
|
||||||
function handleClick(e) {
|
function handleClick(e) {
|
||||||
|
@ -53,11 +52,6 @@ function handleClick(e) {
|
||||||
else insert();
|
else insert();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteNote(e) {
|
|
||||||
await axios.delete(`${$props.url}/${e.id}`);
|
|
||||||
await vnPaginateRef.value.fetch();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function insert() {
|
async function insert() {
|
||||||
if (!newNote.text || ($props.selectType && !newNote.observationTypeFk)) return;
|
if (!newNote.text || ($props.selectType && !newNote.observationTypeFk)) return;
|
||||||
|
|
||||||
|
@ -71,7 +65,7 @@ async function insert() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function confirmAndUpdate() {
|
function confirmAndUpdate() {
|
||||||
if (!newNote.text && originalText)
|
if(!newNote.text && originalText)
|
||||||
quasar
|
quasar
|
||||||
.dialog({
|
.dialog({
|
||||||
component: VnConfirm,
|
component: VnConfirm,
|
||||||
|
@ -94,17 +88,11 @@ async function update() {
|
||||||
...body,
|
...body,
|
||||||
...{ notes: newNote.text },
|
...{ notes: newNote.text },
|
||||||
};
|
};
|
||||||
await axios.patch(
|
await axios.patch(`${$props.saveUrl ?? `${$props.url}/${$props.body.workerFk}`}`, newBody);
|
||||||
`${$props.saveUrl ?? `${$props.url}/${$props.body.workerFk}`}`,
|
|
||||||
newBody,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onBeforeRouteLeave((to, from, next) => {
|
onBeforeRouteLeave((to, from, next) => {
|
||||||
if (
|
if ((newNote.text && !$props.justInput) || (newNote.text !== originalText) && $props.justInput)
|
||||||
(newNote.text && !$props.justInput) ||
|
|
||||||
(newNote.text !== originalText && $props.justInput)
|
|
||||||
)
|
|
||||||
quasar.dialog({
|
quasar.dialog({
|
||||||
component: VnConfirm,
|
component: VnConfirm,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
@ -116,27 +104,20 @@ onBeforeRouteLeave((to, from, next) => {
|
||||||
else next();
|
else next();
|
||||||
});
|
});
|
||||||
|
|
||||||
function fetchData([data]) {
|
function fetchData([ data ]) {
|
||||||
newNote.text = data?.notes;
|
newNote.text = data?.notes;
|
||||||
originalText = data?.notes;
|
originalText = data?.notes;
|
||||||
emit('onFetch', data);
|
emit('onFetch', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleObservationTypes = (data) => {
|
|
||||||
observationTypes.value = data;
|
|
||||||
if(defaultObservationType.value) {
|
|
||||||
newNote.observationTypeFk = defaultObservationType.value;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
v-if="selectType"
|
v-if="selectType"
|
||||||
url="ObservationTypes"
|
url="ObservationTypes"
|
||||||
:filter="{ fields: ['id', 'description', 'code'] }"
|
:filter="{ fields: ['id', 'description'] }"
|
||||||
auto-load
|
auto-load
|
||||||
@on-fetch="handleObservationTypes"
|
@on-fetch="(data) => (observationTypes = data)"
|
||||||
/>
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
v-if="justInput"
|
v-if="justInput"
|
||||||
|
@ -145,8 +126,8 @@ const handleObservationTypes = (data) => {
|
||||||
@on-fetch="fetchData"
|
@on-fetch="fetchData"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<QCard
|
<QCard
|
||||||
class="q-pa-xs q-mb-lg full-width"
|
class="q-pa-xs q-mb-lg full-width"
|
||||||
:class="{ 'just-input': $props.justInput }"
|
:class="{ 'just-input': $props.justInput }"
|
||||||
v-if="$props.addNote || $props.justInput"
|
v-if="$props.addNote || $props.justInput"
|
||||||
>
|
>
|
||||||
|
@ -162,7 +143,7 @@ const handleObservationTypes = (data) => {
|
||||||
v-model="newNote.observationTypeFk"
|
v-model="newNote.observationTypeFk"
|
||||||
option-label="description"
|
option-label="description"
|
||||||
style="flex: 0.15"
|
style="flex: 0.15"
|
||||||
:required="'required' in originalAttrs"
|
:required="isRequired"
|
||||||
@keyup.enter.stop="insert"
|
@keyup.enter.stop="insert"
|
||||||
/>
|
/>
|
||||||
<VnInput
|
<VnInput
|
||||||
|
@ -170,10 +151,10 @@ const handleObservationTypes = (data) => {
|
||||||
type="textarea"
|
type="textarea"
|
||||||
:label="$props.justInput && newNote.text ? '' : t('Add note here...')"
|
:label="$props.justInput && newNote.text ? '' : t('Add note here...')"
|
||||||
filled
|
filled
|
||||||
|
size="lg"
|
||||||
autogrow
|
autogrow
|
||||||
autofocus
|
|
||||||
@keyup.enter.stop="handleClick"
|
@keyup.enter.stop="handleClick"
|
||||||
:required="'required' in originalAttrs"
|
:required="isRequired"
|
||||||
clearable
|
clearable
|
||||||
>
|
>
|
||||||
<template #append>
|
<template #append>
|
||||||
|
@ -198,15 +179,15 @@ const handleObservationTypes = (data) => {
|
||||||
:url="$props.url"
|
:url="$props.url"
|
||||||
order="created DESC"
|
order="created DESC"
|
||||||
:limit="0"
|
:limit="0"
|
||||||
:user-filter="userFilter"
|
:user-filter="$props.filter"
|
||||||
:filter="filter"
|
|
||||||
auto-load
|
auto-load
|
||||||
ref="vnPaginateRef"
|
ref="vnPaginateRef"
|
||||||
class="show"
|
class="show"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
:search-url="false"
|
search-url="notes"
|
||||||
@on-fetch="
|
@on-fetch="
|
||||||
newNote.text = '';
|
newNote.text = '';
|
||||||
|
newNote.observationTypeFk = null;
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<template #body="{ rows }">
|
<template #body="{ rows }">
|
||||||
|
@ -237,27 +218,12 @@ const handleObservationTypes = (data) => {
|
||||||
>
|
>
|
||||||
{{
|
{{
|
||||||
observationTypes.find(
|
observationTypes.find(
|
||||||
(ot) => ot.id === note.observationTypeFk,
|
(ot) => ot.id === note.observationTypeFk
|
||||||
)?.description
|
)?.description
|
||||||
}}
|
}}
|
||||||
</QBadge>
|
</QBadge>
|
||||||
</div>
|
</div>
|
||||||
<span v-text="toDateHourMin(note.created)" />
|
<span v-text="toDateHourMin(note.created)" />
|
||||||
<div>
|
|
||||||
<QIcon
|
|
||||||
v-if="'deletable' in originalAttrs"
|
|
||||||
name="delete"
|
|
||||||
size="sm"
|
|
||||||
class="cursor-pointer"
|
|
||||||
color="primary"
|
|
||||||
@click="deleteNote(note)"
|
|
||||||
data-cy="notesRemoveNoteBtn"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ t('ticketNotes.removeNote') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<QCardSection class="q-pa-xs q-my-none q-py-none">
|
<QCardSection class="q-pa-xs q-my-none q-py-none">
|
||||||
|
|
|
@ -115,7 +115,7 @@ onMounted(async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
arrayData.reset(['data']);
|
if (!store.keepData) arrayData.reset(['data']);
|
||||||
arrayData.resetPagination();
|
arrayData.resetPagination();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -215,7 +215,6 @@ defineExpose({
|
||||||
paginate,
|
paginate,
|
||||||
userParams: arrayData.store.userParams,
|
userParams: arrayData.store.userParams,
|
||||||
currentFilter: arrayData.store.currentFilter,
|
currentFilter: arrayData.store.currentFilter,
|
||||||
arrayData,
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,6 @@ const props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
userFilter: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
filter: {
|
filter: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null,
|
default: null,
|
||||||
|
@ -208,9 +204,8 @@ async function search() {
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.q-field--focused) {
|
:deep(.q-field--focused) {
|
||||||
.q-icon,
|
.q-icon {
|
||||||
.q-placeholder {
|
color: black;
|
||||||
color: var(--vn-black-text-color);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ const id = props.entityId;
|
||||||
:to="{ name: routeName, params: { id: id } }"
|
:to="{ name: routeName, params: { id: id } }"
|
||||||
class="header link"
|
class="header link"
|
||||||
:href="url"
|
:href="url"
|
||||||
data-cy="goToSummaryBtn"
|
|
||||||
>
|
>
|
||||||
<QIcon name="open_in_new" color="white" size="sm" />
|
<QIcon name="open_in_new" color="white" size="sm" />
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
|
@ -53,8 +53,3 @@ const manaCode = ref(props.manaCode);
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
Promotion mana: Maná promoción
|
|
||||||
Claim mana: Maná reclamación
|
|
||||||
</i18n>
|
|
||||||
|
|
|
@ -6,12 +6,10 @@ const session = useSession();
|
||||||
const token = session.getToken();
|
const token = session.getToken();
|
||||||
|
|
||||||
describe('downloadFile', () => {
|
describe('downloadFile', () => {
|
||||||
|
const baseUrl = 'http://localhost:9000';
|
||||||
let defaulCreateObjectURL;
|
let defaulCreateObjectURL;
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
vi.mock('src/composables/getUrl', () => ({
|
|
||||||
getUrl: vi.fn().mockResolvedValue(''),
|
|
||||||
}));
|
|
||||||
defaulCreateObjectURL = window.URL.createObjectURL;
|
defaulCreateObjectURL = window.URL.createObjectURL;
|
||||||
window.URL.createObjectURL = vi.fn(() => 'blob:http://localhost:9000/blob-id');
|
window.URL.createObjectURL = vi.fn(() => 'blob:http://localhost:9000/blob-id');
|
||||||
});
|
});
|
||||||
|
@ -24,14 +22,15 @@ describe('downloadFile', () => {
|
||||||
headers: { 'content-disposition': 'attachment; filename="test-file.txt"' },
|
headers: { 'content-disposition': 'attachment; filename="test-file.txt"' },
|
||||||
};
|
};
|
||||||
vi.spyOn(axios, 'get').mockImplementation((url) => {
|
vi.spyOn(axios, 'get').mockImplementation((url) => {
|
||||||
if (url.includes('downloadFile')) return Promise.resolve(res);
|
if (url == 'Urls/getUrl') return Promise.resolve({ data: baseUrl });
|
||||||
|
else if (url.includes('downloadFile')) return Promise.resolve(res);
|
||||||
});
|
});
|
||||||
|
|
||||||
await downloadFile(1);
|
await downloadFile(1);
|
||||||
|
|
||||||
expect(axios.get).toHaveBeenCalledWith(
|
expect(axios.get).toHaveBeenCalledWith(
|
||||||
`/api/dms/1/downloadFile?access_token=${token}`,
|
`${baseUrl}/api/dms/1/downloadFile?access_token=${token}`,
|
||||||
{ responseType: 'blob' },
|
{ responseType: 'blob' }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
import { describe, it, expect, vi } from 'vitest';
|
|
||||||
import { useRequired } from '../useRequired';
|
|
||||||
|
|
||||||
vi.mock('../useValidator', () => ({
|
|
||||||
useValidator: () => ({
|
|
||||||
validations: () => ({
|
|
||||||
required: vi.fn((isRequired, val) => {
|
|
||||||
if (!isRequired) return true;
|
|
||||||
return val !== null && val !== undefined && val !== '';
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('useRequired', () => {
|
|
||||||
it('should detect required when attr is boolean true', () => {
|
|
||||||
const attrs = { required: true };
|
|
||||||
const { isRequired } = useRequired(attrs);
|
|
||||||
expect(isRequired).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should detect required when attr is boolean false', () => {
|
|
||||||
const attrs = { required: false };
|
|
||||||
const { isRequired } = useRequired(attrs);
|
|
||||||
expect(isRequired).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should detect required when attr exists without value', () => {
|
|
||||||
const attrs = { required: '' };
|
|
||||||
const { isRequired } = useRequired(attrs);
|
|
||||||
expect(isRequired).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false when required attr does not exist', () => {
|
|
||||||
const attrs = { someOtherAttr: 'value' };
|
|
||||||
const { isRequired } = useRequired(attrs);
|
|
||||||
expect(isRequired).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('requiredFieldRule', () => {
|
|
||||||
it('should validate required field with value', () => {
|
|
||||||
const attrs = { required: true };
|
|
||||||
const { requiredFieldRule } = useRequired(attrs);
|
|
||||||
expect(requiredFieldRule('some value')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should validate required field with empty value', () => {
|
|
||||||
const attrs = { required: true };
|
|
||||||
const { requiredFieldRule } = useRequired(attrs);
|
|
||||||
expect(requiredFieldRule('')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should pass validation when field is not required', () => {
|
|
||||||
const attrs = { required: false };
|
|
||||||
const { requiredFieldRule } = useRequired(attrs);
|
|
||||||
expect(requiredFieldRule('')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle null and undefined values', () => {
|
|
||||||
const attrs = { required: true };
|
|
||||||
const { requiredFieldRule } = useRequired(attrs);
|
|
||||||
expect(requiredFieldRule(null)).toBe(false);
|
|
||||||
expect(requiredFieldRule(undefined)).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -23,19 +23,18 @@ describe('useRole', () => {
|
||||||
name: `T'Challa`,
|
name: `T'Challa`,
|
||||||
nickname: 'Black Panther',
|
nickname: 'Black Panther',
|
||||||
lang: 'en',
|
lang: 'en',
|
||||||
worker: { department: { departmentFk: 155 } },
|
|
||||||
};
|
};
|
||||||
const expectedUser = {
|
const expectedUser = {
|
||||||
id: 999,
|
id: 999,
|
||||||
name: `T'Challa`,
|
name: `T'Challa`,
|
||||||
nickname: 'Black Panther',
|
nickname: 'Black Panther',
|
||||||
lang: 'en',
|
lang: 'en',
|
||||||
departmentFk: 155,
|
|
||||||
};
|
};
|
||||||
const expectedRoles = ['salesPerson', 'admin'];
|
const expectedRoles = ['salesPerson', 'admin'];
|
||||||
vi.spyOn(axios, 'get').mockResolvedValueOnce({
|
vi.spyOn(axios, 'get')
|
||||||
|
.mockResolvedValueOnce({
|
||||||
data: { roles: rolesData, user: fetchedUser },
|
data: { roles: rolesData, user: fetchedUser },
|
||||||
});
|
})
|
||||||
|
|
||||||
vi.spyOn(role.state, 'setUser');
|
vi.spyOn(role.state, 'setUser');
|
||||||
vi.spyOn(role.state, 'setRoles');
|
vi.spyOn(role.state, 'setRoles');
|
||||||
|
|
|
@ -75,7 +75,6 @@ describe('session', () => {
|
||||||
userConfig: {
|
userConfig: {
|
||||||
darkMode: false,
|
darkMode: false,
|
||||||
},
|
},
|
||||||
worker: { department: { departmentFk: 155 } },
|
|
||||||
};
|
};
|
||||||
const rolesData = [
|
const rolesData = [
|
||||||
{
|
{
|
||||||
|
@ -144,7 +143,7 @@ describe('session', () => {
|
||||||
await session.destroy(); // this clears token and user for any other test
|
await session.destroy(); // this clears token and user for any other test
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
{},
|
{}
|
||||||
);
|
);
|
||||||
|
|
||||||
describe('RenewToken', () => {
|
describe('RenewToken', () => {
|
||||||
|
@ -176,7 +175,7 @@ describe('session', () => {
|
||||||
await session.checkValidity();
|
await session.checkValidity();
|
||||||
expect(sessionStorage.getItem('token')).toEqual(expectedToken);
|
expect(sessionStorage.getItem('token')).toEqual(expectedToken);
|
||||||
expect(sessionStorage.getItem('tokenMultimedia')).toEqual(
|
expect(sessionStorage.getItem('tokenMultimedia')).toEqual(
|
||||||
expectedTokenMultimedia,
|
expectedTokenMultimedia
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('Should renewToken', async () => {
|
it('Should renewToken', async () => {
|
||||||
|
@ -205,7 +204,7 @@ describe('session', () => {
|
||||||
await session.checkValidity();
|
await session.checkValidity();
|
||||||
expect(sessionStorage.getItem('token')).not.toEqual(expectedToken);
|
expect(sessionStorage.getItem('token')).not.toEqual(expectedToken);
|
||||||
expect(sessionStorage.getItem('tokenMultimedia')).not.toEqual(
|
expect(sessionStorage.getItem('tokenMultimedia')).not.toEqual(
|
||||||
expectedTokenMultimedia,
|
expectedTokenMultimedia
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,6 +29,7 @@ export async function checkEntryLock(entryFk, userFk) {
|
||||||
.dialog({
|
.dialog({
|
||||||
component: VnConfirm,
|
component: VnConfirm,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
'data-cy': 'entry-lock-confirm',
|
||||||
title: t('entry.lock.title'),
|
title: t('entry.lock.title'),
|
||||||
message: t('entry.lock.message', {
|
message: t('entry.lock.message', {
|
||||||
userName: data?.user?.nickname,
|
userName: data?.user?.nickname,
|
||||||
|
|
|
@ -7,33 +7,18 @@ const { getTokenMultimedia } = useSession();
|
||||||
const token = getTokenMultimedia();
|
const token = getTokenMultimedia();
|
||||||
|
|
||||||
export async function downloadFile(id, model = 'dms', urlPath = '/downloadFile', url) {
|
export async function downloadFile(id, model = 'dms', urlPath = '/downloadFile', url) {
|
||||||
const appUrl = await getAppUrl();
|
const appUrl = (await getUrl('', 'lilium')).replace('/#/', '');
|
||||||
const response = await axios.get(
|
const response = await axios.get(
|
||||||
url ?? `${appUrl}/api/${model}/${id}${urlPath}?access_token=${token}`,
|
url ?? `${appUrl}/api/${model}/${id}${urlPath}?access_token=${token}`,
|
||||||
{ responseType: 'blob' },
|
{ responseType: 'blob' }
|
||||||
);
|
);
|
||||||
|
|
||||||
download(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function downloadDocuware(url, params) {
|
|
||||||
const appUrl = await getAppUrl();
|
|
||||||
const response = await axios.get(`${appUrl}/api/` + url, {
|
|
||||||
responseType: 'blob',
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
|
|
||||||
download(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
function download(response) {
|
|
||||||
const contentDisposition = response.headers['content-disposition'];
|
const contentDisposition = response.headers['content-disposition'];
|
||||||
const matches = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(contentDisposition);
|
const matches = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(contentDisposition);
|
||||||
const filename = matches?.[1] ? matches[1].replace(/['"]/g, '') : 'downloaded-file';
|
const filename =
|
||||||
|
matches != null && matches[1]
|
||||||
|
? matches[1].replace(/['"]/g, '')
|
||||||
|
: 'downloaded-file';
|
||||||
|
|
||||||
exportFile(filename, response.data);
|
exportFile(filename, response.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAppUrl() {
|
|
||||||
return (await getUrl('', 'lilium')).replace('/#/', '');
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
export function getColAlign(col) {
|
export function getColAlign(col) {
|
||||||
let align;
|
let align;
|
||||||
switch (col.component) {
|
switch (col.component) {
|
||||||
case 'time':
|
|
||||||
case 'date':
|
|
||||||
case 'select':
|
case 'select':
|
||||||
align = 'left';
|
align = 'left';
|
||||||
break;
|
break;
|
||||||
case 'number':
|
case 'number':
|
||||||
align = 'right';
|
align = 'right';
|
||||||
break;
|
break;
|
||||||
case 'time':
|
|
||||||
case 'date':
|
case 'date':
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
align = 'center';
|
align = 'center';
|
||||||
|
|
|
@ -30,16 +30,9 @@ export function useAcl() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasAcl(model, prop, accessType) {
|
|
||||||
const modelAcl = state.getAcls().value[model];
|
|
||||||
const propAcl = modelAcl?.[prop] || modelAcl?.['*'];
|
|
||||||
return !!(propAcl?.[accessType] || propAcl?.['*']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fetch,
|
fetch,
|
||||||
hasAny,
|
hasAny,
|
||||||
state,
|
state,
|
||||||
hasAcl,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ export function useArrayData(key, userOptions) {
|
||||||
'searchUrl',
|
'searchUrl',
|
||||||
'navigate',
|
'navigate',
|
||||||
'mapKey',
|
'mapKey',
|
||||||
|
'keepData',
|
||||||
'oneRecord',
|
'oneRecord',
|
||||||
];
|
];
|
||||||
if (typeof userOptions === 'object') {
|
if (typeof userOptions === 'object') {
|
||||||
|
@ -107,7 +108,7 @@ export function useArrayData(key, userOptions) {
|
||||||
store.hasMoreData = limit && response.data.length >= limit;
|
store.hasMoreData = limit && response.data.length >= limit;
|
||||||
|
|
||||||
if (!append && !isDialogOpened() && updateRouter) {
|
if (!append && !isDialogOpened() && updateRouter) {
|
||||||
if (updateStateParams(response.data)?.redirect) return;
|
if (updateStateParams(response.data)?.redirect && !store.keepData) return;
|
||||||
}
|
}
|
||||||
store.isLoading = false;
|
store.isLoading = false;
|
||||||
canceller = null;
|
canceller = null;
|
||||||
|
@ -147,7 +148,8 @@ export function useArrayData(key, userOptions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function applyFilter({ filter, params }, fetchOptions = {}) {
|
async function applyFilter({ filter, params }, fetchOptions = {}) {
|
||||||
if (filter) store.filter = filter;
|
if (filter) store.userFilter = filter;
|
||||||
|
store.filter = {};
|
||||||
if (params) store.userParams = { ...params };
|
if (params) store.userParams = { ...params };
|
||||||
|
|
||||||
const response = await fetch(fetchOptions);
|
const response = await fetch(fetchOptions);
|
||||||
|
@ -188,7 +190,7 @@ export function useArrayData(key, userOptions) {
|
||||||
|
|
||||||
store.order = order;
|
store.order = order;
|
||||||
resetPagination();
|
resetPagination();
|
||||||
await fetch({});
|
fetch({});
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
return { index, order };
|
return { index, order };
|
||||||
|
@ -243,7 +245,7 @@ export function useArrayData(key, userOptions) {
|
||||||
async function loadMore() {
|
async function loadMore() {
|
||||||
if (!store.hasMoreData) return;
|
if (!store.hasMoreData) return;
|
||||||
|
|
||||||
store.skip = (store?.filter?.limit ?? store.limit) * store.page;
|
store.skip = store.limit * store.page;
|
||||||
store.page += 1;
|
store.page += 1;
|
||||||
|
|
||||||
await fetch({ append: true });
|
await fetch({ append: true });
|
||||||
|
|
|
@ -11,7 +11,6 @@ export async function useCau(res, message) {
|
||||||
const { config, headers, request, status, statusText, data } = res || {};
|
const { config, headers, request, status, statusText, data } = res || {};
|
||||||
const { params, url, method, signal, headers: confHeaders } = config || {};
|
const { params, url, method, signal, headers: confHeaders } = config || {};
|
||||||
const { message: resMessage, code, name } = data?.error || {};
|
const { message: resMessage, code, name } = data?.error || {};
|
||||||
delete confHeaders?.Authorization;
|
|
||||||
|
|
||||||
const additionalData = {
|
const additionalData = {
|
||||||
path: location.hash,
|
path: location.hash,
|
||||||
|
@ -41,7 +40,7 @@ export async function useCau(res, message) {
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
const locale = i18n.global.t;
|
const locale = i18n.global.t;
|
||||||
const reason = ref(
|
const reason = ref(
|
||||||
code == 'ACCESS_DENIED' ? locale('cau.askPrivileges') : '',
|
code == 'ACCESS_DENIED' ? locale('cau.askPrivileges') : ''
|
||||||
);
|
);
|
||||||
openConfirmationModal(
|
openConfirmationModal(
|
||||||
locale('cau.title'),
|
locale('cau.title'),
|
||||||
|
@ -60,9 +59,10 @@ export async function useCau(res, message) {
|
||||||
'onUpdate:modelValue': (val) => (reason.value = val),
|
'onUpdate:modelValue': (val) => (reason.value = val),
|
||||||
label: locale('cau.inputLabel'),
|
label: locale('cau.inputLabel'),
|
||||||
class: 'full-width',
|
class: 'full-width',
|
||||||
|
required: true,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,7 +14,7 @@ export function useFilterParams(key) {
|
||||||
watch(
|
watch(
|
||||||
() => arrayData.value.store?.currentFilter,
|
() => arrayData.value.store?.currentFilter,
|
||||||
(val, oldValue) => (val || oldValue) && setUserParams(val),
|
(val, oldValue) => (val || oldValue) && setUserParams(val),
|
||||||
{ immediate: true, deep: true },
|
{ immediate: true, deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
function parseOrder(urlOrders) {
|
function parseOrder(urlOrders) {
|
||||||
|
@ -54,7 +54,7 @@ export function useFilterParams(key) {
|
||||||
Object.assign(params, item);
|
Object.assign(params, item);
|
||||||
});
|
});
|
||||||
delete params[key];
|
delete params[key];
|
||||||
} else if (value && typeof value === 'object' && !Array.isArray(value)) {
|
} else if (value && typeof value === 'object') {
|
||||||
const param = Object.values(value)[0];
|
const param = Object.values(value)[0];
|
||||||
if (typeof param == 'string') params[key] = param.replaceAll('%', '');
|
if (typeof param == 'string') params[key] = param.replaceAll('%', '');
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,14 @@ import { useValidator } from 'src/composables/useValidator';
|
||||||
|
|
||||||
export function useRequired($attrs) {
|
export function useRequired($attrs) {
|
||||||
const { validations } = useValidator();
|
const { validations } = useValidator();
|
||||||
const isRequired =
|
const hasRequired = Object.keys($attrs).includes('required');
|
||||||
typeof $attrs['required'] === 'boolean'
|
let isRequired = false;
|
||||||
? $attrs['required']
|
if (hasRequired) {
|
||||||
: Object.keys($attrs).includes('required');
|
const required = $attrs['required'];
|
||||||
|
if (typeof required === 'boolean') {
|
||||||
|
isRequired = required;
|
||||||
|
}
|
||||||
|
}
|
||||||
const requiredFieldRule = (val) => validations().required(isRequired, val);
|
const requiredFieldRule = (val) => validations().required(isRequired, val);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -13,7 +13,6 @@ export function useRole() {
|
||||||
name: data.user.name,
|
name: data.user.name,
|
||||||
nickname: data.user.nickname,
|
nickname: data.user.nickname,
|
||||||
lang: data.user.lang || 'es',
|
lang: data.user.lang || 'es',
|
||||||
departmentFk: data.user.worker.department.departmentFk,
|
|
||||||
};
|
};
|
||||||
state.setUser(userData);
|
state.setUser(userData);
|
||||||
state.setRoles(roles);
|
state.setRoles(roles);
|
||||||
|
|
|
@ -15,7 +15,6 @@ body.body--light {
|
||||||
--vn-empty-tag: #acacac;
|
--vn-empty-tag: #acacac;
|
||||||
--vn-black-text-color: black;
|
--vn-black-text-color: black;
|
||||||
--vn-text-color-contrast: white;
|
--vn-text-color-contrast: white;
|
||||||
--vn-link-color: #1e90ff;
|
|
||||||
|
|
||||||
background-color: var(--vn-page-color);
|
background-color: var(--vn-page-color);
|
||||||
|
|
||||||
|
@ -39,7 +38,6 @@ body.body--dark {
|
||||||
--vn-empty-tag: #2d2d2d;
|
--vn-empty-tag: #2d2d2d;
|
||||||
--vn-black-text-color: black;
|
--vn-black-text-color: black;
|
||||||
--vn-text-color-contrast: black;
|
--vn-text-color-contrast: black;
|
||||||
--vn-link-color: #66bfff;
|
|
||||||
|
|
||||||
background-color: var(--vn-page-color);
|
background-color: var(--vn-page-color);
|
||||||
|
|
||||||
|
@ -51,7 +49,7 @@ a {
|
||||||
}
|
}
|
||||||
|
|
||||||
.link {
|
.link {
|
||||||
color: var(--vn-link-color);
|
color: $color-link;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&--white {
|
&--white {
|
||||||
|
@ -60,14 +58,14 @@ a {
|
||||||
}
|
}
|
||||||
|
|
||||||
.tx-color-link {
|
.tx-color-link {
|
||||||
color: var(--vn-link-color) !important;
|
color: $color-link !important;
|
||||||
}
|
}
|
||||||
.tx-color-font {
|
.tx-color-font {
|
||||||
color: var(--vn-link-color) !important;
|
color: $color-link !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-link {
|
.header-link {
|
||||||
color: var(--vn-link-color) !important;
|
color: $color-link !important;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-bottom: solid $primary;
|
border-bottom: solid $primary;
|
||||||
border-width: 2px;
|
border-width: 2px;
|
||||||
|
@ -325,6 +323,7 @@ input::-webkit-inner-spin-button {
|
||||||
min-height: auto !important;
|
min-height: auto !important;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
|
padding-bottom: 2px;
|
||||||
.q-field__native.row {
|
.q-field__native.row {
|
||||||
min-height: auto !important;
|
min-height: auto !important;
|
||||||
}
|
}
|
||||||
|
@ -336,7 +335,3 @@ input::-webkit-inner-spin-button {
|
||||||
border: 1px solid;
|
border: 1px solid;
|
||||||
box-shadow: 0 4px 6px #00000000;
|
box-shadow: 0 4px 6px #00000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.containerShrinked {
|
|
||||||
width: 70%;
|
|
||||||
}
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ $alert: $negative;
|
||||||
$white: #fff;
|
$white: #fff;
|
||||||
$dark: #3d3d3d;
|
$dark: #3d3d3d;
|
||||||
// custom
|
// custom
|
||||||
|
$color-link: #66bfff;
|
||||||
$color-spacer-light: #a3a3a31f;
|
$color-spacer-light: #a3a3a31f;
|
||||||
$color-spacer: #7979794d;
|
$color-spacer: #7979794d;
|
||||||
$border-thin-light: 1px solid $color-spacer-light;
|
$border-thin-light: 1px solid $color-spacer-light;
|
||||||
|
|
|
@ -3,8 +3,6 @@ import { useI18n } from 'vue-i18n';
|
||||||
export default function (value, options = {}) {
|
export default function (value, options = {}) {
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
|
|
||||||
if (!isValidDate(value)) return null;
|
|
||||||
|
|
||||||
if (!options.dateStyle && !options.timeStyle) {
|
if (!options.dateStyle && !options.timeStyle) {
|
||||||
options.day = '2-digit';
|
options.day = '2-digit';
|
||||||
options.month = '2-digit';
|
options.month = '2-digit';
|
||||||
|
@ -12,12 +10,7 @@ export default function (value, options = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { locale } = useI18n();
|
const { locale } = useI18n();
|
||||||
const newDate = new Date(value);
|
const date = new Date(value);
|
||||||
|
|
||||||
return new Intl.DateTimeFormat(locale.value, options).format(newDate);
|
return new Intl.DateTimeFormat(locale.value, options).format(date);
|
||||||
}
|
|
||||||
// handle 0000-00-00
|
|
||||||
function isValidDate(date) {
|
|
||||||
const parsedDate = new Date(date);
|
|
||||||
return parsedDate instanceof Date && !isNaN(parsedDate.getTime());
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,6 @@ globals:
|
||||||
rowRemoved: Row removed
|
rowRemoved: Row removed
|
||||||
pleaseWait: Please wait...
|
pleaseWait: Please wait...
|
||||||
noPinnedModules: You don't have any pinned modules
|
noPinnedModules: You don't have any pinned modules
|
||||||
enterToConfirm: Press Enter to confirm
|
|
||||||
summary:
|
summary:
|
||||||
basicData: Basic data
|
basicData: Basic data
|
||||||
daysOnward: Days onward
|
daysOnward: Days onward
|
||||||
|
@ -99,6 +98,7 @@ globals:
|
||||||
file: File
|
file: File
|
||||||
selectFile: Select a file
|
selectFile: Select a file
|
||||||
copyClipboard: Copy on clipboard
|
copyClipboard: Copy on clipboard
|
||||||
|
salesPerson: SalesPerson
|
||||||
send: Send
|
send: Send
|
||||||
code: Code
|
code: Code
|
||||||
since: Since
|
since: Since
|
||||||
|
@ -152,14 +152,10 @@ globals:
|
||||||
maxTemperature: Max
|
maxTemperature: Max
|
||||||
minTemperature: Min
|
minTemperature: Min
|
||||||
changePass: Change password
|
changePass: Change password
|
||||||
setPass: Set password
|
|
||||||
deleteConfirmTitle: Delete selected elements
|
deleteConfirmTitle: Delete selected elements
|
||||||
changeState: Change state
|
changeState: Change state
|
||||||
raid: 'Raid {daysInForward} days'
|
raid: 'Raid {daysInForward} days'
|
||||||
isVies: Vies
|
isVies: Vies
|
||||||
department: Department
|
|
||||||
noData: No data available
|
|
||||||
vehicle: Vehicle
|
|
||||||
pageTitles:
|
pageTitles:
|
||||||
logIn: Login
|
logIn: Login
|
||||||
addressEdit: Update address
|
addressEdit: Update address
|
||||||
|
@ -347,6 +343,7 @@ globals:
|
||||||
params:
|
params:
|
||||||
description: Description
|
description: Description
|
||||||
clientFk: Client id
|
clientFk: Client id
|
||||||
|
salesPersonFk: Sales person
|
||||||
warehouseFk: Warehouse
|
warehouseFk: Warehouse
|
||||||
provinceFk: Province
|
provinceFk: Province
|
||||||
stateFk: State
|
stateFk: State
|
||||||
|
@ -369,12 +366,6 @@ globals:
|
||||||
countryFk: Country
|
countryFk: Country
|
||||||
countryCodeFk: Country
|
countryCodeFk: Country
|
||||||
companyFk: Company
|
companyFk: Company
|
||||||
nickname: Alias
|
|
||||||
changedModel: Entity
|
|
||||||
changedModelValue: Search
|
|
||||||
changedModelId: Entity id
|
|
||||||
userFk: User
|
|
||||||
action: Action
|
|
||||||
model: Model
|
model: Model
|
||||||
fuel: Fuel
|
fuel: Fuel
|
||||||
active: Active
|
active: Active
|
||||||
|
@ -536,7 +527,6 @@ ticket:
|
||||||
customerCard: Customer card
|
customerCard: Customer card
|
||||||
ticketList: Ticket List
|
ticketList: Ticket List
|
||||||
newOrder: New Order
|
newOrder: New Order
|
||||||
ticketClaimed: Claimed ticket
|
|
||||||
boxing:
|
boxing:
|
||||||
expedition: Expedition
|
expedition: Expedition
|
||||||
created: Created
|
created: Created
|
||||||
|
@ -609,6 +599,7 @@ worker:
|
||||||
balance: Balance
|
balance: Balance
|
||||||
medical: Medical
|
medical: Medical
|
||||||
list:
|
list:
|
||||||
|
department: Department
|
||||||
schedule: Schedule
|
schedule: Schedule
|
||||||
newWorker: New worker
|
newWorker: New worker
|
||||||
summary:
|
summary:
|
||||||
|
@ -651,7 +642,6 @@ worker:
|
||||||
model: Model
|
model: Model
|
||||||
serialNumber: Serial number
|
serialNumber: Serial number
|
||||||
removePDA: Deallocate PDA
|
removePDA: Deallocate PDA
|
||||||
sendToTablet: Send to tablet
|
|
||||||
create:
|
create:
|
||||||
lastName: Last name
|
lastName: Last name
|
||||||
birth: Birth
|
birth: Birth
|
||||||
|
@ -701,10 +691,8 @@ worker:
|
||||||
machine: Machine
|
machine: Machine
|
||||||
business:
|
business:
|
||||||
tableVisibleColumns:
|
tableVisibleColumns:
|
||||||
id: ID
|
|
||||||
started: Start Date
|
started: Start Date
|
||||||
ended: End Date
|
ended: End Date
|
||||||
hourlyLabor: Time sheet
|
|
||||||
company: Company
|
company: Company
|
||||||
reasonEnd: Reason for Termination
|
reasonEnd: Reason for Termination
|
||||||
department: Department
|
department: Department
|
||||||
|
@ -712,7 +700,6 @@ worker:
|
||||||
calendarType: Work Calendar
|
calendarType: Work Calendar
|
||||||
workCenter: Work Center
|
workCenter: Work Center
|
||||||
payrollCategories: Contract Category
|
payrollCategories: Contract Category
|
||||||
workerBusinessAgreementName: Agreement
|
|
||||||
occupationCode: Contribution Code
|
occupationCode: Contribution Code
|
||||||
rate: Rate
|
rate: Rate
|
||||||
businessType: Contract Type
|
businessType: Contract Type
|
||||||
|
@ -822,7 +809,6 @@ travel:
|
||||||
search: Search travel
|
search: Search travel
|
||||||
searchInfo: You can search by travel id or name
|
searchInfo: You can search by travel id or name
|
||||||
id: Id
|
id: Id
|
||||||
awbFk: AWB
|
|
||||||
travelList:
|
travelList:
|
||||||
tableVisibleColumns:
|
tableVisibleColumns:
|
||||||
ref: Reference
|
ref: Reference
|
||||||
|
@ -843,11 +829,8 @@ travel:
|
||||||
CloneTravelAndEntries: Clone travel and his entries
|
CloneTravelAndEntries: Clone travel and his entries
|
||||||
deleteTravel: Delete travel
|
deleteTravel: Delete travel
|
||||||
AddEntry: Add entry
|
AddEntry: Add entry
|
||||||
availabled: Availabled
|
|
||||||
availabledHour: Availabled hour
|
|
||||||
thermographs: Thermographs
|
thermographs: Thermographs
|
||||||
hb: HB
|
hb: HB
|
||||||
roundedCc: Rounded CC
|
|
||||||
basicData:
|
basicData:
|
||||||
daysInForward: Automatic movement (Raid)
|
daysInForward: Automatic movement (Raid)
|
||||||
isRaid: Raid
|
isRaid: Raid
|
||||||
|
@ -870,6 +853,7 @@ components:
|
||||||
mine: For me
|
mine: For me
|
||||||
hasMinPrice: Minimum price
|
hasMinPrice: Minimum price
|
||||||
# LatestBuysFilter
|
# LatestBuysFilter
|
||||||
|
salesPersonFk: Buyer
|
||||||
supplierFk: Supplier
|
supplierFk: Supplier
|
||||||
from: From
|
from: From
|
||||||
to: To
|
to: To
|
||||||
|
@ -890,7 +874,7 @@ components:
|
||||||
openCard: View
|
openCard: View
|
||||||
openSummary: Summary
|
openSummary: Summary
|
||||||
viewSummary: Summary
|
viewSummary: Summary
|
||||||
vnDescriptor:
|
cardDescriptor:
|
||||||
mainList: Main list
|
mainList: Main list
|
||||||
summary: Summary
|
summary: Summary
|
||||||
moreOptions: More options
|
moreOptions: More options
|
||||||
|
@ -900,8 +884,6 @@ components:
|
||||||
VnLv:
|
VnLv:
|
||||||
copyText: '{copyValue} has been copied to the clipboard'
|
copyText: '{copyValue} has been copied to the clipboard'
|
||||||
iban_tooltip: 'IBAN: ES21 1234 5678 90 0123456789'
|
iban_tooltip: 'IBAN: ES21 1234 5678 90 0123456789'
|
||||||
VnNotes:
|
|
||||||
clientWithoutPhone: 'The following clients do not have a phone number and the message will not be sent to them: {clientWithoutPhone}'
|
|
||||||
weekdays:
|
weekdays:
|
||||||
sun: Sunday
|
sun: Sunday
|
||||||
mon: Monday
|
mon: Monday
|
||||||
|
|
|
@ -51,7 +51,6 @@ globals:
|
||||||
pleaseWait: Por favor espera...
|
pleaseWait: Por favor espera...
|
||||||
noPinnedModules: No has fijado ningún módulo
|
noPinnedModules: No has fijado ningún módulo
|
||||||
split: Split
|
split: Split
|
||||||
enterToConfirm: Pulsa Enter para confirmar
|
|
||||||
summary:
|
summary:
|
||||||
basicData: Datos básicos
|
basicData: Datos básicos
|
||||||
daysOnward: Días adelante
|
daysOnward: Días adelante
|
||||||
|
@ -103,6 +102,7 @@ globals:
|
||||||
file: Fichero
|
file: Fichero
|
||||||
selectFile: Seleccione un fichero
|
selectFile: Seleccione un fichero
|
||||||
copyClipboard: Copiar en portapapeles
|
copyClipboard: Copiar en portapapeles
|
||||||
|
salesPerson: Comercial
|
||||||
send: Enviar
|
send: Enviar
|
||||||
code: Código
|
code: Código
|
||||||
since: Desde
|
since: Desde
|
||||||
|
@ -156,14 +156,10 @@ globals:
|
||||||
maxTemperature: Máx
|
maxTemperature: Máx
|
||||||
minTemperature: Mín
|
minTemperature: Mín
|
||||||
changePass: Cambiar contraseña
|
changePass: Cambiar contraseña
|
||||||
setPass: Establecer contraseña
|
|
||||||
deleteConfirmTitle: Eliminar los elementos seleccionados
|
deleteConfirmTitle: Eliminar los elementos seleccionados
|
||||||
changeState: Cambiar estado
|
changeState: Cambiar estado
|
||||||
raid: 'Redada {daysInForward} días'
|
raid: 'Redada {daysInForward} días'
|
||||||
isVies: Vies
|
isVies: Vies
|
||||||
noData: Datos no disponibles
|
|
||||||
department: Departamento
|
|
||||||
vehicle: Vehículo
|
|
||||||
pageTitles:
|
pageTitles:
|
||||||
logIn: Inicio de sesión
|
logIn: Inicio de sesión
|
||||||
addressEdit: Modificar consignatario
|
addressEdit: Modificar consignatario
|
||||||
|
@ -350,6 +346,7 @@ globals:
|
||||||
params:
|
params:
|
||||||
description: Descripción
|
description: Descripción
|
||||||
clientFk: Id cliente
|
clientFk: Id cliente
|
||||||
|
salesPersonFk: Comercial
|
||||||
warehouseFk: Almacén
|
warehouseFk: Almacén
|
||||||
provinceFk: Provincia
|
provinceFk: Provincia
|
||||||
stateFk: Estado
|
stateFk: Estado
|
||||||
|
@ -370,12 +367,6 @@ globals:
|
||||||
countryFk: País
|
countryFk: País
|
||||||
countryCodeFk: País
|
countryCodeFk: País
|
||||||
companyFk: Empresa
|
companyFk: Empresa
|
||||||
nickname: Alias
|
|
||||||
changedModel: Entidad
|
|
||||||
changedModelValue: Buscar
|
|
||||||
changedModelId: Id de entidad
|
|
||||||
userFk: Usuario
|
|
||||||
action: Acción
|
|
||||||
errors:
|
errors:
|
||||||
statusUnauthorized: Acceso denegado
|
statusUnauthorized: Acceso denegado
|
||||||
statusInternalServerError: Ha ocurrido un error interno del servidor
|
statusInternalServerError: Ha ocurrido un error interno del servidor
|
||||||
|
@ -536,13 +527,13 @@ ticket:
|
||||||
state: Estado
|
state: Estado
|
||||||
shipped: Enviado
|
shipped: Enviado
|
||||||
landed: Entregado
|
landed: Entregado
|
||||||
|
salesPerson: Comercial
|
||||||
total: Total
|
total: Total
|
||||||
card:
|
card:
|
||||||
customerId: ID cliente
|
customerId: ID cliente
|
||||||
customerCard: Ficha del cliente
|
customerCard: Ficha del cliente
|
||||||
ticketList: Listado de tickets
|
ticketList: Listado de tickets
|
||||||
newOrder: Nuevo pedido
|
newOrder: Nuevo pedido
|
||||||
ticketClaimed: Ticket reclamado
|
|
||||||
boxing:
|
boxing:
|
||||||
expedition: Expedición
|
expedition: Expedición
|
||||||
created: Creado
|
created: Creado
|
||||||
|
@ -627,6 +618,8 @@ invoiceOut:
|
||||||
errors:
|
errors:
|
||||||
downloadCsvFailed: Error al descargar CSV
|
downloadCsvFailed: Error al descargar CSV
|
||||||
order:
|
order:
|
||||||
|
field:
|
||||||
|
salesPersonFk: Comercial
|
||||||
form:
|
form:
|
||||||
clientFk: Cliente
|
clientFk: Cliente
|
||||||
addressFk: Dirección
|
addressFk: Dirección
|
||||||
|
@ -694,6 +687,7 @@ worker:
|
||||||
formation: Formación
|
formation: Formación
|
||||||
medical: Mutua
|
medical: Mutua
|
||||||
list:
|
list:
|
||||||
|
department: Departamento
|
||||||
schedule: Horario
|
schedule: Horario
|
||||||
newWorker: Nuevo trabajador
|
newWorker: Nuevo trabajador
|
||||||
summary:
|
summary:
|
||||||
|
@ -736,7 +730,6 @@ worker:
|
||||||
model: Modelo
|
model: Modelo
|
||||||
serialNumber: Número de serie
|
serialNumber: Número de serie
|
||||||
removePDA: Desasignar PDA
|
removePDA: Desasignar PDA
|
||||||
sendToTablet: Enviar a la tablet
|
|
||||||
create:
|
create:
|
||||||
lastName: Apellido
|
lastName: Apellido
|
||||||
birth: Fecha de nacimiento
|
birth: Fecha de nacimiento
|
||||||
|
@ -774,10 +767,8 @@ worker:
|
||||||
concept: Concepto
|
concept: Concepto
|
||||||
business:
|
business:
|
||||||
tableVisibleColumns:
|
tableVisibleColumns:
|
||||||
id: Id
|
|
||||||
started: Fecha inicio
|
started: Fecha inicio
|
||||||
ended: Fecha fin
|
ended: Fecha fin
|
||||||
hourlyLabor: Ficha
|
|
||||||
company: Empresa
|
company: Empresa
|
||||||
reasonEnd: Motivo finalización
|
reasonEnd: Motivo finalización
|
||||||
department: Departamento
|
department: Departamento
|
||||||
|
@ -788,13 +779,12 @@ worker:
|
||||||
occupationCode: Cotización
|
occupationCode: Cotización
|
||||||
rate: Tarifa
|
rate: Tarifa
|
||||||
businessType: Contrato
|
businessType: Contrato
|
||||||
workerBusinessAgreementName: Convenio
|
|
||||||
amount: Salario
|
amount: Salario
|
||||||
basicSalary: Salario transportistas
|
basicSalary: Salario transportistas
|
||||||
notes: Notas
|
notes: Notas
|
||||||
operator:
|
operator:
|
||||||
numberOfWagons: Número de vagones
|
numberOfWagons: Número de vagones
|
||||||
train: Tren
|
train: tren
|
||||||
itemPackingType: Tipo de embalaje
|
itemPackingType: Tipo de embalaje
|
||||||
warehouse: Almacén
|
warehouse: Almacén
|
||||||
sector: Sector
|
sector: Sector
|
||||||
|
@ -848,7 +838,6 @@ supplier:
|
||||||
verified: Verificado
|
verified: Verificado
|
||||||
isActive: Está activo
|
isActive: Está activo
|
||||||
billingData: Forma de pago
|
billingData: Forma de pago
|
||||||
financialData: Datos financieros
|
|
||||||
payDeadline: Plazo de pago
|
payDeadline: Plazo de pago
|
||||||
payDay: Día de pago
|
payDay: Día de pago
|
||||||
account: Cuenta
|
account: Cuenta
|
||||||
|
@ -905,7 +894,6 @@ travel:
|
||||||
search: Buscar envío
|
search: Buscar envío
|
||||||
searchInfo: Buscar envío por id o nombre
|
searchInfo: Buscar envío por id o nombre
|
||||||
id: Id
|
id: Id
|
||||||
awbFk: Guía aérea
|
|
||||||
travelList:
|
travelList:
|
||||||
tableVisibleColumns:
|
tableVisibleColumns:
|
||||||
ref: Referencia
|
ref: Referencia
|
||||||
|
@ -927,10 +915,7 @@ travel:
|
||||||
deleteTravel: Eliminar envío
|
deleteTravel: Eliminar envío
|
||||||
AddEntry: Añadir entrada
|
AddEntry: Añadir entrada
|
||||||
thermographs: Termógrafos
|
thermographs: Termógrafos
|
||||||
availabled: F. Disponible
|
|
||||||
availabledHour: Hora Disponible
|
|
||||||
hb: HB
|
hb: HB
|
||||||
roundedCc: CC redondeado
|
|
||||||
basicData:
|
basicData:
|
||||||
daysInForward: Desplazamiento automatico (redada)
|
daysInForward: Desplazamiento automatico (redada)
|
||||||
isRaid: Redada
|
isRaid: Redada
|
||||||
|
@ -954,6 +939,7 @@ components:
|
||||||
hasMinPrice: Precio mínimo
|
hasMinPrice: Precio mínimo
|
||||||
wareHouseFk: Almacén
|
wareHouseFk: Almacén
|
||||||
# LatestBuysFilter
|
# LatestBuysFilter
|
||||||
|
salesPersonFk: Comprador
|
||||||
supplierFk: Proveedor
|
supplierFk: Proveedor
|
||||||
visible: Visible
|
visible: Visible
|
||||||
active: Activo
|
active: Activo
|
||||||
|
@ -974,7 +960,7 @@ components:
|
||||||
openCard: Ficha
|
openCard: Ficha
|
||||||
openSummary: Detalles
|
openSummary: Detalles
|
||||||
viewSummary: Vista previa
|
viewSummary: Vista previa
|
||||||
vnDescriptor:
|
cardDescriptor:
|
||||||
mainList: Listado principal
|
mainList: Listado principal
|
||||||
summary: Resumen
|
summary: Resumen
|
||||||
moreOptions: Más opciones
|
moreOptions: Más opciones
|
||||||
|
@ -984,8 +970,6 @@ components:
|
||||||
VnLv:
|
VnLv:
|
||||||
copyText: '{copyValue} se ha copiado al portapepeles'
|
copyText: '{copyValue} se ha copiado al portapepeles'
|
||||||
iban_tooltip: 'IBAN: ES21 1234 5678 90 0123456789'
|
iban_tooltip: 'IBAN: ES21 1234 5678 90 0123456789'
|
||||||
VnNotes:
|
|
||||||
clientWithoutPhone: 'Estos clientes no tienen asociado número de télefono y el sms no les será enviado: {clientWithoutPhone}'
|
|
||||||
weekdays:
|
weekdays:
|
||||||
sun: Domingo
|
sun: Domingo
|
||||||
mon: Lunes
|
mon: Lunes
|
||||||
|
|
|
@ -47,7 +47,7 @@ const rolesOptions = ref([]);
|
||||||
:label="t('globals.name')"
|
:label="t('globals.name')"
|
||||||
v-model="params.name"
|
v-model="params.name"
|
||||||
lazy-rules
|
lazy-rules
|
||||||
filled
|
is-outlined
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
|
@ -57,7 +57,7 @@ const rolesOptions = ref([]);
|
||||||
:label="t('account.card.alias')"
|
:label="t('account.card.alias')"
|
||||||
v-model="params.nickname"
|
v-model="params.nickname"
|
||||||
lazy-rules
|
lazy-rules
|
||||||
filled
|
is-outlined
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
|
@ -75,7 +75,8 @@ const rolesOptions = ref([]);
|
||||||
use-input
|
use-input
|
||||||
hide-selected
|
hide-selected
|
||||||
dense
|
dense
|
||||||
filled
|
outlined
|
||||||
|
rounded
|
||||||
:input-debounce="0"
|
:input-debounce="0"
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
|
|
|
@ -149,12 +149,14 @@ const columns = computed(() => [
|
||||||
:right-search="false"
|
:right-search="false"
|
||||||
>
|
>
|
||||||
<template #more-create-dialog="{ data }">
|
<template #more-create-dialog="{ data }">
|
||||||
|
<QCardSection>
|
||||||
<VnInputPassword
|
<VnInputPassword
|
||||||
:label="t('Password')"
|
:label="t('Password')"
|
||||||
v-model="data.password"
|
v-model="data.password"
|
||||||
:required="true"
|
:required="true"
|
||||||
autocomplete="new-password"
|
autocomplete="new-password"
|
||||||
/>
|
/>
|
||||||
|
</QCardSection>
|
||||||
</template>
|
</template>
|
||||||
</VnTable>
|
</VnTable>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -56,7 +56,8 @@ onBeforeMount(() => {
|
||||||
option-label="name"
|
option-label="name"
|
||||||
use-input
|
use-input
|
||||||
dense
|
dense
|
||||||
filled
|
outlined
|
||||||
|
rounded
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
|
@ -71,7 +72,8 @@ onBeforeMount(() => {
|
||||||
option-label="name"
|
option-label="name"
|
||||||
use-input
|
use-input
|
||||||
dense
|
dense
|
||||||
filled
|
outlined
|
||||||
|
rounded
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
|
@ -81,7 +83,7 @@ onBeforeMount(() => {
|
||||||
:label="t('acls.aclFilter.property')"
|
:label="t('acls.aclFilter.property')"
|
||||||
v-model="params.property"
|
v-model="params.property"
|
||||||
lazy-rules
|
lazy-rules
|
||||||
filled
|
is-outlined
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
|
@ -96,7 +98,8 @@ onBeforeMount(() => {
|
||||||
option-label="name"
|
option-label="name"
|
||||||
use-input
|
use-input
|
||||||
dense
|
dense
|
||||||
filled
|
outlined
|
||||||
|
rounded
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
|
@ -111,7 +114,8 @@ onBeforeMount(() => {
|
||||||
option-label="name"
|
option-label="name"
|
||||||
use-input
|
use-input
|
||||||
dense
|
dense
|
||||||
filled
|
outlined
|
||||||
|
rounded
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import VnCard from 'components/common/VnCard.vue';
|
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
||||||
import AliasDescriptor from './AliasDescriptor.vue';
|
import AliasDescriptor from './AliasDescriptor.vue';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnCard
|
<VnCardBeta
|
||||||
data-key="Alias"
|
data-key="Alias"
|
||||||
url="MailAliases"
|
url="MailAliases"
|
||||||
:descriptor="AliasDescriptor"
|
:descriptor="AliasDescriptor"
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue