Compare commits
No commits in common. "dev" and "hotfix_account_descriptor" have entirely different histories.
dev
...
hotfix_acc
|
@ -1,4 +1,4 @@
|
||||||
export default {
|
module.exports = {
|
||||||
// https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
|
// https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
|
||||||
// This option interrupts the configuration hierarchy at this file
|
// This option interrupts the configuration hierarchy at this file
|
||||||
// Remove this if you have an higher level ESLint config file (it usually happens into a monorepos)
|
// Remove this if you have an higher level ESLint config file (it usually happens into a monorepos)
|
||||||
|
@ -58,7 +58,7 @@ export default {
|
||||||
rules: {
|
rules: {
|
||||||
'prefer-promise-reject-errors': 'off',
|
'prefer-promise-reject-errors': 'off',
|
||||||
'no-unused-vars': 'warn',
|
'no-unused-vars': 'warn',
|
||||||
'vue/no-multiple-template-root': 'off',
|
"vue/no-multiple-template-root": "off" ,
|
||||||
// allow debugger during development only
|
// allow debugger during development only
|
||||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||||
},
|
},
|
|
@ -29,9 +29,5 @@ yarn-error.log*
|
||||||
*.sln
|
*.sln
|
||||||
|
|
||||||
# Cypress directories and files
|
# Cypress directories and files
|
||||||
/test/cypress/videos
|
/tests/cypress/videos
|
||||||
/test/cypress/screenshots
|
/tests/cypress/screenshots
|
||||||
|
|
||||||
# VitePress directories and files
|
|
||||||
/docs/.vitepress/cache
|
|
||||||
/docs/.vuepress
|
|
|
@ -1,24 +1,23 @@
|
||||||
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
const fs = require('fs');
|
||||||
import { join, resolve } from 'path';
|
const path = require('path');
|
||||||
|
|
||||||
function getCurrentBranchName(p = process.cwd()) {
|
function getCurrentBranchName(p = process.cwd()) {
|
||||||
if (!existsSync(p)) return false;
|
if (!fs.existsSync(p)) return false;
|
||||||
|
|
||||||
const gitHeadPath = join(p, '.git', 'HEAD');
|
const gitHeadPath = path.join(p, '.git', 'HEAD');
|
||||||
|
|
||||||
if (!existsSync(gitHeadPath)) {
|
if (!fs.existsSync(gitHeadPath))
|
||||||
return getCurrentBranchName(resolve(p, '..'));
|
return getCurrentBranchName(path.resolve(p, '..'));
|
||||||
}
|
|
||||||
|
|
||||||
const headContent = readFileSync(gitHeadPath, 'utf-8');
|
const headContent = fs.readFileSync(gitHeadPath, 'utf-8');
|
||||||
return headContent.trim().split('/')[2];
|
return headContent.trim().split('/')[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
const branchName = getCurrentBranchName();
|
const branchName = getCurrentBranchName();
|
||||||
|
|
||||||
if (branchName) {
|
if (branchName) {
|
||||||
const msgPath = '.git/COMMIT_EDITMSG';
|
const msgPath = `.git/COMMIT_EDITMSG`;
|
||||||
const msg = readFileSync(msgPath, 'utf-8');
|
const msg = fs.readFileSync(msgPath, 'utf-8');
|
||||||
const reference = branchName.match(/^\d+/);
|
const reference = branchName.match(/^\d+/);
|
||||||
|
|
||||||
const referenceTag = `refs #${reference}`;
|
const referenceTag = `refs #${reference}`;
|
||||||
|
@ -27,7 +26,8 @@ if (branchName) {
|
||||||
|
|
||||||
if (splitedMsg.length > 1) {
|
if (splitedMsg.length > 1) {
|
||||||
const finalMsg = splitedMsg[0] + ': ' + referenceTag + splitedMsg.slice(1).join(':');
|
const finalMsg = splitedMsg[0] + ': ' + referenceTag + splitedMsg.slice(1).join(':');
|
||||||
writeFileSync(msgPath, finalMsg);
|
fs.writeFileSync(msgPath, finalMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export default {
|
module.exports = {
|
||||||
singleQuote: true,
|
singleQuote: true,
|
||||||
printWidth: 90,
|
printWidth: 90,
|
||||||
tabWidth: 4,
|
tabWidth: 4,
|
||||||
|
|
1166
CHANGELOG.md
1166
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
|
@ -4,8 +4,7 @@ def PROTECTED_BRANCH
|
||||||
|
|
||||||
def BRANCH_ENV = [
|
def BRANCH_ENV = [
|
||||||
test: 'test',
|
test: 'test',
|
||||||
master: 'production',
|
master: 'production'
|
||||||
beta: 'production'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
node {
|
node {
|
||||||
|
@ -16,8 +15,7 @@ node {
|
||||||
PROTECTED_BRANCH = [
|
PROTECTED_BRANCH = [
|
||||||
'dev',
|
'dev',
|
||||||
'test',
|
'test',
|
||||||
'master',
|
'master'
|
||||||
'beta'
|
|
||||||
].contains(env.BRANCH_NAME)
|
].contains(env.BRANCH_NAME)
|
||||||
|
|
||||||
// https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
|
// https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
export default { extends: ['@commitlint/config-conventional'] };
|
module.exports = { extends: ['@commitlint/config-conventional'] };
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
import { defineConfig } from 'cypress';
|
const { defineConfig } = require('cypress');
|
||||||
// https://docs.cypress.io/app/tooling/reporters
|
|
||||||
// https://docs.cypress.io/app/references/configuration
|
|
||||||
// https://www.npmjs.com/package/cypress-mochawesome-reporter
|
|
||||||
|
|
||||||
export default defineConfig({
|
module.exports = defineConfig({
|
||||||
e2e: {
|
e2e: {
|
||||||
baseUrl: 'http://localhost:9000/',
|
baseUrl: 'http://localhost:9000/',
|
||||||
experimentalStudio: true,
|
experimentalStudio: true,
|
||||||
|
@ -11,32 +8,16 @@ export default defineConfig({
|
||||||
screenshotsFolder: 'test/cypress/screenshots',
|
screenshotsFolder: 'test/cypress/screenshots',
|
||||||
supportFile: 'test/cypress/support/index.js',
|
supportFile: 'test/cypress/support/index.js',
|
||||||
videosFolder: 'test/cypress/videos',
|
videosFolder: 'test/cypress/videos',
|
||||||
downloadsFolder: 'test/cypress/downloads',
|
|
||||||
video: false,
|
video: false,
|
||||||
specPattern: 'test/cypress/integration/**/*.spec.js',
|
specPattern: 'test/cypress/integration/**/*.spec.js',
|
||||||
experimentalRunAllSpecs: true,
|
experimentalRunAllSpecs: true,
|
||||||
watchForFileChanges: true,
|
|
||||||
reporter: 'cypress-mochawesome-reporter',
|
|
||||||
reporterOptions: {
|
|
||||||
charts: true,
|
|
||||||
reportPageTitle: 'Cypress Inline Reporter',
|
|
||||||
reportFilename: '[status]_[datetime]-report',
|
|
||||||
embeddedScreenshots: true,
|
|
||||||
reportDir: 'test/cypress/reports',
|
|
||||||
inlineAssets: true,
|
|
||||||
},
|
|
||||||
component: {
|
component: {
|
||||||
componentFolder: 'src',
|
componentFolder: 'src',
|
||||||
testFiles: '**/*.spec.js',
|
testFiles: '**/*.spec.js',
|
||||||
supportFile: 'test/cypress/support/unit.js',
|
supportFile: 'test/cypress/support/unit.js',
|
||||||
},
|
},
|
||||||
setupNodeEvents: async (on, config) => {
|
setupNodeEvents(on, config) {
|
||||||
const plugin = await import('cypress-mochawesome-reporter/plugin');
|
// implement node event listeners here
|
||||||
plugin.default(on);
|
|
||||||
|
|
||||||
return config;
|
|
||||||
},
|
},
|
||||||
viewportWidth: 1280,
|
|
||||||
viewportHeight: 720,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
import { defineConfig } from 'vitepress';
|
|
||||||
|
|
||||||
// https://vitepress.dev/reference/site-config
|
|
||||||
export default defineConfig({
|
|
||||||
title: 'Lilium',
|
|
||||||
description: 'Lilium docs',
|
|
||||||
themeConfig: {
|
|
||||||
// https://vitepress.dev/reference/default-theme-config
|
|
||||||
nav: [
|
|
||||||
{ text: 'Home', link: '/' },
|
|
||||||
{ text: 'Components', link: '/components/vnInput' },
|
|
||||||
{ text: 'Composables', link: '/composables/useArrayData' },
|
|
||||||
],
|
|
||||||
|
|
||||||
sidebar: [
|
|
||||||
{
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
text: 'Components',
|
|
||||||
collapsible: true,
|
|
||||||
collapsed: true,
|
|
||||||
items: [{ text: 'VnInput', link: '/components/vnInput' }],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Composables',
|
|
||||||
collapsible: true,
|
|
||||||
collapsed: true,
|
|
||||||
items: [
|
|
||||||
{ text: 'useArrayData', link: '/composables/useArrayData' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
socialLinks: [{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }],
|
|
||||||
},
|
|
||||||
});
|
|
|
@ -1,136 +0,0 @@
|
||||||
# VnInput
|
|
||||||
|
|
||||||
`VnInput` is a custom input component that provides various useful features such as validation, input clearing, and more.
|
|
||||||
|
|
||||||
## Props
|
|
||||||
|
|
||||||
### `modelValue`
|
|
||||||
|
|
||||||
- **Type:** `String | Number`
|
|
||||||
- **Default:** `null`
|
|
||||||
- **Description:** The value of the model bound to the component.
|
|
||||||
|
|
||||||
### `isOutlined`
|
|
||||||
|
|
||||||
- **Type:** `Boolean`
|
|
||||||
- **Default:** `false`
|
|
||||||
- **Description:** If `true`, the component is rendered with an outlined style.
|
|
||||||
|
|
||||||
### `info`
|
|
||||||
|
|
||||||
- **Type:** `String`
|
|
||||||
- **Default:** `''`
|
|
||||||
- **Description:** Additional information displayed alongside the component.
|
|
||||||
|
|
||||||
### `clearable`
|
|
||||||
|
|
||||||
- **Type:** `Boolean`
|
|
||||||
- **Default:** `true`
|
|
||||||
- **Description:** If `true`, the component shows a button to clear the input.
|
|
||||||
|
|
||||||
### `emptyToNull`
|
|
||||||
|
|
||||||
- **Type:** `Boolean`
|
|
||||||
- **Default:** `true`
|
|
||||||
- **Description:** If `true`, converts empty inputs to `null`.
|
|
||||||
|
|
||||||
### `insertable`
|
|
||||||
|
|
||||||
- **Type:** `Boolean`
|
|
||||||
- **Default:** `false`
|
|
||||||
- **Description:** If `true`, allows the insertion of new values.
|
|
||||||
|
|
||||||
### `maxlength`
|
|
||||||
|
|
||||||
- **Type:** `Number`
|
|
||||||
- **Default:** `null`
|
|
||||||
- **Description:** The maximum number of characters allowed in the input.
|
|
||||||
|
|
||||||
### `uppercase`
|
|
||||||
|
|
||||||
- **Type:** `Boolean`
|
|
||||||
- **Default:** `false`
|
|
||||||
- **Description:** If `true`, converts the input text to uppercase.
|
|
||||||
|
|
||||||
## Emits
|
|
||||||
|
|
||||||
### `update:modelValue`
|
|
||||||
|
|
||||||
- **Description:** Emits the updated model value.
|
|
||||||
- **Behavior:** This event is emitted whenever the input value changes. It is used to update the model value bound to the component.
|
|
||||||
|
|
||||||
### `update:options`
|
|
||||||
|
|
||||||
- **Description:** Emits the updated options.
|
|
||||||
- **Behavior:** This event is emitted when the component's options change. It is useful for components with dynamic options.
|
|
||||||
|
|
||||||
### `keyup.enter`
|
|
||||||
|
|
||||||
- **Description:** Emits an event when the Enter key is pressed.
|
|
||||||
- **Behavior:** This event is emitted whenever the Enter key is pressed while the input is focused. It can be used to handle specific actions when the input is confirmed.
|
|
||||||
|
|
||||||
### `remove`
|
|
||||||
|
|
||||||
- **Description:** Emits an event to remove the current value.
|
|
||||||
- **Behavior:** This event is emitted when the clear button (close icon) is clicked. It is used to handle the removal of the current input value.
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
### `focus`
|
|
||||||
|
|
||||||
- **Description:** Focuses the input.
|
|
||||||
- **Behavior:** This function is exposed so it can be called from outside the component. It uses `vnInputRef.value.focus()` to focus the input.
|
|
||||||
|
|
||||||
### `handleKeydown`
|
|
||||||
|
|
||||||
- **Description:** Handles the `keydown` event of the input.
|
|
||||||
- **Behavior:** This function is called whenever a key is pressed while the input is focused. If the pressed key is `Backspace`, it does nothing. If `insertable` is `true` and the pressed key is a number, it calls `handleInsertMode`.
|
|
||||||
|
|
||||||
### `handleInsertMode`
|
|
||||||
|
|
||||||
- **Description:** Handles the insertion mode of values.
|
|
||||||
- **Behavior:** This function is called when `insertable` is `true` and a numeric key is pressed. It inserts the value at the cursor position and updates the input value. Then, it moves the cursor to the correct position.
|
|
||||||
|
|
||||||
### `handleUppercase`
|
|
||||||
|
|
||||||
- **Description:** Converts the input value to uppercase.
|
|
||||||
- **Behavior:** This function is called when the uppercase icon is clicked. It converts the current input value to uppercase.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```vue
|
|
||||||
<template>
|
|
||||||
<VnInput
|
|
||||||
v-model="inputValue"
|
|
||||||
:isOutlined="true"
|
|
||||||
info="Additional information"
|
|
||||||
:clearable="true"
|
|
||||||
:emptyToNull="true"
|
|
||||||
:insertable="false"
|
|
||||||
:maxlength="50"
|
|
||||||
:uppercase="true"
|
|
||||||
@update:modelValue="handleUpdate"
|
|
||||||
@keyup.enter="handleEnter"
|
|
||||||
@remove="handleRemove"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
|
|
||||||
const inputValue = ref('');
|
|
||||||
|
|
||||||
const handleUpdate = (value) => {
|
|
||||||
console.log('Updated value:', value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleEnter = () => {
|
|
||||||
console.log('Enter pressed');
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleRemove = () => {
|
|
||||||
console.log('Value removed');
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
```
|
|
|
@ -1,215 +0,0 @@
|
||||||
# useArrayData
|
|
||||||
|
|
||||||
`useArrayData` is a composable function that provides a set of utilities for managing array data in a Vue component. It leverages Pinia for state management and provides various methods for fetching, filtering, and manipulating data.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
|
||||||
|
|
||||||
const {
|
|
||||||
fetch,
|
|
||||||
applyFilter,
|
|
||||||
addFilter,
|
|
||||||
getCurrentFilter,
|
|
||||||
setCurrentFilter,
|
|
||||||
addFilterWhere,
|
|
||||||
addOrder,
|
|
||||||
deleteOrder,
|
|
||||||
refresh,
|
|
||||||
destroy,
|
|
||||||
loadMore,
|
|
||||||
store,
|
|
||||||
totalRows,
|
|
||||||
updateStateParams,
|
|
||||||
isLoading,
|
|
||||||
deleteOption,
|
|
||||||
reset,
|
|
||||||
resetPagination,
|
|
||||||
} = useArrayData('myKey', userOptions);
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
### `key`
|
|
||||||
|
|
||||||
- **Type:** `String`
|
|
||||||
- **Description:** A unique key to identify the data store.
|
|
||||||
|
|
||||||
### `userOptions`
|
|
||||||
|
|
||||||
- **Type:** `Object`
|
|
||||||
- **Description:** An object containing user-defined options for configuring the data store.
|
|
||||||
|
|
||||||
## Methods
|
|
||||||
|
|
||||||
### `fetch`
|
|
||||||
|
|
||||||
Fetches data from the server.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`options`** : An object with the following properties:
|
|
||||||
- `append` (Boolean): Whether to append the fetched data to the existing data.
|
|
||||||
- `updateRouter` (Boolean): Whether to update the router with the current filter.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Promise`** : A promise that resolves with the fetched data.
|
|
||||||
|
|
||||||
### `applyFilter`
|
|
||||||
|
|
||||||
Applies a filter to the data.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`filter`** : An object containing the filter criteria.
|
|
||||||
- **`params`** : Additional parameters for the filter.
|
|
||||||
- **`fetchOptions`** : Options for the fetch method.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Promise`** : A promise that resolves with the filtered data.
|
|
||||||
|
|
||||||
### `addFilter`
|
|
||||||
|
|
||||||
Adds a filter to the existing filters.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`filter`** : An object containing the filter criteria.
|
|
||||||
- **`params`** : Additional parameters for the filter.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Promise`** : A promise that resolves with the updated filter and parameters.
|
|
||||||
|
|
||||||
### `getCurrentFilter`
|
|
||||||
|
|
||||||
Gets the current filter applied to the data.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Object`** : The current filter and parameters.
|
|
||||||
|
|
||||||
### `setCurrentFilter`
|
|
||||||
|
|
||||||
Sets the current filter for the data.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Object`** : The current filter and parameters.
|
|
||||||
|
|
||||||
### `addFilterWhere`
|
|
||||||
|
|
||||||
Adds a `where` clause to the existing filters.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`where`** : An object containing the `where` clause.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Promise`** : A promise that resolves when the filter is applied.
|
|
||||||
|
|
||||||
### `addOrder`
|
|
||||||
|
|
||||||
Adds an order to the existing orders.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`field`** : The field to order by.
|
|
||||||
- **`direction`** : The direction of the order (`ASC` or `DESC`).
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Promise`** : A promise that resolves with the updated order.
|
|
||||||
|
|
||||||
### `deleteOrder`
|
|
||||||
|
|
||||||
Deletes an order from the existing orders.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`field`** : The field to delete the order for.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Promise`** : A promise that resolves when the order is deleted.
|
|
||||||
|
|
||||||
### `refresh`
|
|
||||||
|
|
||||||
Refreshes the data by re-fetching it from the server.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Promise`** : A promise that resolves with the refreshed data.
|
|
||||||
|
|
||||||
### `destroy`
|
|
||||||
|
|
||||||
Destroys the data store for the given key.
|
|
||||||
|
|
||||||
### `loadMore`
|
|
||||||
|
|
||||||
Loads more data by incrementing the pagination.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
- **`Promise`** : A promise that resolves with the additional data.
|
|
||||||
|
|
||||||
### `updateStateParams`
|
|
||||||
|
|
||||||
Updates the state parameters with the given data.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`data`** : The data to update the state parameters with.
|
|
||||||
|
|
||||||
### `deleteOption`
|
|
||||||
|
|
||||||
Deletes an option from the store.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`option`** : The option to delete.
|
|
||||||
|
|
||||||
### `reset`
|
|
||||||
|
|
||||||
Resets the store to its default state.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
- **`opts`** : An array of options to reset.
|
|
||||||
|
|
||||||
### `resetPagination`
|
|
||||||
|
|
||||||
Resets the pagination for the store.
|
|
||||||
|
|
||||||
## Computed Properties
|
|
||||||
|
|
||||||
### `totalRows`
|
|
||||||
|
|
||||||
- **Description:** The total number of rows in the data.
|
|
||||||
- **Type:** `Number`
|
|
||||||
|
|
||||||
### `isLoading`
|
|
||||||
|
|
||||||
- **Description:** Whether the data is currently being loaded.
|
|
||||||
- **Type:** `Boolean`
|
|
||||||
|
|
||||||
```vue
|
|
||||||
<script setup>
|
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
|
||||||
|
|
||||||
const userOptions = {
|
|
||||||
url: '/api/data',
|
|
||||||
limit: 10,
|
|
||||||
};
|
|
||||||
|
|
||||||
const arrayData = useArrayData('myKey', userOptions);
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
|
@ -1,13 +0,0 @@
|
||||||
---
|
|
||||||
# https://vitepress.dev/reference/default-theme-home-page
|
|
||||||
layout: home
|
|
||||||
|
|
||||||
hero:
|
|
||||||
name: 'Lilium'
|
|
||||||
text: 'Lilium docs'
|
|
||||||
tagline: Powered by Verdnatura
|
|
||||||
actions:
|
|
||||||
- theme: brand
|
|
||||||
text: Docs
|
|
||||||
link: /components/vnInput
|
|
||||||
---
|
|
135
package.json
135
package.json
|
@ -1,74 +1,65 @@
|
||||||
{
|
{
|
||||||
"name": "salix-front",
|
"name": "salix-front",
|
||||||
"version": "25.06.0",
|
"version": "24.34.0",
|
||||||
"description": "Salix frontend",
|
"description": "Salix frontend",
|
||||||
"productName": "Salix",
|
"productName": "Salix",
|
||||||
"author": "Verdnatura",
|
"author": "Verdnatura",
|
||||||
"private": true,
|
"private": true,
|
||||||
"packageManager": "pnpm@8.15.1",
|
"packageManager": "pnpm@8.15.1",
|
||||||
"type": "module",
|
"scripts": {
|
||||||
"scripts": {
|
"lint": "eslint --ext .js,.vue ./",
|
||||||
"resetDatabase": "cd ../salix && gulp docker",
|
"format": "prettier --write \"**/*.{js,vue,scss,html,md,json}\" --ignore-path .gitignore",
|
||||||
"lint": "eslint --ext .js,.vue ./",
|
"test:e2e": "cypress open",
|
||||||
"format": "prettier --write \"**/*.{js,vue,scss,html,md,json}\" --ignore-path .gitignore",
|
"test:e2e:ci": "cd ../salix && gulp docker && cd ../salix-front && cypress run",
|
||||||
"test:e2e": "cypress open",
|
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
|
||||||
"test:e2e:ci": "npm run resetDatabase && cd ../salix-front && cypress run",
|
"test:unit": "vitest",
|
||||||
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
|
"test:unit:ci": "vitest run",
|
||||||
"test:unit": "vitest",
|
"commitlint": "commitlint --edit",
|
||||||
"test:unit:ci": "vitest run",
|
"prepare": "npx husky install",
|
||||||
"commitlint": "commitlint --edit",
|
"addReferenceTag": "node .husky/addReferenceTag.js"
|
||||||
"prepare": "npx husky install",
|
},
|
||||||
"addReferenceTag": "node .husky/addReferenceTag.js",
|
"dependencies": {
|
||||||
"docs:dev": "vitepress dev docs",
|
"@quasar/cli": "^2.3.0",
|
||||||
"docs:build": "vitepress build docs",
|
"@quasar/extras": "^1.16.9",
|
||||||
"docs:preview": "vitepress preview docs"
|
"axios": "^1.4.0",
|
||||||
},
|
"chromium": "^3.0.3",
|
||||||
"dependencies": {
|
"croppie": "^2.6.5",
|
||||||
"@quasar/cli": "^2.4.1",
|
"pinia": "^2.1.3",
|
||||||
"@quasar/extras": "^1.16.16",
|
"quasar": "^2.14.5",
|
||||||
"axios": "^1.4.0",
|
"validator": "^13.9.0",
|
||||||
"chromium": "^3.0.3",
|
"vue": "^3.3.4",
|
||||||
"croppie": "^2.6.5",
|
"vue-i18n": "^9.2.2",
|
||||||
"moment": "^2.30.1",
|
"vue-router": "^4.2.1"
|
||||||
"pinia": "^2.1.3",
|
},
|
||||||
"quasar": "^2.17.7",
|
"devDependencies": {
|
||||||
"validator": "^13.9.0",
|
"@commitlint/cli": "^19.2.1",
|
||||||
"vue": "^3.5.13",
|
"@commitlint/config-conventional": "^19.1.0",
|
||||||
"vue-i18n": "^9.3.0",
|
"@intlify/unplugin-vue-i18n": "^0.8.1",
|
||||||
"vue-router": "^4.2.5"
|
"@pinia/testing": "^0.1.2",
|
||||||
},
|
"@quasar/app-vite": "^1.7.3",
|
||||||
"devDependencies": {
|
"@quasar/quasar-app-extension-qcalendar": "4.0.0-beta.15",
|
||||||
"@commitlint/cli": "^19.2.1",
|
"@quasar/quasar-app-extension-testing-unit-vitest": "^0.4.0",
|
||||||
"@commitlint/config-conventional": "^19.1.0",
|
"@vue/test-utils": "^2.4.4",
|
||||||
"@intlify/unplugin-vue-i18n": "^0.8.2",
|
"autoprefixer": "^10.4.14",
|
||||||
"@pinia/testing": "^0.1.2",
|
"cypress": "^13.6.6",
|
||||||
"@quasar/app-vite": "^2.0.8",
|
"eslint": "^8.41.0",
|
||||||
"@quasar/quasar-app-extension-qcalendar": "^4.0.2",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
"@quasar/quasar-app-extension-testing-unit-vitest": "^0.4.0",
|
"eslint-plugin-cypress": "^2.13.3",
|
||||||
"@vue/test-utils": "^2.4.4",
|
"eslint-plugin-vue": "^9.14.1",
|
||||||
"autoprefixer": "^10.4.14",
|
"husky": "^8.0.0",
|
||||||
"cypress": "^13.6.6",
|
"postcss": "^8.4.23",
|
||||||
"cypress-mochawesome-reporter": "^3.8.2",
|
"prettier": "^2.8.8",
|
||||||
"eslint": "^9.18.0",
|
"vitest": "^0.31.1"
|
||||||
"eslint-config-prettier": "^10.0.1",
|
},
|
||||||
"eslint-plugin-cypress": "^4.1.0",
|
"engines": {
|
||||||
"eslint-plugin-vue": "^9.32.0",
|
"node": "^20 || ^18 || ^16",
|
||||||
"husky": "^8.0.0",
|
"npm": ">= 8.1.2",
|
||||||
"postcss": "^8.4.23",
|
"yarn": ">= 1.21.1",
|
||||||
"prettier": "^3.4.2",
|
"bun": ">= 1.0.25"
|
||||||
"sass": "^1.83.4",
|
},
|
||||||
"vitepress": "^1.6.3",
|
"overrides": {
|
||||||
"vitest": "^0.34.0"
|
"@vitejs/plugin-vue": "^5.0.4",
|
||||||
},
|
"vite": "^5.1.4",
|
||||||
"engines": {
|
"vitest": "^0.31.1"
|
||||||
"node": "^20 || ^18 || ^16",
|
}
|
||||||
"npm": ">= 8.1.2",
|
|
||||||
"yarn": ">= 1.21.1",
|
|
||||||
"bun": ">= 1.0.25"
|
|
||||||
},
|
|
||||||
"overrides": {
|
|
||||||
"@vitejs/plugin-vue": "^5.2.1",
|
|
||||||
"vite": "^6.0.11",
|
|
||||||
"vitest": "^0.31.1"
|
|
||||||
}
|
|
||||||
}
|
}
|
5041
pnpm-lock.yaml
5041
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -1,14 +1,10 @@
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
// https://github.com/michael-ciniawsky/postcss-load-config
|
// https://github.com/michael-ciniawsky/postcss-load-config
|
||||||
|
|
||||||
import autoprefixer from 'autoprefixer';
|
module.exports = {
|
||||||
// Uncomment the following line if you want to support RTL CSS
|
|
||||||
// import rtlcss from 'postcss-rtlcss';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
plugins: [
|
plugins: [
|
||||||
// https://github.com/postcss/autoprefixer
|
// https://github.com/postcss/autoprefixer
|
||||||
autoprefixer({
|
require('autoprefixer')({
|
||||||
overrideBrowserslist: [
|
overrideBrowserslist: [
|
||||||
'last 4 Chrome versions',
|
'last 4 Chrome versions',
|
||||||
'last 4 Firefox versions',
|
'last 4 Firefox versions',
|
||||||
|
@ -22,7 +18,10 @@ export default {
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// https://github.com/elchininet/postcss-rtlcss
|
// https://github.com/elchininet/postcss-rtlcss
|
||||||
// If you want to support RTL CSS, uncomment the following line:
|
// If you want to support RTL css, then
|
||||||
// rtlcss(),
|
// 1. yarn/npm install postcss-rtlcss
|
||||||
|
// 2. optionally set quasar.config.js > framework > lang to an RTL language
|
||||||
|
// 3. uncomment the following line:
|
||||||
|
// require('postcss-rtlcss')
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
export default [
|
|
||||||
{
|
|
||||||
path: '/api',
|
|
||||||
rule: { target: 'http://0.0.0.0:3000' },
|
|
||||||
},
|
|
||||||
];
|
|
|
@ -8,11 +8,11 @@
|
||||||
// Configuration for your app
|
// Configuration for your app
|
||||||
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js
|
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js
|
||||||
|
|
||||||
import { configure } from 'quasar/wrappers';
|
const { configure } = require('quasar/wrappers');
|
||||||
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
|
const VueI18nPlugin = require('@intlify/unplugin-vue-i18n/vite');
|
||||||
import path from 'path';
|
const path = require('path');
|
||||||
|
|
||||||
export default configure(function (/* ctx */) {
|
module.exports = configure(function (/* ctx */) {
|
||||||
return {
|
return {
|
||||||
eslint: {
|
eslint: {
|
||||||
// fix: true,
|
// fix: true,
|
||||||
|
@ -179,6 +179,7 @@ export default configure(function (/* ctx */) {
|
||||||
'render', // keep this as last one
|
'render', // keep this as last one
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
// https://v2.quasar.dev/quasar-cli/developing-pwa/configuring-pwa
|
// https://v2.quasar.dev/quasar-cli/developing-pwa/configuring-pwa
|
||||||
pwa: {
|
pwa: {
|
||||||
workboxMode: 'generateSW', // or 'injectManifest'
|
workboxMode: 'generateSW', // or 'injectManifest'
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
{
|
{
|
||||||
"@quasar/testing-unit-vitest": {
|
"@quasar/testing-unit-vitest": {
|
||||||
"options": [
|
"options": ["scripts"]
|
||||||
"scripts"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"@quasar/qcalendar": {}
|
"@quasar/qcalendar": {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,23 +2,18 @@ import axios from 'axios';
|
||||||
import { useSession } from 'src/composables/useSession';
|
import { useSession } from 'src/composables/useSession';
|
||||||
import { Router } from 'src/router';
|
import { Router } from 'src/router';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
import { useStateQueryStore } from 'src/stores/useStateQueryStore';
|
|
||||||
import { getToken, isLoggedIn } from 'src/utils/session';
|
|
||||||
import { i18n } from 'src/boot/i18n';
|
|
||||||
|
|
||||||
|
const session = useSession();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
const stateQuery = useStateQueryStore();
|
|
||||||
const baseUrl = '/api/';
|
axios.defaults.baseURL = '/api/';
|
||||||
axios.defaults.baseURL = baseUrl;
|
|
||||||
const axiosNoError = axios.create({ baseURL: baseUrl });
|
|
||||||
|
|
||||||
const onRequest = (config) => {
|
const onRequest = (config) => {
|
||||||
const token = getToken();
|
const token = session.getToken();
|
||||||
if (token.length && !config.headers.Authorization) {
|
if (token.length && !config.headers.Authorization) {
|
||||||
config.headers.Authorization = token;
|
config.headers.Authorization = token;
|
||||||
config.headers['Accept-Language'] = i18n.global.locale.value;
|
|
||||||
}
|
}
|
||||||
stateQuery.add(config);
|
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,34 +22,62 @@ const onRequestError = (error) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onResponse = (response) => {
|
const onResponse = (response) => {
|
||||||
const config = response.config;
|
const { method } = response.config;
|
||||||
stateQuery.remove(config);
|
|
||||||
|
|
||||||
if (config.method === 'patch') {
|
const isSaveRequest = method === 'patch';
|
||||||
|
if (isSaveRequest) {
|
||||||
notify('globals.dataSaved', 'positive');
|
notify('globals.dataSaved', 'positive');
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onResponseError = async (error) => {
|
const onResponseError = (error) => {
|
||||||
stateQuery.remove(error.config);
|
let message = '';
|
||||||
|
|
||||||
if (isLoggedIn() && error.response?.status === 401) {
|
const response = error.response;
|
||||||
await useSession().destroy(false);
|
const responseData = response && response.data;
|
||||||
|
const responseError = responseData && response.data.error;
|
||||||
|
if (responseError) {
|
||||||
|
message = responseError.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (response?.status) {
|
||||||
|
case 422:
|
||||||
|
if (error.name == 'ValidationError')
|
||||||
|
message +=
|
||||||
|
' "' +
|
||||||
|
responseError.details.context +
|
||||||
|
'.' +
|
||||||
|
Object.keys(responseError.details.codes).join(',') +
|
||||||
|
'"';
|
||||||
|
break;
|
||||||
|
case 500:
|
||||||
|
message = 'errors.statusInternalServerError';
|
||||||
|
break;
|
||||||
|
case 502:
|
||||||
|
message = 'errors.statusBadGateway';
|
||||||
|
break;
|
||||||
|
case 504:
|
||||||
|
message = 'errors.statusGatewayTimeout';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (session.isLoggedIn() && response?.status === 401) {
|
||||||
|
session.destroy(false);
|
||||||
const hash = window.location.hash;
|
const hash = window.location.hash;
|
||||||
const url = hash.slice(1);
|
const url = hash.slice(1);
|
||||||
Router.push(`/login?redirect=${url}`);
|
Router.push(`/login?redirect=${url}`);
|
||||||
} else if (!isLoggedIn()) {
|
} else if (!session.isLoggedIn()) {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notify(message, 'negative');
|
||||||
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
};
|
};
|
||||||
|
|
||||||
axios.interceptors.request.use(onRequest, onRequestError);
|
axios.interceptors.request.use(onRequest, onRequestError);
|
||||||
axios.interceptors.response.use(onResponse, onResponseError);
|
axios.interceptors.response.use(onResponse, onResponseError);
|
||||||
axiosNoError.interceptors.request.use(onRequest);
|
|
||||||
axiosNoError.interceptors.response.use(onResponse);
|
|
||||||
|
|
||||||
export { onRequest, onResponseError, axiosNoError };
|
export { onRequest, onResponseError };
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
import { QInput } from 'quasar';
|
|
||||||
import setDefault from './setDefault';
|
|
||||||
|
|
||||||
setDefault(QInput, 'dense', true);
|
|
|
@ -1,4 +0,0 @@
|
||||||
import { QSelect } from 'quasar';
|
|
||||||
import setDefault from './setDefault';
|
|
||||||
|
|
||||||
setDefault(QSelect, 'dense', true);
|
|
|
@ -1,11 +1,9 @@
|
||||||
import { boot } from 'quasar/wrappers';
|
import { boot } from 'quasar/wrappers';
|
||||||
import { createI18n } from 'vue-i18n';
|
import { createI18n } from 'vue-i18n';
|
||||||
import messages from 'src/i18n';
|
import messages from 'src/i18n';
|
||||||
import { useState } from 'src/composables/useState';
|
|
||||||
const user = useState().getUser();
|
|
||||||
|
|
||||||
const i18n = createI18n({
|
const i18n = createI18n({
|
||||||
locale: user.value.lang || navigator.language || navigator.userLanguage,
|
locale: navigator.language || navigator.userLanguage,
|
||||||
fallbackLocale: 'en',
|
fallbackLocale: 'en',
|
||||||
globalInjection: true,
|
globalInjection: true,
|
||||||
messages,
|
messages,
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
export default {
|
|
||||||
mounted: function (el, binding) {
|
|
||||||
const shortcut = binding.value ?? '+';
|
|
||||||
|
|
||||||
const { key, ctrl, alt, callback } =
|
|
||||||
typeof shortcut === 'string'
|
|
||||||
? {
|
|
||||||
key: shortcut,
|
|
||||||
ctrl: true,
|
|
||||||
alt: true,
|
|
||||||
callback: () =>
|
|
||||||
document
|
|
||||||
.querySelector(`button[shortcut="${shortcut}"]`)
|
|
||||||
?.click(),
|
|
||||||
}
|
|
||||||
: binding.value;
|
|
||||||
|
|
||||||
const handleKeydown = (event) => {
|
|
||||||
if (event.key === key && (!ctrl || event.ctrlKey) && (!alt || event.altKey)) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Attach the event listener to the window
|
|
||||||
window.addEventListener('keydown', handleKeydown);
|
|
||||||
|
|
||||||
el._handleKeydown = handleKeydown;
|
|
||||||
},
|
|
||||||
unmounted: function (el) {
|
|
||||||
if (el._handleKeydown) {
|
|
||||||
window.removeEventListener('keydown', el._handleKeydown);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,36 +0,0 @@
|
||||||
import routes from 'src/router/modules';
|
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
|
|
||||||
let isNotified = false;
|
|
||||||
|
|
||||||
export default {
|
|
||||||
created: function () {
|
|
||||||
const router = useRouter();
|
|
||||||
const keyBindingMap = routes
|
|
||||||
.filter((route) => route.meta.keyBinding)
|
|
||||||
.reduce((map, route) => {
|
|
||||||
map['Key' + route.meta.keyBinding.toUpperCase()] = route.path;
|
|
||||||
return map;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
const handleKeyDown = (event) => {
|
|
||||||
const { ctrlKey, altKey, code } = event;
|
|
||||||
|
|
||||||
if (ctrlKey && altKey && keyBindingMap[code] && !isNotified) {
|
|
||||||
event.preventDefault();
|
|
||||||
router.push(keyBindingMap[code]);
|
|
||||||
isNotified = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleKeyUp = (event) => {
|
|
||||||
const { ctrlKey, altKey } = event;
|
|
||||||
if (!ctrlKey || !altKey) {
|
|
||||||
isNotified = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
window.addEventListener('keydown', handleKeyDown);
|
|
||||||
window.addEventListener('keyup', handleKeyUp);
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,51 +1,30 @@
|
||||||
function focusFirstInput(input) {
|
import { getCurrentInstance } from 'vue';
|
||||||
input.focus();
|
|
||||||
}
|
|
||||||
export default {
|
export default {
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
const that = this;
|
const vm = getCurrentInstance();
|
||||||
|
if (vm.type.name === 'QForm') {
|
||||||
const form = document.querySelector('.q-form#formModel');
|
if (!['searchbarForm', 'filterPanelForm'].includes(this.$el?.id)) {
|
||||||
if (!form) return;
|
// TODO: AUTOFOCUS IS NOT FOCUSING
|
||||||
try {
|
const that = this;
|
||||||
const inputsFormCard = form.querySelectorAll(
|
this.$el.addEventListener('keyup', function (evt) {
|
||||||
`input:not([disabled]):not([type="checkbox"])`
|
if (evt.key === 'Enter') {
|
||||||
);
|
const input = evt.target;
|
||||||
if (inputsFormCard.length) {
|
if (input.type == 'textarea' && evt.shiftKey) {
|
||||||
focusFirstInput(inputsFormCard[0]);
|
evt.preventDefault();
|
||||||
|
let { selectionStart, selectionEnd } = input;
|
||||||
|
input.value =
|
||||||
|
input.value.substring(0, selectionStart) +
|
||||||
|
'\n' +
|
||||||
|
input.value.substring(selectionEnd);
|
||||||
|
selectionStart = selectionEnd = selectionStart + 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
evt.preventDefault();
|
||||||
|
that.onSubmit();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
const textareas = document.querySelectorAll(
|
|
||||||
'textarea:not([disabled]), [contenteditable]:not([disabled])'
|
|
||||||
);
|
|
||||||
if (textareas.length) {
|
|
||||||
focusFirstInput(textareas[textareas.length - 1]);
|
|
||||||
}
|
|
||||||
const inputs = document.querySelectorAll(
|
|
||||||
'form#formModel input:not([disabled]):not([type="checkbox"])'
|
|
||||||
);
|
|
||||||
const input = inputs[0];
|
|
||||||
if (!input) return;
|
|
||||||
|
|
||||||
focusFirstInput(input);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
}
|
||||||
form.addEventListener('keyup', function (evt) {
|
|
||||||
if (evt.key === 'Enter' && !that.$attrs['prevent-submit']) {
|
|
||||||
const input = evt.target;
|
|
||||||
if (input.type == 'textarea' && evt.shiftKey) {
|
|
||||||
evt.preventDefault();
|
|
||||||
let { selectionStart, selectionEnd } = input;
|
|
||||||
input.value =
|
|
||||||
input.value.substring(0, selectionStart) +
|
|
||||||
'\n' +
|
|
||||||
input.value.substring(selectionEnd);
|
|
||||||
selectionStart = selectionEnd = selectionStart + 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
evt.preventDefault();
|
|
||||||
that.onSubmit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1 @@
|
||||||
export * from './defaults/qTable';
|
export * from './defaults/qTable';
|
||||||
export * from './defaults/qInput';
|
|
||||||
export * from './defaults/qSelect';
|
|
||||||
|
|
|
@ -1,54 +1,6 @@
|
||||||
import axios from 'axios';
|
|
||||||
import { boot } from 'quasar/wrappers';
|
import { boot } from 'quasar/wrappers';
|
||||||
import qFormMixin from './qformMixin';
|
import qFormMixin from './qformMixin';
|
||||||
import keyShortcut from './keyShortcut';
|
|
||||||
import { QForm } from 'quasar';
|
|
||||||
import { QLayout } from 'quasar';
|
|
||||||
import mainShortcutMixin from './mainShortcutMixin';
|
|
||||||
import { useCau } from 'src/composables/useCau';
|
|
||||||
|
|
||||||
export default boot(({ app }) => {
|
export default boot(({ app }) => {
|
||||||
QForm.mixins = [qFormMixin];
|
app.mixin(qFormMixin);
|
||||||
QLayout.mixins = [mainShortcutMixin];
|
|
||||||
|
|
||||||
app.directive('shortcut', keyShortcut);
|
|
||||||
app.config.errorHandler = async (error) => {
|
|
||||||
let message;
|
|
||||||
const response = error.response;
|
|
||||||
const responseData = response?.data;
|
|
||||||
const responseError = responseData && response.data.error;
|
|
||||||
if (responseError) {
|
|
||||||
message = responseError.message;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (response?.status) {
|
|
||||||
case 422:
|
|
||||||
if (error.name == 'ValidationError')
|
|
||||||
message +=
|
|
||||||
' "' +
|
|
||||||
responseError.details.context +
|
|
||||||
'.' +
|
|
||||||
Object.keys(responseError.details.codes).join(',') +
|
|
||||||
'"';
|
|
||||||
break;
|
|
||||||
case 500:
|
|
||||||
message = 'errors.statusInternalServerError';
|
|
||||||
break;
|
|
||||||
case 502:
|
|
||||||
message = 'errors.statusBadGateway';
|
|
||||||
break;
|
|
||||||
case 504:
|
|
||||||
message = 'errors.statusGatewayTimeout';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.error(error);
|
|
||||||
if (error instanceof axios.CanceledError) {
|
|
||||||
const env = process.env.NODE_ENV;
|
|
||||||
if (env && env !== 'development') return;
|
|
||||||
message = 'Duplicate request';
|
|
||||||
}
|
|
||||||
|
|
||||||
await useCau(response, message);
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, ref, onMounted, nextTick, computed } from 'vue';
|
import { reactive, ref, onMounted, nextTick } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
|
||||||
|
@ -7,29 +7,27 @@ import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import FormModelPopup from './FormModelPopup.vue';
|
import FormModelPopup from './FormModelPopup.vue';
|
||||||
import { useState } from 'src/composables/useState';
|
|
||||||
|
defineProps({ showEntityField: { type: Boolean, default: true } });
|
||||||
|
|
||||||
const emit = defineEmits(['onDataSaved']);
|
const emit = defineEmits(['onDataSaved']);
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const bicInputRef = ref(null);
|
const bicInputRef = ref(null);
|
||||||
const state = useState();
|
const bankEntityFormData = reactive({
|
||||||
|
name: null,
|
||||||
const customer = computed(() => state.get('customer'));
|
bic: null,
|
||||||
|
countryFk: null,
|
||||||
|
id: null,
|
||||||
|
});
|
||||||
|
|
||||||
const countriesFilter = {
|
const countriesFilter = {
|
||||||
fields: ['id', 'name', 'code'],
|
fields: ['id', 'name', 'code'],
|
||||||
};
|
};
|
||||||
|
|
||||||
const bankEntityFormData = reactive({
|
|
||||||
name: null,
|
|
||||||
bic: null,
|
|
||||||
countryFk: customer.value?.countryFk,
|
|
||||||
});
|
|
||||||
|
|
||||||
const countriesOptions = ref([]);
|
const countriesOptions = ref([]);
|
||||||
|
|
||||||
const onDataSaved = (...args) => {
|
const onDataSaved = (formData, requestResponse) => {
|
||||||
emit('onDataSaved', ...args);
|
emit('onDataSaved', formData, requestResponse);
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
@ -41,6 +39,7 @@ onMounted(async () => {
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
url="Countries"
|
url="Countries"
|
||||||
|
:filter="countriesFilter"
|
||||||
auto-load
|
auto-load
|
||||||
@on-fetch="(data) => (countriesOptions = data)"
|
@on-fetch="(data) => (countriesOptions = data)"
|
||||||
/>
|
/>
|
||||||
|
@ -50,7 +49,6 @@ onMounted(async () => {
|
||||||
:title="t('title')"
|
:title="t('title')"
|
||||||
:subtitle="t('subtitle')"
|
:subtitle="t('subtitle')"
|
||||||
:form-initial-data="bankEntityFormData"
|
:form-initial-data="bankEntityFormData"
|
||||||
:filter="countriesFilter"
|
|
||||||
@on-data-saved="onDataSaved"
|
@on-data-saved="onDataSaved"
|
||||||
>
|
>
|
||||||
<template #form-inputs="{ data, validate }">
|
<template #form-inputs="{ data, validate }">
|
||||||
|
@ -82,13 +80,7 @@ onMounted(async () => {
|
||||||
:rules="validate('bankEntity.countryFk')"
|
:rules="validate('bankEntity.countryFk')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div v-if="showEntityField" class="col">
|
||||||
v-if="
|
|
||||||
countriesOptions.find((c) => c.id === data.countryFk)?.code ==
|
|
||||||
'ES'
|
|
||||||
"
|
|
||||||
class="col"
|
|
||||||
>
|
|
||||||
<VnInput
|
<VnInput
|
||||||
:label="t('id')"
|
:label="t('id')"
|
||||||
v-model="data.id"
|
v-model="data.id"
|
||||||
|
|
|
@ -0,0 +1,155 @@
|
||||||
|
<script setup>
|
||||||
|
import { reactive, ref, computed } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
import FetchData from 'components/FetchData.vue';
|
||||||
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
import FormModelPopup from './FormModelPopup.vue';
|
||||||
|
import VnInputDate from './common/VnInputDate.vue';
|
||||||
|
|
||||||
|
const emit = defineEmits(['onDataSaved']);
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const manualInvoiceFormData = reactive({
|
||||||
|
maxShipped: Date.vnNew(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const formModelPopupRef = ref();
|
||||||
|
const invoiceOutSerialsOptions = ref([]);
|
||||||
|
const taxAreasOptions = ref([]);
|
||||||
|
const ticketsOptions = ref([]);
|
||||||
|
const clientsOptions = ref([]);
|
||||||
|
const isLoading = computed(() => formModelPopupRef.value?.isLoading);
|
||||||
|
|
||||||
|
const onDataSaved = async (formData, requestResponse) => {
|
||||||
|
emit('onDataSaved', formData, requestResponse);
|
||||||
|
if (requestResponse && requestResponse.id)
|
||||||
|
router.push({ name: 'InvoiceOutSummary', params: { id: requestResponse.id } });
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<FetchData
|
||||||
|
url="InvoiceOutSerials"
|
||||||
|
:filter="{ where: { code: { neq: 'R' } }, order: ['code'] }"
|
||||||
|
@on-fetch="(data) => (invoiceOutSerialsOptions = data)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
url="TaxAreas"
|
||||||
|
:filter="{ order: ['code'] }"
|
||||||
|
@on-fetch="(data) => (taxAreasOptions = data)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
|
<FormModelPopup
|
||||||
|
ref="formModelPopupRef"
|
||||||
|
:title="t('Create manual invoice')"
|
||||||
|
url-create="InvoiceOuts/createManualInvoice"
|
||||||
|
model="invoiceOut"
|
||||||
|
:form-initial-data="manualInvoiceFormData"
|
||||||
|
@on-data-saved="onDataSaved"
|
||||||
|
>
|
||||||
|
<template #form-inputs="{ data }">
|
||||||
|
<span v-if="isLoading" class="text-primary invoicing-text">
|
||||||
|
<QIcon name="warning" class="fill-icon q-mr-sm" size="md" />
|
||||||
|
{{ t('Invoicing in progress...') }}
|
||||||
|
</span>
|
||||||
|
<VnRow>
|
||||||
|
<VnSelect
|
||||||
|
:label="t('Ticket')"
|
||||||
|
:options="ticketsOptions"
|
||||||
|
hide-selected
|
||||||
|
option-label="id"
|
||||||
|
option-value="id"
|
||||||
|
v-model="data.ticketFk"
|
||||||
|
@update:model-value="data.clientFk = null"
|
||||||
|
url="Tickets"
|
||||||
|
:where="{ refFk: null }"
|
||||||
|
:fields="['id', 'nickname']"
|
||||||
|
:filter-options="{ order: 'shipped DESC' }"
|
||||||
|
>
|
||||||
|
<template #option="scope">
|
||||||
|
<QItem v-bind="scope.itemProps">
|
||||||
|
<QItemSection>
|
||||||
|
<QItemLabel> #{{ scope.opt?.id }} </QItemLabel>
|
||||||
|
<QItemLabel caption>{{ scope.opt?.nickname }}</QItemLabel>
|
||||||
|
</QItemSection>
|
||||||
|
</QItem>
|
||||||
|
</template>
|
||||||
|
</VnSelect>
|
||||||
|
<span class="row items-center" style="max-width: max-content">{{
|
||||||
|
t('Or')
|
||||||
|
}}</span>
|
||||||
|
<VnSelect
|
||||||
|
:label="t('Client')"
|
||||||
|
:options="clientsOptions"
|
||||||
|
hide-selected
|
||||||
|
option-label="name"
|
||||||
|
option-value="id"
|
||||||
|
v-model="data.clientFk"
|
||||||
|
@update:model-value="data.ticketFk = null"
|
||||||
|
url="Clients"
|
||||||
|
:fields="['id', 'name']"
|
||||||
|
:filter-options="{ order: 'name ASC' }"
|
||||||
|
/>
|
||||||
|
<VnInputDate :label="t('Max date')" v-model="data.maxShipped" />
|
||||||
|
</VnRow>
|
||||||
|
<VnRow>
|
||||||
|
<VnSelect
|
||||||
|
:label="t('Serial')"
|
||||||
|
:options="invoiceOutSerialsOptions"
|
||||||
|
hide-selected
|
||||||
|
option-label="description"
|
||||||
|
option-value="code"
|
||||||
|
v-model="data.serial"
|
||||||
|
/>
|
||||||
|
<VnSelect
|
||||||
|
:label="t('Area')"
|
||||||
|
:options="taxAreasOptions"
|
||||||
|
hide-selected
|
||||||
|
option-label="code"
|
||||||
|
option-value="code"
|
||||||
|
v-model="data.taxArea"
|
||||||
|
/>
|
||||||
|
</VnRow>
|
||||||
|
<VnRow>
|
||||||
|
<VnInput
|
||||||
|
:label="t('Reference')"
|
||||||
|
type="textarea"
|
||||||
|
v-model="data.reference"
|
||||||
|
fill-input
|
||||||
|
autogrow
|
||||||
|
/>
|
||||||
|
</VnRow>
|
||||||
|
</template>
|
||||||
|
</FormModelPopup>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.invoicing-text {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: $primary;
|
||||||
|
font-size: 24px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<i18n>
|
||||||
|
es:
|
||||||
|
Create manual invoice: Crear factura manual
|
||||||
|
Ticket: Ticket
|
||||||
|
Client: Cliente
|
||||||
|
Max date: Fecha límite
|
||||||
|
Serial: Serie
|
||||||
|
Area: Area
|
||||||
|
Reference: Referencia
|
||||||
|
Or: O
|
||||||
|
Invoicing in progress...: Facturación en progreso...
|
||||||
|
</i18n>
|
|
@ -1,38 +1,35 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
import FetchData from 'components/FetchData.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import VnSelectProvince from 'components/VnSelectProvince.vue';
|
import VnSelectProvince from 'components/VnSelectProvince.vue';
|
||||||
import VnInput from 'components/common/VnInput.vue';
|
import VnInput from 'components/common/VnInput.vue';
|
||||||
import FormModelPopup from './FormModelPopup.vue';
|
import FormModelPopup from './FormModelPopup.vue';
|
||||||
|
|
||||||
const emit = defineEmits(['onDataSaved']);
|
const emit = defineEmits(['onDataSaved']);
|
||||||
const $props = defineProps({
|
|
||||||
countryFk: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
provinceSelected: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const cityFormData = ref({
|
const cityFormData = reactive({
|
||||||
name: null,
|
name: null,
|
||||||
provinceFk: null,
|
provinceFk: null,
|
||||||
});
|
});
|
||||||
onMounted(() => {
|
|
||||||
cityFormData.value.provinceFk = $props.provinceSelected;
|
const provincesOptions = ref([]);
|
||||||
});
|
|
||||||
const onDataSaved = (...args) => {
|
const onDataSaved = (...args) => {
|
||||||
emit('onDataSaved', ...args);
|
emit('onDataSaved', ...args);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<FetchData
|
||||||
|
@on-fetch="(data) => (provincesOptions = data)"
|
||||||
|
auto-load
|
||||||
|
url="Provinces"
|
||||||
|
/>
|
||||||
<FormModelPopup
|
<FormModelPopup
|
||||||
:title="t('New city')"
|
:title="t('New city')"
|
||||||
:subtitle="t('Please, ensure you put the correct data!')"
|
:subtitle="t('Please, ensure you put the correct data!')"
|
||||||
|
@ -40,7 +37,6 @@ const onDataSaved = (...args) => {
|
||||||
url-create="towns"
|
url-create="towns"
|
||||||
model="city"
|
model="city"
|
||||||
@on-data-saved="onDataSaved"
|
@on-data-saved="onDataSaved"
|
||||||
data-cy="newCityForm"
|
|
||||||
>
|
>
|
||||||
<template #form-inputs="{ data, validate }">
|
<template #form-inputs="{ data, validate }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
|
@ -48,16 +44,8 @@ const onDataSaved = (...args) => {
|
||||||
:label="t('Name')"
|
:label="t('Name')"
|
||||||
v-model="data.name"
|
v-model="data.name"
|
||||||
:rules="validate('city.name')"
|
:rules="validate('city.name')"
|
||||||
required
|
|
||||||
data-cy="cityName"
|
|
||||||
/>
|
|
||||||
<VnSelectProvince
|
|
||||||
:province-selected="$props.provinceSelected"
|
|
||||||
:country-fk="$props.countryFk"
|
|
||||||
v-model="data.provinceFk"
|
|
||||||
required
|
|
||||||
data-cy="provinceCity"
|
|
||||||
/>
|
/>
|
||||||
|
<VnSelectProvince v-model="data.provinceFk" />
|
||||||
</VnRow>
|
</VnRow>
|
||||||
</template>
|
</template>
|
||||||
</FormModelPopup>
|
</FormModelPopup>
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
import FormModelPopup from './FormModelPopup.vue';
|
|
||||||
|
|
||||||
const emit = defineEmits(['onDataSaved']);
|
|
||||||
const { t } = useI18n();
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<FormModelPopup
|
|
||||||
url-create="Expenses"
|
|
||||||
model="Expense"
|
|
||||||
:title="t('New expense')"
|
|
||||||
:form-initial-data="{ id: null, isWithheld: false, name: null }"
|
|
||||||
@on-data-saved="emit('onDataSaved', $event)"
|
|
||||||
>
|
|
||||||
<template #form-inputs="{ data, validate }">
|
|
||||||
<VnRow>
|
|
||||||
<VnInput
|
|
||||||
:label="`${t('globals.code')}`"
|
|
||||||
v-model="data.id"
|
|
||||||
:required="true"
|
|
||||||
:rules="validate('expense.code')"
|
|
||||||
/>
|
|
||||||
<QCheckbox
|
|
||||||
dense
|
|
||||||
size="sm"
|
|
||||||
:label="`${t('It\'s a withholding')}`"
|
|
||||||
v-model="data.isWithheld"
|
|
||||||
:rules="validate('expense.isWithheld')"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow>
|
|
||||||
<VnInput
|
|
||||||
:label="`${t('globals.description')}`"
|
|
||||||
v-model="data.name"
|
|
||||||
:required="true"
|
|
||||||
:rules="validate('expense.description')"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
</template>
|
|
||||||
</FormModelPopup>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
New expense: Nuevo gasto
|
|
||||||
It's a withholding: Es una retención
|
|
||||||
</i18n>
|
|
|
@ -21,14 +21,11 @@ const postcodeFormData = reactive({
|
||||||
provinceFk: null,
|
provinceFk: null,
|
||||||
townFk: null,
|
townFk: null,
|
||||||
});
|
});
|
||||||
const townsFetchDataRef = ref(false);
|
|
||||||
const townFilter = ref({});
|
|
||||||
|
|
||||||
const countriesRef = ref(false);
|
const provincesFetchDataRef = ref(null);
|
||||||
|
const countriesOptions = ref([]);
|
||||||
const provincesOptions = ref([]);
|
const provincesOptions = ref([]);
|
||||||
const townsOptions = ref([]);
|
|
||||||
const town = ref({});
|
const town = ref({});
|
||||||
const countryFilter = ref({});
|
|
||||||
|
|
||||||
function onDataSaved(formData) {
|
function onDataSaved(formData) {
|
||||||
const newPostcode = {
|
const newPostcode = {
|
||||||
|
@ -40,90 +37,50 @@ function onDataSaved(formData) {
|
||||||
({ id }) => id === formData.provinceFk
|
({ id }) => id === formData.provinceFk
|
||||||
);
|
);
|
||||||
newPostcode.province = provinceObject?.name;
|
newPostcode.province = provinceObject?.name;
|
||||||
const countryObject = countriesRef.value.opts.find(
|
const countryObject = countriesOptions.value.find(
|
||||||
({ id }) => id === formData.countryFk
|
({ id }) => id === formData.countryFk
|
||||||
);
|
);
|
||||||
newPostcode.country = countryObject?.name;
|
newPostcode.country = countryObject?.name;
|
||||||
emit('onDataSaved', newPostcode);
|
emit('onDataSaved', newPostcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setCountry(countryFk, data) {
|
|
||||||
data.townFk = null;
|
|
||||||
data.provinceFk = null;
|
|
||||||
data.countryFk = countryFk;
|
|
||||||
await fetchTowns();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Province
|
|
||||||
async function setProvince(id, data) {
|
|
||||||
if (data.provinceFk === id) return;
|
|
||||||
const newProvince = provincesOptions.value.find((province) => province.id == id);
|
|
||||||
if (newProvince) data.countryFk = newProvince.countryFk;
|
|
||||||
postcodeFormData.provinceFk = id;
|
|
||||||
await fetchTowns();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onProvinceCreated(data) {
|
|
||||||
postcodeFormData.provinceFk = data.id;
|
|
||||||
}
|
|
||||||
function provinceByCountry(countryFk = postcodeFormData.countryFk) {
|
|
||||||
return provincesOptions.value
|
|
||||||
.filter((province) => province.countryFk === countryFk)
|
|
||||||
.map(({ id }) => id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Town
|
|
||||||
async function handleTowns(data) {
|
|
||||||
townsOptions.value = data;
|
|
||||||
}
|
|
||||||
function setTown(newTown, data) {
|
|
||||||
town.value = newTown;
|
|
||||||
data.provinceFk = newTown?.provinceFk ?? newTown;
|
|
||||||
data.countryFk = newTown?.province?.countryFk ?? newTown;
|
|
||||||
}
|
|
||||||
async function onCityCreated(newTown, formData) {
|
async function onCityCreated(newTown, formData) {
|
||||||
|
await provincesFetchDataRef.value.fetch();
|
||||||
newTown.province = provincesOptions.value.find(
|
newTown.province = provincesOptions.value.find(
|
||||||
(province) => province.id === newTown.provinceFk
|
(province) => province.id === newTown.provinceFk
|
||||||
);
|
);
|
||||||
formData.townFk = newTown;
|
formData.townFk = newTown;
|
||||||
setTown(newTown, formData);
|
setTown(newTown, formData);
|
||||||
}
|
}
|
||||||
async function fetchTowns(countryFk = postcodeFormData.countryFk) {
|
|
||||||
if (!countryFk) return;
|
function setTown(newTown, data) {
|
||||||
const provinces = postcodeFormData.provinceFk
|
if (!newTown) return;
|
||||||
? [postcodeFormData.provinceFk]
|
town.value = newTown;
|
||||||
: provinceByCountry();
|
data.provinceFk = newTown.provinceFk;
|
||||||
townFilter.value.where = {
|
data.countryFk = newTown.province.countryFk;
|
||||||
provinceFk: {
|
|
||||||
inq: provinces,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
await townsFetchDataRef.value?.fetch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function filterTowns(name) {
|
async function setProvince(id, data) {
|
||||||
if (name !== '') {
|
await provincesFetchDataRef.value.fetch();
|
||||||
townFilter.value.where = {
|
const newProvince = provincesOptions.value.find((province) => province.id == id);
|
||||||
name: {
|
if (!newProvince) return;
|
||||||
like: `%${name}%`,
|
|
||||||
},
|
data.countryFk = newProvince.countryFk;
|
||||||
};
|
|
||||||
await townsFetchDataRef.value?.fetch();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
ref="townsFetchDataRef"
|
ref="provincesFetchDataRef"
|
||||||
:sort-by="['name ASC']"
|
@on-fetch="(data) => (provincesOptions = data)"
|
||||||
:limit="30"
|
|
||||||
:filter="townFilter"
|
|
||||||
@on-fetch="handleTowns"
|
|
||||||
auto-load
|
auto-load
|
||||||
url="Towns/location"
|
url="Provinces/location"
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
@on-fetch="(data) => (countriesOptions = data)"
|
||||||
|
auto-load
|
||||||
|
url="Countries"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormModelPopup
|
<FormModelPopup
|
||||||
url-create="postcodes"
|
url-create="postcodes"
|
||||||
model="postcode"
|
model="postcode"
|
||||||
|
@ -139,24 +96,18 @@ async function filterTowns(name) {
|
||||||
:label="t('Postcode')"
|
:label="t('Postcode')"
|
||||||
v-model="data.code"
|
v-model="data.code"
|
||||||
:rules="validate('postcode.code')"
|
:rules="validate('postcode.code')"
|
||||||
clearable
|
|
||||||
required
|
|
||||||
data-cy="locationPostcode"
|
|
||||||
/>
|
/>
|
||||||
<VnSelectDialog
|
<VnSelectDialog
|
||||||
:label="t('City')"
|
:label="t('City')"
|
||||||
|
url="Towns/location"
|
||||||
@update:model-value="(value) => setTown(value, data)"
|
@update:model-value="(value) => setTown(value, data)"
|
||||||
@filter="filterTowns"
|
|
||||||
:tooltip="t('Create city')"
|
|
||||||
v-model="data.townFk"
|
v-model="data.townFk"
|
||||||
:options="townsOptions"
|
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
:rules="validate('postcode.city')"
|
:rules="validate('postcode.city')"
|
||||||
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
|
:roles-allowed-to-create="['deliveryAssistant']"
|
||||||
:emit-value="false"
|
:emit-value="false"
|
||||||
required
|
clearable
|
||||||
data-cy="locationTown"
|
|
||||||
>
|
>
|
||||||
<template #option="{ itemProps, opt }">
|
<template #option="{ itemProps, opt }">
|
||||||
<QItem v-bind="itemProps">
|
<QItem v-bind="itemProps">
|
||||||
|
@ -171,8 +122,6 @@ async function filterTowns(name) {
|
||||||
</template>
|
</template>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CreateNewCityForm
|
<CreateNewCityForm
|
||||||
:country-fk="data.countryFk"
|
|
||||||
:province-selected="data.provinceFk"
|
|
||||||
@on-data-saved="
|
@on-data-saved="
|
||||||
(_, requestResponse) =>
|
(_, requestResponse) =>
|
||||||
onCityCreated(requestResponse, data)
|
onCityCreated(requestResponse, data)
|
||||||
|
@ -183,34 +132,17 @@ async function filterTowns(name) {
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnSelectProvince
|
<VnSelectProvince
|
||||||
:country-fk="data.countryFk"
|
|
||||||
:province-selected="data.provinceFk"
|
|
||||||
@update:model-value="(value) => setProvince(value, data)"
|
@update:model-value="(value) => setProvince(value, data)"
|
||||||
@update:options="
|
|
||||||
(data) => {
|
|
||||||
provincesOptions = data;
|
|
||||||
}
|
|
||||||
"
|
|
||||||
v-model="data.provinceFk"
|
v-model="data.provinceFk"
|
||||||
@on-province-created="onProvinceCreated"
|
|
||||||
required
|
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
ref="countriesRef"
|
|
||||||
:limit="30"
|
|
||||||
:filter="countryFilter"
|
|
||||||
:sort-by="['name ASC']"
|
|
||||||
auto-load
|
|
||||||
url="Countries"
|
|
||||||
required
|
|
||||||
:label="t('Country')"
|
:label="t('Country')"
|
||||||
|
:options="countriesOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
v-model="data.countryFk"
|
v-model="data.countryFk"
|
||||||
:rules="validate('postcode.countryFk')"
|
:rules="validate('postcode.countryFk')"
|
||||||
@update:model-value="(value) => setCountry(value, data)"
|
|
||||||
data-cy="locationCountry"
|
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
</template>
|
</template>
|
||||||
|
@ -220,7 +152,6 @@ async function filterTowns(name) {
|
||||||
<i18n>
|
<i18n>
|
||||||
es:
|
es:
|
||||||
New postcode: Nuevo código postal
|
New postcode: Nuevo código postal
|
||||||
Create city: Crear población
|
|
||||||
Please, ensure you put the correct data!: ¡Por favor, asegúrese de poner los datos correctos!
|
Please, ensure you put the correct data!: ¡Por favor, asegúrese de poner los datos correctos!
|
||||||
City: Población
|
City: Población
|
||||||
Province: Provincia
|
Province: Provincia
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, reactive, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
import FetchData from 'components/FetchData.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
@ -15,29 +16,23 @@ const provinceFormData = reactive({
|
||||||
name: null,
|
name: null,
|
||||||
autonomyFk: null,
|
autonomyFk: null,
|
||||||
});
|
});
|
||||||
const $props = defineProps({
|
|
||||||
countryFk: {
|
const autonomiesOptions = ref([]);
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const autonomiesRef = ref([]);
|
|
||||||
|
|
||||||
const onDataSaved = (dataSaved, requestResponse) => {
|
const onDataSaved = (dataSaved, requestResponse) => {
|
||||||
requestResponse.autonomy = autonomiesRef.value.opts.find(
|
requestResponse.autonomy = autonomiesOptions.value.find(
|
||||||
(autonomy) => autonomy.id == requestResponse.autonomyFk
|
(autonomy) => autonomy.id == requestResponse.autonomyFk
|
||||||
);
|
);
|
||||||
emit('onDataSaved', dataSaved, requestResponse);
|
emit('onDataSaved', dataSaved, requestResponse);
|
||||||
};
|
};
|
||||||
const where = computed(() => {
|
|
||||||
if (!$props.countryFk) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
return { countryFk: $props.countryFk };
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<FetchData
|
||||||
|
@on-fetch="(data) => (autonomiesOptions = data)"
|
||||||
|
auto-load
|
||||||
|
url="Autonomies/location"
|
||||||
|
/>
|
||||||
<FormModelPopup
|
<FormModelPopup
|
||||||
:title="t('New province')"
|
:title="t('New province')"
|
||||||
:subtitle="t('Please, ensure you put the correct data!')"
|
:subtitle="t('Please, ensure you put the correct data!')"
|
||||||
|
@ -52,19 +47,10 @@ const where = computed(() => {
|
||||||
:label="t('Name')"
|
:label="t('Name')"
|
||||||
v-model="data.name"
|
v-model="data.name"
|
||||||
:rules="validate('province.name')"
|
:rules="validate('province.name')"
|
||||||
required
|
|
||||||
data-cy="provinceName"
|
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
data-cy="autonomyProvince"
|
|
||||||
required
|
|
||||||
ref="autonomiesRef"
|
|
||||||
auto-load
|
|
||||||
:where="where"
|
|
||||||
url="Autonomies/location"
|
|
||||||
:sort-by="['name ASC']"
|
|
||||||
:limit="30"
|
|
||||||
:label="t('Autonomy')"
|
:label="t('Autonomy')"
|
||||||
|
:options="autonomiesOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
|
|
|
@ -38,7 +38,7 @@ const onDataSaved = (dataSaved) => {
|
||||||
@on-fetch="(data) => (warehousesOptions = data)"
|
@on-fetch="(data) => (warehousesOptions = data)"
|
||||||
auto-load
|
auto-load
|
||||||
url="Warehouses"
|
url="Warehouses"
|
||||||
:filter="{ fields: ['id', 'name'], order: 'name ASC' }"
|
:filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }"
|
||||||
/>
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
@on-fetch="(data) => (temperaturesOptions = data)"
|
@on-fetch="(data) => (temperaturesOptions = data)"
|
||||||
|
@ -50,7 +50,7 @@ const onDataSaved = (dataSaved) => {
|
||||||
model="thermograph"
|
model="thermograph"
|
||||||
:title="t('New thermograph')"
|
:title="t('New thermograph')"
|
||||||
:form-initial-data="thermographFormData"
|
:form-initial-data="thermographFormData"
|
||||||
@on-data-saved="(_, response) => onDataSaved(response)"
|
@on-data-saved="onDataSaved($event)"
|
||||||
>
|
>
|
||||||
<template #form-inputs="{ data, validate }">
|
<template #form-inputs="{ data, validate }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { computed, ref, useAttrs, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
import { useRouter, onBeforeRouteLeave } from 'vue-router';
|
import { useRouter, onBeforeRouteLeave } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
|
@ -10,14 +10,12 @@ import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||||
import SkeletonTable from 'components/ui/SkeletonTable.vue';
|
import SkeletonTable from 'components/ui/SkeletonTable.vue';
|
||||||
import { tMobile } from 'src/composables/tMobile';
|
import { tMobile } from 'src/composables/tMobile';
|
||||||
import getDifferences from 'src/filters/getDifferences';
|
|
||||||
|
|
||||||
const { push } = useRouter();
|
const { push } = useRouter();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { validate } = useValidator();
|
const { validate } = useValidator();
|
||||||
const $attrs = useAttrs();
|
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
model: {
|
model: {
|
||||||
|
@ -79,7 +77,7 @@ const isLoading = ref(false);
|
||||||
const hasChanges = ref(false);
|
const hasChanges = ref(false);
|
||||||
const originalData = ref();
|
const originalData = ref();
|
||||||
const vnPaginateRef = ref();
|
const vnPaginateRef = ref();
|
||||||
const formData = ref([]);
|
const formData = ref();
|
||||||
const saveButtonRef = ref(null);
|
const saveButtonRef = ref(null);
|
||||||
const watchChanges = ref();
|
const watchChanges = ref();
|
||||||
const formUrl = computed(() => $props.url);
|
const formUrl = computed(() => $props.url);
|
||||||
|
@ -96,7 +94,6 @@ defineExpose({
|
||||||
saveChanges,
|
saveChanges,
|
||||||
getChanges,
|
getChanges,
|
||||||
formData,
|
formData,
|
||||||
originalData,
|
|
||||||
vnPaginateRef,
|
vnPaginateRef,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -114,11 +111,9 @@ onBeforeRouteLeave((to, from, next) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
async function fetch(data) {
|
async function fetch(data) {
|
||||||
const keyData = $attrs['key-data'];
|
resetData(data);
|
||||||
const rows = keyData ? data[keyData] : data;
|
emit('onFetch', data);
|
||||||
resetData(rows);
|
return data;
|
||||||
emit('onFetch', rows);
|
|
||||||
return rows;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetData(data) {
|
function resetData(data) {
|
||||||
|
@ -130,7 +125,7 @@ function resetData(data) {
|
||||||
originalData.value = JSON.parse(JSON.stringify(data));
|
originalData.value = JSON.parse(JSON.stringify(data));
|
||||||
formData.value = JSON.parse(JSON.stringify(data));
|
formData.value = JSON.parse(JSON.stringify(data));
|
||||||
|
|
||||||
if (watchChanges.value) watchChanges.value(); //destroy watcher
|
if (watchChanges.value) watchChanges.value(); //destoy watcher
|
||||||
watchChanges.value = watch(formData, () => (hasChanges.value = true), { deep: true });
|
watchChanges.value = watch(formData, () => (hasChanges.value = true), { deep: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +144,7 @@ function filter(value, update, filterOptions) {
|
||||||
(ref) => {
|
(ref) => {
|
||||||
ref.setOptionIndex(-1);
|
ref.setOptionIndex(-1);
|
||||||
ref.moveOptionSelection(1, true);
|
ref.moveOptionSelection(1, true);
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,13 +174,14 @@ async function saveChanges(data) {
|
||||||
const changes = data || getChanges();
|
const changes = data || getChanges();
|
||||||
try {
|
try {
|
||||||
await axios.post($props.saveUrl || $props.url + '/crud', changes);
|
await axios.post($props.saveUrl || $props.url + '/crud', changes);
|
||||||
} finally {
|
} catch (e) {
|
||||||
isLoading.value = false;
|
return (isLoading.value = false);
|
||||||
}
|
}
|
||||||
originalData.value = JSON.parse(JSON.stringify(formData.value));
|
originalData.value = JSON.parse(JSON.stringify(formData.value));
|
||||||
if (changes.creates?.length) await vnPaginateRef.value.fetch();
|
if (changes.creates?.length) await vnPaginateRef.value.fetch();
|
||||||
|
|
||||||
hasChanges.value = false;
|
hasChanges.value = false;
|
||||||
|
isLoading.value = false;
|
||||||
emit('saveChanges', data);
|
emit('saveChanges', data);
|
||||||
quasar.notify({
|
quasar.notify({
|
||||||
type: 'positive',
|
type: 'positive',
|
||||||
|
@ -193,11 +189,11 @@ async function saveChanges(data) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function insert(pushData = $props.dataRequired) {
|
async function insert() {
|
||||||
const $index = formData.value.length
|
const $index = formData.value.length
|
||||||
? formData.value[formData.value.length - 1].$index + 1
|
? formData.value[formData.value.length - 1].$index + 1
|
||||||
: 0;
|
: 0;
|
||||||
formData.value.push(Object.assign({ $index }, pushData));
|
formData.value.push(Object.assign({ $index }, $props.dataRequired));
|
||||||
hasChanges.value = true;
|
hasChanges.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +211,7 @@ async function remove(data) {
|
||||||
|
|
||||||
if (preRemove.length) {
|
if (preRemove.length) {
|
||||||
newData = newData.filter(
|
newData = newData.filter(
|
||||||
(form) => !preRemove.some((index) => index == form.$index),
|
(form) => !preRemove.some((index) => index == form.$index)
|
||||||
);
|
);
|
||||||
const changes = getChanges();
|
const changes = getChanges();
|
||||||
if (!changes.creates?.length && !changes.updates?.length)
|
if (!changes.creates?.length && !changes.updates?.length)
|
||||||
|
@ -238,8 +234,6 @@ async function remove(data) {
|
||||||
newData = newData.filter((form) => !ids.some((id) => id == form[pk]));
|
newData = newData.filter((form) => !ids.some((id) => id == form[pk]));
|
||||||
fetch(newData);
|
fetch(newData);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
reset();
|
|
||||||
}
|
}
|
||||||
emit('update:selected', []);
|
emit('update:selected', []);
|
||||||
}
|
}
|
||||||
|
@ -252,7 +246,7 @@ function getChanges() {
|
||||||
for (const [i, row] of formData.value.entries()) {
|
for (const [i, row] of formData.value.entries()) {
|
||||||
if (!row[pk]) {
|
if (!row[pk]) {
|
||||||
creates.push(row);
|
creates.push(row);
|
||||||
} else if (originalData.value[i]) {
|
} else if (originalData.value) {
|
||||||
const data = getDifferences(originalData.value[i], row);
|
const data = getDifferences(originalData.value[i], row);
|
||||||
if (!isEmpty(data)) {
|
if (!isEmpty(data)) {
|
||||||
updates.push({
|
updates.push({
|
||||||
|
@ -271,10 +265,34 @@ function getChanges() {
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDifferences(obj1, obj2) {
|
||||||
|
let diff = {};
|
||||||
|
delete obj1.$index;
|
||||||
|
delete obj2.$index;
|
||||||
|
|
||||||
|
for (let key in obj1) {
|
||||||
|
if (obj2[key] && JSON.stringify(obj1[key]) !== JSON.stringify(obj2[key])) {
|
||||||
|
diff[key] = obj2[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let key in obj2) {
|
||||||
|
if (
|
||||||
|
obj1[key] === undefined ||
|
||||||
|
JSON.stringify(obj1[key]) !== JSON.stringify(obj2[key])
|
||||||
|
) {
|
||||||
|
diff[key] = obj2[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return diff;
|
||||||
|
}
|
||||||
|
|
||||||
function isEmpty(obj) {
|
function isEmpty(obj) {
|
||||||
if (obj == null) return true;
|
if (obj == null) return true;
|
||||||
if (Array.isArray(obj)) return !obj.length;
|
if (obj === undefined) return true;
|
||||||
return !Object.keys(obj).length;
|
if (Object.keys(obj).length === 0) return true;
|
||||||
|
|
||||||
|
if (obj.length > 0) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reload(params) {
|
async function reload(params) {
|
||||||
|
@ -374,7 +392,6 @@ watch(formUrl, async () => {
|
||||||
@click="onSubmit"
|
@click="onSubmit"
|
||||||
:disable="!hasChanges"
|
:disable="!hasChanges"
|
||||||
:title="t('globals.save')"
|
:title="t('globals.save')"
|
||||||
data-cy="crudModelDefaultSaveBtn"
|
|
||||||
/>
|
/>
|
||||||
<slot name="moreAfterActions" />
|
<slot name="moreAfterActions" />
|
||||||
</QBtnGroup>
|
</QBtnGroup>
|
||||||
|
|
|
@ -156,22 +156,26 @@ const rotateRight = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
if (!newPhoto.files && !newPhoto.url) {
|
try {
|
||||||
notify(t('Select an image'), 'negative');
|
if (!newPhoto.files && !newPhoto.url) {
|
||||||
return;
|
notify(t('Select an image'), 'negative');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
type: 'blob',
|
||||||
|
};
|
||||||
|
|
||||||
|
editor.value
|
||||||
|
.result(options)
|
||||||
|
.then((result) => {
|
||||||
|
const file = new File([result], newPhoto.files?.name || '');
|
||||||
|
newPhoto.blob = file;
|
||||||
|
})
|
||||||
|
.then(() => makeRequest());
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error uploading image');
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = {
|
|
||||||
type: 'blob',
|
|
||||||
};
|
|
||||||
|
|
||||||
editor.value
|
|
||||||
.result(options)
|
|
||||||
.then((result) => {
|
|
||||||
const file = new File([result], newPhoto.files?.name || '');
|
|
||||||
newPhoto.blob = file;
|
|
||||||
})
|
|
||||||
.then(() => makeRequest());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const makeRequest = async () => {
|
const makeRequest = async () => {
|
||||||
|
|
|
@ -51,17 +51,21 @@ const onDataSaved = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
isLoading.value = true;
|
try {
|
||||||
const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk }));
|
isLoading.value = true;
|
||||||
const payload = {
|
const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk }));
|
||||||
field: selectedField.value.field,
|
const payload = {
|
||||||
newValue: newValue.value,
|
field: selectedField.value.field,
|
||||||
lines: rowsToEdit,
|
newValue: newValue.value,
|
||||||
};
|
lines: rowsToEdit,
|
||||||
|
};
|
||||||
|
|
||||||
await axios.post($props.editUrl, payload);
|
await axios.post($props.editUrl, payload);
|
||||||
onDataSaved();
|
onDataSaved();
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error submitting table cell edit');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeForm = () => {
|
const closeForm = () => {
|
||||||
|
@ -85,14 +89,12 @@ const closeForm = () => {
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="label"
|
option-label="label"
|
||||||
v-model="selectedField"
|
v-model="selectedField"
|
||||||
data-cy="field-to-edit"
|
|
||||||
/>
|
/>
|
||||||
<component
|
<component
|
||||||
:is="inputs[selectedField?.component || 'input']"
|
:is="inputs[selectedField?.component || 'input']"
|
||||||
v-bind="selectedField?.attrs || {}"
|
v-bind="selectedField?.attrs || {}"
|
||||||
v-model="newValue"
|
v-model="newValue"
|
||||||
:label="t('Value')"
|
:label="t('Value')"
|
||||||
data-cy="value-to-edit"
|
|
||||||
style="width: 200px"
|
style="width: 200px"
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
|
|
@ -44,7 +44,7 @@ onMounted(async () => {
|
||||||
|
|
||||||
async function fetch(fetchFilter = {}) {
|
async function fetch(fetchFilter = {}) {
|
||||||
try {
|
try {
|
||||||
const filter = { ...fetchFilter, ...$props.filter }; // eslint-disable-line vue/no-dupe-keys
|
const filter = Object.assign(fetchFilter, $props.filter); // eslint-disable-line vue/no-dupe-keys
|
||||||
if ($props.where && !fetchFilter.where) filter.where = $props.where;
|
if ($props.where && !fetchFilter.where) filter.where = $props.where;
|
||||||
if ($props.sortBy) filter.order = $props.sortBy;
|
if ($props.sortBy) filter.order = $props.sortBy;
|
||||||
if ($props.limit) filter.limit = $props.limit;
|
if ($props.limit) filter.limit = $props.limit;
|
||||||
|
|
|
@ -50,25 +50,25 @@ const loading = ref(false);
|
||||||
|
|
||||||
const tableColumns = computed(() => [
|
const tableColumns = computed(() => [
|
||||||
{
|
{
|
||||||
label: t('globals.id'),
|
label: t('entry.buys.id'),
|
||||||
name: 'id',
|
name: 'id',
|
||||||
field: 'id',
|
field: 'id',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('globals.name'),
|
label: t('entry.buys.name'),
|
||||||
name: 'name',
|
name: 'name',
|
||||||
field: 'name',
|
field: 'name',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('globals.size'),
|
label: t('entry.buys.size'),
|
||||||
name: 'size',
|
name: 'size',
|
||||||
field: 'size',
|
field: 'size',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('globals.producer'),
|
label: t('entry.buys.producer'),
|
||||||
name: 'producerName',
|
name: 'producerName',
|
||||||
field: 'producer',
|
field: 'producer',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
@ -84,30 +84,34 @@ const tableColumns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
let filter = itemFilter;
|
try {
|
||||||
const params = itemFilterParams;
|
let filter = itemFilter;
|
||||||
const where = {};
|
const params = itemFilterParams;
|
||||||
for (let key in params) {
|
const where = {};
|
||||||
const value = params[key];
|
for (let key in params) {
|
||||||
if (!value) continue;
|
const value = params[key];
|
||||||
|
if (!value) continue;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'name':
|
case 'name':
|
||||||
where[key] = { like: `%${value}%` };
|
where[key] = { like: `%${value}%` };
|
||||||
break;
|
break;
|
||||||
case 'producerFk':
|
case 'producerFk':
|
||||||
case 'typeFk':
|
case 'typeFk':
|
||||||
case 'size':
|
case 'size':
|
||||||
case 'inkFk':
|
case 'inkFk':
|
||||||
where[key] = value;
|
where[key] = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
filter.where = where;
|
||||||
filter.where = where;
|
|
||||||
|
|
||||||
const { data } = await axios.get(props.url, {
|
const { data } = await axios.get(props.url, {
|
||||||
params: { filter: JSON.stringify(filter) },
|
params: { filter: JSON.stringify(filter) },
|
||||||
});
|
});
|
||||||
tableRows.value = data;
|
tableRows.value = data;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching entries items');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeForm = () => {
|
const closeForm = () => {
|
||||||
|
@ -148,10 +152,10 @@ const selectItem = ({ id }) => {
|
||||||
</span>
|
</span>
|
||||||
<h1 class="title">{{ t('Filter item') }}</h1>
|
<h1 class="title">{{ t('Filter item') }}</h1>
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnInput :label="t('globals.name')" v-model="itemFilterParams.name" />
|
<VnInput :label="t('entry.buys.name')" v-model="itemFilterParams.name" />
|
||||||
<VnInput :label="t('entry.buys.size')" v-model="itemFilterParams.size" />
|
<VnInput :label="t('entry.buys.size')" v-model="itemFilterParams.size" />
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('globals.producer')"
|
:label="t('entry.buys.producer')"
|
||||||
:options="producersOptions"
|
:options="producersOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
|
@ -159,7 +163,7 @@ const selectItem = ({ id }) => {
|
||||||
v-model="itemFilterParams.producerFk"
|
v-model="itemFilterParams.producerFk"
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('globals.type')"
|
:label="t('entry.buys.type')"
|
||||||
:options="ItemTypesOptions"
|
:options="ItemTypesOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
|
|
|
@ -48,13 +48,13 @@ const loading = ref(false);
|
||||||
|
|
||||||
const tableColumns = computed(() => [
|
const tableColumns = computed(() => [
|
||||||
{
|
{
|
||||||
label: t('globals.id'),
|
label: t('entry.basicData.id'),
|
||||||
name: 'id',
|
name: 'id',
|
||||||
field: 'id',
|
field: 'id',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('globals.warehouseOut'),
|
label: t('entry.basicData.warehouseOut'),
|
||||||
name: 'warehouseOutFk',
|
name: 'warehouseOutFk',
|
||||||
field: 'warehouseOutFk',
|
field: 'warehouseOutFk',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
@ -62,7 +62,7 @@ const tableColumns = computed(() => [
|
||||||
warehousesOptions.value.find((warehouse) => warehouse.id === val).name,
|
warehousesOptions.value.find((warehouse) => warehouse.id === val).name,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('globals.warehouseIn'),
|
label: t('entry.basicData.warehouseIn'),
|
||||||
name: 'warehouseInFk',
|
name: 'warehouseInFk',
|
||||||
field: 'warehouseInFk',
|
field: 'warehouseInFk',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
@ -70,14 +70,14 @@ const tableColumns = computed(() => [
|
||||||
warehousesOptions.value.find((warehouse) => warehouse.id === val).name,
|
warehousesOptions.value.find((warehouse) => warehouse.id === val).name,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('globals.shipped'),
|
label: t('entry.basicData.shipped'),
|
||||||
name: 'shipped',
|
name: 'shipped',
|
||||||
field: 'shipped',
|
field: 'shipped',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
format: (val) => toDate(val),
|
format: (val) => toDate(val),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('globals.landed'),
|
label: t('entry.basicData.landed'),
|
||||||
name: 'landed',
|
name: 'landed',
|
||||||
field: 'landed',
|
field: 'landed',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
@ -86,28 +86,32 @@ const tableColumns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
let filter = travelFilter;
|
try {
|
||||||
const params = travelFilterParams;
|
let filter = travelFilter;
|
||||||
const where = {};
|
const params = travelFilterParams;
|
||||||
for (let key in params) {
|
const where = {};
|
||||||
const value = params[key];
|
for (let key in params) {
|
||||||
if (!value) continue;
|
const value = params[key];
|
||||||
|
if (!value) continue;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'agencyModeFk':
|
case 'agencyModeFk':
|
||||||
case 'warehouseInFk':
|
case 'warehouseInFk':
|
||||||
case 'warehouseOutFk':
|
case 'warehouseOutFk':
|
||||||
case 'shipped':
|
case 'shipped':
|
||||||
case 'landed':
|
case 'landed':
|
||||||
where[key] = value;
|
where[key] = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
filter.where = where;
|
filter.where = where;
|
||||||
const { data } = await axios.get('Travels', {
|
const { data } = await axios.get('Travels', {
|
||||||
params: { filter: JSON.stringify(filter) },
|
params: { filter: JSON.stringify(filter) },
|
||||||
});
|
});
|
||||||
tableRows.value = data;
|
tableRows.value = data;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching travels');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeForm = () => {
|
const closeForm = () => {
|
||||||
|
@ -142,7 +146,7 @@ const selectTravel = ({ id }) => {
|
||||||
<h1 class="title">{{ t('Filter travels') }}</h1>
|
<h1 class="title">{{ t('Filter travels') }}</h1>
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('globals.agency')"
|
:label="t('entry.basicData.agency')"
|
||||||
:options="agenciesOptions"
|
:options="agenciesOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
|
@ -150,7 +154,7 @@ const selectTravel = ({ id }) => {
|
||||||
v-model="travelFilterParams.agencyModeFk"
|
v-model="travelFilterParams.agencyModeFk"
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('globals.warehouseOut')"
|
:label="t('entry.basicData.warehouseOut')"
|
||||||
:options="warehousesOptions"
|
:options="warehousesOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
|
@ -158,7 +162,7 @@ const selectTravel = ({ id }) => {
|
||||||
v-model="travelFilterParams.warehouseOutFk"
|
v-model="travelFilterParams.warehouseOutFk"
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('globals.warehouseIn')"
|
:label="t('entry.basicData.warehouseIn')"
|
||||||
:options="warehousesOptions"
|
:options="warehousesOptions"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
|
@ -166,11 +170,11 @@ const selectTravel = ({ id }) => {
|
||||||
v-model="travelFilterParams.warehouseInFk"
|
v-model="travelFilterParams.warehouseInFk"
|
||||||
/>
|
/>
|
||||||
<VnInputDate
|
<VnInputDate
|
||||||
:label="t('globals.shipped')"
|
:label="t('entry.basicData.shipped')"
|
||||||
v-model="travelFilterParams.shipped"
|
v-model="travelFilterParams.shipped"
|
||||||
/>
|
/>
|
||||||
<VnInputDate
|
<VnInputDate
|
||||||
:label="t('globals.landed')"
|
:label="t('entry.basicData.landed')"
|
||||||
v-model="travelFilterParams.landed"
|
v-model="travelFilterParams.landed"
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { onMounted, onUnmounted, computed, ref, watch, nextTick } from 'vue';
|
import { onMounted, onUnmounted, computed, ref, watch, nextTick } from 'vue';
|
||||||
import { onBeforeRouteLeave, useRouter, useRoute } from 'vue-router';
|
import { onBeforeRouteLeave, useRouter } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
|
@ -12,6 +12,7 @@ import SkeletonForm from 'components/ui/SkeletonForm.vue';
|
||||||
import VnConfirm from './ui/VnConfirm.vue';
|
import VnConfirm from './ui/VnConfirm.vue';
|
||||||
import { tMobile } from 'src/composables/tMobile';
|
import { tMobile } from 'src/composables/tMobile';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
const { push } = useRouter();
|
const { push } = useRouter();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
|
@ -21,7 +22,7 @@ const { t } = useI18n();
|
||||||
const { validate } = useValidator();
|
const { validate } = useValidator();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const myForm = ref(null);
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
url: {
|
url: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -86,14 +87,6 @@ const $props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
defaultTrim: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
maxWidth: {
|
|
||||||
type: [String, Boolean],
|
|
||||||
default: '800px',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
||||||
const modelValue = computed(
|
const modelValue = computed(
|
||||||
|
@ -109,19 +102,14 @@ const originalData = ref({});
|
||||||
const formData = computed(() => state.get(modelValue));
|
const formData = computed(() => state.get(modelValue));
|
||||||
const defaultButtons = computed(() => ({
|
const defaultButtons = computed(() => ({
|
||||||
save: {
|
save: {
|
||||||
dataCy: 'saveDefaultBtn',
|
|
||||||
color: 'primary',
|
color: 'primary',
|
||||||
icon: 'save',
|
icon: 'save',
|
||||||
label: 'globals.save',
|
label: 'globals.save',
|
||||||
click: () => myForm.value.submit(),
|
|
||||||
type: 'submit',
|
|
||||||
},
|
},
|
||||||
reset: {
|
reset: {
|
||||||
dataCy: 'resetDefaultBtn',
|
|
||||||
color: 'primary',
|
color: 'primary',
|
||||||
icon: 'restart_alt',
|
icon: 'restart_alt',
|
||||||
label: 'globals.reset',
|
label: 'globals.reset',
|
||||||
click: () => reset(),
|
|
||||||
},
|
},
|
||||||
...$props.defaultButtons,
|
...$props.defaultButtons,
|
||||||
}));
|
}));
|
||||||
|
@ -198,7 +186,6 @@ async function fetch() {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
state.set(modelValue, {});
|
state.set(modelValue, {});
|
||||||
originalData.value = {};
|
originalData.value = {};
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,10 +195,7 @@ async function save() {
|
||||||
|
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
try {
|
try {
|
||||||
formData.value = trimData(formData.value);
|
const body = $props.mapper ? $props.mapper(formData.value) : formData.value;
|
||||||
const body = $props.mapper
|
|
||||||
? $props.mapper(formData.value, originalData.value)
|
|
||||||
: formData.value;
|
|
||||||
const method = $props.urlCreate ? 'post' : 'patch';
|
const method = $props.urlCreate ? 'post' : 'patch';
|
||||||
const url =
|
const url =
|
||||||
$props.urlCreate || $props.urlUpdate || $props.url || arrayData.store.url;
|
$props.urlCreate || $props.urlUpdate || $props.url || arrayData.store.url;
|
||||||
|
@ -225,6 +209,9 @@ async function save() {
|
||||||
updateAndEmit('onDataSaved', formData.value, response?.data);
|
updateAndEmit('onDataSaved', formData.value, response?.data);
|
||||||
if ($props.reload) await arrayData.fetch({});
|
if ($props.reload) await arrayData.fetch({});
|
||||||
hasChanges.value = false;
|
hasChanges.value = false;
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
notify('errors.writeRequest', 'negative');
|
||||||
} finally {
|
} finally {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
|
@ -266,35 +253,17 @@ function updateAndEmit(evt, val, res) {
|
||||||
emit(evt, state.get(modelValue), res);
|
emit(evt, state.get(modelValue), res);
|
||||||
}
|
}
|
||||||
|
|
||||||
function trimData(data) {
|
|
||||||
if (!$props.defaultTrim) return data;
|
|
||||||
for (const key in data) {
|
|
||||||
if (typeof data[key] == 'string') data[key] = data[key].trim();
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
save,
|
save,
|
||||||
isLoading,
|
isLoading,
|
||||||
hasChanges,
|
hasChanges,
|
||||||
reset,
|
reset,
|
||||||
fetch,
|
fetch,
|
||||||
formData,
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="column items-center full-width">
|
<div class="column items-center full-width">
|
||||||
<QForm
|
<QForm @submit="save" @reset="reset" class="q-pa-md" id="formModel">
|
||||||
ref="myForm"
|
|
||||||
v-if="formData"
|
|
||||||
@submit="save"
|
|
||||||
@reset="reset"
|
|
||||||
class="q-pa-md"
|
|
||||||
:style="maxWidth ? 'max-width: ' + maxWidth : ''"
|
|
||||||
id="formModel"
|
|
||||||
:prevent-submit="$attrs['prevent-submit']"
|
|
||||||
>
|
|
||||||
<QCard>
|
<QCard>
|
||||||
<slot
|
<slot
|
||||||
v-if="formData"
|
v-if="formData"
|
||||||
|
@ -322,12 +291,11 @@ defineExpose({
|
||||||
:color="defaultButtons.reset.color"
|
:color="defaultButtons.reset.color"
|
||||||
:icon="defaultButtons.reset.icon"
|
:icon="defaultButtons.reset.icon"
|
||||||
flat
|
flat
|
||||||
@click="defaultButtons.reset.click"
|
@click="reset"
|
||||||
:disable="!hasChanges"
|
:disable="!hasChanges"
|
||||||
:title="t(defaultButtons.reset.label)"
|
:title="t(defaultButtons.reset.label)"
|
||||||
/>
|
/>
|
||||||
<QBtnDropdown
|
<QBtnDropdown
|
||||||
data-cy="saveAndContinueDefaultBtn"
|
|
||||||
v-if="$props.goTo"
|
v-if="$props.goTo"
|
||||||
@click="saveAndGo"
|
@click="saveAndGo"
|
||||||
:label="tMobile('globals.saveAndContinue')"
|
:label="tMobile('globals.saveAndContinue')"
|
||||||
|
@ -363,7 +331,7 @@ defineExpose({
|
||||||
:label="tMobile('globals.save')"
|
:label="tMobile('globals.save')"
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="save"
|
icon="save"
|
||||||
@click="defaultButtons.save.click"
|
@click="save"
|
||||||
:disable="!hasChanges"
|
:disable="!hasChanges"
|
||||||
:title="t(defaultButtons.save.label)"
|
:title="t(defaultButtons.save.label)"
|
||||||
/>
|
/>
|
||||||
|
@ -382,6 +350,7 @@ defineExpose({
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
#formModel {
|
#formModel {
|
||||||
|
max-width: 800px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,6 @@ defineExpose({
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
@click="emit('onDataCanceled')"
|
@click="emit('onDataCanceled')"
|
||||||
v-close-popup
|
v-close-popup
|
||||||
data-cy="FormModelPopup_cancel"
|
|
||||||
z-max
|
|
||||||
/>
|
/>
|
||||||
<QBtn
|
<QBtn
|
||||||
:label="t('globals.save')"
|
:label="t('globals.save')"
|
||||||
|
@ -72,8 +70,6 @@ defineExpose({
|
||||||
class="q-ml-sm"
|
class="q-ml-sm"
|
||||||
:disabled="isLoading"
|
:disabled="isLoading"
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
data-cy="FormModelPopup_save"
|
|
||||||
z-max
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
const emit = defineEmits(['onSubmit']);
|
const emit = defineEmits(['onSubmit']);
|
||||||
|
|
||||||
const $props = defineProps({
|
defineProps({
|
||||||
title: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
|
@ -25,21 +25,16 @@ const $props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
submitOnEnter: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const closeButton = ref(null);
|
const closeButton = ref(null);
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
if ($props.submitOnEnter) {
|
emit('onSubmit');
|
||||||
emit('onSubmit');
|
closeForm();
|
||||||
closeForm();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeForm = () => {
|
const closeForm = () => {
|
||||||
|
|
|
@ -9,8 +9,6 @@ import VnSelect from 'components/common/VnSelect.vue';
|
||||||
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
|
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
|
||||||
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { getParamWhere } from 'src/filters';
|
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
@ -28,24 +26,32 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const itemCategories = ref([]);
|
||||||
|
const selectedCategoryFk = ref(null);
|
||||||
|
const selectedTypeFk = ref(null);
|
||||||
const itemTypesOptions = ref([]);
|
const itemTypesOptions = ref([]);
|
||||||
|
const suppliersOptions = ref([]);
|
||||||
const tagOptions = ref([]);
|
const tagOptions = ref([]);
|
||||||
const tagValues = ref([]);
|
const tagValues = ref([]);
|
||||||
const categoryList = ref(null);
|
|
||||||
const selectedCategoryFk = ref(getParamWhere(route.query.table, 'categoryFk', false));
|
|
||||||
const selectedTypeFk = ref(getParamWhere(route.query.table, 'typeFk', false));
|
|
||||||
|
|
||||||
const selectedCategory = computed(() => {
|
const categoryList = computed(() => {
|
||||||
return (categoryList.value || []).find(
|
return (itemCategories.value || [])
|
||||||
(category) => category?.id === selectedCategoryFk.value,
|
.filter((category) => category.display)
|
||||||
);
|
.map((category) => ({
|
||||||
|
...category,
|
||||||
|
icon: `vn:${(category.icon || '').split('-')[1]}`,
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const selectedCategory = computed(() =>
|
||||||
|
(itemCategories.value || []).find(
|
||||||
|
(category) => category?.id === selectedCategoryFk.value
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
const selectedType = computed(() => {
|
const selectedType = computed(() => {
|
||||||
return (itemTypesOptions.value || []).find(
|
return (itemTypesOptions.value || []).find(
|
||||||
(type) => type?.id === selectedTypeFk.value,
|
(type) => type?.id === selectedTypeFk.value
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -81,17 +87,21 @@ const applyTags = (params, search) => {
|
||||||
search();
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchItemTypes = async (id = selectedCategoryFk.value) => {
|
const fetchItemTypes = async (id) => {
|
||||||
const filter = {
|
try {
|
||||||
fields: ['id', 'name', 'categoryFk'],
|
const filter = {
|
||||||
where: { categoryFk: id },
|
fields: ['id', 'name', 'categoryFk'],
|
||||||
include: 'category',
|
where: { categoryFk: id },
|
||||||
order: 'name ASC',
|
include: 'category',
|
||||||
};
|
order: 'name ASC',
|
||||||
const { data } = await axios.get('ItemTypes', {
|
};
|
||||||
params: { filter: JSON.stringify(filter) },
|
const { data } = await axios.get('ItemTypes', {
|
||||||
});
|
params: { filter: JSON.stringify(filter) },
|
||||||
itemTypesOptions.value = data;
|
});
|
||||||
|
itemTypesOptions.value = data;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching item types', err);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getCategoryClass = (category, params) => {
|
const getCategoryClass = (category, params) => {
|
||||||
|
@ -101,38 +111,45 @@ const getCategoryClass = (category, params) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSelectedTagValues = async (tag) => {
|
const getSelectedTagValues = async (tag) => {
|
||||||
if (!tag?.selectedTag?.id) return;
|
try {
|
||||||
tag.value = null;
|
if (!tag?.selectedTag?.id) return;
|
||||||
const filter = {
|
tag.value = null;
|
||||||
fields: ['value'],
|
const filter = {
|
||||||
order: 'value ASC',
|
fields: ['value'],
|
||||||
limit: 30,
|
order: 'value ASC',
|
||||||
};
|
limit: 30,
|
||||||
|
};
|
||||||
|
|
||||||
const params = { filter: JSON.stringify(filter) };
|
const params = { filter: JSON.stringify(filter) };
|
||||||
const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, {
|
const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, {
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
tag.valueOptions = data;
|
tag.valueOptions = data;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error getting selected tag values');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeTag = (index, params, search) => {
|
const removeTag = (index, params, search) => {
|
||||||
(tagValues.value || []).splice(index, 1);
|
(tagValues.value || []).splice(index, 1);
|
||||||
applyTags(params, search);
|
applyTags(params, search);
|
||||||
};
|
};
|
||||||
const setCategoryList = (data) => {
|
|
||||||
categoryList.value = (data || [])
|
|
||||||
.filter((category) => category.display)
|
|
||||||
.map((category) => ({
|
|
||||||
...category,
|
|
||||||
icon: `vn:${(category.icon || '').split('-')[1]}`,
|
|
||||||
}));
|
|
||||||
fetchItemTypes();
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData url="ItemCategories" limit="30" auto-load @on-fetch="setCategoryList" />
|
<FetchData
|
||||||
|
url="ItemCategories"
|
||||||
|
limit="30"
|
||||||
|
auto-load
|
||||||
|
@on-fetch="(data) => (itemCategories = data)"
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
url="Suppliers"
|
||||||
|
limit="30"
|
||||||
|
auto-load
|
||||||
|
:filter="{ fields: ['id', 'name', 'nickname'], order: 'name ASC', limit: 30 }"
|
||||||
|
@on-fetch="(data) => (suppliersOptions = data)"
|
||||||
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
url="Tags"
|
url="Tags"
|
||||||
:filter="{ fields: ['id', 'name', 'isFree'] }"
|
:filter="{ fields: ['id', 'name', 'isFree'] }"
|
||||||
|
@ -142,8 +159,8 @@ const setCategoryList = (data) => {
|
||||||
/>
|
/>
|
||||||
<VnFilterPanel
|
<VnFilterPanel
|
||||||
:data-key="props.dataKey"
|
:data-key="props.dataKey"
|
||||||
:expr-builder="props.exprBuilder"
|
:expr-builder="exprBuilder"
|
||||||
:custom-tags="props.customTags"
|
:custom-tags="customTags"
|
||||||
>
|
>
|
||||||
<template #tags="{ tag, formatFn }">
|
<template #tags="{ tag, formatFn }">
|
||||||
<strong v-if="tag.label === 'categoryFk'">
|
<strong v-if="tag.label === 'categoryFk'">
|
||||||
|
@ -231,7 +248,7 @@ const setCategoryList = (data) => {
|
||||||
>
|
>
|
||||||
<QItemSection class="col">
|
<QItemSection class="col">
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('globals.tag')"
|
:label="t('components.itemsFilterPanel.tag')"
|
||||||
v-model="value.selectedTag"
|
v-model="value.selectedTag"
|
||||||
:options="tagOptions"
|
:options="tagOptions"
|
||||||
option-label="name"
|
option-label="name"
|
||||||
|
@ -280,12 +297,11 @@ const setCategoryList = (data) => {
|
||||||
/>
|
/>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem class="q-mt-lg">
|
<QItem class="q-mt-lg">
|
||||||
<QBtn
|
<QIcon
|
||||||
icon="add_circle"
|
name="add_circle"
|
||||||
shortcut="+"
|
|
||||||
flat
|
|
||||||
class="fill-icon-on-hover q-px-xs"
|
class="fill-icon-on-hover q-px-xs"
|
||||||
color="primary"
|
color="primary"
|
||||||
|
size="sm"
|
||||||
@click="tagValues.push({})"
|
@click="tagValues.push({})"
|
||||||
/>
|
/>
|
||||||
</QItem>
|
</QItem>
|
||||||
|
@ -341,11 +357,4 @@ es:
|
||||||
floramondo: Floramondo
|
floramondo: Floramondo
|
||||||
salesPersonFk: Comprador
|
salesPersonFk: Comprador
|
||||||
categoryFk: Categoría
|
categoryFk: Categoría
|
||||||
Plant: Planta natural
|
|
||||||
Flower: Flor fresca
|
|
||||||
Handmade: Hecho a mano
|
|
||||||
Artificial: Artificial
|
|
||||||
Green: Verdes frescos
|
|
||||||
Accessories: Complementos florales
|
|
||||||
Fruit: Fruta
|
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { onMounted, watch, ref, reactive, computed } from 'vue';
|
import { onMounted, ref, reactive } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { QSeparator, useQuasar } from 'quasar';
|
import { QSeparator, useQuasar } from 'quasar';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
@ -9,72 +9,26 @@ import { toLowerCamel } from 'src/filters';
|
||||||
import routes from 'src/router/modules';
|
import routes from 'src/router/modules';
|
||||||
import LeftMenuItem from './LeftMenuItem.vue';
|
import LeftMenuItem from './LeftMenuItem.vue';
|
||||||
import LeftMenuItemGroup from './LeftMenuItemGroup.vue';
|
import LeftMenuItemGroup from './LeftMenuItemGroup.vue';
|
||||||
import VnInput from './common/VnInput.vue';
|
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const navigation = useNavigationStore();
|
const navigation = useNavigationStore();
|
||||||
const router = useRouter();
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
source: {
|
source: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'main',
|
default: 'main',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const initialized = ref(false);
|
|
||||||
const items = ref([]);
|
|
||||||
const expansionItemElements = reactive({});
|
const expansionItemElements = reactive({});
|
||||||
const pinnedModules = computed(() => {
|
|
||||||
const map = new Map();
|
|
||||||
items.value.forEach((item) => item.isPinned && map.set(item.name, item));
|
|
||||||
return map;
|
|
||||||
});
|
|
||||||
const search = ref(null);
|
|
||||||
|
|
||||||
const filteredItems = computed(() => {
|
|
||||||
if (!search.value) return items.value;
|
|
||||||
const normalizedSearch = normalize(search.value);
|
|
||||||
return items.value.filter((item) => {
|
|
||||||
const locale = normalize(t(item.title));
|
|
||||||
return locale.includes(normalizedSearch);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const filteredPinnedModules = computed(() => {
|
|
||||||
if (!search.value) return pinnedModules.value;
|
|
||||||
const normalizedSearch = search.value
|
|
||||||
.normalize('NFD')
|
|
||||||
.replace(/[\u0300-\u036f]/g, '')
|
|
||||||
.toLowerCase();
|
|
||||||
const map = new Map();
|
|
||||||
for (const [key, pinnedModule] of pinnedModules.value) {
|
|
||||||
const locale = t(pinnedModule.title)
|
|
||||||
.normalize('NFD')
|
|
||||||
.replace(/[\u0300-\u036f]/g, '')
|
|
||||||
.toLowerCase();
|
|
||||||
if (locale.includes(normalizedSearch)) map.set(key, pinnedModule);
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await navigation.fetchPinned();
|
await navigation.fetchPinned();
|
||||||
getRoutes();
|
getRoutes();
|
||||||
initialized.value = true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
|
||||||
() => route.matched,
|
|
||||||
() => {
|
|
||||||
if (!initialized.value) return;
|
|
||||||
items.value = [];
|
|
||||||
getRoutes();
|
|
||||||
},
|
|
||||||
{ deep: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
function findMatches(search, item) {
|
function findMatches(search, item) {
|
||||||
const matches = [];
|
const matches = [];
|
||||||
function findRoute(search, item) {
|
function findRoute(search, item) {
|
||||||
|
@ -93,16 +47,18 @@ function findMatches(search, item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addChildren(module, route, parent) {
|
function addChildren(module, route, parent) {
|
||||||
const menus = route?.meta?.menu ?? route?.menus?.[props.source]; //backwards compatible
|
if (route.menus) {
|
||||||
if (!menus) return;
|
const mainMenus = route.menus[props.source];
|
||||||
|
const matches = findMatches(mainMenus, route);
|
||||||
|
|
||||||
const matches = findMatches(menus, route);
|
for (const child of matches) {
|
||||||
|
navigation.addMenuItem(module, child, parent);
|
||||||
for (const child of matches) {
|
}
|
||||||
navigation.addMenuItem(module, child, parent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const items = ref([]);
|
||||||
|
|
||||||
function getRoutes() {
|
function getRoutes() {
|
||||||
if (props.source === 'main') {
|
if (props.source === 'main') {
|
||||||
const modules = Object.assign([], navigation.getModules().value);
|
const modules = Object.assign([], navigation.getModules().value);
|
||||||
|
@ -123,26 +79,16 @@ function getRoutes() {
|
||||||
if (props.source === 'card') {
|
if (props.source === 'card') {
|
||||||
const currentRoute = route.matched[1];
|
const currentRoute = route.matched[1];
|
||||||
const currentModule = toLowerCamel(currentRoute.name);
|
const currentModule = toLowerCamel(currentRoute.name);
|
||||||
let moduleDef = routes.find(
|
const moduleDef = routes.find(
|
||||||
(route) => toLowerCamel(route.name) === currentModule
|
(route) => toLowerCamel(route.name) === currentModule
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!moduleDef) return;
|
if (!moduleDef) return;
|
||||||
if (!moduleDef?.menus) moduleDef = betaGetRoutes();
|
|
||||||
addChildren(currentModule, moduleDef, items.value);
|
addChildren(currentModule, moduleDef, items.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function betaGetRoutes() {
|
|
||||||
let menuRoute;
|
|
||||||
let index = route.matched.length - 1;
|
|
||||||
while (!menuRoute && index > 0) {
|
|
||||||
if (route.matched[index]?.meta?.menu) menuRoute = route.matched[index];
|
|
||||||
index--;
|
|
||||||
}
|
|
||||||
return menuRoute;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function togglePinned(item, event) {
|
async function togglePinned(item, event) {
|
||||||
if (event.defaultPrevented) return;
|
if (event.defaultPrevented) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -168,64 +114,22 @@ async function togglePinned(item, event) {
|
||||||
const handleItemExpansion = (itemName) => {
|
const handleItemExpansion = (itemName) => {
|
||||||
expansionItemElements[itemName].scrollToLastElement();
|
expansionItemElements[itemName].scrollToLastElement();
|
||||||
};
|
};
|
||||||
|
|
||||||
function normalize(text) {
|
|
||||||
return text
|
|
||||||
.normalize('NFD')
|
|
||||||
.replace(/[\u0300-\u036f]/g, '')
|
|
||||||
.toLowerCase();
|
|
||||||
}
|
|
||||||
const searchModule = () => {
|
|
||||||
const [item] = filteredItems.value;
|
|
||||||
if (item) router.push({ name: item.name });
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<QList padding class="column-max-width">
|
<QList padding class="column-max-width">
|
||||||
<template v-if="$props.source === 'main'">
|
<template v-if="$props.source === 'main'">
|
||||||
<template v-if="$route?.matched[1]?.name === 'Dashboard'">
|
<template v-if="$route?.matched[1]?.name === 'Dashboard'">
|
||||||
<QItem class="q-pb-md">
|
<QItem class="header">
|
||||||
<VnInput
|
<QItemSection avatar>
|
||||||
v-model="search"
|
<QIcon name="view_module" />
|
||||||
:label="t('Search modules')"
|
</QItemSection>
|
||||||
class="full-width"
|
<QItemSection> {{ t('globals.modules') }}</QItemSection>
|
||||||
filled
|
|
||||||
dense
|
|
||||||
autofocus
|
|
||||||
@keyup.enter.stop="searchModule()"
|
|
||||||
/>
|
|
||||||
</QItem>
|
</QItem>
|
||||||
<QSeparator />
|
<QSeparator />
|
||||||
<template v-if="filteredPinnedModules.size && !search">
|
<template v-for="item in items" :key="item.name">
|
||||||
<LeftMenuItem
|
<template v-if="item.children">
|
||||||
v-for="[key, pinnedModule] of filteredPinnedModules"
|
<LeftMenuItem :item="item" group="modules">
|
||||||
:key="key"
|
|
||||||
:item="pinnedModule"
|
|
||||||
group="modules"
|
|
||||||
>
|
|
||||||
<template #side>
|
|
||||||
<QBtn
|
|
||||||
v-if="pinnedModule.isPinned === true"
|
|
||||||
@click="togglePinned(pinnedModule, $event)"
|
|
||||||
icon="remove_circle"
|
|
||||||
size="xs"
|
|
||||||
flat
|
|
||||||
round
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ t('components.leftMenu.removeFromPinned') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</template>
|
|
||||||
</LeftMenuItem>
|
|
||||||
<QSeparator />
|
|
||||||
</template>
|
|
||||||
<template v-for="(item, index) in filteredItems" :key="item.name">
|
|
||||||
<template
|
|
||||||
v-if="search ||item.children && !filteredPinnedModules.has(item.name)"
|
|
||||||
>
|
|
||||||
<LeftMenuItem :item="item" group="modules" :class="search && index === 0 ? 'searched' : ''">
|
|
||||||
<template #side>
|
<template #side>
|
||||||
<QBtn
|
<QBtn
|
||||||
v-if="item.isPinned === true"
|
v-if="item.isPinned === true"
|
||||||
|
@ -342,11 +246,4 @@ const searchModule = () => {
|
||||||
.header {
|
.header {
|
||||||
color: var(--vn-label-color);
|
color: var(--vn-label-color);
|
||||||
}
|
}
|
||||||
.searched{
|
|
||||||
background-color: var(--vn-section-hover-color);
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
Search modules: Buscar módulos
|
|
||||||
</i18n>
|
|
||||||
|
|
|
@ -33,17 +33,13 @@ const itemComputed = computed(() => {
|
||||||
<QItemSection avatar v-if="!itemComputed.icon">
|
<QItemSection avatar v-if="!itemComputed.icon">
|
||||||
<QIcon name="disabled_by_default" />
|
<QIcon name="disabled_by_default" />
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QItemSection>
|
<QItemSection>{{ t(itemComputed.title) }}</QItemSection>
|
||||||
{{ t(itemComputed.title) }}
|
|
||||||
<QTooltip v-if="item.keyBinding">
|
|
||||||
{{ 'Ctrl + Alt + ' + item?.keyBinding?.toUpperCase() }}
|
|
||||||
</QTooltip>
|
|
||||||
</QItemSection>
|
|
||||||
<QItemSection side>
|
<QItemSection side>
|
||||||
<slot name="side" :item="itemComputed" />
|
<slot name="side" :item="itemComputed" />
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.q-item {
|
.q-item {
|
||||||
min-height: 5vh;
|
min-height: 5vh;
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { onMounted, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { useStateQueryStore } from 'src/stores/useStateQueryStore';
|
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import PinnedModules from './PinnedModules.vue';
|
import PinnedModules from './PinnedModules.vue';
|
||||||
import UserPanel from 'components/UserPanel.vue';
|
import UserPanel from 'components/UserPanel.vue';
|
||||||
|
@ -13,25 +12,19 @@ import VnAvatar from './ui/VnAvatar.vue';
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const stateQuery = useStateQueryStore();
|
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const user = state.getUser();
|
const user = state.getUser();
|
||||||
const appName = 'Lilium';
|
const appName = 'Lilium';
|
||||||
const pinnedModulesRef = ref();
|
|
||||||
|
|
||||||
onMounted(() => stateStore.setMounted());
|
onMounted(() => stateStore.setMounted());
|
||||||
const refresh = () => window.location.reload();
|
|
||||||
|
const pinnedModulesRef = ref();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<QHeader color="white" elevated>
|
<QHeader color="white" elevated>
|
||||||
<QToolbar class="q-py-sm q-px-md">
|
<QToolbar class="q-py-sm q-px-md">
|
||||||
<QBtn
|
<QBtn @click="stateStore.toggleLeftDrawer()" icon="menu" round dense flat>
|
||||||
@click="stateStore.toggleLeftDrawer()"
|
|
||||||
icon="dock_to_right"
|
|
||||||
round
|
|
||||||
dense
|
|
||||||
flat
|
|
||||||
>
|
|
||||||
<QTooltip bottom anchor="bottom right">
|
<QTooltip bottom anchor="bottom right">
|
||||||
{{ t('globals.collapseMenu') }}
|
{{ t('globals.collapseMenu') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
|
@ -51,27 +44,21 @@ const refresh = () => window.location.reload();
|
||||||
</QBtn>
|
</QBtn>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<VnBreadcrumbs v-if="$q.screen.gt.sm" />
|
<VnBreadcrumbs v-if="$q.screen.gt.sm" />
|
||||||
<QSpinner
|
|
||||||
color="primary"
|
|
||||||
class="q-ml-md"
|
|
||||||
:class="{
|
|
||||||
'no-visible': !stateQuery.isLoading().value,
|
|
||||||
}"
|
|
||||||
size="xs"
|
|
||||||
data-cy="loading-spinner"
|
|
||||||
/>
|
|
||||||
<QSpace />
|
<QSpace />
|
||||||
<div id="searchbar" class="searchbar"></div>
|
<div id="searchbar" class="searchbar"></div>
|
||||||
<QSpace />
|
<QSpace />
|
||||||
<div class="q-pl-sm q-gutter-sm row items-center no-wrap">
|
<div class="q-pl-sm q-gutter-sm row items-center no-wrap">
|
||||||
<div id="actions-prepend"></div>
|
<div id="actions-prepend"></div>
|
||||||
<QIcon
|
<QBtn
|
||||||
name="refresh"
|
flat
|
||||||
size="md"
|
v-if="!quasar.platform.is.mobile"
|
||||||
color="red"
|
@click="pinnedModulesRef.redirect($route.params.id)"
|
||||||
v-if="state.get('error')"
|
icon="more_up"
|
||||||
@click="refresh"
|
>
|
||||||
/>
|
<QTooltip>
|
||||||
|
{{ t('Go to Salix') }}
|
||||||
|
</QTooltip>
|
||||||
|
</QBtn>
|
||||||
<QBtn
|
<QBtn
|
||||||
:class="{ 'q-pa-none': quasar.platform.is.mobile }"
|
:class="{ 'q-pa-none': quasar.platform.is.mobile }"
|
||||||
id="pinnedModules"
|
id="pinnedModules"
|
||||||
|
@ -103,6 +90,7 @@ const refresh = () => window.location.reload();
|
||||||
<VnBreadcrumbs v-if="$q.screen.lt.md" class="q-ml-md" />
|
<VnBreadcrumbs v-if="$q.screen.lt.md" class="q-ml-md" />
|
||||||
</QHeader>
|
</QHeader>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.searchbar {
|
.searchbar {
|
||||||
width: max-content;
|
width: max-content;
|
||||||
|
@ -111,3 +99,9 @@ const refresh = () => window.location.reload();
|
||||||
background-color: var(--vn-section-color);
|
background-color: var(--vn-section-color);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<i18n>
|
||||||
|
en:
|
||||||
|
Go to Salix: Go to Salix
|
||||||
|
es:
|
||||||
|
Go to Salix: Ir a Salix
|
||||||
|
</i18n>
|
||||||
|
|
|
@ -1,170 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref, reactive } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
import { useDialogPluginComponent } from 'quasar';
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
|
||||||
import FormPopup from './FormPopup.vue';
|
|
||||||
import axios from 'axios';
|
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
invoiceOutData: {
|
|
||||||
type: Object,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const { dialogRef } = useDialogPluginComponent();
|
|
||||||
const { t } = useI18n();
|
|
||||||
const router = useRouter();
|
|
||||||
const { notify } = useNotify();
|
|
||||||
|
|
||||||
const rectificativeTypeOptions = ref([]);
|
|
||||||
const siiTypeInvoiceOutsOptions = ref([]);
|
|
||||||
const invoiceParams = reactive({
|
|
||||||
id: $props.invoiceOutData?.id,
|
|
||||||
inheritWarehouse: true,
|
|
||||||
});
|
|
||||||
const invoiceCorrectionTypesOptions = ref([]);
|
|
||||||
|
|
||||||
const refund = async () => {
|
|
||||||
const params = {
|
|
||||||
id: invoiceParams.id,
|
|
||||||
withWarehouse: invoiceParams.inheritWarehouse,
|
|
||||||
cplusRectificationTypeFk: invoiceParams.cplusRectificationTypeFk,
|
|
||||||
siiTypeInvoiceOutFk: invoiceParams.siiTypeInvoiceOutFk,
|
|
||||||
invoiceCorrectionTypeFk: invoiceParams.invoiceCorrectionTypeFk,
|
|
||||||
};
|
|
||||||
|
|
||||||
const { data } = await axios.post('InvoiceOuts/refundAndInvoice', params);
|
|
||||||
notify(t('Refunded invoice'), 'positive');
|
|
||||||
const [id] = data?.refundId || [];
|
|
||||||
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<FetchData
|
|
||||||
url="CplusRectificationTypes"
|
|
||||||
:filter="{ order: 'description' }"
|
|
||||||
@on-fetch="
|
|
||||||
(data) => (
|
|
||||||
(rectificativeTypeOptions = data),
|
|
||||||
(invoiceParams.cplusRectificationTypeFk = data.filter(
|
|
||||||
(type) => type.description == 'I – Por diferencias'
|
|
||||||
)[0].id)
|
|
||||||
)
|
|
||||||
"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
url="SiiTypeInvoiceOuts"
|
|
||||||
:filter="{ where: { code: { like: 'R%' } } }"
|
|
||||||
@on-fetch="
|
|
||||||
(data) => (
|
|
||||||
(siiTypeInvoiceOutsOptions = data),
|
|
||||||
(invoiceParams.siiTypeInvoiceOutFk = data.filter(
|
|
||||||
(type) => type.code == 'R4'
|
|
||||||
)[0].id)
|
|
||||||
)
|
|
||||||
"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
url="InvoiceCorrectionTypes"
|
|
||||||
@on-fetch="(data) => (invoiceCorrectionTypesOptions = data)"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
|
|
||||||
<QDialog ref="dialogRef">
|
|
||||||
<FormPopup
|
|
||||||
@on-submit="refund()"
|
|
||||||
:custom-submit-button-label="t('Accept')"
|
|
||||||
:default-cancel-button="false"
|
|
||||||
>
|
|
||||||
<template #form-inputs>
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Rectificative type')"
|
|
||||||
:options="rectificativeTypeOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="description"
|
|
||||||
option-value="id"
|
|
||||||
v-model="invoiceParams.cplusRectificationTypeFk"
|
|
||||||
:required="true"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Class')"
|
|
||||||
:options="siiTypeInvoiceOutsOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="description"
|
|
||||||
option-value="id"
|
|
||||||
v-model="invoiceParams.siiTypeInvoiceOutFk"
|
|
||||||
:required="true"
|
|
||||||
>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem v-bind="scope.itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>
|
|
||||||
{{ scope.opt?.code }} -
|
|
||||||
{{ scope.opt?.description }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
</VnRow>
|
|
||||||
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Type')"
|
|
||||||
:options="invoiceCorrectionTypesOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="description"
|
|
||||||
option-value="id"
|
|
||||||
v-model="invoiceParams.invoiceCorrectionTypeFk"
|
|
||||||
:required="true"
|
|
||||||
/> </VnRow
|
|
||||||
><VnRow>
|
|
||||||
<div>
|
|
||||||
<QCheckbox
|
|
||||||
:label="t('Inherit warehouse')"
|
|
||||||
v-model="invoiceParams.inheritWarehouse"
|
|
||||||
/>
|
|
||||||
<QIcon name="info" class="cursor-info q-ml-sm" size="sm">
|
|
||||||
<QTooltip>{{ t('Inherit warehouse tooltip') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</div>
|
|
||||||
</VnRow>
|
|
||||||
</template>
|
|
||||||
</FormPopup>
|
|
||||||
</QDialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
en:
|
|
||||||
Refund invoice: Refund invoice
|
|
||||||
Rectificative type: Rectificative type
|
|
||||||
Class: Class
|
|
||||||
Type: Type
|
|
||||||
Refunded invoice: Refunded invoice
|
|
||||||
Inherit warehouse: Inherit the warehouse
|
|
||||||
Inherit warehouse tooltip: Select this option to inherit the warehouse when refunding the invoice
|
|
||||||
Accept: Accept
|
|
||||||
Error refunding invoice: Error refunding invoice
|
|
||||||
es:
|
|
||||||
Refund invoice: Abonar factura
|
|
||||||
Rectificative type: Tipo rectificativa
|
|
||||||
Class: Clase
|
|
||||||
Type: Tipo
|
|
||||||
Refunded invoice: Factura abonada
|
|
||||||
Inherit warehouse: Heredar el almacén
|
|
||||||
Inherit warehouse tooltip: Seleccione esta opción para heredar el almacén al abonar la factura.
|
|
||||||
Accept: Aceptar
|
|
||||||
Error refunding invoice: Error abonando factura
|
|
||||||
</i18n>
|
|
|
@ -44,7 +44,7 @@ const onDataSaved = (data) => {
|
||||||
<FormModelPopup
|
<FormModelPopup
|
||||||
url-create="Items/regularize"
|
url-create="Items/regularize"
|
||||||
model="Items"
|
model="Items"
|
||||||
:title="t('item.regularizeStock')"
|
:title="t('Regularize stock')"
|
||||||
:form-initial-data="regularizeFormData"
|
:form-initial-data="regularizeFormData"
|
||||||
@on-data-saved="onDataSaved($event)"
|
@on-data-saved="onDataSaved($event)"
|
||||||
>
|
>
|
||||||
|
@ -55,7 +55,6 @@ const onDataSaved = (data) => {
|
||||||
v-model.number="data.quantity"
|
v-model.number="data.quantity"
|
||||||
type="number"
|
type="number"
|
||||||
autofocus
|
autofocus
|
||||||
data-cy="regularizeStockInput"
|
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow>
|
<VnRow>
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
<script setup>
|
|
||||||
defineProps({ row: { type: Object, required: true } });
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<span>
|
|
||||||
<QIcon
|
|
||||||
v-if="row.isTaxDataChecked === 0"
|
|
||||||
name="vn:no036"
|
|
||||||
color="primary"
|
|
||||||
size="xs"
|
|
||||||
>
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.noVerifiedData') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.hasTicketRequest" name="vn:buyrequest" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.purchaseRequest') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.itemShortage" name="vn:unavailable" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.notVisible') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.isFreezed" name="vn:frozen" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.clientFrozen') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon
|
|
||||||
v-if="row.risk"
|
|
||||||
name="vn:risk"
|
|
||||||
:color="row.hasHighRisk ? 'negative' : 'primary'"
|
|
||||||
size="xs"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ $t('salesTicketsTable.risk') }}: {{ row.risk - row.credit }}
|
|
||||||
</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.hasComponentLack" name="vn:components" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.componentLack') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.isTooLittle" name="vn:isTooLittle" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.tooLittle') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
|
@ -2,12 +2,13 @@
|
||||||
import { ref, reactive } from 'vue';
|
import { ref, reactive } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { useQuasar, useDialogPluginComponent } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
import VnSelect from 'components/common/VnSelect.vue';
|
||||||
import FormPopup from './FormPopup.vue';
|
import FormPopup from './FormPopup.vue';
|
||||||
|
import { useDialogPluginComponent } from 'quasar';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
|
|
||||||
|
@ -17,19 +18,19 @@ const $props = defineProps({
|
||||||
default: () => {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { dialogRef } = useDialogPluginComponent();
|
const { dialogRef } = useDialogPluginComponent();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
|
||||||
const rectificativeTypeOptions = ref([]);
|
|
||||||
const siiTypeInvoiceOutsOptions = ref([]);
|
|
||||||
const checked = ref(true);
|
const checked = ref(true);
|
||||||
const transferInvoiceParams = reactive({
|
const transferInvoiceParams = reactive({
|
||||||
id: $props.invoiceOutData?.id,
|
id: $props.invoiceOutData?.id,
|
||||||
|
refFk: $props.invoiceOutData?.ref,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const rectificativeTypeOptions = ref([]);
|
||||||
|
const siiTypeInvoiceOutsOptions = ref([]);
|
||||||
const invoiceCorrectionTypesOptions = ref([]);
|
const invoiceCorrectionTypesOptions = ref([]);
|
||||||
|
|
||||||
const selectedClient = (client) => {
|
const selectedClient = (client) => {
|
||||||
|
@ -43,38 +44,43 @@ const makeInvoice = async () => {
|
||||||
const params = {
|
const params = {
|
||||||
id: transferInvoiceParams.id,
|
id: transferInvoiceParams.id,
|
||||||
cplusRectificationTypeFk: transferInvoiceParams.cplusRectificationTypeFk,
|
cplusRectificationTypeFk: transferInvoiceParams.cplusRectificationTypeFk,
|
||||||
siiTypeInvoiceOutFk: transferInvoiceParams.siiTypeInvoiceOutFk,
|
|
||||||
invoiceCorrectionTypeFk: transferInvoiceParams.invoiceCorrectionTypeFk,
|
invoiceCorrectionTypeFk: transferInvoiceParams.invoiceCorrectionTypeFk,
|
||||||
newClientFk: transferInvoiceParams.newClientFk,
|
newClientFk: transferInvoiceParams.newClientFk,
|
||||||
|
refFk: transferInvoiceParams.refFk,
|
||||||
|
siiTypeInvoiceOutFk: transferInvoiceParams.siiTypeInvoiceOutFk,
|
||||||
makeInvoice: checked.value,
|
makeInvoice: checked.value,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (checked.value && hasToInvoiceByAddress) {
|
try {
|
||||||
const response = await new Promise((resolve) => {
|
if (checked.value && hasToInvoiceByAddress) {
|
||||||
quasar
|
const response = await new Promise((resolve) => {
|
||||||
.dialog({
|
quasar
|
||||||
component: VnConfirm,
|
.dialog({
|
||||||
componentProps: {
|
component: VnConfirm,
|
||||||
title: t('Bill destination client'),
|
componentProps: {
|
||||||
message: t('transferInvoiceInfo'),
|
title: t('Bill destination client'),
|
||||||
},
|
message: t('transferInvoiceInfo'),
|
||||||
})
|
},
|
||||||
.onOk(() => {
|
})
|
||||||
resolve(true);
|
.onOk(() => {
|
||||||
})
|
resolve(true);
|
||||||
.onCancel(() => {
|
})
|
||||||
resolve(false);
|
.onCancel(() => {
|
||||||
});
|
resolve(false);
|
||||||
});
|
});
|
||||||
if (!response) {
|
});
|
||||||
return;
|
if (!response) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const { data } = await axios.post('InvoiceOuts/transfer', params);
|
const { data } = await axios.post('InvoiceOuts/transferInvoice', params);
|
||||||
notify(t('Transferred invoice'), 'positive');
|
notify(t('Transferred invoice'), 'positive');
|
||||||
const id = data?.[0];
|
const id = data?.[0];
|
||||||
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error transfering invoice', err);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import quasarLang from 'src/utils/quasarLang';
|
|
||||||
|
|
||||||
import { onMounted, computed, ref } from 'vue';
|
import { onMounted, computed, ref } from 'vue';
|
||||||
|
import { Dark, Quasar } from 'quasar';
|
||||||
import { Dark } from 'quasar';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
@ -16,14 +13,12 @@ import FetchData from 'components/FetchData.vue';
|
||||||
import { useClipboard } from 'src/composables/useClipboard';
|
import { useClipboard } from 'src/composables/useClipboard';
|
||||||
import { useRole } from 'src/composables/useRole';
|
import { useRole } from 'src/composables/useRole';
|
||||||
import VnAvatar from './ui/VnAvatar.vue';
|
import VnAvatar from './ui/VnAvatar.vue';
|
||||||
import useNotify from 'src/composables/useNotify';
|
|
||||||
|
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const session = useSession();
|
const session = useSession();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { t, locale } = useI18n();
|
const { t, locale } = useI18n();
|
||||||
const { copyText } = useClipboard();
|
const { copyText } = useClipboard();
|
||||||
const { notify } = useNotify();
|
|
||||||
|
|
||||||
const userLocale = computed({
|
const userLocale = computed({
|
||||||
get() {
|
get() {
|
||||||
|
@ -34,7 +29,14 @@ const userLocale = computed({
|
||||||
|
|
||||||
value = localeEquivalence[value] ?? value;
|
value = localeEquivalence[value] ?? value;
|
||||||
|
|
||||||
quasarLang(value);
|
try {
|
||||||
|
/* @vite-ignore */
|
||||||
|
import(`../../node_modules/quasar/lang/${value}.mjs`).then((lang) => {
|
||||||
|
Quasar.lang.set(lang.default);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
//
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -51,7 +53,6 @@ const user = state.getUser();
|
||||||
const warehousesData = ref();
|
const warehousesData = ref();
|
||||||
const companiesData = ref();
|
const companiesData = ref();
|
||||||
const accountBankData = ref();
|
const accountBankData = ref();
|
||||||
const isEmployee = computed(() => useRole().isEmployee());
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
updatePreferences();
|
updatePreferences();
|
||||||
|
@ -69,28 +70,18 @@ function updatePreferences() {
|
||||||
|
|
||||||
async function saveDarkMode(value) {
|
async function saveDarkMode(value) {
|
||||||
const query = `/UserConfigs/${user.value.id}`;
|
const query = `/UserConfigs/${user.value.id}`;
|
||||||
try {
|
await axios.patch(query, {
|
||||||
await axios.patch(query, {
|
darkMode: value,
|
||||||
darkMode: value,
|
});
|
||||||
});
|
user.value.darkMode = value;
|
||||||
user.value.darkMode = value;
|
|
||||||
onDataSaved();
|
|
||||||
} catch (error) {
|
|
||||||
onDataError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveLanguage(value) {
|
async function saveLanguage(value) {
|
||||||
const query = `/VnUsers/${user.value.id}`;
|
const query = `/VnUsers/${user.value.id}`;
|
||||||
try {
|
await axios.patch(query, {
|
||||||
await axios.patch(query, { lang: value });
|
lang: value,
|
||||||
|
});
|
||||||
user.value.lang = value;
|
user.value.lang = value;
|
||||||
useState().setUser(user.value);
|
|
||||||
onDataSaved();
|
|
||||||
} catch (error) {
|
|
||||||
onDataError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function logout() {
|
function logout() {
|
||||||
|
@ -106,23 +97,11 @@ function localUserData() {
|
||||||
state.setUser(user.value);
|
state.setUser(user.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveUserData(param, value) {
|
function saveUserData(param, value) {
|
||||||
try {
|
axios.post('UserConfigs/setUserConfig', { [param]: value });
|
||||||
await axios.post('UserConfigs/setUserConfig', { [param]: value });
|
localUserData();
|
||||||
localUserData();
|
|
||||||
onDataSaved();
|
|
||||||
} catch (error) {
|
|
||||||
onDataError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
const isEmployee = computed(() => useRole().isEmployee());
|
||||||
const onDataSaved = () => {
|
|
||||||
notify('globals.dataSaved', 'positive');
|
|
||||||
};
|
|
||||||
|
|
||||||
const onDataError = () => {
|
|
||||||
notify('errors.updateUserConfig', 'negative');
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -7,72 +7,38 @@ import VnSelectDialog from 'components/common/VnSelectDialog.vue';
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
import CreateNewProvinceForm from './CreateNewProvinceForm.vue';
|
import CreateNewProvinceForm from './CreateNewProvinceForm.vue';
|
||||||
|
|
||||||
const emit = defineEmits(['onProvinceCreated', 'onProvinceFetched', 'update:options']);
|
const emit = defineEmits(['onProvinceCreated']);
|
||||||
const $props = defineProps({
|
const provinceFk = defineModel({ type: Number });
|
||||||
countryFk: {
|
watch(provinceFk, async () => await provincesFetchDataRef.value.fetch());
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
provinceSelected: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const provinceFk = defineModel({ type: Number, default: null });
|
|
||||||
|
|
||||||
const { validate } = useValidator();
|
const { validate } = useValidator();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const filter = ref({
|
|
||||||
include: { relation: 'country' },
|
const provincesOptions = ref();
|
||||||
where: {
|
|
||||||
countryFk: $props.countryFk,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const provincesOptions = ref($props.provinces);
|
|
||||||
const provincesFetchDataRef = ref();
|
const provincesFetchDataRef = ref();
|
||||||
provinceFk.value = $props.provinceSelected;
|
|
||||||
if (!$props.countryFk) {
|
|
||||||
filter.value.where = {};
|
|
||||||
}
|
|
||||||
async function onProvinceCreated(_, data) {
|
async function onProvinceCreated(_, data) {
|
||||||
await provincesFetchDataRef.value.fetch({ where: { countryFk: $props.countryFk } });
|
await provincesFetchDataRef.value.fetch();
|
||||||
provinceFk.value = data.id;
|
provinceFk.value = data.id;
|
||||||
emit('onProvinceCreated', data);
|
emit('onProvinceCreated', data);
|
||||||
}
|
}
|
||||||
async function handleProvinces(data) {
|
|
||||||
provincesOptions.value = data;
|
|
||||||
emit('update:options', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => $props.countryFk,
|
|
||||||
async () => {
|
|
||||||
if ($props.countryFk) {
|
|
||||||
filter.value.where.countryFk = $props.countryFk;
|
|
||||||
} else filter.value.where = {};
|
|
||||||
await provincesFetchDataRef.value.fetch({});
|
|
||||||
emit('onProvinceFetched', provincesOptions.value);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
ref="provincesFetchDataRef"
|
ref="provincesFetchDataRef"
|
||||||
:filter="filter"
|
:filter="{ include: { relation: 'country' } }"
|
||||||
@on-fetch="handleProvinces"
|
@on-fetch="(data) => (provincesOptions = data)"
|
||||||
url="Provinces"
|
|
||||||
auto-load
|
auto-load
|
||||||
|
url="Provinces"
|
||||||
/>
|
/>
|
||||||
<VnSelectDialog
|
<VnSelectDialog
|
||||||
data-cy="locationProvince"
|
|
||||||
:label="t('Province')"
|
:label="t('Province')"
|
||||||
:options="provincesOptions"
|
:options="provincesOptions"
|
||||||
:tooltip="t('Create province')"
|
|
||||||
hide-selected
|
hide-selected
|
||||||
v-model="provinceFk"
|
v-model="provinceFk"
|
||||||
:rules="validate && validate('postcode.provinceFk')"
|
:rules="validate && validate('postcode.provinceFk')"
|
||||||
:acls="[{ model: 'Province', props: '*', accessType: 'WRITE' }]"
|
:roles-allowed-to-create="['deliveryAssistant']"
|
||||||
>
|
>
|
||||||
<template #option="{ itemProps, opt }">
|
<template #option="{ itemProps, opt }">
|
||||||
<QItem v-bind="itemProps">
|
<QItem v-bind="itemProps">
|
||||||
|
@ -83,15 +49,11 @@ watch(
|
||||||
</QItem>
|
</QItem>
|
||||||
</template>
|
</template>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CreateNewProvinceForm
|
<CreateNewProvinceForm @on-data-saved="onProvinceCreated" />
|
||||||
:country-fk="$props.countryFk"
|
|
||||||
@on-data-saved="onProvinceCreated"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
</VnSelectDialog>
|
</VnSelectDialog>
|
||||||
</template>
|
</template>
|
||||||
<i18n>
|
<i18n>
|
||||||
es:
|
es:
|
||||||
Province: Provincia
|
Province: Provincia
|
||||||
Create province: Crear provincia
|
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { markRaw, computed } from 'vue';
|
import { markRaw, computed, defineModel } from 'vue';
|
||||||
import { QIcon, QCheckbox } from 'quasar';
|
import { QIcon, QCheckbox } from 'quasar';
|
||||||
import { dashIfEmpty } from 'src/filters';
|
import { dashIfEmpty } from 'src/filters';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { markRaw, computed } from 'vue';
|
import { markRaw, computed, defineModel } from 'vue';
|
||||||
import { QCheckbox } from 'quasar';
|
import { QCheckbox } from 'quasar';
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ import VnInputDate from 'components/common/VnInputDate.vue';
|
||||||
import VnInputTime from 'components/common/VnInputTime.vue';
|
import VnInputTime from 'components/common/VnInputTime.vue';
|
||||||
import VnTableColumn from 'components/VnTable/VnColumn.vue';
|
import VnTableColumn from 'components/VnTable/VnColumn.vue';
|
||||||
|
|
||||||
|
defineExpose({ addFilter });
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
column: {
|
column: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
@ -25,20 +27,14 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
searchUrl: {
|
searchUrl: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'table',
|
default: 'params',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
defineExpose({ addFilter, props: $props });
|
|
||||||
|
|
||||||
const model = defineModel(undefined, { required: true });
|
const model = defineModel(undefined, { required: true });
|
||||||
const arrayData = useArrayData(
|
const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl });
|
||||||
$props.dataKey,
|
|
||||||
$props.searchUrl ? { searchUrl: $props.searchUrl } : null
|
|
||||||
);
|
|
||||||
const columnFilter = computed(() => $props.column?.columnFilter);
|
const columnFilter = computed(() => $props.column?.columnFilter);
|
||||||
|
|
||||||
const updateEvent = { 'update:modelValue': addFilter };
|
const updateEvent = { 'update:modelValue': addFilter, remove: () => addFilter(null) };
|
||||||
const enterEvent = {
|
const enterEvent = {
|
||||||
'keyup.enter': () => addFilter(model.value),
|
'keyup.enter': () => addFilter(model.value),
|
||||||
remove: () => addFilter(null),
|
remove: () => addFilter(null),
|
||||||
|
@ -119,11 +115,11 @@ const components = {
|
||||||
rawSelect: selectComponent,
|
rawSelect: selectComponent,
|
||||||
};
|
};
|
||||||
|
|
||||||
async function addFilter(value, name) {
|
async function addFilter(value) {
|
||||||
value ??= undefined;
|
value ??= undefined;
|
||||||
if (value && typeof value === 'object') value = model.value;
|
if (value && typeof value === 'object') value = model.value;
|
||||||
value = value === '' ? undefined : value;
|
value = value === '' ? undefined : value;
|
||||||
let field = columnFilter.value?.name ?? $props.column.name ?? name;
|
let field = columnFilter.value?.name ?? $props.column.name;
|
||||||
|
|
||||||
if (columnFilter.value?.inWhere) {
|
if (columnFilter.value?.inWhere) {
|
||||||
if (columnFilter.value.alias) field = columnFilter.value.alias + '.' + field;
|
if (columnFilter.value.alias) field = columnFilter.value.alias + '.' + field;
|
||||||
|
@ -146,10 +142,6 @@ function alignRow() {
|
||||||
const showFilter = computed(
|
const showFilter = computed(
|
||||||
() => $props.column?.columnFilter !== false && $props.column.name != 'tableActions'
|
() => $props.column?.columnFilter !== false && $props.column.name != 'tableActions'
|
||||||
);
|
);
|
||||||
|
|
||||||
const onTabPressed = async () => {
|
|
||||||
if (model.value) enterEvent['keyup.enter']();
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
|
@ -164,7 +156,6 @@ const onTabPressed = async () => {
|
||||||
v-model="model"
|
v-model="model"
|
||||||
:components="components"
|
:components="components"
|
||||||
component-prop="columnFilter"
|
component-prop="columnFilter"
|
||||||
@keydown.tab="onTabPressed"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { useArrayData } from 'composables/useArrayData';
|
||||||
const model = defineModel({ type: Object });
|
const model = defineModel({ type: Object });
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
name: {
|
name: {
|
||||||
type: [String, Boolean],
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
label: {
|
label: {
|
||||||
|
@ -17,7 +17,7 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
searchUrl: {
|
searchUrl: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'table',
|
default: 'params',
|
||||||
},
|
},
|
||||||
vertical: {
|
vertical: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,69 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref } from 'vue';
|
|
||||||
|
|
||||||
import VnFilterPanel from 'components/ui/VnFilterPanel.vue';
|
|
||||||
import VnFilter from 'components/VnTable/VnFilter.vue';
|
|
||||||
import VnTableOrder from 'src/components/VnTable/VnOrder.vue';
|
|
||||||
|
|
||||||
defineProps({
|
|
||||||
columns: {
|
|
||||||
type: Array,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
searchUrl: {
|
|
||||||
type: [String, Boolean],
|
|
||||||
default: 'table',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const tableFilterRef = ref([]);
|
|
||||||
|
|
||||||
function columnName(col) {
|
|
||||||
const column = { ...col, ...col.columnFilter };
|
|
||||||
let name = column.name;
|
|
||||||
if (column.alias) name = column.alias + '.' + name;
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<VnFilterPanel v-bind="$attrs" :search-button="true" :disable-submit-event="true">
|
|
||||||
<template #body="{ params, orders }">
|
|
||||||
<div
|
|
||||||
class="row no-wrap flex-center"
|
|
||||||
v-for="col of columns.filter((c) => c.columnFilter ?? true)"
|
|
||||||
:key="col.id"
|
|
||||||
>
|
|
||||||
<VnFilter
|
|
||||||
ref="tableFilterRef"
|
|
||||||
:column="col"
|
|
||||||
:data-key="$attrs['data-key']"
|
|
||||||
v-model="params[columnName(col)]"
|
|
||||||
:search-url="searchUrl"
|
|
||||||
/>
|
|
||||||
<VnTableOrder
|
|
||||||
v-if="col?.columnFilter !== false && col?.name !== 'tableActions'"
|
|
||||||
v-model="orders[col.orderBy ?? col.name]"
|
|
||||||
:name="col.orderBy ?? col.name"
|
|
||||||
:data-key="$attrs['data-key']"
|
|
||||||
:search-url="searchUrl"
|
|
||||||
:vertical="true"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<slot
|
|
||||||
name="moreFilterPanel"
|
|
||||||
:params="params"
|
|
||||||
:orders="orders"
|
|
||||||
:columns="columns"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template #tags="{ tag, formatFn, getLocale }">
|
|
||||||
<div class="q-gutter-x-xs">
|
|
||||||
<strong>{{ getLocale(`${tag.label}`) }}: </strong>
|
|
||||||
<span>{{ formatFn(tag.value) }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
|
|
||||||
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
|
||||||
</template>
|
|
||||||
</VnFilterPanel>
|
|
||||||
</template>
|
|
|
@ -135,7 +135,7 @@ onMounted(async () => {
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<QBtn icon="vn:visible_columns" class="bg-vn-section-color q-mr-sm q-px-sm" dense>
|
<QBtn icon="vn:visible_columns" class="bg-vn-section-color q-mr-md q-px-sm" dense>
|
||||||
<QPopupProxy ref="popupProxyRef">
|
<QPopupProxy ref="popupProxyRef">
|
||||||
<QCard class="column q-pa-md">
|
<QCard class="column q-pa-md">
|
||||||
<QIcon name="info" size="sm" class="info-icon">
|
<QIcon name="info" size="sm" class="info-icon">
|
||||||
|
@ -152,7 +152,7 @@ onMounted(async () => {
|
||||||
<QCheckbox
|
<QCheckbox
|
||||||
v-for="col in localColumns"
|
v-for="col in localColumns"
|
||||||
:key="col.name"
|
:key="col.name"
|
||||||
:label="col.label ?? col.name"
|
:label="col.label"
|
||||||
v-model="col.visible"
|
v-model="col.visible"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
import { describe, expect, it, beforeAll, beforeEach, vi } from 'vitest';
|
|
||||||
import { createWrapper } from 'app/test/vitest/helper';
|
|
||||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
|
||||||
|
|
||||||
describe('VnTable', () => {
|
|
||||||
let wrapper;
|
|
||||||
let vm;
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
wrapper = createWrapper(VnTable, {
|
|
||||||
propsData: {
|
|
||||||
columns: [],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
vm = wrapper.vm;
|
|
||||||
|
|
||||||
vi.mock('src/composables/useFilterParams', () => {
|
|
||||||
return {
|
|
||||||
useFilterParams: vi.fn(() => ({
|
|
||||||
params: {},
|
|
||||||
orders: {},
|
|
||||||
})),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => (vm.selected = []));
|
|
||||||
|
|
||||||
describe('handleSelection()', () => {
|
|
||||||
const rows = [{ $index: 0 }, { $index: 1 }, { $index: 2 }];
|
|
||||||
const selectedRows = [{ $index: 1 }];
|
|
||||||
it('should add rows to selected when shift key is pressed and rows are added except last one', () => {
|
|
||||||
vm.handleSelection(
|
|
||||||
{ evt: { shiftKey: true }, added: true, rows: selectedRows },
|
|
||||||
rows
|
|
||||||
);
|
|
||||||
expect(vm.selected).toEqual([{ $index: 0 }]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not add rows to selected when shift key is not pressed', () => {
|
|
||||||
vm.handleSelection(
|
|
||||||
{ evt: { shiftKey: false }, added: true, rows: selectedRows },
|
|
||||||
rows
|
|
||||||
);
|
|
||||||
expect(vm.selected).toEqual([]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not add rows to selected when rows are not added', () => {
|
|
||||||
vm.handleSelection(
|
|
||||||
{ evt: { shiftKey: true }, added: false, rows: selectedRows },
|
|
||||||
rows
|
|
||||||
);
|
|
||||||
expect(vm.selected).toEqual([]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,121 +0,0 @@
|
||||||
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';
|
|
||||||
|
|
||||||
describe('VnVisibleColumns', () => {
|
|
||||||
let wrapper;
|
|
||||||
let vm;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
wrapper = createWrapper(VnVisibleColumn, {
|
|
||||||
propsData: {
|
|
||||||
tableCode: 'testTable',
|
|
||||||
skip: ['skippedColumn'],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
vm = wrapper.vm;
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('setUserConfigViewData()', () => {
|
|
||||||
it('should initialize localColumns with visible configuration', () => {
|
|
||||||
vm.columns = [
|
|
||||||
{ name: 'columnMockName', label: undefined },
|
|
||||||
{ name: 'columnMockAddress', label: undefined },
|
|
||||||
{ name: 'columnMockId', label: undefined },
|
|
||||||
];
|
|
||||||
const configuration = {
|
|
||||||
columnMockName: true,
|
|
||||||
columnMockAddress: false,
|
|
||||||
columnMockId: true,
|
|
||||||
};
|
|
||||||
const expectedColumns = [
|
|
||||||
{ name: 'columnMockName', label: undefined, visible: true },
|
|
||||||
{ name: 'columnMockAddress', label: undefined, visible: false },
|
|
||||||
{ name: 'columnMockId', label: undefined, visible: true },
|
|
||||||
];
|
|
||||||
|
|
||||||
vm.setUserConfigViewData(configuration, false);
|
|
||||||
|
|
||||||
expect(vm.localColumns).toEqual(expectedColumns);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should skip columns based on props', () => {
|
|
||||||
vm.columns = [
|
|
||||||
{ name: 'columnMockName', label: undefined },
|
|
||||||
{ name: 'columnMockId', label: undefined },
|
|
||||||
{ name: 'skippedColumn', label: 'Skipped Column' },
|
|
||||||
];
|
|
||||||
const configuration = {
|
|
||||||
columnMockName: true,
|
|
||||||
skippedColumn: false,
|
|
||||||
columnMockId: true,
|
|
||||||
};
|
|
||||||
const expectedColumns = [
|
|
||||||
{ name: 'columnMockName', label: undefined, visible: true },
|
|
||||||
{ name: 'columnMockId', label: undefined, visible: true },
|
|
||||||
];
|
|
||||||
|
|
||||||
vm.setUserConfigViewData(configuration, false);
|
|
||||||
|
|
||||||
expect(vm.localColumns).toEqual(expectedColumns);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('toggleMarkAll()', () => {
|
|
||||||
it('should set all localColumns to visible=true', () => {
|
|
||||||
vm.localColumns = [
|
|
||||||
{ name: 'columnMockName', visible: false },
|
|
||||||
{ name: 'columnMockId', visible: false },
|
|
||||||
];
|
|
||||||
|
|
||||||
vm.toggleMarkAll(true);
|
|
||||||
|
|
||||||
expect(vm.localColumns.every((col) => col.visible)).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set all localColumns to visible=false', () => {
|
|
||||||
vm.localColumns = [
|
|
||||||
{ name: 'columnMockName', visible: true },
|
|
||||||
{ name: 'columnMockId', visible: true },
|
|
||||||
];
|
|
||||||
|
|
||||||
vm.toggleMarkAll(false);
|
|
||||||
|
|
||||||
expect(vm.localColumns.every((col) => col.visible)).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('saveConfig()', () => {
|
|
||||||
it('should call setUserConfigViewData and axios.post with correct params', async () => {
|
|
||||||
const mockAxiosPost = vi.spyOn(axios, 'post').mockResolvedValue({
|
|
||||||
data: [{ id: 1 }],
|
|
||||||
});
|
|
||||||
|
|
||||||
vm.localColumns = [
|
|
||||||
{ name: 'columnMockName', visible: true },
|
|
||||||
{ name: 'columnMockId', visible: false },
|
|
||||||
];
|
|
||||||
|
|
||||||
await vm.saveConfig();
|
|
||||||
|
|
||||||
expect(mockAxiosPost).toHaveBeenCalledWith('UserConfigViews/crud', {
|
|
||||||
creates: [
|
|
||||||
{
|
|
||||||
userFk: vm.user.id,
|
|
||||||
tableCode: vm.tableCode,
|
|
||||||
tableConfig: vm.tableCode,
|
|
||||||
configuration: {
|
|
||||||
columnMockName: true,
|
|
||||||
columnMockId: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,12 +0,0 @@
|
||||||
export default function (initialFooter, data) {
|
|
||||||
const footer = data.reduce(
|
|
||||||
(acc, row) => {
|
|
||||||
Object.entries(initialFooter).forEach(([key, initialValue]) => {
|
|
||||||
acc[key] += row?.[key] !== undefined ? row[key] : initialValue;
|
|
||||||
});
|
|
||||||
return acc;
|
|
||||||
},
|
|
||||||
{ ...initialFooter }
|
|
||||||
);
|
|
||||||
return footer;
|
|
||||||
}
|
|
|
@ -1,248 +0,0 @@
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
|
||||||
import CrudModel from 'components/CrudModel.vue';
|
|
||||||
import { vi, afterEach, beforeEach, beforeAll, describe, expect, it } from 'vitest';
|
|
||||||
|
|
||||||
describe('CrudModel', () => {
|
|
||||||
let wrapper;
|
|
||||||
let vm;
|
|
||||||
let data;
|
|
||||||
beforeAll(() => {
|
|
||||||
wrapper = createWrapper(CrudModel, {
|
|
||||||
global: {
|
|
||||||
stubs: [
|
|
||||||
'vnPaginate',
|
|
||||||
'useState',
|
|
||||||
'arrayData',
|
|
||||||
'useStateStore',
|
|
||||||
'vue-i18n',
|
|
||||||
],
|
|
||||||
mocks: {
|
|
||||||
validate: vi.fn(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
propsData: {
|
|
||||||
dataRequired: {
|
|
||||||
fk: 1,
|
|
||||||
},
|
|
||||||
dataKey: 'crudModelKey',
|
|
||||||
model: 'crudModel',
|
|
||||||
url: 'crudModelUrl',
|
|
||||||
saveFn: '',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
wrapper=wrapper.wrapper;
|
|
||||||
vm=wrapper.vm;
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
vm.fetch([]);
|
|
||||||
vm.watchChanges = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('insert()', () => {
|
|
||||||
it('should new element in list with index 0 if formData not has data', () => {
|
|
||||||
vm.insert();
|
|
||||||
|
|
||||||
expect(vm.formData.length).toEqual(1);
|
|
||||||
expect(vm.formData[0].fk).toEqual(1);
|
|
||||||
expect(vm.formData[0].$index).toEqual(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getChanges()', () => {
|
|
||||||
it('should return correct updates and creates', async () => {
|
|
||||||
vm.fetch([
|
|
||||||
{ id: 1, name: 'New name one' },
|
|
||||||
{ id: 2, name: 'New name two' },
|
|
||||||
{ id: 3, name: 'Bruce Wayne' },
|
|
||||||
]);
|
|
||||||
|
|
||||||
vm.originalData = [
|
|
||||||
{ id: 1, name: 'Tony Starks' },
|
|
||||||
{ id: 2, name: 'Jessica Jones' },
|
|
||||||
{ id: 3, name: 'Bruce Wayne' },
|
|
||||||
];
|
|
||||||
|
|
||||||
vm.insert();
|
|
||||||
const result = vm.getChanges();
|
|
||||||
|
|
||||||
const expected = {
|
|
||||||
creates: [
|
|
||||||
{
|
|
||||||
$index: 3,
|
|
||||||
fk: 1,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
updates: [
|
|
||||||
{
|
|
||||||
data: {
|
|
||||||
name: 'New name one',
|
|
||||||
},
|
|
||||||
where: {
|
|
||||||
id: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: {
|
|
||||||
name: 'New name two',
|
|
||||||
},
|
|
||||||
where: {
|
|
||||||
id: 2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(result).toEqual(expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getDifferences()', () => {
|
|
||||||
it('should return the differences between two objects', async () => {
|
|
||||||
const obj1 = {
|
|
||||||
a: 1,
|
|
||||||
b: 2,
|
|
||||||
c: 3,
|
|
||||||
};
|
|
||||||
const obj2 = {
|
|
||||||
a: null,
|
|
||||||
b: 4,
|
|
||||||
d: 5,
|
|
||||||
};
|
|
||||||
|
|
||||||
const result = vm.getDifferences(obj1, obj2);
|
|
||||||
|
|
||||||
expect(result).toEqual({
|
|
||||||
a: null,
|
|
||||||
b: 4,
|
|
||||||
d: 5,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('isEmpty()', () => {
|
|
||||||
let dummyObj;
|
|
||||||
let dummyArray;
|
|
||||||
let result;
|
|
||||||
it('should return true if object si null', async () => {
|
|
||||||
dummyObj = null;
|
|
||||||
result = vm.isEmpty(dummyObj);
|
|
||||||
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return true if object si undefined', async () => {
|
|
||||||
dummyObj = undefined;
|
|
||||||
result = vm.isEmpty(dummyObj);
|
|
||||||
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return true if object is empty', async () => {
|
|
||||||
dummyObj ={};
|
|
||||||
result = vm.isEmpty(dummyObj);
|
|
||||||
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false if object is not empty', async () => {
|
|
||||||
dummyObj = {a:1, b:2, c:3};
|
|
||||||
result = vm.isEmpty(dummyObj);
|
|
||||||
|
|
||||||
expect(result).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return true if array is empty', async () => {
|
|
||||||
dummyArray = [];
|
|
||||||
result = vm.isEmpty(dummyArray);
|
|
||||||
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false if array is not empty', async () => {
|
|
||||||
dummyArray = [1,2,3];
|
|
||||||
result = vm.isEmpty(dummyArray);
|
|
||||||
|
|
||||||
expect(result).toBe(false);
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('resetData()', () => {
|
|
||||||
it('should add $index to elements in data[] and sets originalData and formData with data', async () => {
|
|
||||||
data = [{
|
|
||||||
name: 'Tony',
|
|
||||||
lastName: 'Stark',
|
|
||||||
age: 42,
|
|
||||||
}];
|
|
||||||
|
|
||||||
vm.resetData(data);
|
|
||||||
|
|
||||||
expect(vm.originalData).toEqual(data);
|
|
||||||
expect(vm.originalData[0].$index).toEqual(0);
|
|
||||||
expect(vm.formData).toEqual(data);
|
|
||||||
expect(vm.formData[0].$index).toEqual(0);
|
|
||||||
expect(vm.watchChanges).not.toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should dont do nothing if data is null', async () => {
|
|
||||||
vm.resetData(null);
|
|
||||||
|
|
||||||
expect(vm.watchChanges).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set originalData and formatData with data and generate watchChanges', async () => {
|
|
||||||
data = {
|
|
||||||
name: 'Tony',
|
|
||||||
lastName: 'Stark',
|
|
||||||
age: 42,
|
|
||||||
};
|
|
||||||
|
|
||||||
vm.resetData(data);
|
|
||||||
|
|
||||||
expect(vm.originalData).toEqual(data);
|
|
||||||
expect(vm.formData).toEqual(data);
|
|
||||||
expect(vm.watchChanges).not.toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('saveChanges()', () => {
|
|
||||||
data = [{
|
|
||||||
name: 'Tony',
|
|
||||||
lastName: 'Stark',
|
|
||||||
age: 42,
|
|
||||||
}];
|
|
||||||
|
|
||||||
it('should call saveFn if exists', async () => {
|
|
||||||
await wrapper.setProps({ saveFn: vi.fn() });
|
|
||||||
|
|
||||||
vm.saveChanges(data);
|
|
||||||
|
|
||||||
expect(vm.saveFn).toHaveBeenCalledOnce();
|
|
||||||
expect(vm.isLoading).toBe(false);
|
|
||||||
expect(vm.hasChanges).toBe(false);
|
|
||||||
|
|
||||||
await wrapper.setProps({ saveFn: '' });
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should use default url if there's not saveFn", async () => {
|
|
||||||
const postMock =vi.spyOn(axios, 'post');
|
|
||||||
|
|
||||||
vm.formData = [{
|
|
||||||
name: 'Bruce',
|
|
||||||
lastName: 'Wayne',
|
|
||||||
age: 45,
|
|
||||||
}]
|
|
||||||
|
|
||||||
await vm.saveChanges(data);
|
|
||||||
|
|
||||||
expect(postMock).toHaveBeenCalledWith(vm.url + '/crud', data);
|
|
||||||
expect(vm.isLoading).toBe(false);
|
|
||||||
expect(vm.hasChanges).toBe(false);
|
|
||||||
expect(vm.originalData).toEqual(JSON.parse(JSON.stringify(vm.formData)));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,56 +0,0 @@
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
|
||||||
import EditForm from 'components/EditTableCellValueForm.vue';
|
|
||||||
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
|
||||||
|
|
||||||
const fieldA = 'fieldA';
|
|
||||||
const fieldB = 'fieldB';
|
|
||||||
|
|
||||||
describe('EditForm', () => {
|
|
||||||
let vm;
|
|
||||||
const mockRows = [
|
|
||||||
{ id: 1, itemFk: 101 },
|
|
||||||
{ id: 2, itemFk: 102 },
|
|
||||||
];
|
|
||||||
const mockFieldsOptions = [
|
|
||||||
{ label: 'Field A', field: fieldA, component: 'input', attrs: {} },
|
|
||||||
{ label: 'Field B', field: fieldB, component: 'date', attrs: {} },
|
|
||||||
];
|
|
||||||
const editUrl = '/api/edit';
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
vi.spyOn(axios, 'post').mockResolvedValue({ status: 200 });
|
|
||||||
vm = createWrapper(EditForm, {
|
|
||||||
props: {
|
|
||||||
rows: mockRows,
|
|
||||||
fieldsOptions: mockFieldsOptions,
|
|
||||||
editUrl,
|
|
||||||
},
|
|
||||||
}).vm;
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
|
||||||
it('should call axios.post with the correct parameters in the payload', async () => {
|
|
||||||
const selectedField = { field: fieldA, component: 'input', attrs: {} };
|
|
||||||
const newValue = 'Test Value';
|
|
||||||
|
|
||||||
vm.selectedField = selectedField;
|
|
||||||
vm.newValue = newValue;
|
|
||||||
|
|
||||||
await vm.onSubmit();
|
|
||||||
|
|
||||||
const payload = axios.post.mock.calls[0][1];
|
|
||||||
|
|
||||||
expect(axios.post).toHaveBeenCalledWith(editUrl, expect.any(Object));
|
|
||||||
expect(payload.field).toEqual(fieldA);
|
|
||||||
expect(payload.newValue).toEqual(newValue);
|
|
||||||
|
|
||||||
expect(payload.lines).toEqual(expect.arrayContaining(mockRows));
|
|
||||||
|
|
||||||
expect(vm.isLoading).toEqual(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,82 +0,0 @@
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
|
||||||
import FilterItemForm from 'src/components/FilterItemForm.vue';
|
|
||||||
import { vi, beforeAll, describe, expect, it } from 'vitest';
|
|
||||||
|
|
||||||
describe('FilterItemForm', () => {
|
|
||||||
let vm;
|
|
||||||
let wrapper;
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
wrapper = createWrapper(FilterItemForm, {
|
|
||||||
props: {
|
|
||||||
url: 'Items/withName',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
vm = wrapper.vm;
|
|
||||||
wrapper = wrapper.wrapper;
|
|
||||||
|
|
||||||
vi.spyOn(axios, 'get').mockResolvedValue({
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: 999996,
|
|
||||||
name: 'bolas de madera',
|
|
||||||
size: 2,
|
|
||||||
inkFk: null,
|
|
||||||
producerFk: null,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should filter data and populate tableRows for table display', async () => {
|
|
||||||
vm.itemFilterParams.name = 'bolas de madera';
|
|
||||||
|
|
||||||
await vm.onSubmit();
|
|
||||||
|
|
||||||
const expectedFilter = {
|
|
||||||
include: [
|
|
||||||
{ relation: 'producer', scope: { fields: ['name'] } },
|
|
||||||
{ relation: 'ink', scope: { fields: ['name'] } },
|
|
||||||
],
|
|
||||||
where: {"name":{"like":"%bolas de madera%"}},
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(axios.get).toHaveBeenCalledWith('Items/withName', {
|
|
||||||
params: { filter: JSON.stringify(expectedFilter) },
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(vm.tableRows).toEqual([
|
|
||||||
{
|
|
||||||
id: 999996,
|
|
||||||
name: 'bolas de madera',
|
|
||||||
size: 2,
|
|
||||||
inkFk: null,
|
|
||||||
producerFk: null,
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle an empty itemFilterParams correctly', async () => {
|
|
||||||
vm.itemFilterParams.name = null;
|
|
||||||
vm.itemFilterParams = {};
|
|
||||||
|
|
||||||
await vm.onSubmit();
|
|
||||||
|
|
||||||
const expectedFilter = {
|
|
||||||
include: [
|
|
||||||
{ relation: 'producer', scope: { fields: ['name'] } },
|
|
||||||
{ relation: 'ink', scope: { fields: ['name'] } },
|
|
||||||
],
|
|
||||||
where: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(axios.get).toHaveBeenCalledWith('Items/withName', {
|
|
||||||
params: { filter: JSON.stringify(expectedFilter) },
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should emit "itemSelected" with the correct id and close the form', () => {
|
|
||||||
vm.selectItem({ id: 12345 });
|
|
||||||
expect(wrapper.emitted('itemSelected')[0]).toEqual([12345]);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,149 +0,0 @@
|
||||||
import { describe, expect, it, beforeAll, vi, afterAll } from 'vitest';
|
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
|
||||||
import FormModel from 'src/components/FormModel.vue';
|
|
||||||
|
|
||||||
describe('FormModel', () => {
|
|
||||||
const model = 'mockModel';
|
|
||||||
const url = 'mockUrl';
|
|
||||||
const formInitialData = { mockKey: 'mockVal' };
|
|
||||||
|
|
||||||
describe('modelValue', () => {
|
|
||||||
it('should use the provided model', () => {
|
|
||||||
const { vm } = mount({ propsData: { model } });
|
|
||||||
expect(vm.modelValue).toBe(model);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should use the route meta title when model is not provided', () => {
|
|
||||||
const { vm } = mount({});
|
|
||||||
expect(vm.modelValue).toBe('formModel_mockTitle');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('onMounted()', () => {
|
|
||||||
let mockGet;
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
mockGet = vi.spyOn(axios, 'get').mockResolvedValue({ data: {} });
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(() => {
|
|
||||||
mockGet.mockRestore();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not fetch when has formInitialData', () => {
|
|
||||||
mount({ propsData: { url, model, autoLoad: true, formInitialData } });
|
|
||||||
expect(mockGet).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should fetch when there is url and auto-load', () => {
|
|
||||||
mount({ propsData: { url, model, autoLoad: true } });
|
|
||||||
expect(mockGet).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not observe changes', () => {
|
|
||||||
const { vm } = mount({
|
|
||||||
propsData: { url, model, observeFormChanges: false, formInitialData },
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(vm.hasChanges).toBe(true);
|
|
||||||
vm.reset();
|
|
||||||
expect(vm.hasChanges).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should observe changes', async () => {
|
|
||||||
const { vm } = mount({
|
|
||||||
propsData: { url, model, formInitialData },
|
|
||||||
});
|
|
||||||
vm.state.set(model, formInitialData);
|
|
||||||
expect(vm.hasChanges).toBe(false);
|
|
||||||
|
|
||||||
vm.formData.mockKey = 'newVal';
|
|
||||||
await vm.$nextTick();
|
|
||||||
expect(vm.hasChanges).toBe(true);
|
|
||||||
vm.formData.mockKey = 'mockVal';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('trimData()', () => {
|
|
||||||
let vm;
|
|
||||||
beforeAll(() => {
|
|
||||||
vm = mount({}).vm;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should trim whitespace from string values', () => {
|
|
||||||
const data = { key1: ' value1 ', key2: ' value2 ' };
|
|
||||||
const trimmedData = vm.trimData(data);
|
|
||||||
expect(trimmedData).toEqual({ key1: 'value1', key2: 'value2' });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not modify non-string values', () => {
|
|
||||||
const data = { key1: 123, key2: true, key3: null, key4: undefined };
|
|
||||||
const trimmedData = vm.trimData(data);
|
|
||||||
expect(trimmedData).toEqual(data);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('save()', async () => {
|
|
||||||
it('should not call if there are not changes', async () => {
|
|
||||||
const { vm } = mount({ propsData: { url, model } });
|
|
||||||
|
|
||||||
await vm.save();
|
|
||||||
expect(vm.hasChanges).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call axios.patch with the right data', async () => {
|
|
||||||
const spy = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
|
||||||
const { vm } = mount({ propsData: { url, model, formInitialData } });
|
|
||||||
vm.formData.mockKey = 'newVal';
|
|
||||||
await vm.$nextTick();
|
|
||||||
await vm.save();
|
|
||||||
expect(spy).toHaveBeenCalled();
|
|
||||||
vm.formData.mockKey = 'mockVal';
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call axios.post with the right data', async () => {
|
|
||||||
const spy = vi.spyOn(axios, 'post').mockResolvedValue({ data: {} });
|
|
||||||
const { vm } = mount({
|
|
||||||
propsData: { url, model, formInitialData, urlCreate: 'mockUrlCreate' },
|
|
||||||
});
|
|
||||||
vm.formData.mockKey = 'newVal';
|
|
||||||
await vm.$nextTick();
|
|
||||||
await vm.save();
|
|
||||||
expect(spy).toHaveBeenCalled();
|
|
||||||
vm.formData.mockKey = 'mockVal';
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should use the saveFn', async () => {
|
|
||||||
const { vm } = mount({
|
|
||||||
propsData: { url, model, formInitialData, saveFn: () => {} },
|
|
||||||
});
|
|
||||||
const spyPatch = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
|
||||||
const spySaveFn = vi.spyOn(vm.$props, 'saveFn');
|
|
||||||
|
|
||||||
vm.formData.mockKey = 'newVal';
|
|
||||||
await vm.$nextTick();
|
|
||||||
await vm.save();
|
|
||||||
expect(spyPatch).not.toHaveBeenCalled();
|
|
||||||
expect(spySaveFn).toHaveBeenCalled();
|
|
||||||
vm.formData.mockKey = 'mockVal';
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should reload the data after save', async () => {
|
|
||||||
const { vm } = mount({
|
|
||||||
propsData: { url, model, formInitialData, reload: true },
|
|
||||||
});
|
|
||||||
vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
|
||||||
|
|
||||||
vm.formData.mockKey = 'newVal';
|
|
||||||
await vm.$nextTick();
|
|
||||||
await vm.save();
|
|
||||||
vm.formData.mockKey = 'mockVal';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function mount({ propsData = {} }) {
|
|
||||||
return createWrapper(FormModel, {
|
|
||||||
propsData,
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
|
||||||
import { useHasContent } from 'src/composables/useHasContent';
|
|
||||||
import { watch } from 'vue';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
const stateStore = useStateStore();
|
|
||||||
const hasContent = useHasContent('#advanced-menu');
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
isMainSection: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => $props.isMainSection,
|
|
||||||
(val) => {
|
|
||||||
if (stateStore) stateStore.rightAdvancedDrawer = val;
|
|
||||||
},
|
|
||||||
{ immediate: true },
|
|
||||||
);
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<Teleport to="#searchbar-after" v-if="stateStore.isHeaderMounted()">
|
|
||||||
<QBtn
|
|
||||||
v-if="hasContent || $slots['advanced-menu']"
|
|
||||||
flat
|
|
||||||
@click="stateStore.toggleRightAdvancedDrawer()"
|
|
||||||
round
|
|
||||||
icon="tune"
|
|
||||||
color="white"
|
|
||||||
>
|
|
||||||
<QTooltip bottom anchor="bottom right">
|
|
||||||
{{ t('globals.advancedMenu') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</Teleport>
|
|
||||||
<QDrawer
|
|
||||||
v-model="stateStore.rightAdvancedDrawer"
|
|
||||||
side="right"
|
|
||||||
:width="256"
|
|
||||||
:overlay="!isMainSection"
|
|
||||||
v-bind="$attrs"
|
|
||||||
>
|
|
||||||
<QScrollArea class="fit">
|
|
||||||
<div id="advanced-menu"></div>
|
|
||||||
<slot v-if="!hasContent" name="advanced-menu" />
|
|
||||||
</QScrollArea>
|
|
||||||
</QDrawer>
|
|
||||||
</template>
|
|
|
@ -1,23 +1,35 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, useSlots } from 'vue';
|
import { ref, onMounted, useSlots } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { useQuasar } from 'quasar';
|
|
||||||
import { useHasContent } from 'src/composables/useHasContent';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
const quasar = useQuasar();
|
|
||||||
const stateStore = useStateStore();
|
|
||||||
const slots = useSlots();
|
const slots = useSlots();
|
||||||
const hasContent = useHasContent('#right-panel');
|
const hasContent = ref(false);
|
||||||
|
const rightPanel = ref(null);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if ((!slots['right-panel'] && !hasContent.value) || quasar.platform.is.mobile)
|
rightPanel.value = document.querySelector('#right-panel');
|
||||||
stateStore.rightDrawer = false;
|
if (!rightPanel.value) return;
|
||||||
|
|
||||||
|
// Check if there's content to display
|
||||||
|
const observer = new MutationObserver(() => {
|
||||||
|
hasContent.value = rightPanel.value.childNodes.length;
|
||||||
|
});
|
||||||
|
|
||||||
|
observer.observe(rightPanel.value, {
|
||||||
|
subtree: true,
|
||||||
|
childList: true,
|
||||||
|
attributes: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!slots['right-panel'] && !hasContent.value) stateStore.rightDrawer = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const stateStore = useStateStore();
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<Teleport to="#actions-prepend" v-if="stateStore.isHeaderMounted()">
|
<Teleport to="#actions-append" v-if="stateStore.isHeaderMounted()">
|
||||||
<div class="row q-gutter-x-sm">
|
<div class="row q-gutter-x-sm">
|
||||||
<QBtn
|
<QBtn
|
||||||
v-if="hasContent || $slots['right-panel']"
|
v-if="hasContent || $slots['right-panel']"
|
||||||
|
@ -25,8 +37,7 @@ onMounted(() => {
|
||||||
@click="stateStore.toggleRightDrawer()"
|
@click="stateStore.toggleRightDrawer()"
|
||||||
round
|
round
|
||||||
dense
|
dense
|
||||||
icon="dock_to_left"
|
icon="menu"
|
||||||
data-cy="toggle-right-drawer"
|
|
||||||
>
|
>
|
||||||
<QTooltip bottom anchor="bottom right">
|
<QTooltip bottom anchor="bottom right">
|
||||||
{{ t('globals.collapseMenu') }}
|
{{ t('globals.collapseMenu') }}
|
||||||
|
@ -34,7 +45,7 @@ onMounted(() => {
|
||||||
</QBtn>
|
</QBtn>
|
||||||
</div>
|
</div>
|
||||||
</Teleport>
|
</Teleport>
|
||||||
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256">
|
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
|
||||||
<QScrollArea class="fit">
|
<QScrollArea class="fit">
|
||||||
<div id="right-panel"></div>
|
<div id="right-panel"></div>
|
||||||
<slot v-if="!hasContent" name="right-panel" />
|
<slot v-if="!hasContent" name="right-panel" />
|
||||||
|
|
|
@ -58,71 +58,79 @@ const getConfig = async (url, filter) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchViewConfigData = async () => {
|
const fetchViewConfigData = async () => {
|
||||||
const userConfigFilter = {
|
try {
|
||||||
where: { tableCode: $props.tableCode, userFk: user.value.id },
|
const userConfigFilter = {
|
||||||
};
|
where: { tableCode: $props.tableCode, userFk: user.value.id },
|
||||||
const userConfig = await getConfig('UserConfigViews', userConfigFilter);
|
};
|
||||||
|
const userConfig = await getConfig('UserConfigViews', userConfigFilter);
|
||||||
|
|
||||||
if (userConfig) {
|
if (userConfig) {
|
||||||
initialUserConfigViewData.value = userConfig;
|
initialUserConfigViewData.value = userConfig;
|
||||||
setUserConfigViewData(userConfig.configuration);
|
setUserConfigViewData(userConfig.configuration);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultConfigFilter = { where: { tableCode: $props.tableCode } };
|
const defaultConfigFilter = { where: { tableCode: $props.tableCode } };
|
||||||
const defaultConfig = await getConfig('DefaultViewConfigs', defaultConfigFilter);
|
const defaultConfig = await getConfig('DefaultViewConfigs', defaultConfigFilter);
|
||||||
|
|
||||||
if (defaultConfig) {
|
if (defaultConfig) {
|
||||||
// Si el backend devuelve una configuración por defecto la usamos
|
// Si el backend devuelve una configuración por defecto la usamos
|
||||||
setUserConfigViewData(defaultConfig.columns);
|
setUserConfigViewData(defaultConfig.columns);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// Si no hay configuración por defecto mostramos todas las columnas
|
// Si no hay configuración por defecto mostramos todas las columnas
|
||||||
const defaultColumns = {};
|
const defaultColumns = {};
|
||||||
$props.allColumns.forEach((col) => (defaultColumns[col] = true));
|
$props.allColumns.forEach((col) => (defaultColumns[col] = true));
|
||||||
setUserConfigViewData(defaultColumns);
|
setUserConfigViewData(defaultColumns);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching config view data', err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveConfig = async () => {
|
const saveConfig = async () => {
|
||||||
const params = {};
|
try {
|
||||||
const configuration = {};
|
const params = {};
|
||||||
|
const configuration = {};
|
||||||
|
|
||||||
formattedCols.value.forEach((col) => {
|
formattedCols.value.forEach((col) => {
|
||||||
const { name, active } = col;
|
const { name, active } = col;
|
||||||
configuration[name] = active;
|
configuration[name] = active;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Si existe una view config del usuario hacemos un update si no la creamos
|
// Si existe una view config del usuario hacemos un update si no la creamos
|
||||||
if (initialUserConfigViewData.value) {
|
if (initialUserConfigViewData.value) {
|
||||||
params.updates = [
|
params.updates = [
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
|
configuration: configuration,
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
id: initialUserConfigViewData.value.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
params.creates = [
|
||||||
|
{
|
||||||
|
userFk: user.value.id,
|
||||||
|
tableCode: $props.tableCode,
|
||||||
|
tableConfig: $props.tableCode,
|
||||||
configuration: configuration,
|
configuration: configuration,
|
||||||
},
|
},
|
||||||
where: {
|
];
|
||||||
id: initialUserConfigViewData.value.id,
|
}
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
params.creates = [
|
|
||||||
{
|
|
||||||
userFk: user.value.id,
|
|
||||||
tableCode: $props.tableCode,
|
|
||||||
tableConfig: $props.tableCode,
|
|
||||||
configuration: configuration,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await axios.post('UserConfigViews/crud', params);
|
const response = await axios.post('UserConfigViews/crud', params);
|
||||||
if (response.data && response.data[0]) {
|
if (response.data && response.data[0]) {
|
||||||
initialUserConfigViewData.value = response.data[0];
|
initialUserConfigViewData.value = response.data[0];
|
||||||
|
}
|
||||||
|
emitSavedConfig();
|
||||||
|
notify('globals.dataSaved', 'positive');
|
||||||
|
popupProxyRef.value.hide();
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error saving user view config', err);
|
||||||
}
|
}
|
||||||
emitSavedConfig();
|
|
||||||
notify('globals.dataSaved', 'positive');
|
|
||||||
popupProxyRef.value.hide();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const emitSavedConfig = () => {
|
const emitSavedConfig = () => {
|
||||||
|
|
|
@ -1,24 +1,20 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { nextTick, ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
import { QInput } from 'quasar';
|
import { QInput } from 'quasar';
|
||||||
|
|
||||||
const $props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
insertable: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'accountShortToStandard']);
|
const emit = defineEmits(['update:modelValue', 'accountShortToStandard']);
|
||||||
|
|
||||||
let internalValue = ref($props.modelValue);
|
let internalValue = ref(props.modelValue);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => $props.modelValue,
|
() => props.modelValue,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
internalValue.value = newVal;
|
internalValue.value = newVal;
|
||||||
}
|
}
|
||||||
|
@ -32,46 +28,8 @@ watch(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleKeydown = (e) => {
|
|
||||||
if (e.key === 'Backspace') return;
|
|
||||||
if (e.key === '.') {
|
|
||||||
accountShortToStandard();
|
|
||||||
// TODO: Fix this setTimeout, with nextTick doesn't work
|
|
||||||
setTimeout(() => {
|
|
||||||
setCursorPosition(0, e.target);
|
|
||||||
}, 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($props.insertable && e.key.match(/[0-9]/)) {
|
|
||||||
handleInsertMode(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
function setCursorPosition(pos, el = vnInputRef.value) {
|
|
||||||
el.focus();
|
|
||||||
el.setSelectionRange(pos, pos);
|
|
||||||
}
|
|
||||||
const vnInputRef = ref(false);
|
|
||||||
const handleInsertMode = (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
const input = e.target;
|
|
||||||
const cursorPos = input.selectionStart;
|
|
||||||
const { maxlength } = vnInputRef.value;
|
|
||||||
let currentValue = internalValue.value;
|
|
||||||
if (!currentValue) currentValue = e.key;
|
|
||||||
const newValue = e.key;
|
|
||||||
if (newValue && !isNaN(newValue) && cursorPos < maxlength) {
|
|
||||||
internalValue.value =
|
|
||||||
currentValue.substring(0, cursorPos) +
|
|
||||||
newValue +
|
|
||||||
currentValue.substring(cursorPos + 1);
|
|
||||||
}
|
|
||||||
nextTick(() => {
|
|
||||||
input.setSelectionRange(cursorPos + 1, cursorPos + 1);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
function accountShortToStandard() {
|
function accountShortToStandard() {
|
||||||
internalValue.value = internalValue.value?.replace(
|
internalValue.value = internalValue.value.replace(
|
||||||
'.',
|
'.',
|
||||||
'0'.repeat(11 - internalValue.value.length)
|
'0'.repeat(11 - internalValue.value.length)
|
||||||
);
|
);
|
||||||
|
@ -79,5 +37,5 @@ function accountShortToStandard() {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<QInput @keydown="handleKeydown" ref="vnInputRef" v-model="internalValue" />
|
<q-input v-model="internalValue" />
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -15,7 +15,7 @@ let root = ref(null);
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
matched.value = currentRoute.value.matched.filter(
|
matched.value = currentRoute.value.matched.filter(
|
||||||
(matched) => !!matched?.meta?.title || !!matched?.meta?.icon
|
(matched) => Object.keys(matched.meta).length
|
||||||
);
|
);
|
||||||
breadcrumbs.value.length = 0;
|
breadcrumbs.value.length = 0;
|
||||||
if (!matched.value[0]) return;
|
if (!matched.value[0]) return;
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import VnSelect from './VnSelect.vue';
|
|
||||||
|
|
||||||
defineProps({
|
|
||||||
selectProps: { type: Object, required: true },
|
|
||||||
promise: { type: Function, default: () => {} },
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<QBtnDropdown v-bind="$attrs" color="primary">
|
|
||||||
<VnSelect
|
|
||||||
v-bind="selectProps"
|
|
||||||
hide-selected
|
|
||||||
hide-dropdown-icon
|
|
||||||
focus-on-mount
|
|
||||||
@update:model-value="promise"
|
|
||||||
data-cy="vnBtnSelect_select"
|
|
||||||
/>
|
|
||||||
</QBtnDropdown>
|
|
||||||
</template>
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onBeforeMount, computed } from 'vue';
|
import { onBeforeMount, computed } from 'vue';
|
||||||
import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router';
|
import { useRoute, onBeforeRouteUpdate } from 'vue-router';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import useCardSize from 'src/composables/useCardSize';
|
import useCardSize from 'src/composables/useCardSize';
|
||||||
|
@ -8,6 +8,7 @@ import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
||||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||||
import LeftMenu from 'components/LeftMenu.vue';
|
import LeftMenu from 'components/LeftMenu.vue';
|
||||||
import RightMenu from 'components/common/RightMenu.vue';
|
import RightMenu from 'components/common/RightMenu.vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
dataKey: { type: String, required: true },
|
dataKey: { type: String, required: true },
|
||||||
baseUrl: { type: String, default: undefined },
|
baseUrl: { type: String, default: undefined },
|
||||||
|
@ -17,36 +18,23 @@ const props = defineProps({
|
||||||
filterPanel: { type: Object, default: undefined },
|
filterPanel: { type: Object, default: undefined },
|
||||||
searchDataKey: { type: String, default: undefined },
|
searchDataKey: { type: String, default: undefined },
|
||||||
searchbarProps: { type: Object, default: undefined },
|
searchbarProps: { type: Object, default: undefined },
|
||||||
redirectOnError: { type: Boolean, default: false },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
|
||||||
const url = computed(() => {
|
const url = computed(() => {
|
||||||
if (props.baseUrl) {
|
if (props.baseUrl) return `${props.baseUrl}/${route.params.id}`;
|
||||||
return `${props.baseUrl}/${route.params.id}`;
|
|
||||||
}
|
|
||||||
return props.customUrl;
|
return props.customUrl;
|
||||||
});
|
});
|
||||||
const searchRightDataKey = computed(() => {
|
|
||||||
if (!props.searchDataKey) return route.name;
|
|
||||||
return props.searchDataKey;
|
|
||||||
});
|
|
||||||
const arrayData = useArrayData(props.dataKey, {
|
const arrayData = useArrayData(props.dataKey, {
|
||||||
url: url.value,
|
url: url.value,
|
||||||
filter: props.filter,
|
filter: props.filter,
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
try {
|
if (!props.baseUrl) arrayData.store.filter.where = { id: route.params.id };
|
||||||
if (!props.baseUrl) arrayData.store.filter.where = { id: route.params.id };
|
await arrayData.fetch({ append: false, updateRouter: false });
|
||||||
await arrayData.fetch({ append: false, updateRouter: false });
|
|
||||||
} catch {
|
|
||||||
const { matched: matches } = router.currentRoute.value;
|
|
||||||
const { path } = matches.at(-1);
|
|
||||||
router.push({ path: path.replace(/:id.*/, '') });
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (props.baseUrl) {
|
if (props.baseUrl) {
|
||||||
|
@ -74,16 +62,17 @@ if (props.baseUrl) {
|
||||||
<slot name="searchbar" v-if="props.searchDataKey">
|
<slot name="searchbar" v-if="props.searchDataKey">
|
||||||
<VnSearchbar :data-key="props.searchDataKey" v-bind="props.searchbarProps" />
|
<VnSearchbar :data-key="props.searchDataKey" v-bind="props.searchbarProps" />
|
||||||
</slot>
|
</slot>
|
||||||
|
<slot v-else name="searchbar" />
|
||||||
<RightMenu>
|
<RightMenu>
|
||||||
<template #right-panel v-if="props.filterPanel">
|
<template #right-panel v-if="props.filterPanel">
|
||||||
<component :is="props.filterPanel" :data-key="searchRightDataKey" />
|
<component :is="props.filterPanel" :data-key="props.searchDataKey" />
|
||||||
</template>
|
</template>
|
||||||
</RightMenu>
|
</RightMenu>
|
||||||
<QPageContainer>
|
<QPageContainer>
|
||||||
<QPage>
|
<QPage>
|
||||||
<VnSubToolbar />
|
<VnSubToolbar />
|
||||||
<div :class="[useCardSize(), $attrs.class]">
|
<div :class="[useCardSize(), $attrs.class]">
|
||||||
<RouterView :key="route.path" />
|
<RouterView />
|
||||||
</div>
|
</div>
|
||||||
</QPage>
|
</QPage>
|
||||||
</QPageContainer>
|
</QPageContainer>
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { onBeforeMount, computed } from 'vue';
|
|
||||||
import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router';
|
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
|
||||||
import useCardSize from 'src/composables/useCardSize';
|
|
||||||
import LeftMenu from 'components/LeftMenu.vue';
|
|
||||||
import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
dataKey: { type: String, required: true },
|
|
||||||
baseUrl: { type: String, default: undefined },
|
|
||||||
customUrl: { type: String, default: undefined },
|
|
||||||
filter: { type: Object, default: () => {} },
|
|
||||||
userFilter: { type: Object, default: () => {} },
|
|
||||||
descriptor: { type: Object, required: true },
|
|
||||||
filterPanel: { type: Object, default: undefined },
|
|
||||||
searchDataKey: { type: String, default: undefined },
|
|
||||||
searchbarProps: { type: Object, default: undefined },
|
|
||||||
redirectOnError: { type: Boolean, default: false },
|
|
||||||
});
|
|
||||||
|
|
||||||
const stateStore = useStateStore();
|
|
||||||
const route = useRoute();
|
|
||||||
const router = useRouter();
|
|
||||||
const url = computed(() => {
|
|
||||||
if (props.baseUrl) {
|
|
||||||
return `${props.baseUrl}/${route.params.id}`;
|
|
||||||
}
|
|
||||||
return props.customUrl;
|
|
||||||
});
|
|
||||||
|
|
||||||
const arrayData = useArrayData(props.dataKey, {
|
|
||||||
url: url.value,
|
|
||||||
filter: props.filter,
|
|
||||||
userFilter: props.userFilter,
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
|
||||||
try {
|
|
||||||
if (!props.baseUrl) arrayData.store.filter.where = { id: route.params.id };
|
|
||||||
await arrayData.fetch({ append: false, updateRouter: false });
|
|
||||||
} catch {
|
|
||||||
const { matched: matches } = router.currentRoute.value;
|
|
||||||
const { path } = matches.at(-1);
|
|
||||||
router.push({ path: path.replace(/:id.*/, '') });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (props.baseUrl) {
|
|
||||||
onBeforeRouteUpdate(async (to, from) => {
|
|
||||||
if (to.params.id !== from.params.id) {
|
|
||||||
arrayData.store.url = `${props.baseUrl}/${to.params.id}`;
|
|
||||||
await arrayData.fetch({ append: false, updateRouter: false });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<Teleport to="#left-panel" v-if="stateStore.isHeaderMounted()">
|
|
||||||
<component :is="descriptor" />
|
|
||||||
<QSeparator />
|
|
||||||
<LeftMenu source="card" />
|
|
||||||
</Teleport>
|
|
||||||
<VnSubToolbar />
|
|
||||||
<div :class="[useCardSize(), $attrs.class]">
|
|
||||||
<RouterView :key="route.path" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
|
@ -1,136 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import VnRow from '../ui/VnRow.vue';
|
|
||||||
import FetchData from '../FetchData.vue';
|
|
||||||
import useNotify from 'src/composables/useNotify';
|
|
||||||
import VnInputPassword from 'src/components/common/VnInputPassword.vue';
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
submitFn: { type: Function, default: () => {} },
|
|
||||||
askOldPass: { type: Boolean, default: false },
|
|
||||||
});
|
|
||||||
const emit = defineEmits(['onSubmit']);
|
|
||||||
const { t } = useI18n();
|
|
||||||
const { notify } = useNotify();
|
|
||||||
|
|
||||||
const form = ref();
|
|
||||||
const changePassDialog = ref();
|
|
||||||
const passwords = ref({ newPassword: null, repeatPassword: null });
|
|
||||||
const requirements = ref([]);
|
|
||||||
const isLoading = ref(false);
|
|
||||||
|
|
||||||
const validate = async () => {
|
|
||||||
const { newPassword, repeatPassword, oldPassword } = passwords.value;
|
|
||||||
|
|
||||||
if (!newPassword) {
|
|
||||||
notify(t('You must enter a new password'), 'negative');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (newPassword !== repeatPassword) {
|
|
||||||
notify(t("Passwords don't match"), 'negative');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
isLoading.value = true;
|
|
||||||
await props.submitFn(newPassword, oldPassword);
|
|
||||||
emit('onSubmit');
|
|
||||||
} catch (e) {
|
|
||||||
notify('errors.writeRequest', 'negative');
|
|
||||||
} finally {
|
|
||||||
changePassDialog.value.hide();
|
|
||||||
isLoading.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
defineExpose({ show: () => changePassDialog.value.show() });
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<FetchData
|
|
||||||
url="UserPasswords/findOne"
|
|
||||||
auto-load
|
|
||||||
@on-fetch="(data) => (requirements = data)"
|
|
||||||
/>
|
|
||||||
<QDialog ref="changePassDialog">
|
|
||||||
<QCard style="width: 350px">
|
|
||||||
<QCardSection>
|
|
||||||
<slot name="header">
|
|
||||||
<VnRow class="items-center" style="flex-direction: row">
|
|
||||||
<span class="text-h6" v-text="t('globals.changePass')" />
|
|
||||||
<QIcon
|
|
||||||
class="cursor-pointer"
|
|
||||||
name="close"
|
|
||||||
size="xs"
|
|
||||||
style="flex: 0"
|
|
||||||
v-close-popup
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
</slot>
|
|
||||||
</QCardSection>
|
|
||||||
<QForm ref="form">
|
|
||||||
<QCardSection>
|
|
||||||
<VnInputPassword
|
|
||||||
v-if="props.askOldPass"
|
|
||||||
:label="t('Old password')"
|
|
||||||
v-model="passwords.oldPassword"
|
|
||||||
:required="true"
|
|
||||||
:toggle-visibility="true"
|
|
||||||
autofocus
|
|
||||||
/>
|
|
||||||
<VnInputPassword
|
|
||||||
:label="t('New password')"
|
|
||||||
v-model="passwords.newPassword"
|
|
||||||
:required="true"
|
|
||||||
:toggle-visibility="true"
|
|
||||||
:info="
|
|
||||||
t('passwordRequirements', {
|
|
||||||
length: requirements.length,
|
|
||||||
nAlpha: requirements.nAlpha,
|
|
||||||
nUpper: requirements.nUpper,
|
|
||||||
nDigits: requirements.nDigits,
|
|
||||||
nPunct: requirements.nPunct,
|
|
||||||
})
|
|
||||||
"
|
|
||||||
autofocus
|
|
||||||
/>
|
|
||||||
|
|
||||||
<VnInputPassword
|
|
||||||
:label="t('Repeat password')"
|
|
||||||
v-model="passwords.repeatPassword"
|
|
||||||
:toggle-visibility="true"
|
|
||||||
/>
|
|
||||||
</QCardSection>
|
|
||||||
</QForm>
|
|
||||||
<QCardActions>
|
|
||||||
<slot name="actions">
|
|
||||||
<QBtn
|
|
||||||
:disabled="isLoading"
|
|
||||||
:loading="isLoading"
|
|
||||||
:label="t('globals.cancel')"
|
|
||||||
class="q-ml-sm"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
type="reset"
|
|
||||||
v-close-popup
|
|
||||||
/>
|
|
||||||
<QBtn
|
|
||||||
:disabled="isLoading"
|
|
||||||
:loading="isLoading"
|
|
||||||
:label="t('globals.confirm')"
|
|
||||||
color="primary"
|
|
||||||
@click="validate"
|
|
||||||
/>
|
|
||||||
</slot>
|
|
||||||
</QCardActions>
|
|
||||||
</QCard>
|
|
||||||
</QDialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
New password: Nueva contraseña
|
|
||||||
Repeat password: Repetir contraseña
|
|
||||||
You must enter a new password: Debes introducir la nueva contraseña
|
|
||||||
Passwords don't match: Las contraseñas no coinciden
|
|
||||||
</i18n>
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from 'vue';
|
import { computed, defineModel } from 'vue';
|
||||||
|
|
||||||
const model = defineModel(undefined, { required: true });
|
const model = defineModel(undefined, { required: true });
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
|
@ -17,15 +17,17 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let mixed;
|
||||||
const componentArray = computed(() => {
|
const componentArray = computed(() => {
|
||||||
if (typeof $props.prop === 'object') return [$props.prop];
|
if (typeof $props.prop === 'object') return [$props.prop];
|
||||||
return $props.prop;
|
return $props.prop;
|
||||||
});
|
});
|
||||||
|
|
||||||
function mix(toComponent) {
|
function mix(toComponent) {
|
||||||
|
if (mixed) return mixed;
|
||||||
const { component, attrs, event } = toComponent;
|
const { component, attrs, event } = toComponent;
|
||||||
const customComponent = $props.components[component];
|
const customComponent = $props.components[component];
|
||||||
return {
|
mixed = {
|
||||||
component: customComponent?.component ?? component,
|
component: customComponent?.component ?? component,
|
||||||
attrs: {
|
attrs: {
|
||||||
...toValueAttrs(attrs),
|
...toValueAttrs(attrs),
|
||||||
|
@ -35,6 +37,7 @@ function mix(toComponent) {
|
||||||
},
|
},
|
||||||
event: { ...customComponent?.event, ...event },
|
event: { ...customComponent?.event, ...event },
|
||||||
};
|
};
|
||||||
|
return mixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toValueAttrs(attrs) {
|
function toValueAttrs(attrs) {
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
<script setup>
|
|
||||||
const model = defineModel({ type: [String, Number], required: true });
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<QDate v-model="model" :today-btn="true" :options="$attrs.options" />
|
|
||||||
</template>
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.q-date {
|
|
||||||
width: 245px;
|
|
||||||
min-width: unset;
|
|
||||||
|
|
||||||
:deep(.q-date__calendar) {
|
|
||||||
padding-bottom: 0;
|
|
||||||
}
|
|
||||||
:deep(.q-date__view) {
|
|
||||||
min-height: 245px;
|
|
||||||
padding: 8px;
|
|
||||||
}
|
|
||||||
:deep(.q-date__calendar-days-container) {
|
|
||||||
min-height: 160px;
|
|
||||||
height: unset;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.q-date__header) {
|
|
||||||
padding: 2px 2px 5px 12px;
|
|
||||||
height: 60px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,39 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { toDateFormat } from 'src/filters/date.js';
|
|
||||||
|
|
||||||
defineProps({ date: { type: [Date, String], required: true } });
|
|
||||||
|
|
||||||
function getBadgeAttrs(date) {
|
|
||||||
let today = Date.vnNew();
|
|
||||||
today.setHours(0, 0, 0, 0);
|
|
||||||
let timeTicket = new Date(date);
|
|
||||||
timeTicket.setHours(0, 0, 0, 0);
|
|
||||||
|
|
||||||
let timeDiff = today - timeTicket;
|
|
||||||
|
|
||||||
if (timeDiff == 0) return { color: 'warning', class: 'black-text-color' };
|
|
||||||
if (timeDiff < 0) return { color: 'success', class: 'black-text-color' };
|
|
||||||
return { color: 'transparent', class: 'normal-text-color' };
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatShippedDate(date) {
|
|
||||||
if (!date) return '-';
|
|
||||||
const dateSplit = date.split('T');
|
|
||||||
const [year, month, day] = dateSplit[0].split('-');
|
|
||||||
const newDate = new Date(year, month - 1, day);
|
|
||||||
return toDateFormat(newDate);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<QBadge v-bind="getBadgeAttrs(date)" class="q-pa-sm" style="font-size: 14px">
|
|
||||||
{{ formatShippedDate(date) }}
|
|
||||||
</QBadge>
|
|
||||||
</template>
|
|
||||||
<style lang="scss">
|
|
||||||
.black-text-color {
|
|
||||||
color: var(--vn-black-text-color);
|
|
||||||
}
|
|
||||||
.normal-text-color {
|
|
||||||
color: var(--vn-text-color);
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -31,10 +31,6 @@ const $props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
description: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const warehouses = ref();
|
const warehouses = ref();
|
||||||
|
@ -47,8 +43,7 @@ const dms = ref({});
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
defaultData();
|
defaultData();
|
||||||
if (!$props.formInitialData)
|
if (!$props.formInitialData)
|
||||||
dms.value.description =
|
dms.value.description = t($props.model + 'Description', dms.value);
|
||||||
$props.description ?? t($props.model + 'Description', dms.value);
|
|
||||||
});
|
});
|
||||||
function onFileChange(files) {
|
function onFileChange(files) {
|
||||||
dms.value.hasFileAttached = !!files;
|
dms.value.hasFileAttached = !!files;
|
||||||
|
@ -59,6 +54,7 @@ function mapperDms(data) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
const { files } = data;
|
const { files } = data;
|
||||||
if (files) formData.append(files?.name, files);
|
if (files) formData.append(files?.name, files);
|
||||||
|
delete data.files;
|
||||||
|
|
||||||
const dms = {
|
const dms = {
|
||||||
hasFile: !!data.hasFile,
|
hasFile: !!data.hasFile,
|
||||||
|
@ -82,7 +78,6 @@ async function save() {
|
||||||
const body = mapperDms(dms.value);
|
const body = mapperDms(dms.value);
|
||||||
const response = await axios.post(getUrl(), body[0], body[1]);
|
const response = await axios.post(getUrl(), body[0], body[1]);
|
||||||
emit('onDataSaved', body[1].params, response);
|
emit('onDataSaved', body[1].params, response);
|
||||||
delete dms.value.files;
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,14 +158,13 @@ function addDefaultData(data) {
|
||||||
/>
|
/>
|
||||||
<QFile
|
<QFile
|
||||||
ref="inputFileRef"
|
ref="inputFileRef"
|
||||||
:label="t('globals.file')"
|
:label="t('entry.buys.file')"
|
||||||
v-model="dms.files"
|
v-model="dms.files"
|
||||||
:multiple="false"
|
:multiple="false"
|
||||||
:accept="allowedContentTypes"
|
:accept="allowedContentTypes"
|
||||||
@update:model-value="onFileChange(dms.files)"
|
@update:model-value="onFileChange(dms.files)"
|
||||||
class="required"
|
class="required"
|
||||||
:display-value="dms.file"
|
:display-value="dms.file"
|
||||||
data-cy="VnDms_inputFile"
|
|
||||||
>
|
>
|
||||||
<template #append>
|
<template #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
|
|
|
@ -5,14 +5,12 @@ import { useRoute } from 'vue-router';
|
||||||
import { useQuasar, QCheckbox, QBtn, QInput } from 'quasar';
|
import { useQuasar, QCheckbox, QBtn, QInput } from 'quasar';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
import VnUserLink from '../ui/VnUserLink.vue';
|
|
||||||
import { downloadFile } from 'src/composables/downloadFile';
|
|
||||||
import VnImg from 'components/ui/VnImg.vue';
|
|
||||||
import VnPaginate from 'components/ui/VnPaginate.vue';
|
import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||||
import VnDms from 'src/components/common/VnDms.vue';
|
import VnDms from 'src/components/common/VnDms.vue';
|
||||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||||
import { useSession } from 'src/composables/useSession';
|
import VnUserLink from '../ui/VnUserLink.vue';
|
||||||
|
import { downloadFile } from 'src/composables/downloadFile';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
|
@ -20,7 +18,6 @@ const { t } = useI18n();
|
||||||
const rows = ref();
|
const rows = ref();
|
||||||
const dmsRef = ref();
|
const dmsRef = ref();
|
||||||
const formDialog = ref({});
|
const formDialog = ref({});
|
||||||
const token = useSession().getTokenMultimedia();
|
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
model: {
|
model: {
|
||||||
|
@ -92,23 +89,6 @@ const dmsFilter = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
|
||||||
label: '',
|
|
||||||
name: 'file',
|
|
||||||
align: 'left',
|
|
||||||
component: VnImg,
|
|
||||||
props: (prop) => {
|
|
||||||
return {
|
|
||||||
storage: 'dms',
|
|
||||||
collection: null,
|
|
||||||
resolution: null,
|
|
||||||
id: Number(prop.row.file.split('.')[0]),
|
|
||||||
token: token,
|
|
||||||
class: 'rounded',
|
|
||||||
ratio: 1,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
align: 'left',
|
align: 'left',
|
||||||
field: 'id',
|
field: 'id',
|
||||||
|
@ -155,13 +135,19 @@ const columns = computed(() => [
|
||||||
field: 'hasFile',
|
field: 'hasFile',
|
||||||
label: t('globals.original'),
|
label: t('globals.original'),
|
||||||
name: 'hasFile',
|
name: 'hasFile',
|
||||||
toolTip: t('The documentation is available in paper form'),
|
|
||||||
component: QCheckbox,
|
component: QCheckbox,
|
||||||
props: (prop) => ({
|
props: (prop) => ({
|
||||||
disable: true,
|
disable: true,
|
||||||
'model-value': Boolean(prop.value),
|
'model-value': Boolean(prop.value),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
align: 'left',
|
||||||
|
field: 'file',
|
||||||
|
label: t('globals.file'),
|
||||||
|
name: 'file',
|
||||||
|
component: 'span',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
align: 'left',
|
align: 'left',
|
||||||
field: 'worker',
|
field: 'worker',
|
||||||
|
@ -202,7 +188,7 @@ const columns = computed(() => [
|
||||||
prop.row.id,
|
prop.row.id,
|
||||||
$props.downloadModel,
|
$props.downloadModel,
|
||||||
undefined,
|
undefined,
|
||||||
prop.row.download,
|
prop.row.download
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -297,14 +283,13 @@ defineExpose({
|
||||||
ref="dmsRef"
|
ref="dmsRef"
|
||||||
:data-key="$props.model"
|
:data-key="$props.model"
|
||||||
:url="$props.model"
|
:url="$props.model"
|
||||||
:user-filter="dmsFilter"
|
:filter="dmsFilter"
|
||||||
:order="['dmsFk DESC']"
|
:order="['dmsFk DESC']"
|
||||||
auto-load
|
:auto-load="true"
|
||||||
@on-fetch="setData"
|
@on-fetch="setData"
|
||||||
>
|
>
|
||||||
<template #body>
|
<template #body>
|
||||||
<QTable
|
<QTable
|
||||||
v-if="rows"
|
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:rows="rows"
|
:rows="rows"
|
||||||
class="full-width q-mt-md"
|
class="full-width q-mt-md"
|
||||||
|
@ -312,14 +297,6 @@ defineExpose({
|
||||||
row-key="clientFk"
|
row-key="clientFk"
|
||||||
:grid="$q.screen.lt.sm"
|
:grid="$q.screen.lt.sm"
|
||||||
>
|
>
|
||||||
<template #header="props">
|
|
||||||
<QTr :props="props" class="bg">
|
|
||||||
<QTh v-for="col in props.cols" :key="col.name" :props="props">
|
|
||||||
<QTooltip v-if="col.toolTip">{{ col.toolTip }}</QTooltip
|
|
||||||
>{{ col.label }}
|
|
||||||
</QTh>
|
|
||||||
</QTr>
|
|
||||||
</template>
|
|
||||||
<template #body-cell="props">
|
<template #body-cell="props">
|
||||||
<QTd :props="props">
|
<QTd :props="props">
|
||||||
<QTr :props="props">
|
<QTr :props="props">
|
||||||
|
@ -374,7 +351,7 @@ defineExpose({
|
||||||
v-if="
|
v-if="
|
||||||
shouldRenderButton(
|
shouldRenderButton(
|
||||||
button.name,
|
button.name,
|
||||||
props.row.isDocuware,
|
props.row.isDocuware
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
:is="button.component"
|
:is="button.component"
|
||||||
|
@ -401,14 +378,7 @@ defineExpose({
|
||||||
/>
|
/>
|
||||||
</QDialog>
|
</QDialog>
|
||||||
<QPageSticky position="bottom-right" :offset="[25, 25]">
|
<QPageSticky position="bottom-right" :offset="[25, 25]">
|
||||||
<QBtn
|
<QBtn fab color="primary" icon="add" @click="showFormDialog()" class="fill-icon">
|
||||||
fab
|
|
||||||
color="primary"
|
|
||||||
icon="add"
|
|
||||||
shortcut="+"
|
|
||||||
@click="showFormDialog()"
|
|
||||||
class="fill-icon"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ t('Upload file') }}
|
{{ t('Upload file') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
|
@ -416,6 +386,10 @@ defineExpose({
|
||||||
</QPageSticky>
|
</QPageSticky>
|
||||||
</template>
|
</template>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.q-gutter-y-ms {
|
||||||
|
display: grid;
|
||||||
|
row-gap: 20px;
|
||||||
|
}
|
||||||
.labelColor {
|
.labelColor {
|
||||||
color: var(--vn-label-color);
|
color: var(--vn-label-color);
|
||||||
}
|
}
|
||||||
|
@ -423,10 +397,8 @@ defineExpose({
|
||||||
<i18n>
|
<i18n>
|
||||||
en:
|
en:
|
||||||
contentTypesInfo: Allowed file types {allowedContentTypes}
|
contentTypesInfo: Allowed file types {allowedContentTypes}
|
||||||
The documentation is available in paper form: The documentation is available in paper form
|
|
||||||
es:
|
es:
|
||||||
contentTypesInfo: Tipos de archivo permitidos {allowedContentTypes}
|
contentTypesInfo: Tipos de archivo permitidos {allowedContentTypes}
|
||||||
Generate identifier for original file: Generar identificador para archivo original
|
Generate identifier for original file: Generar identificador para archivo original
|
||||||
Upload file: Subir fichero
|
Upload file: Subir fichero
|
||||||
the documentation is available in paper form: Se tiene la documentación en papel
|
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref, useAttrs, nextTick } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRequired } from 'src/composables/useRequired';
|
|
||||||
|
|
||||||
const $attrs = useAttrs();
|
|
||||||
const { isRequired, requiredFieldRule } = useRequired($attrs);
|
|
||||||
const { t } = useI18n();
|
|
||||||
const emit = defineEmits([
|
const emit = defineEmits([
|
||||||
'update:modelValue',
|
'update:modelValue',
|
||||||
'update:options',
|
'update:options',
|
||||||
|
@ -30,31 +26,16 @@ const $props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
emptyToNull: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
insertable: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
maxlength: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
uppercase: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const requiredFieldRule = (val) => !!val || t('globals.fieldRequired');
|
||||||
const vnInputRef = ref(null);
|
const vnInputRef = ref(null);
|
||||||
const value = computed({
|
const value = computed({
|
||||||
get() {
|
get() {
|
||||||
return $props.modelValue;
|
return $props.modelValue;
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
if ($props.emptyToNull && value === '') value = null;
|
|
||||||
emit('update:modelValue', value);
|
emit('update:modelValue', value);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -75,113 +56,50 @@ const focus = () => {
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
focus,
|
focus,
|
||||||
vnInputRef,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const mixinRules = [
|
const inputRules = [
|
||||||
requiredFieldRule,
|
|
||||||
...($attrs.rules ?? []),
|
|
||||||
(val) => {
|
(val) => {
|
||||||
const { maxlength } = vnInputRef.value;
|
const { min } = vnInputRef.value.$attrs;
|
||||||
if (maxlength && +val.length > maxlength)
|
|
||||||
return t(`maxLength`, { value: maxlength });
|
|
||||||
const { min, max } = vnInputRef.value.$attrs;
|
|
||||||
if (!min) return null;
|
|
||||||
if (min >= 0) if (Math.floor(val) < min) return t('inputMin', { value: min });
|
if (min >= 0) if (Math.floor(val) < min) return t('inputMin', { value: min });
|
||||||
if (!max) return null;
|
|
||||||
if (max > 0) {
|
|
||||||
if (Math.floor(val) > max) return t('inputMax', { value: max });
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const handleKeydown = (e) => {
|
|
||||||
if (e.key === 'Backspace') return;
|
|
||||||
|
|
||||||
if ($props.insertable && e.key.match(/[0-9]/)) {
|
|
||||||
handleInsertMode(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleInsertMode = (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
const input = e.target;
|
|
||||||
const cursorPos = input.selectionStart;
|
|
||||||
const { maxlength } = vnInputRef.value;
|
|
||||||
let currentValue = value.value;
|
|
||||||
if (!currentValue) currentValue = e.key;
|
|
||||||
const newValue = e.key;
|
|
||||||
if (newValue && !isNaN(newValue) && cursorPos < maxlength) {
|
|
||||||
value.value =
|
|
||||||
currentValue.substring(0, cursorPos) +
|
|
||||||
newValue +
|
|
||||||
currentValue.substring(cursorPos + 1);
|
|
||||||
}
|
|
||||||
nextTick(() => {
|
|
||||||
input.setSelectionRange(cursorPos + 1, cursorPos + 1);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleUppercase = () => {
|
|
||||||
value.value = value.value?.toUpperCase() || '';
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div @mouseover="hover = true" @mouseleave="hover = false">
|
<div
|
||||||
|
@mouseover="hover = true"
|
||||||
|
@mouseleave="hover = false"
|
||||||
|
:rules="$attrs.required ? [requiredFieldRule] : null"
|
||||||
|
>
|
||||||
<QInput
|
<QInput
|
||||||
ref="vnInputRef"
|
ref="vnInputRef"
|
||||||
v-model="value"
|
v-model="value"
|
||||||
v-bind="{ ...$attrs, ...styleAttrs }"
|
v-bind="{ ...$attrs, ...styleAttrs }"
|
||||||
:type="$attrs.type"
|
:type="$attrs.type"
|
||||||
:class="{ required: isRequired }"
|
:class="{ required: $attrs.required }"
|
||||||
@keyup.enter="emit('keyup.enter')"
|
@keyup.enter="emit('keyup.enter')"
|
||||||
@keydown="handleKeydown"
|
|
||||||
:clearable="false"
|
:clearable="false"
|
||||||
:rules="mixinRules"
|
:rules="inputRules"
|
||||||
:lazy-rules="true"
|
:lazy-rules="true"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_input'"
|
|
||||||
>
|
>
|
||||||
<template #prepend>
|
<template v-if="$slots.prepend" #prepend>
|
||||||
<slot name="prepend" />
|
<slot name="prepend" />
|
||||||
</template>
|
</template>
|
||||||
<template #append>
|
<template #append>
|
||||||
|
<slot name="append" v-if="$slots.append && !$attrs.disabled" />
|
||||||
<QIcon
|
<QIcon
|
||||||
name="close"
|
name="close"
|
||||||
size="xs"
|
size="xs"
|
||||||
:style="{
|
v-if="hover && value && !$attrs.disabled && $props.clearable"
|
||||||
visibility:
|
|
||||||
hover &&
|
|
||||||
value &&
|
|
||||||
!$attrs.disabled &&
|
|
||||||
!$attrs.readonly &&
|
|
||||||
$props.clearable
|
|
||||||
? 'visible'
|
|
||||||
: 'hidden',
|
|
||||||
}"
|
|
||||||
@click="
|
@click="
|
||||||
() => {
|
() => {
|
||||||
value = null;
|
value = null;
|
||||||
vnInputRef.focus();
|
|
||||||
emit('remove');
|
emit('remove');
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
></QIcon>
|
></QIcon>
|
||||||
|
|
||||||
<QIcon
|
|
||||||
name="match_case"
|
|
||||||
size="xs"
|
|
||||||
v-if="!$attrs.disabled && !($attrs.readonly) && $props.uppercase"
|
|
||||||
@click="handleUppercase"
|
|
||||||
class="uppercase-icon"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ t('Convert to uppercase') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
|
|
||||||
<slot name="append" v-if="$slots.append && !$attrs.disabled" />
|
|
||||||
<QIcon v-if="info" name="info">
|
<QIcon v-if="info" name="info">
|
||||||
<QTooltip max-width="350px">
|
<QTooltip max-width="350px">
|
||||||
{{ info }}
|
{{ info }}
|
||||||
|
@ -191,27 +109,9 @@ const handleUppercase = () => {
|
||||||
</QInput>
|
</QInput>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
|
||||||
.uppercase-icon {
|
|
||||||
transition: color 0.3s, transform 0.2s;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uppercase-icon:hover {
|
|
||||||
color: #ed9937;
|
|
||||||
transform: scale(1.2);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<i18n>
|
<i18n>
|
||||||
en:
|
en:
|
||||||
inputMin: Must be more than {value}
|
inputMin: Must be more than {value}
|
||||||
maxLength: The value exceeds {value} characters
|
|
||||||
inputMax: Must be less than {value}
|
|
||||||
|
|
||||||
es:
|
es:
|
||||||
inputMin: Debe ser mayor a {value}
|
inputMin: Debe ser mayor a {value}
|
||||||
maxLength: El valor excede los {value} carácteres
|
|
||||||
inputMax: Debe ser menor a {value}
|
|
||||||
Convert to uppercase: Convertir a mayúsculas
|
|
||||||
</i18n>
|
</i18n>
|
|
@ -1,32 +1,38 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, watch, computed, ref, useAttrs } from 'vue';
|
import { onMounted, watch, computed, ref } from 'vue';
|
||||||
import { date } from 'quasar';
|
import { date } from 'quasar';
|
||||||
import VnDate from './VnDate.vue';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRequired } from 'src/composables/useRequired';
|
|
||||||
|
|
||||||
const $attrs = useAttrs();
|
|
||||||
const { isRequired, requiredFieldRule } = useRequired($attrs);
|
|
||||||
const model = defineModel({ type: [String, Date] });
|
|
||||||
|
|
||||||
|
const model = defineModel({ type: String });
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
isOutlined: {
|
isOutlined: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
showEvent: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const vnInputDateRef = ref(null);
|
const { t } = useI18n();
|
||||||
|
const requiredFieldRule = (val) => !!val || t('globals.fieldRequired');
|
||||||
|
|
||||||
const dateFormat = 'DD/MM/YYYY';
|
const dateFormat = 'DD/MM/YYYY';
|
||||||
const isPopupOpen = ref();
|
const isPopupOpen = ref();
|
||||||
const hover = ref();
|
const hover = ref();
|
||||||
const mask = ref();
|
const mask = ref();
|
||||||
|
|
||||||
const mixinRules = [requiredFieldRule, ...($attrs.rules ?? [])];
|
onMounted(() => {
|
||||||
|
// fix quasar bug
|
||||||
|
mask.value = '##/##/####';
|
||||||
|
});
|
||||||
|
|
||||||
|
const styleAttrs = computed(() => {
|
||||||
|
return $props.isOutlined
|
||||||
|
? {
|
||||||
|
dense: true,
|
||||||
|
outlined: true,
|
||||||
|
rounded: true,
|
||||||
|
}
|
||||||
|
: {};
|
||||||
|
});
|
||||||
|
|
||||||
const formattedDate = computed({
|
const formattedDate = computed({
|
||||||
get() {
|
get() {
|
||||||
|
@ -38,12 +44,15 @@ const formattedDate = computed({
|
||||||
let newDate;
|
let newDate;
|
||||||
if (value) {
|
if (value) {
|
||||||
// parse input
|
// parse input
|
||||||
if (value.includes('/') && value.length >= 10) {
|
if (value.includes('/')) {
|
||||||
if (value.at(2) == '/') value = value.split('/').reverse().join('/');
|
if (value.length == 6) value = value + new Date().getFullYear();
|
||||||
value = date.formatDate(
|
if (value.length >= 10) {
|
||||||
new Date(value).toISOString(),
|
if (value.at(2) == '/') value = value.split('/').reverse().join('/');
|
||||||
'YYYY-MM-DDTHH:mm:ss.SSSZ'
|
value = date.formatDate(
|
||||||
);
|
new Date(value).toISOString(),
|
||||||
|
'YYYY-MM-DDTHH:mm:ss.SSSZ'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const [year, month, day] = value.split('-').map((e) => parseInt(e));
|
const [year, month, day] = value.split('-').map((e) => parseInt(e));
|
||||||
newDate = new Date(year, month - 1, day);
|
newDate = new Date(year, month - 1, day);
|
||||||
|
@ -66,47 +75,25 @@ const formattedDate = computed({
|
||||||
const popupDate = computed(() =>
|
const popupDate = computed(() =>
|
||||||
model.value ? date.formatDate(new Date(model.value), 'YYYY/MM/DD') : model.value
|
model.value ? date.formatDate(new Date(model.value), 'YYYY/MM/DD') : model.value
|
||||||
);
|
);
|
||||||
onMounted(() => {
|
|
||||||
// fix quasar bug
|
|
||||||
mask.value = '##/##/####';
|
|
||||||
});
|
|
||||||
watch(
|
watch(
|
||||||
() => model.value,
|
() => model.value,
|
||||||
(val) => (formattedDate.value = val),
|
(val) => (formattedDate.value = val),
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
const styleAttrs = computed(() => {
|
|
||||||
return $props.isOutlined
|
|
||||||
? {
|
|
||||||
dense: true,
|
|
||||||
outlined: true,
|
|
||||||
rounded: true,
|
|
||||||
}
|
|
||||||
: {};
|
|
||||||
});
|
|
||||||
|
|
||||||
const manageDate = (date) => {
|
|
||||||
formattedDate.value = date;
|
|
||||||
isPopupOpen.value = false;
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div @mouseover="hover = true" @mouseleave="hover = false">
|
<div @mouseover="hover = true" @mouseleave="hover = false">
|
||||||
<QInput
|
<QInput
|
||||||
ref="vnInputDateRef"
|
|
||||||
v-model="formattedDate"
|
v-model="formattedDate"
|
||||||
class="vn-input-date"
|
class="vn-input-date"
|
||||||
:mask="mask"
|
:mask="mask"
|
||||||
placeholder="dd/mm/aaaa"
|
placeholder="dd/mm/aaaa"
|
||||||
v-bind="{ ...$attrs, ...styleAttrs }"
|
v-bind="{ ...$attrs, ...styleAttrs }"
|
||||||
:class="{ required: isRequired }"
|
:class="{ required: $attrs.required }"
|
||||||
:rules="mixinRules"
|
:rules="$attrs.required ? [requiredFieldRule] : null"
|
||||||
:clearable="false"
|
:clearable="false"
|
||||||
@click="isPopupOpen = !isPopupOpen"
|
|
||||||
@keydown="isPopupOpen = false"
|
|
||||||
hide-bottom-space
|
|
||||||
>
|
>
|
||||||
<template #append>
|
<template #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
|
@ -119,14 +106,18 @@ const manageDate = (date) => {
|
||||||
!$attrs.disable
|
!$attrs.disable
|
||||||
"
|
"
|
||||||
@click="
|
@click="
|
||||||
vnInputDateRef.focus();
|
|
||||||
model = null;
|
model = null;
|
||||||
isPopupOpen = false;
|
isPopupOpen = false;
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
|
<QIcon
|
||||||
|
name="event"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="isPopupOpen = !isPopupOpen"
|
||||||
|
:title="t('Open date')"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<QMenu
|
<QMenu
|
||||||
v-if="$q.screen.gt.xs"
|
|
||||||
transition-show="scale"
|
transition-show="scale"
|
||||||
transition-hide="scale"
|
transition-hide="scale"
|
||||||
v-model="isPopupOpen"
|
v-model="isPopupOpen"
|
||||||
|
@ -135,14 +126,30 @@ const manageDate = (date) => {
|
||||||
:no-focus="true"
|
:no-focus="true"
|
||||||
:no-parent-event="true"
|
:no-parent-event="true"
|
||||||
>
|
>
|
||||||
<VnDate v-model="popupDate" @update:model-value="manageDate" />
|
<QDate
|
||||||
|
v-model="popupDate"
|
||||||
|
:landscape="true"
|
||||||
|
:today-btn="true"
|
||||||
|
@update:model-value="
|
||||||
|
(date) => {
|
||||||
|
formattedDate = date;
|
||||||
|
isPopupOpen = false;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/>
|
||||||
</QMenu>
|
</QMenu>
|
||||||
<QDialog v-else v-model="isPopupOpen">
|
|
||||||
<VnDate v-model="popupDate" @update:model-value="manageDate" />
|
|
||||||
</QDialog>
|
|
||||||
</QInput>
|
</QInput>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<style lang="scss">
|
||||||
|
.vn-input-date.q-field--standard.q-field--readonly .q-field__control:before {
|
||||||
|
border-bottom-style: solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vn-input-date.q-field--outlined.q-field--readonly .q-field__control:before {
|
||||||
|
border-style: solid;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<i18n>
|
<i18n>
|
||||||
es:
|
es:
|
||||||
Open date: Abrir fecha
|
Open date: Abrir fecha
|
||||||
|
|
|
@ -1,28 +1,8 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
|
||||||
defineProps({
|
|
||||||
step: { type: Number, default: 0.01 },
|
|
||||||
decimalPlaces: { type: Number, default: 2 },
|
|
||||||
positive: { type: Boolean, default: true },
|
|
||||||
});
|
|
||||||
|
|
||||||
const model = defineModel({ type: [Number, String] });
|
const model = defineModel({ type: [Number, String] });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnInput
|
<VnInput v-bind="$attrs" v-model.number="model" type="number" />
|
||||||
v-bind="$attrs"
|
|
||||||
v-model.number="model"
|
|
||||||
type="number"
|
|
||||||
:step="step"
|
|
||||||
@input="
|
|
||||||
(evt) => {
|
|
||||||
const val = evt.target.value;
|
|
||||||
if (positive && val < 0) return (model = 0);
|
|
||||||
const [, decimal] = val.split('.');
|
|
||||||
if (val && decimal?.length > decimalPlaces)
|
|
||||||
model = parseFloat(val).toFixed(decimalPlaces);
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
import { ref } from 'vue';
|
|
||||||
|
|
||||||
const model = defineModel({ type: [Number, String] });
|
|
||||||
const $props = defineProps({
|
|
||||||
toggleVisibility: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const showPassword = ref(false);
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<VnInput
|
|
||||||
v-bind="{ ...$attrs }"
|
|
||||||
v-model="model"
|
|
||||||
:type="
|
|
||||||
$props.toggleVisibility ? (showPassword ? 'text' : 'password') : $attrs.type
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<template #append v-if="toggleVisibility">
|
|
||||||
<QIcon
|
|
||||||
:name="showPassword ? 'visibility_off' : 'visibility'"
|
|
||||||
class="cursor-pointer"
|
|
||||||
@click="showPassword = !showPassword"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</VnInput>
|
|
||||||
</template>
|
|
|
@ -1,11 +1,8 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref, useAttrs } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
import { date } from 'quasar';
|
import { date } from 'quasar';
|
||||||
import VnTime from './VnTime.vue';
|
|
||||||
import { useRequired } from 'src/composables/useRequired';
|
|
||||||
|
|
||||||
const $attrs = useAttrs();
|
|
||||||
const { isRequired, requiredFieldRule } = useRequired($attrs);
|
|
||||||
const model = defineModel({ type: String });
|
const model = defineModel({ type: String });
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
timeOnly: {
|
timeOnly: {
|
||||||
|
@ -17,9 +14,10 @@ const props = defineProps({
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const vnInputTimeRef = ref(null);
|
const initialDate = ref(model.value);
|
||||||
const initialDate = ref(model.value ?? Date.vnNew());
|
const { t } = useI18n();
|
||||||
const mixinRules = [requiredFieldRule, ...($attrs.rules ?? [])];
|
const requiredFieldRule = (val) => !!val || t('globals.fieldRequired');
|
||||||
|
|
||||||
const dateFormat = 'HH:mm';
|
const dateFormat = 'HH:mm';
|
||||||
const isPopupOpen = ref();
|
const isPopupOpen = ref();
|
||||||
const hover = ref();
|
const hover = ref();
|
||||||
|
@ -69,19 +67,16 @@ function dateToTime(newDate) {
|
||||||
<template>
|
<template>
|
||||||
<div @mouseover="hover = true" @mouseleave="hover = false">
|
<div @mouseover="hover = true" @mouseleave="hover = false">
|
||||||
<QInput
|
<QInput
|
||||||
ref="vnInputTimeRef"
|
|
||||||
class="vn-input-time"
|
class="vn-input-time"
|
||||||
mask="##:##"
|
mask="##:##"
|
||||||
placeholder="--:--"
|
placeholder="--:--"
|
||||||
v-model="formattedTime"
|
v-model="formattedTime"
|
||||||
v-bind="{ ...$attrs, ...styleAttrs }"
|
v-bind="{ ...$attrs, ...styleAttrs }"
|
||||||
:class="{ required: isRequired }"
|
:class="{ required: $attrs.required }"
|
||||||
style="min-width: 100px"
|
style="min-width: 100px"
|
||||||
:rules="mixinRules"
|
:rules="$attrs.required ? [requiredFieldRule] : null"
|
||||||
@click="isPopupOpen = !isPopupOpen"
|
@click="isPopupOpen = false"
|
||||||
@keydown="isPopupOpen = false"
|
|
||||||
type="time"
|
type="time"
|
||||||
hide-bottom-space
|
|
||||||
>
|
>
|
||||||
<template #append>
|
<template #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
|
@ -94,14 +89,18 @@ function dateToTime(newDate) {
|
||||||
!$attrs.disable
|
!$attrs.disable
|
||||||
"
|
"
|
||||||
@click="
|
@click="
|
||||||
vnInputTimeRef.focus();
|
|
||||||
model = null;
|
model = null;
|
||||||
isPopupOpen = false;
|
isPopupOpen = false;
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
|
<QIcon
|
||||||
|
name="Schedule"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="isPopupOpen = !isPopupOpen"
|
||||||
|
:title="t('Open time')"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<QMenu
|
<QMenu
|
||||||
v-if="$q.screen.gt.xs"
|
|
||||||
transition-show="scale"
|
transition-show="scale"
|
||||||
transition-hide="scale"
|
transition-hide="scale"
|
||||||
v-model="isPopupOpen"
|
v-model="isPopupOpen"
|
||||||
|
@ -110,11 +109,8 @@ function dateToTime(newDate) {
|
||||||
:no-focus="true"
|
:no-focus="true"
|
||||||
:no-parent-event="true"
|
:no-parent-event="true"
|
||||||
>
|
>
|
||||||
<VnTime v-model="formattedTime" />
|
<QTime v-model="formattedTime" mask="HH:mm" landscape now-btn />
|
||||||
</QMenu>
|
</QMenu>
|
||||||
<QDialog v-else v-model="isPopupOpen">
|
|
||||||
<VnTime v-model="formattedTime" />
|
|
||||||
</QDialog>
|
|
||||||
</QInput>
|
</QInput>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -2,99 +2,32 @@
|
||||||
import CreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue';
|
import CreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue';
|
||||||
import VnSelectDialog from 'components/common/VnSelectDialog.vue';
|
import VnSelectDialog from 'components/common/VnSelectDialog.vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { ref, watch } from 'vue';
|
|
||||||
import { useAttrs } from 'vue';
|
|
||||||
import { useRequired } from 'src/composables/useRequired';
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const emit = defineEmits(['update:model-value', 'update:options']);
|
const value = defineModel({ type: [String, Number, Object] });
|
||||||
const $attrs = useAttrs();
|
|
||||||
const { isRequired, requiredFieldRule } = useRequired($attrs);
|
|
||||||
const props = defineProps({
|
|
||||||
location: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.location,
|
|
||||||
(newValue) => {
|
|
||||||
if (!modelValue.value) return;
|
|
||||||
modelValue.value = formatLocation(newValue) ?? null;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const mixinRules = [requiredFieldRule];
|
|
||||||
const locationProperties = [
|
|
||||||
'postcode',
|
|
||||||
(obj) =>
|
|
||||||
obj.city
|
|
||||||
? `${obj.city}${obj.province?.name ? `(${obj.province.name})` : ''}`
|
|
||||||
: null,
|
|
||||||
(obj) => obj.country?.name,
|
|
||||||
];
|
|
||||||
|
|
||||||
const formatLocation = (obj, properties = locationProperties) => {
|
|
||||||
const parts = properties.map((prop) => {
|
|
||||||
if (typeof prop === 'string') {
|
|
||||||
return obj[prop];
|
|
||||||
} else if (typeof prop === 'function') {
|
|
||||||
return prop(obj);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
|
|
||||||
const filteredParts = parts.filter(
|
|
||||||
(part) => part !== null && part !== undefined && part !== ''
|
|
||||||
);
|
|
||||||
|
|
||||||
return filteredParts.join(', ');
|
|
||||||
};
|
|
||||||
|
|
||||||
const modelValue = ref(props.location ? formatLocation(props.location) : null);
|
|
||||||
|
|
||||||
function showLabel(data) {
|
function showLabel(data) {
|
||||||
const dataProperties = [
|
return `${data.code} - ${data.town}(${data.province}), ${data.country}`;
|
||||||
'code',
|
|
||||||
(obj) => (obj.town ? `${obj.town}(${obj.province})` : null),
|
|
||||||
'country',
|
|
||||||
];
|
|
||||||
return formatLocation(data, dataProperties);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleModelValue = (data) => {
|
|
||||||
emit('update:model-value', data);
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VnSelectDialog
|
<VnSelectDialog
|
||||||
v-model="modelValue"
|
v-model="value"
|
||||||
|
option-value="code"
|
||||||
option-filter-value="search"
|
option-filter-value="search"
|
||||||
:option-label="
|
:option-label="(opt) => showLabel(opt)"
|
||||||
(opt) => (typeof modelValue === 'string' ? modelValue : showLabel(opt))
|
|
||||||
"
|
|
||||||
url="Postcodes/filter"
|
url="Postcodes/filter"
|
||||||
@update:model-value="handleModelValue"
|
|
||||||
:use-like="false"
|
:use-like="false"
|
||||||
:label="t('Location')"
|
:label="t('Location')"
|
||||||
:placeholder="t('search_by_postalcode')"
|
:placeholder="t('search_by_postalcode')"
|
||||||
:input-debounce="300"
|
:input-debounce="300"
|
||||||
:class="{ required: isRequired }"
|
:class="{ required: $attrs.required }"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
|
clearable
|
||||||
:emit-value="false"
|
:emit-value="false"
|
||||||
:tooltip="t('Create new location')"
|
|
||||||
:rules="mixinRules"
|
|
||||||
:lazy-rules="true"
|
|
||||||
>
|
>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CreateNewPostcode
|
<CreateNewPostcode @on-data-saved="(newValue) => (value = newValue)" />
|
||||||
@on-data-saved="
|
|
||||||
(newValue) => {
|
|
||||||
modelValue = newValue;
|
|
||||||
emit('update:model-value', newValue);
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
<template #option="{ itemProps, opt }">
|
<template #option="{ itemProps, opt }">
|
||||||
<QItem v-bind="itemProps">
|
<QItem v-bind="itemProps">
|
||||||
|
@ -117,9 +50,7 @@ const handleModelValue = (data) => {
|
||||||
<i18n>
|
<i18n>
|
||||||
en:
|
en:
|
||||||
search_by_postalcode: Search by postalcode, town, province or country
|
search_by_postalcode: Search by postalcode, town, province or country
|
||||||
Create new location: Create new location
|
|
||||||
es:
|
es:
|
||||||
Location: Ubicación
|
Location: Ubicación
|
||||||
Create new location: Crear nueva ubicación
|
|
||||||
search_by_postalcode: Buscar por código postal, ciudad o país
|
search_by_postalcode: Buscar por código postal, ciudad o país
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -14,8 +14,6 @@ import VnJsonValue from '../common/VnJsonValue.vue';
|
||||||
import FetchData from '../FetchData.vue';
|
import FetchData from '../FetchData.vue';
|
||||||
import VnSelect from './VnSelect.vue';
|
import VnSelect from './VnSelect.vue';
|
||||||
import VnUserLink from '../ui/VnUserLink.vue';
|
import VnUserLink from '../ui/VnUserLink.vue';
|
||||||
import VnPaginate from '../ui/VnPaginate.vue';
|
|
||||||
import RightMenu from './RightMenu.vue';
|
|
||||||
|
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const validationsStore = useValidator();
|
const validationsStore = useValidator();
|
||||||
|
@ -68,10 +66,9 @@ const filter = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
where: { and: [{ originFk: route.params.id }] },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const paginate = ref();
|
const workers = ref();
|
||||||
const actions = ref();
|
const actions = ref();
|
||||||
const changeInput = ref();
|
const changeInput = ref();
|
||||||
const searchInput = ref();
|
const searchInput = ref();
|
||||||
|
@ -131,7 +128,7 @@ const actionsIcon = {
|
||||||
};
|
};
|
||||||
const validDate = new RegExp(
|
const validDate = new RegExp(
|
||||||
/^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])/.source +
|
/^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])/.source +
|
||||||
/T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/.source,
|
/T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/.source
|
||||||
);
|
);
|
||||||
|
|
||||||
function castJsonValue(value) {
|
function castJsonValue(value) {
|
||||||
|
@ -193,7 +190,7 @@ function getLogTree(data) {
|
||||||
user: log.user,
|
user: log.user,
|
||||||
userFk: log.userFk,
|
userFk: log.userFk,
|
||||||
logs: [],
|
logs: [],
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Model
|
// Model
|
||||||
|
@ -211,7 +208,7 @@ function getLogTree(data) {
|
||||||
id: log.changedModelId,
|
id: log.changedModelId,
|
||||||
showValue: log.changedModelValue,
|
showValue: log.changedModelValue,
|
||||||
logs: [],
|
logs: [],
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
nLogs = 0;
|
nLogs = 0;
|
||||||
}
|
}
|
||||||
|
@ -238,8 +235,9 @@ async function openPointRecord(id, modelLog) {
|
||||||
const locale = validations[modelLog.model]?.locale || {};
|
const locale = validations[modelLog.model]?.locale || {};
|
||||||
pointRecord.value = parseProps(propNames, locale, data);
|
pointRecord.value = parseProps(propNames, locale, data);
|
||||||
}
|
}
|
||||||
async function setLogTree(data) {
|
async function setLogTree() {
|
||||||
if (!data) return;
|
filter.where = { and: [{ originFk: route.params.id }] };
|
||||||
|
const { data } = await getLogs(filter);
|
||||||
logTree.value = getLogTree(data);
|
logTree.value = getLogTree(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +266,15 @@ async function applyFilter() {
|
||||||
filter.where.and.push(selectedFilters.value);
|
filter.where.and.push(selectedFilters.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
paginate.value.fetch(filter);
|
const { data } = await getLogs(filter);
|
||||||
|
|
||||||
|
logTree.value = getLogTree(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getLogs(filter) {
|
||||||
|
return axios.get(props.url ?? `${props.model}Logs`, {
|
||||||
|
params: { filter: JSON.stringify(filter) },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDate(type) {
|
function setDate(type) {
|
||||||
|
@ -283,7 +289,7 @@ function setDate(type) {
|
||||||
to = date.adjustDate(
|
to = date.adjustDate(
|
||||||
to,
|
to,
|
||||||
{ hour: 21, minute: 59, second: 59, millisecond: 999 },
|
{ hour: 21, minute: 59, second: 59, millisecond: 999 },
|
||||||
true,
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -366,11 +372,13 @@ async function clearFilter() {
|
||||||
dateTo.value = undefined;
|
dateTo.value = undefined;
|
||||||
userRadio.value = undefined;
|
userRadio.value = undefined;
|
||||||
Object.keys(checkboxOptions.value).forEach(
|
Object.keys(checkboxOptions.value).forEach(
|
||||||
(opt) => (checkboxOptions.value[opt].selected = false),
|
(opt) => (checkboxOptions.value[opt].selected = false)
|
||||||
);
|
);
|
||||||
await applyFilter();
|
await applyFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setLogTree();
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
stateStore.rightDrawer = false;
|
stateStore.rightDrawer = false;
|
||||||
});
|
});
|
||||||
|
@ -379,10 +387,20 @@ watch(
|
||||||
() => router.currentRoute.value.params.id,
|
() => router.currentRoute.value.params.id,
|
||||||
() => {
|
() => {
|
||||||
applyFilter();
|
applyFilter();
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
<FetchData
|
||||||
|
:url="`${props.model}Logs/${route.params.id}/editors`"
|
||||||
|
:filter="{
|
||||||
|
fields: ['id', 'nickname', 'name', 'image'],
|
||||||
|
order: 'nickname',
|
||||||
|
limit: 30,
|
||||||
|
}"
|
||||||
|
@on-fetch="(data) => (workers = data)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
:url="`${props.model}Logs/${route.params.id}/models`"
|
:url="`${props.model}Logs/${route.params.id}/models`"
|
||||||
:filter="{ order: ['changedModel'] }"
|
:filter="{ order: ['changedModel'] }"
|
||||||
|
@ -392,7 +410,7 @@ watch(
|
||||||
const changedModel = item.changedModel;
|
const changedModel = item.changedModel;
|
||||||
return {
|
return {
|
||||||
locale: useCapitalize(
|
locale: useCapitalize(
|
||||||
validations[changedModel]?.locale?.name ?? changedModel,
|
validations[changedModel]?.locale?.name ?? changedModel
|
||||||
),
|
),
|
||||||
value: changedModel,
|
value: changedModel,
|
||||||
};
|
};
|
||||||
|
@ -400,422 +418,365 @@ watch(
|
||||||
"
|
"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<VnPaginate
|
<div
|
||||||
ref="paginate"
|
class="column items-center logs origin-log q-mt-md"
|
||||||
:data-key="`${model}Log`"
|
v-for="(originLog, originLogIndex) in logTree"
|
||||||
:url="`${model}Logs`"
|
:key="originLogIndex"
|
||||||
:filter="filter"
|
|
||||||
:skeleton="false"
|
|
||||||
auto-load
|
|
||||||
@on-fetch="setLogTree"
|
|
||||||
search-url="logs"
|
|
||||||
>
|
>
|
||||||
<template #body>
|
<QItem class="origin-info items-center q-my-md" v-if="logTree.length > 1">
|
||||||
<div
|
<h6 class="origin-id text-grey">
|
||||||
class="column items-center logs origin-log q-mt-md"
|
{{ useCapitalize(validations[props.model].locale.name) }}
|
||||||
v-for="(originLog, originLogIndex) in logTree"
|
#{{ originLog.originFk }}
|
||||||
:key="originLogIndex"
|
</h6>
|
||||||
>
|
<div class="line bg-grey"></div>
|
||||||
<QItem class="origin-info items-center q-my-md" v-if="logTree.length > 1">
|
</QItem>
|
||||||
<h6 class="origin-id text-grey">
|
<div
|
||||||
{{ useCapitalize(validations[props.model].locale.name) }}
|
class="user-log q-mb-sm"
|
||||||
#{{ originLog.originFk }}
|
v-for="(userLog, userIndex) in originLog.logs"
|
||||||
</h6>
|
:key="userIndex"
|
||||||
<div class="line bg-grey"></div>
|
>
|
||||||
</QItem>
|
<div class="timeline">
|
||||||
<div
|
<div class="user-avatar">
|
||||||
class="user-log q-mb-sm"
|
<VnUserLink :worker-id="userLog?.user?.id">
|
||||||
v-for="(userLog, userIndex) in originLog.logs"
|
<template #link>
|
||||||
:key="userIndex"
|
<VnAvatar
|
||||||
|
:class="{ 'cursor-pointer': userLog?.user?.id }"
|
||||||
|
:worker-id="userLog?.user?.id"
|
||||||
|
:title="userLog?.user?.nickname"
|
||||||
|
:show-letter="!userLog?.user"
|
||||||
|
size="lg"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</VnUserLink>
|
||||||
|
</div>
|
||||||
|
<div class="arrow bg-panel" v-if="byRecord"></div>
|
||||||
|
<div class="line"></div>
|
||||||
|
</div>
|
||||||
|
<QList class="user-changes" v-if="userLog">
|
||||||
|
<QItem
|
||||||
|
class="model-log column q-px-none q-py-xs"
|
||||||
|
v-for="(modelLog, modelLogIndex) in userLog.logs"
|
||||||
|
:key="modelLogIndex"
|
||||||
>
|
>
|
||||||
<div class="timeline">
|
<QItemSection>
|
||||||
<div class="user-avatar">
|
<QItemLabel class="model-info q-mb-xs" v-if="!byRecord">
|
||||||
<VnUserLink :worker-id="userLog?.user?.id">
|
<QChip
|
||||||
<template #link>
|
dense
|
||||||
<VnAvatar
|
size="md"
|
||||||
:class="{ 'cursor-pointer': userLog?.user?.id }"
|
class="model-name q-mr-xs text-white"
|
||||||
:worker-id="userLog?.user?.id"
|
v-if="
|
||||||
:title="userLog?.user?.nickname"
|
!(modelLog.changedModel && modelLog.changedModelId) &&
|
||||||
:show-letter="!userLog?.user"
|
modelLog.model
|
||||||
size="lg"
|
"
|
||||||
/>
|
:style="{
|
||||||
</template>
|
backgroundColor: useColor(modelLog.model),
|
||||||
</VnUserLink>
|
}"
|
||||||
</div>
|
:title="`${modelLog.model} #${modelLog.id}`"
|
||||||
<div class="arrow bg-panel" v-if="byRecord"></div>
|
>
|
||||||
<div class="line"></div>
|
{{ t(modelLog.modelI18n) }}
|
||||||
</div>
|
</QChip>
|
||||||
<QList class="user-changes" v-if="userLog">
|
|
||||||
<QItem
|
|
||||||
class="model-log column q-px-none q-py-xs"
|
|
||||||
v-for="(modelLog, modelLogIndex) in userLog.logs"
|
|
||||||
:key="modelLogIndex"
|
|
||||||
>
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel class="model-info q-mb-xs" v-if="!byRecord">
|
|
||||||
<QChip
|
|
||||||
dense
|
|
||||||
size="md"
|
|
||||||
class="model-name q-mr-xs text-white"
|
|
||||||
v-if="
|
|
||||||
!(
|
|
||||||
modelLog.changedModel &&
|
|
||||||
modelLog.changedModelId
|
|
||||||
) && modelLog.model
|
|
||||||
"
|
|
||||||
:style="{
|
|
||||||
backgroundColor: useColor(modelLog.model),
|
|
||||||
}"
|
|
||||||
:title="`${modelLog.model} #${modelLog.id}`"
|
|
||||||
>
|
|
||||||
{{ t(modelLog.modelI18n) }}
|
|
||||||
</QChip>
|
|
||||||
|
|
||||||
<span
|
<span
|
||||||
class="model-id q-mr-xs"
|
class="model-id q-mr-xs"
|
||||||
v-if="modelLog.summaryId"
|
v-if="modelLog.summaryId"
|
||||||
v-text="`#${modelLog.summaryId}`"
|
v-text="`#${modelLog.summaryId}`"
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
class="model-value"
|
class="model-value"
|
||||||
:title="modelLog.showValue"
|
:title="modelLog.showValue"
|
||||||
v-text="modelLog.showValue"
|
v-text="modelLog.showValue"
|
||||||
/>
|
/>
|
||||||
<QBtn
|
<QBtn
|
||||||
flat
|
flat
|
||||||
round
|
round
|
||||||
color="grey"
|
color="grey"
|
||||||
class="q-mr-xs q-ml-auto"
|
class="q-mr-xs q-ml-auto"
|
||||||
size="sm"
|
size="sm"
|
||||||
icon="filter_alt"
|
icon="filter_alt"
|
||||||
:title="t('recordChanges')"
|
:title="t('recordChanges')"
|
||||||
@click.stop="filterByRecord(modelLog)"
|
@click.stop="filterByRecord(modelLog)"
|
||||||
/>
|
/>
|
||||||
</QItemLabel>
|
</QItemLabel>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<QCard
|
<QCard
|
||||||
class="changes-log q-py-none q-mb-xs"
|
class="changes-log q-py-none q-mb-xs"
|
||||||
v-for="(log, logIndex) in modelLog.logs"
|
v-for="(log, logIndex) in modelLog.logs"
|
||||||
:key="logIndex"
|
:key="logIndex"
|
||||||
|
>
|
||||||
|
<QCardSection class="change-info q-pa-none">
|
||||||
|
<QItem
|
||||||
|
class="q-px-sm q-py-xs justify-between items-center"
|
||||||
>
|
>
|
||||||
<QCardSection class="change-info q-pa-none">
|
<div
|
||||||
<QItem
|
class="date text-grey text-caption q-mr-sm"
|
||||||
class="q-px-sm q-py-xs justify-between items-center"
|
:title="
|
||||||
>
|
date.formatDate(
|
||||||
<div
|
log.creationDate,
|
||||||
class="date text-grey text-caption q-mr-sm"
|
'DD/MM/YYYY hh:mm:ss'
|
||||||
:title="
|
) ?? `date:'dd/MM/yyyy HH:mm:ss'`
|
||||||
date.formatDate(
|
"
|
||||||
log.creationDate,
|
|
||||||
'DD/MM/YYYY hh:mm:ss',
|
|
||||||
) ?? `date:'dd/MM/yyyy HH:mm:ss'`
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ toRelativeDate(log.creationDate) }}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<QBtn
|
|
||||||
color="grey"
|
|
||||||
class="pit"
|
|
||||||
icon="preview"
|
|
||||||
flat
|
|
||||||
round
|
|
||||||
:title="t('pointRecord')"
|
|
||||||
padding="none"
|
|
||||||
v-if="log.action != 'insert'"
|
|
||||||
@click.stop="
|
|
||||||
openPointRecord(log.id, modelLog)
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<QPopupProxy>
|
|
||||||
<QCard v-if="pointRecord">
|
|
||||||
<div
|
|
||||||
class="header q-px-sm q-py-xs q-ma-none text-white text-bold bg-primary"
|
|
||||||
>
|
|
||||||
{{ modelLog.modelI18n }}
|
|
||||||
<span v-if="modelLog.id"
|
|
||||||
>#{{
|
|
||||||
modelLog.id
|
|
||||||
}}</span
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<QCardSection
|
|
||||||
class="change-detail q-pa-sm"
|
|
||||||
>
|
|
||||||
<QItem
|
|
||||||
v-for="(
|
|
||||||
value, index
|
|
||||||
) in pointRecord"
|
|
||||||
:key="index"
|
|
||||||
class="q-pa-none"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="json-field q-mr-xs text-grey"
|
|
||||||
:title="
|
|
||||||
value.name
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{
|
|
||||||
value.nameI18n
|
|
||||||
}}:
|
|
||||||
</span>
|
|
||||||
<VnJsonValue
|
|
||||||
:value="
|
|
||||||
value.val.val
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</QItem>
|
|
||||||
</QCardSection>
|
|
||||||
</QCard>
|
|
||||||
</QPopupProxy>
|
|
||||||
</QBtn>
|
|
||||||
<QIcon
|
|
||||||
class="action q-ml-xs"
|
|
||||||
:class="actionsClass[log.action]"
|
|
||||||
:name="actionsIcon[log.action]"
|
|
||||||
:title="
|
|
||||||
t(
|
|
||||||
`actions.${
|
|
||||||
actionsText[log.action]
|
|
||||||
}`,
|
|
||||||
)
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</QItem>
|
|
||||||
</QCardSection>
|
|
||||||
<QCardSection
|
|
||||||
class="change-detail q-px-sm q-py-xs"
|
|
||||||
:class="{ expanded: log.expand }"
|
|
||||||
v-if="log.props.length || log.description"
|
|
||||||
>
|
>
|
||||||
<QIcon
|
{{ toRelativeDate(log.creationDate) }}
|
||||||
class="cursor-pointer q-mr-md"
|
</div>
|
||||||
|
<div>
|
||||||
|
<QBtn
|
||||||
color="grey"
|
color="grey"
|
||||||
name="expand_more"
|
class="pit"
|
||||||
:title="t('globals.details')"
|
icon="preview"
|
||||||
size="sm"
|
flat
|
||||||
@click="log.expand = !log.expand"
|
round
|
||||||
/>
|
:title="t('pointRecord')"
|
||||||
<span v-if="log.props.length" class="attributes">
|
padding="none"
|
||||||
<span
|
v-if="log.action != 'insert'"
|
||||||
v-if="!log.expand"
|
@click.stop="
|
||||||
class="q-pa-none text-grey"
|
openPointRecord(log.id, modelLog)
|
||||||
>
|
"
|
||||||
<span
|
>
|
||||||
v-for="(prop, propIndex) in log.props"
|
<QPopupProxy>
|
||||||
:key="propIndex"
|
<QCard v-if="pointRecord">
|
||||||
class="basic-json"
|
<div
|
||||||
>
|
class="header q-px-sm q-py-xs q-ma-none text-white text-bold bg-primary"
|
||||||
<span
|
|
||||||
class="json-field"
|
|
||||||
:title="prop.name"
|
|
||||||
>
|
>
|
||||||
{{ prop.nameI18n }}:
|
{{ modelLog.modelI18n }}
|
||||||
</span>
|
<span v-if="modelLog.id"
|
||||||
<VnJsonValue :value="prop.val.val" />
|
>#{{ modelLog.id }}</span
|
||||||
<span
|
>
|
||||||
v-if="
|
</div>
|
||||||
propIndex <
|
<QCardSection
|
||||||
log.props.length - 1
|
class="change-detail q-pa-sm"
|
||||||
"
|
>
|
||||||
>,
|
<QItem
|
||||||
</span>
|
v-for="(
|
||||||
|
value, index
|
||||||
|
) in pointRecord"
|
||||||
|
:key="index"
|
||||||
|
class="q-pa-none"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="json-field q-mr-xs text-grey"
|
||||||
|
:title="value.name"
|
||||||
|
>
|
||||||
|
{{ value.nameI18n }}:
|
||||||
|
</span>
|
||||||
|
<VnJsonValue
|
||||||
|
:value="value.val.val"
|
||||||
|
/>
|
||||||
|
</QItem>
|
||||||
|
</QCardSection>
|
||||||
|
</QCard>
|
||||||
|
</QPopupProxy>
|
||||||
|
</QBtn>
|
||||||
|
<QIcon
|
||||||
|
class="action q-ml-xs"
|
||||||
|
:class="actionsClass[log.action]"
|
||||||
|
:name="actionsIcon[log.action]"
|
||||||
|
:title="
|
||||||
|
t(`actions.${actionsText[log.action]}`)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</QItem>
|
||||||
|
</QCardSection>
|
||||||
|
<QCardSection
|
||||||
|
class="change-detail q-px-sm q-py-xs"
|
||||||
|
:class="{ expanded: log.expand }"
|
||||||
|
v-if="log.props.length || log.description"
|
||||||
|
>
|
||||||
|
<QIcon
|
||||||
|
class="cursor-pointer q-mr-md"
|
||||||
|
color="grey"
|
||||||
|
name="expand_more"
|
||||||
|
:title="t('globals.details')"
|
||||||
|
size="sm"
|
||||||
|
@click="log.expand = !log.expand"
|
||||||
|
/>
|
||||||
|
<span v-if="log.props.length" class="attributes">
|
||||||
|
<span v-if="!log.expand" class="q-pa-none text-grey">
|
||||||
|
<span
|
||||||
|
v-for="(prop, propIndex) in log.props"
|
||||||
|
:key="propIndex"
|
||||||
|
class="basic-json"
|
||||||
|
>
|
||||||
|
<span class="json-field" :title="prop.name">
|
||||||
|
{{ prop.nameI18n }}:
|
||||||
|
</span>
|
||||||
|
<VnJsonValue :value="prop.val.val" />
|
||||||
|
<span v-if="propIndex < log.props.length - 1"
|
||||||
|
>,
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
v-if="log.expand"
|
||||||
|
class="expanded-json column q-pa-none"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="(prop, prop2Index) in log.props"
|
||||||
|
:key="prop2Index"
|
||||||
|
class="q-pa-none text-grey"
|
||||||
|
>
|
||||||
|
<span class="json-field" :title="prop.name">
|
||||||
|
{{ prop.nameI18n }}:
|
||||||
|
</span>
|
||||||
|
<VnJsonValue :value="prop.val.val" />
|
||||||
|
<span v-if="prop.val.id" class="id-value">
|
||||||
|
#{{ prop.val.id }}
|
||||||
|
</span>
|
||||||
|
<span v-if="log.action == 'update'">
|
||||||
|
←
|
||||||
|
<VnJsonValue :value="prop.old.val" />
|
||||||
|
<span v-if="prop.old.id" class="id-value">
|
||||||
|
#{{ prop.old.id }}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span
|
</div>
|
||||||
v-if="log.expand"
|
</span>
|
||||||
class="expanded-json column q-pa-none"
|
</span>
|
||||||
>
|
<span v-if="!log.props.length" class="description">
|
||||||
<div
|
{{ log.description }}
|
||||||
v-for="(
|
</span>
|
||||||
prop, prop2Index
|
</QCardSection>
|
||||||
) in log.props"
|
</QCard>
|
||||||
:key="prop2Index"
|
|
||||||
class="q-pa-none text-grey"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="json-field"
|
|
||||||
:title="prop.name"
|
|
||||||
>
|
|
||||||
{{ prop.nameI18n }}:
|
|
||||||
</span>
|
|
||||||
<VnJsonValue :value="prop.val.val" />
|
|
||||||
<span
|
|
||||||
v-if="prop.val.id"
|
|
||||||
class="id-value"
|
|
||||||
>
|
|
||||||
#{{ prop.val.id }}
|
|
||||||
</span>
|
|
||||||
<span v-if="log.action == 'update'">
|
|
||||||
←
|
|
||||||
<VnJsonValue
|
|
||||||
:value="prop.old.val"
|
|
||||||
/>
|
|
||||||
<span
|
|
||||||
v-if="prop.old.id"
|
|
||||||
class="id-value"
|
|
||||||
>
|
|
||||||
#{{ prop.old.id }}
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
v-if="!log.props.length"
|
|
||||||
class="description"
|
|
||||||
>
|
|
||||||
{{ log.description }}
|
|
||||||
</span>
|
|
||||||
</QCardSection>
|
|
||||||
</QCard>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</QList>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</VnPaginate>
|
|
||||||
<RightMenu>
|
|
||||||
<template #right-panel>
|
|
||||||
<QList dense>
|
|
||||||
<QSeparator />
|
|
||||||
<QItem class="q-mt-sm">
|
|
||||||
<QInput
|
|
||||||
:label="t('globals.search')"
|
|
||||||
v-model="searchInput"
|
|
||||||
class="full-width"
|
|
||||||
clearable
|
|
||||||
clear-icon="close"
|
|
||||||
@keyup.enter="() => selectFilter('search')"
|
|
||||||
@focusout="() => selectFilter('search')"
|
|
||||||
@clear="() => selectFilter('search')"
|
|
||||||
>
|
|
||||||
<template #append>
|
|
||||||
<QIcon name="info" class="cursor-pointer">
|
|
||||||
<QTooltip>{{ t('tooltips.search') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</template>
|
|
||||||
</QInput>
|
|
||||||
</QItem>
|
|
||||||
<QItem>
|
|
||||||
<VnSelect
|
|
||||||
class="full-width"
|
|
||||||
:label="t('globals.entity')"
|
|
||||||
v-model="selectedFilters.changedModel"
|
|
||||||
option-label="locale"
|
|
||||||
option-value="value"
|
|
||||||
:options="actions"
|
|
||||||
@update:model-value="selectFilter('action')"
|
|
||||||
hide-selected
|
|
||||||
/>
|
|
||||||
</QItem>
|
|
||||||
<QItem class="q-mt-sm">
|
|
||||||
<QOptionGroup
|
|
||||||
size="sm"
|
|
||||||
v-model="userRadio"
|
|
||||||
:options="userTypes"
|
|
||||||
color="primary"
|
|
||||||
@update:model-value="selectFilter('userRadio')"
|
|
||||||
right-label
|
|
||||||
>
|
|
||||||
<template #label="{ label }">
|
|
||||||
{{ t(`Users.${label}`) }}
|
|
||||||
</template>
|
|
||||||
</QOptionGroup>
|
|
||||||
</QItem>
|
|
||||||
<QItem class="q-mt-sm">
|
|
||||||
<QItemSection v-if="userRadio !== null">
|
|
||||||
<VnSelect
|
|
||||||
class="full-width"
|
|
||||||
:label="t('globals.user')"
|
|
||||||
v-model="userSelect"
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
:url="`${model}Logs/${route.params.id}/editors`"
|
|
||||||
:fields="['id', 'nickname', 'name', 'image']"
|
|
||||||
sort-by="nickname"
|
|
||||||
@update:model-value="selectFilter('userSelect')"
|
|
||||||
hide-selected
|
|
||||||
>
|
|
||||||
<template #option="{ opt, itemProps }">
|
|
||||||
<QItem
|
|
||||||
v-bind="itemProps"
|
|
||||||
class="q-pa-xs row items-center"
|
|
||||||
>
|
|
||||||
<QItemSection class="col-3 items-center">
|
|
||||||
<VnAvatar :worker-id="opt.id" />
|
|
||||||
</QItemSection>
|
|
||||||
<QItemSection class="col-9 justify-center">
|
|
||||||
<span>{{ opt.name }}</span>
|
|
||||||
<span class="text-grey">{{ opt.nickname }}</span>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem class="q-mt-sm">
|
|
||||||
<QInput
|
|
||||||
:label="t('globals.changes')"
|
|
||||||
v-model="changeInput"
|
|
||||||
class="full-width"
|
|
||||||
clearable
|
|
||||||
clear-icon="close"
|
|
||||||
@keyup.enter="selectFilter('change')"
|
|
||||||
@focusout="selectFilter('change')"
|
|
||||||
@clear="selectFilter('change')"
|
|
||||||
>
|
|
||||||
<template #append>
|
|
||||||
<QIcon name="info" class="cursor-pointer">
|
|
||||||
<QTooltip max-width="250px">{{
|
|
||||||
t('tooltips.changes')
|
|
||||||
}}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</template>
|
|
||||||
</QInput>
|
|
||||||
</QItem>
|
|
||||||
<QItem
|
|
||||||
:class="index == 'create' ? 'q-mt-md' : 'q-mt-xs'"
|
|
||||||
v-for="(checkboxOption, index) in checkboxOptions"
|
|
||||||
:key="index"
|
|
||||||
>
|
|
||||||
<QCheckbox
|
|
||||||
size="sm"
|
|
||||||
v-model="checkboxOption.selected"
|
|
||||||
:label="t(`actions.${checkboxOption.label}`)"
|
|
||||||
@update:model-value="selectFilter"
|
|
||||||
/>
|
|
||||||
</QItem>
|
|
||||||
<QItem class="q-mt-sm">
|
|
||||||
<QInput
|
|
||||||
class="full-width"
|
|
||||||
:label="t('globals.date')"
|
|
||||||
@click="dateFromDialog = true"
|
|
||||||
@focus="(evt) => evt.target.blur()"
|
|
||||||
@clear="selectFilter('date', 'to')"
|
|
||||||
v-model="dateFrom"
|
|
||||||
clearable
|
|
||||||
clear-icon="close"
|
|
||||||
/>
|
|
||||||
</QItem>
|
|
||||||
<QItem class="q-mt-sm">
|
|
||||||
<QInput
|
|
||||||
class="full-width"
|
|
||||||
:label="t('globals.to')"
|
|
||||||
@click="dateToDialog = true"
|
|
||||||
@focus="(evt) => evt.target.blur()"
|
|
||||||
@clear="selectFilter('date', 'from')"
|
|
||||||
v-model="dateTo"
|
|
||||||
clearable
|
|
||||||
clear-icon="close"
|
|
||||||
/>
|
|
||||||
</QItem>
|
|
||||||
</QList>
|
</QList>
|
||||||
</template>
|
</div>
|
||||||
</RightMenu>
|
</div>
|
||||||
|
<Teleport to="#right-panel" v-if="stateStore.isHeaderMounted()">
|
||||||
|
<QList dense>
|
||||||
|
<QSeparator />
|
||||||
|
<QItem class="q-mt-sm">
|
||||||
|
<QInput
|
||||||
|
:label="t('globals.search')"
|
||||||
|
v-model="searchInput"
|
||||||
|
class="full-width"
|
||||||
|
clearable
|
||||||
|
clear-icon="close"
|
||||||
|
@keyup.enter="() => selectFilter('search')"
|
||||||
|
@focusout="() => selectFilter('search')"
|
||||||
|
@clear="() => selectFilter('search')"
|
||||||
|
>
|
||||||
|
<template #append>
|
||||||
|
<QIcon name="info" class="cursor-pointer">
|
||||||
|
<QTooltip>{{ t('tooltips.search') }}</QTooltip>
|
||||||
|
</QIcon>
|
||||||
|
</template>
|
||||||
|
</QInput>
|
||||||
|
</QItem>
|
||||||
|
<QItem>
|
||||||
|
<VnSelect
|
||||||
|
class="full-width"
|
||||||
|
:label="t('globals.entity')"
|
||||||
|
v-model="selectedFilters.changedModel"
|
||||||
|
option-label="locale"
|
||||||
|
option-value="value"
|
||||||
|
:options="actions"
|
||||||
|
@update:model-value="selectFilter('action')"
|
||||||
|
hide-selected
|
||||||
|
/>
|
||||||
|
</QItem>
|
||||||
|
<QItem class="q-mt-sm">
|
||||||
|
<QOptionGroup
|
||||||
|
size="sm"
|
||||||
|
v-model="userRadio"
|
||||||
|
:options="userTypes"
|
||||||
|
color="primary"
|
||||||
|
@update:model-value="selectFilter('userRadio')"
|
||||||
|
right-label
|
||||||
|
>
|
||||||
|
<template #label="{ label }">
|
||||||
|
{{ t(`Users.${label}`) }}
|
||||||
|
</template>
|
||||||
|
</QOptionGroup>
|
||||||
|
</QItem>
|
||||||
|
<QItem class="q-mt-sm">
|
||||||
|
<QItemSection v-if="!workers">
|
||||||
|
<QSkeleton type="QInput" class="full-width" />
|
||||||
|
</QItemSection>
|
||||||
|
<QItemSection v-if="workers && userRadio !== null">
|
||||||
|
<VnSelect
|
||||||
|
class="full-width"
|
||||||
|
:label="t('globals.user')"
|
||||||
|
v-model="userSelect"
|
||||||
|
option-label="name"
|
||||||
|
option-value="id"
|
||||||
|
:options="workers"
|
||||||
|
@update:model-value="selectFilter('userSelect')"
|
||||||
|
hide-selected
|
||||||
|
>
|
||||||
|
<template #option="{ opt, itemProps }">
|
||||||
|
<QItem v-bind="itemProps" class="q-pa-xs row items-center">
|
||||||
|
<QItemSection class="col-3 items-center">
|
||||||
|
<VnAvatar :worker-id="opt.id" />
|
||||||
|
</QItemSection>
|
||||||
|
<QItemSection class="col-9 justify-center">
|
||||||
|
<span>{{ opt.name }}</span>
|
||||||
|
<span class="text-grey">{{ opt.nickname }}</span>
|
||||||
|
</QItemSection>
|
||||||
|
</QItem>
|
||||||
|
</template>
|
||||||
|
</VnSelect>
|
||||||
|
</QItemSection>
|
||||||
|
</QItem>
|
||||||
|
<QItem class="q-mt-sm">
|
||||||
|
<QInput
|
||||||
|
:label="t('globals.changes')"
|
||||||
|
v-model="changeInput"
|
||||||
|
class="full-width"
|
||||||
|
clearable
|
||||||
|
clear-icon="close"
|
||||||
|
@keyup.enter="selectFilter('change')"
|
||||||
|
@focusout="selectFilter('change')"
|
||||||
|
@clear="selectFilter('change')"
|
||||||
|
>
|
||||||
|
<template #append>
|
||||||
|
<QIcon name="info" class="cursor-pointer">
|
||||||
|
<QTooltip max-width="250px">{{
|
||||||
|
t('tooltips.changes')
|
||||||
|
}}</QTooltip>
|
||||||
|
</QIcon>
|
||||||
|
</template>
|
||||||
|
</QInput>
|
||||||
|
</QItem>
|
||||||
|
<QItem
|
||||||
|
:class="index == 'create' ? 'q-mt-md' : 'q-mt-xs'"
|
||||||
|
v-for="(checkboxOption, index) in checkboxOptions"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
|
<QCheckbox
|
||||||
|
size="sm"
|
||||||
|
v-model="checkboxOption.selected"
|
||||||
|
:label="t(`actions.${checkboxOption.label}`)"
|
||||||
|
@update:model-value="selectFilter"
|
||||||
|
/>
|
||||||
|
</QItem>
|
||||||
|
<QItem class="q-mt-sm">
|
||||||
|
<QInput
|
||||||
|
class="full-width"
|
||||||
|
:label="t('globals.date')"
|
||||||
|
@click="dateFromDialog = true"
|
||||||
|
@focus="(evt) => evt.target.blur()"
|
||||||
|
@clear="selectFilter('date', 'to')"
|
||||||
|
v-model="dateFrom"
|
||||||
|
clearable
|
||||||
|
clear-icon="close"
|
||||||
|
/>
|
||||||
|
</QItem>
|
||||||
|
<QItem class="q-mt-sm">
|
||||||
|
<QInput
|
||||||
|
class="full-width"
|
||||||
|
:label="t('to')"
|
||||||
|
@click="dateToDialog = true"
|
||||||
|
@focus="(evt) => evt.target.blur()"
|
||||||
|
@clear="selectFilter('date', 'from')"
|
||||||
|
v-model="dateTo"
|
||||||
|
clearable
|
||||||
|
clear-icon="close"
|
||||||
|
/>
|
||||||
|
</QItem>
|
||||||
|
</QList>
|
||||||
|
</Teleport>
|
||||||
<QDialog v-model="dateFromDialog">
|
<QDialog v-model="dateFromDialog">
|
||||||
<QDate
|
<QDate
|
||||||
:years-in-month-view="false"
|
:years-in-month-view="false"
|
||||||
|
@ -1059,9 +1020,9 @@ en:
|
||||||
Deletes: Deletes
|
Deletes: Deletes
|
||||||
Accesses: Accesses
|
Accesses: Accesses
|
||||||
Users:
|
Users:
|
||||||
User: User
|
User: Usuario
|
||||||
All: All
|
All: Todo
|
||||||
System: System
|
System: Sistema
|
||||||
properties:
|
properties:
|
||||||
id: ID
|
id: ID
|
||||||
claimFk: Claim ID
|
claimFk: Claim ID
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
|
||||||
import { onMounted, ref } from 'vue';
|
|
||||||
import { useQuasar } from 'quasar';
|
|
||||||
import LeftMenu from '../LeftMenu.vue';
|
|
||||||
|
|
||||||
const stateStore = useStateStore();
|
|
||||||
const $props = defineProps({
|
|
||||||
leftDrawer: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
onMounted(
|
|
||||||
() => (stateStore.leftDrawer = useQuasar().screen.gt.xs ? $props.leftDrawer : false)
|
|
||||||
);
|
|
||||||
|
|
||||||
const teleportRef = ref({});
|
|
||||||
const hasContent = ref();
|
|
||||||
let observer;
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
if (!teleportRef.value) return;
|
|
||||||
const checkContent = () => {
|
|
||||||
hasContent.value = teleportRef.value?.innerHTML?.trim() !== '';
|
|
||||||
};
|
|
||||||
|
|
||||||
observer = new MutationObserver(checkContent);
|
|
||||||
observer.observe(teleportRef.value, { childList: true, subtree: true });
|
|
||||||
|
|
||||||
checkContent();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<QDrawer v-model="stateStore.leftDrawer" show-if-above :width="256">
|
|
||||||
<QScrollArea class="fit text-grey-8">
|
|
||||||
<div id="left-panel" ref="teleportRef"></div>
|
|
||||||
<LeftMenu v-if="!hasContent" />
|
|
||||||
</QScrollArea>
|
|
||||||
</QDrawer>
|
|
||||||
<QPageContainer>
|
|
||||||
<QPage>
|
|
||||||
<RouterView />
|
|
||||||
</QPage>
|
|
||||||
</QPageContainer>
|
|
||||||
</template>
|
|
|
@ -9,6 +9,10 @@ const $props = defineProps({
|
||||||
type: Number, //Progress value (1.0 > x > 0.0)
|
type: Number, //Progress value (1.0 > x > 0.0)
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
showDialog: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
cancelled: {
|
cancelled: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
|
@ -20,22 +24,30 @@ const emit = defineEmits(['cancel', 'close']);
|
||||||
|
|
||||||
const dialogRef = ref(null);
|
const dialogRef = ref(null);
|
||||||
|
|
||||||
const showDialog = defineModel('showDialog', {
|
const _showDialog = computed({
|
||||||
type: Boolean,
|
get: () => $props.showDialog,
|
||||||
default: false,
|
set: (value) => {
|
||||||
|
if (value) dialogRef.value.show();
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const _progress = computed(() => $props.progress);
|
const _progress = computed(() => $props.progress);
|
||||||
|
|
||||||
const progressLabel = computed(() => `${Math.round($props.progress * 100)}%`);
|
const progressLabel = computed(() => `${Math.round($props.progress * 100)}%`);
|
||||||
|
|
||||||
|
const cancel = () => {
|
||||||
|
dialogRef.value.hide();
|
||||||
|
emit('cancel');
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<QDialog ref="dialogRef" v-model="showDialog" @hide="emit('close')">
|
<QDialog ref="dialogRef" v-model="_showDialog" @hide="onDialogHide">
|
||||||
<QCard class="full-width dialog">
|
<QCard class="full-width dialog">
|
||||||
<QCardSection class="row">
|
<QCardSection class="row">
|
||||||
<span class="text-h6">{{ t('Progress') }}</span>
|
<span class="text-h6">{{ t('Progress') }}</span>
|
||||||
<QSpace />
|
<QSpace />
|
||||||
<QBtn icon="close" flat round dense v-close-popup />
|
<QBtn icon="close" flat round dense @click="emit('close')" />
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<QCardSection>
|
<QCardSection>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
|
@ -68,7 +80,7 @@ const progressLabel = computed(() => `${Math.round($props.progress * 100)}%`);
|
||||||
type="button"
|
type="button"
|
||||||
flat
|
flat
|
||||||
class="text-primary"
|
class="text-primary"
|
||||||
v-close-popup
|
@click="cancel()"
|
||||||
>
|
>
|
||||||
{{ t('globals.cancel') }}
|
{{ t('globals.cancel') }}
|
||||||
</QBtn>
|
</QBtn>
|
||||||
|
|
|
@ -2,12 +2,5 @@
|
||||||
const model = defineModel({ type: Boolean, required: true });
|
const model = defineModel({ type: Boolean, required: true });
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<QRadio
|
<QRadio v-model="model" v-bind="$attrs" dense :dark="true" class="q-mr-sm" />
|
||||||
v-model="model"
|
|
||||||
v-bind="$attrs"
|
|
||||||
dense
|
|
||||||
:dark="true"
|
|
||||||
class="q-mr-sm"
|
|
||||||
size="xs"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,115 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import RightAdvancedMenu from './RightAdvancedMenu.vue';
|
|
||||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
|
||||||
import VnTableFilter from '../VnTable/VnTableFilter.vue';
|
|
||||||
import { onBeforeMount, onMounted, onUnmounted, computed, ref } from 'vue';
|
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
|
||||||
import { useHasContent } from 'src/composables/useHasContent';
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
section: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
dataKey: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
searchBar: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
prefix: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
rightFilter: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
columns: {
|
|
||||||
type: Array,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
arrayDataProps: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
redirect: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
keepData: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
let arrayData;
|
|
||||||
const sectionValue = computed(() => $props.section ?? $props.dataKey);
|
|
||||||
const isMainSection = ref(false);
|
|
||||||
|
|
||||||
const searchbarId = 'section-searchbar';
|
|
||||||
const advancedMenuSlot = 'advanced-menu';
|
|
||||||
const hasContent = useHasContent(`#${searchbarId}`);
|
|
||||||
|
|
||||||
onBeforeMount(() => {
|
|
||||||
if ($props.dataKey)
|
|
||||||
arrayData = useArrayData($props.dataKey, {
|
|
||||||
searchUrl: 'table',
|
|
||||||
keepData: $props.keepData,
|
|
||||||
...$props.arrayDataProps,
|
|
||||||
navigate: $props.redirect,
|
|
||||||
});
|
|
||||||
checkIsMain();
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
const unsubscribe = router.afterEach(() => {
|
|
||||||
checkIsMain();
|
|
||||||
});
|
|
||||||
onUnmounted(unsubscribe);
|
|
||||||
});
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
|
||||||
if (arrayData) arrayData.destroy();
|
|
||||||
});
|
|
||||||
|
|
||||||
function checkIsMain() {
|
|
||||||
isMainSection.value = sectionValue.value == route.name;
|
|
||||||
if (!isMainSection.value && arrayData) {
|
|
||||||
arrayData.reset(['userParams', 'filter']);
|
|
||||||
arrayData.setCurrentFilter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<slot name="searchbar">
|
|
||||||
<VnSearchbar
|
|
||||||
v-if="searchBar && !hasContent"
|
|
||||||
v-bind="arrayDataProps"
|
|
||||||
:data-key="dataKey"
|
|
||||||
:label="$t(`${prefix}.search`)"
|
|
||||||
:info="$t(`${prefix}.searchInfo`)"
|
|
||||||
/>
|
|
||||||
<div :id="searchbarId"></div>
|
|
||||||
</slot>
|
|
||||||
<RightAdvancedMenu :is-main-section="isMainSection">
|
|
||||||
<template #advanced-menu v-if="$slots[advancedMenuSlot] || rightFilter">
|
|
||||||
<slot :name="advancedMenuSlot">
|
|
||||||
<VnTableFilter
|
|
||||||
v-if="rightFilter && columns"
|
|
||||||
:data-key="dataKey"
|
|
||||||
:array-data="arrayData"
|
|
||||||
:columns="columns"
|
|
||||||
/>
|
|
||||||
</slot>
|
|
||||||
</template>
|
|
||||||
</RightAdvancedMenu>
|
|
||||||
<slot name="body" v-if="isMainSection" />
|
|
||||||
<RouterView v-else />
|
|
||||||
</template>
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
<script setup>
|
||||||
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
|
import LeftMenu from 'components/LeftMenu.vue';
|
||||||
|
import { onMounted } from 'vue';
|
||||||
|
|
||||||
|
const stateStore = useStateStore();
|
||||||
|
const $props = defineProps({
|
||||||
|
leftDrawer: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
onMounted(() => (stateStore.leftDrawer = $props.leftDrawer));
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<QDrawer v-model="stateStore.leftDrawer" show-if-above :width="256">
|
||||||
|
<QScrollArea class="fit text-grey-8">
|
||||||
|
<LeftMenu />
|
||||||
|
</QScrollArea>
|
||||||
|
</QDrawer>
|
||||||
|
<QPageContainer>
|
||||||
|
<RouterView></RouterView>
|
||||||
|
</QPageContainer>
|
||||||
|
</template>
|
|
@ -1,21 +1,8 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, toRefs, computed, watch, onMounted, useAttrs } from 'vue';
|
import { ref, toRefs, computed, watch, onMounted } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import FetchData from 'src/components/FetchData.vue';
|
||||||
import { useRequired } from 'src/composables/useRequired';
|
|
||||||
import dataByOrder from 'src/utils/dataByOrder';
|
|
||||||
import { QItemLabel } from 'quasar';
|
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'update:options', 'remove']);
|
const emit = defineEmits(['update:modelValue', 'update:options', 'remove']);
|
||||||
const $attrs = useAttrs();
|
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
const isRequired = computed(() => {
|
|
||||||
return useRequired($attrs).isRequired;
|
|
||||||
});
|
|
||||||
const requiredFieldRule = computed(() => {
|
|
||||||
return useRequired($attrs).requiredFieldRule;
|
|
||||||
});
|
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
|
@ -27,17 +14,13 @@ const $props = defineProps({
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
optionLabel: {
|
optionLabel: {
|
||||||
type: [String, Function],
|
type: [String],
|
||||||
default: 'name',
|
default: 'name',
|
||||||
},
|
},
|
||||||
optionValue: {
|
optionValue: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'id',
|
default: 'id',
|
||||||
},
|
},
|
||||||
optionCaption: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
optionFilter: {
|
optionFilter: {
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
|
@ -54,10 +37,6 @@ const $props = defineProps({
|
||||||
type: [Array],
|
type: [Array],
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
exprBuilder: {
|
|
||||||
type: Function,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
isClearable: {
|
isClearable: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
|
@ -94,54 +73,19 @@ const $props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
params: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
noOne: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
dataKey: {
|
|
||||||
type: String,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
isOutlined: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const mixinRules = [requiredFieldRule, ...($attrs.rules ?? [])];
|
const { t } = useI18n();
|
||||||
const {
|
const requiredFieldRule = (val) => val ?? t('globals.fieldRequired');
|
||||||
optionLabel,
|
|
||||||
optionValue,
|
const { optionLabel, optionValue, optionFilter, optionFilterValue, options, modelValue } =
|
||||||
optionCaption,
|
toRefs($props);
|
||||||
optionFilter,
|
|
||||||
optionFilterValue,
|
|
||||||
options,
|
|
||||||
modelValue,
|
|
||||||
} = toRefs($props);
|
|
||||||
const myOptions = ref([]);
|
const myOptions = ref([]);
|
||||||
const myOptionsOriginal = ref([]);
|
const myOptionsOriginal = ref([]);
|
||||||
const vnSelectRef = ref();
|
const vnSelectRef = ref();
|
||||||
|
const dataRef = ref();
|
||||||
const lastVal = ref();
|
const lastVal = ref();
|
||||||
const noOneText = t('globals.noOne');
|
|
||||||
const noOneOpt = ref({
|
|
||||||
[optionValue.value]: false,
|
|
||||||
[optionLabel.value]: noOneText,
|
|
||||||
});
|
|
||||||
const styleAttrs = computed(() => {
|
|
||||||
return $props.isOutlined
|
|
||||||
? {
|
|
||||||
dense: true,
|
|
||||||
outlined: true,
|
|
||||||
rounded: true,
|
|
||||||
}
|
|
||||||
: {};
|
|
||||||
});
|
|
||||||
const isLoading = ref(false);
|
|
||||||
const useURL = computed(() => $props.url);
|
|
||||||
const value = computed({
|
const value = computed({
|
||||||
get() {
|
get() {
|
||||||
return $props.modelValue;
|
return $props.modelValue;
|
||||||
|
@ -156,39 +100,26 @@ watch(options, (newValue) => {
|
||||||
setOptions(newValue);
|
setOptions(newValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(modelValue, async (newValue) => {
|
watch(modelValue, (newValue) => {
|
||||||
if (!myOptions?.value?.some((option) => option[optionValue.value] == newValue))
|
if (!myOptions.value.some((option) => option[optionValue.value] == newValue))
|
||||||
await fetchFilter(newValue);
|
fetchFilter(newValue);
|
||||||
|
|
||||||
if ($props.noOne) myOptions.value.unshift(noOneOpt.value);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
setOptions(options.value);
|
setOptions(options.value);
|
||||||
if (useURL.value && $props.modelValue && !findKeyInOptions())
|
if ($props.url && $props.modelValue && !findKeyInOptions())
|
||||||
fetchFilter($props.modelValue);
|
fetchFilter($props.modelValue);
|
||||||
if ($props.focusOnMount) setTimeout(() => vnSelectRef.value.showPopup(), 300);
|
if ($props.focusOnMount) setTimeout(() => vnSelectRef.value.showPopup(), 300);
|
||||||
});
|
});
|
||||||
|
|
||||||
const arrayDataKey =
|
|
||||||
$props.dataKey ?? ($props.url?.length > 0 ? $props.url : $attrs.name ?? $attrs.label);
|
|
||||||
|
|
||||||
const arrayData = useArrayData(arrayDataKey, {
|
|
||||||
url: $props.url,
|
|
||||||
searchUrl: false,
|
|
||||||
mapKey: $attrs['map-key'],
|
|
||||||
});
|
|
||||||
|
|
||||||
function findKeyInOptions() {
|
function findKeyInOptions() {
|
||||||
if (!$props.options) return;
|
if (!$props.options) return;
|
||||||
return filter($props.modelValue, $props.options)?.length;
|
return filter($props.modelValue, $props.options)?.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setOptions(data) {
|
function setOptions(data) {
|
||||||
data = dataByOrder(data, $props.sortBy);
|
|
||||||
myOptions.value = JSON.parse(JSON.stringify(data));
|
myOptions.value = JSON.parse(JSON.stringify(data));
|
||||||
myOptionsOriginal.value = JSON.parse(JSON.stringify(data));
|
myOptionsOriginal.value = JSON.parse(JSON.stringify(data));
|
||||||
emit('update:options', data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function filter(val, options) {
|
function filter(val, options) {
|
||||||
|
@ -205,15 +136,15 @@ function filter(val, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!row) return;
|
if (!row) return;
|
||||||
const id = String(row[$props.optionValue]);
|
const id = row[$props.optionValue];
|
||||||
const optionLabel = String(row[$props.optionLabel]).toLowerCase();
|
const optionLabel = String(row[$props.optionLabel]).toLowerCase();
|
||||||
|
|
||||||
return id.includes(search) || optionLabel.includes(search);
|
return id == search || optionLabel.includes(search);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchFilter(val) {
|
async function fetchFilter(val) {
|
||||||
if (!$props.url) return;
|
if (!$props.url || !dataRef.value) return;
|
||||||
|
|
||||||
const { fields, include, sortBy, limit } = $props;
|
const { fields, include, sortBy, limit } = $props;
|
||||||
const key =
|
const key =
|
||||||
|
@ -222,27 +153,14 @@ async function fetchFilter(val) {
|
||||||
? optionValue.value
|
? optionValue.value
|
||||||
: optionFilter.value ?? optionLabel.value);
|
: optionFilter.value ?? optionLabel.value);
|
||||||
|
|
||||||
let defaultWhere = {};
|
const defaultWhere = $props.useLike
|
||||||
if ($props.filterOptions.length) {
|
? { [key]: { like: `%${val}%` } }
|
||||||
defaultWhere = $props.filterOptions.reduce((obj, prop) => {
|
: { [key]: val };
|
||||||
if (!obj.or) obj.or = [];
|
|
||||||
obj.or.push({ [prop]: getVal(val) });
|
|
||||||
return obj;
|
|
||||||
}, {});
|
|
||||||
} else defaultWhere = { [key]: getVal(val) };
|
|
||||||
const where = { ...(val ? defaultWhere : {}), ...$props.where };
|
const where = { ...(val ? defaultWhere : {}), ...$props.where };
|
||||||
$props.exprBuilder && Object.assign(where, $props.exprBuilder(key, val));
|
const fetchOptions = { where, include, limit };
|
||||||
const filterOptions = { where, include, limit };
|
if (fields) fetchOptions.fields = fields;
|
||||||
if (fields) filterOptions.fields = fields;
|
if (sortBy) fetchOptions.order = sortBy;
|
||||||
if (sortBy) filterOptions.order = sortBy;
|
return dataRef.value.fetch(fetchOptions);
|
||||||
arrayData.resetPagination();
|
|
||||||
|
|
||||||
const { data } = await arrayData.applyFilter(
|
|
||||||
{ filter: filterOptions },
|
|
||||||
{ updateRouter: false }
|
|
||||||
);
|
|
||||||
setOptions(data);
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function filterHandler(val, update) {
|
async function filterHandler(val, update) {
|
||||||
|
@ -262,9 +180,6 @@ async function filterHandler(val, update) {
|
||||||
} else newOptions = filter(val, myOptionsOriginal.value);
|
} else newOptions = filter(val, myOptionsOriginal.value);
|
||||||
update(
|
update(
|
||||||
() => {
|
() => {
|
||||||
if ($props.noOne && noOneText.toLowerCase().includes(val.toLowerCase()))
|
|
||||||
newOptions.unshift(noOneOpt.value);
|
|
||||||
|
|
||||||
myOptions.value = newOptions;
|
myOptions.value = newOptions;
|
||||||
},
|
},
|
||||||
(ref) => {
|
(ref) => {
|
||||||
|
@ -279,72 +194,24 @@ async function filterHandler(val, update) {
|
||||||
function nullishToTrue(value) {
|
function nullishToTrue(value) {
|
||||||
return value ?? true;
|
return value ?? true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getVal = (val) => ($props.useLike ? { like: `%${val}%` } : val);
|
|
||||||
|
|
||||||
async function onScroll({ to, direction, from, index }) {
|
|
||||||
const lastIndex = myOptions.value.length - 1;
|
|
||||||
|
|
||||||
if (from === 0 && index === 0) return;
|
|
||||||
if (!useURL.value && !$props.fetchRef) return;
|
|
||||||
if (direction === 'decrease') return;
|
|
||||||
if (to === lastIndex && arrayData.store.hasMoreData && !isLoading.value) {
|
|
||||||
isLoading.value = true;
|
|
||||||
await arrayData.loadMore();
|
|
||||||
setOptions(arrayData.store.data);
|
|
||||||
vnSelectRef.value.scrollTo(lastIndex);
|
|
||||||
isLoading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({ opts: myOptions, vnSelectRef });
|
|
||||||
|
|
||||||
function handleKeyDown(event) {
|
|
||||||
if (event.key === 'Tab' && !event.shiftKey) {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
const inputValue = vnSelectRef.value?.inputValue;
|
|
||||||
|
|
||||||
if (inputValue) {
|
|
||||||
const matchingOption = myOptions.value.find(
|
|
||||||
(option) =>
|
|
||||||
option[optionLabel.value].toLowerCase() === inputValue.toLowerCase()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matchingOption) {
|
|
||||||
emit('update:modelValue', matchingOption[optionValue.value]);
|
|
||||||
} else {
|
|
||||||
emit('update:modelValue', inputValue);
|
|
||||||
}
|
|
||||||
vnSelectRef.value?.hidePopup();
|
|
||||||
}
|
|
||||||
|
|
||||||
const focusableElements = document.querySelectorAll(
|
|
||||||
'a:not([disabled]), button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), details:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled])'
|
|
||||||
);
|
|
||||||
const currentIndex = Array.prototype.indexOf.call(
|
|
||||||
focusableElements,
|
|
||||||
event.target
|
|
||||||
);
|
|
||||||
if (currentIndex >= 0 && currentIndex < focusableElements.length - 1) {
|
|
||||||
focusableElements[currentIndex + 1].focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCaption(opt) {
|
|
||||||
if (optionCaption.value === false) return;
|
|
||||||
return opt[optionCaption.value] || opt[optionValue.value];
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<FetchData
|
||||||
|
ref="dataRef"
|
||||||
|
:url="$props.url"
|
||||||
|
@on-fetch="(data) => setOptions(data)"
|
||||||
|
:where="where || { [optionValue]: value }"
|
||||||
|
:limit="limit"
|
||||||
|
:sort-by="sortBy"
|
||||||
|
:fields="fields"
|
||||||
|
/>
|
||||||
<QSelect
|
<QSelect
|
||||||
v-model="value"
|
v-model="value"
|
||||||
:options="myOptions"
|
:options="myOptions"
|
||||||
:option-label="optionLabel"
|
:option-label="optionLabel"
|
||||||
:option-value="optionValue"
|
:option-value="optionValue"
|
||||||
v-bind="{ ...$attrs, ...styleAttrs }"
|
v-bind="$attrs"
|
||||||
@filter="filterHandler"
|
@filter="filterHandler"
|
||||||
:emit-value="nullishToTrue($attrs['emit-value'])"
|
:emit-value="nullishToTrue($attrs['emit-value'])"
|
||||||
:map-options="nullishToTrue($attrs['map-options'])"
|
:map-options="nullishToTrue($attrs['map-options'])"
|
||||||
|
@ -353,22 +220,15 @@ function getCaption(opt) {
|
||||||
:fill-input="nullishToTrue($attrs['fill-input'])"
|
:fill-input="nullishToTrue($attrs['fill-input'])"
|
||||||
ref="vnSelectRef"
|
ref="vnSelectRef"
|
||||||
lazy-rules
|
lazy-rules
|
||||||
:class="{ required: isRequired }"
|
:class="{ required: $attrs.required }"
|
||||||
:rules="mixinRules"
|
:rules="$attrs.required ? [requiredFieldRule] : null"
|
||||||
virtual-scroll-slice-size="options.length"
|
virtual-scroll-slice-size="options.length"
|
||||||
hide-bottom-space
|
|
||||||
:input-debounce="useURL ? '300' : '0'"
|
|
||||||
:loading="isLoading"
|
|
||||||
@virtual-scroll="onScroll"
|
|
||||||
@keydown="handleKeyDown"
|
|
||||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_select'"
|
|
||||||
:data-url="url"
|
|
||||||
>
|
>
|
||||||
<template #append>
|
<template v-if="isClearable" #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
v-show="isClearable && value"
|
v-show="value"
|
||||||
name="close"
|
name="close"
|
||||||
@click="
|
@click.stop="
|
||||||
() => {
|
() => {
|
||||||
value = null;
|
value = null;
|
||||||
emit('remove');
|
emit('remove');
|
||||||
|
@ -379,38 +239,7 @@ function getCaption(opt) {
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
|
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
|
||||||
<div v-if="slotName == 'append'">
|
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
||||||
<QIcon
|
|
||||||
v-show="isClearable && value"
|
|
||||||
name="close"
|
|
||||||
@click.stop="
|
|
||||||
() => {
|
|
||||||
value = null;
|
|
||||||
emit('remove');
|
|
||||||
}
|
|
||||||
"
|
|
||||||
class="cursor-pointer"
|
|
||||||
size="xs"
|
|
||||||
/>
|
|
||||||
<slot name="append" v-if="$slots.append" v-bind="slotData ?? {}" />
|
|
||||||
</div>
|
|
||||||
<slot v-else :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
|
||||||
</template>
|
|
||||||
<template #option="{ opt, itemProps }">
|
|
||||||
<QItem v-bind="itemProps">
|
|
||||||
<QItemSection v-if="typeof opt !== 'object'"> {{ opt }}</QItemSection>
|
|
||||||
<QItemSection v-else-if="opt[optionValue] == opt[optionLabel]">
|
|
||||||
<QItemLabel>{{ opt[optionLabel] }}</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
<QItemSection v-else>
|
|
||||||
<QItemLabel>
|
|
||||||
{{ opt[optionLabel] }}
|
|
||||||
</QItemLabel>
|
|
||||||
<QItemLabel caption v-if="getCaption(opt)">
|
|
||||||
{{ `#${getCaption(opt)}` }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
</template>
|
||||||
</QSelect>
|
</QSelect>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,22 +1,16 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import { useRole } from 'src/composables/useRole';
|
import { useRole } from 'src/composables/useRole';
|
||||||
import { useAcl } from 'src/composables/useAcl';
|
|
||||||
|
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
const emit = defineEmits(['update:modelValue']);
|
const emit = defineEmits(['update:modelValue']);
|
||||||
|
|
||||||
const value = defineModel({ type: [String, Number, Object] });
|
const value = defineModel({ type: [String, Number, Object] });
|
||||||
const select = ref(null);
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
rolesAllowedToCreate: {
|
rolesAllowedToCreate: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => ['developer'],
|
default: () => ['developer'],
|
||||||
},
|
},
|
||||||
acls: {
|
|
||||||
type: Array,
|
|
||||||
default: () => [],
|
|
||||||
},
|
|
||||||
actionIcon: {
|
actionIcon: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'add',
|
default: 'add',
|
||||||
|
@ -28,27 +22,26 @@ const $props = defineProps({
|
||||||
});
|
});
|
||||||
|
|
||||||
const role = useRole();
|
const role = useRole();
|
||||||
const acl = useAcl();
|
const showForm = ref(false);
|
||||||
|
|
||||||
const isAllowedToCreate = computed(() => {
|
const isAllowedToCreate = computed(() => {
|
||||||
if ($props.acls.length) return acl.hasAny($props.acls);
|
|
||||||
return role.hasAny($props.rolesAllowedToCreate);
|
return role.hasAny($props.rolesAllowedToCreate);
|
||||||
});
|
});
|
||||||
|
|
||||||
defineExpose({ vnSelectDialogRef: select });
|
const toggleForm = () => {
|
||||||
|
showForm.value = !showForm.value;
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
ref="select"
|
|
||||||
v-model="value"
|
v-model="value"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
@update:model-value="(...args) => emit('update:modelValue', ...args)"
|
@update:model-value="(...args) => emit('update:modelValue', ...args)"
|
||||||
>
|
>
|
||||||
<template v-if="isAllowedToCreate" #append>
|
<template v-if="isAllowedToCreate" #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_icon'"
|
@click.stop.prevent="toggleForm()"
|
||||||
@click.stop.prevent="$refs.dialog.show()"
|
|
||||||
:name="actionIcon"
|
:name="actionIcon"
|
||||||
:size="actionIcon === 'add' ? 'xs' : 'sm'"
|
:size="actionIcon === 'add' ? 'xs' : 'sm'"
|
||||||
:class="['default-icon', { '--add-icon': actionIcon === 'add' }]"
|
:class="['default-icon', { '--add-icon': actionIcon === 'add' }]"
|
||||||
|
@ -58,7 +51,7 @@ defineExpose({ vnSelectDialogRef: select });
|
||||||
>
|
>
|
||||||
<QTooltip v-if="tooltip">{{ tooltip }}</QTooltip>
|
<QTooltip v-if="tooltip">{{ tooltip }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QDialog ref="dialog" transition-show="scale" transition-hide="scale">
|
<QDialog v-model="showForm" transition-show="scale" transition-hide="scale">
|
||||||
<slot name="form" />
|
<slot name="form" />
|
||||||
</QDialog>
|
</QDialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { onBeforeMount, ref, useAttrs } from 'vue';
|
|
||||||
import axios from 'axios';
|
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
|
||||||
|
|
||||||
const { schema, table, column, translation, defaultOptions } = defineProps({
|
|
||||||
schema: {
|
|
||||||
type: String,
|
|
||||||
default: 'vn',
|
|
||||||
},
|
|
||||||
table: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
column: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
translation: {
|
|
||||||
type: Function,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
defaultOptions: {
|
|
||||||
type: Array,
|
|
||||||
default: () => [],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const $attrs = useAttrs();
|
|
||||||
const options = ref([]);
|
|
||||||
onBeforeMount(async () => {
|
|
||||||
options.value = [].concat(defaultOptions);
|
|
||||||
const { data } = await axios.get(`Applications/get-enum-values`, {
|
|
||||||
params: { schema, table, column },
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const value of data)
|
|
||||||
options.value.push({
|
|
||||||
[$attrs['option-value'] ?? 'id']: value,
|
|
||||||
[$attrs['option-label'] ?? 'name']: translation ? translation(value) : value,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<VnSelect
|
|
||||||
v-bind="$attrs"
|
|
||||||
:options="options"
|
|
||||||
:key="options.length"
|
|
||||||
:input-debounce="0"
|
|
||||||
/>
|
|
||||||
</template>
|
|
|
@ -1,35 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { computed } from 'vue';
|
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
|
||||||
|
|
||||||
const model = defineModel({ type: [String, Number, Object] });
|
|
||||||
const url = 'Suppliers';
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<VnSelect
|
|
||||||
:label="$t('globals.supplier')"
|
|
||||||
v-bind="$attrs"
|
|
||||||
v-model="model"
|
|
||||||
:url="url"
|
|
||||||
option-value="id"
|
|
||||||
option-label="nickname"
|
|
||||||
:fields="['id', 'name', 'nickname', 'nif']"
|
|
||||||
sort-by="name ASC"
|
|
||||||
>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem v-bind="scope.itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>
|
|
||||||
{{ scope.opt?.name }}
|
|
||||||
</QItemLabel>
|
|
||||||
<QItemLabel caption>
|
|
||||||
{{
|
|
||||||
`#${scope.opt?.id} , ${scope.opt?.nickname} (${scope.opt?.nif})`
|
|
||||||
}}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
</template>
|
|
|
@ -1,88 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { computed, useAttrs } from 'vue';
|
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
|
||||||
import VnAvatar from 'src/components/ui/VnAvatar.vue';
|
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue']);
|
|
||||||
const $props = defineProps({
|
|
||||||
hasAvatar: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
info: {
|
|
||||||
type: String,
|
|
||||||
default: undefined,
|
|
||||||
},
|
|
||||||
modelValue: {
|
|
||||||
type: [String, Number, Object],
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const $attrs = useAttrs();
|
|
||||||
|
|
||||||
const value = computed({
|
|
||||||
get() {
|
|
||||||
return $props.modelValue;
|
|
||||||
},
|
|
||||||
set(val) {
|
|
||||||
emit('update:modelValue', val);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const url = computed(() => {
|
|
||||||
let url = 'Workers/search';
|
|
||||||
const { departmentCodes } = $attrs.params ?? {};
|
|
||||||
if (!departmentCodes) return url;
|
|
||||||
const params = new URLSearchParams({
|
|
||||||
departmentCodes: JSON.stringify(departmentCodes),
|
|
||||||
});
|
|
||||||
|
|
||||||
return url.concat(`?${params.toString()}`);
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<VnSelect
|
|
||||||
:label="$t('globals.worker')"
|
|
||||||
v-bind="$attrs"
|
|
||||||
v-model="value"
|
|
||||||
:url="url"
|
|
||||||
option-value="id"
|
|
||||||
option-label="nickname"
|
|
||||||
:fields="['id', 'name', 'nickname', 'code']"
|
|
||||||
:filter-options="['id', 'name', 'nickname', 'code']"
|
|
||||||
sort-by="nickname ASC"
|
|
||||||
data-cy="vnWorkerSelect"
|
|
||||||
>
|
|
||||||
<template #prepend v-if="$props.hasAvatar">
|
|
||||||
<VnAvatar :worker-id="value" color="primary" v-bind="$attrs" />
|
|
||||||
</template>
|
|
||||||
<template #append v-if="$props.info">
|
|
||||||
<QIcon name="info" class="cursor-pointer">
|
|
||||||
<QTooltip>{{ $t($props.info) }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</template>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem v-bind="scope.itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>
|
|
||||||
{{ scope.opt.name }}
|
|
||||||
</QItemLabel>
|
|
||||||
<QItemLabel v-if="!scope.opt.id">
|
|
||||||
{{ scope.opt.nickname }}
|
|
||||||
</QItemLabel>
|
|
||||||
<QItemLabel caption v-else>
|
|
||||||
#{{ scope.opt.id }}, {{ scope.opt.nickname }},
|
|
||||||
{{ scope.opt.code }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
Responsible for approving invoices: Responsable de aprobar las facturas
|
|
||||||
</i18n>
|
|
|
@ -86,7 +86,7 @@ async function send() {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<QDialog ref="dialogRef" data-cy="vnSmsDialog">
|
<QDialog ref="dialogRef">
|
||||||
<QCard class="q-pa-sm">
|
<QCard class="q-pa-sm">
|
||||||
<QCardSection class="row items-center q-pb-none">
|
<QCardSection class="row items-center q-pb-none">
|
||||||
<span class="text-h6 text-grey">
|
<span class="text-h6 text-grey">
|
||||||
|
@ -161,7 +161,6 @@ async function send() {
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
color="primary"
|
color="primary"
|
||||||
unelevated
|
unelevated
|
||||||
data-cy="sendSmsBtn"
|
|
||||||
/>
|
/>
|
||||||
</QCardActions>
|
</QCardActions>
|
||||||
</QCard>
|
</QCard>
|
||||||
|
|
|
@ -10,10 +10,6 @@ defineProps({
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: 'md-width',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
defineEmits([...useDialogPluginComponent.emits]);
|
defineEmits([...useDialogPluginComponent.emits]);
|
||||||
|
@ -21,19 +17,7 @@ defineEmits([...useDialogPluginComponent.emits]);
|
||||||
const { dialogRef, onDialogHide } = useDialogPluginComponent();
|
const { dialogRef, onDialogHide } = useDialogPluginComponent();
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<QDialog ref="dialogRef" @hide="onDialogHide">
|
<QDialog ref="dialogRef" @hide="onDialogHide" full-width>
|
||||||
<component :is="summary" :id="id" :class="width" />
|
<component :is="summary" :id="id" />
|
||||||
</QDialog>
|
</QDialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.md-width {
|
|
||||||
max-width: $width-md;
|
|
||||||
}
|
|
||||||
.lg-width {
|
|
||||||
max-width: $width-lg;
|
|
||||||
}
|
|
||||||
.xlg-width {
|
|
||||||
max-width: $width-xl;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
<script setup>
|
|
||||||
const model = defineModel({ type: [String, Number], required: true });
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<QTime v-model="model" now-btn mask="HH:mm" />
|
|
||||||
</template>
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.q-time {
|
|
||||||
width: 230px;
|
|
||||||
min-width: unset;
|
|
||||||
:deep(.q-time__header) {
|
|
||||||
min-height: unset;
|
|
||||||
height: 50px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue