Compare commits
3 Commits
dev
...
5895-jsdoc
Author | SHA1 | Date |
---|---|---|
Carlos Satorres | 18848fdc8c | |
Carlos Satorres | 001be29991 | |
Carlos Satorres | e487930911 |
|
@ -1,4 +1,4 @@
|
||||||
export default {
|
module.exports = {
|
||||||
// https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
|
// https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
|
||||||
// This option interrupts the configuration hierarchy at this file
|
// This option interrupts the configuration hierarchy at this file
|
||||||
// Remove this if you have an higher level ESLint config file (it usually happens into a monorepos)
|
// Remove this if you have an higher level ESLint config file (it usually happens into a monorepos)
|
||||||
|
@ -58,7 +58,7 @@ export default {
|
||||||
rules: {
|
rules: {
|
||||||
'prefer-promise-reject-errors': 'off',
|
'prefer-promise-reject-errors': 'off',
|
||||||
'no-unused-vars': 'warn',
|
'no-unused-vars': 'warn',
|
||||||
'vue/no-multiple-template-root': 'off',
|
|
||||||
// allow debugger during development only
|
// allow debugger during development only
|
||||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||||
},
|
},
|
||||||
|
|
|
@ -29,9 +29,5 @@ yarn-error.log*
|
||||||
*.sln
|
*.sln
|
||||||
|
|
||||||
# Cypress directories and files
|
# Cypress directories and files
|
||||||
/test/cypress/videos
|
/tests/cypress/videos
|
||||||
/test/cypress/screenshots
|
/tests/cypress/screenshots
|
||||||
|
|
||||||
# VitePress directories and files
|
|
||||||
/docs/.vitepress/cache
|
|
||||||
/docs/.vuepress
|
|
|
@ -1,33 +0,0 @@
|
||||||
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
||||||
import { join, resolve } from 'path';
|
|
||||||
|
|
||||||
function getCurrentBranchName(p = process.cwd()) {
|
|
||||||
if (!existsSync(p)) return false;
|
|
||||||
|
|
||||||
const gitHeadPath = join(p, '.git', 'HEAD');
|
|
||||||
|
|
||||||
if (!existsSync(gitHeadPath)) {
|
|
||||||
return getCurrentBranchName(resolve(p, '..'));
|
|
||||||
}
|
|
||||||
|
|
||||||
const headContent = readFileSync(gitHeadPath, 'utf-8');
|
|
||||||
return headContent.trim().split('/')[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
const branchName = getCurrentBranchName();
|
|
||||||
|
|
||||||
if (branchName) {
|
|
||||||
const msgPath = '.git/COMMIT_EDITMSG';
|
|
||||||
const msg = readFileSync(msgPath, 'utf-8');
|
|
||||||
const reference = branchName.match(/^\d+/);
|
|
||||||
|
|
||||||
const referenceTag = `refs #${reference}`;
|
|
||||||
if (!msg.includes(referenceTag) && reference) {
|
|
||||||
const splitedMsg = msg.split(':');
|
|
||||||
|
|
||||||
if (splitedMsg.length > 1) {
|
|
||||||
const finalMsg = splitedMsg[0] + ': ' + referenceTag + splitedMsg.slice(1).join(':');
|
|
||||||
writeFileSync(msgPath, finalMsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
#!/usr/bin/env sh
|
|
||||||
. "$(dirname -- "$0")/_/husky.sh"
|
|
||||||
|
|
||||||
echo "Running husky commit-msg hook"
|
|
||||||
npx --no-install commitlint --edit
|
|
||||||
echo "Adding reference tag to commit message"
|
|
||||||
node .husky/addReferenceTag.js
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export default {
|
module.exports = {
|
||||||
singleQuote: true,
|
singleQuote: true,
|
||||||
printWidth: 90,
|
printWidth: 90,
|
||||||
tabWidth: 4,
|
tabWidth: 4,
|
||||||
|
|
|
@ -14,5 +14,5 @@
|
||||||
"[vue]": {
|
"[vue]": {
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
},
|
},
|
||||||
"cSpell.words": ["axios", "composables"]
|
"cSpell.words": ["axios"]
|
||||||
}
|
}
|
||||||
|
|
1574
CHANGELOG.md
|
@ -1,6 +1,5 @@
|
||||||
FROM node:stretch-slim
|
FROM node:stretch-slim
|
||||||
RUN corepack enable pnpm
|
RUN npm install -g @quasar/cli
|
||||||
RUN pnpm install -g @quasar/cli
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY dist/spa ./
|
COPY dist/spa ./
|
||||||
CMD ["quasar", "serve", "./", "--history", "--hostname", "0.0.0.0"]
|
CMD ["quasar", "serve", "./", "--history", "--hostname", "0.0.0.0"]
|
|
@ -1,121 +1,97 @@
|
||||||
#!/usr/bin/env groovy
|
#!/usr/bin/env groovy
|
||||||
|
|
||||||
def PROTECTED_BRANCH
|
|
||||||
|
|
||||||
def BRANCH_ENV = [
|
|
||||||
test: 'test',
|
|
||||||
master: 'production',
|
|
||||||
beta: 'production'
|
|
||||||
]
|
|
||||||
|
|
||||||
node {
|
|
||||||
stage('Setup') {
|
|
||||||
env.FRONT_REPLICAS = 1
|
|
||||||
env.NODE_ENV = BRANCH_ENV[env.BRANCH_NAME] ?: 'dev'
|
|
||||||
|
|
||||||
PROTECTED_BRANCH = [
|
|
||||||
'dev',
|
|
||||||
'test',
|
|
||||||
'master',
|
|
||||||
'beta'
|
|
||||||
].contains(env.BRANCH_NAME)
|
|
||||||
|
|
||||||
// https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
|
|
||||||
echo "NODE_NAME: ${env.NODE_NAME}"
|
|
||||||
echo "WORKSPACE: ${env.WORKSPACE}"
|
|
||||||
|
|
||||||
configFileProvider([
|
|
||||||
configFile(fileId: 'salix-front.properties',
|
|
||||||
variable: 'PROPS_FILE')
|
|
||||||
]) {
|
|
||||||
def props = readProperties file: PROPS_FILE
|
|
||||||
props.each {key, value -> env."${key}" = value }
|
|
||||||
props.each {key, value -> echo "${key}: ${value}" }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PROTECTED_BRANCH) {
|
|
||||||
configFileProvider([
|
|
||||||
configFile(fileId: "salix-front.branch.${env.BRANCH_NAME}",
|
|
||||||
variable: 'BRANCH_PROPS_FILE')
|
|
||||||
]) {
|
|
||||||
def props = readProperties file: BRANCH_PROPS_FILE
|
|
||||||
props.each {key, value -> env."${key}" = value }
|
|
||||||
props.each {key, value -> echo "${key}: ${value}" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
options {
|
options {
|
||||||
disableConcurrentBuilds()
|
disableConcurrentBuilds()
|
||||||
}
|
}
|
||||||
tools {
|
|
||||||
nodejs 'node-v18'
|
|
||||||
}
|
|
||||||
environment {
|
environment {
|
||||||
PROJECT_NAME = 'lilium'
|
PROJECT_NAME = 'lilium'
|
||||||
|
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
|
stage('Checkout') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
switch (env.BRANCH_NAME) {
|
||||||
|
case 'master':
|
||||||
|
env.NODE_ENV = 'production'
|
||||||
|
env.FRONT_REPLICAS = 2
|
||||||
|
break
|
||||||
|
case 'test':
|
||||||
|
env.NODE_ENV = 'test'
|
||||||
|
env.FRONT_REPLICAS = 1
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setEnv()
|
||||||
|
}
|
||||||
|
}
|
||||||
stage('Install') {
|
stage('Install') {
|
||||||
environment {
|
environment {
|
||||||
NODE_ENV = ""
|
NODE_ENV = ""
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
sh 'pnpm install --prefer-offline'
|
nodejs('node-v18') {
|
||||||
|
sh 'npm install --no-audit --prefer-offline'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Test') {
|
stage('Test') {
|
||||||
when {
|
when { not { anyOf {
|
||||||
expression { !PROTECTED_BRANCH }
|
branch 'test'
|
||||||
}
|
branch 'master'
|
||||||
|
}}}
|
||||||
environment {
|
environment {
|
||||||
NODE_ENV = ""
|
NODE_ENV = ""
|
||||||
}
|
}
|
||||||
|
parallel {
|
||||||
|
stage('Frontend') {
|
||||||
steps {
|
steps {
|
||||||
sh 'pnpm run test:unit:ci'
|
nodejs('node-v18') {
|
||||||
|
sh 'npm run test:unit:ci'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
post {
|
|
||||||
always {
|
|
||||||
junit(
|
|
||||||
testResults: 'junitresults.xml',
|
|
||||||
allowEmptyResults: true
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Build') {
|
stage('Build') {
|
||||||
when {
|
when { anyOf {
|
||||||
expression { PROTECTED_BRANCH }
|
branch 'test'
|
||||||
}
|
branch 'master'
|
||||||
|
}}
|
||||||
environment {
|
environment {
|
||||||
CREDENTIALS = credentials('docker-registry')
|
CREDENTIALS = credentials('docker-registry')
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
|
nodejs('node-v18') {
|
||||||
sh 'quasar build'
|
sh 'quasar build'
|
||||||
script {
|
|
||||||
def packageJson = readJSON file: 'package.json'
|
|
||||||
env.VERSION = "${packageJson.version}-build${env.BUILD_ID}"
|
|
||||||
}
|
}
|
||||||
dockerBuild()
|
dockerBuild()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Deploy') {
|
stage('Deploy') {
|
||||||
when {
|
when { anyOf {
|
||||||
expression { PROTECTED_BRANCH }
|
branch 'test'
|
||||||
|
branch 'master'
|
||||||
|
}}
|
||||||
|
environment {
|
||||||
|
DOCKER_HOST = "${env.SWARM_HOST}"
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
|
sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
always {
|
||||||
script {
|
script {
|
||||||
def packageJson = readJSON file: 'package.json'
|
if (!['master', 'test'].contains(env.BRANCH_NAME)) {
|
||||||
env.VERSION = "${packageJson.version}-build${env.BUILD_ID}"
|
try {
|
||||||
}
|
junit 'junitresults.xml'
|
||||||
withKubeConfig([
|
junit 'junit.xml'
|
||||||
serverUrl: "$KUBERNETES_API",
|
} catch (e) {
|
||||||
credentialsId: 'kubernetes',
|
echo e.toString()
|
||||||
namespace: 'lilium'
|
}
|
||||||
]) {
|
|
||||||
sh 'kubectl set image deployment/lilium-$BRANCH_NAME lilium-$BRANCH_NAME=$REGISTRY/salix-frontend:$VERSION'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ Lilium frontend
|
||||||
## Install the dependencies
|
## Install the dependencies
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm install
|
npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install quasar cli
|
### Install quasar cli
|
||||||
|
@ -23,13 +23,13 @@ quasar dev
|
||||||
### Run unit tests
|
### Run unit tests
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm run test:unit
|
npm run test:unit
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run e2e tests
|
### Run e2e tests
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm run test:e2e
|
npm run test:e2e
|
||||||
```
|
```
|
||||||
|
|
||||||
### Build the app for production
|
### Build the app for production
|
||||||
|
|
34
changelog.sh
|
@ -1,34 +0,0 @@
|
||||||
features_types=(chore feat style)
|
|
||||||
changes_types=(refactor perf)
|
|
||||||
fix_types=(fix revert)
|
|
||||||
file="CHANGELOG.md"
|
|
||||||
file_tmp="temp_log.txt"
|
|
||||||
file_current_tmp="temp_current_log.txt"
|
|
||||||
|
|
||||||
setType(){
|
|
||||||
echo "### $1" >> $file_tmp
|
|
||||||
arr=("$@")
|
|
||||||
echo "" > $file_current_tmp
|
|
||||||
for i in "${arr[@]}"
|
|
||||||
do
|
|
||||||
git log --grep="$i" --oneline --no-merges --format="- %s %d by:%an" master..test >> $file_current_tmp
|
|
||||||
done
|
|
||||||
# remove duplicates
|
|
||||||
sort -o $file_current_tmp -u $file_current_tmp
|
|
||||||
cat $file_current_tmp >> $file_tmp
|
|
||||||
echo "" >> $file_tmp
|
|
||||||
# remove tmp current file
|
|
||||||
[ -e $file_current_tmp ] && rm $file_current_tmp
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "# Version XX.XX - XXXX-XX-XX" >> $file_tmp
|
|
||||||
echo "" >> $file_tmp
|
|
||||||
|
|
||||||
setType "Added 🆕" "${features_types[@]}"
|
|
||||||
setType "Changed 📦" "${changes_types[@]}"
|
|
||||||
setType "Fixed 🛠️" "${fix_types[@]}"
|
|
||||||
|
|
||||||
cat $file >> $file_tmp
|
|
||||||
mv $file_tmp $file
|
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
export default { extends: ['@commitlint/config-conventional'] };
|
|
|
@ -1,42 +1,22 @@
|
||||||
import { defineConfig } from 'cypress';
|
const { defineConfig } = require('cypress');
|
||||||
// https://docs.cypress.io/app/tooling/reporters
|
|
||||||
// https://docs.cypress.io/app/references/configuration
|
|
||||||
// https://www.npmjs.com/package/cypress-mochawesome-reporter
|
|
||||||
|
|
||||||
export default defineConfig({
|
module.exports = defineConfig({
|
||||||
e2e: {
|
e2e: {
|
||||||
baseUrl: 'http://localhost:9000/',
|
baseUrl: 'http://localhost:9000/',
|
||||||
experimentalStudio: true,
|
|
||||||
fixturesFolder: 'test/cypress/fixtures',
|
fixturesFolder: 'test/cypress/fixtures',
|
||||||
screenshotsFolder: 'test/cypress/screenshots',
|
screenshotsFolder: 'test/cypress/screenshots',
|
||||||
supportFile: 'test/cypress/support/index.js',
|
supportFile: 'test/cypress/support/index.js',
|
||||||
videosFolder: 'test/cypress/videos',
|
videosFolder: 'test/cypress/videos',
|
||||||
downloadsFolder: 'test/cypress/downloads',
|
|
||||||
video: false,
|
video: false,
|
||||||
specPattern: 'test/cypress/integration/**/*.spec.js',
|
specPattern: 'test/cypress/integration/*.spec.js',
|
||||||
experimentalRunAllSpecs: true,
|
experimentalRunAllSpecs: true,
|
||||||
watchForFileChanges: true,
|
|
||||||
reporter: 'cypress-mochawesome-reporter',
|
|
||||||
reporterOptions: {
|
|
||||||
charts: true,
|
|
||||||
reportPageTitle: 'Cypress Inline Reporter',
|
|
||||||
reportFilename: '[status]_[datetime]-report',
|
|
||||||
embeddedScreenshots: true,
|
|
||||||
reportDir: 'test/cypress/reports',
|
|
||||||
inlineAssets: true,
|
|
||||||
},
|
|
||||||
component: {
|
component: {
|
||||||
componentFolder: 'src',
|
componentFolder: 'src',
|
||||||
testFiles: '**/*.spec.js',
|
testFiles: '**/*.spec.js',
|
||||||
supportFile: 'test/cypress/support/unit.js',
|
supportFile: 'test/cypress/support/unit.js',
|
||||||
},
|
},
|
||||||
setupNodeEvents: async (on, config) => {
|
setupNodeEvents(on, config) {
|
||||||
const plugin = await import('cypress-mochawesome-reporter/plugin');
|
// implement node event listeners here
|
||||||
plugin.default(on);
|
|
||||||
|
|
||||||
return config;
|
|
||||||
},
|
},
|
||||||
viewportWidth: 1280,
|
|
||||||
viewportHeight: 720,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 118 KiB |
After Width: | Height: | Size: 120 KiB |
After Width: | Height: | Size: 114 KiB |
After Width: | Height: | Size: 120 KiB |
After Width: | Height: | Size: 117 KiB |
|
@ -0,0 +1,65 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>JSDoc: Home</title>
|
||||||
|
|
||||||
|
<script src="scripts/prettify/prettify.js"> </script>
|
||||||
|
<script src="scripts/prettify/lang-css.js"> </script>
|
||||||
|
<!--[if lt IE 9]>
|
||||||
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||||
|
<![endif]-->
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div id="main">
|
||||||
|
|
||||||
|
<h1 class="page-title">Home</h1>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3> </h3>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav>
|
||||||
|
<h2><a href="index.html">Home</a></h2>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<br class="clear">
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Fri Nov 24 2023 13:16:37 GMT+0100 (Central European Standard Time)
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script> prettyPrint(); </script>
|
||||||
|
<script src="scripts/linenumber.js"> </script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*global document */
|
||||||
|
(() => {
|
||||||
|
const source = document.getElementsByClassName('prettyprint source linenums');
|
||||||
|
let i = 0;
|
||||||
|
let lineNumber = 0;
|
||||||
|
let lineId;
|
||||||
|
let lines;
|
||||||
|
let totalLines;
|
||||||
|
let anchorHash;
|
||||||
|
|
||||||
|
if (source && source[0]) {
|
||||||
|
anchorHash = document.location.hash.substring(1);
|
||||||
|
lines = source[0].getElementsByTagName('li');
|
||||||
|
totalLines = lines.length;
|
||||||
|
|
||||||
|
for (; i < totalLines; i++) {
|
||||||
|
lineNumber++;
|
||||||
|
lineId = `line${lineNumber}`;
|
||||||
|
lines[i].id = lineId;
|
||||||
|
if (lineId === anchorHash) {
|
||||||
|
lines[i].className += ' selected';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
|
@ -0,0 +1,202 @@
|
||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
|
@ -0,0 +1,2 @@
|
||||||
|
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n"]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com",
|
||||||
|
/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]);
|
|
@ -0,0 +1,28 @@
|
||||||
|
var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
|
||||||
|
(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
|
||||||
|
[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
|
||||||
|
f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
|
||||||
|
(j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
|
||||||
|
{b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
|
||||||
|
t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
|
||||||
|
"string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
|
||||||
|
l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
|
||||||
|
q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
|
||||||
|
q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
|
||||||
|
"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
|
||||||
|
a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
|
||||||
|
for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
|
||||||
|
m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
|
||||||
|
a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
|
||||||
|
j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
|
||||||
|
"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
|
||||||
|
H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
|
||||||
|
J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
|
||||||
|
I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
|
||||||
|
["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
|
||||||
|
/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
|
||||||
|
["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
|
||||||
|
hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
|
||||||
|
!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
|
||||||
|
250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
|
||||||
|
PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();
|
|
@ -0,0 +1,358 @@
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Open Sans';
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
src: url('../fonts/OpenSans-Regular-webfont.eot');
|
||||||
|
src:
|
||||||
|
local('Open Sans'),
|
||||||
|
local('OpenSans'),
|
||||||
|
url('../fonts/OpenSans-Regular-webfont.eot?#iefix') format('embedded-opentype'),
|
||||||
|
url('../fonts/OpenSans-Regular-webfont.woff') format('woff'),
|
||||||
|
url('../fonts/OpenSans-Regular-webfont.svg#open_sansregular') format('svg');
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Open Sans Light';
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
src: url('../fonts/OpenSans-Light-webfont.eot');
|
||||||
|
src:
|
||||||
|
local('Open Sans Light'),
|
||||||
|
local('OpenSans Light'),
|
||||||
|
url('../fonts/OpenSans-Light-webfont.eot?#iefix') format('embedded-opentype'),
|
||||||
|
url('../fonts/OpenSans-Light-webfont.woff') format('woff'),
|
||||||
|
url('../fonts/OpenSans-Light-webfont.svg#open_sanslight') format('svg');
|
||||||
|
}
|
||||||
|
|
||||||
|
html
|
||||||
|
{
|
||||||
|
overflow: auto;
|
||||||
|
background-color: #fff;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body
|
||||||
|
{
|
||||||
|
font-family: 'Open Sans', sans-serif;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: #4d4e53;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
a, a:visited, a:active {
|
||||||
|
color: #0095dd;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
header
|
||||||
|
{
|
||||||
|
display: block;
|
||||||
|
padding: 0px 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
tt, code, kbd, samp {
|
||||||
|
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.class-description {
|
||||||
|
font-size: 130%;
|
||||||
|
line-height: 140%;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
margin-top: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.class-description:empty {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main {
|
||||||
|
float: left;
|
||||||
|
width: 70%;
|
||||||
|
}
|
||||||
|
|
||||||
|
article dl {
|
||||||
|
margin-bottom: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
article img {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
section
|
||||||
|
{
|
||||||
|
display: block;
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 12px 24px;
|
||||||
|
border-bottom: 1px solid #ccc;
|
||||||
|
margin-right: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.variation {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.signature-attributes {
|
||||||
|
font-size: 60%;
|
||||||
|
color: #aaa;
|
||||||
|
font-style: italic;
|
||||||
|
font-weight: lighter;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav
|
||||||
|
{
|
||||||
|
display: block;
|
||||||
|
float: right;
|
||||||
|
margin-top: 28px;
|
||||||
|
width: 30%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-left: 1px solid #ccc;
|
||||||
|
padding-left: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul {
|
||||||
|
font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif;
|
||||||
|
font-size: 100%;
|
||||||
|
line-height: 17px;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
list-style-type: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul a, nav ul a:visited, nav ul a:active {
|
||||||
|
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
||||||
|
line-height: 18px;
|
||||||
|
color: #4D4E53;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav h3 {
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav li {
|
||||||
|
margin-top: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
display: block;
|
||||||
|
padding: 6px;
|
||||||
|
margin-top: 12px;
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 90%;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4 {
|
||||||
|
font-weight: 200;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1
|
||||||
|
{
|
||||||
|
font-family: 'Open Sans Light', sans-serif;
|
||||||
|
font-size: 48px;
|
||||||
|
letter-spacing: -2px;
|
||||||
|
margin: 12px 24px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2, h3.subsection-title
|
||||||
|
{
|
||||||
|
font-size: 30px;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: -1px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3
|
||||||
|
{
|
||||||
|
font-size: 24px;
|
||||||
|
letter-spacing: -0.5px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h4
|
||||||
|
{
|
||||||
|
font-size: 18px;
|
||||||
|
letter-spacing: -0.33px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
color: #4d4e53;
|
||||||
|
}
|
||||||
|
|
||||||
|
h5, .container-overview .subsection-title
|
||||||
|
{
|
||||||
|
font-size: 120%;
|
||||||
|
font-weight: bold;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
margin: 8px 0 3px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h6
|
||||||
|
{
|
||||||
|
font-size: 100%;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
margin: 6px 0 3px 0;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
table
|
||||||
|
{
|
||||||
|
border-spacing: 0;
|
||||||
|
border: 0;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
td, th
|
||||||
|
{
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
margin: 0px;
|
||||||
|
text-align: left;
|
||||||
|
vertical-align: top;
|
||||||
|
padding: 4px 6px;
|
||||||
|
display: table-cell;
|
||||||
|
}
|
||||||
|
|
||||||
|
thead tr
|
||||||
|
{
|
||||||
|
background-color: #ddd;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
th { border-right: 1px solid #aaa; }
|
||||||
|
tr > th:last-child { border-right: 1px solid #ddd; }
|
||||||
|
|
||||||
|
.ancestors, .attribs { color: #999; }
|
||||||
|
.ancestors a, .attribs a
|
||||||
|
{
|
||||||
|
color: #999 !important;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clear
|
||||||
|
{
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.important
|
||||||
|
{
|
||||||
|
font-weight: bold;
|
||||||
|
color: #950B02;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yes-def {
|
||||||
|
text-indent: -1000px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.type-signature {
|
||||||
|
color: #aaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.name, .signature {
|
||||||
|
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details { margin-top: 14px; border-left: 2px solid #DDD; }
|
||||||
|
.details dt { width: 120px; float: left; padding-left: 10px; padding-top: 6px; }
|
||||||
|
.details dd { margin-left: 70px; }
|
||||||
|
.details ul { margin: 0; }
|
||||||
|
.details ul { list-style-type: none; }
|
||||||
|
.details li { margin-left: 30px; padding-top: 6px; }
|
||||||
|
.details pre.prettyprint { margin: 0 }
|
||||||
|
.details .object-value { padding-top: 0; }
|
||||||
|
|
||||||
|
.description {
|
||||||
|
margin-bottom: 1em;
|
||||||
|
margin-top: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.code-caption
|
||||||
|
{
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 107%;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.source
|
||||||
|
{
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
width: 80%;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint.source {
|
||||||
|
width: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.source code
|
||||||
|
{
|
||||||
|
font-size: 100%;
|
||||||
|
line-height: 18px;
|
||||||
|
display: block;
|
||||||
|
padding: 4px 12px;
|
||||||
|
margin: 0;
|
||||||
|
background-color: #fff;
|
||||||
|
color: #4D4E53;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint code span.line
|
||||||
|
{
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint.linenums
|
||||||
|
{
|
||||||
|
padding-left: 70px;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint.linenums ol
|
||||||
|
{
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint.linenums li
|
||||||
|
{
|
||||||
|
border-left: 3px #ddd solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint.linenums li.selected,
|
||||||
|
.prettyprint.linenums li.selected *
|
||||||
|
{
|
||||||
|
background-color: lightyellow;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint.linenums li *
|
||||||
|
{
|
||||||
|
-webkit-user-select: text;
|
||||||
|
-moz-user-select: text;
|
||||||
|
-ms-user-select: text;
|
||||||
|
user-select: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
.params .name, .props .name, .name code {
|
||||||
|
color: #4D4E53;
|
||||||
|
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
||||||
|
font-size: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.params td.description > p:first-child,
|
||||||
|
.props td.description > p:first-child
|
||||||
|
{
|
||||||
|
margin-top: 0;
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.params td.description > p:last-child,
|
||||||
|
.props td.description > p:last-child
|
||||||
|
{
|
||||||
|
margin-bottom: 0;
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.disabled {
|
||||||
|
color: #454545;
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
/* JSDoc prettify.js theme */
|
||||||
|
|
||||||
|
/* plain text */
|
||||||
|
.pln {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* string content */
|
||||||
|
.str {
|
||||||
|
color: #006400;
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a keyword */
|
||||||
|
.kwd {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a comment */
|
||||||
|
.com {
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a type name */
|
||||||
|
.typ {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a literal value */
|
||||||
|
.lit {
|
||||||
|
color: #006400;
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* punctuation */
|
||||||
|
.pun {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* lisp open bracket */
|
||||||
|
.opn {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* lisp close bracket */
|
||||||
|
.clo {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a markup tag name */
|
||||||
|
.tag {
|
||||||
|
color: #006400;
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a markup attribute name */
|
||||||
|
.atn {
|
||||||
|
color: #006400;
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a markup attribute value */
|
||||||
|
.atv {
|
||||||
|
color: #006400;
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a declaration */
|
||||||
|
.dec {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a variable name */
|
||||||
|
.var {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a function name */
|
||||||
|
.fun {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Specify class=linenums on a pre to get line numbering */
|
||||||
|
ol.linenums {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
|
@ -0,0 +1,132 @@
|
||||||
|
/* Tomorrow Theme */
|
||||||
|
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
|
||||||
|
/* Pretty printing styles. Used with prettify.js. */
|
||||||
|
/* SPAN elements with the classes below are added by prettyprint. */
|
||||||
|
/* plain text */
|
||||||
|
.pln {
|
||||||
|
color: #4d4d4c; }
|
||||||
|
|
||||||
|
@media screen {
|
||||||
|
/* string content */
|
||||||
|
.str {
|
||||||
|
color: #718c00; }
|
||||||
|
|
||||||
|
/* a keyword */
|
||||||
|
.kwd {
|
||||||
|
color: #8959a8; }
|
||||||
|
|
||||||
|
/* a comment */
|
||||||
|
.com {
|
||||||
|
color: #8e908c; }
|
||||||
|
|
||||||
|
/* a type name */
|
||||||
|
.typ {
|
||||||
|
color: #4271ae; }
|
||||||
|
|
||||||
|
/* a literal value */
|
||||||
|
.lit {
|
||||||
|
color: #f5871f; }
|
||||||
|
|
||||||
|
/* punctuation */
|
||||||
|
.pun {
|
||||||
|
color: #4d4d4c; }
|
||||||
|
|
||||||
|
/* lisp open bracket */
|
||||||
|
.opn {
|
||||||
|
color: #4d4d4c; }
|
||||||
|
|
||||||
|
/* lisp close bracket */
|
||||||
|
.clo {
|
||||||
|
color: #4d4d4c; }
|
||||||
|
|
||||||
|
/* a markup tag name */
|
||||||
|
.tag {
|
||||||
|
color: #c82829; }
|
||||||
|
|
||||||
|
/* a markup attribute name */
|
||||||
|
.atn {
|
||||||
|
color: #f5871f; }
|
||||||
|
|
||||||
|
/* a markup attribute value */
|
||||||
|
.atv {
|
||||||
|
color: #3e999f; }
|
||||||
|
|
||||||
|
/* a declaration */
|
||||||
|
.dec {
|
||||||
|
color: #f5871f; }
|
||||||
|
|
||||||
|
/* a variable name */
|
||||||
|
.var {
|
||||||
|
color: #c82829; }
|
||||||
|
|
||||||
|
/* a function name */
|
||||||
|
.fun {
|
||||||
|
color: #4271ae; } }
|
||||||
|
/* Use higher contrast and text-weight for printable form. */
|
||||||
|
@media print, projection {
|
||||||
|
.str {
|
||||||
|
color: #060; }
|
||||||
|
|
||||||
|
.kwd {
|
||||||
|
color: #006;
|
||||||
|
font-weight: bold; }
|
||||||
|
|
||||||
|
.com {
|
||||||
|
color: #600;
|
||||||
|
font-style: italic; }
|
||||||
|
|
||||||
|
.typ {
|
||||||
|
color: #404;
|
||||||
|
font-weight: bold; }
|
||||||
|
|
||||||
|
.lit {
|
||||||
|
color: #044; }
|
||||||
|
|
||||||
|
.pun, .opn, .clo {
|
||||||
|
color: #440; }
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
color: #006;
|
||||||
|
font-weight: bold; }
|
||||||
|
|
||||||
|
.atn {
|
||||||
|
color: #404; }
|
||||||
|
|
||||||
|
.atv {
|
||||||
|
color: #060; } }
|
||||||
|
/* Style */
|
||||||
|
/*
|
||||||
|
pre.prettyprint {
|
||||||
|
background: white;
|
||||||
|
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.5;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
padding: 10px; }
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Specify class=linenums on a pre to get line numbering */
|
||||||
|
ol.linenums {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0; }
|
||||||
|
|
||||||
|
/* IE indents via margin-left */
|
||||||
|
li.L0,
|
||||||
|
li.L1,
|
||||||
|
li.L2,
|
||||||
|
li.L3,
|
||||||
|
li.L4,
|
||||||
|
li.L5,
|
||||||
|
li.L6,
|
||||||
|
li.L7,
|
||||||
|
li.L8,
|
||||||
|
li.L9 {
|
||||||
|
/* */ }
|
||||||
|
|
||||||
|
/* Alternate shading for lines */
|
||||||
|
li.L1,
|
||||||
|
li.L3,
|
||||||
|
li.L5,
|
||||||
|
li.L7,
|
||||||
|
li.L9 {
|
||||||
|
/* */ }
|
|
@ -1,7 +1,17 @@
|
||||||
version: '3.7'
|
version: '3.7'
|
||||||
services:
|
services:
|
||||||
main:
|
main:
|
||||||
image: registry.verdnatura.es/salix-frontend:${VERSION:?}
|
image: registry.verdnatura.es/salix-frontend:${BRANCH_NAME:?}
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ./Dockerfile
|
dockerfile: ./Dockerfile
|
||||||
|
ports:
|
||||||
|
- 4000
|
||||||
|
deploy:
|
||||||
|
replicas: ${FRONT_REPLICAS:?}
|
||||||
|
placement:
|
||||||
|
constraints:
|
||||||
|
- node.role == worker
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: 1G
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
import { defineConfig } from 'vitepress';
|
|
||||||
|
|
||||||
// https://vitepress.dev/reference/site-config
|
|
||||||
export default defineConfig({
|
|
||||||
title: 'Lilium',
|
|
||||||
description: 'Lilium docs',
|
|
||||||
themeConfig: {
|
|
||||||
// https://vitepress.dev/reference/default-theme-config
|
|
||||||
nav: [
|
|
||||||
{ text: 'Home', link: '/' },
|
|
||||||
{ text: 'Components', link: '/components/vnInput' },
|
|
||||||
{ text: 'Composables', link: '/composables/useArrayData' },
|
|
||||||
],
|
|
||||||
|
|
||||||
sidebar: [
|
|
||||||
{
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
text: 'Components',
|
|
||||||
collapsible: true,
|
|
||||||
collapsed: true,
|
|
||||||
items: [{ text: 'VnInput', link: '/components/vnInput' }],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Composables',
|
|
||||||
collapsible: true,
|
|
||||||
collapsed: true,
|
|
||||||
items: [
|
|
||||||
{ text: 'useArrayData', link: '/composables/useArrayData' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
socialLinks: [{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }],
|
|
||||||
},
|
|
||||||
});
|
|
|
@ -1,136 +0,0 @@
|
||||||
# VnInput
|
|
||||||
|
|
||||||
`VnInput` is a custom input component that provides various useful features such as validation, input clearing, and more.
|
|
||||||
|
|
||||||
## Props
|
|
||||||
|
|
||||||
### `modelValue`
|
|
||||||
|
|
||||||
- **Type:** `String | Number`
|
|
||||||
- **Default:** `null`
|
|
||||||
- **Description:** The value of the model bound to the component.
|
|
||||||
|
|
||||||
### `isOutlined`
|
|
||||||
|
|
||||||
- **Type:** `Boolean`
|
|
||||||
- **Default:** `false`
|
|
||||||
- **Description:** If `true`, the component is rendered with an outlined style.
|
|
||||||
|
|
||||||
### `info`
|
|
||||||
|
|
||||||
- **Type:** `String`
|
|
||||||
- **Default:** `''`
|
|
||||||
- **Description:** Additional information displayed alongside the component.
|
|
||||||
|
|
||||||
### `clearable`
|
|
||||||
|
|
||||||
- **Type:** `Boolean`
|
|
||||||
- **Default:** `true`
|
|
||||||
- **Description:** If `true`, the component shows a button to clear the input.
|
|
||||||
|
|
||||||
### `emptyToNull`
|
|
||||||
|
|
||||||
- **Type:** `Boolean`
|
|
||||||
- **Default:** `true`
|
|
||||||
- **Description:** If `true`, converts empty inputs to `null`.
|
|
||||||
|
|
||||||
### `insertable`
|
|
||||||
|
|
||||||
- **Type:** `Boolean`
|
|
||||||
- **Default:** `false`
|
|
||||||
- **Description:** If `true`, allows the insertion of new values.
|
|
||||||
|
|
||||||
### `maxlength`
|
|
||||||
|
|
||||||
- **Type:** `Number`
|
|
||||||
- **Default:** `null`
|
|
||||||
- **Description:** The maximum number of characters allowed in the input.
|
|
||||||
|
|
||||||
### `uppercase`
|
|
||||||
|
|
||||||
- **Type:** `Boolean`
|
|
||||||
- **Default:** `false`
|
|
||||||
- **Description:** If `true`, converts the input text to uppercase.
|
|
||||||
|
|
||||||
## Emits
|
|
||||||
|
|
||||||
### `update:modelValue`
|
|
||||||
|
|
||||||
- **Description:** Emits the updated model value.
|
|
||||||
- **Behavior:** This event is emitted whenever the input value changes. It is used to update the model value bound to the component.
|
|
||||||
|
|
||||||
### `update:options`
|
|
||||||
|
|
||||||
- **Description:** Emits the updated options.
|
|
||||||
- **Behavior:** This event is emitted when the component's options change. It is useful for components with dynamic options.
|
|
||||||
|
|
||||||
### `keyup.enter`
|
|
||||||
|
|
||||||
- **Description:** Emits an event when the Enter key is pressed.
|
|
||||||
- **Behavior:** This event is emitted whenever the Enter key is pressed while the input is focused. It can be used to handle specific actions when the input is confirmed.
|
|
||||||
|
|
||||||
### `remove`
|
|
||||||
|
|
||||||
- **Description:** Emits an event to remove the current value.
|
|
||||||
- **Behavior:** This event is emitted when the clear button (close icon) is clicked. It is used to handle the removal of the current input value.
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
### `focus`
|
|
||||||
|
|
||||||
- **Description:** Focuses the input.
|
|
||||||
- **Behavior:** This function is exposed so it can be called from outside the component. It uses `vnInputRef.value.focus()` to focus the input.
|
|
||||||
|
|
||||||
### `handleKeydown`
|
|
||||||
|
|
||||||
- **Description:** Handles the `keydown` event of the input.
|
|
||||||
- **Behavior:** This function is called whenever a key is pressed while the input is focused. If the pressed key is `Backspace`, it does nothing. If `insertable` is `true` and the pressed key is a number, it calls `handleInsertMode`.
|
|
||||||
|
|
||||||
### `handleInsertMode`
|
|
||||||
|
|
||||||
- **Description:** Handles the insertion mode of values.
|
|
||||||
- **Behavior:** This function is called when `insertable` is `true` and a numeric key is pressed. It inserts the value at the cursor position and updates the input value. Then, it moves the cursor to the correct position.
|
|
||||||
|
|
||||||
### `handleUppercase`
|
|
||||||
|
|
||||||
- **Description:** Converts the input value to uppercase.
|
|
||||||
- **Behavior:** This function is called when the uppercase icon is clicked. It converts the current input value to uppercase.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```vue
|
|
||||||
<template>
|
|
||||||
<VnInput
|
|
||||||
v-model="inputValue"
|
|
||||||
:isOutlined="true"
|
|
||||||
info="Additional information"
|
|
||||||
:clearable="true"
|
|
||||||
:emptyToNull="true"
|
|
||||||
:insertable="false"
|
|
||||||
:maxlength="50"
|
|
||||||
:uppercase="true"
|
|
||||||
@update:modelValue="handleUpdate"
|
|
||||||
@keyup.enter="handleEnter"
|
|
||||||
@remove="handleRemove"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
|
|
||||||
const inputValue = ref('');
|
|
||||||
|
|
||||||
const handleUpdate = (value) => {
|
|
||||||
console.log('Updated value:', value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleEnter = () => {
|
|
||||||
console.log('Enter pressed');
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleRemove = () => {
|
|
||||||
console.log('Value removed');
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
```
|
|
|
@ -1,215 +0,0 @@
|
||||||
# useArrayData
|
|
||||||
|
|
||||||
`useArrayData` is a composable function that provides a set of utilities for managing array data in a Vue component. It leverages Pinia for state management and provides various methods for fetching, filtering, and manipulating data.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
|
||||||
|
|
||||||
const {
|
|
||||||
fetch,
|
|
||||||
applyFilter,
|
|
||||||
addFilter,
|
|
||||||
getCurrentFilter,
|
|
||||||
setCurrentFilter,
|
|
||||||
addFilterWhere,
|
|
||||||
addOrder,
|
|
||||||
deleteOrder,
|
|
||||||
refresh,
|
|
||||||
destroy,
|
|
||||||
loadMore,
|
|
||||||
store,
|
|
||||||
totalRows,
|
|
||||||
updateStateParams,
|
|
||||||
isLoading,
|
|
||||||
deleteOption,
|
|
||||||
reset,
|
|
||||||
resetPagination,
|
|
||||||
} = useArrayData('myKey', userOptions);
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
### `key`
|
|
||||||
|
|
||||||
- **Type:** `String`
|
|
||||||
- **Description:** A unique key to identify the data store.
|
|
||||||
|
|
||||||
### `userOptions`
|
|
||||||
|
|
||||||
- **Type:** `Object`
|
|
||||||
- **Description:** An object containing user-defined options for configuring the data store.
|
|
||||||
|
|
||||||
## Methods
|
|
||||||
|
|
||||||
### `fetch`
|
|
||||||
|
|
||||||
Fetches data from the server.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`options`** : An object with the following properties:
|
|
||||||
- `append` (Boolean): Whether to append the fetched data to the existing data.
|
|
||||||
- `updateRouter` (Boolean): Whether to update the router with the current filter.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Promise`** : A promise that resolves with the fetched data.
|
|
||||||
|
|
||||||
### `applyFilter`
|
|
||||||
|
|
||||||
Applies a filter to the data.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`filter`** : An object containing the filter criteria.
|
|
||||||
- **`params`** : Additional parameters for the filter.
|
|
||||||
- **`fetchOptions`** : Options for the fetch method.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Promise`** : A promise that resolves with the filtered data.
|
|
||||||
|
|
||||||
### `addFilter`
|
|
||||||
|
|
||||||
Adds a filter to the existing filters.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`filter`** : An object containing the filter criteria.
|
|
||||||
- **`params`** : Additional parameters for the filter.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Promise`** : A promise that resolves with the updated filter and parameters.
|
|
||||||
|
|
||||||
### `getCurrentFilter`
|
|
||||||
|
|
||||||
Gets the current filter applied to the data.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Object`** : The current filter and parameters.
|
|
||||||
|
|
||||||
### `setCurrentFilter`
|
|
||||||
|
|
||||||
Sets the current filter for the data.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Object`** : The current filter and parameters.
|
|
||||||
|
|
||||||
### `addFilterWhere`
|
|
||||||
|
|
||||||
Adds a `where` clause to the existing filters.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`where`** : An object containing the `where` clause.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Promise`** : A promise that resolves when the filter is applied.
|
|
||||||
|
|
||||||
### `addOrder`
|
|
||||||
|
|
||||||
Adds an order to the existing orders.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`field`** : The field to order by.
|
|
||||||
- **`direction`** : The direction of the order (`ASC` or `DESC`).
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Promise`** : A promise that resolves with the updated order.
|
|
||||||
|
|
||||||
### `deleteOrder`
|
|
||||||
|
|
||||||
Deletes an order from the existing orders.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`field`** : The field to delete the order for.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Promise`** : A promise that resolves when the order is deleted.
|
|
||||||
|
|
||||||
### `refresh`
|
|
||||||
|
|
||||||
Refreshes the data by re-fetching it from the server.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Promise`** : A promise that resolves with the refreshed data.
|
|
||||||
|
|
||||||
### `destroy`
|
|
||||||
|
|
||||||
Destroys the data store for the given key.
|
|
||||||
|
|
||||||
### `loadMore`
|
|
||||||
|
|
||||||
Loads more data by incrementing the pagination.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Promise`** : A promise that resolves with the additional data.
|
|
||||||
|
|
||||||
### `updateStateParams`
|
|
||||||
|
|
||||||
Updates the state parameters with the given data.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`data`** : The data to update the state parameters with.
|
|
||||||
|
|
||||||
### `deleteOption`
|
|
||||||
|
|
||||||
Deletes an option from the store.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`option`** : The option to delete.
|
|
||||||
|
|
||||||
### `reset`
|
|
||||||
|
|
||||||
Resets the store to its default state.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`opts`** : An array of options to reset.
|
|
||||||
|
|
||||||
### `resetPagination`
|
|
||||||
|
|
||||||
Resets the pagination for the store.
|
|
||||||
|
|
||||||
## Computed Properties
|
|
||||||
|
|
||||||
### `totalRows`
|
|
||||||
|
|
||||||
- **Description:** The total number of rows in the data.
|
|
||||||
- **Type:** `Number`
|
|
||||||
|
|
||||||
### `isLoading`
|
|
||||||
|
|
||||||
- **Description:** Whether the data is currently being loaded.
|
|
||||||
- **Type:** `Boolean`
|
|
||||||
|
|
||||||
```vue
|
|
||||||
<script setup>
|
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
|
||||||
|
|
||||||
const userOptions = {
|
|
||||||
url: '/api/data',
|
|
||||||
limit: 10,
|
|
||||||
};
|
|
||||||
|
|
||||||
const arrayData = useArrayData('myKey', userOptions);
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
|
@ -1,13 +0,0 @@
|
||||||
---
|
|
||||||
# https://vitepress.dev/reference/default-theme-home-page
|
|
||||||
layout: home
|
|
||||||
|
|
||||||
hero:
|
|
||||||
name: 'Lilium'
|
|
||||||
text: 'Lilium docs'
|
|
||||||
tagline: Powered by Verdnatura
|
|
||||||
actions:
|
|
||||||
- theme: brand
|
|
||||||
text: Docs
|
|
||||||
link: /components/vnInput
|
|
||||||
---
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"plugins": [],
|
||||||
|
"source": {
|
||||||
|
"include": ["src"],
|
||||||
|
"includePattern": "\\.(vue|js)$",
|
||||||
|
"excludePattern": "(node_modules\\/docs)"
|
||||||
|
},
|
||||||
|
"templates": {
|
||||||
|
"cleverLinks": false,
|
||||||
|
"monospaceLinks": false
|
||||||
|
},
|
||||||
|
"opts": {
|
||||||
|
"recurse": true,
|
||||||
|
"destination": "./doc"
|
||||||
|
}
|
||||||
|
}
|
67
package.json
|
@ -1,74 +1,57 @@
|
||||||
{
|
{
|
||||||
"name": "salix-front",
|
"name": "salix-front",
|
||||||
"version": "25.06.0",
|
"version": "23.48.01",
|
||||||
"description": "Salix frontend",
|
"description": "Salix frontend",
|
||||||
"productName": "Salix",
|
"productName": "Salix",
|
||||||
"author": "Verdnatura",
|
"author": "Verdnatura",
|
||||||
"private": true,
|
"private": true,
|
||||||
"packageManager": "pnpm@8.15.1",
|
|
||||||
"type": "module",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"resetDatabase": "cd ../salix && gulp docker",
|
|
||||||
"lint": "eslint --ext .js,.vue ./",
|
"lint": "eslint --ext .js,.vue ./",
|
||||||
"format": "prettier --write \"**/*.{js,vue,scss,html,md,json}\" --ignore-path .gitignore",
|
"format": "prettier --write \"**/*.{js,vue,scss,html,md,json}\" --ignore-path .gitignore",
|
||||||
"test:e2e": "cypress open",
|
"test:e2e": "cypress open",
|
||||||
"test:e2e:ci": "npm run resetDatabase && cd ../salix-front && cypress run",
|
"test:e2e:ci": "cd ../salix && gulp docker && cd ../salix-front && cypress run --browser electron",
|
||||||
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
|
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
|
||||||
"test:unit": "vitest",
|
"test:unit": "vitest",
|
||||||
"test:unit:ci": "vitest run",
|
"test:unit:ci": "vitest run"
|
||||||
"commitlint": "commitlint --edit",
|
|
||||||
"prepare": "npx husky install",
|
|
||||||
"addReferenceTag": "node .husky/addReferenceTag.js",
|
|
||||||
"docs:dev": "vitepress dev docs",
|
|
||||||
"docs:build": "vitepress build docs",
|
|
||||||
"docs:preview": "vitepress preview docs"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@quasar/cli": "^2.4.1",
|
"@quasar/cli": "^2.3.0",
|
||||||
"@quasar/extras": "^1.16.16",
|
"@quasar/extras": "^1.16.4",
|
||||||
"axios": "^1.4.0",
|
"axios": "^1.4.0",
|
||||||
"chromium": "^3.0.3",
|
"chromium": "^3.0.3",
|
||||||
"croppie": "^2.6.5",
|
|
||||||
"moment": "^2.30.1",
|
|
||||||
"pinia": "^2.1.3",
|
"pinia": "^2.1.3",
|
||||||
"quasar": "^2.17.7",
|
"quasar": "^2.12.0",
|
||||||
"validator": "^13.9.0",
|
"validator": "^13.9.0",
|
||||||
"vue": "^3.5.13",
|
"vue": "^3.3.4",
|
||||||
"vue-i18n": "^9.3.0",
|
"vue-i18n": "^9.2.2",
|
||||||
"vue-router": "^4.2.5"
|
"vue-router": "^4.2.1",
|
||||||
|
"vue-router-mock": "^0.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^19.2.1",
|
"@intlify/unplugin-vue-i18n": "^0.8.1",
|
||||||
"@commitlint/config-conventional": "^19.1.0",
|
|
||||||
"@intlify/unplugin-vue-i18n": "^0.8.2",
|
|
||||||
"@pinia/testing": "^0.1.2",
|
"@pinia/testing": "^0.1.2",
|
||||||
"@quasar/app-vite": "^2.0.8",
|
"@quasar/app-vite": "^1.4.3",
|
||||||
"@quasar/quasar-app-extension-qcalendar": "^4.0.2",
|
"@quasar/quasar-app-extension-testing-unit-vitest": "^0.3.0",
|
||||||
"@quasar/quasar-app-extension-testing-unit-vitest": "^0.4.0",
|
"@vue/test-utils": "^2.3.2",
|
||||||
"@vue/test-utils": "^2.4.4",
|
|
||||||
"autoprefixer": "^10.4.14",
|
"autoprefixer": "^10.4.14",
|
||||||
"cypress": "^13.6.6",
|
"cypress": "^12.13.0",
|
||||||
"cypress-mochawesome-reporter": "^3.8.2",
|
"eslint": "^8.41.0",
|
||||||
"eslint": "^9.18.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
"eslint-config-prettier": "^10.0.1",
|
"eslint-plugin-cypress": "^2.13.3",
|
||||||
"eslint-plugin-cypress": "^4.1.0",
|
"eslint-plugin-vue": "^9.14.1",
|
||||||
"eslint-plugin-vue": "^9.32.0",
|
"jsdoc": "^4.0.2",
|
||||||
"husky": "^8.0.0",
|
|
||||||
"postcss": "^8.4.23",
|
"postcss": "^8.4.23",
|
||||||
"prettier": "^3.4.2",
|
"prettier": "^2.8.8",
|
||||||
"sass": "^1.83.4",
|
"vitest": "^0.31.1"
|
||||||
"vitepress": "^1.6.3",
|
|
||||||
"vitest": "^0.34.0"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^20 || ^18 || ^16",
|
"node": "^20 || ^18 || ^16",
|
||||||
"npm": ">= 8.1.2",
|
"npm": ">= 8.1.2",
|
||||||
"yarn": ">= 1.21.1",
|
"yarn": ">= 1.21.1"
|
||||||
"bun": ">= 1.0.25"
|
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"@vitejs/plugin-vue": "^5.2.1",
|
"@vitejs/plugin-vue": "^4.0.0",
|
||||||
"vite": "^6.0.11",
|
"vite": "^4.3.5",
|
||||||
"vitest": "^0.31.1"
|
"vitest": "^0.31.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
8089
pnpm-lock.yaml
|
@ -1,14 +1,10 @@
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
// https://github.com/michael-ciniawsky/postcss-load-config
|
// https://github.com/michael-ciniawsky/postcss-load-config
|
||||||
|
|
||||||
import autoprefixer from 'autoprefixer';
|
module.exports = {
|
||||||
// Uncomment the following line if you want to support RTL CSS
|
|
||||||
// import rtlcss from 'postcss-rtlcss';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
plugins: [
|
plugins: [
|
||||||
// https://github.com/postcss/autoprefixer
|
// https://github.com/postcss/autoprefixer
|
||||||
autoprefixer({
|
require('autoprefixer')({
|
||||||
overrideBrowserslist: [
|
overrideBrowserslist: [
|
||||||
'last 4 Chrome versions',
|
'last 4 Chrome versions',
|
||||||
'last 4 Firefox versions',
|
'last 4 Firefox versions',
|
||||||
|
@ -22,7 +18,10 @@ export default {
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// https://github.com/elchininet/postcss-rtlcss
|
// https://github.com/elchininet/postcss-rtlcss
|
||||||
// If you want to support RTL CSS, uncomment the following line:
|
// If you want to support RTL css, then
|
||||||
// rtlcss(),
|
// 1. yarn/npm install postcss-rtlcss
|
||||||
|
// 2. optionally set quasar.config.js > framework > lang to an RTL language
|
||||||
|
// 3. uncomment the following line:
|
||||||
|
// require('postcss-rtlcss')
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
export default [
|
|
||||||
{
|
|
||||||
path: '/api',
|
|
||||||
rule: { target: 'http://0.0.0.0:3000' },
|
|
||||||
},
|
|
||||||
];
|
|
Before Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 9.9 KiB |
|
@ -8,11 +8,11 @@
|
||||||
// Configuration for your app
|
// Configuration for your app
|
||||||
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js
|
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js
|
||||||
|
|
||||||
import { configure } from 'quasar/wrappers';
|
const { configure } = require('quasar/wrappers');
|
||||||
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
|
const VueI18nPlugin = require('@intlify/unplugin-vue-i18n/vite');
|
||||||
import path from 'path';
|
const path = require('path');
|
||||||
|
|
||||||
export default configure(function (/* ctx */) {
|
module.exports = configure(function (/* ctx */) {
|
||||||
return {
|
return {
|
||||||
eslint: {
|
eslint: {
|
||||||
// fix: true,
|
// fix: true,
|
||||||
|
@ -29,7 +29,7 @@ export default configure(function (/* ctx */) {
|
||||||
// app boot file (/src/boot)
|
// app boot file (/src/boot)
|
||||||
// --> boot files are part of "main.js"
|
// --> boot files are part of "main.js"
|
||||||
// https://v2.quasar.dev/quasar-cli/boot-files
|
// https://v2.quasar.dev/quasar-cli/boot-files
|
||||||
boot: ['i18n', 'axios', 'vnDate', 'validations', 'quasar', 'quasar.defaults'],
|
boot: ['i18n', 'axios', 'vnDate'],
|
||||||
|
|
||||||
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css
|
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css
|
||||||
css: ['app.scss'],
|
css: ['app.scss'],
|
||||||
|
@ -66,9 +66,7 @@ export default configure(function (/* ctx */) {
|
||||||
// publicPath: '/',
|
// publicPath: '/',
|
||||||
// analyze: true,
|
// analyze: true,
|
||||||
// env: {},
|
// env: {},
|
||||||
rawDefine: {
|
// rawDefine: {}
|
||||||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
|
||||||
},
|
|
||||||
// ignorePublicFolder: true,
|
// ignorePublicFolder: true,
|
||||||
// minify: false,
|
// minify: false,
|
||||||
// polyfillModulePreload: true,
|
// polyfillModulePreload: true,
|
||||||
|
@ -91,13 +89,14 @@ export default configure(function (/* ctx */) {
|
||||||
|
|
||||||
vitePlugins: [
|
vitePlugins: [
|
||||||
[
|
[
|
||||||
VueI18nPlugin({
|
VueI18nPlugin,
|
||||||
runtimeOnly: false,
|
{
|
||||||
include: [
|
// if you want to use Vue I18n Legacy API, you need to set `compositionOnly: false`
|
||||||
path.resolve(__dirname, './src/i18n/locale/**'),
|
// compositionOnly: false,
|
||||||
path.resolve(__dirname, './src/pages/**/locale/**'),
|
|
||||||
],
|
// you need to set i18n resource including paths !
|
||||||
}),
|
include: path.resolve(__dirname, './src/i18n/**'),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -115,13 +114,15 @@ export default configure(function (/* ctx */) {
|
||||||
secure: false,
|
secure: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
open: false,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#framework
|
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#framework
|
||||||
framework: {
|
framework: {
|
||||||
config: {
|
config: {
|
||||||
config: {
|
config: {
|
||||||
|
brand: {
|
||||||
|
primary: 'orange',
|
||||||
|
},
|
||||||
dark: 'auto',
|
dark: 'auto',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -179,6 +180,7 @@ export default configure(function (/* ctx */) {
|
||||||
'render', // keep this as last one
|
'render', // keep this as last one
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
// https://v2.quasar.dev/quasar-cli/developing-pwa/configuring-pwa
|
// https://v2.quasar.dev/quasar-cli/developing-pwa/configuring-pwa
|
||||||
pwa: {
|
pwa: {
|
||||||
workboxMode: 'generateSW', // or 'injectManifest'
|
workboxMode: 'generateSW', // or 'injectManifest'
|
||||||
|
|
|
@ -3,6 +3,5 @@
|
||||||
"options": [
|
"options": [
|
||||||
"scripts"
|
"scripts"
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
"@quasar/qcalendar": {}
|
|
||||||
}
|
}
|
|
@ -1,11 +1,10 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted } from 'vue';
|
import { onMounted } from 'vue';
|
||||||
import { useQuasar, Dark } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const { availableLocales, locale, fallbackLocale } = useI18n();
|
const { availableLocales, locale, fallbackLocale } = useI18n();
|
||||||
Dark.set(true);
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
let userLang = window.navigator.language;
|
let userLang = window.navigator.language;
|
||||||
|
@ -16,7 +15,7 @@ onMounted(() => {
|
||||||
if (availableLocales.includes(userLang)) {
|
if (availableLocales.includes(userLang)) {
|
||||||
locale.value = userLang;
|
locale.value = userLang;
|
||||||
} else {
|
} else {
|
||||||
locale.value = fallbackLocale.value;
|
locale.value = fallbackLocale;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,20 @@
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import { Notify } from 'quasar';
|
||||||
import { useSession } from 'src/composables/useSession';
|
import { useSession } from 'src/composables/useSession';
|
||||||
import { Router } from 'src/router';
|
import { Router } from 'src/router';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import { i18n } from './i18n';
|
||||||
import { useStateQueryStore } from 'src/stores/useStateQueryStore';
|
|
||||||
import { getToken, isLoggedIn } from 'src/utils/session';
|
|
||||||
import { i18n } from 'src/boot/i18n';
|
|
||||||
|
|
||||||
const { notify } = useNotify();
|
const session = useSession();
|
||||||
const stateQuery = useStateQueryStore();
|
const { t } = i18n.global;
|
||||||
const baseUrl = '/api/';
|
|
||||||
axios.defaults.baseURL = baseUrl;
|
axios.defaults.baseURL = '/api/';
|
||||||
const axiosNoError = axios.create({ baseURL: baseUrl });
|
|
||||||
|
|
||||||
const onRequest = (config) => {
|
const onRequest = (config) => {
|
||||||
const token = getToken();
|
const token = session.getToken();
|
||||||
if (token.length && !config.headers.Authorization) {
|
if (token.length && config.headers) {
|
||||||
config.headers.Authorization = token;
|
config.headers.Authorization = token;
|
||||||
config.headers['Accept-Language'] = i18n.global.locale.value;
|
|
||||||
}
|
}
|
||||||
stateQuery.add(config);
|
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,34 +23,59 @@ const onRequestError = (error) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onResponse = (response) => {
|
const onResponse = (response) => {
|
||||||
const config = response.config;
|
const { method } = response.config;
|
||||||
stateQuery.remove(config);
|
|
||||||
|
|
||||||
if (config.method === 'patch') {
|
const isSaveRequest = method === 'patch';
|
||||||
notify('globals.dataSaved', 'positive');
|
if (isSaveRequest) {
|
||||||
|
Notify.create({
|
||||||
|
message: t('globals.dataSaved'),
|
||||||
|
type: 'positive',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onResponseError = async (error) => {
|
const onResponseError = (error) => {
|
||||||
stateQuery.remove(error.config);
|
let message = '';
|
||||||
|
|
||||||
if (isLoggedIn() && error.response?.status === 401) {
|
const response = error.response;
|
||||||
await useSession().destroy(false);
|
const responseData = response && response.data;
|
||||||
|
const responseError = responseData && response.data.error;
|
||||||
|
if (responseError) {
|
||||||
|
message = responseError.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (response?.status) {
|
||||||
|
case 500:
|
||||||
|
message = 'errors.statusInternalServerError';
|
||||||
|
break;
|
||||||
|
case 502:
|
||||||
|
message = 'errors.statusBadGateway';
|
||||||
|
break;
|
||||||
|
case 504:
|
||||||
|
message = 'errors.statusGatewayTimeout';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (session.isLoggedIn() && response?.status === 401) {
|
||||||
|
session.destroy();
|
||||||
const hash = window.location.hash;
|
const hash = window.location.hash;
|
||||||
const url = hash.slice(1);
|
const url = hash.slice(1);
|
||||||
Router.push(`/login?redirect=${url}`);
|
Router.push({ path: url });
|
||||||
} else if (!isLoggedIn()) {
|
} else if (!session.isLoggedIn()) {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Notify.create({
|
||||||
|
message: t(message),
|
||||||
|
type: 'negative',
|
||||||
|
});
|
||||||
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
};
|
};
|
||||||
|
|
||||||
axios.interceptors.request.use(onRequest, onRequestError);
|
axios.interceptors.request.use(onRequest, onRequestError);
|
||||||
axios.interceptors.response.use(onResponse, onResponseError);
|
axios.interceptors.response.use(onResponse, onResponseError);
|
||||||
axiosNoError.interceptors.request.use(onRequest);
|
|
||||||
axiosNoError.interceptors.response.use(onResponse);
|
|
||||||
|
|
||||||
export { onRequest, onResponseError, axiosNoError };
|
export { onRequest, onResponseError };
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
import { QInput } from 'quasar';
|
|
||||||
import setDefault from './setDefault';
|
|
||||||
|
|
||||||
setDefault(QInput, 'dense', true);
|
|
|
@ -1,4 +0,0 @@
|
||||||
import { QSelect } from 'quasar';
|
|
||||||
import setDefault from './setDefault';
|
|
||||||
|
|
||||||
setDefault(QSelect, 'dense', true);
|
|
|
@ -1,5 +0,0 @@
|
||||||
import { QTable } from 'quasar';
|
|
||||||
import setDefault from './setDefault';
|
|
||||||
|
|
||||||
setDefault(QTable, 'pagination', { rowsPerPage: 0 });
|
|
||||||
setDefault(QTable, 'hidePagination', true);
|
|
|
@ -1,18 +0,0 @@
|
||||||
export default function (component, key, value) {
|
|
||||||
const prop = component.props[key];
|
|
||||||
switch (typeof prop) {
|
|
||||||
case 'object':
|
|
||||||
prop.default = value;
|
|
||||||
break;
|
|
||||||
case 'function':
|
|
||||||
component.props[key] = {
|
|
||||||
type: prop,
|
|
||||||
default: value,
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
case 'undefined':
|
|
||||||
throw new Error('unknown prop: ' + key);
|
|
||||||
default:
|
|
||||||
throw new Error('unhandled type: ' + typeof prop);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +1,9 @@
|
||||||
import { boot } from 'quasar/wrappers';
|
import { boot } from 'quasar/wrappers';
|
||||||
import { createI18n } from 'vue-i18n';
|
import { createI18n } from 'vue-i18n';
|
||||||
import messages from 'src/i18n';
|
import messages from 'src/i18n';
|
||||||
import { useState } from 'src/composables/useState';
|
|
||||||
const user = useState().getUser();
|
|
||||||
|
|
||||||
const i18n = createI18n({
|
const i18n = createI18n({
|
||||||
locale: user.value.lang || navigator.language || navigator.userLanguage,
|
locale: navigator.language || navigator.userLanguage,
|
||||||
fallbackLocale: 'en',
|
fallbackLocale: 'en',
|
||||||
globalInjection: true,
|
globalInjection: true,
|
||||||
messages,
|
messages,
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
export default {
|
|
||||||
mounted: function (el, binding) {
|
|
||||||
const shortcut = binding.value ?? '+';
|
|
||||||
|
|
||||||
const { key, ctrl, alt, callback } =
|
|
||||||
typeof shortcut === 'string'
|
|
||||||
? {
|
|
||||||
key: shortcut,
|
|
||||||
ctrl: true,
|
|
||||||
alt: true,
|
|
||||||
callback: () =>
|
|
||||||
document
|
|
||||||
.querySelector(`button[shortcut="${shortcut}"]`)
|
|
||||||
?.click(),
|
|
||||||
}
|
|
||||||
: binding.value;
|
|
||||||
|
|
||||||
const handleKeydown = (event) => {
|
|
||||||
if (event.key === key && (!ctrl || event.ctrlKey) && (!alt || event.altKey)) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Attach the event listener to the window
|
|
||||||
window.addEventListener('keydown', handleKeydown);
|
|
||||||
|
|
||||||
el._handleKeydown = handleKeydown;
|
|
||||||
},
|
|
||||||
unmounted: function (el) {
|
|
||||||
if (el._handleKeydown) {
|
|
||||||
window.removeEventListener('keydown', el._handleKeydown);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,36 +0,0 @@
|
||||||
import routes from 'src/router/modules';
|
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
|
|
||||||
let isNotified = false;
|
|
||||||
|
|
||||||
export default {
|
|
||||||
created: function () {
|
|
||||||
const router = useRouter();
|
|
||||||
const keyBindingMap = routes
|
|
||||||
.filter((route) => route.meta.keyBinding)
|
|
||||||
.reduce((map, route) => {
|
|
||||||
map['Key' + route.meta.keyBinding.toUpperCase()] = route.path;
|
|
||||||
return map;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
const handleKeyDown = (event) => {
|
|
||||||
const { ctrlKey, altKey, code } = event;
|
|
||||||
|
|
||||||
if (ctrlKey && altKey && keyBindingMap[code] && !isNotified) {
|
|
||||||
event.preventDefault();
|
|
||||||
router.push(keyBindingMap[code]);
|
|
||||||
isNotified = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleKeyUp = (event) => {
|
|
||||||
const { ctrlKey, altKey } = event;
|
|
||||||
if (!ctrlKey || !altKey) {
|
|
||||||
isNotified = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
window.addEventListener('keydown', handleKeyDown);
|
|
||||||
window.addEventListener('keyup', handleKeyUp);
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,51 +0,0 @@
|
||||||
function focusFirstInput(input) {
|
|
||||||
input.focus();
|
|
||||||
}
|
|
||||||
export default {
|
|
||||||
mounted: function () {
|
|
||||||
const that = this;
|
|
||||||
|
|
||||||
const form = document.querySelector('.q-form#formModel');
|
|
||||||
if (!form) return;
|
|
||||||
try {
|
|
||||||
const inputsFormCard = form.querySelectorAll(
|
|
||||||
`input:not([disabled]):not([type="checkbox"])`
|
|
||||||
);
|
|
||||||
if (inputsFormCard.length) {
|
|
||||||
focusFirstInput(inputsFormCard[0]);
|
|
||||||
}
|
|
||||||
const textareas = document.querySelectorAll(
|
|
||||||
'textarea:not([disabled]), [contenteditable]:not([disabled])'
|
|
||||||
);
|
|
||||||
if (textareas.length) {
|
|
||||||
focusFirstInput(textareas[textareas.length - 1]);
|
|
||||||
}
|
|
||||||
const inputs = document.querySelectorAll(
|
|
||||||
'form#formModel input:not([disabled]):not([type="checkbox"])'
|
|
||||||
);
|
|
||||||
const input = inputs[0];
|
|
||||||
if (!input) return;
|
|
||||||
|
|
||||||
focusFirstInput(input);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
form.addEventListener('keyup', function (evt) {
|
|
||||||
if (evt.key === 'Enter' && !that.$attrs['prevent-submit']) {
|
|
||||||
const input = evt.target;
|
|
||||||
if (input.type == 'textarea' && evt.shiftKey) {
|
|
||||||
evt.preventDefault();
|
|
||||||
let { selectionStart, selectionEnd } = input;
|
|
||||||
input.value =
|
|
||||||
input.value.substring(0, selectionStart) +
|
|
||||||
'\n' +
|
|
||||||
input.value.substring(selectionEnd);
|
|
||||||
selectionStart = selectionEnd = selectionStart + 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
evt.preventDefault();
|
|
||||||
that.onSubmit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,3 +0,0 @@
|
||||||
export * from './defaults/qTable';
|
|
||||||
export * from './defaults/qInput';
|
|
||||||
export * from './defaults/qSelect';
|
|
|
@ -1,54 +0,0 @@
|
||||||
import axios from 'axios';
|
|
||||||
import { boot } from 'quasar/wrappers';
|
|
||||||
import qFormMixin from './qformMixin';
|
|
||||||
import keyShortcut from './keyShortcut';
|
|
||||||
import { QForm } from 'quasar';
|
|
||||||
import { QLayout } from 'quasar';
|
|
||||||
import mainShortcutMixin from './mainShortcutMixin';
|
|
||||||
import { useCau } from 'src/composables/useCau';
|
|
||||||
|
|
||||||
export default boot(({ app }) => {
|
|
||||||
QForm.mixins = [qFormMixin];
|
|
||||||
QLayout.mixins = [mainShortcutMixin];
|
|
||||||
|
|
||||||
app.directive('shortcut', keyShortcut);
|
|
||||||
app.config.errorHandler = async (error) => {
|
|
||||||
let message;
|
|
||||||
const response = error.response;
|
|
||||||
const responseData = response?.data;
|
|
||||||
const responseError = responseData && response.data.error;
|
|
||||||
if (responseError) {
|
|
||||||
message = responseError.message;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (response?.status) {
|
|
||||||
case 422:
|
|
||||||
if (error.name == 'ValidationError')
|
|
||||||
message +=
|
|
||||||
' "' +
|
|
||||||
responseError.details.context +
|
|
||||||
'.' +
|
|
||||||
Object.keys(responseError.details.codes).join(',') +
|
|
||||||
'"';
|
|
||||||
break;
|
|
||||||
case 500:
|
|
||||||
message = 'errors.statusInternalServerError';
|
|
||||||
break;
|
|
||||||
case 502:
|
|
||||||
message = 'errors.statusBadGateway';
|
|
||||||
break;
|
|
||||||
case 504:
|
|
||||||
message = 'errors.statusGatewayTimeout';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.error(error);
|
|
||||||
if (error instanceof axios.CanceledError) {
|
|
||||||
const env = process.env.NODE_ENV;
|
|
||||||
if (env && env !== 'development') return;
|
|
||||||
message = 'Duplicate request';
|
|
||||||
}
|
|
||||||
|
|
||||||
await useCau(response, message);
|
|
||||||
};
|
|
||||||
});
|
|
|
@ -1,6 +0,0 @@
|
||||||
import { boot } from 'quasar/wrappers';
|
|
||||||
import { useValidationsStore } from 'src/stores/useValidationsStore';
|
|
||||||
|
|
||||||
export default boot(async ({ store }) => {
|
|
||||||
await useValidationsStore(store).fetchModels();
|
|
||||||
});
|
|
|
@ -15,14 +15,4 @@ export default boot(() => {
|
||||||
Date.vnNow = () => {
|
Date.vnNow = () => {
|
||||||
return new Date(Date.vnUTC()).getTime();
|
return new Date(Date.vnUTC()).getTime();
|
||||||
};
|
};
|
||||||
|
|
||||||
Date.vnFirstDayOfMonth = () => {
|
|
||||||
const date = new Date(Date.vnUTC());
|
|
||||||
return new Date(date.getFullYear(), date.getMonth(), 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
Date.vnLastDayOfMonth = () => {
|
|
||||||
const date = new Date(Date.vnUTC());
|
|
||||||
return new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,119 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { reactive, ref, onMounted, nextTick, computed } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
|
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import FormModelPopup from './FormModelPopup.vue';
|
|
||||||
import { useState } from 'src/composables/useState';
|
|
||||||
|
|
||||||
const emit = defineEmits(['onDataSaved']);
|
|
||||||
const { t } = useI18n();
|
|
||||||
const bicInputRef = ref(null);
|
|
||||||
const state = useState();
|
|
||||||
|
|
||||||
const customer = computed(() => state.get('customer'));
|
|
||||||
|
|
||||||
const countriesFilter = {
|
|
||||||
fields: ['id', 'name', 'code'],
|
|
||||||
};
|
|
||||||
|
|
||||||
const bankEntityFormData = reactive({
|
|
||||||
name: null,
|
|
||||||
bic: null,
|
|
||||||
countryFk: customer.value?.countryFk,
|
|
||||||
});
|
|
||||||
|
|
||||||
const countriesOptions = ref([]);
|
|
||||||
|
|
||||||
const onDataSaved = (...args) => {
|
|
||||||
emit('onDataSaved', ...args);
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
await nextTick();
|
|
||||||
bicInputRef.value.focus();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<FetchData
|
|
||||||
url="Countries"
|
|
||||||
auto-load
|
|
||||||
@on-fetch="(data) => (countriesOptions = data)"
|
|
||||||
/>
|
|
||||||
<FormModelPopup
|
|
||||||
url-create="bankEntities"
|
|
||||||
model="bankEntity"
|
|
||||||
:title="t('title')"
|
|
||||||
:subtitle="t('subtitle')"
|
|
||||||
:form-initial-data="bankEntityFormData"
|
|
||||||
:filter="countriesFilter"
|
|
||||||
@on-data-saved="onDataSaved"
|
|
||||||
>
|
|
||||||
<template #form-inputs="{ data, validate }">
|
|
||||||
<VnRow>
|
|
||||||
<VnInput
|
|
||||||
:label="t('name')"
|
|
||||||
v-model="data.name"
|
|
||||||
:required="true"
|
|
||||||
:rules="validate('bankEntity.name')"
|
|
||||||
/>
|
|
||||||
<VnInput
|
|
||||||
ref="bicInputRef"
|
|
||||||
:label="t('swift')"
|
|
||||||
v-model="data.bic"
|
|
||||||
:required="true"
|
|
||||||
:rules="validate('bankEntity.bic')"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow>
|
|
||||||
<div class="col">
|
|
||||||
<VnSelect
|
|
||||||
:label="t('country')"
|
|
||||||
v-model="data.countryFk"
|
|
||||||
:options="countriesOptions"
|
|
||||||
option-value="id"
|
|
||||||
option-label="name"
|
|
||||||
hide-selected
|
|
||||||
:required="true"
|
|
||||||
:rules="validate('bankEntity.countryFk')"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-if="
|
|
||||||
countriesOptions.find((c) => c.id === data.countryFk)?.code ==
|
|
||||||
'ES'
|
|
||||||
"
|
|
||||||
class="col"
|
|
||||||
>
|
|
||||||
<VnInput
|
|
||||||
:label="t('id')"
|
|
||||||
v-model="data.id"
|
|
||||||
:required="true"
|
|
||||||
:rules="validate('city.name')"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</VnRow>
|
|
||||||
</template>
|
|
||||||
</FormModelPopup>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
en:
|
|
||||||
title: New bank entity
|
|
||||||
subtitle: Please, ensure you put the correct data!
|
|
||||||
name: Name
|
|
||||||
swift: Swift
|
|
||||||
country: Country
|
|
||||||
id: Entity code
|
|
||||||
es:
|
|
||||||
title: Nueva entidad bancaria
|
|
||||||
subtitle: ¡Por favor, asegúrate de poner los datos correctos!
|
|
||||||
name: Nombre
|
|
||||||
swift: Swift
|
|
||||||
country: País
|
|
||||||
id: Código de la entidad
|
|
||||||
</i18n>
|
|
|
@ -1,72 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { onMounted, ref } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import VnSelectProvince from 'components/VnSelectProvince.vue';
|
|
||||||
import VnInput from 'components/common/VnInput.vue';
|
|
||||||
import FormModelPopup from './FormModelPopup.vue';
|
|
||||||
|
|
||||||
const emit = defineEmits(['onDataSaved']);
|
|
||||||
const $props = defineProps({
|
|
||||||
countryFk: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
provinceSelected: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
const cityFormData = ref({
|
|
||||||
name: null,
|
|
||||||
provinceFk: null,
|
|
||||||
});
|
|
||||||
onMounted(() => {
|
|
||||||
cityFormData.value.provinceFk = $props.provinceSelected;
|
|
||||||
});
|
|
||||||
const onDataSaved = (...args) => {
|
|
||||||
emit('onDataSaved', ...args);
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<FormModelPopup
|
|
||||||
:title="t('New city')"
|
|
||||||
:subtitle="t('Please, ensure you put the correct data!')"
|
|
||||||
:form-initial-data="cityFormData"
|
|
||||||
url-create="towns"
|
|
||||||
model="city"
|
|
||||||
@on-data-saved="onDataSaved"
|
|
||||||
data-cy="newCityForm"
|
|
||||||
>
|
|
||||||
<template #form-inputs="{ data, validate }">
|
|
||||||
<VnRow>
|
|
||||||
<VnInput
|
|
||||||
:label="t('Name')"
|
|
||||||
v-model="data.name"
|
|
||||||
:rules="validate('city.name')"
|
|
||||||
required
|
|
||||||
data-cy="cityName"
|
|
||||||
/>
|
|
||||||
<VnSelectProvince
|
|
||||||
:province-selected="$props.provinceSelected"
|
|
||||||
:country-fk="$props.countryFk"
|
|
||||||
v-model="data.provinceFk"
|
|
||||||
required
|
|
||||||
data-cy="provinceCity"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
</template>
|
|
||||||
</FormModelPopup>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
New city: Nueva ciudad
|
|
||||||
Please, ensure you put the correct data!: ¡Por favor, asegúrese de poner los datos correctos!
|
|
||||||
Name: Nombre
|
|
||||||
Province: Provincia
|
|
||||||
</i18n>
|
|
|
@ -1,50 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
import FormModelPopup from './FormModelPopup.vue';
|
|
||||||
|
|
||||||
const emit = defineEmits(['onDataSaved']);
|
|
||||||
const { t } = useI18n();
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<FormModelPopup
|
|
||||||
url-create="Expenses"
|
|
||||||
model="Expense"
|
|
||||||
:title="t('New expense')"
|
|
||||||
:form-initial-data="{ id: null, isWithheld: false, name: null }"
|
|
||||||
@on-data-saved="emit('onDataSaved', $event)"
|
|
||||||
>
|
|
||||||
<template #form-inputs="{ data, validate }">
|
|
||||||
<VnRow>
|
|
||||||
<VnInput
|
|
||||||
:label="`${t('globals.code')}`"
|
|
||||||
v-model="data.id"
|
|
||||||
:required="true"
|
|
||||||
:rules="validate('expense.code')"
|
|
||||||
/>
|
|
||||||
<QCheckbox
|
|
||||||
dense
|
|
||||||
size="sm"
|
|
||||||
:label="`${t('It\'s a withholding')}`"
|
|
||||||
v-model="data.isWithheld"
|
|
||||||
:rules="validate('expense.isWithheld')"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow>
|
|
||||||
<VnInput
|
|
||||||
:label="`${t('globals.description')}`"
|
|
||||||
v-model="data.name"
|
|
||||||
:required="true"
|
|
||||||
:rules="validate('expense.description')"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
</template>
|
|
||||||
</FormModelPopup>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
New expense: Nuevo gasto
|
|
||||||
It's a withholding: Es una retención
|
|
||||||
</i18n>
|
|
|
@ -1,229 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { reactive, ref } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
|
||||||
import VnSelectProvince from 'src/components/VnSelectProvince.vue';
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
import CreateNewCityForm from './CreateNewCityForm.vue';
|
|
||||||
import VnSelectDialog from 'components/common/VnSelectDialog.vue';
|
|
||||||
import FormModelPopup from './FormModelPopup.vue';
|
|
||||||
|
|
||||||
const emit = defineEmits(['onDataSaved']);
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
const postcodeFormData = reactive({
|
|
||||||
code: null,
|
|
||||||
countryFk: null,
|
|
||||||
provinceFk: null,
|
|
||||||
townFk: null,
|
|
||||||
});
|
|
||||||
const townsFetchDataRef = ref(false);
|
|
||||||
const townFilter = ref({});
|
|
||||||
|
|
||||||
const countriesRef = ref(false);
|
|
||||||
const provincesOptions = ref([]);
|
|
||||||
const townsOptions = ref([]);
|
|
||||||
const town = ref({});
|
|
||||||
const countryFilter = ref({});
|
|
||||||
|
|
||||||
function onDataSaved(formData) {
|
|
||||||
const newPostcode = {
|
|
||||||
...formData,
|
|
||||||
};
|
|
||||||
newPostcode.town = town.value.name;
|
|
||||||
newPostcode.townFk = town.value.id;
|
|
||||||
const provinceObject = provincesOptions.value.find(
|
|
||||||
({ id }) => id === formData.provinceFk
|
|
||||||
);
|
|
||||||
newPostcode.province = provinceObject?.name;
|
|
||||||
const countryObject = countriesRef.value.opts.find(
|
|
||||||
({ id }) => id === formData.countryFk
|
|
||||||
);
|
|
||||||
newPostcode.country = countryObject?.name;
|
|
||||||
emit('onDataSaved', newPostcode);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function setCountry(countryFk, data) {
|
|
||||||
data.townFk = null;
|
|
||||||
data.provinceFk = null;
|
|
||||||
data.countryFk = countryFk;
|
|
||||||
await fetchTowns();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Province
|
|
||||||
async function setProvince(id, data) {
|
|
||||||
if (data.provinceFk === id) return;
|
|
||||||
const newProvince = provincesOptions.value.find((province) => province.id == id);
|
|
||||||
if (newProvince) data.countryFk = newProvince.countryFk;
|
|
||||||
postcodeFormData.provinceFk = id;
|
|
||||||
await fetchTowns();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onProvinceCreated(data) {
|
|
||||||
postcodeFormData.provinceFk = data.id;
|
|
||||||
}
|
|
||||||
function provinceByCountry(countryFk = postcodeFormData.countryFk) {
|
|
||||||
return provincesOptions.value
|
|
||||||
.filter((province) => province.countryFk === countryFk)
|
|
||||||
.map(({ id }) => id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Town
|
|
||||||
async function handleTowns(data) {
|
|
||||||
townsOptions.value = data;
|
|
||||||
}
|
|
||||||
function setTown(newTown, data) {
|
|
||||||
town.value = newTown;
|
|
||||||
data.provinceFk = newTown?.provinceFk ?? newTown;
|
|
||||||
data.countryFk = newTown?.province?.countryFk ?? newTown;
|
|
||||||
}
|
|
||||||
async function onCityCreated(newTown, formData) {
|
|
||||||
newTown.province = provincesOptions.value.find(
|
|
||||||
(province) => province.id === newTown.provinceFk
|
|
||||||
);
|
|
||||||
formData.townFk = newTown;
|
|
||||||
setTown(newTown, formData);
|
|
||||||
}
|
|
||||||
async function fetchTowns(countryFk = postcodeFormData.countryFk) {
|
|
||||||
if (!countryFk) return;
|
|
||||||
const provinces = postcodeFormData.provinceFk
|
|
||||||
? [postcodeFormData.provinceFk]
|
|
||||||
: provinceByCountry();
|
|
||||||
townFilter.value.where = {
|
|
||||||
provinceFk: {
|
|
||||||
inq: provinces,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
await townsFetchDataRef.value?.fetch();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function filterTowns(name) {
|
|
||||||
if (name !== '') {
|
|
||||||
townFilter.value.where = {
|
|
||||||
name: {
|
|
||||||
like: `%${name}%`,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
await townsFetchDataRef.value?.fetch();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<FetchData
|
|
||||||
ref="townsFetchDataRef"
|
|
||||||
:sort-by="['name ASC']"
|
|
||||||
:limit="30"
|
|
||||||
:filter="townFilter"
|
|
||||||
@on-fetch="handleTowns"
|
|
||||||
auto-load
|
|
||||||
url="Towns/location"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormModelPopup
|
|
||||||
url-create="postcodes"
|
|
||||||
model="postcode"
|
|
||||||
:title="t('New postcode')"
|
|
||||||
:subtitle="t('Please, ensure you put the correct data!')"
|
|
||||||
:form-initial-data="postcodeFormData"
|
|
||||||
:mapper="(data) => (data.townFk = data.townFk.id) && data"
|
|
||||||
@on-data-saved="onDataSaved"
|
|
||||||
>
|
|
||||||
<template #form-inputs="{ data, validate }">
|
|
||||||
<VnRow>
|
|
||||||
<VnInput
|
|
||||||
:label="t('Postcode')"
|
|
||||||
v-model="data.code"
|
|
||||||
:rules="validate('postcode.code')"
|
|
||||||
clearable
|
|
||||||
required
|
|
||||||
data-cy="locationPostcode"
|
|
||||||
/>
|
|
||||||
<VnSelectDialog
|
|
||||||
:label="t('City')"
|
|
||||||
@update:model-value="(value) => setTown(value, data)"
|
|
||||||
@filter="filterTowns"
|
|
||||||
:tooltip="t('Create city')"
|
|
||||||
v-model="data.townFk"
|
|
||||||
:options="townsOptions"
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
:rules="validate('postcode.city')"
|
|
||||||
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
|
|
||||||
:emit-value="false"
|
|
||||||
required
|
|
||||||
data-cy="locationTown"
|
|
||||||
>
|
|
||||||
<template #option="{ itemProps, opt }">
|
|
||||||
<QItem v-bind="itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>{{ opt.name }}</QItemLabel>
|
|
||||||
<QItemLabel caption>
|
|
||||||
{{ opt.province.name }},
|
|
||||||
{{ opt.province.country.name }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
<template #form>
|
|
||||||
<CreateNewCityForm
|
|
||||||
:country-fk="data.countryFk"
|
|
||||||
:province-selected="data.provinceFk"
|
|
||||||
@on-data-saved="
|
|
||||||
(_, requestResponse) =>
|
|
||||||
onCityCreated(requestResponse, data)
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</VnSelectDialog>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow>
|
|
||||||
<VnSelectProvince
|
|
||||||
:country-fk="data.countryFk"
|
|
||||||
:province-selected="data.provinceFk"
|
|
||||||
@update:model-value="(value) => setProvince(value, data)"
|
|
||||||
@update:options="
|
|
||||||
(data) => {
|
|
||||||
provincesOptions = data;
|
|
||||||
}
|
|
||||||
"
|
|
||||||
v-model="data.provinceFk"
|
|
||||||
@on-province-created="onProvinceCreated"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
<VnSelect
|
|
||||||
ref="countriesRef"
|
|
||||||
:limit="30"
|
|
||||||
:filter="countryFilter"
|
|
||||||
:sort-by="['name ASC']"
|
|
||||||
auto-load
|
|
||||||
url="Countries"
|
|
||||||
required
|
|
||||||
:label="t('Country')"
|
|
||||||
hide-selected
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
v-model="data.countryFk"
|
|
||||||
:rules="validate('postcode.countryFk')"
|
|
||||||
@update:model-value="(value) => setCountry(value, data)"
|
|
||||||
data-cy="locationCountry"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
</template>
|
|
||||||
</FormModelPopup>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
New postcode: Nuevo código postal
|
|
||||||
Create city: Crear población
|
|
||||||
Please, ensure you put the correct data!: ¡Por favor, asegúrese de poner los datos correctos!
|
|
||||||
City: Población
|
|
||||||
Province: Provincia
|
|
||||||
Country: País
|
|
||||||
Postcode: Código postal
|
|
||||||
</i18n>
|
|
|
@ -1,94 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { computed, reactive, ref } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
import FormModelPopup from './FormModelPopup.vue';
|
|
||||||
|
|
||||||
const emit = defineEmits(['onDataSaved']);
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
const provinceFormData = reactive({
|
|
||||||
name: null,
|
|
||||||
autonomyFk: null,
|
|
||||||
});
|
|
||||||
const $props = defineProps({
|
|
||||||
countryFk: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const autonomiesRef = ref([]);
|
|
||||||
|
|
||||||
const onDataSaved = (dataSaved, requestResponse) => {
|
|
||||||
requestResponse.autonomy = autonomiesRef.value.opts.find(
|
|
||||||
(autonomy) => autonomy.id == requestResponse.autonomyFk
|
|
||||||
);
|
|
||||||
emit('onDataSaved', dataSaved, requestResponse);
|
|
||||||
};
|
|
||||||
const where = computed(() => {
|
|
||||||
if (!$props.countryFk) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
return { countryFk: $props.countryFk };
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<FormModelPopup
|
|
||||||
:title="t('New province')"
|
|
||||||
:subtitle="t('Please, ensure you put the correct data!')"
|
|
||||||
url-create="provinces"
|
|
||||||
model="province"
|
|
||||||
:form-initial-data="provinceFormData"
|
|
||||||
@on-data-saved="onDataSaved"
|
|
||||||
>
|
|
||||||
<template #form-inputs="{ data, validate }">
|
|
||||||
<VnRow>
|
|
||||||
<VnInput
|
|
||||||
:label="t('Name')"
|
|
||||||
v-model="data.name"
|
|
||||||
:rules="validate('province.name')"
|
|
||||||
required
|
|
||||||
data-cy="provinceName"
|
|
||||||
/>
|
|
||||||
<VnSelect
|
|
||||||
data-cy="autonomyProvince"
|
|
||||||
required
|
|
||||||
ref="autonomiesRef"
|
|
||||||
auto-load
|
|
||||||
:where="where"
|
|
||||||
url="Autonomies/location"
|
|
||||||
:sort-by="['name ASC']"
|
|
||||||
:limit="30"
|
|
||||||
:label="t('Autonomy')"
|
|
||||||
hide-selected
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
v-model="data.autonomyFk"
|
|
||||||
:rules="validate('province.autonomyFk')"
|
|
||||||
>
|
|
||||||
<template #option="{ itemProps, opt }">
|
|
||||||
<QItem v-bind="itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>{{ opt.name }}</QItemLabel>
|
|
||||||
<QItemLabel caption> {{ opt.country.name }} </QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
</VnRow>
|
|
||||||
</template>
|
|
||||||
</FormModelPopup>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
New province: Nueva provincia
|
|
||||||
Please, ensure you put the correct data!: ¡Por favor, asegúrese de poner los datos correctos!
|
|
||||||
Name: Nombre
|
|
||||||
Autonomy: Autonomía
|
|
||||||
</i18n>
|
|
|
@ -1,105 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { reactive, ref } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
import FormModelPopup from './FormModelPopup.vue';
|
|
||||||
|
|
||||||
const emit = defineEmits(['onDataSaved']);
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
const thermographFormData = reactive({
|
|
||||||
thermographId: null,
|
|
||||||
model: 'DISPOSABLE',
|
|
||||||
warehouseId: null,
|
|
||||||
temperatureFk: 'cool',
|
|
||||||
});
|
|
||||||
|
|
||||||
const thermographsModels = ref(null);
|
|
||||||
const warehousesOptions = ref([]);
|
|
||||||
const temperaturesOptions = ref([]);
|
|
||||||
|
|
||||||
const onDataSaved = (dataSaved) => {
|
|
||||||
emit('onDataSaved', dataSaved);
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<FetchData
|
|
||||||
@on-fetch="(data) => (thermographsModels = data)"
|
|
||||||
auto-load
|
|
||||||
url="Thermographs/getThermographModels"
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
@on-fetch="(data) => (warehousesOptions = data)"
|
|
||||||
auto-load
|
|
||||||
url="Warehouses"
|
|
||||||
:filter="{ fields: ['id', 'name'], order: 'name ASC' }"
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
@on-fetch="(data) => (temperaturesOptions = data)"
|
|
||||||
auto-load
|
|
||||||
url="Temperatures"
|
|
||||||
/>
|
|
||||||
<FormModelPopup
|
|
||||||
url-create="Thermographs/createThermograph"
|
|
||||||
model="thermograph"
|
|
||||||
:title="t('New thermograph')"
|
|
||||||
:form-initial-data="thermographFormData"
|
|
||||||
@on-data-saved="(_, response) => onDataSaved(response)"
|
|
||||||
>
|
|
||||||
<template #form-inputs="{ data, validate }">
|
|
||||||
<VnRow>
|
|
||||||
<VnInput
|
|
||||||
:label="t('Identifier')"
|
|
||||||
v-model="data.thermographId"
|
|
||||||
:required="true"
|
|
||||||
:rules="validate('thermograph.id')"
|
|
||||||
/>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Model')"
|
|
||||||
:options="thermographsModels"
|
|
||||||
hide-selected
|
|
||||||
option-label="value"
|
|
||||||
option-value="value"
|
|
||||||
v-model="data.model"
|
|
||||||
:required="true"
|
|
||||||
:rules="validate('thermograph.model')"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow class="row q-gutter-md q-mb-xl">
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Warehouse')"
|
|
||||||
:options="warehousesOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
v-model="data.warehouseId"
|
|
||||||
:required="true"
|
|
||||||
/>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Temperature')"
|
|
||||||
:options="temperaturesOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="name"
|
|
||||||
option-value="code"
|
|
||||||
v-model="data.temperatureFk"
|
|
||||||
:required="true"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
</template>
|
|
||||||
</FormModelPopup>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
Identifier: Identificador
|
|
||||||
Model: Modelo
|
|
||||||
Warehouse: Almacén
|
|
||||||
Temperature: Temperatura
|
|
||||||
New thermograph: Nuevo termógrafo
|
|
||||||
</i18n>
|
|
|
@ -1,7 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { computed, ref, useAttrs, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
import { useRouter, onBeforeRouteLeave } from 'vue-router';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import { useValidator } from 'src/composables/useValidator';
|
import { useValidator } from 'src/composables/useValidator';
|
||||||
|
@ -10,17 +9,15 @@ import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||||
import SkeletonTable from 'components/ui/SkeletonTable.vue';
|
import SkeletonTable from 'components/ui/SkeletonTable.vue';
|
||||||
import { tMobile } from 'src/composables/tMobile';
|
import { tMobile } from 'src/composables/tMobile';
|
||||||
import getDifferences from 'src/filters/getDifferences';
|
|
||||||
|
|
||||||
const { push } = useRouter();
|
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { validate } = useValidator();
|
const { validate } = useValidator();
|
||||||
const $attrs = useAttrs();
|
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
model: {
|
model: {
|
||||||
|
/** @type import('vue').PropType<Model> */
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
|
@ -28,10 +25,6 @@ const $props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
limit: {
|
|
||||||
type: Number,
|
|
||||||
default: 20,
|
|
||||||
},
|
|
||||||
saveUrl: {
|
saveUrl: {
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
|
@ -64,24 +57,14 @@ const $props = defineProps({
|
||||||
type: Function,
|
type: Function,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
goTo: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
description: 'It is used for redirect on click "save and continue"',
|
|
||||||
},
|
|
||||||
hasSubToolbar: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
const hasChanges = ref(false);
|
const hasChanges = ref(false);
|
||||||
const originalData = ref();
|
const originalData = ref();
|
||||||
const vnPaginateRef = ref();
|
const vnPaginateRef = ref();
|
||||||
const formData = ref([]);
|
const formData = ref();
|
||||||
const saveButtonRef = ref(null);
|
const saveButtonRef = ref(null);
|
||||||
const watchChanges = ref();
|
|
||||||
const formUrl = computed(() => $props.url);
|
const formUrl = computed(() => $props.url);
|
||||||
|
|
||||||
const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']);
|
const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']);
|
||||||
|
@ -94,51 +77,27 @@ defineExpose({
|
||||||
reset,
|
reset,
|
||||||
hasChanges,
|
hasChanges,
|
||||||
saveChanges,
|
saveChanges,
|
||||||
getChanges,
|
|
||||||
formData,
|
|
||||||
originalData,
|
|
||||||
vnPaginateRef,
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeRouteLeave((to, from, next) => {
|
|
||||||
if (hasChanges.value)
|
|
||||||
quasar.dialog({
|
|
||||||
component: VnConfirm,
|
|
||||||
componentProps: {
|
|
||||||
title: t('globals.unsavedPopup.title'),
|
|
||||||
message: t('globals.unsavedPopup.subtitle'),
|
|
||||||
promise: () => next(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
else next();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
async function fetch(data) {
|
async function fetch(data) {
|
||||||
const keyData = $attrs['key-data'];
|
|
||||||
const rows = keyData ? data[keyData] : data;
|
|
||||||
resetData(rows);
|
|
||||||
emit('onFetch', rows);
|
|
||||||
return rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetData(data) {
|
|
||||||
if (!data) return;
|
|
||||||
if (data && Array.isArray(data)) {
|
if (data && Array.isArray(data)) {
|
||||||
let $index = 0;
|
let $index = 0;
|
||||||
data.map((d) => (d.$index = $index++));
|
data.map((d) => (d.$index = $index++));
|
||||||
}
|
}
|
||||||
originalData.value = JSON.parse(JSON.stringify(data));
|
|
||||||
formData.value = JSON.parse(JSON.stringify(data));
|
|
||||||
|
|
||||||
if (watchChanges.value) watchChanges.value(); //destroy watcher
|
originalData.value = data && JSON.parse(JSON.stringify(data));
|
||||||
watchChanges.value = watch(formData, () => (hasChanges.value = true), { deep: true });
|
formData.value = data && JSON.parse(JSON.stringify(data));
|
||||||
|
watch(formData, () => (hasChanges.value = true), { deep: true });
|
||||||
|
|
||||||
|
emit('onFetch', data);
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reset() {
|
async function reset() {
|
||||||
await fetch(originalData.value);
|
await fetch(originalData.value);
|
||||||
hasChanges.value = false;
|
hasChanges.value = false;
|
||||||
}
|
}
|
||||||
|
// eslint-disable-next-line vue/no-dupe-keys
|
||||||
function filter(value, update, filterOptions) {
|
function filter(value, update, filterOptions) {
|
||||||
update(
|
update(
|
||||||
() => {
|
() => {
|
||||||
|
@ -149,7 +108,7 @@ function filter(value, update, filterOptions) {
|
||||||
(ref) => {
|
(ref) => {
|
||||||
ref.setOptionIndex(-1);
|
ref.setOptionIndex(-1);
|
||||||
ref.moveOptionSelection(1, true);
|
ref.moveOptionSelection(1, true);
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,43 +120,30 @@ async function onSubmit() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
await saveChanges($props.saveFn ? formData.value : null);
|
await saveChanges();
|
||||||
}
|
|
||||||
|
|
||||||
async function onSubmitAndGo() {
|
|
||||||
await onSubmit();
|
|
||||||
push({ path: $props.goTo });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveChanges(data) {
|
async function saveChanges(data) {
|
||||||
if ($props.saveFn) {
|
if ($props.saveFn) return $props.saveFn(data, getChanges);
|
||||||
$props.saveFn(data, getChanges);
|
|
||||||
isLoading.value = false;
|
|
||||||
hasChanges.value = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const changes = data || getChanges();
|
const changes = data || getChanges();
|
||||||
try {
|
try {
|
||||||
await axios.post($props.saveUrl || $props.url + '/crud', changes);
|
await axios.post($props.saveUrl || $props.url + '/crud', changes);
|
||||||
} finally {
|
} catch (e) {
|
||||||
isLoading.value = false;
|
return (isLoading.value = false);
|
||||||
}
|
}
|
||||||
originalData.value = JSON.parse(JSON.stringify(formData.value));
|
originalData.value = JSON.parse(JSON.stringify(formData.value));
|
||||||
if (changes.creates?.length) await vnPaginateRef.value.fetch();
|
if (changes.creates?.length) await vnPaginateRef.value.fetch();
|
||||||
|
|
||||||
hasChanges.value = false;
|
hasChanges.value = false;
|
||||||
|
isLoading.value = false;
|
||||||
emit('saveChanges', data);
|
emit('saveChanges', data);
|
||||||
quasar.notify({
|
|
||||||
type: 'positive',
|
|
||||||
message: t('globals.dataSaved'),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function insert(pushData = $props.dataRequired) {
|
async function insert() {
|
||||||
const $index = formData.value.length
|
const $index = formData.value.length
|
||||||
? formData.value[formData.value.length - 1].$index + 1
|
? formData.value[formData.value.length - 1].$index + 1
|
||||||
: 0;
|
: 0;
|
||||||
formData.value.push(Object.assign({ $index }, pushData));
|
formData.value.push(Object.assign({ $index }, $props.dataRequired));
|
||||||
hasChanges.value = true;
|
hasChanges.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +161,7 @@ async function remove(data) {
|
||||||
|
|
||||||
if (preRemove.length) {
|
if (preRemove.length) {
|
||||||
newData = newData.filter(
|
newData = newData.filter(
|
||||||
(form) => !preRemove.some((index) => index == form.$index),
|
(form) => !preRemove.some((index) => index == form.$index)
|
||||||
);
|
);
|
||||||
const changes = getChanges();
|
const changes = getChanges();
|
||||||
if (!changes.creates?.length && !changes.updates?.length)
|
if (!changes.creates?.length && !changes.updates?.length)
|
||||||
|
@ -227,8 +173,8 @@ async function remove(data) {
|
||||||
.dialog({
|
.dialog({
|
||||||
component: VnConfirm,
|
component: VnConfirm,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
title: t('globals.confirmDeletion'),
|
title: t('confirmDeletion'),
|
||||||
message: t('globals.confirmDeletionMessage'),
|
message: t('confirmDeletionMessage'),
|
||||||
newData,
|
newData,
|
||||||
ids,
|
ids,
|
||||||
},
|
},
|
||||||
|
@ -238,8 +184,6 @@ async function remove(data) {
|
||||||
newData = newData.filter((form) => !ids.some((id) => id == form[pk]));
|
newData = newData.filter((form) => !ids.some((id) => id == form[pk]));
|
||||||
fetch(newData);
|
fetch(newData);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
reset();
|
|
||||||
}
|
}
|
||||||
emit('update:selected', []);
|
emit('update:selected', []);
|
||||||
}
|
}
|
||||||
|
@ -249,10 +193,11 @@ function getChanges() {
|
||||||
const creates = [];
|
const creates = [];
|
||||||
|
|
||||||
const pk = $props.primaryKey;
|
const pk = $props.primaryKey;
|
||||||
|
|
||||||
for (const [i, row] of formData.value.entries()) {
|
for (const [i, row] of formData.value.entries()) {
|
||||||
if (!row[pk]) {
|
if (!row[pk]) {
|
||||||
creates.push(row);
|
creates.push(row);
|
||||||
} else if (originalData.value[i]) {
|
} else if (originalData.value) {
|
||||||
const data = getDifferences(originalData.value[i], row);
|
const data = getDifferences(originalData.value[i], row);
|
||||||
if (!isEmpty(data)) {
|
if (!isEmpty(data)) {
|
||||||
updates.push({
|
updates.push({
|
||||||
|
@ -271,15 +216,34 @@ function getChanges() {
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isEmpty(obj) {
|
function getDifferences(obj1, obj2) {
|
||||||
if (obj == null) return true;
|
let diff = {};
|
||||||
if (Array.isArray(obj)) return !obj.length;
|
delete obj1.$index;
|
||||||
return !Object.keys(obj).length;
|
delete obj2.$index;
|
||||||
|
|
||||||
|
for (let key in obj1) {
|
||||||
|
if (obj2[key] && obj1[key] !== obj2[key]) {
|
||||||
|
diff[key] = obj2[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let key in obj2) {
|
||||||
|
if (obj1[key] === undefined || obj1[key] !== obj2[key]) {
|
||||||
|
diff[key] = obj2[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reload(params) {
|
function isEmpty(obj) {
|
||||||
const data = await vnPaginateRef.value.fetch(params);
|
if (obj == null) return true;
|
||||||
fetch(data);
|
if (obj === undefined) return true;
|
||||||
|
if (Object.keys(obj).length === 0) return true;
|
||||||
|
|
||||||
|
if (obj.length > 0) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function reload() {
|
||||||
|
vnPaginateRef.value.fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(formUrl, async () => {
|
watch(formUrl, async () => {
|
||||||
|
@ -290,12 +254,10 @@ watch(formUrl, async () => {
|
||||||
<template>
|
<template>
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
:url="url"
|
:url="url"
|
||||||
:limit="limit"
|
v-bind="$attrs"
|
||||||
@on-fetch="fetch"
|
@on-fetch="fetch"
|
||||||
@on-change="fetch"
|
|
||||||
:skeleton="false"
|
:skeleton="false"
|
||||||
ref="vnPaginateRef"
|
ref="vnPaginateRef"
|
||||||
v-bind="$attrs"
|
|
||||||
>
|
>
|
||||||
<template #body v-if="formData">
|
<template #body v-if="formData">
|
||||||
<slot
|
<slot
|
||||||
|
@ -306,11 +268,8 @@ watch(formUrl, async () => {
|
||||||
></slot>
|
></slot>
|
||||||
</template>
|
</template>
|
||||||
</VnPaginate>
|
</VnPaginate>
|
||||||
<SkeletonTable
|
<SkeletonTable v-if="!formData" />
|
||||||
v-if="!formData && $attrs.autoLoad"
|
<Teleport to="#st-actions" v-if="stateStore?.isSubToolbarShown()">
|
||||||
:columns="$attrs.columns?.length"
|
|
||||||
/>
|
|
||||||
<Teleport to="#st-actions" v-if="stateStore?.isSubToolbarShown() && hasSubToolbar">
|
|
||||||
<QBtnGroup push style="column-gap: 10px">
|
<QBtnGroup push style="column-gap: 10px">
|
||||||
<slot name="moreBeforeActions" />
|
<slot name="moreBeforeActions" />
|
||||||
<QBtn
|
<QBtn
|
||||||
|
@ -333,40 +292,7 @@ watch(formUrl, async () => {
|
||||||
:title="t('globals.reset')"
|
:title="t('globals.reset')"
|
||||||
v-if="$props.defaultReset"
|
v-if="$props.defaultReset"
|
||||||
/>
|
/>
|
||||||
<QBtnDropdown
|
|
||||||
v-if="$props.goTo && $props.defaultSave"
|
|
||||||
@click="onSubmitAndGo"
|
|
||||||
:label="tMobile('globals.saveAndContinue')"
|
|
||||||
:title="t('globals.saveAndContinue')"
|
|
||||||
:disable="!hasChanges"
|
|
||||||
color="primary"
|
|
||||||
icon="save"
|
|
||||||
split
|
|
||||||
>
|
|
||||||
<QList>
|
|
||||||
<QItem
|
|
||||||
color="primary"
|
|
||||||
clickable
|
|
||||||
v-close-popup
|
|
||||||
@click="onSubmit"
|
|
||||||
:title="t('globals.save')"
|
|
||||||
>
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>
|
|
||||||
<QIcon
|
|
||||||
name="save"
|
|
||||||
color="white"
|
|
||||||
class="q-mr-sm"
|
|
||||||
size="sm"
|
|
||||||
/>
|
|
||||||
{{ t('globals.save').toUpperCase() }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</QList>
|
|
||||||
</QBtnDropdown>
|
|
||||||
<QBtn
|
<QBtn
|
||||||
v-else-if="!$props.goTo && $props.defaultSave"
|
|
||||||
:label="tMobile('globals.save')"
|
:label="tMobile('globals.save')"
|
||||||
ref="saveButtonRef"
|
ref="saveButtonRef"
|
||||||
color="primary"
|
color="primary"
|
||||||
|
@ -374,7 +300,7 @@ watch(formUrl, async () => {
|
||||||
@click="onSubmit"
|
@click="onSubmit"
|
||||||
:disable="!hasChanges"
|
:disable="!hasChanges"
|
||||||
:title="t('globals.save')"
|
:title="t('globals.save')"
|
||||||
data-cy="crudModelDefaultSaveBtn"
|
v-if="$props.defaultSave"
|
||||||
/>
|
/>
|
||||||
<slot name="moreAfterActions" />
|
<slot name="moreAfterActions" />
|
||||||
</QBtnGroup>
|
</QBtnGroup>
|
||||||
|
@ -385,3 +311,16 @@ watch(formUrl, async () => {
|
||||||
color="primary"
|
color="primary"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<i18n>
|
||||||
|
{
|
||||||
|
"en": {
|
||||||
|
"confirmDeletion": "Confirm deletion",
|
||||||
|
"confirmDeletionMessage": "Are you sure you want to delete this?"
|
||||||
|
},
|
||||||
|
"es": {
|
||||||
|
"confirmDeletion": "Confirmar eliminación",
|
||||||
|
"confirmDeletionMessage": "Seguro que quieres eliminar?"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</i18n>
|
||||||
|
|
|
@ -1,349 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { reactive, computed, ref } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
|
|
||||||
import Croppie from 'croppie/croppie';
|
|
||||||
import 'croppie/croppie.css';
|
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
|
||||||
import axios from 'axios';
|
|
||||||
|
|
||||||
const emit = defineEmits(['closeForm', 'onPhotoUploaded']);
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
id: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
collection: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
const { notify } = useNotify();
|
|
||||||
|
|
||||||
const uploadMethodsOptions = [
|
|
||||||
{ label: t('Select from computer'), value: 'computer' },
|
|
||||||
{ label: t('Import from external URL'), value: 'URL' },
|
|
||||||
];
|
|
||||||
|
|
||||||
const viewportTypes = [
|
|
||||||
{
|
|
||||||
code: 'normal',
|
|
||||||
description: t('Normal'),
|
|
||||||
viewport: {
|
|
||||||
width: 400,
|
|
||||||
height: 400,
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
width: 1200,
|
|
||||||
height: 1200,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
code: 'panoramic',
|
|
||||||
description: t('Panoramic'),
|
|
||||||
viewport: {
|
|
||||||
width: 675,
|
|
||||||
height: 450,
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
width: 1350,
|
|
||||||
height: 900,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
code: 'vertical',
|
|
||||||
description: t('Vertical'),
|
|
||||||
viewport: {
|
|
||||||
width: 306.66,
|
|
||||||
height: 533.33,
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
width: 460,
|
|
||||||
height: 800,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const uploadMethodSelected = ref('computer');
|
|
||||||
const viewPortTypeSelected = ref(viewportTypes[0]);
|
|
||||||
const inputFileRef = ref(null);
|
|
||||||
const allowedContentTypes = ref('');
|
|
||||||
const photoContainerRef = ref(null);
|
|
||||||
const editor = ref(null);
|
|
||||||
const newPhoto = reactive({
|
|
||||||
id: props.id,
|
|
||||||
collection: props.collection,
|
|
||||||
file: null,
|
|
||||||
url: null,
|
|
||||||
blob: null,
|
|
||||||
});
|
|
||||||
|
|
||||||
const openInputFile = () => {
|
|
||||||
inputFileRef.value.pickFiles();
|
|
||||||
};
|
|
||||||
|
|
||||||
const displayEditor = () => {
|
|
||||||
const viewportType = viewPortTypeSelected.value;
|
|
||||||
const viewport = viewportType.viewport;
|
|
||||||
const boundaryWidth = viewport.width + 200;
|
|
||||||
const boundaryHeight = viewport.height + 200;
|
|
||||||
|
|
||||||
if (editor.value) editor.value.destroy();
|
|
||||||
editor.value = new Croppie(photoContainerRef.value, {
|
|
||||||
viewport: { width: viewport.width, height: viewport.height },
|
|
||||||
boundary: { width: boundaryWidth, height: boundaryHeight },
|
|
||||||
enableOrientation: true,
|
|
||||||
showZoomer: true,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const viewportSelection = computed({
|
|
||||||
get() {
|
|
||||||
return viewPortTypeSelected.value;
|
|
||||||
},
|
|
||||||
set(val) {
|
|
||||||
viewPortTypeSelected.value = val;
|
|
||||||
|
|
||||||
const hasFile = newPhoto.files || newPhoto.url;
|
|
||||||
if (!val || !hasFile) return;
|
|
||||||
|
|
||||||
let file;
|
|
||||||
if (uploadMethodSelected.value == 'computer') file = newPhoto.files;
|
|
||||||
else if (uploadMethodSelected.value == 'URL') file = newPhoto.url;
|
|
||||||
|
|
||||||
updatePhotoPreview(file);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const updatePhotoPreview = (value) => {
|
|
||||||
if (value) {
|
|
||||||
displayEditor();
|
|
||||||
if (uploadMethodSelected.value == 'computer') {
|
|
||||||
newPhoto.files = value;
|
|
||||||
const reader = new FileReader();
|
|
||||||
reader.onload = (e) => editor.value.bind({ url: e.target.result });
|
|
||||||
reader.readAsDataURL(value);
|
|
||||||
} else if (uploadMethodSelected.value == 'URL') {
|
|
||||||
newPhoto.url = value;
|
|
||||||
const img = new Image();
|
|
||||||
img.crossOrigin = 'Anonymous';
|
|
||||||
img.src = value;
|
|
||||||
img.onload = () => editor.value.bind({ url: value });
|
|
||||||
img.onerror = () => {
|
|
||||||
notify(
|
|
||||||
t("This photo provider doesn't allow remote downloads"),
|
|
||||||
'negative'
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const rotateLeft = () => {
|
|
||||||
editor.value.rotate(90);
|
|
||||||
};
|
|
||||||
|
|
||||||
const rotateRight = () => {
|
|
||||||
editor.value.rotate(-90);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onSubmit = () => {
|
|
||||||
if (!newPhoto.files && !newPhoto.url) {
|
|
||||||
notify(t('Select an image'), 'negative');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = {
|
|
||||||
type: 'blob',
|
|
||||||
};
|
|
||||||
|
|
||||||
editor.value
|
|
||||||
.result(options)
|
|
||||||
.then((result) => {
|
|
||||||
const file = new File([result], newPhoto.files?.name || '');
|
|
||||||
newPhoto.blob = file;
|
|
||||||
})
|
|
||||||
.then(() => makeRequest());
|
|
||||||
};
|
|
||||||
|
|
||||||
const makeRequest = async () => {
|
|
||||||
const formData = new FormData();
|
|
||||||
const now = Date.vnNew();
|
|
||||||
const timestamp = now.getTime();
|
|
||||||
const fileName = `${newPhoto.files?.name}_${timestamp}`;
|
|
||||||
formData.append('blob', newPhoto.blob, fileName);
|
|
||||||
|
|
||||||
await axios.post('Images/upload', formData, {
|
|
||||||
params: newPhoto,
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'multipart/form-data',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
emit('closeForm');
|
|
||||||
emit('onPhotoUploaded');
|
|
||||||
|
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<FetchData
|
|
||||||
ref="allowTypesRef"
|
|
||||||
url="ImageContainers/allowedContentTypes"
|
|
||||||
@on-fetch="(data) => (allowedContentTypes = data.join(', '))"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<QForm @submit="onSubmit()" class="all-pointer-events">
|
|
||||||
<QCard class="q-pa-lg">
|
|
||||||
<span ref="closeButton" class="close-icon" v-close-popup>
|
|
||||||
<QIcon name="close" size="sm" />
|
|
||||||
</span>
|
|
||||||
<h1 class="title">{{ t('Edit photo') }}</h1>
|
|
||||||
<div class="row q-gutter-lg">
|
|
||||||
<div
|
|
||||||
v-show="newPhoto.files || newPhoto.url"
|
|
||||||
class="row q-gutter-lg items-center"
|
|
||||||
>
|
|
||||||
<QIcon
|
|
||||||
name="rotate_left"
|
|
||||||
size="sm"
|
|
||||||
color="primary"
|
|
||||||
class="cursor-pointer"
|
|
||||||
@click="rotateLeft()"
|
|
||||||
>
|
|
||||||
<!-- <QTooltip class="no-pointer-events">
|
|
||||||
{{ t('Rotate left') }}
|
|
||||||
</QTooltip> -->
|
|
||||||
</QIcon>
|
|
||||||
<div>
|
|
||||||
<div ref="photoContainerRef" />
|
|
||||||
</div>
|
|
||||||
<QIcon
|
|
||||||
name="rotate_right"
|
|
||||||
size="sm"
|
|
||||||
color="primary"
|
|
||||||
class="cursor-pointer"
|
|
||||||
@click="rotateRight()"
|
|
||||||
>
|
|
||||||
<!-- <QTooltip class="no-pointer-events">
|
|
||||||
{{ t('Rotate right') }}
|
|
||||||
</QTooltip> -->
|
|
||||||
</QIcon>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="column">
|
|
||||||
<VnRow>
|
|
||||||
<QOptionGroup
|
|
||||||
:options="uploadMethodsOptions"
|
|
||||||
type="radio"
|
|
||||||
v-model="uploadMethodSelected"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow>
|
|
||||||
<QFile
|
|
||||||
v-if="uploadMethodSelected === 'computer'"
|
|
||||||
ref="inputFileRef"
|
|
||||||
:label="t('File')"
|
|
||||||
:multiple="false"
|
|
||||||
v-model="newPhoto.files"
|
|
||||||
@update:model-value="updatePhotoPreview($event)"
|
|
||||||
:accept="allowedContentTypes"
|
|
||||||
class="required cursor-pointer"
|
|
||||||
>
|
|
||||||
<template #append>
|
|
||||||
<QIcon
|
|
||||||
name="vn:attach"
|
|
||||||
class="cursor-pointer q-mr-sm"
|
|
||||||
@click="openInputFile()"
|
|
||||||
>
|
|
||||||
<!-- <QTooltip>{{ t('globals.selectFile') }}</QTooltip> -->
|
|
||||||
</QIcon>
|
|
||||||
<QIcon name="info" class="cursor-pointer">
|
|
||||||
<QTooltip>{{
|
|
||||||
t('globals.allowedFilesText', {
|
|
||||||
allowedContentTypes: allowedContentTypes,
|
|
||||||
})
|
|
||||||
}}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</template>
|
|
||||||
</QFile>
|
|
||||||
<VnInput
|
|
||||||
v-if="uploadMethodSelected === 'URL'"
|
|
||||||
v-model="newPhoto.url"
|
|
||||||
@update:model-value="updatePhotoPreview($event)"
|
|
||||||
placeholder="https://"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Orientation')"
|
|
||||||
:options="viewportTypes"
|
|
||||||
hide-selected
|
|
||||||
option-label="description"
|
|
||||||
v-model="viewportSelection"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<div class="q-mt-lg row justify-end">
|
|
||||||
<QBtn
|
|
||||||
:label="t('globals.save')"
|
|
||||||
type="submit"
|
|
||||||
color="primary"
|
|
||||||
:disabled="isLoading"
|
|
||||||
:loading="isLoading"
|
|
||||||
/>
|
|
||||||
<QBtn
|
|
||||||
:label="t('globals.cancel')"
|
|
||||||
type="reset"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
class="q-ml-sm"
|
|
||||||
:disabled="isLoading"
|
|
||||||
:loading="isLoading"
|
|
||||||
v-close-popup
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</QCard>
|
|
||||||
</QForm>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.title {
|
|
||||||
font-size: 17px;
|
|
||||||
font-weight: bold;
|
|
||||||
line-height: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.close-icon {
|
|
||||||
position: absolute;
|
|
||||||
top: 20px;
|
|
||||||
right: 20px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
Edit photo: Editar foto
|
|
||||||
Select from computer: Seleccionar desde ordenador
|
|
||||||
Import from external URL: Importar desde URL externa
|
|
||||||
Vertical: Vertical
|
|
||||||
Normal: Normal
|
|
||||||
Panoramic: Panorámica
|
|
||||||
Orientation: Orientación
|
|
||||||
File: Fichero
|
|
||||||
This photo provider doesn't allow remote downloads: Este proveedor de fotos no permite descargas remotas
|
|
||||||
Rotate left: Girar a la izquierda
|
|
||||||
Rotate right: Girar a la derecha
|
|
||||||
Select an image: Selecciona una imagen
|
|
||||||
</i18n>
|
|
|
@ -1,149 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref, markRaw } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import { QCheckbox } from 'quasar';
|
|
||||||
|
|
||||||
import axios from 'axios';
|
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
|
||||||
|
|
||||||
const emit = defineEmits(['onDataSaved']);
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
rows: {
|
|
||||||
type: Array,
|
|
||||||
default: () => [],
|
|
||||||
},
|
|
||||||
fieldsOptions: {
|
|
||||||
type: Array,
|
|
||||||
default: () => [],
|
|
||||||
},
|
|
||||||
editUrl: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
const { notify } = useNotify();
|
|
||||||
|
|
||||||
const inputs = {
|
|
||||||
input: markRaw(VnInput),
|
|
||||||
number: markRaw(VnInput),
|
|
||||||
date: markRaw(VnInputDate),
|
|
||||||
checkbox: markRaw(QCheckbox),
|
|
||||||
select: markRaw(VnSelect),
|
|
||||||
};
|
|
||||||
|
|
||||||
const newValue = ref(null);
|
|
||||||
const selectedField = ref(null);
|
|
||||||
const closeButton = ref(null);
|
|
||||||
const isLoading = ref(false);
|
|
||||||
|
|
||||||
const onDataSaved = () => {
|
|
||||||
notify('globals.dataSaved', 'positive');
|
|
||||||
emit('onDataSaved');
|
|
||||||
closeForm();
|
|
||||||
};
|
|
||||||
|
|
||||||
const onSubmit = async () => {
|
|
||||||
isLoading.value = true;
|
|
||||||
const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk }));
|
|
||||||
const payload = {
|
|
||||||
field: selectedField.value.field,
|
|
||||||
newValue: newValue.value,
|
|
||||||
lines: rowsToEdit,
|
|
||||||
};
|
|
||||||
|
|
||||||
await axios.post($props.editUrl, payload);
|
|
||||||
onDataSaved();
|
|
||||||
isLoading.value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
const closeForm = () => {
|
|
||||||
if (closeButton.value) closeButton.value.click();
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<QForm @submit="onSubmit()" class="all-pointer-events">
|
|
||||||
<QCard class="q-pa-lg">
|
|
||||||
<span ref="closeButton" class="close-icon" v-close-popup>
|
|
||||||
<QIcon name="close" size="sm" />
|
|
||||||
</span>
|
|
||||||
<span class="title">{{ t('Edit') }}</span>
|
|
||||||
<span class="countLines">{{ ` ${rows.length} ` }}</span>
|
|
||||||
<span class="title">{{ t('buy(s)') }}</span>
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Field to edit')"
|
|
||||||
:options="fieldsOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="label"
|
|
||||||
v-model="selectedField"
|
|
||||||
data-cy="field-to-edit"
|
|
||||||
/>
|
|
||||||
<component
|
|
||||||
:is="inputs[selectedField?.component || 'input']"
|
|
||||||
v-bind="selectedField?.attrs || {}"
|
|
||||||
v-model="newValue"
|
|
||||||
:label="t('Value')"
|
|
||||||
data-cy="value-to-edit"
|
|
||||||
style="width: 200px"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<div class="q-mt-lg row justify-end">
|
|
||||||
<QBtn
|
|
||||||
:label="t('globals.cancel')"
|
|
||||||
type="reset"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
:disabled="isLoading"
|
|
||||||
:loading="isLoading"
|
|
||||||
v-close-popup
|
|
||||||
/>
|
|
||||||
<QBtn
|
|
||||||
:label="t('globals.save')"
|
|
||||||
type="submit"
|
|
||||||
color="primary"
|
|
||||||
class="q-ml-sm"
|
|
||||||
:disabled="isLoading"
|
|
||||||
:loading="isLoading"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</QCard>
|
|
||||||
</QForm>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.title {
|
|
||||||
font-size: 17px;
|
|
||||||
font-weight: bold;
|
|
||||||
line-height: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.close-icon {
|
|
||||||
position: absolute;
|
|
||||||
top: 20px;
|
|
||||||
right: 20px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.countLines {
|
|
||||||
font-size: 24px;
|
|
||||||
color: $primary;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
Edit: Editar
|
|
||||||
buy(s): compra(s)
|
|
||||||
Field to edit: Campo a editar
|
|
||||||
Value: Valor
|
|
||||||
</i18n>
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted } from 'vue';
|
import { h, onMounted } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
|
@ -24,13 +24,9 @@ const $props = defineProps({
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
type: [String, Number],
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
params: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['onFetch']);
|
const emit = defineEmits(['onFetch']);
|
||||||
|
@ -42,24 +38,27 @@ onMounted(async () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
async function fetch(fetchFilter = {}) {
|
async function fetch() {
|
||||||
try {
|
try {
|
||||||
const filter = { ...fetchFilter, ...$props.filter }; // eslint-disable-line vue/no-dupe-keys
|
const filter = Object.assign({}, $props.filter); // eslint-disable-line vue/no-dupe-keys
|
||||||
if ($props.where && !fetchFilter.where) filter.where = $props.where;
|
if ($props.where) filter.where = $props.where;
|
||||||
if ($props.sortBy) filter.order = $props.sortBy;
|
if ($props.sortBy) filter.order = $props.sortBy;
|
||||||
if ($props.limit) filter.limit = $props.limit;
|
if ($props.limit) filter.limit = $props.limit;
|
||||||
|
|
||||||
const { data } = await axios.get($props.url, {
|
const { data } = await axios.get($props.url, {
|
||||||
params: { filter: JSON.stringify(filter), ...$props.params },
|
params: { filter },
|
||||||
});
|
});
|
||||||
|
|
||||||
emit('onFetch', data);
|
emit('onFetch', data);
|
||||||
return data;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const render = () => {
|
||||||
|
return h('div', []);
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<template></template>
|
<render />
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,226 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref, reactive, computed } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
|
||||||
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
|
|
||||||
|
|
||||||
import axios from 'axios';
|
|
||||||
import { dashIfEmpty } from 'src/filters';
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
url: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits(['itemSelected']);
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
const itemFilter = {
|
|
||||||
include: [
|
|
||||||
{
|
|
||||||
relation: 'producer',
|
|
||||||
scope: {
|
|
||||||
fields: ['name'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
relation: 'ink',
|
|
||||||
scope: {
|
|
||||||
fields: ['name'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const itemFilterParams = reactive({});
|
|
||||||
const closeButton = ref(null);
|
|
||||||
const isLoading = ref(false);
|
|
||||||
const producersOptions = ref([]);
|
|
||||||
const ItemTypesOptions = ref([]);
|
|
||||||
const InksOptions = ref([]);
|
|
||||||
const tableRows = ref([]);
|
|
||||||
const loading = ref(false);
|
|
||||||
|
|
||||||
const tableColumns = computed(() => [
|
|
||||||
{
|
|
||||||
label: t('globals.id'),
|
|
||||||
name: 'id',
|
|
||||||
field: 'id',
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('globals.name'),
|
|
||||||
name: 'name',
|
|
||||||
field: 'name',
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('globals.size'),
|
|
||||||
name: 'size',
|
|
||||||
field: 'size',
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('globals.producer'),
|
|
||||||
name: 'producerName',
|
|
||||||
field: 'producer',
|
|
||||||
align: 'left',
|
|
||||||
format: (val) => dashIfEmpty(val),
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
label: t('entry.buys.color'),
|
|
||||||
name: 'ink',
|
|
||||||
field: (row) => row?.ink?.name,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
const onSubmit = async () => {
|
|
||||||
let filter = itemFilter;
|
|
||||||
const params = itemFilterParams;
|
|
||||||
const where = {};
|
|
||||||
for (let key in params) {
|
|
||||||
const value = params[key];
|
|
||||||
if (!value) continue;
|
|
||||||
|
|
||||||
switch (key) {
|
|
||||||
case 'name':
|
|
||||||
where[key] = { like: `%${value}%` };
|
|
||||||
break;
|
|
||||||
case 'producerFk':
|
|
||||||
case 'typeFk':
|
|
||||||
case 'size':
|
|
||||||
case 'inkFk':
|
|
||||||
where[key] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
filter.where = where;
|
|
||||||
|
|
||||||
const { data } = await axios.get(props.url, {
|
|
||||||
params: { filter: JSON.stringify(filter) },
|
|
||||||
});
|
|
||||||
tableRows.value = data;
|
|
||||||
};
|
|
||||||
|
|
||||||
const closeForm = () => {
|
|
||||||
if (closeButton.value) closeButton.value.click();
|
|
||||||
};
|
|
||||||
|
|
||||||
const selectItem = ({ id }) => {
|
|
||||||
emit('itemSelected', id);
|
|
||||||
closeForm();
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<FetchData
|
|
||||||
url="Producers"
|
|
||||||
@on-fetch="(data) => (producersOptions = data)"
|
|
||||||
:filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
url="ItemTypes"
|
|
||||||
:filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }"
|
|
||||||
order="name"
|
|
||||||
@on-fetch="(data) => (ItemTypesOptions = data)"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
url="Inks"
|
|
||||||
:filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }"
|
|
||||||
order="name"
|
|
||||||
@on-fetch="(data) => (InksOptions = data)"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<QForm @submit="onSubmit()" class="all-pointer-events">
|
|
||||||
<QCard class="column" style="padding: 32px; z-index: 100">
|
|
||||||
<span ref="closeButton" class="close-icon" v-close-popup>
|
|
||||||
<QIcon name="close" size="sm" />
|
|
||||||
</span>
|
|
||||||
<h1 class="title">{{ t('Filter item') }}</h1>
|
|
||||||
<VnRow>
|
|
||||||
<VnInput :label="t('globals.name')" v-model="itemFilterParams.name" />
|
|
||||||
<VnInput :label="t('entry.buys.size')" v-model="itemFilterParams.size" />
|
|
||||||
<VnSelect
|
|
||||||
:label="t('globals.producer')"
|
|
||||||
:options="producersOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
v-model="itemFilterParams.producerFk"
|
|
||||||
/>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('globals.type')"
|
|
||||||
:options="ItemTypesOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
v-model="itemFilterParams.typeFk"
|
|
||||||
/>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('entry.buys.color')"
|
|
||||||
:options="InksOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
v-model="itemFilterParams.inkFk"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<div class="q-mt-lg row justify-end">
|
|
||||||
<QBtn
|
|
||||||
:label="t('globals.search')"
|
|
||||||
type="submit"
|
|
||||||
color="primary"
|
|
||||||
:disabled="isLoading"
|
|
||||||
:loading="isLoading"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<QTable
|
|
||||||
:columns="tableColumns"
|
|
||||||
:rows="tableRows"
|
|
||||||
:loading="loading"
|
|
||||||
:hide-header="!tableRows || !tableRows.length > 0"
|
|
||||||
:no-data-label="t('Enter a new search')"
|
|
||||||
class="q-mt-lg"
|
|
||||||
@row-click="(_, row) => selectItem(row)"
|
|
||||||
>
|
|
||||||
<template #body-cell-id="{ row }">
|
|
||||||
<QTd auto-width @click.stop>
|
|
||||||
<QBtn flat color="blue">{{ row.id }}</QBtn>
|
|
||||||
<ItemDescriptorProxy :id="row.id" />
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
</QTable>
|
|
||||||
</QCard>
|
|
||||||
</QForm>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
Filter item: Filtrar artículo
|
|
||||||
Enter a new search: Introduce una nueva búsqueda
|
|
||||||
</i18n>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.title {
|
|
||||||
font-size: 17px;
|
|
||||||
font-weight: bold;
|
|
||||||
line-height: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.close-icon {
|
|
||||||
position: absolute;
|
|
||||||
top: 20px;
|
|
||||||
right: 20px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,225 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref, reactive, computed } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
|
||||||
import TravelDescriptorProxy from 'src/pages/Travel/Card/TravelDescriptorProxy.vue';
|
|
||||||
|
|
||||||
import axios from 'axios';
|
|
||||||
import { toDate } from 'src/filters';
|
|
||||||
|
|
||||||
const emit = defineEmits(['travelSelected']);
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
const travelFilter = {
|
|
||||||
include: [
|
|
||||||
{
|
|
||||||
relation: 'agency',
|
|
||||||
scope: {
|
|
||||||
fields: ['name'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
relation: 'warehouseIn',
|
|
||||||
scope: {
|
|
||||||
fields: ['name'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
relation: 'warehouseOut',
|
|
||||||
scope: {
|
|
||||||
fields: ['name'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const travelFilterParams = reactive({});
|
|
||||||
const closeButton = ref(null);
|
|
||||||
const isLoading = ref(false);
|
|
||||||
const agenciesOptions = ref([]);
|
|
||||||
const warehousesOptions = ref([]);
|
|
||||||
const tableRows = ref([]);
|
|
||||||
const loading = ref(false);
|
|
||||||
|
|
||||||
const tableColumns = computed(() => [
|
|
||||||
{
|
|
||||||
label: t('globals.id'),
|
|
||||||
name: 'id',
|
|
||||||
field: 'id',
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('globals.warehouseOut'),
|
|
||||||
name: 'warehouseOutFk',
|
|
||||||
field: 'warehouseOutFk',
|
|
||||||
align: 'left',
|
|
||||||
format: (val) =>
|
|
||||||
warehousesOptions.value.find((warehouse) => warehouse.id === val).name,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('globals.warehouseIn'),
|
|
||||||
name: 'warehouseInFk',
|
|
||||||
field: 'warehouseInFk',
|
|
||||||
align: 'left',
|
|
||||||
format: (val) =>
|
|
||||||
warehousesOptions.value.find((warehouse) => warehouse.id === val).name,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('globals.shipped'),
|
|
||||||
name: 'shipped',
|
|
||||||
field: 'shipped',
|
|
||||||
align: 'left',
|
|
||||||
format: (val) => toDate(val),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('globals.landed'),
|
|
||||||
name: 'landed',
|
|
||||||
field: 'landed',
|
|
||||||
align: 'left',
|
|
||||||
format: (val) => toDate(val),
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
const onSubmit = async () => {
|
|
||||||
let filter = travelFilter;
|
|
||||||
const params = travelFilterParams;
|
|
||||||
const where = {};
|
|
||||||
for (let key in params) {
|
|
||||||
const value = params[key];
|
|
||||||
if (!value) continue;
|
|
||||||
|
|
||||||
switch (key) {
|
|
||||||
case 'agencyModeFk':
|
|
||||||
case 'warehouseInFk':
|
|
||||||
case 'warehouseOutFk':
|
|
||||||
case 'shipped':
|
|
||||||
case 'landed':
|
|
||||||
where[key] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
filter.where = where;
|
|
||||||
const { data } = await axios.get('Travels', {
|
|
||||||
params: { filter: JSON.stringify(filter) },
|
|
||||||
});
|
|
||||||
tableRows.value = data;
|
|
||||||
};
|
|
||||||
|
|
||||||
const closeForm = () => {
|
|
||||||
if (closeButton.value) closeButton.value.click();
|
|
||||||
};
|
|
||||||
|
|
||||||
const selectTravel = ({ id }) => {
|
|
||||||
emit('travelSelected', id);
|
|
||||||
closeForm();
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<FetchData
|
|
||||||
url="AgencyModes"
|
|
||||||
@on-fetch="(data) => (agenciesOptions = data)"
|
|
||||||
:filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
url="Warehouses"
|
|
||||||
:filter="{ fields: ['id', 'name'] }"
|
|
||||||
order="name"
|
|
||||||
@on-fetch="(data) => (warehousesOptions = data)"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<QForm @submit="onSubmit()" class="all-pointer-events">
|
|
||||||
<QCard class="column" style="padding: 32px; z-index: 100">
|
|
||||||
<span ref="closeButton" class="close-icon" v-close-popup>
|
|
||||||
<QIcon name="close" size="sm" />
|
|
||||||
</span>
|
|
||||||
<h1 class="title">{{ t('Filter travels') }}</h1>
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('globals.agency')"
|
|
||||||
:options="agenciesOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
v-model="travelFilterParams.agencyModeFk"
|
|
||||||
/>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('globals.warehouseOut')"
|
|
||||||
:options="warehousesOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
v-model="travelFilterParams.warehouseOutFk"
|
|
||||||
/>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('globals.warehouseIn')"
|
|
||||||
:options="warehousesOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
v-model="travelFilterParams.warehouseInFk"
|
|
||||||
/>
|
|
||||||
<VnInputDate
|
|
||||||
:label="t('globals.shipped')"
|
|
||||||
v-model="travelFilterParams.shipped"
|
|
||||||
/>
|
|
||||||
<VnInputDate
|
|
||||||
:label="t('globals.landed')"
|
|
||||||
v-model="travelFilterParams.landed"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<div class="q-mt-lg row justify-end">
|
|
||||||
<QBtn
|
|
||||||
:label="t('globals.search')"
|
|
||||||
type="submit"
|
|
||||||
color="primary"
|
|
||||||
:disabled="isLoading"
|
|
||||||
:loading="isLoading"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<QTable
|
|
||||||
:columns="tableColumns"
|
|
||||||
:rows="tableRows"
|
|
||||||
:loading="loading"
|
|
||||||
:hide-header="!tableRows || !tableRows.length > 0"
|
|
||||||
:no-data-label="t('Enter a new search')"
|
|
||||||
class="q-mt-lg"
|
|
||||||
@row-click="(_, row) => selectTravel(row)"
|
|
||||||
>
|
|
||||||
<template #body-cell-id="{ row }">
|
|
||||||
<QTd auto-width @click.stop>
|
|
||||||
<QBtn flat color="blue">{{ row.id }}</QBtn>
|
|
||||||
<TravelDescriptorProxy :id="row.id" />
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
</QTable>
|
|
||||||
</QCard>
|
|
||||||
</QForm>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
Filter travels: Filtro envíos
|
|
||||||
Enter a new search: Introduce una nueva búsqueda
|
|
||||||
</i18n>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.title {
|
|
||||||
font-size: 17px;
|
|
||||||
font-weight: bold;
|
|
||||||
line-height: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.close-icon {
|
|
||||||
position: absolute;
|
|
||||||
top: 20px;
|
|
||||||
right: 20px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,27 +1,19 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { onMounted, onUnmounted, computed, ref, watch, nextTick } from 'vue';
|
import { onMounted, onUnmounted, computed, ref, watch } from 'vue';
|
||||||
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';
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { useValidator } from 'src/composables/useValidator';
|
import { useValidator } from 'src/composables/useValidator';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
|
||||||
import SkeletonForm from 'components/ui/SkeletonForm.vue';
|
import SkeletonForm from 'components/ui/SkeletonForm.vue';
|
||||||
import VnConfirm from './ui/VnConfirm.vue';
|
|
||||||
import { tMobile } from 'src/composables/tMobile';
|
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
|
||||||
|
|
||||||
const { push } = useRouter();
|
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { validate } = useValidator();
|
const { validate } = useValidator();
|
||||||
const { notify } = useNotify();
|
|
||||||
const route = useRoute();
|
|
||||||
const myForm = ref(null);
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
url: {
|
url: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -29,7 +21,7 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
model: {
|
model: {
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
default: '',
|
||||||
},
|
},
|
||||||
filter: {
|
filter: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
@ -39,210 +31,71 @@ const $props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
urlCreate: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
defaultActions: {
|
defaultActions: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
defaultButtons: {
|
|
||||||
type: Object,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
autoLoad: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
formInitialData: {
|
|
||||||
type: Object,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
observeFormChanges: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
description:
|
|
||||||
'Esto se usa principalmente para permitir guardar sin hacer cambios (Útil para la feature de clonar ya que en este caso queremos poder guardar de primeras)',
|
|
||||||
},
|
|
||||||
mapper: {
|
|
||||||
type: Function,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
clearStoreOnUnmount: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
saveFn: {
|
|
||||||
type: Function,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
goTo: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
description: 'It is used for redirect on click "save and continue"',
|
|
||||||
},
|
|
||||||
reload: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
defaultTrim: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
maxWidth: {
|
|
||||||
type: [String, Boolean],
|
|
||||||
default: '800px',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
|
||||||
const modelValue = computed(
|
|
||||||
() => $props.model ?? `formModel_${route?.meta?.title ?? route.name}`
|
|
||||||
).value;
|
|
||||||
const componentIsRendered = ref(false);
|
|
||||||
const arrayData = useArrayData(modelValue);
|
|
||||||
const isLoading = ref(false);
|
|
||||||
// Si elegimos observar los cambios del form significa que inicialmente las actions estaran deshabilitadas
|
|
||||||
const isResetting = ref(false);
|
|
||||||
const hasChanges = ref(!$props.observeFormChanges);
|
|
||||||
const originalData = ref({});
|
|
||||||
const formData = computed(() => state.get(modelValue));
|
|
||||||
const defaultButtons = computed(() => ({
|
|
||||||
save: {
|
|
||||||
dataCy: 'saveDefaultBtn',
|
|
||||||
color: 'primary',
|
|
||||||
icon: 'save',
|
|
||||||
label: 'globals.save',
|
|
||||||
click: () => myForm.value.submit(),
|
|
||||||
type: 'submit',
|
|
||||||
},
|
|
||||||
reset: {
|
|
||||||
dataCy: 'resetDefaultBtn',
|
|
||||||
color: 'primary',
|
|
||||||
icon: 'restart_alt',
|
|
||||||
label: 'globals.reset',
|
|
||||||
click: () => reset(),
|
|
||||||
},
|
|
||||||
...$props.defaultButtons,
|
|
||||||
}));
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
originalData.value = JSON.parse(JSON.stringify($props.formInitialData ?? {}));
|
|
||||||
|
|
||||||
nextTick(() => (componentIsRendered.value = true));
|
|
||||||
|
|
||||||
// Podemos enviarle al form la estructura de data inicial sin necesidad de fetchearla
|
|
||||||
state.set(modelValue, $props.formInitialData);
|
|
||||||
|
|
||||||
if (!$props.formInitialData) {
|
|
||||||
if ($props.autoLoad && $props.url) await fetch();
|
|
||||||
else if (arrayData.store.data) updateAndEmit('onFetch', arrayData.store.data);
|
|
||||||
}
|
|
||||||
if ($props.observeFormChanges) {
|
|
||||||
watch(
|
|
||||||
() => formData.value,
|
|
||||||
(newVal, oldVal) => {
|
|
||||||
if (!oldVal) return;
|
|
||||||
hasChanges.value =
|
|
||||||
!isResetting.value &&
|
|
||||||
JSON.stringify(newVal) !== JSON.stringify(originalData.value);
|
|
||||||
isResetting.value = false;
|
|
||||||
},
|
|
||||||
{ deep: true }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!$props.url)
|
const emit = defineEmits(['onFetch']);
|
||||||
watch(
|
|
||||||
() => arrayData.store.data,
|
|
||||||
(val) => updateAndEmit('onFetch', val)
|
|
||||||
);
|
|
||||||
|
|
||||||
watch(
|
defineExpose({
|
||||||
() => [$props.url, $props.filter],
|
save,
|
||||||
async () => {
|
});
|
||||||
originalData.value = null;
|
|
||||||
reset();
|
|
||||||
await fetch();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
onBeforeRouteLeave((to, from, next) => {
|
onMounted(async () => await fetch());
|
||||||
if (hasChanges.value && $props.observeFormChanges)
|
|
||||||
quasar.dialog({
|
|
||||||
component: VnConfirm,
|
|
||||||
componentProps: {
|
|
||||||
title: t('globals.unsavedPopup.title'),
|
|
||||||
message: t('globals.unsavedPopup.subtitle'),
|
|
||||||
promise: () => next(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
else next();
|
|
||||||
});
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
// Restauramos los datos originales en el store si se realizaron cambios en el formulario pero no se guardaron, evitando modificaciones erróneas.
|
state.unset($props.model);
|
||||||
if (hasChanges.value) return state.set(modelValue, originalData.value);
|
|
||||||
if ($props.clearStoreOnUnmount) state.unset(modelValue);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isLoading = ref(false);
|
||||||
|
const hasChanges = ref(false);
|
||||||
|
const originalData = ref();
|
||||||
|
const formData = computed(() => state.get($props.model));
|
||||||
|
const formUrl = computed(() => $props.url);
|
||||||
|
|
||||||
|
function tMobile(...args) {
|
||||||
|
if (!quasar.platform.is.mobile) return t(...args);
|
||||||
|
}
|
||||||
|
|
||||||
async function fetch() {
|
async function fetch() {
|
||||||
try {
|
const { data } = await axios.get($props.url, {
|
||||||
let { data } = await axios.get($props.url, {
|
params: { filter: $props.filter },
|
||||||
params: { filter: JSON.stringify($props.filter) },
|
|
||||||
});
|
});
|
||||||
if (Array.isArray(data)) data = data[0] ?? {};
|
|
||||||
|
|
||||||
updateAndEmit('onFetch', data);
|
state.set($props.model, data);
|
||||||
} catch (e) {
|
originalData.value = data && JSON.parse(JSON.stringify(data));
|
||||||
state.set(modelValue, {});
|
|
||||||
originalData.value = {};
|
watch(formData.value, () => (hasChanges.value = true));
|
||||||
throw e;
|
|
||||||
}
|
emit('onFetch', state.get($props.model));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
if ($props.observeFormChanges && !hasChanges.value)
|
if (!hasChanges.value) {
|
||||||
return notify('globals.noChanges', 'negative');
|
return quasar.notify({
|
||||||
|
type: 'negative',
|
||||||
|
message: t('globals.noChanges'),
|
||||||
|
});
|
||||||
|
}
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
try {
|
await axios.patch($props.urlUpdate || $props.url, formData.value);
|
||||||
formData.value = trimData(formData.value);
|
|
||||||
const body = $props.mapper
|
|
||||||
? $props.mapper(formData.value, originalData.value)
|
|
||||||
: formData.value;
|
|
||||||
const method = $props.urlCreate ? 'post' : 'patch';
|
|
||||||
const url =
|
|
||||||
$props.urlCreate || $props.urlUpdate || $props.url || arrayData.store.url;
|
|
||||||
let response;
|
|
||||||
|
|
||||||
if ($props.saveFn) response = await $props.saveFn(body);
|
originalData.value = JSON.parse(JSON.stringify(formData.value));
|
||||||
else response = await axios[method](url, body);
|
|
||||||
|
|
||||||
if ($props.urlCreate) notify('globals.dataCreated', 'positive');
|
|
||||||
|
|
||||||
updateAndEmit('onDataSaved', formData.value, response?.data);
|
|
||||||
if ($props.reload) await arrayData.fetch({});
|
|
||||||
hasChanges.value = false;
|
hasChanges.value = false;
|
||||||
} finally {
|
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async function saveAndGo() {
|
|
||||||
await save();
|
|
||||||
push({ path: $props.goTo });
|
|
||||||
}
|
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
updateAndEmit('onFetch', originalData.value);
|
state.set($props.model, originalData.value);
|
||||||
if ($props.observeFormChanges) {
|
originalData.value = JSON.parse(JSON.stringify(originalData.value));
|
||||||
hasChanges.value = false;
|
|
||||||
isResetting.value = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
watch(formData.value, () => (hasChanges.value = true));
|
||||||
|
|
||||||
|
emit('onFetch', state.get($props.model));
|
||||||
|
hasChanges.value = false;
|
||||||
|
}
|
||||||
// eslint-disable-next-line vue/no-dupe-keys
|
// eslint-disable-next-line vue/no-dupe-keys
|
||||||
function filter(value, update, filterOptions) {
|
function filter(value, update, filterOptions) {
|
||||||
update(
|
update(
|
||||||
|
@ -258,133 +111,71 @@ function filter(value, update, filterOptions) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateAndEmit(evt, val, res) {
|
watch(formUrl, async () => {
|
||||||
state.set(modelValue, val);
|
originalData.value = null;
|
||||||
originalData.value = val && JSON.parse(JSON.stringify(val));
|
reset();
|
||||||
if (!$props.url) arrayData.store.data = val;
|
fetch();
|
||||||
|
|
||||||
emit(evt, state.get(modelValue), res);
|
|
||||||
}
|
|
||||||
|
|
||||||
function trimData(data) {
|
|
||||||
if (!$props.defaultTrim) return data;
|
|
||||||
for (const key in data) {
|
|
||||||
if (typeof data[key] == 'string') data[key] = data[key].trim();
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
save,
|
|
||||||
isLoading,
|
|
||||||
hasChanges,
|
|
||||||
reset,
|
|
||||||
fetch,
|
|
||||||
formData,
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="column items-center full-width">
|
<QBanner v-if="hasChanges" class="text-white bg-warning">
|
||||||
|
<QIcon name="warning" size="md" class="q-mr-md" />
|
||||||
|
<span>{{ t('globals.changesToSave') }}</span>
|
||||||
|
</QBanner>
|
||||||
|
<div class="column items-center">
|
||||||
<QForm
|
<QForm
|
||||||
ref="myForm"
|
|
||||||
v-if="formData"
|
v-if="formData"
|
||||||
@submit="save"
|
@submit="save"
|
||||||
@reset="reset"
|
@reset="reset"
|
||||||
class="q-pa-md"
|
class="q-pa-md"
|
||||||
:style="maxWidth ? 'max-width: ' + maxWidth : ''"
|
|
||||||
id="formModel"
|
id="formModel"
|
||||||
:prevent-submit="$attrs['prevent-submit']"
|
|
||||||
>
|
>
|
||||||
<QCard>
|
<QCard>
|
||||||
<slot
|
<slot
|
||||||
v-if="formData"
|
|
||||||
name="form"
|
name="form"
|
||||||
:data="formData"
|
:data="formData"
|
||||||
:validate="validate"
|
:validate="validate"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
/>
|
/>
|
||||||
<SkeletonForm v-else />
|
|
||||||
</QCard>
|
</QCard>
|
||||||
</QForm>
|
</QForm>
|
||||||
</div>
|
</div>
|
||||||
<Teleport
|
<Teleport to="#st-actions" v-if="stateStore?.isSubToolbarShown()">
|
||||||
to="#st-actions"
|
<div v-if="$props.defaultActions">
|
||||||
v-if="
|
|
||||||
$props.defaultActions &&
|
|
||||||
stateStore?.isSubToolbarShown() &&
|
|
||||||
componentIsRendered
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<QBtnGroup push class="q-gutter-x-sm">
|
<QBtnGroup push class="q-gutter-x-sm">
|
||||||
<slot name="moreActions" />
|
<slot name="moreActions" />
|
||||||
<QBtn
|
<QBtn
|
||||||
:label="tMobile(defaultButtons.reset.label)"
|
:label="tMobile('globals.reset')"
|
||||||
:color="defaultButtons.reset.color"
|
|
||||||
:icon="defaultButtons.reset.icon"
|
|
||||||
flat
|
|
||||||
@click="defaultButtons.reset.click"
|
|
||||||
:disable="!hasChanges"
|
|
||||||
:title="t(defaultButtons.reset.label)"
|
|
||||||
/>
|
|
||||||
<QBtnDropdown
|
|
||||||
data-cy="saveAndContinueDefaultBtn"
|
|
||||||
v-if="$props.goTo"
|
|
||||||
@click="saveAndGo"
|
|
||||||
:label="tMobile('globals.saveAndContinue')"
|
|
||||||
:title="t('globals.saveAndContinue')"
|
|
||||||
:disable="!hasChanges"
|
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="save"
|
icon="restart_alt"
|
||||||
split
|
flat
|
||||||
>
|
@click="reset"
|
||||||
<QList>
|
:disable="!hasChanges"
|
||||||
<QItem
|
:title="t('globals.reset')"
|
||||||
clickable
|
|
||||||
v-close-popup
|
|
||||||
@click="save"
|
|
||||||
:title="t('globals.save')"
|
|
||||||
>
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>
|
|
||||||
<QIcon
|
|
||||||
name="save"
|
|
||||||
color="white"
|
|
||||||
class="q-mr-sm"
|
|
||||||
size="sm"
|
|
||||||
/>
|
/>
|
||||||
{{ t('globals.save').toUpperCase() }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</QList>
|
|
||||||
</QBtnDropdown>
|
|
||||||
<QBtn
|
<QBtn
|
||||||
v-else
|
|
||||||
:label="tMobile('globals.save')"
|
:label="tMobile('globals.save')"
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="save"
|
icon="save"
|
||||||
@click="defaultButtons.save.click"
|
@click="save"
|
||||||
:disable="!hasChanges"
|
:disable="!hasChanges"
|
||||||
:title="t(defaultButtons.save.label)"
|
:title="t('globals.save')"
|
||||||
/>
|
/>
|
||||||
</QBtnGroup>
|
</QBtnGroup>
|
||||||
|
</div>
|
||||||
</Teleport>
|
</Teleport>
|
||||||
|
<SkeletonForm v-if="!formData" />
|
||||||
<QInnerLoading
|
<QInnerLoading
|
||||||
:showing="isLoading"
|
:showing="isLoading"
|
||||||
:label="t('globals.pleaseWait')"
|
:label="t('globals.pleaseWait')"
|
||||||
color="primary"
|
color="primary"
|
||||||
style="min-width: 100%"
|
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.q-notifications {
|
|
||||||
color: black;
|
|
||||||
}
|
|
||||||
#formModel {
|
#formModel {
|
||||||
|
max-width: 800px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.q-card {
|
.q-card {
|
||||||
padding: 32px;
|
padding: 32px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,96 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref, computed } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
import FormModel from 'components/FormModel.vue';
|
|
||||||
|
|
||||||
const emit = defineEmits(['onDataSaved', 'onDataCanceled']);
|
|
||||||
|
|
||||||
defineProps({
|
|
||||||
title: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
subtitle: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
const formModelRef = ref(null);
|
|
||||||
const closeButton = ref(null);
|
|
||||||
|
|
||||||
const onDataSaved = (formData, requestResponse) => {
|
|
||||||
if (closeButton.value) closeButton.value.click();
|
|
||||||
emit('onDataSaved', formData, requestResponse);
|
|
||||||
};
|
|
||||||
|
|
||||||
const isLoading = computed(() => formModelRef.value?.isLoading);
|
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
isLoading,
|
|
||||||
onDataSaved,
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<FormModel
|
|
||||||
ref="formModelRef"
|
|
||||||
:observe-form-changes="false"
|
|
||||||
:default-actions="false"
|
|
||||||
v-bind="$attrs"
|
|
||||||
@on-data-saved="onDataSaved"
|
|
||||||
>
|
|
||||||
<template #form="{ data, validate }">
|
|
||||||
<span ref="closeButton" class="close-icon" v-close-popup>
|
|
||||||
<QIcon name="close" size="sm" />
|
|
||||||
</span>
|
|
||||||
<h1 class="title">{{ title }}</h1>
|
|
||||||
<p>{{ subtitle }}</p>
|
|
||||||
<slot name="form-inputs" :data="data" :validate="validate" />
|
|
||||||
<div class="q-mt-lg row justify-end">
|
|
||||||
<QBtn
|
|
||||||
:label="t('globals.cancel')"
|
|
||||||
:title="t('globals.cancel')"
|
|
||||||
type="reset"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
:disabled="isLoading"
|
|
||||||
:loading="isLoading"
|
|
||||||
@click="emit('onDataCanceled')"
|
|
||||||
v-close-popup
|
|
||||||
data-cy="FormModelPopup_cancel"
|
|
||||||
z-max
|
|
||||||
/>
|
|
||||||
<QBtn
|
|
||||||
:label="t('globals.save')"
|
|
||||||
:title="t('globals.save')"
|
|
||||||
type="submit"
|
|
||||||
color="primary"
|
|
||||||
class="q-ml-sm"
|
|
||||||
:disabled="isLoading"
|
|
||||||
:loading="isLoading"
|
|
||||||
data-cy="FormModelPopup_save"
|
|
||||||
z-max
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</FormModel>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.title {
|
|
||||||
font-size: 17px;
|
|
||||||
font-weight: bold;
|
|
||||||
line-height: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.close-icon {
|
|
||||||
position: absolute;
|
|
||||||
top: 20px;
|
|
||||||
right: 20px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,101 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
const emit = defineEmits(['onSubmit']);
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
title: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
subtitle: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
defaultSubmitButton: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
defaultCancelButton: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
customSubmitButtonLabel: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
submitOnEnter: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
const closeButton = ref(null);
|
|
||||||
const isLoading = ref(false);
|
|
||||||
|
|
||||||
const onSubmit = () => {
|
|
||||||
if ($props.submitOnEnter) {
|
|
||||||
emit('onSubmit');
|
|
||||||
closeForm();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const closeForm = () => {
|
|
||||||
if (closeButton.value) closeButton.value.click();
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<QForm
|
|
||||||
@submit="onSubmit($event)"
|
|
||||||
class="all-pointer-events full-width"
|
|
||||||
style="max-width: 800px"
|
|
||||||
>
|
|
||||||
<QCard class="q-pa-lg">
|
|
||||||
<span ref="closeButton" class="close-icon" v-close-popup>
|
|
||||||
<QIcon name="close" size="sm" />
|
|
||||||
</span>
|
|
||||||
<h1 class="title">{{ title }}</h1>
|
|
||||||
<p>{{ subtitle }}</p>
|
|
||||||
<slot name="form-inputs" />
|
|
||||||
<div class="q-mt-lg row justify-end">
|
|
||||||
<QBtn
|
|
||||||
v-if="defaultCancelButton"
|
|
||||||
:label="t('globals.cancel')"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
class="q-ml-sm"
|
|
||||||
:disabled="isLoading"
|
|
||||||
:loading="isLoading"
|
|
||||||
v-close-popup
|
|
||||||
/>
|
|
||||||
<QBtn
|
|
||||||
v-if="defaultSubmitButton"
|
|
||||||
:label="customSubmitButtonLabel || t('globals.save')"
|
|
||||||
type="submit"
|
|
||||||
color="primary"
|
|
||||||
:disabled="isLoading"
|
|
||||||
:loading="isLoading"
|
|
||||||
/>
|
|
||||||
<slot name="custom-buttons" />
|
|
||||||
</div>
|
|
||||||
</QCard>
|
|
||||||
</QForm>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.title {
|
|
||||||
font-size: 17px;
|
|
||||||
font-weight: bold;
|
|
||||||
line-height: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.close-icon {
|
|
||||||
position: absolute;
|
|
||||||
top: 20px;
|
|
||||||
right: 20px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,351 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { computed, ref } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
import VnInput from 'components/common/VnInput.vue';
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
|
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
|
||||||
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
|
|
||||||
|
|
||||||
import axios from 'axios';
|
|
||||||
import { getParamWhere } from 'src/filters';
|
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
const props = defineProps({
|
|
||||||
dataKey: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
customTags: {
|
|
||||||
type: Array,
|
|
||||||
default: () => [],
|
|
||||||
},
|
|
||||||
exprBuilder: {
|
|
||||||
type: Function,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
|
|
||||||
const itemTypesOptions = ref([]);
|
|
||||||
const tagOptions = ref([]);
|
|
||||||
const tagValues = ref([]);
|
|
||||||
const categoryList = ref(null);
|
|
||||||
const selectedCategoryFk = ref(getParamWhere(route.query.table, 'categoryFk', false));
|
|
||||||
const selectedTypeFk = ref(getParamWhere(route.query.table, 'typeFk', false));
|
|
||||||
|
|
||||||
const selectedCategory = computed(() => {
|
|
||||||
return (categoryList.value || []).find(
|
|
||||||
(category) => category?.id === selectedCategoryFk.value,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
const selectedType = computed(() => {
|
|
||||||
return (itemTypesOptions.value || []).find(
|
|
||||||
(type) => type?.id === selectedTypeFk.value,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
const selectCategory = async (params, categoryId, search) => {
|
|
||||||
if (params.categoryFk === categoryId) {
|
|
||||||
resetCategory(params);
|
|
||||||
search();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
selectedCategoryFk.value = categoryId;
|
|
||||||
params.categoryFk = categoryId;
|
|
||||||
await fetchItemTypes(categoryId);
|
|
||||||
search();
|
|
||||||
};
|
|
||||||
|
|
||||||
const resetCategory = (params) => {
|
|
||||||
selectedCategoryFk.value = null;
|
|
||||||
itemTypesOptions.value = null;
|
|
||||||
if (params) {
|
|
||||||
params.categoryFk = null;
|
|
||||||
params.typeFk = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const applyTags = (params, search) => {
|
|
||||||
params.tags = tagValues.value
|
|
||||||
.filter((tag) => tag.selectedTag && tag.value)
|
|
||||||
.map((tag) => ({
|
|
||||||
tagFk: tag.selectedTag.id,
|
|
||||||
tagName: tag.selectedTag.name,
|
|
||||||
value: tag.value,
|
|
||||||
}));
|
|
||||||
search();
|
|
||||||
};
|
|
||||||
|
|
||||||
const fetchItemTypes = async (id = selectedCategoryFk.value) => {
|
|
||||||
const filter = {
|
|
||||||
fields: ['id', 'name', 'categoryFk'],
|
|
||||||
where: { categoryFk: id },
|
|
||||||
include: 'category',
|
|
||||||
order: 'name ASC',
|
|
||||||
};
|
|
||||||
const { data } = await axios.get('ItemTypes', {
|
|
||||||
params: { filter: JSON.stringify(filter) },
|
|
||||||
});
|
|
||||||
itemTypesOptions.value = data;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getCategoryClass = (category, params) => {
|
|
||||||
if (category.id === params?.categoryFk) {
|
|
||||||
return 'active';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getSelectedTagValues = async (tag) => {
|
|
||||||
if (!tag?.selectedTag?.id) return;
|
|
||||||
tag.value = null;
|
|
||||||
const filter = {
|
|
||||||
fields: ['value'],
|
|
||||||
order: 'value ASC',
|
|
||||||
limit: 30,
|
|
||||||
};
|
|
||||||
|
|
||||||
const params = { filter: JSON.stringify(filter) };
|
|
||||||
const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, {
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
tag.valueOptions = data;
|
|
||||||
};
|
|
||||||
|
|
||||||
const removeTag = (index, params, search) => {
|
|
||||||
(tagValues.value || []).splice(index, 1);
|
|
||||||
applyTags(params, search);
|
|
||||||
};
|
|
||||||
const setCategoryList = (data) => {
|
|
||||||
categoryList.value = (data || [])
|
|
||||||
.filter((category) => category.display)
|
|
||||||
.map((category) => ({
|
|
||||||
...category,
|
|
||||||
icon: `vn:${(category.icon || '').split('-')[1]}`,
|
|
||||||
}));
|
|
||||||
fetchItemTypes();
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<FetchData url="ItemCategories" limit="30" auto-load @on-fetch="setCategoryList" />
|
|
||||||
<FetchData
|
|
||||||
url="Tags"
|
|
||||||
:filter="{ fields: ['id', 'name', 'isFree'] }"
|
|
||||||
auto-load
|
|
||||||
limit="30"
|
|
||||||
@on-fetch="(data) => (tagOptions = data)"
|
|
||||||
/>
|
|
||||||
<VnFilterPanel
|
|
||||||
:data-key="props.dataKey"
|
|
||||||
:expr-builder="props.exprBuilder"
|
|
||||||
:custom-tags="props.customTags"
|
|
||||||
>
|
|
||||||
<template #tags="{ tag, formatFn }">
|
|
||||||
<strong v-if="tag.label === 'categoryFk'">
|
|
||||||
{{ t(selectedCategory?.name || '') }}
|
|
||||||
</strong>
|
|
||||||
<strong v-else-if="tag.label === 'typeFk'">
|
|
||||||
{{ t(selectedType?.name || '') }}
|
|
||||||
</strong>
|
|
||||||
<div v-else class="q-gutter-x-xs">
|
|
||||||
<strong>{{ t(`components.itemsFilterPanel.${tag.label}`) }}: </strong>
|
|
||||||
<span>{{ formatFn(tag.value) }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template #customTags="{ tags, params }">
|
|
||||||
<template v-for="tag in tags" :key="tag.label">
|
|
||||||
<VnFilterPanelChip
|
|
||||||
v-for="chip in tag.value"
|
|
||||||
:key="chip"
|
|
||||||
removable
|
|
||||||
@remove="removeTagChip(chip, params, searchFn)"
|
|
||||||
>
|
|
||||||
<div class="q-gutter-x-xs">
|
|
||||||
<strong>{{ chip.tagName }}: </strong>
|
|
||||||
<span>"{{ chip.value }}"</span>
|
|
||||||
</div>
|
|
||||||
</VnFilterPanelChip>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
<template #body="{ params, searchFn }">
|
|
||||||
<QItem class="category-filter q-mt-md">
|
|
||||||
<QBtn
|
|
||||||
dense
|
|
||||||
flat
|
|
||||||
round
|
|
||||||
v-for="category in categoryList"
|
|
||||||
:key="category.name"
|
|
||||||
:class="['category', getCategoryClass(category, params)]"
|
|
||||||
:icon="category.icon"
|
|
||||||
@click="selectCategory(params, category.id, searchFn)"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ t(category.name) }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</QItem>
|
|
||||||
<QItem class="q-my-md">
|
|
||||||
<QItemSection>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('components.itemsFilterPanel.typeFk')"
|
|
||||||
v-model="params.typeFk"
|
|
||||||
:options="itemTypesOptions"
|
|
||||||
option-value="id"
|
|
||||||
option-label="name"
|
|
||||||
dense
|
|
||||||
outlined
|
|
||||||
rounded
|
|
||||||
use-input
|
|
||||||
:disable="!selectedCategoryFk"
|
|
||||||
@update:model-value="
|
|
||||||
(value) => {
|
|
||||||
selectedTypeFk = value;
|
|
||||||
searchFn();
|
|
||||||
}
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<template #option="{ itemProps, opt }">
|
|
||||||
<QItem v-bind="itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>{{ opt.name }}</QItemLabel>
|
|
||||||
<QItemLabel caption>
|
|
||||||
{{ opt.categoryName }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
<QSeparator />
|
|
||||||
<slot name="body" :params="params" :search-fn="searchFn" />
|
|
||||||
<QItem
|
|
||||||
v-for="(value, index) in tagValues"
|
|
||||||
:key="value"
|
|
||||||
class="q-mt-md filter-value"
|
|
||||||
>
|
|
||||||
<QItemSection class="col">
|
|
||||||
<VnSelect
|
|
||||||
:label="t('globals.tag')"
|
|
||||||
v-model="value.selectedTag"
|
|
||||||
:options="tagOptions"
|
|
||||||
option-label="name"
|
|
||||||
dense
|
|
||||||
outlined
|
|
||||||
rounded
|
|
||||||
:emit-value="false"
|
|
||||||
use-input
|
|
||||||
:is-clearable="false"
|
|
||||||
@update:model-value="getSelectedTagValues(value)"
|
|
||||||
/>
|
|
||||||
</QItemSection>
|
|
||||||
<QItemSection class="col">
|
|
||||||
<VnSelect
|
|
||||||
v-if="!value?.selectedTag?.isFree && value.valueOptions"
|
|
||||||
:label="t('components.itemsFilterPanel.value')"
|
|
||||||
v-model="value.value"
|
|
||||||
:options="value.valueOptions || []"
|
|
||||||
option-value="value"
|
|
||||||
option-label="value"
|
|
||||||
dense
|
|
||||||
outlined
|
|
||||||
rounded
|
|
||||||
emit-value
|
|
||||||
use-input
|
|
||||||
:disable="!value"
|
|
||||||
:is-clearable="false"
|
|
||||||
@update:model-value="applyTags(params, searchFn)"
|
|
||||||
/>
|
|
||||||
<VnInput
|
|
||||||
v-else
|
|
||||||
v-model="value.value"
|
|
||||||
:label="t('components.itemsFilterPanel.value')"
|
|
||||||
:disable="!value"
|
|
||||||
is-outlined
|
|
||||||
:is-clearable="false"
|
|
||||||
@keyup.enter="applyTags(params, searchFn)"
|
|
||||||
/>
|
|
||||||
</QItemSection>
|
|
||||||
<QIcon
|
|
||||||
name="delete"
|
|
||||||
class="fill-icon-on-hover q-px-xs"
|
|
||||||
color="primary"
|
|
||||||
size="sm"
|
|
||||||
@click="removeTag(index, params, searchFn)"
|
|
||||||
/>
|
|
||||||
</QItem>
|
|
||||||
<QItem class="q-mt-lg">
|
|
||||||
<QBtn
|
|
||||||
icon="add_circle"
|
|
||||||
shortcut="+"
|
|
||||||
flat
|
|
||||||
class="fill-icon-on-hover q-px-xs"
|
|
||||||
color="primary"
|
|
||||||
@click="tagValues.push({})"
|
|
||||||
/>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnFilterPanel>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.category-filter {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 12px;
|
|
||||||
|
|
||||||
.category {
|
|
||||||
padding: 8px;
|
|
||||||
width: 60px;
|
|
||||||
height: 60px;
|
|
||||||
font-size: 1.4rem;
|
|
||||||
background-color: var(--vn-accent-color);
|
|
||||||
|
|
||||||
&.active {
|
|
||||||
background-color: $primary;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-value {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
en:
|
|
||||||
params:
|
|
||||||
supplier: Supplier
|
|
||||||
from: From
|
|
||||||
to: To
|
|
||||||
active: Is active
|
|
||||||
visible: Is visible
|
|
||||||
floramondo: Is floramondo
|
|
||||||
salesPersonFk: Buyer
|
|
||||||
categoryFk: Category
|
|
||||||
|
|
||||||
es:
|
|
||||||
params:
|
|
||||||
supplier: Proveedor
|
|
||||||
from: Desde
|
|
||||||
to: Hasta
|
|
||||||
active: Activo
|
|
||||||
visible: Visible
|
|
||||||
floramondo: Floramondo
|
|
||||||
salesPersonFk: Comprador
|
|
||||||
categoryFk: Categoría
|
|
||||||
Plant: Planta natural
|
|
||||||
Flower: Flor fresca
|
|
||||||
Handmade: Hecho a mano
|
|
||||||
Artificial: Artificial
|
|
||||||
Green: Verdes frescos
|
|
||||||
Accessories: Complementos florales
|
|
||||||
Fruit: Fruta
|
|
||||||
</i18n>
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { onMounted, watch, ref, reactive, computed } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { QSeparator, useQuasar } from 'quasar';
|
import { QSeparator, useQuasar } from 'quasar';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
@ -9,72 +9,24 @@ import { toLowerCamel } from 'src/filters';
|
||||||
import routes from 'src/router/modules';
|
import routes from 'src/router/modules';
|
||||||
import LeftMenuItem from './LeftMenuItem.vue';
|
import LeftMenuItem from './LeftMenuItem.vue';
|
||||||
import LeftMenuItemGroup from './LeftMenuItemGroup.vue';
|
import LeftMenuItemGroup from './LeftMenuItemGroup.vue';
|
||||||
import VnInput from './common/VnInput.vue';
|
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const navigation = useNavigationStore();
|
const navigation = useNavigationStore();
|
||||||
const router = useRouter();
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
source: {
|
source: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'main',
|
default: 'main',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const initialized = ref(false);
|
|
||||||
const items = ref([]);
|
|
||||||
const expansionItemElements = reactive({});
|
|
||||||
const pinnedModules = computed(() => {
|
|
||||||
const map = new Map();
|
|
||||||
items.value.forEach((item) => item.isPinned && map.set(item.name, item));
|
|
||||||
return map;
|
|
||||||
});
|
|
||||||
const search = ref(null);
|
|
||||||
|
|
||||||
const filteredItems = computed(() => {
|
|
||||||
if (!search.value) return items.value;
|
|
||||||
const normalizedSearch = normalize(search.value);
|
|
||||||
return items.value.filter((item) => {
|
|
||||||
const locale = normalize(t(item.title));
|
|
||||||
return locale.includes(normalizedSearch);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const filteredPinnedModules = computed(() => {
|
|
||||||
if (!search.value) return pinnedModules.value;
|
|
||||||
const normalizedSearch = search.value
|
|
||||||
.normalize('NFD')
|
|
||||||
.replace(/[\u0300-\u036f]/g, '')
|
|
||||||
.toLowerCase();
|
|
||||||
const map = new Map();
|
|
||||||
for (const [key, pinnedModule] of pinnedModules.value) {
|
|
||||||
const locale = t(pinnedModule.title)
|
|
||||||
.normalize('NFD')
|
|
||||||
.replace(/[\u0300-\u036f]/g, '')
|
|
||||||
.toLowerCase();
|
|
||||||
if (locale.includes(normalizedSearch)) map.set(key, pinnedModule);
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await navigation.fetchPinned();
|
await navigation.fetchPinned();
|
||||||
getRoutes();
|
getRoutes();
|
||||||
initialized.value = true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
|
||||||
() => route.matched,
|
|
||||||
() => {
|
|
||||||
if (!initialized.value) return;
|
|
||||||
items.value = [];
|
|
||||||
getRoutes();
|
|
||||||
},
|
|
||||||
{ deep: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
function findMatches(search, item) {
|
function findMatches(search, item) {
|
||||||
const matches = [];
|
const matches = [];
|
||||||
function findRoute(search, item) {
|
function findRoute(search, item) {
|
||||||
|
@ -93,16 +45,17 @@ function findMatches(search, item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addChildren(module, route, parent) {
|
function addChildren(module, route, parent) {
|
||||||
const menus = route?.meta?.menu ?? route?.menus?.[props.source]; //backwards compatible
|
if (route.menus) {
|
||||||
if (!menus) return;
|
const mainMenus = route.menus[props.source];
|
||||||
|
const matches = findMatches(mainMenus, route);
|
||||||
const matches = findMatches(menus, route);
|
|
||||||
|
|
||||||
for (const child of matches) {
|
for (const child of matches) {
|
||||||
navigation.addMenuItem(module, child, parent);
|
navigation.addMenuItem(module, child, parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const items = ref([]);
|
||||||
function getRoutes() {
|
function getRoutes() {
|
||||||
if (props.source === 'main') {
|
if (props.source === 'main') {
|
||||||
const modules = Object.assign([], navigation.getModules().value);
|
const modules = Object.assign([], navigation.getModules().value);
|
||||||
|
@ -111,9 +64,10 @@ function getRoutes() {
|
||||||
const moduleDef = routes.find(
|
const moduleDef = routes.find(
|
||||||
(route) => toLowerCamel(route.name) === item.module
|
(route) => toLowerCamel(route.name) === item.module
|
||||||
);
|
);
|
||||||
if (!moduleDef) continue;
|
|
||||||
item.children = [];
|
item.children = [];
|
||||||
|
|
||||||
|
if (!moduleDef) continue;
|
||||||
|
|
||||||
addChildren(item.module, moduleDef, item.children);
|
addChildren(item.module, moduleDef, item.children);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,26 +77,16 @@ function getRoutes() {
|
||||||
if (props.source === 'card') {
|
if (props.source === 'card') {
|
||||||
const currentRoute = route.matched[1];
|
const currentRoute = route.matched[1];
|
||||||
const currentModule = toLowerCamel(currentRoute.name);
|
const currentModule = toLowerCamel(currentRoute.name);
|
||||||
let moduleDef = routes.find(
|
const moduleDef = routes.find(
|
||||||
(route) => toLowerCamel(route.name) === currentModule
|
(route) => toLowerCamel(route.name) === currentModule
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!moduleDef) return;
|
if (!moduleDef) return;
|
||||||
if (!moduleDef?.menus) moduleDef = betaGetRoutes();
|
|
||||||
addChildren(currentModule, moduleDef, items.value);
|
addChildren(currentModule, moduleDef, items.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function betaGetRoutes() {
|
|
||||||
let menuRoute;
|
|
||||||
let index = route.matched.length - 1;
|
|
||||||
while (!menuRoute && index > 0) {
|
|
||||||
if (route.matched[index]?.meta?.menu) menuRoute = route.matched[index];
|
|
||||||
index--;
|
|
||||||
}
|
|
||||||
return menuRoute;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function togglePinned(item, event) {
|
async function togglePinned(item, event) {
|
||||||
if (event.defaultPrevented) return;
|
if (event.defaultPrevented) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -164,68 +108,22 @@ async function togglePinned(item, event) {
|
||||||
type: 'positive',
|
type: 'positive',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleItemExpansion = (itemName) => {
|
|
||||||
expansionItemElements[itemName].scrollToLastElement();
|
|
||||||
};
|
|
||||||
|
|
||||||
function normalize(text) {
|
|
||||||
return text
|
|
||||||
.normalize('NFD')
|
|
||||||
.replace(/[\u0300-\u036f]/g, '')
|
|
||||||
.toLowerCase();
|
|
||||||
}
|
|
||||||
const searchModule = () => {
|
|
||||||
const [item] = filteredItems.value;
|
|
||||||
if (item) router.push({ name: item.name });
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<QList padding class="column-max-width">
|
<QList padding class="column-max-width">
|
||||||
<template v-if="$props.source === 'main'">
|
<template v-if="$props.source === 'main'">
|
||||||
<template v-if="$route?.matched[1]?.name === 'Dashboard'">
|
<template v-if="$route?.matched[1]?.name === 'Dashboard'">
|
||||||
<QItem class="q-pb-md">
|
<QItem class="header">
|
||||||
<VnInput
|
<QItemSection avatar>
|
||||||
v-model="search"
|
<QIcon name="view_module" />
|
||||||
:label="t('Search modules')"
|
</QItemSection>
|
||||||
class="full-width"
|
<QItemSection> {{ t('globals.modules') }}</QItemSection>
|
||||||
filled
|
|
||||||
dense
|
|
||||||
autofocus
|
|
||||||
@keyup.enter.stop="searchModule()"
|
|
||||||
/>
|
|
||||||
</QItem>
|
</QItem>
|
||||||
<QSeparator />
|
<QSeparator />
|
||||||
<template v-if="filteredPinnedModules.size && !search">
|
<template v-for="item in items" :key="item.name">
|
||||||
<LeftMenuItem
|
<template v-if="item.children">
|
||||||
v-for="[key, pinnedModule] of filteredPinnedModules"
|
<LeftMenuItem :item="item" group="modules">
|
||||||
:key="key"
|
|
||||||
:item="pinnedModule"
|
|
||||||
group="modules"
|
|
||||||
>
|
|
||||||
<template #side>
|
|
||||||
<QBtn
|
|
||||||
v-if="pinnedModule.isPinned === true"
|
|
||||||
@click="togglePinned(pinnedModule, $event)"
|
|
||||||
icon="remove_circle"
|
|
||||||
size="xs"
|
|
||||||
flat
|
|
||||||
round
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ t('components.leftMenu.removeFromPinned') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</template>
|
|
||||||
</LeftMenuItem>
|
|
||||||
<QSeparator />
|
|
||||||
</template>
|
|
||||||
<template v-for="(item, index) in filteredItems" :key="item.name">
|
|
||||||
<template
|
|
||||||
v-if="search ||item.children && !filteredPinnedModules.has(item.name)"
|
|
||||||
>
|
|
||||||
<LeftMenuItem :item="item" group="modules" :class="search && index === 0 ? 'searched' : ''">
|
|
||||||
<template #side>
|
<template #side>
|
||||||
<QBtn
|
<QBtn
|
||||||
v-if="item.isPinned === true"
|
v-if="item.isPinned === true"
|
||||||
|
@ -308,21 +206,6 @@ const searchModule = () => {
|
||||||
<template v-if="$props.source === 'card'">
|
<template v-if="$props.source === 'card'">
|
||||||
<template v-for="item in items" :key="item.name">
|
<template v-for="item in items" :key="item.name">
|
||||||
<LeftMenuItem v-if="!item.children" :item="item" />
|
<LeftMenuItem v-if="!item.children" :item="item" />
|
||||||
<QList v-else>
|
|
||||||
<QExpansionItem
|
|
||||||
v-ripple
|
|
||||||
clickable
|
|
||||||
:icon="item.icon"
|
|
||||||
:label="t(item.title)"
|
|
||||||
:content-inset-level="0.5"
|
|
||||||
@after-show="handleItemExpansion(item.name)"
|
|
||||||
>
|
|
||||||
<LeftMenuItemGroup
|
|
||||||
:ref="(el) => (expansionItemElements[item.name] = el)"
|
|
||||||
:item="item"
|
|
||||||
/>
|
|
||||||
</QExpansionItem>
|
|
||||||
</QList>
|
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</QList>
|
</QList>
|
||||||
|
@ -340,13 +223,6 @@ const searchModule = () => {
|
||||||
max-width: 256px;
|
max-width: 256px;
|
||||||
}
|
}
|
||||||
.header {
|
.header {
|
||||||
color: var(--vn-label-color);
|
color: #999999;
|
||||||
}
|
|
||||||
.searched{
|
|
||||||
background-color: var(--vn-section-hover-color);
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
Search modules: Buscar módulos
|
|
||||||
</i18n>
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
const { t, te } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
item: {
|
item: {
|
||||||
|
@ -11,41 +11,19 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const itemComputed = computed(() => {
|
const item = computed(() => props.item); // eslint-disable-line vue/no-dupe-keys
|
||||||
const item = JSON.parse(JSON.stringify(props.item));
|
|
||||||
const [, , section] = item.title.split('.');
|
|
||||||
|
|
||||||
if (!te(item.title)) item.title = t(`globals.pageTitles.${section}`);
|
|
||||||
return item;
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<QItem
|
<QItem active-class="text-primary" :to="{ name: item.name }" clickable v-ripple>
|
||||||
active-class="bg-vn-hover"
|
<QItemSection avatar v-if="item.icon">
|
||||||
class="min-height"
|
<QIcon :name="item.icon" />
|
||||||
:to="{ name: itemComputed.name }"
|
|
||||||
clickable
|
|
||||||
v-ripple
|
|
||||||
>
|
|
||||||
<QItemSection avatar v-if="itemComputed.icon">
|
|
||||||
<QIcon :name="itemComputed.icon" />
|
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QItemSection avatar v-if="!itemComputed.icon">
|
<QItemSection avatar v-if="!item.icon">
|
||||||
<QIcon name="disabled_by_default" />
|
<QIcon name="disabled_by_default" />
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QItemSection>
|
<QItemSection>{{ t(item.title) }}</QItemSection>
|
||||||
{{ t(itemComputed.title) }}
|
|
||||||
<QTooltip v-if="item.keyBinding">
|
|
||||||
{{ 'Ctrl + Alt + ' + item?.keyBinding?.toUpperCase() }}
|
|
||||||
</QTooltip>
|
|
||||||
</QItemSection>
|
|
||||||
<QItemSection side>
|
<QItemSection side>
|
||||||
<slot name="side" :item="itemComputed" />
|
<slot name="side" :item="item" />
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
</template>
|
</template>
|
||||||
<style lang="scss" scoped>
|
|
||||||
.q-item {
|
|
||||||
min-height: 5vh;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref } from 'vue';
|
import { computed } from 'vue';
|
||||||
import LeftMenuItem from './LeftMenuItem.vue';
|
import LeftMenuItem from './LeftMenuItem.vue';
|
||||||
import { elementIsVisibleInViewport } from 'src/composables/elementIsVisibleInViewport';
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
item: {
|
item: {
|
||||||
|
@ -14,27 +13,10 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const groupEnd = ref(null);
|
|
||||||
|
|
||||||
const scrollToLastElement = () => {
|
|
||||||
if (groupEnd.value && !elementIsVisibleInViewport(groupEnd.value)) {
|
|
||||||
groupEnd.value.scrollIntoView({
|
|
||||||
behavior: 'smooth',
|
|
||||||
block: 'end',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const item = computed(() => props.item); // eslint-disable-line vue/no-dupe-keys
|
const item = computed(() => props.item); // eslint-disable-line vue/no-dupe-keys
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
scrollToLastElement,
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<template v-for="section in item.children" :key="section.name">
|
<template v-for="section in item.children" :key="section.name">
|
||||||
<LeftMenuItem :item="section" />
|
<LeftMenuItem :item="section" />
|
||||||
</template>
|
</template>
|
||||||
<div ref="groupEnd" />
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,33 +1,35 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { useSession } from 'src/composables/useSession';
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { useStateQueryStore } from 'src/stores/useStateQueryStore';
|
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import PinnedModules from './PinnedModules.vue';
|
import PinnedModules from './PinnedModules.vue';
|
||||||
import UserPanel from 'components/UserPanel.vue';
|
import UserPanel from 'components/UserPanel.vue';
|
||||||
import VnBreadcrumbs from './common/VnBreadcrumbs.vue';
|
import VnBreadcrumbs from './common/VnBreadcrumbs.vue';
|
||||||
import VnAvatar from './ui/VnAvatar.vue';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const session = useSession();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const stateQuery = useStateQueryStore();
|
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const user = state.getUser();
|
const user = state.getUser();
|
||||||
|
const token = session.getToken();
|
||||||
const appName = 'Lilium';
|
const appName = 'Lilium';
|
||||||
const pinnedModulesRef = ref();
|
|
||||||
|
|
||||||
onMounted(() => stateStore.setMounted());
|
onMounted(() => stateStore.setMounted());
|
||||||
const refresh = () => window.location.reload();
|
|
||||||
|
const pinnedModulesRef = ref();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<QHeader color="white" elevated>
|
<QHeader class="bg-dark" color="white" elevated>
|
||||||
<QToolbar class="q-py-sm q-px-md">
|
<QToolbar class="q-py-sm q-px-md">
|
||||||
<QBtn
|
<QBtn
|
||||||
@click="stateStore.toggleLeftDrawer()"
|
@click="stateStore.toggleLeftDrawer()"
|
||||||
icon="dock_to_right"
|
icon="menu"
|
||||||
|
class="q-mr-sm"
|
||||||
round
|
round
|
||||||
dense
|
dense
|
||||||
flat
|
flat
|
||||||
|
@ -37,7 +39,13 @@ const refresh = () => window.location.reload();
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QBtn>
|
</QBtn>
|
||||||
<RouterLink to="/">
|
<RouterLink to="/">
|
||||||
<QBtn color="primary" flat round v-if="!quasar.platform.is.mobile">
|
<QBtn
|
||||||
|
class="q-ml-xs"
|
||||||
|
color="primary"
|
||||||
|
flat
|
||||||
|
round
|
||||||
|
v-if="!quasar.platform.is.mobile"
|
||||||
|
>
|
||||||
<QAvatar square size="md">
|
<QAvatar square size="md">
|
||||||
<QImg
|
<QImg
|
||||||
src="~/assets/salix_icon.svg"
|
src="~/assets/salix_icon.svg"
|
||||||
|
@ -51,27 +59,21 @@ const refresh = () => window.location.reload();
|
||||||
</QBtn>
|
</QBtn>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<VnBreadcrumbs v-if="$q.screen.gt.sm" />
|
<VnBreadcrumbs v-if="$q.screen.gt.sm" />
|
||||||
<QSpinner
|
|
||||||
color="primary"
|
|
||||||
class="q-ml-md"
|
|
||||||
:class="{
|
|
||||||
'no-visible': !stateQuery.isLoading().value,
|
|
||||||
}"
|
|
||||||
size="xs"
|
|
||||||
data-cy="loading-spinner"
|
|
||||||
/>
|
|
||||||
<QSpace />
|
<QSpace />
|
||||||
<div id="searchbar" class="searchbar"></div>
|
<div id="searchbar" class="searchbar"></div>
|
||||||
<QSpace />
|
<QSpace />
|
||||||
<div class="q-pl-sm q-gutter-sm row items-center no-wrap">
|
<div class="q-pl-sm q-gutter-sm row items-center no-wrap">
|
||||||
<div id="actions-prepend"></div>
|
<div id="actions-prepend"></div>
|
||||||
<QIcon
|
<QBtn
|
||||||
name="refresh"
|
flat
|
||||||
size="md"
|
v-if="!quasar.platform.is.mobile"
|
||||||
color="red"
|
@click="pinnedModulesRef.redirect($route.params.id)"
|
||||||
v-if="state.get('error')"
|
icon="more_up"
|
||||||
@click="refresh"
|
>
|
||||||
/>
|
<QTooltip>
|
||||||
|
{{ t('Go to Salix') }}
|
||||||
|
</QTooltip>
|
||||||
|
</QBtn>
|
||||||
<QBtn
|
<QBtn
|
||||||
:class="{ 'q-pa-none': quasar.platform.is.mobile }"
|
:class="{ 'q-pa-none': quasar.platform.is.mobile }"
|
||||||
id="pinnedModules"
|
id="pinnedModules"
|
||||||
|
@ -85,13 +87,21 @@ const refresh = () => window.location.reload();
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
<PinnedModules ref="pinnedModulesRef" />
|
<PinnedModules ref="pinnedModulesRef" />
|
||||||
</QBtn>
|
</QBtn>
|
||||||
<QBtn class="q-pa-none" rounded dense flat no-wrap id="user">
|
<QBtn
|
||||||
<VnAvatar
|
:class="{ 'q-pa-none': quasar.platform.is.mobile }"
|
||||||
:worker-id="user.id"
|
rounded
|
||||||
:title="user.name"
|
dense
|
||||||
size="lg"
|
flat
|
||||||
color="transparent"
|
no-wrap
|
||||||
/>
|
id="user"
|
||||||
|
>
|
||||||
|
<QAvatar size="lg">
|
||||||
|
<QImg
|
||||||
|
:src="`/api/Images/user/160x160/${user.id}/download?access_token=${token}`"
|
||||||
|
spinner-color="primary"
|
||||||
|
>
|
||||||
|
</QImg>
|
||||||
|
</QAvatar>
|
||||||
<QTooltip bottom>
|
<QTooltip bottom>
|
||||||
{{ t('globals.userPanel') }}
|
{{ t('globals.userPanel') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
|
@ -103,11 +113,15 @@ const refresh = () => window.location.reload();
|
||||||
<VnBreadcrumbs v-if="$q.screen.lt.md" class="q-ml-md" />
|
<VnBreadcrumbs v-if="$q.screen.lt.md" class="q-ml-md" />
|
||||||
</QHeader>
|
</QHeader>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.searchbar {
|
.searchbar {
|
||||||
width: max-content;
|
width: max-content;
|
||||||
}
|
}
|
||||||
.q-header {
|
|
||||||
background-color: var(--vn-section-color);
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
<i18n>
|
||||||
|
en:
|
||||||
|
Go to Salix: Go to Salix
|
||||||
|
es:
|
||||||
|
Go to Salix: Ir a Salix
|
||||||
|
</i18n>
|
||||||
|
|
|
@ -1,170 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref, reactive } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
import { useDialogPluginComponent } from 'quasar';
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
|
||||||
import FormPopup from './FormPopup.vue';
|
|
||||||
import axios from 'axios';
|
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
invoiceOutData: {
|
|
||||||
type: Object,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const { dialogRef } = useDialogPluginComponent();
|
|
||||||
const { t } = useI18n();
|
|
||||||
const router = useRouter();
|
|
||||||
const { notify } = useNotify();
|
|
||||||
|
|
||||||
const rectificativeTypeOptions = ref([]);
|
|
||||||
const siiTypeInvoiceOutsOptions = ref([]);
|
|
||||||
const invoiceParams = reactive({
|
|
||||||
id: $props.invoiceOutData?.id,
|
|
||||||
inheritWarehouse: true,
|
|
||||||
});
|
|
||||||
const invoiceCorrectionTypesOptions = ref([]);
|
|
||||||
|
|
||||||
const refund = async () => {
|
|
||||||
const params = {
|
|
||||||
id: invoiceParams.id,
|
|
||||||
withWarehouse: invoiceParams.inheritWarehouse,
|
|
||||||
cplusRectificationTypeFk: invoiceParams.cplusRectificationTypeFk,
|
|
||||||
siiTypeInvoiceOutFk: invoiceParams.siiTypeInvoiceOutFk,
|
|
||||||
invoiceCorrectionTypeFk: invoiceParams.invoiceCorrectionTypeFk,
|
|
||||||
};
|
|
||||||
|
|
||||||
const { data } = await axios.post('InvoiceOuts/refundAndInvoice', params);
|
|
||||||
notify(t('Refunded invoice'), 'positive');
|
|
||||||
const [id] = data?.refundId || [];
|
|
||||||
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<FetchData
|
|
||||||
url="CplusRectificationTypes"
|
|
||||||
:filter="{ order: 'description' }"
|
|
||||||
@on-fetch="
|
|
||||||
(data) => (
|
|
||||||
(rectificativeTypeOptions = data),
|
|
||||||
(invoiceParams.cplusRectificationTypeFk = data.filter(
|
|
||||||
(type) => type.description == 'I – Por diferencias'
|
|
||||||
)[0].id)
|
|
||||||
)
|
|
||||||
"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
url="SiiTypeInvoiceOuts"
|
|
||||||
:filter="{ where: { code: { like: 'R%' } } }"
|
|
||||||
@on-fetch="
|
|
||||||
(data) => (
|
|
||||||
(siiTypeInvoiceOutsOptions = data),
|
|
||||||
(invoiceParams.siiTypeInvoiceOutFk = data.filter(
|
|
||||||
(type) => type.code == 'R4'
|
|
||||||
)[0].id)
|
|
||||||
)
|
|
||||||
"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
url="InvoiceCorrectionTypes"
|
|
||||||
@on-fetch="(data) => (invoiceCorrectionTypesOptions = data)"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
|
|
||||||
<QDialog ref="dialogRef">
|
|
||||||
<FormPopup
|
|
||||||
@on-submit="refund()"
|
|
||||||
:custom-submit-button-label="t('Accept')"
|
|
||||||
:default-cancel-button="false"
|
|
||||||
>
|
|
||||||
<template #form-inputs>
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Rectificative type')"
|
|
||||||
:options="rectificativeTypeOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="description"
|
|
||||||
option-value="id"
|
|
||||||
v-model="invoiceParams.cplusRectificationTypeFk"
|
|
||||||
:required="true"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Class')"
|
|
||||||
:options="siiTypeInvoiceOutsOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="description"
|
|
||||||
option-value="id"
|
|
||||||
v-model="invoiceParams.siiTypeInvoiceOutFk"
|
|
||||||
:required="true"
|
|
||||||
>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem v-bind="scope.itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>
|
|
||||||
{{ scope.opt?.code }} -
|
|
||||||
{{ scope.opt?.description }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
</VnRow>
|
|
||||||
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Type')"
|
|
||||||
:options="invoiceCorrectionTypesOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="description"
|
|
||||||
option-value="id"
|
|
||||||
v-model="invoiceParams.invoiceCorrectionTypeFk"
|
|
||||||
:required="true"
|
|
||||||
/> </VnRow
|
|
||||||
><VnRow>
|
|
||||||
<div>
|
|
||||||
<QCheckbox
|
|
||||||
:label="t('Inherit warehouse')"
|
|
||||||
v-model="invoiceParams.inheritWarehouse"
|
|
||||||
/>
|
|
||||||
<QIcon name="info" class="cursor-info q-ml-sm" size="sm">
|
|
||||||
<QTooltip>{{ t('Inherit warehouse tooltip') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</div>
|
|
||||||
</VnRow>
|
|
||||||
</template>
|
|
||||||
</FormPopup>
|
|
||||||
</QDialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
en:
|
|
||||||
Refund invoice: Refund invoice
|
|
||||||
Rectificative type: Rectificative type
|
|
||||||
Class: Class
|
|
||||||
Type: Type
|
|
||||||
Refunded invoice: Refunded invoice
|
|
||||||
Inherit warehouse: Inherit the warehouse
|
|
||||||
Inherit warehouse tooltip: Select this option to inherit the warehouse when refunding the invoice
|
|
||||||
Accept: Accept
|
|
||||||
Error refunding invoice: Error refunding invoice
|
|
||||||
es:
|
|
||||||
Refund invoice: Abonar factura
|
|
||||||
Rectificative type: Tipo rectificativa
|
|
||||||
Class: Clase
|
|
||||||
Type: Tipo
|
|
||||||
Refunded invoice: Factura abonada
|
|
||||||
Inherit warehouse: Heredar el almacén
|
|
||||||
Inherit warehouse tooltip: Seleccione esta opción para heredar el almacén al abonar la factura.
|
|
||||||
Accept: Aceptar
|
|
||||||
Error refunding invoice: Error abonando factura
|
|
||||||
</i18n>
|
|
|
@ -1,82 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { reactive, ref } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import FormModelPopup from './FormModelPopup.vue';
|
|
||||||
|
|
||||||
const emit = defineEmits(['onDataSaved']);
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
itemFk: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
warehouseFk: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
const regularizeFormData = reactive({
|
|
||||||
itemFk: Number(props.itemFk),
|
|
||||||
warehouseFk: props.warehouseFk,
|
|
||||||
quantity: null,
|
|
||||||
});
|
|
||||||
|
|
||||||
const warehousesOptions = ref([]);
|
|
||||||
|
|
||||||
const onDataSaved = (data) => {
|
|
||||||
emit('onDataSaved', data);
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<FetchData
|
|
||||||
url="Warehouses"
|
|
||||||
@on-fetch="(data) => (warehousesOptions = data)"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FormModelPopup
|
|
||||||
url-create="Items/regularize"
|
|
||||||
model="Items"
|
|
||||||
:title="t('item.regularizeStock')"
|
|
||||||
:form-initial-data="regularizeFormData"
|
|
||||||
@on-data-saved="onDataSaved($event)"
|
|
||||||
>
|
|
||||||
<template #form-inputs="{ data }">
|
|
||||||
<VnRow>
|
|
||||||
<QInput
|
|
||||||
:label="t('Type the visible quantity')"
|
|
||||||
v-model.number="data.quantity"
|
|
||||||
type="number"
|
|
||||||
autofocus
|
|
||||||
data-cy="regularizeStockInput"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow>
|
|
||||||
<div class="col">
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Warehouse')"
|
|
||||||
v-model.number="data.warehouseFk"
|
|
||||||
:options="warehousesOptions"
|
|
||||||
option-value="id"
|
|
||||||
option-label="name"
|
|
||||||
hide-selected
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</VnRow>
|
|
||||||
</template>
|
|
||||||
</FormModelPopup>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
Warehouse: Almacén
|
|
||||||
Type the visible quantity: Introduce la cantidad visible
|
|
||||||
Regularize stock: Regularizar stock
|
|
||||||
</i18n>
|
|
|
@ -1,40 +0,0 @@
|
||||||
<script setup>
|
|
||||||
defineProps({ row: { type: Object, required: true } });
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<span>
|
|
||||||
<QIcon
|
|
||||||
v-if="row.isTaxDataChecked === 0"
|
|
||||||
name="vn:no036"
|
|
||||||
color="primary"
|
|
||||||
size="xs"
|
|
||||||
>
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.noVerifiedData') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.hasTicketRequest" name="vn:buyrequest" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.purchaseRequest') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.itemShortage" name="vn:unavailable" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.notVisible') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.isFreezed" name="vn:frozen" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.clientFrozen') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon
|
|
||||||
v-if="row.risk"
|
|
||||||
name="vn:risk"
|
|
||||||
:color="row.hasHighRisk ? 'negative' : 'primary'"
|
|
||||||
size="xs"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ $t('salesTicketsTable.risk') }}: {{ row.risk - row.credit }}
|
|
||||||
</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.hasComponentLack" name="vn:components" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.componentLack') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.isTooLittle" name="vn:isTooLittle" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.tooLittle') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
|
@ -1,220 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref, reactive } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
import { useQuasar, useDialogPluginComponent } from 'quasar';
|
|
||||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
|
||||||
import FormPopup from './FormPopup.vue';
|
|
||||||
import axios from 'axios';
|
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
invoiceOutData: {
|
|
||||||
type: Object,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const { dialogRef } = useDialogPluginComponent();
|
|
||||||
const quasar = useQuasar();
|
|
||||||
const { t } = useI18n();
|
|
||||||
const router = useRouter();
|
|
||||||
const { notify } = useNotify();
|
|
||||||
|
|
||||||
const rectificativeTypeOptions = ref([]);
|
|
||||||
const siiTypeInvoiceOutsOptions = ref([]);
|
|
||||||
const checked = ref(true);
|
|
||||||
const transferInvoiceParams = reactive({
|
|
||||||
id: $props.invoiceOutData?.id,
|
|
||||||
});
|
|
||||||
const invoiceCorrectionTypesOptions = ref([]);
|
|
||||||
|
|
||||||
const selectedClient = (client) => {
|
|
||||||
transferInvoiceParams.selectedClientData = client;
|
|
||||||
};
|
|
||||||
|
|
||||||
const makeInvoice = async () => {
|
|
||||||
const hasToInvoiceByAddress =
|
|
||||||
transferInvoiceParams.selectedClientData.hasToInvoiceByAddress;
|
|
||||||
|
|
||||||
const params = {
|
|
||||||
id: transferInvoiceParams.id,
|
|
||||||
cplusRectificationTypeFk: transferInvoiceParams.cplusRectificationTypeFk,
|
|
||||||
siiTypeInvoiceOutFk: transferInvoiceParams.siiTypeInvoiceOutFk,
|
|
||||||
invoiceCorrectionTypeFk: transferInvoiceParams.invoiceCorrectionTypeFk,
|
|
||||||
newClientFk: transferInvoiceParams.newClientFk,
|
|
||||||
makeInvoice: checked.value,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (checked.value && hasToInvoiceByAddress) {
|
|
||||||
const response = await new Promise((resolve) => {
|
|
||||||
quasar
|
|
||||||
.dialog({
|
|
||||||
component: VnConfirm,
|
|
||||||
componentProps: {
|
|
||||||
title: t('Bill destination client'),
|
|
||||||
message: t('transferInvoiceInfo'),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.onOk(() => {
|
|
||||||
resolve(true);
|
|
||||||
})
|
|
||||||
.onCancel(() => {
|
|
||||||
resolve(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
if (!response) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const { data } = await axios.post('InvoiceOuts/transfer', params);
|
|
||||||
notify(t('Transferred invoice'), 'positive');
|
|
||||||
const id = data?.[0];
|
|
||||||
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<FetchData
|
|
||||||
url="CplusRectificationTypes"
|
|
||||||
:filter="{ order: 'description' }"
|
|
||||||
@on-fetch="
|
|
||||||
(data) => (
|
|
||||||
(rectificativeTypeOptions = data),
|
|
||||||
(transferInvoiceParams.cplusRectificationTypeFk = data.filter(
|
|
||||||
(type) => type.description == 'I – Por diferencias'
|
|
||||||
)[0].id)
|
|
||||||
)
|
|
||||||
"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
url="SiiTypeInvoiceOuts"
|
|
||||||
:filter="{ where: { code: { like: 'R%' } } }"
|
|
||||||
@on-fetch="
|
|
||||||
(data) => (
|
|
||||||
(siiTypeInvoiceOutsOptions = data),
|
|
||||||
(transferInvoiceParams.siiTypeInvoiceOutFk = data.filter(
|
|
||||||
(type) => type.code == 'R4'
|
|
||||||
)[0].id)
|
|
||||||
)
|
|
||||||
"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
url="InvoiceCorrectionTypes"
|
|
||||||
@on-fetch="(data) => (invoiceCorrectionTypesOptions = data)"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<QDialog ref="dialogRef">
|
|
||||||
<FormPopup
|
|
||||||
@on-submit="makeInvoice()"
|
|
||||||
:title="t('Transfer invoice')"
|
|
||||||
:custom-submit-button-label="t('Transfer client')"
|
|
||||||
:default-cancel-button="false"
|
|
||||||
>
|
|
||||||
<template #form-inputs>
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Client')"
|
|
||||||
:options="clientsOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
v-model="transferInvoiceParams.newClientFk"
|
|
||||||
:required="true"
|
|
||||||
url="Clients"
|
|
||||||
:fields="['id', 'name', 'hasToInvoiceByAddress']"
|
|
||||||
auto-load
|
|
||||||
>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem
|
|
||||||
v-bind="scope.itemProps"
|
|
||||||
@click="selectedClient(scope.opt)"
|
|
||||||
>
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>
|
|
||||||
#{{ scope.opt?.id }} - {{ scope.opt?.name }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Rectificative type')"
|
|
||||||
:options="rectificativeTypeOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="description"
|
|
||||||
option-value="id"
|
|
||||||
v-model="transferInvoiceParams.cplusRectificationTypeFk"
|
|
||||||
:required="true"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Class')"
|
|
||||||
:options="siiTypeInvoiceOutsOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="description"
|
|
||||||
option-value="id"
|
|
||||||
v-model="transferInvoiceParams.siiTypeInvoiceOutFk"
|
|
||||||
:required="true"
|
|
||||||
>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem v-bind="scope.itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>
|
|
||||||
{{ scope.opt?.code }} -
|
|
||||||
{{ scope.opt?.description }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Type')"
|
|
||||||
:options="invoiceCorrectionTypesOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="description"
|
|
||||||
option-value="id"
|
|
||||||
v-model="transferInvoiceParams.invoiceCorrectionTypeFk"
|
|
||||||
:required="true"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow>
|
|
||||||
<div>
|
|
||||||
<QCheckbox
|
|
||||||
:label="t('Bill destination client')"
|
|
||||||
v-model="checked"
|
|
||||||
/>
|
|
||||||
<QIcon name="info" class="cursor-info q-ml-sm" size="sm">
|
|
||||||
<QTooltip>{{ t('transferInvoiceInfo') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</div>
|
|
||||||
</VnRow>
|
|
||||||
</template>
|
|
||||||
</FormPopup>
|
|
||||||
</QDialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
en:
|
|
||||||
checkInfo: New tickets from the destination customer will be generated in the consignee by default.
|
|
||||||
transferInvoiceInfo: Destination customer is marked to bill in the consignee
|
|
||||||
confirmTransferInvoice: The destination customer has selected to bill in the consignee, do you want to continue?
|
|
||||||
es:
|
|
||||||
Transfer invoice: Transferir factura
|
|
||||||
Transfer client: Transferir cliente
|
|
||||||
Client: Cliente
|
|
||||||
Rectificative type: Tipo rectificativa
|
|
||||||
Class: Clase
|
|
||||||
Type: Tipo
|
|
||||||
Transferred invoice: Factura transferida
|
|
||||||
Bill destination client: Facturar cliente destino
|
|
||||||
transferInvoiceInfo: Los nuevos tickets del cliente destino, serán generados en el consignatario por defecto.
|
|
||||||
confirmTransferInvoice: El cliente destino tiene marcado facturar por consignatario, desea continuar?
|
|
||||||
</i18n>
|
|
|
@ -1,29 +1,17 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import quasarLang from 'src/utils/quasarLang';
|
import { onMounted, computed } from 'vue';
|
||||||
|
import { Dark, Quasar } from 'quasar';
|
||||||
import { onMounted, computed, ref } from 'vue';
|
|
||||||
|
|
||||||
import { Dark } from 'quasar';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
import { useSession } from 'src/composables/useSession';
|
import { useSession } from 'src/composables/useSession';
|
||||||
import { localeEquivalence } from 'src/i18n/index';
|
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import { useClipboard } from 'src/composables/useClipboard';
|
|
||||||
import { useRole } from 'src/composables/useRole';
|
|
||||||
import VnAvatar from './ui/VnAvatar.vue';
|
|
||||||
import useNotify from 'src/composables/useNotify';
|
|
||||||
|
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const session = useSession();
|
const session = useSession();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { t, locale } = useI18n();
|
const { t, locale } = useI18n();
|
||||||
const { copyText } = useClipboard();
|
|
||||||
const { notify } = useNotify();
|
|
||||||
|
|
||||||
const userLocale = computed({
|
const userLocale = computed({
|
||||||
get() {
|
get() {
|
||||||
|
@ -32,9 +20,18 @@ const userLocale = computed({
|
||||||
set(value) {
|
set(value) {
|
||||||
locale.value = value;
|
locale.value = value;
|
||||||
|
|
||||||
value = localeEquivalence[value] ?? value;
|
if (value === 'en') value = 'en-GB';
|
||||||
|
|
||||||
quasarLang(value);
|
// FIXME: Dynamic imports from absolute paths are not compatible with vite:
|
||||||
|
// https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations
|
||||||
|
try {
|
||||||
|
const langList = import.meta.glob('../../node_modules/quasar/lang/*.mjs');
|
||||||
|
langList[`../../node_modules/quasar/lang/${value}.mjs`]().then((lang) => {
|
||||||
|
Quasar.lang.set(lang.default);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
//
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -48,10 +45,7 @@ const darkMode = computed({
|
||||||
});
|
});
|
||||||
|
|
||||||
const user = state.getUser();
|
const user = state.getUser();
|
||||||
const warehousesData = ref();
|
const token = session.getToken();
|
||||||
const companiesData = ref();
|
|
||||||
const accountBankData = ref();
|
|
||||||
const isEmployee = computed(() => useRole().isEmployee());
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
updatePreferences();
|
updatePreferences();
|
||||||
|
@ -69,87 +63,31 @@ function updatePreferences() {
|
||||||
|
|
||||||
async function saveDarkMode(value) {
|
async function saveDarkMode(value) {
|
||||||
const query = `/UserConfigs/${user.value.id}`;
|
const query = `/UserConfigs/${user.value.id}`;
|
||||||
try {
|
|
||||||
await axios.patch(query, {
|
await axios.patch(query, {
|
||||||
darkMode: value,
|
darkMode: value,
|
||||||
});
|
});
|
||||||
user.value.darkMode = value;
|
user.value.darkMode = value;
|
||||||
onDataSaved();
|
|
||||||
} catch (error) {
|
|
||||||
onDataError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveLanguage(value) {
|
async function saveLanguage(value) {
|
||||||
const query = `/VnUsers/${user.value.id}`;
|
const query = `/VnUsers/${user.value.id}`;
|
||||||
try {
|
await axios.patch(query, {
|
||||||
await axios.patch(query, { lang: value });
|
lang: value,
|
||||||
|
});
|
||||||
user.value.lang = value;
|
user.value.lang = value;
|
||||||
useState().setUser(user.value);
|
|
||||||
onDataSaved();
|
|
||||||
} catch (error) {
|
|
||||||
onDataError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function logout() {
|
function logout() {
|
||||||
session.destroy();
|
session.destroy();
|
||||||
router.push('/login');
|
router.push('/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyUserToken() {
|
|
||||||
copyText(session.getToken(), { label: 'components.userPanel.copyToken' });
|
|
||||||
}
|
|
||||||
|
|
||||||
function localUserData() {
|
|
||||||
state.setUser(user.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveUserData(param, value) {
|
|
||||||
try {
|
|
||||||
await axios.post('UserConfigs/setUserConfig', { [param]: value });
|
|
||||||
localUserData();
|
|
||||||
onDataSaved();
|
|
||||||
} catch (error) {
|
|
||||||
onDataError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const onDataSaved = () => {
|
|
||||||
notify('globals.dataSaved', 'positive');
|
|
||||||
};
|
|
||||||
|
|
||||||
const onDataError = () => {
|
|
||||||
notify('errors.updateUserConfig', 'negative');
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<QMenu anchor="bottom left">
|
||||||
url="Warehouses"
|
|
||||||
order="name"
|
|
||||||
@on-fetch="(data) => (warehousesData = data)"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
v-if="isEmployee"
|
|
||||||
url="Companies"
|
|
||||||
order="name"
|
|
||||||
@on-fetch="(data) => (companiesData = data)"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
v-if="isEmployee"
|
|
||||||
url="Accountings"
|
|
||||||
order="name"
|
|
||||||
@on-fetch="(data) => (accountBankData = data)"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<QMenu anchor="bottom left" class="bg-vn-section-color">
|
|
||||||
<div class="row no-wrap q-pa-md">
|
<div class="row no-wrap q-pa-md">
|
||||||
<div class="col column">
|
<div class="column panel">
|
||||||
<div class="text-h6 q-ma-sm q-mb-none">
|
<div class="text-h6 q-mb-md">
|
||||||
{{ t('components.userPanel.settings') }}
|
{{ t('components.userPanel.settings') }}
|
||||||
</div>
|
</div>
|
||||||
<QToggle
|
<QToggle
|
||||||
|
@ -157,7 +95,7 @@ const onDataError = () => {
|
||||||
@update:model-value="saveLanguage"
|
@update:model-value="saveLanguage"
|
||||||
:label="t(`globals.lang['${userLocale}']`)"
|
:label="t(`globals.lang['${userLocale}']`)"
|
||||||
icon="public"
|
icon="public"
|
||||||
color="primary"
|
color="orange"
|
||||||
false-value="es"
|
false-value="es"
|
||||||
true-value="en"
|
true-value="en"
|
||||||
/>
|
/>
|
||||||
|
@ -166,128 +104,43 @@ const onDataError = () => {
|
||||||
@update:model-value="saveDarkMode"
|
@update:model-value="saveDarkMode"
|
||||||
:label="t(`globals.darkMode`)"
|
:label="t(`globals.darkMode`)"
|
||||||
checked-icon="dark_mode"
|
checked-icon="dark_mode"
|
||||||
color="primary"
|
color="orange"
|
||||||
unchecked-icon="light_mode"
|
unchecked-icon="light_mode"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<QSeparator vertical inset class="q-mx-lg" />
|
<QSeparator vertical inset class="q-mx-lg" />
|
||||||
|
|
||||||
<div class="col column items-center q-mb-sm">
|
<div class="column items-center panel">
|
||||||
<VnAvatar
|
<QAvatar size="80px">
|
||||||
:worker-id="user.id"
|
<QImg
|
||||||
:title="user.name"
|
:src="`/api/Images/user/160x160/${user.id}/download?access_token=${token}`"
|
||||||
size="xxl"
|
spinner-color="white"
|
||||||
color="transparent"
|
|
||||||
/>
|
|
||||||
<QBtn
|
|
||||||
v-if="isEmployee"
|
|
||||||
class="q-mt-sm q-px-md"
|
|
||||||
:to="`/worker/${user.id}`"
|
|
||||||
color="primary"
|
|
||||||
:label="t('globals.myAccount')"
|
|
||||||
dense
|
|
||||||
/>
|
/>
|
||||||
|
</QAvatar>
|
||||||
|
|
||||||
<div class="text-subtitle1 q-mt-md">
|
<div class="text-subtitle1 q-mt-md">
|
||||||
<strong>{{ user.nickname }}</strong>
|
<strong>{{ user.nickname }}</strong>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div class="text-subtitle3 text-grey-7 q-mb-xs">@{{ user.name }}</div>
|
||||||
class="text-subtitle3 text-grey-7 q-mb-xs copyText"
|
|
||||||
@click="copyUserToken()"
|
|
||||||
>
|
|
||||||
@{{ user.name }}
|
|
||||||
</div>
|
|
||||||
<QBtn
|
<QBtn
|
||||||
id="logout"
|
id="logout"
|
||||||
color="primary"
|
color="orange"
|
||||||
flat
|
flat
|
||||||
:label="t('globals.logOut')"
|
:label="t('globals.logOut')"
|
||||||
size="sm"
|
size="sm"
|
||||||
icon="logout"
|
icon="logout"
|
||||||
@click="logout()"
|
@click="logout()"
|
||||||
v-close-popup
|
v-close-popup
|
||||||
dense
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<QSeparator inset class="q-mx-lg" />
|
|
||||||
<div class="col q-gutter-xs q-pa-md">
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('components.userPanel.localWarehouse')"
|
|
||||||
v-model="user.localWarehouseFk"
|
|
||||||
:options="warehousesData"
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
input-debounce="0"
|
|
||||||
hide-selected
|
|
||||||
@update:model-value="localUserData"
|
|
||||||
/>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('components.userPanel.localBank')"
|
|
||||||
v-model="user.localBankFk"
|
|
||||||
:options="accountBankData"
|
|
||||||
option-label="bank"
|
|
||||||
option-value="id"
|
|
||||||
input-debounce="0"
|
|
||||||
hide-selected
|
|
||||||
@update:model-value="localUserData"
|
|
||||||
>
|
|
||||||
<template #option="{ itemProps, opt }">
|
|
||||||
<QItem v-bind="itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>
|
|
||||||
{{ `${opt.id}: ${opt.bank}` }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('components.userPanel.localCompany')"
|
|
||||||
hide-selected
|
|
||||||
v-model="user.localCompanyFk"
|
|
||||||
:options="companiesData"
|
|
||||||
option-label="code"
|
|
||||||
option-value="id"
|
|
||||||
input-debounce="0"
|
|
||||||
@update:model-value="localUserData"
|
|
||||||
/>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('components.userPanel.userWarehouse')"
|
|
||||||
hide-selected
|
|
||||||
v-model="user.warehouseFk"
|
|
||||||
:options="warehousesData"
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
input-debounce="0"
|
|
||||||
@update:model-value="(v) => saveUserData('warehouseFk', v)"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('components.userPanel.userCompany')"
|
|
||||||
hide-selected
|
|
||||||
v-model="user.companyFk"
|
|
||||||
:options="companiesData"
|
|
||||||
option-label="code"
|
|
||||||
option-value="id"
|
|
||||||
style="flex: 0"
|
|
||||||
dense
|
|
||||||
input-debounce="0"
|
|
||||||
@update:model-value="(v) => saveUserData('companyFk', v)"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
</div>
|
|
||||||
</QMenu>
|
</QMenu>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.copyText {
|
.panel {
|
||||||
&:hover {
|
width: 150px;
|
||||||
cursor: alias;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,97 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref, watch } from 'vue';
|
|
||||||
import { useValidator } from 'src/composables/useValidator';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
import VnSelectDialog from 'components/common/VnSelectDialog.vue';
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import CreateNewProvinceForm from './CreateNewProvinceForm.vue';
|
|
||||||
|
|
||||||
const emit = defineEmits(['onProvinceCreated', 'onProvinceFetched', 'update:options']);
|
|
||||||
const $props = defineProps({
|
|
||||||
countryFk: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
provinceSelected: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const provinceFk = defineModel({ type: Number, default: null });
|
|
||||||
|
|
||||||
const { validate } = useValidator();
|
|
||||||
const { t } = useI18n();
|
|
||||||
const filter = ref({
|
|
||||||
include: { relation: 'country' },
|
|
||||||
where: {
|
|
||||||
countryFk: $props.countryFk,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const provincesOptions = ref($props.provinces);
|
|
||||||
const provincesFetchDataRef = ref();
|
|
||||||
provinceFk.value = $props.provinceSelected;
|
|
||||||
if (!$props.countryFk) {
|
|
||||||
filter.value.where = {};
|
|
||||||
}
|
|
||||||
async function onProvinceCreated(_, data) {
|
|
||||||
await provincesFetchDataRef.value.fetch({ where: { countryFk: $props.countryFk } });
|
|
||||||
provinceFk.value = data.id;
|
|
||||||
emit('onProvinceCreated', data);
|
|
||||||
}
|
|
||||||
async function handleProvinces(data) {
|
|
||||||
provincesOptions.value = data;
|
|
||||||
emit('update:options', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => $props.countryFk,
|
|
||||||
async () => {
|
|
||||||
if ($props.countryFk) {
|
|
||||||
filter.value.where.countryFk = $props.countryFk;
|
|
||||||
} else filter.value.where = {};
|
|
||||||
await provincesFetchDataRef.value.fetch({});
|
|
||||||
emit('onProvinceFetched', provincesOptions.value);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<FetchData
|
|
||||||
ref="provincesFetchDataRef"
|
|
||||||
:filter="filter"
|
|
||||||
@on-fetch="handleProvinces"
|
|
||||||
url="Provinces"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<VnSelectDialog
|
|
||||||
data-cy="locationProvince"
|
|
||||||
:label="t('Province')"
|
|
||||||
:options="provincesOptions"
|
|
||||||
:tooltip="t('Create province')"
|
|
||||||
hide-selected
|
|
||||||
v-model="provinceFk"
|
|
||||||
:rules="validate && validate('postcode.provinceFk')"
|
|
||||||
:acls="[{ model: 'Province', props: '*', accessType: 'WRITE' }]"
|
|
||||||
>
|
|
||||||
<template #option="{ itemProps, opt }">
|
|
||||||
<QItem v-bind="itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>{{ opt.name }}</QItemLabel>
|
|
||||||
<QItemLabel caption> {{ opt.country.name }} </QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
<template #form>
|
|
||||||
<CreateNewProvinceForm
|
|
||||||
:country-fk="$props.countryFk"
|
|
||||||
@on-data-saved="onProvinceCreated"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</VnSelectDialog>
|
|
||||||
</template>
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
Province: Provincia
|
|
||||||
Create province: Crear provincia
|
|
||||||
</i18n>
|
|
|
@ -1,57 +0,0 @@
|
||||||
<script setup>
|
|
||||||
defineProps({
|
|
||||||
columns: {
|
|
||||||
type: Array,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
row: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
function stopEventPropagation(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<slot name="beforeChip" :row="row"></slot>
|
|
||||||
<span
|
|
||||||
v-for="col of columns"
|
|
||||||
:key="col.name"
|
|
||||||
@click="stopEventPropagation"
|
|
||||||
class="cursor-text"
|
|
||||||
>
|
|
||||||
<QChip
|
|
||||||
v-if="col.chip.condition(row[col.name], row)"
|
|
||||||
:title="col.label"
|
|
||||||
:class="[
|
|
||||||
col.chip.color
|
|
||||||
? col.chip.color(row)
|
|
||||||
: !col.chip.icon && 'bg-chip-secondary',
|
|
||||||
col.chip.icon && 'q-px-none',
|
|
||||||
]"
|
|
||||||
dense
|
|
||||||
square
|
|
||||||
>
|
|
||||||
<span v-if="!col.chip.icon">
|
|
||||||
{{ col.format ? col.format(row) : row[col.name] }}
|
|
||||||
</span>
|
|
||||||
<QIcon v-else :name="col.chip.icon" color="primary-light" />
|
|
||||||
</QChip>
|
|
||||||
</span>
|
|
||||||
<slot name="afterChip" :row="row"></slot>
|
|
||||||
</template>
|
|
||||||
<style lang="scss">
|
|
||||||
.bg-chip-secondary {
|
|
||||||
background-color: var(--vn-page-color);
|
|
||||||
color: var(--vn-text-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.cursor-text {
|
|
||||||
pointer-events: all;
|
|
||||||
cursor: text;
|
|
||||||
user-select: all;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,190 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { markRaw, computed } from 'vue';
|
|
||||||
import { QIcon, QCheckbox } from 'quasar';
|
|
||||||
import { dashIfEmpty } from 'src/filters';
|
|
||||||
|
|
||||||
/* basic input */
|
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
|
||||||
import VnSelectCache from 'components/common/VnSelectCache.vue';
|
|
||||||
import VnInput from 'components/common/VnInput.vue';
|
|
||||||
import VnInputNumber from 'components/common/VnInputNumber.vue';
|
|
||||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
|
||||||
import VnInputTime from 'components/common/VnInputTime.vue';
|
|
||||||
import VnComponent from 'components/common/VnComponent.vue';
|
|
||||||
import VnUserLink from 'components/ui/VnUserLink.vue';
|
|
||||||
|
|
||||||
const model = defineModel(undefined, { required: true });
|
|
||||||
const $props = defineProps({
|
|
||||||
column: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
row: {
|
|
||||||
type: Object,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
default: {
|
|
||||||
type: [Object, String],
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
componentProp: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
isEditable: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
showLabel: {
|
|
||||||
type: Boolean,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const defaultSelect = {
|
|
||||||
attrs: {
|
|
||||||
row: $props.row,
|
|
||||||
disable: !$props.isEditable,
|
|
||||||
class: 'fit',
|
|
||||||
},
|
|
||||||
forceAttrs: {
|
|
||||||
label: $props.showLabel && $props.column.label,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const defaultComponents = {
|
|
||||||
input: {
|
|
||||||
component: markRaw(VnInput),
|
|
||||||
attrs: {
|
|
||||||
disable: !$props.isEditable,
|
|
||||||
class: 'fit',
|
|
||||||
},
|
|
||||||
forceAttrs: {
|
|
||||||
label: $props.showLabel && $props.column.label,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
number: {
|
|
||||||
component: markRaw(VnInputNumber),
|
|
||||||
attrs: {
|
|
||||||
disable: !$props.isEditable,
|
|
||||||
class: 'fit',
|
|
||||||
},
|
|
||||||
forceAttrs: {
|
|
||||||
label: $props.showLabel && $props.column.label,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
date: {
|
|
||||||
component: markRaw(VnInputDate),
|
|
||||||
attrs: {
|
|
||||||
readonly: !$props.isEditable,
|
|
||||||
disable: !$props.isEditable,
|
|
||||||
style: 'min-width: 125px',
|
|
||||||
class: 'fit',
|
|
||||||
},
|
|
||||||
forceAttrs: {
|
|
||||||
label: $props.showLabel && $props.column.label,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
time: {
|
|
||||||
component: markRaw(VnInputTime),
|
|
||||||
attrs: {
|
|
||||||
disable: !$props.isEditable,
|
|
||||||
},
|
|
||||||
forceAttrs: {
|
|
||||||
label: $props.showLabel && $props.column.label,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
checkbox: {
|
|
||||||
component: markRaw(QCheckbox),
|
|
||||||
attrs: ({ model }) => {
|
|
||||||
const defaultAttrs = {
|
|
||||||
disable: !$props.isEditable,
|
|
||||||
'model-value': Boolean(model),
|
|
||||||
class: 'no-padding fit',
|
|
||||||
};
|
|
||||||
|
|
||||||
if (typeof model == 'number') {
|
|
||||||
defaultAttrs['true-value'] = 1;
|
|
||||||
defaultAttrs['false-value'] = 0;
|
|
||||||
}
|
|
||||||
return defaultAttrs;
|
|
||||||
},
|
|
||||||
forceAttrs: {
|
|
||||||
label: $props.showLabel && $props.column.label,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
component: markRaw(VnSelectCache),
|
|
||||||
...defaultSelect,
|
|
||||||
},
|
|
||||||
rawSelect: {
|
|
||||||
component: markRaw(VnSelect),
|
|
||||||
...defaultSelect,
|
|
||||||
},
|
|
||||||
icon: {
|
|
||||||
component: markRaw(QIcon),
|
|
||||||
},
|
|
||||||
userLink: {
|
|
||||||
component: markRaw(VnUserLink),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const value = computed(() => {
|
|
||||||
return $props.column.format
|
|
||||||
? $props.column.format($props.row, dashIfEmpty)
|
|
||||||
: dashIfEmpty($props.row[$props.column.name]);
|
|
||||||
});
|
|
||||||
|
|
||||||
const col = computed(() => {
|
|
||||||
let newColumn = { ...$props.column };
|
|
||||||
const specific = newColumn[$props.componentProp];
|
|
||||||
if (specific) {
|
|
||||||
newColumn = {
|
|
||||||
...newColumn,
|
|
||||||
...specific,
|
|
||||||
...specific.attrs,
|
|
||||||
...specific.forceAttrs,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
(/^is[A-Z]/.test(newColumn.name) || /^has[A-Z]/.test(newColumn.name)) &&
|
|
||||||
newColumn.component == null
|
|
||||||
)
|
|
||||||
newColumn.component = 'checkbox';
|
|
||||||
if ($props.default && !newColumn.component) newColumn.component = $props.default;
|
|
||||||
|
|
||||||
return newColumn;
|
|
||||||
});
|
|
||||||
|
|
||||||
const components = computed(() => $props.components ?? defaultComponents);
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<div class="row no-wrap">
|
|
||||||
<VnComponent
|
|
||||||
v-if="col.before"
|
|
||||||
:prop="col.before"
|
|
||||||
:components="components"
|
|
||||||
:value="{ row, model }"
|
|
||||||
v-model="model"
|
|
||||||
/>
|
|
||||||
<VnComponent
|
|
||||||
v-if="col.component"
|
|
||||||
:prop="col"
|
|
||||||
:components="components"
|
|
||||||
:value="{ row, model }"
|
|
||||||
v-model="model"
|
|
||||||
/>
|
|
||||||
<span :title="value" v-else>{{ value }}</span>
|
|
||||||
<VnComponent
|
|
||||||
v-if="col.after"
|
|
||||||
:prop="col.after"
|
|
||||||
:components="components"
|
|
||||||
:value="{ row, model }"
|
|
||||||
v-model="model"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
|
@ -1,170 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { markRaw, computed } from 'vue';
|
|
||||||
import { QCheckbox } from 'quasar';
|
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
|
||||||
|
|
||||||
/* basic input */
|
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
|
||||||
import VnInput from 'components/common/VnInput.vue';
|
|
||||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
|
||||||
import VnInputTime from 'components/common/VnInputTime.vue';
|
|
||||||
import VnTableColumn from 'components/VnTable/VnColumn.vue';
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
column: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
showTitle: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
dataKey: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
searchUrl: {
|
|
||||||
type: String,
|
|
||||||
default: 'table',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
defineExpose({ addFilter, props: $props });
|
|
||||||
|
|
||||||
const model = defineModel(undefined, { required: true });
|
|
||||||
const arrayData = useArrayData(
|
|
||||||
$props.dataKey,
|
|
||||||
$props.searchUrl ? { searchUrl: $props.searchUrl } : null
|
|
||||||
);
|
|
||||||
const columnFilter = computed(() => $props.column?.columnFilter);
|
|
||||||
|
|
||||||
const updateEvent = { 'update:modelValue': addFilter };
|
|
||||||
const enterEvent = {
|
|
||||||
'keyup.enter': () => addFilter(model.value),
|
|
||||||
remove: () => addFilter(null),
|
|
||||||
};
|
|
||||||
|
|
||||||
const defaultAttrs = {
|
|
||||||
filled: !$props.showTitle,
|
|
||||||
class: 'q-px-xs q-pb-xs q-pt-none fit',
|
|
||||||
dense: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
const forceAttrs = {
|
|
||||||
label: $props.showTitle ? '' : columnFilter.value?.label ?? $props.column.label,
|
|
||||||
};
|
|
||||||
|
|
||||||
const selectComponent = {
|
|
||||||
component: markRaw(VnSelect),
|
|
||||||
event: updateEvent,
|
|
||||||
attrs: {
|
|
||||||
class: 'q-px-sm q-pb-xs q-pt-none fit',
|
|
||||||
dense: true,
|
|
||||||
filled: !$props.showTitle,
|
|
||||||
},
|
|
||||||
forceAttrs,
|
|
||||||
};
|
|
||||||
|
|
||||||
const components = {
|
|
||||||
input: {
|
|
||||||
component: markRaw(VnInput),
|
|
||||||
event: enterEvent,
|
|
||||||
attrs: {
|
|
||||||
...defaultAttrs,
|
|
||||||
clearable: true,
|
|
||||||
},
|
|
||||||
forceAttrs,
|
|
||||||
},
|
|
||||||
number: {
|
|
||||||
component: markRaw(VnInput),
|
|
||||||
event: enterEvent,
|
|
||||||
attrs: {
|
|
||||||
...defaultAttrs,
|
|
||||||
clearable: true,
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
forceAttrs,
|
|
||||||
},
|
|
||||||
date: {
|
|
||||||
component: markRaw(VnInputDate),
|
|
||||||
event: updateEvent,
|
|
||||||
attrs: {
|
|
||||||
...defaultAttrs,
|
|
||||||
style: 'min-width: 150px',
|
|
||||||
},
|
|
||||||
forceAttrs,
|
|
||||||
},
|
|
||||||
time: {
|
|
||||||
component: markRaw(VnInputTime),
|
|
||||||
event: updateEvent,
|
|
||||||
attrs: {
|
|
||||||
...defaultAttrs,
|
|
||||||
disable: !$props.isEditable,
|
|
||||||
},
|
|
||||||
forceAttrs: {
|
|
||||||
label: $props.showLabel && $props.column.label,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
checkbox: {
|
|
||||||
component: markRaw(QCheckbox),
|
|
||||||
event: updateEvent,
|
|
||||||
attrs: {
|
|
||||||
dense: true,
|
|
||||||
class: $props.showTitle ? 'q-py-sm q-mt-md' : 'q-px-md q-py-xs fit',
|
|
||||||
'toggle-indeterminate': true,
|
|
||||||
},
|
|
||||||
forceAttrs,
|
|
||||||
},
|
|
||||||
select: selectComponent,
|
|
||||||
rawSelect: selectComponent,
|
|
||||||
};
|
|
||||||
|
|
||||||
async function addFilter(value, name) {
|
|
||||||
value ??= undefined;
|
|
||||||
if (value && typeof value === 'object') value = model.value;
|
|
||||||
value = value === '' ? undefined : value;
|
|
||||||
let field = columnFilter.value?.name ?? $props.column.name ?? name;
|
|
||||||
|
|
||||||
if (columnFilter.value?.inWhere) {
|
|
||||||
if (columnFilter.value.alias) field = columnFilter.value.alias + '.' + field;
|
|
||||||
return await arrayData.addFilterWhere({ [field]: value });
|
|
||||||
}
|
|
||||||
await arrayData.addFilter({ params: { [field]: value } });
|
|
||||||
}
|
|
||||||
|
|
||||||
function alignRow() {
|
|
||||||
switch ($props.column.align) {
|
|
||||||
case 'left':
|
|
||||||
return 'justify-start items-start';
|
|
||||||
case 'right':
|
|
||||||
return 'justify-end items-end';
|
|
||||||
default:
|
|
||||||
return 'flex-center';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const showFilter = computed(
|
|
||||||
() => $props.column?.columnFilter !== false && $props.column.name != 'tableActions'
|
|
||||||
);
|
|
||||||
|
|
||||||
const onTabPressed = async () => {
|
|
||||||
if (model.value) enterEvent['keyup.enter']();
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<div
|
|
||||||
v-if="showFilter"
|
|
||||||
class="full-width"
|
|
||||||
:class="alignRow()"
|
|
||||||
style="max-height: 45px; overflow: hidden"
|
|
||||||
>
|
|
||||||
<VnTableColumn
|
|
||||||
:column="$props.column"
|
|
||||||
default="input"
|
|
||||||
v-model="model"
|
|
||||||
:components="components"
|
|
||||||
component-prop="columnFilter"
|
|
||||||
@keydown.tab="onTabPressed"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
|
@ -1,95 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
|
||||||
const model = defineModel({ type: Object });
|
|
||||||
const $props = defineProps({
|
|
||||||
name: {
|
|
||||||
type: [String, Boolean],
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
label: {
|
|
||||||
type: String,
|
|
||||||
default: undefined,
|
|
||||||
},
|
|
||||||
dataKey: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
searchUrl: {
|
|
||||||
type: String,
|
|
||||||
default: 'table',
|
|
||||||
},
|
|
||||||
vertical: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const hover = ref();
|
|
||||||
const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl });
|
|
||||||
|
|
||||||
async function orderBy(name, direction) {
|
|
||||||
if (!name) return;
|
|
||||||
switch (direction) {
|
|
||||||
case 'DESC':
|
|
||||||
direction = undefined;
|
|
||||||
break;
|
|
||||||
case undefined:
|
|
||||||
direction = 'ASC';
|
|
||||||
break;
|
|
||||||
case 'ASC':
|
|
||||||
direction = 'DESC';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!direction) return await arrayData.deleteOrder(name);
|
|
||||||
await arrayData.addOrder(name, direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({ orderBy });
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<div
|
|
||||||
@mouseenter="hover = true"
|
|
||||||
@mouseleave="hover = false"
|
|
||||||
@click="orderBy(name, model?.direction)"
|
|
||||||
class="row items-center no-wrap cursor-pointer"
|
|
||||||
>
|
|
||||||
<span :title="label">{{ label }}</span>
|
|
||||||
<QChip
|
|
||||||
v-if="name"
|
|
||||||
:label="!vertical ? model?.index : ''"
|
|
||||||
:icon="
|
|
||||||
(model?.index || hover) && !vertical
|
|
||||||
? model?.direction == 'DESC'
|
|
||||||
? 'arrow_downward'
|
|
||||||
: 'arrow_upward'
|
|
||||||
: undefined
|
|
||||||
"
|
|
||||||
:size="vertical ? '' : 'sm'"
|
|
||||||
:class="[
|
|
||||||
model?.index ? 'color-vn-text' : 'bg-transparent',
|
|
||||||
vertical ? 'q-px-none' : '',
|
|
||||||
]"
|
|
||||||
class="no-box-shadow"
|
|
||||||
:clickable="true"
|
|
||||||
style="min-width: 40px"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="column flex-center"
|
|
||||||
v-if="vertical"
|
|
||||||
:style="!model?.index && 'color: #5d5d5d'"
|
|
||||||
>
|
|
||||||
{{ model?.index }}
|
|
||||||
<QIcon
|
|
||||||
:name="
|
|
||||||
model?.index
|
|
||||||
? model?.direction == 'DESC'
|
|
||||||
? 'arrow_downward'
|
|
||||||
: 'arrow_upward'
|
|
||||||
: 'swap_vert'
|
|
||||||
"
|
|
||||||
size="xs"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</QChip>
|
|
||||||
</div>
|
|
||||||
</template>
|
|