Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 8828-filterVnSelectWarehouses
This commit is contained in:
commit
b6b9e1d97d
|
@ -18,6 +18,8 @@
|
|||
"test:e2e:summary": "bash ./test/cypress/summary.sh",
|
||||
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
|
||||
"test:front": "vitest",
|
||||
"test:ui": "vitest --ui",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
"test:front:ci": "vitest run",
|
||||
"commitlint": "commitlint --edit",
|
||||
"prepare": "npx husky install",
|
||||
|
@ -27,6 +29,8 @@
|
|||
"docs:preview": "vitepress preview docs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@eslint/eslintrc": "^3.2.0",
|
||||
"@eslint/js": "^9.20.0",
|
||||
"@quasar/cli": "^2.4.1",
|
||||
"@quasar/extras": "^1.16.16",
|
||||
"axios": "^1.4.0",
|
||||
|
@ -52,6 +56,7 @@
|
|||
"@quasar/app-vite": "^2.0.8",
|
||||
"@quasar/quasar-app-extension-qcalendar": "^4.0.2",
|
||||
"@quasar/quasar-app-extension-testing-unit-vitest": "^0.4.0",
|
||||
"@vitest/ui": "3.1.1",
|
||||
"@vue/compiler-sfc": "^3.5.13",
|
||||
"@vue/test-utils": "^2.4.4",
|
||||
"autoprefixer": "^10.4.14",
|
||||
|
@ -59,6 +64,7 @@
|
|||
"cypress-mochawesome-reporter": "^3.8.2",
|
||||
"eslint": "^9.18.0",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
"eslint-import-resolver-alias": "^1.1.2",
|
||||
"eslint-plugin-cypress": "^4.1.0",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"eslint-plugin-vue": "^9.32.0",
|
||||
|
@ -69,8 +75,7 @@
|
|||
"postcss": "^8.4.23",
|
||||
"prettier": "^3.4.2",
|
||||
"sass": "^1.83.4",
|
||||
"vitepress": "^1.6.3",
|
||||
"vitest": "^0.34.0",
|
||||
"vitest": "^3.0.3",
|
||||
"xunit-viewer": "^10.6.1"
|
||||
},
|
||||
"engines": {
|
||||
|
|
3165
pnpm-lock.yaml
3165
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,227 @@
|
|||
/* eslint-disable */
|
||||
/**
|
||||
* THIS FILE IS GENERATED AUTOMATICALLY.
|
||||
* 1. DO NOT edit this file directly as it won't do anything.
|
||||
* 2. EDIT the original quasar.config file INSTEAD.
|
||||
* 3. DO NOT git commit this file. It should be ignored.
|
||||
*
|
||||
* This file is still here because there was an error in
|
||||
* the original quasar.config file and this allows you to
|
||||
* investigate the Node.js stack error.
|
||||
*
|
||||
* After you fix the original file, this file will be
|
||||
* deleted automatically.
|
||||
**/
|
||||
|
||||
|
||||
// quasar.config.js
|
||||
import { configure } from "quasar/wrappers";
|
||||
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
|
||||
import path from "path";
|
||||
var __quasar_inject_dirname__ = "/home/jsegarra/Projects/salix-front";
|
||||
var target = `http://${process.env.CI ? "back" : "localhost"}:3000`;
|
||||
var quasar_config_default = configure(function() {
|
||||
return {
|
||||
eslint: {
|
||||
// fix: true,
|
||||
// include = [],
|
||||
// exclude = [],
|
||||
// rawOptions = {},
|
||||
warnings: true,
|
||||
errors: true
|
||||
},
|
||||
// https://v2.quasar.dev/quasar-cli/prefetch-feature
|
||||
// preFetch: true,
|
||||
// app boot file (/src/boot)
|
||||
// --> boot files are part of "main.js"
|
||||
// https://v2.quasar.dev/quasar-cli/boot-files
|
||||
boot: ["i18n", "axios", "vnDate", "validations", "quasar", "quasar.defaults"],
|
||||
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css
|
||||
css: ["app.scss"],
|
||||
// https://github.com/quasarframework/quasar/tree/dev/extras
|
||||
extras: [
|
||||
// 'ionicons-v4',
|
||||
// 'mdi-v5',
|
||||
// 'fontawesome-v6',
|
||||
// 'eva-icons',
|
||||
// 'themify',
|
||||
// 'line-awesome',
|
||||
// 'roboto-font-latin-ext', // this or either 'roboto-font', NEVER both!
|
||||
"roboto-font",
|
||||
"material-icons-outlined",
|
||||
"material-symbols-outlined"
|
||||
],
|
||||
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#build
|
||||
build: {
|
||||
target: {
|
||||
browser: ["es2022", "edge88", "firefox78", "chrome87", "safari13.1"],
|
||||
node: "node20"
|
||||
},
|
||||
vueRouterMode: "hash",
|
||||
// available values: 'hash', 'history'
|
||||
// vueRouterBase,
|
||||
// vueDevtools,
|
||||
// vueOptionsAPI: false,
|
||||
// rebuildCache: true, // rebuilds Vite/linter/etc cache on startup
|
||||
// publicPath: '/',
|
||||
// analyze: true,
|
||||
// env: {},
|
||||
rawDefine: {
|
||||
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV)
|
||||
},
|
||||
// ignorePublicFolder: true,
|
||||
// minify: false,
|
||||
// polyfillModulePreload: true,
|
||||
// distDir
|
||||
extendViteConf(viteConf) {
|
||||
delete viteConf.build.polyfillModulePreload;
|
||||
viteConf.build.modulePreload = {
|
||||
polyfill: false
|
||||
};
|
||||
},
|
||||
// viteVuePluginOptions: {},
|
||||
alias: {
|
||||
composables: path.join(__quasar_inject_dirname__, "./src/composables"),
|
||||
filters: path.join(__quasar_inject_dirname__, "./src/filters")
|
||||
},
|
||||
vitePlugins: [
|
||||
[
|
||||
VueI18nPlugin({
|
||||
strictMessage: false,
|
||||
runtimeOnly: false,
|
||||
include: [
|
||||
path.resolve(__quasar_inject_dirname__, "./src/i18n/locale/**"),
|
||||
path.resolve(__quasar_inject_dirname__, "./src/pages/**/locale/**")
|
||||
]
|
||||
})
|
||||
]
|
||||
]
|
||||
},
|
||||
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#devServer
|
||||
devServer: {
|
||||
server: {
|
||||
type: "http"
|
||||
},
|
||||
proxy: {
|
||||
"/api": {
|
||||
target,
|
||||
logLevel: "debug",
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
}
|
||||
},
|
||||
open: false,
|
||||
allowedHosts: [
|
||||
"front",
|
||||
// Agrega este nombre de host
|
||||
"localhost"
|
||||
// Opcional, para pruebas locales
|
||||
]
|
||||
},
|
||||
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#framework
|
||||
framework: {
|
||||
config: {
|
||||
config: {
|
||||
dark: "auto"
|
||||
}
|
||||
},
|
||||
lang: "en-GB",
|
||||
// iconSet: 'material-icons', // Quasar icon set
|
||||
// lang: 'en-US', // Quasar language pack
|
||||
// For special cases outside of where the auto-import strategy can have an impact
|
||||
// (like functional components as one of the examples),
|
||||
// you can manually specify Quasar components/directives to be available everywhere:
|
||||
//
|
||||
// components: [],
|
||||
// directives: [],
|
||||
// Quasar plugins
|
||||
plugins: ["Notify", "Dialog"],
|
||||
all: "auto",
|
||||
autoImportComponentCase: "pascal"
|
||||
},
|
||||
// animations: 'all', // --- includes all animations
|
||||
// https://v2.quasar.dev/options/animations
|
||||
animations: [],
|
||||
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#property-sourcefiles
|
||||
// sourceFiles: {
|
||||
// rootComponent: 'src/App.vue',
|
||||
// router: 'src/router/index',
|
||||
// store: 'src/store/index',
|
||||
// registerServiceWorker: 'src-pwa/register-service-worker',
|
||||
// serviceWorker: 'src-pwa/custom-service-worker',
|
||||
// pwaManifestFile: 'src-pwa/manifest.json',
|
||||
// electronMain: 'src-electron/electron-main',
|
||||
// electronPreload: 'src-electron/electron-preload'
|
||||
// },
|
||||
// https://v2.quasar.dev/quasar-cli/developing-ssr/configuring-ssr
|
||||
ssr: {
|
||||
// ssrPwaHtmlFilename: 'offline.html', // do NOT use index.html as name!
|
||||
// will mess up SSR
|
||||
// extendSSRWebserverConf (esbuildConf) {},
|
||||
// extendPackageJson (json) {},
|
||||
pwa: false,
|
||||
// manualStoreHydration: true,
|
||||
// manualPostHydrationTrigger: true,
|
||||
prodPort: 3e3,
|
||||
// The default port that the production server should use
|
||||
// (gets superseded if process.env.PORT is specified at runtime)
|
||||
middlewares: [
|
||||
"render"
|
||||
// keep this as last one
|
||||
]
|
||||
},
|
||||
// https://v2.quasar.dev/quasar-cli/developing-pwa/configuring-pwa
|
||||
pwa: {
|
||||
workboxMode: "generateSW",
|
||||
// or 'injectManifest'
|
||||
injectPwaMetaTags: true,
|
||||
swFilename: "sw.js",
|
||||
manifestFilename: "manifest.json",
|
||||
useCredentialsForManifestTag: false
|
||||
// useFilenameHashes: true,
|
||||
// extendGenerateSWOptions (cfg) {}
|
||||
// extendInjectManifestOptions (cfg) {},
|
||||
// extendManifestJson (json) {}
|
||||
// extendPWACustomSWConf (esbuildConf) {}
|
||||
},
|
||||
// Full list of options: https://v2.quasar.dev/quasar-cli/developing-cordova-apps/configuring-cordova
|
||||
cordova: {
|
||||
// noIosLegacyBuildFlag: true, // uncomment only if you know what you are doing
|
||||
},
|
||||
// Full list of options: https://v2.quasar.dev/quasar-cli/developing-capacitor-apps/configuring-capacitor
|
||||
capacitor: {
|
||||
hideSplashscreen: true
|
||||
},
|
||||
// Full list of options: https://v2.quasar.dev/quasar-cli/developing-electron-apps/configuring-electron
|
||||
electron: {
|
||||
// extendElectronMainConf (esbuildConf)
|
||||
// extendElectronPreloadConf (esbuildConf)
|
||||
inspectPort: 5858,
|
||||
bundler: "packager",
|
||||
// 'packager' or 'builder'
|
||||
packager: {
|
||||
// https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options
|
||||
// OS X / Mac App Store
|
||||
// appBundleId: '',
|
||||
// appCategoryType: '',
|
||||
// osxSign: '',
|
||||
// protocol: 'myapp://path',
|
||||
// Windows only
|
||||
// win32metadata: { ... }
|
||||
},
|
||||
builder: {
|
||||
// https://www.electron.build/configuration/configuration
|
||||
appId: "salix-frontend"
|
||||
}
|
||||
},
|
||||
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-browser-extensions/configuring-bex
|
||||
bex: {
|
||||
contentScripts: ["my-content-script"]
|
||||
// extendBexScriptsConf (esbuildConf) {}
|
||||
// extendBexManifestJson (json) {}
|
||||
}
|
||||
};
|
||||
});
|
||||
export {
|
||||
quasar_config_default as default
|
||||
};
|
|
@ -9,6 +9,30 @@ vi.mock('src/composables/useSession', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
// Mock axios
|
||||
vi.mock('axios', () => ({
|
||||
default: {
|
||||
create: vi.fn(() => ({
|
||||
interceptors: {
|
||||
request: { use: vi.fn() },
|
||||
response: { use: vi.fn() },
|
||||
},
|
||||
})),
|
||||
interceptors: {
|
||||
request: { use: vi.fn() },
|
||||
response: { use: vi.fn() },
|
||||
},
|
||||
defaults: {
|
||||
baseURL: '',
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock('src/router', () => ({
|
||||
Router: {
|
||||
push: vi.fn(),
|
||||
},
|
||||
}));
|
||||
vi.mock('src/stores/useStateQueryStore', () => ({
|
||||
useStateQueryStore: () => ({
|
||||
add: () => vi.fn(),
|
||||
|
@ -29,7 +53,7 @@ describe('Axios boot', () => {
|
|||
'Accept-Language': 'en-US',
|
||||
Authorization: 'DEFAULT_TOKEN',
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -332,6 +332,7 @@ watch(formUrl, async () => {
|
|||
:disable="!selected?.length"
|
||||
:title="t('globals.remove')"
|
||||
v-if="$props.defaultRemove"
|
||||
data-cy="crudModelDefaultRemoveBtn"
|
||||
/>
|
||||
<QBtn
|
||||
:label="tMobile('globals.reset')"
|
||||
|
|
|
@ -13,13 +13,12 @@ import VnConfirm from './ui/VnConfirm.vue';
|
|||
import { tMobile } from 'src/composables/tMobile';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { getDifferences, getUpdatedValues } from 'src/filters';
|
||||
|
||||
const { push } = useRouter();
|
||||
const quasar = useQuasar();
|
||||
const state = useState();
|
||||
const stateStore = useStateStore();
|
||||
const { t } = useI18n();
|
||||
const { validate } = useValidator();
|
||||
const { validate, validations } = useValidator();
|
||||
const { notify } = useNotify();
|
||||
const route = useRoute();
|
||||
const myForm = ref(null);
|
||||
|
@ -119,7 +118,7 @@ const defaultButtons = computed(() => ({
|
|||
color: 'primary',
|
||||
icon: 'save',
|
||||
label: 'globals.save',
|
||||
click: async () => await save(),
|
||||
click: async (evt) => submitForm(evt),
|
||||
type: 'submit',
|
||||
},
|
||||
reset: {
|
||||
|
@ -132,6 +131,13 @@ const defaultButtons = computed(() => ({
|
|||
...$props.defaultButtons,
|
||||
}));
|
||||
|
||||
const submitForm = async (evt) => {
|
||||
const isFormValid = await myForm.value.validate();
|
||||
if (isFormValid) {
|
||||
await save(evt);
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
nextTick(() => (componentIsRendered.value = true));
|
||||
|
||||
|
@ -227,10 +233,9 @@ async function save() {
|
|||
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);
|
||||
else response = await axios[method](url, body);
|
||||
const response = await Promise.resolve(
|
||||
$props.saveFn ? $props.saveFn(body) : axios[method](url, body),
|
||||
);
|
||||
|
||||
if ($props.urlCreate) notify('globals.dataCreated', 'positive');
|
||||
|
||||
|
@ -307,11 +312,13 @@ async function onKeyup(evt) {
|
|||
selectionStart = selectionEnd = selectionStart + 1;
|
||||
return;
|
||||
}
|
||||
await save();
|
||||
await myForm.value.submit(evt);
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
submitForm,
|
||||
myForm,
|
||||
save,
|
||||
isLoading,
|
||||
hasChanges,
|
||||
|
@ -325,7 +332,7 @@ defineExpose({
|
|||
<QForm
|
||||
ref="myForm"
|
||||
v-if="formData"
|
||||
@submit.prevent
|
||||
@submit.prevent="save"
|
||||
@keyup.prevent="onKeyup"
|
||||
@reset="reset"
|
||||
class="q-pa-md"
|
||||
|
@ -339,6 +346,7 @@ defineExpose({
|
|||
name="form"
|
||||
:data="formData"
|
||||
:validate="validate"
|
||||
:validations="validations()"
|
||||
:filter="filter"
|
||||
/>
|
||||
<SkeletonForm v-else />
|
||||
|
|
|
@ -41,9 +41,12 @@ const onDataSaved = async (formData, requestResponse) => {
|
|||
emit('onDataSaved', formData, requestResponse);
|
||||
};
|
||||
|
||||
const onClick = async (saveAndContinue) => {
|
||||
const onClick = async (saveAndContinue = showSaveAndContinueBtn) => {
|
||||
await formModelRef.value.myForm.validate(true);
|
||||
isSaveAndContinue.value = saveAndContinue;
|
||||
await formModelRef.value.save();
|
||||
if (formModelRef.value) {
|
||||
await formModelRef.value.submitForm();
|
||||
}
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
|
@ -59,16 +62,23 @@ defineExpose({
|
|||
ref="formModelRef"
|
||||
:observe-form-changes="false"
|
||||
:default-actions="false"
|
||||
@submit="onClick"
|
||||
v-bind="$attrs"
|
||||
@on-data-saved="onDataSaved"
|
||||
:prevent-submit="false"
|
||||
>
|
||||
<template #form="{ data, validate }">
|
||||
<template #form="{ data, validate, validations }">
|
||||
<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" />
|
||||
<slot
|
||||
name="form-inputs"
|
||||
:data="data"
|
||||
:validate="validate"
|
||||
:validations="validations"
|
||||
/>
|
||||
<div class="q-mt-lg row justify-end">
|
||||
<QBtn
|
||||
:label="t('globals.cancel')"
|
||||
|
@ -87,12 +97,13 @@ defineExpose({
|
|||
:flat="showSaveAndContinueBtn"
|
||||
:label="t('globals.save')"
|
||||
:title="t('globals.save')"
|
||||
@click="onClick(false)"
|
||||
:type="!showSaveAndContinueBtn ? 'submit' : 'button'"
|
||||
color="primary"
|
||||
class="q-ml-sm"
|
||||
:disabled="isLoading"
|
||||
:loading="isLoading"
|
||||
data-cy="FormModelPopup_save"
|
||||
@click="showSaveAndContinueBtn ? onClick(false) : null"
|
||||
z-max
|
||||
/>
|
||||
<QBtn
|
||||
|
@ -100,12 +111,13 @@ defineExpose({
|
|||
:label="t('globals.isSaveAndContinue')"
|
||||
:title="t('globals.isSaveAndContinue')"
|
||||
color="primary"
|
||||
:type="showSaveAndContinueBtn ? 'submit' : 'button'"
|
||||
class="q-ml-sm"
|
||||
:disabled="isLoading"
|
||||
:loading="isLoading"
|
||||
data-cy="FormModelPopup_isSaveAndContinue"
|
||||
@click="showSaveAndContinueBtn ? onClick(true) : null"
|
||||
z-max
|
||||
@click="onClick(true)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -1,12 +1,22 @@
|
|||
<script setup>
|
||||
import { toCurrency } from 'src/filters';
|
||||
import { getValueFromPath } from 'src/composables/getValueFromPath';
|
||||
|
||||
defineProps({ row: { type: Object, required: true } });
|
||||
const { row, visibleProblems = null } = defineProps({
|
||||
row: { type: Object, required: true },
|
||||
visibleProblems: { type: Array },
|
||||
});
|
||||
|
||||
function showProblem(problem) {
|
||||
const val = getValueFromPath(row, problem);
|
||||
if (!visibleProblems) return val;
|
||||
return !!(visibleProblems?.includes(problem) && val);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<span class="q-gutter-x-xs">
|
||||
<router-link
|
||||
v-if="row.claim?.claimFk"
|
||||
v-if="showProblem('claim.claimFk')"
|
||||
:to="{ name: 'ClaimBasicData', params: { id: row.claim?.claimFk } }"
|
||||
class="link"
|
||||
>
|
||||
|
@ -18,7 +28,7 @@ defineProps({ row: { type: Object, required: true } });
|
|||
</QIcon>
|
||||
</router-link>
|
||||
<QIcon
|
||||
v-if="row?.isDeleted"
|
||||
v-if="showProblem('isDeleted')"
|
||||
color="primary"
|
||||
name="vn:deletedTicket"
|
||||
size="xs"
|
||||
|
@ -29,7 +39,7 @@ defineProps({ row: { type: Object, required: true } });
|
|||
</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon
|
||||
v-if="row?.hasRisk"
|
||||
v-if="showProblem('hasRisk')"
|
||||
name="vn:risk"
|
||||
:color="row.hasHighRisk ? 'negative' : 'primary'"
|
||||
size="xs"
|
||||
|
@ -40,51 +50,76 @@ defineProps({ row: { type: Object, required: true } });
|
|||
</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon
|
||||
v-if="row?.hasComponentLack"
|
||||
v-if="showProblem('hasComponentLack')"
|
||||
name="vn:components"
|
||||
color="primary"
|
||||
size="xs"
|
||||
>
|
||||
<QTooltip>{{ $t('salesTicketsTable.componentLack') }}</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon v-if="row?.hasItemDelay" color="primary" size="xs" name="vn:hasItemDelay">
|
||||
<QIcon
|
||||
v-if="showProblem('hasItemDelay')"
|
||||
color="primary"
|
||||
size="xs"
|
||||
name="vn:hasItemDelay"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ $t('ticket.summary.hasItemDelay') }}
|
||||
</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon v-if="row?.hasItemLost" color="primary" size="xs" name="vn:hasItemLost">
|
||||
<QIcon
|
||||
v-if="showProblem('hasItemLost')"
|
||||
color="primary"
|
||||
size="xs"
|
||||
name="vn:hasItemLost"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ $t('salesTicketsTable.hasItemLost') }}
|
||||
</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon
|
||||
v-if="row?.hasItemShortage"
|
||||
v-if="showProblem('hasItemShortage')"
|
||||
name="vn:unavailable"
|
||||
color="primary"
|
||||
size="xs"
|
||||
>
|
||||
<QTooltip>{{ $t('salesTicketsTable.notVisible') }}</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon v-if="row?.hasRounding" color="primary" name="sync_problem" size="xs">
|
||||
<QIcon
|
||||
v-if="showProblem('hasRounding')"
|
||||
color="primary"
|
||||
name="sync_problem"
|
||||
size="xs"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ $t('ticketList.rounding') }}
|
||||
</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon
|
||||
v-if="row?.hasTicketRequest"
|
||||
v-if="showProblem('hasTicketRequest')"
|
||||
name="vn:buyrequest"
|
||||
color="primary"
|
||||
size="xs"
|
||||
>
|
||||
<QTooltip>{{ $t('salesTicketsTable.purchaseRequest') }}</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon v-if="row?.isTaxDataChecked" name="vn:no036" color="primary" size="xs">
|
||||
<QIcon
|
||||
v-if="showProblem('isTaxDataChecked')"
|
||||
name="vn:no036"
|
||||
color="primary"
|
||||
size="xs"
|
||||
>
|
||||
<QTooltip>{{ $t('salesTicketsTable.noVerifiedData') }}</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon v-if="row?.isFreezed" name="vn:frozen" color="primary" size="xs">
|
||||
<QIcon v-if="showProblem('isFreezed')" name="vn:frozen" color="primary" size="xs">
|
||||
<QTooltip>{{ $t('salesTicketsTable.clientFrozen') }}</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon v-if="row?.isTooLittle" name="vn:isTooLittle" color="primary" size="xs">
|
||||
<QIcon
|
||||
v-if="showProblem('isTooLittle')"
|
||||
name="vn:isTooLittle"
|
||||
color="primary"
|
||||
size="xs"
|
||||
>
|
||||
<QTooltip>{{ $t('salesTicketsTable.tooLittle') }}</QTooltip>
|
||||
</QIcon>
|
||||
</span>
|
||||
|
|
|
@ -19,6 +19,7 @@ import { useQuasar, date } from 'quasar';
|
|||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { useFilterParams } from 'src/composables/useFilterParams';
|
||||
import { dashIfEmpty, toDate } from 'src/filters';
|
||||
import { useTableHeight } from './filters/useTableHeight';
|
||||
|
||||
import CrudModel from 'src/components/CrudModel.vue';
|
||||
import FormModelPopup from 'components/FormModelPopup.vue';
|
||||
|
@ -117,7 +118,7 @@ const $props = defineProps({
|
|||
},
|
||||
tableHeight: {
|
||||
type: String,
|
||||
default: '90vh',
|
||||
default: undefined,
|
||||
},
|
||||
footer: {
|
||||
type: Boolean,
|
||||
|
@ -166,6 +167,7 @@ const tableRef = ref();
|
|||
const params = ref(useFilterParams($attrs['data-key']).params);
|
||||
const orders = ref(useFilterParams($attrs['data-key']).orders);
|
||||
const app = inject('app');
|
||||
const tableHeight = useTableHeight();
|
||||
|
||||
const editingRow = ref(null);
|
||||
const editingField = ref(null);
|
||||
|
@ -227,6 +229,7 @@ watch(
|
|||
|
||||
defineExpose({
|
||||
create: createForm,
|
||||
showForm,
|
||||
reload,
|
||||
redirect: redirectFn,
|
||||
selected,
|
||||
|
@ -678,7 +681,7 @@ const rowCtrlClickFunction = computed(() => {
|
|||
table-header-class="bg-header"
|
||||
card-container-class="grid-three"
|
||||
flat
|
||||
:style="isTableMode && `max-height: ${tableHeight}`"
|
||||
:style="isTableMode && `max-height: ${$props.tableHeight || tableHeight}`"
|
||||
:virtual-scroll="isTableMode"
|
||||
@virtual-scroll="handleScroll"
|
||||
@row-click="(event, row) => handleRowClick(event, row)"
|
||||
|
@ -1042,7 +1045,7 @@ const rowCtrlClickFunction = computed(() => {
|
|||
:model="$attrs['data-key'] + 'Create'"
|
||||
@on-data-saved="(_, res) => createForm.onDataSaved(res)"
|
||||
>
|
||||
<template #form-inputs="{ data }">
|
||||
<template #form-inputs="{ data, validations }">
|
||||
<slot name="alter-create" :data="data">
|
||||
<div :style="createComplement?.containerStyle">
|
||||
<div
|
||||
|
@ -1060,6 +1063,7 @@ const rowCtrlClickFunction = computed(() => {
|
|||
:key="column.name"
|
||||
:name="`column-create-${column.name}`"
|
||||
:data="data"
|
||||
:validations="validations"
|
||||
:column-name="column.name"
|
||||
:label="column.label"
|
||||
>
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { describe, expect, it, beforeEach, afterEach, vi } from 'vitest';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import VnVisibleColumn from '../VnVisibleColumn.vue';
|
||||
import { axios } from 'app/test/vitest/helper';
|
||||
|
||||
import { default as axios } from 'axios';
|
||||
describe('VnVisibleColumns', () => {
|
||||
let wrapper;
|
||||
let vm;
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
import { onMounted, nextTick, ref } from 'vue';
|
||||
|
||||
export function useTableHeight() {
|
||||
const tableHeight = ref('90vh');
|
||||
|
||||
onMounted(async () => {
|
||||
await nextTick();
|
||||
let height = 100;
|
||||
Array.from(document.querySelectorAll('[role="toolbar"]'))
|
||||
.filter((element) => window.getComputedStyle(element).display !== 'none')
|
||||
.forEach(() => {
|
||||
height -= 10;
|
||||
});
|
||||
tableHeight.value = `${height}vh`;
|
||||
});
|
||||
|
||||
return tableHeight;
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import { default as axios } from 'axios';
|
||||
|
||||
import CrudModel from 'components/CrudModel.vue';
|
||||
import { vi, afterEach, beforeEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import EditForm from 'components/EditTableCellValueForm.vue';
|
||||
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
const fieldA = 'fieldA';
|
||||
const fieldB = 'fieldB';
|
||||
|
||||
describe('EditForm', () => {
|
||||
let vm;
|
||||
const mockRows = [
|
||||
{ id: 1, itemFk: 101 },
|
||||
{ id: 2, itemFk: 102 },
|
||||
];
|
||||
const mockFieldsOptions = [
|
||||
{ label: 'Field A', field: fieldA, component: 'input', attrs: {} },
|
||||
{ label: 'Field B', field: fieldB, component: 'date', attrs: {} },
|
||||
];
|
||||
const editUrl = '/api/edit';
|
||||
|
||||
beforeAll(() => {
|
||||
vi.spyOn(axios, 'post').mockResolvedValue({ status: 200 });
|
||||
vm = createWrapper(EditForm, {
|
||||
props: {
|
||||
rows: mockRows,
|
||||
fieldsOptions: mockFieldsOptions,
|
||||
editUrl,
|
||||
},
|
||||
}).vm;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
it('should call axios.post with the correct parameters in the payload', async () => {
|
||||
const selectedField = { field: fieldA, component: 'input', attrs: {} };
|
||||
const newValue = 'Test Value';
|
||||
|
||||
vm.selectedField = selectedField;
|
||||
vm.newValue = newValue;
|
||||
|
||||
await vm.onSubmit();
|
||||
|
||||
const payload = axios.post.mock.calls[0][1];
|
||||
|
||||
expect(axios.post).toHaveBeenCalledWith(editUrl, expect.any(Object));
|
||||
expect(payload.field).toEqual(fieldA);
|
||||
expect(payload.newValue).toEqual(newValue);
|
||||
|
||||
expect(payload.lines).toEqual(expect.arrayContaining(mockRows));
|
||||
|
||||
expect(vm.isLoading).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,4 +1,6 @@
|
|||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import { default as axios } from 'axios';
|
||||
|
||||
import FilterItemForm from 'src/components/FilterItemForm.vue';
|
||||
import { vi, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
|
@ -38,9 +40,9 @@ describe('FilterItemForm', () => {
|
|||
{ relation: 'producer', scope: { fields: ['name'] } },
|
||||
{ relation: 'ink', scope: { fields: ['name'] } },
|
||||
],
|
||||
where: {"name":{"like":"%bolas de madera%"}},
|
||||
where: { name: { like: '%bolas de madera%' } },
|
||||
};
|
||||
|
||||
|
||||
expect(axios.get).toHaveBeenCalledWith('Items/withName', {
|
||||
params: { filter: JSON.stringify(expectedFilter) },
|
||||
});
|
||||
|
@ -79,4 +81,4 @@ describe('FilterItemForm', () => {
|
|||
vm.selectItem({ id: 12345 });
|
||||
expect(wrapper.emitted('itemSelected')[0]).toEqual([12345]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { describe, expect, it, beforeAll, vi, afterAll } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import { default as axios } from 'axios';
|
||||
|
||||
import FormModel from 'src/components/FormModel.vue';
|
||||
|
||||
describe('FormModel', () => {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import Leftmenu from 'components/LeftMenu.vue';
|
||||
import { vi, describe, expect, it, beforeAll, afterEach, beforeEach } from 'vitest';
|
||||
import { default as axios } from 'axios';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import LeftMenu from 'components/LeftMenu.vue';
|
||||
import * as vueRouter from 'vue-router';
|
||||
import { useNavigationStore } from 'src/stores/useNavigationStore';
|
||||
|
||||
|
@ -101,7 +102,7 @@ function mount(source = 'main') {
|
|||
vi.spyOn(axios, 'get').mockResolvedValue({
|
||||
data: [],
|
||||
});
|
||||
const wrapper = createWrapper(Leftmenu, {
|
||||
const wrapper = createWrapper(LeftMenu, {
|
||||
propsData: {
|
||||
source,
|
||||
},
|
||||
|
@ -164,7 +165,7 @@ describe('getRoutes', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Leftmenu as card', () => {
|
||||
describe('LeftMenu as card', () => {
|
||||
beforeAll(() => {
|
||||
vm = mount('card').vm;
|
||||
});
|
||||
|
@ -173,7 +174,7 @@ describe('Leftmenu as card', () => {
|
|||
vm.getRoutes();
|
||||
});
|
||||
});
|
||||
describe('Leftmenu as main', () => {
|
||||
describe('LeftMenu as main', () => {
|
||||
beforeEach(() => {
|
||||
vm = mount().vm;
|
||||
});
|
||||
|
|
|
@ -1,65 +1,63 @@
|
|||
import { vi, describe, expect, it, beforeEach, afterEach } from 'vitest';
|
||||
import { vi, describe, expect, it, beforeEach, beforeAll, afterEach } from 'vitest';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import UserPanel from 'src/components/UserPanel.vue';
|
||||
import axios from 'axios';
|
||||
import { useState } from 'src/composables/useState';
|
||||
|
||||
vi.mock('src/utils/quasarLang', () => ({
|
||||
default: vi.fn(),
|
||||
}));
|
||||
|
||||
describe('UserPanel', () => {
|
||||
let wrapper;
|
||||
let vm;
|
||||
let state;
|
||||
let wrapper;
|
||||
let vm;
|
||||
let state;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = createWrapper(UserPanel, {});
|
||||
state = useState();
|
||||
state.setUser({
|
||||
id: 115,
|
||||
name: 'itmanagement',
|
||||
nickname: 'itManagementNick',
|
||||
lang: 'en',
|
||||
darkMode: false,
|
||||
companyFk: 442,
|
||||
warehouseFk: 1,
|
||||
beforeEach(() => {
|
||||
wrapper = createWrapper(UserPanel, {});
|
||||
state = useState();
|
||||
state.setUser({
|
||||
id: 115,
|
||||
name: 'itmanagement',
|
||||
nickname: 'itManagementNick',
|
||||
lang: 'en',
|
||||
darkMode: false,
|
||||
companyFk: 442,
|
||||
warehouseFk: 1,
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
vm = wrapper.vm;
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
vm = wrapper.vm;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should fetch warehouses data on mounted', async () => {
|
||||
const fetchData = wrapper.findComponent({ name: 'FetchData' });
|
||||
expect(fetchData.props('url')).toBe('Warehouses');
|
||||
expect(fetchData.props('autoLoad')).toBe(true);
|
||||
});
|
||||
it('should fetch warehouses data on mounted', async () => {
|
||||
const fetchData = wrapper.findComponent({ name: 'FetchData' });
|
||||
expect(fetchData.props('url')).toBe('Warehouses');
|
||||
expect(fetchData.props('autoLoad')).toBe(true);
|
||||
});
|
||||
|
||||
it('should toggle dark mode correctly and update preferences', async () => {
|
||||
await vm.saveDarkMode(true);
|
||||
expect(axios.patch).toHaveBeenCalledWith('/UserConfigs/115', { darkMode: true });
|
||||
expect(vm.user.darkMode).toBe(true);
|
||||
await vm.updatePreferences();
|
||||
expect(vm.darkMode).toBe(true);
|
||||
});
|
||||
it('should toggle dark mode correctly and update preferences', async () => {
|
||||
await vm.saveDarkMode(true);
|
||||
expect(axios.patch).toHaveBeenCalledWith('/UserConfigs/115', { darkMode: true });
|
||||
expect(vm.user.darkMode).toBe(true);
|
||||
vm.updatePreferences();
|
||||
expect(vm.darkMode).toBe(true);
|
||||
});
|
||||
|
||||
it('should change user language and update preferences', async () => {
|
||||
const userLanguage = 'es';
|
||||
await vm.saveLanguage(userLanguage);
|
||||
expect(axios.patch).toHaveBeenCalledWith('/VnUsers/115', { lang: userLanguage });
|
||||
expect(vm.user.lang).toBe(userLanguage);
|
||||
await vm.updatePreferences();
|
||||
expect(vm.locale).toBe(userLanguage);
|
||||
});
|
||||
it('should change user language and update preferences', async () => {
|
||||
const userLanguage = 'es';
|
||||
await vm.saveLanguage(userLanguage);
|
||||
expect(axios.patch).toHaveBeenCalledWith('/VnUsers/115', { lang: userLanguage });
|
||||
expect(vm.user.lang).toBe(userLanguage);
|
||||
vm.updatePreferences();
|
||||
expect(vm.locale).toBe(userLanguage);
|
||||
});
|
||||
|
||||
it('should update user data', async () => {
|
||||
const key = 'name';
|
||||
const value = 'itboss';
|
||||
await vm.saveUserData(key, value);
|
||||
expect(axios.post).toHaveBeenCalledWith('UserConfigs/setUserConfig', { [key]: value });
|
||||
});
|
||||
});
|
||||
it('should update user data', async () => {
|
||||
const key = 'name';
|
||||
const value = 'itboss';
|
||||
await vm.saveUserData(key, value);
|
||||
expect(axios.post).toHaveBeenCalledWith('UserConfigs/setUserConfig', {
|
||||
[key]: value,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
|
||||
const $props = defineProps({
|
||||
colors: {
|
||||
type: String,
|
||||
|
@ -6,9 +8,9 @@ const $props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
const colorArray = JSON.parse($props.colors)?.value;
|
||||
const colorArray = computed(() => JSON.parse($props.colors)?.value);
|
||||
const maxHeight = 30;
|
||||
const colorHeight = maxHeight / colorArray?.length;
|
||||
const colorHeight = maxHeight / colorArray.value?.length;
|
||||
</script>
|
||||
<template>
|
||||
<div v-if="colors" class="color-div" :style="{ height: `${maxHeight}px` }">
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<script setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import axios from 'axios';
|
||||
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const model = defineModel({ type: [Number, String] });
|
||||
const emit = defineEmits(['updateBic']);
|
||||
|
||||
const getIbanCountry = (bank) => {
|
||||
return bank.substr(0, 2);
|
||||
};
|
||||
|
||||
const autofillBic = async (iban) => {
|
||||
if (!iban) return;
|
||||
|
||||
const bankEntityId = parseInt(iban.substr(4, 4));
|
||||
const ibanCountry = getIbanCountry(iban);
|
||||
|
||||
if (ibanCountry != 'ES') return;
|
||||
|
||||
const filter = { where: { id: bankEntityId.value } };
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
|
||||
const { data } = await axios.get(`BankEntities`, { params });
|
||||
|
||||
emit('updateBic', data[0].id);
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<VnInput
|
||||
:label="t('IBAN')"
|
||||
clearable
|
||||
v-model="model"
|
||||
@update:model-value="autofillBic($event)"
|
||||
>
|
||||
<template #append>
|
||||
<QIcon name="info" class="cursor-info">
|
||||
<QTooltip>{{ t('components.iban_tooltip') }}</QTooltip>
|
||||
</QIcon>
|
||||
</template>
|
||||
</VnInput>
|
||||
</template>
|
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
import { watch } from 'vue';
|
||||
import { toDateString } from 'src/filters';
|
||||
import { toDateHourMinSec } from 'src/filters';
|
||||
|
||||
const props = defineProps({
|
||||
value: { type: [String, Number, Boolean, Object], default: undefined },
|
||||
|
@ -40,7 +40,7 @@ const updateValue = () => {
|
|||
break;
|
||||
case 'object':
|
||||
if (props.value instanceof Date) {
|
||||
t = toDateString(props.value);
|
||||
t = toDateHourMinSec(props.value);
|
||||
} else {
|
||||
t = props.value.toString();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import VnChangePassword from 'src/components/common/VnChangePassword.vue';
|
||||
import { vi, beforeEach, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
import { Notify } from 'quasar';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import { default as axios } from 'axios';
|
||||
import { vi, afterEach, beforeEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
import VnDms from 'src/components/common/VnDms.vue';
|
||||
|
||||
|
@ -40,7 +41,10 @@ describe('VnDms', () => {
|
|||
companyFk: 2,
|
||||
dmsTypeFk: 3,
|
||||
description: 'This is a test description',
|
||||
files: { name: 'example.txt', content: new Blob(['file content'], { type: 'text/plain' })},
|
||||
files: {
|
||||
name: 'example.txt',
|
||||
content: new Blob(['file content'], { type: 'text/plain' }),
|
||||
},
|
||||
};
|
||||
|
||||
const expectedBody = {
|
||||
|
@ -59,7 +63,7 @@ describe('VnDms', () => {
|
|||
url: '/test',
|
||||
formInitialData: { id: 1, reference: 'test' },
|
||||
model: 'Worker',
|
||||
}
|
||||
},
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
vm = wrapper.vm;
|
||||
|
@ -98,7 +102,7 @@ describe('VnDms', () => {
|
|||
expect(vm.getUrl()).toBe('/test');
|
||||
});
|
||||
|
||||
it('should returns url dms/"props.formInitialData.id"/updateFile when prop url is null', async () => {
|
||||
it('should returns url dms/"props.formInitialData.id"/updateFile when prop url is null', async () => {
|
||||
await wrapper.setProps({ url: null });
|
||||
expect(vm.getUrl()).toBe('dms/1/updateFile');
|
||||
});
|
||||
|
@ -113,7 +117,9 @@ describe('VnDms', () => {
|
|||
describe('save', () => {
|
||||
it('should save data correctly', async () => {
|
||||
await vm.save();
|
||||
expect(postMock).toHaveBeenCalledWith(vm.getUrl(), expect.any(FormData), { params: expectedBody });
|
||||
expect(postMock).toHaveBeenCalledWith(vm.getUrl(), expect.any(FormData), {
|
||||
params: expectedBody,
|
||||
});
|
||||
expect(wrapper.emitted('onDataSaved')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
@ -127,8 +133,8 @@ describe('VnDms', () => {
|
|||
warehouseFk: 2,
|
||||
companyFk: 3,
|
||||
dmsTypeFk: 2,
|
||||
description: 'This is a test description'
|
||||
}
|
||||
description: 'This is a test description',
|
||||
};
|
||||
await wrapper.setProps({ formInitialData: testData });
|
||||
vm.defaultData();
|
||||
|
||||
|
@ -137,10 +143,10 @@ describe('VnDms', () => {
|
|||
|
||||
it('should add reference with "route.params.id" to dms if formInitialData is null', async () => {
|
||||
await wrapper.setProps({ formInitialData: null });
|
||||
vm.route.params.id= '111';
|
||||
vm.route.params.id = '111';
|
||||
vm.defaultData();
|
||||
|
||||
expect(vm.dms.reference).toBe('111');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import { default as axios } from 'axios';
|
||||
|
||||
import VnDmsList from 'src/components/common/VnDmsList.vue';
|
||||
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ describe('VnJsonValue', () => {
|
|||
const date = new Date('2023-01-01');
|
||||
const wrapper = buildComponent({ value: date });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe('2023-01-01');
|
||||
expect(span.text()).toBe('01/01/2023, 01:00:00');
|
||||
expect(span.classes()).toContain('json-object');
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import VnLog from 'src/components/common/VnLog.vue';
|
||||
|
||||
describe('VnLog', () => {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { describe, it, expect, vi, afterEach, beforeEach, afterAll } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import { default as axios } from 'axios';
|
||||
import VnNotes from 'src/components/ui/VnNotes.vue';
|
||||
|
||||
describe('VnNotes', () => {
|
||||
|
|
|
@ -6,6 +6,7 @@ import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
|||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useClipboard } from 'src/composables/useClipboard';
|
||||
import VnMoreOptions from './VnMoreOptions.vue';
|
||||
import { getValueFromPath } from 'src/composables/getValueFromPath';
|
||||
|
||||
const entity = defineModel({ type: Object, default: null });
|
||||
const $props = defineProps({
|
||||
|
@ -56,18 +57,6 @@ const routeName = computed(() => {
|
|||
return `${routeName}Summary`;
|
||||
});
|
||||
|
||||
function getValueFromPath(path) {
|
||||
if (!path) return;
|
||||
const keys = path.toString().split('.');
|
||||
let current = entity.value;
|
||||
|
||||
for (const key of keys) {
|
||||
if (current[key] === undefined) return undefined;
|
||||
else current = current[key];
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
function copyIdText(id) {
|
||||
copyText(id, {
|
||||
component: {
|
||||
|
@ -170,10 +159,10 @@ const toModule = computed(() => {
|
|||
<div class="title">
|
||||
<span
|
||||
v-if="title"
|
||||
:title="getValueFromPath(title)"
|
||||
:title="getValueFromPath(entity, title)"
|
||||
:data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_title`"
|
||||
>
|
||||
{{ getValueFromPath(title) ?? title }}
|
||||
{{ getValueFromPath(entity, title) ?? title }}
|
||||
</span>
|
||||
<slot v-else name="description" :entity="entity">
|
||||
<span
|
||||
|
@ -189,7 +178,7 @@ const toModule = computed(() => {
|
|||
class="subtitle"
|
||||
:data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_subtitle`"
|
||||
>
|
||||
#{{ getValueFromPath(subtitle) ?? entity.id }}
|
||||
#{{ getValueFromPath(entity, subtitle) ?? entity.id }}
|
||||
</QItemLabel>
|
||||
<QBtn
|
||||
round
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach, beforeEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import { default as axios } from 'axios';
|
||||
|
||||
import CardSummary from 'src/components/ui/CardSummary.vue';
|
||||
import * as vueRouter from 'vue-router';
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||
|
||||
describe('VnPaginate', () => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { describe, it, expect, beforeAll, vi } from 'vitest';
|
||||
import { axios } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
import parsePhone from 'src/filters/parsePhone';
|
||||
|
||||
describe('parsePhone filter', () => {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import VnSms from 'src/components/ui/VnSms.vue';
|
||||
|
||||
describe('VnSms', () => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterAll } from 'vitest';
|
||||
import { axios } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
import { downloadFile } from 'src/composables/downloadFile';
|
||||
import { useSession } from 'src/composables/useSession';
|
||||
const session = useSession();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterAll } from 'vitest';
|
||||
import { axios, flushPromises } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
|
||||
import { flushPromises } from '@vue/test-utils';
|
||||
import { useAcl } from 'src/composables/useAcl';
|
||||
|
||||
describe('useAcl', () => {
|
||||
|
|
|
@ -1,15 +1,39 @@
|
|||
import { describe, expect, it, beforeEach, afterEach, vi } from 'vitest';
|
||||
import { axios, flushPromises } from 'app/test/vitest/helper';
|
||||
import { default as axios } from 'axios';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import { useRouter } from 'vue-router';
|
||||
import * as vueRouter from 'vue-router';
|
||||
import { setActivePinia, createPinia } from 'pinia';
|
||||
|
||||
describe('useArrayData', () => {
|
||||
const filter = '{"limit":20,"skip":0}';
|
||||
const params = { supplierFk: 2 };
|
||||
|
||||
beforeEach(() => {
|
||||
vi.spyOn(useRouter(), 'replace');
|
||||
vi.spyOn(useRouter(), 'push');
|
||||
setActivePinia(createPinia());
|
||||
|
||||
// Mock route
|
||||
vi.spyOn(vueRouter, 'useRoute').mockReturnValue({
|
||||
path: 'mockSection/list',
|
||||
matched: [],
|
||||
query: {},
|
||||
params: {},
|
||||
meta: { moduleName: 'mockName' },
|
||||
});
|
||||
|
||||
// Mock router
|
||||
vi.spyOn(vueRouter, 'useRouter').mockReturnValue({
|
||||
push: vi.fn(),
|
||||
replace: vi.fn(),
|
||||
currentRoute: {
|
||||
value: {
|
||||
path: 'mockSection/list',
|
||||
params: { id: 1 },
|
||||
meta: { moduleName: 'mockName' },
|
||||
matched: [{ path: 'mockName/:id' }],
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
@ -17,103 +41,69 @@ describe('useArrayData', () => {
|
|||
});
|
||||
|
||||
it('should fetch and replace url with new params', async () => {
|
||||
vi.spyOn(axios, 'get').mockReturnValueOnce({ data: [] });
|
||||
vi.spyOn(axios, 'get').mockResolvedValueOnce({ data: [] });
|
||||
|
||||
const arrayData = useArrayData('ArrayData', { url: 'mockUrl' });
|
||||
const arrayData = useArrayData('ArrayData', {
|
||||
url: 'mockUrl',
|
||||
searchUrl: 'params',
|
||||
});
|
||||
|
||||
arrayData.store.userParams = params;
|
||||
arrayData.fetch({});
|
||||
await arrayData.fetch({});
|
||||
|
||||
await flushPromises();
|
||||
const routerReplace = useRouter().replace.mock.calls[0][0];
|
||||
|
||||
expect(axios.get.mock.calls[0][1].params).toEqual({
|
||||
filter,
|
||||
supplierFk: 2,
|
||||
expect(axios.get).toHaveBeenCalledWith('mockUrl', {
|
||||
signal: expect.any(Object),
|
||||
params: {
|
||||
filter,
|
||||
supplierFk: 2,
|
||||
},
|
||||
});
|
||||
expect(routerReplace.path).toEqual('mockSection/list');
|
||||
|
||||
expect(routerReplace.path).toBe('mockSection/list');
|
||||
expect(JSON.parse(routerReplace.query.params)).toEqual(
|
||||
expect.objectContaining(params),
|
||||
);
|
||||
});
|
||||
|
||||
it('should get data and send new URL without keeping parameters, if there is only one record', async () => {
|
||||
vi.spyOn(axios, 'get').mockReturnValueOnce({ data: [{ id: 1 }] });
|
||||
it('should redirect to detail when single record is returned with navigation', async () => {
|
||||
vi.spyOn(axios, 'get').mockResolvedValueOnce({
|
||||
data: [{ id: 1 }],
|
||||
});
|
||||
|
||||
const arrayData = useArrayData('ArrayData', { url: 'mockUrl', navigate: {} });
|
||||
const arrayData = useArrayData('ArrayData', {
|
||||
url: 'mockUrl',
|
||||
navigate: {},
|
||||
});
|
||||
|
||||
arrayData.store.userParams = params;
|
||||
arrayData.fetch({});
|
||||
await arrayData.fetch({});
|
||||
|
||||
await flushPromises();
|
||||
const routerPush = useRouter().push.mock.calls[0][0];
|
||||
|
||||
expect(axios.get.mock.calls[0][1].params).toEqual({
|
||||
filter,
|
||||
supplierFk: 2,
|
||||
});
|
||||
expect(routerPush.path).toEqual('mockName/1');
|
||||
expect(routerPush.path).toBe('mockName/1');
|
||||
expect(routerPush.query).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should get data and send new URL keeping parameters, if you have more than one record', async () => {
|
||||
vi.spyOn(axios, 'get').mockReturnValueOnce({ data: [{ id: 1 }, { id: 2 }] });
|
||||
|
||||
vi.spyOn(vueRouter, 'useRoute').mockReturnValue({
|
||||
matched: [],
|
||||
query: {},
|
||||
params: {},
|
||||
meta: { moduleName: 'mockName' },
|
||||
path: 'mockName/1',
|
||||
});
|
||||
vi.spyOn(vueRouter, 'useRouter').mockReturnValue({
|
||||
push: vi.fn(),
|
||||
replace: vi.fn(),
|
||||
currentRoute: {
|
||||
value: {
|
||||
params: {
|
||||
id: 1,
|
||||
},
|
||||
meta: { moduleName: 'mockName' },
|
||||
matched: [{ path: 'mockName/:id' }],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const arrayData = useArrayData('ArrayData', { url: 'mockUrl', navigate: {} });
|
||||
|
||||
arrayData.store.userParams = params;
|
||||
arrayData.fetch({});
|
||||
|
||||
await flushPromises();
|
||||
const routerPush = useRouter().push.mock.calls[0][0];
|
||||
|
||||
expect(axios.get.mock.calls[0][1].params).toEqual({
|
||||
filter,
|
||||
supplierFk: 2,
|
||||
});
|
||||
expect(routerPush.path).toEqual('mockName/');
|
||||
expect(routerPush.query.params).toBeDefined();
|
||||
});
|
||||
|
||||
it('should return one record', async () => {
|
||||
vi.spyOn(axios, 'get').mockReturnValueOnce({
|
||||
it('should return one record when oneRecord is true', async () => {
|
||||
vi.spyOn(axios, 'get').mockResolvedValueOnce({
|
||||
data: [
|
||||
{ id: 1, name: 'Entity 1' },
|
||||
{ id: 2, name: 'Entity 2' },
|
||||
],
|
||||
});
|
||||
const arrayData = useArrayData('ArrayData', { url: 'mockUrl', oneRecord: true });
|
||||
|
||||
const arrayData = useArrayData('ArrayData', {
|
||||
url: 'mockUrl',
|
||||
oneRecord: true,
|
||||
});
|
||||
|
||||
await arrayData.fetch({});
|
||||
|
||||
expect(arrayData.store.data).toEqual({ id: 1, name: 'Entity 1' });
|
||||
});
|
||||
|
||||
it('should handle empty data gracefully if has to return one record', async () => {
|
||||
vi.spyOn(axios, 'get').mockReturnValueOnce({ data: [] });
|
||||
const arrayData = useArrayData('ArrayData', { url: 'mockUrl', oneRecord: true });
|
||||
await arrayData.fetch({});
|
||||
|
||||
expect(arrayData.store.data).toBeUndefined();
|
||||
expect(arrayData.store.data).toEqual({
|
||||
id: 1,
|
||||
name: 'Entity 1',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { vi, describe, expect, it } from 'vitest';
|
||||
import { axios, flushPromises } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
import { flushPromises } from '@vue/test-utils';
|
||||
import { useRole } from 'composables/useRole';
|
||||
const role = useRole();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { vi, describe, expect, it, beforeAll, beforeEach } from 'vitest';
|
||||
import { axios } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
import { useSession } from 'composables/useSession';
|
||||
import { useState } from 'composables/useState';
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { vi, describe, expect, it } from 'vitest';
|
||||
import { axios, flushPromises } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
import { flushPromises } from '@vue/test-utils';
|
||||
import { useTokenConfig } from 'composables/useTokenConfig';
|
||||
const tokenConfig = useTokenConfig();
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
export function getValueFromPath(root, path) {
|
||||
if (!root || !path) return;
|
||||
const keys = path.toString().split('.');
|
||||
let current = root;
|
||||
|
||||
for (const key of keys) {
|
||||
if (current[key] === undefined) return undefined;
|
||||
else current = current[key];
|
||||
}
|
||||
return current;
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
import axios from 'axios';
|
||||
|
||||
export async function beforeSave(data, getChanges, modelOrigin) {
|
||||
try {
|
||||
const changes = data.updates;
|
||||
if (!changes) return data;
|
||||
const patchPromises = [];
|
||||
|
||||
for (const change of changes) {
|
||||
let patchData = {};
|
||||
|
||||
if ('hasMinPrice' in change.data) {
|
||||
patchData.hasMinPrice = change.data?.hasMinPrice;
|
||||
delete change.data.hasMinPrice;
|
||||
}
|
||||
if ('minPrice' in change.data) {
|
||||
patchData.minPrice = change.data?.minPrice;
|
||||
delete change.data.minPrice;
|
||||
}
|
||||
|
||||
if (Object.keys(patchData).length > 0) {
|
||||
const promise = axios
|
||||
.get(`${modelOrigin}/findOne`, {
|
||||
params: {
|
||||
filter: {
|
||||
fields: ['itemFk'],
|
||||
where: { id: change.where.id },
|
||||
},
|
||||
},
|
||||
})
|
||||
.then((row) => {
|
||||
return axios.patch(`Items/${row.data.itemFk}`, patchData);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error processing change: ', change, error);
|
||||
});
|
||||
|
||||
patchPromises.push(promise);
|
||||
}
|
||||
}
|
||||
|
||||
await Promise.all(patchPromises);
|
||||
|
||||
data.updates = changes.filter((change) => Object.keys(change.data).length > 0);
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error in beforeSave:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
|
@ -5,12 +5,11 @@ import { useArrayDataStore } from 'stores/useArrayDataStore';
|
|||
import { buildFilter } from 'filters/filterPanel';
|
||||
import { isDialogOpened } from 'src/filters';
|
||||
|
||||
const arrayDataStore = useArrayDataStore();
|
||||
|
||||
export function useArrayData(key, userOptions) {
|
||||
key ??= useRoute().meta.moduleName;
|
||||
|
||||
if (!key) throw new Error('ArrayData: A key is required to use this composable');
|
||||
const arrayDataStore = useArrayDataStore(); // Move inside function
|
||||
|
||||
if (!arrayDataStore.get(key)) arrayDataStore.set(key);
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ export function useSession() {
|
|||
const { data: isValidToken } = await axios.get('VnUsers/validateToken');
|
||||
if (isValidToken)
|
||||
destroyTokenPromises = Object.entries(tokens).map(([key, url]) =>
|
||||
destroyToken(url, storage, key)
|
||||
destroyToken(url, storage, key),
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
|
|
|
@ -78,7 +78,8 @@ export function useValidator() {
|
|||
if (min >= 0)
|
||||
if (Math.floor(value) < min) return t('inputMin', { value: min });
|
||||
},
|
||||
custom: (value) => validation.bindedFunction(value) || 'Invalid value',
|
||||
custom: (value) =>
|
||||
eval(`(${validation.bindedFunction})`)(value) || 'Invalid value',
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -340,3 +340,6 @@ input::-webkit-inner-spin-button {
|
|||
.containerShrinked {
|
||||
width: 70%;
|
||||
}
|
||||
.q-item__section--main ~ .q-item__section--side {
|
||||
padding-inline: 0;
|
||||
}
|
||||
|
|
|
@ -877,6 +877,11 @@ components:
|
|||
active: Is active
|
||||
floramondo: Is floramondo
|
||||
showBadDates: Show future items
|
||||
name: Nombre
|
||||
rate2: Grouping price
|
||||
rate3: Packing price
|
||||
minPrice: Min. Price
|
||||
itemFk: Item id
|
||||
userPanel:
|
||||
copyToken: Token copied to clipboard
|
||||
settings: Settings
|
||||
|
|
|
@ -961,6 +961,11 @@ components:
|
|||
to: Hasta
|
||||
floramondo: Floramondo
|
||||
showBadDates: Ver items a futuro
|
||||
name: Nombre
|
||||
rate2: Precio grouping
|
||||
rate3: Precio packing
|
||||
minPrice: Precio mínimo
|
||||
itemFk: Id item
|
||||
userPanel:
|
||||
copyToken: Token copiado al portapapeles
|
||||
settings: Configuración
|
||||
|
|
|
@ -123,8 +123,8 @@ async function fetchMana() {
|
|||
|
||||
async function updateDiscount({ saleFk, discount, canceller }) {
|
||||
const body = { salesIds: [saleFk], newDiscount: discount };
|
||||
const claimId = claim.value.ticketFk;
|
||||
const query = `Tickets/${claimId}/updateDiscount`;
|
||||
const ticketFk = claim.value.ticketFk;
|
||||
const query = `Tickets/${ticketFk}/updateDiscount`;
|
||||
|
||||
await axios.post(query, body, {
|
||||
signal: canceller.signal,
|
||||
|
|
|
@ -88,13 +88,13 @@ const columns = [
|
|||
auto-load
|
||||
>
|
||||
<template #column-itemFk="{ row }">
|
||||
<span class="link">
|
||||
<span class="link" @click.stop>
|
||||
{{ row.itemFk }}
|
||||
<ItemDescriptorProxy :id="row.itemFk" />
|
||||
</span>
|
||||
</template>
|
||||
<template #column-ticketFk="{ row }">
|
||||
<span class="link">
|
||||
<span class="link" @click.stop>
|
||||
{{ row.ticketFk }}
|
||||
<TicketDescriptorProxy :id="row.ticketFk" />
|
||||
</span>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import ClaimDescriptorMenu from 'pages/Claim/Card/ClaimDescriptorMenu.vue';
|
||||
|
||||
describe('ClaimDescriptorMenu', () => {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import ClaimLines from '/src/pages/Claim/Card/ClaimLines.vue';
|
||||
|
||||
describe('ClaimLines', () => {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import ClaimLinesImport from 'pages/Claim/Card/ClaimLinesImport.vue';
|
||||
|
||||
describe('ClaimLinesImport', () => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import ClaimPhoto from 'pages/Claim/Card/ClaimPhoto.vue';
|
||||
|
||||
describe('ClaimPhoto', () => {
|
||||
let vm;
|
||||
|
||||
|
@ -61,7 +61,7 @@ describe('ClaimPhoto', () => {
|
|||
title: 'This file will be deleted',
|
||||
icon: 'delete',
|
||||
data: { index: 1 },
|
||||
promise: vm.deleteDms
|
||||
promise: vm.deleteDms,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
|
|
@ -9,6 +9,7 @@ import VnInput from 'src/components/common/VnInput.vue';
|
|||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
|
||||
import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue';
|
||||
import VnInputBic from 'src/components/common/VnInputBic.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
@ -17,7 +18,7 @@ const bankEntitiesRef = ref(null);
|
|||
|
||||
const filter = {
|
||||
fields: ['id', 'bic', 'name'],
|
||||
order: 'bic ASC'
|
||||
order: 'bic ASC',
|
||||
};
|
||||
|
||||
const getBankEntities = (data, formData) => {
|
||||
|
@ -43,13 +44,11 @@ const getBankEntities = (data, formData) => {
|
|||
</VnRow>
|
||||
|
||||
<VnRow>
|
||||
<VnInput :label="t('IBAN')" clearable v-model="data.iban">
|
||||
<template #append>
|
||||
<QIcon name="info" class="cursor-info">
|
||||
<QTooltip>{{ t('components.iban_tooltip') }}</QTooltip>
|
||||
</QIcon>
|
||||
</template>
|
||||
</VnInput>
|
||||
<VnInputBic
|
||||
:label="t('IBAN')"
|
||||
v-model="data.iban"
|
||||
@update-bic="(bankEntityFk) => (data.bankEntityFk = bankEntityFk)"
|
||||
/>
|
||||
<VnSelectDialog
|
||||
:label="t('Swift / BIC')"
|
||||
ref="bankEntitiesRef"
|
||||
|
|
|
@ -79,7 +79,7 @@ async function acceptPropagate({ isEqualizated }) {
|
|||
observe-form-changes
|
||||
@on-data-saved="checkEtChanges"
|
||||
>
|
||||
<template #form="{ data, validate }">
|
||||
<template #form="{ data, validate, validations }">
|
||||
<VnRow>
|
||||
<VnInput
|
||||
:label="t('Social name')"
|
||||
|
@ -112,6 +112,7 @@ async function acceptPropagate({ isEqualizated }) {
|
|||
v-model="data.sageTaxTypeFk"
|
||||
data-cy="sageTaxTypeFk"
|
||||
:required="data.isTaxDataChecked"
|
||||
:rules="[(val) => validations.required(data.isTaxDataChecked, val)]"
|
||||
/>
|
||||
<VnSelect
|
||||
:label="t('Sage transaction type')"
|
||||
|
@ -122,6 +123,9 @@ async function acceptPropagate({ isEqualizated }) {
|
|||
data-cy="sageTransactionTypeFk"
|
||||
v-model="data.sageTransactionTypeFk"
|
||||
:required="data.isTaxDataChecked"
|
||||
:rules="[
|
||||
(val) => validations.required(data.sageTransactionTypeFk, val),
|
||||
]"
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
|
|
|
@ -181,7 +181,7 @@ const sumRisk = ({ clientRisks }) => {
|
|||
<QCard class="vn-one">
|
||||
<VnTitle
|
||||
:url="`#/customer/${entityId}/billing-data`"
|
||||
:text="t('customer.summary.billingData')"
|
||||
:text="t('customer.summary.payMethodFk')"
|
||||
/>
|
||||
<VnLv
|
||||
:label="t('customer.summary.payMethod')"
|
||||
|
@ -289,7 +289,7 @@ const sumRisk = ({ clientRisks }) => {
|
|||
<VnLv
|
||||
v-if="entity.creditInsurance"
|
||||
:label="t('customer.summary.securedCredit')"
|
||||
:value="toCurrency(entity.creditInsurance)"
|
||||
:value="`${toCurrency(entity.creditInsurance)} (${entity.classifications[0]?.insurances[0]?.grade || ''})`"
|
||||
:info="t('customer.summary.securedCreditInfo')"
|
||||
/>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import CustomerPayments from 'src/pages/Customer/Payments/CustomerPayments.vue';
|
||||
|
||||
describe('CustomerPayments', () => {
|
||||
|
|
|
@ -19,6 +19,7 @@ import { checkEntryLock } from 'src/composables/checkEntryLock';
|
|||
import VnRow from 'src/components/ui/VnRow.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
||||
import { beforeSave } from 'src/composables/updateMinPriceBeforeSave';
|
||||
|
||||
const $props = defineProps({
|
||||
id: {
|
||||
|
@ -415,56 +416,6 @@ function getAmountStyle(row) {
|
|||
return { color: 'var(--vn-label-color)' };
|
||||
}
|
||||
|
||||
async function beforeSave(data, getChanges) {
|
||||
try {
|
||||
const changes = data.updates;
|
||||
if (!changes) return data;
|
||||
const patchPromises = [];
|
||||
|
||||
for (const change of changes) {
|
||||
let patchData = {};
|
||||
|
||||
if ('hasMinPrice' in change.data) {
|
||||
patchData.hasMinPrice = change.data?.hasMinPrice;
|
||||
delete change.data.hasMinPrice;
|
||||
}
|
||||
if ('minPrice' in change.data) {
|
||||
patchData.minPrice = change.data?.minPrice;
|
||||
delete change.data.minPrice;
|
||||
}
|
||||
|
||||
if (Object.keys(patchData).length > 0) {
|
||||
const promise = axios
|
||||
.get('Buys/findOne', {
|
||||
params: {
|
||||
filter: {
|
||||
fields: ['itemFk'],
|
||||
where: { id: change.where.id },
|
||||
},
|
||||
},
|
||||
})
|
||||
.then((buy) => {
|
||||
return axios.patch(`Items/${buy.data.itemFk}`, patchData);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error processing change: ', change, error);
|
||||
});
|
||||
|
||||
patchPromises.push(promise);
|
||||
}
|
||||
}
|
||||
|
||||
await Promise.all(patchPromises);
|
||||
|
||||
data.updates = changes.filter((change) => Object.keys(change.data).length > 0);
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error in beforeSave:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
function invertQuantitySign(rows, sign) {
|
||||
for (const row of rows) {
|
||||
if (sign > 0) row.quantity = Math.abs(row.quantity);
|
||||
|
@ -697,7 +648,7 @@ onMounted(() => {
|
|||
:right-search="false"
|
||||
:row-click="false"
|
||||
:columns="columns"
|
||||
:beforeSaveFn="beforeSave"
|
||||
:beforeSaveFn="(data, getChanges) => beforeSave(data, getChanges, 'Buys')"
|
||||
class="buyList"
|
||||
:table-height="$props.tableHeight ?? '84vh'"
|
||||
auto-load
|
||||
|
@ -787,7 +738,7 @@ onMounted(() => {
|
|||
<span data-cy="footer-amount">{{ footer?.amount }} / </span>
|
||||
<span style="color: var(--q-positive)">{{ footer?.checkedAmount }}</span>
|
||||
</template>
|
||||
<template #column-create-itemFk="{ data }">
|
||||
<template #column-create-itemFk="{ data, validations }">
|
||||
<VnSelect
|
||||
url="Items/search"
|
||||
v-model="data.itemFk"
|
||||
|
@ -801,7 +752,8 @@ onMounted(() => {
|
|||
await setBuyUltimate(value, data);
|
||||
}
|
||||
"
|
||||
:required="true"
|
||||
required
|
||||
:rules="[(val) => validations.required(true, val)]"
|
||||
data-cy="itemFk-create-popup"
|
||||
sort-by="nickname DESC"
|
||||
>
|
||||
|
|
|
@ -79,6 +79,30 @@ const columns = computed(() => [
|
|||
inWhere: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'issued',
|
||||
label: t('invoiceOut.summary.issued'),
|
||||
component: 'date',
|
||||
format: (row) => toDate(row.issued),
|
||||
columnField: { component: null },
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'created',
|
||||
label: t('globals.created'),
|
||||
component: 'date',
|
||||
columnField: { component: null },
|
||||
format: (row) => toDate(row.created),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'dued',
|
||||
label: t('invoiceOut.summary.expirationDate'),
|
||||
component: 'date',
|
||||
columnField: { component: null },
|
||||
format: (row) => toDate(row.dued),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'clientFk',
|
||||
|
@ -132,22 +156,6 @@ const columns = computed(() => [
|
|||
cardVisible: true,
|
||||
format: (row) => toCurrency(row.amount),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'created',
|
||||
label: t('globals.created'),
|
||||
component: 'date',
|
||||
columnField: { component: null },
|
||||
format: (row) => toDate(row.created),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'dued',
|
||||
label: t('invoiceOut.summary.dued'),
|
||||
component: 'date',
|
||||
columnField: { component: null },
|
||||
format: (row) => toDate(row.dued),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'customsAgentFk',
|
||||
|
|
|
@ -22,7 +22,7 @@ const $props = defineProps({
|
|||
});
|
||||
</script>
|
||||
<template>
|
||||
<QPopupProxy style="max-width: 10px">
|
||||
<QPopupProxy style="max-width: 10px" data-cy="ItemDescriptor">
|
||||
<ItemDescriptor
|
||||
v-if="$props.id"
|
||||
:id="$props.id"
|
||||
|
|
|
@ -1,574 +1,386 @@
|
|||
<script setup>
|
||||
import { onMounted, ref, onUnmounted, nextTick, computed } from 'vue';
|
||||
import { onMounted, ref, onUnmounted, computed, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||
import FetchedTags from 'components/ui/FetchedTags.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||
import EditTableCellValueForm from 'src/components/EditTableCellValueForm.vue';
|
||||
import ItemFixedPriceFilter from './ItemFixedPriceFilter.vue';
|
||||
import { useQuasar } from 'quasar';
|
||||
import ItemDescriptorProxy from './Card/ItemDescriptorProxy.vue';
|
||||
import { tMobile } from 'src/composables/tMobile';
|
||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||
import FetchData from 'src/components/FetchData.vue';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { toDate } from 'src/filters';
|
||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||
import { useState } from 'src/composables/useState';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import axios from 'axios';
|
||||
import { isLower, isBigger } from 'src/filters/date.js';
|
||||
|
||||
import { beforeSave } from 'src/composables/updateMinPriceBeforeSave';
|
||||
|
||||
import FetchedTags from 'components/ui/FetchedTags.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import EditFixedPriceForm from 'src/pages/Item/components/EditFixedPriceForm.vue';
|
||||
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
import { QCheckbox } from 'quasar';
|
||||
import VnColor from 'src/components/common/VnColor.vue';
|
||||
|
||||
import { toDate } from 'src/filters';
|
||||
import { isLower, isBigger } from 'src/filters/date.js';
|
||||
import ItemFixedPriceFilter from './ItemFixedPriceFilter.vue';
|
||||
import ItemDescriptorProxy from './Card/ItemDescriptorProxy.vue';
|
||||
import { toCurrency } from 'src/filters';
|
||||
|
||||
const quasar = useQuasar();
|
||||
const stateStore = useStateStore();
|
||||
const { t } = useI18n();
|
||||
const { openConfirmationModal } = useVnConfirm();
|
||||
const state = useState();
|
||||
const { notify } = useNotify();
|
||||
const tableRef = ref();
|
||||
const editTableCellDialogRef = ref(null);
|
||||
const user = state.getUser();
|
||||
const fixedPrices = ref([]);
|
||||
const warehousesOptions = ref([]);
|
||||
const hasSelectedRows = computed(() => rowsSelected.value.length > 0);
|
||||
const rowsSelected = ref([]);
|
||||
const itemFixedPriceFilterRef = ref();
|
||||
|
||||
const editFixedPriceForm = ref(null);
|
||||
const selectedRows = ref([]);
|
||||
const hasSelectedRows = computed(() => selectedRows.value.length > 0);
|
||||
const isToClone = ref(false);
|
||||
const dateColor = 'var(--vn-label-text-color)';
|
||||
const state = useState();
|
||||
const user = state.getUser().fn();
|
||||
const warehouse = computed(() => user.warehouseFk);
|
||||
onMounted(async () => {
|
||||
stateStore.rightDrawer = true;
|
||||
});
|
||||
onUnmounted(() => (stateStore.rightDrawer = false));
|
||||
|
||||
const defaultColumnAttrs = {
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
};
|
||||
const columns = computed(() => [
|
||||
{
|
||||
label: t('item.fixedPrice.itemFk'),
|
||||
name: 'itemFk',
|
||||
...defaultColumnAttrs,
|
||||
isId: true,
|
||||
columnField: {
|
||||
component: 'input',
|
||||
type: 'number',
|
||||
},
|
||||
columnClass: 'shrink',
|
||||
},
|
||||
{
|
||||
label: t('globals.name'),
|
||||
name: 'name',
|
||||
...defaultColumnAttrs,
|
||||
create: true,
|
||||
label: t('item.fixedPrice.itemFk'),
|
||||
labelAbbreviation: 'Id',
|
||||
toolTip: t('item.fixedPrice.itemFk'),
|
||||
component: 'input',
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
attrs: {
|
||||
component: 'select',
|
||||
url: 'Items',
|
||||
fields: ['id', 'name', 'subName'],
|
||||
optionLabel: 'name',
|
||||
optionValue: 'name',
|
||||
optionValue: 'id',
|
||||
uppercase: false,
|
||||
},
|
||||
inWhere: true,
|
||||
},
|
||||
width: '55px',
|
||||
isEditable: false,
|
||||
},
|
||||
{
|
||||
labelAbbreviation: '',
|
||||
name: 'hex',
|
||||
columnSearch: false,
|
||||
isEditable: false,
|
||||
width: '9px',
|
||||
component: 'select',
|
||||
attrs: {
|
||||
url: 'Inks',
|
||||
fields: ['id', 'name'],
|
||||
},
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('globals.name'),
|
||||
name: 'name',
|
||||
create: true,
|
||||
component: 'input',
|
||||
isEditable: false,
|
||||
},
|
||||
{
|
||||
label: t('item.fixedPrice.groupingPrice'),
|
||||
labelAbbreviation: 'P. Group',
|
||||
toolTip: t('item.fixedPrice.groupingPrice'),
|
||||
name: 'rate2',
|
||||
...defaultColumnAttrs,
|
||||
component: 'input',
|
||||
type: 'number',
|
||||
component: 'number',
|
||||
create: true,
|
||||
createOrder: 3,
|
||||
createAttrs: {
|
||||
required: true,
|
||||
},
|
||||
width: '50px',
|
||||
format: (row) => toCurrency(row.rate2),
|
||||
},
|
||||
{
|
||||
label: t('item.fixedPrice.packingPrice'),
|
||||
labelAbbreviation: 'P. Pack',
|
||||
toolTip: t('item.fixedPrice.packingPrice'),
|
||||
name: 'rate3',
|
||||
...defaultColumnAttrs,
|
||||
component: 'input',
|
||||
type: 'number',
|
||||
component: 'number',
|
||||
create: true,
|
||||
createOrder: 4,
|
||||
createAttrs: {
|
||||
required: true,
|
||||
},
|
||||
width: '50px',
|
||||
format: (row) => toCurrency(row.rate3),
|
||||
},
|
||||
{
|
||||
name: 'hasMinPrice',
|
||||
label: t('item.fixedPrice.hasMinPrice'),
|
||||
labelAbbreviation: t('item.fixedPrice.MP'),
|
||||
toolTip: t('item.fixedPrice.hasMinPrice'),
|
||||
label: t('item.fixedPrice.hasMinPrice'),
|
||||
component: 'checkbox',
|
||||
attrs: {
|
||||
toggleIndeterminate: false,
|
||||
},
|
||||
width: '50px',
|
||||
},
|
||||
|
||||
{
|
||||
label: t('item.fixedPrice.minPrice'),
|
||||
labelAbbreviation: 'Min.P',
|
||||
toolTip: t('item.fixedPrice.minPrice'),
|
||||
name: 'minPrice',
|
||||
...defaultColumnAttrs,
|
||||
component: 'input',
|
||||
type: 'number',
|
||||
component: 'number',
|
||||
width: '50px',
|
||||
style: (row) => {
|
||||
if (!row?.hasMinPrice) return { color: 'var(--vn-label-color)' };
|
||||
},
|
||||
format: (row) => toCurrency(row.minPrice),
|
||||
},
|
||||
{
|
||||
label: t('item.fixedPrice.started'),
|
||||
field: 'started',
|
||||
name: 'started',
|
||||
format: ({ started }) => toDate(started),
|
||||
...defaultColumnAttrs,
|
||||
columnField: {
|
||||
component: 'date',
|
||||
class: 'shrink',
|
||||
},
|
||||
component: 'date',
|
||||
columnFilter: {
|
||||
component: 'date',
|
||||
},
|
||||
columnClass: 'expand',
|
||||
createAttrs: {
|
||||
required: true,
|
||||
},
|
||||
create: true,
|
||||
createOrder: 5,
|
||||
width: '65px',
|
||||
},
|
||||
{
|
||||
label: t('item.fixedPrice.ended'),
|
||||
name: 'ended',
|
||||
...defaultColumnAttrs,
|
||||
columnField: {
|
||||
component: 'date',
|
||||
class: 'shrink',
|
||||
},
|
||||
component: 'date',
|
||||
columnFilter: {
|
||||
component: 'date',
|
||||
},
|
||||
columnClass: 'expand',
|
||||
format: (row) => toDate(row.ended),
|
||||
createAttrs: {
|
||||
required: true,
|
||||
},
|
||||
create: true,
|
||||
createOrder: 6,
|
||||
width: '65px',
|
||||
},
|
||||
|
||||
{
|
||||
align: 'center',
|
||||
label: t('globals.warehouse'),
|
||||
name: 'warehouseFk',
|
||||
...defaultColumnAttrs,
|
||||
columnClass: 'shrink',
|
||||
component: 'select',
|
||||
options: warehousesOptions,
|
||||
columnFilter: {
|
||||
name: 'warehouseFk',
|
||||
inWhere: true,
|
||||
component: 'select',
|
||||
attrs: {
|
||||
options: warehousesOptions,
|
||||
'option-label': 'name',
|
||||
'option-value': 'id',
|
||||
},
|
||||
attrs: {
|
||||
url: 'Warehouses',
|
||||
fields: ['id', 'name'],
|
||||
optionLabel: 'name',
|
||||
optionValue: 'id',
|
||||
},
|
||||
create: true,
|
||||
format: (row, dashIfEmpty) => dashIfEmpty(row.warehouseName),
|
||||
width: '80px',
|
||||
},
|
||||
{
|
||||
align: 'right',
|
||||
name: 'tableActions',
|
||||
actions: [
|
||||
{
|
||||
title: t('delete'),
|
||||
icon: 'delete',
|
||||
action: (row) => confirmRemove(row),
|
||||
title: t('globals.clone'),
|
||||
icon: 'vn:clone',
|
||||
action: (row) => openCloneFixedPriceForm(row),
|
||||
isPrimary: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
const editTableFieldsOptions = [
|
||||
{
|
||||
field: 'rate2',
|
||||
label: t('item.fixedPrice.groupingPrice'),
|
||||
component: 'input',
|
||||
attrs: {
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'rate3',
|
||||
label: t('item.fixedPrice.packingPrice'),
|
||||
component: 'input',
|
||||
attrs: {
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'minPrice',
|
||||
label: t('item.fixedPrice.minPrice'),
|
||||
component: 'input',
|
||||
attrs: {
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'started',
|
||||
label: t('item.fixedPrice.started'),
|
||||
component: 'date',
|
||||
},
|
||||
{
|
||||
field: 'ended',
|
||||
label: t('item.fixedPrice.ended'),
|
||||
component: 'date',
|
||||
},
|
||||
{
|
||||
field: 'warehouseFk',
|
||||
label: t('globals.warehouse'),
|
||||
component: 'select',
|
||||
attrs: {
|
||||
options: [],
|
||||
'option-label': 'name',
|
||||
'option-value': 'id',
|
||||
},
|
||||
},
|
||||
];
|
||||
const getRowUpdateInputEvents = (props, resetMinPrice, inputType = 'text') => {
|
||||
return inputType === 'text'
|
||||
? {
|
||||
'keyup.enter': () => upsertPrice(props, resetMinPrice),
|
||||
blur: () => upsertPrice(props, resetMinPrice),
|
||||
}
|
||||
: { 'update:modelValue': () => upsertPrice(props, resetMinPrice) };
|
||||
const openEditFixedPriceForm = () => {
|
||||
editFixedPriceForm.value.show();
|
||||
};
|
||||
|
||||
const updateMinPrice = async (value, props) => {
|
||||
props.row.hasMinPrice = value;
|
||||
await upsertPrice({
|
||||
row: props.row,
|
||||
col: { field: 'hasMinPrice' },
|
||||
rowIndex: props.rowIndex,
|
||||
});
|
||||
const openCloneFixedPriceForm = (row) => {
|
||||
tableRef.value.showForm = true;
|
||||
isToClone.value = true;
|
||||
tableRef.value.create.title = t('Clone fixed price');
|
||||
tableRef.value.create.formInitialData = (({
|
||||
itemFk,
|
||||
rate2,
|
||||
rate3,
|
||||
started,
|
||||
ended,
|
||||
warehouseFk,
|
||||
}) => ({
|
||||
itemFk,
|
||||
rate2,
|
||||
rate3,
|
||||
started,
|
||||
ended,
|
||||
warehouseFk,
|
||||
}))(JSON.parse(JSON.stringify(row)));
|
||||
};
|
||||
|
||||
const validations = ({ row }) => {
|
||||
const requiredFields = [
|
||||
'itemFk',
|
||||
'started',
|
||||
'ended',
|
||||
'rate2',
|
||||
'rate3',
|
||||
'warehouseFk',
|
||||
];
|
||||
const isValid = requiredFields.every(
|
||||
(field) => row[field] !== null && row[field] !== undefined
|
||||
);
|
||||
return isValid;
|
||||
};
|
||||
const upsertPrice = async (props, resetMinPrice = false) => {
|
||||
const isValid = validations({ ...props });
|
||||
if (!isValid) {
|
||||
return;
|
||||
}
|
||||
const { row } = props;
|
||||
const changes = tableRef.value.CrudModelRef.getChanges();
|
||||
if (changes?.updates?.length > 0) {
|
||||
if (resetMinPrice) row.hasMinPrice = 0;
|
||||
}
|
||||
if (!changes.updates && !changes.creates) return;
|
||||
const data = await upsertFixedPrice(row);
|
||||
Object.assign(tableRef.value.CrudModelRef.formData[props.rowIndex], data);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
tableRef.value.reload();
|
||||
};
|
||||
|
||||
async function upsertFixedPrice(row) {
|
||||
const { data } = await axios.patch('FixedPrices/upsertFixedPrice', row);
|
||||
data.hasMinPrice = data.hasMinPrice ? 1 : 0;
|
||||
return data;
|
||||
}
|
||||
|
||||
function checkLastVisibleRow() {
|
||||
let lastVisibleRow = null;
|
||||
|
||||
getTableRows().forEach((row, index) => {
|
||||
const rect = row.getBoundingClientRect();
|
||||
if (rect.top >= 0 && rect.bottom <= window.innerHeight) {
|
||||
lastVisibleRow = index;
|
||||
}
|
||||
});
|
||||
|
||||
return lastVisibleRow;
|
||||
}
|
||||
|
||||
const addRow = (original = null) => {
|
||||
let copy = null;
|
||||
const today = Date.vnNew();
|
||||
const millisecsInDay = 86400000;
|
||||
const daysInWeek = 7;
|
||||
const nextWeek = new Date(today.getTime() + daysInWeek * millisecsInDay);
|
||||
|
||||
copy = {
|
||||
id: 0,
|
||||
started: today,
|
||||
ended: nextWeek,
|
||||
hasMinPrice: 0,
|
||||
$index: 0,
|
||||
};
|
||||
return { original, copy };
|
||||
};
|
||||
|
||||
const getTableRows = () =>
|
||||
document.getElementsByClassName('q-table')[0].querySelectorAll('tr.cursor-pointer');
|
||||
|
||||
function highlightNewRow({ $index: index }) {
|
||||
const row = getTableRows()[index];
|
||||
if (row) {
|
||||
row.classList.add('highlight');
|
||||
setTimeout(() => {
|
||||
row.classList.remove('highlight');
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
const openEditTableCellDialog = () => {
|
||||
editTableCellDialogRef.value.show();
|
||||
};
|
||||
|
||||
const onEditCellDataSaved = async () => {
|
||||
rowsSelected.value = [];
|
||||
tableRef.value.reload();
|
||||
};
|
||||
|
||||
const removeFuturePrice = async () => {
|
||||
rowsSelected.value.forEach(({ id }) => {
|
||||
const rowIndex = fixedPrices.value.findIndex(({ id }) => id === id);
|
||||
removePrice(id, rowIndex);
|
||||
});
|
||||
};
|
||||
|
||||
function confirmRemove(item, isFuture) {
|
||||
const promise = async () =>
|
||||
isFuture ? removeFuturePrice(item.id) : removePrice(item.id);
|
||||
quasar.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t('globals.rowWillBeRemoved'),
|
||||
message: t('globals.confirmDeletion'),
|
||||
promise,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const removePrice = async (id) => {
|
||||
await axios.delete(`FixedPrices/${id}`);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
tableRef.value.reload({});
|
||||
};
|
||||
const dateStyle = (date) =>
|
||||
date
|
||||
? {
|
||||
'bg-color': 'warning',
|
||||
'is-outlined': true,
|
||||
color: 'var(--vn-black-text-color)',
|
||||
}
|
||||
: {};
|
||||
: { color: dateColor, 'background-color': 'transparent' };
|
||||
|
||||
function handleOnDataSave({ CrudModelRef }) {
|
||||
const { original, copy } = addRow(CrudModelRef.formData[checkLastVisibleRow()]);
|
||||
if (original) {
|
||||
CrudModelRef.formData.splice(original?.$index ?? 0, 0, copy);
|
||||
} else {
|
||||
CrudModelRef.insert(copy);
|
||||
const onDataSaved = () => {
|
||||
tableRef.value.CrudModelRef.saveChanges();
|
||||
selectedRows.value = [];
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
if (tableRef.value) {
|
||||
tableRef.value.showForm = false;
|
||||
}
|
||||
nextTick(() => {
|
||||
highlightNewRow(original ?? { $index: 0 });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
() => tableRef.value?.showForm,
|
||||
(newVal) => {
|
||||
if (!newVal) {
|
||||
tableRef.value.create.title = '';
|
||||
tableRef.value.create.formInitialData = { warehouseFk: warehouse };
|
||||
if (tableRef.value) {
|
||||
isToClone.value = false;
|
||||
tableRef.value.create.title = t('Create fixed price');
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
@on-fetch="(data) => (warehousesOptions = data)"
|
||||
auto-load
|
||||
url="Warehouses"
|
||||
:filter="{ fields: ['id', 'name'], order: 'name ASC' }"
|
||||
/>
|
||||
<RightMenu>
|
||||
<template #right-panel>
|
||||
<ItemFixedPriceFilter
|
||||
data-key="ItemFixedPrices"
|
||||
ref="itemFixedPriceFilterRef"
|
||||
/>
|
||||
<ItemFixedPriceFilter data-key="ItemFixedPrices" />
|
||||
</template>
|
||||
</RightMenu>
|
||||
<VnSubToolbar>
|
||||
<template #st-actions>
|
||||
<VnSubToolbar />
|
||||
<Teleport to="#st-data" v-if="stateStore?.isSubToolbarShown()">
|
||||
<QBtnGroup push style="column-gap: 10px">
|
||||
<QBtn
|
||||
:disable="!hasSelectedRows"
|
||||
@click="openEditTableCellDialog()"
|
||||
@click="openEditFixedPriceForm()"
|
||||
color="primary"
|
||||
icon="edit"
|
||||
flat
|
||||
:label="t('globals.edit')"
|
||||
data-cy="FixedPriceToolbarEditBtn"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('Edit fixed price(s)') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
<QBtn
|
||||
:disable="!hasSelectedRows"
|
||||
:label="tMobile('globals.remove')"
|
||||
color="primary"
|
||||
icon="delete"
|
||||
flat
|
||||
@click="(row) => confirmRemove(row, true)"
|
||||
:title="t('globals.remove')"
|
||||
/>
|
||||
</template>
|
||||
</VnSubToolbar>
|
||||
</QBtnGroup>
|
||||
</Teleport>
|
||||
<VnTable
|
||||
:default-remove="false"
|
||||
:default-reset="false"
|
||||
:default-save="false"
|
||||
ref="tableRef"
|
||||
data-key="ItemFixedPrices"
|
||||
url="FixedPrices/filter"
|
||||
:order="['name DESC', 'itemFk DESC']"
|
||||
:order="'name DESC'"
|
||||
save-url="FixedPrices/crud"
|
||||
ref="tableRef"
|
||||
dense
|
||||
:filter="{
|
||||
where: {
|
||||
warehouseFk: user.warehouseFk,
|
||||
},
|
||||
}"
|
||||
:columns="columns"
|
||||
default-mode="table"
|
||||
auto-load
|
||||
:is-editable="true"
|
||||
:right-search="false"
|
||||
:table="{
|
||||
'row-key': 'id',
|
||||
selection: 'multiple',
|
||||
}"
|
||||
v-model:selected="rowsSelected"
|
||||
:create-as-dialog="false"
|
||||
v-model:selected="selectedRows"
|
||||
:create="{
|
||||
onDataSaved: handleOnDataSave,
|
||||
urlCreate: 'FixedPrices',
|
||||
title: t('Create fixed price'),
|
||||
formInitialData: { warehouseFk: warehouse },
|
||||
onDataSaved: () => tableRef.reload(),
|
||||
showSaveAndContinueBtn: true,
|
||||
}"
|
||||
:disable-option="{ card: true }"
|
||||
:has-sub-toolbar="false"
|
||||
auto-load
|
||||
:beforeSaveFn="(data, getChanges) => beforeSave(data, getChanges, 'FixedPrices')"
|
||||
>
|
||||
<template #header-selection="scope">
|
||||
<QCheckbox v-model="scope.selected" />
|
||||
<template #column-hex="{ row }">
|
||||
<VnColor :colors="row?.hexJson" style="height: 100%; min-width: 2000px" />
|
||||
</template>
|
||||
<template #body-selection="scope">
|
||||
{{ scope }}
|
||||
<QCheckbox flat v-model="scope.selected" />
|
||||
<template #column-name="{ row }">
|
||||
<span class="link">
|
||||
{{ row.name }}
|
||||
<ItemDescriptorProxy :id="row.itemFk" />
|
||||
</span>
|
||||
<span class="subName">{{ row.subName }}</span>
|
||||
<FetchedTags :item="row" :columns="6" />
|
||||
</template>
|
||||
|
||||
<template #column-itemFk="props">
|
||||
<template #column-started="{ row }">
|
||||
<div class="editable-text q-pb-xxs">
|
||||
<QBadge class="badge" :style="dateStyle(isLower(row?.ended))">
|
||||
{{ toDate(row?.started) }}
|
||||
</QBadge>
|
||||
</div>
|
||||
</template>
|
||||
<template #column-ended="{ row }">
|
||||
<div class="editable-text q-pb-xxs">
|
||||
<QBadge class="badge" :style="dateStyle(isBigger(row?.ended))">
|
||||
{{ toDate(row?.ended) }}
|
||||
</QBadge>
|
||||
</div>
|
||||
</template>
|
||||
<template #column-create-name="{ data }">
|
||||
<VnSelect
|
||||
style="max-width: 100px"
|
||||
url="Items/withName"
|
||||
hide-selected
|
||||
option-label="id"
|
||||
url="Items/search"
|
||||
v-model="data.itemFk"
|
||||
:label="t('item.fixedPrice.itemName')"
|
||||
:fields="['id', 'name']"
|
||||
:filter-options="['id', 'name']"
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
v-model="props.row.itemFk"
|
||||
v-on="getRowUpdateInputEvents(props, true, 'select')"
|
||||
:required="true"
|
||||
sort-by="name ASC"
|
||||
data-cy="FixedPriceCreateNameSelect"
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel> #{{ scope.opt?.id }} </QItemLabel>
|
||||
<QItemLabel caption>{{ scope.opt?.name }}</QItemLabel>
|
||||
<QItemLabel>
|
||||
{{ scope.opt.name }}
|
||||
</QItemLabel>
|
||||
<QItemLabel caption> #{{ scope.opt.id }} </QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelect>
|
||||
</template>
|
||||
<template #column-name="{ row }">
|
||||
<span class="link">
|
||||
{{ row.name }}
|
||||
</span>
|
||||
<span class="subName">{{ row.subName }}</span>
|
||||
<ItemDescriptorProxy :id="row.itemFk" />
|
||||
<FetchedTags :item="row" :columns="3" />
|
||||
</template>
|
||||
<template #column-rate2="props">
|
||||
<QTd class="col">
|
||||
<VnInput
|
||||
type="currency"
|
||||
style="width: 75px"
|
||||
v-model.number="props.row.rate2"
|
||||
v-on="getRowUpdateInputEvents(props)"
|
||||
>
|
||||
<template #append>€</template>
|
||||
</VnInput>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #column-rate3="props">
|
||||
<QTd class="col">
|
||||
<VnInput
|
||||
style="width: 75px"
|
||||
type="currency"
|
||||
v-model.number="props.row.rate3"
|
||||
v-on="getRowUpdateInputEvents(props)"
|
||||
>
|
||||
<template #append>€</template>
|
||||
</VnInput>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #column-minPrice="props">
|
||||
<QTd class="col">
|
||||
<div class="row" style="align-items: center">
|
||||
<QCheckbox
|
||||
:model-value="props.row.hasMinPrice"
|
||||
@update:model-value="updateMinPrice($event, props)"
|
||||
:false-value="0"
|
||||
:true-value="1"
|
||||
:toggle-indeterminate="false"
|
||||
/>
|
||||
<VnInput
|
||||
class="col"
|
||||
type="currency"
|
||||
mask="###.##"
|
||||
:disable="props.row.hasMinPrice === 0"
|
||||
v-model.number="props.row.minPrice"
|
||||
v-on="getRowUpdateInputEvents(props)"
|
||||
>
|
||||
<template #append>€</template>
|
||||
</VnInput>
|
||||
</div>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #column-started="props">
|
||||
<VnInputDate
|
||||
class="vnInputDate"
|
||||
:show-event="true"
|
||||
v-model="props.row.started"
|
||||
v-on="getRowUpdateInputEvents(props, false, 'date')"
|
||||
v-bind="dateStyle(isBigger(props.row.started))"
|
||||
/>
|
||||
</template>
|
||||
<template #column-ended="props">
|
||||
<VnInputDate
|
||||
class="vnInputDate"
|
||||
:show-event="true"
|
||||
v-model="props.row.ended"
|
||||
v-on="getRowUpdateInputEvents(props, false, 'date')"
|
||||
v-bind="dateStyle(isLower(props.row.ended))"
|
||||
/>
|
||||
</template>
|
||||
<template #column-warehouseFk="props">
|
||||
<QTd class="col">
|
||||
<VnSelect
|
||||
style="max-width: 150px"
|
||||
:options="warehousesOptions"
|
||||
hide-selected
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
v-model="props.row.warehouseFk"
|
||||
v-on="getRowUpdateInputEvents(props, false, 'select')"
|
||||
/>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #column-deleteAction="{ row, rowIndex }">
|
||||
<QIcon
|
||||
name="delete"
|
||||
size="sm"
|
||||
class="cursor-pointer fill-icon-on-hover"
|
||||
color="primary"
|
||||
@click.stop="
|
||||
openConfirmationModal(
|
||||
t('globals.rowWillBeRemoved'),
|
||||
t('Do you want to clone this item?'),
|
||||
() => removePrice(row.id, rowIndex)
|
||||
)
|
||||
"
|
||||
<template #column-create-warehouseFk="{ data }">
|
||||
<VnSelect
|
||||
:label="t('globals.warehouse')"
|
||||
url="Warehouses"
|
||||
v-model="data.warehouseFk"
|
||||
:fields="['id', 'name']"
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
hide-selected
|
||||
:required="true"
|
||||
sort-by="name ASC"
|
||||
data-cy="FixedPriceCreateWarehouseSelect"
|
||||
>
|
||||
<QTooltip class="text-no-wrap">
|
||||
{{ t('globals.delete') }}
|
||||
</QTooltip>
|
||||
</QIcon>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel>
|
||||
{{ scope.opt.name }}
|
||||
</QItemLabel>
|
||||
<QItemLabel caption> #{{ scope.opt.id }} </QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelect>
|
||||
</template>
|
||||
</VnTable>
|
||||
|
||||
<QDialog ref="editTableCellDialogRef">
|
||||
<EditTableCellValueForm
|
||||
<QDialog ref="editFixedPriceForm">
|
||||
<EditFixedPriceForm
|
||||
edit-url="FixedPrices/editFixedPrice"
|
||||
:rows="rowsSelected"
|
||||
:fields-options="editTableFieldsOptions"
|
||||
@on-data-saved="onEditCellDataSaved()"
|
||||
:rows="selectedRows"
|
||||
:fields-options="
|
||||
columns.filter(
|
||||
({ isEditable, component, name }) =>
|
||||
isEditable !== false && component && name !== 'itemFk',
|
||||
)
|
||||
"
|
||||
:beforeSave="beforeSave"
|
||||
@on-data-saved="onDataSaved"
|
||||
/>
|
||||
</QDialog>
|
||||
</template>
|
||||
|
@ -623,8 +435,17 @@ tbody tr.highlight .q-td {
|
|||
color: var(--vn-label-color);
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.badge {
|
||||
background-color: $warning;
|
||||
}
|
||||
</style>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
Add fixed price: Añadir precio fijado
|
||||
Edit fixed price(s): Editar precio(s) fijado(s)
|
||||
Create fixed price: Crear precio fijado
|
||||
Clone fixed price: Clonar precio fijado
|
||||
</i18n>
|
||||
|
|
|
@ -29,6 +29,7 @@ const props = defineProps({
|
|||
dense
|
||||
filled
|
||||
use-input
|
||||
:use-like="false"
|
||||
@update:model-value="searchFn()"
|
||||
sort-by="nickname ASC"
|
||||
/>
|
||||
|
@ -50,21 +51,19 @@ const props = defineProps({
|
|||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem class="q-my-md">
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnInputDate
|
||||
:label="t('params.started')"
|
||||
v-model="params.started"
|
||||
:label="t('params.started')"
|
||||
filled
|
||||
@update:model-value="searchFn()"
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem class="q-my-md">
|
||||
<QItemSection>
|
||||
<VnInputDate
|
||||
:label="t('params.ended')"
|
||||
v-model="params.ended"
|
||||
:label="t('params.ended')"
|
||||
filled
|
||||
@update:model-value="searchFn()"
|
||||
/>
|
||||
|
|
|
@ -7,7 +7,7 @@ import FetchData from 'components/FetchData.vue';
|
|||
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import { QCheckbox } from 'quasar';
|
||||
import VnCheckbox from 'src/components/common/VnCheckbox.vue';
|
||||
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import { useValidator } from 'src/composables/useValidator';
|
||||
|
@ -250,10 +250,9 @@ onMounted(async () => {
|
|||
</QItemSection>
|
||||
</QItem>
|
||||
<!-- Tags filter -->
|
||||
<QItem class="row items-center">
|
||||
<QItemLabel>
|
||||
{{ t('params.tags') }}
|
||||
</QItemLabel>
|
||||
<QItemLabel header>
|
||||
{{ t('params.tags') }}
|
||||
|
||||
<QIcon
|
||||
name="add_circle"
|
||||
class="fill-icon-on-hover q-ml-md"
|
||||
|
@ -261,7 +260,7 @@ onMounted(async () => {
|
|||
color="primary"
|
||||
@click="tagValues.push({})"
|
||||
/>
|
||||
</QItem>
|
||||
</QItemLabel>
|
||||
<QItem
|
||||
v-for="(tag, index) in tagValues"
|
||||
:key="index"
|
||||
|
@ -269,6 +268,7 @@ onMounted(async () => {
|
|||
>
|
||||
<QItemSection class="col">
|
||||
<VnSelect
|
||||
class="full-width"
|
||||
:label="t('params.tag')"
|
||||
v-model="tag.selectedTag"
|
||||
:options="tagOptions"
|
||||
|
@ -316,25 +316,19 @@ onMounted(async () => {
|
|||
/>
|
||||
</QItem>
|
||||
<!-- Filter fields -->
|
||||
<QItem class="row items-center">
|
||||
<QItemLabel>
|
||||
{{ t('More fields') }}
|
||||
</QItemLabel>
|
||||
<QItemLabel header
|
||||
>{{ t('More fields') }}
|
||||
<QIcon
|
||||
name="add_circle"
|
||||
class="fill-icon-on-hover q-ml-md"
|
||||
size="sm"
|
||||
color="primary"
|
||||
@click="fieldFiltersValues.push({})"
|
||||
/>
|
||||
</QItem>
|
||||
<QItem
|
||||
v-for="(fieldFilter, index) in fieldFiltersValues"
|
||||
:key="index"
|
||||
class="row items-center"
|
||||
>
|
||||
/></QItemLabel>
|
||||
<QItem v-for="(fieldFilter, index) in fieldFiltersValues" :key="index">
|
||||
<QItemSection class="col">
|
||||
<VnSelect
|
||||
class="full-width"
|
||||
:label="t('params.tag')"
|
||||
:model-value="fieldFilter.selectedField"
|
||||
:options="moreFields"
|
||||
|
@ -355,7 +349,7 @@ onMounted(async () => {
|
|||
/>
|
||||
</QItemSection>
|
||||
<QItemSection class="col">
|
||||
<QCheckbox
|
||||
<VnCheckbox
|
||||
v-if="fieldFilter.selectedField?.type === 'boolean'"
|
||||
v-model="fieldFilter.value"
|
||||
:label="t('params.value')"
|
||||
|
@ -370,13 +364,14 @@ onMounted(async () => {
|
|||
@keydown.enter="applyFieldFilters(params, searchFn)"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QIcon
|
||||
name="delete"
|
||||
class="fill-icon-on-hover q-ml-xs"
|
||||
size="sm"
|
||||
color="primary"
|
||||
@click="removeFieldFilter(index, params, searchFn)"
|
||||
/>
|
||||
<QItemSection side
|
||||
><QIcon
|
||||
name="delete"
|
||||
class="fill-icon-on-hover q-ml-xs"
|
||||
size="sm"
|
||||
color="primary"
|
||||
@click="removeFieldFilter(index, params, searchFn)"
|
||||
/></QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
|
|
|
@ -8,11 +8,6 @@ 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,
|
||||
|
@ -26,10 +21,14 @@ const $props = defineProps({
|
|||
type: String,
|
||||
default: '',
|
||||
},
|
||||
beforeSave: {
|
||||
type: Function,
|
||||
default: () => {},
|
||||
},
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
const { notify } = useNotify();
|
||||
const emit = defineEmits(['onDataSaved']);
|
||||
|
||||
const inputs = {
|
||||
input: markRaw(VnInput),
|
||||
|
@ -44,24 +43,13 @@ 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;
|
||||
$props.rows.forEach((row) => {
|
||||
row[selectedField.value.name] = newValue.value;
|
||||
});
|
||||
emit('onDataSaved', $props.rows);
|
||||
closeForm();
|
||||
};
|
||||
|
||||
const closeForm = () => {
|
||||
|
@ -78,21 +66,24 @@ const closeForm = () => {
|
|||
<span class="title">{{ t('Edit') }}</span>
|
||||
<span class="countLines">{{ ` ${rows.length} ` }}</span>
|
||||
<span class="title">{{ t('buy(s)') }}</span>
|
||||
<VnRow>
|
||||
<VnRow class="q-mt-md">
|
||||
<VnSelect
|
||||
class="editOption"
|
||||
:label="t('Field to edit')"
|
||||
:options="fieldsOptions"
|
||||
hide-selected
|
||||
option-label="label"
|
||||
v-model="selectedField"
|
||||
data-cy="field-to-edit"
|
||||
data-cy="EditFixedPriceSelectOption"
|
||||
@update:model-value="newValue = null"
|
||||
:class="{ 'is-select': selectedField?.component === 'select' }"
|
||||
/>
|
||||
<component
|
||||
:is="inputs[selectedField?.component || 'input']"
|
||||
v-bind="selectedField?.attrs || {}"
|
||||
v-model="newValue"
|
||||
:label="t('Value')"
|
||||
data-cy="value-to-edit"
|
||||
data-cy="EditFixedPriceValueOption"
|
||||
style="width: 200px"
|
||||
/>
|
||||
</VnRow>
|
||||
|
@ -140,6 +131,15 @@ const closeForm = () => {
|
|||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
.editOption .q-field__inner .q-field__control {
|
||||
padding: 0 !important;
|
||||
}
|
||||
.editOption.is-select .q-field__inner .q-field__control {
|
||||
padding: 0 !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
Edit: Editar
|
|
@ -0,0 +1,46 @@
|
|||
import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import EditFixedPriceForm from 'src/pages/Item/components/EditFixedPriceForm.vue';
|
||||
|
||||
describe('EditFixedPriceForm.vue', () => {
|
||||
let wrapper;
|
||||
let vm;
|
||||
|
||||
const mockRows = [
|
||||
{ id: 1, itemFk: 101 },
|
||||
{ id: 2, itemFk: 102 },
|
||||
];
|
||||
|
||||
const mockFieldsOptions = [
|
||||
{
|
||||
name: 'price',
|
||||
label: 'Price',
|
||||
component: 'input',
|
||||
attrs: { type: 'number' },
|
||||
},
|
||||
];
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = createWrapper(EditFixedPriceForm, {
|
||||
props: {
|
||||
rows: JSON.parse(JSON.stringify(mockRows)),
|
||||
fieldsOptions: mockFieldsOptions,
|
||||
},
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
vm = wrapper.vm;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should emit "onDataSaved" with updated rows on submit', async () => {
|
||||
vm.selectedField = mockFieldsOptions[0];
|
||||
vm.newValue = 199.99;
|
||||
|
||||
await vm.onSubmit();
|
||||
|
||||
expect(wrapper.emitted('onDataSaved')).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -167,6 +167,8 @@ item:
|
|||
started: Started
|
||||
ended: Ended
|
||||
warehouse: Warehouse
|
||||
MP: MP
|
||||
itemName: Item
|
||||
create:
|
||||
name: Name
|
||||
tag: Tag
|
||||
|
|
|
@ -173,6 +173,8 @@ item:
|
|||
started: Inicio
|
||||
ended: Fin
|
||||
warehouse: Almacén
|
||||
MP: PM
|
||||
itemName: Nombre
|
||||
create:
|
||||
name: Nombre
|
||||
tag: Etiqueta
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import Login from 'pages/Login/LoginMain.vue';
|
||||
import axios from 'axios';
|
||||
|
||||
describe('Login', () => {
|
||||
let vm;
|
||||
|
|
|
@ -295,13 +295,11 @@ watch(
|
|||
:user-filter="lineFilter"
|
||||
>
|
||||
<template #column-image="{ row }">
|
||||
<div class="image-wrapper">
|
||||
<VnImg
|
||||
:id="parseInt(row?.item?.image)"
|
||||
class="rounded"
|
||||
zoom-resolution="1600x900"
|
||||
/>
|
||||
</div>
|
||||
<VnImg
|
||||
:id="parseInt(row?.item?.image)"
|
||||
class="rounded"
|
||||
zoom-resolution="1600x900"
|
||||
/>
|
||||
</template>
|
||||
<template #column-id="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
|
@ -361,12 +359,6 @@ watch(
|
|||
}
|
||||
}
|
||||
|
||||
.image-wrapper {
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
margin-left: 30%;
|
||||
}
|
||||
|
||||
.header {
|
||||
color: $primary;
|
||||
font-weight: bold;
|
||||
|
|
|
@ -91,7 +91,7 @@ const totalPrice = computed(() => {
|
|||
const totalNewPrice = computed(() => {
|
||||
return rows.value.reduce(
|
||||
(acc, item) => acc + item.component.newPrice * item.quantity,
|
||||
0
|
||||
0,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -210,18 +210,18 @@ onMounted(async () => {
|
|||
flat
|
||||
>
|
||||
<template #body-cell-item="{ row }">
|
||||
<QTd @click.stop class="link">
|
||||
<QBtn flat>
|
||||
<QTd align="center">
|
||||
<span @click.stop class="link">
|
||||
{{ row.itemFk }}
|
||||
<ItemDescriptorProxy :id="row.itemFk" />
|
||||
</QBtn>
|
||||
</span>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-description="{ row }">
|
||||
<QTd style="min-width: 120px; max-width: 120px">
|
||||
<div class="column q-pb-xs" style="min-width: 120px">
|
||||
<span>{{ row.item.name }}</span>
|
||||
<FetchedTags :item="row.item" class="full-width" />
|
||||
<FetchedTags :item="row.item" class="full-width" :columns="6" />
|
||||
</div>
|
||||
</QTd>
|
||||
</template>
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import FormModelPopup from 'components/FormModelPopup.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
|
||||
import { useState } from 'src/composables/useState';
|
||||
import VnSelectWorker from 'src/components/common/VnSelectWorker.vue';
|
||||
|
||||
const emit = defineEmits(['onRequestCreated']);
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
const state = useState();
|
||||
const user = state.getUser();
|
||||
const stateFetchDataRef = ref(null);
|
||||
const statesOptions = ref([]);
|
||||
|
||||
const onStateFkChange = (formData) => (formData.userFk = user.value.id);
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
ref="stateFetchDataRef"
|
||||
url="States"
|
||||
auto-load
|
||||
@on-fetch="(data) => (statesOptions = data)"
|
||||
/>
|
||||
<FormModelPopup
|
||||
:title="t('Create tracking')"
|
||||
url-create="Tickets/state"
|
||||
model="CreateTicketTracking"
|
||||
:form-initial-data="{ ticketFk: route.params.id }"
|
||||
@on-data-saved="() => emit('onRequestCreated')"
|
||||
>
|
||||
<template #form-inputs="{ data }">
|
||||
<VnRow>
|
||||
<VnSelect
|
||||
v-model="data.stateFk"
|
||||
:label="t('ticketList.state')"
|
||||
:options="statesOptions"
|
||||
@update:model-value="onStateFkChange(data)"
|
||||
hide-selected
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
/>
|
||||
<VnSelectWorker v-model="data.userFk" :fields="['id', 'name']" />
|
||||
</VnRow>
|
||||
</template>
|
||||
</FormModelPopup>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
Create tracking: Crear estado
|
||||
</i18n>
|
|
@ -46,7 +46,7 @@ async function getClaims() {
|
|||
originalTicket.value = data[0]?.originalTicketFk;
|
||||
}
|
||||
async function getProblems() {
|
||||
const { data } = await axios.get(`Tickets/${entityId.value}/getTicketProblems`);
|
||||
const { data } = await axios.get(`Tickets/getTicketProblems`, {params: { ids: [entityId.value] }});
|
||||
if (!data) return;
|
||||
problems.value = data[0];
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ const columns = computed(() => [
|
|||
align: 'left',
|
||||
label: t('globals.quantity'),
|
||||
name: 'quantity',
|
||||
class: 'shrink',
|
||||
format: (row) => toCurrency(row.quantity),
|
||||
},
|
||||
{
|
||||
|
@ -791,7 +792,7 @@ watch(
|
|||
{{ row?.item?.subName.toUpperCase() }}
|
||||
</div>
|
||||
</div>
|
||||
<FetchedTags v-if="row.item" :item="row.item" :max-length="6" />
|
||||
<FetchedTags v-if="row.item" :item="row.item" :columns="6" :max-length="6" />
|
||||
<QPopupProxy v-if="row.id && isTicketEditable">
|
||||
<VnInput
|
||||
v-model="row.concept"
|
||||
|
|
|
@ -1,27 +1,23 @@
|
|||
<script setup>
|
||||
import { ref, computed, watch, reactive } from 'vue';
|
||||
import { ref, reactive, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
|
||||
import TicketCreateTracking from './TicketCreateTracking.vue';
|
||||
import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnSelectWorker from 'src/components/common/VnSelectWorker.vue';
|
||||
import { useState } from 'src/composables/useState';
|
||||
|
||||
import { toDateTimeFormat } from 'src/filters/date.js';
|
||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
const state = useState();
|
||||
|
||||
const user = state.getUser();
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
const createTrackingDialogRef = ref(null);
|
||||
const paginateRef = ref(null);
|
||||
|
||||
watch(
|
||||
() => route.params.id,
|
||||
async (val) => {
|
||||
paginateFilter.where.ticketFk = val;
|
||||
paginateRef.value.fetch();
|
||||
},
|
||||
);
|
||||
|
||||
const tableRef = ref(null);
|
||||
const onStateFkChange = (formData) => (formData.userFk = user.value.id);
|
||||
const paginateFilter = reactive({
|
||||
include: [
|
||||
{
|
||||
|
@ -56,75 +52,68 @@ const columns = computed(() => [
|
|||
name: 'state',
|
||||
field: 'state',
|
||||
align: 'left',
|
||||
format: (val) => val.name,
|
||||
format: (row) => row.state?.name,
|
||||
},
|
||||
{
|
||||
label: t('expedition.worker'),
|
||||
name: 'worker',
|
||||
align: 'left',
|
||||
field: 'user',
|
||||
},
|
||||
{
|
||||
label: t('expedition.created'),
|
||||
name: 'created',
|
||||
field: 'created',
|
||||
align: 'left',
|
||||
format: (val) => toDateTimeFormat(val),
|
||||
format: ({ created }) => toDateTimeFormat(created),
|
||||
},
|
||||
]);
|
||||
|
||||
const openCreateModal = () => createTrackingDialogRef.value.show();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<QPage class="column items-center q-pa-md">
|
||||
<VnPaginate
|
||||
ref="paginateRef"
|
||||
data-key="TicketTracking"
|
||||
:user-filter="paginateFilter"
|
||||
search-url="table"
|
||||
url="TicketTrackings"
|
||||
auto-load
|
||||
order="created DESC"
|
||||
:limit="0"
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
<QTable
|
||||
:rows="rows"
|
||||
:columns="columns"
|
||||
row-key="id"
|
||||
:pagination="{ rowsPerPage: 0 }"
|
||||
class="full-width q-mt-md"
|
||||
:no-data-label="t('globals.noResults')"
|
||||
>
|
||||
<template #body-cell-worker="{ row }">
|
||||
<QTd>
|
||||
<QBtn flat class="link" @click.stop>
|
||||
{{ row.user?.name }}
|
||||
<WorkerDescriptorProxy :id="row.user?.worker?.id" />
|
||||
</QBtn>
|
||||
</QTd>
|
||||
</template>
|
||||
</QTable>
|
||||
</template>
|
||||
</VnPaginate>
|
||||
<QDialog
|
||||
ref="createTrackingDialogRef"
|
||||
transition-show="scale"
|
||||
transition-hide="scale"
|
||||
>
|
||||
<TicketCreateTracking @on-request-created="paginateRef.fetch()" />
|
||||
</QDialog>
|
||||
<QPageSticky :offset="[20, 20]">
|
||||
<QBtn
|
||||
@click="openCreateModal()"
|
||||
color="primary"
|
||||
fab
|
||||
icon="add"
|
||||
v-shortcut="'+'"
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
:right-search="false"
|
||||
:column-search="false"
|
||||
:disable-option="{ card: true, table: true }"
|
||||
:search-url="false"
|
||||
:columns="columns"
|
||||
data-key="TicketTracking"
|
||||
:user-filter="paginateFilter"
|
||||
url="TicketTrackings"
|
||||
auto-load
|
||||
order="created DESC"
|
||||
:limit="0"
|
||||
:without-header="true"
|
||||
:create="{
|
||||
urlCreate: 'Tickets/state',
|
||||
title: t('Create tracking'),
|
||||
onDataSaved: () => tableRef.reload(),
|
||||
formInitialData: {
|
||||
ticketFk: route.params.id,
|
||||
},
|
||||
}"
|
||||
>
|
||||
<template #more-create-dialog="{ data }">
|
||||
<VnSelect
|
||||
url="States"
|
||||
v-model="data.stateFk"
|
||||
:label="t('ticketList.state')"
|
||||
auto-load
|
||||
@update:model-value="onStateFkChange(data)"
|
||||
hide-selected
|
||||
/>
|
||||
<QTooltip class="text-no-wrap">
|
||||
{{ t('tracking.addState') }}
|
||||
</QTooltip>
|
||||
</QPageSticky>
|
||||
</QPage>
|
||||
<VnSelectWorker v-model="data.userFk" :fields="['id', 'name']" />
|
||||
</template>
|
||||
<template #column-worker="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row.user.name }}
|
||||
<WorkerDescriptorProxy :id="row.user?.worker?.id" />
|
||||
</span>
|
||||
</template>
|
||||
</VnTable>
|
||||
</template>
|
||||
<i18n>
|
||||
es:
|
||||
Create tracking: Crear estado
|
||||
</i18n>
|
||||
|
|
|
@ -134,7 +134,7 @@ onMounted(() => (stateStore.rightDrawer = true));
|
|||
auto-load
|
||||
>
|
||||
<template #column-itemFk="{ row }">
|
||||
<span class="link">
|
||||
<span class="link" @click.stop>
|
||||
{{ row.itemFk }}
|
||||
<ItemDescriptorProxy :id="row.itemFk" />
|
||||
</span>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import TicketBoxing from 'pages/Ticket/Card/TicketBoxing.vue';
|
||||
|
||||
// #4836 - Investigate how to test q-drawer outside
|
||||
|
@ -21,7 +22,11 @@ describe('TicketBoxing', () => {
|
|||
min: 1,
|
||||
max: 2,
|
||||
};
|
||||
const videoList = ['2022-01-01T01-01-00.mp4', '2022-02-02T02-02-00.mp4', '2022-03-03T03-03-00.mp4'];
|
||||
const videoList = [
|
||||
'2022-01-01T01-01-00.mp4',
|
||||
'2022-02-02T02-02-00.mp4',
|
||||
'2022-03-03T03-03-00.mp4',
|
||||
];
|
||||
|
||||
vi.spyOn(axios, 'get').mockResolvedValue({ data: videoList });
|
||||
vi.spyOn(vm.quasar, 'notify');
|
||||
|
@ -44,7 +49,9 @@ describe('TicketBoxing', () => {
|
|||
|
||||
await vm.getVideoList(expeditionId, timed);
|
||||
|
||||
expect(vm.quasar.notify).toHaveBeenCalledWith(expect.objectContaining({ type: 'negative' }));
|
||||
expect(vm.quasar.notify).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ type: 'negative' })
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,6 +14,8 @@ import { useState } from 'src/composables/useState';
|
|||
import { toDateFormat } from 'src/filters/date.js';
|
||||
import axios from 'axios';
|
||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
import { QTable } from 'quasar';
|
||||
import TicketProblems from 'src/components/TicketProblems.vue';
|
||||
|
||||
const state = useState();
|
||||
const { t } = useI18n();
|
||||
|
@ -27,6 +29,16 @@ const selectedTickets = ref([]);
|
|||
const vnTableRef = ref({});
|
||||
const originElRef = ref(null);
|
||||
const destinationElRef = ref(null);
|
||||
const actions = {
|
||||
advance: {
|
||||
title: t('advanceTickets.advanceTickets'),
|
||||
cb: moveTicketsAdvance,
|
||||
},
|
||||
advanceWithoutNegative: {
|
||||
title: t('advanceTickets.advanceTicketsWithoutNegatives'),
|
||||
cb: splitTickets,
|
||||
},
|
||||
};
|
||||
let today = Date.vnNew().toISOString();
|
||||
const tomorrow = new Date(today);
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
|
@ -78,6 +90,15 @@ const ticketColumns = computed(() => [
|
|||
headerClass: 'horizontal-separator',
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
label: t('globals.agency'),
|
||||
name: 'agency',
|
||||
field: 'agency',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
headerClass: 'horizontal-separator',
|
||||
columnFilter: false,
|
||||
},
|
||||
{
|
||||
label: t('advanceTickets.preparation'),
|
||||
name: 'preparation',
|
||||
|
@ -85,7 +106,6 @@ const ticketColumns = computed(() => [
|
|||
align: 'left',
|
||||
sortable: true,
|
||||
headerClass: 'horizontal-separator',
|
||||
columnFilter: false,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -110,10 +130,17 @@ const ticketColumns = computed(() => [
|
|||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.futureId'),
|
||||
name: 'futureId',
|
||||
label: '',
|
||||
name: 'problems',
|
||||
headerClass: 'vertical-separator horizontal-separator',
|
||||
columnClass: 'vertical-separator',
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.futureId'),
|
||||
name: 'futureId',
|
||||
headerClass: 'horizontal-separator',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -242,7 +269,7 @@ const requestComponentUpdate = async (ticket, isWithoutNegatives) => {
|
|||
return { query, params };
|
||||
};
|
||||
|
||||
const moveTicketsAdvance = async () => {
|
||||
async function moveTicketsAdvance() {
|
||||
let ticketsToMove = [];
|
||||
for (const ticket of selectedTickets.value) {
|
||||
if (!ticket.id) {
|
||||
|
@ -267,7 +294,7 @@ const moveTicketsAdvance = async () => {
|
|||
vnTableRef.value.reload();
|
||||
selectedTickets.value = [];
|
||||
if (ticketsToMove.length) notify(t('advanceTickets.moveTicketSuccess'), 'positive');
|
||||
};
|
||||
}
|
||||
|
||||
const progressLength = ref(0);
|
||||
const progressPercentage = computed(() => {
|
||||
|
@ -290,7 +317,7 @@ const progressAdd = () => {
|
|||
}
|
||||
};
|
||||
|
||||
const splitTickets = async () => {
|
||||
async function splitTickets() {
|
||||
try {
|
||||
showProgressDialog.value = true;
|
||||
for (const ticket of selectedTickets.value) {
|
||||
|
@ -310,7 +337,7 @@ const splitTickets = async () => {
|
|||
} finally {
|
||||
vnTableRef.value.reload();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const resetProgressData = () => {
|
||||
if (cancelProgress.value) cancelProgress.value = false;
|
||||
|
@ -326,6 +353,32 @@ const handleCloseProgressDialog = () => {
|
|||
|
||||
const handleCancelProgress = () => (cancelProgress.value = true);
|
||||
|
||||
const confirmAction = (action) => {
|
||||
openConfirmationModal(actions[action].title, false, actions[action].cb, null, {
|
||||
component: QTable,
|
||||
props: {
|
||||
columns: [
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.destination'),
|
||||
name: 'id',
|
||||
field: (row) => row.id,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('advanceTickets.origin'),
|
||||
name: 'futureId',
|
||||
field: (row) => row.futureId,
|
||||
},
|
||||
],
|
||||
rows: selectedTickets.value,
|
||||
class: 'full-width',
|
||||
dense: true,
|
||||
flat: true,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => vnTableRef.value.tableRef?.$el,
|
||||
($el) => {
|
||||
|
@ -399,15 +452,7 @@ watch(
|
|||
color="primary"
|
||||
class="q-mr-sm"
|
||||
:disable="!selectedTickets.length"
|
||||
@click.stop="
|
||||
openConfirmationModal(
|
||||
t('advanceTickets.advanceTicketTitle'),
|
||||
t(`advanceTickets.advanceTitleSubtitle`, {
|
||||
selectedTickets: selectedTickets.length,
|
||||
}),
|
||||
moveTicketsAdvance,
|
||||
)
|
||||
"
|
||||
@click.stop="confirmAction('advance')"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('advanceTickets.advanceTickets') }}
|
||||
|
@ -417,15 +462,7 @@ watch(
|
|||
icon="alt_route"
|
||||
color="primary"
|
||||
:disable="!selectedTickets.length"
|
||||
@click.stop="
|
||||
openConfirmationModal(
|
||||
t('advanceTickets.advanceWithoutNegativeTitle'),
|
||||
t(`advanceTickets.advanceWithoutNegativeSubtitle`, {
|
||||
selectedTickets: selectedTickets.length,
|
||||
}),
|
||||
splitTickets,
|
||||
)
|
||||
"
|
||||
@click.stop="confirmAction('advanceWithoutNegative')"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('advanceTickets.advanceTicketsWithoutNegatives') }}
|
||||
|
@ -454,9 +491,9 @@ watch(
|
|||
}"
|
||||
v-model:selected="selectedTickets"
|
||||
:pagination="{ rowsPerPage: 0 }"
|
||||
:no-data-label="t('globals.noResults')"
|
||||
:no-data-label="$t('globals.noResults')"
|
||||
:right-search="false"
|
||||
:order="['futureTotalWithVat ASC']"
|
||||
:order="['futureTotalWithVat ASC']"
|
||||
auto-load
|
||||
:disable-option="{ card: true }"
|
||||
>
|
||||
|
@ -522,6 +559,9 @@ watch(
|
|||
{{ toCurrency(row.totalWithVat || 0) }}
|
||||
</QBadge>
|
||||
</template>
|
||||
<template #column-problems="{ row }">
|
||||
<TicketProblems :row="row.problems" :visible-problems="['hasRisk']" />
|
||||
</template>
|
||||
<template #column-futureId="{ row }">
|
||||
<QBtn flat class="link" dense>
|
||||
{{ row.futureId }}
|
||||
|
|
|
@ -10,7 +10,7 @@ import VnInputDate from 'src/components/common/VnInputDate.vue';
|
|||
import axios from 'axios';
|
||||
import { onMounted } from 'vue';
|
||||
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
||||
|
||||
import VnCheckbox from 'src/components/common/VnCheckbox.vue';
|
||||
const { t, te } = useI18n();
|
||||
const props = defineProps({
|
||||
dataKey: {
|
||||
|
@ -127,18 +127,20 @@ onMounted(async () => await getItemPackingTypes());
|
|||
<QItemSection>
|
||||
<VnInputNumber
|
||||
v-model="params.scopeDays"
|
||||
:label="t('Days onward')"
|
||||
:label="t('globals.daysOnward')"
|
||||
filled
|
||||
:step="0"
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<QCheckbox
|
||||
<VnCheckbox
|
||||
:label="t('params.isFullMovable')"
|
||||
v-model="params.isFullMovable"
|
||||
toggle-indeterminate
|
||||
@update:model-value="searchFn()"
|
||||
dense
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
|
@ -171,11 +173,12 @@ onMounted(async () => await getItemPackingTypes());
|
|||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<QCheckbox
|
||||
<VnCheckbox
|
||||
toggle-indeterminate
|
||||
label="only with destination"
|
||||
:label="t('params.onlyWithDestination')"
|
||||
v-model="params.onlyWithDestination"
|
||||
@update:model-value="searchFn()"
|
||||
dense
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
|
@ -199,8 +202,8 @@ es:
|
|||
Vertical: Vertical
|
||||
iptInfo: Encajado
|
||||
params:
|
||||
dateFuture: fecha origen
|
||||
dateToAdvance: Fecha destino
|
||||
dateFuture: F. origen
|
||||
dateToAdvance: F. destino
|
||||
futureIpt: IPT Origen
|
||||
ipt: IPT destino
|
||||
isFullMovable: 100% movible
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach, beforeEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import TicketAdvance from 'pages/Ticket/TicketAdvance.vue';
|
||||
import { Notify } from 'quasar';
|
||||
import { nextTick } from 'vue';
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import axios from 'axios';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import WagonCreate from 'pages/Wagon/WagonCreate.vue';
|
||||
|
||||
describe('WagonCreate', () => {
|
||||
|
|
|
@ -166,50 +166,44 @@ const yearList = ref(generateYears());
|
|||
}}
|
||||
</QCardSection>
|
||||
</div>
|
||||
<QList dense class="list q-gutter-y-sm q-my-lg">
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnSelect
|
||||
:label="t('Year')"
|
||||
v-model="selectedYear"
|
||||
:options="yearList"
|
||||
dense
|
||||
filled
|
||||
use-input
|
||||
:is-clearable="false"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QItemSection>
|
||||
<VnSelect
|
||||
:label="t('Contract')"
|
||||
v-model="selectedBusinessFk"
|
||||
:options="contractList"
|
||||
option-value="businessFk"
|
||||
option-label="businessFk"
|
||||
dense
|
||||
filled
|
||||
use-input
|
||||
:is-clearable="false"
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel># {{ scope.opt?.businessFk }}</QItemLabel>
|
||||
<QItemLabel caption>
|
||||
{{ toDateFormat(scope.opt?.started) }} -
|
||||
{{
|
||||
scope.opt?.ended
|
||||
? toDateFormat(scope.opt?.ended)
|
||||
: 'Indef.'
|
||||
}}
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelect>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</QList>
|
||||
<div dense class="column q-gutter-y-sm q-px-md">
|
||||
<VnSelect
|
||||
:label="t('Year')"
|
||||
v-model="selectedYear"
|
||||
:options="yearList"
|
||||
dense
|
||||
filled
|
||||
use-input
|
||||
:is-clearable="false"
|
||||
/>
|
||||
<VnSelect
|
||||
:label="t('Contract')"
|
||||
v-model="selectedBusinessFk"
|
||||
:options="contractList"
|
||||
option-value="businessFk"
|
||||
option-label="businessFk"
|
||||
dense
|
||||
filled
|
||||
use-input
|
||||
:is-clearable="false"
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel># {{ scope.opt?.businessFk }}</QItemLabel>
|
||||
<QItemLabel caption>
|
||||
{{ toDateFormat(scope.opt?.started) }} -
|
||||
{{
|
||||
scope.opt?.ended
|
||||
? toDateFormat(scope.opt?.ended)
|
||||
: 'Indef.'
|
||||
}}
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelect>
|
||||
</div>
|
||||
<QList dense class="list q-gutter-y-xs q-my-md">
|
||||
<QItem v-for="type in absenceTypeList" :key="type.id">
|
||||
<WorkerEventLabel
|
||||
|
|
|
@ -11,7 +11,7 @@ const $props = defineProps({
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<QPopupProxy>
|
||||
<QPopupProxy data-cy="WorkerDescriptor">
|
||||
<WorkerDescriptor
|
||||
v-if="$props.id"
|
||||
:id="$props.id"
|
||||
|
|
|
@ -20,6 +20,7 @@ const { notify } = useNotify();
|
|||
const loadingDocuware = ref(true);
|
||||
const tableRef = ref();
|
||||
const dialog = ref();
|
||||
const getAvailablePdaRef = ref();
|
||||
const route = useRoute();
|
||||
const { openConfirmationModal } = useVnConfirm();
|
||||
const routeId = computed(() => route.params.id);
|
||||
|
@ -84,6 +85,7 @@ function reloadData() {
|
|||
initialData.value.deviceProductionFk = null;
|
||||
initialData.value.simFk = null;
|
||||
tableRef.value.reload();
|
||||
getAvailablePdaRef.value.fetch();
|
||||
}
|
||||
|
||||
async function fetchDocuware() {
|
||||
|
@ -135,6 +137,7 @@ async function deallocatePDA(deviceProductionFk) {
|
|||
);
|
||||
delete tableRef.value.CrudModelRef.formData[index];
|
||||
notify(t('PDA deallocated'), 'positive');
|
||||
await getAvailablePdaRef.value.fetch();
|
||||
}
|
||||
|
||||
function isSigned(row) {
|
||||
|
@ -144,6 +147,7 @@ function isSigned(row) {
|
|||
|
||||
<template>
|
||||
<FetchData
|
||||
ref="getAvailablePdaRef"
|
||||
url="workers/getAvailablePda"
|
||||
@on-fetch="(data) => (deviceProductions = data)"
|
||||
auto-load
|
||||
|
@ -234,7 +238,7 @@ function isSigned(row) {
|
|||
data-cy="workerPda-download"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('worker.pda.download') }}
|
||||
{{ t('globals.downloadPdf') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
</template>
|
||||
|
@ -307,4 +311,5 @@ es:
|
|||
This PDA is already assigned to another user: Este PDA ya está asignado a otro usuario
|
||||
Are you sure you want to send it?: ¿Seguro que quieres enviarlo?
|
||||
Sign PDA: Firmar PDA
|
||||
PDF sended to signed: PDF enviado para firmar
|
||||
</i18n>
|
||||
|
|
|
@ -18,6 +18,8 @@ import { useState } from 'src/composables/useState';
|
|||
import axios from 'axios';
|
||||
import VnSelectWorker from 'src/components/common/VnSelectWorker.vue';
|
||||
import VnSection from 'src/components/common/VnSection.vue';
|
||||
import VnInputBic from 'src/components/common/VnInputBic.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const tableRef = ref();
|
||||
const { viewSummary } = useSummaryDialog();
|
||||
|
@ -161,16 +163,6 @@ function generateCodeUser(worker) {
|
|||
|
||||
if (!worker.companyFk) worker.companyFk = user.companyFk;
|
||||
}
|
||||
|
||||
async function autofillBic(worker) {
|
||||
if (!worker || !worker.iban) return;
|
||||
|
||||
let bankEntityId = parseInt(worker.iban.substr(4, 4));
|
||||
let filter = { where: { id: bankEntityId } };
|
||||
|
||||
const { data } = await axios.get(`BankEntities`, { params: { filter } });
|
||||
worker.bankEntityFk = data?.[0]?.id ?? undefined;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
|
@ -331,20 +323,14 @@ async function autofillBic(worker) {
|
|||
(val) => !val && delete data.payMethodFk
|
||||
"
|
||||
/>
|
||||
<VnInput
|
||||
<VnInputBic
|
||||
:label="t('IBAN')"
|
||||
v-model="data.iban"
|
||||
:label="t('worker.create.iban')"
|
||||
:disable="data.isFreelance"
|
||||
@update:model-value="autofillBic(data)"
|
||||
>
|
||||
<template #append>
|
||||
<QIcon name="info" class="cursor-info">
|
||||
<QTooltip>{{
|
||||
t('components.iban_tooltip')
|
||||
}}</QTooltip>
|
||||
</QIcon>
|
||||
</template>
|
||||
</VnInput>
|
||||
@update-bic="
|
||||
(bankEntityFk) => (data.bankEntityFk = bankEntityFk)
|
||||
"
|
||||
/>
|
||||
</VnRow>
|
||||
<VnRow>
|
||||
<VnSelectDialog
|
||||
|
@ -362,7 +348,6 @@ async function autofillBic(worker) {
|
|||
},
|
||||
]"
|
||||
:disable="data.isFreelance"
|
||||
@update:model-value="autofillBic(data)"
|
||||
:filter-options="['bic', 'name']"
|
||||
>
|
||||
<template #form>
|
||||
|
|
|
@ -11,7 +11,7 @@ const $props = defineProps({
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<QPopupProxy>
|
||||
<QPopupProxy data-cy="ZoneDescriptor">
|
||||
<ZoneDescriptor v-if="$props.id" :id="$props.id" :summary="ZoneSummary" />
|
||||
</QPopupProxy>
|
||||
</template>
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
import { describe, expect, it, beforeEach } from 'vitest';
|
||||
import { setActivePinia, createPinia } from 'pinia';
|
||||
import { useArrayDataStore } from '../useArrayDataStore';
|
||||
|
||||
describe('useArrayDataStore', () => {
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia());
|
||||
});
|
||||
|
||||
it('should get undefined for non-existent key', () => {
|
||||
const store = useArrayDataStore();
|
||||
expect(store.get('nonExistent')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should set default state for new key', () => {
|
||||
const store = useArrayDataStore();
|
||||
store.set('test');
|
||||
const state = store.get('test');
|
||||
|
||||
expect(state).toMatchObject({
|
||||
filter: {},
|
||||
userFilter: {},
|
||||
userParams: {},
|
||||
url: '',
|
||||
limit: 20,
|
||||
skip: 0,
|
||||
order: '',
|
||||
isLoading: false,
|
||||
userParamsChanged: false,
|
||||
exprBuilder: null,
|
||||
searchUrl: 'params',
|
||||
navigate: null,
|
||||
page: 1,
|
||||
mapKey: 'id',
|
||||
oneRecord: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('should clear state for specific key', () => {
|
||||
const store = useArrayDataStore();
|
||||
store.set('test');
|
||||
store.clear('test');
|
||||
expect(store.get('test')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should reset all properties when no options provided', () => {
|
||||
const store = useArrayDataStore();
|
||||
store.set('test');
|
||||
const state = store.get('test');
|
||||
state.limit = 50;
|
||||
state.page = 3;
|
||||
|
||||
store.reset('test');
|
||||
expect(store.get('test').limit).toBe(20);
|
||||
expect(store.get('test').page).toBe(1);
|
||||
});
|
||||
|
||||
it('should reset only specified properties', () => {
|
||||
const store = useArrayDataStore();
|
||||
store.set('test');
|
||||
const state = store.get('test');
|
||||
state.limit = 50;
|
||||
state.page = 3;
|
||||
state.url = 'test-url';
|
||||
|
||||
store.reset('test', ['limit', 'page']);
|
||||
expect(state.limit).toBe(20);
|
||||
expect(state.page).toBe(1);
|
||||
expect(state.url).toBe('test-url');
|
||||
});
|
||||
|
||||
it('should reset nested properties', () => {
|
||||
const store = useArrayDataStore();
|
||||
store.set('test');
|
||||
const state = store.get('test');
|
||||
state.filter.skip = 10;
|
||||
|
||||
store.reset('test', ['filter.skip']);
|
||||
expect(state.filter.skip).toBe(0);
|
||||
});
|
||||
|
||||
it('should reset pagination properties', () => {
|
||||
const store = useArrayDataStore();
|
||||
store.set('test');
|
||||
const state = store.get('test');
|
||||
state.skip = 20;
|
||||
state.filter.skip = 20;
|
||||
state.page = 3;
|
||||
|
||||
store.resetPagination('test');
|
||||
expect(state.skip).toBe(0);
|
||||
expect(state.filter.skip).toBe(0);
|
||||
expect(state.page).toBe(1);
|
||||
});
|
||||
});
|
|
@ -1,15 +1,17 @@
|
|||
import { setActivePinia, createPinia } from 'pinia';
|
||||
import { describe, beforeEach, afterEach, it, expect, vi, beforeAll } from 'vitest';
|
||||
import { describe, beforeEach, afterEach, it, expect, vi } from 'vitest';
|
||||
import { useNavigationStore } from '../useNavigationStore';
|
||||
import axios from 'axios';
|
||||
import { default as axios } from 'axios';
|
||||
|
||||
let store;
|
||||
|
||||
vi.mock('src/router/modules', () => [
|
||||
{ name: 'Item', meta: {} },
|
||||
{ name: 'Shelving', meta: {} },
|
||||
{ name: 'Order', meta: {} },
|
||||
]);
|
||||
vi.mock('src/router/modules', () => ({
|
||||
default: [
|
||||
{ name: 'Item', meta: {} },
|
||||
{ name: 'Shelving', meta: {} },
|
||||
{ name: 'Order', meta: {} },
|
||||
],
|
||||
}));
|
||||
|
||||
vi.mock('src/filters', () => ({
|
||||
toLowerCamel: vi.fn((name) => name.toLowerCase()),
|
||||
|
|
|
@ -44,7 +44,7 @@ export async function findImports(targetFile, visited = new Set(), identation =
|
|||
];
|
||||
}
|
||||
|
||||
return getUniques(fullTree); // Remove duplicates
|
||||
return getUniques([...fullTree, targetFile]); // Remove duplicates
|
||||
}
|
||||
|
||||
function getUniques(array) {
|
||||
|
|
|
@ -25,7 +25,7 @@ async function getChangedModules() {
|
|||
if (change.startsWith(E2E_PATH)) changedArray.push(change);
|
||||
changedModules = new Set(changedArray);
|
||||
}
|
||||
return [...changedModules].join('\n');
|
||||
return cleanSpecs(changedModules).join('\n');
|
||||
}
|
||||
|
||||
getChangedModules()
|
||||
|
@ -34,3 +34,20 @@ getChangedModules()
|
|||
console.error(e);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
function cleanSpecs(changedModules) {
|
||||
let specifics = [];
|
||||
const modules = [];
|
||||
for (const changed of changedModules) {
|
||||
if (changed.endsWith('*.spec.js')) {
|
||||
modules.push(changed);
|
||||
continue;
|
||||
}
|
||||
specifics.push(changed);
|
||||
}
|
||||
specifics = specifics.filter(
|
||||
(spec) => !modules.some((module) => spec.startsWith(module.split('**')[0])),
|
||||
);
|
||||
|
||||
return [...modules, ...specifics];
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
describe('InvoiceInList', () => {
|
||||
const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(1)';
|
||||
const firstId = `${firstRow} > td:nth-child(2) span`;
|
||||
const firstDetailBtn = `${firstRow} .q-btn:nth-child(1)`;
|
||||
const invoiceId = '6';
|
||||
const summaryHeaders = (opt) => `.summaryBody > .${opt} > .q-pb-lg > .header-link`;
|
||||
const mockInvoiceRef = `createMockInvoice${Math.floor(Math.random() * 100)}`;
|
||||
const mock = {
|
||||
|
@ -31,7 +31,13 @@ describe('InvoiceInList', () => {
|
|||
});
|
||||
|
||||
it('should open the details', () => {
|
||||
cy.get(firstDetailBtn).click();
|
||||
cy.get('[data-col-field="id"]').then(($cells) => {
|
||||
const exactMatch = [...$cells].find(
|
||||
(cell) => cell.textContent.trim() === invoiceId,
|
||||
);
|
||||
expect(exactMatch).to.exist;
|
||||
cy.wrap(exactMatch).closest('tr').find('.q-btn:nth-child(1)').click();
|
||||
});
|
||||
cy.get(summaryHeaders('max-width')).contains('Basic data');
|
||||
cy.get(summaryHeaders('vat')).contains('Vat');
|
||||
});
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
/// <reference types="cypress" />
|
||||
function goTo(n = 1) {
|
||||
return `.q-virtual-scroll__content > :nth-child(${n})`;
|
||||
}
|
||||
const firstRow = goTo();
|
||||
describe('Handle Items FixedPrice', () => {
|
||||
const grouping = 'Grouping price';
|
||||
const saveEditBtn = '.q-mt-lg > .q-btn--standard';
|
||||
const createForm = {
|
||||
'Grouping price': { val: '5' },
|
||||
'Packing price': { val: '5' },
|
||||
Started: { val: '01-01-2001', type: 'date' },
|
||||
Ended: { val: '15-01-2001', type: 'date' },
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
cy.viewport(1280, 720);
|
||||
cy.login('developer');
|
||||
|
@ -13,50 +18,57 @@ describe('Handle Items FixedPrice', () => {
|
|||
'.q-header > .q-toolbar > :nth-child(1) > .q-btn__content > .q-icon',
|
||||
).click();
|
||||
});
|
||||
it.skip('filter', function () {
|
||||
|
||||
it('filter by category', () => {
|
||||
cy.get('.category-filter > :nth-child(1) > .q-btn__content > .q-icon').click();
|
||||
cy.selectOption('.list > :nth-child(2)', 'Alstroemeria');
|
||||
cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content > .q-icon').click();
|
||||
|
||||
cy.addBtnClick();
|
||||
cy.selectOption(`${firstRow} > :nth-child(2)`, '#13');
|
||||
cy.get(`${firstRow} > :nth-child(4)`).find('input').type(1);
|
||||
cy.get(`${firstRow} > :nth-child(5)`).find('input').type('2');
|
||||
cy.selectOption(`${firstRow} > :nth-child(9)`, 'Warehouse One');
|
||||
cy.get('.q-notification__message').should('have.text', 'Data saved');
|
||||
/* ==== End Cypress Studio ==== */
|
||||
});
|
||||
it.skip('Create and delete ', function () {
|
||||
cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content > .q-icon').click();
|
||||
cy.addBtnClick();
|
||||
cy.selectOption(`${firstRow} > :nth-child(2)`, '#11');
|
||||
cy.get(`${firstRow} > :nth-child(4)`).type('1');
|
||||
cy.get(`${firstRow} > :nth-child(5)`).type('2');
|
||||
cy.selectOption(`${firstRow} > :nth-child(9)`, 'Warehouse One');
|
||||
cy.get('.q-notification__message').should('have.text', 'Data saved');
|
||||
cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content > .q-icon').click();
|
||||
cy.get(`${firstRow} > .text-right > .q-btn > .q-btn__content > .q-icon`).click();
|
||||
cy.get(
|
||||
'.q-card__actions > .q-btn--unelevated > .q-btn__content > .block',
|
||||
).click();
|
||||
cy.get('.q-notification__message').should('have.text', 'Data saved');
|
||||
cy.get('.q-table__middle').should('be.visible').should('have.length', 1);
|
||||
});
|
||||
|
||||
it.skip('Massive edit', function () {
|
||||
cy.get(' .bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner ').click();
|
||||
cy.get('#subToolbar > .q-btn--standard').click();
|
||||
cy.selectOption("[data-cy='field-to-edit']", 'Min price');
|
||||
cy.dataCy('value-to-edit').find('input').type('1');
|
||||
cy.get('.countLines').should('have.text', ' 1 ');
|
||||
cy.get('.q-mt-lg > .q-btn--standard').click();
|
||||
cy.get('.q-notification__message').should('have.text', 'Data saved');
|
||||
it('should create a new fixed price, then delete it', () => {
|
||||
cy.dataCy('vnTableCreateBtn').click();
|
||||
cy.dataCy('FixedPriceCreateNameSelect').type('Melee weapon combat fist 15cm');
|
||||
cy.get('.q-menu .q-item').contains('Melee weapon combat fist 15cm').click();
|
||||
cy.dataCy('FixedPriceCreateWarehouseSelect').type('Warehouse One');
|
||||
cy.get('.q-menu .q-item').contains('Warehouse One').click();
|
||||
cy.get('.q-menu').then(($menu) => {
|
||||
if ($menu.is(':visible')) {
|
||||
cy.dataCy('FixedPriceCreateWarehouseSelect').as('focusedElement').focus();
|
||||
cy.dataCy('FixedPriceCreateWarehouseSelect').blur();
|
||||
}
|
||||
});
|
||||
cy.fillInForm(createForm);
|
||||
cy.dataCy('FormModelPopup_save').click();
|
||||
cy.checkNotification('Data created');
|
||||
cy.get('[data-col-field="name"]').each(($el) => {
|
||||
cy.wrap($el)
|
||||
.invoke('text')
|
||||
.then((text) => {
|
||||
if (text.includes('Melee weapon combat fist 15cm')) {
|
||||
cy.wrap($el).parent().find('.q-checkbox').click();
|
||||
cy.get('[data-cy="crudModelDefaultRemoveBtn"]').click();
|
||||
cy.dataCy('VnConfirm_confirm').click().click();
|
||||
cy.checkNotification('Data saved');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
it.skip('Massive remove', function () {
|
||||
cy.get(' .bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner ').click();
|
||||
cy.get('#subToolbar > .q-btn--flat').click();
|
||||
cy.get(
|
||||
'.q-card__actions > .q-btn--unelevated > .q-btn__content > .block',
|
||||
).click();
|
||||
cy.get('.q-notification__message').should('have.text', 'Data saved');
|
||||
|
||||
it('should edit all items', () => {
|
||||
cy.get('.bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner').click();
|
||||
cy.dataCy('FixedPriceToolbarEditBtn').should('not.be.disabled');
|
||||
cy.dataCy('FixedPriceToolbarEditBtn').click();
|
||||
cy.dataCy('EditFixedPriceSelectOption').type(grouping);
|
||||
cy.get('.q-menu .q-item').contains(grouping).click();
|
||||
cy.dataCy('EditFixedPriceValueOption').type('5');
|
||||
cy.get(saveEditBtn).click();
|
||||
cy.checkNotification('Data saved');
|
||||
});
|
||||
|
||||
it('should remove all items', () => {
|
||||
cy.get('.bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner').click();
|
||||
cy.dataCy('crudModelDefaultRemoveBtn').should('not.be.disabled');
|
||||
cy.dataCy('crudModelDefaultRemoveBtn').click();
|
||||
cy.dataCy('VnConfirm_confirm').click();
|
||||
cy.checkNotification('Data saved');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -19,6 +19,7 @@ describe('Item summary', () => {
|
|||
cy.get('.q-menu > .q-list > :nth-child(1) > .q-item__section').click();
|
||||
cy.dataCy('regularizeStockInput').type('10');
|
||||
cy.dataCy('Warehouse_select').type('Warehouse One{enter}');
|
||||
cy.dataCy('FormModelPopup_save').click();
|
||||
cy.checkNotification('Data created');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
describe('Route extended list', () => {
|
||||
describe.skip('Route extended list', () => {
|
||||
const getSelector = (colField) => `tr:last-child > [data-col-field="${colField}"]`;
|
||||
|
||||
const selectors = {
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/// <reference types="cypress" />
|
||||
describe('TicketBasicData', () => {
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.viewport(1920, 1080);
|
||||
cy.visit('/#/ticket/31/basic-data');
|
||||
});
|
||||
|
||||
it('Should redirect to customer basic data', () => {
|
||||
cy.get('.q-page').should('be.visible');
|
||||
cy.get(':nth-child(2) > div > .text-primary').click();
|
||||
cy.dataCy('Address_select').click();
|
||||
cy.get('.q-btn-group ').find('.q-btn__content > .q-icon').click();
|
||||
cy.get(
|
||||
'[data-cy="CustomerBasicData-menu-item"] > .q-item__section--main',
|
||||
).click();
|
||||
cy.url().should('include', '/customer/1104/basic-data');
|
||||
});
|
||||
it.only('stepper', () => {
|
||||
cy.get('.q-stepper__tab--active').should('have.class', 'q-stepper__tab--active');
|
||||
|
||||
cy.get('.q-stepper__nav > .q-btn--standard').click();
|
||||
cy.get('.q-stepper__tab--done').should('have.class', 'q-stepper__tab--done');
|
||||
cy.get('.q-stepper__tab--active').should('have.class', 'q-stepper__tab--active');
|
||||
cy.get('tr:nth-child(1)>:nth-child(1)>span').should('have.class', 'link').click();
|
||||
cy.dataCy('ItemDescriptor').should('exist');
|
||||
|
||||
cy.get('.q-drawer__content > :nth-child(1)').each(() => {
|
||||
cy.get('span').should('contain.text', 'Price: €');
|
||||
cy.get('span').should('contain.text', 'New price: €');
|
||||
cy.get('span').should('contain.text', 'Difference: €');
|
||||
});
|
||||
cy.get(
|
||||
':nth-child(3) > .q-radio > .q-radio__inner > .q-radio__bg > .q-radio__check',
|
||||
).should('have.class', 'q-radio__check');
|
||||
cy.get(
|
||||
'.q-stepper__step-inner > .q-drawer-container > .q-drawer > .q-drawer__content',
|
||||
).click();
|
||||
cy.get(':nth-child(2) > :nth-child(1) > .text-weight-bold').click();
|
||||
cy.get(':nth-child(3) > .q-radio > .q-radio__inner').should(
|
||||
'have.class',
|
||||
'q-radio__inner--truthy',
|
||||
);
|
||||
cy.get('.q-drawer__content > :nth-child(2)').click();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,30 @@
|
|||
/// <reference types="cypress" />
|
||||
|
||||
describe('TicketComponents', () => {
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.viewport(1920, 1080);
|
||||
cy.visit('/#/ticket/1/components');
|
||||
});
|
||||
it('Should load layout', () => {
|
||||
cy.get('.q-page').should('be.visible');
|
||||
cy.validateScrollContent([
|
||||
{ row: 2, col: 2, text: 'Base to commission: €799.20' },
|
||||
{ row: 2, col: 3, text: 'Total without VAT: €807.20' },
|
||||
{ row: 3, col: 2, text: 'valor de compra: €425.000' },
|
||||
{ row: 3, col: 4, text: 'maná auto: €7.998' },
|
||||
{ row: 4, col: 2, text: 'Price: €5.00' },
|
||||
{ row: 4, col: 3, text: 'Bonus: €1.00' },
|
||||
{ row: 4, col: 5, text: 'Packages: 6' },
|
||||
{ row: 4, col: 4, text: 'Zone: Zone pickup A ' },
|
||||
{ row: 5, col: 2, text: 'Total price: €16.00' },
|
||||
]);
|
||||
cy.get(':nth-child(4) > .link').click();
|
||||
|
||||
cy.dataCy('ZoneDescriptor').should('exist');
|
||||
cy.getRowCol('total').should('have.text', '€250.000€247.000€4.970');
|
||||
cy.getRowCol('import').should('have.text', '€50.000€49.400€0.994');
|
||||
cy.getRowCol('components').should('have.text', 'valor de compramargenmaná auto');
|
||||
cy.getRowCol('serie').should('have.text', 'costeempresacartera_comercial');
|
||||
});
|
||||
});
|
|
@ -1,7 +1,5 @@
|
|||
/// <reference types="cypress" />
|
||||
describe('TicketList', () => {
|
||||
const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(1)';
|
||||
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.viewport(1920, 1080);
|
||||
|
@ -11,7 +9,7 @@ describe('TicketList', () => {
|
|||
const searchResults = (search) => {
|
||||
if (search) cy.typeSearchbar().type(search);
|
||||
cy.dataCy('vn-searchbar').find('input').type('{enter}');
|
||||
cy.get(firstRow).should('exist');
|
||||
cy.getRow().should('exist');
|
||||
};
|
||||
|
||||
it('should search results', () => {
|
||||
|
@ -24,13 +22,13 @@ describe('TicketList', () => {
|
|||
cy.window().then((win) => {
|
||||
cy.stub(win, 'open').as('windowOpen');
|
||||
});
|
||||
cy.get(firstRow).should('be.visible').find('.q-btn:first').click();
|
||||
cy.getRow().should('be.visible').find('.q-btn:first').click();
|
||||
cy.get('@windowOpen').should('be.calledWithMatch', /\/ticket\/\d+\/sale/);
|
||||
});
|
||||
|
||||
it('should open ticket summary', () => {
|
||||
searchResults();
|
||||
cy.get(firstRow).find('.q-btn:last').click();
|
||||
cy.getRow().find('.q-btn:last').click();
|
||||
cy.get('.summaryHeader').should('exist');
|
||||
cy.get('.summaryBody').should('exist');
|
||||
});
|
||||
|
@ -43,8 +41,9 @@ describe('TicketList', () => {
|
|||
cy.dataCy('Customer ID_input').clear('1');
|
||||
cy.dataCy('Customer ID_input').type('1101{enter}');
|
||||
|
||||
cy.get('[data-cy="vnTableCreateBtn"] > .q-btn__content > .q-icon').click();
|
||||
cy.waitSpinner();
|
||||
cy.intercept('GET', /\/api\/Clients\?filter/).as('clientFilter');
|
||||
cy.vnTableCreateBtn();
|
||||
cy.wait('@clientFilter');
|
||||
cy.dataCy('Customer_select').should('have.value', 'Bruce Wayne');
|
||||
cy.dataCy('Address_select').click();
|
||||
|
||||
|
@ -52,8 +51,7 @@ describe('TicketList', () => {
|
|||
cy.dataCy('Address_select').should('have.value', 'Bruce Wayne');
|
||||
});
|
||||
it('Client list create new ticket', () => {
|
||||
cy.dataCy('vnTableCreateBtn').should('exist');
|
||||
cy.dataCy('vnTableCreateBtn').click();
|
||||
cy.vnTableCreateBtn();
|
||||
const data = {
|
||||
Customer: { val: 1, type: 'select' },
|
||||
Warehouse: { val: 'Warehouse One', type: 'select' },
|
||||
|
|
|
@ -19,7 +19,7 @@ describe('TicketNotes', () => {
|
|||
cy.checkNotification('Data saved');
|
||||
cy.dataCy('ticketNotesRemoveNoteBtn').should('exist');
|
||||
cy.dataCy('ticketNotesRemoveNoteBtn').click();
|
||||
cy.dataCy('VnConfirm_confirm').click();
|
||||
cy.confirmVnConfirm();
|
||||
cy.checkNotification('Data saved');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/// <reference types="cypress" />
|
||||
describe('TicketPackages', () => {
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.viewport(1920, 1080);
|
||||
cy.visit('/#/ticket/31/package');
|
||||
});
|
||||
|
||||
it('Should load layout', () => {
|
||||
cy.get('.q-page').should('be.visible');
|
||||
cy.get('.vn-row > .q-btn > .q-btn__content > .q-icon').click();
|
||||
cy.dataCy('Package_select').click();
|
||||
cy.get('.q-menu :nth-child(1) >.q-item__section').click();
|
||||
cy.dataCy('Quantity_input').clear().type('5');
|
||||
cy.saveCrudModel();
|
||||
cy.checkNotification('Data saved');
|
||||
cy.get('.q-mb-md > .text-primary').click();
|
||||
cy.confirmVnConfirm();
|
||||
cy.checkNotification('Data saved');
|
||||
});
|
||||
});
|
|
@ -0,0 +1,18 @@
|
|||
/// <reference types="cypress" />
|
||||
describe('TicketPictures', () => {
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.viewport(1920, 1080);
|
||||
cy.visit('/#/ticket/31/picture');
|
||||
});
|
||||
it('Should load layout', () => {
|
||||
cy.get(':nth-child(1) > .q-card > .content').should('be.visible');
|
||||
cy.get('.content > .link').should('be.visible').click();
|
||||
cy.dataCy('ItemDescriptor').should('exist');
|
||||
cy.dataCy('vnLvColor:');
|
||||
cy.dataCy('vnLvColor:');
|
||||
cy.dataCy('vnLvTallos:');
|
||||
cy.get('.q-mt-md').should('be.visible');
|
||||
cy.get(':nth-child(1) > .q-card > .img-wrapper').should('be.visible');
|
||||
});
|
||||
});
|
|
@ -7,8 +7,7 @@ describe('TicketRequest', () => {
|
|||
});
|
||||
|
||||
it('Creates a new request', () => {
|
||||
cy.dataCy('vnTableCreateBtn').should('exist');
|
||||
cy.dataCy('vnTableCreateBtn').click();
|
||||
cy.vnTableCreateBtn();
|
||||
const data = {
|
||||
Description: { val: 'Purchase description' },
|
||||
Atender: { val: 'buyerNick', type: 'select' },
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
const firstRow = 'tbody > :nth-child(1)';
|
||||
|
||||
describe('TicketSale', () => {
|
||||
describe('Ticket #23', () => {
|
||||
describe('#23', () => {
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.login('salesBoss');
|
||||
cy.viewport(1920, 1080);
|
||||
cy.visit('/#/ticket/23/sale');
|
||||
});
|
||||
|
@ -16,10 +16,12 @@ describe('TicketSale', () => {
|
|||
cy.waitForElement('[data-cy="ticketEditManaProxy"]');
|
||||
cy.dataCy('ticketEditManaProxy').should('exist');
|
||||
cy.waitForElement('[data-cy="Price_input"]');
|
||||
cy.dataCy('Price_input').clear();
|
||||
cy.dataCy('Price_input').type(price);
|
||||
cy.dataCy('Price_input').clear().type(price);
|
||||
cy.intercept('POST', /\/api\/Sales\/\d+\/updatePrice/).as('updatePrice');
|
||||
|
||||
cy.dataCy('saveManaBtn').click();
|
||||
handleVnConfirm();
|
||||
cy.wait('@updatePrice').its('response.statusCode').should('eq', 200);
|
||||
|
||||
cy.get('[data-col-field="price"]')
|
||||
.find('.q-btn > .q-btn__content')
|
||||
|
@ -32,10 +34,14 @@ describe('TicketSale', () => {
|
|||
cy.waitForElement('[data-cy="ticketEditManaProxy"]');
|
||||
cy.dataCy('ticketEditManaProxy').should('exist');
|
||||
cy.waitForElement('[data-cy="Disc_input"]');
|
||||
cy.dataCy('Disc_input').clear();
|
||||
cy.dataCy('Disc_input').type(discount);
|
||||
cy.dataCy('Disc_input').clear().type(discount);
|
||||
cy.intercept('POST', /\/api\/Tickets\/\d+\/updateDiscount/).as(
|
||||
'updateDiscount',
|
||||
);
|
||||
|
||||
cy.dataCy('saveManaBtn').click();
|
||||
handleVnConfirm();
|
||||
cy.wait('@updateDiscount').its('response.statusCode').should('eq', 204);
|
||||
|
||||
cy.get('[data-col-field="discount"]')
|
||||
.find('.q-btn > .q-btn__content')
|
||||
|
@ -46,6 +52,8 @@ describe('TicketSale', () => {
|
|||
const concept = Math.floor(Math.random() * 100) + 1;
|
||||
cy.waitForElement(firstRow);
|
||||
cy.get('[data-col-field="item"]').click();
|
||||
cy.intercept('POST', '**/api').as('postRequest');
|
||||
|
||||
cy.get('.q-menu')
|
||||
.find('[data-cy="undefined_input"]')
|
||||
.type(concept)
|
||||
|
@ -58,6 +66,8 @@ describe('TicketSale', () => {
|
|||
const quantity = Math.floor(Math.random() * 100) + 1;
|
||||
cy.waitForElement(firstRow);
|
||||
cy.dataCy('ticketSaleQuantityInput').find('input').clear();
|
||||
cy.intercept('POST', '**/api').as('postRequest');
|
||||
|
||||
cy.dataCy('ticketSaleQuantityInput')
|
||||
.find('input')
|
||||
.type(quantity)
|
||||
|
@ -71,7 +81,7 @@ describe('TicketSale', () => {
|
|||
.should('have.value', `${quantity}`);
|
||||
});
|
||||
});
|
||||
describe('Ticket to add claim #24', () => {
|
||||
describe('#24 add claim', () => {
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.viewport(1920, 1080);
|
||||
|
@ -82,15 +92,15 @@ describe('TicketSale', () => {
|
|||
selectFirstRow();
|
||||
cy.dataCy('ticketSaleMoreActionsDropdown').click();
|
||||
cy.dataCy('createClaimItem').click();
|
||||
cy.dataCy('VnConfirm_confirm').click();
|
||||
cy.confirmVnConfirm();
|
||||
cy.url().should('contain', 'claim/');
|
||||
// Delete created claim to avoid cluttering the database
|
||||
cy.dataCy('descriptor-more-opts').click();
|
||||
cy.dataCy('deleteClaim').click();
|
||||
cy.dataCy('VnConfirm_confirm').click();
|
||||
cy.confirmVnConfirm();
|
||||
});
|
||||
});
|
||||
describe('Free ticket #31', () => {
|
||||
describe('#31 free ticket', () => {
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.viewport(1920, 1080);
|
||||
|
@ -129,7 +139,9 @@ describe('TicketSale', () => {
|
|||
cy.dataCy('ticketSaleMoreActionsDropdown').should('be.disabled');
|
||||
});
|
||||
|
||||
it('should update discount when "Update discount" is clicked', () => {
|
||||
it.only('should update discount when "Update discount" is clicked', () => {
|
||||
const discount = Number((Math.random() * 99 + 1).toFixed(2));
|
||||
|
||||
selectFirstRow();
|
||||
cy.dataCy('ticketSaleMoreActionsDropdown').click();
|
||||
cy.waitForElement('[data-cy="updateDiscountItem"]');
|
||||
|
@ -137,9 +149,13 @@ describe('TicketSale', () => {
|
|||
cy.dataCy('updateDiscountItem').click();
|
||||
cy.waitForElement('[data-cy="ticketSaleDiscountInput"]');
|
||||
cy.dataCy('ticketSaleDiscountInput').find('input').focus();
|
||||
cy.dataCy('ticketSaleDiscountInput').find('input').type('10');
|
||||
cy.intercept('POST', /\/api\/Tickets\/\d+\/updateDiscount/).as(
|
||||
'updateDiscount',
|
||||
);
|
||||
cy.dataCy('ticketSaleDiscountInput').find('input').type(discount);
|
||||
|
||||
cy.dataCy('saveManaBtn').click();
|
||||
cy.waitForElement('.q-notification__message');
|
||||
cy.wait('@updateDiscount').its('response.statusCode').should('eq', 204);
|
||||
cy.checkNotification('Data saved');
|
||||
cy.dataCy('ticketSaleMoreActionsDropdown').should('be.disabled');
|
||||
});
|
||||
|
@ -148,7 +164,7 @@ describe('TicketSale', () => {
|
|||
selectFirstRow();
|
||||
cy.dataCy('ticketSaleMoreActionsDropdown').click();
|
||||
cy.dataCy('createClaimItem').click();
|
||||
cy.dataCy('VnConfirm_confirm').click();
|
||||
cy.confirmVnConfirm();
|
||||
cy.checkNotification('Future ticket date not allowed');
|
||||
});
|
||||
|
||||
|
@ -173,7 +189,7 @@ describe('TicketSale', () => {
|
|||
cy.url().should('match', /\/ticket\/31\/log/);
|
||||
});
|
||||
});
|
||||
describe('Ticket to transfer #32', () => {
|
||||
describe('#32 transfer', () => {
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.viewport(1920, 1080);
|
||||
|
@ -194,9 +210,7 @@ function selectFirstRow() {
|
|||
cy.get(firstRow).find('.q-checkbox__inner').click();
|
||||
}
|
||||
function handleVnConfirm() {
|
||||
cy.get('[data-cy="VnConfirm_confirm"]').click();
|
||||
cy.waitForElement('.q-notification__message');
|
||||
cy.confirmVnConfirm();
|
||||
|
||||
cy.get('.q-notification__message').should('be.visible');
|
||||
cy.checkNotification('Data saved');
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/// <reference types="cypress" />
|
||||
function uncheckedSVG(className, state) {
|
||||
cy.get(`${className} .q-checkbox__svg`).should(
|
||||
state === 'checked' ? 'not.have.attr' : 'have.attr',
|
||||
'fill',
|
||||
'none',
|
||||
);
|
||||
}
|
||||
function checkedSVG(className, state) {
|
||||
cy.get(`${className} .q-checkbox__svg> .q-checkbox__truthy`).should(
|
||||
state === 'checked' ? 'not.have.attr' : 'have.attr',
|
||||
'fill',
|
||||
'none',
|
||||
);
|
||||
}
|
||||
|
||||
function clickIconAndCloseDialog(n) {
|
||||
cy.get(
|
||||
`:nth-child(1) > :nth-child(6) > :nth-child(${n}) > .q-btn__content > .q-icon`,
|
||||
).click();
|
||||
}
|
||||
|
||||
describe('TicketSaleTracking', () => {
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.viewport(1920, 1080);
|
||||
cy.visit('/#/ticket/1/sale-tracking');
|
||||
});
|
||||
|
||||
it('Should load layout', () => {
|
||||
cy.get('.q-page').should('be.visible');
|
||||
// Check checkbox states
|
||||
uncheckedSVG('.pink', 'checked');
|
||||
uncheckedSVG('.cyan', 'checked');
|
||||
uncheckedSVG('.warning', 'checked');
|
||||
uncheckedSVG('.info', 'checked');
|
||||
checkedSVG('.yellow', 'unchecked');
|
||||
|
||||
cy.get('.q-page').click();
|
||||
cy.get(
|
||||
':nth-child(1) > :nth-child(6) > :nth-child(2) > .q-btn__content > .q-icon',
|
||||
).click();
|
||||
cy.get('body').type('{esc}');
|
||||
cy.get(
|
||||
':nth-child(1) > :nth-child(6) > :nth-child(1) > .q-btn__content > .q-icon',
|
||||
).click();
|
||||
cy.get(
|
||||
'.q-dialog__inner > .q-table__container :nth-child(1) > :nth-child(2) .link.q-btn',
|
||||
).click();
|
||||
|
||||
cy.dataCy('WorkerDescriptor').should('exist');
|
||||
});
|
||||
});
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue